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


PHP SpoonFilter::htmlspecialchars方法代码示例

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


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

示例1: execute

 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $categoryTitle = trim(\SpoonFilter::getPostValue('value', null, '', 'string'));
     // validate
     if ($categoryTitle === '') {
         $this->output(self::BAD_REQUEST, null, BL::err('TitleIsRequired'));
     } else {
         // get the data
         // build array
         $item['title'] = \SpoonFilter::htmlspecialchars($categoryTitle);
         $item['language'] = BL::getWorkingLanguage();
         $meta['keywords'] = $item['title'];
         $meta['keywords_overwrite'] = 'N';
         $meta['description'] = $item['title'];
         $meta['description_overwrite'] = 'N';
         $meta['title'] = $item['title'];
         $meta['title_overwrite'] = 'N';
         $meta['url'] = BackendBlogModel::getURLForCategory(\SpoonFilter::urlise($item['title']));
         // update
         $item['id'] = BackendBlogModel::insertCategory($item, $meta);
         // output
         $this->output(self::OK, $item, vsprintf(BL::msg('AddedCategory'), array($item['title'])));
     }
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:29,代码来源:AddCategory.php

示例2: execute

 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $id = \SpoonFilter::getPostValue('id', null, 0, 'int');
     $tag = trim(\SpoonFilter::getPostValue('value', null, '', 'string'));
     // validate id
     if ($id === 0) {
         $this->output(self::BAD_REQUEST, null, 'no id provided');
     } else {
         // validate tag name
         if ($tag === '') {
             $this->output(self::BAD_REQUEST, null, BL::err('NameIsRequired'));
         } else {
             // check if tag exists
             if (BackendTagsModel::existsTag($tag)) {
                 $this->output(self::BAD_REQUEST, null, BL::err('TagAlreadyExists'));
             } else {
                 $item['id'] = $id;
                 $item['tag'] = \SpoonFilter::htmlspecialchars($tag);
                 $item['url'] = BackendTagsModel::getURL(CommonUri::getUrl(\SpoonFilter::htmlspecialcharsDecode($item['tag'])), $id);
                 BackendTagsModel::update($item);
                 $this->output(self::OK, $item, vsprintf(BL::msg('Edited'), array($item['tag'])));
             }
         }
     }
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:30,代码来源:Edit.php

