smarty_internal_resource_file.php
Current file: C:\DATA\Viktor\Diplomka\XSLT-Benchmarking/Libs/Smarty/sysplugins/smarty_internal_resource_file.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
0.00% 0 / 1
0.00% 0 / 4 CRAP
0.00% 0 / 25
Smarty_Internal_Resource_File
0.00% 0 / 1
0.00% 0 / 4 132
0.00% 0 / 25
 populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null)
0.00% 0 / 1 30
0.00% 0 / 12
 populateTimestamp(Smarty_Template_Source $source)
0.00% 0 / 1 2
0.00% 0 / 3
 getContent(Smarty_Template_Source $source)
0.00% 0 / 1 12
0.00% 0 / 5
 getBasename(Smarty_Template_Source $source)
0.00% 0 / 1 6
0.00% 0 / 5



       1                 : <?php                                                                                                 
       2                 : /**                                                                                                   
       3                 :  * Smarty Internal Plugin Resource File                                                               
       4                 :  *                                                                                                    
       5                 :  * @package Smarty                                                                                    
       6                 :  * @subpackage TemplateResources                                                                      
       7                 :  * @author Uwe Tews                                                                                   
       8                 :  * @author Rodney Rehm                                                                                
       9                 :  */                                                                                                   
      10                 :                                                                                                       
      11                 : /**                                                                                                   
      12                 :  * Smarty Internal Plugin Resource File                                                               
      13                 :  *                                                                                                    
      14                 :  * Implements the file system as resource for Smarty templates                                        
      15                 :  *                                                                                                    
      16                 :  * @package Smarty                                                                                    
      17                 :  * @subpackage TemplateResources                                                                      
      18                 :  */                                                                                                   
      19                 : class Smarty_Internal_Resource_File extends Smarty_Resource {                                         
      20                 :                                                                                                       
      21                 :     /**                                                                                               
      22                 :      * populate Source Object with meta data from Resource                                            
      23                 :      *                                                                                                
      24                 :      * @param Smarty_Template_Source   $source    source object                                       
      25                 :      * @param Smarty_Internal_Template $_template template object                                     
      26                 :      */                                                                                               
      27                 :     public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null)
      28                 :     {                                                                                                 
      29               0 :         $source->filepath = $this->buildFilepath($source, $_template);                                
      30                 :                                                                                                       
      31               0 :         if ($source->filepath !== false) {                                                            
      32               0 :             if (is_object($source->smarty->security_policy)) {                                        
      33               0 :                 $source->smarty->security_policy->isTrustedResourceDir($source->filepath);            
      34               0 :             }                                                                                         
      35                 :                                                                                                       
      36               0 :             $source->uid = sha1($source->filepath);                                                   
      37               0 :             if ($source->smarty->compile_check && !isset($source->timestamp)) {                       
      38               0 :                 $source->timestamp = @filemtime($source->filepath);                                   
      39               0 :                 $source->exists = !!$source->timestamp;                                               
      40               0 :             }                                                                                         
      41               0 :         }                                                                                             
      42               0 :     }                                                                                                 
      43                 :                                                                                                       
      44                 :     /**                                                                                               
      45                 :      * populate Source Object with timestamp and exists from Resource                                 
      46                 :      *                                                                                                
      47                 :      * @param Smarty_Template_Source $source source object                                            
      48                 :      */                                                                                               
      49                 :     public function populateTimestamp(Smarty_Template_Source $source)                                 
      50                 :     {                                                                                                 
      51               0 :         $source->timestamp = @filemtime($source->filepath);                                           
      52               0 :         $source->exists = !!$source->timestamp;                                                       
      53               0 :     }                                                                                                 
      54                 :                                                                                                       
      55                 :     /**                                                                                               
      56                 :      * Load template's source from file into current template object                                  
      57                 :      *                                                                                                
      58                 :      * @param Smarty_Template_Source $source source object                                            
      59                 :      * @return string template source                                                                 
      60                 :      * @throws SmartyException if source cannot be loaded                                             
      61                 :      */                                                                                               
      62                 :     public function getContent(Smarty_Template_Source $source)                                        
      63                 :     {                                                                                                 
      64               0 :         if ($source->timestamp) {                                                                     
      65               0 :             return file_get_contents($source->filepath);                                              
      66                 :         }                                                                                             
      67               0 :         if ($source instanceof Smarty_Config_Source) {                                                
      68               0 :             throw new SmartyException("Unable to read config {$source->type} '{$source->name}'");     
      69                 :         }                                                                                             
      70               0 :         throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");       
      71                 :     }                                                                                                 
      72                 :                                                                                                       
      73                 :     /**                                                                                               
      74                 :      * Determine basename for compiled filename                                                       
      75                 :      *                                                                                                
      76                 :      * @param Smarty_Template_Source $source source object                                            
      77                 :      * @return string resource's basename                                                             
      78                 :      */                                                                                               
      79                 :     public function getBasename(Smarty_Template_Source $source)                                       
      80                 :     {                                                                                                 
      81               0 :         $_file = $source->name;                                                                       
      82               0 :         if (($_pos = strpos($_file, ']')) !== false) {                                                
      83               0 :             $_file = substr($_file, $_pos + 1);                                                       
      84               0 :         }                                                                                             
      85               0 :         return basename($_file);                                                                      
      86                 :     }                                                                                                 
      87                 :                                                                                                       
      88                 : }                                                                                                     
      89                 :                                                                                                       


Generated by PHP_CodeCoverage @package_version@ using PHP 5.3.6 and PHPUnit @package_version@ at Tue Jun 26 15:06:55 CEST 2012.