Example #1
0
 function addHelper($helper_name, $helper_path = null)
 {
     require_once AK_LIB_DIR . DS . 'AkActionView' . DS . 'AkHelperLoader.php';
     $helper_name = AkInflector::camelize($helper_name);
     $helper_path = empty($helper_path) ? $this->getPath() . DS . 'lib' . DS . AkInflector::underscore($helper_name) . '.php' : $helper_path;
     AkHelperLoader::addPluginHelper($helper_name, array('path' => $helper_path));
 }
Example #2
0
    function _getAvailableHelpers()
    {
        $helpers = array();
        if(empty($this->available_helpers)){
            if(defined('AK_SINTAGS_AVALABLE_HELPERS')){
                $helpers = unserialize(AK_SINTAGS_AVALABLE_HELPERS);
            }else{
                require_once(AK_LIB_DIR.DS.'AkActionView'.DS.'AkHelperLoader.php');
                if($underscored_helper_names = AkHelperLoader::getInstantiatedHelperNames()){
                    foreach ($underscored_helper_names as $underscored_helper_name){
                        $helper_class_name = AkInflector::camelize($underscored_helper_name);
                        if(class_exists($helper_class_name)){
                            $methods = get_class_methods($helper_class_name);
                            $vars=get_class_vars($helper_class_name);
                            if (AK_PHP5 && isset($vars['dynamic_helpers'])) {
                                $dynamic_helpers = Ak::toArray($vars['dynamic_helpers']);
                                foreach ($dynamic_helpers as $method_name){
                                    $this->dynamic_helpers[$method_name] = $underscored_helper_name;
                                }
                            }
                            foreach (get_class_methods($helper_class_name) as $method_name){
                                if($method_name[0] != '_'){
                                    $helpers[$method_name] = $underscored_helper_name;
                                }
                            }
                        }
                    }
                    $helpers['render'] = 'controller';
                    $helpers['render_partial'] = 'controller';
                }
            }
            $this->available_helpers = $helpers;
        }
        return $this->available_helpers;

    }
Example #3
0
 /**
  * Creates an instance of each available helper and links it into into current mailer.
  *
  * Mailer helpers work as Controller helpers but without the Request context
  */
 public function getHelpers()
 {
     require_once AK_LIB_DIR . DS . 'AkActionView' . DS . 'AkHelperLoader.php';
     $HelperLoader = new AkHelperLoader();
     $HelperLoader->setHandler(&$this);
     return $HelperLoader->getHelpersForMailer();
 }
Example #4
0
 /**
  * Creates an instance of each available helper and links it into into current controller.
  * 
  * Per example, if a helper TextHelper is located into the file text_helper.php. 
  * An instance is created on current controller
  * at $this->text_helper. This instance is also available on the view by calling $text_helper.
  * 
  * Helpers can be found at lib/AkActionView/helpers (this might change in a future)
  */
 function instantiateHelpers()
 {
     require_once(AK_LIB_DIR.DS.'AkActionView'.DS.'AkHelperLoader.php');
     $HelperLoader = new AkHelperLoader();
     $HelperLoader->setController(&$this);
     $HelperLoader->instantiateHelpers();
 }
Example #5
0
 public function addHelper($helper_name, $helper_path = null)
 {
     $helper_name = AkInflector::camelize($helper_name);
     $helper_path = empty($helper_path) ? $this->getPath() . DS . 'lib' . DS . AkInflector::underscore($helper_name) . '.php' : $helper_path;
     AkHelperLoader::addPluginHelper($helper_name, array('path' => $helper_path));
 }
Example #6
0
 /**
  * Creates an instance of each available helper and links it into into current controller.
  *
  * Per example, if a helper TextHelper is located into the file text_helper.php.
  * An instance is created on current controller
  * at $this->text_helper. This instance is also available on the view by calling $text_helper.
  *
  * Helpers can be found at lib/AkActionView/helpers (this might change in a future)
  */
 function instantiateHelpers()
 {
     Ak::setStaticVar('AkHelperLoader', $this->getHelperLoader());
     return;
     require_once AK_LIB_DIR . DS . 'AkActionView' . DS . 'AkHelperLoader.php';
     $HelperLoader = new AkHelperLoader();
     $HelperLoader->setController(&$this);
     $HelperLoader->instantiateHelpers();
     Ak::setStaticVar('AkHelperLoader', $HelperLoader);
 }
Example #7
0
 function _getHelpersChecksum()
 {
     if (!isset($this->_helpers_checksum)) {
         require_once AK_LIB_DIR . DS . 'AkActionView' . DS . 'AkHelperLoader.php';
         $this->_helpers_checksum = md5('v1' . serialize(AkHelperLoader::getInstantiatedHelperNames()));
     }
     return $this->_helpers_checksum;
 }
Example #8
0
 function getPluginHelperNames()
 {
     $handler =& $this->_Handler;
     $handler->plugin_helpers = !isset($handler->plugin_helpers) ? 'all' : $handler->plugin_helpers;
     $helper_names = AkHelperLoader::addPluginHelper(false);
     // Trick for getting helper names set by AkPlugin::addHelper
     if (empty($helper_names)) {
         return array();
     } elseif ($handler->plugin_helpers == 'all') {
         return $helper_names;
     } else {
         $selected_helper_names = array();
         foreach (Ak::toArray($handler->plugin_helpers) as $helper_name) {
             $helper_name = AkInflector::camelize($helper_name);
             if ($path = array_shift(array_keys($helper_names, AkInflector::camelize($helper_name)))) {
                 $selected_helper_names[$path] = $helper_names[$path];
             }
         }
         return $selected_helper_names;
     }
 }
Example #9
0
 public function _getHelpersChecksum()
 {
     if (!isset($this->_helpers_checksum)) {
         $this->_helpers_checksum = md5('v1' . serialize(AkHelperLoader::getInstantiatedHelperNames()));
     }
     return $this->_helpers_checksum;
 }