private function onEdit() { $form = $this->getForm(); if (false !== ($error = $form->validate($this->module))) { #, array('langid', 'title', 'message')))) { return $error; } $langid = $this->lang->getID(); if (false === $this->news->saveTranslation($langid, $form->getVar('title'), $form->getVar('message'))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $options = 0; $back = ''; $oldhidden = $this->news->isHidden(); $newhidden = isset($_POST['hidden']); $options |= $newhidden ? GWF_News::HIDDEN : 0; if ($newhidden !== $oldhidden) { $back .= $this->module->message('msg_hidden_' . ($newhidden ? 1 : 0)); } $oldmail = $this->news->isToBeMailed(); $newmail = isset($_POST['mailme']); $options |= $newmail ? GWF_News::MAIL_ME : 0; if ($newmail !== $oldmail) { $back .= $this->module->message('msg_mailme_' . ($newmail ? 1 : 0)); } if (false === $this->news->saveVar('news_options', $options)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } // if ($this->module->cfgNewsInForum()) // { // $back .= $this->newsToForum($this->news, !$newhidden); // } return $back . $this->module->message('msg_edited', array($this->news->displayTitle(), $this->lang->displayName())); }
private function getItems(GWF_Language $lang) { $back = array(); $items = GWF_News::getNews($this->module->cfgFeedItemcount(), 0, 1, "news_date DESC", false); $langid = $lang->getID(); foreach ($items as $item) { $item instanceof GWF_News; $t = $item->getTranslationB($langid); $back[] = array('title' => $t['newst_title'], 'descr' => GWF_Message::display($t['newst_message'], true, false, false), 'guid' => Common::getAbsoluteURL($item->hrefShow($lang), false), 'link' => Common::getAbsoluteURL($item->hrefShow($lang), false), 'date' => $item->displayDate(), 'pub_date' => $item->rssDate()); } return $back; }
private function templateRanking(GWF_Language $lang, $user) { $db = gdo_db(); $ipp = 50; $iso = $lang->getISO(); $langid = $lang->getID(); $users = GWF_TABLE_PREFIX . 'user'; $regat = GWF_TABLE_PREFIX . 'wc_regat'; # Count number of users playing this language. $query = "SELECT COUNT(DISTINCT regat_uid) AS c FROM {$regat} WHERE regat_langid={$langid} AND regat_options&4=0"; if (false === ($result = $db->queryFirst($query))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } # Page Menu $nItems = intval($result['c']); $nPages = GWF_PageMenu::getPagecount($ipp, $nItems); list($page, $hl_rank) = $this->getPageRank($langid, $ipp, $user); GWF_Website::setPageTitle($this->module->lang('pt_langrank', array($lang->displayName(), $page, $nPages))); GWF_Website::setMetaTags($this->module->lang('mt_ranking_lang', array($lang->displayName()))); GWF_Website::setMetaDescr($this->module->lang('md_ranking_lang', array($lang->displayName(), $page, $nPages))); // echo 'PAGE:'; // var_dump($page); // // echo 'RANK:'; // var_dump($hl_rank); // $page = Common::clamp($page, 1, $nPages); $from = GWF_PageMenu::getFrom($page, $ipp); # Query Data $query = "SELECT r1.regat_uid AS user_id, user_name, user_level, user_countryid, r1.regat_sid, r1.regat_solved AS solved, r2.sum AS sum " . "FROM {$regat} AS r1 " . "JOIN (SELECT regat_uid,SUM(regat_score) AS sum FROM {$regat} WHERE regat_langid={$langid} GROUP BY regat_uid ORDER BY SUM(regat_score) DESC LIMIT {$from},{$ipp}) AS r2 ON r1.regat_uid=r2.regat_uid " . "JOIN {$users} AS u ON u.user_id=r1.regat_uid " . "WHERE regat_options&4=0 " . "ORDER BY sum DESC "; if (false === ($result = $db->queryRead($query))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } // var_dump($query); $data = array(); while (false !== ($row = $db->fetchAssoc($result))) { $uid = intval($row['user_id']); if (!isset($data[$uid])) { $data[$uid] = new GWF_User($row); } $sid = $row['regat_sid']; $data[$uid]->setVar('ss_' . $sid, (double) $row['solved']); } $db->free($result); # Show template $tVars = array('rank' => $from + 1, 'hlrank' => $hl_rank, 'page_menu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . 'lang_ranking/' . $iso . '/page-%PAGE%'), 'langname' => $lang->displayName(), 'users' => $data, 'sites' => WC_Site::getSitesLang($langid), 'form_action' => $this->getMethodHref(), 'iso' => $lang->getISO()); return $this->module->templatePHP('ranking_lang.php', $tVars); }
public function hrefShow(GWF_Language $lang) { $langid = $lang->getID(); $newsid = $this->getVar('news_id'); $catid = $this->getVar('news_catid'); $cat = Common::urlencodeSEO($this->getCategoryTitle($langid)); $title = Common::urlencodeSEO($this->getTitleL($langid)); return GWF_WEB_ROOT . sprintf('news/%s/%s/%s/%s/%s#newsid_%s', $lang->getVar('lang_iso'), $catid, $cat, $newsid, $title, $newsid); }