/** * Get a list of themes or start theme download * * Supported params: * 1. name - Theme name. Tells API that this is an attempt to download a theme * E.g. http://seotoaster.dev/api/toaster/themes/name/ecommerce * 2. kind [full|light] - Type of theme to download. Requires name param * E.g. http://seotoaster.dev/api/toaster/themes/name/ecommerce/kind/full * 3. sql [1|0] - Tells API to include or not sql dump to the full theme. Requires name and kind=full * E.g. http://seotoaster.dev/api/toaster/themes/name/ecommerce/kind/full/sql/0 * 4. media [1|0] - Tells API to include or not media directory to the full theme. Requires name and kind=full * E.g. http://seotoaster.dev/api/toaster/themes/name/ecommerce/kind/full/media/0 * 5. teasers [1|0] - Tells API to include or not previews directory to the full theme. Requires name and kind=full * E.g. http://seotoaster.dev/api/toaster/themes/name/ecommerce/kind/full/teasers/0 * Full example * http://seotoaster.dev/api/toaster/themes/name/ecommerce/kind/full/sql/0/media/1/teasers/1 * @return array */ public function getAction() { $themesPath = $this->_websiteHelper->getPath() . $this->_themesConfig['path']; // if parameter 'name' specified in the query, we assume user is trying to download a theme if ($this->_request->has('name')) { $themeName = filter_var($this->_request->getParam('name'), FILTER_SANITIZE_STRING); $themePath = $themesPath . $themeName; // check if full theme requested - perform necessary actions $isFull = $this->_request->has('kind') && $this->_request->getParam('kind') == self::THEME_KIND_FULL; // exporting theme $this->_exportTheme($themeName, $isFull); } // themes list request $themesList = array(); $themesDirs = Tools_Filesystem_Tools::scanDirectoryForDirs($themesPath); // there are no themes in the theme directory if (empty($themesDirs)) { $this->_error($this->_translator->translate('Aw! No themes found!'), self::REST_STATUS_NOT_FOUND); } foreach ($themesDirs as $themeName) { $files = Tools_Filesystem_Tools::scanDirectory($themesPath . $themeName, false, false); $requiredFiles = preg_grep('/^(' . implode('|', $this->_protectedTemplates) . ')\\.html$/i', $files); if (sizeof($requiredFiles) != sizeof($this->_protectedTemplates)) { continue; } $previews = preg_grep('/^preview\\.(png|jpg|gif)$/i', $files); $hasData = file_exists($themesPath . $themeName . DIRECTORY_SEPARATOR . self::THEME_DATA_FILE) || is_dir($themesPath . $themeName . DIRECTORY_SEPARATOR . 'media/') || is_dir($themesPath . $themeName . DIRECTORY_SEPARATOR . 'previews/'); array_push($themesList, array('name' => $themeName, 'preview' => !empty($previews) ? $this->_websiteHelper->getUrl() . $this->_themesConfig['path'] . $themeName . '/' . reset($previews) : $this->_websiteHelper->getUrl() . 'system/images/noimage.png', 'isCurrent' => $this->_configHelper->getConfig('currentTheme') == $themeName, 'hasData' => $hasData)); } if (empty($themesList)) { $this->_error($this->_translator->translate('Aw! Looks like none of your themes are valid!'), self::REST_STATUS_NOT_FOUND); } return $themesList; }
public static function getNames() { $includePath = explode(PATH_SEPARATOR, get_include_path()); $widgetsNames = array(); foreach ($includePath as $path) { if (is_readable($path . DIRECTORY_SEPARATOR . 'Widgets')) { $widgetsNames = array_merge($widgetsNames, Tools_Filesystem_Tools::scanDirectoryForDirs($path . DIRECTORY_SEPARATOR . 'Widgets')); } } sort($widgetsNames); return $widgetsNames; }
private function _getFoldersList($imagesOnly = false) { $listFolders = Tools_Filesystem_Tools::scanDirectoryForDirs($this->_websiteConfig['path'] . $this->_websiteConfig['media']); if (!empty($listFolders)) { if ($imagesOnly) { foreach ($listFolders as $key => $folder) { if (!is_dir($this->_websiteConfig['path'] . $this->_websiteConfig['media'] . $folder . '/small')) { unset($listFolders[$key]); } } } $listFolders = array_combine($listFolders, $listFolders); } return $listFolders; }
public static function findAvialablePlugins() { $website = Zend_Controller_Action_HelperBroker::getStaticHelper('Website'); $misc = Zend_Registry::get('misc'); $pluginsPath = $website->getPath() . $misc['pluginsPath']; $pluginsDirs = Tools_Filesystem_Tools::scanDirectoryForDirs($pluginsPath); $plugins = array(); if (!empty($pluginsDirs)) { foreach ($pluginsDirs as $pluginDir) { $required = array('readme.txt', ucfirst($pluginDir) . '.php'); $pluginDirContent = Tools_Filesystem_Tools::scanDirectory($pluginsPath . '/' . $pluginDir, false, false); // check if plugin is bundle, then do not show in the plugin managment screen if (in_array('.bundle', $pluginDirContent)) { continue; } if ($required == array_intersect($required, $pluginDirContent)) { $plugins[] = $pluginDir; } } } return $plugins; }
public function refreshfoldersAction() { $websiteData = Zend_Registry::get('website'); $this->_helper->response->success(Tools_Filesystem_Tools::scanDirectoryForDirs($websiteData['path'] . $websiteData['media'])); }