@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -Yii::import('cii.commands.CiiConsoleCommand');
|
|
| 3 | +Yii::import ('cii.commands.CiiConsoleCommand');
|
|
| 4 | 4 | class CiiCacheCommand extends CiiConsoleCommand |
| 5 | 5 | {
|
| 6 | - public function actionFlush() |
|
| 6 | + public function actionFlush () |
|
| 7 | 7 | {
|
| 8 | - $this->log(Yii::app()->cache->flush() ? "Cache flushed" : "Unable to flush cache. Are we connected?"); |
|
| 9 | - unlink(__DIR__.DS.'..'.DS.'runtime'.DS.'modules.config.php'); |
|
| 8 | + $this->log (Yii::app ()->cache->flush () ? "Cache flushed" : "Unable to flush cache. Are we connected?"); |
|
| 9 | + unlink (__DIR__ . DS . '..' . DS . 'runtime' . DS . 'modules.config.php'); |
|
| 10 | 10 | return; |
| 11 | 11 | } |
| 12 | 12 | } |
@@ -1,10 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | Yii::import('cii.commands.CiiConsoleCommand');
|
| 4 | -class CiiCacheCommand extends CiiConsoleCommand |
|
| 5 | -{
|
|
| 6 | - public function actionFlush() |
|
| 7 | - {
|
|
| 4 | +class CiiCacheCommand extends CiiConsoleCommand |
|
| 5 | +{ |
|
| 6 | + public function actionFlush() |
|
| 7 | + { |
|
| 8 | 8 | $this->log(Yii::app()->cache->flush() ? "Cache flushed" : "Unable to flush cache. Are we connected?"); |
| 9 | 9 | unlink(__DIR__.DS.'..'.DS.'runtime'.DS.'modules.config.php'); |
| 10 | 10 | return; |
@@ -1,36 +1,36 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -Yii::import('cii.commands.CiiConsoleCommand');
|
|
| 3 | +Yii::import ('cii.commands.CiiConsoleCommand');
|
|
| 4 | 4 | class CiiClassMapCommand extends CiiConsoleCommand |
| 5 | 5 | {
|
| 6 | - public function actionIndex() |
|
| 6 | + public function actionIndex () |
|
| 7 | 7 | {
|
| 8 | 8 | $data = "<?php\n"; |
| 9 | 9 | $data .= '$basePath = dirname(__FILE__) . \'/..\';' . "\n"; |
| 10 | 10 | $data .= 'Yii::$classMap = ' . "array(\n"; |
| 11 | 11 | |
| 12 | - $this->updateDataPath(Yii::getPathOfAlias('ext'), $data);
|
|
| 13 | - $this->updateDataPath( Yii::getPathOfAlias('application.models'), $data);
|
|
| 14 | - $this->updateDataPath(Yii::getPathOfAlias('application.controllers'), $data);
|
|
| 12 | + $this->updateDataPath (Yii::getPathOfAlias ('ext'), $data);
|
|
| 13 | + $this->updateDataPath (Yii::getPathOfAlias ('application.models'), $data);
|
|
| 14 | + $this->updateDataPath (Yii::getPathOfAlias ('application.controllers'), $data);
|
|
| 15 | 15 | |
| 16 | - $data .= ");\n"; |
|
| 16 | + $data .= ");\n"; |
|
| 17 | 17 | |
| 18 | - $handle = fopen(Yii::getPathOfAlias('application.config') . DIRECTORY_SEPARATOR . 'classmap.php', 'w+');
|
|
| 19 | - fwrite($handle, $data); |
|
| 20 | - fclose($handle); |
|
| 18 | + $handle = fopen (Yii::getPathOfAlias ('application.config') . DIRECTORY_SEPARATOR . 'classmap.php', 'w+');
|
|
| 19 | + fwrite ($handle, $data); |
|
| 20 | + fclose ($handle); |
|
| 21 | 21 | return; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - private function updateDataPath($path, &$data) |
|
| 24 | + private function updateDataPath ($path, &$data) |
|
| 25 | 25 | {
|
| 26 | - $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST); |
|
| 27 | - foreach($objects as $name => $object) |
|
| 26 | + $objects = new RecursiveIteratorIterator (new RecursiveDirectoryIterator ($path), RecursiveIteratorIterator::SELF_FIRST); |
|
| 27 | + foreach ($objects as $name => $object) |
|
| 28 | 28 | {
|
| 29 | - if (strpos($name, '.php') !== false && strpos($name, 'gii') === false) |
|
| 29 | + if (strpos ($name, '.php') !== false && strpos ($name, 'gii') === false) |
|
| 30 | 30 | {
|
| 31 | - $id = str_replace('.php', '', substr( $name, strrpos( $name, '/' )+1 ));
|
|
| 32 | - if ($this->startsWithUpper($id)) |
|
| 33 | - $data .= " '" . $id . "' => " . '$basePath . \'' . str_replace('/var/www/ciims/protected', '', $name) . "',\n";
|
|
| 31 | + $id = str_replace ('.php', '', substr ($name, strrpos ($name, '/') + 1));
|
|
| 32 | + if ($this->startsWithUpper ($id)) |
|
| 33 | + $data .= " '" . $id . "' => " . '$basePath . \'' . str_replace ('/var/www/ciims/protected', '', $name) . "',\n";
|
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | /** |
| 41 | 41 | * @param string $str |
| 42 | 42 | */ |
| 43 | - private function startsWithUpper($str) |
|
| 43 | + private function startsWithUpper ($str) |
|
| 44 | 44 | {
|
| 45 | 45 | $chr = mb_substr ($str, 0, 1, "UTF-8"); |
| 46 | - return mb_strtolower($chr, "UTF-8") != $chr; |
|
| 46 | + return mb_strtolower ($chr, "UTF-8") != $chr; |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | Yii::import('cii.commands.CiiConsoleCommand');
|
| 4 | -class CiiClassMapCommand extends CiiConsoleCommand |
|
| 5 | -{
|
|
| 6 | - public function actionIndex() |
|
| 7 | - {
|
|
| 4 | +class CiiClassMapCommand extends CiiConsoleCommand |
|
| 5 | +{ |
|
| 6 | + public function actionIndex() |
|
| 7 | + { |
|
| 8 | 8 | $data = "<?php\n"; |
| 9 | 9 | $data .= '$basePath = dirname(__FILE__) . \'/..\';' . "\n"; |
| 10 | 10 | $data .= 'Yii::$classMap = ' . "array(\n"; |
@@ -21,16 +21,17 @@ discard block |
||
| 21 | 21 | return; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - private function updateDataPath($path, &$data) |
|
| 25 | - {
|
|
| 24 | + private function updateDataPath($path, &$data) |
|
| 25 | + { |
|
| 26 | 26 | $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST); |
| 27 | 27 | foreach($objects as $name => $object) |
| 28 | 28 | {
|
| 29 | 29 | if (strpos($name, '.php') !== false && strpos($name, 'gii') === false) |
| 30 | 30 | {
|
| 31 | 31 | $id = str_replace('.php', '', substr( $name, strrpos( $name, '/' )+1 ));
|
| 32 | - if ($this->startsWithUpper($id)) |
|
| 33 | - $data .= " '" . $id . "' => " . '$basePath . \'' . str_replace('/var/www/ciims/protected', '', $name) . "',\n";
|
|
| 32 | + if ($this->startsWithUpper($id)) { |
|
| 33 | + $data .= " '" . $id . "' => " . '$basePath . \'' . str_replace('/var/www/ciims/protected', '', $name) . "',\n"; |
|
| 34 | + } |
|
| 34 | 35 | } |
| 35 | 36 | } |
| 36 | 37 | |
@@ -40,8 +41,8 @@ discard block |
||
| 40 | 41 | /** |
| 41 | 42 | * @param string $str |
| 42 | 43 | */ |
| 43 | - private function startsWithUpper($str) |
|
| 44 | - {
|
|
| 44 | + private function startsWithUpper($str) |
|
| 45 | + { |
|
| 45 | 46 | $chr = mb_substr ($str, 0, 1, "UTF-8"); |
| 46 | 47 | return mb_strtolower($chr, "UTF-8") != $chr; |
| 47 | 48 | } |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | /** |
| 3 | 3 | * This is an alternative implementation of the MessageCommand class, designed to work with CiiMS' modules and themes |
| 4 | 4 | */ |
| 5 | -Yii::import('cii.commands.CiiConsoleCommand'); |
|
| 5 | +Yii::import ('cii.commands.CiiConsoleCommand'); |
|
| 6 | 6 | class CiiMessageCommand extends CiiConsoleCommand |
| 7 | 7 | { |
| 8 | 8 | |
@@ -28,12 +28,12 @@ discard block |
||
| 28 | 28 | * Default args |
| 29 | 29 | * @return array |
| 30 | 30 | */ |
| 31 | - private function getArgs() |
|
| 31 | + private function getArgs () |
|
| 32 | 32 | { |
| 33 | 33 | return array( |
| 34 | 34 | 'type' => 'core', |
| 35 | - 'sourcePath' => Yii::getPathOfAlias('application').DS, |
|
| 36 | - 'messagePath' => Yii::getPathOfAlias('application.messages').DS, |
|
| 35 | + 'sourcePath' => Yii::getPathOfAlias ('application') . DS, |
|
| 36 | + 'messagePath' => Yii::getPathOfAlias ('application.messages') . DS, |
|
| 37 | 37 | 'languages' => array('en_us'), |
| 38 | 38 | 'fileTypes' => array('php'), |
| 39 | 39 | 'overwrite' => true, |
@@ -61,102 +61,102 @@ discard block |
||
| 61 | 61 | /** |
| 62 | 62 | * Init method |
| 63 | 63 | */ |
| 64 | - public function init() |
|
| 64 | + public function init () |
|
| 65 | 65 | { |
| 66 | - $this->_config = $this->getArgs(); |
|
| 66 | + $this->_config = $this->getArgs (); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * Generates translation files for a given mtheme |
| 71 | 71 | * @param string $name The name of the theme to generate translations for |
| 72 | 72 | */ |
| 73 | - public function actionThemes($name=NULL) |
|
| 73 | + public function actionThemes ($name = NULL) |
|
| 74 | 74 | { |
| 75 | 75 | if ($name === NULL) |
| 76 | - $this->usageError('A theme was not specified for translations'); |
|
| 76 | + $this->usageError ('A theme was not specified for translations'); |
|
| 77 | 77 | |
| 78 | 78 | $this->_config['type'] = 'theme'; |
| 79 | - array_push($this->_config['exclude'], 'modules'); |
|
| 80 | - $this->_config['sourcePath'] .= '..'.DS.'themes' . DS . $name . DS; |
|
| 81 | - $this->_config['messagePath'] = $this->_config['sourcePath'].'messages'; |
|
| 82 | - $this->execute(); |
|
| 79 | + array_push ($this->_config['exclude'], 'modules'); |
|
| 80 | + $this->_config['sourcePath'] .= '..' . DS . 'themes' . DS . $name . DS; |
|
| 81 | + $this->_config['messagePath'] = $this->_config['sourcePath'] . 'messages'; |
|
| 82 | + $this->execute (); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * Generates translation files for a given module |
| 87 | 87 | * @param string $name The name of the module to generate translations for |
| 88 | 88 | */ |
| 89 | - public function actionModules($name=NULL) |
|
| 89 | + public function actionModules ($name = NULL) |
|
| 90 | 90 | { |
| 91 | 91 | if ($name === NULL) |
| 92 | - $this->usageError('A module was not specified for translations'); |
|
| 92 | + $this->usageError ('A module was not specified for translations'); |
|
| 93 | 93 | |
| 94 | 94 | $this->_config['type'] = 'module'; |
| 95 | - array_push($this->_config['exclude'], 'themes'); |
|
| 95 | + array_push ($this->_config['exclude'], 'themes'); |
|
| 96 | 96 | unset($this->_config['exclude']['modules']); |
| 97 | - $this->_config['sourcePath'] = Yii::getPathOfAlias('application.modules') . DS . $name . DS; |
|
| 98 | - $this->_config['messagePath'] = $this->_config['sourcePath'].'messages'; |
|
| 99 | - $this->execute($this->_config); |
|
| 97 | + $this->_config['sourcePath'] = Yii::getPathOfAlias ('application.modules') . DS . $name . DS; |
|
| 98 | + $this->_config['messagePath'] = $this->_config['sourcePath'] . 'messages'; |
|
| 99 | + $this->execute ($this->_config); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | 103 | * Defualt action |
| 104 | 104 | */ |
| 105 | - public function actionIndex() |
|
| 105 | + public function actionIndex () |
|
| 106 | 106 | { |
| 107 | - array_push($this->_config['exclude'], 'modules'); |
|
| 108 | - array_push($this->_config['exclude'], 'themes'); |
|
| 109 | - return $this->execute(); |
|
| 107 | + array_push ($this->_config['exclude'], 'modules'); |
|
| 108 | + array_push ($this->_config['exclude'], 'themes'); |
|
| 109 | + return $this->execute (); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * Execute the action. |
| 114 | 114 | */ |
| 115 | - private function execute() |
|
| 115 | + private function execute () |
|
| 116 | 116 | { |
| 117 | 117 | // Validate the configuration |
| 118 | - extract($this->_config); |
|
| 119 | - $this->validateConfig(); |
|
| 118 | + extract ($this->_config); |
|
| 119 | + $this->validateConfig (); |
|
| 120 | 120 | |
| 121 | 121 | // Determine the messages |
| 122 | - foreach($this->getFiles() as $file) |
|
| 123 | - $this->_messages = array_merge_recursive($this->_messages,$this->extractMessages($file,$this->_translator)); |
|
| 122 | + foreach ($this->getFiles () as $file) |
|
| 123 | + $this->_messages = array_merge_recursive ($this->_messages, $this->extractMessages ($file, $this->_translator)); |
|
| 124 | 124 | |
| 125 | - foreach($languages as $language) |
|
| 125 | + foreach ($languages as $language) |
|
| 126 | 126 | { |
| 127 | - $dir = $messagePath.DS.$language; |
|
| 127 | + $dir = $messagePath . DS . $language; |
|
| 128 | 128 | |
| 129 | - $this->createDirectory($dir); |
|
| 129 | + $this->createDirectory ($dir); |
|
| 130 | 130 | |
| 131 | 131 | foreach ($this->_messages as $category=>$msgs) |
| 132 | 132 | { |
| 133 | - $msgs = array_values(array_unique($msgs)); |
|
| 133 | + $msgs = array_values (array_unique ($msgs)); |
|
| 134 | 134 | |
| 135 | - $dir = $this->_config['messagePath'].DS.$language; |
|
| 135 | + $dir = $this->_config['messagePath'] . DS . $language; |
|
| 136 | 136 | |
| 137 | - if ($this->_config['type'] == 'theme') |
|
| 137 | + if ($this->_config['type'] == 'theme') |
|
| 138 | 138 | { |
| 139 | - $data = explode('.', $category); |
|
| 139 | + $data = explode ('.', $category); |
|
| 140 | 140 | unset($data[0]); |
| 141 | - $dirPath = implode(DS, $data); |
|
| 141 | + $dirPath = implode (DS, $data); |
|
| 142 | 142 | } |
| 143 | 143 | else if ($this->_config['type'] == 'module') |
| 144 | 144 | { |
| 145 | - $data = explode('.', $category); |
|
| 145 | + $data = explode ('.', $category); |
|
| 146 | 146 | unset($data[0]); |
| 147 | 147 | unset($data[1]); |
| 148 | - $dirPath = implode(DS, $data); |
|
| 148 | + $dirPath = implode (DS, $data); |
|
| 149 | 149 | } |
| 150 | 150 | else |
| 151 | - $dirPath = implode(DS, explode('.', $category)); |
|
| 151 | + $dirPath = implode (DS, explode ('.', $category)); |
|
| 152 | 152 | |
| 153 | 153 | if (empty($dirPath)) |
| 154 | 154 | continue; |
| 155 | 155 | |
| 156 | - $this->createDirectory($dir . DS . $dirPath); |
|
| 157 | - $this->createDirectory($dir . DS . $language); |
|
| 156 | + $this->createDirectory ($dir . DS . $dirPath); |
|
| 157 | + $this->createDirectory ($dir . DS . $language); |
|
| 158 | 158 | |
| 159 | - $this->generateMessageFile($msgs,$dir.DS.$dirPath.'.php',$overwrite,$removeOld,$sort); |
|
| 159 | + $this->generateMessageFile ($msgs, $dir . DS . $dirPath . '.php', $overwrite, $removeOld, $sort); |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | } |
@@ -166,12 +166,12 @@ discard block |
||
| 166 | 166 | * @param string $directory |
| 167 | 167 | * @return boolean |
| 168 | 168 | */ |
| 169 | - private function createDirectory($directory) |
|
| 169 | + private function createDirectory ($directory) |
|
| 170 | 170 | { |
| 171 | - if (!is_dir($directory)) |
|
| 171 | + if (!is_dir ($directory)) |
|
| 172 | 172 | { |
| 173 | - if (!mkdir($directory, 0777, true)) |
|
| 174 | - $this->usageError('The directory ' . $directory .' could not be created. Please make sure this process has write access to this directory.'); |
|
| 173 | + if (!mkdir ($directory, 0777, true)) |
|
| 174 | + $this->usageError ('The directory ' . $directory . ' could not be created. Please make sure this process has write access to this directory.'); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | return true; |
@@ -181,10 +181,10 @@ discard block |
||
| 181 | 181 | * Retrieves the files that should be translated |
| 182 | 182 | * @return array $files |
| 183 | 183 | */ |
| 184 | - private function getFiles() |
|
| 184 | + private function getFiles () |
|
| 185 | 185 | { |
| 186 | - extract($this->_config); |
|
| 187 | - $files = CFileHelper::findFiles(realpath($sourcePath),array( |
|
| 186 | + extract ($this->_config); |
|
| 187 | + $files = CFileHelper::findFiles (realpath ($sourcePath), array( |
|
| 188 | 188 | 'fileTypes' => $fileTypes, |
| 189 | 189 | 'exclude' => $exclude |
| 190 | 190 | )); |
@@ -192,11 +192,11 @@ discard block |
||
| 192 | 192 | // Strip out all extensions |
| 193 | 193 | foreach ($files as $k=>$file) |
| 194 | 194 | { |
| 195 | - if (strpos($file, 'extensions') !== false) |
|
| 195 | + if (strpos ($file, 'extensions') !== false) |
|
| 196 | 196 | unset($files[$k]); |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - reset($files); |
|
| 199 | + reset ($files); |
|
| 200 | 200 | |
| 201 | 201 | return $files; |
| 202 | 202 | } |
@@ -204,58 +204,58 @@ discard block |
||
| 204 | 204 | /** |
| 205 | 205 | * Does basic validation on the configuration options |
| 206 | 206 | */ |
| 207 | - private function validateConfig() |
|
| 207 | + private function validateConfig () |
|
| 208 | 208 | { |
| 209 | - extract($this->_config); |
|
| 209 | + extract ($this->_config); |
|
| 210 | 210 | |
| 211 | - if(!isset($sourcePath,$messagePath,$languages)) |
|
| 212 | - $this->usageError('The configuration file must specify "sourcePath", "messagePath" and "languages".'); |
|
| 211 | + if (!isset($sourcePath, $messagePath, $languages)) |
|
| 212 | + $this->usageError ('The configuration file must specify "sourcePath", "messagePath" and "languages".'); |
|
| 213 | 213 | |
| 214 | - if(!is_dir($sourcePath)) |
|
| 215 | - $this->usageError("The source path $sourcePath is not a valid directory."); |
|
| 214 | + if (!is_dir ($sourcePath)) |
|
| 215 | + $this->usageError ("The source path $sourcePath is not a valid directory."); |
|
| 216 | 216 | |
| 217 | - if(!is_dir($messagePath)) |
|
| 218 | - $this->usageError("The message path $messagePath is not a valid directory."); |
|
| 217 | + if (!is_dir ($messagePath)) |
|
| 218 | + $this->usageError ("The message path $messagePath is not a valid directory."); |
|
| 219 | 219 | |
| 220 | - if(empty($languages)) |
|
| 221 | - $this->usageError("Languages cannot be empty."); |
|
| 220 | + if (empty($languages)) |
|
| 221 | + $this->usageError ("Languages cannot be empty."); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | /** |
| 225 | 225 | * @param string $translator |
| 226 | 226 | */ |
| 227 | - protected function extractMessages($fileName,$translator) |
|
| 227 | + protected function extractMessages ($fileName, $translator) |
|
| 228 | 228 | { |
| 229 | - $subject=file_get_contents($fileName); |
|
| 230 | - $messages=array(); |
|
| 231 | - if(!is_array($translator)) |
|
| 232 | - $translator=array($translator); |
|
| 229 | + $subject = file_get_contents ($fileName); |
|
| 230 | + $messages = array(); |
|
| 231 | + if (!is_array ($translator)) |
|
| 232 | + $translator = array($translator); |
|
| 233 | 233 | |
| 234 | 234 | foreach ($translator as $currentTranslator) |
| 235 | 235 | { |
| 236 | - $n=preg_match_all('/\b'.$currentTranslator.'\s*\(\s*(\'[\w.\/]*?(?<!\.)\'|"[\w.]*?(?<!\.)")\s*,\s*(\'.*?(?<!\\\\)\'|".*?(?<!\\\\)")\s*[,\)]/s',$subject,$matches,PREG_SET_ORDER); |
|
| 236 | + $n = preg_match_all ('/\b' . $currentTranslator . '\s*\(\s*(\'[\w.\/]*?(?<!\.)\'|"[\w.]*?(?<!\.)")\s*,\s*(\'.*?(?<!\\\\)\'|".*?(?<!\\\\)")\s*[,\)]/s', $subject, $matches, PREG_SET_ORDER); |
|
| 237 | 237 | |
| 238 | - for($i=0; $i<$n; ++$i) |
|
| 238 | + for ($i = 0; $i < $n; ++$i) |
|
| 239 | 239 | { |
| 240 | - if(($pos=strpos($matches[$i][1],'.'))!==false) |
|
| 240 | + if (($pos = strpos ($matches[$i][1], '.')) !== false) |
|
| 241 | 241 | { |
| 242 | - if (strpos($matches[$i][1],'Dashboard')!==false || strpos($matches[$i][1],'Hybridauth')!==false || strpos($matches[$i][1],'Install')!==false) |
|
| 243 | - $category='module.'.substr($matches[$i][1],1,-1); |
|
| 244 | - else if (strpos($matches[$i][1],'Theme')!==false) |
|
| 245 | - $category=$matches[$i][1]; |
|
| 242 | + if (strpos ($matches[$i][1], 'Dashboard') !== false || strpos ($matches[$i][1], 'Hybridauth') !== false || strpos ($matches[$i][1], 'Install') !== false) |
|
| 243 | + $category = 'module.' . substr ($matches[$i][1], 1, -1); |
|
| 244 | + else if (strpos ($matches[$i][1], 'Theme') !== false) |
|
| 245 | + $category = $matches[$i][1]; |
|
| 246 | 246 | else |
| 247 | - $category=substr($matches[$i][1],$pos+1,-1); |
|
| 247 | + $category = substr ($matches[$i][1], $pos + 1, -1); |
|
| 248 | 248 | } |
| 249 | 249 | else |
| 250 | - $category=substr($matches[$i][1],1,-1); |
|
| 250 | + $category = substr ($matches[$i][1], 1, -1); |
|
| 251 | 251 | |
| 252 | 252 | |
| 253 | - $message=$matches[$i][2]; |
|
| 253 | + $message = $matches[$i][2]; |
|
| 254 | 254 | |
| 255 | - $category = str_replace("'", '', $category); |
|
| 255 | + $category = str_replace ("'", '', $category); |
|
| 256 | 256 | |
| 257 | 257 | // This is how Yii does it |
| 258 | - $messages[$category][]=eval("return $message;"); // use eval to eliminate quote escape |
|
| 258 | + $messages[$category][] = eval("return $message;"); // use eval to eliminate quote escape |
|
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | |
@@ -268,74 +268,74 @@ discard block |
||
| 268 | 268 | * @param boolean $removeOld |
| 269 | 269 | * @param boolean $sort |
| 270 | 270 | */ |
| 271 | - protected function generateMessageFile($messages,$fileName,$overwrite,$removeOld,$sort) |
|
| 271 | + protected function generateMessageFile ($messages, $fileName, $overwrite, $removeOld, $sort) |
|
| 272 | 272 | { |
| 273 | 273 | echo "Saving messages to $fileName..."; |
| 274 | - if(is_file($fileName)) |
|
| 274 | + if (is_file ($fileName)) |
|
| 275 | 275 | { |
| 276 | - $translated=require($fileName); |
|
| 277 | - sort($messages); |
|
| 278 | - ksort($translated); |
|
| 279 | - if(array_keys($translated)==$messages) |
|
| 276 | + $translated = require($fileName); |
|
| 277 | + sort ($messages); |
|
| 278 | + ksort ($translated); |
|
| 279 | + if (array_keys ($translated) == $messages) |
|
| 280 | 280 | { |
| 281 | 281 | echo "nothing new...skipped.\n"; |
| 282 | 282 | return; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | - $merged=array(); |
|
| 286 | - $untranslated=array(); |
|
| 285 | + $merged = array(); |
|
| 286 | + $untranslated = array(); |
|
| 287 | 287 | |
| 288 | - foreach($messages as $message) |
|
| 288 | + foreach ($messages as $message) |
|
| 289 | 289 | { |
| 290 | - if(array_key_exists($message,$translated) && strlen($translated[$message])>0) |
|
| 291 | - $merged[$message]=$translated[$message]; |
|
| 290 | + if (array_key_exists ($message, $translated) && strlen ($translated[$message]) > 0) |
|
| 291 | + $merged[$message] = $translated[$message]; |
|
| 292 | 292 | else |
| 293 | - $untranslated[]=$message; |
|
| 293 | + $untranslated[] = $message; |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - ksort($merged); |
|
| 297 | - sort($untranslated); |
|
| 298 | - $todo=array(); |
|
| 296 | + ksort ($merged); |
|
| 297 | + sort ($untranslated); |
|
| 298 | + $todo = array(); |
|
| 299 | 299 | |
| 300 | - foreach($untranslated as $message) |
|
| 301 | - $todo[$message]=''; |
|
| 300 | + foreach ($untranslated as $message) |
|
| 301 | + $todo[$message] = ''; |
|
| 302 | 302 | |
| 303 | - ksort($translated); |
|
| 303 | + ksort ($translated); |
|
| 304 | 304 | |
| 305 | - foreach($translated as $message=>$translation) |
|
| 305 | + foreach ($translated as $message=>$translation) |
|
| 306 | 306 | { |
| 307 | - if(!isset($merged[$message]) && !isset($todo[$message]) && !$removeOld) |
|
| 307 | + if (!isset($merged[$message]) && !isset($todo[$message]) && !$removeOld) |
|
| 308 | 308 | { |
| 309 | - if(substr($translation,0,2)==='@@' && substr($translation,-2)==='@@') |
|
| 310 | - $todo[$message]=$translation; |
|
| 309 | + if (substr ($translation, 0, 2) === '@@' && substr ($translation, -2) === '@@') |
|
| 310 | + $todo[$message] = $translation; |
|
| 311 | 311 | else if ($translation == '') |
| 312 | 312 | $todo[$message] = ''; |
| 313 | 313 | else |
| 314 | - $todo[$message]='@@'.$translation.'@@'; |
|
| 314 | + $todo[$message] = '@@' . $translation . '@@'; |
|
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - $merged=array_merge($todo,$merged); |
|
| 318 | + $merged = array_merge ($todo, $merged); |
|
| 319 | 319 | |
| 320 | - if($sort) |
|
| 321 | - ksort($merged); |
|
| 320 | + if ($sort) |
|
| 321 | + ksort ($merged); |
|
| 322 | 322 | |
| 323 | - if($overwrite === false) |
|
| 324 | - $fileName.='.merged'; |
|
| 323 | + if ($overwrite === false) |
|
| 324 | + $fileName .= '.merged'; |
|
| 325 | 325 | |
| 326 | 326 | echo "translation merged.\n"; |
| 327 | 327 | } |
| 328 | 328 | else |
| 329 | 329 | { |
| 330 | - $merged=array(); |
|
| 331 | - foreach($messages as $message) |
|
| 332 | - $merged[$message]=''; |
|
| 330 | + $merged = array(); |
|
| 331 | + foreach ($messages as $message) |
|
| 332 | + $merged[$message] = ''; |
|
| 333 | 333 | |
| 334 | - ksort($merged); |
|
| 334 | + ksort ($merged); |
|
| 335 | 335 | echo "saved.\n"; |
| 336 | 336 | } |
| 337 | - $array=str_replace("\r",'',var_export($merged,true)); |
|
| 338 | - $content=<<<EOD |
|
| 337 | + $array = str_replace ("\r", '', var_export ($merged, true)); |
|
| 338 | + $content = <<<EOD |
|
| 339 | 339 | <?php |
| 340 | 340 | /** |
| 341 | 341 | * Message translations. |
@@ -357,6 +357,6 @@ discard block |
||
| 357 | 357 | return $array; |
| 358 | 358 | |
| 359 | 359 | EOD; |
| 360 | - file_put_contents($fileName, $content); |
|
| 360 | + file_put_contents ($fileName, $content); |
|
| 361 | 361 | } |
| 362 | 362 | } |
@@ -72,8 +72,9 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function actionThemes($name=NULL) |
| 74 | 74 | { |
| 75 | - if ($name === NULL) |
|
| 76 | - $this->usageError('A theme was not specified for translations'); |
|
| 75 | + if ($name === NULL) { |
|
| 76 | + $this->usageError('A theme was not specified for translations'); |
|
| 77 | + } |
|
| 77 | 78 | |
| 78 | 79 | $this->_config['type'] = 'theme'; |
| 79 | 80 | array_push($this->_config['exclude'], 'modules'); |
@@ -88,8 +89,9 @@ discard block |
||
| 88 | 89 | */ |
| 89 | 90 | public function actionModules($name=NULL) |
| 90 | 91 | { |
| 91 | - if ($name === NULL) |
|
| 92 | - $this->usageError('A module was not specified for translations'); |
|
| 92 | + if ($name === NULL) { |
|
| 93 | + $this->usageError('A module was not specified for translations'); |
|
| 94 | + } |
|
| 93 | 95 | |
| 94 | 96 | $this->_config['type'] = 'module'; |
| 95 | 97 | array_push($this->_config['exclude'], 'themes'); |
@@ -119,8 +121,9 @@ discard block |
||
| 119 | 121 | $this->validateConfig(); |
| 120 | 122 | |
| 121 | 123 | // Determine the messages |
| 122 | - foreach($this->getFiles() as $file) |
|
| 123 | - $this->_messages = array_merge_recursive($this->_messages,$this->extractMessages($file,$this->_translator)); |
|
| 124 | + foreach($this->getFiles() as $file) { |
|
| 125 | + $this->_messages = array_merge_recursive($this->_messages,$this->extractMessages($file,$this->_translator)); |
|
| 126 | + } |
|
| 124 | 127 | |
| 125 | 128 | foreach($languages as $language) |
| 126 | 129 | { |
@@ -139,19 +142,19 @@ discard block |
||
| 139 | 142 | $data = explode('.', $category); |
| 140 | 143 | unset($data[0]); |
| 141 | 144 | $dirPath = implode(DS, $data); |
| 142 | - } |
|
| 143 | - else if ($this->_config['type'] == 'module') |
|
| 145 | + } else if ($this->_config['type'] == 'module') |
|
| 144 | 146 | { |
| 145 | 147 | $data = explode('.', $category); |
| 146 | 148 | unset($data[0]); |
| 147 | 149 | unset($data[1]); |
| 148 | 150 | $dirPath = implode(DS, $data); |
| 151 | + } else { |
|
| 152 | + $dirPath = implode(DS, explode('.', $category)); |
|
| 149 | 153 | } |
| 150 | - else |
|
| 151 | - $dirPath = implode(DS, explode('.', $category)); |
|
| 152 | 154 | |
| 153 | - if (empty($dirPath)) |
|
| 154 | - continue; |
|
| 155 | + if (empty($dirPath)) { |
|
| 156 | + continue; |
|
| 157 | + } |
|
| 155 | 158 | |
| 156 | 159 | $this->createDirectory($dir . DS . $dirPath); |
| 157 | 160 | $this->createDirectory($dir . DS . $language); |
@@ -170,8 +173,9 @@ discard block |
||
| 170 | 173 | { |
| 171 | 174 | if (!is_dir($directory)) |
| 172 | 175 | { |
| 173 | - if (!mkdir($directory, 0777, true)) |
|
| 174 | - $this->usageError('The directory ' . $directory .' could not be created. Please make sure this process has write access to this directory.'); |
|
| 176 | + if (!mkdir($directory, 0777, true)) { |
|
| 177 | + $this->usageError('The directory ' . $directory .' could not be created. Please make sure this process has write access to this directory.'); |
|
| 178 | + } |
|
| 175 | 179 | } |
| 176 | 180 | |
| 177 | 181 | return true; |
@@ -192,8 +196,9 @@ discard block |
||
| 192 | 196 | // Strip out all extensions |
| 193 | 197 | foreach ($files as $k=>$file) |
| 194 | 198 | { |
| 195 | - if (strpos($file, 'extensions') !== false) |
|
| 196 | - unset($files[$k]); |
|
| 199 | + if (strpos($file, 'extensions') !== false) { |
|
| 200 | + unset($files[$k]); |
|
| 201 | + } |
|
| 197 | 202 | } |
| 198 | 203 | |
| 199 | 204 | reset($files); |
@@ -208,17 +213,21 @@ discard block |
||
| 208 | 213 | { |
| 209 | 214 | extract($this->_config); |
| 210 | 215 | |
| 211 | - if(!isset($sourcePath,$messagePath,$languages)) |
|
| 212 | - $this->usageError('The configuration file must specify "sourcePath", "messagePath" and "languages".'); |
|
| 216 | + if(!isset($sourcePath,$messagePath,$languages)) { |
|
| 217 | + $this->usageError('The configuration file must specify "sourcePath", "messagePath" and "languages".'); |
|
| 218 | + } |
|
| 213 | 219 | |
| 214 | - if(!is_dir($sourcePath)) |
|
| 215 | - $this->usageError("The source path $sourcePath is not a valid directory."); |
|
| 220 | + if(!is_dir($sourcePath)) { |
|
| 221 | + $this->usageError("The source path $sourcePath is not a valid directory."); |
|
| 222 | + } |
|
| 216 | 223 | |
| 217 | - if(!is_dir($messagePath)) |
|
| 218 | - $this->usageError("The message path $messagePath is not a valid directory."); |
|
| 224 | + if(!is_dir($messagePath)) { |
|
| 225 | + $this->usageError("The message path $messagePath is not a valid directory."); |
|
| 226 | + } |
|
| 219 | 227 | |
| 220 | - if(empty($languages)) |
|
| 221 | - $this->usageError("Languages cannot be empty."); |
|
| 228 | + if(empty($languages)) { |
|
| 229 | + $this->usageError("Languages cannot be empty."); |
|
| 230 | + } |
|
| 222 | 231 | } |
| 223 | 232 | |
| 224 | 233 | /** |
@@ -228,8 +237,9 @@ discard block |
||
| 228 | 237 | { |
| 229 | 238 | $subject=file_get_contents($fileName); |
| 230 | 239 | $messages=array(); |
| 231 | - if(!is_array($translator)) |
|
| 232 | - $translator=array($translator); |
|
| 240 | + if(!is_array($translator)) { |
|
| 241 | + $translator=array($translator); |
|
| 242 | + } |
|
| 233 | 243 | |
| 234 | 244 | foreach ($translator as $currentTranslator) |
| 235 | 245 | { |
@@ -239,15 +249,16 @@ discard block |
||
| 239 | 249 | { |
| 240 | 250 | if(($pos=strpos($matches[$i][1],'.'))!==false) |
| 241 | 251 | { |
| 242 | - if (strpos($matches[$i][1],'Dashboard')!==false || strpos($matches[$i][1],'Hybridauth')!==false || strpos($matches[$i][1],'Install')!==false) |
|
| 243 | - $category='module.'.substr($matches[$i][1],1,-1); |
|
| 244 | - else if (strpos($matches[$i][1],'Theme')!==false) |
|
| 245 | - $category=$matches[$i][1]; |
|
| 246 | - else |
|
| 247 | - $category=substr($matches[$i][1],$pos+1,-1); |
|
| 252 | + if (strpos($matches[$i][1],'Dashboard')!==false || strpos($matches[$i][1],'Hybridauth')!==false || strpos($matches[$i][1],'Install')!==false) { |
|
| 253 | + $category='module.'.substr($matches[$i][1],1,-1); |
|
| 254 | + } else if (strpos($matches[$i][1],'Theme')!==false) { |
|
| 255 | + $category=$matches[$i][1]; |
|
| 256 | + } else { |
|
| 257 | + $category=substr($matches[$i][1],$pos+1,-1); |
|
| 258 | + } |
|
| 259 | + } else { |
|
| 260 | + $category=substr($matches[$i][1],1,-1); |
|
| 248 | 261 | } |
| 249 | - else |
|
| 250 | - $category=substr($matches[$i][1],1,-1); |
|
| 251 | 262 | |
| 252 | 263 | |
| 253 | 264 | $message=$matches[$i][2]; |
@@ -287,18 +298,20 @@ discard block |
||
| 287 | 298 | |
| 288 | 299 | foreach($messages as $message) |
| 289 | 300 | { |
| 290 | - if(array_key_exists($message,$translated) && strlen($translated[$message])>0) |
|
| 291 | - $merged[$message]=$translated[$message]; |
|
| 292 | - else |
|
| 293 | - $untranslated[]=$message; |
|
| 301 | + if(array_key_exists($message,$translated) && strlen($translated[$message])>0) { |
|
| 302 | + $merged[$message]=$translated[$message]; |
|
| 303 | + } else { |
|
| 304 | + $untranslated[]=$message; |
|
| 305 | + } |
|
| 294 | 306 | } |
| 295 | 307 | |
| 296 | 308 | ksort($merged); |
| 297 | 309 | sort($untranslated); |
| 298 | 310 | $todo=array(); |
| 299 | 311 | |
| 300 | - foreach($untranslated as $message) |
|
| 301 | - $todo[$message]=''; |
|
| 312 | + foreach($untranslated as $message) { |
|
| 313 | + $todo[$message]=''; |
|
| 314 | + } |
|
| 302 | 315 | |
| 303 | 316 | ksort($translated); |
| 304 | 317 | |
@@ -306,30 +319,33 @@ discard block |
||
| 306 | 319 | { |
| 307 | 320 | if(!isset($merged[$message]) && !isset($todo[$message]) && !$removeOld) |
| 308 | 321 | { |
| 309 | - if(substr($translation,0,2)==='@@' && substr($translation,-2)==='@@') |
|
| 310 | - $todo[$message]=$translation; |
|
| 311 | - else if ($translation == '') |
|
| 312 | - $todo[$message] = ''; |
|
| 313 | - else |
|
| 314 | - $todo[$message]='@@'.$translation.'@@'; |
|
| 322 | + if(substr($translation,0,2)==='@@' && substr($translation,-2)==='@@') { |
|
| 323 | + $todo[$message]=$translation; |
|
| 324 | + } else if ($translation == '') { |
|
| 325 | + $todo[$message] = ''; |
|
| 326 | + } else { |
|
| 327 | + $todo[$message]='@@'.$translation.'@@'; |
|
| 328 | + } |
|
| 315 | 329 | } |
| 316 | 330 | } |
| 317 | 331 | |
| 318 | 332 | $merged=array_merge($todo,$merged); |
| 319 | 333 | |
| 320 | - if($sort) |
|
| 321 | - ksort($merged); |
|
| 334 | + if($sort) { |
|
| 335 | + ksort($merged); |
|
| 336 | + } |
|
| 322 | 337 | |
| 323 | - if($overwrite === false) |
|
| 324 | - $fileName.='.merged'; |
|
| 338 | + if($overwrite === false) { |
|
| 339 | + $fileName.='.merged'; |
|
| 340 | + } |
|
| 325 | 341 | |
| 326 | 342 | echo "translation merged.\n"; |
| 327 | - } |
|
| 328 | - else |
|
| 343 | + } else |
|
| 329 | 344 | { |
| 330 | 345 | $merged=array(); |
| 331 | - foreach($messages as $message) |
|
| 332 | - $merged[$message]=''; |
|
| 346 | + foreach($messages as $message) { |
|
| 347 | + $merged[$message]=''; |
|
| 348 | + } |
|
| 333 | 349 | |
| 334 | 350 | ksort($merged); |
| 335 | 351 | echo "saved.\n"; |
@@ -1,341 +1,341 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * This is an alternative implementation of the MessageCommand class, designed to work with CiiMS' modules and themes |
|
| 4 | - */ |
|
| 3 | + * This is an alternative implementation of the MessageCommand class, designed to work with CiiMS' modules and themes |
|
| 4 | + */ |
|
| 5 | 5 | Yii::import('cii.commands.CiiConsoleCommand'); |
| 6 | 6 | class CiiMessageCommand extends CiiConsoleCommand |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * The configuration object |
|
| 11 | - * @var array _$config |
|
| 12 | - */ |
|
| 13 | - private $_config = array(); |
|
| 14 | - |
|
| 15 | - /** |
|
| 16 | - * The messages that should be translated |
|
| 17 | - * @var array $_messages |
|
| 18 | - */ |
|
| 19 | - private $_messages = array(); |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * The stirng that should be used for translations |
|
| 23 | - * @var string $_translator |
|
| 24 | - */ |
|
| 25 | - private $_translator = 'Yii::t'; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * Default args |
|
| 29 | - * @return array |
|
| 30 | - */ |
|
| 31 | - private function getArgs() |
|
| 32 | - { |
|
| 33 | - return array( |
|
| 34 | - 'type' => 'core', |
|
| 35 | - 'sourcePath' => Yii::getPathOfAlias('application').DS, |
|
| 36 | - 'messagePath' => Yii::getPathOfAlias('application.messages').DS, |
|
| 37 | - 'languages' => array('en_us'), |
|
| 38 | - 'fileTypes' => array('php'), |
|
| 39 | - 'overwrite' => true, |
|
| 40 | - 'sort' => true, |
|
| 41 | - 'removeOld' => false, |
|
| 42 | - 'exclude' => array( |
|
| 43 | - 'assets', |
|
| 44 | - 'css', |
|
| 45 | - 'js', |
|
| 46 | - 'images', |
|
| 47 | - '.svn', |
|
| 48 | - '.gitignore', |
|
| 49 | - '.git', |
|
| 50 | - 'yiilite.php', |
|
| 51 | - 'yiit.php', |
|
| 52 | - 'i18n/data', |
|
| 53 | - 'messages', |
|
| 54 | - 'vendor', |
|
| 55 | - 'tests', |
|
| 56 | - 'runtime' |
|
| 57 | - ) |
|
| 58 | - ); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * Init method |
|
| 63 | - */ |
|
| 64 | - public function init() |
|
| 65 | - { |
|
| 66 | - $this->_config = $this->getArgs(); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * Generates translation files for a given mtheme |
|
| 71 | - * @param string $name The name of the theme to generate translations for |
|
| 72 | - */ |
|
| 73 | - public function actionThemes($name=NULL) |
|
| 74 | - { |
|
| 75 | - if ($name === NULL) |
|
| 76 | - $this->usageError('A theme was not specified for translations'); |
|
| 77 | - |
|
| 78 | - $this->_config['type'] = 'theme'; |
|
| 79 | - array_push($this->_config['exclude'], 'modules'); |
|
| 80 | - $this->_config['sourcePath'] .= '..'.DS.'themes' . DS . $name . DS; |
|
| 81 | - $this->_config['messagePath'] = $this->_config['sourcePath'].'messages'; |
|
| 82 | - $this->execute(); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Generates translation files for a given module |
|
| 87 | - * @param string $name The name of the module to generate translations for |
|
| 88 | - */ |
|
| 89 | - public function actionModules($name=NULL) |
|
| 90 | - { |
|
| 91 | - if ($name === NULL) |
|
| 92 | - $this->usageError('A module was not specified for translations'); |
|
| 93 | - |
|
| 94 | - $this->_config['type'] = 'module'; |
|
| 95 | - array_push($this->_config['exclude'], 'themes'); |
|
| 96 | - unset($this->_config['exclude']['modules']); |
|
| 97 | - $this->_config['sourcePath'] = Yii::getPathOfAlias('application.modules') . DS . $name . DS; |
|
| 98 | - $this->_config['messagePath'] = $this->_config['sourcePath'].'messages'; |
|
| 99 | - $this->execute($this->_config); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Defualt action |
|
| 104 | - */ |
|
| 105 | - public function actionIndex() |
|
| 106 | - { |
|
| 107 | - array_push($this->_config['exclude'], 'modules'); |
|
| 108 | - array_push($this->_config['exclude'], 'themes'); |
|
| 109 | - return $this->execute(); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * Execute the action. |
|
| 114 | - */ |
|
| 115 | - private function execute() |
|
| 116 | - { |
|
| 117 | - // Validate the configuration |
|
| 118 | - extract($this->_config); |
|
| 119 | - $this->validateConfig(); |
|
| 120 | - |
|
| 121 | - // Determine the messages |
|
| 122 | - foreach($this->getFiles() as $file) |
|
| 123 | - $this->_messages = array_merge_recursive($this->_messages,$this->extractMessages($file,$this->_translator)); |
|
| 124 | - |
|
| 125 | - foreach($languages as $language) |
|
| 126 | - { |
|
| 127 | - $dir = $messagePath.DS.$language; |
|
| 128 | - |
|
| 129 | - $this->createDirectory($dir); |
|
| 130 | - |
|
| 131 | - foreach ($this->_messages as $category=>$msgs) |
|
| 132 | - { |
|
| 133 | - $msgs = array_values(array_unique($msgs)); |
|
| 134 | - |
|
| 135 | - $dir = $this->_config['messagePath'].DS.$language; |
|
| 136 | - |
|
| 137 | - if ($this->_config['type'] == 'theme') |
|
| 138 | - { |
|
| 139 | - $data = explode('.', $category); |
|
| 140 | - unset($data[0]); |
|
| 141 | - $dirPath = implode(DS, $data); |
|
| 142 | - } |
|
| 143 | - else if ($this->_config['type'] == 'module') |
|
| 144 | - { |
|
| 145 | - $data = explode('.', $category); |
|
| 146 | - unset($data[0]); |
|
| 147 | - unset($data[1]); |
|
| 148 | - $dirPath = implode(DS, $data); |
|
| 149 | - } |
|
| 150 | - else |
|
| 151 | - $dirPath = implode(DS, explode('.', $category)); |
|
| 152 | - |
|
| 153 | - if (empty($dirPath)) |
|
| 154 | - continue; |
|
| 155 | - |
|
| 156 | - $this->createDirectory($dir . DS . $dirPath); |
|
| 157 | - $this->createDirectory($dir . DS . $language); |
|
| 158 | - |
|
| 159 | - $this->generateMessageFile($msgs,$dir.DS.$dirPath.'.php',$overwrite,$removeOld,$sort); |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * Creates a directory at the given path |
|
| 166 | - * @param string $directory |
|
| 167 | - * @return boolean |
|
| 168 | - */ |
|
| 169 | - private function createDirectory($directory) |
|
| 170 | - { |
|
| 171 | - if (!is_dir($directory)) |
|
| 172 | - { |
|
| 173 | - if (!mkdir($directory, 0777, true)) |
|
| 174 | - $this->usageError('The directory ' . $directory .' could not be created. Please make sure this process has write access to this directory.'); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - return true; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * Retrieves the files that should be translated |
|
| 182 | - * @return array $files |
|
| 183 | - */ |
|
| 184 | - private function getFiles() |
|
| 185 | - { |
|
| 186 | - extract($this->_config); |
|
| 187 | - $files = CFileHelper::findFiles(realpath($sourcePath),array( |
|
| 188 | - 'fileTypes' => $fileTypes, |
|
| 189 | - 'exclude' => $exclude |
|
| 190 | - )); |
|
| 191 | - |
|
| 192 | - // Strip out all extensions |
|
| 193 | - foreach ($files as $k=>$file) |
|
| 194 | - { |
|
| 195 | - if (strpos($file, 'extensions') !== false) |
|
| 196 | - unset($files[$k]); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - reset($files); |
|
| 200 | - |
|
| 201 | - return $files; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * Does basic validation on the configuration options |
|
| 206 | - */ |
|
| 207 | - private function validateConfig() |
|
| 208 | - { |
|
| 209 | - extract($this->_config); |
|
| 210 | - |
|
| 211 | - if(!isset($sourcePath,$messagePath,$languages)) |
|
| 212 | - $this->usageError('The configuration file must specify "sourcePath", "messagePath" and "languages".'); |
|
| 213 | - |
|
| 214 | - if(!is_dir($sourcePath)) |
|
| 215 | - $this->usageError("The source path $sourcePath is not a valid directory."); |
|
| 216 | - |
|
| 217 | - if(!is_dir($messagePath)) |
|
| 218 | - $this->usageError("The message path $messagePath is not a valid directory."); |
|
| 219 | - |
|
| 220 | - if(empty($languages)) |
|
| 221 | - $this->usageError("Languages cannot be empty."); |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * @param string $translator |
|
| 226 | - */ |
|
| 227 | - protected function extractMessages($fileName,$translator) |
|
| 228 | - { |
|
| 229 | - $subject=file_get_contents($fileName); |
|
| 230 | - $messages=array(); |
|
| 231 | - if(!is_array($translator)) |
|
| 232 | - $translator=array($translator); |
|
| 233 | - |
|
| 234 | - foreach ($translator as $currentTranslator) |
|
| 235 | - { |
|
| 236 | - $n=preg_match_all('/\b'.$currentTranslator.'\s*\(\s*(\'[\w.\/]*?(?<!\.)\'|"[\w.]*?(?<!\.)")\s*,\s*(\'.*?(?<!\\\\)\'|".*?(?<!\\\\)")\s*[,\)]/s',$subject,$matches,PREG_SET_ORDER); |
|
| 237 | - |
|
| 238 | - for($i=0; $i<$n; ++$i) |
|
| 239 | - { |
|
| 240 | - if(($pos=strpos($matches[$i][1],'.'))!==false) |
|
| 241 | - { |
|
| 242 | - if (strpos($matches[$i][1],'Dashboard')!==false || strpos($matches[$i][1],'Hybridauth')!==false || strpos($matches[$i][1],'Install')!==false) |
|
| 243 | - $category='module.'.substr($matches[$i][1],1,-1); |
|
| 244 | - else if (strpos($matches[$i][1],'Theme')!==false) |
|
| 245 | - $category=$matches[$i][1]; |
|
| 246 | - else |
|
| 247 | - $category=substr($matches[$i][1],$pos+1,-1); |
|
| 248 | - } |
|
| 249 | - else |
|
| 250 | - $category=substr($matches[$i][1],1,-1); |
|
| 251 | - |
|
| 252 | - |
|
| 253 | - $message=$matches[$i][2]; |
|
| 254 | - |
|
| 255 | - $category = str_replace("'", '', $category); |
|
| 256 | - |
|
| 257 | - // This is how Yii does it |
|
| 258 | - $messages[$category][]=eval("return $message;"); // use eval to eliminate quote escape |
|
| 259 | - } |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - return $messages; |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - /** |
|
| 266 | - * @param string $fileName |
|
| 267 | - * @param boolean $overwrite |
|
| 268 | - * @param boolean $removeOld |
|
| 269 | - * @param boolean $sort |
|
| 270 | - */ |
|
| 271 | - protected function generateMessageFile($messages,$fileName,$overwrite,$removeOld,$sort) |
|
| 272 | - { |
|
| 273 | - echo "Saving messages to $fileName..."; |
|
| 274 | - if(is_file($fileName)) |
|
| 275 | - { |
|
| 276 | - $translated=require($fileName); |
|
| 277 | - sort($messages); |
|
| 278 | - ksort($translated); |
|
| 279 | - if(array_keys($translated)==$messages) |
|
| 280 | - { |
|
| 281 | - echo "nothing new...skipped.\n"; |
|
| 282 | - return; |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - $merged=array(); |
|
| 286 | - $untranslated=array(); |
|
| 287 | - |
|
| 288 | - foreach($messages as $message) |
|
| 289 | - { |
|
| 290 | - if(array_key_exists($message,$translated) && strlen($translated[$message])>0) |
|
| 291 | - $merged[$message]=$translated[$message]; |
|
| 292 | - else |
|
| 293 | - $untranslated[]=$message; |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - ksort($merged); |
|
| 297 | - sort($untranslated); |
|
| 298 | - $todo=array(); |
|
| 299 | - |
|
| 300 | - foreach($untranslated as $message) |
|
| 301 | - $todo[$message]=''; |
|
| 302 | - |
|
| 303 | - ksort($translated); |
|
| 304 | - |
|
| 305 | - foreach($translated as $message=>$translation) |
|
| 306 | - { |
|
| 307 | - if(!isset($merged[$message]) && !isset($todo[$message]) && !$removeOld) |
|
| 308 | - { |
|
| 309 | - if(substr($translation,0,2)==='@@' && substr($translation,-2)==='@@') |
|
| 310 | - $todo[$message]=$translation; |
|
| 311 | - else if ($translation == '') |
|
| 312 | - $todo[$message] = ''; |
|
| 313 | - else |
|
| 314 | - $todo[$message]='@@'.$translation.'@@'; |
|
| 315 | - } |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - $merged=array_merge($todo,$merged); |
|
| 319 | - |
|
| 320 | - if($sort) |
|
| 321 | - ksort($merged); |
|
| 322 | - |
|
| 323 | - if($overwrite === false) |
|
| 324 | - $fileName.='.merged'; |
|
| 325 | - |
|
| 326 | - echo "translation merged.\n"; |
|
| 327 | - } |
|
| 328 | - else |
|
| 329 | - { |
|
| 330 | - $merged=array(); |
|
| 331 | - foreach($messages as $message) |
|
| 332 | - $merged[$message]=''; |
|
| 333 | - |
|
| 334 | - ksort($merged); |
|
| 335 | - echo "saved.\n"; |
|
| 336 | - } |
|
| 337 | - $array=str_replace("\r",'',var_export($merged,true)); |
|
| 338 | - $content=<<<EOD |
|
| 9 | + /** |
|
| 10 | + * The configuration object |
|
| 11 | + * @var array _$config |
|
| 12 | + */ |
|
| 13 | + private $_config = array(); |
|
| 14 | + |
|
| 15 | + /** |
|
| 16 | + * The messages that should be translated |
|
| 17 | + * @var array $_messages |
|
| 18 | + */ |
|
| 19 | + private $_messages = array(); |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * The stirng that should be used for translations |
|
| 23 | + * @var string $_translator |
|
| 24 | + */ |
|
| 25 | + private $_translator = 'Yii::t'; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * Default args |
|
| 29 | + * @return array |
|
| 30 | + */ |
|
| 31 | + private function getArgs() |
|
| 32 | + { |
|
| 33 | + return array( |
|
| 34 | + 'type' => 'core', |
|
| 35 | + 'sourcePath' => Yii::getPathOfAlias('application').DS, |
|
| 36 | + 'messagePath' => Yii::getPathOfAlias('application.messages').DS, |
|
| 37 | + 'languages' => array('en_us'), |
|
| 38 | + 'fileTypes' => array('php'), |
|
| 39 | + 'overwrite' => true, |
|
| 40 | + 'sort' => true, |
|
| 41 | + 'removeOld' => false, |
|
| 42 | + 'exclude' => array( |
|
| 43 | + 'assets', |
|
| 44 | + 'css', |
|
| 45 | + 'js', |
|
| 46 | + 'images', |
|
| 47 | + '.svn', |
|
| 48 | + '.gitignore', |
|
| 49 | + '.git', |
|
| 50 | + 'yiilite.php', |
|
| 51 | + 'yiit.php', |
|
| 52 | + 'i18n/data', |
|
| 53 | + 'messages', |
|
| 54 | + 'vendor', |
|
| 55 | + 'tests', |
|
| 56 | + 'runtime' |
|
| 57 | + ) |
|
| 58 | + ); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * Init method |
|
| 63 | + */ |
|
| 64 | + public function init() |
|
| 65 | + { |
|
| 66 | + $this->_config = $this->getArgs(); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * Generates translation files for a given mtheme |
|
| 71 | + * @param string $name The name of the theme to generate translations for |
|
| 72 | + */ |
|
| 73 | + public function actionThemes($name=NULL) |
|
| 74 | + { |
|
| 75 | + if ($name === NULL) |
|
| 76 | + $this->usageError('A theme was not specified for translations'); |
|
| 77 | + |
|
| 78 | + $this->_config['type'] = 'theme'; |
|
| 79 | + array_push($this->_config['exclude'], 'modules'); |
|
| 80 | + $this->_config['sourcePath'] .= '..'.DS.'themes' . DS . $name . DS; |
|
| 81 | + $this->_config['messagePath'] = $this->_config['sourcePath'].'messages'; |
|
| 82 | + $this->execute(); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Generates translation files for a given module |
|
| 87 | + * @param string $name The name of the module to generate translations for |
|
| 88 | + */ |
|
| 89 | + public function actionModules($name=NULL) |
|
| 90 | + { |
|
| 91 | + if ($name === NULL) |
|
| 92 | + $this->usageError('A module was not specified for translations'); |
|
| 93 | + |
|
| 94 | + $this->_config['type'] = 'module'; |
|
| 95 | + array_push($this->_config['exclude'], 'themes'); |
|
| 96 | + unset($this->_config['exclude']['modules']); |
|
| 97 | + $this->_config['sourcePath'] = Yii::getPathOfAlias('application.modules') . DS . $name . DS; |
|
| 98 | + $this->_config['messagePath'] = $this->_config['sourcePath'].'messages'; |
|
| 99 | + $this->execute($this->_config); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Defualt action |
|
| 104 | + */ |
|
| 105 | + public function actionIndex() |
|
| 106 | + { |
|
| 107 | + array_push($this->_config['exclude'], 'modules'); |
|
| 108 | + array_push($this->_config['exclude'], 'themes'); |
|
| 109 | + return $this->execute(); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * Execute the action. |
|
| 114 | + */ |
|
| 115 | + private function execute() |
|
| 116 | + { |
|
| 117 | + // Validate the configuration |
|
| 118 | + extract($this->_config); |
|
| 119 | + $this->validateConfig(); |
|
| 120 | + |
|
| 121 | + // Determine the messages |
|
| 122 | + foreach($this->getFiles() as $file) |
|
| 123 | + $this->_messages = array_merge_recursive($this->_messages,$this->extractMessages($file,$this->_translator)); |
|
| 124 | + |
|
| 125 | + foreach($languages as $language) |
|
| 126 | + { |
|
| 127 | + $dir = $messagePath.DS.$language; |
|
| 128 | + |
|
| 129 | + $this->createDirectory($dir); |
|
| 130 | + |
|
| 131 | + foreach ($this->_messages as $category=>$msgs) |
|
| 132 | + { |
|
| 133 | + $msgs = array_values(array_unique($msgs)); |
|
| 134 | + |
|
| 135 | + $dir = $this->_config['messagePath'].DS.$language; |
|
| 136 | + |
|
| 137 | + if ($this->_config['type'] == 'theme') |
|
| 138 | + { |
|
| 139 | + $data = explode('.', $category); |
|
| 140 | + unset($data[0]); |
|
| 141 | + $dirPath = implode(DS, $data); |
|
| 142 | + } |
|
| 143 | + else if ($this->_config['type'] == 'module') |
|
| 144 | + { |
|
| 145 | + $data = explode('.', $category); |
|
| 146 | + unset($data[0]); |
|
| 147 | + unset($data[1]); |
|
| 148 | + $dirPath = implode(DS, $data); |
|
| 149 | + } |
|
| 150 | + else |
|
| 151 | + $dirPath = implode(DS, explode('.', $category)); |
|
| 152 | + |
|
| 153 | + if (empty($dirPath)) |
|
| 154 | + continue; |
|
| 155 | + |
|
| 156 | + $this->createDirectory($dir . DS . $dirPath); |
|
| 157 | + $this->createDirectory($dir . DS . $language); |
|
| 158 | + |
|
| 159 | + $this->generateMessageFile($msgs,$dir.DS.$dirPath.'.php',$overwrite,$removeOld,$sort); |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * Creates a directory at the given path |
|
| 166 | + * @param string $directory |
|
| 167 | + * @return boolean |
|
| 168 | + */ |
|
| 169 | + private function createDirectory($directory) |
|
| 170 | + { |
|
| 171 | + if (!is_dir($directory)) |
|
| 172 | + { |
|
| 173 | + if (!mkdir($directory, 0777, true)) |
|
| 174 | + $this->usageError('The directory ' . $directory .' could not be created. Please make sure this process has write access to this directory.'); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + return true; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * Retrieves the files that should be translated |
|
| 182 | + * @return array $files |
|
| 183 | + */ |
|
| 184 | + private function getFiles() |
|
| 185 | + { |
|
| 186 | + extract($this->_config); |
|
| 187 | + $files = CFileHelper::findFiles(realpath($sourcePath),array( |
|
| 188 | + 'fileTypes' => $fileTypes, |
|
| 189 | + 'exclude' => $exclude |
|
| 190 | + )); |
|
| 191 | + |
|
| 192 | + // Strip out all extensions |
|
| 193 | + foreach ($files as $k=>$file) |
|
| 194 | + { |
|
| 195 | + if (strpos($file, 'extensions') !== false) |
|
| 196 | + unset($files[$k]); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + reset($files); |
|
| 200 | + |
|
| 201 | + return $files; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * Does basic validation on the configuration options |
|
| 206 | + */ |
|
| 207 | + private function validateConfig() |
|
| 208 | + { |
|
| 209 | + extract($this->_config); |
|
| 210 | + |
|
| 211 | + if(!isset($sourcePath,$messagePath,$languages)) |
|
| 212 | + $this->usageError('The configuration file must specify "sourcePath", "messagePath" and "languages".'); |
|
| 213 | + |
|
| 214 | + if(!is_dir($sourcePath)) |
|
| 215 | + $this->usageError("The source path $sourcePath is not a valid directory."); |
|
| 216 | + |
|
| 217 | + if(!is_dir($messagePath)) |
|
| 218 | + $this->usageError("The message path $messagePath is not a valid directory."); |
|
| 219 | + |
|
| 220 | + if(empty($languages)) |
|
| 221 | + $this->usageError("Languages cannot be empty."); |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * @param string $translator |
|
| 226 | + */ |
|
| 227 | + protected function extractMessages($fileName,$translator) |
|
| 228 | + { |
|
| 229 | + $subject=file_get_contents($fileName); |
|
| 230 | + $messages=array(); |
|
| 231 | + if(!is_array($translator)) |
|
| 232 | + $translator=array($translator); |
|
| 233 | + |
|
| 234 | + foreach ($translator as $currentTranslator) |
|
| 235 | + { |
|
| 236 | + $n=preg_match_all('/\b'.$currentTranslator.'\s*\(\s*(\'[\w.\/]*?(?<!\.)\'|"[\w.]*?(?<!\.)")\s*,\s*(\'.*?(?<!\\\\)\'|".*?(?<!\\\\)")\s*[,\)]/s',$subject,$matches,PREG_SET_ORDER); |
|
| 237 | + |
|
| 238 | + for($i=0; $i<$n; ++$i) |
|
| 239 | + { |
|
| 240 | + if(($pos=strpos($matches[$i][1],'.'))!==false) |
|
| 241 | + { |
|
| 242 | + if (strpos($matches[$i][1],'Dashboard')!==false || strpos($matches[$i][1],'Hybridauth')!==false || strpos($matches[$i][1],'Install')!==false) |
|
| 243 | + $category='module.'.substr($matches[$i][1],1,-1); |
|
| 244 | + else if (strpos($matches[$i][1],'Theme')!==false) |
|
| 245 | + $category=$matches[$i][1]; |
|
| 246 | + else |
|
| 247 | + $category=substr($matches[$i][1],$pos+1,-1); |
|
| 248 | + } |
|
| 249 | + else |
|
| 250 | + $category=substr($matches[$i][1],1,-1); |
|
| 251 | + |
|
| 252 | + |
|
| 253 | + $message=$matches[$i][2]; |
|
| 254 | + |
|
| 255 | + $category = str_replace("'", '', $category); |
|
| 256 | + |
|
| 257 | + // This is how Yii does it |
|
| 258 | + $messages[$category][]=eval("return $message;"); // use eval to eliminate quote escape |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + return $messages; |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * @param string $fileName |
|
| 267 | + * @param boolean $overwrite |
|
| 268 | + * @param boolean $removeOld |
|
| 269 | + * @param boolean $sort |
|
| 270 | + */ |
|
| 271 | + protected function generateMessageFile($messages,$fileName,$overwrite,$removeOld,$sort) |
|
| 272 | + { |
|
| 273 | + echo "Saving messages to $fileName..."; |
|
| 274 | + if(is_file($fileName)) |
|
| 275 | + { |
|
| 276 | + $translated=require($fileName); |
|
| 277 | + sort($messages); |
|
| 278 | + ksort($translated); |
|
| 279 | + if(array_keys($translated)==$messages) |
|
| 280 | + { |
|
| 281 | + echo "nothing new...skipped.\n"; |
|
| 282 | + return; |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + $merged=array(); |
|
| 286 | + $untranslated=array(); |
|
| 287 | + |
|
| 288 | + foreach($messages as $message) |
|
| 289 | + { |
|
| 290 | + if(array_key_exists($message,$translated) && strlen($translated[$message])>0) |
|
| 291 | + $merged[$message]=$translated[$message]; |
|
| 292 | + else |
|
| 293 | + $untranslated[]=$message; |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + ksort($merged); |
|
| 297 | + sort($untranslated); |
|
| 298 | + $todo=array(); |
|
| 299 | + |
|
| 300 | + foreach($untranslated as $message) |
|
| 301 | + $todo[$message]=''; |
|
| 302 | + |
|
| 303 | + ksort($translated); |
|
| 304 | + |
|
| 305 | + foreach($translated as $message=>$translation) |
|
| 306 | + { |
|
| 307 | + if(!isset($merged[$message]) && !isset($todo[$message]) && !$removeOld) |
|
| 308 | + { |
|
| 309 | + if(substr($translation,0,2)==='@@' && substr($translation,-2)==='@@') |
|
| 310 | + $todo[$message]=$translation; |
|
| 311 | + else if ($translation == '') |
|
| 312 | + $todo[$message] = ''; |
|
| 313 | + else |
|
| 314 | + $todo[$message]='@@'.$translation.'@@'; |
|
| 315 | + } |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + $merged=array_merge($todo,$merged); |
|
| 319 | + |
|
| 320 | + if($sort) |
|
| 321 | + ksort($merged); |
|
| 322 | + |
|
| 323 | + if($overwrite === false) |
|
| 324 | + $fileName.='.merged'; |
|
| 325 | + |
|
| 326 | + echo "translation merged.\n"; |
|
| 327 | + } |
|
| 328 | + else |
|
| 329 | + { |
|
| 330 | + $merged=array(); |
|
| 331 | + foreach($messages as $message) |
|
| 332 | + $merged[$message]=''; |
|
| 333 | + |
|
| 334 | + ksort($merged); |
|
| 335 | + echo "saved.\n"; |
|
| 336 | + } |
|
| 337 | + $array=str_replace("\r",'',var_export($merged,true)); |
|
| 338 | + $content=<<<EOD |
|
| 339 | 339 | <?php |
| 340 | 340 | /** |
| 341 | 341 | * Message translations. |
@@ -357,6 +357,6 @@ discard block |
||
| 357 | 357 | return $array; |
| 358 | 358 | |
| 359 | 359 | EOD; |
| 360 | - file_put_contents($fileName, $content); |
|
| 361 | - } |
|
| 360 | + file_put_contents($fileName, $content); |
|
| 361 | + } |
|
| 362 | 362 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Import System/Cli/Commands/MigrateCommand |
| 3 | -Yii::import('system.cli.commands.MigrateCommand'); |
|
| 3 | +Yii::import ('system.cli.commands.MigrateCommand'); |
|
| 4 | 4 | /** |
| 5 | 5 | * This class is an injection container for CDbMigration which permits us to |
| 6 | 6 | * directly access CDbMigrations from our web application without having |
@@ -21,10 +21,10 @@ discard block |
||
| 21 | 21 | * This is our overloaded getDbConnection, allowing us to tell yii what our db connection is |
| 22 | 22 | * without it having to go through |
| 23 | 23 | */ |
| 24 | - public function getDbConnection() |
|
| 24 | + public function getDbConnection () |
|
| 25 | 25 | { |
| 26 | - $connection = new CDbConnection("mysql:host={$this->dsn['host']};dbname={$this->dsn['dbname']}", $this->dsn['username'], $this->dsn['password']); |
|
| 27 | - $connection->setActive(true); |
|
| 26 | + $connection = new CDbConnection ("mysql:host={$this->dsn['host']};dbname={$this->dsn['dbname']}", $this->dsn['username'], $this->dsn['password']); |
|
| 27 | + $connection->setActive (true); |
|
| 28 | 28 | return $connection; |
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -$basePath = dirname(__FILE__) . '/..'; |
|
| 2 | +$basePath = dirname (__FILE__) . '/..'; |
|
| 3 | 3 | Yii::$classMap = array( |
| 4 | 4 | 'YiinfiniteScroller' => $basePath . '/extensions/yiinfinite-scroll/YiinfiniteScroller.php', |
| 5 | 5 | 'ContentMetadata' => $basePath . '/models/ContentMetadata.php', |
@@ -1,62 +1,62 @@ |
||
| 1 | 1 | <?php return array( |
| 2 | - 'basePath' => dirname(__FILE__).DIRECTORY_SEPARATOR.'..', |
|
| 3 | - 'name' => 'CiiMS Installer', |
|
| 4 | - 'preload' => array( |
|
| 5 | - 'cii' |
|
| 6 | - ), |
|
| 7 | - 'import' => array( |
|
| 8 | - 'application.components.*', |
|
| 9 | - 'application.modules.install.*' |
|
| 10 | - ), |
|
| 11 | - 'modules' => array( |
|
| 12 | - 'install' |
|
| 13 | - ), |
|
| 14 | - 'components' => array( |
|
| 15 | - 'cii' => array( |
|
| 16 | - 'class' => 'vendor.charlesportwoodii.cii.components.CiiBase' |
|
| 17 | - ), |
|
| 18 | - 'errorHandler' => array( |
|
| 19 | - 'errorAction' => '/install/default/error', |
|
| 20 | - ), |
|
| 21 | - 'session' => array( |
|
| 22 | - 'autoStart' => true, |
|
| 23 | - 'sessionName' => 'CiiMS_Installer', |
|
| 24 | - 'cookieMode' => 'only', |
|
| 25 | - ), |
|
| 26 | - 'cache' => array( |
|
| 27 | - 'class' => 'CFileCache' |
|
| 28 | - ), |
|
| 29 | - 'urlManager' => array( |
|
| 30 | - 'urlFormat' => 'path', |
|
| 31 | - 'showScriptName' => false, |
|
| 32 | - 'rules' => array( |
|
| 33 | - '' => '/install/default/index', |
|
| 34 | - '/migrate' => '/install/default/migrate', |
|
| 35 | - '/runmigrations' => '/install/default/runmigrations', |
|
| 36 | - '/createadmin' => '/install/default/createadmin', |
|
| 37 | - '/admin' => '/install/default/admin' |
|
| 38 | - ), |
|
| 39 | - ), |
|
| 40 | - 'log' => array( |
|
| 41 | - 'class' => 'CLogRouter', |
|
| 42 | - 'routes' => array( |
|
| 43 | - array( |
|
| 44 | - 'class' => 'CWebLogRoute', |
|
| 45 | - 'levels' => 'error, warning, trace, info', |
|
| 46 | - 'enabled' => true |
|
| 47 | - ), |
|
| 48 | - array( |
|
| 49 | - 'class'=>'CProfileLogRoute', |
|
| 50 | - 'report'=>'summary', |
|
| 51 | - 'enabled' => true |
|
| 52 | - ) |
|
| 53 | - ) |
|
| 54 | - ), |
|
| 55 | - ), |
|
| 56 | - 'params' => array( |
|
| 57 | - 'stage' => 0, |
|
| 58 | - 'debug' => true, |
|
| 59 | - 'trace' => 3 |
|
| 60 | - ), |
|
| 2 | + 'basePath' => dirname(__FILE__).DIRECTORY_SEPARATOR.'..', |
|
| 3 | + 'name' => 'CiiMS Installer', |
|
| 4 | + 'preload' => array( |
|
| 5 | + 'cii' |
|
| 6 | + ), |
|
| 7 | + 'import' => array( |
|
| 8 | + 'application.components.*', |
|
| 9 | + 'application.modules.install.*' |
|
| 10 | + ), |
|
| 11 | + 'modules' => array( |
|
| 12 | + 'install' |
|
| 13 | + ), |
|
| 14 | + 'components' => array( |
|
| 15 | + 'cii' => array( |
|
| 16 | + 'class' => 'vendor.charlesportwoodii.cii.components.CiiBase' |
|
| 17 | + ), |
|
| 18 | + 'errorHandler' => array( |
|
| 19 | + 'errorAction' => '/install/default/error', |
|
| 20 | + ), |
|
| 21 | + 'session' => array( |
|
| 22 | + 'autoStart' => true, |
|
| 23 | + 'sessionName' => 'CiiMS_Installer', |
|
| 24 | + 'cookieMode' => 'only', |
|
| 25 | + ), |
|
| 26 | + 'cache' => array( |
|
| 27 | + 'class' => 'CFileCache' |
|
| 28 | + ), |
|
| 29 | + 'urlManager' => array( |
|
| 30 | + 'urlFormat' => 'path', |
|
| 31 | + 'showScriptName' => false, |
|
| 32 | + 'rules' => array( |
|
| 33 | + '' => '/install/default/index', |
|
| 34 | + '/migrate' => '/install/default/migrate', |
|
| 35 | + '/runmigrations' => '/install/default/runmigrations', |
|
| 36 | + '/createadmin' => '/install/default/createadmin', |
|
| 37 | + '/admin' => '/install/default/admin' |
|
| 38 | + ), |
|
| 39 | + ), |
|
| 40 | + 'log' => array( |
|
| 41 | + 'class' => 'CLogRouter', |
|
| 42 | + 'routes' => array( |
|
| 43 | + array( |
|
| 44 | + 'class' => 'CWebLogRoute', |
|
| 45 | + 'levels' => 'error, warning, trace, info', |
|
| 46 | + 'enabled' => true |
|
| 47 | + ), |
|
| 48 | + array( |
|
| 49 | + 'class'=>'CProfileLogRoute', |
|
| 50 | + 'report'=>'summary', |
|
| 51 | + 'enabled' => true |
|
| 52 | + ) |
|
| 53 | + ) |
|
| 54 | + ), |
|
| 55 | + ), |
|
| 56 | + 'params' => array( |
|
| 57 | + 'stage' => 0, |
|
| 58 | + 'debug' => true, |
|
| 59 | + 'trace' => 3 |
|
| 60 | + ), |
|
| 61 | 61 | ); |
| 62 | 62 | |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php return array( |
| 2 | - 'basePath' => dirname(__FILE__).DIRECTORY_SEPARATOR.'..', |
|
| 2 | + 'basePath' => dirname (__FILE__) . DIRECTORY_SEPARATOR . '..', |
|
| 3 | 3 | 'name' => 'CiiMS Installer', |
| 4 | 4 | 'preload' => array( |
| 5 | 5 | 'cii' |
@@ -20,145 +20,145 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | $import = function($default=false) { |
| 22 | 22 | |
| 23 | - $modules = (require __DIR__ . DS . 'modules.php'); |
|
| 23 | + $modules = (require __DIR__ . DS . 'modules.php'); |
|
| 24 | 24 | |
| 25 | - if ($default === true) |
|
| 26 | - return $modules; |
|
| 25 | + if ($default === true) |
|
| 26 | + return $modules; |
|
| 27 | 27 | |
| 28 | - $m = array( |
|
| 29 | - 'application.models.*', |
|
| 30 | - 'application.models.forms.*', |
|
| 31 | - 'application.models.settings.*' |
|
| 32 | - ); |
|
| 28 | + $m = array( |
|
| 29 | + 'application.models.*', |
|
| 30 | + 'application.models.forms.*', |
|
| 31 | + 'application.models.settings.*' |
|
| 32 | + ); |
|
| 33 | 33 | |
| 34 | - foreach ($modules as $k=>$v) { |
|
| 35 | - $m[] = 'application.modules.'.$v.'.*'; |
|
| 36 | - } |
|
| 34 | + foreach ($modules as $k=>$v) { |
|
| 35 | + $m[] = 'application.modules.'.$v.'.*'; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - return $m; |
|
| 38 | + return $m; |
|
| 39 | 39 | }; |
| 40 | 40 | |
| 41 | 41 | $ciimsCoreConfig = array( |
| 42 | - 'basePath' => __DIR__.DS.'..', |
|
| 43 | - 'name' => NULL, |
|
| 44 | - 'sourceLanguage' => 'en_US', |
|
| 45 | - 'preload' => array( |
|
| 46 | - 'cii', |
|
| 47 | - 'analytics' |
|
| 48 | - ), |
|
| 49 | - 'import' => $import(), |
|
| 50 | - 'modules' => $import(true), |
|
| 51 | - 'behaviors' => array( |
|
| 52 | - 'onBeginRequest' => array( |
|
| 53 | - 'class' => 'vendor.charlesportwoodii.yii-newrelic.behaviors.YiiNewRelicWebAppBehavior', |
|
| 54 | - ), |
|
| 55 | - ), |
|
| 56 | - 'components' => array( |
|
| 57 | - 'themeManager' => array( |
|
| 58 | - 'basePath' => (__DIR__ . DS . '..' . DS . '..' . DS . 'themes') |
|
| 59 | - ), |
|
| 60 | - 'messages' => array( |
|
| 61 | - 'class' => 'vendor.charlesportwoodii.cii.components.CiiPHPMessageSource' |
|
| 62 | - ), |
|
| 63 | - 'newRelic' => array( |
|
| 64 | - 'class' => 'vendor.charlesportwoodii.yii-newrelic.YiiNewRelic', |
|
| 65 | - 'setAppNameToYiiName' => false |
|
| 66 | - ), |
|
| 67 | - 'cii' => array( |
|
| 68 | - 'class' => 'vendor.charlesportwoodii.cii.components.CiiBase' |
|
| 69 | - ), |
|
| 70 | - 'analytics' => array( |
|
| 71 | - 'class' => 'vendor.charlesportwoodii.cii.components.CiiAnalytics', |
|
| 72 | - 'lowerBounceRate' => true, |
|
| 73 | - 'options' => array(), |
|
| 74 | - ), |
|
| 75 | - 'assetManager' => array( |
|
| 76 | - 'class' => 'vendor.charlesportwoodii.cii.components.CiiAssetManager', |
|
| 77 | - ), |
|
| 78 | - 'clientScript' => array( |
|
| 79 | - 'class' => 'vendor.charlesportwoodii.cii.components.CiiClientScript', |
|
| 80 | - ), |
|
| 81 | - 'errorHandler' => array( |
|
| 82 | - 'errorAction' => 'site/error', |
|
| 83 | - ), |
|
| 84 | - 'session' => array( |
|
| 85 | - 'autoStart' => true, |
|
| 86 | - 'sessionName' => '_ciims', |
|
| 87 | - 'cookieMode' => 'only', |
|
| 88 | - 'cookieParams' => array( |
|
| 89 | - 'httponly' => true, |
|
| 90 | - 'secure' => ( |
|
| 91 | - (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || |
|
| 92 | - (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) || |
|
| 93 | - (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') |
|
| 94 | - ) |
|
| 95 | - ) |
|
| 96 | - ), |
|
| 97 | - 'urlManager' => array( |
|
| 98 | - 'class' => 'vendor.charlesportwoodii.cii.components.CiiURLManager', |
|
| 99 | - 'urlFormat' => 'path', |
|
| 100 | - 'showScriptName' => false |
|
| 101 | - ), |
|
| 102 | - 'user' => array( |
|
| 103 | - 'authTimeout' => 900, |
|
| 104 | - 'absoluteAuthTimeout' => 1900, |
|
| 105 | - 'autoRenewCookie' => true |
|
| 106 | - ), |
|
| 107 | - 'db' => array( |
|
| 108 | - 'class' => 'CDbConnection', |
|
| 109 | - 'connectionString' => NULL, |
|
| 110 | - 'emulatePrepare' => true, |
|
| 111 | - 'username' => NULL, |
|
| 112 | - 'password' => NULL, |
|
| 113 | - 'charset' => 'utf8', |
|
| 114 | - 'schemaCachingDuration' => 3600, |
|
| 115 | - 'enableProfiling' => false, |
|
| 116 | - 'enableParamLogging' => false |
|
| 117 | - ), |
|
| 118 | - 'log' => array( |
|
| 119 | - 'class' => 'CLogRouter', |
|
| 120 | - 'routes' => array( |
|
| 121 | - array( |
|
| 122 | - 'class'=>'CFileLogRoute', |
|
| 123 | - 'levels'=>'error, warning', |
|
| 124 | - ) |
|
| 125 | - ) |
|
| 126 | - ), |
|
| 127 | - 'cache' => array( |
|
| 128 | - 'class' => 'CFileCache', |
|
| 129 | - ) |
|
| 130 | - ), |
|
| 131 | - 'params' => array( |
|
| 132 | - 'encryptionKey' => NULL, |
|
| 133 | - 'debug' => false, |
|
| 134 | - 'trace' => 0, |
|
| 135 | - 'NewRelicAppName' => null, |
|
| 136 | - 'max_fileupload_size' => (10 * 1024 * 1024), |
|
| 137 | - 'cards' => 'https://cards.ciims.io/1.0.0', |
|
| 138 | - ) |
|
| 42 | + 'basePath' => __DIR__.DS.'..', |
|
| 43 | + 'name' => NULL, |
|
| 44 | + 'sourceLanguage' => 'en_US', |
|
| 45 | + 'preload' => array( |
|
| 46 | + 'cii', |
|
| 47 | + 'analytics' |
|
| 48 | + ), |
|
| 49 | + 'import' => $import(), |
|
| 50 | + 'modules' => $import(true), |
|
| 51 | + 'behaviors' => array( |
|
| 52 | + 'onBeginRequest' => array( |
|
| 53 | + 'class' => 'vendor.charlesportwoodii.yii-newrelic.behaviors.YiiNewRelicWebAppBehavior', |
|
| 54 | + ), |
|
| 55 | + ), |
|
| 56 | + 'components' => array( |
|
| 57 | + 'themeManager' => array( |
|
| 58 | + 'basePath' => (__DIR__ . DS . '..' . DS . '..' . DS . 'themes') |
|
| 59 | + ), |
|
| 60 | + 'messages' => array( |
|
| 61 | + 'class' => 'vendor.charlesportwoodii.cii.components.CiiPHPMessageSource' |
|
| 62 | + ), |
|
| 63 | + 'newRelic' => array( |
|
| 64 | + 'class' => 'vendor.charlesportwoodii.yii-newrelic.YiiNewRelic', |
|
| 65 | + 'setAppNameToYiiName' => false |
|
| 66 | + ), |
|
| 67 | + 'cii' => array( |
|
| 68 | + 'class' => 'vendor.charlesportwoodii.cii.components.CiiBase' |
|
| 69 | + ), |
|
| 70 | + 'analytics' => array( |
|
| 71 | + 'class' => 'vendor.charlesportwoodii.cii.components.CiiAnalytics', |
|
| 72 | + 'lowerBounceRate' => true, |
|
| 73 | + 'options' => array(), |
|
| 74 | + ), |
|
| 75 | + 'assetManager' => array( |
|
| 76 | + 'class' => 'vendor.charlesportwoodii.cii.components.CiiAssetManager', |
|
| 77 | + ), |
|
| 78 | + 'clientScript' => array( |
|
| 79 | + 'class' => 'vendor.charlesportwoodii.cii.components.CiiClientScript', |
|
| 80 | + ), |
|
| 81 | + 'errorHandler' => array( |
|
| 82 | + 'errorAction' => 'site/error', |
|
| 83 | + ), |
|
| 84 | + 'session' => array( |
|
| 85 | + 'autoStart' => true, |
|
| 86 | + 'sessionName' => '_ciims', |
|
| 87 | + 'cookieMode' => 'only', |
|
| 88 | + 'cookieParams' => array( |
|
| 89 | + 'httponly' => true, |
|
| 90 | + 'secure' => ( |
|
| 91 | + (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || |
|
| 92 | + (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) || |
|
| 93 | + (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') |
|
| 94 | + ) |
|
| 95 | + ) |
|
| 96 | + ), |
|
| 97 | + 'urlManager' => array( |
|
| 98 | + 'class' => 'vendor.charlesportwoodii.cii.components.CiiURLManager', |
|
| 99 | + 'urlFormat' => 'path', |
|
| 100 | + 'showScriptName' => false |
|
| 101 | + ), |
|
| 102 | + 'user' => array( |
|
| 103 | + 'authTimeout' => 900, |
|
| 104 | + 'absoluteAuthTimeout' => 1900, |
|
| 105 | + 'autoRenewCookie' => true |
|
| 106 | + ), |
|
| 107 | + 'db' => array( |
|
| 108 | + 'class' => 'CDbConnection', |
|
| 109 | + 'connectionString' => NULL, |
|
| 110 | + 'emulatePrepare' => true, |
|
| 111 | + 'username' => NULL, |
|
| 112 | + 'password' => NULL, |
|
| 113 | + 'charset' => 'utf8', |
|
| 114 | + 'schemaCachingDuration' => 3600, |
|
| 115 | + 'enableProfiling' => false, |
|
| 116 | + 'enableParamLogging' => false |
|
| 117 | + ), |
|
| 118 | + 'log' => array( |
|
| 119 | + 'class' => 'CLogRouter', |
|
| 120 | + 'routes' => array( |
|
| 121 | + array( |
|
| 122 | + 'class'=>'CFileLogRoute', |
|
| 123 | + 'levels'=>'error, warning', |
|
| 124 | + ) |
|
| 125 | + ) |
|
| 126 | + ), |
|
| 127 | + 'cache' => array( |
|
| 128 | + 'class' => 'CFileCache', |
|
| 129 | + ) |
|
| 130 | + ), |
|
| 131 | + 'params' => array( |
|
| 132 | + 'encryptionKey' => NULL, |
|
| 133 | + 'debug' => false, |
|
| 134 | + 'trace' => 0, |
|
| 135 | + 'NewRelicAppName' => null, |
|
| 136 | + 'max_fileupload_size' => (10 * 1024 * 1024), |
|
| 137 | + 'cards' => 'https://cards.ciims.io/1.0.0', |
|
| 138 | + ) |
|
| 139 | 139 | ); |
| 140 | 140 | |
| 141 | 141 | // CLI specific data |
| 142 | 142 | if (php_sapi_name() == "cli") |
| 143 | 143 | { |
| 144 | - $ciimsCoreConfig['behaviors'] = array( |
|
| 145 | - 'onBeginRequest' => array( |
|
| 146 | - 'class' => 'vendor.charlesportwoodii.yii-newrelic.behaviors.YiiNewRelicConsoleAppBehavior', |
|
| 147 | - ), |
|
| 148 | - 'onEndRequest' => array( |
|
| 149 | - 'class' => 'vendor.charlesportwoodii.yii-newrelic.behaviors.YiiNewRelicConsoleAppBehavior', |
|
| 150 | - ) |
|
| 151 | - ); |
|
| 144 | + $ciimsCoreConfig['behaviors'] = array( |
|
| 145 | + 'onBeginRequest' => array( |
|
| 146 | + 'class' => 'vendor.charlesportwoodii.yii-newrelic.behaviors.YiiNewRelicConsoleAppBehavior', |
|
| 147 | + ), |
|
| 148 | + 'onEndRequest' => array( |
|
| 149 | + 'class' => 'vendor.charlesportwoodii.yii-newrelic.behaviors.YiiNewRelicConsoleAppBehavior', |
|
| 150 | + ) |
|
| 151 | + ); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | if (php_sapi_name() != "cli" && YII_DEBUG) |
| 155 | 155 | { |
| 156 | - $ciimsCoreConfig['preload'][] = 'debug'; |
|
| 157 | - $ciimsCoreConfig['components']['debug'] = array( |
|
| 158 | - 'class' => 'vendor.zhuravljov.yii2-debug.Yii2Debug', |
|
| 159 | - 'enabled' => YII_DEBUG, |
|
| 160 | - 'allowedIPs' => array('*') |
|
| 161 | - ); |
|
| 156 | + $ciimsCoreConfig['preload'][] = 'debug'; |
|
| 157 | + $ciimsCoreConfig['components']['debug'] = array( |
|
| 158 | + 'class' => 'vendor.zhuravljov.yii2-debug.Yii2Debug', |
|
| 159 | + 'enabled' => YII_DEBUG, |
|
| 160 | + 'allowedIPs' => array('*') |
|
| 161 | + ); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | return $ciimsCoreConfig; |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * @license http://opensource.org/licenses/MIT MIT LICENSE |
| 19 | 19 | * @link https://github.com/charlesportwoodii/CiiMS |
| 20 | 20 | */ |
| 21 | -$import = function($default=false) { |
|
| 21 | +$import = function ($default = false) { |
|
| 22 | 22 | |
| 23 | 23 | $modules = (require __DIR__ . DS . 'modules.php'); |
| 24 | 24 | |
@@ -32,22 +32,22 @@ discard block |
||
| 32 | 32 | ); |
| 33 | 33 | |
| 34 | 34 | foreach ($modules as $k=>$v) { |
| 35 | - $m[] = 'application.modules.'.$v.'.*'; |
|
| 35 | + $m[] = 'application.modules.' . $v . '.*'; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | return $m; |
| 39 | 39 | }; |
| 40 | 40 | |
| 41 | 41 | $ciimsCoreConfig = array( |
| 42 | - 'basePath' => __DIR__.DS.'..', |
|
| 42 | + 'basePath' => __DIR__ . DS . '..', |
|
| 43 | 43 | 'name' => NULL, |
| 44 | 44 | 'sourceLanguage' => 'en_US', |
| 45 | 45 | 'preload' => array( |
| 46 | 46 | 'cii', |
| 47 | 47 | 'analytics' |
| 48 | 48 | ), |
| 49 | - 'import' => $import(), |
|
| 50 | - 'modules' => $import(true), |
|
| 49 | + 'import' => $import (), |
|
| 50 | + 'modules' => $import (true), |
|
| 51 | 51 | 'behaviors' => array( |
| 52 | 52 | 'onBeginRequest' => array( |
| 53 | 53 | 'class' => 'vendor.charlesportwoodii.yii-newrelic.behaviors.YiiNewRelicWebAppBehavior', |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | ); |
| 140 | 140 | |
| 141 | 141 | // CLI specific data |
| 142 | -if (php_sapi_name() == "cli") |
|
| 142 | +if (php_sapi_name () == "cli") |
|
| 143 | 143 | { |
| 144 | 144 | $ciimsCoreConfig['behaviors'] = array( |
| 145 | 145 | 'onBeginRequest' => array( |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | ); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | -if (php_sapi_name() != "cli" && YII_DEBUG) |
|
| 154 | +if (php_sapi_name () != "cli" && YII_DEBUG) |
|
| 155 | 155 | { |
| 156 | 156 | $ciimsCoreConfig['preload'][] = 'debug'; |
| 157 | 157 | $ciimsCoreConfig['components']['debug'] = array( |
@@ -18,12 +18,14 @@ |
||
| 18 | 18 | * @license http://opensource.org/licenses/MIT MIT LICENSE |
| 19 | 19 | * @link https://github.com/charlesportwoodii/CiiMS |
| 20 | 20 | */ |
| 21 | -$import = function($default=false) { |
|
| 21 | +$import = function($default=false) |
|
| 22 | +{ |
|
| 22 | 23 | |
| 23 | 24 | $modules = (require __DIR__ . DS . 'modules.php'); |
| 24 | 25 | |
| 25 | - if ($default === true) |
|
| 26 | - return $modules; |
|
| 26 | + if ($default === true) { |
|
| 27 | + return $modules; |
|
| 28 | + } |
|
| 27 | 29 | |
| 28 | 30 | $m = array( |
| 29 | 31 | 'application.models.*', |
@@ -6,30 +6,30 @@ |
||
| 6 | 6 | |
| 7 | 7 | // Attempt to load the cached file if it exists |
| 8 | 8 | if (file_exists($cachedConfig)) |
| 9 | - return require($cachedConfig); |
|
| 9 | + return require($cachedConfig); |
|
| 10 | 10 | else |
| 11 | 11 | { |
| 12 | - // Otherwise generate one, and return it |
|
| 13 | - $response = array(); |
|
| 12 | + // Otherwise generate one, and return it |
|
| 13 | + $response = array(); |
|
| 14 | 14 | |
| 15 | - // Find all the modules currently installed, and preload them |
|
| 16 | - foreach (new IteratorIterator(new DirectoryIterator($directory)) as $filename) |
|
| 17 | - { |
|
| 18 | - // Don't import dot files |
|
| 19 | - if (!$filename->isDot() && strpos($filename->getFileName(), ".") === false) |
|
| 20 | - { |
|
| 21 | - $path = $filename->getPathname(); |
|
| 15 | + // Find all the modules currently installed, and preload them |
|
| 16 | + foreach (new IteratorIterator(new DirectoryIterator($directory)) as $filename) |
|
| 17 | + { |
|
| 18 | + // Don't import dot files |
|
| 19 | + if (!$filename->isDot() && strpos($filename->getFileName(), ".") === false) |
|
| 20 | + { |
|
| 21 | + $path = $filename->getPathname(); |
|
| 22 | 22 | |
| 23 | - if (file_exists($path.DS.'config'.DS.'main.php')) |
|
| 24 | - $response[$filename->getFilename()] = require($path.DS.'config'.DS.'main.php'); |
|
| 25 | - else |
|
| 26 | - array_push($response, $filename->getFilename()); |
|
| 27 | - } |
|
| 28 | - } |
|
| 23 | + if (file_exists($path.DS.'config'.DS.'main.php')) |
|
| 24 | + $response[$filename->getFilename()] = require($path.DS.'config'.DS.'main.php'); |
|
| 25 | + else |
|
| 26 | + array_push($response, $filename->getFilename()); |
|
| 27 | + } |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - $encoded = serialize($response); |
|
| 31 | - file_put_contents($cachedConfig, '<?php return unserialize(\''.$encoded.'\');'); |
|
| 30 | + $encoded = serialize($response); |
|
| 31 | + file_put_contents($cachedConfig, '<?php return unserialize(\''.$encoded.'\');'); |
|
| 32 | 32 | |
| 33 | - // return the response |
|
| 34 | - return $response; |
|
| 33 | + // return the response |
|
| 34 | + return $response; |
|
| 35 | 35 | } |
@@ -2,10 +2,10 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | // Set the scan directory |
| 4 | 4 | $directory = __DIR__ . DS . '..' . DS . 'modules'; |
| 5 | -$cachedConfig = __DIR__.DS.'..'.DS.'runtime'.DS.'modules.config.php'; |
|
| 5 | +$cachedConfig = __DIR__ . DS . '..' . DS . 'runtime' . DS . 'modules.config.php'; |
|
| 6 | 6 | |
| 7 | 7 | // Attempt to load the cached file if it exists |
| 8 | -if (file_exists($cachedConfig)) |
|
| 8 | +if (file_exists ($cachedConfig)) |
|
| 9 | 9 | return require($cachedConfig); |
| 10 | 10 | else |
| 11 | 11 | { |
@@ -13,22 +13,22 @@ discard block |
||
| 13 | 13 | $response = array(); |
| 14 | 14 | |
| 15 | 15 | // Find all the modules currently installed, and preload them |
| 16 | - foreach (new IteratorIterator(new DirectoryIterator($directory)) as $filename) |
|
| 16 | + foreach (new IteratorIterator (new DirectoryIterator ($directory)) as $filename) |
|
| 17 | 17 | { |
| 18 | 18 | // Don't import dot files |
| 19 | - if (!$filename->isDot() && strpos($filename->getFileName(), ".") === false) |
|
| 19 | + if (!$filename->isDot () && strpos ($filename->getFileName (), ".") === false) |
|
| 20 | 20 | { |
| 21 | - $path = $filename->getPathname(); |
|
| 21 | + $path = $filename->getPathname (); |
|
| 22 | 22 | |
| 23 | - if (file_exists($path.DS.'config'.DS.'main.php')) |
|
| 24 | - $response[$filename->getFilename()] = require($path.DS.'config'.DS.'main.php'); |
|
| 23 | + if (file_exists ($path . DS . 'config' . DS . 'main.php')) |
|
| 24 | + $response[$filename->getFilename ()] = require($path . DS . 'config' . DS . 'main.php'); |
|
| 25 | 25 | else |
| 26 | - array_push($response, $filename->getFilename()); |
|
| 26 | + array_push ($response, $filename->getFilename ()); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - $encoded = serialize($response); |
|
| 31 | - file_put_contents($cachedConfig, '<?php return unserialize(\''.$encoded.'\');'); |
|
| 30 | + $encoded = serialize ($response); |
|
| 31 | + file_put_contents ($cachedConfig, '<?php return unserialize(\'' . $encoded . '\');'); |
|
| 32 | 32 | |
| 33 | 33 | // return the response |
| 34 | 34 | return $response; |
@@ -5,9 +5,9 @@ discard block |
||
| 5 | 5 | $cachedConfig = __DIR__.DS.'..'.DS.'runtime'.DS.'modules.config.php'; |
| 6 | 6 | |
| 7 | 7 | // Attempt to load the cached file if it exists |
| 8 | -if (file_exists($cachedConfig)) |
|
| 8 | +if (file_exists($cachedConfig)) { |
|
| 9 | 9 | return require($cachedConfig); |
| 10 | -else |
|
| 10 | +} else |
|
| 11 | 11 | { |
| 12 | 12 | // Otherwise generate one, and return it |
| 13 | 13 | $response = array(); |
@@ -20,10 +20,11 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | $path = $filename->getPathname(); |
| 22 | 22 | |
| 23 | - if (file_exists($path.DS.'config'.DS.'main.php')) |
|
| 24 | - $response[$filename->getFilename()] = require($path.DS.'config'.DS.'main.php'); |
|
| 25 | - else |
|
| 26 | - array_push($response, $filename->getFilename()); |
|
| 23 | + if (file_exists($path.DS.'config'.DS.'main.php')) { |
|
| 24 | + $response[$filename->getFilename()] = require($path.DS.'config'.DS.'main.php'); |
|
| 25 | + } else { |
|
| 26 | + array_push($response, $filename->getFilename()); |
|
| 27 | + } |
|
| 27 | 28 | } |
| 28 | 29 | } |
| 29 | 30 | |
@@ -2,126 +2,126 @@ |
||
| 2 | 2 | |
| 3 | 3 | class CategoriesController extends CiiController |
| 4 | 4 | {
|
| 5 | - /** |
|
| 6 | - * Base filter, allows logged in and non-logged in users to cache the page |
|
| 7 | - */ |
|
| 8 | - public function filters() |
|
| 9 | - {
|
|
| 10 | - $id = Yii::app()->getRequest()->getQuery('id');
|
|
| 11 | - |
|
| 12 | - if ($id == NULL || $id === false) |
|
| 13 | - throw new CHttpException(400, Yii::t('ciims.controllers.Categories', 'Invalid routing'));
|
|
| 14 | - |
|
| 15 | - return CMap::mergeArray(parent::filters(), array( |
|
| 16 | - array( |
|
| 17 | - 'CHttpCacheFilter + index', |
|
| 18 | - 'cacheControl'=>Cii::get(Yii::app()->user->id) == NULL ? 'public' : 'private' .', no-cache, must-revalidate', |
|
| 19 | - 'etagSeed'=>$id |
|
| 20 | - ), |
|
| 21 | - array( |
|
| 22 | - 'COutputCache + list', |
|
| 23 | - 'duration' => YII_DEBUG ? 1 : 86400, |
|
| 24 | - 'varyByParam' => array('page'),
|
|
| 25 | - 'varyByLanguage' => true, |
|
| 26 | - 'dependency' => array( |
|
| 27 | - 'class'=>'CDbCacheDependency', |
|
| 28 | - 'sql'=>'SELECT MAX(updated) FROM content WHERE category_id = :id', |
|
| 29 | - 'params' => array(':id' => $id)
|
|
| 30 | - ) |
|
| 31 | - ), |
|
| 32 | - array( |
|
| 33 | - 'COutputCache + rss', |
|
| 34 | - 'duration' => YII_DEBUG ? 1 : 86400, |
|
| 35 | - 'dependency' => array( |
|
| 36 | - 'class'=>'CDbCacheDependency', |
|
| 37 | - 'sql'=>'SELECT MAX(updated) FROM content WHERE category_id = :id', |
|
| 38 | - 'params' => array(':id' => $id)
|
|
| 39 | - ) |
|
| 40 | - ) |
|
| 41 | - )); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Handles all incoming requests for the entire site that are not previous defined in CUrlManager |
|
| 46 | - * Requests come in, are verified, and then pulled from the database dynamically |
|
| 47 | - * Shows all blog posts for a particular category_id |
|
| 48 | - * @param $id - The content ID that we want to pull from the database |
|
| 49 | - **/ |
|
| 50 | - public function actionIndex($id=NULL) |
|
| 51 | - {
|
|
| 52 | - // Run a pre check of our data |
|
| 53 | - $this->beforeCiiAction($id); |
|
| 54 | - |
|
| 55 | - // Retrieve the data |
|
| 56 | - $category = Categories::model()->findByPk($id); |
|
| 57 | - |
|
| 58 | - // Set the layout |
|
| 59 | - $this->setLayout('default');
|
|
| 60 | - |
|
| 61 | - $this->setPageTitle(Yii::t('ciims.controllers.Categories', '{{app_name}} | {{label}}', array(
|
|
| 62 | - '{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
|
|
| 63 | - '{{label}}' => $category->name
|
|
| 64 | - ))); |
|
| 65 | - |
|
| 66 | - $pageSize = Cii::getConfig('categoryPaginationSize', 10);
|
|
| 67 | - |
|
| 68 | - $criteria = Content::model() |
|
| 69 | - ->getBaseCriteria() |
|
| 70 | - ->addCondition('type_id >= 2')
|
|
| 71 | - ->addCondition("category_id = " . $id)
|
|
| 72 | - ->addCondition('password = ""');
|
|
| 73 | - |
|
| 74 | - $criteria->limit = $pageSize; |
|
| 75 | - $criteria->order = 'created DESC'; |
|
| 76 | - |
|
| 77 | - $itemCount = Content::model()->count($criteria); |
|
| 78 | - $pages=new CPagination($itemCount); |
|
| 79 | - $pages->pageSize=$pageSize; |
|
| 80 | - |
|
| 81 | - |
|
| 82 | - $criteria->offset = $criteria->limit*($pages->getCurrentPage()); |
|
| 83 | - $data = Content::model()->findAll($criteria); |
|
| 84 | - |
|
| 85 | - $pages->applyLimit($criteria); |
|
| 86 | - |
|
| 87 | - $this->render('index', array(
|
|
| 88 | - 'id' => $id, |
|
| 89 | - 'category' => $category, |
|
| 90 | - 'data' => $data, |
|
| 91 | - 'itemCount' => $itemCount, |
|
| 92 | - 'pages' => $pages, |
|
| 93 | - 'meta' => array( |
|
| 94 | - 'description' => $category->getDescription() |
|
| 95 | - ))); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * Displays either all posts or all posts for a particular category_id if an $id is set in RSS Format |
|
| 100 | - * So that RSS Readers can access the website |
|
| 101 | - * @param int $id |
|
| 102 | - */ |
|
| 103 | - public function actionRss($id=NULL) |
|
| 104 | - {
|
|
| 105 | - Yii::app()->log->routes[0]->enabled = false; |
|
| 106 | - ob_end_clean(); |
|
| 107 | - header('Content-type: text/xml; charset=utf-8');
|
|
| 108 | - $url = 'http://'.Yii::app()->request->serverName . Yii::app()->baseUrl; |
|
| 109 | - $this->setLayout(null); |
|
| 110 | - $criteria = Content::model() |
|
| 111 | - ->getBaseCriteria() |
|
| 112 | - ->addCondition('type_id >= 2')
|
|
| 113 | - ->addCondition('password = ""');
|
|
| 114 | - |
|
| 115 | - if ($id !== NULL) |
|
| 116 | - $criteria->addCondition("category_id = " . $id);
|
|
| 117 | - |
|
| 118 | - $criteria->order = 'created DESC'; |
|
| 119 | - $data = Content::model()->findAll($criteria); |
|
| 120 | - |
|
| 121 | - $this->renderPartial('application.views.site/rss', array(
|
|
| 122 | - 'data' => $data, |
|
| 123 | - 'url' => $url |
|
| 124 | - )); |
|
| 125 | - return; |
|
| 126 | - } |
|
| 5 | + /** |
|
| 6 | + * Base filter, allows logged in and non-logged in users to cache the page |
|
| 7 | + */ |
|
| 8 | + public function filters() |
|
| 9 | + {
|
|
| 10 | + $id = Yii::app()->getRequest()->getQuery('id');
|
|
| 11 | + |
|
| 12 | + if ($id == NULL || $id === false) |
|
| 13 | + throw new CHttpException(400, Yii::t('ciims.controllers.Categories', 'Invalid routing'));
|
|
| 14 | + |
|
| 15 | + return CMap::mergeArray(parent::filters(), array( |
|
| 16 | + array( |
|
| 17 | + 'CHttpCacheFilter + index', |
|
| 18 | + 'cacheControl'=>Cii::get(Yii::app()->user->id) == NULL ? 'public' : 'private' .', no-cache, must-revalidate', |
|
| 19 | + 'etagSeed'=>$id |
|
| 20 | + ), |
|
| 21 | + array( |
|
| 22 | + 'COutputCache + list', |
|
| 23 | + 'duration' => YII_DEBUG ? 1 : 86400, |
|
| 24 | + 'varyByParam' => array('page'),
|
|
| 25 | + 'varyByLanguage' => true, |
|
| 26 | + 'dependency' => array( |
|
| 27 | + 'class'=>'CDbCacheDependency', |
|
| 28 | + 'sql'=>'SELECT MAX(updated) FROM content WHERE category_id = :id', |
|
| 29 | + 'params' => array(':id' => $id)
|
|
| 30 | + ) |
|
| 31 | + ), |
|
| 32 | + array( |
|
| 33 | + 'COutputCache + rss', |
|
| 34 | + 'duration' => YII_DEBUG ? 1 : 86400, |
|
| 35 | + 'dependency' => array( |
|
| 36 | + 'class'=>'CDbCacheDependency', |
|
| 37 | + 'sql'=>'SELECT MAX(updated) FROM content WHERE category_id = :id', |
|
| 38 | + 'params' => array(':id' => $id)
|
|
| 39 | + ) |
|
| 40 | + ) |
|
| 41 | + )); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Handles all incoming requests for the entire site that are not previous defined in CUrlManager |
|
| 46 | + * Requests come in, are verified, and then pulled from the database dynamically |
|
| 47 | + * Shows all blog posts for a particular category_id |
|
| 48 | + * @param $id - The content ID that we want to pull from the database |
|
| 49 | + **/ |
|
| 50 | + public function actionIndex($id=NULL) |
|
| 51 | + {
|
|
| 52 | + // Run a pre check of our data |
|
| 53 | + $this->beforeCiiAction($id); |
|
| 54 | + |
|
| 55 | + // Retrieve the data |
|
| 56 | + $category = Categories::model()->findByPk($id); |
|
| 57 | + |
|
| 58 | + // Set the layout |
|
| 59 | + $this->setLayout('default');
|
|
| 60 | + |
|
| 61 | + $this->setPageTitle(Yii::t('ciims.controllers.Categories', '{{app_name}} | {{label}}', array(
|
|
| 62 | + '{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
|
|
| 63 | + '{{label}}' => $category->name
|
|
| 64 | + ))); |
|
| 65 | + |
|
| 66 | + $pageSize = Cii::getConfig('categoryPaginationSize', 10);
|
|
| 67 | + |
|
| 68 | + $criteria = Content::model() |
|
| 69 | + ->getBaseCriteria() |
|
| 70 | + ->addCondition('type_id >= 2')
|
|
| 71 | + ->addCondition("category_id = " . $id)
|
|
| 72 | + ->addCondition('password = ""');
|
|
| 73 | + |
|
| 74 | + $criteria->limit = $pageSize; |
|
| 75 | + $criteria->order = 'created DESC'; |
|
| 76 | + |
|
| 77 | + $itemCount = Content::model()->count($criteria); |
|
| 78 | + $pages=new CPagination($itemCount); |
|
| 79 | + $pages->pageSize=$pageSize; |
|
| 80 | + |
|
| 81 | + |
|
| 82 | + $criteria->offset = $criteria->limit*($pages->getCurrentPage()); |
|
| 83 | + $data = Content::model()->findAll($criteria); |
|
| 84 | + |
|
| 85 | + $pages->applyLimit($criteria); |
|
| 86 | + |
|
| 87 | + $this->render('index', array(
|
|
| 88 | + 'id' => $id, |
|
| 89 | + 'category' => $category, |
|
| 90 | + 'data' => $data, |
|
| 91 | + 'itemCount' => $itemCount, |
|
| 92 | + 'pages' => $pages, |
|
| 93 | + 'meta' => array( |
|
| 94 | + 'description' => $category->getDescription() |
|
| 95 | + ))); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * Displays either all posts or all posts for a particular category_id if an $id is set in RSS Format |
|
| 100 | + * So that RSS Readers can access the website |
|
| 101 | + * @param int $id |
|
| 102 | + */ |
|
| 103 | + public function actionRss($id=NULL) |
|
| 104 | + {
|
|
| 105 | + Yii::app()->log->routes[0]->enabled = false; |
|
| 106 | + ob_end_clean(); |
|
| 107 | + header('Content-type: text/xml; charset=utf-8');
|
|
| 108 | + $url = 'http://'.Yii::app()->request->serverName . Yii::app()->baseUrl; |
|
| 109 | + $this->setLayout(null); |
|
| 110 | + $criteria = Content::model() |
|
| 111 | + ->getBaseCriteria() |
|
| 112 | + ->addCondition('type_id >= 2')
|
|
| 113 | + ->addCondition('password = ""');
|
|
| 114 | + |
|
| 115 | + if ($id !== NULL) |
|
| 116 | + $criteria->addCondition("category_id = " . $id);
|
|
| 117 | + |
|
| 118 | + $criteria->order = 'created DESC'; |
|
| 119 | + $data = Content::model()->findAll($criteria); |
|
| 120 | + |
|
| 121 | + $this->renderPartial('application.views.site/rss', array(
|
|
| 122 | + 'data' => $data, |
|
| 123 | + 'url' => $url |
|
| 124 | + )); |
|
| 125 | + return; |
|
| 126 | + } |
|
| 127 | 127 | } |
@@ -5,17 +5,17 @@ discard block |
||
| 5 | 5 | /** |
| 6 | 6 | * Base filter, allows logged in and non-logged in users to cache the page |
| 7 | 7 | */ |
| 8 | - public function filters() |
|
| 8 | + public function filters () |
|
| 9 | 9 | {
|
| 10 | - $id = Yii::app()->getRequest()->getQuery('id');
|
|
| 10 | + $id = Yii::app ()->getRequest ()->getQuery ('id');
|
|
| 11 | 11 | |
| 12 | 12 | if ($id == NULL || $id === false) |
| 13 | - throw new CHttpException(400, Yii::t('ciims.controllers.Categories', 'Invalid routing'));
|
|
| 13 | + throw new CHttpException (400, Yii::t ('ciims.controllers.Categories', 'Invalid routing'));
|
|
| 14 | 14 | |
| 15 | - return CMap::mergeArray(parent::filters(), array( |
|
| 15 | + return CMap::mergeArray (parent::filters (), array( |
|
| 16 | 16 | array( |
| 17 | 17 | 'CHttpCacheFilter + index', |
| 18 | - 'cacheControl'=>Cii::get(Yii::app()->user->id) == NULL ? 'public' : 'private' .', no-cache, must-revalidate', |
|
| 18 | + 'cacheControl'=>Cii::get (Yii::app ()->user->id) == NULL ? 'public' : 'private' . ', no-cache, must-revalidate', |
|
| 19 | 19 | 'etagSeed'=>$id |
| 20 | 20 | ), |
| 21 | 21 | array( |
@@ -47,51 +47,51 @@ discard block |
||
| 47 | 47 | * Shows all blog posts for a particular category_id |
| 48 | 48 | * @param $id - The content ID that we want to pull from the database |
| 49 | 49 | **/ |
| 50 | - public function actionIndex($id=NULL) |
|
| 50 | + public function actionIndex ($id = NULL) |
|
| 51 | 51 | {
|
| 52 | 52 | // Run a pre check of our data |
| 53 | - $this->beforeCiiAction($id); |
|
| 53 | + $this->beforeCiiAction ($id); |
|
| 54 | 54 | |
| 55 | 55 | // Retrieve the data |
| 56 | - $category = Categories::model()->findByPk($id); |
|
| 56 | + $category = Categories::model ()->findByPk ($id); |
|
| 57 | 57 | |
| 58 | 58 | // Set the layout |
| 59 | - $this->setLayout('default');
|
|
| 59 | + $this->setLayout ('default');
|
|
| 60 | 60 | |
| 61 | - $this->setPageTitle(Yii::t('ciims.controllers.Categories', '{{app_name}} | {{label}}', array(
|
|
| 62 | - '{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
|
|
| 61 | + $this->setPageTitle (Yii::t ('ciims.controllers.Categories', '{{app_name}} | {{label}}', array(
|
|
| 62 | + '{{app_name}}' => Cii::getConfig ('name', Yii::app ()->name),
|
|
| 63 | 63 | '{{label}}' => $category->name
|
| 64 | 64 | ))); |
| 65 | 65 | |
| 66 | - $pageSize = Cii::getConfig('categoryPaginationSize', 10);
|
|
| 66 | + $pageSize = Cii::getConfig ('categoryPaginationSize', 10);
|
|
| 67 | 67 | |
| 68 | - $criteria = Content::model() |
|
| 69 | - ->getBaseCriteria() |
|
| 70 | - ->addCondition('type_id >= 2')
|
|
| 71 | - ->addCondition("category_id = " . $id)
|
|
| 72 | - ->addCondition('password = ""');
|
|
| 68 | + $criteria = Content::model () |
|
| 69 | + ->getBaseCriteria () |
|
| 70 | + ->addCondition ('type_id >= 2')
|
|
| 71 | + ->addCondition ("category_id = " . $id)
|
|
| 72 | + ->addCondition ('password = ""');
|
|
| 73 | 73 | |
| 74 | 74 | $criteria->limit = $pageSize; |
| 75 | 75 | $criteria->order = 'created DESC'; |
| 76 | 76 | |
| 77 | - $itemCount = Content::model()->count($criteria); |
|
| 78 | - $pages=new CPagination($itemCount); |
|
| 79 | - $pages->pageSize=$pageSize; |
|
| 77 | + $itemCount = Content::model ()->count ($criteria); |
|
| 78 | + $pages = new CPagination ($itemCount); |
|
| 79 | + $pages->pageSize = $pageSize; |
|
| 80 | 80 | |
| 81 | 81 | |
| 82 | - $criteria->offset = $criteria->limit*($pages->getCurrentPage()); |
|
| 83 | - $data = Content::model()->findAll($criteria); |
|
| 82 | + $criteria->offset = $criteria->limit * ($pages->getCurrentPage ()); |
|
| 83 | + $data = Content::model ()->findAll ($criteria); |
|
| 84 | 84 | |
| 85 | - $pages->applyLimit($criteria); |
|
| 85 | + $pages->applyLimit ($criteria); |
|
| 86 | 86 | |
| 87 | - $this->render('index', array(
|
|
| 87 | + $this->render ('index', array(
|
|
| 88 | 88 | 'id' => $id, |
| 89 | 89 | 'category' => $category, |
| 90 | 90 | 'data' => $data, |
| 91 | 91 | 'itemCount' => $itemCount, |
| 92 | 92 | 'pages' => $pages, |
| 93 | 93 | 'meta' => array( |
| 94 | - 'description' => $category->getDescription() |
|
| 94 | + 'description' => $category->getDescription () |
|
| 95 | 95 | ))); |
| 96 | 96 | } |
| 97 | 97 | |
@@ -100,25 +100,25 @@ discard block |
||
| 100 | 100 | * So that RSS Readers can access the website |
| 101 | 101 | * @param int $id |
| 102 | 102 | */ |
| 103 | - public function actionRss($id=NULL) |
|
| 103 | + public function actionRss ($id = NULL) |
|
| 104 | 104 | {
|
| 105 | - Yii::app()->log->routes[0]->enabled = false; |
|
| 106 | - ob_end_clean(); |
|
| 107 | - header('Content-type: text/xml; charset=utf-8');
|
|
| 108 | - $url = 'http://'.Yii::app()->request->serverName . Yii::app()->baseUrl; |
|
| 109 | - $this->setLayout(null); |
|
| 110 | - $criteria = Content::model() |
|
| 111 | - ->getBaseCriteria() |
|
| 112 | - ->addCondition('type_id >= 2')
|
|
| 113 | - ->addCondition('password = ""');
|
|
| 105 | + Yii::app ()->log->routes[0]->enabled = false; |
|
| 106 | + ob_end_clean (); |
|
| 107 | + header ('Content-type: text/xml; charset=utf-8');
|
|
| 108 | + $url = 'http://' . Yii::app ()->request->serverName . Yii::app ()->baseUrl; |
|
| 109 | + $this->setLayout (null); |
|
| 110 | + $criteria = Content::model () |
|
| 111 | + ->getBaseCriteria () |
|
| 112 | + ->addCondition ('type_id >= 2')
|
|
| 113 | + ->addCondition ('password = ""');
|
|
| 114 | 114 | |
| 115 | 115 | if ($id !== NULL) |
| 116 | - $criteria->addCondition("category_id = " . $id);
|
|
| 116 | + $criteria->addCondition ("category_id = " . $id);
|
|
| 117 | 117 | |
| 118 | 118 | $criteria->order = 'created DESC'; |
| 119 | - $data = Content::model()->findAll($criteria); |
|
| 119 | + $data = Content::model ()->findAll ($criteria); |
|
| 120 | 120 | |
| 121 | - $this->renderPartial('application.views.site/rss', array(
|
|
| 121 | + $this->renderPartial ('application.views.site/rss', array(
|
|
| 122 | 122 | 'data' => $data, |
| 123 | 123 | 'url' => $url |
| 124 | 124 | )); |
@@ -1,16 +1,17 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class CategoriesController extends CiiController |
|
| 4 | -{
|
|
| 3 | +class CategoriesController extends CiiController |
|
| 4 | +{ |
|
| 5 | 5 | /** |
| 6 | 6 | * Base filter, allows logged in and non-logged in users to cache the page |
| 7 | 7 | */ |
| 8 | - public function filters() |
|
| 9 | - {
|
|
| 8 | + public function filters() |
|
| 9 | + { |
|
| 10 | 10 | $id = Yii::app()->getRequest()->getQuery('id');
|
| 11 | 11 | |
| 12 | - if ($id == NULL || $id === false) |
|
| 13 | - throw new CHttpException(400, Yii::t('ciims.controllers.Categories', 'Invalid routing'));
|
|
| 12 | + if ($id == NULL || $id === false) { |
|
| 13 | + throw new CHttpException(400, Yii::t('ciims.controllers.Categories', 'Invalid routing')); |
|
| 14 | + } |
|
| 14 | 15 | |
| 15 | 16 | return CMap::mergeArray(parent::filters(), array( |
| 16 | 17 | array( |
@@ -47,8 +48,8 @@ discard block |
||
| 47 | 48 | * Shows all blog posts for a particular category_id |
| 48 | 49 | * @param $id - The content ID that we want to pull from the database |
| 49 | 50 | **/ |
| 50 | - public function actionIndex($id=NULL) |
|
| 51 | - {
|
|
| 51 | + public function actionIndex($id=NULL) |
|
| 52 | + { |
|
| 52 | 53 | // Run a pre check of our data |
| 53 | 54 | $this->beforeCiiAction($id); |
| 54 | 55 | |
@@ -100,8 +101,8 @@ discard block |
||
| 100 | 101 | * So that RSS Readers can access the website |
| 101 | 102 | * @param int $id |
| 102 | 103 | */ |
| 103 | - public function actionRss($id=NULL) |
|
| 104 | - {
|
|
| 104 | + public function actionRss($id=NULL) |
|
| 105 | + { |
|
| 105 | 106 | Yii::app()->log->routes[0]->enabled = false; |
| 106 | 107 | ob_end_clean(); |
| 107 | 108 | header('Content-type: text/xml; charset=utf-8');
|
@@ -112,8 +113,9 @@ discard block |
||
| 112 | 113 | ->addCondition('type_id >= 2')
|
| 113 | 114 | ->addCondition('password = ""');
|
| 114 | 115 | |
| 115 | - if ($id !== NULL) |
|
| 116 | - $criteria->addCondition("category_id = " . $id);
|
|
| 116 | + if ($id !== NULL) { |
|
| 117 | + $criteria->addCondition("category_id = " . $id); |
|
| 118 | + } |
|
| 117 | 119 | |
| 118 | 120 | $criteria->order = 'created DESC'; |
| 119 | 121 | $data = Content::model()->findAll($criteria); |