Index: branches/5.3.x/core/units/helpers/deployment_helper.php =================================================================== diff -u -N -r15677 -r15902 --- branches/5.3.x/core/units/helpers/deployment_helper.php (.../deployment_helper.php) (revision 15677) +++ branches/5.3.x/core/units/helpers/deployment_helper.php (.../deployment_helper.php) (revision 15902) @@ -1,6 +1,6 @@ _event = new kEvent('adm:OnDummy'); $this->isCommandLine = isset($GLOBALS['argv']) && count($GLOBALS['argv']); if ( !$this->isCommandLine ) { @@ -99,6 +108,18 @@ } /** + * Sets event, associated with deployment + * + * @param kEvent $event + * @return void + * @access public + */ + public function setEvent(kEvent $event) + { + $this->_event = $event; + } + + /** * Adds message to script execution log * * @param string $message @@ -185,13 +206,38 @@ } if ( !$this->isCommandLine ) { + echo kUtil::escape($this->_runShellScript()); echo '' . PHP_EOL; } return $ret; } /** + * Runs user-specific shell script when deployment happens from Web + * + * @return string + * @access protected + */ + protected function _runShellScript() + { + if ( !$this->Application->isDebugMode(false) ) { + return ''; + } + + $wrapper_script = '/usr/local/bin/guest2host_server.sh'; + $script_name = FULL_PATH .'/tools/' . ($this->dryRun ? 'synchronize.sh' : 'deploy.sh'); + + if ( file_exists($wrapper_script) && file_exists($script_name) ) { + $script_name = preg_replace('/^.*\/web/', constant('DBG_LOCAL_BASE_PATH'), $script_name); + + return shell_exec($wrapper_script . ' ' . $script_name . ' 2>&1'); + } + + return ''; + } + + /** * Deploys pending changes to a site * * @param string $module_name @@ -206,7 +252,10 @@ return false; } - if ( !$this->dryRun ) { + if ( $this->dryRun ) { + $this->exportLanguagePack(); + } + else { $this->importLanguagePack(); } @@ -233,6 +282,29 @@ } /** + * Exports latest language pack + * + * @return void + * @access private + */ + private function exportLanguagePack() + { + static $languages = null; + + if ( !isset($languages) ) { + $sql = 'SELECT LanguageId + FROM ' . $this->Application->getUnitConfig('lang')->getTableName() . ' + WHERE Enabled = 1'; + $languages = $this->Conn->GetCol($sql); + } + + $language_import_helper = $this->Application->recallObject('LanguageImportHelper'); + /* @var $language_import_helper LanguageImportHelper */ + + $language_import_helper->performExport(EXPORT_PATH . '/' . $this->moduleName . '.lang', '|0|1|2|', $languages, '|' . $this->moduleName . '|'); + } + + /** * Resets unit and section cache * * @return void @@ -241,14 +313,19 @@ private function resetCaches() { // 2. reset unit config cache (so new classes get auto-registered) - $this->out('Resetting Unit Config Cache ... '); - $this->Application->HandleEvent(new kEvent('adm:OnResetConfigsCache')); + $this->out('Resetting Configs Files Cache and Parsed System Data ... '); + $this->_event->CallSubEvent('OnResetConfigsCache'); $this->displayStatus('OK'); // 3. reset sections cache - $this->out('Resetting Sections Cache ... '); - $this->Application->HandleEvent(new kEvent('adm:OnResetSections')); + $this->out('Resetting Admin Console Sections ... '); + $this->_event->CallSubEvent('OnResetSections'); $this->displayStatus('OK'); + + // 4. reset mod-rewrite cache + $this->out('Resetting ModRewrite Cache ... '); + $this->_event->CallSubEvent('OnResetModRwCache'); + $this->displayStatus('OK'); } /** @@ -259,8 +336,8 @@ */ private function refreshThemes() { - $this->out('Rebuilding Theme Files ... '); - $this->Application->HandleEvent(new kEvent('adm:OnRebuildThemes')); + $this->out('Refreshing Theme Files ... '); + $this->_event->CallSubEvent('OnRebuildThemes'); $this->displayStatus('OK'); } @@ -422,7 +499,8 @@ } elseif ( $sql ) { $this->toLog($sql . ' ... ', false); - echo mb_substr(trim(preg_replace('/(\n|\t| )+/is', ' ', ($this->isCommandLine ? $sql : htmlspecialchars($sql, null, CHARSET)))), 0, self::SQL_TRIM_LENGTH) . ' ... '; + $escaped_sql = $this->isCommandLine ? $sql : kUtil::escape($sql); + echo mb_substr(trim(preg_replace('/(\n|\t| )+/is', ' ', $escaped_sql)), 0, self::SQL_TRIM_LENGTH) . ' ... '; $this->Conn->Query($sql); @@ -563,26 +641,10 @@ $html_color = $html_color_map[$color][$bold ? 'bold' : 'normal']; - return '' . htmlspecialchars($text, null, CHARSET) . ''; + return '' . kUtil::escape($text, kUtil::ESCAPE_HTML) . ''; } /** - * Makes given text bold - * - * @param string $text - * @return string - * @access private - */ - private function boldText($text) - { - if ( $this->isCommandLine ) { - return "\033[1m" . $text . "\033[0m"; - } - - return '' . htmlspecialchars($text, null, CHARSET) . ''; - } - - /** * Displays last command execution status * * @param string $status_text @@ -611,7 +673,7 @@ private function out($text, $new_line = false) { if ( !$this->isCommandLine ) { - $text = htmlspecialchars($text, null, CHARSET); + $text = kUtil::escape($text); } echo $text . ($new_line ? PHP_EOL : '');