Beispiel #1
0
 public static function getProperties($id)
 {
     $rez = array('success' => true, 'data' => array());
     if (!is_numeric($id)) {
         return $rez;
     }
     $rez['menu'] = Browser\CreateMenu::getMenuForPath($id);
     $file = new Objects\File($id);
     $rez['data'] = $file->load();
     $d =& $rez['data'];
     $d['path'] = str_replace(',', '/', $d['path']);
     $t = strtotime($d['cdate']);
     $dateFormat = getOption('long_date_format');
     $timeFormat = getOption('time_format');
     $d['ago_date'] = date($dateFormat, $t) . ' ' . L\get('at') . ' ' . date($timeFormat, $t);
     $d['ago_date'] = Util\translateMonths($d['ago_date']);
     $d['ago_text'] = Util\formatAgoTime($d['cdate']);
     if (!empty($d['versions'])) {
         foreach ($d['versions'] as &$r) {
             $r['template_id'] = $rez['data']['template_id'];
             $t = strtotime($r['cdate']);
             $r['ago_date'] = date($dateFormat, $t) . ' ' . L\get('at') . ' ' . date($timeFormat, $t);
             $r['ago_date'] = Util\translateMonths($r['ago_date']);
             $r['ago_text'] = Util\formatAgoTime($r['cdate']);
         }
     }
     return $rez;
 }
Beispiel #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;
 }
Beispiel #3
0
 /**
  * get create menu for current node
  * @param  array   $rp request params
  * @return varchar menu config string
  */
 public function getCreateMenu(&$rp)
 {
     return Browser\CreateMenu::getMenuForPath($this->id);
 }