Merge branch 'master' into loops

Conflicts:
	core/lib/Thelia/Core/Template/Loop/Category.php
	core/lib/Thelia/Core/Template/Loop/FeatureValue.php
	core/lib/Thelia/Core/Template/Loop/Folder.php
	core/lib/Thelia/Core/Template/Loop/Product.php
	core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php
	install/faker.php
This commit is contained in:
Etienne Roudeix
2013-08-21 09:19:56 +02:00
3275 changed files with 929970 additions and 274940 deletions

5
install/INSTALL-TODO.txt Normal file → Executable file
View File

@@ -19,3 +19,8 @@ Variables Config à initialiser:
- password.length : longueur du mot de passe, défaut 4
- form.secret : token csrf
- verifyStock : vérification du stock lors du paiement/ajout au panier. Defaut 1
- default_images_quality_percent : qualité par défaut des images générées (0 à 100, défaut: 75).
- original_image_delivery_mode : mode de mise à disposition des images originales (full resolution) dans le cache. 'symlink' pour un lien symbolique, 'copy' pour une copie
- images_library_path : chemin vers le répertoire où sont stockés les images source (defaut: local/media/images)
- image_cache_dir_from_web_root : le repértoire de base où sont cachées les images, relatif à /web (cache/images)
- imagine_graphic_driver : le drivers utilisé par Imagine (gd, imagik, gmagick), defaut: 'gd'

BIN
install/faker-assets/FreeSans.ttf Executable file

Binary file not shown.

View File

