dolibarr /htdocs/core/menus/smartphone/smartphone.lib.php

Language PHP Lines 179
MD5 Hash b76d2d0d4961698ed5b6f64518fa10d6 Estimated Cost $421,501 (why?)
Repository https://github.com/asterix14/dolibarr.git View Raw File
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
/* Copyright (C) 2010 Laurent Destailleur  <eldy@users.sourceforge.net>
 * Copyright (C) 2010 Regis Houssin        <regis@dolibarr.fr>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 * or see http://www.gnu.org/
 */

/**
 *  \file		htdocs/core/menus/smartphone/smartphone.lib.php
 *  \brief		Library for file smartphone menus
 */


/**
 * Core function to output top menu smartphone
 *
 * @param $db
 * @param $atarget
 * @param $type_user     0=Internal,1=External,2=All
 * @param $limitmenuto	 To limit menu to a top or left menu value
 */
function print_smartphone_menu($db,$atarget,$type_user,$limitmenuto)
{
	require_once(DOL_DOCUMENT_ROOT."/core/class/menubase.class.php");

	global $user,$conf,$langs,$dolibarr_main_db_name;

	$submenus='';

	$tabMenu=array();

	$menutop = new Menubase($db,'smartphone','top');
	$menuleft = new Menubase($db,'smartphone','left');
	$newTabMenu = $menutop->menuTopCharger('', '', $type_user, 'smartphone',$tabMenu);
	$numTabMenu = count($newTabMenu);

	print_start_menu_array();
    for($i=0; $i<$numTabMenu; $i++)
	{
		if ($newTabMenu[$i]['enabled'] == true)
		{
			if ($newTabMenu[$i]['right'] == true)	// Is allowed
			{
				// Define url
				if (preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url']))
				{
					$url = dol_buildpath($newTabMenu[$i]['url'],1);
					$url=preg_replace('/&amp.*/i','',$url);
				}
				else
				{
					$menus='';

					if ($limitmenuto > 0)
					{
						$newmenu = new Menu();
						$leftmenu = $menuleft->menuLeftCharger($newmenu,$newTabMenu[$i]['mainmenu'],'',($user->societe_id?1:0),'smartphone',$tabMenu);
						$menus = $leftmenu->liste;
						//var_dump($menus);
					}

					print_start_menu_entry();

					if (is_array($menus) && !empty($menus) && $limitmenuto > 0)
					{
						$title=$newTabMenu[$i]['titre'];
						// To remove & and special chars: $title=dol_string_unaccent(dol_string_nospecial(dol_html_entity_decode($newTabMenu[$i]['titre'],ENT_QUOTES,'UTF-8'),'',array('&')));
						print_text_menu_entry($title);

						$num = count($menus);
						//var_dump($menus);

					    if ($num > 0) print_start_submenu_array();

                        for($j=0; $j<$num; $j++)
						{
							$url=dol_buildpath($menus[$j]['url'],1);
							$url=preg_replace('/&amp.*/i','',$url);

							if ($menus[$j]['level'] == 0)
							{
								print_start_menu_entry();
								if (empty($menus[$j+1]['level'])) print '<a href="'.$url.'"'.($menus[$j]['atarget']?" target='".$menus[$j]['atarget']."'":($atarget?" target=$atarget":'')).'>';
								$title=$menus[$j]['titre'];
								// To remove & and special chars: $title=dol_string_unaccent(dol_string_nospecial(dol_html_entity_decode($menus[$j]['titre'],ENT_QUOTES,'UTF-8'),'',array('&')));
								print_text_menu_entry($title);
								if (empty($menus[$j+1]['level'])) print '</a>';
							}

							if ($menus[$j]['level'] > 0)
							{
								if ($menus[$j-1]['level'] == 0) print_start_submenu_array();

								print_start_menu_entry();
								print '<a href="'.$url.'"'.($menus[$j]['atarget']?" target='".$menus[$j]['atarget']."'":($atarget?" target=$atarget":'')).'>';
								$title=$menus[$j]['titre'];
								// To remove & and special chars: $title=dol_string_unaccent(dol_string_nospecial(dol_html_entity_decode($menus[$j]['titre'],ENT_QUOTES,'UTF-8'),'',array('&')));
								print_text_menu_entry($title);
								print '</a>';
								print_end_menu_entry();

								if (empty($menus[$j+1]['level'])) print_end_menu();
							}

							if (empty($menus[$j+1]['level'])) print_end_menu_entry();
						}

                    	if ($num > 0) print_end_menu();
					}
					else
					{
						$url=dol_buildpath($newTabMenu[$i]['url'],1);
						$url=preg_replace('/&amp.*/i','',$url);

						print '<a href="'.$url.'"'.($newTabMenu[$i]['atarget']?" target='".$newTabMenu[$i]['atarget']."'":($atarget?" target=$atarget":'')).'>';
						$title=$newTabMenu[$i]['titre'];
						// To remove & and special chars: $title=dol_string_unaccent(dol_string_nospecial(dol_html_entity_decode($newTabMenu[$i]['titre'],ENT_QUOTES,'UTF-8'),'',array('&')));
						print_text_menu_entry($title);
						print '</a>';
					}

					print_end_menu_entry();
				}
			}
		}
	}

	print_end_menu();
	print "\n";
}

function print_start_menu_array($theme='c')
{
	print '<ul data-role="listview" data-theme="'.$theme.'">';
	print "\n";
}

function print_start_submenu_array()
{
	print '<ul>';
	print "\n";
}

function print_start_menu_entry()
{
	print '<li>';
}

function print_text_menu_entry($text)
{
	print $text;
}

function print_end_menu_entry()
{
	print '</li>';
	print "\n";
}

function print_end_menu()
{
	print '</ul>';
	print "\n";
}

?>
Back to Top