Exemplo n.º 1
0
 /**
  * create thesauri
  * @return void
  */
 protected function createThesauri($pid, &$th, $prefix)
 {
     $o = new \CB\Objects\Object();
     foreach ($th as $k => &$v) {
         //create $k folder under pid
         echo "creating '{$k}' .. ";
         $id = $o->create(array('id' => null, 'pid' => $pid, 'template_id' => BBM::$cfg['folderTemplateId'], 'name' => $k, 'data' => array('_title' => $k)));
         $this->thesauriIds[$prefix . $k] = array('id' => $id);
         echo "ok\n";
         if (Util\isAssocArray($v)) {
             //subfolders
             $this->createThesauri($id, $v, $prefix . $k . '/');
         } else {
             //create thesauri items
             $i = 1;
             foreach ($v as $item) {
                 $o->create(array('id' => null, 'pid' => $id, 'template_id' => BBM::$cfg['thesauriTemplateId'], 'name' => $item, 'data' => array("en" => $item, "iconCls" => "icon-tag-small", "visible" => 1, "order" => $i++)));
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  * get data for defined plugins to be displayed in properties panel for selected object
  * @param  array $p remote properties containing object id
  * @return ext   direct responce
  */
 public function getPluginsData($p)
 {
     $id = @$p['id'];
     $templateId = @$p['template_id'];
     $template = null;
     $templateData = null;
     $objectPlugins = null;
     $rez = array('success' => false, 'data' => array());
     if (empty($id) && empty($templateId) || !is_numeric($id) && !is_numeric($templateId)) {
         return $rez;
     }
     if (is_numeric($id)) {
         if (!$this->idExists($id)) {
             return $rez;
         }
         if (!Security::canRead($id)) {
             throw new \Exception(L\get('Access_denied'));
         }
         $rez['menu'] = Browser\CreateMenu::getMenuForPath($id);
         /* now we'll try to detect plugins config that could be found in following places:
                1. in config of the template for the given object, named object_plugins
                2. in core config, property object_type_plugins (config definitions per available template type values: object, case, task etc)
                3. a generic config,  named default_object_plugins, could be defined in core config
            */
         $o = $this->getCachedObject($id);
         if (!empty($o)) {
             $template = $o->getTemplate();
             if (!empty($template)) {
                 $templateData = $template->getData();
             }
         }
     } else {
         $id = null;
         $templates = Templates\SingletonCollection::getInstance();
         $templateData = $templates->getTemplate($templateId)->getData();
     }
     $from = empty($p['from']) ? '' : $p['from'];
     if (!empty($from)) {
         if (isset($templateData['cfg']['object_plugins'])) {
             $op = $templateData['cfg']['object_plugins'];
             if (!empty($op[$from])) {
                 $objectPlugins = $op[$from];
             } else {
                 //check if config has only numeric keys, i.e. plugins specified directly (without a category)
                 if (!Util\isAssocArray($op)) {
                     $objectPlugins = $op;
                 } else {
                     $objectPlugins = Config::getObjectTypePluginsConfig(@$templateData['type'], $from);
                 }
             }
         }
     }
     if (empty($objectPlugins)) {
         if (!empty($templateData['cfg']['object_plugins'])) {
             $objectPlugins = $templateData['cfg']['object_plugins'];
         } else {
             $objectPlugins = Config::getObjectTypePluginsConfig($templateData['type'], $from);
         }
     }
     $rez['success'] = true;
     if (empty($objectPlugins)) {
         return $rez;
     }
     foreach ($objectPlugins as $pluginName) {
         $class = '\\CB\\Objects\\Plugins\\' . ucfirst($pluginName);
         $pClass = new $class($id);
         $prez = $pClass->getData();
         $rez['data'][$pluginName] = $prez;
     }
     return $rez;
 }