Ejemplo n.º 1
0
								$arAnswer["ID"],
								$arAnswer["FIELD_WIDTH"],
								"IMAGE",
								0,
								"",
								$arAnswer["FIELD_PARAM"]);

							$arResult["QUESTIONS"][$FIELD_SID]["HTML_CODE"][] = $res;

							break;
						case "file":
							if (strlen(trim($arAnswer["MESSAGE"]))>0)
							{
								$res .= $arAnswer["MESSAGE"];
							}
							if ($arFile = CFormResult::GetFileByAnswerID($arParams["RESULT_ID"], $arAnswer["ID"]))
							{
								if (intval($arFile["USER_FILE_ID"])>0)
								{
									$res .= "<a title=\"".GetMessage("FORM_VIEW_FILE")."\" target=\"_blank\" class=\"tablebodylink\" href=\"/freetrix/tools/form_show_file.php?rid=".$arParams["RESULT_ID"]."&hash=".$arFile["USER_FILE_HASH"]."&lang=".LANGUAGE_ID."\">".htmlspecialcharsbx($arFile["USER_FILE_NAME"])."</a>&nbsp;(";
									$res .= CFile::FormatSize($arFile["USER_FILE_SIZE"]);
									$res .= ")&nbsp;&nbsp;[&nbsp;<a title=\"".str_replace("#FILE_NAME#", $arFile["USER_FILE_NAME"], GetMessage("FORM_DOWNLOAD_FILE"))."\" class=\"tablebodylink\" href=\"/freetrix/tools/form_show_file.php?rid=".$arParams["RESULT_ID"]."&hash=".$arFile["USER_FILE_HASH"]."&lang=".LANGUAGE_ID."&action=download\">".GetMessage("FORM_DOWNLOAD")."</a>&nbsp;]<br />";
									$res .= '<input type="checkbox" value="Y" name="form_file_'.$arAnswer['ID'].'_del" id="form_file_'.$arAnswer['ID'].'_del" /><label for="form_file_'.$arAnswer['ID'].'_del">'.GetMessage('FORM_DELETE_FILE').'</label><br />';

									$res .= "<br />";
								} //endif;
							} //endif;


							$res .= CForm::GetFileField(
								$arAnswer["ID"],
Ejemplo n.º 2
0
 /**
  * <p>Вставка полей ответа на вопрос в шаблон. Параметры поля ввода задаются в настройках вопроса.</p>
  *
  *
  * @param string $FIELD_SID  Строковой идентификатор поля вопроса. Обязательный параметр.
  *
  * @param  $string  CSS-класс для подписи к полю ввода. Необязательный параметр.
  *
  * @param mixed $CSSClass = ""] 
  *
  * @return string <p>Возвращается HTML-код для вставки полей формы</p> <a
  * name="examples"></a><h4>Использование</h4> <pre class="syntax"> &lt;?=$FORM-&gt;ShowInput('MYFIELD_5')?&gt;
  * </pre>
  *
  * <h4>See Also</h4> 
  * <menu> <li><a href="http://dev.1c-bitrix.ru/api_help/form/classes/cformoutput/index.php">Класс CFormOutput</a></li>
  * <li><a
  * href="http://dev.1c-bitrix.ru/api_help/form/classes/cformoutput/showinputcaption.php">CFormOutput::ShowInputCaption</a></li>
  * <li><a
  * href="http://dev.1c-bitrix.ru/api_help/form/classes/cformoutput/showinputcaptionimage.php">CFormOutput::ShowInputCaptionImage</a></li>
  * </menu></b<br><br>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/form/classes/cformoutput/showinput.php
  * @author Bitrix
  */
 public function ShowInput($FIELD_SID, $caption_css_class = '')
 {
     $arrVALUES = $this->arrVALUES;
     if (is_array($this->arAnswers[$FIELD_SID])) {
         $res = "";
         reset($this->arAnswers[$FIELD_SID]);
         if (is_array($this->arDropDown[$FIELD_SID])) {
             reset($this->arDropDown[$FIELD_SID]);
         }
         if (is_array($this->arMutiselect[$FIELD_SID])) {
             reset($this->arMutiselect[$FIELD_SID]);
         }
         while (list($key, $arAnswer) = each($this->arAnswers[$FIELD_SID])) {
             if ($arAnswer["FIELD_TYPE"] == "dropdown" && $show_dropdown == "Y") {
                 continue;
             }
             if ($arAnswer["FIELD_TYPE"] == "multiselect" && $show_multiselect == "Y") {
                 continue;
             }
             if ($key > 0) {
                 $res .= "<br />";
             }
             switch ($arAnswer["FIELD_TYPE"]) {
                 case "radio":
                     $ans_id = "form_checkbox_" . $FIELD_SID . "_" . $arAnswer['ID'];
                     $arAnswer['FIELD_PARAM'] .= ' id="' . $ans_id . '"';
                     $value = CForm::GetRadioValue($FIELD_SID, $arAnswer, $arrVALUES);
                     $input = CForm::GetRadioField($FIELD_SID, $arAnswer["ID"], $value, $arAnswer["FIELD_PARAM"]);
                     if (strlen($ans_id) > 0) {
                         $res .= $input;
                         $res .= "<label for=\"" . $ans_id . "\">";
                         $res .= "<span class=\"" . $caption_css_class . "\">&nbsp;" . $arAnswer["MESSAGE"] . "</span></label>";
                     } else {
                         $res .= "<label>";
                         $res .= $input;
                         $res .= "<span class=\"" . $caption_css_class . "\">&nbsp;" . $arAnswer["MESSAGE"] . "</span></label>";
                     }
                     break;
                 case "checkbox":
                     $ans_id = "form_checkbox_" . $FIELD_SID . "_" . $arAnswer['ID'];
                     $arAnswer['FIELD_PARAM'] .= ' id="' . $ans_id . '"';
                     $value = CForm::GetCheckBoxValue($FIELD_SID, $arAnswer, $arrVALUES);
                     $input = CForm::GetCheckBoxField($FIELD_SID, $arAnswer["ID"], $value, $arAnswer["FIELD_PARAM"]);
                     if (strlen($ans_id) > 0) {
                         $res .= $input;
                         $res .= "<label for=\"" . $ans_id . "\">";
                         $res .= "<span class=\"" . $caption_css_class . "\">&nbsp;" . $arAnswer["MESSAGE"] . "</span></label>";
                     } else {
                         $res .= "<label>";
                         $res .= $input;
                         $res .= "<span class=\"" . $caption_css_class . "\">&nbsp;" . $arAnswer["MESSAGE"] . "</span></label>";
                     }
                     break;
                 case "dropdown":
                     if ($show_dropdown != "Y") {
                         $value = CForm::GetDropDownValue($FIELD_SID, $this->arDropDown, $arrVALUES);
                         $res .= CForm::GetDropDownField($FIELD_SID, $this->arDropDown[$FIELD_SID], $value, $arAnswer["FIELD_PARAM"]);
                         $show_dropdown = "Y";
                     }
                     break;
                 case "multiselect":
                     if ($show_multiselect != "Y") {
                         $value = CForm::GetMultiSelectValue($FIELD_SID, $this->arMultiSelect, $arrVALUES);
                         $res .= CForm::GetMultiSelectField($FIELD_SID, $this->arMultiSelect[$FIELD_SID], $value, $arAnswer["FIELD_HEIGHT"], $arAnswer["FIELD_PARAM"]);
                         $show_multiselect = "Y";
                     }
                     break;
                 case "text":
                     if (strlen(trim($arAnswer["MESSAGE"])) > 0) {
                         $res .= "<span class=\"" . $caption_css_class . "\">" . $arAnswer["MESSAGE"] . "</span><br />";
                     }
                     $value = CForm::GetTextValue($arAnswer["ID"], $arAnswer, $arrVALUES);
                     $res .= CForm::GetTextField($arAnswer["ID"], $value, $arAnswer["FIELD_WIDTH"], $arAnswer["FIELD_PARAM"]);
                     break;
                 case "hidden":
                     /*
                     if (strlen(trim($arAnswer["MESSAGE"]))>0)
                     {
                     	$res .= "<span class=\"".$caption_css_class."\">".$arAnswer["MESSAGE"]."</span><br />";
                     }
                     */
                     $value = CForm::GetHiddenValue($arAnswer["ID"], $arAnswer, $arrVALUES);
                     $res .= CForm::GetHiddenField($arAnswer["ID"], $value, $arAnswer["FIELD_PARAM"]);
                     break;
                 case "password":
                     if (strlen(trim($arAnswer["MESSAGE"])) > 0) {
                         $res .= "<span class=\"" . $caption_css_class . "\">" . $arAnswer["MESSAGE"] . "</span><br />";
                     }
                     $value = CForm::GetPasswordValue($arAnswer["ID"], $arAnswer, $arrVALUES);
                     $res .= CForm::GetPasswordField($arAnswer["ID"], $value, $arAnswer["FIELD_WIDTH"], $arAnswer["FIELD_PARAM"]);
                     break;
                 case "email":
                     if (strlen(trim($arAnswer["MESSAGE"])) > 0) {
                         $res .= "<span class=\"" . $caption_css_class . "\">" . $arAnswer["MESSAGE"] . "</span><br />";
                     }
                     $value = CForm::GetEmailValue($arAnswer["ID"], $arAnswer, $arrVALUES);
                     $res .= CForm::GetEmailField($arAnswer["ID"], $value, $arAnswer["FIELD_WIDTH"], $arAnswer["FIELD_PARAM"]);
                     break;
                 case "url":
                     if (strlen(trim($arAnswer["MESSAGE"])) > 0) {
                         $res .= "<span class=\"" . $caption_css_class . "\">" . $arAnswer["MESSAGE"] . "</span><br />";
                     }
                     $value = CForm::GetUrlValue($arAnswer["ID"], $arAnswer, $arrVALUES);
                     $res .= CForm::GetUrlField($arAnswer["ID"], $value, $arAnswer["FIELD_WIDTH"], $arAnswer["FIELD_PARAM"]);
                     break;
                 case "textarea":
                     if (strlen(trim($arAnswer["MESSAGE"])) > 0) {
                         $res .= "<span class=\"" . $caption_css_class . "\">" . $arAnswer["MESSAGE"] . "</span><br />";
                     }
                     $value = CForm::GetTextAreaValue($arAnswer["ID"], $arAnswer, $arrVALUES);
                     $res .= CForm::GetTextAreaField($arAnswer["ID"], $arAnswer["FIELD_WIDTH"], $arAnswer["FIELD_HEIGHT"], $arAnswer["FIELD_PARAM"], $value);
                     break;
                 case "date":
                     if (strlen(trim($arAnswer["MESSAGE"])) > 0) {
                         $res .= "<span class=\"" . $caption_css_class . "\">" . $arAnswer["MESSAGE"] . " (" . CSite::GetDateFormat("SHORT") . ")</span><br />";
                     }
                     $value = CForm::GetDateValue($arAnswer["ID"], $arAnswer, $arrVALUES);
                     $res .= CForm::GetDateField($arAnswer["ID"], $this->arForm["SID"], $value, $arAnswer["FIELD_WIDTH"], $arAnswer["FIELD_PARAM"]);
                     break;
                 case "image":
                     if (strlen(trim($arAnswer["MESSAGE"])) > 0) {
                         $res .= "<span class=\"" . $caption_css_class . "\">" . $arAnswer["MESSAGE"] . "</span><br />";
                     }
                     if ($this->RESULT_ID) {
                         if ($arFile = CFormResult::GetFileByAnswerID($this->RESULT_ID, $arAnswer["ID"])) {
                             if (intval($arFile["USER_FILE_ID"]) > 0) {
                                 if ($arFile["USER_FILE_IS_IMAGE"] == "Y") {
                                     $res .= CFile::ShowImage($arFile["USER_FILE_ID"], 0, 0, "border=0", "", true);
                                     $res .= "<br />";
                                 }
                                 //endif;
                             }
                             //endif;
                         }
                         // endif
                     }
                     // endif
                     $res .= CForm::GetFileField($arAnswer["ID"], $arAnswer["FIELD_WIDTH"], "IMAGE", 0, "", $arAnswer["FIELD_PARAM"]);
                     break;
                 case "file":
                     if (strlen(trim($arAnswer["MESSAGE"])) > 0) {
                         $res .= "<span class=\"" . $caption_css_class . "\">" . $arAnswer["MESSAGE"] . "</span><br />";
                     }
                     if ($this->RESULT_ID) {
                         if ($arFile = CFormResult::GetFileByAnswerID($this->RESULT_ID, $arAnswer["ID"])) {
                             if (intval($arFile["USER_FILE_ID"]) > 0) {
                                 $res .= "<a title=\"" . GetMessage("FORM_VIEW_FILE") . "\" target=\"_blank\" class=\"tablebodylink\" href=\"/bitrix/tools/form_show_file.php?rid=" . $this->RESULT_ID . "&hash=" . $arFile["USER_FILE_HASH"] . "&lang=" . LANGUAGE_ID . "\">" . htmlspecialcharsbx($arFile["USER_FILE_NAME"]) . "</a>&nbsp;(";
                                 $res .= CFile::FormatSize($arFile["USER_FILE_SIZE"]);
                                 $res .= ")&nbsp;&nbsp;[&nbsp;<a title=\"" . str_replace("#FILE_NAME#", $arFile["USER_FILE_NAME"], GetMessage("FORM_DOWNLOAD_FILE")) . "\" class=\"tablebodylink\" href=\"/bitrix/tools/form_show_file.php?rid=" . $this->RESULT_ID . "&hash=" . $arFile["USER_FILE_HASH"] . "&lang=" . LANGUAGE_ID . "&action=download\">" . GetMessage("FORM_DOWNLOAD") . "</a>&nbsp;]";
                                 $res .= "<br /><br />";
                             }
                             //endif;
                         }
                         //endif;
                     }
                     $res .= CForm::GetFileField($arAnswer["ID"], $arAnswer["FIELD_WIDTH"], "FILE", 0, "", $arAnswer["FIELD_PARAM"]);
                     break;
             }
             //endswitch;
         }
         //endwhile;
         return $res;
     } elseif (is_array($this->arQuestions[$FIELD_SID]) && $this->arQuestions[$FIELD_SID]["ADDITIONAL"] == "Y") {
         $res = "";
         switch ($this->arQuestions[$FIELD_SID]["FIELD_TYPE"]) {
             case "text":
                 $value = CForm::GetTextAreaValue("ADDITIONAL_" . $this->arQuestions[$FIELD_SID]["ID"], array(), $this->arrVALUES);
                 $res .= CForm::GetTextAreaField("ADDITIONAL_" . $this->arQuestions[$FIELD_SID]["ID"], "60", "5", "", $value);
                 break;
             case "integer":
                 $value = CForm::GetTextValue("ADDITIONAL_" . $this->arQuestions[$FIELD_SID]["ID"], array(), $this->arrVALUES);
                 $res .= CForm::GetTextField("ADDITIONAL_" . $this->arQuestions[$FIELD_SID]["ID"], $value);
                 break;
             case "date":
                 $value = CForm::GetDateValue("ADDITIONAL_" . $this->arQuestions[$FIELD_SID]["ID"], array(), $this->arrVALUES);
                 $res .= CForm::GetDateField("ADDITIONAL_" . $this->arQuestions[$FIELD_SID]["ID"], $arForm["SID"], $value);
                 break;
         }
         //endswitch;
         return $res;
     } else {
         return "";
     }
 }
Ejemplo n.º 3
0
     if ($arFile = CFormResult::GetFileByAnswerID($RESULT_ID, $arAnswer["ID"])) {
         if (intval($arFile["USER_FILE_ID"]) > 0) {
             if ($arFile["USER_FILE_IS_IMAGE"] == "Y") {
                 echo CFile::ShowImage($arFile["USER_FILE_ID"], 0, 0, "border=0", "", true);
                 echo "<br />";
                 echo '<input type="checkbox" value="Y" name="form_image_' . $arAnswer['ID'] . '_del" id="form_image_' . $arAnswer['ID'] . '_del" /><label for="form_image_' . $arAnswer['ID'] . '_del">' . GetMessage('FORM_DELETE_FILE') . '</label><br />';
             }
             //endif;
         }
         //endif;
     }
     // endif
     echo CForm::GetFileField($arAnswer["ID"], $arAnswer["FIELD_WIDTH"], "IMAGE", 0, "", $arAnswer["FIELD_PARAM"]) . '<br />';
     break;
 case "file":
     if ($arFile = CFormResult::GetFileByAnswerID($RESULT_ID, $arAnswer["ID"])) {
         if (intval($arFile["USER_FILE_ID"]) > 0) {
             echo "<a title=\"" . GetMessage("FORM_VIEW_FILE") . "\" target=\"_blank\" class=\"tablebodylink\" href=\"/bitrix/tools/form_show_file.php?rid=" . $RESULT_ID . "&hash=" . $arFile["USER_FILE_HASH"] . "&lang=" . LANGUAGE_ID . "\">" . htmlspecialcharsbx($arFile["USER_FILE_NAME"]) . "</a>&nbsp;(";
             $a = array("b", "Kb", "Mb", "Gb");
             $pos = 0;
             $size = $arFile["USER_FILE_SIZE"];
             while ($size >= 1024) {
                 $size /= 1024;
                 $pos++;
             }
             echo round($size, 2) . " " . $a[$pos];
             echo ")&nbsp;&nbsp;[&nbsp;<a title=\"" . str_replace("#FILE_NAME#", $arFile["USER_FILE_NAME"], GetMessage("FORM_DOWNLOAD_FILE")) . "\" class=\"tablebodylink\" href=\"/bitrix/tools/form_show_file.php?rid=" . $RESULT_ID . "&hash=" . $arFile["USER_FILE_HASH"] . "&lang=" . LANGUAGE_ID . "&action=download\">" . GetMessage("FORM_DOWNLOAD") . "</a>&nbsp;]<br />";
             echo '<input type="checkbox" value="Y" name="form_file_' . $arAnswer['ID'] . '_del" id="form_file_' . $arAnswer['ID'] . '_del" /><label for="form_file_' . $arAnswer['ID'] . '_del">' . GetMessage('FORM_DELETE_FILE') . '</label><br />';
             echo "<br />";
         }
         //endif;