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


PHP ca_sets::addAttribute方法代码示例

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


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

示例1: addNewSet

 public function addNewSet()
 {
     if (!$this->request->isLoggedIn()) {
         $this->response->setRedirect(caNavUrl($this->request, '', 'LoginReg', 'form'));
         return;
     }
     global $g_ui_locale_id;
     // current locale_id for user
     $va_errors_new_set = array();
     $t_new_set = new ca_sets();
     $pn_set_id = $this->request->getParameter('set_id', pInteger);
     $ps_name = $this->request->getParameter('name', pString);
     if (!$ps_name) {
         $va_errors_new_set["name"] = _t("Please enter the name of your collection");
     }
     $vs_desc = $this->request->getParameter('description', pString);
     $t_list = new ca_lists();
     $vn_set_type_user = $t_list->getItemIDFromList('set_types', 'user');
     if (sizeof($va_errors_new_set) == 0) {
         $t_new_set->setMode(ACCESS_WRITE);
         $t_new_set->set('access', $this->request->getParameter('access', pInteger));
         $t_new_set->set('table_num', 57);
         // 57=ca_objects
         $t_new_set->set('type_id', $vn_set_type_user);
         // type="user"
         $t_new_set->set('user_id', $this->request->getUserID());
         $t_new_set->set('set_code', $this->request->getUserID() . '_' . time());
         // create new attribute
         $t_new_set->addAttribute(array('set_intro' => $vs_desc, 'locale_id' => $g_ui_locale_id), 'set_intro');
         $t_new_set->insert();
         if ($vn_new_set_id = $t_new_set->getPrimaryKey()) {
             $t_new_set->addLabel(array('name' => $ps_name), $g_ui_locale_id, null, true);
             // select the current set
             $this->request->user->setVar('current_set_id', $vn_new_set_id);
             //clear t_new_set object so form appears blank and load t_set so edit form is populated
             $t_new_set = new ca_sets();
             $t_set = new ca_sets($vn_new_set_id);
         }
     }
     $this->view->setVar('errors_new_set', $va_errors_new_set);
     $this->index();
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:42,代码来源:SetsController.php

示例2: 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 lightbox.  You have read only access.");
             $this->view->setVar('errors', $va_errors);
             $this->addItemForm();
             return;
         }
     } else {
         $t_set = new ca_sets();
         # --- 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 lightbox");
         }
         # --- 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();
         $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 lightbox');
                     $this->render("Form/reload_html.php");
                 }
             } else {
                 $this->view->setVar('message', _t("Item already in lightbox."));
                 $this->render("Form/reload_html.php");
             }
         } else {
             $this->view->setVar('message', _t("Object ID is not defined"));
             $this->render("Form/reload_html.php");
         }
     }
 }
开发者ID:ffarago,项目名称:pawtucket2,代码行数:89,代码来源:SetsController.php


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