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


PHP BaseModel::html_purifier方法代码示例

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


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

示例1: getPurifier

 /**
  * Return HTMLPurifier instance
  *
  * @return HTMLPurifier Returns instance
  */
 public static function getPurifier()
 {
     if (!BaseModel::$html_purifier) {
         BaseModel::$html_purifier = new HTMLPurifier();
     }
     return BaseModel::$html_purifier;
 }
开发者ID:samrahman,项目名称:providence,代码行数:12,代码来源:BaseModel.php

示例2: setPreference

 /**
  * Sets value of user preference. Returns false if preference or value is invalid.
  *
  * @access public
  * @param string $ps_pref Name of user preference
  * @param mixed $ps_val Value of preference
  * @return bool True if preference was set; false if it could not be set.
  */
 public function setPreference($ps_pref, $ps_val)
 {
     if ($this->isValidPreference($ps_pref)) {
         if ($this->purify()) {
             if (!BaseModel::$html_purifier) {
                 BaseModel::$html_purifier = new HTMLPurifier();
             }
             $ps_val = BaseModel::$html_purifier->purify($ps_val);
         }
         if ($this->isValidPreferenceValue($ps_pref, $ps_val, 1)) {
             $va_prefs = $this->getVar("_user_preferences");
             $va_prefs[$ps_pref] = $ps_val;
             $this->setVar("_user_preferences", $va_prefs);
             return true;
         } else {
             return false;
         }
     } else {
         $this->postError(920, _t("%1 is not a valid user preference", $ps_pref), "User->getPreference()");
         return false;
     }
 }
开发者ID:kai-iak,项目名称:providence,代码行数:30,代码来源:ca_users.php

