/** * Returns picture list. * * @return array */ public function getPictureList() { if (isset($this->parameters['categoryID'])) { $category = CategoryHandler::getInstance()->getCategory($this->parameters['categoryID']); $categoryIDs = array($category->categoryID); foreach ($category->getChildCategories() as $childCategory) { $categoryIDs[] = $childCategory->categoryID; } // fetch news pictures $pictureList = new GroupedNewsPictureList(); $pictureList->getConditionBuilder()->add('news_picture.categoryID IN (?)', array($categoryIDs)); $pictureList->readObjects(); // assign variables WCF::getTPL()->assign(array('categoryID' => $this->parameters['categoryID'], 'category' => $category, 'childCategories' => $category->getChildCategories(), 'pictures' => $pictureList->getObjects())); return array('categoryID' => $this->parameters['categoryID'], 'template' => WCF::getTPL()->fetch('groupedPictureList', 'news')); } else { $categoryID = 0; // get first category $categories = CategoryHandler::getInstance()->getCategories('de.voolia.news.picture.category'); while (!empty($categories)) { $tCategory = array_shift($categories); if ($tCategory->parentCategoryID == 0) { $categoryID = $tCategory->categoryID; $category = $tCategory; break; } } if ($categoryID) { // fetch category node tree $categoryTree = new NewsPictureCategoryNodeTree('de.voolia.news.picture.category'); $categoryList = $categoryTree->getIterator(); $categoryList->setMaxDepth(0); $categoryIDs = array($categoryID); foreach ($category->getChildCategories() as $childCategory) { $categoryIDs[] = $childCategory->categoryID; } $pictureList = new GroupedNewsPictureList(); $pictureList->getConditionBuilder()->add('news_picture.categoryID IN (?)', array($categoryIDs)); $pictureList->readObjects(); // assign variables WCF::getTPL()->assign(array('categoryID' => $categoryID, 'categoryList' => $categoryList, 'pictures' => $pictureList->getObjects())); } // fetch aleady selected/uploaded picture if ($this->parameters['pictureID']) { $picture = new NewsPicture($this->parameters['pictureID']); if ($picture->pictureID) { WCF::getTPL()->assign('picture', $picture); } } return array('categoryID' => $categoryID, 'template' => WCF::getTPL()->fetch('pictureListInspector', 'news')); } }
/** * @see \wcf\page\IPage::readData() */ public function readData() { parent::readData(); if (!$this->categoryID) { return; } // categories $categoryTree = new NewsPictureCategoryNodeTree('de.voolia.news.picture.category'); $this->categoryList = $categoryTree->getIterator(); $this->categoryList->setMaxDepth(0); // pictures $categoryIDs = array($this->categoryID); foreach ($this->category->getChildCategories() as $childCategory) { $categoryIDs[] = $childCategory->categoryID; } $this->pictureList = new GroupedNewsPictureList(); $this->pictureList->getConditionBuilder()->add('news_picture.categoryID IN (?)', array($categoryIDs)); $this->pictureList->readObjects(); }
/** * @see \wcf\page\IPage::readData() */ public function readData() { parent::readData(); $categoryTree = new NewsPictureCategoryNodeTree('de.voolia.news.picture.category'); $this->categoryList = $categoryTree->getIterator(); $this->categoryList->setMaxDepth(0); }