public function install($ptHandle = null) { $th = PageTheme::getByFileHandle($ptHandle); if ($ptHandle == null) { $this->redirect('/dashboard/pages/themes'); } $v = Loader::helper('validation/error'); try { if (is_object($th)) { $t = PageTheme::add($ptHandle); $this->redirect('/dashboard/pages/themes/inspect', $t->getThemeID(), 1); } else { throw new Exception('Invalid Theme'); } } catch (Exception $e) { switch ($e->getMessage()) { case PageTheme::E_THEME_INSTALLED: $v->add(t('That theme has already been installed.')); break; default: $v->add($e->getMessage()); break; } $this->set('error', $v); } $this->view(); }
public static function getAvailableThemes($filterInstalled = true) { // scans the directory for available themes. For those who don't want to go through // the hassle of uploading $db = Loader::db(); $dh = Loader::helper('file'); $themes = $dh->getDirectoryContents(DIR_FILES_THEMES); if ($filterInstalled) { // strip out themes we've already installed $handles = $db->GetCol("select ptHandle from PageThemes"); $themesTemp = array(); foreach($themes as $t) { if (!in_array($t, $handles)) { $themesTemp[] = $t; } } $themes = $themesTemp; } if (count($themes) > 0) { $themesTemp = array(); // get theme objects from the file system foreach($themes as $t) { $th = PageTheme::getByFileHandle($t); if (!empty($th)) { $themesTemp[] = $th; } } $themes = $themesTemp; } return $themes; }