Changeset 384

Show
Ignore:
Timestamp:
10/05/07 20:46:36 (1 year ago)
Author:
bermiferrer
Message:

Adding support for module shared model. If a module admin exists and there is a file at app/models/admin_controller.php, it will be included before the module controller.
Adding support for module default layout. Controllers inside modules, will have app/views/layouts/module_name.tpl as their default layout.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/config/locales/en.php

    r383 r384  
    155155$dictionary['Please add force=true to the argument list in order to overwrite existing files.'] = 'Please add force=true to the argument list in order to overwrite existing files.'; 
    156156 
     157// 2007-10-06 3:15:57 
     158 
     159 
     160$dictionary['Could not find a helper to handle the method "%method" you called in your view'] = 'Could not find a helper to handle the method "%method" you called in your view'; 
     161 
    157162 
    158163?> 
  • trunk/config/locales/es.php

    r383 r384  
    149149$dictionary['Please add force=true to the argument list in order to overwrite existing files.'] = 'Please add force=true to the argument list in order to overwrite existing files.'; 
    150150 
     151// 2007-10-06 3:15:57 
     152 
     153 
     154$dictionary['Could not find a helper to handle the method "%method" you called in your view'] = 'Could not find a helper to handle the method "%method" you called in your view'; 
     155 
    151156 
    152157?> 
  • trunk/lib/AkActionController.php

    r383 r384  
    125125     
    126126    var $module_name; 
    127  
     127    var $_module_path; 
     128     
    128129    /** 
    129130     * Old fashioned way of dispatching requests. Please use AkDispatcher or roll your own. 
     
    235236    { 
    236237        $helpers = $this->getDefaultHelpers(); 
    237  
    238238        $helpers = array_merge($helpers, $this->getApplicationHelpers()); 
    239  
     239         
    240240        require_once(AK_LIB_DIR.DS.'AkActionView'.DS.'AkActionViewHelper.php'); 
    241241 
    242242        $current_controller_helper = $this->getControllerName(); 
    243         $current_controller_helper_file_name = AK_HELPERS_DIR.DS.AkInflector::underscore($current_controller_helper).'_helper.php'; 
     243        $current_controller_helper_file_name = AK_HELPERS_DIR.DS.$this->_module_path.AkInflector::underscore($current_controller_helper).'_helper.php'; 
     244         
    244245        if(file_exists($current_controller_helper_file_name)){ 
    245246            $helpers[$current_controller_helper_file_name] = $current_controller_helper; 
     
    286287    { 
    287288        $helper_names = array(); 
    288  
    289289        if ($this->app_helpers == 'all' ){ 
    290290            $available_helpers = Ak::dir(AK_HELPERS_DIR,array('dirs'=>false)); 
     
    520520        $this->_flash_handled ? null : $this->_handleFlashAttribute(); 
    521521 
    522         // Ror Backwards compatibility 
    523522        if(!is_array($options)){ 
    524523            return $this->renderFile(empty($options) ? $this->getDefaultTemplateName() : $options, $status, true); 
     
    778777 
    779778        if(!isset($this->controller_name)){ 
    780             $current_class_name = get_class($this); 
     779            $current_class_name = str_replace('_', '::', get_class($this)); 
    781780 
    782781            $included_controllers = $this->_getIncludedControllerNames(); 
    783             $lowercase_included_controllers = array_filter($included_controllers, 'strtolower'); 
     782            $lowercase_included_controllers = array_map('strtolower', $included_controllers); 
    784783            $key = array_search(strtolower($current_class_name), $lowercase_included_controllers, true); 
    785784            $found_controller = substr($included_controllers[$key], 0, -10); 
     
    807806            $this->module_name = join('/', array_map(array('AkInflector','underscore'), strstr($module_parts, '::') ? explode('::', $module_parts) : array($module_parts))); 
    808807            $this->controller_name = substr($this->controller_name, strrpos($this->controller_name, '::')+2); 
     808 
    809809        } 
    810810    } 
     
    13721372        if(!empty($layout)){ 
    13731373            $layout = strstr($layout,'/') || strstr($layout,DS) ? $layout : 'layouts'.DS.$layout; 
    1374             $layout = substr($layout,0,7) === 'layouts' ? AK_VIEWS_DIR.DS.$layout.'.tpl' : $layout.'.tpl'; 
     1374            $layout = substr($layout,0,7) === 'layouts' ?  
     1375            (empty($this->_module_path) ? AK_VIEWS_DIR.DS.$layout.'.tpl' : AK_VIEWS_DIR.DS.'layouts'.DS.trim($this->_module_path, DS).'.tpl') :  
     1376            $layout.'.tpl'; 
    13751377            if (file_exists($layout)) { 
    13761378                return $layout; 
  • trunk/lib/AkRequest.php

    r383 r384  
    746746        if(!empty($params['module'])){ 
    747747            $module_path = trim(str_replace(array('/','\\'), DS, Ak::sanitize_include($params['module'], 'high')), DS).DS; 
     748            $module_shared_model = AK_CONTROLLERS_DIR.DS.trim($module_path,DS).'_controller.php'; 
    748749            $module_class_peffix = str_replace(' ','_',AkInflector::titleize(str_replace(DS,' ', trim($module_path, DS)))).'_'; 
    749750        } 
     
    753754        $controller_path = AK_CONTROLLERS_DIR.DS.$module_path.$controller_file_name; 
    754755        include_once(AK_APP_DIR.DS.'application_controller.php'); 
     756         
     757        if(!empty($module_path) && file_exists($module_shared_model)){ 
     758            include_once($module_shared_model); 
     759        } 
     760         
    755761        if(@!include_once($controller_path)){ 
    756762            trigger_error(Ak::t('Could not find the file /app/controllers/<i>%controller_file_name</i> for '.