Exemplo n.º 1
0
 public function testSearchById()
 {
     $content = ContentQuery::create()->findOne();
     if (null === $content) {
         $content = new \Thelia\Model\Content();
         $content->setVisible(1);
         $content->setTitle('foo');
         $content->save();
     }
     $otherParameters = array("visible" => "*");
     $this->baseTestSearchById($content->getId(), $otherParameters);
 }
Exemplo n.º 2
0
 /**
  * generates a folder and its contents to be used in Position tests
  *
  * @return Folder the parent folder
  */
 protected function getFolderForPositionTest()
 {
     if (null === self::$folderForPositionTest) {
         $folder = new Folder();
         $folder->setParent(0);
         $folder->setVisible(1);
         $folder->setPosition(1);
         $this->setI18n($folder);
         $folder->save();
         for ($i = 0; $i < 4; $i++) {
             $content = new \Thelia\Model\Content();
             $content->addFolder($folder);
             $content->setVisible(1);
             $content->setPosition($i + 1);
             $this->setI18n($content);
             $contentFolders = $content->getContentFolders();
             $collection = new Collection();
             $collection->prepend($contentFolders[0]->setDefaultFolder(1));
             $content->setContentFolders($collection);
             $content->save();
         }
         self::$folderForPositionTest = $folder;
     }
     return self::$folderForPositionTest;
 }
Exemplo n.º 3
0
 generate_document($document, 'folder', $folder->getId());
 for ($j = 0; $j < 3; $j++) {
     $subfolder = new Thelia\Model\Folder();
     $subfolder->setParent($folder->getId());
     $subfolder->setVisible(1);
     $subfolder->setPosition($j + 1);
     setI18n($subfolder);
     $subfolder->save();
     $image = new \Thelia\Model\FolderImage();
     $image->setFolderId($subfolder->getId());
     generate_image($image, 'folder', $subfolder->getId());
     $document = new \Thelia\Model\FolderDocument();
     $document->setFolderId($folder->getId());
     generate_document($document, 'folder', $subfolder->getId());
     for ($k = 0; $k < 4; $k++) {
         $content = new Thelia\Model\Content();
         $content->addFolder($subfolder);
         $contentFolders = $content->getContentFolders();
         $collection = new \Propel\Runtime\Collection\Collection();
         $collection->prepend($contentFolders[0]->setDefaultFolder(1));
         $content->setContentFolders($collection);
         $content->setVisible(1);
         $content->setPosition($k + 1);
         setI18n($content);
         $content->save();
         $contentId = $content->getId();
         $contentIdList[] = $contentId;
         $image = new \Thelia\Model\ContentImage();
         $image->setContentId($contentId);
         generate_image($image, 'content', $contentId);
         $document = new \Thelia\Model\ContentDocument();
Exemplo n.º 4
0
function createContents($faker, $folders, $con)
{
    echo "start creating contents\n";
    $fileSystem = new \Symfony\Component\Filesystem\Filesystem();
    $contents = array();
    if (($handle = fopen(THELIA_ROOT . '/setup/import/contents.csv', "r")) !== FALSE) {
        $row = 0;
        while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
            $row++;
            if ($row == 1) {
                continue;
            }
            $content = new \Thelia\Model\Content();
            $content->setVisible(1)->setPosition($row - 1)->setLocale('fr_FR')->setTitle(trim($data[0]))->setChapo($faker->text(20))->setDescription($faker->text(200))->setLocale('en_US')->setTitle(trim($data[1]))->setChapo($faker->text(20))->setDescription($faker->text(200));
            // folder
            $contentFolders = explode(';', $data[7]);
            $defaultFolder = null;
            foreach ($contentFolders as $contentFolder) {
                $contentFolder = trim($contentFolder);
                if (array_key_exists($contentFolder, $folders)) {
                    $content->addFolder($folders[$contentFolder]);
                    if (null === $defaultFolder) {
                        $defaultFolder = $folders[$contentFolder]->getId();
                    }
                }
            }
            $content->getContentFolders()->getFirst()->setDefaultFolder(true)->save($con);
            $content->save($con);
            $images = explode(';', $data[6]);
            foreach ($images as $image) {
                $image = trim($image);
                if (empty($image)) {
                    continue;
                }
                $contentImage = new \Thelia\Model\ContentImage();
                $contentImage->setContentId($content->getId())->setFile($image)->save($con);
                $fileSystem->copy(THELIA_ROOT . 'setup/import/images/' . $image, THELIA_ROOT . 'local/media/images/content/' . $image, true);
            }
            $contents[trim($data[1])] = $content;
        }
        fclose($handle);
    }
    echo "Contents created successfully\n";
    return $contents;
}