Пример #1
0
 function showAllAction()
 {
     if (!Config::get("allCategoriesPageEnabled")) {
         return $this->return404();
     }
     Display::set("adPage", "allcategories");
     //get all categories first parents then childs to build tree
     $c = new Criteria();
     $c->addOrder("parentCategoryId, name");
     $categories = $this->category->findAll($c, "categoryId, parentCategoryId, name, urlName, validatedSitesCount");
     $tree = new NavigationTree();
     foreach ($categories as $category) {
         $value = $category;
         //add node to tree
         $tree->addNode($category['categoryId'], $category['parentCategoryId'], $value);
     }
     //build tree
     $this->set("allCategories", $tree->render());
 }
Пример #2
0
 function createOptionsList($onlyPossibleTender = false)
 {
     $categories = Model::factoryInstance("categoryParent")->getCategoriesForSelect();
     $tree = new NavigationTree();
     foreach ($categories as $category) {
         $value = array("name" => $category->name);
         $tree->addNode($category->categoryId, $category->parentId, $value);
     }
     $results = $tree->getFullOptionList();
     if ($onlyPossibleTender) {
         $categoryPossible = $this->category->getArray(null, "possibleTender");
         foreach ($results as $key => $result) {
             if (!$categoryPossible[$key]) {
                 unset($results[$key]);
             }
         }
     }
     asort($results);
     return $results;
 }
Пример #3
0
 public function rebuildTable()
 {
     $c = new Criteria();
     $this->del($c);
     $categoryModel = Model::factoryInstance($this->categoryModelName);
     $categoryPrimaryKey = $categoryModel->getPrimaryKey();
     $categories = $categoryModel->findAll($c, $categoryPrimaryKey . "," . $this->categoryParentKey);
     $tree = new NavigationTree();
     foreach ($categories as $category) {
         $tree->addNode($category[$categoryPrimaryKey], $category[$this->categoryParentKey]);
     }
     $connections = $tree->getAllConnections();
     foreach ($connections as $connection) {
         $this->addNode($connection['parentCategoryId'], $connection['categoryId']);
     }
 }
Пример #4
0
 function createUrlNames()
 {
     $withParents = Config::get('advancedUrlRewritingParentsEnabled');
     set_time_limit(600);
     $categories = $this->category->findAll(null, "categoryId, parentCategoryId, name, urlName");
     $tree = new NavigationTree();
     foreach ($categories as $category) {
         $tree->addNode($category['categoryId'], $category['parentCategoryId'], array("name" => $category['name'], "urlName" => $category['urlName']));
     }
     $connections = $tree->getAllConnections();
     $urlNames = array("");
     foreach ($connections as $connection) {
         $urlName = NameTool::strToAscii($connection['value']['name']);
         if ($withParents) {
             $urlName = ltrim($urlNames[$connection['depth'] - 1] . "\\" . $urlName, "\\");
             $urlNames[$connection['depth']] = $urlName;
         }
         $urlName = $this->category->getFreeUrlName($urlName, $connection['categoryId']);
         if ($connection['value']['urlName'] && $connection['value']['urlName'] != $urlName && !$this->rewrite->findByPk($connection['value']['urlName'])) {
             $rewrite = new RewriteRecord();
             $rewrite->originalUrl = $connection['value']['urlName'];
             $rewrite->rewrittedUrl = $urlName;
             $rewrite->save();
         }
         $this->category->updateByPk(array("urlName" => $urlName), $connection['categoryId']);
     }
 }