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


PHP CUtil::translit方法代码示例

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


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

示例1: transformName

 protected function transformName($name, $bForceMD5 = false, $bSkipExt = false)
 {
     //safe filename without path
     $fileName = GetFileName($name);
     $originalName = $bForceMD5 != true && COption::GetOptionString("main", "save_original_file_name", "N") == "Y";
     if ($originalName) {
         //transforming original name:
         //transliteration
         if (COption::GetOptionString("main", "translit_original_file_name", "N") == "Y") {
             $fileName = CUtil::translit($fileName, LANGUAGE_ID, array("max_len" => 1024, "safe_chars" => ".", "replace_space" => '-'));
         }
         //replace invalid characters
         if (COption::GetOptionString("main", "convert_original_file_name", "Y") == "Y") {
             $io = CBXVirtualIo::GetInstance();
             $fileName = $io->RandomizeInvalidFilename($fileName);
         }
     }
     //double extension vulnerability
     $fileName = RemoveScriptExtension($fileName);
     //safe extention without "."
     $fileExt = GetFileExtension($fileName);
     if (!$originalName) {
         //name is md5-generated:
         $fileName = md5(uniqid("", true)) . ($bSkipExt == true ? '' : "." . $fileExt);
     }
     //.jpe is not image type on many systems
     if ($bSkipExt == false && strtolower($fileExt) == "jpe") {
         $fileName = substr($fileName, 0, -4) . ".jpg";
     }
     return $fileName;
 }
开发者ID:spas-viktor,项目名称:books,代码行数:31,代码来源:file.php

示例2: translite

	public function translite($text)

	{

		$arParams = array("replace_space" => "-", "replace_other" => "-");

		return \CUtil::translit(trim($text), "ru", $arParams);

	}
开发者ID:ASDAFF,项目名称:bitrix_tehnomir,代码行数:9,代码来源:Text.php

