Пример #1
0
 public function testSearchById()
 {
     $folder = FolderQuery::create()->findOne();
     if (null === $folder) {
         $folder = new \Thelia\Model\Folder();
         $folder->setParent(0);
         $folder->setVisible(1);
         $folder->setTitle('foo');
         $folder->save();
     }
     $otherParameters = array("visible" => "*");
     $this->baseTestSearchById($folder->getId(), $otherParameters);
 }
Пример #2
0
 /**
  * generates a folder and its sub folders to be used in Position tests
  *
  * @return int the parent folder id
  */
 protected function getFolderIdForPositionTest()
 {
     if (null === self::$folderIdForPositionTest) {
         $folder = new \Thelia\Model\Folder();
         $folder->setParent(0);
         $folder->setVisible(1);
         $folder->setPosition(1);
         $this->setI18n($folder);
         $folder->save();
         for ($i = 0; $i < 4; $i++) {
             $subFolder = new \Thelia\Model\Folder();
             $subFolder->setParent($folder->getId());
             $subFolder->setVisible(1);
             $subFolder->setPosition($i + 1);
             $this->setI18n($subFolder);
             $subFolder->save();
         }
         self::$folderIdForPositionTest = $folder->getId();
     }
     return self::$folderIdForPositionTest;
 }
Пример #3
0
 $contentIdList = array();
 for ($i = 0; $i < 4; $i++) {
     $folder = new Thelia\Model\Folder();
     $folder->setParent(0);
     $folder->setVisible(1);
     $folder->setPosition($i + 1);
     setI18n($folder);
     $folder->save();
     $image = new \Thelia\Model\FolderImage();
     $image->setFolderId($folder->getId());
     generate_image($image, 'folder', $folder->getId());
     $document = new \Thelia\Model\FolderDocument();
     $document->setFolderId($folder->getId());
     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();
Пример #4
0
function createFolders($faker, $con)
{
    echo "start creating folders\n";
    $fileSystem = new \Symfony\Component\Filesystem\Filesystem();
    $folders = array();
    if (($handle = fopen(THELIA_ROOT . '/setup/import/folders.csv', "r")) !== FALSE) {
        $row = 0;
        while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
            $row++;
            if ($row == 1) {
                continue;
            }
            $folder = new \Thelia\Model\Folder();
            $folder->setVisible(1)->setPosition($row - 1)->setLocale('fr_FR')->setTitle(trim($data[0]))->setChapo($faker->text(20))->setDescription($faker->text(100))->setLocale('en_US')->setTitle(trim($data[1]))->setChapo($faker->text(20))->setDescription($faker->text(100))->save($con);
            $folders[trim($data[1])] = $folder;
            $images = explode(';', $data[6]);
            foreach ($images as $image) {
                $image = trim($image);
                if (empty($image)) {
                    continue;
                }
                $folderImage = new \Thelia\Model\FolderImage();
                $folderImage->setFolderId($folder->getId())->setFile($image)->save($con);
                $fileSystem->copy(THELIA_ROOT . 'setup/import/images/' . $image, THELIA_ROOT . 'local/media/images/folder/' . $image, true);
            }
        }
        fclose($handle);
    }
    echo "Folders created successfully\n";
    return $folders;
}