示例3: execute

 /**
  * Execute the action
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // get parameters
     $charset = $this->getContainer()->getParameter('kernel.charset');
     $searchTerm = \SpoonFilter::getPostValue('term', null, '');
     $term = $charset == 'utf-8' ? \SpoonFilter::htmlspecialchars($searchTerm) : \SpoonFilter::htmlentities($searchTerm);
     $limit = (int) $this->get('fork.settings')->get('Search', 'autocomplete_num_items', 10);
     // validate
     if ($term == '') {
         $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
     } else {
         // get matches
         $matches = FrontendSearchModel::getStartsWith($term, FRONTEND_LANGUAGE, $limit);
         // get search url
         $url = FrontendNavigation::getURLForBlock('Search');
         // loop items and set search url
         foreach ($matches as &$match) {
             $match['url'] = $url . '?form=search&q=' . $match['term'];
         }
         // output
         $this->output(self::OK, $matches);
     }
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:28,代码来源:Autocomplete.php

示例4: execute

 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $charset = $this->getContainer()->getParameter('kernel.charset');
     $searchTerm = \SpoonFilter::getPostValue('term', null, '');
     $term = $charset == 'utf-8' ? \SpoonFilter::htmlspecialchars($searchTerm) : \SpoonFilter::htmlentities($searchTerm);
     // validate search term
     if ($term == '') {
         $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
     } else {
         // previous search result
         $previousTerm = \SpoonSession::exists('searchTerm') ? \SpoonSession::get('searchTerm') : '';
         \SpoonSession::set('searchTerm', '');
         // save this term?
         if ($previousTerm != $term) {
             // format data
             $this->statistics = array();
             $this->statistics['term'] = $term;
             $this->statistics['language'] = LANGUAGE;
             $this->statistics['time'] = FrontendModel::getUTCDate();
             $this->statistics['data'] = serialize(array('server' => $_SERVER));
             $this->statistics['num_results'] = FrontendSearchModel::getTotal($term);
             // save data
             FrontendSearchModel::save($this->statistics);
         }
         // save current search term in cookie
         \SpoonSession::set('searchTerm', $term);
         // output
         $this->output(self::OK);
     }
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:35,代码来源:Save.php

示例5: execute

 /**
  * Execute the action
  *
  * @return	void
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // get parameters
     $id = SpoonFilter::getPostValue('id', null, 0, 'int');
     $tag = trim(SpoonFilter::getPostValue('value', null, '', 'string'));
     // validate
     if ($id === 0) {
         $this->output(self::BAD_REQUEST, null, 'no id provided');
     }
     if ($tag === '') {
         $this->output(self::BAD_REQUEST, null, BL::err('NameIsRequired'));
     }
     // check if tag exists
     if (BackendTagsModel::existsTag($tag)) {
         $this->output(self::BAD_REQUEST, null, BL::err('TagAlreadyExists'));
     }
     // build array
     $item['id'] = $id;
     $item['tag'] = SpoonFilter::htmlspecialchars($tag);
     $item['url'] = BackendTagsModel::getURL($item['tag'], $id);
     // update
     BackendTagsModel::update($item);
     // output
     $this->output(self::OK, $item, vsprintf(BL::msg('Edited'), array($item['tag'])));
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:32,代码来源:edit.php

示例6: getValue

 /**
  * Retrieve the initial or submitted value.
  *
  * @param	bool[optional] $allowHTML	Is HTML allowed?
  * @return	string
  */
 public function getValue($allowHTML = null)
 {
     // redefine default value
     $value = $this->value;
     // added to form
     if ($this->isSubmitted()) {
         // post/get data
         $data = $this->getMethod(true);
         // submitted by post/get (may be empty)
         if (isset($data[$this->attributes['name']])) {
             // value
             $value = $data[$this->getName()];
             $value = is_scalar($value) ? (string) $value : 'Array';
             if (!$allowHTML) {
                 $value = Spoon::getCharset() == 'utf-8' ? SpoonFilter::htmlspecialchars($value) : SpoonFilter::htmlentities($value);
             }
         }
     }
     return $value;
 }
开发者ID:jeroendesloovere,项目名称:library,代码行数:26,代码来源:hidden.php

