public static function getDescription($siteid) { $siteid = (int) $siteid; $browser_lid = GWF_Language::getCurrentID(); if (false === ($result = GDO::table('WC_Site')->selectAll('site_desc_lid, site_desc_txt', "site_desc_sid={$siteid} AND (site_desc_lid= {$browser_lid} OR site_desc_lid=site_descr_lid)", '', array('description'), 2, 0, GDO::ARRAY_N))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } // $sites = GWF_TABLE_PREFIX.'wc_site'; // $descr = GWF_TABLE_PREFIX.'wc_site_descr'; // $db = gdo_db(); // // $query = "SELECT site_desc_lid, site_desc_txt FROM $sites JOIN $descr ON site_desc_sid=site_id WHERE site_desc_sid=$siteid AND (site_desc_lid=$browser_lid OR site_desc_lid=site_descr_lid)"; // // if (false === ($result = $db->queryAll($query, false))) { // return ''; // } // if (count($result) === 2) { if ($result[0][0] === $browser_lid) { return $result[0][1]; } else { return $result[1][1]; } } else { return $result[0][1]; } }
function module_PageBuilder_monthly() { require_once GWF_CORE_PATH . 'module/PageBuilder/GWF_Page.php'; $enabled = GWF_Page::ENABLED; $langid = GWF_Language::getCurrentID(); $db = gdo_db(); $t = GWF_TABLE_PREFIX . 'page'; $query = "SELECT IFNULL(p2.page_otherid,p1.page_otherid), IFNULL(p2.page_title,p1.page_title), IFNULL(p2.page_url,p1.page_url), IFNULL(p2.page_date,p1.page_date) FROM {$t} p1 LEFT JOIN {$t} p2 ON p1.page_otherid=p2.page_otherid AND p2.page_lang={$langid} WHERE p1.page_lang=0 ORDER BY 4 DESC"; if (false === ($result = $db->queryRead($query))) { return ''; } $first = NULL; $tree = array(); while (false !== ($page = $db->fetchRow($result))) { if ($first === NULL) { $first = $page; } monthlyAddTree($tree, $page); } $db->free($result); if (count($tree) === 0) { return ''; } // $first = $pages[key($pages)]; $currdate = $first[3]; list($y, $m, $d) = monthlySplit($currdate); $cy = $y; $cm = $m; $cd = $d; // $tree = monthlyGetTree($pages); $back = '<div class="gwf_pb_monthly fr">' . PHP_EOL; foreach ($tree as $year => $y2) { $c = count($y2); $back .= "<ol id=\"_pby{$year}\"><li>{$year}({$c})</li>\n"; foreach ($y2 as $m1 => $m2) { $c = count($m2); $month = GWF_HTML::lang('M' . ($m1 + 0)); $back .= "<li>{$year} {$month} ({$c})<ol>\n"; foreach ($m2 as $page) { $url = htmlspecialchars(GWF_WEB_ROOT . $page[2]); $title = htmlspecialchars($page[1]); $back .= "<li><a href=\"{$url}\" title=\"{$title}\">{$title}</a></li>\n"; } $back .= "</ol></li>\n"; } $back .= "</ol>\n"; } $back .= '</div>' . PHP_EOL; return $back; echo $back; return; }
public function templateShow() { if (false === ($news = GWF_News::getNewsQuick($this->module->getNewsPerPage(), $this->catid, $this->page, GWF_Language::getCurrentID()))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $date = count($news) > 0 ? $news[0]['news_date'] : GWF_Settings::getSetting('gwf_site_birthday') . '090000'; $date = GWF_Time::displayDate($date); GWF_Website::setPageTitle($this->module->lang('pt_news', array($date))); GWF_Website::setMetaTags($this->module->lang('mt_news', array($date))); GWF_Website::setMetaDescr($this->module->lang('md_news', array($this->page, $this->nPages))); // $mod_forum = GWF_Module::getModule('Forum', true); $tVars = array('news' => $news, 'titles' => GWF_News::getTitlesQuick($this->catid, GWF_Language::getCurrentID()), 'cats' => GWF_News::getCategories(), 'catid' => $this->catid, 'cat' => GWF_HTML::display($this->catTitle), 'page_menu' => $this->getPageMenu(), 'page' => $this->page, 'can_sign' => $this->module->canSignNewsletter(GWF_Session::getUser()), 'href_sign_news' => $this->module->hrefSignNewsletter(), 'may_add' => GWF_User::isAdminS() || GWF_User::isStaffS(), 'href_add' => $this->module->hrefAddNews()); return $this->module->templatePHP('show.php', $tVars); }
private function buildFAQ() { $back = array(); $faq = GDO::table('GWF_HelpdeskFAQ'); $lid = GWF_Language::getCurrentID(); $where = "(hdf_langid=0 OR hdf_langid={$lid})"; if (false === ($result = $faq->select('*', $where, '', NULL))) { return $back; } while (false !== ($row = $faq->fetch($result, GDO::ARRAY_A))) { $back[] = $this->buildFAQRow($row); } $faq->free($result); return $back; }
private function getForm($row) { $user = GWF_User::getStaticOrGuest(); if ($row === false) { $email = $user->getValidMail(); $type = 0; $langid = GWF_Language::getCurrentID(); } else { $email = $row->getEMail(); $type = $row->getType(); $langid = $row->getLangID(); } $data = array('email' => array(GWF_Form::STRING, $email, $this->module->lang('th_email')), 'type' => array(GWF_Form::SELECT, GWF_Newsletter::getTypeSelectB($this->module, 'type', $type), $this->module->lang('th_type')), 'langid' => array(GWF_Form::SELECT, GWF_LangSelect::single(GWF_Language::SUPPORTED, 'langid', $langid), $this->module->lang('th_langid')), 'sign' => array(GWF_Form::SUBMIT, $this->module->lang('btn_sign'), '')); return new GWF_Form(GDO::table('GWF_Newsletter'), $data); }
public static function single($name, $selected, $parent_id = 0) { if (false === ($mod_cat = GWF_Module::loadModuleDB('Category', true, true))) { return GWF_HTML::err('ERR_MODULE_MISSING', array('Category')); } $langid = GWF_Language::getCurrentID(); $data = array(); $data[] = array('0', $mod_cat->lang('th_sel')); if (false !== ($cats = GWF_Category::getAllCategoriesCached())) { foreach ($cats as $cat) { $cat instanceof GWF_Category; $cat->loadTranslations(); $trans = $cat->getTranslation($langid); $data[] = array($cat->getID(), false !== $trans ? $trans : $cat->getVar('cat_tree_key')); } } return GWF_Select::display($name, $data, $selected); }
public static function getFakeNews($title, $message) { return self::newNews(GWF_Time::getDate(), 0, 0, GWF_Language::getCurrentID(), $title, $message, true); // return new GWF_News(array( // 'news_date' => GWF_Time::getDate(GWF_Date::LEN_MINUTE), // 'news_userid' => false, // 'news_trans' => array( // $langid=>array( // 'newst_langid' => $langid, // 'newst_newsid' => 0, // 'newst_title' => $title, // 'newst_message' => $message, // 'newst_options' => 0, // 'newst_threadid' => 0, // ), // ), // )); }
public static function getPreviewRow($email) { return new self(array('nl_email' => $email, 'nl_userid' => 0, 'nl_options' => self::TYPE_FIELDS, 'nl_unsign' => 'B4Dc0d3dCh42z', 'nl_langid' => GWF_Language::getCurrentID())); }
public function getTranslatedText($langid = 0) { $langid = (string) $langid; if ($langid === '0') { $langid = (string) GWF_Language::getCurrentID(); } if (isset($this->gdo_data['translations'][$langid])) { return $this->gdo_data['translations'][$langid]['cl_translation']; } else { return $this->getVar('key for ' . $langid); } }
public function execute() { $form = $this->formQuicksearch(); # I like typehinting :S $module = $this->module; $module instanceof Module_PageBuilder; $user = GWF_User::getStaticOrGuest(); $ulid = GWF_Language::getCurrentID(); $table = GDO::table('GWF_Page'); $joins = NULL; $tablename = $table->getTableName(); # Build where clause $term = ''; $where = '1'; $language = ''; $languaged = '1'; if (isset($_GET['quicksearch'])) { # Termwhere if ('' !== ($term = Common::getGetString('term', ''))) { $fields = array('page_author_name', 'page_title', 'page_content'); if (false === ($where = GWF_QuickSearch::getQuickSearchConditions($table, $fields, $term))) { $where = '1'; } } # Langwhere if (0 !== ($language = Common::getGetInt('lang', 0))) { if (GWF_LangSelect::isValidLanguage($language, false, GWF_Language::SUPPORTED)) { $languaged = "(SELECT 1 FROM `{$tablename}` lt WHERE lt.page_otherid=t.page_otherid AND lt.page_lang={$language})"; } } } $published = 'page_options&' . (GWF_Page::ENABLED | GWF_Page::LOCKED) . '=' . GWF_Page::ENABLED; $permquery = '1'; # TODO: Check group permissions! $where = "({$permquery}) AND ({$where}) AND ({$published}) AND ({$languaged})"; # Setup pagemenu $ipp = 25; $nItems = $table->selectVar('COUNT(DISTINCT(page_otherid))', $where, '', $joins); $nPages = GWF_PageMenu::getPagecount($ipp, $nItems); $page = Common::clamp(Common::getGetInt('page', 1), 1, $nPages); $from = GWF_PageMenu::getFrom($page, $ipp); # Setup order $by = Common::getGetString('by', 'page_id'); $dir = Common::getGetString('dir', 'ASC'); $orderby = $table->getMultiOrderby($by, $dir); # Now query only page_otherids if (false === ($pageids = $table->selectColumn('DISTINCT(page_otherid)', $where, $orderby, $joins, $ipp, $from))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } # Setup page array $pages = array(); $languages = GWF_Language::getSupported(); foreach ($pageids as $otherid) { $pagedata = $table->selectAll('page_id, page_lang, page_author_name, page_create_date, page_date, page_url, page_title', "page_otherid={$otherid}", "page_id={$otherid}"); $title = ''; $_langs = array(); foreach ($pagedata as $data) { $pagelang = $data['page_lang']; // echo "$pagelang<br/>"; # English 2nd choice if ($pagelang === '1' && $title === '') { $title = $data['page_title']; } elseif ($data['page_lang'] === $ulid) { $title = $data['page_title']; } # Store for next loop $_langs[$pagelang] = array($data['page_url']); } # Build output flags $langstring = ''; foreach ($languages as $language) { $language instanceof GWF_Language; $lid = $language->getID(); if (isset($_langs[$lid])) { $langstring .= sprintf('<a href="%s%s">%s</a>', GWF_WEB_ROOT, $_langs[$lid][0], $language->displayFlag(), $lid); } else { $langstring .= sprintf('<a href="%sindex.php?mo=PageBuilder&me=Translate&pageid=%s&to_lang_id=%s">%s</a>', GWF_WEB_ROOT, $otherid, $lid, GWF_Language::displayUnknownFlag($module->lang('translate_to', array($language->displayName())))); } } # Add as page row $pages[] = array('page_id' => $pagedata[0]['page_id'], 'page_otherid' => $otherid, 'page_title' => $title, 'page_url' => $pagedata[0]['page_url'], 'languages' => $langstring, 'page_date' => $pagedata[0]['page_date'], 'page_create_date' => $pagedata[0]['page_create_date'], 'page_author_name' => $pagedata[0]['page_author_name']); } # Display $tVars = array('quicksearch' => $form->templateX($this->module->lang('ft_search'), GWF_WEB_ROOT . 'index.php'), 'pages' => $pages, 'languages' => $languages, 'pagemenu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . 'index.php?mo=Lamb&me=Links&term=' . urlencode($term) . '&by=' . urlencode($by) . '&dir=' . urlencode($dir) . '&page=%PAGE%'), 'sort_url' => GWF_WEB_ROOT . 'index.php?mo=Lamb&me=Links&language=' . $language . '&term=' . urlencode($term) . '&by=%BY%&dir=%DIR%&page=' . $page); return $module->template('search.tpl', $tVars); }