public function saveToIBProp($iblockID, $elementID, $propCode, $action = self::F_IB_IMG_PROP_APPEND) { if (true !== $this->_bRequestsComplete && true !== $this->_bDownloadsComplete) { return false; } $arProp = array(); $arErr = array(); if (is_numeric($propCode)) { $propID = intval($propCode); $propCode = Tools::getPropCodeById($iblockID, $propID, $arProp, $arErr); if ($propCode === false) { return false; } } else { $propID = Tools::getPropIdByCode($iblockID, $propCode, $arProp, $arErr); if ($propID === false) { return false; } } if (!empty($arErr)) { return false; } if ($arProp['PROPERTY_TYPE'] != 'F') { return false; } if ($arProp['MULTIPLE'] != 'Y') { return false; } $arFileList = array(); /** @var Request $Request */ foreach ($this->_arRequestList as $Request) { if ($Request->isDownloadSuccess()) { $downloadFileRelPath = $Request->getDownloadFilePath(false); $arFile = \CFile::MakeFileArray($downloadFileRelPath); if (!empty($arFile)) { $arFileList[] = $arFile; } } } if (!empty($arFileList)) { switch ($action) { case self::F_IB_IMG_PROP_REPLACE: \CIBlockElement::SetPropertyValuesEx($elementID, $iblockID, array($arProp['ID'] => $arFileList)); break; case self::F_IB_IMG_PROP_APPEND: \CIBlockElement::SetPropertyValues($elementID, $iblockID, $arFileList, $arProp['ID']); break; } } return true; }
public function saveEntityClass($path = null) { if (empty($path)) { $path = $this->config->getClassPath(); } Tools::_fixFilePath($path); if ('/' != substr($path, 0, 1)) { $path = '/bitrix/modules/' . $this->config->getModuleID() . '/' . $path; } if (!CheckDirPath(OBX_DOC_ROOT . $path)) { throw new Err('', Err::E_CLASS_SAVE_FAILED); } if (false === file_put_contents(OBX_DOC_ROOT . $path, $this->phpClass->generateClass())) { return false; } return true; }
public function __construct($multiDownloadID = null, $downloadFolder = null) { $this->_bEncapsulatedID = false; if (null !== $multiDownloadID) { $multiDownloadID = trim($multiDownloadID); if (empty($multiDownloadID)) { $this->_bEncapsulatedID = true; } Tools::_fixFileName($multiDownloadID); $this->_ID = $multiDownloadID; } else { $this->_bEncapsulatedID = true; } if ($this->_bEncapsulatedID === true) { $this->_ID = static::generateID(); } $this->_multiDwnFolder = Request::DOWNLOAD_FOLDER . '/' . static::DWN_FOLDER_PREFIX . $this->_ID; //if( ! ($bSuccess = CheckDirPath($this->_multiDwnFolder.'/')) ) { // throw new RequestError('', RequestError::E_NO_ACCESS_DWN_FOLDER); //} $this->_multiDwnDir = OBX_DOC_ROOT . $this->_multiDwnFolder; $this->_curlMulti = curl_multi_init(); }
/** * @param int $iblockID * @param int $elementID * @param int|string $propCode * @param int $action * @param string $description * @throws RequestError * @return bool */ public function saveToIBProp($iblockID, $elementID, $propCode, $action = self::F_IB_IMG_PROP_APPEND, $description = '') { if (true !== $this->_bRequestSuccess && true !== $this->_bDownloadSuccess) { return false; } $arProp = array(); $arErr = array(); if (is_numeric($propCode)) { $propID = intval($propCode); $propCode = Tools::getPropCodeById($iblockID, $propID, $arProp, $arErr); if ($propCode === false) { throw new RequestError('', RequestError::E_BX_FILE_PROP_NOT_FOUND); } } else { $propID = Tools::getPropIdByCode($iblockID, $propCode, $arProp, $arErr); if ($propID === false) { throw new RequestError('', RequestError::E_BX_FILE_PROP_NOT_FOUND); } } if ($arProp['PROPERTY_TYPE'] != 'F') { throw new RequestError('', RequestError::E_BX_FILE_PROP_WRONG_TYPE); } if ($this->_ID === null) { $this->_ID = static::generateID(); } 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); $arFile = \CFile::MakeFileArray($downloadFileRelPath); } $arFile['name'] = $this->_originalName . '.' . $this->_originalExt; if (is_string($description) && !empty($description)) { $arFile['description'] = $description; } switch ($action) { case self::F_IB_IMG_PROP_REPLACE: \CIBlockElement::SetPropertyValuesEx($elementID, $iblockID, array($arProp['ID'] => $arFile)); break; case self::F_IB_IMG_PROP_APPEND: \CIBlockElement::SetPropertyValues($elementID, $iblockID, $arFile, $arProp['ID']); break; } return true; }
function dc($data, $collapseTitle = '', $bPrintCondition = true) { Tools::debugConsoleLog($data, $collapseTitle, $bPrintCondition); }
public function importXMLData() { if (!$this->_bIBlockSelected) { return false; } $bTypeSuccess = $this->createIBlockType(); if (!$bTypeSuccess) { return false; } if (!$this->deleteOldIBlockData()) { return false; } // Это если мы реинсталлируем данные инфоблоков if ($this->_iblockID == 0) { $arFields = Tools::arrayMergeRecursiveDistinct(self::$_arDefaultIBlockFields, $this->_arConfig['IBLOCK'][$this->_iblockCode]); $arPermissions = $arFields['PERMISSIONS']; $dbGroup = \CGroup::GetList($by = "", $order = "", array("STRING_ID" => "content_editor")); if ($arGroup = $dbGroup->Fetch()) { $arPermissions[$arGroup["ID"]] = 'W'; } unset($arFields['IBLOCK_TYPE_ID']); unset($arFields['XML_FILE']); unset($arFields['FORM_SETTINGS']); unset($arFields['PERMISSIONS']); $arFields['CODE'] = $this->_iblockCode; $arFields['LID'] = WIZARD_SITE_ID; $this->_iblockID = \WizardServices::ImportIBlockFromXML($this->_iblockXMLFile, $this->_iblockCode, $this->_iblockType, WIZARD_SITE_ID, $arPermissions); if ($this->_iblockID < 1) { die('Error importing xml-data:' . "<br /> \n" . 'xml file: "' . htmlspecialchars($this->_iblockXMLFile) . '"' . ",<br /> \n" . 'iblock code: "' . htmlspecialchars($this->_iblockCode) . '"' . ",<br /> \n" . 'iblock type: "' . htmlspecialchars($this->_iblockType) . '"'); } $iblock = new \CIBlock(); $iblock->Update($this->_iblockID, $arFields); } else { $arSites = self::getIBlockSites($this->_iblockID); if (!in_array(WIZARD_SITE_ID, $arSites)) { $arSites[] = WIZARD_SITE_ID; $iblock = new \CIBlock(); $iblock->Update($this->_iblockID, array("LID" => $arSites)); } } }
protected static function normalizePath($path) { Tools::_fixFilePath($path); return $path; }