/**
* Определяет значения META-тегов элемента
*
* @param array $row данные о текущем элементе
* @return void
*/
protected function meta($row)
{
$this->result["timeedit"] = $row["timeedit"];
$this->result["titlemodule"] = $row["name"];
$this->result["edit_meta"] = array("id" => $row["id"], "table" => $this->diafan->_site->module);
if(! empty($row["canonical"]))
{
$this->result["canonical"] = $row["canonical"];
}
elseif($this->diafan->_route->dpage > 1 || $this->diafan->_route->rpage > 1 || $this->diafan->_route->sort)
{
$this->result["canonical"] = $this->diafan->_route->current_link(array("dpage", "sort", "rpage"));
}
if(! empty($row["noindex"]))
{
$this->result["noindex"] = $row["noindex"];
}
$config_title = $this->diafan->configmodules("title_tpl");
$config_keywords = $this->diafan->configmodules("keywords_tpl");
$config_descr = $this->diafan->configmodules("descr_tpl");
if($this->diafan->configmodules("cat") && (
! $row["title_meta"] && strpos($config_title, '%category') !== false
|| ! $row["keywords"] && strpos($config_keywords, '%category') !== false
|| ! $row["descr"] && strpos($config_descr, '%category') !== false
|| ! $row["title_meta"] && strpos($config_title, '%parent_category') !== false
|| ! $row["keywords"] && strpos($config_keywords, '%parent_category') !== false
|| ! $row["descr"] && strpos($config_descr, '%parent_category') !== false))
{
$cat = DB::query_fetch_array("SELECT parent_id, [name] FROM {%h_category} WHERE id=%d LIMIT 1", $this->diafan->_site->module, $row["cat_id"]);
$category_name = $cat["name"];
}
else
{
$category_name = '';
}
if(! $row["title_meta"] && strpos($config_title, '%parent_category') !== false
|| ! $row["keywords"] && strpos($config_keywords, '%parent_category') !== false
|| ! $row["descr"] && strpos($config_descr, '%parent_category') !== false)
{
$parent_category_name = DB::query_result("SELECT [name] FROM {%h_category} WHERE id=%d LIMIT 1", $this->diafan->_site->module, $cat["parent_id"]);
}
else
{
$parent_category_name = '';
}
$parent_category_name_dash = ($parent_category_name ? ' — '.$parent_category_name : '');
$category_name_dash = ($category_name ? ' — '.$category_name : '');
$this->result["title_meta"] = $row["title_meta"];
if (! $row["title_meta"] && $config_title)
{
$this->result["title_meta"] = str_replace(
array('%name', '%category', '%parent_category'),
array($row["name"], $category_name_dash, $parent_category_name_dash),
$config_title
);
}
$content_text = strip_tags(DB::query_result("SELECT text1 FROM {shop} WHERE id=%d LIMIT 1", $row["id"]));
$this->result["keywords"] = $row["keywords"];
if (! $row["keywords"] && $config_keywords)
{
$this->result["keywords"] = str_replace(
array('%name', '%category', '%parent_category', '%text'),
array($row["name"], $category_name_dash, $parent_category_name_dash, $content_text),
$config_keywords
);
}
$this->result["descr"] = $row["descr"];
if (! $row["descr"] && $config_descr)
{
$this->result["descr"] = str_replace(
array('%name', '%category', '%parent_category', '%text'),
array($row["name"], $category_name_dash, $parent_category_name_dash, $content_text),
$config_descr
);
}
}
Показать весь код