Example #1
0
 function GetFieldInputValuePrintable($documentType, $arFieldType, $fieldValue)
 {
     $result = $fieldValue;
     switch ($arFieldType['Type']) {
         case "user":
             if (!is_array($fieldValue)) {
                 $fieldValue = array($fieldValue);
             }
             $result = CBPHelper::UsersArrayToString($fieldValue, null, array("iblock", "CIBlockDocument", $documentType));
             break;
         case "bool":
             if (is_array($fieldValue)) {
                 $result = array();
                 foreach ($fieldValue as $r) {
                     $result[] = strtoupper($r) != "N" && !empty($r) ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO");
                 }
             } else {
                 $result = strtoupper($fieldValue) != "N" && !empty($fieldValue) ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO");
             }
             break;
         case "file":
             if (is_array($fieldValue)) {
                 $result = array();
                 foreach ($fieldValue as $r) {
                     $r = intval($r);
                     $dbImg = CFile::GetByID($r);
                     if ($arImg = $dbImg->Fetch()) {
                         $result[] = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($arImg["FILE_NAME"]) . "&i=" . $r . "&h=" . md5($arImg["SUBDIR"]) . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]";
                     }
                 }
             } else {
                 $fieldValue = intval($fieldValue);
                 $dbImg = CFile::GetByID($fieldValue);
                 if ($arImg = $dbImg->Fetch()) {
                     $result = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($arImg["FILE_NAME"]) . "&i=" . $fieldValue . "&h=" . md5($arImg["SUBDIR"]) . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]";
                 }
             }
             break;
         case "select":
             if (is_array($arFieldType["Options"])) {
                 if (is_array($fieldValue)) {
                     $result = array();
                     foreach ($fieldValue as $r) {
                         if (array_key_exists($r, $arFieldType["Options"])) {
                             $result[] = $arFieldType["Options"][$r];
                         }
                     }
                 } else {
                     if (array_key_exists($fieldValue, $arFieldType["Options"])) {
                         $result = $arFieldType["Options"][$fieldValue];
                     }
                 }
             }
             break;
     }
     if (strpos($arFieldType['Type'], ":") !== false) {
         if ($arFieldType["Type"] == "S:employee") {
             $fieldValue = CBPHelper::StripUserPrefix($fieldValue);
         }
         $arCustomType = CIBlockProperty::GetUserType(substr($arFieldType['Type'], 2));
         if (array_key_exists("GetPublicViewHTML", $arCustomType)) {
             if (is_array($fieldValue) && !CBPHelper::IsAssociativeArray($fieldValue)) {
                 $result = array();
                 foreach ($fieldValue as $value) {
                     $r = call_user_func_array($arCustomType["GetPublicViewHTML"], array(array("LINK_IBLOCK_ID" => $arFieldType["Options"]), array("VALUE" => $value), ""));
                     $result[] = HTMLToTxt($r);
                 }
             } else {
                 $result = call_user_func_array($arCustomType["GetPublicViewHTML"], array(array("LINK_IBLOCK_ID" => $arFieldType["Options"]), array("VALUE" => $fieldValue), ""));
                 $result = HTMLToTxt($result);
             }
         }
     }
     return $result;
 }
Example #2
0
 private function FunctionConvert($args)
 {
     if (!is_array($args)) {
         $args = array($args);
     }
     $ar = $this->ArrgsToArray($args);
     $val = array_shift($ar);
     $type = array_shift($ar);
     $attr = array_shift($ar);
     $type = strtolower($type);
     if ($type === 'printableuserb24') {
         $result = array();
         $users = CBPHelper::StripUserPrefix($val);
         if (!is_array($users)) {
             $users = array($users);
         }
         foreach ($users as $userId) {
             $db = CUser::GetByID($userId);
             if ($ar = $db->GetNext()) {
                 $ix = randString(5);
                 $attr = !empty($attr) ? 'href="' . $attr . '"' : 'href="#" onClick="return false;"';
                 $result[] = '<a class="feed-post-user-name" id="bp_' . $userId . '_' . $ix . '" ' . $attr . ' bx-post-author-id="' . $userId . '">' . CUser::FormatName(CSite::GetNameFormat(false), $ar, false) . '</a><script type="text/javascript">BX.tooltip(\'' . $userId . '\', "bp_' . $userId . '_' . $ix . '", "");</script>';
             }
         }
         $result = implode(", ", $result);
     } elseif ($type == 'printableuser') {
         $result = array();
         $users = CBPHelper::StripUserPrefix($val);
         if (!is_array($users)) {
             $users = array($users);
         }
         foreach ($users as $userId) {
             $db = CUser::GetByID($userId);
             if ($ar = $db->GetNext()) {
                 $result[] = CUser::FormatName(CSite::GetNameFormat(false), $ar, false);
             }
         }
         $result = implode(", ", $result);
     } else {
         $result = $val;
     }
     return $result;
 }