Project

General

Profile

« Previous | Next » 

Revision 1535

Added by Dietmar over 12 years ago

! changes in code modul
+ add function getTableEngine to class.database
+ add Quickskin to include folder
+ add reworkes Droplet SectionPicker to load modules frontend.css

View differences:

branches/2.8.x/CHANGELOG
11 11
! = Update/Change
12 12

  
13 13
=========================== add small Features 2.8.2 ==========================
14
10 Dez-2011 Build 1535 Dietmar Woellbrink (Luisehahne)
15
! changes in code modul
16
+ add function getTableEngine to class.database 
17
+ add Quickskin to include folder
18
+ add reworkes Droplet SectionPicker to load modules frontend.css
14 19
08 Dez-2011 Build 1534 Werner v.d.Decken(DarkViper)
15 20
# /output_filter/filter-routines.php rel-URL Filter fixed for mailto-links
16 21
08 Dez-2011 Build 1533 Dietmar Woellbrink (Luisehahne)
branches/2.8.x/wb/include/quickSkin/class.quickskindebugger.php
1
<?php
2
/*~ class.quickskindebugger.php
3
.---------------------------------------------------------------------------.
4
|  Software: QuickSkinDebugger Class * Used by QuickSkin Class              |
5
|   Version: 5.0                                                            |
6
|   Contact: andy.prevost@worxteam.com,andy@codeworx.ca                     |
7
|      Info: http://quickskin.sourceforge.net                               |
8
|   Support: http://sourceforge.net/projects/quickskin/                     |
9
| ------------------------------------------------------------------------- |
10
|    Author: Andy Prevost andy.prevost@worxteam.com (admin)                 |
11
|    Author: Manuel 'EndelWar' Dalla Lana endelwar@aregar.it (former admin) |
12
|    Author: Philipp v. Criegern philipp@criegern.com (original founder)    |
13
| Copyright (c) 2002-2009, Andy Prevost. All Rights Reserved.               |
14
|    * NOTE: QuickSkin is the SmartTemplate project renamed. SmartTemplate  |
15
|            information and downloads can still be accessed at the         |
16
|            smarttemplate.sourceforge.net site                             |
17
| ------------------------------------------------------------------------- |
18
|   License: Distributed under the Lesser General Public License (LGPL)     |
19
|            http://www.gnu.org/copyleft/lesser.html                        |
20
| This program is distributed in the hope that it will be useful - WITHOUT  |
21
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or     |
22
| FITNESS FOR A PARTICULAR PURPOSE.                                         |
23
| ------------------------------------------------------------------------- |
24
| We offer a number of paid services:                                       |
25
| - Web Hosting on highly optimized fast and secure servers                 |
26
| - Technology Consulting                                                   |
27
| - Oursourcing (highly qualified programmers and graphic designers)        |
28
'---------------------------------------------------------------------------'
29
Last modified: January 01 2009 ~*/
30

  
31
/* designed to work with PHP5 - will NOT work with PHP4 */
32

  
33
class QuickSkinDebugger {
34

  
35
  /* The template Filename
36
   * @access private
37
   */
38
  private $filename;
39

  
40
  /* The template itself
41
   * @access private
42
   */
43
  private $template;
44

  
45
  /* Default Left delimiter
46
   * Can be overwritten by global configuration array $_CONFIG['left_delimiter']
47
   * @access public
48
   */
49
  private $left_delimiter =  '{';
50

  
51
  /* Default Right delimiter
52
   * Can be overwritten by global configuration array $_CONFIG['right_delimiter']
53
   * @access public
54
   */
55
  private $right_delimiter =  '}';
56

  
57
  /* QuickSkinDebugger Constructor
58
   * @param string $template_filename HTML Template Filename
59
   */
60
  function __construct( $template_filename, $right_delimiter = '}', $left_delimiter = '{' ) {
61
    $this->filename  =  $template_filename;
62

  
63
    /* Load Template */
64
    if ($hd  =  @fopen($template_filename,  'r')) {
65
      $this->template  =  fread($hd,  filesize($template_filename));
66
      fclose($hd);
67
    } else {
68
      $this->template  =  'QuickSkin Debugger Error: File not found: ' . $template_filename;
69
    }
70
    $this->tab[0]  =  '';
71
    for ($i=1;  $i < 10;  $i++) {
72
      $this->tab[$i]  =  str_repeat('    ', $i);
73
    }
74
    $this->right_delimiter = $right_delimiter;
75
    $this->left_delimiter = $left_delimiter;
76
  }
77

  
78
  /* Main Template Parser
79
   * @param string $compiled_template_filename Compiled Template Filename
80
   * @desc Creates Compiled PHP Template
81
   */
82
  function start ( $vars ) {
83
    $page  =  $this->template;
84

  
85
    $page  =  preg_replace("/(<!-- BEGIN [ a-zA-Z0-9_.]* -->)/",  "\n$1\n",  $page);
86
    $page  =  preg_replace("/(<!-- IF .+? -->)/",  "\n$1\n",  $page);
87
    $page  =  preg_replace("/(<!-- END.*? -->)/",  "\n$1\n",  $page);
88
    $page  =  preg_replace("/(<!-- ELSEIF .+? -->)/",  "\n$1\n",  $page);
89
    $page  =  preg_replace("/(<!-- ELSE [ a-zA-Z0-9_.]*-->)/",  "\n$1\n",  $page);
90

  
91
    $page  =  $this->highlight_html($page);
92

  
93
    $rows      =  explode("\n",  $page);
94
    $page_arr  =  array();
95
    $level     =  0;
96
    $blocklvl  =  0;
97
    $rowcnt    =  0;
98
    $spancnt   =  0;
99
    $offset    =  22;
100
    $lvl_block =  array();
101
    $lvl_row   =  array();
102
    $lvl_typ   =  array();
103
    foreach ($rows as $row) {
104
      if ($row  =  trim($row)) {
105
        $closespan  =  false;
106
        if (substr($row, $offset, 12) == '&lt;!-- END ') {
107
          if ($level < 1) {
108
            $level++;
109
            $error[$rowcnt]  =  'END Without BEGIN';
110
          } elseif ($lvl_typ[$level] != 'BEGIN') {
111
            $error[$lvl_row[$level]]  =  'IF without ENDIF';
112
            $error[$rowcnt]  =  'END Without BEGIN';
113
          }
114
          $blocklvl--;
115
          $level--;
116
          $closespan  =  true;
117
        }
118
        if (substr($row, $offset, 14) == '&lt;!-- ENDIF ') {
119
          if ($level < 1) {
120
            $level++;
121
            $error[$rowcnt]  =  'ENDIF Without IF';
122
          } elseif ($lvl_typ[$level] != 'IF') {
123
            $error[$lvl_row[$level]]  =  'BEGIN without END';
124
            $error[$rowcnt]  =  'ENDIF Without IF';
125
          }
126
          $closespan  =  true;
127
          $level--;
128
        }
129
        if ($closespan) {
130
          $page_arr[$rowcnt-1]  .=  '</span>';
131
        }
132
        $this_row  =  $this->tab[$level] . $row;
133
        if (substr($row, $offset, 12) == '&lt;!-- ELSE') {
134
          if ($level < 1) {
135
            $error[$rowcnt]  =  'ELSE Without IF';
136
          } elseif ($lvl_typ[$level] != 'IF') {
137
            $error[$rowcnt]  =  'ELSE Without IF';
138
          } else {
139
            $this_row  =  $this->tab[$level-1] . $row;
140
          }
141
        }
142
        if (substr($row, $offset, 14) == '&lt;!-- BEGIN ') {
143
          if ($blocklvl == 0) {
144
            if ($lp = strpos($row, '--&gt;')) {
145
              if ($blockname  =  trim(substr($row, $offset + 14, $lp -$offset -14))) {
146
                if ($nr = count($vars[$blockname])) {
147
                  $this_row  .=  $this->toggleview($nr . ' Entries');
148
                } else {
149
                  $this_row  .=  $this->toggleview('Emtpy');
150
                }
151
              }
152
            }
153
          } else {
154
            $this_row  .=  $this->toggleview('[');
155
          }
156
          $blocklvl++;
157
          $level++;
158
          $lvl_row[$level]  =  $rowcnt;
159
          $lvl_typ[$level]  =  'BEGIN';
160
        } elseif (substr($row, $offset, 11) == '&lt;!-- IF ') {
161
          $level++;
162
          $lvl_row[$level]  =  $rowcnt;
163
          $lvl_typ[$level]  =  'IF';
164
          $this_row  .=  $this->toggleview();
165
        }
166
        $page_arr[]  =  $this_row;
167
        $lvl_block[$rowcnt]  =  $blocklvl;
168
        $rowcnt++;
169
      }
170
    }
171
    if ($level > 0) {
172
      $error[$lvl_row[$level]]  =  'Block not closed';
173
    }
174

  
175
    $page  =  join("\n", $page_arr);
176
    $rows  =  explode("\n",  $page);
177
    $cnt   =  count($rows);
178

  
179
    for ($i = 0;  $i < $cnt;  $i++) {
180
      /* Add Errortext */
181
      if (isset($error)) {
182
        if ($err = $error[$i]) {
183
          $rows[$i]  =  '<b>' . $rows[$i] . '        ERROR: ' . $err . '!</b>';
184
        }
185
      }
186

  
187
      /* Replace Scalars */
188
      $right_delimiter = preg_quote($this->right_delimiter);
189
      $left_delimiter = preg_quote($this->left_delimiter);
190
      if (preg_match_all("/$left_delimiter([a-zA-Z0-9_. &;]+)$right_delimiter/", $rows[$i], $var)) {
191
        foreach ($var[1] as $tag) {
192
          $fulltag  =  $tag;
193
          if ($delim = strpos($tag, ' &gt; ')) {
194
            $tag  =  substr($tag, 0, $delim);
195
          }
196
          if (substr($tag, 0, 4) == 'top.') {
197
            $title  =  $this->tip($vars[substr($tag, 4)]);
198
          } elseif ($lvl_block[$i] == 0) {
199
            $title  =  $this->tip($vars[$tag]);
200
          } else {
201
            $title  =  '[BLOCK?]';
202
          }
203
          $code  =  '<b title="' . $title . '">' . $left_delimiter . $fulltag . $right_delimiter . '</b>';
204
          $rows[$i]  =  str_replace('{'.$fulltag.'}',  $code,  $rows[$i]);
205
        }
206
      }
207

  
208
      /* Replace Extensions */
209
      if (preg_match_all("/$left_delimiter([a-zA-Z0-9_]+):([^}]*)$right_delimiter/", $rows[$i], $var)) {
210
        foreach ($var[2] as $tmpcnt => $tag) {
211
          $fulltag  =  $tag;
212
          if ($delim = strpos($tag, ' &gt; ')) {
213
            $tag  =  substr($tag, 0, $delim);
214
          }
215
          if (strpos($tag, ',')) {
216
            list($tag, $addparam)  =  explode(',', $tag, 2);
217
          }
218
          $extension  =  $var[1][$tmpcnt];
219

  
220
          if (substr($tag, 0, 4) == 'top.') {
221
            $title  =  $this->tip($vars[substr($tag, 4)]);
222
          } elseif ($lvl_block[$i] == 0) {
223
            $title  =  $this->tip($vars[$tag]);
224
          } else {
225
            $title  =  '[BLOCK?]';
226
          }
227
          $code  =  '<b title="' . $title . '">' . $this->left_delimiter . $extension . ':' . $fulltag . $this->right_delimiter . '</b>';
228
          $rows[$i]  =  str_replace($this->left_delimiter . $extension . ':' . $fulltag . $this->right_delimiter,  $code,  $rows[$i]);
229
        }
230
      }
231

  
232
      /* 'IF nnn' Blocks */
233
      if (preg_match_all('/&lt;!-- IF ([a-zA-Z0-9_.]+) --&gt;/', $rows[$i], $var)) {
234
        foreach ($var[1] as $tag) {
235
          if (substr($tag, 0, 4) == 'top.') {
236
            $title  =  $this->tip($vars[substr($tag, 4)]);
237
          } elseif ($lvl_block[$i] == 0) {
238
            $title  =  $this->tip($vars[$tag]);
239
          } else {
240
            $title  =  '[BLOCK?]';
241
          }
242
          $code  =  '<span title="' . $title . '">&lt;!-- IF ' . $tag . ' --&gt;</span>';
243
          $rows[$i]  =  str_replace("&lt;!-- IF $tag --&gt;",  $code,  $rows[$i]);
244
          if ($title == '[NULL]') {
245
            $rows[$i]  =  str_replace('Hide',  'Show',  $rows[$i]);
246
            $rows[$i]  =  str_replace('block',  'none',  $rows[$i]);
247
          }
248
        }
249
      }
250
    }
251
    $page  =  join('<br>', $rows);
252

  
253
    /* Print Header */
254
    echo '<html><head><script type="text/javascript">
255
        function toggleVisibility(el, src) {
256
        var v = el.style.display == "block";
257
        var str = src.innerHTML;
258
        el.style.display = v ? "none" : "block";
259
        src.innerHTML = v ? str.replace(/Hide/, "Show") : str.replace(/Show/, "Hide");}
260
        </script></head><body>';
261

  
262
    /* Print Index */
263
    echo '<font face="Arial" Size="3"><b>';
264
    echo 'QuickSkin Debugger<br>';
265
    echo '<font size="2"><li>PHP-Script: ' . $_SERVER['SCRIPT_FILENAME'] . '</li><li>Template: ' . $this->filename . '</li></font><hr>';
266
    echo '<li><a href="#template_code">Template</a></li>';
267
    echo '<li><a href="#compiled_code">Compiled Template</a></li>';
268
    echo '<li><a href="#data_code">Data</a></li>';
269
    echo '</b></font><hr>';
270

  
271
    /* Print Template */
272
    echo '<a name="template_code"><br><font face="Arial" Size="3"><b>Template:</b>&nbsp;[<a href="javascript:void(\'\');" onclick="toggleVisibility(document.getElementById(\'Template\'), this); return false">Hide Ouptut</a>]</font><br>';
273
    echo '<table border="0" cellpadding="4" cellspacing="1" width="100%" bgcolor="#C6D3EF"><tr><td bgcolor="#F0F0F0"><pre id="Template" style="display:block">';
274
    echo $page;
275
    echo '</pre></td></tr></table>';
276

  
277
    /* Print Compiled Template */
278
    if (@include_once ("class.quickskinparser.php")) {
279
      $parser = new QuickSkinParser($this->filename);
280
      $compiled  =  $parser->compile();
281
      echo '<a name="compiled_code"><br><br><font face="Arial" Size="3"><b>Compiled Template:</b>&nbsp;[<a href="javascript:void(\'\');" onclick="toggleVisibility(document.getElementById(\'Compiled\'), this); return false">Hide Ouptut</a>]</font><br>';
282
      echo '<table border="0" cellpadding="4" cellspacing="1" width="100%" bgcolor="#C6D3EF"><tr><td bgcolor="#F0F0F0"><pre id="Compiled" style="display:block">';
283
      highlight_string($compiled);
284
      echo '</pre></td></tr></table>';
285
    } else {
286
      exit( "QuickSkin Error: Cannot find class.quickskinparser.php; check QuickSkin installation");
287
    }
288

  
289
    /* Print Data */
290
    echo '<a name="data_code"><br><br><font face="Arial" Size="3"><b>Data:</b>&nbsp;[<a href="javascript:void(\'\');" onclick="toggleVisibility(document.getElementById(\'Data\'), this); return false">Hide Ouptut</a>]</font><br>';
291
    echo '<table border="0" cellpadding="4" cellspacing="1" width="100%" bgcolor="#C6D3EF"><tr><td bgcolor="#F0F0F0"><pre id="Data" style="display:block">';
292
    echo $this->vardump($vars);
293
    echo '</pre></td></tr></table></body></html>';
294
  }
295

  
296
  /* Insert Hide/Show Layer Switch
297
   * @param string $suffix Additional Text
298
   * @desc Insert Hide/Show Layer Switch
299
   */
300
  function toggleview ( $suffix = '') {
301
    global $spancnt;
302

  
303
    $spancnt++;
304
    if ($suffix) {
305
      $suffix  .=  ':';
306
    }
307
    $ret =  '[' . $suffix . '<a href="javascript:void(\'\');" onclick="toggleVisibility(document.getElementById(\'Block' . $spancnt . '\'), this); return false">Hide Block</a>]<span id="Block' . $spancnt . '" style="display:block">';
308
    return $ret;
309
  }
310

  
311
  /* Create Title Text
312
   * @param string $value Content
313
   * @desc Create Title Text
314
   */
315
  function tip ( $value ) {
316
    if (empty($value)) {
317
      return '[NULL]';
318
    } else {
319
      $ret = htmlentities(substr($value,0,200));
320
      return $ret;
321
    }
322
  }
323

  
324
  /* Recursive Variable Display Output
325
   * @param mixed $var Content
326
   * @param int $depth Incremented Indent Counter for Recursive Calls
327
   * @return string Variable Content
328
   * @access private
329
   * @desc Recursive Variable Display Output
330
   */
331
    function vardump($var, $depth = 0) {
332
      if (is_array($var)) {
333
        $result  =  "Array (" . count($var) . ")<BR>";
334
        foreach(array_keys($var) as $key) {
335
          $result  .=  $this->tab[$depth] . "<B>$key</B>: " . $this->vardump($var[$key],  $depth+1);
336
        }
337
        return $result;
338
      } else {
339
        $ret =  htmlentities($var) . '<BR>';
340
        return $ret;
341
      }
342
    }
343

  
344
  /* Splits Template-Style Variable Names into an Array-Name/Key-Name Components
345
   * @param string $tag Variale Name used in Template
346
   * @return array  Array Name, Key Name
347
   * @access private
348
   * @desc Splits Template-Style Variable Names into an Array-Name/Key-Name Components
349
   */
350
  function var_name($tag) {
351
    $parent_level  =  0;
352
    while (substr($tag, 0, 7) == 'parent.') {
353
      $tag  =  substr($tag, 7);
354
      $parent_level++;
355
    }
356
    if (substr($tag, 0, 4) == 'top.') {
357
      $ret = array('_stack[0]', substr($tag,4));
358
      return $ret;
359
    } elseif ($parent_level) {
360
      $ret = array('_stack[$_stack_cnt-'.$parent_level.']', $tag);
361
      return $ret;
362
    } else {
363
      $ret = array('_obj', $tag);
364
      return $ret;
365
    }
366
  }
367

  
368
  /* Highlight HTML Source
369
   * @param string $code HTML Source
370
   * @return string Hightlighte HTML Source
371
   * @access private
372
   * @desc Highlight HTML Source
373
   */
374
  function highlight_html ( $code ) {
375
    $code  =  htmlentities($code);
376
    $code  =  preg_replace('/([a-zA-Z_]+)=/',  '<font color="#FF0000">$1=</font>',  $code);
377
    $code  =  preg_replace('/(&lt;[\/a-zA-Z0-9&;]+)/',  '<font color="#0000FF">$1</font>',  $code);
378
    $code  =  str_replace('&lt;!--',  '<font color="#008080">&lt;!--',  $code);
379
    $code  =  str_replace('--&gt;',  '--&gt;</font>',  $code);
380
    $code  =  preg_replace('/[\r\n]+/',  "\n",  $code);
381
    return $code;
382
  }
383
}
384
?>
0 385

  
branches/2.8.x/wb/include/quickSkin/qx/qx_substr.php
1
<?php
2
  /**
3
  * QuickSkin Extension substr
4
  * Insert specific part of a string
5
  *
6
  * Usage Example:
7
  * Content:  $template->assign('HEADLINE', 'My Title');
8
  * Template: <font size=4>{substr:HEADLINE,0,1}</font>{substr:HEADLINE,1}
9
  * Result:   <font size=4>M</font>y Title
10
  *
11
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
12
  */
