core = $modules->core; $this->modules = $modules; $this->store = new dcStore($modules, $xml_url); $this->page_url = $this->core->adminurl->get('admin.plugins'); $this->setPath($modules_root); $this->setIndex(__('other')); } /** * Begin a new list. * * @param string $id New list ID * @return adminModulesList self instance */ public function setList($id) { $this->data = array(); $this->page_tab = ''; $this->list_id = $id; return $this; } /** * Get list ID. * * @return List ID */ public function getList() { return $this->list_id; } /// @name Modules root directory methods //@{ /** * Set path info. * * @param string $root Modules root directories * @return adminModulesList self instance */ protected function setPath($root) { $paths = explode(PATH_SEPARATOR, $root); $path = array_pop($paths); unset($paths); $this->path = $path; if (is_dir($path) && is_writeable($path)) { $this->path_writable = true; $this->path_pattern = preg_quote($path,'!'); } return $this; } /** * Get modules root directory. * * @return Path to work on */ public function getPath() { return $this->path; } /** * Check if modules root directory is writable. * * @return True if directory is writable */ public function isWritablePath() { return $this->path_writable; } /** * Check if root directory of a module is deletable. * * @param string $root Module root directory * @return True if directory is delatable */ public function isDeletablePath($root) { return $this->path_writable && (preg_match('!^'.$this->path_pattern.'!', $root) || defined('DC_DEV') && DC_DEV) && $this->core->auth->isSuperAdmin(); } //@} /// @name Page methods //@{ /** * Set page base URL. * * @param string $url Page base URL * @return adminModulesList self instance */ public function setURL($url) { $this->page_qs = strpos('?', $url) ? '&' : '?'; $this->page_url = $url; return $this; } /** * Get page URL. * * @param string|array $queries Additionnal query string * @param booleany $with_tab Add current tab to URL end * @return Clean page URL */ public function getURL($queries='', $with_tab=true) { return $this->page_url. (!empty($queries) ? $this->page_qs : ''). (is_array($queries) ? http_build_query($queries) : $queries). ($with_tab && !empty($this->page_tab) ? '#'.$this->page_tab : ''); } /** * Set page tab. * * @param string $tab Page tab * @return adminModulesList self instance */ public function setTab($tab) { $this->page_tab = $tab; return $this; } /** * Get page tab. * * @return Page tab */ public function getTab() { return $this->page_tab; } /** * Set page redirection. * * @param string $default Default redirection * @return adminModulesList self instance */ public function setRedir($default='') { $this->page_redir = empty($_REQUEST['redir']) ? $default : $_REQUEST['redir']; return $this; } /** * Get page redirection. * * @return Page redirection */ public function getRedir() { return empty($this->page_redir) ? $this->getURL() : $this->page_redir; } //@} /// @name Search methods //@{ /** * Get search query. * * @return Search query */ public function getSearch() { $query = !empty($_REQUEST['m_search']) ? trim($_REQUEST['m_search']) : null; return strlen($query) > 2 ? $query : null; } /** * Display searh form. * * @return adminModulesList self instance */ public function displaySearch() { $query = $this->getSearch(); if (empty($this->data) && $query === null) { return $this; } echo '