/** * */ public function Info() { $t_tag = new ca_item_tags(); $this->view->setVar('unmoderated_tag_count', $t_tag->getUnmoderatedTagCount()); $this->view->setVar('moderated_tag_count', $t_tag->getModeratedTagCount()); $this->view->setVar('total_taggings_count', $t_tag->getTagCount()); $this->view->setVar('total_tag_count', $t_tag->getItemTagsCount()); return $this->render('widget_tags_info_html.php', true); }
/** * Adds a tag to currently loaded row. Returns null if no row is loaded. Otherwise returns true * if tag was successfully added, false if an error occurred in which case the errors will be available * via the model's standard error methods (getErrors() and friends. * * Most of the parameters are optional with the exception of $ps_tag - the text of the tag. Note that * tag text is monolingual; if you want to do multilingual tags then you must add multiple tags. * * The parameters are: * * @param $ps_tag [string] Text of the tag (mandatory) * @param $pn_user_id [integer] A valid ca_users.user_id indicating the user who added the tag; is null for tags 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 $pn_access [integer] Determines public visibility of tag; if set to 0 then tag is not visible to public; if set to 1 tag is visible (optional - default is 0) * @param $pn_moderator [integer] A valid ca_users.user_id value indicating who moderated the tag; if omitted or set to null then moderation status will not be set unless app.conf setting dont_moderate_comments = 1 (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. */ public function addTag($ps_tag, $pn_user_id = null, $pn_locale_id = null, $pn_access = 0, $pn_moderator = null, $pa_options = 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; } if (!$pn_locale_id) { $this->postError(2830, _t('No locale was set for tag'), 'BaseModel->addTag()', 'ca_item_tags'); return false; } if (!isset($pa_options['purify'])) { $pa_options['purify'] = true; } if ($this->purify() || (bool) $pa_options['purify']) { $ps_tag = BaseModel::getPurifier()->purify($ps_tag); } $t_tag = new ca_item_tags(); $t_tag->purify($this->purify() || $pa_options['purify']); if (!$t_tag->load(array('tag' => $ps_tag, 'locale_id' => $pn_locale_id))) { // create new new $t_tag->setMode(ACCESS_WRITE); $t_tag->set('tag', $ps_tag); $t_tag->set('locale_id', $pn_locale_id); $vn_tag_id = $t_tag->insert(); if ($t_tag->numErrors()) { $this->errors = $t_tag->errors; return false; } } else { $vn_tag_id = $t_tag->getPrimaryKey(); } $t_ixt = new ca_items_x_tags(); $t_ixt->setMode(ACCESS_WRITE); $t_ixt->set('table_num', $this->tableNum()); $t_ixt->set('row_id', $this->getPrimaryKey()); $t_ixt->set('user_id', $pn_user_id); $t_ixt->set('tag_id', $vn_tag_id); $t_ixt->set('access', $pn_access); if (!is_null($pn_moderator)) { $t_ixt->set('moderated_by_user_id', $pn_moderator); $t_ixt->set('moderated_on', _t('now')); } elseif ($this->_CONFIG->get("dont_moderate_comments")) { $t_ixt->set('moderated_on', _t('now')); } $t_ixt->insert(); if ($t_ixt->numErrors()) { $this->errors = $t_ixt->errors; return false; } return true; }
public function renderWidget($ps_widget_id, &$pa_settings) { parent::renderWidget($ps_widget_id, $pa_settings); global $g_ui_locale_id; if ($pa_settings["display_limit"] && intval($pa_settings["display_limit"]) > 0 && intval($pa_settings["display_limit"]) < 1000) { $vn_limit = intval($pa_settings["display_limit"]); } else { $vn_limit = 10; } $this->opo_view->setVar('limit', $vn_limit); $vn_show_type = intval($pa_settings["show_moderated_type"]); $vs_tag_type = ""; switch ($vn_show_type) { case 1: $vs_mode = "moderated"; $vs_tag_type = _t("moderated"); break; # --------------------------------------- # --------------------------------------- case 0: $vs_mode = "unmoderated"; $vs_tag_type = _t("unmoderated"); break; # --------------------------------------- # --------------------------------------- default: $vs_mode = ""; $vs_tag_type = ""; break; # --------------------------------------- } $this->opo_view->setVar('tag_type', $vs_tag_type); $t_tags = new ca_item_tags(); $va_tags = $t_tags->getTags($vs_mode, $vn_limit); $this->opo_view->setVar('tags_list', $va_tags); $this->opo_view->setVar('request', $this->getRequest()); $this->opo_view->setVar('settings', $pa_settings); return $this->opo_view->render('main_html.php'); }