示例3: validateFile

 protected function validateFile(&$strFileName, $arFile, $bForceMD5 = false)
 {
     $strFileName = GetFileName($arFile["name"]);
     //File is going to be deleted
     if (isset($arFile["del"]) && $arFile["del"] != "") {
         //There is no new file as replacement
         if ($strFileName == "") {
             return "";
         }
     }
     if ($arFile["name"] == "") {
         return "";
     }
     if (COption::GetOptionInt("main", "disk_space") > 0) {
         $quota = new CDiskQuota();
         if (!$quota->checkDiskQuota($arFile)) {
             return GetMessage("FILE_BAD_QUOTA");
         }
     }
     $io = CBXVirtualIo::GetInstance();
     if ($bForceMD5 != true && COption::GetOptionString("main", "save_original_file_name", "N") == "Y") {
         if (COption::GetOptionString("main", "translit_original_file_name", "N") == "Y") {
             $strFileName = CUtil::translit($strFileName, LANGUAGE_ID, array("max_len" => 1024, "safe_chars" => ".", "replace_space" => '-'));
         }
         if (COption::GetOptionString("main", "convert_original_file_name", "Y") == "Y") {
             $strFileName = $io->RandomizeInvalidFilename($strFileName);
         }
     }
     if (!$io->ValidateFilenameString($strFileName)) {
         return GetMessage("MAIN_BAD_FILENAME1");
     }
     //check for double extension vulnerability
     $strFileName = RemoveScriptExtension($strFileName);
     if ($strFileName == '') {
         return GetMessage("FILE_BAD_FILENAME");
     }
     if (strlen($strFileName) > 255) {
         return GetMessage("MAIN_BAD_FILENAME_LEN");
     }
     //check .htaccess etc.
     if (IsFileUnsafe($strFileName)) {
         return GetMessage("FILE_BAD_TYPE");
     }
     //nginx returns octet-stream for .jpg
     if (GetFileNameWithoutExtension($strFileName) == '') {
         return GetMessage("FILE_BAD_FILENAME");
     }
     return "";
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:49,代码来源:file.php

示例4: ConvertToUrlForm

    public static function ConvertToUrlForm($propName, $propValue)
    {
        if (CModule::IncludeModule("iblock")) {
            // check if infoblock contains conversion
            $arSelect = Array("ID", "NAME","CODE", "PROPERTY_CATEGORY");
            $arFilter = Array("IBLOCK_ID"=>37, "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y", "PROPERTY_CATEGORY_VALUE"=>$propName, "NAME"=>$propValue);
            $res = CIBlockElement::GetList(Array(), $arFilter, false, false, $arSelect);
            $ob = $res->GetNext();
            if ($ob)
                return $ob["CODE"];

            // if no, make convertion and add to infoblock
            $urlForm = CUtil::translit($propValue,"ru", array("replace_space"=>"-","replace_other"=>"-"));
            $el = new CIBlockElement;
            $res = $el->Add(array(
                "IBLOCK_ID"=>37,
                "NAME"=>$propValue,
                "CODE"=>$urlForm,
                "PROPERTY_VALUES"=>array("CATEGORY"=>$propName)
            ));
            return $urlForm;
        }
    }
开发者ID:akniyev,项目名称:arteva.ru,代码行数:23,代码来源:process_filter_in_url.php

示例5: SaveFile

	function SaveFile($arFile, $strSavePath, $bForceMD5=false, $bSkipExt=false)
	{
		$strFileName = GetFileName($arFile["name"]);	/* filename.gif */

		if(isset($arFile["del"]) && $arFile["del"] <> '')
		{
			CFile::DoDelete($arFile["old_file"]);
			if($strFileName == '')
				return "NULL";
		}

		if($arFile["name"] == '')
		{
			if(is_set($arFile, "description") && intval($arFile["old_file"])>0)
				CFile::UpdateDesc($arFile["old_file"], $arFile["description"]);
			return false;
		}

		if(is_set($arFile, "content") && !is_set($arFile, "size"))
			$arFile["size"] = CUtil::BinStrlen($arFile["content"]);
		else
			$arFile["size"] = filesize($arFile["tmp_name"]);

		/****************************** QUOTA ******************************/
		if (COption::GetOptionInt("main", "disk_space") > 0)
		{
			$quota = new CDiskQuota();
			if (!$quota->checkDiskQuota($arFile))
				return false;
		}
		/****************************** QUOTA ******************************/

		$arFile["ORIGINAL_NAME"] = $strFileName;

		$io = CBXVirtualIo::GetInstance();
		if($bForceMD5 != true && COption::GetOptionString("main", "save_original_file_name", "N") == "Y")
		{
			if(COption::GetOptionString("main", "translit_original_file_name", "N") == "Y")
				$strFileName = CUtil::translit($strFileName, LANGUAGE_ID, array("max_len"=>1024, "safe_chars"=>"."));

			if(COption::GetOptionString("main", "convert_original_file_name", "Y") == "Y")
				$strFileName = $io->RandomizeInvalidFilename($strFileName);
		}

		if(!$io->ValidateFilenameString($strFileName))
			return false;

		//check for double extension vulnerability
		$strFileName = RemoveScriptExtension($strFileName);
		if($strFileName == '')
			return false;

		if(strlen($strFileName) > 255)
			return false;

		//check .htaccess etc.
		if(IsFileUnsafe($strFileName))
			return false;

		//nginx returns octet-stream for .jpg
		if(GetFileNameWithoutExtension($strFileName) == '')
			return false;

		$upload_dir = COption::GetOptionString("main", "upload_dir", "upload");

		if($arFile["type"]=="image/pjpeg" || $arFile["type"]=="image/jpg")
			$arFile["type"]="image/jpeg";

		//.jpe is not image type on many systems
		if(strtolower(GetFileExtension($strFileName)) == "jpe")
			$strFileName = substr($strFileName, 0, -4).".jpg";

		$bExternalStorage = false;
		foreach(GetModuleEvents("main", "OnFileSave", true) as $arEvent)
		{
			if(ExecuteModuleEventEx($arEvent, array(&$arFile, $strFileName, $strSavePath, $bForceMD5, $bSkipExt)))
			{
				$bExternalStorage = true;
				break;
			}
		}

		if(!$bExternalStorage)
		{
			$newName = '';
			if($bForceMD5 != true && COption::GetOptionString("main", "save_original_file_name", "N")=="Y")
			{
				$dir_add = '';
				$i=0;
				while(true)
				{
					$dir_add = substr(md5(uniqid(mt_rand(), true)), 0, 3);
					if(!$io->FileExists($_SERVER["DOCUMENT_ROOT"]."/".$upload_dir."/".$strSavePath."/".$dir_add."/".$strFileName))
						break;
					if($i>=25)
					{
						$j=0;
						while(true)
						{
							$dir_add = substr(md5(mt_rand()), 0, 3)."/".substr(md5(mt_rand()), 0, 3);
//.........这里部分代码省略.........
开发者ID:nProfessor,项目名称:Mytb,代码行数:101,代码来源:file.php

示例6: ImportSection


//.........这里部分代码省略.........
             $this->_xml_file->Add(array("PARENT_ID" => 0, "LEFT_MARGIN" => $arDBSection["ID"]));
         }
         return true;
     }
     if ($XML_PROPERTIES_PARENT) {
         $rs = $this->_xml_file->GetList(array("ID" => "asc"), array("PARENT_ID" => $XML_PROPERTIES_PARENT), array("ID"));
         while ($ar = $rs->Fetch()) {
             $arXMLProp = $this->_xml_file->GetAllChildrenArray($ar["ID"]);
             if (array_key_exists($this->mess["IBLOCK_XML2_ID"], $arXMLProp) && array_key_exists($arXMLProp[$this->mess["IBLOCK_XML2_ID"]], $arUserFields)) {
                 $arUserField = $arUserFields[$arXMLProp[$this->mess["IBLOCK_XML2_ID"]]];
                 unset($arXMLProp[$this->mess["IBLOCK_XML2_ID"]]);
                 $arProp = array();
                 $i = 0;
                 foreach ($arXMLProp as $value) {
                     if ($arUserField["USER_TYPE"]["BASE_TYPE"] === "file") {
                         $arProp["n" . $i++] = $this->MakeFileArray($value);
                     } elseif ($arUserField["USER_TYPE"]["BASE_TYPE"] === "enum") {
                         $arProp["n" . $i++] = $this->GetSectionEnumByXML_ID($arUserField["ID"], $value);
                     } else {
                         $arProp["n" . $i++] = $value;
                     }
                 }
                 if ($arUserField["MULTIPLE"] == "N") {
                     $arSection[$arUserField["FIELD_NAME"]] = array_pop($arProp);
                 } else {
                     $arSection[$arUserField["FIELD_NAME"]] = $arProp;
                 }
             }
         }
     }
     $obSection = new CIBlockSection();
     $rsSection = $obSection->GetList(array(), array("IBLOCK_ID" => $IBLOCK_ID, "XML_ID" => $arSection["XML_ID"]), false);
     if ($arDBSection = $rsSection->Fetch()) {
         if (!array_key_exists("CODE", $arSection) && is_array($this->translit_on_update)) {
             $arSection["CODE"] = CUtil::translit($arSection["NAME"], LANGUAGE_ID, $this->translit_on_update);
             //Check if name was not changed in a way to update CODE
             if (substr($arDBSection["CODE"], 0, strlen($arSection["CODE"])) === $arSection["CODE"]) {
                 unset($arSection["CODE"]);
             } else {
                 $arSection["CODE"] = $this->CheckSectionCode($IBLOCK_ID, $arSection["CODE"]);
             }
         }
         $bChanged = false;
         foreach ($arSection as $key => $value) {
             if (is_array($arDBSection[$key]) || $arDBSection[$key] != $value) {
                 $bChanged = true;
                 break;
             }
         }
         if ($bChanged) {
             foreach ($arUserFields as $arField1) {
                 if ($arField1["USER_TYPE"]["BASE_TYPE"] == "file") {
                     $sectionUF = $USER_FIELD_MANAGER->GetUserFields("IBLOCK_" . $IBLOCK_ID . "_SECTION", $arDBSection["ID"]);
                     foreach ($sectionUF as $arField2) {
                         if ($arField2["USER_TYPE"]["BASE_TYPE"] == "file" && isset($arSection[$arField2["FIELD_NAME"]])) {
                             if ($arField2["MULTIPLE"] == "Y" && is_array($arField2["VALUE"])) {
                                 foreach ($arField2["VALUE"] as $old_file_id) {
                                     $arSection[$arField2["FIELD_NAME"]][] = array("del" => true, "old_id" => $old_file_id);
                                 }
                             } elseif ($arField2["MULTIPLE"] == "N" && $arField2["VALUE"] > 0) {
                                 $arSection[$arField2["FIELD_NAME"]]["old_id"] = $arField2["VALUE"];
                             }
                         }
                     }
                     break;
                 }
开发者ID:nycmic,项目名称:bittest,代码行数:67,代码来源:cml2.php

示例7: cmlStartElement


//.........这里部分代码省略.........
                    $currentProperty["DataType"] = "L";
                } else {
                    $currentProperty["DataType"] = "S";
                }
                $strSql = "INSERT INTO b_catalog_cml_property (XML_ID, CATALOG_ID, DATA_TYPE, MULTIPLE, NAME, DEFAULT_VALUE) " . "VALUES ('" . $currentProperty["ID"] . "', " . $currentCatalog["BID"] . ", '" . $currentProperty["DataType"] . "', '" . $currentProperty["Multiple"] . "', '" . $DB->ForSql($currentProperty["Name"]) . "', '" . $DB->ForSql($currentProperty["DefaultValue"]) . "')";
                $DB->Query($strSql);
                $cmlLoadCnts["PROPERTY"]++;
            }
            break;
        case $nameUTF["PropertyVariant"]:
            if ($currentProperty) {
                $currentPropertyEnum = array();
                $currentPropertyEnum["ID"] = $attrs[$nameUTF["ID"]];
                $currentPropertyEnum["Name"] = $attrs[$nameUTF["Name"]];
                $currentPropertyEnum["Default"] = $currentProperty["DefaultValue"] == $currentPropertyEnum["ID"] ? "Y" : "N";
                $strSql = "INSERT INTO b_catalog_cml_property_var (XML_ID, CATALOG_ID, PROPERTY_XML_ID, NAME, DEFAULT_VALUE) " . "VALUES ('" . $currentPropertyEnum["ID"] . "', " . $currentCatalog["BID"] . ", '" . $currentProperty["ID"] . "', '" . $DB->ForSql($currentPropertyEnum["Name"]) . "', '" . $currentPropertyEnum["Default"] . "')";
                $DB->Query($strSql);
            }
            break;
        case $nameUTF["Category"]:
            if ($currentCatalog) {
                $currentCategory = array();
                if (in_array($nameUTF["ID"], array_keys($attrs))) {
                    $currentCategory["ID"] = $attrs[$nameUTF["ID"]];
                }
                if (in_array($nameUTF["Name"], array_keys($attrs))) {
                    $currentCategory["Name"] = $attrs[$nameUTF["Name"]];
                }
                if (in_array($nameUTF["ParentCategory"], array_keys($attrs))) {
                    $currentCategory["ParentCategory"] = $attrs[$nameUTF["ParentCategory"]];
                }
                $currentCategory["Code"] = false;
                if (true === $boolTranslitSection) {
                    $currentCategory["Code"] = CUtil::translit($currentCategory["Name"], 'ru', $arTranslitSection);
                }
                $strSql = "INSERT INTO b_catalog_cml_section (XML_ID, CATALOG_ID, PARENT_XML_ID, NAME, CODE) " . "VALUES ('" . $currentCategory["ID"] . "', " . $currentCatalog["BID"] . ", '" . $currentCategory["ParentCategory"] . "', '" . $DB->ForSql($currentCategory["Name"]) . "', '" . (false === $currentCategory["Code"] ? '' : $DB->ForSql($currentCategory["Code"])) . "')";
                $DB->Query($strSql);
                $cmlLoadCnts["SECTION"]++;
            }
            break;
        case $nameUTF["Product"]:
            if ($currentCatalog) {
                $currentProduct = array();
                $currentProduct["ID"] = $attrs[$nameUTF["ID"]];
                $currentProduct["Name"] = $attrs[$nameUTF["Name"]];
                $currentProduct["ParentCategory"] = $attrs[$nameUTF["ParentCategory"]];
                $currentProduct["Code"] = false;
                if (true === $boolTranslitElement) {
                    $currentProduct["Code"] = CUtil::translit($currentProduct["Name"], 'ru', $arTranslitElement);
                }
                $strSql = "INSERT INTO b_catalog_cml_product (XML_ID, CATALOG_ID, NAME, MODIFIED_BY, PARENT_CATEGORY, CODE) " . "VALUES ('" . $currentProduct["ID"] . "', " . $currentCatalog["BID"] . ", '" . $DB->ForSql($currentProduct["Name"]) . "', " . (IntVal($USER->GetID()) > 0 ? IntVal($USER->GetID()) : 1) . ", '" . $currentProduct["ParentCategory"] . "', '" . (false === $currentProduct["Code"] ? '' : $DB->ForSql($currentProduct["Code"])) . "')";
                $DB->Query($strSql);
                if (function_exists("catalog_1c_mutator_productT")) {
                    catalog_1c_mutator_productT($attrs);
                }
                $cmlLoadCnts["PRODUCT"]++;
                if (strlen($currentProduct["ParentCategory"]) > 0) {
                    $strSql = "INSERT INTO b_catalog_cml_product_cat (CATALOG_ID, PRODUCT_XML_ID, CATEGORY_XML_ID) " . "VALUES (" . $currentCatalog["BID"] . ", '" . $currentProduct["ID"] . "',  '" . $currentProduct["ParentCategory"] . "')";
                    $DB->Query($strSql);
                }
            }
            break;
        case $nameUTF["CategoryReference"]:
            if ($currentProduct) {
                $strSql = "INSERT INTO b_catalog_cml_product_cat (CATALOG_ID, PRODUCT_XML_ID, CATEGORY_XML_ID) " . "VALUES (" . $currentCatalog["BID"] . ", '" . $currentProduct["ID"] . "',  '" . $attrs[$nameUTF["IdInCatalog"]] . "')";
                $DB->Query($strSql);
开发者ID:rasuldev,项目名称:torino,代码行数:67,代码来源:commerceml_g_run.php

示例8: IncludeModuleLangFile

<?php

require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/mail/prolog.php";
$MOD_RIGHT = $APPLICATION->GetGroupRight("mail");
if ($MOD_RIGHT < "R") {
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
IncludeModuleLangFile(__FILE__);
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/mail/include.php";
$dbr = $DB->Query("SELECT * FROM b_mail_msg_attachment WHERE ID=" . intval($ID));
if ($dbr_arr = $dbr->Fetch()) {
    $utfName = CHTTP::urnEncode($dbr_arr['FILE_NAME'], 'UTF-8');
    $translitName = CUtil::translit($dbr_arr['FILE_NAME'], LANGUAGE_ID, array('max_len' => 1024, 'safe_chars' => '.', 'replace_space' => '-'));
    header("Content-Type: application/force-download; name=\"" . $translitName . "\"");
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: " . $dbr_arr["FILE_SIZE"]);
    header("Content-Disposition: attachment; filename=\"" . $translitName . "\"; filename*=utf-8''" . $utfName);
    header("Expires: 0");
    header("Cache-Control: no-cache, must-revalidate");
    header("Pragma: no-cache");
    if ($dbr_arr['FILE_ID']) {
        if ($file = CFile::makeFileArray($dbr_arr['FILE_ID'])) {
            readfile($file['tmp_name']);
        }
    } else {
        echo $dbr_arr['FILE_DATA'];
    }
    die;
}
$APPLICATION->SetTitle(GetMessage("EDIT_MESSAGE_TITLE"));
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:31,代码来源:mail_attachment_view.php

示例9: modify

 public function modify($value)
 {
     return \CUtil::translit($value, 'ru', ["max_len" => 100, "change_case" => 'L', "replace_space" => '_', "replace_other" => '_', "delete_repeat_replace" => true, "safe_chars" => '']);
 }
开发者ID:HannibalLecktor,项目名称:alfa74,代码行数:4,代码来源:valuemodifier.php

示例10: bildArrFields

	/**
	 * [bildArrFields description]
	 * @param  object $obprop
	 * @param  integer $sortKey
	 * @return array
	 */
	protected function bildArrFields($obprop, $sortKey){
		$name = null; $id1c = null;
		$name = $obprop->Наименование;
		$id1c = $obprop->Ид;
		$translitParams = $this->translitParams();
		$arFields = Array(
			"NAME" => (string)$name,
			"ACTIVE" => "Y",
			"SORT" => ($sortKey > 0)? ($sortKey * 10) + 500 : 500,
			"CODE" => (string)$id1c,
			"XML_ID" => CUtil::translit($name, "ru", $translitParams),
			"IBLOCK_ID" => $this->getIblockId(),
			"FILTRABLE" => "Y",
		);
	    if (!empty($obprop->ВариантыЗначений)):
	    	$propValues = $obprop->ВариантыЗначений;
	    	$s = 0;
	    	$arFields["PROPERTY_TYPE"] = "L";
	    	$arFields["MULTIPLE"] = "Y";
	    	$arFields["LIST_TYPE"] = "L"; // Может быть "L" - выпадающий список или "C" - флажки.
	    	foreach ($propValues->Вариант as $listvalue):
	    		if (!empty($listvalue->Ид) && !empty($listvalue->Значение)):
	    			$sort = ($s > 0)? ($s*100)+100 : 100;
			    	$arFields["VALUES"][] = Array(
						"VALUE" => (string)$listvalue->Значение,
						"DEF" => "N",
						"SORT" => $sort,
						"XML_ID" => CUtil::translit($listvalue->Значение, "ru", $translitParams)
					);
					$s++;
	    		endif;
	    	endforeach;
		elseif ($id1c == "IMAGES"):
			$arFields["PROPERTY_TYPE"] = "F";
			$arFields["MULTIPLE"] = "Y";
		elseif ($id1c == "ARTIKUL"):
			$arFields["SEARCHABLE"] = "Y";
		elseif ($id1c == "SORT_NEW" || $id1c == "SORT_SALE"):
			$arFields["PROPERTY_TYPE"] = "N";
		else:
			$arFields["PROPERTY_TYPE"] = "S";
		endif;
		return $arFields;
	}
开发者ID:akniyev,项目名称:arteva.ru,代码行数:50,代码来源:addPropertyIblock.php

示例11: bildSections

	/**
	 * [bildSections description]
	 * @param  object $section
	 * @param  int $lvl
	 * @return array
	 */
	protected function bildSections($section, $lvl, $idParent){
		$s = intval($lvl);
		$i = 1;
		foreach ($section->Группа as $sec) :
			//set_time_limit(10);
			$sort = $sec->CML2_SORT;
			$code = CUtil::translit($sec->Наименование, "ru", $this->translitParams());
			foreach ($this->arSectionsIblock as $key => $arSections) :
				if ($code == $arSections["CODE"] && $idParent == $arSections["IBLOCK_SECTION_ID"]):
					unset($this->arSectionsIblock[$key]);
				endif;
			endforeach;
			$rec = $this->addSection($sec, $s, $idParent, $sort);
			if ($rec["result"] === true):
				$result[] = $rec;
				if (!empty($sec->Группы) && isset($sec->Группы)):
					$s++;
					$this->bildSections($sec->Группы, $s, $rec["id"]);
				endif;
			endif;
			$i++;
		endforeach;
		return $result;
	}
开发者ID:akniyev,项目名称:arteva.ru,代码行数:30,代码来源:addSections.php

示例12: getPdfFile

/**
 * [getPdfFile generate and save PDF file]
 * @param  int $idSpec
 * @return str or false
 */
function getPdfFile($idSpec)
{
    $arSpecification = getSpecification($idSpec);
    if ($arSpecification) {
        $allSumSpec = "";
        foreach ($arSpecification["ITEMS"] as $key => $arItems) {
            $allSumSpec += $arItems["DISCOUNT"]["PRICE"] * $arItems["PROPERTY_COUNT_VALUE"];
            $totalPrice += $arItems["DISCOUNT"]["DISCOUNT_PRICE"] * $arItems["PROPERTY_COUNT_VALUE"];
            $allDisSpec += $arItems["DISCOUNT"]["PRICE"] - $arItems["DISCOUNT"]["DISCOUNT_PRICE"];
            $allSumminDisSpec += $arItems["DISCOUNT"]["DISCOUNT_PRICE"] * $arItems["PROPERTY_COUNT_VALUE"];
        }
        include_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/php_interface/include/tcpdf/tcpdf.php";
        $curDate = date("d.m.Y H:i:s");
        global $USER;
        $name = $USER->GetFirstName() . "_" . $USER->GetLastName() . "_" . str_replace(" ", "_", $arSpecification["NAME"]) . "_" . $curDate;
        $nameFile = CUtil::translit($name, "ru", translitParams());
        // create new PDF document
        $pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
        $fontname = TCPDF_FONTS::addTTFfont($_SERVER["DOCUMENT_ROOT"] . "/bitrix/php_interface/include/tcpdf/font_arial/arial.ttf", '', '', 32);
        // set document information
        $pdf->SetAuthor($USER->GetFirstName() . " " . $USER->GetLastName());
        $pdf->SetTitle("Спецификация " . $arSpecification["NAME"]);
        // set font
        $pdf->SetFont($fontname, 'BI', 12);
        // add a page
        $pdf->AddPage();
        $text = "Спецификация: №" . $arSpecification["ID"];
        $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
        $text = "Дизайнер: " . $USER->GetFirstName() . " " . $USER->GetLastName();
        $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
        $text = "Название спецификации: " . $arSpecification["NAME"];
        $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
        $text = "Стоимость товаров: " . number_format($allSumSpec, 0, 0, " ") . " руб.";
        $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
        $text = "Со скидкой: " . number_format($allSumminDisSpec, 0, 0, " ") . " руб.";
        $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
        $text = "Экономия: " . number_format($allDisSpec, 0, 0, " ") . " руб.";
        $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
        $text = "ИТОГО: " . number_format($totalPrice, 0, 0, " ") . " руб.";
        $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
        $text = "Продукты:";
        $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
        foreach ($arSpecification["ITEMS"] as $key => $arItems) {
            $text = $key + 1 . ". Артикул: " . $arItems["PRODUCT"]["PROPERTY_ARTIKUL_VALUE"];
            $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
            $text = "    Идентификатор продукта: " . $arItems["PRODUCT"]["ID"];
            $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
            $text = "    Название: " . $arItems["PRODUCT"]["NAME"];
            $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
            $text = "    Цена: " . number_format($arItems["DISCOUNT"]["DISCOUNT_PRICE"], 0, 0, " ") . " руб.";
            $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
            $text = "    Количество: " . $arItems["PROPERTY_COUNT_VALUE"];
            $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
        }
        $filePath = $_SERVER["DOCUMENT_ROOT"] . "/upload/spec_files/" . $nameFile . ".pdf";
        $path = "/upload/spec_files/" . $nameFile . ".pdf";
        //Close and save PDF document
        $pdf->Output($filePath, 'F');
        return $path;
    }
    return false;
}
开发者ID:akniyev,项目名称:arteva.ru,代码行数:67,代码来源:specifications.php

示例13: importElement

    private function importElement($arItems, $IBLOCK_ID = 0, $event = 'element')
    {
        if (!$IBLOCK_ID)
        {
            $IBLOCK_ID = $this->CATALOG_ID;
        }
        $arResult = array();
        $arOffers = array();

        $el = new \CIBlockElement;
        foreach ($arItems as $arItem)
        {
            if (!strlen($arItem['XML_ID']))
            {
                throw new \Exception('Empty element XML ID '.$arItem['name']);
            }
            $boolUpdate = true;

            if (!strlen($arItem['CODE']))
            {
                $arItem['CODE'] = \CUtil::translit($arItem['NAME'], 'ru', array(
                    "replace_space" => '-',
                    "replace_other" => '-'
                ));
            }
            $arLoadProduct = array(
                'ACTIVE'      => $arItem['ACTIVE'],
                'XML_ID'      => $arItem['XML_ID'],
                'NAME'        => $arItem['NAME'],
                'CODE'        => $arItem['CODE'],
                'DETAIL_TEXT' => $arItem['DESCRIPTION'],
            );
            $params = array(
                'select' => array('ID', 'ACTIVE'),
                'filter' => array(
                    '=IBLOCK_ID' => $IBLOCK_ID,
                    '=XML_ID'    => $arItem['XML_ID']
                )
            );
            $arElem = ElementTable::getRow($params);
            if ($arElem['ID'] > 0)
            {
                $boolUpdate = !App::compareHash($arItem);
                if ($boolUpdate || $arItem['ACTIVE'] !== $arElem['ACTIVE'])
                {
                    $el->Update($arElem['ID'], $arLoadProduct);
                    Report::update($event);
                }
            }
            else
            {
                $arSection = $this->getSectionByXML($arItem['SECTION_XML_ID'], $IBLOCK_ID);
                if (!$arSection['ID'])
                {
                    throw new \Exception('Cant find section with XML ID: '.$arItem['SECTION_XML_ID']);
                }
                $arLoadProduct = array_merge($arLoadProduct, array(
                    'IBLOCK_SECTION_ID' => $arSection['ID'],
                    'IBLOCK_ID'         => $IBLOCK_ID
                ));
                $arElem['ID'] = $el->Add($arLoadProduct);

                App::compareHash($arItem);
                Report::create($event);
            }

            // если элемент не нашли и не создали, выплюнем эксепшен
            if (!$arElem['ID'])
            {
                throw new \Exception('Cant create element');
            }
            $arResult[$arItem['XML_ID']] = $arElem['ID'];

            if ($boolUpdate)
            {
                $arCatalogProduct = array(
                    "ID"     => $arElem['ID'],
                    "WEIGHT" => $arItem['WEIGHT']
                );
                \CCatalogProduct::Add($arCatalogProduct);                      // добавим элемент в каталог
                \CPrice::SetBasePrice($arElem['ID'], $arItem['PRICE'], "RUB"); // установим базовую цену

                $arOfferProp = array();
                if (!empty($arItem['MODIFIERS']))
                {
                    foreach ($arItem['MODIFIERS'] as $arMod)
                    {
                        $arOfferProp[] = array(
                            'XML_ID'       => $this->defaultSectionID,
                            'VALUE_XML_ID' => $arMod['XML_ID'],
                            'REQUIRED'     => $arMod['REQUIRED']
                        );
                    }
                }
                if (!empty($arItem['GROUP_MODIFIERS'])) // тут то же самое, только нужно создать ТП из всего свойства, а не из конкретного значения
                {
                    foreach ($arItem['GROUP_MODIFIERS'] as $arMod)
                    {
                        $arOfferProp[] = array(
                            'XML_ID'       => $arMod['XML_ID'],
//.........这里部分代码省略.........
开发者ID:phwb,项目名称:ugraweb.iiko,代码行数:101,代码来源:import.php

示例14: importIBEl


//.........这里部分代码省略.........
				$el_dA 				= $this->convertArrImport($TYPE, $get_json);
				$el_d				= $el_dA[$el_k];
				
				/* Заголовки */
				if(is_array($el_d['title']))
				{
					$el_title = $el_d['title']['value'];
					unset($el_d['title']);
				}
				elseif(is_array($el_d['name']))
				{
					$el_title = $el_d['name']['value'];
					unset($el_d['name']);
				}
				
				/* Описание */
				if(is_array($el_d['description'])):
					$el_description = nl2br(str_replace($this->getDescStr(), '', $el_d['description']['value']));
					unset($el_d['description']);
				endif;
				
				foreach($el_d AS $el_prop_k => $el_prop_v)
				{
					$PROP[$el_prop_k] = $this->dataChange($el_prop_k, $el_prop_v['value']);
				}
				
				/* Изображения */
				if($TYPE == 'agent')
				{
					$PROP['photo'] = $this->convertArrImport('agentphoto',$this->getJson('agentphoto', array('agent_id' => $el_k, 'width' => '500', 'height' => '500', 'crop' => '0')));
				}
				elseif($TYPE == 'estate')
				{
					$getCoverSize = $this->getCoverSize();
					$PROP['estatecoverphoto'] 	= $this->convertArrImport('estatecoverphoto',$this->getJson('estatecoverphoto', array('estate_id' => $el_k, 'width' => $getCoverSize['width'], 'height' => $getCoverSize['height'], 'crop' => '1', 'watermark' => $this->getWRK())));
					$PROP['estatephoto'] 		= $this->convertArrImport('estatephoto',$this->getJson('estatephoto', array('estate_id' => $el_k, 'width' => '800', 'height' => '600', 'crop' => '0', 'watermark' => $this->getWRK())));
					$PROP['estatephotolayout'] 	= $this->convertArrImport('estatephotolayout',$this->getJson('estatephotolayout', array('estate_id' => $el_k, 'width' => '800', 'height' => '600', 'crop' => '0', 'watermark' => $this->getWRK())));
					if($PROP['edit_date'] == '') 		$PROP['edit_date'] 		= $PROP['creation_date'];
					if($PROP['edit_datetime'] == '') 	$PROP['edit_datetime'] 	= $PROP['creation_datetime'];
				}
				
				/* Добавляем свойства которых нет */
				$this->checkIBProps($TYPE, $el_d);
				
				$el_code = CUtil::translit($el_title.'_'.$el_k, "ru" , array(
					"max_len" 				=> "100",
					"change_case" 			=> "L",
					"replace_space" 		=> "_",
					"replace_other" 		=> "_",
					"delete_repeat_replace" => "true",
					"use_google" 			=> "false",
				));
				
				$arEl = array(
					"MODIFIED_BY" 		=> $GLOBALS['USER']->GetID(),
					"IBLOCK_ID" 		=> $IBLOCK_ID,
					"NAME" 				=> $el_title,
					"CODE" 				=> $el_code,
					"DETAIL_TEXT" 		=> $el_description,
					"DETAIL_TEXT_TYPE" 	=> 'html',
				);
				
				$el = new CIBlockElement;
				
				if(in_array($el_k, $arrIDs['UPD']))
				{
					$cur_id = $el->Update($elDbId, $arEl);
					foreach($PROP AS $PROP_k => $PROP_v)
					{
						CIBlockElement::SetPropertyValues($elDbId, $IBLOCK_ID, $PROP_v, $PROP_k);
					}
					unset($arrIDs['UPD'][$el_k]);
				}
				
				if(in_array($el_k, $arrIDs['NEW']))
				{
					$arEl["PROPERTY_VALUES"] = $PROP;
					$cur_id = $el->Add($arEl);
					unset($arrIDs['NEW'][$el_k]);
				}
				
				$el_count--;
				
				//if($el->LAST_ERROR) AddMessage2Log('Ошибка на типе ' . $TYPE . ': ' . $el->LAST_ERROR);
			}
			
			//AddMessage2Log('Прошло сек '. $LeftTime . ' при времени шага '.$StepTime);
			//AddMessage2Log('Сброс цикла на типе '. $TYPE .' при количестве элементов '.$el_count);
			
			COption::SetOptionString(self::$module_id, 'pr_recrm_start_upd', time());
			$this->tmpDb($arrIDs);
			if($CRON === 'Y') $this->importIBEl('Y', $TYPES); // если крон - рекурсия
			return array(
				'MESS' 	=> GetMessage("PR_RECRM_STATUS_WHAT") . ': "'.prReCrmProps::getTypes('name', $TYPE).'", '.GetMessage("PR_RECRM_STATUS_COUNT").': '.$el_count.'.',
				'STEP' 	=> $STEP,
				'IBT' 	=> $TYPES_G,
			);
		}

	}
开发者ID:ASDAFF,项目名称:bitrix-pr.recrm,代码行数:101,代码来源:prReCrmData.class.php

示例15: xml2id

 private function xml2id($xml)
 {
     $id = CUtil::translit($xml, LANGUAGE_ID, array("max_len" => 50, "change_case" => false, "replace_space" => '_', "replace_other" => '_', "delete_repeat_replace" => true));
     $id = trim($id);
     $id = preg_replace("/([^A-Za-z0-9]+)/", "", $id);
     return $id;
 }
开发者ID:Satariall,项目名称:izurit,代码行数:7,代码来源:class.php


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