DansTonCode.net
quote.smartness() == 42The use of COBOL cripples the mind; its teaching should therefore be regarded as a criminal offense.@author E.W. Dijkstra
Quote #143
php
@
author 
vwatel
0
function _menu_parents_recurse($menu_name, $type = 'menu', $lang = 'en', $path = false){

	$q = db_query("SELECT * FROM menu_links WHERE menu_name = '{$menu_name}' ORDER BY depth, weight ASC");
	$languages_list = locale_language_list();
	$menu_name_read = db_fetch_object(db_query("SELECT title FROM menu_custom WHERE menu_name = '{$menu_name}' LIMIT 1"));
	$menu_structure = array();
	while($data = db_fetch_object($q))
	{
		$lang_un = unserialize($data->options);
		if(isset($lang_un['langcode']) && $lang_un['langcode'] == $lang){

			switch($data->depth)
			{
				case 1:
					$menu[$data->p1] = array('name' => $data->link_title, 'path' => $data->link_path);
				break;
				case 2:
					$menu[$data->p1]['childrens'][$data->p2] = array('name' => $data->link_title, 'path' => $data->link_path);
				break;
				case 3:
					$menu[$data->p1]['childrens'][$data->p2]['childrens'][$data->p3] = array('name' => $data->link_title, 'path' => $data->link_path);
				break;
				case 4:
					$menu[$data->p1]['childrens'][$data->p2]['childrens'][$data->p3]['childrens'][$data->p4] = array('name' => $data->link_title, 'path' => $data->link_path);
				break;
				case 5:
					$menu[$data->p1]['childrens'][$data->p2]['childrens'][$data->p3]['childrens'][$data->p4]['childrens'][$data->p5] = array('name' => $data->link_title, 'path' => $data->link_path);
				break;
				case 6:
					$menu[$data->p1]['childrens'][$data->p2]['childrens'][$data->p3]['childrens'][$data->p4]['childrens'][$data->p5]['childrens'][$data->p6] = array('name' => $data->link_title, 'path' => $data->link_path);
				break;
				case 7:
					$menu[$data->p1]['childrens'][$data->p2]['childrens'][$data->p3]['childrens'][$data->p4]['childrens'][$data->p5]['childrens'][$data->p6]['childrens'][$data->p7] = array('name' => $data->link_title, 'path' => $data->link_path);
				break;
				case 8:
					$menu[$data->p1]['childrens'][$data->p2]['childrens'][$data->p3]['childrens'][$data->p4]['childrens'][$data->p5]['childrens'][$data->p6]['childrens'][$data->p7]['childrens'][$data->p8] = array('name' => $data->link_title, 'path' => $data->link_path);
				break;
				case 9:
					$menu[$data->p1]['childrens'][$data->p2]['childrens'][$data->p3]['childrens'][$data->p4]['childrens'][$data->p5]['childrens'][$data->p6]['childrens'][$data->p7]['childrens'][$data->p8]['childrens'][$data->p9] = array('name' => $data->link_title, 'path' => $data->link_path);
				break;
			}

		}
	}

	if(!$path)
		$menu_structure[$menu_name.&#39;:0&#39;] = &#39;<&#39;.t($menu_name_read->title).&#39;>&#39;;
	else
		$menu_structure[&#39;&#39;] = &#39;<&#39;.t($menu_name_read->title).&#39;>&#39;;

	if($menu){
		foreach($menu as $mlid => $menu_item)
		{
			if($menu_item[&#39;name&#39;]) $menu_structure[(!$path) ? $menu_name.&#39;:&#39;.$mlid : $menu_item[&#39;path&#39;]] = &#39;-- &#39;.$menu_item[&#39;name&#39;];

			if(isset($menu_item[&#39;childrens&#39;]))
			{
				foreach($menu_item[&#39;childrens&#39;] as $children_mlid => $children)
				{
					if($children[&#39;name&#39;]) $menu_structure[$menu_name.&#39;:&#39;.$children_mlid] = &#39;---- &#39;.$children[&#39;name&#39;];

					if(isset($children[&#39;childrens&#39;])){

						foreach($children[&#39;childrens&#39;] as $children2_mlid => $children2)
						{
							if($children2[&#39;name&#39;]) $menu_structure[$menu_name.&#39;:&#39;.$children2_mlid] = &#39;------ &#39;.$children2[&#39;name&#39;];

							if(isset($children2[&#39;childrens&#39;])){

								foreach($children2[&#39;childrens&#39;] as $children3_mlid => $children3)
								{
									if($children3[&#39;name&#39;]) $menu_structure[$menu_name.&#39;:&#39;.$children3_mlid] = &#39;-------- &#39;.$children3[&#39;name&#39;];

									if(isset($children3[&#39;childrens&#39;])){

										foreach($children3[&#39;childrens&#39;] as $children4_mlid => $children4)
										{
											if($children4[&#39;name&#39;]) $menu_structure[$menu_name.&#39;:&#39;.$children4_mlid] = &#39;---------- &#39;.$children4[&#39;name&#39;];

											if(isset($children4[&#39;childrens&#39;])){

												foreach($children4[&#39;childrens&#39;] as $children5_mlid => $children5)
												{
													if($children5[&#39;name&#39;]) $menu_structure[$menu_name.&#39;:&#39;.$children5_mlid] = &#39;------------ &#39;.$children5[&#39;name&#39;];

													if(isset($children5[&#39;childrens&#39;])){

														foreach($children5[&#39;childrens&#39;] as $children6_mlid => $children6)
														{
															if($children6[&#39;name&#39;]) $menu_structure[$menu_name.&#39;:&#39;.$children6_mlid] = &#39;-------------- &#39;.$children6[&#39;name&#39;];

															if(isset($children6[&#39;childrens&#39;])){

																foreach($children6[&#39;childrens&#39;] as $children7_mlid => $children7)
																{
																	if($children7[&#39;name&#39;]) $menu_structure[$menu_name.&#39;:&#39;.$children7_mlid] = &#39;-------------- &#39;.$children7[&#39;name&#39;];
																}
															}

														}
													}

												}
											}

										}
									}

								}
							}
						}

					}
				}
			}
		}
	}

	return $menu_structure;
}
Code source n°143
Code-source en php proposé par vwatel
 
 0