private function getValues()
 {
     $values = array();
     if (array_key_exists('source', $this->params)) {
         $source = $this->params['source'];
         if (CUtils::strLeft($source, ".") == "class") {
             $class = CUtils::strRight($source, ".");
             if (array_key_exists('properties', $this->params)) {
                 $object = new $class(array("properties" => $this->params['properties']));
             } else {
                 $object = new $class();
             }
             $sourceParams = $this->params['params'];
             // для совместимости их надо положить в запрос
             foreach ($sourceParams as $key => $value) {
                 $_POST[$key] = $value;
             }
             $values = $object->actionGetViewData();
         } else {
             $taxonomy = CTaxonomyManager::getTaxonomy($this->params['source']);
             $values = $taxonomy->getTermsList();
         }
     } elseif (array_key_exists('values', $this->params)) {
         $values = $this->params['values'];
     }
     return $values;
 }
Пример #2
0
 /**
  * Объект таксономии, к которой данный термин привязан.
  * Если это самостоятельный объект словаря, то null
  *
  * @return CTaxonomy
  */
 public function getParentTaxonomy()
 {
     if (is_null($this->_taxonomy)) {
         if ($this->getRecord()->hasItem("taxonomy_id")) {
             $this->_taxonomy = CTaxonomyManager::getTaxonomy($this->getRecord()->getItemValue("taxonomy_id"));
         }
     }
     return $this->_taxonomy;
 }
 public function actionGetObject($id)
 {
     $cache_id = $this->taxonomy . "_item_" . $id;
     if (is_null(CApp::getApp()->cache->get($cache_id))) {
         $taxonomy = CTaxonomyManager::getTaxonomy($this->taxonomy);
         $term = $taxonomy->getTerm($id);
         CApp::getApp()->cache->set($cache_id, $term, 30);
     }
     return CApp::getApp()->cache->get($cache_id);
 }
 /**
  * Ищет термин в указанной таксономии. Если не находит - создает
  *
  * @param $taxonomy
  * @param $key
  * @return CTerm
  */
 private function getTerm($taxonomyName, $key)
 {
     if ($taxonomyName == "education_form") {
         $forms = new CArrayList();
         /**
          * Пересортируем формы обучения в другом порядке, чтобы ключом
          * было название
          */
         foreach (CTaxonomyManager::getCacheEducationForms()->getItems() as $form) {
             $forms->add(mb_strtolower($form->getValue()), $form);
         }
         if ($forms->hasElement(mb_strtolower($key))) {
             $term = $forms->getItem(mb_strtolower($key));
         } else {
             $term = new CTerm();
             $term->setTable(TABLE_EDUCATION_FORMS);
             $term->setValue($key);
             $term->save();
             CTaxonomyManager::getCacheEducationForms()->add($term->getId(), $term);
         }
     } elseif ($taxonomyName == "gender") {
         $genders = new CArrayList();
         foreach (CTaxonomyManager::getCacheGenders()->getItems() as $gender) {
             $genders->add(mb_strtoupper($gender->getValue()), $gender);
         }
         if ($genders->hasElement(mb_strtoupper($key))) {
             $term = $genders->getItem(mb_strtoupper($key));
         }
     } else {
         $taxonomy = CTaxonomyManager::getTaxonomy($taxonomyName);
         $term = $taxonomy->getTerm($key);
         if (is_null($term)) {
             $term = new CTerm();
             $term->taxonomy_id = $taxonomy->getId();
             $term->setValue($key);
             $term->save();
             $taxonomy->addTerm($term);
         }
     }
     return $term;
 }
 public function actionGetObject($id)
 {
     $taxonomy = CTaxonomyManager::getTaxonomy($id);
     return $taxonomy;
 }
 /**
  * @param $catalog
  * @return ISearchCatalogInterface
  * @throws Exception
  */
 private function searchObjectsFactory($catalog, $properties = array())
 {
     if ($catalog == "staff") {
         return new CSearchCatalogStaff(array("properties" => $properties));
     } elseif ($catalog == "student") {
         return new CSearchCatalogStudent(array("properties" => $properties));
     } elseif ($catalog == "studentgroup") {
         return new CSearchCatalogStudentGroup(array("properties" => $properties));
     } elseif ($catalog == "sab_commissions") {
         return new CSearchCatalogSABCommission(array());
     } elseif (CUtils::strLeft($catalog, ".") == "class") {
         $class = CUtils::strRight($catalog, ".");
         return new $class(array("properties" => $properties));
     } elseif (!is_null(CTaxonomyManager::getTaxonomy($catalog))) {
         return new CSearchCatalogTaxonomy(array("taxonomy" => $catalog, "properties" => $properties));
     } elseif (!is_null(CTaxonomyManager::getLegacyTaxonomy($catalog))) {
         return new CSearchCatalogTaxonomyLegacy(array("taxonomy" => $catalog, "properties" => $properties));
     } else {
         throw new Exception("Не могу найти каталог для поиска " . $catalog);
     }
 }
 public function actionImportTerms()
 {
     $arr = CRequest::getArray(CTaxonomy::getClassName());
     $taxonomy = CTaxonomyManager::getTaxonomy($arr["id"]);
     $terms = $arr["terms"];
     $terms = explode("\n", $terms);
     foreach ($terms as $t) {
         if (trim($t) != "") {
             $term = new CTerm();
             $term->setTaxonomy($taxonomy);
             $term->setValue($t);
             $term->save();
         }
     }
     $this->redirect("index.php?action=index&id=" . $taxonomy->getId());
 }