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


PHP CIBlock::NumberFormat方法代码示例

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


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

示例1: GetProperties

 /**
  * @param bool|array $arOrder
  * @param array $arFilter
  * @return array
  */
 function GetProperties($arOrder = false, $arFilter = array())
 {
     if ($arOrder === false) {
         $arOrder = array("sort" => "asc", "id" => "asc", "enum_sort" => "asc", "value_id" => "asc");
     }
     if (count($arFilter) == 0 && is_array($this->props)) {
         $arAllProps = array();
         foreach ($this->props as $arProp) {
             if (strlen(trim($arProp["CODE"])) > 0) {
                 $PIND = $arProp["CODE"];
             } else {
                 $PIND = $arProp["ID"];
             }
             $arProp["VALUE"] = $this->fields["PROPERTY_" . $arProp["ID"]];
             $arProp["DESCRIPTION"] = $this->fields["DESCRIPTION_" . $arProp["ID"]];
             if ($arProp["MULTIPLE"] == "N") {
                 if ($arProp["PROPERTY_TYPE"] == "L") {
                     $arProp["VALUE_ENUM_ID"] = $val = $arProp["VALUE"];
                     $arEnum = CIBlockPropertyEnum::GetByID($val);
                     if ($arEnum !== false) {
                         $arProp["~VALUE"] = $arEnum["VALUE"];
                         if (is_array($arProp["VALUE"]) || preg_match("/[;&<>\"]/", $arProp["VALUE"])) {
                             $arProp["VALUE"] = htmlspecialcharsex($arEnum["VALUE"]);
                         } else {
                             $arProp["VALUE"] = $arEnum["VALUE"];
                         }
                         $arProp["VALUE_ENUM"] = $arProp["VALUE"];
                         $arProp["VALUE_XML_ID"] = htmlspecialcharsex($arEnum["XML_ID"]);
                         $arProp["VALUE_SORT"] = $arEnum["SORT"];
                     } else {
                         $arProp["~VALUE"] = "";
                         $arProp["VALUE"] = "";
                     }
                 } elseif (is_array($arProp["VALUE"]) || strlen($arProp["VALUE"])) {
                     if ($arProp["PROPERTY_TYPE"] == "N") {
                         $arProp["VALUE"] = htmlspecialcharsex(CIBlock::NumberFormat($arProp["VALUE"]));
                     }
                     $arProp["~VALUE"] = $this->fields["~PROPERTY_" . $arProp["ID"]];
                     $arProp["~DESCRIPTION"] = $this->fields["~DESCRIPTION_" . $arProp["ID"]];
                 } else {
                     $arProp["VALUE"] = $arProp["~VALUE"] = "";
                     $arProp["DESCRIPTION"] = $arProp["~DESCRIPTION"] = "";
                 }
             } else {
                 $arList = $arProp["VALUE"];
                 $arListTilda = $this->fields["~PROPERTY_" . $arProp["ID"]];
                 if ($arProp["PROPERTY_TYPE"] == "L") {
                     $arProp["~VALUE"] = $arProp["VALUE"] = $arProp["VALUE_ENUM_ID"] = false;
                     $arProp["VALUE_XML_ID"] = false;
                     foreach ($arList as $key => $val) {
                         if (strlen($val) > 0) {
                             $arEnum = CIBlockPropertyEnum::GetByID($key);
                             if ($arEnum !== false) {
                                 $xml_id = htmlspecialcharsex($arEnum["XML_ID"]);
                                 $sort = $arEnum["SORT"];
                             } else {
                                 $xml_id = false;
                                 $sort = false;
                             }
                             if (is_array($arProp["VALUE"])) {
                                 $arProp["VALUE_ENUM_ID"][] = $key;
                                 $arProp["~VALUE"][] = $val;
                                 if (is_array($val) || preg_match("/[;&<>\"]/", $val)) {
                                     $arProp["VALUE"][] = htmlspecialcharsex($val);
                                 } else {
                                     $arProp["VALUE"][] = $val;
                                 }
                                 $arProp["VALUE_XML_ID"][] = $xml_id;
                                 $arProp["VALUE_SORT"][] = $sort;
                             } else {
                                 $arProp["VALUE_ENUM_ID"] = array($key);
                                 $arProp["~VALUE"] = array($val);
                                 if (is_array($val) || preg_match("/[;&<>\"]/", $val)) {
                                     $arProp["VALUE"] = array(htmlspecialcharsex($val));
                                 } else {
                                     $arProp["VALUE"] = array($val);
                                 }
                                 $arProp["VALUE_XML_ID"] = array($xml_id);
                                 $arProp["VALUE_SORT"] = array($sort);
                             }
                         }
                     }
                     $arProp["VALUE_ENUM"] = $arProp["VALUE"];
                 } else {
                     $arDesc = $arProp["DESCRIPTION"];
                     $arDescTilda = $this->fields["~DESCRIPTION_" . $arProp["ID"]];
                     $arProp["~VALUE"] = $arProp["VALUE"] = false;
                     $arProp["~DESCRIPTION"] = $arProp["DESCRIPTION"] = false;
                     foreach ($arList as $key => $val) {
                         if (is_array($val) || strlen($val) > 0) {
                             if (is_array($arProp["VALUE"])) {
                                 $arProp["~VALUE"][] = $arListTilda[$key];
                                 if ($arProp["PROPERTY_TYPE"] == "N") {
                                     $val = htmlspecialcharsex(CIBlock::NumberFormat($val));
                                 }
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:iblock_element.php

示例2: Fetch

 function Fetch()
 {
     /** @global CCacheManager $CACHE_MANAGER */
     global $CACHE_MANAGER;
     /** @global CDatabase $DB */
     global $DB;
     $res = parent::Fetch();
     if (!is_object($this)) {
         return $res;
     }
     $arUpdate = array();
     if ($res) {
         if (is_array($this->arIBlockLongProps)) {
             foreach ($res as $k => $v) {
                 if (preg_match("#^ALIAS_(\\d+)_(.*)\$#", $k, $match)) {
                     $res[$this->arIBlockLongProps[$match[1]] . $match[2]] = $v;
                     unset($res[$k]);
                 }
             }
         }
         if (isset($res["IBLOCK_ID"]) && defined("BX_COMP_MANAGED_CACHE") && $res["IBLOCK_ID"] != $this->_LAST_IBLOCK_ID) {
             CIBlock::registerWithTagCache($res["IBLOCK_ID"]);
             $this->_LAST_IBLOCK_ID = $res["IBLOCK_ID"];
         }
         if (isset($res["ID"]) && $res["ID"] != "" && is_array($this->arIBlockMultProps)) {
             foreach ($this->arIBlockMultProps as $field_name => $db_prop) {
                 if (array_key_exists($field_name, $res)) {
                     if (is_object($res[$field_name])) {
                         $res[$field_name] = $res[$field_name]->load();
                     }
                     if (preg_match("/(_VALUE)\$/", $field_name)) {
                         $descr_name = preg_replace("/(_VALUE)\$/", "_DESCRIPTION", $field_name);
                     } else {
                         $descr_name = preg_replace("/^(PROPERTY_)/", "DESCRIPTION_", $field_name);
                     }
                     if (strlen($res[$field_name]) <= 0) {
                         $strSql = "\n\t\t\t\t\t\t\t\tSELECT VALUE,DESCRIPTION\n\t\t\t\t\t\t\t\tFROM b_iblock_element_prop_m" . $db_prop["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\tIBLOCK_ELEMENT_ID = " . intval($res["ID"]) . "\n\t\t\t\t\t\t\t\t\tAND IBLOCK_PROPERTY_ID = " . intval($db_prop["ORIG_ID"]) . "\n\t\t\t\t\t\t\t\tORDER BY ID\n\t\t\t\t\t\t\t";
                         $rs = $DB->Query($strSql);
                         $res[$field_name] = array();
                         $res[$descr_name] = array();
                         while ($ar = $rs->Fetch()) {
                             $res[$field_name][] = $ar["VALUE"];
                             $res[$descr_name][] = $ar["DESCRIPTION"];
                         }
                         $arUpdate["b_iblock_element_prop_s" . $db_prop["IBLOCK_ID"]]["PROPERTY_" . $db_prop["ORIG_ID"]] = serialize(array("VALUE" => $res[$field_name], "DESCRIPTION" => $res[$descr_name]));
                     } else {
                         $tmp = unserialize($res[$field_name]);
                         $res[$field_name] = $tmp["VALUE"];
                         $res[$descr_name] = $tmp["DESCRIPTION"];
                     }
                     if (is_array($res[$field_name]) && $db_prop["PROPERTY_TYPE"] == "L") {
                         $arTemp = array();
                         foreach ($res[$field_name] as $key => $val) {
                             $arEnum = CIBlockPropertyEnum::GetByID($val);
                             if ($arEnum !== false) {
                                 $arTemp[$val] = $arEnum["VALUE"];
                             }
                         }
                         $res[$field_name] = $arTemp;
                     }
                 }
             }
             foreach ($arUpdate as $strTable => $arFields) {
                 $strUpdate = $DB->PrepareUpdate($strTable, $arFields);
                 if ($strUpdate != "") {
                     $strSql = "UPDATE " . $strTable . " SET " . $strUpdate . " WHERE IBLOCK_ELEMENT_ID = " . intval($res["ID"]);
                     $DB->QueryBind($strSql, $arFields);
                 }
             }
         }
         if (is_array($this->arIBlockConvProps)) {
             foreach ($this->arIBlockConvProps as $strFieldName => $arCallback) {
                 if (is_array($res[$strFieldName])) {
                     foreach ($res[$strFieldName] as $key => $value) {
                         $arValue = call_user_func_array($arCallback["ConvertFromDB"], array($arCallback["PROPERTY"], array("VALUE" => $value, "DESCRIPTION" => "")));
                         $res[$strFieldName][$key] = $arValue["VALUE"];
                     }
                 } else {
                     $arValue = call_user_func_array($arCallback["ConvertFromDB"], array($arCallback["PROPERTY"], array("VALUE" => $res[$strFieldName], "DESCRIPTION" => "")));
                     $res[$strFieldName] = $arValue["VALUE"];
                 }
             }
         }
         if (is_array($this->arIBlockNumProps)) {
             foreach ($this->arIBlockNumProps as $field_name => $db_prop) {
                 if (strlen($res[$field_name]) > 0) {
                     $res[$field_name] = htmlspecialcharsex(CIBlock::NumberFormat($res[$field_name]));
                 }
             }
         }
         if (isset($res["UC_ID"])) {
             $res["CREATED_BY_FORMATTED"] = CUser::FormatName($this->nameTemplate, array("NAME" => $res["UC_NAME"], "LAST_NAME" => $res["UC_LAST_NAME"], "SECOND_NAME" => $res["UC_SECOND_NAME"], "EMAIL" => $res["UC_EMAIL"], "ID" => $res["UC_ID"], "LOGIN" => $res["UC_LOGIN"]), true, false);
             unset($res["UC_NAME"]);
             unset($res["UC_LAST_NAME"]);
             unset($res["UC_SECOND_NAME"]);
             unset($res["UC_EMAIL"]);
             unset($res["UC_ID"]);
             unset($res["UC_LOGIN"]);
         }
     } elseif (defined("BX_COMP_MANAGED_CACHE") && $this->_LAST_IBLOCK_ID == "" && count($this->_FILTER_IBLOCK_ID)) {
//.........这里部分代码省略.........
开发者ID:spas-viktor,项目名称:books,代码行数:101,代码来源:iblockresult.php

示例3: GetProperty


//.........这里部分代码省略.........
             } elseif ($by == "id") {
                 $arSqlOrder["BP.ID"] = $order;
             } elseif ($by == "name") {
                 $arSqlOrder["BP.NAME"] = $order;
             } elseif ($by == "active") {
                 $arSqlOrder["BP.ACTIVE"] = $order;
             } elseif ($by == "value_id") {
                 $arSqlOrder["BEP.ID"] = $order;
             } elseif ($by == "enum_sort") {
                 $arSqlOrder["BEPE.SORT"] = $order;
             } else {
                 $arSqlOrder["BP.SORT"] = $order;
             }
         }
     } else {
         if ($by == "id") {
             $arSqlOrder["BP.ID"] = "asc";
         } elseif ($by == "name") {
             $arSqlOrder["BP.NAME"] = "asc";
         } elseif ($by == "active") {
             $arSqlOrder["BP.ACTIVE"] = "asc";
         } elseif ($by == "value_id") {
             $arSqlOrder["BEP.ID"] = $order;
         } elseif ($by == "enum_sort") {
             $arSqlOrder["BEPE.SORT"] = $order;
         } else {
             $arSqlOrder["BP.SORT"] = "asc";
             $by = "sort";
         }
         if ($order != "desc") {
             $arSqlOrder["BP.SORT"] = "asc";
             $arSqlOrder["BP.ID"] = "asc";
             $arSqlOrder["BEPE.SORT"] = "asc";
             $arSqlOrder["BEP.ID"] = "asc";
             $order = "asc";
         } else {
             $arSqlOrder["BP.SORT"] = "desc";
             $arSqlOrder["BP.ID"] = "desc";
             $arSqlOrder["BEPE.SORT"] = "desc";
             $arSqlOrder["BEP.ID"] = "desc";
         }
     }
     $strSqlOrder = "";
     foreach ($arSqlOrder as $key => $val) {
         $strSqlOrder .= ", " . $key . " " . $val;
     }
     if ($strSqlOrder != "") {
         $strSqlOrder = ' ORDER BY ' . substr($strSqlOrder, 1);
     }
     if ($VERSION == 2) {
         $strTable = "b_iblock_element_prop_m" . $IBLOCK_ID;
     } else {
         $strTable = "b_iblock_element_property";
     }
     $strSql = "\n\t\t\tSELECT BP.*, BEP.ID as PROPERTY_VALUE_ID, BEP.VALUE, BEP.DESCRIPTION, BEPE.VALUE VALUE_ENUM, BEPE.XML_ID VALUE_XML_ID, BEPE.SORT VALUE_SORT\n\t\t\tFROM b_iblock B\n\t\t\t\tINNER JOIN b_iblock_property BP ON B.ID=BP.IBLOCK_ID\n\t\t\t\tLEFT JOIN " . $strTable . " BEP ON (BP.ID = BEP.IBLOCK_PROPERTY_ID AND BEP.IBLOCK_ELEMENT_ID = " . $ELEMENT_ID . ")\n\t\t\t\tLEFT JOIN b_iblock_property_enum BEPE ON (BP.PROPERTY_TYPE = 'L' AND BEPE.ID=BEP.VALUE_ENUM AND BEPE.PROPERTY_ID=BP.ID)\n\t\t\tWHERE B.ID = " . $IBLOCK_ID . "\n\t\t\t\t" . $strSqlSearch . "\n\t\t\t" . $strSqlOrder;
     if ($VERSION == 2) {
         $result = array();
         $arElements = array();
         $rs = $DB->Query($strSql);
         while ($ar = $rs->Fetch()) {
             if ($ar["VERSION"] == 2 && $ar["MULTIPLE"] == "N") {
                 if (!array_key_exists($ELEMENT_ID, $arElements)) {
                     $strSql = "\n\t\t\t\t\t\t\tSELECT *\n\t\t\t\t\t\t\tFROM b_iblock_element_prop_s" . $ar["IBLOCK_ID"] . "\n\t\t\t\t\t\t\tWHERE IBLOCK_ELEMENT_ID = " . $ELEMENT_ID . "\n\t\t\t\t\t\t";
                     $rs2 = $DB->Query($strSql);
                     $arElements[$ELEMENT_ID] = $rs2->Fetch();
                 }
                 if (!isset($arFilter["EMPTY"]) || $arFilter["EMPTY"] == "Y" || strlen($arElements[$ELEMENT_ID]["PROPERTY_" . $ar["ID"]]) > 0) {
                     $val = $arElements[$ELEMENT_ID]["PROPERTY_" . $ar["ID"]];
                     $ar["PROPERTY_VALUE_ID"] = $ELEMENT_ID . ":" . $ar["ID"];
                     if ($ar["PROPERTY_TYPE"] == "L" && intval($val) > 0) {
                         $arEnum = CIBlockPropertyEnum::GetByID($val);
                         if ($arEnum !== false) {
                             $ar["VALUE_ENUM"] = $arEnum["VALUE"];
                             $ar["VALUE_XML_ID"] = $arEnum["XML_ID"];
                             $ar["VALUE_SORT"] = $arEnum["SORT"];
                         }
                     } else {
                         $ar["VALUE_ENUM"] = "";
                     }
                     if ($ar["PROPERTY_TYPE"] == "N" && strlen($val) > 0) {
                         $val = CIBlock::NumberFormat($val);
                     }
                     $ar["DESCRIPTION"] = $arElements[$ELEMENT_ID]["DESCRIPTION_" . $ar["ID"]];
                     $ar["VALUE"] = $val;
                 } else {
                     continue;
                 }
             }
             if ($arFilter["EMPTY"] == "N" && $ar["PROPERTY_VALUE_ID"] == "") {
                 continue;
             }
             $result[] = $ar;
         }
         $rs = new CIBlockPropertyResult();
         $rs->InitFromArray($result);
     } else {
         $rs = new CIBlockPropertyResult($DB->Query($strSql));
     }
     return $rs;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:iblockelement.php

示例4: Fetch

 function Fetch()
 {
     global $DB;
     if (isset($this->lastRes)) {
         $res = $this->lastRes;
         $this->lastRes = null;
     } else {
         $res = parent::Fetch();
     }
     if ($res && $res["USER_TYPE"] != "") {
         $arUserType = CIBlockProperty::GetUserType($res["USER_TYPE"]);
         if (isset($arUserType["ConvertFromDB"])) {
             if (array_key_exists("VALUE", $res)) {
                 $value = array("VALUE" => $res["VALUE"], "DESCRIPTION" => "");
                 $value = call_user_func_array($arUserType["ConvertFromDB"], array($res, $value));
                 $res["VALUE"] = $value["VALUE"];
             }
             if (array_key_exists("DEFAULT_VALUE", $res)) {
                 $value = array("VALUE" => $res["DEFAULT_VALUE"], "DESCRIPTION" => "");
                 $value = call_user_func_array($arUserType["ConvertFromDB"], array($res, $value));
                 $res["DEFAULT_VALUE"] = $value["VALUE"];
             }
         }
         if (strlen($res["USER_TYPE_SETTINGS"])) {
             $res["USER_TYPE_SETTINGS"] = unserialize($res["USER_TYPE_SETTINGS"]);
         }
     }
     if ($res && !empty($this->arProperties)) {
         $this->initPropertiesValues($res["IBLOCK_ELEMENT_ID"]);
         if ($this->VERSION == 2) {
             $arUpdate = array();
             foreach ($this->arProperties as $arProp) {
                 $field_name = "PROPERTY_" . $arProp["ID"];
                 if ($arProp["MULTIPLE"] == "Y") {
                     $descr_name = "DESCRIPTION_" . $arProp["ID"];
                     $value_id_name = "PROPERTY_VALUE_ID_" . $arProp["ID"];
                     if (is_object($res[$field_name])) {
                         $res[$field_name] = $res[$field_name]->load();
                     }
                     $update = false;
                     if (strlen($res[$field_name]) <= 0) {
                         $update = true;
                     } else {
                         $tmp = unserialize($res[$field_name]);
                         if (!isset($tmp['ID'])) {
                             $update = true;
                         }
                     }
                     if ($update) {
                         $strSql = "\n\t\t\t\t\t\t\t\tSELECT ID, VALUE, DESCRIPTION\n\t\t\t\t\t\t\t\tFROM b_iblock_element_prop_m" . $arProp["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\tIBLOCK_ELEMENT_ID = " . (int) $res["IBLOCK_ELEMENT_ID"] . "\n\t\t\t\t\t\t\t\t\tAND IBLOCK_PROPERTY_ID = " . (int) $arProp["ID"] . "\n\t\t\t\t\t\t\t\tORDER BY ID\n\t\t\t\t\t\t\t";
                         $rs = $DB->Query($strSql);
                         $res[$field_name] = array();
                         $res[$descr_name] = array();
                         $res[$value_id_name] = array();
                         while ($ar = $rs->Fetch()) {
                             $res[$field_name][] = $ar["VALUE"];
                             $res[$descr_name][] = $ar["DESCRIPTION"];
                             $res[$value_id_name][] = $ar['ID'];
                         }
                         $arUpdate["b_iblock_element_prop_s" . $arProp["IBLOCK_ID"]]["PROPERTY_" . $arProp["ID"]] = serialize(array("VALUE" => $res[$field_name], "DESCRIPTION" => $res[$descr_name], "ID" => $res[$value_id_name]));
                     } else {
                         $res[$field_name] = $tmp["VALUE"];
                         $res[$descr_name] = $tmp["DESCRIPTION"];
                         $res[$value_id_name] = $tmp["ID"];
                     }
                     if ($this->extMode) {
                         foreach ($res[$field_name] as $field_key => $VALUE) {
                             $this->addPropertyValue($arProp["ID"], $VALUE);
                             $this->addPropertyData($arProp["ID"], $res[$value_id_name][$field_key], $res[$descr_name][$field_key]);
                         }
                     } else {
                         foreach ($res[$field_name] as $VALUE) {
                             $this->addPropertyValue($arProp["ID"], $VALUE);
                         }
                     }
                 } else {
                     if ($res[$field_name] != "") {
                         if ($this->extMode && $arProp["PROPERTY_TYPE"] == PropertyTable::TYPE_NUMBER) {
                             $res[$field_name] = CIBlock::NumberFormat($res[$field_name]);
                         }
                         $this->addPropertyValue($arProp["ID"], $res[$field_name]);
                     }
                     if ($this->extMode) {
                         $this->addPropertyData($arProp["ID"], $res["IBLOCK_ELEMENT_ID"] . ':' . $arProp["ID"], $res["DESCRIPTION_" . $arProp["ID"]]);
                     }
                 }
             }
             foreach ($arUpdate as $strTable => $arFields) {
                 $strUpdate = $DB->PrepareUpdate($strTable, $arFields);
                 if ($strUpdate != "") {
                     $strSql = "UPDATE " . $strTable . " SET " . $strUpdate . " WHERE IBLOCK_ELEMENT_ID = " . intval($res["IBLOCK_ELEMENT_ID"]);
                     $DB->QueryBind($strSql, $arFields);
                 }
             }
             $res = $this->arPropertiesValues;
             if ($this->extMode) {
                 $res['PROPERTY_VALUE_ID'] = $this->arPropertyValuesID;
                 $res['DESCRIPTION'] = $this->arDescriptions;
             }
         } else {
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:iblockpropresult.php


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