Index: branches/RC/core/units/general/helpers/category_helper.php =================================================================== diff -u -N -r11724 -r11760 --- branches/RC/core/units/general/helpers/category_helper.php (.../category_helper.php) (revision 11724) +++ branches/RC/core/units/general/helpers/category_helper.php (.../category_helper.php) (revision 11760) @@ -423,7 +423,40 @@ return $this->_structureTree; } - } + /** + * Replace links like "@@ID@@" to actual template names in given text + * + * @param string $text + * @return string + */ + function replacePageIds($text) + { + if (!preg_match_all('/@@(\\d+)@@/', $text, $regs)) { + return $text; + } -?> \ No newline at end of file + $page_ids = $regs[1]; + + $sql = 'SELECT NamedParentPath, CategoryId + FROM ' . TABLE_PREFIX . 'Category + WHERE CategoryId IN (' . implode(',', $page_ids) . ')'; + $templates = $this->Conn->GetCol($sql, 'CategoryId'); + + foreach ($page_ids as $page_id) { + if (!array_key_exists($page_id, $templates)) { + // internal page was deleted, but link to it was found in given content block data + continue; + } + + $url_params = Array ('m_cat_id' => $page_id, 'pass' => 'm'); + $page_url = $this->Application->HREF(strtolower($templates[$page_id]), '', $url_params); + /*if ($this->Application->IsAdmin()) { + $page_url = preg_replace('/&(admin|editing_mode)=[\d]/', '', $page_url); + }*/ + $text = preg_replace('/@@' . $page_id . '@@/', $page_url, $text); + } + + return $text; + } + } \ No newline at end of file