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


PHP CFile::SaveFile方法代码示例

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


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

示例1: send

 /**
  * @param array $data
  * @return Main\Entity\AddResult
  */
 public static function send(array $data)
 {
     $manageCache = Application::getInstance()->getManagedCache();
     if (CACHED_b_event !== false && $manageCache->read(CACHED_b_event, "events")) {
         $manageCache->clean('events');
     }
     $arFiles = array();
     if (isset($data['FILE'])) {
         if (is_array($data['FILE'])) {
             $arFiles = $data['FILE'];
         }
         unset($data['FILE']);
     }
     $result = MailInternal\EventTable::add($data);
     if ($result->isSuccess()) {
         $id = $result->getId();
         foreach ($arFiles as $file) {
             $arFile = \CFile::MakeFileArray($file);
             $arFile["MODULE_ID"] = "main";
             $fid = \CFile::SaveFile($arFile, "main");
             $dataAttachment = array('EVENT_ID' => $id, 'FILE_ID' => $fid);
             MailInternal\EventAttachmentTable::add($dataAttachment);
         }
     }
     return $result;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:30,代码来源:event.php

示例2: createByTemporaryPath

 /**
  * @param $path
  * @return \WS\Tools\ORM\BitrixEntity\File|null
  * @throws \Exception
  */
 public function createByTemporaryPath($path)
 {
     $file = \CFile::MakeFileArray($path);
     $fileId = \CFile::SaveFile($file, '/upload/');
     if ($fileId) {
         $filter = $this->createFilter()->equal('id', $fileId)->toArray();
         return $this->findOne($filter);
     }
     return null;
 }
开发者ID:Under5,项目名称:bitrix-module-tools,代码行数:15,代码来源:file.php

示例3: SaveFile

 public static function SaveFile($arFile, $arFileStorage)
 {
     $arResult = array();
     if (empty($arFile)) {
         $arResult = array("ERROR_CODE" => "EMPTY_FILE", "ERROR_MESSAGE" => "File is empty");
     }
     if (!empty($arFileStorage["DISC_FOLDER"])) {
         $file = $arFileStorage["DISC_FOLDER"]->uploadFile($arFile, array('NAME' => $arFile["name"], 'CREATED_BY' => $GLOBALS["USER"]->GetID()), array(), true);
         $arResult["ID"] = $file->getId();
     } elseif (!empty($arFileStorage["WEBDAV_DATA"]) && !empty($arFileStorage["WEBDAV_IBLOCK_OBJECT"])) {
         $dropTargetID = $arFileStorage["WEBDAV_IBLOCK_OBJECT"]->GetMetaID("DROPPED");
         $arParent = $arFileStorage["WEBDAV_IBLOCK_OBJECT"]->GetObject(array("section_id" => $dropTargetID));
         if (!$arParent["not_found"]) {
             $path = $arFileStorage["WEBDAV_IBLOCK_OBJECT"]->_get_path($arParent["item_id"], false);
             $tmpName = str_replace(array(":", ".", "/", "\\"), "_", ConvertTimeStamp(time(), "FULL"));
             $tmpOptions = array("path" => str_replace("//", "/", $path . "/" . $tmpName));
             $arParent = $arFileStorage["WEBDAV_IBLOCK_OBJECT"]->GetObject($tmpOptions);
             if ($arParent["not_found"]) {
                 $rMKCOL = $arFileStorage["WEBDAV_IBLOCK_OBJECT"]->MKCOL($tmpOptions);
                 if (intval($rMKCOL) == 201) {
                     $arFileStorage["WEBDAV_DATA"]["SECTION_ID"] = $arFileStorage["WEBDAV_IBLOCK_OBJECT"]->arParams["changed_element_id"];
                 }
             } else {
                 $arFileStorage["WEBDAV_DATA"]["SECTION_ID"] = $arParent['item_id'];
                 if (!$arFileStorage["WEBDAV_IBLOCK_OBJECT"]->CheckUniqueName($tmpName, $arFileStorage["WEBDAV_DATA"]["SECTION_ID"], $tmpRes)) {
                     $path = $arFileStorage["WEBDAV_IBLOCK_OBJECT"]->_get_path($arFileStorage["WEBDAV_DATA"]["SECTION_ID"], false);
                     $tmpName = randString(6);
                     $tmpOptions = array("path" => str_replace("//", "/", $path . "/" . $tmpName));
                     $rMKCOL = $arFileStorage["WEBDAV_IBLOCK_OBJECT"]->MKCOL($tmpOptions);
                     if (intval($rMKCOL) == 201) {
                         $arFileStorage["WEBDAV_DATA"]["SECTION_ID"] = $arFileStorage["WEBDAV_IBLOCK_OBJECT"]->arParams["changed_element_id"];
                     }
                 }
             }
         }
         $options = array("new" => true, 'dropped' => true, "arFile" => $arFile, "arDocumentStates" => false, "arUserGroups" => array_merge($arFileStorage["WEBDAV_IBLOCK_OBJECT"]->USER["GROUPS"], array("Author")), "FILE_NAME" => $arFile["name"], "IBLOCK_ID" => $arFileStorage["WEBDAV_DATA"]["IBLOCK_ID"], "IBLOCK_SECTION_ID" => $arFileStorage["WEBDAV_DATA"]["SECTION_ID"], "USER_FIELDS" => array());
         $GLOBALS['USER_FIELD_MANAGER']->EditFormAddFields($arFileStorage["WEBDAV_IBLOCK_OBJECT"]->GetUfEntity(), $options['USER_FIELDS']);
         $GLOBALS["DB"]->StartTransaction();
         if (!$arFileStorage["WEBDAV_IBLOCK_OBJECT"]->put_commit($options)) {
             $arResult = array("ERROR_CODE" => "error_put", "ERROR_MESSAGE" => $arFileStorage["WEBDAV_IBLOCK_OBJECT"]->LAST_ERROR);
             $GLOBALS["DB"]->Rollback();
         } else {
             $GLOBALS["DB"]->Commit();
             $arResult["ID"] = $options['ELEMENT_ID'];
         }
     } else {
         $arResult["ID"] = CFile::SaveFile($arFile, $arFile["MODULE_ID"]);
     }
     return $arResult;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:50,代码来源:mobile_helper.php

示例4: SaveForDB

 function SaveForDB(&$arFields, $field, $strSavePath)
 {
     $arFile = $arFields[$field];
     if (isset($arFile) && is_array($arFile)) {
         if ($arFile["name"] != '' || $arFile["del"] != '' || array_key_exists("description", $arFile)) {
             $res = CFile::SaveFile($arFile, $strSavePath);
             if ($res !== false) {
                 $arFields[$field] = intval($res) > 0 ? $res : false;
                 return true;
             }
         }
     }
     unset($arFields[$field]);
     return false;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:15,代码来源:file.php

示例5: saveToBXFile

 /**
  * Возвращает -1 в случае ошибки кода битркс и кдиает исключение в случае ошибки obx.core
  * -1 - очень маловероятная ситуация
  * @param string $relUploadDirPath
  * @param int $oldFileID
  * @param string $description
  * @param string $MODULE_ID
  * @throws RequestError
  * @return int
  */
 public function saveToBXFile($relUploadDirPath, $oldFileID = 0, $description = '', $MODULE_ID = null)
 {
     $relUploadDirPath = str_replace(array('\\', '//'), '/', $relUploadDirPath);
     $relUploadDirPath = trim($relUploadDirPath, '/');
     if (strpos($relUploadDirPath, 'upload/') === 0) {
         $relUploadDirPath = substr($relUploadDirPath, 7);
     }
     $relPath = '/upload/' . $relUploadDirPath;
     $path = OBX_DOC_ROOT . $relPath;
     if (!CheckDirPath($path)) {
         throw new RequestError('', RequestError::E_PERM_DENIED);
     }
     $fileID = -1;
     $oldFileID = intval($oldFileID);
     if ($this->_bDownloadSuccess || $this->_bRequestSuccess) {
         if (!CheckDirPath(OBX_DOC_ROOT . static::DOWNLOAD_FOLDER . '/' . $this->_ID)) {
             throw new RequestError('', RequestError::E_PERM_DENIED);
         }
         $downloadFileRelPath = $this->getDownloadFilePath(false);
         if ($this->_bDownloadSuccess) {
             $arFile = \CFile::MakeFileArray($downloadFileRelPath);
         } elseif ($this->_bRequestSuccess) {
             $this->saveToFile($downloadFileRelPath);
             $this->_saveFileName = null;
             $this->_saveRelPath = null;
             $this->_savePath = null;
             $arFile = \CFile::MakeFileArray($downloadFileRelPath);
         }
         $arFile['name'] = $this->_originalName . '.' . $this->_originalExt;
         if ($oldFileID > 0) {
             $arFile['old_file'] = $oldFileID;
         }
         if (is_string($description) && !empty($description)) {
             $arFile['description'] = $description;
         }
         if (null !== $MODULE_ID && IsModuleInstalled($MODULE_ID)) {
             $arFile['MODULE_ID'] = $MODULE_ID;
         }
         $fileID = \CFile::SaveFile($arFile, $relUploadDirPath);
     }
     return $fileID;
 }
开发者ID:OpenBX,项目名称:obx.core,代码行数:52,代码来源:requestbxfile.php

示例6: send

 /**
  * @param array $data
  * @return Main\Entity\AddResult
  */
 public static function send(array $data)
 {
     $arFiles = array();
     if (isset($data['FILE'])) {
         if (is_array($data['FILE'])) {
             $arFiles = $data['FILE'];
         }
         unset($data['FILE']);
     }
     $result = MailInternal\EventTable::add($data);
     if ($result->isSuccess()) {
         $id = $result->getId();
         foreach ($arFiles as $file) {
             $arFile = \CFile::MakeFileArray($file);
             $arFile["MODULE_ID"] = "main";
             $fid = \CFile::SaveFile($arFile, "main");
             $dataAttachment = array('EVENT_ID' => $id, 'FILE_ID' => $fid);
             MailInternal\EventAttachmentTable::add($dataAttachment);
         }
     }
     return $result;
 }
开发者ID:Satariall,项目名称:izurit,代码行数:26,代码来源:event.php

示例7: getValueForDB

 private function getValueForDB($value)
 {
     $property = $this->property;
     if ($property['TYPE'] == 'FILE') {
         $value = Input\File::asMultiple($value);
         foreach ($value as $i => $file) {
             if (Input\File::isDeletedSingle($file)) {
                 unset($value[$i]);
             } else {
                 if (Input\File::isUploadedSingle($file) && ($fileId = \CFile::SaveFile(array('MODULE_ID' => 'sale') + $file, 'sale/order/properties')) && is_numeric($fileId)) {
                     $file = $fileId;
                 }
                 $value[$i] = Input\File::loadInfoSingle($file);
             }
         }
         $this->fields->set('VALUE', $value);
         $value = Input\File::getValue($property, $value);
         foreach (array_diff(Input\File::asMultiple(Input\File::getValue($property, $this->savedValue)), Input\File::asMultiple($value), Input\File::asMultiple(Input\File::getValue($property, $property['DEFAULT_VALUE']))) as $fileId) {
             \CFile::Delete($fileId);
         }
     }
     return $value;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:23,代码来源:propertyvalue.php

示例8: unset

             if (!is_uploaded_file($file["tmp_name"])) {
                 unset($arFiles[$index]);
             }
         }
     }
     //New from media library and file structure
     if (array_key_exists("NEW_FILE", $_POST) && is_array($_POST["NEW_FILE"])) {
         foreach ($_POST["NEW_FILE"] as $index => $value) {
             $arFiles[$index] = CFile::MakeFileArray($value);
         }
     }
     foreach ($arFiles as $file) {
         if (strlen($file["name"]) > 0 and intval($file["size"]) > 0) {
             $resultInsertAttachFile = false;
             $file["MODULE_ID"] = "main";
             $fid = intval(CFile::SaveFile($file, "sender", true));
             if ($fid > 0) {
                 $resultAddAttachFile = \Bitrix\Sender\MailingAttachmentTable::add(array('CHAIN_ID' => $ID, 'FILE_ID' => $fid));
                 $resultInsertAttachFile = $resultAddAttachFile->isSuccess();
             }
             if (!$resultInsertAttachFile) {
                 break;
             }
         }
     }
     if (isset($TEMPLATE_ACTION_SAVE) && $TEMPLATE_ACTION_SAVE == 'Y') {
         if (!empty($TEMPLATE_ACTION_SAVE_NAME) && !empty($MESSAGE)) {
             \Bitrix\Sender\TemplateTable::add(array('NAME' => $TEMPLATE_ACTION_SAVE_NAME, 'CONTENT' => $MESSAGE));
         }
     }
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:mailing_wizard.php

示例9: Edit

 public static function Edit($Params)
 {
     global $DB;
     $source_id = false;
     $arFields = $Params['arFields'];
     $bNew = !isset($arFields['ID']) || $arFields['ID'] <= 0;
     $bFile_FD = $Params['path'] && strlen($Params['path']) > 0;
     $bFile_PC = $Params['file'] && strlen($Params['file']['name']) > 0 && $Params['file']['size'] > 0;
     $io = CBXVirtualIo::GetInstance();
     if ($bFile_FD || $bFile_PC) {
         if ($bFile_FD) {
             $DocRoot = CSite::GetSiteDocRoot(false);
             $tmp_name = $DocRoot . $Params['path'];
             if ($io->FileExists($tmp_name)) {
                 $flTmp = $io->GetFile($tmp_name);
                 $file_name = substr($Params['path'], strrpos($Params['path'], '/') + 1);
                 $arFile = array("name" => $file_name, "size" => $flTmp->GetFileSize(), "tmp_name" => $tmp_name, "type" => CFile::IsImage($file_name) ? 'image' : 'file');
             }
         } else {
             if ($bFile_PC) {
                 $arFile = $Params['file'];
             }
         }
         if (!CMedialib::CheckFileExtention($arFile["name"])) {
             return false;
         }
         if (!$bNew) {
             $arFile["old_file"] = CMedialibItem::GetSourceId($arFields['ID']);
             $arFile["del"] = "Y";
         }
         // Resizing Image
         if (CFile::IsImage($arFile["name"])) {
             $arSize = array('width' => COption::GetOptionInt('fileman', "ml_max_width", 1024), 'height' => COption::GetOptionInt('fileman', "ml_max_height", 1024));
             $res = CFile::ResizeImage($arFile, $arSize);
         }
         $arFile["MODULE_ID"] = "fileman";
         $source_id = CFile::SaveFile($arFile, "medialibrary");
         if ($source_id) {
             $r = CFile::GetByID($source_id);
             if ($arFile = $r->Fetch()) {
                 if (CFile::IsImage($arFile['FILE_NAME'])) {
                     CMedialibItem::GenerateThumbnail($arFile, array('width' => COption::GetOptionInt('fileman', "ml_thumb_width", 140), 'height' => COption::GetOptionInt('fileman', "ml_thumb_height", 105)));
                 }
                 $arFile['PATH'] = CMedialibItem::GetFullPath($arFile);
             }
         }
     }
     // TODO: Add error handling
     if ($bNew && !$source_id) {
         return false;
     }
     // 2. Add to b_medialib_item
     if (!isset($arFields['~DATE_UPDATE'])) {
         $arFields['~DATE_UPDATE'] = $DB->CurrentTimeFunction();
     }
     if (!CMedialibItem::CheckFields($arFields)) {
         return false;
     }
     if (CModule::IncludeModule("search")) {
         $arStem = stemming($arFields['NAME'] . ' ' . $arFields['DESCRIPTION'] . ' ' . $arFields['KEYWORDS'], LANGUAGE_ID);
         if (count($arStem) > 0) {
             $arFields['SEARCHABLE_CONTENT'] = '{' . implode('}{', array_keys($arStem)) . '}';
         } else {
             $arFields['SEARCHABLE_CONTENT'] = '';
         }
     }
     if ($bNew) {
         unset($arFields['ID']);
         $arFields['SOURCE_ID'] = $source_id;
         $arFields['~DATE_CREATE'] = $arFields['~DATE_UPDATE'];
         $arFields['ITEM_TYPE'] = '';
         $ID = CDatabase::Add("b_medialib_item", $arFields, array("DESCRIPTION", "SEARCHABLE_CONTENT"));
     } else {
         if ($source_id) {
             $arFields['SOURCE_ID'] = $source_id;
         }
         $ID = $arFields['ID'];
         unset($arFields['ID']);
         $strUpdate = $DB->PrepareUpdate("b_medialib_item", $arFields);
         $strSql = "UPDATE b_medialib_item SET " . $strUpdate . " WHERE ID=" . IntVal($ID);
         $DB->QueryBind($strSql, array("DESCRIPTION" => $arFields["DESCRIPTION"], "SEARCHABLE_CONTENT" => $arFields["SEARCHABLE_CONTENT"]), false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     // 3. Set fields to b_medialib_collection_item
     if (!$bNew) {
         $strSql = "DELETE FROM b_medialib_collection_item WHERE ITEM_ID=" . IntVal($ID);
         $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     }
     $strCollections = "0";
     for ($i = 0, $l = count($Params['arCollections']); $i < $l; $i++) {
         $strCollections .= "," . IntVal($Params['arCollections'][$i]);
     }
     $strSql = "INSERT INTO b_medialib_collection_item(ITEM_ID, COLLECTION_ID) " . "SELECT " . intVal($ID) . ", ID " . "FROM b_medialib_collection " . "WHERE ID in (" . $strCollections . ")";
     $res = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     if (!$arFields['ID']) {
         $arFields['ID'] = $ID;
     }
     if ($source_id) {
         $arFields = array_merge($arFile, $arFields);
     }
     return $arFields;
//.........这里部分代码省略.........
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:101,代码来源:medialib.php

示例10: Set


//.........这里部分代码省略.........
                 }
             }
             if (in_array("DATE_SHOW_FROM", $arrKeys)) {
                 if (strlen($arFields["DATE_SHOW_FROM"]) > 0) {
                     $arFields_i["DATE_SHOW_FROM"] = $DB->CharToDateFunction($arFields["DATE_SHOW_FROM"]);
                 } else {
                     $arFields_i["DATE_SHOW_FROM"] = "null";
                 }
             }
             if (in_array("DATE_SHOW_TO", $arrKeys)) {
                 if (strlen($arFields["DATE_SHOW_TO"]) > 0) {
                     $time = "";
                     if (defined("FORMAT_DATE") && strlen($arFields["DATE_SHOW_TO"]) <= strlen(FORMAT_DATE)) {
                         $time = " 23:59:59";
                     }
                     $arFields_i["DATE_SHOW_TO"] = $DB->CharToDateFunction($arFields["DATE_SHOW_TO"] . $time);
                 } else {
                     $arFields_i["DATE_SHOW_TO"] = "null";
                 }
             }
             if (in_array("DATE_SHOW_FIRST", $arrKeys)) {
                 $arFields_i["DATE_SHOW_FIRST"] = "null";
             }
             if (in_array("arrIMAGE_ID", $arrKeys) && is_array($arFields["arrIMAGE_ID"])) {
                 $arIMAGE = $arFields["arrIMAGE_ID"];
                 $arIMAGE["MODULE_ID"] = "advertising";
                 if ($BANNER_ID > 0) {
                     $z = $DB->Query("SELECT IMAGE_ID FROM b_adv_banner WHERE ID='{$BANNER_ID}'", false, $err_mess . __LINE__);
                     $zr = $z->Fetch();
                     $arIMAGE["old_file"] = $zr["IMAGE_ID"];
                 }
                 if (strlen($arIMAGE["name"]) > 0 || strlen($arIMAGE["del"]) > 0) {
                     $subdir = COption::GetOptionString("advertising", "UPLOAD_SUBDIR");
                     $fid = CFile::SaveFile($arIMAGE, $subdir);
                     if (intval($fid) > 0) {
                         $arFields_i["IMAGE_ID"] = intval($fid);
                     } else {
                         $arFields_i["IMAGE_ID"] = "null";
                     }
                     if (intval($arBanner["IMAGE_ID"]) != intval($arFields_i["IMAGE_ID"])) {
                         $modify_status = "Y";
                     }
                 }
             }
             if (in_array("IMAGE_ALT", $arrKeys)) {
                 $arFields_i["IMAGE_ALT"] = "'" . $DB->ForSql($arFields["IMAGE_ALT"], 255) . "'";
                 if ("'" . $DB->ForSql($arBanner["IMAGE_ALT"], 255) . "'" != $arFields_i["IMAGE_ALT"]) {
                     $modify_status = "Y";
                 }
             }
             if (in_array("URL", $arrKeys)) {
                 $arFields_i["URL"] = "'" . $DB->ForSql($arFields["URL"], 2000) . "'";
                 if ("'" . $DB->ForSql($arBanner["URL"], 2000) . "'" != $arFields_i["URL"]) {
                     $modify_status = "Y";
                 }
             }
             if (in_array("URL_TARGET", $arrKeys)) {
                 $arFields_i["URL_TARGET"] = "'" . $DB->ForSql($arFields["URL_TARGET"], 255) . "'";
                 if ("'" . $DB->ForSql($arBanner["URL_TARGET"], 255) . "'" != $arFields_i["URL_TARGET"]) {
                     $modify_status = "Y";
                 }
             }
             if (in_array("NO_URL_IN_FLASH", $arrKeys) && ($arFields["NO_URL_IN_FLASH"] == "Y" || $arFields["NO_URL_IN_FLASH"] == "N")) {
                 $arFields_i["NO_URL_IN_FLASH"] = "'" . $arFields["NO_URL_IN_FLASH"] . "'";
                 if ($arBanner["NO_URL_IN_FLASH"] != $arFields_i["NO_URL_IN_FLASH"]) {
                     $modify_status = "Y";
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:67,代码来源:advertising.php

示例11: GetFieldInputValue


//.........这里部分代码省略.........
							{
								$value = strtolower($value);
								if (in_array($value, array("y", "yes", "true", "1")))
								{
									$value = "Y";
								}
								elseif (in_array($value, array("n", "no", "false", "0")))
								{
									$value = "N";
								}
								else
								{
									$value = null;
									$arErrors[] = array(
										"code" => "ErrorValue",
										"message" => GetMessage("BPCGWTL_INVALID4N"),
										"parameter" => $arFieldName["Field"],
									);
								}
							}
							else
							{
								$value = null;
							}
						}
					}
					elseif ($arFieldType["Type"] == "F")
					{
						if (array_key_exists("name", $value) && strlen($value["name"]) > 0)
						{
							if (!array_key_exists("MODULE_ID", $value))
								$value["MODULE_ID"] = "bizproc";

							$value = CFile::SaveFile($value, "bizproc_wf", true, true);
							if (!$value)
							{
								$value = null;
								$arErrors[] = array(
									"code" => "ErrorValue",
									"message" => GetMessage("BPCGWTL_INVALID9N"),
									"parameter" => $arFieldName["Field"],
								);
							}
						}
						else
						{
							$value = null;
						}
					}
					elseif (strpos($arFieldType["Type"], ":") !== false)
					{
						$arCustomType = CIBlockProperty::GetUserType(substr($arFieldType["Type"], 2));
						if (array_key_exists("GetLength", $arCustomType))
						{
							if (call_user_func_array(
								$arCustomType["GetLength"],
								array(
									array("LINK_IBLOCK_ID" => $arFieldType["Options"]),
									array("VALUE" => $value)
								)
							) <= 0)
							{
								$value = null;
							}
						}
						else
开发者ID:ASDAFF,项目名称:1C_Bitrix_info_site,代码行数:67,代码来源:virtualdocument.php

示例12: is_array

             if (is_array($v4)) {
                 $v1 = $v4["DESCRIPTION"];
                 $v2 = is_array($v4["FILTERABLE_FIELDS"]) ? $v4["FILTERABLE_FIELDS"] : (strlen($v4["FILTERABLE_FIELDS"]) > 0 ? array($v4["FILTERABLE_FIELDS"]) : array());
                 $v3 = is_array($v4["VISIBLE_FIELDS"]) ? $v4["VISIBLE_FIELDS"] : (strlen($v4["VISIBLE_FIELDS"]) > 0 ? array($v4["VISIBLE_FIELDS"]) : array());
                 $v5 = is_array($v4["COMPONENT_TEMPLATES"]) ? $v4["COMPONENT_TEMPLATES"] : (strlen($v4["COMPONENT_TEMPLATES"]) > 0 ? array($v4["COMPONENT_TEMPLATES"]) : array());
             }
         }
         $arResult["Data"] = array("Name" => $ar["NAME"], "Description" => $v1, "FilterableFields" => $v2, "VisibleFields" => $v3, "ComponentTemplates" => $v5, "Sort" => $ar["SORT"], "Image" => $ar["PICTURE"], "ElementAdd" => is_array($arMessagesTmp) && array_key_exists("ELEMENT_ADD", $arMessagesTmp) ? $arMessagesTmp["ELEMENT_ADD"] : GetMessage("BPWC_WNC_PNADD"), "UserGroups" => $arG);
     } else {
         $arParams["BLOCK_ID"] = 0;
     }
 }
 if ($arResult["Step"] > 1) {
     $errorMessageTmp = "";
     if (array_key_exists("bp_image", $_FILES)) {
         $imageId = CFile::SaveFile($_FILES["bp_image"], "bizproc_wf", true, true);
     } else {
         $imageId = intval($_REQUEST["bp_image"]);
     }
     $arResult["NewTemplateType"] = "";
     if ($_REQUEST["bp_template"] == "-") {
         $arResult["NewTemplateType"] = "statemachine";
         $_REQUEST["bp_template"] = "";
     } elseif (strlen($_REQUEST["bp_template"]) <= 0) {
         $arResult["NewTemplateType"] = "sequential";
     }
     $arResult["Data"] = array("Name" => trim($_REQUEST["bp_name"]), "Description" => trim($_REQUEST["bp_description"]), "Sort" => intval($_REQUEST["bp_sort"]) > 0 ? intval($_REQUEST["bp_sort"]) : 100, "Image" => $imageId, "ElementAdd" => trim($_REQUEST["bp_element_add"]), "UserGroups" => is_array($_REQUEST["bp_user_groups"]) ? $_REQUEST["bp_user_groups"] : array(), "Template" => preg_replace("/[^a-zA-Z0-9_.-]+/i", "", $_REQUEST["bp_template"]), "FilterableFields" => is_array($_REQUEST["bp_filterablefields"]) ? $_REQUEST["bp_filterablefields"] : (strlen($_REQUEST["bp_filterablefields"]) > 0 ? array($_REQUEST["bp_filterablefields"]) : array()), "VisibleFields" => is_array($_REQUEST["bp_visiblefields"]) ? $_REQUEST["bp_visiblefields"] : (strlen($_REQUEST["bp_visiblefields"]) > 0 ? array($_REQUEST["bp_visiblefields"]) : array()), "ComponentTemplates" => array("Start" => trim($_REQUEST["bp_start_tpl"]), "List" => trim($_REQUEST["bp_list_tpl"]), "View" => trim($_REQUEST["bp_view_tpl"])));
     if (strlen($arResult["Data"]["Name"]) <= 0) {
         $errorMessageTmp .= GetMessage("BPWC_WNC_EMPTY_NAME") . ". ";
     }
     if ($arParams["BLOCK_ID"] <= 0 && strlen($arResult["Data"]["Template"]) > 0) {
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:component.php

示例13: SetPropertyValuesEx


//.........这里部分代码省略.........
                 if (!array_key_exists($ar["IBLOCK_PROPERTY_ID"], $arDBProps)) {
                     $arDBProps[$ar["IBLOCK_PROPERTY_ID"]] = array();
                 }
                 $arDBProps[$ar["IBLOCK_PROPERTY_ID"]][$ar["ID"]] = $ar;
             }
             $rs = $DB->Query("\n\t\t\t\t\tselect *\n\t\t\t\t\tfrom b_iblock_element_prop_s" . $IBLOCK_ID . "\n\t\t\t\t\twhere IBLOCK_ELEMENT_ID=" . $ELEMENT_ID . "\n\t\t\t\t");
             if ($ar = $rs->Fetch()) {
                 foreach ($PROPS_CACHE[$IBLOCK_ID] as $property_id => $property) {
                     if (array_key_exists($property_id, $arProps) && array_key_exists("PROPERTY_" . $property_id, $ar) && $property["MULTIPLE"] == "N" && strlen($ar["PROPERTY_" . $property_id]) > 0) {
                         $pr = array("IBLOCK_PROPERTY_ID" => $property_id, "VALUE" => $ar["PROPERTY_" . $property_id], "DESCRIPTION" => $ar["DESCRIPTION_" . $property_id]);
                         if (!array_key_exists($pr["IBLOCK_PROPERTY_ID"], $arDBProps)) {
                             $arDBProps[$pr["IBLOCK_PROPERTY_ID"]] = array();
                         }
                         $arDBProps[$pr["IBLOCK_PROPERTY_ID"]][$ELEMENT_ID . ":" . $property_id] = $pr;
                     }
                 }
             }
         }
     }
     $arFilesToDelete = array();
     //Handle file properties
     foreach ($arProps as $property_id => $values) {
         if ($PROPS_CACHE[$IBLOCK_ID][$property_id]["PROPERTY_TYPE"] == "F") {
             foreach ($values as $i => $value) {
                 $val = $value["VALUE"];
                 if (strlen($val["del"]) > 0) {
                     $val = "NULL";
                 } else {
                     $val["MODULE_ID"] = "iblock";
                     unset($val["old_file"]);
                     if (strlen($value["DESCRIPTION"]) > 0) {
                         $val["description"] = $value["DESCRIPTION"];
                     }
                     $val = CFile::SaveFile($val, "iblock");
                 }
                 if ($val == "NULL") {
                     //Delete it! Actually it will not add an value
                     unset($arProps[$property_id][$i]);
                 } elseif (intval($val) > 0) {
                     $arProps[$property_id][$i]["VALUE"] = intval($val);
                     if (strlen($value["DESCRIPTION"]) <= 0) {
                         $arProps[$property_id][$i]["DESCRIPTION"] = $arDBProps[$property_id][$value["ID"]]["DESCRIPTION"];
                     }
                 } elseif (strlen($value["DESCRIPTION"]) > 0) {
                     $arProps[$property_id][$i]["VALUE"] = $arDBProps[$property_id][$value["ID"]]["VALUE"];
                     //Only needs to update description so CFile::Delete will not called
                     unset($arDBProps[$property_id][$value["ID"]]);
                 } else {
                     $arProps[$property_id][$i]["VALUE"] = $arDBProps[$property_id][$value["ID"]]["VALUE"];
                     //CFile::Delete will not called
                     unset($arDBProps[$property_id][$value["ID"]]);
                 }
             }
             if (array_key_exists($property_id, $arDBProps)) {
                 foreach ($arDBProps[$property_id] as $id => $value) {
                     $arFilesToDelete[] = array($value["VALUE"], $ELEMENT_ID, "PROPERTY", -1, $IBLOCK_ID);
                 }
             }
         }
     }
     foreach ($arFilesToDelete as $ar) {
         call_user_func_array(array("CIBlockElement", "DeleteFile"), $ar);
     }
     //Now we'll try to find out properties which do not require any update
     if (!array_key_exists("NewElement", $FLAGS)) {
         foreach ($arProps as $property_id => $values) {
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:67,代码来源:iblockelement.php

示例14: SetPropertyValues


//.........这里部分代码省略.........
                         }
                     } else {
                         if ($prop["VERSION"] == 2 && $prop["MULTIPLE"] == "N") {
                             if ($prop["PROPERTY_TYPE"] == "N") {
                                 $val = CIBlock::roundDB($val);
                             }
                             $strSql = "\n\t\t\t\t\t\t\t\t\tUPDATE b_iblock_element_prop_s" . $prop["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\t\tSET PROPERTY_" . $prop["ID"] . "='" . $DB->ForSql($val) . "'\n\t\t\t\t\t\t\t\t\t,DESCRIPTION_" . $prop["ID"] . "=" . ($val_desc !== false ? "'" . $DB->ForSQL($val_desc, 255) . "'" : "null") . "\n\t\t\t\t\t\t\t\t\tWHERE IBLOCK_ELEMENT_ID=" . $ELEMENT_ID;
                         } else {
                             $strSql = "\n\t\t\t\t\t\t\t\t\tUPDATE " . $strTable . "\n\t\t\t\t\t\t\t\t\tSET \tVALUE='" . $DB->ForSql($val) . "'\n\t\t\t\t\t\t\t\t\t\t,VALUE_NUM=" . CIBlock::roundDB($val) . "\n\t\t\t\t\t\t\t\t\t\t" . ($val_desc !== false ? ",DESCRIPTION='" . $DB->ForSql($val_desc, 255) . "'" : "") . "\n\t\t\t\t\t\t\t\t\tWHERE ID=" . $res["ID"];
                         }
                         $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                         if ($prop["VERSION"] == 2 && $prop["MULTIPLE"] == "Y") {
                             $strSql = "\n\t\t\t\t\t\t\t\t\tUPDATE\tb_iblock_element_prop_s" . $prop["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\t\tSET\tPROPERTY_" . $prop["ID"] . "=NULL, DESCRIPTION_" . $prop["ID"] . "=NULL\n\t\t\t\t\t\t\t\t\tWHERE\tIBLOCK_ELEMENT_ID=" . $ELEMENT_ID . "\n\t\t\t\t\t\t\t\t";
                             $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                         }
                     }
                 } elseif ($prop["PROPERTY_TYPE"] == "F") {
                     if (is_array($val)) {
                         if (strlen($val["del"]) > 0) {
                             $val = "NULL";
                         } else {
                             $val["MODULE_ID"] = "iblock";
                             if ($val_desc !== false) {
                                 $val["description"] = $val_desc;
                             }
                             if ($val_desc !== false && strlen($val["name"]) <= 0) {
                                 //update description only
                                 if ($res["VALUE"] > 0) {
                                     CFile::UpdateDesc($res["VALUE"], $val_desc);
                                 }
                                 $val = false;
                             } else {
                                 //register new file
                                 $val = CFile::SaveFile($val, "iblock");
                             }
                         }
                     }
                     if ($val == "NULL") {
                         CIBLockElement::DeleteFile($res["VALUE"], $ELEMENT_ID, "PROPERTY", -1, $prop["IBLOCK_ID"]);
                         if ($prop["VERSION"] == 2 && $prop["MULTIPLE"] == "N") {
                             $strSql = "\n\t\t\t\t\t\t\t\t\tUPDATE b_iblock_element_prop_s" . $prop["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\t\tSET PROPERTY_" . $prop["ID"] . "=null\n\t\t\t\t\t\t\t\t\t,DESCRIPTION_" . $prop["ID"] . "=null\n\t\t\t\t\t\t\t\t\tWHERE IBLOCK_ELEMENT_ID=" . $ELEMENT_ID;
                         } else {
                             $strSql = "DELETE FROM " . $strTable . " WHERE ID=" . $res["ID"];
                         }
                         $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                         if ($prop["VERSION"] == 2 && $prop["MULTIPLE"] == "Y") {
                             $strSql = "\n\t\t\t\t\t\t\t\t\tUPDATE\tb_iblock_element_prop_s" . $prop["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\t\tSET\tPROPERTY_" . $prop["ID"] . "=NULL, DESCRIPTION_" . $prop["ID"] . "=NULL\n\t\t\t\t\t\t\t\t\tWHERE\tIBLOCK_ELEMENT_ID=" . $ELEMENT_ID . "\n\t\t\t\t\t\t\t\t";
                             $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                         }
                     } elseif (IntVal($val) > 0) {
                         if (intval($val) != $res["VALUE"]) {
                             CIBLockElement::DeleteFile($res["VALUE"], $ELEMENT_ID, "PROPERTY", -1, $prop["IBLOCK_ID"]);
                         }
                         if ($prop["VERSION"] == 2 && $prop["MULTIPLE"] == "N") {
                             $strSql = "\n\t\t\t\t\t\t\t\t\tUPDATE b_iblock_element_prop_s" . $prop["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\t\tSET PROPERTY_" . $prop["ID"] . "='" . intval($val) . "'\n\t\t\t\t\t\t\t\t\t" . ($val_desc !== false ? ",DESCRIPTION_" . $prop["ID"] . "='" . $DB->ForSql($val_desc, 255) . "'" : "") . "\n\t\t\t\t\t\t\t\t\tWHERE IBLOCK_ELEMENT_ID=" . $ELEMENT_ID;
                         } else {
                             $strSql = "\n\t\t\t\t\t\t\t\t\tUPDATE " . $strTable . "\n\t\t\t\t\t\t\t\t\tSET \tVALUE='" . intval($val) . "'\n\t\t\t\t\t\t\t\t\t\t,VALUE_NUM='" . intval($val) . "'\n\t\t\t\t\t\t\t\t\t\t" . ($val_desc !== false ? ",DESCRIPTION='" . $DB->ForSql($val_desc, 255) . "'" : "") . "\n\t\t\t\t\t\t\t\t\tWHERE ID=" . $res["ID"];
                         }
                         $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                         if ($prop["VERSION"] == 2 && $prop["MULTIPLE"] == "Y") {
                             $strSql = "\n\t\t\t\t\t\t\t\t\tUPDATE\tb_iblock_element_prop_s" . $prop["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\t\tSET\tPROPERTY_" . $prop["ID"] . "=NULL, DESCRIPTION_" . $prop["ID"] . "=NULL\n\t\t\t\t\t\t\t\t\tWHERE\tIBLOCK_ELEMENT_ID=" . $ELEMENT_ID . "\n\t\t\t\t\t\t\t\t";
                             $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                         }
                     } elseif ($val_desc !== false) {
                         if ($prop["VERSION"] == 2 && $prop["MULTIPLE"] == "N") {
                             $strSql = "\n\t\t\t\t\t\t\t\t\tUPDATE b_iblock_element_prop_s" . $prop["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\t\tSET DESCRIPTION_" . $prop["ID"] . "='" . $DB->ForSql($val_desc, 255) . "'\n\t\t\t\t\t\t\t\t\tWHERE IBLOCK_ELEMENT_ID=" . $ELEMENT_ID . "\n\t\t\t\t\t\t\t\t";
开发者ID:spas-viktor,项目名称:books,代码行数:67,代码来源:iblockelement.php

示例15: in_array

         $bCanReadAll = in_array('*', $arAccessUsers['READ']);
         $bCanReadUser = $bCanReadAll || in_array($user_id, $arAccessUsers["READ"]);
     }
     if ($bCanReadUser) {
         $dbreport = CTimeManReportFull::GetList(array("ID" => "asc"), array("ID" => $report_id, "USER_ID" => $user_id));
         $report = $dbreport->fetch();
     }
 } elseif (!is_array($_SESSION['report_files'])) {
     $_SESSION['report_files'] = array();
 }
 if ($_POST["mode"] == "upload") {
     $arResult = array();
     $count = sizeof($_FILES["report-attachments"]["name"]);
     for ($i = 0; $i < $count; $i++) {
         $arFile = array("name" => $_FILES["report-attachments"]["name"][$i], "size" => $_FILES["report-attachments"]["size"][$i], "tmp_name" => $_FILES["report-attachments"]["tmp_name"][$i], "type" => $_FILES["report-attachments"]["type"][$i], "MODULE_ID" => "timeman");
         $fileID = CFile::SaveFile($arFile, "timeman");
         $tmp = array("name" => $_FILES["report-attachments"]["name"][$i], "fileID" => $fileID);
         if ($fileID) {
             $arResult[] = $tmp;
         }
     }
     if (count($arResult) > 0) {
         if ($report) {
             $arCurFiles = unserialize($report["FILES"]);
             $arFiles = is_array($arCurFiles) && count($arCurFiles) > 0 ? array_merge($arCurFiles, $arResult) : $arResult;
             CTimeManReportFull::Update($report["ID"], array("FILES" => $arFiles));
         } else {
             $_SESSION['report_files'] = array_merge($_SESSION['report_files'], $arResult);
         }
     }
     $APPLICATION->RestartBuffer();
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:31,代码来源:timeman.php


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