示例#1
0
 private function _getExtraType($extraName)
 {
     if (is_null(self::$_extraTypes)) {
         $iaCore = iaCore::instance();
         $iaCore->factory('item');
         self::$_extraTypes = $iaCore->iaDb->keyvalue(array('name', 'type'), iaDb::convertIds(iaCore::STATUS_ACTIVE, 'status'), iaItem::getExtrasTable());
     }
     return isset(self::$_extraTypes[$extraName]) ? self::$_extraTypes[$extraName] : null;
 }
示例#2
0
 public function getAdminMenu()
 {
     $iaDb =& $this->iaCore->iaDb;
     $result = array();
     $menuGroups = array();
     $extras = $this->iaCore->get('extras');
     $stmt = "`extras` IN ('', '" . implode("','", $extras) . "')";
     $rows = $iaDb->all(array('id', 'name', 'title'), $stmt . ' ORDER BY `order`', null, null, 'admin_pages_groups');
     foreach ($rows as $row) {
         $menuGroups[$row['id']] = array_merge($row, array('items' => array()));
     }
     $this->iaCore->factory('item');
     $sql = 'SELECT g.`name` `config`, e.`type`, ' . 'p.`id`, p.`group`, p.`name`, p.`parent`, p.`title`, p.`attr`, p.`alias`, p.`extras` ' . 'FROM `:prefix:table_admin_pages` p ' . 'LEFT JOIN `:prefix:table_config_groups` g ON ' . "(p.`extras` IN (':extras') AND p.`extras` = g.`extras`) " . 'LEFT JOIN `:prefix:table_extras` e ON ' . "(p.`extras` = e.`name`) " . 'WHERE p.`group` IN (:groups) ' . "AND FIND_IN_SET('menu', p.`menus`) " . "AND p.`status` = ':status' " . "AND p.`extras` IN ('',':extras') " . 'ORDER BY p.`order`';
     $sql = iaDb::printf($sql, array('prefix' => $iaDb->prefix, 'table_admin_pages' => 'admin_pages', 'table_config_groups' => iaCore::getConfigGroupsTable(), 'table_extras' => iaItem::getExtrasTable(), 'groups' => implode(',', array_keys($menuGroups)), 'status' => iaCore::STATUS_ACTIVE, 'extras' => implode("','", $extras)));
     $rows = $iaDb->getAll($sql);
     foreach ($rows as $row) {
         $menuGroups[$row['group']]['items'][] = $row;
     }
     $iaAcl = $this->iaCore->factory('acl');
     // config groups to be included as menu items
     $rows = $iaDb->all(array('name', 'title', 'extras'), "`name` != 'email_templates' AND " . $stmt . ' ORDER BY `order`', null, null, iaCore::getConfigGroupsTable());
     $configGroups = array();
     $templateName = $this->iaCore->get('tmpl');
     foreach ($rows as $row) {
         switch (true) {
             case $templateName == $row['extras']:
                 $configGroups['template'] = $row['name'];
                 break;
             case $row['extras']:
                 $row['config'] = $row['name'];
                 $configGroups['plugins'][$row['extras']] = $row;
                 break;
             default:
                 $row['url'] = 'configuration' . IA_URL_DELIMITER . $row['name'] . IA_URL_DELIMITER;
                 $row['name'] = 'configuration_' . $row['name'];
                 $configGroups['common'][] = $row;
         }
     }
     //
     foreach ($menuGroups as $group) {
         if (!$group['items']) {
             continue;
         }
         $separatorsCount = 0;
         $menuEntry = $group;
         $menuEntry['items'] = array();
         if (1 == $group['id']) {
             $menuEntry['items'] = $configGroups['common'];
         }
         foreach ($group['items'] as $item) {
             if ($iaAcl->checkAccess(iaAcl::OBJECT_ADMIN_PAGE . iaAcl::SEPARATOR . iaCore::ACTION_READ, $item['name'])) {
                 $title = iaLanguage::get($item['title'], $item['title']);
                 $data = array('name' => $item['name'], 'parent' => isset($item['parent']) ? $item['parent'] : null, 'title' => $title);
                 if ($item['alias']) {
                     $data['url'] = IA_ADMIN_URL . $item['alias'];
                 }
                 if (isset($item['attr']) && $item['attr']) {
                     $data['attr'] = $item['attr'];
                 }
                 if ($item['type'] != iaItem::TYPE_PACKAGE && isset($item['config']) && $item['config']) {
                     $data['config'] = $item['config'];
                 }
                 if ('templates' == $item['name'] && isset($configGroups['template'])) {
                     $data['config'] = $configGroups['template'];
                 }
                 if (isset($configGroups['plugins'][$item['extras']])) {
                     unset($configGroups['plugins'][$item['extras']]);
                 }
                 $menuEntry['items'][] = $data;
                 if (empty($item['name'])) {
                     $separatorsCount++;
                 }
             }
         }
         // delete separators if no elements allowed
         if ($separatorsCount == count($menuEntry['items'])) {
             unset($menuEntry['items']);
         }
         if (isset($menuEntry['items'][0]['name']) && $menuEntry['items'][0]['name']) {
             $menuHeading = array('name' => null, 'title' => iaLanguage::get('global'));
             if (iaItem::TYPE_PACKAGE == $item['type']) {
                 $menuHeading['config'] = $item['extras'];
             }
             array_unshift($menuEntry['items'], $menuHeading);
         }
         $result[$group['name']] = $menuEntry;
     }
     if (!empty($configGroups['plugins'])) {
         $result['extensions']['items'] = array_merge($result['extensions']['items'], array_values($configGroups['plugins']));
     }
     return $result;
 }
示例#3
0
 protected function _loadItemInstance($itemName)
 {
     $this->_itemName = $itemName;
     if (iaUsers::getItemName() == $this->_itemName) {
         $this->_itemInstance = $this->iaCore->factory('users');
         $this->_packageName = null;
         $this->_options = $this->_itemInstance->{self::ITEM_SEARCH_PROPERTY_OPTIONS};
         return true;
     }
     $itemData = $this->iaDb->row(array('package'), iaDb::convertIds($this->_itemName, 'item'), iaItem::getTable());
     if ($itemData && iaCore::CORE != $itemData['package']) {
         $instance = $this->iaCore->factoryPackage('item', $itemData['package'], iaCore::FRONT, $this->_itemName);
         if (isset($instance->{self::ITEM_SEARCH_PROPERTY_ENABLED}) && true === $instance->{self::ITEM_SEARCH_PROPERTY_ENABLED}) {
             $this->_itemInstance =& $instance;
             $this->_packageName = $itemData['package'];
             $this->_options = isset($instance->{self::ITEM_SEARCH_PROPERTY_OPTIONS}) ? $instance->{self::ITEM_SEARCH_PROPERTY_OPTIONS} : array();
             return true;
         }
     }
     return false;
 }