403Webshell
Server IP : 195.130.67.5  /  Your IP : 216.73.217.154
Web Server : Microsoft-IIS/10.0
System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586
User : IUSR ( 0)
PHP Version : 7.4.19
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /Old Sites/modip/modules/menu_firstchild/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /Old Sites/modip/modules/menu_firstchild/menu_firstchild.module
<?php
// $Id: menu_firstchild.module,v 1.8 2010/10/25 10:43:10 anrikun Exp $

/**
 * @file menu_firstchild.module
 * Main file for the menu_firstchild module.
 *
 * By default, Drupal 6 requires that you enter a path for each menu link you add/edit from the Menu administration page.
 * There are cases you may want to create a parent item, without any path, that simply links to its first viewable child item.
 * Menu Firstchild provides this functionality.
 * Developped by Henri MEDOT <henri.medot[AT]absyx[DOT]fr>
 * http://www.absyx.fr
 */

/**
 * Implementation of hook_menu().
 */
function menu_firstchild_menu() {
  $items['<firstchild>'] = array(
    'page callback' => '_menu_firstchild_menu',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  return $items;
}

function _menu_firstchild_menu() {
  return drupal_not_found();
}

/**
 * Implementation of hook_menu_link_alter().
 */
function menu_firstchild_menu_link_alter(&$item, $menu) {
  if ($item['module'] == 'menu') {
    if ($item['link_path'] == '<firstchild>') {
      $item['options']['alter'] = TRUE;
      $item['options']['unaltered_hidden'] = $item['hidden'];
    }
    else {
      unset($item['options']['unaltered_hidden']);
    }
  }
}

/**
 * Implementation of hook_translated_menu_link_alter().
 */
function menu_firstchild_translated_menu_link_alter(&$item, $map) {
  if (($item['module'] == 'menu') && ($item['link_path'] == '<firstchild>')) {
    $href = _menu_firstchild_get_firstchild_href($item['mlid']);
    if ($href != NULL) {
      $item['href'] = $href;
    }
    else {
      $item['hidden'] = TRUE;
    }
  }
}

function _menu_firstchild_get_firstchild_href($mlid) {
  global $language;
  $result = db_query("SELECT mlid, link_path FROM {menu_links} WHERE plid = %d ORDER BY weight, link_title", $mlid);
  while ($m = db_fetch_array($result)) {
    if ($m['link_path'] != '<firstchild>') {
      $child = menu_link_load($m['mlid']);
      if (!empty($child['access']) && empty($child['hidden'])
       && (!isset($child['localized_options']['langcode']) || ($child['localized_options']['langcode'] == $language->language))) {
        return $m['link_path'];
      }
    }
    else {
      $href = _menu_firstchild_get_firstchild_href($m['mlid']);
      if ($href != NULL) {
        return $href;
      }
    }
  }
  return NULL;
}

/**
 * Implementation of hook_form_alter().
 */
function menu_firstchild_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'menu_overview_form') {
    foreach ($form as $key => $value) {
      if (isset($value['#item']['href']) && ($value['#item']['href'] == '<firstchild>')) {
        $item = $value['#item'];
        $unaltered_hidden = $item['options']['unaltered_hidden'];
        $form[$key]['#item']['hidden'] = $unaltered_hidden;
        $form[$key]['hidden']['#default_value'] = !$unaltered_hidden;
        $form[$key]['#attributes']['class'] = $unaltered_hidden ? 'menu-disabled' : 'menu-enabled';
        $form[$key]['title']['#value'] = check_plain($item['title']) . ($unaltered_hidden ? ' ('. t('disabled') .')' : '');
      }
    }
  }
  elseif (($form_id == 'menu_edit_item') && isset($form['menu']['link_path'])) {
    $form['menu']['link_path']['#description'] .= t(' Enter %firstchild to link to the item\'s first accessible child.', array('%firstchild' => '<firstchild>'));
    if (isset($form['menu']['#item']['options']['unaltered_hidden'])) {
      $form['menu']['enabled']['#default_value'] = !$form['menu']['#item']['options']['unaltered_hidden'];
    }
  }
}

Youez - 2016 - github.com/yon3zu
LinuXploit