本文整理汇总了PHP中CBlogImage::GetByID方法的典型用法代码示例。如果您正苦于以下问题:PHP CBlogImage::GetByID方法的具体用法?PHP CBlogImage::GetByID怎么用?PHP CBlogImage::GetByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBlogImage
的用法示例。
在下文中一共展示了CBlogImage::GetByID方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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>
//.........这里部分代码省略.........
示例2: convert_blog_image
function convert_blog_image($p1 = "", $imageId = "", $p2 = "", $type = "html", $serverName = "")
{
$imageId = IntVal($imageId);
if ($imageId <= 0) {
return;
}
$res = "";
if (IntVal($this->arImages[$imageId]) > 0) {
if ($f = CBlogImage::GetByID($imageId)) {
if ($db_img_arr = CFile::GetFileArray($this->arImages[$imageId])) {
$strImage = $db_img_arr["SRC"];
$strPar = "";
preg_match("/width\\=([0-9]+)/is" . BX_UTF_PCRE_MODIFIER, $p1, $width);
preg_match("/height\\=([0-9]+)/is" . BX_UTF_PCRE_MODIFIER, $p1, $height);
$width = intval($width[1]);
$height = intval($height[1]);
if ($width <= 0) {
preg_match("/width\\=([0-9]+)/is" . BX_UTF_PCRE_MODIFIER, $p2, $width);
$width = intval($width[1]);
}
if ($height <= 0) {
preg_match("/height\\=([0-9]+)/is" . BX_UTF_PCRE_MODIFIER, $p2, $height);
$height = intval($height[1]);
}
if (IntVal($width) <= 0) {
$width = $db_img_arr["WIDTH"];
}
if (IntVal($height) <= 0) {
$height = $db_img_arr["HEIGHT"];
}
if ($width > $this->imageWidth || $height > $this->imageHeight) {
$arFileTmp = CFile::ResizeImageGet($db_img_arr, array("width" => $this->imageWidth, "height" => $this->imageHeight), BX_RESIZE_IMAGE_PROPORTIONAL, true);
if (substr($arFileTmp["src"], 0, 1) == "/") {
$strImage = $serverName . $arFileTmp["src"];
} else {
$strImage = $arFileTmp["src"];
}
$width = $arFileTmp["width"];
$height = $arFileTmp["height"];
}
$strPar = ' width="' . $width . '" height="' . $height . '"';
$res = '<img src="' . $strImage . '" title="' . $f["TITLE"] . '" border="0"' . $strPar . '/>';
}
}
}
return $res;
}
示例3: Delete
function Delete($ID)
{
global $DB;
$ID = IntVal($ID);
unset($GLOBALS["BLOG_IMAGE"]["BLOG_IMAGE_CACHE_" . $ID]);
if ($res = CBlogImage::GetByID($ID)) {
CFile::Delete($res['FILE_ID']);
return $DB->Query("DELETE FROM b_blog_image WHERE ID = " . $ID, true);
}
return false;
}
示例4: convert_blog_image
function convert_blog_image($p1 = "", $imageId = "", $p2 = "", $type = "html", $serverName="")
{
$imageId = IntVal($imageId);
if($imageId <= 0)
return;
$res = "";
if(IntVal($this->arImages[$imageId]) > 0)
{
$this->showedImages[] = $imageId;
if($f = CBlogImage::GetByID($imageId))
{
if(COption::GetOptionString("blog", "use_image_perm", "N") == "N")
{
if($db_img_arr = CFile::GetFileArray($this->arImages[$imageId]))
{
if(substr($db_img_arr["SRC"], 0, 1) == "/")
$strImage = $this->serverName.$db_img_arr["SRC"];
else
$strImage = $db_img_arr["SRC"];
$sourceImage = $strImage;
$strPar = "";
preg_match("/width\=([0-9]+)/is".BX_UTF_PCRE_MODIFIER, $p1, $width);
preg_match("/height\=([0-9]+)/is".BX_UTF_PCRE_MODIFIER, $p1, $height);
$width = intval($width[1]);
$height = intval($height[1]);
if($width <= 0)
{
preg_match("/width\=([0-9]+)/is".BX_UTF_PCRE_MODIFIER, $p2, $width);
$width = intval($width[1]);
}
if($height <= 0)
{
preg_match("/height\=([0-9]+)/is".BX_UTF_PCRE_MODIFIER, $p2, $height);
$height = intval($height[1]);
}
if(IntVal($width) <= 0)
$width = $db_img_arr["WIDTH"];
if(IntVal($height) <= 0)
$height= $db_img_arr["HEIGHT"];
if($width > $this->imageWidth || $height > $this->imageHeight)
{
$arFileTmp = CFile::ResizeImageGet(
$db_img_arr,
array("width" => $this->imageWidth, "height" => $this->imageHeight),
BX_RESIZE_IMAGE_PROPORTIONAL,
true
);
if(substr($arFileTmp["src"], 0, 1) == "/")
$strImage = $this->serverName.$arFileTmp["src"];
else
$strImage = $arFileTmp["src"];
$width = $arFileTmp["width"];
$height = $arFileTmp["height"];
}
$strPar = ' width="'.$width.'" height="'.$height.'"';
$strImage = preg_replace("'(?<!:)/+'s", "/", $strImage);
$sourceImage = preg_replace("'(?<!:)/+'s", "/", $sourceImage);
if(strlen($this->authorName) > 0)
$strPar .= " data-bx-title=\"".$this->authorName."\"";
if ($this->isSonetLog)
{
$strImage = preg_replace("'(?<!:)/+'s", "/", $strImage);
$res = '[IMG]'.$strImage.'[/IMG]';
}
else
{
if($type == "mail")
$res = htmlspecialcharsbx($f["TITLE"])." (IMAGE: ".$strImage." )";
else
$res = '<img src="'.$strImage.'" title="" alt="'.htmlspecialcharsbx($f["TITLE"]).'" border="0"'.$strPar.' data-bx-image="'.$sourceImage.'" />';
}
}
}
else
{
preg_match("/width\=([0-9]+)/is".BX_UTF_PCRE_MODIFIER, $p1, $width);
preg_match("/height\=([0-9]+)/is".BX_UTF_PCRE_MODIFIER, $p1, $height);
$width = intval($width[1]);
$height = intval($height[1]);
if($width <= 0)
{
preg_match("/width\=([0-9]+)/is".BX_UTF_PCRE_MODIFIER, $p2, $width);
$width = intval($width[1]);
}
if($height <= 0)
{
preg_match("/height\=([0-9]+)/is".BX_UTF_PCRE_MODIFIER, $p2, $height);
$height = intval($height[1]);
}
//.........这里部分代码省略.........
示例5: isset
}
$arParams["WIDTH"] = isset($_REQUEST['width']) && intval($_REQUEST['width']) > 0 ? intval($_REQUEST['width']) : 0;
$arParams["HEIGHT"] = isset($_REQUEST['height']) && intval($_REQUEST['height']) > 0 ? intval($_REQUEST['height']) : 0;
$arParams["FILE_ID"] = IntVal($_REQUEST["fid"]);
$arParams["BP_FILE_ID"] = IntVal($_REQUEST["bp_fid"]);
$arParams["PERMISSION"] = false;
$arParams["QUALITY"] = isset($_REQUEST['mobile']) && $_REQUEST["mobile"] == "y" ? "50" : false;
$arResult = array();
$arResult["MESSAGE"] = array();
$arResult["FILE"] = array();
$arResult["POST"] = array();
$arResult["FILE_INFO"] = array();
$user_id = IntVal($USER->GetID());
$arError = array();
if (intVal($arParams["FILE_ID"]) > 0) {
if ($res = CBlogImage::GetByID($arParams["FILE_ID"])) {
$arResult["FILE_INFO"] = $res;
$arResult["FILE"] = CFile::GetFileArray($arResult["FILE_INFO"]["FILE_ID"]);
}
} elseif (intVal($arParams["BP_FILE_ID"]) > 0) {
$arResult["FILE"] = CFile::GetFileArray(intVal($arParams['BP_FILE_ID']));
if (!empty($arResult["FILE"])) {
$dbPost = CBlogPost::GetList(array(), array('UF_BLOG_POST_DOC' => intVal($arParams['BP_FILE_ID'])));
if ($dbPost && ($arPost = $dbPost->Fetch())) {
$arResult["FILE_INFO"] = array('POST_ID' => $arPost['ID'], 'BLOG_ID' => $arPost['BLOG_ID']);
} else {
$dbPost = CBlogComment::GetList(array(), array('UF_BLOG_COMMENT_DOC' => intVal($arParams['BP_FILE_ID'])));
if ($dbPost && ($arPost = $dbPost->Fetch())) {
$arResult["FILE_INFO"] = array('POST_ID' => $arPost['POST_ID'], 'BLOG_ID' => $arPost['BLOG_ID']);
}
}