private function sanitize() { if (false === ($this->cat = GWF_Category::getByID(Common::getGet('catid', 0)))) { $this->catid = 0; $this->catTitle = GWF_HTML::lang('no_category'); } else { $this->catid = $this->cat->getID(); $this->catTitle = $this->cat->getTranslatedText(); } $news = GDO::table('GWF_News'); $catQuery = $this->catid === 0 ? '1' : "news_catid={$this->catid}"; $hiddenQuery = "news_options&1=0"; $condition = "({$catQuery}) AND ({$hiddenQuery})"; $this->numNews = $news->countRows($condition); $npp = $this->module->getNewsPerPage(); $this->nPages = GWF_PageMenu::getPagecount($npp, $this->numNews); $this->page = intval(Common::clamp(Common::getGet('page', '1'), 1, $this->nPages)); }
public static function getCategories() { $langid = GWF_Language::getCurrentID(); $back = array(); foreach (GDO::table(__CLASS__)->selectColumn('DISTINCT(`news_catid`)') as $catid) { if (false === ($cat = GWF_Category::getByID($catid))) { continue; } $cat->loadTranslations(); $back[] = $cat->getTranslatedText($langid); } return $back; }
public function validate_parent(Module_Category $module, $p) { if ($p === '0') { return false; } if ($p === self::$cat->getID() || false === ($cat = GWF_Category::getByID($p)) || $cat->getGroup() !== self::$cat->getGroup()) { return $this->module->lang('err_parent'); } return false; }