Index: branches/5.3.x/core/units/category_items/category_items_config.php =================================================================== diff -u -r15986 -r16124 --- branches/5.3.x/core/units/category_items/category_items_config.php (.../category_items_config.php) (revision 15986) +++ branches/5.3.x/core/units/category_items/category_items_config.php (.../category_items_config.php) (revision 16124) @@ -1,6 +1,6 @@ 'ci', 'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'), 'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'), - 'EventHandlerClass' => Array ('class' => 'CategoryItemsEventHander', 'file' => 'category_items_event_handler.php', 'build_event' => 'OnBuild'), + 'EventHandlerClass' => Array ('class' => 'CategoryItemsEventHandler', 'file' => 'category_items_event_handler.php', 'build_event' => 'OnBuild'), 'TagProcessorClass' => Array ('class' => 'CategoryItemsTagProcessor', 'file' => 'category_items_tag_processor.php', 'build_event' => 'OnBuild'), 'AutoLoad' => true, Index: branches/5.3.x/core/units/languages/languages_event_handler.php =================================================================== diff -u -r16111 -r16124 --- branches/5.3.x/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 16111) +++ branches/5.3.x/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 16124) @@ -1,6 +1,6 @@ Special == 'current' ) { + $event->setEventParam('live_table', true); + } + + parent::dbBuild($object, $event); + } + + /** * Allows to get primary language object * * @param kEvent $event @@ -70,7 +87,17 @@ if ( $event->Special == 'primary' ) { return $this->Application->GetDefaultLanguageId(); } + elseif ( $event->Special == 'current' ) { + $language_id = $this->Application->GetVar('m_lang'); + if ( !$language_id ) { + $language_id = 'default'; + } + + $this->Application->SetVar('m_lang', $language_id); + $this->Application->SetVar($event->getPrefixSpecial() . '_id', $language_id); + } + return parent::getPassedID($event); } Index: branches/5.3.x/core/install/incs/style.css =================================================================== diff -u -r15483 -r16124 --- branches/5.3.x/core/install/incs/style.css (.../style.css) (revision 15483) +++ branches/5.3.x/core/install/incs/style.css (.../style.css) (revision 16124) @@ -35,6 +35,10 @@ font-family: 'Lucida Grande', Verdana, Geneva, Lucida, Helvetica, Arial, sans-serif; } +ol li { + font-family: 'Lucida Grande', Verdana, Geneva, Lucida, Helvetica, Arial, sans-serif; +} + .head_version { padding-right: 5px; font-weight: normal; @@ -223,4 +227,4 @@ #core-tb-prev.disabled { background-position: -64px -704px; } #core-tb-next { background-position: -0px -640px; } #core-tb-next.hover { background-position: -32px -640px; } -#core-tb-next.disabled { background-position: -64px -640px; } \ No newline at end of file +#core-tb-next.disabled { background-position: -64px -640px; } Index: branches/5.3.x/core/units/fck/fck_eh.php =================================================================== diff -u -r15902 -r16124 --- branches/5.3.x/core/units/fck/fck_eh.php (.../fck_eh.php) (revision 15902) +++ branches/5.3.x/core/units/fck/fck_eh.php (.../fck_eh.php) (revision 16124) @@ -1,6 +1,6 @@ Application->recallObject('theme.current'); + + /** @var MinifyHelper $minify_helper */ $minify_helper = $this->Application->recallObject('MinifyHelper'); - /* @var $minify_helper MinifyHelper */ $this->Application->InitParser(); - $styles_css = $minify_helper->CompressScriptTag( Array ('files' => 'inc/style.css') ); + $styles_css = $minify_helper->CompressScriptTag(array('files' => $theme->getStylesheetFile(true))); $event->redirect = 'external:' . $styles_css; } - } \ No newline at end of file + } Index: branches/5.3.x/core/kernel/db/dblist.php =================================================================== diff -u -r16111 -r16124 --- branches/5.3.x/core/kernel/db/dblist.php (.../dblist.php) (revision 16111) +++ branches/5.3.x/core/kernel/db/dblist.php (.../dblist.php) (revision 16124) @@ -1,6 +1,6 @@ SetPage(1); $this->Query($force); } + else if ( $this->Application->HttpQuery->refererIsOurSite() ) { + // no records & page > 1, try to reset to last page + $this->SetPage($this->GetTotalPages()); + $this->Query($force); + } else { // no records & page > 1, show 404 page trigger_error('Unknown page ' . $this->Page . ' in ' . $this->getPrefixSpecial() . ' list, leading to "404 Not Found"', E_USER_NOTICE); Index: branches/5.3.x/core/kernel/application.php =================================================================== diff -u -r16111 -r16124 --- branches/5.3.x/core/kernel/application.php (.../application.php) (revision 16111) +++ branches/5.3.x/core/kernel/application.php (.../application.php) (revision 16124) @@ -1,6 +1,6 @@ GetVar('m_lang'); - - if ( !$language_id ) { - $language_id = 'default'; - } - - $this->SetVar('lang.current_id', $language_id); - $this->SetVar('m_lang', $language_id); - - $lang_mode = $this->GetVar('lang_mode'); - $this->SetVar('lang_mode', ''); - + /** @var LanguagesItem $lang */ $lang = $this->recallObject('lang.current'); - /* @var $lang kDBItem */ if ( !$lang->isLoaded() || (!$this->isAdmin && !$lang->GetDBField('Enabled')) ) { if ( !defined('IS_INSTALL') ) { $this->ApplicationDie('Unknown or disabled language'); } } - - $this->SetVar('lang_mode', $lang_mode); } /** @@ -530,16 +516,8 @@ return $path; } - $theme_id = $this->GetVar('m_theme'); - if ( !$theme_id ) { - $theme_id = 'default'; // $this->GetDefaultThemeId(1); // 1 to force front-end mode! - } - - $this->SetVar('m_theme', $theme_id); - $this->SetVar('theme.current_id', $theme_id); // KOSTJA: this is to fool theme' getPassedID - + /** @var ThemeItem $theme */ $theme = $this->recallObject('theme.current'); - /* @var $theme ThemeItem */ if ( !$theme->isLoaded() || !$theme->GetDBField('Enabled') ) { return false; @@ -1942,8 +1920,8 @@ return; } else { - if ( $this->GetVar('ajax') == 'yes' && $t != $this->GetVar('t') ) { - // redirection to other then current template during ajax request + if ( $this->GetVar('ajax') == 'yes' && ($t != $this->GetVar('t') || !$this->isSOPSafe($location, $t)) ) { + // redirection to other then current template during ajax request OR SOP violation kUtil::safeDefine('DBG_SKIP_REPORTING', 1); echo '#redirect#' . $location; } @@ -1978,6 +1956,34 @@ } /** + * Determines if real redirect should be made within AJAX request. + * + * @param string $url Location. + * @param string $template Template. + * + * @return boolean + * @link http://en.wikipedia.org/wiki/Same-origin_policy + */ + protected function isSOPSafe($url, $template) + { + $parsed_url = parse_url($url); + + if ( $parsed_url['scheme'] . '://' != PROTOCOL ) { + return false; + } + + if ( $parsed_url['host'] != SERVER_NAME ) { + return false; + } + + if ( defined('PORT') && isset($parsed_url['port']) && $parsed_url['port'] != PORT ) { + return false; + } + + return true; + } + + /** * Returns translation of given label * * @param string $label Index: branches/5.3.x/core/units/category_items/category_items_event_handler.php =================================================================== diff -u -r15986 -r16124 --- branches/5.3.x/core/units/category_items/category_items_event_handler.php (.../category_items_event_handler.php) (revision 15986) +++ branches/5.3.x/core/units/category_items/category_items_event_handler.php (.../category_items_event_handler.php) (revision 16124) @@ -1,6 +1,6 @@ 1, 'default' => 0 ), 'TemplateAliases' => Array ('type' => 'string', 'formatter' => 'kSerializedFormatter', 'default' => 'a:0:{}'), + 'StylesheetFile' => array( + 'type' => 'string', 'max_len' => 255, + 'error_msgs' => array('not_found' => '!la_error_FileNotFound!'), + 'not_null' => 1, 'default' => '' + ), 'ImageResizeRules' => Array ('type' => 'string', 'default' => NULL), ), @@ -152,6 +157,7 @@ 'Enabled' => Array ( 'title' => 'column:la_fld_Status', 'filter_block' => 'grid_options_filter', 'width' => 200, ), // 'PrimaryTheme' => Array ( 'title' => 'column:la_fld_Primary', 'filter_block' => 'grid_options_filter'), 'LanguagePackInstalled' => Array ('title' => 'la_col_LanguagePackInstalled', 'filter_block' => 'grid_options_filter', 'width' => 200,), + 'StylesheetFile' => array('filter_block' => 'grid_like_filter', 'width' => 150, 'hidden' => 1), ), ), ), Index: branches/5.3.x/core/units/helpers/curl_helper.php =================================================================== diff -u -r16111 -r16124 --- branches/5.3.x/core/units/helpers/curl_helper.php (.../curl_helper.php) (revision 16111) +++ branches/5.3.x/core/units/helpers/curl_helper.php (.../curl_helper.php) (revision 16124) @@ -1,6 +1,6 @@ false, CURLOPT_SSL_VERIFYHOST => false, + + // Prevents CURL from adding "Expect: 100-continue" header for POST requests. CURLOPT_HTTPHEADER => Array ('Expect:'), ); Index: branches/5.3.x/core/install.php =================================================================== diff -u -r15999 -r16124 --- branches/5.3.x/core/install.php (.../install.php) (revision 15999) +++ branches/5.3.x/core/install.php (.../install.php) (revision 16124) @@ -1,6 +1,6 @@ currentStep) { case 'sys_requirements': $required_checks = Array ( - 'php_version', 'curl', 'simplexml', 'freetype', 'gd_version', + 'php_version', 'composer', 'curl', 'simplexml', 'freetype', 'gd_version', 'jpeg', 'mysql', 'json', 'date.timezone', 'output_buffering', ); Index: branches/5.3.x/core/kernel/utility/validator.php =================================================================== diff -u -r15677 -r16124 --- branches/5.3.x/core/kernel/utility/validator.php (.../validator.php) (revision 15677) +++ branches/5.3.x/core/kernel/utility/validator.php (.../validator.php) (revision 16124) @@ -1,6 +1,6 @@ SetError($field, 'bad_type', null, Array ($params['type'])); + $this->SetError($field, 'bad_type', null, array('type' => $params['type'])); return false; } @@ -256,7 +256,10 @@ if ( !isset($min_val) ) $min_val = '-∞'; if ( !isset($max_val) ) $max_val = '∞'; - $this->SetError($field, 'value_out_of_range', null, Array ($min_val, $max_val)); + $this->SetError($field, 'value_out_of_range', null, array( + 'min_value' => $min_val, + 'max_value' => $max_val + )); return false; } @@ -271,7 +274,11 @@ } if ( !$res ) { - $error_params = Array ((int)getArrayValue($params, 'min_len'), (int)getArrayValue($params, 'max_len'), mb_strlen($val)); + $error_params = array( + 'min_length' => (int)getArrayValue($params, 'min_len'), + 'max_length' => (int)getArrayValue($params, 'max_len'), + 'value' => mb_strlen($val) + ); $this->SetError($field, 'length_out_of_range', null, $error_params); return false; @@ -425,9 +432,23 @@ $msg = $this->Application->ReplaceLanguageTags($msg, $force_escape); if ( isset($this->FieldErrors[$field]['params']) ) { - return vsprintf($msg, $this->FieldErrors[$field]['params']); + $params = $this->FieldErrors[$field]['params']; } + else { + $params = array(); + } + $field_phrase = $this->Application->isAdmin ? 'la_fld_' . $field : 'lu_fld_' . $field; + $params['field'] = $this->Application->Phrase($field_phrase); + + foreach ( $params as $param_name => $param_value ) { + $msg = str_replace('{' . $param_name . '}', $param_value, $msg, $replacement_count); + } + + if ( strpos($msg, '%s') !== false ) { + trigger_error('Unexpected "%s" in field "' . $field . '" validation error message (pseudo: "' . $error_pseudo . '") in "' . $this->dataSource->Prefix . '" unit', E_USER_WARNING); + } + return $msg; } @@ -501,4 +522,4 @@ { $this->FieldErrors = Array(); } -} \ No newline at end of file +} Index: branches/5.3.x/core/units/helpers/fck_helper.php =================================================================== diff -u -r15999 -r16124 --- branches/5.3.x/core/units/helpers/fck_helper.php (.../fck_helper.php) (revision 15999) +++ branches/5.3.x/core/units/helpers/fck_helper.php (.../fck_helper.php) (revision 16124) @@ -1,6 +1,6 @@ Application->GetFrontThemePath(), '/') . '/inc'; + /** @var ThemeItem $theme */ + $theme = $this->Application->recallObject('theme.current'); + $stylesheet_file = $theme->getStylesheetFile(true); - if ( file_exists(FULL_PATH . '/' . $theme_path . '/style.css') ) { + if ( $stylesheet_file ) { + $stylesheet_folder_url = dirname($stylesheet_file) . '/'; + $url_params = Array ('events[fck]' => 'OnGetsEditorStyles', 'no_pass_through' => 1, 'pass' => 'm'); $styles_css = $this->Application->HREF('index', '_FRONT_END_', $url_params, 'index.php'); } else { - $theme_path = trim(EDITOR_PATH, '/'); - $styles_css = $this->Application->BaseURL() . $theme_path . '/style.css'; + $stylesheet_folder_url = $this->Application->BaseURL(rtrim(EDITOR_PATH, '/')); + $styles_css = $stylesheet_folder_url . 'style.css'; } - $styles_js = $this->Application->BaseURL() . $theme_path . '/styles.js'; + $styles_js = $stylesheet_folder_url . 'styles.js'; return array($styles_css, $styles_js); } @@ -618,4 +622,4 @@ return $ret; } -} \ No newline at end of file +} Index: branches/5.3.x/core/install/install_schema.sql =================================================================== diff -u -r15999 -r16124 --- branches/5.3.x/core/install/install_schema.sql (.../install_schema.sql) (revision 15999) +++ branches/5.3.x/core/install/install_schema.sql (.../install_schema.sql) (revision 16124) @@ -380,6 +380,7 @@ StylesheetId int(10) unsigned NOT NULL DEFAULT '0', LanguagePackInstalled tinyint(3) unsigned NOT NULL DEFAULT '0', TemplateAliases text, + StylesheetFile varchar(255) NOT NULL DEFAULT '', ImageResizeRules text, PRIMARY KEY (ThemeId), KEY Enabled (Enabled), @@ -1464,4 +1465,4 @@ TransitionEffect varchar(255) NOT NULL DEFAULT '', TransitionEffectCustom varchar(255) NOT NULL DEFAULT '', PRIMARY KEY (PromoBlockGroupId) -); \ No newline at end of file +); Index: branches/5.3.x/index.php =================================================================== diff -u -r16111 -r16124 --- branches/5.3.x/index.php (.../index.php) (revision 16111) +++ branches/5.3.x/index.php (.../index.php) (revision 16124) @@ -1,6 +1,6 @@ GetDBField('StylesheetFile') ?: 'inc/style.css', '/'); + + $theme_path = FULL_PATH . '/themes/' . $this->GetDBField('Name'); + $stylesheet_file = $theme_path . '/' . $stylesheet_file; + + if ( !file_exists($stylesheet_file) ) { + return false; + } + + if ( $as_url ) { + /** @var FileHelper $file_helper */ + $file_helper = $this->Application->recallObject('FileHelper'); + + return $file_helper->pathToUrl($stylesheet_file); + } + + return $stylesheet_file; + } + } Index: branches/5.3.x/core/install/steps_db.xml =================================================================== diff -u -r15677 -r16124 --- branches/5.3.x/core/install/steps_db.xml (.../steps_db.xml) (revision 15677) +++ branches/5.3.x/core/install/steps_db.xml (.../steps_db.xml) (revision 16124) @@ -222,7 +222,7 @@ The System Requirements Check option should be used to ensure proper system behavior in the current environment.

- PHP version 5.2.0 or above*
+ PHP version 5.3.2 or above*
Use this PHP version or better to ensure normal website operation on every day basis.

@@ -235,6 +235,15 @@ to minify HTML, CSS and JavaScript output of website. This allows to make websites, which opens even faster, then before.

+ Dependencies via Composer
+ In-Portal uses Composer to install required 3rd-party libraries. + Please ensure, that:
+

    +
  1. Composer is installed (instructions)
  2. +
  3. Dependencies are installed (instructions)
  4. +
+

+

Memory caching support
When available use Memcached memory object caching system for data caching. Will severely improve website performance under heavy load and page loading speed in general. @@ -327,4 +336,4 @@

]]> - \ No newline at end of file + Index: branches/5.3.x/core/units/themes/themes_eh.php =================================================================== diff -u -r15698 -r16124 --- branches/5.3.x/core/units/themes/themes_eh.php (.../themes_eh.php) (revision 15698) +++ branches/5.3.x/core/units/themes/themes_eh.php (.../themes_eh.php) (revision 16124) @@ -1,6 +1,6 @@ Special == 'current' ) { + $event->setEventParam('live_table', true); + } + + parent::dbBuild($object, $event); + } + + /** + * Ensures that current theme detection will fallback to primary without extra DB query. + * + * @param kEvent $event Event. + * + * @return integer + */ + public function getPassedID(kEvent $event) + { + if ( $event->Special == 'current' ) { + $theme_id = $this->Application->GetVar('m_theme'); + + if ( !$theme_id ) { + $theme_id = 'default'; + } + + $this->Application->SetVar('m_theme', $theme_id); + $this->Application->SetVar($event->getPrefixSpecial() . '_id', $theme_id); + } + + return parent::getPassedID($event); + } + + /** * Allows to set selected theme as primary * * @param kEvent $event @@ -92,6 +132,25 @@ } /** + * Validate entered stylesheet path. + * + * @param kEvent $event Event. + * + * @return void + */ + protected function OnBeforeItemUpdate(kEvent $event) + { + parent::OnBeforeItemUpdate($event); + + /** @var ThemeItem $object */ + $object = $event->getObject(); + + if ( $object->GetDBField('StylesheetFile') && !$object->getStylesheetFile() ) { + $object->SetError('StylesheetFile', 'not_found'); + } + } + + /** * Set's primary theme (when checkbox used on editing form) * * @param kEvent $event Index: branches/5.3.x/core/admin_templates/themes/themes_edit.tpl =================================================================== diff -u -r15483 -r16124 --- branches/5.3.x/core/admin_templates/themes/themes_edit.tpl (.../themes_edit.tpl) (revision 15483) +++ branches/5.3.x/core/admin_templates/themes/themes_edit.tpl (.../themes_edit.tpl) (revision 16124) @@ -61,6 +61,8 @@ + +