You are here

function menu_patterns_get_arguments in Patterns 7

File

patterns_components/components/menu.inc, line 153

Code

function menu_patterns_get_arguments($action, $tag, $form_id, &$loop = FALSE) {

  // taken from menu_load_links
  if ($tag == 'menu_item' && $action == PATTERNS_MODIFY && $form_id == 'menu_edit_item') {
    $links = db_select('menu_links', 'ml', array(
      'fetch' => PDO::FETCH_ASSOC,
    ))
      ->fields('ml')
      ->execute()
      ->fetchAll();

    //print_r($links); //for debug
    $loop = TRUE;
    $return = array();
    $i = 0;
    foreach ($links as &$link) {
      $i++;
      if ($link['link_title'] == '') {
        $link['link_title'] = 'null';
      }
      $link['options'] = unserialize($link['options']);
      $link['href'] = "";
      array_push($return, array(
        "edit",
        $link,
        $link,
      ));
    }
    return $return;
  }
  elseif ($tag == 'menu' && $action == PATTERNS_MODIFY && $form_id == 'menu_edit_menu') {
    $loop = TRUE;
    $result = db_query("SELECT * FROM {menu_custom} ORDER BY title", array(), array(
      'fetch' => PDO::FETCH_ASSOC,
    ));
    $return = array();
    foreach ($result as $menu) {
      array_push($return, array(
        "edit",
        $menu,
      ));
    }
    return $return;
  }
}