11 include_once
RMCPATH.
'/include/tpl_functions.php';
71 if (!function_exists(
"xoops_cp_header") && !$rmc_config[
'jquery'])
return;
72 $this->version = str_replace(
" ",
'-',
RMCVERSION);
82 public function get(){
85 if (!isset($instance)) {
106 $theme = isset($rmc_config[
'theme']) ? $rmc_config[
'theme'] :
'default';
108 if (!file_exists(
RMCPATH.
'/themes/'.$theme.
'/admin_gui.php')){
112 $rm_theme_url =
RMCURL.
'/themes/'.$theme;
115 $rmc_messages = array();
116 if (isset($_SESSION[
'rmMsg'])){
117 foreach ($_SESSION[
'rmMsg'] as $msg){
118 $rmc_messages[] = $msg;
120 unset($_SESSION[
'rmMsg']);
123 include_once
RMCPATH.
'/themes/'.$theme.
'/admin_gui.php';
124 $output = ob_get_clean();
126 $output =
RMEvents::get()->run_event(
'rmcommon.admin.output', $output);
145 if (!function_exists(
"xoops_cp_header")){
147 $theme = $xoopsConfig[
'theme_set'];
148 $where = XOOPS_THEME_PATH.
'/'.$theme;
149 $where .=
$type==
'module' ?
'/modules/' :
'/'.$plugin.
's/';
150 $where .= $module.($plugin!=
'' ?
'/'.$plugin :
'');
152 if(is_file($where.
'/'.
$file))
return $where.
'/'.
$file;
154 $where = XOOPS_ROOT_PATH.
'/modules/'.$module.
'/templates';
155 $where .=
$type!=
'module' ?
"/$type" :
'';
159 if(is_file($where))
return $where;
163 $theme = isset($rmc_config[
'theme']) ? $rmc_config[
'theme'] :
'default';
165 $where =
$type==
'module' ?
'modules/'.$module : (
$type==
'plugin' ? $module.
'/'.$plugin :
'modules/rmcommon');
167 $lpath =
RMCPATH.
'/themes/'.$theme.
'/'.$where.
'/'.
$file;
169 if (!is_dir(
RMCPATH.
'/themes/'.$theme)){
173 if (file_exists($lpath))
176 if (
$type==
'plugin'){
179 return XOOPS_ROOT_PATH.
'/'.$where.
'/templates/'.
$file;
193 $theme = $xoopsConfig[
'theme_set'];
194 $subdir = $subdir ==
'' ?
'templates' : $subdir;
196 if(!is_dir(XOOPS_ROOT_PATH.
'/modules/'.$module))
return;
198 $tpath = XOOPS_THEME_PATH.
'/'.$theme.
'/modules/'.$module.
'/'.($subdir!=
'templates'?$subdir.
'/':
'').
$file;
203 return XOOPS_ROOT_PATH.
'/modules/'.$module.
'/'.$subdir.
'/'.
$file;
225 public function help($single = 0){
227 return $this->help_link[0][
'link'];
233 $this->help_link[] = array(
234 'caption' => $caption,
245 $this->messages[] = array(
'text'=>$message,
'level'=>$level);
262 if (is_array($head)):
263 array_merge($this->tpl_head, $head);
265 $this->tpl_head[] = $head;
286 if (strpos(
$url,
"?")>1){
287 if (strpos(
$url,
'ver=')===FALSE){
288 $url .=
"&ver=".$this->version;
291 $url .=
"?ver=".$this->version;
295 if (isset($this->tpl_scripts[
$id]))
return;
297 $this->tpl_scripts[
$id] = array(
'url'=>
$url,
'type'=>
$type,
'footer'=>$footer);
305 $this->tpl_hscripts[] = $script;
312 $ret =
'<script type="text/javascript">'.
"\n";
314 foreach($this->tpl_hscripts as $script){
316 $ret .= $script.
"\n";
317 $ret .=
"//".str_repeat(
"-",20).
"\n";
333 if(
$file==
'jquery.min.js' && $element==
'rmcommon' && !$rmc_config[
'jquery'])
return;
336 $url = XOOPS_URL.
'/modules/'.$element.
'/'.$subfolder.
'/js/'.
$file;
338 if (strpos(
$url,
"?")>1){
339 if (strpos(
$url,
'ver=')===FALSE){
340 $url .=
"&ver=".$this->version;
343 $url .=
"?ver=".$this->version;
348 if (isset($this->tpl_scripts[
$id]))
return;
350 if (!defined(
'XOOPS_CPFUNC_LOADED')){
351 $theme = isset($xoopsConfig[
'theme_set']) ? $xoopsConfig[
'theme_set'] :
'default';
352 $themepath = XOOPS_THEME_PATH.
'/'.$theme;
353 $themeurl = XOOPS_THEME_URL.
'/'.$theme;
355 $theme = isset($rmc_config[
'theme']) ? $rmc_config[
'theme'] :
'default';
356 $themepath =
RMCPATH.
'/themes/'.$theme;
357 $themeurl =
RMCURL.
'/themes/'.$theme;
360 $theme_file = $themepath.
'/js/'.$element.($element!=
'' ?
'/' :
'').($subfolder!=
'' ? $subfolder.
'/' :
'').$file;
362 if (is_file($theme_file)){
363 $url = $themeurl.
'/js/'.($element!=
'' ? $element.
'/' :
'').($subfolder!=
'' ? $subfolder.
'/' :
'').$file;
365 $url = XOOPS_URL.
'/'.($element!=
'' ?
'modules/'.$element.
'/' :
'').($subfolder!=
'' ? $subfolder.
'/' :
'').
'js/'.
$file;
368 if (strpos(
$url,
"?")>1){
369 if (strpos(
$url,
'ver=')===FALSE){
370 $url .=
"&ver=".$this->version;
373 $url .=
"?ver=".$this->version;
376 $this->tpl_scripts[
$id] = array(
'url'=>
$url,
'type'=>
$type,
'more'=>$more,
'footer' => $footer);
380 public function add_theme_script($script, $theme=
'', $subfolder=
'',
$type=
'text/javascript', $more=
'', $footer =
false){
383 if(defined(
'XOOPS_CPFUNC_LOADED')){
385 $theme = $theme==
'' ? $rmc_config[
'theme'] : $theme;
386 $file =
RMCPATH.
'/themes/'.$theme.
'/js/'.($subfolder!=
''?$subfolder.
'/':
'').$script;
391 $theme = $theme==
'' ? $xoopsConfig[
'theme_set'] :$theme;
392 $file = XOOPS_THEME_PATH.
'/'.$theme.
'/js/'.($subfolder!=
''?$subfolder.
'/':
'').$script;
393 $url = str_replace(XOOPS_THEME_PATH, XOOPS_THEME_URL,
$file);
397 $id = crc32($script.$theme.$subfolder.$type.$more);
399 if(!file_exists(
$file))
return;
401 if (strpos(
$url,
"?")>1){
402 if (strpos(
$url,
'ver=')===FALSE){
403 $url .=
"&ver=".$this->version;
406 $url .=
"?ver=".$this->version;
409 $this->tpl_scripts[
$id] = array(
423 if(!$rmc_config[
'jquery'])
return;
428 $this->
add_script(
"http://code.jquery.com/jquery-latest.js");
438 $this->tpl_scripts =
$ev->run_event(
'rmcommon.get.scripts',$this->tpl_scripts);
446 $this->tpl_scripts = array();
456 $this->
add_script($script[
'url'], $script[
'type']);
465 public function add_style($sheet, $element=
'rmcommon', $subfolder=
'', $media=
'all', $more=
'', $front =
false, $footer =
false){
468 $id = crc32($sheet.$element.$subfolder.$media.$more);
470 if (isset($this->tpl_styles[
$id]))
return;
472 if (!function_exists(
"xoops_cp_header")){
473 $theme = isset($xoopsConfig[
'theme_set']) ? $xoopsConfig[
'theme_set'] :
'default';
474 $themepath = XOOPS_THEME_PATH.
'/'.$theme;
475 $themeurl = XOOPS_THEME_URL.
'/'.$theme;
477 $theme = isset($rmc_config[
'theme']) ? $rmc_config[
'theme'] :
'default';
478 $themepath =
RMCPATH.
'/themes/'.$theme;
479 $themeurl =
RMCURL.
'/themes/'.$theme;
482 $theme_file = $themepath.
'/css/'.$element.($element!=
'' ?
'/' :
'').($subfolder!=
'' ? $subfolder.
'/' :
'').$sheet;
484 if (is_file($theme_file)){
485 $url = $themeurl.
'/css/'.($element!=
'' ? $element.
'/' :
'').($subfolder!=
'' ? $subfolder.
'/' :
'').$sheet;
487 $url = XOOPS_URL.
'/'.($element!=
'' ?
'modules/'.$element.
'/' :
'').($subfolder!=
'' ? $subfolder.
'/' :
'').
'css/'.$sheet;
490 if (strpos(
$url,
"?")>1){
491 if (strpos(
$url,
'ver=')===FALSE){
492 $url .=
"&ver=".$this->version;
495 $url .=
"?ver=".$this->version;
498 $this->tpl_styles[
$id] = array(
511 public function add_xoops_style($sheet, $element=
'rmcommon', $subfolder=
'', $media=
'all', $more=
'', $footer =
false){
513 $this->
add_style($sheet, $element, $subfolder, $media, $more,
true, $footer);
525 public function add_theme_style($sheet, $theme=
'', $subfolder=
'', $media=
'all', $more=
'', $footer=
false){
528 if(defined(
'XOOPS_CPFUNC_LOADED') && is_dir(
RMCPATH.
'/themes/'.$theme)){
530 $theme = $theme==
'' ? $rmc_config[
'theme'] : $theme;
531 $file =
RMCPATH.
'/themes/'.$theme.
'/css/'.($subfolder!=
''?$subfolder.
'/':
'').$sheet;
536 $theme = $theme==
'' ? $xoopsConfig[
'theme_set'] :$theme;
537 $file = XOOPS_THEME_PATH.
'/'.$theme.
'/css/'.($subfolder!=
''?$subfolder.
'/':
'').$sheet;
538 $url = str_replace(XOOPS_THEME_PATH, XOOPS_THEME_URL,
$file);
542 $id = crc32($sheet.$theme.$subfolder.$media.$more);
544 if(!file_exists(
$file))
return;
546 if (strpos(
$url,
"?")>1){
547 if (strpos(
$url,
'ver=')===FALSE){
548 $url .=
"&ver=".$this->version;
551 $url .=
"?ver=".$this->version;
554 $this->tpl_styles[
$id] = array(
567 public function style_url($sheet, $element=
'rmcommon', $subfolder=
''){
570 if(defined(
'XOOPS_CPFUNC_LOADED')){
572 $theme = isset($rmc_config[
'theme']) ? $rmc_config[
'theme'] :
'twop6';
573 $file =
RMCPATH.
'/themes/'.$theme.
'/css/'.($element!=
'' ? $element :
'rmcommon').
'/'.($subfolder!=
''?$subfolder.
'/':
'').$sheet;
578 $theme = $xoopsConfig[
'theme_set'];
579 $file = XOOPS_THEME_PATH.
'/'.$theme.
'/css/'.($subfolder!=
''?$subfolder.
'/':
'').$sheet;
580 $url = str_replace(XOOPS_THEME_PATH, XOOPS_THEME_URL,
$file);
584 if (!is_file(
$file)){
585 $url = XOOPS_URL.
'/'.($element!=
'' ?
'modules/'.$element.
'/' :
'').($subfolder!=
'' ? $subfolder.
'/' :
'').
'css/'.$sheet;
588 if (strpos(
$url,
"?")>1){
589 if (strpos(
$url,
'ver=')===FALSE){
590 $url .=
"&ver=".$this->version;
593 $url .=
"?ver=".$this->version;
604 $this->tpl_styles =
$ev->run_event(
'rmcommon.get.styles',$this->tpl_styles);
611 $this->tpl_styles = array();
617 if (!is_array(
$styles))
return;
621 $this->
add_style($style[
'sheet'], $style[
'system'], $style[
'subfolder'], $style[
'media'], $style[
'more']);
630 public function assign($varname, $value){
631 $this->tpl_vars[$varname] = $value;
638 public function append($varname, $value){
639 $this->tpl_vars[$varname][] = $value;
654 if (isset($this->tpl_vars[$varname])){
655 return $this->tpl_vars[$varname];
671 if ($caption==
'' || $link==
'')
return;
675 if (isset($this->tpl_menus[
$id]))
return;
677 $this->tpl_menus[
$id] = array(
'caption'=>$caption,
'link'=>$link,
'icon'=>$icon,
'class'=>
$class,
'target'=>
$target,
'type'=>
'normal');
681 $this->tpl_menus = array(
'type'=>
'separator');
688 $this->tpl_menus =
RMEvents::get()->run_event(
'rmcommon.menus_options',$this->tpl_menus, $this);
697 $this->menus[] = array(
702 'location' => $location,
711 public function add_tool($title, $link, $icon=
'', $location=
''){
712 $this->toolbar[] = array(
716 'location' => $location