Index: branches/5.2.x/core/units/helpers/list_helper.php =================================================================== diff -u -r14646 -r14699 --- branches/5.2.x/core/units/helpers/list_helper.php (.../list_helper.php) (revision 14646) +++ branches/5.2.x/core/units/helpers/list_helper.php (.../list_helper.php) (revision 14699) @@ -117,7 +117,9 @@ $sorting_prefix = getArrayValue($list_sortings, $list->Special) ? $list->Special : ''; $user_sorting_start = 0; - if ( $forced_sorting = getArrayValue($list_sortings, $sorting_prefix, 'ForcedSorting') ) { + $forced_sorting = getArrayValue($list_sortings, $sorting_prefix, 'ForcedSorting'); + + if ( $forced_sorting ) { $user_sorting_start = count($forced_sorting); } @@ -130,6 +132,7 @@ * @param kDBItem $object * @param string $list_prefix * @param bool $next + * @param string $select_fields * @return int */ function getNavigationResource(&$object, $list_prefix, $next = true, $select_fields = null) Index: branches/5.2.x/core/units/modules/modules_event_handler.php =================================================================== diff -u -r14602 -r14699 --- branches/5.2.x/core/units/modules/modules_event_handler.php (.../modules_event_handler.php) (revision 14602) +++ branches/5.2.x/core/units/modules/modules_event_handler.php (.../modules_event_handler.php) (revision 14699) @@ -1,6 +1,6 @@ getObject(); /* @var $object kDBList */ - + if ($event->Special) { $object->addFilter('current_module', '%1$s.Name = '.$event->Special); } @@ -130,7 +130,11 @@ { parent::OnAfterListQuery($event); - $new_modules = $this->_getNewModules(); + $modules_helper =& $this->Application->recallObject('ModulesHelper'); + /* @var $modules_helper kModulesHelper */ + + $new_modules = $modules_helper->getModules(kModulesHelper::NOT_INSTALLED); + if (!$new_modules || $this->Application->RecallVar('user_id') != USER_ROOT) { return ; } @@ -154,48 +158,4 @@ $object->addRecord($module_record); } } - - /** - * Returns list of modules, that are not installed, but available in file system - * - * @return Array - */ - function _getNewModules() - { - $modules_helper =& $this->Application->recallObject('ModulesHelper'); - /* @var $modules_helper kModulesHelper */ - - $modules = Array (); - if ($dir = @opendir(MODULES_PATH)) { - while (($file = readdir($dir)) !== false) { - if ($file != '.' && $file != '..') { - $module_folder = MODULES_PATH . '/' . $file; - if (is_dir($module_folder) && $this->_isModule($module_folder)) { - // this is module -> check if it's installed already - if (!$modules_helper->moduleInstalled($file)) { - $install_order = trim( file_get_contents($module_folder . '/install/install_order.txt') ); - $modules[$install_order] = $file; - } - } - } - } - - closedir($dir); - } - - // allows to control module install order - ksort($modules, SORT_NUMERIC); - return $modules; - } - - /** - * Checks, that given folder is module root folder - * - * @param string $folder - * @return bool - */ - function _isModule($folder) - { - return file_exists($folder . '/install.php') && file_exists($folder . '/install/install_schema.sql'); - } } \ No newline at end of file Index: branches/5.2.x/core/kernel/session/session_storage.php =================================================================== diff -u -r14628 -r14699 --- branches/5.2.x/core/kernel/session/session_storage.php (.../session_storage.php) (revision 14628) +++ branches/5.2.x/core/kernel/session/session_storage.php (.../session_storage.php) (revision 14699) @@ -1,7 +1,7 @@ _getStylesheetPath() . DIRECTORY_SEPARATOR); - while (false !== ($file = $dh->read())) { - if ( preg_match('/admin-(.*)-([\d]+).css/', $file, $rets) ) { - if ($rets[1] == $style_name && $rets[2] > $last_compiled) { - $last_compiled = $rets[2]; - } + $iterator = new DirectoryIterator( $this->_getStylesheetPath() . DIRECTORY_SEPARATOR ); + /* @var $file_info DirectoryIterator */ + + foreach ($iterator as $file_info) { + if ( !$file_info->isFile() ) { + continue; } - } - $dh->close(); + $regs = $this->isSkinFile( $file_info->getFilename() ); + if ( $regs && $regs[1] == $style_name && $regs[2] > $last_compiled ) { + $last_compiled = max($last_compiled, $regs[2]); + } + } + return $last_compiled; } @@ -222,14 +231,29 @@ */ function deleteCompiled() { - $dh = dir($this->_getStylesheetPath() . DIRECTORY_SEPARATOR); + $iterator = new DirectoryIterator( $this->_getStylesheetPath() . DIRECTORY_SEPARATOR ); + /* @var $file_info DirectoryIterator */ - while (false !== ($file = $dh->read())) { - if ( preg_match('/admin-(.*)-([\d]+).css/', $file, $rets) ) { - unlink($dh->path . $file); + foreach ($iterator as $file_info) { + if ( $file_info->isFile() && $this->isSkinFile( $file_info->getFilename() ) ) { + unlink( $file_info->getPathname() ); } } + } - $dh->close(); + /** + * Determines if given file is admin skin file + * + * @param string $filename + * @return array|bool + * @access protected + */ + protected function isSkinFile($filename) + { + if ( preg_match(self::SKIN_REGEXP, $filename, $regs) ) { + return $regs; + } + + return false; } } \ No newline at end of file Index: branches/5.2.x/core/kernel/managers/url_manager.php =================================================================== diff -u -r14653 -r14699 --- branches/5.2.x/core/kernel/managers/url_manager.php (.../url_manager.php) (revision 14653) +++ branches/5.2.x/core/kernel/managers/url_manager.php (.../url_manager.php) (revision 14699) @@ -1,6 +1,6 @@ Application->recallObject('HTTPQuery'); /* @var $http_query kHTTPQuery */ - + $get_sid = getArrayValue($http_query->Get, $this->GETName); } @@ -1022,12 +1022,13 @@ /** * Deletes given sessions * - * @return Array - * @access private + * @param $session_ids + * @param int $delete_reason + * @return void */ function DeleteSessions($session_ids, $delete_reason = SESSION_LOG_EXPIRED) { - return $this->Storage->DeleteSessions($session_ids, $delete_reason); + $this->Storage->DeleteSessions($session_ids, $delete_reason); } /** Index: branches/5.2.x/core/install/prerequisites.php =================================================================== diff -u -r14244 -r14699 --- branches/5.2.x/core/install/prerequisites.php (.../prerequisites.php) (revision 14244) +++ branches/5.2.x/core/install/prerequisites.php (.../prerequisites.php) (revision 14699) @@ -1,6 +1,6 @@ Application->recallObject('FCKHelper'); /* @var $fck_helper fckFCKHelper */ $default_folders = defined('FCK_DEFAULT_FOLDERS') ? FCK_DEFAULT_FOLDERS : Array ('Files', 'Images', 'Flash', 'Media', 'Documents'); foreach ($default_folders as $index => $folder) { - if (!$fck_helper->CreateFolder($folder)) { + if ( !$fck_helper->CreateFolder($folder) ) { unset($default_folders[$index]); } } - if (!$default_folders) { + if ( !$default_folders ) { return ''; } $ret = ''; foreach ($default_folders as $folder) { $selected = ($this->Application->GetVar('type') == $folder) ? 'selected' : ''; - $ret.= '' . $folder; + $ret .= '' . $folder; } return $ret; } - - function PrintFolders($params) - { - $order_by = $this->Application->GetVar('order_by'); - $sort_by = $this->Application->GetVar('sort_by'); - $params['folder'] = $this->Application->GetVar('folder'); - $files_dir = WRITEABLE."/user_files/".$params['folder']."/"; - $aFolders = $this->ReadFolders($files_dir); - $block_params = $this->prepareTagParams($params); - $block_params['name'] = $block_params['render_as']; - $ret = ''; - foreach ($aFolders as $k => $v) { - $block_params['folder_name'] = $v; - $block_params['path'] = $params['folder']."/".$v; - $ret .= $this->Application->ParseBlock($block_params); - } - return $ret; - } - - function PrintFiles($params) - { - $params['folder'] = $this->Application->GetVar('folder'); - $files_dir = WRITEABLE . "/user_files/" . $params['folder'] . "/"; - $files_url = BASE_PATH . WRITEBALE_BASE . "/user_files/" . $params['folder']."/"; - $aFiles = $this->ReadFiles($files_dir); - $block_params = $this->prepareTagParams($params); - $block_params['name'] = $block_params['render_as']; - $ret = ''; - $date_format = "m/d/Y h:i A"; - $a_ext = Array('ai','avi','bmp','cs','dll','doc','exe','fla','gif','htm','html','jpg','js','mdb','mp3','pdf','png','ppt','rdp','swf','swt','txt','vsd','xls','xml','zip'); - foreach ($aFiles as $k => $v) { - $size = filesize( $files_dir . $v ) ; - if ( $size > 0 ) { - $size = round( $size / 1024 ); - $size = ($size < 1)? 1:$size;// round( $iFileSize / 1024 ) ; - } - - $ext = strtolower( pathinfo($v, PATHINFO_EXTENSION) ); - if (in_array($ext, $a_ext)) { - $icon = $ext; - } - else { - $icon = 'default.icon'; - } - - $block_params['file_name'] = $v; - $block_params['size'] = $size; - $block_params['url'] = $files_url.$v; - $block_params['icon'] = $icon; - $block_params['date'] = date($date_format, filectime( $files_dir . $v )); -// $block_params['path'] = $params['folder']."/".$v; - $ret .= $this->Application->ParseBlock($block_params); - } - return $ret; - } } \ No newline at end of file Index: branches/5.2.x/core/units/helpers/modules_helper.php =================================================================== diff -u -r14628 -r14699 --- branches/5.2.x/core/units/helpers/modules_helper.php (.../modules_helper.php) (revision 14628) +++ branches/5.2.x/core/units/helpers/modules_helper.php (.../modules_helper.php) (revision 14699) @@ -1,6 +1,6 @@ Application->recallObject('Session'); /* @var $session Session */ - + return $session->CookiesEnabled; } @@ -204,33 +219,14 @@ */ protected function _getFreeModules($vars) { - $skip_modules = Array ('.', '..'); $domain = $this->_GetDomain($vars); + $modules = array_map('strtolower', $this->getModules()); if ( !$this->_IsLocalSite($domain) ) { - array_push($skip_modules, 'in-commerce', 'in-auction'); + return array_diff($modules, Array ('in-commerce', 'in-auction')); } - $ret = Array (); - $folder = dir(MODULES_PATH); - - if ( $folder === false ) { - return Array (); - } - - while ( ($entry = $folder->read()) !== false ) { - $entry_lowercased = strtolower($entry); - - if ( !is_dir($folder->path . '/' . $entry) || in_array($entry_lowercased, $skip_modules) ) { - continue; - } - - $ret[] = $entry_lowercased; - } - - $folder->close(); - - return $ret; + return $modules; } /** @@ -248,6 +244,7 @@ /** * Returns domain from licences (and direct in case of install script) * + * @param Array $vars * @return string */ function _GetDomain($vars) @@ -368,6 +365,8 @@ if ($i > 20) return 99; if ($i > 10) return '.'.($this->_GetObscureValue(6.5)+1); if ($i == 'a') return 0xa; + + return 0; } function _Chr($val) @@ -431,16 +430,69 @@ { static $modules = null; - if (is_null($modules)) { + if ( is_null($modules) ) { $sql = 'SELECT LOWER(Name) FROM ' . $this->Application->getUnitOption('mod', 'TableName'); $modules = $this->Conn->GetCol($sql); } - if ($module_name == 'kernel') { + if ( $module_name == 'kernel' ) { $module_name = 'in-portal'; } return in_array(strtolower($module_name), $modules); } + + /** + * Returns list of matching modules + * + * @param int $module_type + * @return Array + * @access public + */ + public function getModules($module_type = self::ANY) + { + $modules = Array (); + + $iterator = new DirectoryIterator(MODULES_PATH); + /* @var $file_info DirectoryIterator */ + + foreach ($iterator as $file_info) { + $file_path = $file_info->getPathname(); + + if ( $file_info->isDir() && !$file_info->isDot() && $this->isInPortalModule($file_path) ) { + $install_order = trim( file_get_contents($file_path . '/install/install_order.txt') ); + $modules[$install_order] = $file_info->getFilename(); + } + } + + // allows to control module install order + ksort($modules, SORT_NUMERIC); + + if ( $module_type == self::ANY ) { + return $modules; + } + + foreach ($modules as $install_order => $module_name) { + $installed = $this->moduleInstalled($module_name); + + if ( ($module_type == self::INSTALLED && !$installed) || ($module_type == self::NOT_INSTALLED && $installed) ) { + unset($modules[$install_order]); + } + } + + return $modules; + } + + /** + * Checks, that given folder is In-Portal module's root folder + * + * @param string $folder_path + * @return bool + * @access public + */ + public static function isInPortalModule($folder_path) + { + return file_exists($folder_path . '/install.php') && file_exists($folder_path . '/install/install_schema.sql'); + } } \ No newline at end of file Index: branches/5.2.x/core/units/users/users_tag_processor.php =================================================================== diff -u -r14663 -r14699 --- branches/5.2.x/core/units/users/users_tag_processor.php (.../users_tag_processor.php) (revision 14663) +++ branches/5.2.x/core/units/users/users_tag_processor.php (.../users_tag_processor.php) (revision 14699) @@ -1,6 +1,6 @@ getObject($params); /* @var $object kDBItem */ - + $params['img_path'] = $image_url; $image_dimensions = $this->ImageSize($params); $params['img_size'] = $image_dimensions ? $image_dimensions : ' width="' . $params['DefaultWidth'] . '"'; Index: branches/5.2.x/core/units/forms/forms/forms_eh.php =================================================================== diff -u -r14675 -r14699 --- branches/5.2.x/core/units/forms/forms/forms_eh.php (.../forms_eh.php) (revision 14675) +++ branches/5.2.x/core/units/forms/forms/forms_eh.php (.../forms_eh.php) (revision 14699) @@ -1,6 +1,6 @@ fromTag = true; - if( isset($forse_escaping) ) { - $this->fromTag = $forse_escaping; + if( isset($force_escaping) ) { + $this->fromTag = $force_escaping; } preg_match_all("(!(la|lu)[^!]+!)", $text, $res, PREG_PATTERN_ORDER); Index: branches/5.2.x/core/admin_templates/browser/frmcreatefolder.tpl =================================================================== diff -u -r14244 -r14699 --- branches/5.2.x/core/admin_templates/browser/frmcreatefolder.tpl (.../frmcreatefolder.tpl) (revision 14244) +++ branches/5.2.x/core/admin_templates/browser/frmcreatefolder.tpl (.../frmcreatefolder.tpl) (revision 14699) @@ -32,7 +32,7 @@
![]() |
+ ![]() |
Index: branches/5.2.x/core/units/selectors/selectors_item.php
===================================================================
diff -u -r14244 -r14699
--- branches/5.2.x/core/units/selectors/selectors_item.php (.../selectors_item.php) (revision 14244)
+++ branches/5.2.x/core/units/selectors/selectors_item.php (.../selectors_item.php) (revision 14699)
@@ -1,6 +1,6 @@
themesFolder.'/');
- while (($filename = readdir($fh))) {
- if (in_array($filename, $skip_filenames)) {
- continue;
- }
+ $iterator = new DirectoryIterator($this->themesFolder . '/');
+ /* @var $file_info DirectoryIterator */
- if (is_dir($this->themesFolder.'/'.$filename)) {
+ foreach ($iterator as $file_info) {
+ $filename = $file_info->getFilename();
+
+ if ( $file_info->isDir() && !$file_info->isDot() && $filename != '.svn' && $filename != 'CVS' ) {
$theme_id = $this->refreshTheme($filename);
+
if ($theme_id) {
$themes_found[] = $theme_id;
// increment serial of updated themes
Index: branches/5.2.x/core/kernel/managers/cache_manager.php
===================================================================
diff -u -r14628 -r14699
--- branches/5.2.x/core/kernel/managers/cache_manager.php (.../cache_manager.php) (revision 14628)
+++ branches/5.2.x/core/kernel/managers/cache_manager.php (.../cache_manager.php) (revision 14699)
@@ -1,6 +1,6 @@
DeleteUnitCache();
}
-
+
/**
* Loads data, that was cached during unit config parsing
*
@@ -442,7 +442,8 @@
/**
* Returns caching type (none, memory, temporary)
*
- * @return int
+ * @param int $caching_type
+ * @return bool
* @access public
*/
public function isCachingType($caching_type)
@@ -480,6 +481,7 @@
* @param int $key key name to add to cache
* @param mixed $value value of chached record
* @param int $expiration when value expires (0 - doesn't expire)
+ * @return bool
* @access public
*/
public function setCache($key, $value, $expiration = 0)
Index: branches/5.2.x/core/install.php
===================================================================
diff -u -r14692 -r14699
--- branches/5.2.x/core/install.php (.../install.php) (revision 14692)
+++ branches/5.2.x/core/install.php (.../install.php) (revision 14699)
@@ -1,6 +1,6 @@
ScanModules();
foreach ($modules as $module_path) {
- $contants_file = MODULES_PATH . '/' . $module_path . '/constants.php';
+ $constants_file = MODULES_PATH . '/' . $module_path . '/constants.php';
- if ( file_exists($contants_file) ) {
- kUtil::includeOnce($contants_file);
+ if ( file_exists($constants_file) ) {
+ kUtil::includeOnce($constants_file);
}
}
}
@@ -1392,23 +1392,14 @@
{
static $modules = null;
- if (!isset($modules)) {
- $modules = Array();
- $fh = opendir(MODULES_PATH);
- while ( ($sub_folder = readdir($fh)) ) {
- $folder_path = MODULES_PATH . '/'.$sub_folder;
- if ($sub_folder != '.' && $sub_folder != '..' && is_dir($folder_path)) {
- // this is folder in MODULES_PATH directory
- if (file_exists($folder_path.'/install.php') && file_exists($folder_path.'/install/install_schema.sql')) {
- $install_order = trim( file_get_contents($folder_path . '/install/install_order.txt') );
- $modules[$install_order] = $sub_folder;
- }
- }
- }
+ if ( !isset($modules) ) {
+ // use direct include, because it's called before kApplication::Init, that creates class factory
+ kUtil::includeOnce( KERNEL_PATH . kApplication::MODULE_HELPER_PATH );
+
+ $modules_helper = new kModulesHelper();
+ $modules = $modules_helper->getModules();
}
- // allows to control module install order
- ksort($modules, SORT_NUMERIC);
return $modules;
}
Index: branches/5.2.x/core/kernel/globals.php
===================================================================
diff -u -r14664 -r14699
--- branches/5.2.x/core/kernel/globals.php (.../globals.php) (revision 14664)
+++ branches/5.2.x/core/kernel/globals.php (.../globals.php) (revision 14699)
@@ -1,6 +1,6 @@
cache[$type])) $this->cache[$type] = Array();
+ /*if ( !isset($this->cache[$type]) ) {
+ $this->cache[$type] = Array ();
+ }*/
+
$this->cache[$type][$key] = $value;
- if ($is_new) {
+
+ if ( $is_new ) {
$this->cacheStatus[$type][$key] = true;
}
}
@@ -146,7 +151,7 @@
/**
* Fill required fields with dummy values
*
- * @param kEvent $event
+ * @param kEvent|bool $event
* @param kCatDBItem|bool $object
* @param bool $set_status
*/
@@ -856,6 +861,8 @@
* Enter description here...
*
* @param kEvent $event
+ * @param Array $record_data
+ * @return bool
*/
function processCurrentItem(&$event, $record_data)
{
@@ -1222,7 +1229,7 @@
* Loads import/export options
*
* @param kEvent $event
- * @return void
+ * @return Array
*/
function loadOptions(&$event)
{
@@ -1376,30 +1383,29 @@
return ;
}
- $object =& $event->getObject();
-
- $import_filenames = Array ();
-
$file_helper =& $this->Application->recallObject('FileHelper');
/* @var $file_helper FileHelper */
+ $import_filenames = Array ();
$file_helper->CheckFolder(EXPORT_PATH);
- if ( $folder_handle = opendir(EXPORT_PATH) ) {
- while ( false !== ($file = readdir($folder_handle)) ) {
- if ( is_dir(EXPORT_PATH . '/' . $file) || substr($file, 0, 1) == '.' || strtolower($file) == 'cvs' || strtolower($file) == 'dummy' || filesize(EXPORT_PATH . '/' . $file) == 0 ) {
- continue;
- }
+ $iterator = new DirectoryIterator(EXPORT_PATH);
+ /* @var $file_info DirectoryIterator */
- $file_size = kUtil::formatSize(filesize(EXPORT_PATH . '/' . $file));
- $import_filenames[$file] = $file . ' (' . $file_size . ')';
+ foreach ($iterator as $file_info) {
+ $file = $file_info->getFilename();
+
+ if ( $file_info->isDir() || $file == 'dummy' || $file_info->getSize() == 0 ) {
+ continue;
}
- closedir($folder_handle);
+
+ $import_filenames[$file] = $file . ' (' . kUtil::formatSize( $file_info->getSize() ) . ')';
}
- $options = $object->GetFieldOptions('ImportLocalFilename');
- $options['options'] = $import_filenames;
- $object->SetFieldOptions('ImportLocalFilename', $options);
+ $object =& $event->getObject();
+ /* @var $object kDBItem */
+
+ $object->SetFieldOption('ImportLocalFilename', 'options', $import_filenames);
}
/**
Index: branches/5.2.x/core/units/statistics/statistics_tag_processor.php
===================================================================
diff -u -r14628 -r14699
--- branches/5.2.x/core/units/statistics/statistics_tag_processor.php (.../statistics_tag_processor.php) (revision 14628)
+++ branches/5.2.x/core/units/statistics/statistics_tag_processor.php (.../statistics_tag_processor.php) (revision 14699)
@@ -1,6 +1,6 @@
Application->recallObject('lang.current');
/* @var $lang LanguagesItem */
-
+
$value = $lang->formatNumber($value, $this->PostFormattingParams['precision']);
break;
@@ -124,7 +124,7 @@
// m:post_format field=" |