public function displayLang() { # FIXME: page_lang not assigned //if (false === ($lang = GWF_Language::getByID($this->getVar('page_lang')))) { if (false === ($lang = GWF_Language::getByID(1))) { return GWF_Module::getModule('PageBuilder')->lang('lang_all'); } return $lang->displayName(); }
public function validate_target(Module_Language $m, $arg) { if (isset($_POST['all_targets'])) { return false; } if (false === ($this->target = GWF_Language::getByID($arg))) { return GWF_HTML::lang('ERR_UNKNOWN_LANGUAGE'); } return false; }
private function onCheck() { $form = $this->getForm(); if (false !== ($errors = $form->validate($this->module))) { return $errors . $this->templateChecker(); } if (false === ($this->lang = GWF_Language::getByID(Common::getPost('langs')))) { return GWF_HTML::err('ERR_UNKNOWN_LANGUAGE') . $this->templateChecker(); } $this->show_warns = isset($_POST['warns']); return $this->templateChecker() . $this->onCheckB(); }
public static function isValidLanguage($langid, $allow_zero = false, $bitmask = self::TYPE_ALL) { $min = $allow_zero === true ? -1 : 0; if ($min >= ($langid = (int) $langid)) { return false; } if ($langid === 0) { return true; # Zero allowed } if (false === ($lang = GWF_Language::getByID($langid))) { return false; } return $lang->isOptionEnabled($bitmask); }
public function newsToForum(GWF_News $news, $visible = true) { if (false === ($poster = $news->getUser())) { return GWF_HTML::error('News_Edit', 'News_Edit::newsToForum(): Nobody as Poster'); } // Get News root. if (false === ($news_root = $this->getNewsForumRoot())) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $root_id = $news_root->getID(); $lang_roots = array(); foreach ($news->getTranslations() as $t) { if (false === ($lang = GWF_Language::getByID($t['newst_langid']))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === ($lang_board = $this->getNewsForumLangCached($lang, $root_id))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $iso = $lang->getISO(); $tid = (int) $t['newst_threadid']; $lang_roots[$iso] = $lang_board; $bid = $lang_board->getID(); $thread = GWF_ForumThread::getByID($tid); $title = $t['newst_title']; $message = $t['newst_message']; $gid = 0; $options = GWF_ForumThread::GUEST_VIEW; $options |= $visible ? 0 : GWF_ForumThread::INVISIBLE; if (!$visible) { if ($thread !== false) { $thread->setVisible($visible); } } else { if ($thread === false) { if (false === ($thread = GWF_ForumThread::newThread($poster, $title, $message, $options, $bid, $gid))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } } else { if (false === ($post = $thread->getFirstPost())) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $post->saveVar('post_message', $message)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } } $thread->setVisible($visible); } $tid = $thread === false ? 0 : $thread->getID(); $langid = $lang->getID(); $newsid = $news->getID(); // Save threadid if (false === GDO::table('GWF_NewsTranslation')->update("newst_threadid={$tid}", "newst_langid={$langid} AND newst_newsid={$newsid}")) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } } // Set Boards Visible $news_root->setVisible($visible); foreach ($lang_roots as $iso => $board) { $board->setVisible($visible); } return ''; }
echo $tVars['module']->templatePHP('_admin_nav.php', $tVars); $headers = array(array($tLang->lang('th_date'), 'news_date', 'ASC'), array($tLang->lang('th_userid'), 'user_name', 'ASC'), array($tLang->lang('th_catid'), 'news_catid', 'ASC'), array($tLang->lang('th_langid')), array($tLang->lang('th_title')), array($tLang->lang('th_hidden'), 'news_options&' . GWF_News::HIDDEN, 'DESC')); echo $tVars['page_menu']; echo GWF_Table::start(); echo GWF_Table::displayHeaders1($headers, $tVars['sort_url']); foreach ($tVars['news'] as $item) { $item instanceof GWF_News; $newsid = $item->getID(); $trans = $item->getTranslations(); $date = $item->displayDate(); $author = $item->displayAuthor(); $cat = $item->displayCategory(); $lang_visible = $tLang->lang('th_visible'); $lang_hidden = $tLang->lang('th_hidden'); foreach ($trans as $langid => $t) { var_dump($langid, $t); if ($item->isHidden()) { $icon = GWF_Button::add($lang_hidden, $item->hrefEnable()); } else { $icon = GWF_Button::sub($lang_visible, $item->hrefDisable()); } echo GWF_Table::rowStart(); $title = $t['newst_title']; $data[] = array($date, $author, $cat, GWF_Language::getByID($langid)->display('lang_nativename'), sprintf('<a href="%snews/edit/%d-%s/langid-%d">%s</a>', GWF_WEB_ROOT, $newsid, Common::urlencodeSEO($title), $langid, $title), $item->isHidden() ? $icon_hidden : $icon_visible); echo GWF_Table::rowEnd(); } } echo GWF_Table::end(); echo $tVars['page_menu']; echo GWF_Button::wrap(GWF_Button::add($tLang->lang('btn_add'), GWF_WEB_ROOT . 'news/add'));
/** * @return GWF_Language */ public function getSecLanguage() { return GWF_Language::getByID($this->getVar('user_langid2')); }
public function onEdit(WC_Site $site, $is_admin) { $form = $this->getForm($site, $is_admin); if (false !== ($errors = $form->validate($this->module))) { return $errors; } $basescore_changed = $language_changed = $status_changed = $spc_changed = $powarg_changed = false; if ($is_admin) { $basescore_changed = $form->getVar('site_basescore') != $site->getBasescore(); $language_changed = $form->getVar('site_language') !== $site->getLangID(); $status_changed = $form->getVar('site_status') !== $site->getStatus(); $spc_changed = $form->getVar('site_spc') !== $site->getVar('site_spc'); $powarg_changed = $form->getVar('site_powarg') !== $site->getVar('site_powarg'); $site->saveVars(array('site_classname' => $form->getVar('site_classname'), 'site_basescore' => $form->getVar('site_basescore'), 'site_usercount' => $form->getVar('site_usercount'), 'site_challcount' => $form->getVar('site_challcount'), 'site_joindate' => $form->getVar('site_joindate'), 'site_authkey' => $form->getVar('site_authkey'), 'site_status' => $form->getVar('site_status'), 'site_language' => $form->getVar('site_language'), 'site_spc' => $form->getVar('site_spc'), 'site_powarg' => $form->getVar('site_powarg'), 'site_color' => $form->getVar('site_color'))); } $site->saveVars(array('site_name' => $form->getVar('site_name'), 'site_country' => $form->getVar('site_country'), 'site_launchdate' => $form->getVar('site_launchdate'), 'site_xauthkey' => $form->getVar('site_xauthkey'), 'site_irc' => $form->getVar('site_irc'), 'site_url' => $form->getVar('site_url'), 'site_url_mail' => $form->getVar('site_url_mail'), 'site_url_score' => $form->getVar('site_url_score'), 'site_url_profile' => $form->getVar('site_url_profile'))); $site->setVar('site_country', GWF_Country::getByID($form->getVar('site_country'))); $site->setVar('site_language', GWF_Language::getByID($form->getVar('site_language'))); # Update tags if Admin if ($is_admin) { $new_tags = $form->getVar('site_tags'); if ($site->getTags() !== $new_tags) { echo GWF_HTML::message('WeChall', 'Fixing challenge site tags..'); $site->saveVar('site_tags', str_replace(' ', '', $new_tags)); require_once GWF_CORE_PATH . 'module/WeChall/WC_SiteCats.php'; WC_SiteCats::fixCatBits(); } } // $out = $this->onEditWarflag($site, isset($_POST['warenbl'])); $old_linear = $site->isLinear(); $site->saveOption(WC_Site::LINEAR, isset($_POST['linear'])); $linear_changed = $old_linear !== $site->isLinear(); $site->saveOption(WC_Site::NO_URLENCODE, isset($_POST['no_urlencode'])); $site->saveOption(WC_Site::AUTO_UPDATE, isset($_POST['auto_update'])); $site->saveOption(WC_Site::HIDE_BY_DEFAULT, isset($_POST['default_hide'])); $site->saveOption(WC_Site::ONSITE_RANK, isset($_POST['onsite_rank'])); $site->saveOption(WC_Site::NO_V1_SCRIPTS, isset($_POST['no_v1'])); # Trigger warbox config parsing. // if ($site->isWarBox()) // { // // $site->getWarIP(); // Module_WeChall::instance()->flushWarboxConfig(); // } # Recalculate in case of a change // if ($site->isScored()) // { if ($basescore_changed || $language_changed || $status_changed || $powarg_changed || $spc_changed || $linear_changed) { $site->recalcSite(); WC_RegAt::calcTotalscores(); } // } return $this->module->message('msg_site_edited', array($site->displayName())); #.$out; }
$lang_hidden = $tLang->lang('th_hidden'); echo GWF_Table::start(); foreach ($tVars['news'] as $item) { $item instanceof GWF_News; $newsid = $item->getID(); $trans = $item->getTranslations(); $author = $item->displayAuthor(); $cat = $item->displayCategory(); $date = $item->displayDate(); foreach ($trans as $langid => $t) { if ($item->isHidden()) { $icon = GWF_Button::sub($lang_hidden, $item->hrefEnable()); } else { $icon = GWF_Button::add($lang_visible, $item->hrefDisable()); } echo GWF_Table::rowStart(); echo GWF_Table::column($date, 'gwf_date'); echo GWF_Table::column($author); echo GWF_Table::column($cat); echo GWF_Table::column(GWF_Language::getByID($langid)->display('lang_nativename')); $title = $t['newst_title']; $href = GWF_WEB_ROOT . sprintf('news/edit/%d-%s/langid-%d', $newsid, Common::urlencodeSEO($title), $langid); echo GWF_Table::column(sprintf('<a href="%s">%s</a>', $href, htmlspecialchars($title))); echo GWF_Table::column($icon); echo GWF_Table::rowEnd(); } } echo GWF_Table::end(); echo $tVars['page_menu']; $buttons = GWF_Button::add($tLang->lang('btn_add'), GWF_WEB_ROOT . 'news/add'); echo GWF_Button::wrap($buttons);
private function onDefault() { if (false === ($langid = $this->getPostLangID('default'))) { return GWF_HTML::err('ERR_UNKNOWN_LANGUAGE'); } $form = $this->getFormEdit($langid, ''); if (false !== ($error = $form->validate($this->module))) { return $error; } if ($this->site->getVar('site_descr_lid') == $langid) { return ''; } $descr = WC_SiteDescr::getDescriptions($this->site->getID()); if (!isset($descr[$langid])) { return $this->module->error('err_no_descr'); } if (false === $this->site->saveVars(array('site_descr_lid' => $langid))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } return $this->module->message('msg_def_descr', array(GWF_Language::getByID($langid)->displayName())); }
public function onEdit(GWF_Category $cat) { $keyOld = $cat->getKey(); $form = $this->getForm($cat); if (false !== ($error = $form->validate($this->module))) { return $error; } // if ('' !== ($error = $form->validateVars(array('key', 'langid')))) { // return $error; // } // new translation $back = ''; if (0 !== ($langid = (int) Common::getPost('langid', 0))) { $trans = Common::getPost('newtrans'); if (false === $cat->saveTranslation($langid, $trans)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $back .= $this->module->message('msg_trans_added', array(GWF_Language::getByID($langid)->display('lang_name'), GWF_HTML::display($keyOld), GWF_HTML::display($trans))); } // change key! $keyNew = $form->getVar('key'); if ($keyOld !== $keyNew) { $cat->saveVar('key', $keyNew); $back .= $this->module->message('msg_new_key', array(GWF_HTML::display($keyOld), GWF_HTML::display($keyNew))); } # Change tree $parent = $form->getVar('parent', '0'); $oldpar = $cat->getParentID(); if ($oldpar !== $parent) { if (!$cat->saveVar('cat_tree_pid', $parent)) { $back .= GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } else { $cat->rebuildFullTree(); $back .= $this->module->message('msg_new_parent'); } } if (!isset($_POST['trans']) || !is_array($_POST['trans'])) { $_POST['trans'] = array(); } # update translation foreach ($_POST['trans'] as $langid => $textNew) { $textOld = $cat->getTranslation($langid); if ($textNew !== $textOld) { if (false === $cat->saveTranslation($langid, $textNew)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $langname = GWF_Language::getByID($langid)->display('lang_name'); $back .= $this->module->message('msg_trans_changed', array($langname, GWF_HTML::display($textNew))); } } return $back; }
<?php echo GWF_Box::box($tLang->lang('pi_ranking'), $tLang->lang('pit_ranking')); WC_HTML::rankingPageButtons(); $headers = array(array($tLang->lang('th_rank')), array(), array($tLang->lang('th_user_name')), array($tLang->lang('th_num_linked')), array($tLang->lang('th_user_level'))); $isos = array(); foreach ($tVars['langs'] as $lang) { $lang = GWF_Language::getByID($lang); $iso = $lang->getISO(); $href = GWF_WEB_ROOT . 'lang_ranking/' . $iso; $head = sprintf('<a href="%s">%s</a>', $href, $lang->displayName()); $headers[] = array($head); $isos[] = $iso; } $rank = $tVars['rank']; $highlight_rank = $tVars['highlight_rank']; $samerank = $rank; $samescore = 0; echo $tVars['pagemenu']; echo '<table>' . PHP_EOL; // echo '<thead>'.PHP_EOL; echo GWF_Table::displayHeaders2($headers); // echo '</thead>'.PHP_EOL; foreach ($tVars['userdata'] as $user) { $user instanceof GWF_User; // var_dump($user->getGDOData()); $score = $user->getLevel(); if ($score !== $samescore) { $samerank = $rank; $samescore = $score; }