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


PHP ModUtil::getUserMods方法代码示例

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


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

示例1: display

 /**
  * display block
  *
  * @param        array       $blockinfo     a blockinfo structure
  * @return       output      the rendered bock
  */
 public function display($blockinfo)
 {
     // security check
     if (!SecurityUtil::checkPermission('ExtendedMenublock::', $blockinfo['bid'] . '::', ACCESS_READ)) {
         return;
     }
     // Break out options from our content field
     $vars = BlockUtil::varsFromContent($blockinfo['content']);
     // template to use
     if (empty($vars['template'])) {
         $vars['template'] = 'blocks_block_extmenu.tpl';
     }
     // stylesheet to use
     if (empty($vars['stylesheet'])) {
         $vars['stylesheet'] = 'extmenu.css';
     }
     // add the stylesheet to the header
     PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet('Blocks', $vars['stylesheet']));
     // if cache is enabled, checks for a cached output
     if ($this->view->getCaching()) {
         // set the cache id
         $this->view->setCacheId($blockinfo['bkey'] . '/bid' . $blockinfo['bid'] . '/' . UserUtil::getGidCacheString());
         // check out if the contents are cached
         if ($this->view->is_cached($vars['template'])) {
             $blockinfo['content'] = $this->view->fetch($vars['template']);
             return BlockUtil::themeBlock($blockinfo);
         }
     }
     // create default block variables
     if (!isset($vars['blocktitles'])) {
         $vars['blocktitles'] = array();
     }
     if (!isset($vars['links'])) {
         $vars['links'] = array();
     }
     if (!isset($vars['stylesheet'])) {
         $vars['stylesheet'] = '';
     }
     if (!isset($vars['menuid'])) {
         $vars['menuid'] = 0;
     }
     // get language and default to en
     $thislang = ZLanguage::getLanguageCode();
     if (!array_key_exists($thislang, $vars['links'])) {
         $thislang = 'en';
     }
     // if specific blocktitle for selected language exists, use it
     if (array_key_exists($thislang, $vars['blocktitles']) && !empty($vars['blocktitles'][$thislang])) {
         $blockinfo['title'] = $vars['blocktitles'][$thislang];
     }
     // Content
     $menuitems = array();
     if (!empty($vars['links'][$thislang])) {
         $blocked = array();
         foreach ($vars['links'][$thislang] as $linkid => $link) {
             $link['parentid'] = isset($link['parentid']) ? $link['parentid'] : null;
             $denied = !SecurityUtil::checkPermission('ExtendedMenublock::', $blockinfo['bid'] . ':' . $linkid . ':', ACCESS_READ);
             if ($denied || !is_null($link['parentid']) && in_array($link['parentid'], $blocked)) {
                 $blocked[] = $linkid;
             } elseif (!isset($link['active']) || $link['active'] != '1') {
                 $blocked[] = $linkid;
             } else {
                 // pre zk1.2 check
                 if (!isset($link['id'])) {
                     $link['id'] = $linkid;
                 }
                 $link['url'] = ModUtil::apiFunc('Blocks', 'user', 'encodebracketurl', $link['url']);
                 // check for multiple options in image
                 $this->checkImage($link);
                 $menuitems[] = $link;
             }
         }
     }
     // Modules
     if (!empty($vars['displaymodules'])) {
         $newmods = ModUtil::getUserMods();
         $mods = array();
         foreach ($newmods as $module) {
             if (!preg_match('#(?:error|blocks)#', strtolower($module['name']))) {
                 $mods[] = $module;
             }
         }
         // Separate from current content, if any
         if (count($menuitems) > 0) {
             $menuitems[] = array('name' => ' ', 'url' => '', 'title' => '', 'level' => 0, 'parentid' => null, 'image' => '');
             if (SecurityUtil::checkPermission('ExtendedMenublock::', $blockinfo['bid'] . '::', ACCESS_ADMIN)) {
                 $menuitems[] = array('name' => $this->__('--Installed modules--'), 'url' => ModUtil::url('Blocks', 'admin', 'modify', array('bid' => $blockinfo['bid'])), 'title' => '', 'level' => 0, 'parentid' => null, 'image' => '');
             }
         }
         foreach ($mods as $mod) {
             // prepare image
             if (SecurityUtil::checkPermission("{$mod['name']}::", '::', ACCESS_OVERVIEW)) {
                 $menuitems[] = array('name' => $mod['displayname'], 'url' => ModUtil::url($mod['name'], 'user', 'main'), 'title' => $mod['description'], 'level' => 0, 'parentid' => null, 'image' => '');
             }
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例2: modifyconfig

    /**
     * Modify Theme settings.
     */
    public function modifyconfig()
    {
        // Security check
        if (!SecurityUtil::checkPermission('Theme::', '::', ACCESS_EDIT)) {
            return LogUtil::registerPermissionError();
        }

        // assign a list of modules suitable for html_options
        $usermods = ModUtil::getUserMods();
        $mods = array();
        foreach ($usermods as $usermod) {
            $mods[$usermod['name']] = $usermod['displayname'];
        }

        // register the renderer object allow access to various view values
        $this->view->register_object('render', $this->view);

        // check for a .htaccess file
        if (file_exists('.htaccess')) {
            $this->view->assign('htaccess', 1);
        } else {
            $this->view->assign('htaccess', 0);
        }

        // assign the output variables and fetch the template
        return $this->view->assign('mods', $mods)
                          // assign all module vars
                          ->assign($this->getVars())
                          // assign an csrftoken for the clear cache/compile links
                          ->assign('csrftoken', SecurityUtil::generateCsrfToken($this->serviceManager, true))
                          // assign the core config var
                          ->assign('theme_change', System::getVar('theme_change'))
                          // extracted list of non-cached mods
                          ->assign('modulesnocache', array_flip(explode(',', $this->getVar('modulesnocache'))))
                          ->fetch('theme_admin_modifyconfig.tpl');
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:39,代码来源:Admin.php

示例3: _import_menu

    /**
     * Convert data of selected menu to menutree style
     * Used to import menus
     */
    private function _import_menu($bid)
    {
        if ((!isset($bid)) || (isset($bid) && !is_numeric($bid))) {
            return;
        }

        $menu = BlockUtil::getBlockInfo($bid);
        $menuVars = BlockUtil::varsFromContent($menu['content']);

        $userlanguage = ZLanguage::getLanguageCode();

        $menuType = strtolower($menu['bkey']);
        switch ($menuType) {
            case 'menutree':
                $data = isset($menuVars['menutree_content']) ? $menuVars['menutree_content'] : array();
                break;

            case 'menu':
                if (isset($menuVars['content']) && !empty($menuVars['content'])) {
                    $reflang = $userlanguage;
                    $pid = 1;
                    $data = array();
                    $contentlines = explode('LINESPLIT', $menuVars['content']);
                    foreach ($contentlines as $lineno => $contentline) {
                        list($href, $name, $title) = explode('|', $contentline);
                        if (!empty($name)) {
                            $className = '';
                            $parent = 0;
                            $state = 1;
                            $lang = $reflang;
                            $id = $pid;
                            $data[$lineno][$reflang] = compact('href','name','title','className','parent','state','lang','lineno','id');
                            $pid++;
                        }
                    }
                    $langs = (array)$reflang;
                    $lineno++;
                }
                break;

            case 'extmenu':
                if (isset($menuVars['links']) && !empty($menuVars['links'])) {
                    $langs = array_keys($menuVars['links']);
                    $data = array();
                    foreach ($langs as $lang) {
                        foreach ($menuVars['links'][$lang] as $id => $link) {
                            $data[$id][$lang] = array(
                                    'id'        => $id + 1,
                                    'name'      => isset($link['name']) && !empty($link['name']) ? $link['name'] : $this->__('no name'),
                                    'href'      => isset($link['url']) ? $link['url'] : '',
                                    'title'     => isset($link['title']) ? $link['title'] : '',
                                    'className' => '',
                                    'state'     => isset($link['active']) && $link['active'] && $link['name'] ? 1 : 0,
                                    'lang'      => $lang,
                                    'lineno'    => $id,
                                    'parent'    => 0
                            );
                        }
                    }
                    ksort($data);
                    $pid = $id + 2;
                    $lineno = count($data);
                }
                break;
        }

        if (!empty($menuVars['displaymodules'])) {
            $mods = ModUtil::getUserMods();

            if (is_array($mods) && count($mods)>0) {
                foreach ($mods as $mod) {
                    $tmp = array('name'  => $mod['displayname'],
                                 'href'  => DataUtil::formatForDisplay(ModUtil::url($mod['name'], 'user', 'main')),
                                 'title' => $mod['description']);

                    foreach ($langs as $lang) {
                        $tmp = array_merge($tmp, array('className' => '',
                                                       'parent' => 0,
                                                       'lang' => $lang,
                                                       'state' => 1,
                                                       'lineno' => $lineno,
                                                       'id' => $pid));
                        $tmparray[$lang] = $tmp;
                    }

                    $data[] = $tmparray;
                    $pid++;
                    $lineno++;
                }
            }
        }

        return $data;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:98,代码来源:Menutree.php

示例4: display

    /**
     * display block
     *
     * @param  array  $blockinfo a blockinfo structure
     * @return output the rendered bock
     */
    public function display($blockinfo)
    {
        // security check
        if (!SecurityUtil::checkPermission('Menublock::', "$blockinfo[title]::", ACCESS_READ)) {
            return;
        }

        // Break out options from our content field
        $vars = BlockUtil::varsFromContent($blockinfo['content']);

        // add the stylesheet to the header
        if (isset($vars['stylesheet'])) {
            PageUtil::addVar('stylesheet', ThemeUtil::getModuleStyleSheet('Blocks', $vars['stylesheet']));
        }

        // if cache is enabled, checks for a cached output
        if ($this->view->getCaching()) {
            // set the cache id
            $this->view->setCacheId($blockinfo['bkey'].'/bid'.$blockinfo['bid'].'/'.UserUtil::getGidCacheString());

            // check out if the contents are cached
            if ($this->view->is_cached('blocks_block_menu.tpl')) {
                $blockinfo['content'] = $this->view->fetch('blocks_block_menu.tpl');

                return BlockUtil::themeBlock($blockinfo);
            }
        }

        // Styling - this is deprecated and is only to support old menu for now
        if (empty($vars['style'])) {
            $vars['style'] = 1;
        }

        // Content
        $menuitems = array();
        if (!empty($vars['content'])) {
            $contentlines = explode('LINESPLIT', $vars['content']);
            foreach ($contentlines as $contentline) {
                list($url, $title, $comment) = explode('|', $contentline);
                if (SecurityUtil::checkPermission('Menublock::', "$blockinfo[title]:$title:", ACCESS_READ)) {
                    $menuitems[] = self::addMenuItem($title, $url, $comment);
                    $content = true;
                }
            }
        }

        // Modules
        if (!empty($vars['displaymodules'])) {
            $mods = ModUtil::getUserMods();

            // Separate from current content, if any
            if ($vars['content'] == 1) {
                $menuitems[] = self::addMenuItem('', '', '');
            }

            foreach ($mods as $mod) {
                if (SecurityUtil::checkPermission("$mod[name]::", '::', ACCESS_OVERVIEW)) {
                    $menuitems[] = self::addMenuItem($mod['displayname'], ModUtil::url($mod['name'], 'user', 'main'), $mod['description']);
                    $content = true;
                }
            }
        }

        // check for any empty result set
        if (empty($menuitems)) {
            return;
        }

        // assign the items
        $this->view->assign('menuitems', $menuitems);

        // get the block content
        $blockinfo['content'] = $this->view->fetch('blocks_block_menu.tpl');

        // pass the block array back to the theme for display
        return BlockUtil::themeBlock($blockinfo);
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:83,代码来源:Menu.php

示例5: pnModGetUserMods

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

示例6: modules

 /**
  * Return list of user modules
  *
  * Syntax used in menutree
  * {ext:Blocks:modules:[flat]}
  * Last param is optional
  *
  * @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
  * @return mixed array of links if successful, false otherwise
  */
 public function modules($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;
     }
     // 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 $extrainfo if 'flat' - don't group links
     if ($extrainfo != 'flat') {
         $links['modules'] = array($lang => array('id' => $idoffset++, 'name' => $item['name'], 'href' => '', '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 = $extrainfo != 'flat' ? $links['modules'][$lang]['id'] : $item['parent'];
     $mods = ModUtil::getUserMods();
     foreach ($mods as $mod) {
         if (SecurityUtil::checkPermission("{$mod['name']}::", '::', ACCESS_OVERVIEW)) {
             $links[] = array($lang => array('id' => $idoffset++, 'name' => $mod['displayname'], 'href' => ModUtil::url($mod['name'], 'user', 'main'), 'title' => $mod['description'], 'className' => '', 'state' => 1, 'lang' => $lang, 'lineno' => $lineno++, 'parent' => $parentNode));
         }
     }
     return $links;
 }
开发者ID:,项目名称:,代码行数:40,代码来源:


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