Server IP : 103.233.192.212 / Your IP : 3.22.51.104 Web Server : Apache/2 System : Linux sv1.inde.co.th 3.10.0-1160.36.2.el7.x86_64 #1 SMP Wed Jul 21 11:57:15 UTC 2021 x86_64 User : sumpatuan ( 1058) PHP Version : 5.5.38 Disable Function : symlink,shell_exec,exec,proc_close,proc_open,popen,system,dl,putenv,passthru,escapeshellarg,escapeshellcmd,pcntl_exec,proc_get_status,proc_nice,proc_terminate,pclose,ini_alter,virtual,openlog,ini_restore MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/sumpatuan/public_html/backup/framework/gii/generators/module/ |
Upload File : |
<?php class ModuleCode extends CCodeModel { public $moduleID; public function rules() { return array_merge(parent::rules(), array( array('moduleID', 'filter', 'filter'=>'trim'), array('moduleID', 'required'), array('moduleID', 'match', 'pattern'=>'/^\w+$/', 'message'=>'{attribute} should only contain word characters.'), )); } public function attributeLabels() { return array_merge(parent::attributeLabels(), array( 'moduleID'=>'Module ID', )); } public function successMessage() { if(Yii::app()->hasModule($this->moduleID)) return 'The module has been generated successfully. You may '.CHtml::link('try it now', Yii::app()->createUrl($this->moduleID), array('target'=>'_blank')).'.'; $output=<<<EOD <p>The module has been generated successfully.</p> <p>To access the module, you need to modify the application configuration as follows:</p> EOD; $code=<<<EOD <?php return array( 'modules'=>array( '{$this->moduleID}', ), ...... ); EOD; return $output.highlight_string($code,true); } public function prepare() { $this->files=array(); $templatePath=$this->templatePath; $modulePath=$this->modulePath; $moduleTemplateFile=$templatePath.DIRECTORY_SEPARATOR.'module.php'; $this->files[]=new CCodeFile( $modulePath.'/'.$this->moduleClass.'.php', $this->render($moduleTemplateFile) ); $files=CFileHelper::findFiles($templatePath,array( 'exclude'=>array( '.svn', '.gitignore' ), )); foreach($files as $file) { if($file!==$moduleTemplateFile) { if(CFileHelper::getExtension($file)==='php') $content=$this->render($file); elseif(basename($file)==='.yii') // an empty directory { $file=dirname($file); $content=null; } else $content=file_get_contents($file); $this->files[]=new CCodeFile( $modulePath.substr($file,strlen($templatePath)), $content ); } } } public function getModuleClass() { return ucfirst($this->moduleID).'Module'; } public function getModulePath() { return Yii::app()->modulePath.DIRECTORY_SEPARATOR.$this->moduleID; } }