示例7: execute

 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $formId = \SpoonFilter::getPostValue('form_id', null, '', 'int');
     $fieldId = \SpoonFilter::getPostValue('field_id', null, '', 'int');
     $type = \SpoonFilter::getPostValue('type', array('checkbox', 'dropdown', 'datetime', 'heading', 'paragraph', 'radiobutton', 'submit', 'textarea', 'textbox'), '', 'string');
     $label = trim(\SpoonFilter::getPostValue('label', null, '', 'string'));
     $values = trim(\SpoonFilter::getPostValue('values', null, '', 'string'));
     // this is somewhat a nasty hack, but it makes special chars work.
     $values = \SpoonFilter::htmlspecialcharsDecode($values);
     $defaultValues = trim(\SpoonFilter::getPostValue('default_values', null, '', 'string'));
     $placeholder = trim(\SpoonFilter::getPostValue('placeholder', null, '', 'string'));
     $required = \SpoonFilter::getPostValue('required', array('Y', 'N'), 'N', 'string');
     $requiredErrorMessage = trim(\SpoonFilter::getPostValue('required_error_message', null, '', 'string'));
     $validation = \SpoonFilter::getPostValue('validation', array('email', 'numeric', 'time'), '', 'string');
     $validationParameter = trim(\SpoonFilter::getPostValue('validation_parameter', null, '', 'string'));
     $errorMessage = trim(\SpoonFilter::getPostValue('error_message', null, '', 'string'));
     // special field for textbox: reply to
     $replyTo = \SpoonFilter::getPostValue('reply_to', array('Y', 'N'), 'N', 'string');
     // special fields for datetime
     $inputType = \SpoonFilter::getPostValue('input_type', array('date', 'time'), 'date', 'string');
     $valueAmount = trim(\SpoonFilter::getPostValue('value_amount', null, '', 'string'));
     $valueType = trim(\SpoonFilter::getPostValue('value_type', null, '', 'string'));
     // invalid form id
     if (!BackendFormBuilderModel::exists($formId)) {
         $this->output(self::BAD_REQUEST, null, 'form does not exist');
     } else {
         // invalid fieldId
         if ($fieldId !== 0 && !BackendFormBuilderModel::existsField($fieldId, $formId)) {
             $this->output(self::BAD_REQUEST, null, 'field does not exist');
         } else {
             // invalid type
             if ($type == '') {
                 $this->output(self::BAD_REQUEST, null, 'invalid type provided');
             } else {
                 // extra validation is only possible for textfields & datetime fields
                 if ($type != 'textbox' && $type != 'datetime') {
                     $validation = '';
                     $validationParameter = '';
                     $errorMessage = '';
                 }
                 // init
                 $errors = array();
                 // validate textbox
                 if ($type == 'textbox') {
                     if ($label == '') {
                         $errors['label'] = BL::getError('LabelIsRequired');
                     }
                     if ($required == 'Y' && $requiredErrorMessage == '') {
                         $errors['required_error_message'] = BL::getError('ErrorMessageIsRequired');
                     }
                     if ($validation != '' && $errorMessage == '') {
                         $errors['error_message'] = BL::getError('ErrorMessageIsRequired');
                     }
                     if ($replyTo == 'Y' && $validation != 'email') {
                         $errors['reply_to_error_message'] = BL::getError('EmailValidationIsRequired');
                     }
                 } elseif ($type == 'textarea') {
                     // validate textarea
                     if ($label == '') {
                         $errors['label'] = BL::getError('LabelIsRequired');
                     }
                     if ($required == 'Y' && $requiredErrorMessage == '') {
                         $errors['required_error_message'] = BL::getError('ErrorMessageIsRequired');
                     }
                     if ($validation != '' && $errorMessage == '') {
                         $errors['error_message'] = BL::getError('ErrorMessageIsRequired');
                     }
                 } elseif ($type == 'datetime') {
                     // validate datetime
                     if ($label == '') {
                         $errors['label'] = BL::getError('LabelIsRequired');
                     }
                     if (in_array($valueType, array('day', 'week', 'month', 'year')) && $valueAmount == '') {
                         $errors['default_value_error_message'] = BL::getError('ValueIsRequired');
                     }
                     if ($required == 'Y' && $requiredErrorMessage == '') {
                         $errors['required_error_message'] = BL::getError('ErrorMessageIsRequired');
                     }
                     if ($validation != '' && $errorMessage == '') {
                         $errors['error_message'] = BL::getError('ErrorMessageIsRequired');
                     }
                 } elseif ($type == 'heading' && $values == '') {
                     // validate heading
                     $errors['values'] = BL::getError('ValueIsRequired');
                 } elseif ($type == 'paragraph' && $values == '') {
                     // validate paragraphs
                     $errors['values'] = BL::getError('ValueIsRequired');
                 } elseif ($type == 'submit' && $values == '') {
                     // validate submitbuttons
                     $errors['values'] = BL::getError('ValueIsRequired');
                 } elseif ($type == 'dropdown') {
                     // validate dropdown
                     $values = trim($values, ',');
                     // validate
                     if ($label == '') {
//.........这里部分代码省略.........
开发者ID:newaltcoin,项目名称:forkcms,代码行数:101,代码来源:SaveField.php

示例8: truncate

 /**
  * Truncate a string
  *    syntax: {$var|truncate:max-length[:append-hellip][:closest-word]}
  *
  * @param string $var         The string passed from the template.
  * @param int    $length      The maximum length of the truncated string.
  * @param bool   $useHellip   Should a hellip be appended if the length exceeds the requested length?
  * @param bool   $closestWord Truncate on exact length or on closest word?
  * @return string
  */
 public static function truncate($var = null, $length, $useHellip = true, $closestWord = false)
 {
     // init vars
     $charset = BackendModel::getContainer()->getParameter('kernel.charset');
     // remove special chars, all of them, also the ones that shouldn't be there.
     $var = \SpoonFilter::htmlentitiesDecode($var, null, ENT_QUOTES);
     // remove HTML
     $var = strip_tags($var);
     // less characters
     if (mb_strlen($var) <= $length) {
         return \SpoonFilter::htmlspecialchars($var);
     } else {
         // more characters
         // hellip is seen as 1 char, so remove it from length
         if ($useHellip) {
             $length = $length - 1;
         }
         // truncate
         if ($closestWord) {
             $var = mb_substr($var, 0, strrpos(substr($var, 0, $length + 1), ' '), $charset);
         } else {
             $var = mb_substr($var, 0, $length, $charset);
         }
         // add hellip
         if ($useHellip) {
             $var .= '…';
         }
         // return
         return \SpoonFilter::htmlspecialchars($var, ENT_QUOTES);
     }
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:41,代码来源:TemplateModifiers.php

示例9: parseSeo

 /**
  * Parse SEO specific data
  */
 private function parseSeo()
 {
     // when on the homepage of the default language, set the clean site url as canonical, because of redirect fix
     $queryString = trim($this->URL->getQueryString(), '/');
     $language = $this->get('fork.settings')->get('Core', 'default_language', SITE_DEFAULT_LANGUAGE);
     if ($queryString == $language) {
         $this->canonical = rtrim(SITE_URL, '/');
         if ($this->getContainer()->getParameter('site.multilanguage')) {
             $this->canonical .= '/' . $language;
         }
     }
     // any canonical URL provided?
     if ($this->canonical != '') {
         $url = $this->canonical;
     } else {
         // get the chunks of the current url
         $urlChunks = parse_url($this->URL->getQueryString());
         // a canonical url should contain the domain. So make sure you
         // redirect your website to a single url with .htaccess
         $url = rtrim(SITE_URL, '/');
         if (isset($urlChunks['port'])) {
             $url .= ':' . $urlChunks['port'];
         }
         if (isset($urlChunks['path'])) {
             $url .= '/' . $urlChunks['path'];
         }
         // any items provided through GET?
         if (isset($urlChunks['query'])) {
             // the items we should add into the canonical url
             $itemsToAdd = array('page');
             $addToUrl = array();
             // loop all items in GET and check if we should ignore them
             foreach ($_GET as $key => $value) {
                 if (in_array($key, $itemsToAdd)) {
                     $addToUrl[$key] = $value;
                 }
             }
             // add GET-params
             if (!empty($addToUrl)) {
                 $url .= '?' . http_build_query($addToUrl);
             }
         }
     }
     // prevent against xss
     $charset = $this->getContainer()->getParameter('kernel.charset');
     $url = $charset == 'utf-8' ? \SpoonFilter::htmlspecialchars($url) : \SpoonFilter::htmlentities($url);
     $this->addLink(array('rel' => 'canonical', 'href' => $url));
     if ($this->get('fork.settings')->get('Core', 'seo_noodp', false)) {
         $this->addMetaData(array('name' => 'robots', 'content' => 'noodp'));
     }
     if ($this->get('fork.settings')->get('Core', 'seo_noydir', false)) {
         $this->addMetaData(array('name' => 'robots', 'content' => 'noydir'));
     }
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:57,代码来源:Header.php

示例10: truncate

 /**
  * Truncate a string
  *
  * @param string $string    The string to truncate.
  * @param int    $length    The maximumlength for the string.
  * @param bool   $useHellip Should a hellip be appended?
  * @return string
  */
 public static function truncate($string, $length, $useHellip = true)
 {
     // remove special chars
     $string = htmlspecialchars_decode($string);
     // less characters
     if (mb_strlen($string) <= $length) {
         return \SpoonFilter::htmlspecialchars($string);
     } else {
         // more characters
         // hellip is seen as 1 char, so remove it from length
         if ($useHellip) {
             $length = $length - 1;
         }
         // get the amount of requested characters
         $string = mb_substr($string, 0, $length);
         // add hellip
         if ($useHellip) {
             $string .= '…';
         }
         return \SpoonFilter::htmlspecialchars($string);
     }
 }
开发者ID:newaltcoin,项目名称:forkcms,代码行数:30,代码来源:DataGridFunctions.php

示例11: truncate

 /**
  * Truncate a string
  *    syntax: {{ $string|truncate($max-length, $append-hellip, $closest-word) }}.
  *
  * @param string $string      The string passed from the template.
  * @param int    $length      The maximum length of the truncated string.
  * @param bool   $useHellip   Should a hellip be appended if the length exceeds the requested length?
  * @param bool   $closestWord Truncate on exact length or on closest word?
  *
  * @return string
  */
 public static function truncate($string, $length, $useHellip = true, $closestWord = false)
 {
     // remove special chars, all of them, also the ones that shouldn't be there.
     $string = \SpoonFilter::htmlentitiesDecode($string, null, ENT_QUOTES);
     // remove HTML
     $string = strip_tags($string);
     // less characters
     if (mb_strlen($string) <= $length) {
         return \SpoonFilter::htmlspecialchars($string);
     } else {
         // more characters
         // hellip is seen as 1 char, so remove it from length
         if ($useHellip) {
             --$length;
         }
         // truncate
         if ($closestWord) {
             $string = mb_substr($string, 0, strrpos(substr($string, 0, $length + 1), ' '), 'UTF-8');
         } else {
             $string = mb_substr($string, 0, $length, 'UTF8');
         }
         // add hellip
         if ($useHellip) {
             $string .= '…';
         }
         // return
         return \SpoonFilter::htmlspecialchars($string, ENT_QUOTES);
     }
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:40,代码来源:BaseTwigModifiers.php

示例12: getValue

 /**
  * Retrieve the initial or submitted value.
  *
  * @return	string
  * @param	bool[optional] $allowHTML	Is HTML allowed?
  */
 public function getValue($allowHTML = null)
 {
     // redefine html & default value
     $allowHTML = $allowHTML !== null ? (bool) $allowHTML : $this->isHTML;
     $value = $this->value;
     // contains html
     if ($this->isHTML) {
         // set value
         $value = SPOON_CHARSET == 'utf-8' ? SpoonFilter::htmlspecialchars($value) : SpoonFilter::htmlentities($value);
     }
     // form submitted
     if ($this->isSubmitted()) {
         // post/get data
         $data = $this->getMethod(true);
         // submitted by post (may be empty)
         if (isset($data[$this->getName()])) {
             // value
             $value = $data[$this->attributes['name']];
             // maximum length?
             if (isset($this->attributes['maxlength']) && $this->attributes['maxlength'] > 0) {
                 $value = mb_substr($value, 0, (int) $this->attributes['maxlength'], SPOON_CHARSET);
             }
             // html allowed?
             if (!$allowHTML) {
                 $value = SPOON_CHARSET == 'utf-8' ? SpoonFilter::htmlspecialchars($value) : SpoonFilter::htmlentities($value);
             }
         }
     }
     return $value;
 }
开发者ID:jincongho,项目名称:clienthub,代码行数:36,代码来源:textarea.php

示例13: truncate

 /**
  * Truncate a string
  * 	syntax: {$var|truncate:max-length[:append-hellip]}
  *
  * @param string[optional] $var A placeholder var, will be replaced with the generated HTML.
  * @param int $length The maximum length of the truncated string.
  * @param bool[optional] $useHellip Should a hellip be appended if the length exceeds the requested length?
  * @return string
  */
 public static function truncate($var = null, $length, $useHellip = true)
 {
     // remove special chars
     $var = htmlspecialchars_decode($var, ENT_QUOTES);
     // remove HTML
     $var = strip_tags($var);
     // less characters
     if (mb_strlen($var) <= $length) {
         return SpoonFilter::htmlspecialchars($var);
     } else {
         // hellip is seen as 1 char, so remove it from length
         if ($useHellip) {
             $length = $length - 1;
         }
         // get the amount of requested characters
         $var = mb_substr($var, 0, $length);
         // add hellip
         if ($useHellip) {
             $var .= '…';
         }
         return SpoonFilter::htmlspecialchars($var, ENT_QUOTES);
     }
 }
开发者ID:nickmancol,项目名称:forkcms-rhcloud,代码行数:32,代码来源:template.php

示例14: execute

 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $formId = SpoonFilter::getPostValue('form_id', null, '', 'int');
     $fieldId = SpoonFilter::getPostValue('field_id', null, '', 'int');
     $type = SpoonFilter::getPostValue('type', array('checkbox', 'dropdown', 'heading', 'paragraph', 'radiobutton', 'submit', 'textarea', 'textbox'), '', 'string');
     $label = trim(SpoonFilter::getPostValue('label', null, '', 'string'));
     $values = trim(SpoonFilter::getPostValue('values', null, '', 'string'));
     $defaultValues = trim(SpoonFilter::getPostValue('default_values', null, '', 'string'));
     $required = SpoonFilter::getPostValue('required', array('Y', 'N'), 'N', 'string');
     $requiredErrorMessage = trim(SpoonFilter::getPostValue('required_error_message', null, '', 'string'));
     $validation = SpoonFilter::getPostValue('validation', array('email', 'numeric'), '', 'string');
     $validationParameter = trim(SpoonFilter::getPostValue('validation_parameter', null, '', 'string'));
     $errorMessage = trim(SpoonFilter::getPostValue('error_message', null, '', 'string'));
     // invalid form id
     if (!BackendFormBuilderModel::exists($formId)) {
         $this->output(self::BAD_REQUEST, null, 'form does not exist');
     }
     // invalid fieldId
     if ($fieldId !== 0 && !BackendFormBuilderModel::existsField($fieldId, $formId)) {
         $this->output(self::BAD_REQUEST, null, 'field does not exist');
     }
     // invalid type
     if ($type == '') {
         $this->output(self::BAD_REQUEST, null, 'invalid type provided');
     }
     // init
     $errors = array();
     // validate textbox
     if ($type == 'textbox') {
         if ($label == '') {
             $errors['label'] = BL::getError('LabelIsRequired');
         }
         if ($required == 'Y' && $requiredErrorMessage == '') {
             $errors['required_error_message'] = BL::getError('ErrorMessageIsRequired');
         }
         if ($validation != '' && $errorMessage == '') {
             $errors['error_message'] = BL::getError('ErrorMessageIsRequired');
         }
     } elseif ($type == 'textarea') {
         if ($label == '') {
             $errors['label'] = BL::getError('LabelIsRequired');
         }
         if ($required == 'Y' && $requiredErrorMessage == '') {
             $errors['required_error_message'] = BL::getError('ErrorMessageIsRequired');
         }
         if ($validation != '' && $errorMessage == '') {
             $errors['error_message'] = BL::getError('ErrorMessageIsRequired');
         }
     } elseif ($type == 'heading' && $values == '') {
         $errors['values'] = BL::getError('ValueIsRequired');
     } elseif ($type == 'paragraph' && $values == '') {
         $errors['values'] = BL::getError('ValueIsRequired');
     } elseif ($type == 'submit' && $values == '') {
         $errors['values'] = BL::getError('ValueIsRequired');
     } elseif ($type == 'dropdown') {
         // values trim
         $values = trim($values, ',');
         // validate
         if ($label == '') {
             $errors['label'] = BL::getError('LabelIsRequired');
         }
         if ($required == 'Y' && $requiredErrorMessage == '') {
             $errors['required_error_message'] = BL::getError('ErrorMessageIsRequired');
         }
         if ($values == '') {
             $errors['values'] = BL::getError('ValueIsRequired');
         }
     } elseif ($type == 'radiobutton') {
         if ($label == '') {
             $errors['label'] = BL::getError('LabelIsRequired');
         }
         if ($required == 'Y' && $requiredErrorMessage == '') {
             $errors['required_error_message'] = BL::getError('ErrorMessageIsRequired');
         }
         if ($values == '') {
             $errors['values'] = BL::getError('ValueIsRequired');
         }
     } elseif ($type == 'checkbox') {
         if ($label == '') {
             $errors['label'] = BL::getError('LabelIsRequired');
         }
         if ($required == 'Y' && $requiredErrorMessage == '') {
             $errors['required_error_message'] = BL::getError('ErrorMessageIsRequired');
         }
     }
     // got errors
     if (!empty($errors)) {
         $this->output(self::OK, array('errors' => $errors), 'form contains errors');
     }
     // htmlspecialchars except for paragraphs
     if ($type != 'paragraph') {
         if ($values != '') {
             $values = SpoonFilter::htmlspecialchars($values);
         }
         if ($defaultValues != '') {
//.........这里部分代码省略.........
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:101,代码来源:save_field.php

示例15: testGetValue

 public function testGetValue()
 {
     $_POST['form'] = 'textfield';
     $_POST['name'] = '<a href="http://www.spoon-library.be">Bobby Tables, my friends call mééé</a>';
     $this->assertEquals(SpoonFilter::htmlspecialchars($_POST['name']), $this->txtName->getValue());
     $this->assertEquals($_POST['name'], $this->txtName->getValue(true));
     $_POST['name'] = array('foo', 'bar');
     $this->assertEquals('Array', $this->txtName->getValue());
 }
开发者ID:sunkangtaichi,项目名称:library,代码行数:9,代码来源:SpoonFormTextTest.php


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