本文整理汇总了PHP中CBlogPost::Add方法的典型用法代码示例。如果您正苦于以下问题:PHP CBlogPost::Add方法的具体用法?PHP CBlogPost::Add怎么用?PHP CBlogPost::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBlogPost
的用法示例。
在下文中一共展示了CBlogPost::Add方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
}
if (!$iCommentID && isset($_REQUEST["parentId"])) {
$arCategory = array();
$arBlog = CBlog::GetByUrl($arParams["BLOG_URL"]);
if (!empty($arResult["ELEMENT"]["TAGS"])) {
$arCategoryVal = explode(",", $arResult["ELEMENT"]["TAGS"]);
foreach ($arCategoryVal as $k => $v) {
if ($id = CBlogCategory::Add(array("BLOG_ID" => $arBlog["ID"], "NAME" => $v))) {
$arCategory[] = $id;
}
}
}
$arResult["ELEMENT"]["DETAIL_PICTURE"] = CFile::GetFileArray($arResult["ELEMENT"]["DETAIL_PICTURE"]);
$arResult["ELEMENT"]["REAL_PICTURE"] = CFile::GetFileArray($arResult["ELEMENT"]["PROPERTIES"]["REAL_PICTURE"]["VALUE"]);
$arFields = array("TITLE" => $arResult["ELEMENT"]["NAME"], "DETAIL_TEXT" => "[IMG]http://" . $_SERVER['HTTP_HOST'] . $arResult["ELEMENT"]["DETAIL_PICTURE"]["SRC"] . "[/IMG]\n" . "[URL=http://" . $_SERVER['HTTP_HOST'] . $arResult["ELEMENT"]["~DETAIL_PAGE_URL"] . "]" . $arResult["ELEMENT"]["NAME"] . "[/URL]\n" . (!empty($arResult["ELEMENT"]["TAGS"]) ? $arResult["ELEMENT"]["TAGS"] . "\n" : "") . $arResult["ELEMENT"]["~DETAIL_TEXT"] . "\n" . "[URL=http://" . $_SERVER['HTTP_HOST'] . $arResult["ELEMENT"]["REAL_PICTURE"]["SRC"] . "]" . GetMessage("P_ORIGINAL") . "[/URL]", "CATEGORY_ID" => implode(",", $arCategory), "PUBLISH_STATUS" => "P", "PERMS_POST" => array(), "PERMS_COMMENT" => array(), "=DATE_CREATE" => $DB->GetNowFunction(), "=DATE_PUBLISH" => $DB->GetNowFunction(), "AUTHOR_ID" => !empty($arResult["ELEMENT"]["CREATED_BY"]) ? $arResult["ELEMENT"]["CREATED_BY"] : 1, "BLOG_ID" => $arBlog["ID"], "ENABLE_TRACKBACK" => "N");
$newID = CBlogPost::Add($arFields);
if ($newID > 0) {
foreach ($arCategory as $key) {
CBlogPostCategory::Add(array("BLOG_ID" => $arBlog["ID"], "POST_ID" => $newID, "CATEGORY_ID" => $key));
}
BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"]);
BXClearCache(True, "/" . SITE_ID . "/blog/last_messages/");
BXClearCache(True, "/" . SITE_ID . "/blog/groups/" . $arBlog["GROUP_ID"] . "/");
$iCommentID = $newID;
CIBlockElement::SetPropertyValues($arResult["ELEMENT"]["ID"], $arParams["IBLOCK_ID"], $iCommentID, "BLOG_POST_ID");
}
}
$arResult["COMMENT_ID"] = $iCommentID;
if ($arParams["CACHE_TIME"] > 0) {
$cache->StartDataCache($arParams["CACHE_TIME"], $cache_id, $cache_path);
$cache->EndDataCache(array("COMMENT_ID" => $arResult["COMMENT_ID"], "ELEMENT" => $arResult["ELEMENT"]));
示例2: NewPost
function NewPost($params)
{
global $USER, $DB;
$blogId = IntVal(CBlogMetaWeblog::DecodeParams($params[0]["#"]["value"][0]["#"]));
$user = CBlogMetaWeblog::DecodeParams($params[1]["#"]["value"][0]["#"]);
$password = CBlogMetaWeblog::DecodeParams($params[2]["#"]["value"][0]["#"]);
$arPostInfo = $params[3]["#"]["value"][0]["#"]["struct"][0]["#"]["member"];
$publish = $params[4]["#"]["value"][0]["#"]["boolean"][0]["#"];
foreach ($arPostInfo as $val) {
${$val["#"]["name"][0]["#"]} = CBlogMetaWeblog::DecodeParams($val["#"]["value"][0]["#"]);
}
$arCategory = array();
if (is_array($categories["data"][0]["#"]["value"])) {
foreach ($categories["data"][0]["#"]["value"] as $val) {
$catTmp = CBlogMetaWeblog::DecodeParams($val["#"]);
if (strlen($catTmp) > 0) {
$arCategory[] = $catTmp;
}
}
}
if (CBlogMetaWeblog::Authorize($user, $password)) {
$result = '';
$userId = $USER->GetID();
if (IntVal($blogId) > 0) {
$dbBlog = CBlog::GetList(array(), array("GROUP_SITE_ID" => SITE_ID, "ACTIVE" => "Y", "ID" => $blogId), false, false, array("ID", "URL", "NAME", "GROUP_ID", "SOCNET_GROUP_ID"));
if ($arBlog = $dbBlog->GetNext()) {
$CATEGORYtmp = array();
$dbCategory = CBlogCategory::GetList(array(), array("BLOG_ID" => $blogId));
while ($arCat = $dbCategory->Fetch()) {
$arCatBlog[ToLower($arCat["NAME"])] = $arCat["ID"];
}
if (intval($arBlog["SOCNET_GROUP_ID"]) > 0 && CModule::IncludeModule("socialnetwork") && method_exists("CSocNetGroup", "GetSite")) {
$arSites = array();
$rsGroupSite = CSocNetGroup::GetSite($arBlog["SOCNET_GROUP_ID"]);
while ($arGroupSite = $rsGroupSite->Fetch()) {
$arSites[] = $arGroupSite["LID"];
}
} else {
$arSites = array(SITE_ID);
}
foreach ($arCategory as $tg) {
$tg = trim($tg);
if (!in_array($arCatBlog[ToLower($tg)], $CATEGORYtmp)) {
if (IntVal($arCatBlog[ToLower($tg)]) > 0) {
$CATEGORYtmp[] = $arCatBlog[ToLower($tg)];
} else {
$CATEGORYtmp[] = CBlogCategory::Add(array("BLOG_ID" => $blogId, "NAME" => $tg));
foreach ($arSites as $site_id_tmp) {
BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/category/");
}
}
}
}
$dbSite = CSite::GetByID(SITE_ID);
$arSite = $dbSite->Fetch();
$serverName = htmlspecialcharsEx($arSite["SERVER_NAME"]);
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", "www.bitrixsoft.com");
}
}
$arImgRepl = array();
$dbImage = CBlogImage::GetList(array(), array("POST_ID" => false, "BLOG_ID" => $blogId, "IS_COMMENT" => "N"));
while ($arImage = $dbImage->Fetch()) {
$path = "";
$path = CFile::GetPath($arImage["FILE_ID"]);
$path = "http://" . $serverName . $path;
if (strpos($description, $path) !== false) {
$description = str_replace('<img src="' . $path . '" alt=""/>', "[IMG ID=" . $arImage["ID"] . "]", $description);
$arImgRepl[] = $arImage["ID"];
}
}
$arFields = array("BLOG_ID" => $blogId, "AUTHOR_ID" => $userId, "TITLE" => $title, "DETAIL_TEXT" => $description, "DETAIL_TEXT_TYPE" => "html", "=DATE_PUBLISH" => $DB->GetNowFunction(), "=DATE_CREATE" => $DB->GetNowFunction(), "PUBLISH_STATUS" => $publish == 1 ? "P" : "D", "ENABLE_TRACKBACK" => "N", "ENABLE_COMMENTS" => "Y", "CATEGORY_ID" => implode(",", $CATEGORYtmp), "PERMS_POST" => array(), "PERMS_COMMENT" => array());
$postId = CBlogPost::Add($arFields);
if (IntVal($postId) > 0) {
foreach ($CATEGORYtmp as $v) {
CBlogPostCategory::Add(array("BLOG_ID" => $arBlog["ID"], "POST_ID" => $postId, "CATEGORY_ID" => $v));
}
foreach ($arImgRepl as $v) {
CBlogImage::Update($v, array("POST_ID" => $postId));
}
foreach ($arSites as $site_id_tmp) {
BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/first_page/");
BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/calendar/");
BXClearCache(True, "/" . $site_id_tmp . "/blog/last_messages/");
BXClearCache(True, "/" . $site_id_tmp . "/blog/commented_posts/");
BXClearCache(True, "/" . $site_id_tmp . "/blog/popular_posts/");
BXClearCache(True, "/" . $site_id_tmp . "/blog/last_comments/");
BXClearCache(True, "/" . $site_id_tmp . "/blog/groups/" . $arBlog["GROUP_ID"] . "/");
BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/rss_out/");
BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/rss_all/");
BXClearCache(True, "/" . $site_id_tmp . "/blog/rss_sonet/");
BXClearCache(True, "/" . $site_id_tmp . "/blog/rss_all/");
BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/favorite/");
}
return '<params>
<param>
<value>
//.........这里部分代码省略.........
示例3: foreach
$arStatusList = CIdeaManagment::getInstance()->GetStatusList();
foreach ($arStatusList as $UF) {
$arUFIdByName[$UF["XML_ID"]] = $UF["ID"];
}
//Categories
$categoryID = array();
$categoryID[0][] = CBlogCategory::Add(array("BLOG_ID" => $blogID, "NAME" => GetMessage("IDEA_BLOG_DEMO_CATEGORY_1")));
$categoryID[0][] = CBlogCategory::Add(array("BLOG_ID" => $blogID, "NAME" => GetMessage("IDEA_BLOG_DEMO_CATEGORY_2")));
$categoryID[1][] = CBlogCategory::Add(array("BLOG_ID" => $blogID, "NAME" => GetMessage("IDEA_BLOG_DEMO_CATEGORY_3")));
//Post messages
$arBlogPostFields = array();
$arBlogPostFields[] = array("TITLE" => GetMessage("IDEA_BLOG_DEMO_MESSAGE_TITLE_1"), "DETAIL_TEXT" => GetMessage("IDEA_BLOG_DEMO_MESSAGE_BODY_1"), "DETAIL_TEXT_TYPE" => "text", "BLOG_ID" => $blogID, "AUTHOR_ID" => 1, "=DATE_CREATE" => $DB->GetNowFunction(), "=DATE_PUBLISH" => $DB->GetNowFunction(), "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH, "ENABLE_TRACKBACK" => 'N', "ENABLE_COMMENTS" => 'Y', "CATEGORY_ID" => implode(",", $categoryID[0]), "UF_CATEGORY_CODE" => ToUpper(GetMessage("IDEA_UF_CATEGORY_CODE_1")), "UF_STATUS" => $arUFIdByName["COMPLETED"], "PERMS_POST" => array(1 => BLOG_PERMS_READ, 2 => BLOG_PERMS_READ), "PERMS_COMMENT" => array(1 => BLOG_PERMS_WRITE, 2 => BLOG_PERMS_WRITE), "PATH" => '/services/idea/#post_id#/', "CODE" => "company_new_year_2012");
$arBlogPostFields[] = array("TITLE" => GetMessage("IDEA_BLOG_DEMO_MESSAGE_TITLE_2"), "DETAIL_TEXT" => GetMessage("IDEA_BLOG_DEMO_MESSAGE_BODY_2"), "DETAIL_TEXT_TYPE" => "text", "BLOG_ID" => $blogID, "AUTHOR_ID" => 1, "=DATE_CREATE" => $DB->GetNowFunction(), "=DATE_PUBLISH" => $DB->GetNowFunction(), "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH, "ENABLE_TRACKBACK" => 'N', "ENABLE_COMMENTS" => 'Y', "CATEGORY_ID" => implode(",", $categoryID[1]), "UF_CATEGORY_CODE" => ToUpper(GetMessage("IDEA_UF_CATEGORY_CODE_2")), "UF_STATUS" => $arUFIdByName["NEW"], "PERMS_POST" => array(1 => BLOG_PERMS_READ, 2 => BLOG_PERMS_READ), "PERMS_COMMENT" => array(1 => BLOG_PERMS_WRITE, 2 => BLOG_PERMS_WRITE), "PATH" => '/services/idea/#post_id#/', "CODE" => "new_workers");
$arBlogPostId = array();
foreach ($arBlogPostFields as $BlogPostFields) {
$arBlogPostId[] = CBlogPost::Add($BlogPostFields);
}
foreach ($arBlogPostId as $key => $BlogPostId) {
if (!is_array($categoryID[$key])) {
continue;
}
foreach ($categoryID[$key] as $v) {
CBlogPostCategory::Add(array("BLOG_ID" => $blogID, "POST_ID" => $BlogPostId, "CATEGORY_ID" => $v));
}
}
//Post Comments
$arBlogCommentFields = array();
$arBlogCommentFields[] = array("TITLE" => '', "POST_TEXT" => GetMessage("IDEA_BLOG_DEMO_COMMENT_BODY_1"), "BLOG_ID" => $blogID, "POST_ID" => $arBlogPostId[0], "PARENT_ID" => 0, "AUTHOR_ID" => 1, "DATE_CREATE" => ConvertTimeStamp(false, "FULL"), "AUTHOR_IP" => "192.168.0.108", "PATH" => "/services/idea/#post_id#/?commentId=#comment_id###comment_id#");
$arBlogCommentFields[] = array("TITLE" => '', "POST_TEXT" => GetMessage("IDEA_BLOG_DEMO_COMMENT_BODY_2"), "BLOG_ID" => $blogID, "POST_ID" => $arBlogPostId[0], "PARENT_ID" => 0, "AUTHOR_ID" => 1, "DATE_CREATE" => ConvertTimeStamp(false, "FULL"), "AUTHOR_IP" => "192.168.0.108", "PATH" => "/services/idea/#post_id#/?commentId=#comment_id###comment_id#");
$arCommentId = array();
foreach ($arBlogCommentFields as $BlogCommentFields) {
示例4: PostIntoBuzzAsBlog
public static function PostIntoBuzzAsBlog($userTwit, $arSiteId = array(), $userLogin = '')
{
global $DB;
if (!CModule::IncludeModule("blog")) {
return;
}
$arParams = array();
if (IsModuleInstalled('bitrix24') && defined('BX24_HOST_NAME') && $userLogin != '') {
if ($arUserTwit = unserialize(base64_decode($userTwit))) {
$userTwit = $arUserTwit;
}
if ($arSiteIdCheck = unserialize(base64_decode($arSiteId))) {
$arSiteId = $arSiteIdCheck;
}
$dbUser = CUser::GetByLogin($userLogin);
if ($arUser = $dbUser->Fetch()) {
$arParams["USER_ID"] = $arUser["ID"];
}
} else {
$arParams["USER_ID"] = $userTwit['kp_user_id'];
}
if (isset($arSiteId[$userTwit['kp_user_id']])) {
$siteId = $arSiteId[$userTwit['kp_user_id']];
}
if (strlen($siteId) <= 0) {
$siteId = SITE_ID;
}
if (isset($userTwit['text'])) {
$arParams["GROUP_ID"] = COption::GetOptionString("socialnetwork", "userbloggroup_id", false, $siteId);
$arParams["PATH_TO_BLOG"] = COption::GetOptionString("socialnetwork", "userblogpost_page", false, $siteId);
$arParams["PATH_TO_SMILE"] = COption::GetOptionString("socialnetwork", "smile_page", false, $siteId);
$arParams["NAME_TEMPLATE"] = COption::GetOptionString("main", "TOOLTIP_NAME_TEMPLATE", false, $siteId);
$arParams["SHOW_LOGIN"] = 'Y';
$arParams["PATH_TO_POST"] = $arParams["PATH_TO_BLOG"];
$arFilterblg = array("ACTIVE" => "Y", "USE_SOCNET" => "Y", "GROUP_ID" => $arParams["GROUP_ID"], "GROUP_SITE_ID" => $siteId, "OWNER_ID" => $arParams["USER_ID"]);
$groupId = is_array($arParams["GROUP_ID"]) ? IntVal($arParams["GROUP_ID"][0]) : IntVal($arParams["GROUP_ID"]);
if (isset($GLOBALS["BLOG_POST"]["BLOG_P_" . $groupId . "_" . $arParams["USER_ID"]]) && !empty($GLOBALS["BLOG_POST"]["BLOG_P_" . $groupId . "_" . $arParams["USER_ID"]])) {
$arBlog = $GLOBALS["BLOG_POST"]["BLOG_P_" . $groupId . "_" . $arParams["USER_ID"]];
} else {
$dbBl = CBlog::GetList(array(), $arFilterblg);
$arBlog = $dbBl->Fetch();
if (!$arBlog && IsModuleInstalled("intranet")) {
$arBlog = CBlog::GetByOwnerID($arParams["USER_ID"]);
}
$GLOBALS["BLOG_POST"]["BLOG_P_" . $groupId . "_" . $arParams["USER_ID"]] = $arBlog;
}
$arResult["Blog"] = $arBlog;
if (empty($arBlog)) {
if (!empty($arParams["GROUP_ID"])) {
$arFields = array("=DATE_UPDATE" => $DB->CurrentTimeFunction(), "GROUP_ID" => is_array($arParams["GROUP_ID"]) ? IntVal($arParams["GROUP_ID"][0]) : IntVal($arParams["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($arParams["USER_ID"]);
$arUser = $rsUser->Fetch();
if (strlen($arUser["NAME"] . "" . $arUser["LAST_NAME"]) <= 0) {
$arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["LOGIN"];
} else {
$arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["NAME"] . " " . $arUser["LAST_NAME"];
}
$arFields["URL"] = str_replace(" ", "_", $arUser["LOGIN"]) . "-blog-" . SITE_ID;
$arFields["OWNER_ID"] = $arParams["USER_ID"];
$urlCheck = preg_replace("/[^a-zA-Z0-9_-]/is", "", $arFields["URL"]);
if ($urlCheck != $arFields["URL"]) {
$arFields["URL"] = "u" . $arParams["USER_ID"] . "-blog-" . SITE_ID;
}
if (CBlog::GetByUrl($arFields["URL"])) {
$uind = 0;
do {
$uind++;
$arFields["URL"] = $arFields["URL"] . $uind;
} while (CBlog::GetByUrl($arFields["URL"]));
}
$featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $arFields["OWNER_ID"], "blog", "view_post");
if ($featureOperationPerms == SONET_RELATIONS_TYPE_ALL) {
$bRights = true;
}
$arFields["PATH"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG"], array("blog" => $arFields["URL"], "user_id" => $arFields["OWNER_ID"], "group_id" => $arFields["SOCNET_GROUP_ID"]));
$blogID = CBlog::Add($arFields);
if ($bRights) {
CBlog::AddSocnetRead($blogID);
}
$arBlog = CBlog::GetByID($blogID, $arParams["GROUP_ID"]);
}
}
// $DATE_PUBLISH = "";
// if(strlen($_POST["DATE_PUBLISH_DEF"]) > 0)
// $DATE_PUBLISH = $_POST["DATE_PUBLISH_DEF"];
// elseif (strlen($_POST["DATE_PUBLISH"])<=0)
$DATE_PUBLISH = ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL");
// else
// $DATE_PUBLISH = $_POST["DATE_PUBLISH"];
$arFields = array("DETAIL_TEXT" => $userTwit['text'], "DETAIL_TEXT_TYPE" => "text", "DATE_PUBLISH" => $DATE_PUBLISH, "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH, "PATH" => CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arParams["PATH_TO_POST"]), array("post_id" => "#post_id#", "user_id" => $arBlog["OWNER_ID"])), "URL" => $arBlog["URL"], "SOURCE_TYPE" => "twitter");
$arFields["PERMS_POST"] = array();
$arFields["PERMS_COMMENT"] = array();
$arFields["MICRO"] = "N";
if (strlen($arFields["TITLE"]) <= 0) {
$arFields["MICRO"] = "Y";
$arFields["TITLE"] = trim(blogTextParser::killAllTags($arFields["DETAIL_TEXT"]));
if (strlen($arFields["TITLE"]) <= 0) {
$arFields["TITLE"] = GetMessage("BLOG_EMPTY_TITLE_PLACEHOLDER");
}
//.........这里部分代码省略.........
示例5: array
$arFields = array(
'TITLE' => $arResult['ELEMENT']['~NAME'],
'DETAIL_TEXT' =>
"[URL=http://".$_SERVER['HTTP_HOST'].$arResult["ELEMENT"]["~DETAIL_PAGE_URL"]."]".$arResult["ELEMENT"]["~NAME"]."[/URL]\n".
($arResult["ELEMENT"]["~PREVIEW_TEXT"] != '' ? $arResult["ELEMENT"]["~PREVIEW_TEXT"] : '')."\n",
'PUBLISH_STATUS' => BLOG_PUBLISH_STATUS_PUBLISH,
"PERMS_POST" => array(),
"PERMS_COMMENT" => array(),
"=DATE_CREATE" => $DB->GetNowFunction(),
"=DATE_PUBLISH" => $DB->GetNowFunction(),
"AUTHOR_ID" => $ownerID,
"BLOG_ID" => $arResult['BLOG_DATA']['BLOG_ID'],
"ENABLE_TRACKBACK" => "N"
);
$postID = CBlogPost::Add($arFields);
if ($postID)
{
CIBlockElement::SetPropertyValues($arResult['ELEMENT']['ID'], $arResult['ELEMENT']['IBLOCK_ID'], $postID, $arResult['BLOG_DATA']['BLOG_POST_ID_PROP']);
}
}
$arResult['BLOG_DATA']['BLOG_POST_ID'] = $postID;
$arResult['COMMENT_ID'] = $postID;
}
$protocol = (CMain::IsHTTPS()) ? 'https://' : 'http://';
if ($arParams['URL_TO_COMMENT'] !== '')
$arResult['URL_TO_COMMENT'] = $arParams['URL_TO_COMMENT'];
elseif (!empty($arResult['ELEMENT']['~DETAIL_PAGE_URL']))
$arResult['URL_TO_COMMENT'] = $protocol.$_SERVER["HTTP_HOST"].$arResult['ELEMENT']['~DETAIL_PAGE_URL'];
示例6: InstallBlogPost
private function InstallBlogPost()
{
global $DB, $USER;
$arBlogMessages = $this->arResult["INSTALLATION"]["BLOG_POST_ID"] = array();
//1
$CATEGORY_ID = array();
$CATEGORY_ID[] = CBlogCategory::Add(array("BLOG_ID" => $this->arResult["INSTALLATION"]["BLOG_ID"], "NAME" => GetMessage("IDEA_BLOG_TAG_TITLE_1")));
$CATEGORY_ID[] = CBlogCategory::Add(array("BLOG_ID" => $this->arResult["INSTALLATION"]["BLOG_ID"], "NAME" => GetMessage("IDEA_BLOG_TAG_TITLE_2")));
$arBlogMessages["NY"] = array("TITLE" => GetMessage("IDEA_BLOG_MESSAGE_TITLE_1"), "DETAIL_TEXT" => GetMessage("IDEA_BLOG_MESSAGE_DESCRIPTION_1"), "DETAIL_TEXT_TYPE" => "text", "=DATE_CREATE" => $DB->GetNowFunction(), "DATE_PUBLISH" => ConvertTimeStamp(false, "FULL"), "PUBLISH_STATUS" => "P", "ENABLE_TRACKBACK" => "N", "ENABLE_COMMENTS" => "Y", "CATEGORY_ID" => join(',', $CATEGORY_ID), "CODE" => "company_new_year_2012", "UF_CATEGORY_CODE" => "OUR_EVENTS", "UF_STATUS" => $this->arResult["SETTINGS"]["STATUS_ID"]["COMPLETED"], "AUTHOR_ID" => $USER->GetID(), "BLOG_ID" => $this->arResult["INSTALLATION"]["BLOG_ID"], "PREVIEW_TEXT_TYPE" => "text", "PATH" => $this->PublicDir . '#post_id#/', "PERMS_POST" => array("1" => BLOG_PERMS_READ, "2" => BLOG_PERMS_WRITE), "PERMS_COMMENT" => array("1" => BLOG_PERMS_WRITE, "2" => BLOG_PERMS_WRITE));
//2
$CATEGORY_ID = array();
$CATEGORY_ID[] = CBlogCategory::Add(array("BLOG_ID" => $this->arResult["INSTALLATION"]["BLOG_ID"], "NAME" => GetMessage("IDEA_BLOG_TAG_TITLE_3")));
$arBlogMessages["WORKERS"] = array("TITLE" => GetMessage("IDEA_BLOG_MESSAGE_TITLE_2"), "DETAIL_TEXT" => GetMessage("IDEA_BLOG_MESSAGE_DESCRIPTION_2"), "DETAIL_TEXT_TYPE" => "text", "=DATE_CREATE" => $DB->GetNowFunction(), "DATE_PUBLISH" => ConvertTimeStamp(false, "FULL"), "PUBLISH_STATUS" => "P", "ENABLE_TRACKBACK" => "N", "ENABLE_COMMENTS" => "Y", "CATEGORY_ID" => join(',', $CATEGORY_ID), "CODE" => "new_workers", "UF_CATEGORY_CODE" => "OUTSIDE", "UF_STATUS" => $this->arResult["SETTINGS"]["STATUS_ID"]["NEW"], "AUTHOR_ID" => $USER->GetID(), "BLOG_ID" => $this->arResult["INSTALLATION"]["BLOG_ID"], "PREVIEW_TEXT_TYPE" => "text", "PATH" => $this->PublicDir . '#post_id#/', "PERMS_POST" => array("1" => BLOG_PERMS_READ, "2" => BLOG_PERMS_WRITE), "PERMS_COMMENT" => array("1" => BLOG_PERMS_WRITE, "2" => BLOG_PERMS_WRITE));
foreach ($arBlogMessages as $key => $BlogMessage) {
if ($this->arResult["INSTALLATION"]["BLOG_POST_ID"][$key] = CBlogPost::Add($BlogMessage)) {
$arPostCategory = explode(',', $BlogMessage["CATEGORY_ID"]);
foreach ($arPostCategory as $CatId) {
CBlogPostCategory::Add(array("POST_ID" => $this->arResult["INSTALLATION"]["BLOG_POST_ID"][$key], "BLOG_ID" => $this->arResult["INSTALLATION"]["BLOG_ID"], "CATEGORY_ID" => $CatId));
}
}
}
}
示例7: unset
} else {
$postID = 0;
}
unset($rsPosts);
}
if ($postID == 0 && $arParams['BLOG_FROM_AJAX'] === 'N') {
$ownerID = 1;
if (!empty($arResult['ELEMENT']['CREATED_BY'])) {
$ownersIterator = Main\UserTable::getList(array('select' => array('ID'), 'filter' => array('=ID' => $arResult['ELEMENT']['CREATED_BY'])));
if ($owner = $ownersIterator->fetch()) {
$ownerID = $owner['ID'];
}
unset($owner, $ownersIterator);
}
$arFields = array('TITLE' => $arResult['ELEMENT']['~NAME'], 'DETAIL_TEXT' => "[URL=http://" . $_SERVER['HTTP_HOST'] . $arResult["ELEMENT"]["~DETAIL_PAGE_URL"] . "]" . $arResult["ELEMENT"]["~NAME"] . "[/URL]\n" . ($arResult["ELEMENT"]["~PREVIEW_TEXT"] != '' ? $arResult["ELEMENT"]["~PREVIEW_TEXT"] : '') . "\n", 'PUBLISH_STATUS' => BLOG_PUBLISH_STATUS_PUBLISH, "PERMS_POST" => array(), "PERMS_COMMENT" => array(), "=DATE_CREATE" => $DB->GetNowFunction(), "=DATE_PUBLISH" => $DB->GetNowFunction(), "AUTHOR_ID" => $ownerID, "BLOG_ID" => $arResult['BLOG_DATA']['BLOG_ID'], "ENABLE_TRACKBACK" => "N");
$postID = (int) CBlogPost::Add($arFields);
if ($postID > 0) {
CIBlockElement::SetPropertyValues($arResult['ELEMENT']['ID'], $arResult['ELEMENT']['IBLOCK_ID'], $postID, $arResult['BLOG_DATA']['BLOG_POST_ID_PROP']);
}
}
$arResult['BLOG_DATA']['BLOG_POST_ID'] = $postID;
$arResult['COMMENT_ID'] = $postID;
}
$protocol = CMain::IsHTTPS() ? 'https://' : 'http://';
if ($arParams['URL_TO_COMMENT'] !== '') {
$arResult['URL_TO_COMMENT'] = $arParams['URL_TO_COMMENT'];
} elseif (!empty($arResult['ELEMENT']['~DETAIL_PAGE_URL'])) {
$arResult['URL_TO_COMMENT'] = $protocol . $_SERVER["HTTP_HOST"] . $arResult['ELEMENT']['~DETAIL_PAGE_URL'];
} else {
$arResult['URL_TO_COMMENT'] = $protocol . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
}
示例8: AddComment_Review_CreateRoot_Blog
function AddComment_Review_CreateRoot_Blog($arElement, $blogID)
{
if (!CModule::IncludeModule("blog")) {
return false;
}
$arBlog = CBlog::GetByID($blogID);
$arElement["DETAIL_PICTURE"] = CFile::GetFileArray($arElement["DETAIL_PICTURE"]);
$arElement["REAL_PICTURE"] = CFile::GetFileArray($arElement["PROPERTY_REAL_PICTURE_VALUE"]);
if (!empty($arElement["TAGS"])) {
$arCategoryVal = explode(",", $arElement["TAGS"]);
foreach ($arCategoryVal as $k => $v) {
if ($id = CBlogCategory::Add(array("BLOG_ID" => $arBlog["ID"], "NAME" => $v))) {
$arCategory[] = $id;
}
}
}
$arFields = array("TITLE" => $arElement["NAME"], "DETAIL_TEXT" => "[IMG]http://" . $_SERVER['HTTP_HOST'] . $arElement["DETAIL_PICTURE"]["SRC"] . "[/IMG]\n" . "[URL=http://" . $_SERVER['HTTP_HOST'] . $arElement["~DETAIL_PAGE_URL"] . "]" . $arElement["NAME"] . "[/URL]\n" . (!empty($arElement["TAGS"]) ? $arElement["TAGS"] . "\n" : "") . $arElement["~DETAIL_TEXT"] . "\n" . "[URL=http://" . $_SERVER['HTTP_HOST'] . $arElement["REAL_PICTURE"]["SRC"] . "]" . GetMessage("P_ORIGINAL") . "[/URL]", "CATEGORY_ID" => implode(",", $arCategory), "PUBLISH_STATUS" => "P", "PERMS_POST" => array(), "PERMS_COMMENT" => array(), "=DATE_CREATE" => $GLOBALS["DB"]->GetNowFunction(), "=DATE_PUBLISH" => $GLOBALS["DB"]->GetNowFunction(), "AUTHOR_ID" => !empty($arElement["CREATED_BY"]) ? $arElement["CREATED_BY"] : 1, "BLOG_ID" => $arBlog["ID"], "ENABLE_TRACKBACK" => "N");
$POST_ID = CBlogPost::Add($arFields);
return $POST_ID;
}
示例9: htmlspecialcharsBack
$pathTemplate = htmlspecialcharsBack($arParams["PATH_TO_POST"]);
$pathTemplateEdit = htmlspecialcharsBack($arParams["PATH_TO_POST_EDIT"]);
$pathTemplateDraft = htmlspecialcharsBack($arParams["PATH_TO_DRAFT"]);
$pathTemplateBlog = htmlspecialcharsBack($arParams["PATH_TO_BLOG"]);
//take from new params
$pathTemplate = htmlspecialcharsBack($arParams["PATH_TO_BLOG_POST"]);
$pathTemplateEdit = htmlspecialcharsBack($arParams["PATH_TO_BLOG_POST_EDIT"]);
$pathTemplateDraft = htmlspecialcharsBack($arParams["PATH_TO_BLOG_DRAFT"]);
$pathTemplateBlog = htmlspecialcharsBack($arParams["PATH_TO_BLOG_BLOG"]);
$arCopyPost["PATH"] = CComponentEngine::MakePathFromTemplate($pathTemplate, array("blog" => $arCopyBlog["URL"], "post_id" => "#post_id#", "user_id" => $arCopyBlog["OWNER_ID"]));
$arCopyPost["PERMS_POST"] = array();
$arCopyPost["PERMS_COMMENT"] = array();
if ($copyPerms == BLOG_PERMS_PREMODERATE) {
$arCopyPost["PUBLISH_STATUS"] = BLOG_PUBLISH_STATUS_READY;
}
if ($copyID = CBlogPost::Add($arCopyPost)) {
$arCopyPostUpdate = array();
//images
$arCopyImg = array();
$arPat = array();
$arRep = array();
$arFilter = array("POST_ID" => $arParams["ID"], "BLOG_ID" => $arBlog["ID"], "IS_COMMENT" => "N");
$res = CBlogImage::GetList(array("ID" => "ASC"), $arFilter);
while ($arImg = $res->GetNext()) {
$arNewImg = array("FILE_ID" => CFile::MakeFileArray($arImg["FILE_ID"]));
$arNewImg["BLOG_ID"] = $arCopyBlog["ID"];
$arNewImg["POST_ID"] = $copyID;
$arNewImg["USER_ID"] = $arImg["USER_ID"];
$arNewImg["=TIMESTAMP_X"] = $DB->GetNowFunction();
$arNewImg["TITLE"] = $arImg["TITLE"];
$arNewImg["MODULE_ID"] = "blog";
示例10: array
continue;
}
$arImageFields = array("BLOG_ID" => $blogID, "POST_ID" => 0, "USER_ID" => $arUser["ID"], "=TIMESTAMP_X" => $DB->GetNowFunction(), "TITLE" => $file, "IMAGE_SIZE" => $arImages[$file]["size"], "FILE_ID" => $arImages[$file] + array("MODULE_ID" => "blog", "del" => "Y"));
$image_replacement[$key_match] = "";
if ($imgID = CBlogImage::Add($arImageFields)) {
$image_replacement[$key_match] = "[IMG ID=" . $imgID . "]";
$arImagesToUpdate[] = $imgID;
}
}
$arPost["DETAIL_TEXT"] = str_replace($arMatches[0], $image_replacement, $arPost["DETAIL_TEXT"]);
}
// POST
$arPost["BLOG_ID"] = $blogID;
$arPost["AUTHOR_ID"] = $arUser["ID"];
$arPost["CATEGORY_ID"] = implode(",", $iCategory);
$postID = CBlogPost::Add($arPost);
// posts to socialnetwork log
if (CModule::IncludeModule("socialnetwork")) {
$arPost["ID"] = $postID;
$arParams = array("UserID" => $arUser["ID"], "allowHTML" => "N", "allowVideo" => "Y", "PATH_TO_SMILE" => false, "PATH_TO_POST" => WIZARD_SITE_DIR . 'people/user/#user_id#/blog/#post_id#/', "user_id" => $arUser["ID"]);
$arBlog = CBlog::GetByID($blogID);
if ($arPost["ID"]) {
$parserBlog = new blogTextParser(false, $arParams["PATH_TO_SMILE"]);
if ($arPost["DETAIL_TEXT_TYPE"] == "html" && $arParams["allowHTML"] == "Y" && $arBlog["ALLOW_HTML"] == "Y") {
$arAllow = array("HTML" => "Y", "ANCHOR" => "Y", "IMG" => "Y", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "Y", "QUOTE" => "Y", "CODE" => "Y");
if ($arParams["allowVideo"] != "Y") {
$arAllow["VIDEO"] = "N";
}
$text4message = $parserBlog->convert($arPost["DETAIL_TEXT"], false, $arImages, $arAllow);
} else {
$arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "TABLE" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "N");
示例11: GetMessage
$arImage = CFile::MakeFileArray(dirname(__FILE__) . '/images/' . GetMessage("BLOG_DEMO_IMG"));
$arImage["MODULE_ID"] = "blog";
$arFields = array("BLOG_ID" => $blogID, "POST_ID" => $postID, "USER_ID" => 1, "=TIMESTAMP_X" => $DB->GetNowFunction(), "TITLE" => GetMessage("BLOG_DEMO_IMG_TITLE"), "IMAGE_SIZE" => $arImage["size"], "FILE_ID" => $arImage);
CBlogImage::Add($arFields);
CBlogComment::Add(array("TITLE" => GetMessage("BLOG_DEMO_COMMENT_TITLE"), "POST_TEXT" => GetMessage("BLOG_DEMO_COMMENT_BODY"), "BLOG_ID" => $blogID, "POST_ID" => $postID, "PARENT_ID" => 0, "AUTHOR_ID" => 1, "DATE_CREATE" => ConvertTimeStamp(false, "FULL"), "AUTHOR_IP" => "192.168.0.108"));
CBlogSitePath::Add(array("SITE_ID" => $siteID, "PATH" => "/communication/blog/#blog#/", "TYPE" => "B"));
CBlogSitePath::Add(array("SITE_ID" => $siteID, "PATH" => "/communication/blog/#blog#/#post_id#.php", "TYPE" => "P"));
CBlogSitePath::Add(array("SITE_ID" => $siteID, "PATH" => "/communication/blog/user/#user_id#.php", "TYPE" => "U"));
if (IsModuleInstalled("socialnetwork")) {
$rsUser = CUser::GetByID(1);
$arUser = $rsUser->Fetch();
$blogID = CBlog::Add(array("NAME" => GetMessage("BLG_NAME") . " " . $arUser["NAME"] . " " . $arUser["LAST_NAME"], "DESCRIPTION" => "", "GROUP_ID" => $SocNetGroupID, "ENABLE_IMG_VERIF" => 'Y', "EMAIL_NOTIFY" => 'Y', "USE_SOCNET" => 'Y', "ENABLE_RSS" => "Y", "ALLOW_HTML" => "Y", "URL" => str_replace(" ", "_", $arUser["LOGIN"]) . "-blog", "ACTIVE" => "Y", "=DATE_CREATE" => $DB->GetNowFunction(), "=DATE_UPDATE" => $DB->GetNowFunction(), "OWNER_ID" => 1, "PERMS_POST" => array("1" => BLOG_PERMS_READ, "2" => BLOG_PERMS_READ), "PERMS_COMMENT" => array("1" => BLOG_PERMS_WRITE, "2" => BLOG_PERMS_WRITE)));
CBlog::AddSocnetRead($blogID);
$categoryID[] = CBlogCategory::Add(array("BLOG_ID" => $blogID, "NAME" => GetMessage("BLOG_DEMO_CATEGORY_1")));
$categoryID[] = CBlogCategory::Add(array("BLOG_ID" => $blogID, "NAME" => GetMessage("BLOG_DEMO_CATEGORY_2")));
$postID = CBlogPost::Add(array("TITLE" => GetMessage("BLOG_DEMO_MESSAGE_TITLE_1"), "DETAIL_TEXT" => str_replace('[IMG ID=1]', "[IMG ID=2]", GetMessage("BLOG_DEMO_MESSAGE_BODY_1")), "DETAIL_TEXT_TYPE" => "text", "BLOG_ID" => $blogID, "AUTHOR_ID" => 1, "=DATE_CREATE" => $DB->GetNowFunction(), "=DATE_PUBLISH" => $DB->GetNowFunction(), "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH, "ENABLE_TRACKBACK" => 'N', "ENABLE_COMMENTS" => 'Y', "CATEGORY_ID" => implode(",", $categoryID), "PERMS_P" => array(1 => BLOG_PERMS_READ, 2 => BLOG_PERMS_READ), "PERMS_C" => array(1 => BLOG_PERMS_WRITE, 2 => BLOG_PERMS_WRITE)));
foreach ($categoryID as $v) {
CBlogPostCategory::Add(array("BLOG_ID" => $blogID, "POST_ID" => $postID, "CATEGORY_ID" => $v));
}
$arImage = CFile::MakeFileArray(dirname(__FILE__) . '/images/' . GetMessage("BLOG_DEMO_IMG"));
$arImage["MODULE_ID"] = "blog";
$arFields = array("BLOG_ID" => $blogID, "POST_ID" => $postID, "USER_ID" => 1, "=TIMESTAMP_X" => $DB->GetNowFunction(), "TITLE" => GetMessage("BLOG_DEMO_IMG_TITLE"), "IMAGE_SIZE" => $arImage["size"], "FILE_ID" => $arImage);
CBlogImage::Add($arFields);
CBlogComment::Add(array("TITLE" => GetMessage("BLOG_DEMO_COMMENT_TITLE"), "POST_TEXT" => GetMessage("BLOG_DEMO_COMMENT_BODY"), "BLOG_ID" => $blogID, "POST_ID" => $postID, "PARENT_ID" => 0, "AUTHOR_ID" => 1, "DATE_CREATE" => ConvertTimeStamp(false, "FULL"), "AUTHOR_IP" => "192.168.0.108", "PERMS_P" => array(), "PERMS_C" => array()));
}
}
DemoSiteUtil::AddMenuItem("/communication/.left.menu.php", array(GetMessage("BLOG_DEMO_LEFT_MENU_1"), "/communication/blog/", array(), array(), ""));
/*
DemoSiteUtil::AddMenuItem("/communication/blog/.left.menu.php", Array(
GetMessage("BLOG_DEMO_LEFT_MENU_2"),
"/communication/blog/index.php",