Index: branches/RC/core/units/general/cat_tag_processor.php =================================================================== diff -u -r8929 -r8991 --- branches/RC/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 8929) +++ branches/RC/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 8991) @@ -458,6 +458,60 @@ return preg_replace('/('.implode('|', $keywords).')/i', $opening.'\\1'.$closing, $ret); } + + /** + * Returns last modification date of items in category / system + * + * @param Array $params + * @return string + */ + function LastUpdated($params) + { + $category_id = $this->Application->GetVar('m_cat_id'); + $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName'); + + if (isset($params['local']) && $params['local'] && $category_id > 0) { + // scan only current category & it's children + $sql = 'SELECT TreeLeft, TreeRight + FROM '.TABLE_PREFIX.'Category + WHERE CategoryId = '.$category_id; + $tree_info = $this->Conn->GetRow($sql); + + $sql = 'SELECT MAX(item_table.Modified) AS ModDate, MAX(item_table.CreatedOn) AS NewDate + FROM '.$table_name.' item_table + LEFT JOIN '.TABLE_PREFIX.'CategoryItems ci ON (item_table.ResourceId = ci.ItemResourceId) + LEFT JOIN '.TABLE_PREFIX.'Category c ON c.CategoryId = ci.CategoryId + WHERE c.TreeLeft BETWEEN '.$tree_info['TreeLeft'].' AND '.$tree_info['TreeRight']; + } + else { + // scan all categories in system + $sql = 'SELECT MAX(Modified) AS ModDate, MAX(CreatedOn) AS NewDate + FROM '.$table_name; + } + + $row_data = $this->Conn->GetRow($sql); + if (!$row_data) { + return ''; + } + + $date = $row_data[ $row_data['NewDate'] > $row_data['ModDate'] ? 'NewDate' : 'ModDate' ]; + + // format date + $format = isset($params['format']) ? $params['format'] : '_regional_DateTimeFormat'; + if (preg_match("/_regional_(.*)/", $format, $regs)) { + $lang =& $this->Application->recallObject('lang.current'); + if ($regs[1] == 'DateTimeFormat') { + // combined format + $format = $lang->GetDBField('DateFormat').' '.$lang->GetDBField('TimeFormat'); + } + else { + // simple format + $format = $lang->GetDBField($regs[1]); + } + } + + return adodb_date($format, $date); + } } ?> \ No newline at end of file