当前位置: 首页>>代码示例>>PHP>>正文


PHP ModUtil::getAdminMods方法代码示例

本文整理汇总了PHP中ModUtil::getAdminMods方法的典型用法代码示例。如果您正苦于以下问题:PHP ModUtil::getAdminMods方法的具体用法?PHP ModUtil::getAdminMods怎么用?PHP ModUtil::getAdminMods使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModUtil的用法示例。


在下文中一共展示了ModUtil::getAdminMods方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: display

    /**
     * display block
     */
    public function display($blockinfo)
    {
        // Security check
        if (!SecurityUtil::checkPermission('Admin:adminnavblock', "$blockinfo[title]::$blockinfo[bid]", ACCESS_ADMIN)) {
            return;
        }

        // Get variables from content block
        $vars = BlockUtil::varsFromContent($blockinfo['content']);

        // Call the modules API to get the items
        if (!ModUtil::available('Admin')) {
            return;
        }

        $items = ModUtil::apiFunc('Admin', 'admin', 'getall');

        // Check for no items returned
        if (empty($items)) {
            return;
        }

        // get admin capable modules
        $adminmodules = ModUtil::getAdminMods();
        $adminmodulescount = count($adminmodules);

        // Display each item, permissions permitting
        $admincategories = array();
        foreach ($items as $item) {
            if (SecurityUtil::checkPermission('Admin::', "$item[name]::$item[cid]", ACCESS_READ)) {
                $adminlinks = array();
                foreach ($adminmodules as $adminmodule) {
                    // Get all modules in the category
                    $catid = ModUtil::apiFunc('Admin', 'admin', 'getmodcategory',
                                              array('mid' => ModUtil::getIdFromName($adminmodule['name'])));

                    if (($catid == $item['cid']) || (($catid == false) && ($item['cid'] == $this->getVar('defaultcategory')))) {
                        $modinfo = ModUtil::getInfoFromName($adminmodule['name']);
                        $menutexturl = ModUtil::url($modinfo['name'], 'admin');
                        $menutexttitle = $modinfo['displayname'];
                        $adminlinks[] = array('menutexturl' => $menutexturl,
                                              'menutexttitle' => $menutexttitle);
                    }
                }
                $admincategories[] = array('url' => ModUtil::url('Admin', 'admin', 'adminpanel', array('cid' => $item['cid'])),
                                           'title' => DataUtil::formatForDisplay($item['name']),
                                           'modules' => $adminlinks);
            }
        }

        $this->view->assign('admincategories', $admincategories);

        // Populate block info and pass to theme
        $blockinfo['content'] = $this->view->fetch('admin_block_adminnav.tpl');

        return BlockUtil::themeBlock($blockinfo);
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:60,代码来源:Adminnav.php

示例2: categorymenu

    /**
     * Main category menu.
     *
     * @return string HTML string
     */
    public function categorymenu($args)
    {
        // get the current category
        $acid = FormUtil::getPassedValue('acid', isset($args['acid']) ? $args['acid'] : $this->getVar('startcategory'), 'GET');

        // Get all categories
        $categories = array();
        $items = ModUtil::apiFunc('Admin', 'admin', 'getall');
        foreach ($items as $item) {
            if (SecurityUtil::checkPermission('Admin::', "$item[name]::$item[cid]", ACCESS_READ)) {
                $categories[] = $item;
            }
        }

        // get admin capable modules
        $adminmodules = ModUtil::getAdminMods();
        $adminlinks = array();

        foreach ($adminmodules as $adminmodule) {
            if (SecurityUtil::checkPermission("$adminmodule[name]::", '::', ACCESS_EDIT)) {
                $catid = ModUtil::apiFunc('Admin', 'admin', 'getmodcategory', array('mid' => $adminmodule['id']));
                $order = ModUtil::apiFunc('Admin', 'admin', 'getSortOrder',
                                          array('mid' => ModUtil::getIdFromName($adminmodule['name'])));
                $menutexturl = ModUtil::url($adminmodule['name'], 'admin', 'main');
                $menutext = $adminmodule['displayname'];
                $menutexttitle = $adminmodule['description'];
                $adminlinks[$catid][] = array('menutexturl' => $menutexturl,
                        'menutext' => $menutext,
                        'menutexttitle' => $menutexttitle,
                        'modname' => $adminmodule['name'],
                        'order' => $order,
                        'id' => $adminmodule['id']
                );
            }
        }

        foreach ($adminlinks as &$item) {
            usort($item, '_sortAdminModsByOrder');
        }

        $menuoptions = array();
        $possible_cids = array();
        $permission = false;

        if (isset($categories) && is_array($categories)) {
            foreach ($categories as $category) {
                // only categories containing modules where the current user has permissions will
                // be shown, all others will be hidden
                // admin will see all categories
                if ( (isset($adminlinks[$category['cid']]) && count($adminlinks[$category['cid']]) )
                        || SecurityUtil::checkPermission('.*', '.*', ACCESS_ADMIN) ) {
                    $menuoption = array('url'         => ModUtil::url('Admin','admin','adminpanel', array('acid' => $category['cid'])),
                            'title'       => $category['name'],
                            'description' => $category['description'],
                            'cid'         => $category['cid']);
                    if (isset($adminlinks[$category['cid']])) {
                        $menuoption['items'] = $adminlinks[$category['cid']];
                    } else {
                        $menuoption['items'] = array();
                    }
                    $menuoptions[$category['cid']] = $menuoption;
                    $possible_cids[] = $category['cid'];

                    if ($acid == $category['cid']) {
                        $permission =true;
                    }
                }
            }
        }

        // if permission is false we are not allowed to see this category because its
        // empty and we are not admin
        if ($permission==false) {
            // show the first category
            $acid = !empty($possible_cids) ? (int)$possible_cids[0] : null;
        }

        $this->view->assign('currentcat', $acid);
        $this->view->assign('menuoptions', $menuoptions);

        // security analyzer and update checker warnings
        $notices = array();
        $notices['security'] = $this->_securityanalyzer();
        $notices['update'] = $this->_updatecheck();
        $notices['developer'] = $this->_developernotices();
        $this->view->assign('notices', $notices);

        return $this->view->fetch('admin_admin_categorymenu.tpl');
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:94,代码来源:Admin.php

示例3: pnModGetAdminMods

/**
 * The pnModGetAdminMods function gets a list of administration modules.
 *
 * @deprecated
 * @see ModUtil::getAdminMods()
 *
 * @return array An array of module information arrays.
 */
function pnModGetAdminMods()
{
    LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array(__FUNCTION__, 'ModUtil::getAdminMods()')), E_USER_DEPRECATED);
    return ModUtil::getAdminMods();
}
开发者ID:,项目名称:,代码行数:13,代码来源:

