public function Folders($path) { if ($this->mode == 'ftp') { return $this->source_ftp->listDetails($this->ftp_root . $path, 'folders'); } else { return JFolder::Folders($this->source_path . $path); } }
/** * Called before any type of action * * @param string $type Which action is happening (install|uninstall|discover_install) * @param object $parent The object responsible for running this script * * @return boolean True on success */ public function preflight($type, $parent) { // init vars $db = JFactory::getDBO(); $type = strtolower($type); $this->_src = $parent->getParent()->getPath('source'); // tmp folder $this->_target = JPATH_ROOT . '/plugins/system/zoo_zlelements'; // install folder $html = ''; // load ZLFW sys language file JFactory::getLanguage()->load('plg_system_zlframework.sys', JPATH_ADMINISTRATOR, 'en-GB', true); // check dependencies if not uninstalling if ($type != 'uninstall' && !$this->checkRequirements($parent)) { Jerror::raiseWarning(null, $this->_error); return false; } if ($type == 'install' || $type == 'update') { if ($type == 'update') { $cur_manifest = simplexml_load_file(JPATH_ROOT . '/plugins/system/zoo_zlelements/zoo_zlelements.xml'); $new_manifest = $parent->get("manifest"); // if trying to update with older plugin, just update the elements if (version_compare((string) $cur_manifest->version, (string) $new_manifest->version, '>')) { // set the plugin update state $this->_plugin_updated = false; // copy installed plugin files into temp folder to be able to install without issues JFile::copy(JPath::clean(JPATH_ROOT . '/plugins/system/zoo_zlelements/zoo_zlelements.xml'), JPath::clean("{$this->_src}/zoo_zlelements.xml")); JFile::copy(JPath::clean(JPATH_ROOT . '/plugins/system/zoo_zlelements/zoo_zlelements.php'), JPath::clean("{$this->_src}/zoo_zlelements.php")); if (!JFolder::exists("{$this->_src}/languages")) { JFolder::create("{$this->_src}/languages"); } JFile::copy(JPath::clean(JPATH_ROOT . '/administrator/language/en-GB/en-GB.plg_system_zoo_zlelements.ini'), JPath::clean("{$this->_src}/languages/en-GB.plg_system_zoo_zlelements.ini")); $html .= '<p>' . JText::_($this->langString('_ALLREADY_UP_TO_DATE')) . '</p>'; } else { // Remove depricated folders $f = JPATH_ROOT . '/plugins/system/zoo_zlelements/zoo_zlelements/fields'; // even if removed will be repopulated with the new content if (JFolder::exists($f)) { JFolder::delete($f); } } } // make sure elements folder exist if (!JFolder::exists("{$this->_src}/zoo_zlelements")) { JFolder::create("{$this->_src}/zoo_zlelements"); } // element tasks if (JFolder::exists("{$this->_src}/elements")) { // install lang files to admin folder foreach (JFolder::folders("{$this->_src}/elements") as $element) { if (JFolder::exists("{$this->_src}/elements/{$element}/language")) { if (JFolder::copy("{$this->_src}/elements/{$element}/language", JPATH_ADMINISTRATOR . "/language", '', true)) { // we can't use the move function as it's not working on windows servers JFolder::delete("{$this->_src}/elements/{$element}/language"); } } // remove old lang file if (JFile::exists("{$this->_target}/zoo_zlelements/language/en-GB/en-GB.plg_system_zoo_zlelements_{$element}.ini")) { JFile::delete("{$this->_target}/zoo_zlelements/language/en-GB/en-GB.plg_system_zoo_zlelements_{$element}.ini"); } } // move all languages files to the new admin location if (JFolder::exists("{$this->_src}/elements/{$element}/language")) { if (JFolder::copy("{$this->_target}/zoo_zlelements/language", JPATH_ADMINISTRATOR . "/language", '', true)) { // we can't use the move function as it's not working on windows servers JFolder::delete("{$this->_target}/zoo_zlelements/language"); } } // move elements to install folder if (JFolder::exists("{$this->_src}/elements")) { // move the elements, using copy instead of move if (JFolder::copy('elements', 'zoo_zlelements/elements', $this->_src)) { // we can't use the move function as it's not working on windows servers JFolder::delete("{$this->_src}/elements"); } } // execute individual elements install scripts foreach (JFolder::Folders("{$this->_src}/zoo_zlelements/elements") as $element) { $file = "{$this->_src}/zoo_zlelements/elements/{$element}/install.script.php"; if (is_file($file)) { ob_start(); include $file; $html .= ob_get_contents(); ob_end_clean(); } } } } // render message echo $html; }