/** * Call the appropriate command * * @return void */ public function main() { $args = $this->args; $this->args = array_map('strtolower', $this->args); $activate = $this->args[0]; $type = $this->args[1]; $ext = isset($args[2]) ? $args[2] : null; if ($type == 'theme') { if ($activate == 'deactivate') { $this->_deactivateTheme(); return true; } $extensions = $this->_CroogoTheme->getThemes(); } elseif ($type == 'plugin') { $extensions = $this->_CroogoPlugin->getPlugins(); } if (!in_array($ext, $extensions)) { $this->err(__('%s "%s" not found.', ucfirst($type), $ext)); return false; } return $this->{'_' . $activate . ucfirst($type)}($ext); }
/** * List themes */ public function themes($theme = null) { $CroogoTheme = new CroogoTheme(); $all = $this->params['all']; $current = Configure::read('Site.theme'); $themes = $theme == null ? $CroogoTheme->getThemes() : array($theme); $this->out("Themes:", 2); $default = empty($current) || $current == 'default'; $this->out(__d('croogo', '%-20s%-50s%s', __d('croogo', 'Theme'), __d('croogo', 'Author'), __d('croogo', 'Status'))); $this->out(str_repeat('-', 80)); foreach ($themes as $theme) { $active = $theme == $current || $default && $theme == 'default'; $status = $active ? '<success>active</success>' : '<info>inactive</info>'; if (!$active && !$all) { continue; } $data = $CroogoTheme->getThemeData($theme); $author = isset($data['author']) ? $data['author'] : ''; $this->out(__d('croogo', '%-20s%-50s%s', $theme, $author, $status)); } }
/** * testGetThemes */ public function testGetThemes() { $themes = $this->CroogoTheme->getThemes(); $this->assertTrue(array_key_exists('Mytheme', $themes)); }