XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
twop6functions.class.php
Go to the documentation of this file.
1 <?php
2 /*
3 Theme name: Two Point Six
4 Theme URI: http://www.redmexico.com.mx
5 Version: 1.0
6 Author: bitcero
7 Author URI: http://www.bitcero.info
8 */
9 
11 {
15  public function currentModuleMenu($m=''){
16 
18 
19  if(!is_a($xoopsModule, 'XoopsModule')){
20  return false;
21  } else {
23  }
24  // Check user
25  if(!is_a($xoopsUser, 'XoopsUser')) return false;
26 
27  if(!$xoopsUser->isAdmin($mod->mid())) return false;
28 
29  $amenu = $mod->getAdminMenu();
30  $amenu = RMEvents::get()->run_event('rmcommon.current.module.menu', $amenu);
31  if ($amenu){
32  foreach ($amenu as $menu){
33  if(isset($menu['icon']) && $menu['icon']!=''){
34  if(preg_match("/^http.*/", $menu['icon']))
35  $icon = $menu['icon'];
36  else{
37  $m = array();
38 
39  $icon = XOOPS_URL.'/modules/'.$xoopsModule->dirname().'/'.(preg_match("/^(\.\.\/){2,}/", $menu['icon']) ? $menu['icon'] : preg_replace("/^\.\.\/{1}/",'', $menu['icon']));
40  }
41  } else {
42  $icon = '';
43  }
44 
45  $rmTpl->add_menu(
46  $menu['title'],
47  strpos($menu['link'], 'http://')!==FALSE && strpos($menu['link'], 'ftp://')!==FALSE ? $menu['link'] : XOOPS_URL.'/modules/'.$mod->getVar('dirname','n').'/'.$menu['link'],
48  $icon,
49  !empty($menu['class']) ? $menu['class'] : '',
50  isset($menu['location']) ? $menu['location'] : '',
51  isset($menu['options']) ? $menu['options'] : array()
52  );
53  //$rmTpl->add_tool($menu['title'], $menu['link'], isset($menu['icon']) ? $menu['icon'] : '');
54  }
55  }
56 
57  if($mod->hasconfig()){
58  $rmTpl->add_menu(__('Settings','rmcommon'), XOOPS_URL.'/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod='.$mod->mid(), 'option','');
59  }
60 
61  }
62 
66  public function moduleMenu($m){
67 
68  global $xoopsModule, $xoopsUser;
69 
70  if(!is_a($xoopsModule, 'XoopsModule')){
72  } else {
73  if($xoopsModule->dirname()==$m)
74  $mod = $xoopsModule;
75  else
77  }
78 
79  if(!is_a($mod, 'XoopsModule')) return false;
80 
81  // Check user
82  if(!is_a($xoopsUser, 'XoopsUser')) return false;
83 
84  if(!$xoopsUser->isAdmin($mod->mid())) return false;
85 
86  $amenu = $mod->getAdminMenu();
87  $amenu = RMEvents::get()->run_event($mod->dirname().'.module.menu', $amenu);
88  if(empty($amenu)) return false;
89 
90  $return_menu = array();
91 
92  foreach ($amenu as $menu){
93  $return_menu[] = array(
94  'title' => $menu['title'],
95  'link' => strpos($menu['link'], 'http://')!==FALSE && strpos($menu['link'], 'ftp://')!==FALSE ? $menu['link'] : XOOPS_URL.'/modules/'.$mod->getVar('dirname','n').'/'.$menu['link'],
96  'icon' => isset($menu['icon']) ? (strpos($menu['icon'], 'http://')!==FALSE ? $menu['icon'] : XOOPS_URL.'/modules/'.$mod->dirname().'/'.$menu['icon']) : '',
97  'location' => isset($menu['location']) ? $menu['location'] : '',
98  'options' => isset($menu['options']) ? self::moduleSubmenu($menu['options'], $mod) : null
99  );
100  }
101 
102  if($mod->hasconfig()){
103  $return_menu[] = array(
104  'title' => __('Settings','rmcommon'),
105  'link' => XOOPS_URL.'/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod='.$mod->mid(),
106  'icon' => '',
107  'type' => 1
108  );
109  }
110 
111  return $return_menu;
112 
113  }
114 
118  public function moduleSubmenu($submenu, $mod){
119 
120  if(!is_array($submenu)) return array();
121 
122  foreach($submenu as $i => $menu){
123  $submenu[$i]['link'] = strpos($menu['link'], 'http://')!==FALSE && strpos($menu['link'], 'ftp://')!==FALSE ? $menu['link'] : XOOPS_URL.'/modules/'.$mod->getVar('dirname','n').'/'.$menu['link'];
124  }
125 
126  return $submenu;
127 
128  }
129 
130 
134  public function moduleIcon($module, $size = '16'){
135 
136  global $xoopsModule;
137 
138  $available = array(
139  'mylinks' => 'xicon-link',
140  'news' => 'xicon-consulting',
141  'contact' => 'xicon-email',
142  'extgallery' => 'xicon-picture',
143  'date' => 'xicon-date',
144  'fmcontent' => 'xicon-library',
145  'marquee' => 'xicon-advertising',
146  'mastop_go2' => 'xicon-cloud',
147  'moduleinstaller' => 'xicon-download',
148  'pm' => 'xicon-comment',
149  'profile' => 'xicon-profile',
150  'protector' => 'xicon-shield',
151  'tag' => 'xicon-tag',
152  'xforms' => 'xicon-form',
153  'xlanguage' => 'xicon-comment',
154  'xoopsfaq' => 'xicon-faq',
155  'xoopspartners' => 'xicon-me',
156  'system' => 'xicon-gear'
157  );
158 
159  if(!is_a($xoopsModule, 'XoopsModule')) return false;
160 
161  if($xoopsModule->dirname()!=$module){
162  $mod = RMFunctions::load_module($module);
163  } else {
164  $mod = $xoopsModule;
165  }
166 
167  if(isset($available[$mod->dirname()]))
168  return '<i class="xo-icon '.$available[$mod->dirname()].'"></i> ';
169 
170  $icon = $mod->getInfo('icon'.$size);
171  $path = XOOPS_ROOT_PATH.'/modules/'.$mod->dirname().'/'.$icon;
172  if(!is_file($path)){
173  $path = TWOP6_PATH.'/images/modules/'.$mod->dirname().'-'.$size.'.png';
174 
175  if(!is_file($path))
176  $path = TWOP6_PATH.'/images/module.png';
177 
178  }
179 
180  $icon = str_replace(XOOPS_ROOT_PATH, XOOPS_URL, $path);
181 
182  return '<i class="xo-icon" style="background-image: url('.$icon.');"></i> ';
183 
184  }
185 
189  public function extra_headers(){
190  global $xoopsModule;
191 
192  if($xoopsModule->dirname()=='rmcommon'
193  && RMCLOCATION=='modules'
194  && rmc_server_var($_REQUEST, 'action', '')==''){
195 
196  include DESIGNIA_PATH.'/include/sorter.inc';
197 
198  }
199  }
200 
204  public function getIcon($menu){
205  global $xoopsModule;
206 
207  // Icon equivalences
208  $accepted = array(
209  'dashboard' => 'xicon-home',
210  'modules' => 'xicon-plus',
211  'blocks' => 'xicon-block',
212  'users' => 'xicon-user',
213  'imgmanager' => 'xicon-picture',
214  'comments' => 'xicon-comment',
215  'plugins' => 'xicon-plugin',
216  'avatars' => 'xicon-account',
217  'banners' => 'xicon-offer',
218  'blocksadmin' => 'xicon-block',
219  'groups' => 'xicon-users',
220  'images' => 'xicon-picture',
221  'mailusers' => 'xicon-email',
222  'modulesadmin' => 'xicon-plus',
223  'maintenance' => 'xicon-publish',
224  'preferences' => 'xicon-settings',
225  'smilies' => 'xicon-smile',
226  'tplsets' => 'xicon-invoice',
227  'userrank' => 'xicon-star',
228  'allusers' => 'xicon-users',
229  'newuser' => 'xicon-plus',
230  'rmc_imgcats' => 'xicon-category',
231  'rmc_imgnewcat' => 'xicon-addfolder',
232  'rmc_images' => 'xicon-picture',
233  'rmc_newimages' => 'xicon-addpicture',
234  'updates' => 'xicon-refresh',
235  );
236 
237  if(isset($menu['type']))
238  return '<i class="xo-icon xicon-settings"></i> ';
239 
240  if (isset($menu['location']) && isset($accepted[$menu['location']]))
241  return '<i class="xo-icon '.$accepted[$menu['location']].'"></i> ';
242 
243  if(isset($menu['selected']) && isset($accepted[$menu['selected']]))
244  return '<i class="xo-icon '.$accepted[$menu['selected']].'"></i> ';
245 
246  $modurl = XOOPS_URL.'/modules/'.$xoopsModule->dirname().'/';
247 
248  if(isset($menu['icon']) && $menu['icon']!='')
249  return '<i class="xo-icon" style="background-image: url('.preg_replace("/^[\.]+/",'',$menu['icon']).'); background-size: 16px 16px;"></i> ';
250 
251  // Check system menu
252  $matches = array();
253  preg_match("/.*admin\.php\?fct=(.*)/", $menu['link'], $matches);
254 
255  if (!empty($matches) && isset($accepted[$matches[1]]))
256  return '<i class="xo-icon '.$accepted[$matches[1]].'"></i> ';
257 
258  }
259 
260 }