[ Index ]
 

Code source de CakePHP 1.1.13.4450

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/cake/libs/view/ -> helper.php (source)

   1  <?php
   2  /* SVN FILE: $Id: helper.php 4409 2007-02-02 13:20:59Z phpnut $ */
   3  /**
   4   * Backend for helpers.
   5   *
   6   * Internal methods for the Helpers.
   7   *
   8   * PHP versions 4 and 5
   9   *
  10   * CakePHP(tm) :  Rapid Development Framework <http://www.cakephp.org/>
  11   * Copyright 2005-2007, Cake Software Foundation, Inc.
  12   *                                1785 E. Sahara Avenue, Suite 490-204
  13   *                                Las Vegas, Nevada 89104
  14   *
  15   * Licensed under The MIT License
  16   * Redistributions of files must retain the above copyright notice.
  17   *
  18   * @filesource
  19   * @copyright        Copyright 2005-2007, Cake Software Foundation, Inc.
  20   * @link                http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
  21   * @package            cake
  22   * @subpackage        cake.cake.libs.view
  23   * @since            CakePHP(tm) v 0.2.9
  24   * @version            $Revision: 4409 $
  25   * @modifiedby        $LastChangedBy: phpnut $
  26   * @lastmodified    $Date: 2007-02-02 07:20:59 -0600 (Fri, 02 Feb 2007) $
  27   * @license            http://www.opensource.org/licenses/mit-license.php The MIT License
  28   */
  29  /**
  30   * Backend for helpers.
  31   *
  32   * Long description for class
  33   *
  34   * @package        cake
  35   * @subpackage    cake.cake.libs.view
  36   */
  37  class Helper extends Object {
  38  /**
  39   * Holds tag templates.
  40   *
  41   * @access public
  42   * @var array
  43   */
  44      var $tags = array('link' => '<a href="%s" %s>%s</a>',
  45                              'mailto' => '<a href="mailto:%s" %s>%s</a>',
  46                              'form' => '<form %s>',
  47                              'input' => '<input name="data[%s][%s]" %s/>',
  48                              'textarea' => '<textarea name="data[%s][%s]" %s>%s</textarea>',
  49                              'hidden' => '<input type="hidden" name="data[%s][%s]" %s/>',
  50                              'textarea' => '<textarea name="data[%s][%s]" %s>%s</textarea>',
  51                              'checkbox' => '<input type="checkbox" name="data[%s][%s]" %s/>',
  52                              'radio' => '<input type="radio" name="data[%s][%s]" id="%s" %s />%s',
  53                              'selectstart' => '<select name="data[%s][%s]" %s>',
  54                              'selectmultiplestart' => '<select name="data[%s][%s][]" %s>',
  55                              'selectempty' => '<option value="" %s>&nbsp;</option>',
  56                              'selectoption' => '<option value="%s" %s>%s</option>',
  57                              'selectend' => '</select>',
  58                              'password' => '<input type="password" name="data[%s][%s]" %s/>',
  59                              'file' => '<input type="file" name="data[%s][%s]" %s/>',
  60                              'file_no_model' => '<input type="file" name="%s" %s/>',
  61                              'submit' => '<input type="submit" %s/>',
  62                              'image' => '<img src="%s" %s/>',
  63                              'tableheader' => '<th%s>%s</th>',
  64                              'tableheaderrow' => '<tr%s>%s</tr>',
  65                              'tablecell' => '<td%s>%s</td>',
  66                              'tablerow' => '<tr%s>%s</tr>',
  67                              'block' => '<div%s>%s</div>',
  68                              'blockstart' => '<div%s>',
  69                              'blockend' => '</div>',
  70                              'css' => '<link rel="%s" type="text/css" href="%s" %s/>',
  71                              'style' => '<style type="text/css"%s>%s</style>',
  72                              'charset' => '<meta http-equiv="Content-Type" content="text/html; charset=%s" />',
  73                              'javascriptblock' => '<script type="text/javascript">%s</script>',
  74                              'javascriptlink' => '<script type="text/javascript" src="%s"></script>');
  75  /**
  76   * Parses custom config/tags.ini.php and merges with $this->tags.
  77   *
  78   * @return html tags used by helpers
  79   */
  80  	function loadConfig() {
  81  
  82          if (file_exists(APP . 'config' . DS . 'tags.ini.php')) {
  83              $tags = $this->readConfigFile(APP . 'config' . DS . 'tags.ini.php');
  84              $this->tags = am($this->tags, $tags);
  85          }
  86          return $this->tags;
  87      }
  88  /**
  89   * Decides whether to output or return a string.
  90   *
  91   * Based on AUTO_OUTPUT and $return's value, this method decides whether to
  92   * output a string, or return it.
  93   *
  94   * @param  string  $str    String to be output or returned.
  95   * @param  boolean $return Whether this method should return a value or output it.
  96   * @return mixed    Either string or echos the value, depends on AUTO_OUTPUT and $return.
  97   */
  98  	function output($str, $return = false) {
  99          if (AUTO_OUTPUT && $return === false) {
 100              echo $str;
 101          } else {
 102              return $str;
 103          }
 104      }
 105  /**
 106   * Assigns values to tag templates.
 107   *
 108   * Finds a tag template by $keyName, and replaces $values's keys with
 109   * $values's keys.
 110   *
 111   * @param  string $keyName Name of the key in the tag array.
 112   * @param  array  $values  Values to be inserted into tag.
 113   * @return string Tag with inserted values.
 114   */
 115  	function assign($keyName, $values) {
 116          return str_replace('%%' . array_keys($values) . '%%', array_values($values), $this->tags[$keyName]);
 117      }
 118  /**
 119   * Returns an array of settings in given INI file.
 120   *
 121   * @param string $fileName ini file to read
 122   * @return array of lines from the $fileName
 123   */
 124  	function readConfigFile($fileName) {
 125          $fileLineArray = file($fileName);
 126  
 127          foreach($fileLineArray as $fileLine) {
 128              $dataLine = trim($fileLine);
 129              $firstChar = substr($dataLine, 0, 1);
 130  
 131              if ($firstChar != ';' && $dataLine != '') {
 132                  if ($firstChar == '[' && substr($dataLine, -1, 1) == ']') {
 133                      // [section block] we might use this later do not know for sure
 134                      // this could be used to add a key with the section block name
 135                      // but it adds another array level
 136                  } else {
 137                      $delimiter = strpos($dataLine, '=');
 138  
 139                      if ($delimiter > 0) {
 140                          $key = strtolower(trim(substr($dataLine, 0, $delimiter)));
 141                          $value = trim(stripcslashes(substr($dataLine, $delimiter + 1)));
 142  
 143                          if (substr($value, 0, 1) == '"' && substr($value, -1) == '"') {
 144                              $value = substr($value, 1, -1);
 145                          }
 146  
 147                          $iniSetting[$key] = $value;
 148  
 149                      } else {
 150                          $iniSetting[strtolower(trim($dataLine))] = '';
 151                      }
 152                  }
 153              } else {
 154              }
 155          }
 156  
 157          return $iniSetting;
 158      }
 159  /**
 160   * After render callback.  Overridden in subclasses.
 161   *
 162   * @return void
 163   */
 164  	function afterRender() {
 165      }
 166  }
 167  ?>


Généré le : Sun Feb 25 19:27:47 2007 par Balluche grâce à PHPXref 0.7