| [ Index ] |
PHP Cross Reference of Akelos Framework |
[Summary view] [Print] [Text view]
1 <?php 2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 3 4 // +----------------------------------------------------------------------+ 5 // | Akelos Framework - http://www.akelos.org | 6 // +----------------------------------------------------------------------+ 7 // | Copyright (c) 2002-2008, Akelos Media, S.L. & Bermi Ferrer Martinez | 8 // | Released under the GNU Lesser General Public License, see LICENSE.txt| 9 // +----------------------------------------------------------------------+ 10 11 /** 12 * @package ActiveSupport 13 * @subpackage Generators 14 * @author Bermi Ferrer <bermi a.t akelos c.om> 15 * @copyright Copyright (c) 2002-2008, Akelos Media, S.L. http://www.akelos.org 16 * @license GNU Lesser General Public License <http://www.gnu.org/copyleft/lesser.html> 17 */ 18 19 20 class MailerGenerator extends AkelosGenerator 21 { 22 var $command_values = array('class_name','(array)actions'); 23 24 function _preloadPaths() 25 { 26 $this->class_name = AkInflector::camelize($this->class_name); 27 $this->assignVarToTemplate('class_name', $this->class_name); 28 $this->actions = Ak::toArray(@$this->actions); 29 $this->assignVarToTemplate('actions', $this->actions); 30 $this->underscored_class_name = AkInflector::underscore($this->class_name); 31 $this->model_path = 'app'.DS.'models'.DS.$this->underscored_class_name.'.php'; 32 $this->installer_path = 'app'.DS.'installers'.DS.$this->underscored_class_name.'_installer.php'; 33 } 34 35 function hasCollisions() 36 { 37 $this->_preloadPaths(); 38 39 $this->collisions = array(); 40 41 $files = array( 42 AkInflector::toModelFilename($this->class_name), 43 AK_TEST_DIR.DS.'unit'.DS.'app'.DS.'models'.DS.$this->underscored_class_name.'.php' 44 ); 45 46 foreach ($this->actions as $action){ 47 $files[] = AK_VIEWS_DIR.DS.AkInflector::underscore($this->class_name).DS.$action.'.tpl'; 48 } 49 50 foreach ($files as $file_name){ 51 if(file_exists($file_name)){ 52 $this->collisions[] = Ak::t('%file_name file already exists',array('%file_name'=>$file_name)); 53 } 54 } 55 return count($this->collisions) > 0; 56 } 57 58 function generate() 59 { 60 $this->_preloadPaths(); 61 62 $this->class_name = AkInflector::camelize($this->class_name); 63 64 $files = array( 65 'mailer'=>AkInflector::toModelFilename($this->class_name), 66 'unit_test'=>AK_TEST_DIR.DS.'unit'.DS.'app'.DS.'models'.DS.$this->underscored_class_name.'.php' 67 ); 68 69 foreach ($files as $template=>$file_path){ 70 $this->save($file_path, $this->render($template)); 71 } 72 73 $mailer_views_folder = AK_VIEWS_DIR.DS.AkInflector::underscore($this->class_name); 74 @Ak::make_dir($mailer_views_folder); 75 76 foreach ($this->actions as $action){ 77 $this->assignVarToTemplate('action', $action); 78 $path = $mailer_views_folder.DS.$action.'.tpl'; 79 $this->assignVarToTemplate('path', $path); 80 $this->save($path, $this->render('view')); 81 } 82 } 83 } 84 85 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Oct 27 12:43:49 2008 | Cross-referenced by PHPXref 0.6 |