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


PHP Menu::get_id方法代码示例

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


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

示例1: add_filter_fieldset

 public static function add_filter_fieldset(Menu $menu, Template $tpl)
 {
     $tpl_filter = new FileTemplate('admin/menus/filters.tpl');
     $tpl_filter->assign_block_vars('modules', array('ID' => ''));
     foreach (ModulesManager::get_activated_modules_map_sorted_by_localized_name() as $module) {
         $configuration = $module->get_configuration();
         $home_page = $configuration->get_home_page();
         if (!empty($home_page)) {
             $tpl_filter->assign_block_vars('modules', array('ID' => $module->get_id()));
         }
     }
     //Ajout du menu
     if ($menu->get_id() == '') {
         $menu->set_filters(array(new MenuStringFilter('/')));
     }
     // Installed modules
     foreach ($menu->get_filters() as $key => $filter) {
         $filter_pattern = $filter->get_pattern();
         $filter_infos = explode('/', $filter_pattern);
         $module_name = $filter_infos[0];
         $regex = substr(strstr($filter_pattern, '/'), 1);
         $tpl_filter->assign_block_vars('filters', array('ID' => $key, 'FILTER' => $regex));
         $tpl_filter->assign_block_vars('filters.modules', array('ID' => '', 'SELECTED' => $filter_pattern == '/' ? ' selected="selected"' : ''));
         foreach (ModulesManager::get_activated_modules_map_sorted_by_localized_name() as $module) {
             $configuration = $module->get_configuration();
             $home_page = $configuration->get_home_page();
             if (!empty($home_page)) {
                 $tpl_filter->assign_block_vars('filters.modules', array('ID' => $module->get_id(), 'SELECTED' => $module_name == $module->get_id() ? ' selected="selected"' : ''));
             }
         }
     }
     $tpl_filter->add_lang(LangLoader::get('admin-menus-common'));
     $tpl_filter->put_all(array('NBR_FILTER' => $menu->get_id() == '' ? 0 : count($menu->get_filters()) - 1));
     $tpl->put('filters', $tpl_filter);
 }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:35,代码来源:MenuAdminService.class.php

示例2: move

    /**
     * @desc Move a menu into a block and save it. Enable or disable it according to the destination block
     * @param Menu $menu the menu to move
     * @param int $block the destination block
     * @param int $position the destination block position
     * @param bool $save if true, save also the menu
     */
    public static function move(Menu $menu, $block, $position = 0, $save = true)
    {
        if ($menu->get_id() > 0 && $menu->is_enabled()) {
            // Updates the previous block position counter
            // Only for already existing menu that are enabled, not for new ones
            $parameters = array('block' => $menu->get_block(), 'position' => $menu->get_block_position());
            self::$querier->inject('UPDATE ' . DB_TABLE_MENUS . ' SET position=position - 1
				WHERE block=:block AND position > :position', $parameters);
        }
        // Disables the menu if the destination block is the NOT_ENABLED block position
        $menu->enabled($block == Menu::BLOCK_POSITION__NOT_ENABLED ? Menu::MENU_NOT_ENABLED : Menu::MENU_ENABLED);
        // If not enabled, we do not move it so we can restore its position by reactivating it
        if ($menu->is_enabled()) {
            // Moves the menu into the destination block
            $menu->set_block($block);
            // Computes the new block position for the menu
            if (empty($position)) {
                $position_query = self::get_next_position($menu->get_block());
                $menu->set_block_position($position_query);
            }
        }
        if ($save) {
            self::save($menu);
        }
    }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:32,代码来源:MenuService.class.php

示例3: save

 /**
  * 
  * Enter description here ...
  * @param Menu $menu
  */
 public static function save(Menu $menu)
 {
     $dbh = $GLOBALS['dbh'];
     if ($menu->get_id()) {
         // Update
         $data = $dbh->prepare("\n\t\t\t\tUPDATE \n\t\t\t\t\tmenu\n\t\t\t\tSET \n\t\t\t\t\tname=:name, unit=:unit, cost=:cost \n\t\t\t\tWHERE \n\t\t\t\t\tid=:id\n\t\t\t");
         $data->execute(array(':name' => $menu->get_name(), ':unit' => $menu->get_unit(), ':cost' => $menu->get_cost(), ':id' => $menu->get_id()));
     } else {
         // Insert
         $data = $dbh->prepare("\n\t\t\t\tINSERT \n\t\t\t\t\tINTO `menu`(name, unit, cost)\n\t\t\t\tVALUES\n\t\t\t\t\t(:name, :unit, :cost)\n\t\t\t");
         $data->execute(array(':name' => $menu->get_name(), ':unit' => $menu->get_unit(), ':cost' => $menu->get_cost()));
     }
 }
开发者ID:nguyentien,项目名称:ps3,代码行数:18,代码来源:menu.class.php


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