@@ -1,4 +1,11 @@
<?php
use Thelia\Model\ProductImage;
use Thelia\Model\CategoryImage;
use Thelia\Model\FolderImage;
use Thelia\Model\ContentImage;
use Imagine\Image\Color;
use Imagine\Image\Point;
require __DIR__ . '/../core/bootstrap.php';
$thelia = new Thelia\Core\Thelia("dev", true);
@@ -11,7 +18,9 @@ $con->beginTransaction();
$currency = \Thelia\Model\CurrencyQuery::create()->filterByCode('EUR')->findOne();
try {
$stmt = $con->prepare("SET foreign_key_checks = 0");
$stmt->execute();
$attributeCategory = Thelia\Model\AttributeCategoryQuery::create()
->find();
$attributeCategory->delete();
@@ -94,6 +103,9 @@ try {
->find();
$productPrice->delete();
$stmt = $con->prepare("SET foreign_key_checks = 1");
$stmt->execute();
//features and features_av
$featureList = array();
for($i=0; $i<4; $i++) {
@@ -264,6 +276,10 @@ try {
$folder->save();
$image = new FolderImage();
$image->setFolderId($folder->getId());
generate_image($image, 1, 'folder', $folder->getId());
for($j=1; $j<rand(0, 5); $j++) {
$subfolder = new Thelia\Model\Folder();
$subfolder->setParent($folder->getId());
@@ -274,6 +290,10 @@ try {
$subfolder->save();
$image = new FolderImage();
$image->setFolderId($subfolder->getId());
generate_image($image, 1, 'folder', $subfolder->getId());
for($k=0; $k<rand(0, 5); $k++) {
$content = new Thelia\Model\Content();
$content->addFolder($subfolder);
@@ -283,6 +303,10 @@ try {
$content->setDescription($faker->text(255));
$content->save();
$image = new ContentImage();
$image->setContentId($content->getId());
generate_image($image, 1, 'content', $content->getId());
}
}
}
@@ -307,6 +331,10 @@ function createProduct($faker, $category, $position, &$productIdList)
$productId = $product->getId();
$productIdList[] = $productId;
$image = new ProductImage();
$image->setProductId($productId);
generate_image($image, 1, 'product', $productId);
return $product;
}
@@ -320,8 +348,62 @@ function createCategory($faker, $parent, $position, &$categoryIdList)
$category->setDescription($faker->text(255));
$category->save();
$categoryIdList[] = $category->getId();
$cateogoryId = $category->getId();
$categoryIdList[] = $cateogoryId;
$image = new CategoryImage();
$image->setCategoryId($cateogoryId);
generate_image($image, 1, 'category', $cateogoryId);
return $category;
}
function generate_image($image, $position, $typeobj, $id) {
global $faker;
$image
->setTitle($faker->text(20))
->setDescription($faker->text(250))
->setChapo($faker->text(40))
->setPostscriptum($faker->text(40))
->setPosition($position)
->setFile(sprintf("sample-image-%s.png", $id))
->save()
;
// Generate images
$imagine = new Imagine\Gd\Imagine();
$image = $imagine->create(new Imagine\Image\Box(320,240), new Color('#E9730F'));
$white = new Color('#FFF');
$font = $imagine->font(__DIR__.'/faker-assets/FreeSans.ttf', 14, $white);
$tbox = $font->box("THELIA");
$image->draw()->text("THELIA", $font, new Point((320 - $tbox->getWidth()) / 2, 30));
$str = sprintf("%s sample image", ucfirst($typeobj));
$tbox = $font->box($str);
$image->draw()->text($str, $font, new Point((320 - $tbox->getWidth()) / 2, 80));
$font = $imagine->font(__DIR__.'/faker-assets/FreeSans.ttf', 18, $white);
$str = sprintf("%s ID %d", strtoupper($typeobj), $id);
$tbox = $font->box($str);
$image->draw()->text($str, $font, new Point((320 - $tbox->getWidth()) / 2, 180));
$image->draw()
->line(new Point(0, 0), new Point(319, 0), $white)
->line(new Point(319, 0), new Point(319, 239), $white)
->line(new Point(319, 239), new Point(0,239), $white)
->line(new Point(0, 239), new Point(0, 0), $white)
;
$image_file = sprintf("%s/../local/media/images/%s/sample-image-%s.png", __DIR__, $typeobj, $id);
if (! is_dir(dirname($image_file))) mkdir(dirname($image_file), 0777, true);
$image->save($image_file);
}

View File

@@ -6,7 +6,14 @@ INSERT INTO `lang`(`id`,`title`,`code`,`locale`,`url`,`by_default`,`created_at`,
INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updated_at`) VALUES
('session_config.default', '1', 1, 1, NOW(), NOW()),
('verifyStock', '1', 1, 0, NOW(), NOW());
('verifyStock', '1', 1, 0, NOW(), NOW()),
('imagine_graphic_driver', 'gd', 1, 0, NOW(), NOW()),
('default_images_quality_percent', '75', 1, 0, NOW(), NOW()),
('original_image_delivery_mode', 'symlink', 1, 0, NOW(), NOW()),
('images_library_path', 'local/media/images', 1, 0, NOW(), NOW()),
('image_cache_dir_from_web_root', 'cache/images', 1, 0, NOW(), NOW());
INSERT INTO `module` (`code`, `type`, `activate`, `position`, `created_at`, `updated_at`) VALUES ('test', '1', '1', '1', NOW(), NOW());
@@ -23,11 +30,11 @@ INSERT INTO `customer_title_i18n` (`id`, `locale`, `short`, `long`) VALUES
(3, 'en_US', 'Miss', 'Miss'),
(3, 'fr_FR', 'Mlle', 'Madamemoiselle');
INSERT INTO `currency` (`id` ,`code` ,`symbol` ,`rate` ,`by_default` ,`created_at` ,`updated_at`)
INSERT INTO `currency` (`id` ,`code` ,`symbol` ,`rate`, `position` ,`by_default` ,`created_at` ,`updated_at`)
VALUES
(1, 'EUR', '', '1', '1', NOW() , NOW()),
(2, 'USD', '$', '1.26', '0', NOW(), NOW()),
(3, 'GBP', '£', '0.89', '0', NOW(), NOW());
(1, 'EUR', '', '1', 1, '1', NOW() , NOW()),
(2, 'USD', '$', '1.26', 2, '0', NOW(), NOW()),
(3, 'GBP', '£', '0.89', 3, '0', NOW(), NOW());
INSERT INTO `currency_i18n` (`id` ,`locale` ,`name`)
VALUES

View File

@@ -521,6 +521,7 @@ CREATE TABLE `lang`
`code` VARCHAR(10),
`locale` VARCHAR(45),
`url` VARCHAR(255),
`position` INTEGER,
`by_default` TINYINT,
`created_at` DATETIME,
`updated_at` DATETIME,
@@ -603,12 +604,12 @@ CREATE TABLE `content_assoc`
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- produt_image
-- product_image
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `produt_image`;
DROP TABLE IF EXISTS `product_image`;
CREATE TABLE `produt_image`
CREATE TABLE `product_image`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`product_id` INTEGER NOT NULL,
@@ -719,6 +720,7 @@ CREATE TABLE `currency`
`code` VARCHAR(45),
`symbol` VARCHAR(45),
`rate` FLOAT,
`position` INTEGER,
`by_default` TINYINT,
`created_at` DATETIME,
`updated_at` DATETIME,
@@ -1721,12 +1723,12 @@ CREATE TABLE `content_i18n`
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- produt_image_i18n
-- product_image_i18n
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `produt_image_i18n`;
DROP TABLE IF EXISTS `product_image_i18n`;
CREATE TABLE `produt_image_i18n`
CREATE TABLE `product_image_i18n`
(
`id` INTEGER NOT NULL,
`locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL,
@@ -1735,9 +1737,9 @@ CREATE TABLE `produt_image_i18n`
`chapo` TEXT,
`postscriptum` TEXT,
PRIMARY KEY (`id`,`locale`),
CONSTRAINT `produt_image_i18n_FK_1`
CONSTRAINT `product_image_i18n_FK_1`
FOREIGN KEY (`id`)
REFERENCES `produt_image` (`id`)
REFERENCES `product_image` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;