當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CList::addField方法代碼示例

本文整理匯總了PHP中CList::addField方法的典型用法代碼示例。如果您正苦於以下問題:PHP CList::addField方法的具體用法?PHP CList::addField怎麽用?PHP CList::addField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CList的用法示例。


在下文中一共展示了CList::addField方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: AddDocumentField

 public function AddDocumentField($documentType, $fields)
 {
     $iblockId = intval(substr($documentType, strlen("iblock_")));
     if ($iblockId <= 0) {
         throw new CBPArgumentOutOfRangeException("documentType", $documentType);
     }
     if (substr($fields["code"], 0, strlen("PROPERTY_")) == "PROPERTY_") {
         $fields["code"] = substr($fields["code"], strlen("PROPERTY_"));
     }
     $fieldsTemporary = array("NAME" => $fields["name"], "ACTIVE" => "Y", "SORT" => $fields["sort"] ? $fields["sort"] : 900, "CODE" => $fields["code"], 'MULTIPLE' => $fields['multiple'] == 'Y' || (string) $fields['multiple'] === '1' ? 'Y' : 'N', 'IS_REQUIRED' => $fields['required'] == 'Y' || (string) $fields['required'] === '1' ? 'Y' : 'N', "IBLOCK_ID" => $iblockId, "FILTRABLE" => "Y", "SETTINGS" => $fields["settings"] ? $fields["settings"] : array("SHOW_ADD_FORM" => 'Y', "SHOW_EDIT_FORM" => 'Y'), "DEFAULT_VALUE" => $fields['DefaultValue']);
     if (strpos("0123456789", substr($fieldsTemporary["CODE"], 0, 1)) !== false) {
         $fieldsTemporary["CODE"] = self::generateMnemonicCode($fieldsTemporary["CODE"]);
     }
     if (array_key_exists("additional_type_info", $fields)) {
         $fieldsTemporary["LINK_IBLOCK_ID"] = intval($fields["additional_type_info"]);
     }
     if (strstr($fields["type"], ":") !== false) {
         list($fieldsTemporary["TYPE"], $fieldsTemporary["USER_TYPE"]) = explode(":", $fields["type"], 2);
         if ($fields["type"] == "E:EList") {
             $fieldsTemporary["LINK_IBLOCK_ID"] = $fields["options"];
         }
     } elseif ($fields["type"] == "user") {
         $fieldsTemporary["TYPE"] = "S:employee";
         $fieldsTemporary["USER_TYPE"] = "UserID";
     } elseif ($fields["type"] == "date") {
         $fieldsTemporary["TYPE"] = "S:Date";
         $fieldsTemporary["USER_TYPE"] = "Date";
     } elseif ($fields["type"] == "datetime") {
         $fieldsTemporary["TYPE"] = "S:DateTime";
         $fieldsTemporary["USER_TYPE"] = "DateTime";
     } elseif ($fields["type"] == "file") {
         $fieldsTemporary["TYPE"] = "F";
         $fieldsTemporary["USER_TYPE"] = "";
     } elseif ($fields["type"] == "select") {
         $fieldsTemporary["TYPE"] = "L";
         $fieldsTemporary["USER_TYPE"] = false;
         if (is_array($fields["options"])) {
             $i = 10;
             foreach ($fields["options"] as $k => $v) {
                 $def = "N";
                 if ($fields['DefaultValue'] == $v) {
                     $def = "Y";
                 }
                 $fieldsTemporary["VALUES"][] = array("XML_ID" => $k, "VALUE" => $v, "DEF" => $def, "SORT" => $i);
                 $i = $i + 10;
             }
         } elseif (is_string($fields["options"]) && strlen($fields["options"]) > 0) {
             $a = explode("\n", $fields["options"]);
             $i = 10;
             foreach ($a as $v) {
                 $v = trim(trim($v), "\r\n");
                 if (!$v) {
                     continue;
                 }
                 $v1 = $v2 = $v;
                 if (substr($v, 0, 1) == "[" && strpos($v, "]") !== false) {
                     $v1 = substr($v, 1, strpos($v, "]") - 1);
                     $v2 = trim(substr($v, strpos($v, "]") + 1));
                 }
                 $def = "N";
                 if ($fields['DefaultValue'] == $v2) {
                     $def = "Y";
                 }
                 $fieldsTemporary["VALUES"][] = array("XML_ID" => $v1, "VALUE" => $v2, "DEF" => $def, "SORT" => $i);
                 $i = $i + 10;
             }
         }
     } elseif ($fields["type"] == "string") {
         $fieldsTemporary["TYPE"] = "S";
         if ($fields["row_count"] && $fields["col_count"]) {
             $fieldsTemporary["ROW_COUNT"] = $fields["row_count"];
             $fieldsTemporary["COL_COUNT"] = $fields["col_count"];
         } else {
             $fieldsTemporary["ROW_COUNT"] = 1;
             $fieldsTemporary["COL_COUNT"] = 30;
         }
     } elseif ($fields["type"] == "text") {
         $fieldsTemporary["TYPE"] = "S";
         if ($fields["row_count"] && $fields["col_count"]) {
             $fieldsTemporary["ROW_COUNT"] = $fields["row_count"];
             $fieldsTemporary["COL_COUNT"] = $fields["col_count"];
         } else {
             $fieldsTemporary["ROW_COUNT"] = 4;
             $fieldsTemporary["COL_COUNT"] = 30;
         }
     } elseif ($fields["type"] == "int" || $fields["type"] == "double") {
         $fieldsTemporary["TYPE"] = "N";
     } elseif ($fields["type"] == "bool") {
         $fieldsTemporary["TYPE"] = "L";
         $fieldsTemporary["VALUES"][] = array("XML_ID" => 'yes', "VALUE" => GetMessage("BPVDX_YES"), "DEF" => "N", "SORT" => 10);
         $fieldsTemporary["VALUES"][] = array("XML_ID" => 'no', "VALUE" => GetMessage("BPVDX_NO"), "DEF" => "N", "SORT" => 20);
     } else {
         $fieldsTemporary["TYPE"] = $fields["type"];
         $fieldsTemporary["USER_TYPE"] = false;
     }
     $idField = false;
     $properties = CIBlockProperty::getList(array(), array("IBLOCK_ID" => $fieldsTemporary["IBLOCK_ID"], "CODE" => $fieldsTemporary["CODE"]));
     if (!$properties->fetch()) {
         $listObject = new CList($iblockId);
         $idField = $listObject->addField($fieldsTemporary);
//.........這裏部分代碼省略.........
開發者ID:Satariall,項目名稱:izurit,代碼行數:101,代碼來源:bizprocdocument.php


注:本文中的CList::addField方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。