Development

Changeset 2100

You must first sign up to be able to contribute.

Changeset 2100

Show
Ignore:
Timestamp:
09/14/06 23:48:09 (2 years ago)
Author:
synace
Message:

helpers as classes, implements #374

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/synace/data/config/autoload.yml

    r1941 r2100  
    5656    path:           %SF_APP_DIR%/modules/*/lib 
    5757    recursive:      on 
     58 
     59  # helpers 
     60  helpers_lib: 
     61    name:           helpers lib 
     62    path:           %SF_SYMFONY_LIB_DIR%/helpers 
     63    recursive:      on 
  • branches/synace/data/config/settings.yml

    r2011 r2100  
    7575 
    7676    escaping_strategy: bc 
    77     escaping_method:   ESC_ENTITIES 
     77    escaping_method:   EscapingHelper::ESC_ENTITIES 
    7878 
    7979    prototype_web_dir: /sf/prototype 
  • branches/synace/data/skeleton/app/app/config/settings.yml

    r2011 r2100  
    9797#  
    9898#    escaping_strategy: bc 
    99 #    escaping_method:   ESC_ENTITIES 
     99#    escaping_method:   EscapingHelper::ESC_ENTITIES 
    100100# 
    101101#    prototype_web_dir: /sf/prototype 
  • branches/synace/lib/config/sfLoader.class.php

    r2031 r2100  
    120120    static $loaded = array(); 
    121121 
     122    array_unshift($helpers, 'sf'); 
     123 
    122124    $dirs = self::getHelperDirs($moduleName); 
    123125    foreach ($helpers as $helperName) 
    124126    { 
     127      $className = $helperName.'Helper'; 
    125128      if (isset($loaded[$helperName])) 
    126129      { 
    127130        continue; 
    128131      } 
    129  
    130       $fileName = $helperName.'Helper.php'; 
    131       foreach ($dirs as $dir) 
    132       { 
    133         $included = false; 
    134         if (is_readable($dir.'/'.$fileName)) 
    135         { 
    136           include($dir.'/'.$fileName); 
     132      elseif(class_exists($className)) 
     133      { 
     134        self::initHelperClass($className); 
     135        continue; 
     136      } 
     137 
     138      if (!$included) 
     139      { 
     140        //$fileName = $helperName.'Helper.php'; 
     141        $fileName = $helperName.'Helper.class.php'; 
     142        foreach ($dirs as $dir) 
     143        { 
     144          $included = false; 
     145          if (is_readable($dir.'/'.$fileName)) 
     146          { 
     147            include($dir.'/'.$fileName); 
     148            $included = true; 
     149            break; 
     150          } 
     151        } 
     152      } 
     153      if (!$included) 
     154      { 
     155        //attempt to autoload 
     156        if (is_callable(array($className, '_initialize'))) 
     157        { 
    137158          $included = true; 
    138           break; 
    139         } 
    140       } 
    141  
     159        } 
     160      } 
    142161      if (!$included) 
    143162      { 
     
    150169 
    151170      $loaded[$helperName] = true; 
    152     } 
    153   } 
    154  
     171 
     172      self::initHelperClass($className); 
     173    } 
     174  } 
     175  static public function initHelperClass($className) 
     176  { 
     177      //backwards compatibility for built in helper classes 
     178      if (class_exists($className)) 
     179      { 
     180        foreach (get_class_methods($className) as $methodName) 
     181        { 
     182          if (substr($methodName, 0, 2) == '_') 
     183          { 
     184            continue; 
     185          } 
     186          if (!function_exists($methodName)) 
     187          { 
     188            eval('function ' . $methodName . '() { $args = func_get_args(); return call_user_func_array(array("' . $className. '", "' . $methodName . '"), $args); }'); 
     189          } 
     190        } 
     191        if (is_callable(array($className, '_initialize'))) 
     192        { 
     193          call_user_func_array(array($className, '_initialize'), array()); 
     194        } 
     195      } 
     196  } 
    155197  static public function loadPluginConfig() 
    156198  { 
  • branches/synace/lib/debug/sfWebDebug.class.php

    r2032 r2100  
    111111  private function loadHelpers() 
    112112  { 
    113     // require needed helpers 
    114     foreach (array('Helper', 'Url', 'Asset', 'Tag', 'Javascript') as $helperName) 
    115     { 
    116       include_once(sfConfig::get('sf_symfony_lib_dir').'/helper/'.$helperName.'Helper.php'); 
    117     } 
     113    sfLoader::loadHelpers(array('Helper', 'Url', 'Asset', 'Tag', 'Javascript')); 
    118114  } 
    119115 
  • branches/synace/lib/filter/sfCommonFilter.class.php

    r2015 r2100  
    4646 
    4747      // include javascripts and stylesheets 
    48       require_once(sfConfig::get('sf_symfony_lib_dir').'/helper/TagHelper.php'); 
    49       require_once(sfConfig::get('sf_symfony_lib_dir').'/helper/AssetHelper.php'); 
     48      sfLoader::loadHelpers(array('Tag', 'Asset')); 
    5049      $html  = $this->include_javascripts($response); 
    5150      $html .= $this->include_stylesheets($response); 
  • branches/synace/test/functionnal/fixtures/project/apps/frontend/config/settings.yml

    r2069 r2100  
    9797#  
    9898#    escaping_strategy: bc 
    99 #    escaping_method:   ESC_ENTITIES 
     99#    escaping_method:   EscapingHelper::ESC_ENTITIES 
    100100# 
    101101#    prototype_web_dir: /sf/prototype