当前位置: 首页>>代码示例>>PHP>>正文


PHP CBlogImage::Add方法代码示例

本文整理汇总了PHP中CBlogImage::Add方法的典型用法代码示例。如果您正苦于以下问题:PHP CBlogImage::Add方法的具体用法?PHP CBlogImage::Add怎么用?PHP CBlogImage::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CBlogImage的用法示例。


在下文中一共展示了CBlogImage::Add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: NewMediaObject

    function NewMediaObject($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]["#"]);
        $arImage = $params[3]["#"]["value"][0]["#"]["struct"][0]["#"]["member"];
        foreach ($arImage as $val) {
            $arImageInfo[$val["#"]["name"][0]["#"]] = CBlogMetaWeblog::DecodeParams($val["#"]["value"][0]["#"]);
        }
        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"));
                if ($arBlog = $dbBlog->GetNext()) {
                    $filename = trim(str_replace("\\", "/", trim($arImageInfo["name"])), "/");
                    $DIR_NAME = CTempFile::GetDirectoryName(12);
                    $FILE_NAME = rel2abs($DIR_NAME, "/" . $filename);
                    if (strlen($FILE_NAME) > 1 && $FILE_NAME === "/" . $filename) {
                        $ABS_FILE_NAME = $DIR_NAME . $FILE_NAME;
                    } else {
                        $ABS_FILE_NAME = "";
                    }
                    CheckDirPath($DIR_NAME);
                    if (strlen($ABS_FILE_NAME) > 0 && ($fp = fopen($ABS_FILE_NAME, "ab"))) {
                        $result = fwrite($fp, $arImageInfo["bits"]);
                        if ($result !== (function_exists("mb_strlen") ? mb_strlen($arImageInfo["bits"], 'latin1') : strlen($arImageInfo["bits"]))) {
                            return '<fault>
									<value>
										<struct>
											<member>
												<name>faultCode</name>
												<value><int>3</int></value>
												</member>
											<member>
												<name>faultString</name>
												<value><string>Error on saving media object</string></value>
												</member>
											</struct>
										</value>
									</fault>';
                        }
                        fclose($fp);
                    } else {
                        return '<fault>
								<value>
									<struct>
										<member>
											<name>faultCode</name>
											<value><int>3</int></value>
											</member>
										<member>
											<name>faultString</name>
											<value><string>Error on saving media object</string></value>
											</member>
										</struct>
									</value>
								</fault>';
                    }
                    $arFields = array("BLOG_ID" => $arBlog["ID"], "USER_ID" => $userId, "=TIMESTAMP_X" => $DB->GetNowFunction(), "FILE_ID" => array("name" => $arImageInfo["name"], "tmp_name" => $ABS_FILE_NAME, "MODULE_ID" => "blog", "type" => $arImageInfo["type"]));
                    $imageId = CBlogImage::Add($arFields);
                    $arImg = CBlogImage::GetByID($imageId);
                    $arFile = CFile::GetFileArray($arImg["FILE_ID"]);
                    $path = $arFile["SRC"];
                    $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");
                        }
                    }
                    if (strlen($path) > 0) {
                        return '<params>
							<param>
								<value>
									<struct>
									<member>
									<name>url</name>
									<value>
									<string>' . CHTTP::URN2URI($path, $serverName) . '</string>
									</value>
									</member>
									</struct>
								</value>
							</param>
						</params>';
                    }
                }
            }
            return '<fault>
				<value>
					<struct>
						<member>
							<name>faultCode</name>
							<value><int>3</int></value>
							</member>
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:blog_metaweblog.php

示例2: array

 $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";
     if ($imgID = CBlogImage::Add($arNewImg)) {
         $arPat[] = "[IMG ID=" . $arImg["ID"] . "]";
         $arRep[] = "[IMG ID=" . $imgID . "]";
     }
 }
 if (!empty($arRep)) {
     $arCopyPostUpdate["DETAIL_TEXT"] = str_replace($arPat, $arRep, $arCopyPost["DETAIL_TEXT"]);
 }
 //tags
 $arCopyCat = array();
 $dbCategory = CBlogCategory::GetList(array(), array("BLOG_ID" => $arCopyBlog["ID"]));
 while ($arCategory = $dbCategory->Fetch()) {
     $arCatBlogCopy[ToLower($arCategory["NAME"])] = $arCategory["ID"];
 }
 $dbCat = CBlogPostCategory::GetList(array("NAME" => "ASC"), array("BLOG_ID" => $arBlog["ID"], "POST_ID" => $arParams["ID"]));
 while ($arCat = $dbCat->Fetch()) {
开发者ID:rasuldev,项目名称:torino,代码行数:31,代码来源:component.php

示例3: array_merge

 }
 $fieldName = 'UF_BLOG_COMMENT_DOC';
 $arPostFields = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("BLOG_COMMENT", $commentID, LANGUAGE_ID);
 if (isset($GLOBALS[$fieldName]) && is_array($GLOBALS[$fieldName])) {
     $checkArray = $_SESSION["MFI_UPLOADED_FILES_" . $_POST["blog_upload_cid"]];
     $checkArray = array_merge(is_array($checkArray) ? $checkArray : array(), isset($arPostFields["UF_BLOG_COMMENT_DOC"]) ? $arPostFields["UF_BLOG_COMMENT_DOC"]["VALUE"] : array());
     $arAttachedFiles = array();
     foreach ($GLOBALS[$fieldName] as $fileID) {
         $fileID = intval($fileID);
         if ($fileID <= 0 || !in_array($fileID, $checkArray)) {
             continue;
         }
         $arFile = CFile::GetFileArray($fileID);
         if (CFile::CheckImageFile(CFile::MakeFileArray($fileID)) === null) {
             $arImgFields = array("BLOG_ID" => $arBlog["ID"], "POST_ID" => $arPost["ID"], "USER_ID" => IntVal($user_id), "COMMENT_ID" => $commentID, "=TIMESTAMP_X" => $DB->GetNowFunction(), "TITLE" => $arFile["FILE_NAME"], "IMAGE_SIZE" => $arFile["FILE_SIZE"], "FILE_ID" => $fileID, "IS_COMMENT" => "Y", "URL" => $arBlog["URL"], "IMAGE_SIZE_CHECK" => "N");
             $imgID = CBlogImage::Add($arImgFields);
             if (intval($imgID) <= 0) {
                 $GLOBALS["APPLICATION"]->ThrowException("Error Adding file by CBlogImage::Add");
             } else {
                 $arFields["POST_TEXT"] = str_replace("[IMG ID=" . $fileID . "file", "[IMG ID=" . $imgID . "", $arFields["POST_TEXT"]);
             }
         } else {
             $arAttachedFiles[] = $fileID;
         }
     }
     $GLOBALS[$fieldName] = $arAttachedFiles;
 }
 CSocNetLogComponent::checkEmptyUFValue('UF_BLOG_COMMENT_FILE');
 if (count($arParams["COMMENT_PROPERTY"]) > 0) {
     $GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("BLOG_COMMENT", $arFields);
 }
开发者ID:webgksupport,项目名称:alpina,代码行数:31,代码来源:component.php

示例4: GetMessage

    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", 
	Array(), 
	Array(), 
	"" 
));	
*/
$source_base = dirname(__FILE__);
CopyDirFiles($source_base . "/public/" . $LID, $_SERVER["DOCUMENT_ROOT"] . "/communication/blog", true, true);
开发者ID:Satariall,项目名称:izurit,代码行数:31,代码来源:index.php


注:本文中的CBlogImage::Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。