Отмечает активные модели меню (У которых ссылка соответствует текущему path info)
    :param menus: список моделей меню
    :param path_info: path info
    :return:
436177
def mark_current_menus(menus, path_info):
    
    for menu in menus:
        if menu.get_absolute_url() == "/":
            menu.is_current = menu.get_absolute_url() == path_info
        else:
            menu.is_current = path_info.find(menu.get_absolute_url()) == 0
712671
async def _set_persistent_menu(self):
        

        page = self.settings()

        if 'menu' in page:
            await self._send_to_messenger_profile(page, {
                'persistent_menu': page['menu'],
            })

            logger.info('Set menu for page %s', page['page_id'])
866783
protected function walkMenuTree(Menu $m, array $pathSegments) {

		if(!count($pathSegments)) {
			return;
		}

		// return when matching entry in current menu

		if(($e = $m->getSelectedEntry())) {
			return $e;
		}

        // get current page id to evaluate active menu entry
		
		$pathToMatch = urldecode(implode('/', $pathSegments));
		
		foreach($m->getEntries() as $e) {

			$path = urldecode($e->getPath());

            // check for a possible "root" (i.e. "/") path

            if(!$path && !$pathToMatch) {
                $e->getMenu()->setSelectedEntry($e);
                return $e;
            }

            // path segment doesn't match menu entry - finish walk

			if($path && 0 === strpos($pathToMatch, $path)) {

				$pathSegments = explode('/', trim(substr($pathToMatch, strlen($path)), '/'));
				
				$e->getMenu()->setSelectedEntry($e);
				$sm = $e->getSubMenu();

				// walk  into submenu

				if($sm) {
					$this->walkMenuTree($sm, $pathSegments);
				}
			}
		}
	}
294418
def meta_features_path(self, path):
        
        return os.path.join(
                path,
                app.config['XCESSIV_META_FEATURES_FOLDER'],
                str(self.id)
            ) + '.npy'
815183
def update_cookbook_path
      # both cookbook sequences and paths are listed in same order as
      # presented in repo UI. previous to RL v5.7 we received cookbook sequences
      # in an arbitrary order, but this has been fixed as of the release of v5.8
      # (we will not change the order for v5.7-).
      # for chef to execute repos and paths in the order listed, both of these
      # ordered lists need to be inserted in reverse order because the chef code
      # replaces cookbook paths as it reads the array from beginning to end.
      @cookbooks.reverse.each do |cookbook_sequence|
        local_basedir = File.join(@download_path, cookbook_sequence.hash)
        cookbook_sequence.paths.reverse.each do |path|
          dir = File.expand_path(File.join(local_basedir, path))
          unless Chef::Config[:cookbook_path].include?(dir)
            if File.directory?(dir)
              Chef::Config[:cookbook_path] << dir
            else
              RightScale::Log.info("Excluding #{path} from chef cookbooks_path because it was not downloaded")
            end
          end
        end
      end
      RightScale::Log.info("Updated cookbook_path to: #{Chef::Config[:cookbook_path].join(", ")}")
      true
    end
62599
public function editAction()
    {
        /** @var Menus_Entity_Table_Menu $table */
        $table = ORM::getTable($this->plugin, 'Menu');
        /** @var Menus_Entity_Menu $menu */
        $menu = $table->find(arg('id', 'int'));

        if (is_null($menu))
        {
            return 'Такое меню не найдено.';
        }

        $req = Eresus_CMS::getLegacyKernel()->request;

        if ('POST' == $req['method'])
        {
            $menu->name = arg('name', 'word');
            $menu->caption = arg('caption', 'dbsafe');
            $menu->active = true;
            $menu->root = arg('root', 'int');
            $menu->rootLevel = arg('rootLevel', 'int');
            $menu->invisible = arg('invisible', 'int');
            $menu->expandLevelAuto = arg('expandLevelAuto', 'int');
            $menu->expandLevelMax = arg('expandLevelMax', 'int');
            $menu->dropDown = arg('dropDown', 'int');
            $menu->template = arg('template', 'dbsafe');

            $test = $table->findByName($menu->name);
            if (is_null($test) || $test->id == $menu->id)
            {
                $table->update($menu);
                HTTP::redirect('admin.php?mod=ext-menus&id=' . $menu->id);
            }
            else
            {
                ErrorMessage('Меню с таким именем уже есть');
            }
        }

        $form = new EresusForm($this->plugin->templates()->adminPath('form.html', false));
        $form->setValue('sections', $this->adminSectionBranch());
        $form->setValue('action', 'edit');
        $form->setValue('menu', $menu);
        $html = $form->compile();

        return $html;
    }
