Пример #1
0
 public static function validate_tags(Module_Links $module, $arg)
 {
     $errors = array();
     $new = 0;
     $arg = explode(',', trim($arg));
     $taken = array();
     $minlen = 3;
     $maxlen = $module->cfgMaxTagLen();
     foreach ($arg as $tag) {
         $tag = trim($tag);
         if (strlen($tag) === 0) {
             continue;
         }
         if (false === GWF_LinksTag::getByName($tag)) {
             if (self::isValidTagName($tag, $minlen, $maxlen)) {
                 $taken[] = $tag;
                 $new++;
             } else {
                 $errors[] = $module->lang('err_tag', array(GWF_HTML::display($tag), $minlen, $maxlen));
             }
         } else {
             $taken[] = $tag;
         }
     }
     if (count($taken) === 0) {
         $errors[] = $module->lang('err_no_tag');
     }
     $_POST['link_tags'] = implode(',', $taken);
     if (count($errors) === 0) {
         return false;
     }
     return implode('<br/>', $errors);
 }
Пример #2
0
 private function collectTags()
 {
     $back = array();
     $tags = GWF_LinksTag::getCloud();
     foreach ($tags as $tag) {
         $back[] = $tag->display('lt_name');
     }
     return implode(', ', $back);
 }
Пример #3
0
 private function sanitize()
 {
     $this->user = GWF_Session::getUser();
     $links = GDO::table('GWF_Links');
     $this->by = Common::getGet('by', self::DEFAULT_BY);
     $this->dir = Common::getGet('dir', self::DEFAULT_DIR);
     //		if ($this->by === false && $this->dir === false)
     //		{
     //			$this->by = self::DEFAULT_BY;
     //			$this->dir = self::DEFAULT_DIR;
     //			$this->orderby = self::DEFAULT_ORDERBY;
     //		}
     //		else
     //		{
     $this->orderby = $links->getMultiOrderby($this->by, $this->dir);
     //		}
     $this->tag = GWF_LinksTag::getWhitelistedTag(Common::getGet('tag'), '');
     $this->lpp = $this->module->cfgLinksPerPage();
     $this->nLinks = $links->countLinks($this->module, $this->user, $this->tag, false);
     $this->nPages = GWF_PageMenu::getPagecount($this->lpp, $this->nLinks);
     $this->page = Common::clamp(Common::getGet('page', 1), 1, $this->nPages);
     $this->from = GWF_PageMenu::getFrom($this->page, $this->lpp);
     if ($this->tag === '') {
         $this->sortURL = GWF_WEB_ROOT . 'links/by/%BY%/%DIR%/page-1';
         $href = GWF_WEB_ROOT . 'links/by/' . $this->by . '/' . $this->dir . '/page-%PAGE%';
     } else {
         $this->sortURL = GWF_WEB_ROOT . 'links/' . $this->tag . '/by/%BY%/%DIR%/page-1';
         $href = GWF_WEB_ROOT . 'links/' . Common::urlencodeSEO($this->tag) . '/by/' . $this->by . '/' . $this->dir . '/page-%PAGE%';
     }
     //		var_dump($this->tag);
     //		$unread_query = $this->module->getUnreadQuery($this->user);
     $tag_query = $links->getTagQuery($this->tag);
     //		var_dump($tag_query);
     if ($this->module->cfgShowPermitted()) {
         $conditions = "({$tag_query})";
     } else {
         $perm_query = $this->module->getPermQuery($this->user);
         $mod_query = $links->getModQuery($this->user);
         $member_query = $links->getMemberQuery($this->user);
         $private_query = $links->getPrivateQuery($this->user);
         $conditions = "({$perm_query}) AND ({$tag_query}) AND ({$mod_query}) AND ({$member_query}) AND ({$private_query})";
         # AND (NOT $unread_query))";
     }
     //		var_dump($conditions);
     if (false === ($this->links = $links->selectObjects('*', $conditions, $this->orderby, $this->lpp, $this->from))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $this->pagemenu = GWF_PageMenu::display($this->page, $this->nPages, $href);
     $this->add_link_text = GWF_LinksValidator::mayAddLink($this->module, $this->user);
     $this->hrefAdd = $this->add_link_text === false ? $this->module->getMethodURL('Add', '&tag=' . $this->tag) : false;
     //		$this->newLinks = $links->select("(($perm_query) AND ($unread_query) AND ($mod_query) AND ($member_query) AND ($tag_query))", 'link_date ASC');
     return false;
 }
Пример #4
0
 public function removeTags()
 {
     $tags = $this->getTags();
     foreach ($tags as $tag) {
         if (false === GWF_LinksTag::removeTag($this, $tag)) {
             //				return false;
         }
     }
     return GWF_LinksTagMap::remTags($this->getID());
 }