protected static function _upgradeDatabase($sqlFolderPath, $previousVersion, $latestVersion) { $files = RM_Filesystem::getFiles($sqlFolderPath, array('sql')); $upgradeVersions = array(); foreach ($files as $file) { if (strpos($file, '.upgrade.sql') !== false) { $upgradeVersions[] = str_replace('.upgrade.sql', '', $file); } } usort($upgradeVersions, 'version_compare'); $result = true; foreach ($upgradeVersions as $version) { if (version_compare($version, $previousVersion, '>') && version_compare($version, $latestVersion, '<=')) { $result &= RM_SQL_Manager::executeSQLFile($sqlFolderPath . DIRECTORY_SEPARATOR . $version . '.upgrade.sql'); } } return $result; }
/** * Returns array with js full file URLs * * @param string $pluginName plugin name * @return array */ public static function getAdminJSFiles($pluginName) { $folder = self::getPluginFolderpath($pluginName); $folder .= DIRECTORY_SEPARATOR . RM_Plugin_Config::JS; return RM_Filesystem::getFiles($folder, array("js")); }
/** * Returns array with js full file URLs * * @param string $moduleName module name * @return array */ public static function getAdminJSFiles($moduleName) { $folder = self::getModuleFolderpath($moduleName); $folder .= DIRECTORY_SEPARATOR . RM_Module_Config::JS; return RM_Filesystem::getFiles($folder, array("js")); }
/** This performs the DB Upgrade * step 3 * This process will apply the upgrade sql files in sequence. So that all * updates are applied from one version to the next. * * @return json */ public function upgradedatabaseJsonAction() { // get the current db version $system = new RM_System(); $dbVersion = $system->getDBVersion()->current()->db_version; // get the latest version $version = RM_Environment::getInstance()->getLatestVersion(); if ($dbVersion == $version) { RM_Log::toLog('Upgrade - DB upgrade not required as DB is at latest revision: ' . $dbVersion, RM_Log::INFO); return array('data' => array('success' => 1, 'error' => "No DB Upgrade Action Required as DB Version is at Latest Revision")); } // Remove all dots from version so we will get the integer of the version. ie: 1211630 $dbCurrentVersionNumber = (int) str_replace(".", "", $dbVersion); $sqlPath = implode(DIRECTORY_SEPARATOR, array(RM_Environment::getConnector()->getRootPath(), 'RM', 'userdata', 'temp', 'upgrade', 'system', 'sql')); // if this is the stable release switch to the upgrades folder... if (version_compare($dbVersion, "1.0.0", '>=')) { $sqlPath = $sqlPath . DIRECTORY_SEPARATOR . "upgrades"; } $filesContent = array(); $files = RM_Filesystem::getFiles($sqlPath, array('sql')); $numbers = array(); foreach ($files as $file) { $chunks = explode('.', $file); if (count($chunks) == 3 && $chunks[1] == 'upgrade') { $numbers[] = $chunks[0]; } } sort($numbers); foreach ($numbers as $number) { if ($number > $dbCurrentVersionNumber) { $sqlFile = $sqlPath . DIRECTORY_SEPARATOR . $number . ".upgrade.sql"; RM_Log::toLog('Upgrade - Applying DB upgrade file: ' . $sqlFile, RM_Log::INFO); if (file_exists($sqlFile)) { $filesContent[] = file_get_contents($sqlFile); } } } foreach ($filesContent as $fileContent) { try { $result = $system->parseSQL($fileContent); } catch (Exception $e) { $result = false; } if (!$result) { RM_Log::toLog('Upgrade - DB Upgrade has failed!', RM_Log::ERR); $msg = 'The database query for installation/upgrade has failed! More Information about the exception thrown will be in the systemlog'; return array('data' => array('success' => false, 'msg' => $msg)); } } return array('data' => array('success' => true)); }
/** * Resize all thumbnails */ public function resize() { RM_Media_Image::initialize(); $files = RM_Filesystem::getFiles($this->_imageFolder, $this->_extensions); foreach ($files as $filename) { if (RM_Media_Image::isOriginal($filename)) { $this->createThumbnail($filename); } } }