1162678
public function getMenuInfo()
    {
        $result = $this->httpGet(self::WECHAT_MENU_INFO_GET_PREFIX, [
            'access_token' => $this->getAccessToken()
        ]);
        return !array_key_exists('errcode', $result) ? $result : false;
    }
986378
private void addMenuItems(Menu mMenu, boolean subMenu) {
        int groupId = R.id.material_drawer_menu_default_group;
        for (int i = 0; i < mMenu.size(); i++) {
            MenuItem mMenuItem = mMenu.getItem(i);
            IDrawerItem iDrawerItem;
            if (!subMenu && mMenuItem.getGroupId() != groupId && mMenuItem.getGroupId() != 0) {
                groupId = mMenuItem.getGroupId();
                iDrawerItem = new DividerDrawerItem();
                getItemAdapter().add(iDrawerItem);
            }
            if (mMenuItem.hasSubMenu()) {
                iDrawerItem = new PrimaryDrawerItem()
                        .withName(mMenuItem.getTitle().toString())
                        .withIcon(mMenuItem.getIcon())
                        .withIdentifier(mMenuItem.getItemId())
                        .withEnabled(mMenuItem.isEnabled())
                        .withSelectable(false);
                getItemAdapter().add(iDrawerItem);
                addMenuItems(mMenuItem.getSubMenu(), true);
            } else if (mMenuItem.getGroupId() != 0 || subMenu) {
                iDrawerItem = new SecondaryDrawerItem()
                        .withName(mMenuItem.getTitle().toString())
                        .withIcon(mMenuItem.getIcon())
                        .withIdentifier(mMenuItem.getItemId())
                        .withEnabled(mMenuItem.isEnabled());
                getItemAdapter().add(iDrawerItem);
            } else {
                iDrawerItem = new PrimaryDrawerItem()
                        .withName(mMenuItem.getTitle().toString())
                        .withIcon(mMenuItem.getIcon())
                        .withIdentifier(mMenuItem.getItemId())
                        .withEnabled(mMenuItem.isEnabled());
                getItemAdapter().add(iDrawerItem);
            }
        }
    }
234363
def AddPathInfo(self, path_info):
    """"""

    if self._path_type != path_info.path_type:
      message = "Incompatible path types: `%s` and `%s`"
      raise ValueError(message % (self._path_type, path_info.path_type))
    if self._components != path_info.components:
      message = "Incompatible path components: `%s` and `%s`"
      raise ValueError(message % (self._components, path_info.components))

    if path_info.timestamp in self._path_infos:
      raise ValueError("PathInfo with timestamp %r was added before." %
                       path_info.timestamp)

    new_path_info = path_info.Copy()
    if new_path_info.timestamp is None:
      new_path_info.timestamp = rdfvalue.RDFDatetime.Now()
    self._path_infos[new_path_info.timestamp] = new_path_info
451368
def infos(self):
        
        if not hasattr(self, '_infos'):
            self._infos = OrbitInfos(self)
        return self._infos
75748
def mk_notebook_context_menu(callback_object):
    
    callback_object.context_menu = Gtk.Menu()
    menu = callback_object.context_menu
    mi = Gtk.MenuItem(_("New Tab"))
    mi.connect("activate", callback_object.on_new_tab)
    menu.add(mi)
    menu.add(Gtk.SeparatorMenuItem())
    mi = Gtk.MenuItem(_("Save Tabs"))
    mi.connect("activate", callback_object.on_save_tabs)
    menu.add(mi)
    mi = Gtk.MenuItem(_("Restore Tabs"))
    mi.connect("activate", callback_object.on_restore_tabs_with_dialog)
    menu.add(mi)
    menu.add(Gtk.SeparatorMenuItem())
    mi = Gtk.ImageMenuItem("gtk-preferences")
    mi.set_use_stock(True)
    mi.connect("activate", callback_object.on_show_preferences)
    menu.add(mi)
    mi = Gtk.ImageMenuItem("gtk-about")
    mi.set_use_stock(True)
    mi.connect("activate", callback_object.on_show_about)
    menu.add(mi)
    menu.add(Gtk.SeparatorMenuItem())
    mi = Gtk.MenuItem(_("Quit"))
    mi.connect("activate", callback_object.on_quit)
    menu.add(mi)
    menu.show_all()
    return menu
895866
public function network_admin_menu() {
		$page = add_menu_page( esc_html__( 'Networks', 'wp-multi-network' ), esc_html__( 'Networks', 'wp-multi-network' ), 'manage_networks', 'networks', array( $this, 'route_pages' ), 'dashicons-networking', -1 );

		add_submenu_page( 'networks', esc_html__( 'All Networks', 'wp-multi-network' ), esc_html__( 'All Networks', 'wp-multi-network' ), 'list_networks', 'networks', array( $this, 'route_pages' ) );
		add_submenu_page( 'networks', esc_html__( 'Add New', 'wp-multi-network' ), esc_html__( 'Add New', 'wp-multi-network' ), 'create_networks', 'add-new-network', array( $this, 'page_edit_network' ) );

		add_action( "admin_head-{$page}", array( $this, 'fix_menu_highlight_for_move_page' ) );

		require_once wpmn()->plugin_dir . '/includes/classes/class-wp-ms-networks-list-table.php';
	}