示例4: adminlinks

 /**
  * Return list of admin modules
  *
  * Syntax used in menutree
  * {ext:Blocks:adminlinks:[flat,category]}
  * Last param is optional.  It can be flat and/or category separated by a comma.
  * 'flat' will add the admin links in the current menu.  Without 'flat' the links are grouped one level down
  * 'category' additionally groups the admin links by their category.
  * You can combine 'flat' and 'category' to have the category links added in the current menu.
  *
  * @param array $args['item'] menu node to be replaced
  * @param string $args['lang'] current menu language
  * @param string $args['extrainfo'] additional params - if 'flat' then return links ungrouped. if 'category' module links grouped by category
  * @return mixed array of links if successful, false otherwise
  */
 public function adminlinks($args)
 {
     $item = isset($args['item']) && !empty($args['item']) ? $args['item'] : null;
     $lang = isset($args['lang']) && !empty($args['lang']) ? $args['lang'] : null;
     $extrainfo = isset($args['extrainfo']) && !empty($args['extrainfo']) ? $args['extrainfo'] : null;
     // $item ang lang params are required
     if (!$item || !$lang) {
         return false;
     }
     // Convert extrainfo into flags
     $extrainfo = $extrainfo ? preg_split("/[\\s]*,[\\s]*/", trim($extrainfo)) : array();
     $flag = array();
     $flag['flat'] = in_array("flat", $extrainfo);
     //now true or false
     $flag['category'] = in_array("category", $extrainfo);
     //now true or false
     // Make sure admin API is loaded
     if (!ModUtil::loadApi('Admin', 'admin', true)) {
         return false;
     }
     if (!SecurityUtil::checkPermission('Admin::', "::", ACCESS_EDIT)) {
         return array();
         // Since no permission, return empty links
     }
     // get id for first element, use api func to aviod id conflicts inside menu
     $idoffset = Blocks_MenutreeUtil::getIdOffset($item['id']);
     $lineno = 0;
     $links = array();
     // if not flat, group the links into a single menu entry
     if (!$flag['flat']) {
         $links['adminlinks'] = array($lang => array('id' => $idoffset++, 'name' => $item['name'], 'href' => ModUtil::url('Admin', 'admin', 'adminpanel'), 'title' => $item['title'], 'className' => $item['className'], 'state' => $item['state'], 'lang' => $lang, 'lineno' => $lineno++, 'parent' => $item['parent']));
     }
     // need to set parent node id - if links are grouped - use your_accont item id
     // otherwise parent id of replaced menu node
     $parentNode = !$flag['flat'] ? $links['adminlinks'][$lang]['id'] : $item['parent'];
     // First work on the Admin module categories
     $catinfo = array();
     // used to store menu information for the categories
     $catlinks = array();
     if ($flag['category']) {
         // Get all the Categories
         $categories = ModUtil::apiFunc('Admin', 'admin', 'getall');
         foreach ($categories as $item) {
             if (SecurityUtil::checkPermission('Admin::', "{$item['catname']}::{$item['cid']}", ACCESS_EDIT)) {
                 // Set up the menu information for this category
                 $catinfo[$item['cid']] = array('id' => $idoffset, 'no' => 0);
                 $catlinks[] = array($lang => array('id' => $idoffset++, 'name' => $item['catname'], 'href' => ModUtil::url('Admin', 'admin', 'adminpanel', array('acid' => $item['cid'])), 'title' => $item['description'], 'className' => '', 'state' => 1, 'lang' => $lang, 'lineno' => $lineno++, 'parent' => $parentNode));
             }
         }
     }
     // Now work on admin capable modules
     $adminmodules = ModUtil::getAdminMods();
     $displayNameType = ModUtil::getVar('Admin', 'displaynametype', 1);
     $default_cid = ModUtil::getVar('Admin', 'startcategory');
     $adminlinks = array();
     foreach ($adminmodules as $adminmodule) {
         if (SecurityUtil::checkPermission("{$adminmodule['name']}::", '::', ACCESS_EDIT)) {
             $cid = ModUtil::apiFunc('Admin', 'admin', 'getmodcategory', array('mid' => ModUtil::getIdFromName($adminmodule['name'])));
             $cid = isset($catinfo[$cid]) ? $cid : $default_cid;
             // make sure each module is assigned a category
             $modinfo = ModUtil::getInfo(ModUtil::getIdFromName($adminmodule['name']));
             if ($modinfo['type'] == 2 || $modinfo['type'] == 3) {
                 $menutexturl = ModUtil::url($modinfo['name'], 'admin');
             } else {
                 $menutexturl = 'admin.php?module=' . $modinfo['name'];
             }
             if ($displayNameType == 1) {
                 $menutext = $modinfo['displayname'];
             } elseif ($displayNameType == 2) {
                 $menutext = $modinfo['name'];
             } elseif ($displayNameType == 3) {
                 $menutext = $modinfo['displayname'] . ' (' . $modinfo['name'] . ')';
             }
             $adminlinks[] = array($lang => array('id' => $idoffset++, 'name' => $menutext, 'href' => $menutexturl, 'title' => $modinfo['description'], 'className' => '', 'state' => 1, 'lang' => $lang, 'lineno' => $flag['category'] ? $catinfo[$cid]['no']++ : $lineno++, 'parent' => $flag['category'] ? $catinfo[$cid]['id'] : $parentNode));
         }
     }
     $links = array_merge($links, $catlinks, $adminlinks);
     return $links;
 }
开发者ID:,项目名称:,代码行数:94,代码来源:


注:本文中的ModUtil::getAdminMods方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。