本文整理汇总了PHP中CBlog::PreparePath方法的典型用法代码示例。如果您正苦于以下问题:PHP CBlog::PreparePath方法的具体用法?PHP CBlog::PreparePath怎么用?PHP CBlog::PreparePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBlog
的用法示例。
在下文中一共展示了CBlog::PreparePath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: BuildRSS
public static function BuildRSS($postID, $blogID, $type = "RSS2.0", $numPosts = 10, $arPathTemplate = Array())
{
$blogID = IntVal($blogID);
$postID = IntVal($postID);
if($blogID <= 0)
return false;
if($postID <= 0)
return false;
$numPosts = IntVal($numPosts);
$type = strtolower(preg_replace("/[^a-zA-Z0-9.]/is", "", $type));
if ($type != "rss.92" && $type != "atom.03")
$type = "rss2.0";
$rssText = False;
$arBlog = CBlog::GetByID($blogID);
if ($arBlog && $arBlog["ACTIVE"] == "Y" && $arBlog["ENABLE_RSS"] == "Y")
{
$arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]);
if($arGroup["SITE_ID"] == SITE_ID)
{
$arPost = CBlogPost::GetByID($postID);
if(!empty($arPost) && $arPost["BLOG_ID"] == $arBlog["ID"] && $arPost["ENABLE_COMMENTS"] == "Y")
{
$now = date("r");
$nowISO = date("Y-m-d\TH:i:s").substr(date("O"), 0, 3).":".substr(date("O"), -2, 2);
$serverName = "";
$charset = "";
$language = "";
$dbSite = CSite::GetList(($b = "sort"), ($o = "asc"), array("LID" => SITE_ID));
if ($arSite = $dbSite->Fetch())
{
$serverName = $arSite["SERVER_NAME"];
$charset = $arSite["CHARSET"];
$language = $arSite["LANGUAGE_ID"];
}
if (strlen($serverName) <= 0)
{
if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0)
$serverName = SITE_SERVER_NAME;
else
$serverName = COption::GetOptionString("main", "server_name", "");
}
if (strlen($charset) <= 0)
{
if (defined("SITE_CHARSET") && strlen(SITE_CHARSET) > 0)
$charset = SITE_CHARSET;
else
$charset = "windows-1251";
}
if(strlen($arPathTemplate["PATH_TO_BLOG"])>0)
$blogURL = htmlspecialcharsbx("http://".$serverName.CComponentEngine::MakePathFromTemplate($arPathTemplate["PATH_TO_BLOG"], array("blog" => $arBlog["URL"], "user_id" => $arBlog["OWNER_ID"], "group_id" => $arBlog["SOCNET_GROUP_ID"])));
else
$blogURL = htmlspecialcharsbx("http://".$serverName.CBlog::PreparePath($arBlog["URL"], $arGroup["SITE_ID"]));
if(strlen($arPathTemplate["PATH_TO_POST"])>0)
$url = htmlspecialcharsbx("http://".$serverName.CComponentEngine::MakePathFromTemplate($arPathTemplate["PATH_TO_POST"], array("blog" => $arBlog["URL"], "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arPathTemplate["ALLOW_POST_CODE"]), "user_id" => $arBlog["OWNER_ID"], "group_id" => $arBlog["SOCNET_GROUP_ID"])));
else
$url = htmlspecialcharsbx("http://".$serverName.CBlogPost::PreparePath($arBlog["URL"], $arPost["ID"], $arGroup["SITE_ID"]));
$dbUser = CUser::GetByID($arPost["AUTHOR_ID"]);
$arUser = $dbUser->Fetch();
if($arPathTemplate["USE_SOCNET"] == "Y")
{
$blogName = GetMessage("BLG_GCM_RSS_TITLE_SOCNET", Array("#AUTHOR_NAME#" => htmlspecialcharsEx($arUser["NAME"]." ".$arUser["LAST_NAME"]), "#POST_TITLE#" => htmlspecialcharsEx($arPost["TITLE"])));
}
else
{
$blogName = GetMessage("BLG_GCM_RSS_TITLE", Array("#BLOG_NAME#" => htmlspecialcharsEx($arBlog["NAME"]), "#POST_TITLE#" => htmlspecialcharsEx($arPost["TITLE"])));
}
$rssText = "";
if ($type == "rss.92")
{
$rssText .= "<"."?xml version=\"1.0\" encoding=\"".$charset."\"?".">\n\n";
$rssText .= "<rss version=\".92\">\n";
$rssText .= " <channel>\n";
$rssText .= " <title>".$blogName."</title>\n";
$rssText .= " <description>".$blogName."</description>\n";
$rssText .= " <link>".$url."</link>\n";
$rssText .= " <language>".$language."</language>\n";
$rssText .= " <docs>http://backend.userland.com/rss092</docs>\n";
$rssText .= "\n";
}
elseif ($type == "rss2.0")
{
$rssText .= "<"."?xml version=\"1.0\" encoding=\"".$charset."\"?".">\n\n";
$rssText .= "<rss version=\"2.0\">\n";
$rssText .= " <channel>\n";
$rssText .= " <title>".$blogName."</title>\n";
$rssText .= " <description>".$blogName."</description>\n";
//$rssText .= " <guid>".$url."</guid>\n";
$rssText .= " <link>".$url."</link>\n";
$rssText .= " <language>".$language."</language>\n";
$rssText .= " <docs>http://backend.userland.com/rss2</docs>\n";
//.........这里部分代码省略.........
示例2: array
$lAdmin->AddHeaders($arHeaders);
$arVisibleColumns = $lAdmin->GetVisibleHeaderColumns();
$arSelectedFields = array("ID", "NAME", "DATE_CREATE", "DATE_UPDATE", "ACTIVE", "OWNER_ID", "URL", "REAL_URL", "GROUP_ID", "OWNER_LOGIN", "OWNER_NAME", "OWNER_LAST_NAME", "OWNER_EMAIL", "GROUP_NAME", "GROUP_SITE_ID", "SOCNET_GROUP_ID", "USE_SOCNET");
foreach ($arVisibleColumns as $val) {
if (!in_array($val, $arSelectedFields)) {
$arSelectedFields[] = $val;
}
}
$dbResultList = CBlog::GetList(array($by => $order), $arFilter, false, array("nPageSize" => CAdminResult::GetNavSize($sTableID)), $arSelectedFields);
$dbResultList = new CAdminResult($dbResultList, $sTableID);
$dbResultList->NavStart();
$lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("BLB_GROUP_NAV")));
while ($arBlog = $dbResultList->NavNext(true, "f_")) {
$row =& $lAdmin->AddRow($f_ID, $arBlog, "/bitrix/admin/blog_blog_edit.php?ID=" . $f_ID . "&lang=" . LANGUAGE_ID, GetMessage("BLB_UPDATE_ALT"));
$row->AddField("ID", '<a href="/bitrix/admin/blog_blog_edit.php?ID=' . $f_ID . '&lang=' . LANGUAGE_ID . '" title="' . GetMessage("BLB_UPDATE_ALT") . '">' . $f_ID . '</a>');
$row->AddField("NAME", "<a href=\"" . CBlog::PreparePath($f_URL, $f_GROUP_SITE_ID, false, $f_OWNER_ID, $f_SOCNET_GROUP_ID) . "\">" . $f_NAME . "</a>");
$row->AddField("DATE_CREATE", $f_DATE_CREATE);
$row->AddField("DATE_UPDATE", $f_DATE_UPDATE);
$row->AddField("ACTIVE", $f_ACTIVE == "Y" ? GetMessage("BLB_YES") : GetMessage("BLB_NO"));
if (IntVal($f_OWNER_ID) > 0) {
$row->AddField("OWNER_INFO", "<a href=\"/bitrix/admin/user_edit.php?ID=" . $f_OWNER_ID . "&lang=" . LANG . "\">[" . $f_OWNER_ID . "] " . $f_OWNER_NAME . " " . $f_OWNER_LAST_NAME . " (" . $f_OWNER_LOGIN . ")</a>");
}
if (IntVal($f_SOCNET_GROUP_ID) > 0) {
$row->AddField("SOCNET_GROUP_ID", $f_SOCNET_GROUP_ID);
if (CModule::IncludeModule("socialnetwork")) {
$arGroupSo = CSocNetGroup::GetByID($f_SOCNET_GROUP_ID);
if (!empty($arGroupSo)) {
$row->AddField("SOCNET_GROUP_ID", "[" . $f_SOCNET_GROUP_ID . "] " . $arGroupSo["NAME"]);
}
}
}
示例3: OnSearchReindex
function OnSearchReindex($NS = array(), $oCallback = NULL, $callback_method = "")
{
global $DB;
$arResult = array();
//CBlogSearch::Trace('OnSearchReindex', 'NS', $NS);
if ($NS["MODULE"] == "blog" && strlen($NS["ID"]) > 0) {
$category = substr($NS["ID"], 0, 1);
$id = intval(substr($NS["ID"], 1));
} else {
$category = 'B';
//start with blogs
$id = 0;
//very first id
}
//CBlogSearch::Trace('OnSearchReindex', 'category+id', array("CATEGORY"=>$category,"ID"=>$id));
//Reindex blogs
if ($category == 'B') {
$strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tb.ID\n\t\t\t\t\t,bg.SITE_ID\n\t\t\t\t\t,b.REAL_URL\n\t\t\t\t\t,b.URL\n\t\t\t\t\t," . $DB->DateToCharFunction("b.DATE_UPDATE") . " as DATE_UPDATE\n\t\t\t\t\t,b.NAME\n\t\t\t\t\t,b.DESCRIPTION\n\t\t\t\t\t,b.OWNER_ID\n\t\t\t\t\t,b.SOCNET_GROUP_ID\n\t\t\t\t\t,b.USE_SOCNET\n\t\t\t\t\t,b.SEARCH_INDEX\n\t\t\t\tFROM\n\t\t\t\t\tb_blog b\n\t\t\t\t\tINNER JOIN b_blog_group bg ON (b.GROUP_ID = bg.ID)\n\t\t\t\tWHERE\n\t\t\t\t\tb.ACTIVE = 'Y'\n\t\t\t\t\tAND b.SEARCH_INDEX = 'Y'\n\t\t\t\t\t" . ($NS["SITE_ID"] != "" ? "AND bg.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "'" : "") . "\n\t\t\t\t\tAND b.ID > " . $id . "\n\t\t\t\tORDER BY\n\t\t\t\t\tb.ID\n\t\t\t";
//CBlogSearch::Trace('OnSearchReindex', 'strSql', $strSql);
$rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
while ($ar = $rs->Fetch()) {
if ($ar["USE_SOCNET"] == "Y") {
$Result = array("ID" => "B" . $ar["ID"], "BODY" => "", "TITLE" => "");
} else {
//CBlogSearch::Trace('OnSearchReindex', 'ar', $ar);
$arSite = array($ar["SITE_ID"] => CBlog::PreparePath($ar["URL"], $ar["SITE_ID"], false, $ar["OWNER_ID"], $ar["SOCNET_GROUP_ID"]));
//CBlogSearch::Trace('OnSearchReindex', 'arSite', $arSite);
$Result = array("ID" => "B" . $ar["ID"], "LAST_MODIFIED" => $ar["DATE_UPDATE"], "TITLE" => $ar["NAME"], "BODY" => blogTextParser::killAllTags($ar["DESCRIPTION"]), "SITE_ID" => $arSite, "PARAM1" => "BLOG", "PARAM2" => $ar["OWNER_ID"], "PERMISSIONS" => array(2));
//CBlogSearch::Trace('OnSearchReindex', 'Result', $Result);
}
if ($oCallback) {
$res = call_user_func(array($oCallback, $callback_method), $Result);
if (!$res) {
return $Result["ID"];
}
} else {
$arResult[] = $Result;
}
}
//all blogs indexed so let's start index posts
$category = 'P';
$id = 0;
}
if ($category == 'P') {
$arUser2Blog = array();
if (COption::GetOptionString("blog", "socNetNewPerms", "N") == "N") {
$dbB = CBlog::GetList(array(), array("USE_SOCNET" => "Y", "!OWNER_ID" => false), false, false, array("ID", "OWNER_ID", "USE_SOCNET", "GROUP_ID"));
while ($arB = $dbB->Fetch()) {
$arUser2Blog[$arB["OWNER_ID"]][$arB["GROUP_ID"]] = $arB["ID"];
}
}
$bSonet = false;
if (IsModuleInstalled("socialnetwork")) {
$bSonet = true;
}
$parserBlog = new blogTextParser(false, "/bitrix/images/blog/smile/");
$strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tbp.ID\n\t\t\t\t\t,bg.SITE_ID\n\t\t\t\t\t,b.REAL_URL\n\t\t\t\t\t,b.URL\n\t\t\t\t\t," . $DB->DateToCharFunction("bp.DATE_PUBLISH") . " as DATE_PUBLISH\n\t\t\t\t\t,bp.TITLE\n\t\t\t\t\t,bp.DETAIL_TEXT\n\t\t\t\t\t,bp.BLOG_ID\n\t\t\t\t\t,b.OWNER_ID\n\t\t\t\t\t,bp.CATEGORY_ID\n\t\t\t\t\t,b.SOCNET_GROUP_ID\n\t\t\t\t\t,b.USE_SOCNET\n\t\t\t\t\t,b.SEARCH_INDEX\n\t\t\t\t\t,b.GROUP_ID\n\t\t\t\t\t,bp.PATH\n\t\t\t\t\t,bp.MICRO\n\t\t\t\t\t,bp.PUBLISH_STATUS\n\t\t\t\t\t,bp.AUTHOR_ID " . ($bSonet ? ", BSL.ID as SLID" : "") . " FROM\n\t\t\t\t\tb_blog_post bp\n\t\t\t\t\tINNER JOIN b_blog b ON (bp.BLOG_ID = b.ID)\n\t\t\t\t\tINNER JOIN b_blog_group bg ON (b.GROUP_ID = bg.ID) " . ($bSonet ? "LEFT JOIN b_sonet_log BSL ON (BSL.EVENT_ID in ('blog_post', 'blog_post_micro') AND BSL.SOURCE_ID = bp.ID) " : "") . " WHERE\n\t\t\t\t\tbp.DATE_PUBLISH <= " . $DB->CurrentTimeFunction() . "\n\t\t\t\t\tAND b.ACTIVE = 'Y'\n\t\t\t\t\t" . ($NS["SITE_ID"] != "" ? "AND bg.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "'" : "") . "\n\t\t\t\t\tAND bp.ID > " . $id . "\n\t\t\t\t\t\n\t\t\t\tORDER BY\n\t\t\t\t\tbp.ID\n\t\t\t";
/* AND bp.PUBLISH_STATUS = '".$DB->ForSQL(BLOG_PUBLISH_STATUS_PUBLISH)."'*/
//AND b.SEARCH_INDEX = 'Y'
//CBlogSearch::Trace('OnSearchReindex', 'strSql', $strSql);
$rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
while ($ar = $rs->Fetch()) {
//Check permissions
$tag = "";
if ($ar["USE_SOCNET"] != "Y") {
$PostPerms = CBlogUserGroup::GetGroupPerms(1, $ar["BLOG_ID"], $ar["ID"], BLOG_PERMS_POST);
if ($PostPerms < BLOG_PERMS_READ) {
continue;
}
}
//CBlogSearch::Trace('OnSearchReindex', 'ar', $ar);
if (strlen($ar["PATH"]) > 0) {
$arSite = array($ar["SITE_ID"] => str_replace("#post_id#", $ar["ID"], $ar["PATH"]));
} else {
$arSite = array($ar["SITE_ID"] => CBlogPost::PreparePath($ar["URL"], $ar["ID"], $ar["SITE_ID"], false, $ar["OWNER_ID"], $ar["SOCNET_GROUP_ID"]));
}
if (strlen($ar["CATEGORY_ID"]) > 0) {
$arC = explode(",", $ar["CATEGORY_ID"]);
$tag = "";
$arTag = array();
foreach ($arC as $v) {
$arCategory = CBlogCategory::GetByID($v);
$arTag[] = $arCategory["NAME"];
}
$tag = implode(",", $arTag);
}
//CBlogSearch::Trace('OnSearchReindex', 'arSite', $arSite);
$Result = array("ID" => "P" . $ar["ID"], "LAST_MODIFIED" => $ar["DATE_PUBLISH"], "TITLE" => blogTextParser::killAllTags($ar["TITLE"]), "BODY" => blogTextParser::killAllTags($ar["DETAIL_TEXT"]), "SITE_ID" => $arSite, "PARAM1" => "POST", "PARAM2" => $ar["BLOG_ID"], "PERMISSIONS" => array(2), "TAGS" => $tag, "USER_ID" => $ar["AUTHOR_ID"], "ENTITY_TYPE_ID" => "BLOG_POST", "ENTITY_ID" => $ar["ID"]);
if ($ar["USE_SOCNET"] == "Y" && CModule::IncludeModule("socialnetwork")) {
$arF = array();
if (COption::GetOptionString("blog", "socNetNewPerms", "N") == "N") {
if (IntVal($ar["SOCNET_GROUP_ID"]) > 0) {
$newBlogId = 0;
if (IntVal($arUser2Blog[$ar["AUTHOR_ID"]][$ar["GROUP_ID"]]) > 0) {
$newBlogId = IntVal($arUser2Blog[$ar["AUTHOR_ID"]][$ar["GROUP_ID"]]);
} else {
$arFields = array("=DATE_UPDATE" => $DB->CurrentTimeFunction(), "GROUP_ID" => $ar["GROUP_ID"], "ACTIVE" => "Y", "ENABLE_COMMENTS" => "Y", "ENABLE_IMG_VERIF" => "Y", "EMAIL_NOTIFY" => "Y", "ENABLE_RSS" => "Y", "ALLOW_HTML" => "N", "ENABLE_TRACKBACK" => "N", "SEARCH_INDEX" => "Y", "USE_SOCNET" => "Y", "=DATE_CREATE" => $DB->CurrentTimeFunction(), "PERMS_POST" => array(1 => "I", 2 => "I"), "PERMS_COMMENT" => array(1 => "P", 2 => "P"));
$bRights = false;
$rsUser = CUser::GetByID($ar["AUTHOR_ID"]);
$arUser = $rsUser->Fetch();
//.........这里部分代码省略.........
示例4: Update
function Update($ID, $arFields)
{
global $DB;
$ID = IntVal($ID);
if ($ID <= 0) {
return false;
}
if (strlen($arFields["PATH"]) > 0) {
$path = $arFields["PATH"];
unset($arFields["PATH"]);
}
$arFields1 = array();
foreach ($arFields as $key => $value) {
if (substr($key, 0, 1) == "=") {
$arFields1[substr($key, 1)] = $value;
unset($arFields[$key]);
}
}
if (!CBlog::CheckFields("UPDATE", $arFields, $ID)) {
return false;
} elseif (!$GLOBALS["USER_FIELD_MANAGER"]->CheckFields("BLOG_BLOG", $ID, $arFields)) {
return false;
}
$db_events = GetModuleEvents("blog", "OnBeforeBlogUpdate");
while ($arEvent = $db_events->Fetch()) {
if (ExecuteModuleEventEx($arEvent, array($ID, &$arFields)) === false) {
return false;
}
}
$arBlogOld = CBlog::GetByID($ID);
$strUpdate = $DB->PrepareUpdate("b_blog", $arFields);
foreach ($arFields1 as $key => $value) {
if (strlen($strUpdate) > 0) {
$strUpdate .= ", ";
}
$strUpdate .= $key . "=" . $value . " ";
}
if (strlen($strUpdate) > 0) {
$strSql = "UPDATE b_blog SET " . "\t" . $strUpdate . " " . "WHERE ID = " . $ID . " ";
$DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
unset($GLOBALS["BLOG"]["BLOG_CACHE_" . $ID]);
unset($GLOBALS["BLOG"]["BLOG4OWNER_CACHE_" . $arBlogOld["OWNER_ID"]]);
unset($GLOBALS["BLOG"]["BLOG4OWNERGROUP_CACHE_" . $arBlogOld["SOCNET_GROUP_ID"]]);
$events = GetModuleEvents("blog", "OnBlogUpdate");
while ($arEvent = $events->Fetch()) {
ExecuteModuleEventEx($arEvent, array($ID, &$arFields));
}
if (is_set($arFields, "PERMS_POST")) {
CBlog::SetBlogPerms($ID, $arFields["PERMS_POST"], BLOG_PERMS_POST);
}
if (is_set($arFields, "PERMS_COMMENT")) {
CBlog::SetBlogPerms($ID, $arFields["PERMS_COMMENT"], BLOG_PERMS_COMMENT);
}
$GLOBALS["USER_FIELD_MANAGER"]->Update("BLOG_BLOG", $ID, $arFields);
} else {
$ID = False;
}
if ($ID && (is_set($arFields, "NAME") || is_set($arFields, "DESCRIPTION"))) {
if (CModule::IncludeModule("search")) {
$arBlog = CBlog::GetByID($ID);
if ($arBlogOld["ACTIVE"] == "Y" && $arBlog["ACTIVE"] != "Y" || $arBlogOld["SEARCH_INDEX"] == "Y" && $arBlog["SEARCH_INDEX"] != "Y") {
CSearch::DeleteIndex("blog", false, "COMMENT", $ID . "|%");
CSearch::DeleteIndex("blog", false, "POST", $ID);
CSearch::DeleteIndex("blog", "B" . $ID);
} elseif ($arBlog["ACTIVE"] == "Y" && $arBlog["SEARCH_INDEX"] == "Y") {
if ($arBlog["USE_SOCNET"] == "Y") {
CSearch::DeleteIndex("blog", "B" . $ID);
} else {
$arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]);
if (strlen($path) > 0) {
$path = str_replace("#blog_url#", $arBlog["URL"], $path);
$arPostSite = array($arGroup["SITE_ID"] => $path);
} else {
$arPostSite = array($arGroup["SITE_ID"] => CBlog::PreparePath($arBlog["URL"], $arGroup["SITE_ID"], false, $arBlog["OWNER_ID"], $arBlog["SOCNET_GROUP_ID"]));
}
$arSearchIndex = array("SITE_ID" => $arPostSite, "LAST_MODIFIED" => $arBlog["DATE_UPDATE"], "PARAM1" => "BLOG", "PARAM2" => $arBlog["OWNER_ID"], "PERMISSIONS" => array(2), "TITLE" => $arBlog["NAME"], "BODY" => strlen($arBlog["DESCRIPTION"]) > 0 ? $arBlog["DESCRIPTION"] : $arBlog["NAME"]);
CSearch::Index("blog", "B" . $ID, $arSearchIndex);
}
}
}
}
return $ID;
}
示例5: BuildRSS
function BuildRSS($ID, $type = "RSS .92", $numPosts = 10, $blogTemplate = "", $postTemplate = "", $userTemplate = "", $bSoNet = false, $arParams = array())
{
$ID = IntVal($ID);
if ($ID <= 0 && $arParams["USE_SOCNET"] != "Y") {
return false;
}
$numPosts = IntVal($numPosts);
$type = strtolower(preg_replace("/[^a-zA-Z0-9.]/is", "", $type));
if ($type != "rss2.0" && $type != "atom.03") {
$type = "rss.92";
}
$rssText = False;
$arBlog = CBlog::GetByID($ID);
if ($arBlog && $arBlog["ACTIVE"] == "Y" && $arBlog["ENABLE_RSS"] == "Y" || $arParams["USE_SOCNET"] == "Y") {
if (!empty($arBlog)) {
$arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]);
}
if ($arGroup["SITE_ID"] == SITE_ID || $arParams["USE_SOCNET"] == "Y") {
$now = date("r");
$nowISO = date("Y-m-d\\TH:i:s") . substr(date("O"), 0, 3) . ":" . substr(date("O"), -2, 2);
$serverName = "";
$charset = "";
$language = "";
$dbSite = CSite::GetList($b = "sort", $o = "asc", array("LID" => SITE_ID));
if ($arSite = $dbSite->Fetch()) {
$serverName = $arSite["SERVER_NAME"];
$charset = $arSite["CHARSET"];
$language = $arSite["LANGUAGE_ID"];
}
if (strlen($serverName) <= 0) {
if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) {
$serverName = SITE_SERVER_NAME;
} else {
$serverName = COption::GetOptionString("main", "server_name", "");
}
}
if (strlen($charset) <= 0) {
if (defined("SITE_CHARSET") && strlen(SITE_CHARSET) > 0) {
$charset = SITE_CHARSET;
} else {
$charset = "windows-1251";
}
}
if ($bSoNet) {
if (IntVal($arParams["USER_ID"]) > 0) {
$dbUser = CUser::GetByID($arParams["USER_ID"]);
if ($arUser = $dbUser->Fetch()) {
$blogName = htmlspecialcharsbx(GetMessage("BLG_RSS_NAME_SONET", array("#AUTHOR_NAME#" => CUser::FormatName(CSite::GetNameFormat(false), $arUser, true))));
$blogURL = htmlspecialcharsbx("http://" . $serverName . CComponentEngine::MakePathFromTemplate($blogTemplate, array("user_id" => $arParams["USER_ID"])));
}
} else {
if ($arGroupSoNet = CSocNetGroup::GetByID($arParams["SOCNET_GROUP_ID"])) {
$blogName = htmlspecialcharsbx(GetMessage("BLG_RSS_NAME_SONET_GROUP", array("#GROUP_NAME#" => $arGroupSoNet["NAME"])));
$blogURL = htmlspecialcharsbx("http://" . $serverName . CComponentEngine::MakePathFromTemplate($blogTemplate, array("group_id" => $arParams["SOCNET_GROUP_ID"])));
}
}
$blogDescr = "";
} else {
if (strlen($blogTemplate) > 0) {
$blogURL = htmlspecialcharsbx("http://" . $serverName . CComponentEngine::MakePathFromTemplate($blogTemplate, array("blog" => $arBlog["URL"], "user_id" => $arBlog["OWNER_ID"], "group_id" => $arBlog["SOCNET_GROUP_ID"])));
} else {
$blogURL = htmlspecialcharsbx("http://" . $serverName . CBlog::PreparePath($arBlog["URL"], $arGroup["SITE_ID"]));
}
$blogName = htmlspecialcharsbx($arBlog["NAME"]);
$blogDescr = htmlspecialcharsbx($arBlog["DESCRIPTION"]);
}
$rssText = "";
if ($type == "rss.92") {
$rssText .= "<" . "?xml version=\"1.0\" encoding=\"" . $charset . "\"?" . ">\n\n";
$rssText .= "<rss version=\".92\">\n";
$rssText .= " <channel>\n";
$rssText .= "\t<title>" . $blogName . "</title>\n";
$rssText .= "\t<link>" . $blogURL . "</link>\n";
$rssText .= "\t<description>" . $blogDescr . "</description>\n";
$rssText .= "\t<language>" . $language . "</language>\n";
$rssText .= "\t<docs>http://backend.userland.com/rss092</docs>\n";
$rssText .= "\n";
} elseif ($type == "rss2.0") {
$rssText .= "<" . "?xml version=\"1.0\" encoding=\"" . $charset . "\"?" . ">\n\n";
$rssText .= "<rss version=\"2.0\">\n";
$rssText .= " <channel>\n";
$rssText .= "\t<title>" . $blogName . "</title>\n";
//$rssText .= " <guid>".$blogURL."</guid>\n";
$rssText .= "\t<link>" . $blogURL . "</link>\n";
$rssText .= "\t<description>" . $blogDescr . "</description>\n";
$rssText .= "\t<language>" . $language . "</language>\n";
$rssText .= "\t<docs>http://backend.userland.com/rss2</docs>\n";
$rssText .= "\t<pubDate>" . $now . "</pubDate>\n";
$rssText .= "\n";
} elseif ($type == "atom.03") {
$atomID = "tag:" . htmlspecialcharsbx($serverName) . "," . date("Y-m-d") . ":" . $ID;
$rssText .= "<" . "?xml version=\"1.0\" encoding=\"" . $charset . "\"?" . ">\n\n";
$rssText .= "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\" xml:lang=\"" . $language . "\">\n";
$rssText .= " <title>" . $blogName . "</title>\n";
$rssText .= " <tagline>" . $blogURL . "</tagline>\n";
//$rssText .= " <link href=\"".$blogURL."\"/>";
$rssText .= " <id>" . $atomID . "</id>\n";
$rssText .= " <link rel=\"alternate\" type=\"text/html\" href=\"" . $blogURL . "\" />\n";
$rssText .= " <copyright>Copyright (c) " . $blogURL . "</copyright>\n";
$rssText .= " <modified>" . $nowISO . "</modified>\n";
//.........这里部分代码省略.........