1164740
def persistent_menu(menu):
    
    if len(menu) > 3:
        raise Invalid('menu should not exceed 3 call to actions')

    if any(len(item['call_to_actions']) > 5 for item in menu if item['type'] == 'nested'):
        raise Invalid('call_to_actions is limited to 5 for sub-levels')

    for item in menu:
        if len(item['title']) > 30:
            raise Invalid('menu item title should not exceed 30 characters')

        if item['type'] == 'postback' and len(item['payload']) > 1000:
            raise Invalid('menu item payload should not exceed 1000 characters')
1212638
public function addAction()
    {
        $req = Eresus_CMS::getLegacyKernel()->request;

        if ('POST' == $req['method'])
        {
            $menu = new Menus_Entity_Menu();
            $menu->name = arg('name', 'word');
            $menu->caption = arg('caption', 'dbsafe');
            $menu->active = true;
            $menu->root = arg('root', 'int');
            $menu->rootLevel = arg('rootLevel', 'int');
            $menu->invisible = arg('invisible', 'int');
            $menu->expandLevelAuto = arg('expandLevelAuto', 'int');
            $menu->expandLevelMax = arg('expandLevelMax', 'int');
            $menu->dropDown = arg('dropDown', 'int');
            $menu->template = arg('template', 'dbsafe');

            /** @var Menus_Entity_Table_Menu $table */
            $table = $menu->getTable();
            if (is_null($table->findByName($menu->name)))
            {
                $table->persist($menu);
                HTTP::redirect('admin.php?mod=ext-menus');
            }
            else
            {
                ErrorMessage('Меню с таким именем уже есть');
            }
        }
        else
        {
            $menu = null;
        }

        $form = new EresusForm($this->plugin->templates()->adminPath('form.html', false));
        $form->setValue('sections', $this->adminSectionBranch());
        $form->setValue('action', 'create');
        $form->setValue('menu', $menu);
        $html = $form->compile();

        return $html;
    }
856994
def _WritePathInfo(self, client_id, path_info):
    """"""
    if client_id not in self.metadatas:
      raise db.UnknownClientError(client_id)

    path_record = self._GetPathRecord(client_id, path_info)
    path_record.AddPathInfo(path_info)

    parent_path_info = path_info.GetParent()
    if parent_path_info is not None:
      parent_path_record = self._GetPathRecord(client_id, parent_path_info)
      parent_path_record.AddChild(path_info)
728228
def menu(menu_config=None, **kwargs):
    
    request = kwargs.pop("request", None)
    user = kwargs.pop("user", None)
    url_full_name = ":".join(
        [request.resolver_match.namespace, request.resolver_match.url_name]
    )

    if not menu_config:
        menu_config = settings.ARCTIC_MENU

    menu_dict = OrderedDict()
    for menu_entry in menu_config:
        if type(menu_entry) in (list, tuple):

            # check permission based on named_url
            path = None
            if menu_entry[1]:
                if not view_from_url(menu_entry[1]).has_permission(user):
                    continue

                path = reverse(menu_entry[1])
            # icons and collapse are optional
            icon = None
            if (len(menu_entry) >= 3) and (
                not type(menu_entry[2]) in (list, tuple)
            ):
                icon = menu_entry[2]
            active_weight = len(path) if path else 0
            menu_dict[menu_entry[0]] = {
                "url": menu_entry[1],
                "icon": icon,
                "submenu": None,
                "active": is_active(menu_entry, url_full_name),
                "active_weight": active_weight,
            }

            # check if the last item in a menu entry is a submenu
            submenu = _get_submenu(menu_entry)
            if submenu:
                menu_dict[menu_entry[0]]["submenu"] = menu(
                    submenu, user=user, request=request
                )
    return menu_clean(menu_dict)
286221
def _mk_context_menu(self, thumbkey, chname, info):
        
        menu = Widgets.Menu()
        item = menu.add_name("Display")
        item.add_callback('activated',
                          lambda w: self.load_file(
                              thumbkey, chname, info.name, info.path,
                              info.image_future))
        menu.add_separator()
        item = menu.add_name("Remove")
        item.add_callback('activated',
                          lambda w: self.fv.remove_image_by_name(
                              chname, info.name, impath=info.path))

        return menu