[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/libraries/Smarty/libs/sysplugins/ -> smarty_internal_resource_stream.php (source)

   1  <?php
   2  /**
   3   * Smarty Internal Plugin Resource Stream
   4   *
   5   * Implements the streams as resource for Smarty template
   6   *
   7   * @package Smarty
   8   * @subpackage TemplateResources
   9   * @author Uwe Tews
  10   * @author Rodney Rehm
  11   */
  12  
  13  /**
  14   * Smarty Internal Plugin Resource Stream
  15   *
  16   * Implements the streams as resource for Smarty template
  17   *
  18   * @link http://php.net/streams
  19   * @package Smarty
  20   * @subpackage TemplateResources
  21   */
  22  class Smarty_Internal_Resource_Stream extends Smarty_Resource_Recompiled {
  23  
  24      /**
  25       * populate Source Object with meta data from Resource
  26       *
  27       * @param Smarty_Template_Source   $source    source object
  28       * @param Smarty_Internal_Template $_template template object
  29       * @return void
  30       */
  31      public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null)
  32      {
  33          $source->filepath = str_replace(':', '://', $source->resource);
  34          $source->uid = false;
  35          $source->content = $this->getContent($source);
  36          $source->timestamp = false;
  37          $source->exists = !!$source->content;
  38      }
  39  
  40      /**
  41       * Load template's source from stream into current template object
  42       *
  43       * @param Smarty_Template_Source $source source object
  44       * @return string template source
  45       * @throws SmartyException if source cannot be loaded
  46       */
  47      public function getContent(Smarty_Template_Source $source)
  48      {
  49          $t = '';
  50          // the availability of the stream has already been checked in Smarty_Resource::fetch()
  51          $fp = fopen($source->filepath, 'r+');
  52          if ($fp) {
  53              while (!feof($fp) && ($current_line = fgets($fp)) !== false) {
  54                  $t .= $current_line;
  55              }
  56              fclose($fp);
  57              return $t;
  58          } else {
  59              return false;
  60          }
  61      }
  62      
  63      /**
  64       * modify resource_name according to resource handlers specifications
  65       *
  66       * @param Smarty $smarty        Smarty instance
  67       * @param string $resource_name resource_name to make unique
  68       * @return string unique resource name
  69       */
  70      protected function buildUniqueResourceName(Smarty $smarty, $resource_name)
  71      {
  72          return get_class($this) . '#' . $resource_name;
  73      }
  74  }
  75  
  76  ?>


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1