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


PHP ca_sets::purify方法代码示例

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


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

示例1: AjaxAddItem

 public function AjaxAddItem()
 {
     if (!$this->request->isLoggedIn()) {
         $this->response->setRedirect(caNavUrl($this->request, '', 'LoginReg', 'loginForm'));
         return;
     }
     global $g_ui_locale_id;
     // current locale_id for user
     $va_errors = array();
     $o_purifier = new HTMLPurifier();
     # --- set_id is passed through form, otherwise we're saving a new set, and adding the item to it
     if ($this->request->getParameter('set_id', pInteger)) {
         $t_set = $this->_getSet(__CA_EDIT_READ_ACCESS__);
         if (!$t_set && ($t_set = $this->_getSet(__CA_SET_READ_ACCESS__))) {
             $va_errors["general"] = _t("You can not add items to this %1.  You have read only access.", $this->ops_lightbox_display_name);
             $this->view->setVar('errors', $va_errors);
             $this->addItemForm();
             return;
         }
     } else {
         $t_set = new ca_sets();
         $t_set->purify(true);
         # --- set name - if not sent, make a decent default
         $ps_name = $o_purifier->purify($this->request->getParameter('name', pString));
         if (!$ps_name) {
             $ps_name = _t("Your %1", $this->ops_lightbox_display_name);
         }
         # --- set description - optional
         $ps_description = $o_purifier->purify($this->request->getParameter('description', pString));
         $t_list = new ca_lists();
         $vn_set_type_user = $t_list->getItemIDFromList('set_types', $this->request->config->get('user_set_type'));
         $t_object = new ca_objects();
         $t_object->purify(true);
         $vn_object_table_num = $t_object->tableNum();
         $t_set->setMode(ACCESS_WRITE);
         $t_set->set('access', 1);
         #$t_set->set('access', $this->request->getParameter('access', pInteger));
         $t_set->set('table_num', $vn_object_table_num);
         $t_set->set('type_id', $vn_set_type_user);
         $t_set->set('user_id', $this->request->getUserID());
         $t_set->set('set_code', $this->request->getUserID() . '_' . time());
         # --- create new attribute
         if ($ps_description) {
             $t_set->addAttribute(array('description' => $ps_description, 'locale_id' => $g_ui_locale_id), 'description');
         }
         $t_set->insert();
         if ($t_set->numErrors()) {
             $va_errors["general"] = join("; ", $t_set->getErrors());
             $this->view->setVar('errors', $va_errors);
             $this->addItemForm();
             return;
         } else {
             # --- save name - add new label
             $t_set->addLabel(array('name' => $ps_name), $g_ui_locale_id, null, true);
             # --- select the current set
             $this->request->user->setVar('current_set_id', $t_set->get("set_id"));
         }
     }
     if ($t_set) {
         $pn_item_id = null;
         $pn_object_id = $this->request->getParameter('object_id', pInteger);
         if ($pn_object_id) {
             if (!$t_set->isInSet("ca_objects", $pn_object_id, $t_set->get("set_id"))) {
                 if ($pn_item_id = $t_set->addItem($pn_object_id, array(), $this->request->getUserID())) {
                     //
                     // Select primary representation
                     //
                     $t_object = new ca_objects($pn_object_id);
                     $vn_rep_id = $t_object->getPrimaryRepresentationID();
                     // get representation_id for primary
                     $t_item = new ca_set_items($pn_item_id);
                     $t_item->addSelectedRepresentation($vn_rep_id);
                     // flag as selected in item vars
                     $t_item->update();
                     $va_errors = array();
                     $this->view->setVar('message', _t("Successfully added item."));
                     $this->render("Form/reload_html.php");
                 } else {
                     $va_errors["message"] = _t('Could not add item to %1', $this->ops_lightbox_display_name);
                     $this->render("Form/reload_html.php");
                 }
             } else {
                 $this->view->setVar('message', _t("Item already in %1.", $this->ops_lightbox_display_name));
                 $this->render("Form/reload_html.php");
             }
         } else {
             if (($pb_saveLastResults = $this->request->getParameter('saveLastResults', pString)) || ($ps_object_ids = $this->request->getParameter('object_ids', pString))) {
                 if ($pb_saveLastResults) {
                     # --- get object ids from last result
                     $o_context = ResultContext::getResultContextForLastFind($this->request, "ca_objects");
                     $va_object_ids = $o_context->getResultList();
                 } else {
                     $va_object_ids = explode(";", $ps_object_ids);
                 }
                 if (is_array($va_object_ids) && sizeof($va_object_ids)) {
                     # --- check for those already in set
                     $va_object_ids_in_set = $t_set->areInSet("ca_objects", $va_object_ids, $t_set->get("set_id"));
                     $va_object_ids = array_diff($va_object_ids, $va_object_ids_in_set);
                     # --- insert items
                     $t_set->addItems($va_object_ids);
//.........这里部分代码省略.........
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:101,代码来源:SetsController.php


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