XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
tpl_functions.php
Go to the documentation of this file.
1 <?php
2 // $Id: tpl_functions.php 949 2012-04-14 04:18:10Z i.bitcero $
3 // --------------------------------------------------------------
4 // EXM System
5 // Content Management System
6 // Author: Eduardo Cortés <i.bitcero@gmail.com>
7 // Email: bitc3r0@gmail.com
8 // License: GPL 2.0
9 // --------------------------------------------------------------
10 
14 function tpl_cycle($values, $delimiter = ',', $reset = false){
15  static $cycle_index;
16 
17  if (trim($values)=='') {
18  return;
19  }
20 
21  if(is_array($values)) {
22  $cycle_array = $values;
23  } else {
24  $cycle_array = explode($delimiter,$values);
25  }
26 
27  if(!isset($cycle_index) || $reset) {
28  $cycle_index = 0;
29  }
30 
31  $retval = $cycle_array[$cycle_index];
32 
33  if ( $cycle_index >= count($cycle_array) -1 ) {
34  $cycle_index = 0;
35  } else {
36  $cycle_index++;
37  }
38 
39  return $retval;
40 }
41 
45 function xoops_cp_location($location){
46  RMTemplate::get()->assign('admin_location', $location);
47 }
48 
56 function redirectMsg($url, $msg='', $level=5, $icon=''){
57  $i = isset($_SESSION['rmMsg']) ? count($_SESSION['rmMsg']) + 1 : 0;
58  $_SESSION['rmMsg'][$i]['text'] = htmlentities($msg);
59  $_SESSION['rmMsg'][$i]['level'] = $level;
60  header('location: '.preg_replace("/[&]amp;/i", '&', $url));
61  die();
62 }
63 
71 function rmc_server_var($from, $key, $default=''){
72  $ret = isset($from[$key]) ? $from[$key] : $default;
73  return $ret;
74 }
75 
76 function showMessage($msg, $level=0){
77  $_SESSION['rmMsg'][] = array(
78  'text' => htmlentities($msg),
79  'level' => $level
80  );
81 }