コード例 #1
0
ファイル: entry.php プロジェクト: AdiTal/server
 public function parentSetCategories($categories)
 {
     parent::setCategories($categories);
 }
コード例 #2
0
ファイル: entry.php プロジェクト: richhl/kalturaCE
 /**
  * Set the categories (use only the most child categories)
  * 
  * @param string $categories 
  */
 public function setCategories($newCats)
 {
     $newCats = explode(self::ENTRY_CATEGORY_SEPARATOR, $newCats);
     $this->trimCategories($newCats);
     if (count($newCats) > self::MAX_CATEGORIES_PER_ENTRY) {
         throw new kCoreException("Max number of allowed entries per category was reached", kCoreException::MAX_CATEGORIES_PER_ENTRY);
     }
     // remove duplicates
     $newCats = array_unique($newCats);
     // leave only the most child categories
     $mostChildCats = array();
     foreach ($newCats as $currentCat) {
         $unsetI = false;
         $add = true;
         foreach ($mostChildCats as $i => $mostChild) {
             if (strpos($currentCat, $mostChild . categoryPeer::CATEGORY_SEPARATOR) === 0) {
                 $unsetI = $i;
                 break;
             }
             if (strpos($mostChild, $currentCat . categoryPeer::CATEGORY_SEPARATOR) === 0) {
                 $add = false;
             }
         }
         if ($unsetI !== false) {
             unset($mostChildCats[$unsetI]);
         }
         if ($add) {
             $mostChildCats[] = $currentCat;
         }
     }
     $this->old_categories = $this->categories;
     parent::setCategories(implode(",", $mostChildCats));
     $this->is_categories_modified = true;
 }