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


PHP iaUtil::safeHTML方法代碼示例

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


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

示例1: parsePost


//.........這裏部分代碼省略.........
     $iaCore->factory('util');
     iaUtil::loadUTF8Functions('validation', 'bad');
     foreach ($activeFields as $fieldName => $field) {
         isset($data[$fieldName]) || ($data[$fieldName] = '');
         // Check the UTF-8 is well formed
         if (!is_array($data[$fieldName]) && !utf8_is_valid($data[$fieldName])) {
             $data[$fieldName] = utf8_bad_replace($data[$fieldName]);
         }
         if ($field['extra_actions']) {
             if (false === eval($field['extra_actions'])) {
                 continue;
                 // make possible to stop further processing of this field by returning FALSE
             }
         }
         if (in_array($field['type'], array(self::TEXT, self::TEXTAREA, self::NUMBER, self::RADIO, self::CHECKBOX, self::COMBO))) {
             if ($field['required']) {
                 if ($field['required_checks']) {
                     eval($field['required_checks']);
                 }
                 if (empty($data[$fieldName])) {
                     $error = true;
                     $messages[] = in_array($field['type'], array(self::RADIO, self::CHECKBOX, self::COMBO)) ? iaLanguage::getf('field_is_not_selected', array('field' => iaLanguage::get('field_' . $fieldName))) : iaLanguage::getf('field_is_empty', array('field' => iaLanguage::get('field_' . $fieldName)));
                     $invalidFields[] = $fieldName;
                 }
             }
             switch ($field['type']) {
                 case self::NUMBER:
                     $item[$fieldName] = (double) str_replace(' ', '', $data[$fieldName]);
                     break;
                 case self::TEXT:
                     $item[$fieldName] = iaSanitize::tags($data[$fieldName]);
                     break;
                 case self::TEXTAREA:
                     $item[$fieldName] = $field['use_editor'] ? iaUtil::safeHTML($data[$fieldName]) : iaSanitize::tags($data[$fieldName]);
                     break;
                 default:
                     $item[$fieldName] = is_array($data[$fieldName]) ? implode(',', $data[$fieldName]) : $data[$fieldName];
             }
         } elseif (self::DATE == $field['type']) {
             if ($field['required'] && $field['required_checks']) {
                 eval($field['required_checks']);
             } elseif ($field['required'] && empty($data[$fieldName])) {
                 $error = true;
                 $messages[] = iaLanguage::getf('field_is_empty', array('field' => iaLanguage::get('field_' . $fieldName)));
                 $invalidFields[] = $fieldName;
             }
             $data[$fieldName] = trim($data[$fieldName]);
             if (empty($data[$fieldName])) {
                 $item[$fieldName] = $field['allow_null'] ? null : '';
             } else {
                 if (strpos($data[$fieldName], ' ') === false) {
                     $date = $data[$fieldName];
                     $time = false;
                 } else {
                     list($date, $time) = explode(' ', $data[$fieldName]);
                 }
                 // FIXME: fucking shit
                 $array = explode('-', $date);
                 $year = (int) $array[0];
                 $month = max(1, (int) $array[1]);
                 $day = max(1, (int) $array[2]);
                 $year = strlen($year) == 4 ? $year : 2000;
                 $month = strlen($month) < 2 ? '0' . $month : $month;
                 $day = strlen($day) < 2 ? '0' . $day : $day;
                 $item[$fieldName] = $year . '-' . $month . '-' . $day;
                 if ($field['timepicker'] && $time) {
開發者ID:nicefirework,項目名稱:subrion,代碼行數:67,代碼來源:ia.core.field.php


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