示例3: editComment

 /**
  * Edits an existing comment as specified by $pn_comment_id. Will only edit comments that are attached to the 
  * currently loaded row. If called with no row loaded editComment() will return null. If you attempt to modify
  * a comment not associated with the currently loaded row editComment() will return false and post an error.
  * Note that all parameters are mandatory in the sense that the value passed (or the default value if not passed)
  * will be written into the comment. For example, if you don't bother passing $ps_name then it will be set to null, even
  * if there's an existing name value in the field. The only exception is $pn_locale_id; if set to null or omitted then 
  * editComment() will attempt to use the locale value in the global $g_ui_locale_id variable. If this is not set then
  * an error will be posted and editComment() will return false.
  *
  * @param $pn_comment_id [integer] a valid comment_id to be edited; must be related to the currently loaded row (mandatory)
  * @param $ps_comment [string] the text of the comment (mandatory)
  * @param $pn_rating [integer] a number between 1 and 5 indicating the user's rating of the row; higher is better (optional - default is null)
  * @param $pn_user_id [integer] A valid ca_users.user_id indicating the user who posted the comment; is null for comments from non-logged-in users (optional - default is null)
  * @param $pn_locale_id [integer] A valid ca_locales.locale_id indicating the language of the comment. If omitted or left null then the value in the global $g_ui_locale_id variable is used. If $g_ui_locale_id is not set and $pn_locale_id is not set then an error will occur (optional - default is to use $g_ui_locale_id)
  * @param $ps_name [string] Name of user posting comment. Only needs to be set if $pn_user_id is *not* set; used to identify comments posted by non-logged-in users (optional - default is null)
  * @param $ps_email [string] E-mail address of user posting comment. Only needs to be set if $pn_user_id is *not* set; used to identify comments posted by non-logged-in users (optional - default is null)
  * @param $pn_access [integer] Determines public visibility of comments; if set to 0 then comment is not visible to public; if set to 1 comment is visible (optional - default is 0)
  * @param $pn_moderator [integer] A valid ca_users.user_id value indicating who moderated the comment; if omitted or set to null then moderation status will not be set (optional - default is null)
  * @param array $pa_options Array of options. Supported options are:
  *				purify = if true, comment, name and email are run through HTMLPurifier before being stored in the database. Default is true. 
  *				media1_original_filename = original file name to set for comment "media1"
  *				media2_original_filename = original file name to set for comment "media2"
  *				media3_original_filename = original file name to set for comment "media3"
  *				media4_original_filename = original file name to set for comment "media4"
  */
 public function editComment($pn_comment_id, $ps_comment, $pn_rating = null, $pn_user_id = null, $pn_locale_id = null, $ps_name = null, $ps_email = null, $pn_access = null, $pn_moderator = null, $pa_options = null, $ps_media1 = null, $ps_media2 = null, $ps_media3 = null, $ps_media4 = null)
 {
     global $g_ui_locale_id;
     if (!($vn_row_id = $this->getPrimaryKey())) {
         return null;
     }
     if (!$pn_locale_id) {
         $pn_locale_id = $g_ui_locale_id;
     }
     $t_comment = new ca_item_comments($pn_comment_id);
     if (!$t_comment->getPrimaryKey()) {
         $this->postError(2800, _t('Comment id is invalid'), 'BaseModel->editComment()', 'ca_item_comments');
         return false;
     }
     if ($t_comment->get('table_num') != $this->tableNum() || $t_comment->get('row_id') != $vn_row_id) {
         $this->postError(2810, _t('Comment is not part of the current row'), 'BaseModel->editComment()', 'ca_item_comments');
         return false;
     }
     if (!isset($pa_options['purify'])) {
         $pa_options['purify'] = true;
     }
     $t_comment->purify($this->purify() || $pa_options['purify']);
     if ((bool) $pa_options['purify']) {
         if (!BaseModel::$html_purifier) {
             BaseModel::$html_purifier = new HTMLPurifier();
         }
         $ps_comment = BaseModel::$html_purifier->purify($ps_comment);
         $ps_name = BaseModel::$html_purifier->purify($ps_name);
         $ps_email = BaseModel::$html_purifier->purify($ps_email);
     }
     $t_comment->setMode(ACCESS_WRITE);
     $t_comment->set('comment', $ps_comment);
     $t_comment->set('rating', $pn_rating);
     $t_comment->set('user_id', $pn_user_id);
     $t_comment->set('name', $ps_name);
     $t_comment->set('email', $ps_email);
     $t_comment->set('media1', $ps_media1, array('original_filename' => $pa_options['media1_original_filename']));
     $t_comment->set('media2', $ps_media2, array('original_filename' => $pa_options['media2_original_filename']));
     $t_comment->set('media3', $ps_media3, array('original_filename' => $pa_options['media3_original_filename']));
     $t_comment->set('media4', $ps_media4, array('original_filename' => $pa_options['media4_original_filename']));
     if (!is_null($pn_moderator)) {
         $t_comment->set('moderated_by_user_id', $pn_moderator);
         $t_comment->set('moderated_on', 'now');
     }
     if (!is_null($pn_locale_id)) {
         $t_comment->set('locale_id', $pn_locale_id);
     }
     $t_comment->update();
     if ($t_comment->numErrors()) {
         $this->errors = $t_comment->errors;
         return false;
     }
     return true;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:80,代码来源:BaseModel.php

示例4: set


//.........这里部分代码省略.........
                         } else {
                             $o_tep = new TimeExpressionParser();
                             if (!$o_tep->parseTime($vm_value)) {
                                 $this->postError(1805, $o_tep->getParseErrorMessage(), 'BaseModel->set()');
                                 return false;
                             }
                             $va_timestamps = $o_tep->getTimes();
                             if ($this->_FIELD_VALUES[$vs_start_field_name] != $va_timestamps["start"]) {
                                 $this->_FIELD_VALUE_CHANGED[$vs_field] = true;
                                 $this->_FIELD_VALUES[$vs_start_field_name] = $va_timestamps["start"];
                             }
                             if ($this->_FIELD_VALUES[$vs_end_field_name] != $va_timestamps["end"]) {
                                 $this->_FIELD_VALUE_CHANGED[$vs_field] = true;
                                 $this->_FIELD_VALUES[$vs_end_field_name] = $va_timestamps["end"];
                             }
                         }
                     }
                     break;
                 case FT_TIMECODE:
                     $o_tp = new TimecodeParser();
                     if ($o_tp->parse($vm_value)) {
                         if ($o_tp->getParsedValueInSeconds() != $vs_cur_value) {
                             $this->_FIELD_VALUE_CHANGED[$vs_field] = true;
                             $this->_FIELD_VALUES[$vs_field] = $o_tp->getParsedValueInSeconds();
                         }
                     }
                     break;
                 case FT_TEXT:
                     $vm_value = (string) $vm_value;
                     if (is_string($vm_value)) {
                         $vm_value = stripSlashes($vm_value);
                     }
                     if (isset($pa_options['purify']) && $pa_options['purify'] || (bool) $this->opb_purify_input || $this->getFieldInfo($vs_field, "PURIFY") || (bool) $this->getAppConfig()->get('useHTMLPurifier')) {
                         if (!BaseModel::$html_purifier) {
                             BaseModel::$html_purifier = new HTMLPurifier();
                         }
                         $vm_value = BaseModel::$html_purifier->purify((string) $vm_value);
                     }
                     if ($this->getFieldInfo($vs_field, "DISPLAY_TYPE") == DT_LIST_MULTIPLE) {
                         if (is_array($vm_value)) {
                             if (!($vs_list_multiple_delimiter = $this->getFieldInfo($vs_field, 'LIST_MULTIPLE_DELIMITER'))) {
                                 $vs_list_multiple_delimiter = ';';
                             }
                             $vs_string_value = join($vs_list_multiple_delimiter, $vm_value);
                             $vs_string_value = str_replace("", '', $vs_string_value);
                             if ($vs_cur_value !== $vs_string_value) {
                                 $this->_FIELD_VALUE_CHANGED[$vs_field] = true;
                             }
                             $this->_FIELD_VALUES[$vs_field] = $vs_string_value;
                         }
                     } else {
                         $vm_value = str_replace("", '', $vm_value);
                         if ($this->getFieldInfo($vs_field, "ENTITY_ENCODE_INPUT")) {
                             $vs_value_entity_encoded = htmlentities(html_entity_decode($vm_value));
                             if ($vs_cur_value !== $vs_value_entity_encoded) {
                                 $this->_FIELD_VALUE_CHANGED[$vs_field] = true;
                             }
                             $this->_FIELD_VALUES[$vs_field] = $vs_value_entity_encoded;
                         } else {
                             if ($this->getFieldInfo($vs_field, "URL_ENCODE_INPUT")) {
                                 $vs_value_url_encoded = urlencode($vm_value);
                                 if ($vs_cur_value !== $vs_value_url_encoded) {
                                     $this->_FIELD_VALUE_CHANGED[$vs_field] = true;
                                 }
                                 $this->_FIELD_VALUES[$vs_field] = $vs_value_url_encoded;
                             } else {
开发者ID:guaykuru,项目名称:pawtucket,代码行数:67,代码来源:BaseModel.php


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