13
  function qx_substr ( $param, $lim0 = 0, $lim1 = 0 ) {
14
    if ($lim1) {
15
      return substr( $param, $lim0, $lim1 );
16
    } else {
17
      return substr( $param, $lim0 );
18
    }
19
  }
20

  
21
?>
0 22

  
branches/2.8.x/wb/include/quickSkin/qx/qx_db_date.php
1
<?php
2
  /**
3
  * QuickSkin Extension db_date
4
  * Convert Oracle Date (British Format) to Local Formatted Date
5
  *
6
  * Usage Example:
7
  * Content:  $template->assign('UPDATE', $result['LAST_UPDATE_DATE_TIME']);
8
  * Template: Last update: {db_date:UPDATE}
9
  * Result:   Last update: 30.01.2003
10
  *
11
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
12
  */
13
  function qx_db_date ( $param ) {
14
    global $configuration;
15

  
16
    if (preg_match('/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $param)) {
17
      return date( $configuration['date_format'],  strtotime($param) );
18
    } else {
19
      return 'Invalid date format!';
20
    }
21
  }
22

  
23
?>
0 24

  
branches/2.8.x/wb/include/quickSkin/qx/qx_lowercase.php
1
<?php
2
  /**
3
  * QuickSkin Extension lowercase
4
  * Converts String to lowercase
5
  *
6
  * Usage Example:
7
  * Content:  $template->assign('NAME', 'John Doe');
8
  * Template: Username: {lowercase:NAME}
9
  * Result:   Username: john doe
10
  *
11
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
12
  */
13
  function qx_lowercase ( $param ) {
14
    return strtolower( $param );
15
  }
16

  
17
?>
0 18

  
branches/2.8.x/wb/include/quickSkin/qx/qx_mailto.php
1
<?php
2
  /**
3
  * QuickSkin Extension mailto
4
  * creates Mailto-Link from email address
5
  *
6
  * Usage Example:
7
  * Content:  $template->assign('CONTACT', 'philipp@criegern.de' );
8
  * Template: Mail to Webmaster: {mailto:CONTACT}
9
  * Result:   Mail to Webmaster: <a href="mailto:philipp@criegern.de">philipp@criegern.de</a>
10
  *
11
  * @author Andy Prevost andy@codeworxtech.com
12
  */
13
  function qx_mailto ( $param,$name='',$encode=false ) {
14
    if ($encode === false) {
15
      if ( $name != '' ) {
16
        return '<a href="mailto:' . $param . '">' . $name . '</a>';
17
      } else {
18
        return '<a href="mailto:' . $param . '">' . $param . '</a>';
19
      }
20
    } else {
21
      $obfuscatedMailTo = '';
22
      $mailto = "mailto:";
23
      $length = strlen($mailto);
24
      for ($i = 0; $i < $length; $i++) {
25
        $obfuscatedMailTo .= "&#" . ord($mailto[$i]);
26
      }
27
      $mailto = $param;
28
      $length = strlen($mailto);
29
      $param  = '';
30
      for ($i = 0; $i < $length; $i++) {
31
        $param .= "&#" . ord($mailto[$i]);
32
      }
33
      if ( $name != '' ) {
34
        $mailto = $name;
35
        $length = strlen($mailto);
36
        $name  = '';
37
        for ($i = 0; $i < $length; $i++) {
38
          $name .= "&#" . ord($mailto[$i]);
39
        }
40
        return '<a href="' . $obfuscatedMailTo . ':' . $param . '">' . $name . '</a>';
41
      } else {
42
        return '<a href="' . $obfuscatedMailTo . ':' . $param . '">' . $param . '</a>';
43
      }
44

  
45
    }
46
  }
47

  
48
?>
0 49

  
branches/2.8.x/wb/include/quickSkin/qx/qx_number.php
1
<?php
2
  /**
3
  * QuickSkin Extension number
4
  * Format a number with grouped thousands
5
  *
6
  * Usage Example:
7
  * Content:  $template->assign('SUM', 2500000);
8
  * Template: Current balance: {number:SUM}
9
  * Result:   Current balance: 2.500.000,00
10
  *
11
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
12
  */
13
  function qx_number ( $param ) {
14
    global $_CONFIG;
15

  
16
    $decimalChar = ',';
17
    if ( !empty($_CONFIG['decimal_char']) ) {
18
      $decimalChar = $_CONFIG['decimal_char'];
19
    }
20
    $decimalPlaces = 2;
21
    if ( !empty($_CONFIG['decimal_places']) ) {
22
      $decimalPlaces = $_CONFIG['decimal_places'];
23
    }
24
    $thousandsSep = '.';
25
    if ( !empty($_CONFIG['thousands_sep']) ) {
26
      $thousandsSep = $_CONFIG['thousands_sep'];
27
    }
28

  
29
    return number_format( $param, $decimalChar, $decimalPlaces, $thousandsSep );
30
  }
31

  
32
?>
0 33

  
branches/2.8.x/wb/include/quickSkin/qx/qx_count.php
1
<?php
2
  /**
3
  * QuickSkin Extension count
4
  * count element of an array
5
  *
6
  * Usage Example:
7
  * Content:  $template->assign('list', array('a','b'));
8
  * Template: count: {count:list}
9
  * Result:   count: 2
10
  *
11
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
12
  */
13
  function qx_count ( $param ) {
14
    $temp = count( $param );
15
    return $temp;
16
  }
17

  
18
?>
0 19

  
branches/2.8.x/wb/include/quickSkin/qx/qx_current_datetime.php
1
<?php
2
  /**
3
  * QuickSkin Extension current_datetime
4
  * Print Current Date and Time
5
  *
6
  * Usage Example:
7
  * Template: Time: {current_datetime:}
8
  * Result:   Time: 01.01.2009 - 12:46:00
9
  *
10
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
11
  */
12
  function qx_current_datetime () {
13
    global $_CONFIG;
14

  
15
    $datetimeFormat = 'F j, Y H:i:s';
16
    if ( !empty($_CONFIG['datetime_format']) ) {
17
      $datetimeFormat = $_CONFIG['datetime_format'];
18
    }
19
    return date( $datetimeFormat );
20
  }
21

  
22
?>
0 23

  
branches/2.8.x/wb/include/quickSkin/qx/qx_nvl.php
1
<?php
2
  /**
3
  * QuickSkin Extension nvl
4
  * Insert a default value if variable is empty
5
  *
6
  * Usage Example:
7
  * Content:  $template->assign('PREVIEW1', 'picture_21.gif');
8
  * Template: <img src="{nvl:PREVIEW1,'not_available.gif'}"> / <img src="{nvl:PREVIEW2,'not_available.gif'}">
9
  * Result:   <img src="picture_21.gif"> / <img src="not_available.gif">
10
  *
11
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
12
  */
13
  function qx_nvl ( $param, $default ) {
14
    if (strlen($param)) {
15
      return ( $param );
16
    } else {
17
      return ( $default );
18
    }
19
  }
20

  
21
?>
0 22

  
branches/2.8.x/wb/include/quickSkin/qx/qx_db_datetime.php
1
<?php
2
  /**
3
  * QuickSkin Extension db_datetime
4
  * Convert Oracle Date (British Format) to Local Formatted Date and Time
5
  *
6
  * Usage Example:
7
  * Content:  $template->assign('UPDATE', $result['LAST_UPDATE_DATE_TIME']);
8
  * Template: Last update: {db_datetime:UPDATE}
9
  * Result:   Last update: 30.01.2003 - 12:46:00
10
  *
11
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
12
  */
13
  function qx_db_datetime ( $param ) {
14
    global $configuration;
15

  
16
    if (preg_match('/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $param)) {
17
      return date( $configuration['datetime_format'],  strtotime($param) );
18
    } else {
19
      return 'Invalid date format!';
20
    }
21
  }
22

  
23
?>
0 24

  
branches/2.8.x/wb/include/quickSkin/qx/qx_load_config.php
1
<?php
2
  /**
3
  * QuickSkin Extension load_config
4
  * Reads an INI-Style configuration file into an array
5
  *
6
  * Usage Example:
7
  * Configuration File (parameter.ini):
8
  *
9
  *     PAGETITLE   =  Default Page Title
10
  *     [colors]
11
  *     BACKGROUND  =  #FFFFFF
12
  *     TEXT        =  #000000
13
  *
14
  * Template:
15
  *
16
  *     {load_config:"parameter.ini","config"}
17
  *     <title>{config.PAGETITLE}</title>
18
  *     <body bgcolor="{config.colors.BACKGROUND}" text="{config.colors.TEXT}">
19
  *
20
  * Result:
21
  *
22
  *     <title>Default Page Title</title>
23
  *     <body bgcolor="#FFFFFF" text="#000000">
24
  *
25
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
26
  */
27
  function qx_load_config ( $filename,  $name = 'config' ) {
28
    global $_top;
29

  
30
    $section  =  null;
31
    if (is_file($filename)) {
32
      $cfgfile  =  file($filename);
33
      if (is_array($cfgfile)) {
34
        foreach ($cfgfile as $line) {
35
          if (substr($line, 0, 1) != '#') {
36
            if (substr($line, 0, 1) == '[') {
37
              if ($rbr = strpos($line, ']')) {
38
                $section  =  substr($line, 1, $rbr -1);
39
              }
40
            }
41
            if ($tr = strpos($line, '=')) {
42
              $k  =  trim(substr($line, 0, $tr));
43
              $v  =  trim(substr($line, $tr+1));
44
              if (isset($section)) {
45
                $_top[$name][$section][$k]  =  $v;
46
              } else {
47
                $_top[$name][$k]  =  $v;
48
              }
49
            }
50
          }
51
        }
52
      }
53
    }
54
  }
55

  
56
?>
0 57

  
branches/2.8.x/wb/include/quickSkin/qx/qx_regex.php
1
<?php
2
  /**
3
  * QuickSkin Extension regex
4
  * Regular Expression String Replace
5
  *
6
  * Usage Example:
7
  * Content:  $template->assign('NAME', '*My Document*');
8
  * Template: Document Name: {regex:NAME,'/[^a-z0-9]/i','_'}
9
  * Result:   Document Name: _My_Document_
10
  *
11
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
12
  */
13
  function qx_regex ( $param, $pattern, $replace ) {
14
    return preg_replace( $pattern, $replace, $param );
15
  }
16

  
17
?>
0 18

  
branches/2.8.x/wb/include/quickSkin/qx/qx_trim.php
1
<?php
2
  /**
3
  * QuickSkin Extension trim
4
  * Removes leading and trailing Whitespaces and Line Feeds
5
  *
6
  * Usage Example:
7
  * Content:  $template->assign('LINK', ' Click Here  ');
8
  * Template: <a href="/">{trim:LINK}</a>
9
  * Result:   <a href="/">Click Here</a>
10
  *
11
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
12
  */
13
  function qx_trim ( $param ) {
14
    return trim( $param );
15
  }
16

  
17
?>
0 18

  
branches/2.8.x/wb/include/quickSkin/qx/qx_replace.php
1
<?php
2
  /**
3
  * QuickSkin Extension replace
4
  * String Replace
5
  *
6
  * Usage Example:
7
  * Content:  $template->assign('PATH', $path_tranlated);  //  C:\Apache\htdocs\php\test.php
8
  * Template: Script Name: {replace:PATH,'\\','/'}
9
  * Result:   Script Name: C:/Apache/htdocs/php/test.php
10
  *
11
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
12
  */
13
  function qx_replace ( $param, $pattern, $replace ) {
14
    return str_replace( $pattern, $replace, $param );
15
  }
16

  
17
?>
0 18

  
branches/2.8.x/wb/include/quickSkin/qx/qx_stringformat.php
1
<?php
2
  /**
3
  * QuickSkin Extension stringformat
4
  * Inserts a formatted String
5
  *
6
  * Usage Example:
7
  * Content:  $template->assign('SUM', 25);
8
  * Template: Current balance: {stringformat:SUM,'$ %01.2f'}
9
  * Result:   Current balance: $ 25.00
10
  *
11
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
12
  */
13
  function qx_stringformat ( $param, $format ) {
14
    return sprintf( $format,  $param );
15
  }
16

  
17
?>
0 18

  
branches/2.8.x/wb/include/quickSkin/qx/qx_session.php
1
<?php
2
  /**
3
  * QuickSkin Extension session
4
  * Print Content of Session variables
5
  *
6
  * Usage Example:
7
  * Content:  $_SESSION['userName']  =  'Philipp von Criegern';
8
  * Template: Current User: {session:"userName"}
9
  * Result:   Current User: Philipp von Criegern
10
  *
11
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
12
  */
13
  function qx_session ( $param ) {
14
    return $_SESSION[$param];
15
  }
16

  
17
?>
0 18

  
branches/2.8.x/wb/include/quickSkin/qx/qx_truncate.php
1
<?php
2
  /**
3
  * QuickSkin Extension truncate
4
  * Restricts a String to a specific number characters
5
  *
6
  * Usage Example:
7
  * Content:  $template->assign('TEASER', 'PHP 4.3.0RC1 has been released. This is the first release candidate');
8
  * Template: News: {truncate:TEASER,50} ... [more]
9
  * Result:   News: QuickSkin version 5.0 has been released. This is the first ... [more]
10
  *
11
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
12
  */
13
  function qx_truncate ( $param, $size ) {
14
    return substr( $param, 0, $size );
15
  }
16

  
17
?>
0 18

  
branches/2.8.x/wb/include/quickSkin/qx/qx_uppercase.php
1
<?php
2
  /**
3
  * QuickSkin Extension uppercase
4
  * Converts String to uppercase
5
  *
6
  * Usage Example:
7
  * Content:  $template->assign('NAME', 'John Doe');
8
  * Template: Username: {uppercase:NAME}
9
  * Result:   Username: JOHN DOE
10
  *
11
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
12
  */
13
  function qx_uppercase ( $param ) {
14
    return strtoupper( $param );
15
  }
16

  
17
?>
0 18

  
branches/2.8.x/wb/include/quickSkin/qx/qx_header.php
1
<?php
2
  /**
3
  * QuickSkin Extension header
4
  * Sends HTTP Header
5
  *
6
  * Usage Example:
7
  * Content:  $template->assign( 'TITLE', 'SVG Template Demo:' );
8
  *
9
  * Template:
10
  *     {header:"Content-type: image/svg+xml"}<?xml version="1.0" ?>
11
  *     <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
12
  *     <svg width="300px" height="150px" style="shape-rendering:optimizeQuality;text-rendering:optimizeQuality">
13
  *       <circle id="ball" cx="150" cy="75" r="50" style="fill:rgb(200,200,255)" />
14
  *       <text x="70" y="80" id="title" style="font-face:Courier;font-size:12pt">{TITLE}</text>
15
  *     </svg>
16
  *
17
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
18
  */
19
  function qx_header ( $param ) {
20
    header($param);
21
  }
22

  
23

  
0 24

  
branches/2.8.x/wb/include/quickSkin/qx/qx_codesnippetstart.php
1
<?php
2
  /**
3
  * QuickSkin Extension codesnippetstart
4
  * required for the start of a code snippet
5
  *
6
  * Usage Example:
7
  * Template: Code Snippet<br />{codesnippetstart:}
8
  *
9
  * @author Andy Prevost andy@codeworxtech.com
10
  */
11
  function qx_codesnippetstart ( $param='' ) {
12
    /*
13
    nogutter = no line numbers
14
    nocontrols = no menu at top
15
    collapse = = display nothing, menu at top will display '+ expand source'
16
    firstline[value] = starting number to start count
17
    showcolumns = shows "ruler" at top
18
    */
19
    if ( $param = '' ) {
20
      return '<pre name="code" class="php">';
21
    } else {
22
      return '<pre name="code" class="php:' . $param . '">';
23
    }
24
  }
25

  
26
?>
0 27

  
branches/2.8.x/wb/include/quickSkin/qx/qx_options.php
1
<?php
2
  /**
3
  * QuickSkin Extension options
4
  * Creates HTML DropDown Option list from an array
5
  *
6
  * Usage Example I:
7
  * Content:  $template->assign('pick', array( "on", "off" ) );
8
  * Template: Choose: <select name="onoff"> {options:pick} </select>
9
  * Result:   Choose: <select name="onoff"> <option>on</option><option>off</option> </select>
10
  *
11
  * Usage Example II:
12
  * Content:  $template->assign('color',   array( "FF0000" => "Red", "00FF00" => "Green", "0000FF" => "Blue" ) );
13
  *           $template->assign('default', "00FF00" );
14
  * Template: Color: <select name="col"> {options:color,default} </select>
15
  * Result:   Color: <select name="col"> <option value="FF0000">Red</option><option value="00FF00" selected>Green</option><option value="0000FF">Blue</option> </select>
16
  *
17
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
18
  */
19
  function qx_options ( $param,  $default = '_DEFAULT_' ) {
20
    $output  =  '';
21
    if (is_array($param)) {
22
      $keyindex  =  0;
23
      foreach ($param as $key => $value) {
24
        if ($key==$keyindex++ && is_numeric($key)) {
25
          $output  .=  '<option' . (($value == $default) ? '  selected' : '') . '>' . $value . '</option>';
26
        } else {
27
          $output  .=  '<option value="' . $key . '"' . (($key == $default) ? '  selected' : '') . '>' . $value . '</option>';
28
        }
29
      }
30
    }
31
    return $output;
32
  }
33

  
34
?>
0 35

  
branches/2.8.x/wb/include/quickSkin/qx/qx_dateformatgrid.php
1
<?php
2
  /**
3
  * QuickSkin Extension dateformatgrid
4
  * Changes Dateformat
5
  *
6
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
7
  */
8
  function qx_dateformatgrid ( $param, $format = 'F j, Y' ) {
9
    list($month,$day,$year,$hour,$minute,$second) = split("[-:T\.]", $param);
10

  
11
    // handle empty values
12
    if (! $hour) { $hour = '00'; }
13
    if (! $minute) { $minute = '00'; }
14
    if (! $second) { $second = '00'; }
15

  
16
    return date( $format, mktime($hour, $minute, $second, $month, $day, $year));
17
  }
18

  
19
?>
0 20

  
branches/2.8.x/wb/include/quickSkin/qx/qx_encode.php
1
<?php
2
  /**
3
  * QuickSkin Extension encode
4
  * Encodes String (md5)
5
  *
6
  * Usage Example:
7
  * Content:  $template->assign('ID', 123);
8
  * Template: <a href="delete.php?id={encode:ID}">delete</a>
9
  * Result:   <a href="delete.php?id=7B600B6476167773626A">delete</a>
10
  *
11
  * @author Andy Prevost andy@codeworxtech.com
12
  */
13

  
14
  function qx_encode ( $param ) {
15
    return md5( $param );
16
  }
17

  
18
?>
0 19

  
branches/2.8.x/wb/include/quickSkin/qx/qx_current_time.php
1
<?php
2
  /**
3
  * QuickSkin Extension current_time
4
  * Print Current Time
5
  *
6
  * Usage Example:
7
  * Template: Time: {current_time:}
8
  * Result:   Time: 12:46:00
9
  *
10
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
11
  */
12
  function qx_current_time ($meridiem='A') {
13
    global $_CONFIG;
14

  
15
    $timeFormat = 'g:i:s ' . $meridiem;
16
    if ( !empty($_CONFIG['time_format']) ) {
17
      $timeFormat = $_CONFIG['time_format'];
18
    }
19
    return date( $timeFormat );
20
  }
21

  
22
?>
0 23

  
branches/2.8.x/wb/include/quickSkin/qx/qx_db_time.php
1
<?php
2
  /**
3
  * QuickSkin Extension db_time
4
  * Convert Oracle Date (British Format) to Local Formatted Time
5
  *
6
  * Usage Example:
7
  * Content:  $template->assign('UPDATE', $result['LAST_UPDATE_DATE_TIME']);
8
  * Template: Last update: {db_time:UPDATE}
9
  * Result:   Last update: 12:46:00
10
  *
11
  * @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
12
  */
13
  function qx_db_time ( $param ) {
14
    global $configuration;
15

  
16
    if (preg_match('/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $param)) {
17
      return date( $configuration['time_format'],  strtotime($param) );
18
    } else {
19
      return 'Invalid date format!';
20
    }
21
  }
22

  
23
?>
0 24

  
branches/2.8.x/wb/include/quickSkin/qx/qx_mailtoencode.php
1
<?php
2
  /**
3
  * QuickSkin Extension mailtoencode
4
  * Protects email address from being scanned by spam bots
5
  * and optionally builds full mailto: link
6
  *
7
  * Usage Example 1:
8
  * Content:  $template->assign('AUTHOR', 'yourname@yourdomain.com' );
9
  * Template: Author: {mailtoencode:AUTHOR}
10
  * Result:   Author: <a href="&#109&#97&#105&#108&#116&#111&#58&#121;&#111;&#117;&#114;&#110;&#97;&#109;&#101;&#64;&#121;&#111;&#117;&#114;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#99;&#111;&#109;">yourname&#64;yourdomain&#46;com</a>
11
  *
12
  * Usage Example 2 (Email address only):
13
  * Template: Author: {mailtoencode:"yourname@yourdomain.com"}
14
  * Result:   Author: <a href="&#109&#97&#105&#108&#116&#111&#58&#121;&#111;&#117;&#114;&#110;&#97;&#109;&#101;&#64;&#121;&#111;&#117;&#114;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#99;&#111;&#109;">yourname&#64;yourdomain&#46;com</a>
15
  *
16
  * Usage Example 3 (Email address and name):
17
  * Template: Author: {mailtoencode:"yourname@yourdomain.com","Your Name"}
18
  * Result:   Author: <a href="&#109&#97&#105&#108&#116&#111&#58&#121;&#111;&#117;&#114;&#110;&#97;&#109;&#101;&#64;&#121;&#111;&#117;&#114;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#99;&#111;&#109;">Your Name</a>
19
  *
20
  * Usage Example 4 (Email address and name, encode set to true, and class name):
21
  * Template: Author: {mailtoencode:"yourname@yourdomain.com","Your Name",true,'white'}
22
  * Result:   Author: <a href="&#109&#97&#105&#108&#116&#111&#58&#121;&#111;&#117;&#114;&#110;&#97;&#109;&#101;&#64;&#121;&#111;&#117;&#114;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#99;&#111;&#109;" class="white">Your Name</a>
23
  *
24
  * Usage Example 5 (Email address and name, encode set to true, class name and style defined):
25
  * Template: Author: {mailtoencode:"yourname@yourdomain.com","Your Name",true,'white','font-size:18px;'}
26
  * Result:   Author: <a href="&#109&#97&#105&#108&#116&#111&#58&#121;&#111;&#117;&#114;&#110;&#97;&#109;&#101;&#64;&#121;&#111;&#117;&#114;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#99;&#111;&#109;" class="white" style="font-size:18px;">Your Name</a>
27
  *
28
  * Usage Example 6 (Email address and name, encode set to true, no class name and style defined):
29
  * Template: Author: {mailtoencode:"yourname@yourdomain.com","Your Name",true,'','font-size:18px;'}
30
  * Result:   Author: <a href="&#109&#97&#105&#108&#116&#111&#58&#121;&#111;&#117;&#114;&#110;&#97;&#109;&#101;&#64;&#121;&#111;&#117;&#114;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#99;&#111;&#109;" style="font-size:18px;">Your Name</a>
31
  *
32
  * @author Andy Prevost andy@codeworxtech.com
33
  */
34

  
35
  if(!function_exists('str_split')){
36
    function str_split($text, $split = 1){
37
      $array = array();
38
      for($i=0; $i < strlen($text); $i++){
39
        $key = NULL;
40
        for ($j = 0; $j < $split; $j++){
41
          $key .= $text[$i];
42
        }
43
        array_push($array, $key);
44
      }
45
        return $array;
46
    }
47
  }
48

  
49
  function qx_mailtoencode ($emailAddy,$text='',$buildLink=true,$class='',$style='') {
50
    if ( $buildLink ) {
51
      // mailto: portion
52
      $obfuscatedMailTo = '';
53
      $mailto           = "mailto:";
54
      $length           = strlen($mailto);
55
      for ($i = 0; $i < $length; $i++) {
56
        $obfuscatedMailTo .= "&#" . ord($mailto[$i]);
57
      }
58
      // END - mailto: portion
59
      $emailLink  = '<a href="';
60
      $emailLink .= $obfuscatedMailTo;
61
    }
62
    $emailLink .= obfuscate($emailAddy);
63
    if ( $buildLink ) {
64
      $emailLink .= '"';
65
      if ( trim($class) != '' ) {
66
        $emailLink .= ' class="' . $class . '"';
67
      }
68
      if ( trim($style) != '' ) {
69
        $emailLink .= ' style="' . $style . '"';
70
      }
71
      $emailLink .= '>';
72
      if ( trim($text) != '' ) {
73
        $newText    = trim($text);
74
        $newText    = str_replace('@','&#64;',$newText);
75
        $newText    = str_replace('.','&#46;',$newText);
76
        $emailLink .= $newText;
77
      } else {
78
        $newText    = trim($emailAddy);
79
        $newText    = str_replace('@','&#64;',$newText);
80
        $newText    = str_replace('.','&#46;',$newText);
81
        $emailLink .= $newText;
82
      }
83
      $emailLink .= "</a>";
84
    }
85
    return $emailLink;
86
  }
87

  
88
  function obfuscate($text) { // NOTE: Uses function str_split
89
    preg_match_all("/[-a-z0-9\._]+@[-a-z0-9\._]+\.[a-z]{2,4}/", $text, $emails);
90
    $patterns = array();
91
    $replacements = array();
92
    foreach($emails[0] as $email) {
93
      if(!in_array("/$email/", $patterns)) {
94
        $obfuscated = '';
95
        foreach(str_split($email) as $char) {
96
          $obfuscated .= '&#'.ord($char).';';
97
        }
98
        $patterns[] = "/$email/";
99
        $replacements[] = $obfuscated;
100
      }
101
    }
102
    $text = preg_replace($patterns, $replacements, $text);
103
    return $text;
104
  }
105

  
106
?>
0 107

  
branches/2.8.x/wb/include/quickSkin/qx/qx_codesnippetend.php
1
<?php
2
  /**
3
  * QuickSkin Extension codesnippetend
4
  * required for the end of a code snippet
5
  *
6
  * Usage Example:
7
  * Template: Code Snippet<br />{codesnippetend:}
8
  *
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff