/** * Example usage: * <code> * <?php * $SOME_TEMPLATE = '{LANGUAGELINKS}'; // render default (available) lan list, include current query string * </code> * * <code> * <?php * $SOME_TEMPLATE = '{LANGUAGELINKS=English,Bulgarian}'; // render custom lan list, include current query string * </code> * * <code> * <?php * $SOME_TEMPLATE = '{LANGUAGELINKS=English,Bulgarian|noquery}'; // render custom lan list, exclude query * </code> * * <code> * <?php * $SOME_TEMPLATE = '{LANGUAGELINKS=|home}'; // render default (available) lan list, point always to site index * </code> * * @param string $parm */ function languagelinks_shortcode($parm = '') { if (!defined('LANGLINKS_SEPARATOR')) { define('LANGLINKS_SEPARATOR', ' | '); } $tmp = explode('|', $parm, 2); $parm = $tmp[0]; $parms = array(); if (isset($tmp[1])) { parse_str($tmp[1], $parms); } // ignore Query string if required by parms or external code, false by default if (!defined('LANGLINKS_NOQUERY')) { define('LANGLINKS_NOQUERY', isset($parms['noquery'])); } if (!defined('LANGLINKS_HOME')) { define('LANGLINKS_HOME', isset($parms['home'])); } /*require_once(e_HANDLER.'language_class.php'); $slng = new language;*/ $slng = e107::getLanguage(); if (!empty($parm)) { $languageList = explode(',', $parm); } else { $languageList = $slng->installed(); sort($languageList); } if (count($languageList) < 2) { return; } foreach ($languageList as $languageFolder) { $code = $slng->convert($languageFolder); $name = $slng->toNative($languageFolder); //$subdom = (isset($cursub[2])) ? $cursub[0] : ''; if (e107::getPref('multilanguage_subdomain')) { $code = $languageFolder == e107::getPref('sitelanguage') ? 'www' : $code; if (LANGLINKS_HOME) { $link = str_replace($_SERVER['HTTP_HOST'], $code . '.' . e_DOMAIN, SITEURL); } else { $link = !LANGLINKS_NOQUERY ? str_replace($_SERVER['HTTP_HOST'], $code . '.' . e_DOMAIN, e_REQUEST_URL) : str_replace($_SERVER['HTTP_HOST'], $code . '.' . e_DOMAIN, e_REQUEST_SELF); // excludes query string } } else { // TODO - switch to elan=Language query when possible (now it'll break the old DOT query string format) if (LANGLINKS_HOME) { $link = SITEURL . '?elan=' . $code; } else { $e_QUERY = str_replace('[' . e_MENU . ']', "", e_QUERY); $link = !LANGLINKS_NOQUERY ? e_REQUEST_SELF . '?[' . $code . ']' . $e_QUERY : e_REQUEST_SELF . '?elan=' . $code; } } $class = $languageFolder == e_LANGUAGE ? 'languagelink_active' : 'languagelink'; $ret[] = "\n<a class='{$class}' href='{$link}'>{$name}</a>"; } return implode(LANGLINKS_SEPARATOR, $ret); }
/** * Copy data read from the DB into the record to be returned. * $target - e107_users table * $source - phpbb_user table : https://wiki.phpbb.com/Table.phpbb_users */ function copyUserData(&$target, &$source) { // if ($this->copyUserInfo) $target['user_id'] = $source['user_id']; $target['user_name'] = $source['username']; $target['user_loginname'] = $source['username']; $target['user_password'] = $this->convertPassword($source['user_password']); $target['user_email'] = $source['user_email']; $target['user_signature'] = $this->convertText($source['user_sig']); $target['user_image'] = $source['user_avatar']; $target['user_hideemail'] = $source['user_allow_viewemail']; $target['user_join'] = $source['user_regdate']; $target['user_lastvisit'] = $source['user_lastvisit']; $target['user_currentvisit'] = 0; $target['user_admin'] = 0; // $source['user_level']; $target['user_lastpost'] = $source['user_lastpost_time']; $target['user_chats'] = ''; $target['user_comments'] = ''; $target['user_ip'] = $source['user_ip']; $target['user_ban'] = $this->convertUserBan($source['user_type']); $target['user_prefs'] = ''; $target['user_visits'] = ''; $target['user_admin'] = $source['group_id'] == 5 || $source['user_type'] == 3 ? 1 : 0; //user_type == 3 is 'founder' $target['user_login'] = ''; $target['user_class'] = $this->convertUserclass($source['group_id']); $target['user_perms'] = $source['user_type'] == 3 ? '0' : ''; $target['user_realm'] = ''; $target['user_pwchange'] = $source['user_passchg']; $target['user_xup'] = ''; // Extended Fields. $target['user_plugin_forum_viewed'] = 0; $target['user_plugin_forum_posts'] = $source['user_posts']; $target['user_timezone'] = $source['user_timezone']; // source is decimal(5,2) $target['user_language'] = e107::getLanguage()->convert($source['user_lang']); // convert from 2-letter to full. $target['user_location'] = $source['user_from']; $target['user_icq'] = $source['user_icq']; $target['user_aim'] = $source['user_aim']; $target['user_yahoo'] = $source['user_yim']; $target['user_msn'] = $source['user_msnm']; $target['user_homepage'] = $source['user_website']; $target['user_birthday'] = $this->convertBirthday($source['user_birthday']); $target['user_occupation'] = $source['user_occ']; $target['user_interests'] = $source['user_interests']; return $target; }
/** * List the installed language packs. * @return */ function showLanguagePacks() { $frm = e107::getForm(); $ns = e107::getRender(); $tp = e107::getParser(); if (is_readable(e_ADMIN . "ver.php")) { include e_ADMIN . "ver.php"; list($ver, $tmp) = explode(" ", $e107info['e107_version']); } $lans = e107::getLanguage()->installed(); $release_diz = defined("LANG_LAN_30") ? LANG_LAN_30 : "Release Date"; $compat_diz = defined("LANG_LAN_31") ? LANG_LAN_31 : "Compatibility"; $lan_pleasewait = deftrue('LAN_PLEASEWAIT') ? $tp->toJS(LAN_PLEASEWAIT) : "Please Wait"; $text = "<form id='lancheck' method='post' action='" . e_REQUEST_URI . "'>\n\t\t\t<table class='table table-striped'>"; $text .= "<thead>\n\t\t<tr>\n\t\t<th>" . ADLAN_132 . "</th>\n\t\t<th>" . $release_diz . "</th>\n\t\t<th>" . $compat_diz . "</th>\n\t\t<th>" . LAN_STATUS . "</td>\n\t\t<th style='width:25%;white-space:nowrap'>" . LAN_OPTIONS . "</td>\n\t\t</tr>\n\t\t</thead>\n\t\t"; require_once e_HANDLER . "xml_class.php"; $xm = new XMLParse(); foreach ($lans as $language) { if ($language == "English") { continue; } $metaFile = e_LANGUAGEDIR . $language . "/" . $language . ".xml"; if (is_readable($metaFile)) { $rawData = file_get_contents($metaFile); if ($rawData) { $array = $xm->parse($rawData); $value = $array['e107Language']['attributes']; } else { $value = array('date' => " ", 'compatibility' => ' '); } } else { $value = array('date' => " ", 'compatibility' => ' '); } $errFound = isset($_SESSION['lancheck'][$language]['total']) && $_SESSION['lancheck'][$language]['total'] > 0 ? TRUE : FALSE; $text .= "<tr>\n\t\t\t<td >" . $language . "</td>\n\t\t\t<td>" . $value['date'] . "</td>\n\t\t\t<td>" . $value['compatibility'] . "</td>\n\t\t\t<td>" . ($ver != $value['compatibility'] || $errFound ? ADMIN_FALSE_ICON : ADMIN_TRUE_ICON) . "</td>\n\t\t\t<td>"; // $text .= "<input type='submit' name='language_sel[{$language}]' value=\"".LAN_CHECK_2."\" class='btn btn-primary' />"; $text .= "<a href='" . e_REQUEST_URI . "&sub=verify&lan=" . $language . "' class='btn btn-primary' >" . LAN_CHECK_2 . "</a>"; $text .= "\n\t\t\t<input type='submit' name='ziplang[{$language}]' value=\"" . LANG_LAN_23 . "\" class='button' onclick=\"this.value = '" . $lan_pleasewait . "'\" /></td>\n\t\t\t</tr>"; } $text .= "\n\n\t\t</tr></table>"; $text .= "<table class='table table-striped'>"; $text .= "<thead><tr><th>" . LAN_OPTIONS . "</th></tr></thead><tbody>"; $srch = array("[", "]"); $repl = array("<a rel='external' href='http://e107.org/content/About-Us:The-Team#translation-team'>", "</a>"); $diz = deftrue("LANG_LAN_28") ? LANG_LAN_28 : "Check this box if you're an [e107 certified translator]."; $checked = varset($_COOKIE['e107_certified']) == 1 ? true : false; $text .= "<tr><td>"; $text .= $frm->checkbox('contribute_pack', 1, $checked, array('label' => str_replace($srch, $repl, $diz))); $text .= "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t<td>"; // $echecked = varset($_SESSION['lancheck-errors-only']) == 1 ? true : false; // $text .= $frm->checkbox('errorsonly',1,$echecked,array('label'=>$lan_displayerrors)); $text .= " </td>\n\n\t\t</tr>"; // $text .= " // <tr> // <td>".$frm->checkbox('non-core-plugs-themes',1,$echecked,array('label'=>$lan_displayerrors))."</td> // </tr> // "; $text .= "</tbody></table>"; $text .= "</form>"; $text .= "<div class='smalltext center' style='padding-top:50px'>" . LANG_LAN_AGR . "</div>"; $text .= $this->onlineLanguagePacks(); return $text; return; }
/** * Set module aliases * @param array $aliases * @return eRouter */ public function setAliases($aliases = null) { if (null === $aliases) { $lanCode = e107::getLanguage()->convert(e_LANGUAGE); $aliases = e107::findPref('url_aliases/' . $lanCode, array()); } $this->_aliases = $aliases; return $this; }
function user_extended_edit($struct, $curval) { $tp = e107::getParser(); $frm = e107::getForm(); if (trim($curval) == "" && $struct['user_extended_struct_default'] != "") { $curval = $struct['user_extended_struct_default']; } $choices = explode(",", $struct['user_extended_struct_values']); foreach ($choices as $k => $v) { $choices[$k] = str_replace("[E_COMMA]", ",", $v); } $parms = explode("^,^", $struct['user_extended_struct_parms']); $include = preg_replace("/\n/", " ", $tp->toHtml($parms[0])); $regex = $tp->toText($parms[1]); $regexfail = $tp->toText($parms[2]); $fname = "ue[user_" . $struct['user_extended_struct_name'] . "]"; $required = vartrue($struct['user_extended_struct_required']) == 1 ? "required" : ""; $fid = $frm->name2id($fname); if (strpos($include, 'class') === FALSE) { $include .= " class='form-control tbox' "; } switch ($struct['user_extended_struct_type']) { case EUF_TEXT: //textbox //textbox case EUF_INTEGER: //integer $ret = "<input id='{$fid}' type='text' name='{$fname}' value='{$curval}' {$include} {$required} />"; return $ret; break; case EUF_RADIO: //radio $ret = ''; foreach ($choices as $choice) { $choice = trim($choice); if (strpos($choice, "|") !== FALSE) { list($val, $label) = explode("|", $choice); } elseif (strpos($choice, " => ") !== FALSE) { list($val, $label) = explode(" => ", $choice); } else { $val = $choice; $label = $choice; } $label = deftrue($label, $label); if (deftrue('BOOTSTRAP')) { $ret .= $frm->radio($fname, $val, $curval == $val, array('label' => $label, 'required' => $struct['user_extended_struct_required'])); } else { $chk = $curval == $val ? " checked='checked' " : ""; $ret .= "<input id='{$fid}' {$include} type='radio' name='{$fname}' value='{$val}' {$chk} {$required} /> {$label}"; } } return $ret; break; case EUF_CHECKBOX: //checkboxes foreach ($choices as $choice) { $choice = trim($choice); if (strpos($choice, "|") !== FALSE) { list($val, $label) = explode("|", $choice); } elseif (strpos($choice, " => ") !== FALSE) { list($val, $label) = explode(" => ", $choice); } else { $val = $choice; $label = $choice; } $label = deftrue($label, $label); if (deftrue('BOOTSTRAP')) { $ret .= $frm->checkbox($fname, $val, $curval == $val, array('label' => $label, 'required' => $struct['user_extended_struct_required'])); } else { $chk = $curval == $val ? " checked='checked' " : ""; $ret .= "<input {$include} type='checkbox' name='{$fname}[]' value='{$val}' {$chk} /> {$label}<br />"; } } return $ret; break; case EUF_DROPDOWN: //dropdown $ret = "<select {$include} id='{$fid}' name='{$fname}' {$required} >\n"; $ret .= "<option value=''> </option>\n"; // ensures that the user chose it. foreach ($choices as $choice) { $choice = trim($choice); $choice = deftrue($choice, $choice); $sel = $curval == $choice ? " selected='selected' " : ""; $ret .= "<option value='{$choice}' {$sel}>{$choice}</option>\n"; } $ret .= "</select>\n"; return $ret; break; case EUF_PREDEFINED: // predefined list, shown in dropdown $listRoot = trim($struct['user_extended_struct_values']); // Base list name $filename = e_CORE . 'sql/extended_' . $listRoot . '.php'; if (!is_readable($filename)) { return 'No file: ' . $filename; } require_once $filename; $className = 'extended_' . $listRoot; if (!class_exists($className)) { return '?????'; } $temp = new $className(); if (!method_exists($className, 'getValue')) { return '???-???'; } $temp->pointerReset(); $ret = "<select id='{$fid}' {$include} name='{$fname}' {$required} >\n"; $ret .= "<option value=''> </option>\n"; // ensures that the user chooses it. while (FALSE !== ($row = $temp->getValue(0, 'next'))) { $val = key($row); $choice = $temp->getValue($val, 'display'); $sel = $curval == $val ? " selected='selected' " : ''; $ret .= "<option value='{$val}' {$sel}>{$choice}</option>\n"; } $ret .= "</select>\n"; return $ret; case EUF_DB_FIELD: //db_field $sql = e107::getDb('ue'); $order = $choices[3] ? "ORDER BY " . $tp->toDB($choices[3], true) : ""; if ($sql->select($tp->toDB($choices[0], true), $tp->toDB($choices[1], true) . "," . $tp->toDB($choices[2], true), "1 {$order}")) { $choiceList = $sql->db_getList('ALL', FALSE); $ret = "<select id='{$fid}' {$include} name='{$fname}' {$required} >\n"; $ret .= "<option value=''> </option>\n"; // ensures that the user chose it. foreach ($choiceList as $cArray) { $cID = trim($cArray[$choices[1]]); $cText = trim($cArray[$choices[2]]); $sel = $curval == $cID ? " selected='selected' " : ""; $ret .= "<option value='{$cID}' {$sel}>{$cText}</option>\n"; } $ret .= "</select>\n"; return $ret; } else { return ""; } break; case EUF_TEXTAREA: //textarea return "<textarea id='{$fid}' {$include} name='{$fname}' {$required} >{$curval}</textarea>"; break; case EUF_DATE: //date if ($curval == '0000-00-00') { $curval = ''; } return e107::getForm()->datepicker($fname, $curval, 'format=yyyy-mm-dd'); break; case EUF_LANGUAGE: // language $lanlist = e107::getLanguage()->installed(); sort($lanlist); $ret = "<select {$include} id='{$fid}' name='{$fname}' {$required} >\n"; $ret .= "<option value=''> </option>\n"; // ensures that the user chose it. foreach ($lanlist as $choice) { $choice = trim($choice); $sel = $curval == $choice || !USER && $choice == e_LANGUAGE ? " selected='selected' " : ""; $ret .= "<option value='{$choice}' {$sel}>{$choice}</option>\n"; } $ret .= "</select>\n"; break; } return $ret; }
function getOtherNav($type) { $tp = e107::getParser(); $frm = e107::getForm(); if ($type == 'home') { $menu_vars['home']['text'] = ""; // ADLAN_53; $menu_vars['home']['link'] = e_HTTP . 'index.php'; $menu_vars['home']['image'] = $tp->toGlyph('fa-home'); // "<i class='fa fa-home'></i>" ; // "<img src='".E_16_NAV_LEAV."' alt='".ADLAN_151."' class='icon S16' />"; $menu_vars['home']['image_src'] = ADLAN_151; $menu_vars['home']['sort'] = 1; $menu_vars['home']['sub_class'] = 'sub'; // Sub Links for 'home'. require_once e_HANDLER . "sitelinks_class.php"; $slinks = new sitelinks(); $slinks->getlinks(1); $tmp = array(); $c = 0; foreach ($slinks->eLinkList['head_menu'] as $k => $lk) { $subid = 'home_' . $k; $subid = $c; $link = substr($lk['link_url'], 0, 1) != "/" && substr($lk['link_url'], 0, 3) != "{e_" && substr($lk['link_url'], 0, 4) != 'http' ? "{e_BASE}" . $lk['link_url'] : $lk['link_url']; $tmp[$c]['text'] = $tp->toHtml($lk['link_name'], '', 'defs'); $tmp[$c]['description'] = $tp->toHtml($lk['link_description'], '', 'defs'); $tmp[$c]['link'] = $tp->replaceConstants($link, 'full'); $tmp[$c]['image'] = vartrue($lk['link_button']) ? "<img class='icon S16' src='" . $tp->replaceConstants($lk['link_button']) . "' alt='" . $tp->toAttribute($lk['link_description'], '', 'defs') . "' />" : ""; $tmp[$c]['image_large'] = ''; $tmp[$c]['image_src'] = vartrue($lk['link_button']); $tmp[$c]['image_large_src'] = ''; // $tmp[$c]['perm'] = ''; $c++; } $menu_vars['home']['sub'] = $tmp; // -------------------- } elseif ($type == 'logout') { $tmp = array(); $tmp[1]['text'] = LAN_SETTINGS; $tmp[1]['description'] = ADLAN_151; $tmp[1]['link'] = e_BASE . 'usersettings.php'; $tmp[1]['image'] = "<i class='S16 e-settings-16'></i>"; // "<img src='".E_16_CAT_SETT."' alt='".ADLAN_151."' class='icon S16' />"; $tmp[1]['image_large'] = ''; $tmp[1]['image_src'] = ''; $tmp[1]['image_large_src'] = ''; $tmp[2]['text'] = "Personalize"; // TODO - generic LAN in lan_admin.php $tmp[2]['description'] = "Customize administration panels"; $tmp[2]['link'] = e_ADMIN . 'admin.php?mode=customize'; $tmp[2]['image'] = "<i class='S16 e-admins-16'></i>"; //E_16_ADMIN; // "<img src='".E_16_NAV_ADMIN."' alt='".ADLAN_151."' class='icon S16' />"; $tmp[2]['image_large'] = ''; $tmp[2]['image_src'] = ''; $tmp[2]['image_large_src'] = ''; // $tmp[2]['perm'] = ''; $tmp[3]['text'] = LAN_LOGOUT; $tmp[3]['description'] = ADLAN_151; $tmp[3]['link'] = e_ADMIN_ABS . 'admin.php?logout'; $tmp[3]['image'] = "<i class='S16 e-logout-16'></i>"; // "<img src='".E_16_NAV_LGOT."' alt='".ADLAN_151."' class='icon S16' />"; $tmp[3]['image_large'] = ''; $tmp[3]['image_src'] = ''; $tmp[3]['image_large_src'] = ''; $tmp[4]['text'] = LAN_LOGOUT; $tmp[4]['description'] = ADLAN_151; $tmp[4]['link'] = e_ADMIN_ABS . 'admin.php?logout'; $tmp[4]['image'] = ""; $tmp[4]['image_large'] = ''; $tmp[4]['image_src'] = ''; $tmp[4]['image_large_src'] = ''; $tmp[4]['link_class'] = 'divider'; $tmp[5]['text'] = "e107 Website"; $tmp[5]['description'] = ''; $tmp[5]['link'] = 'http://e107.org'; $tmp[5]['image'] = E_16_E107; $tmp[5]['image_large'] = ''; $tmp[5]['image_src'] = ''; $tmp[5]['image_large_src'] = ''; $tmp[5]['link_class'] = ''; $tmp[6]['text'] = "e107 on Twitter"; $tmp[6]['description'] = ''; $tmp[6]['link'] = 'http://twitter.com/e107'; $tmp[6]['image'] = E_16_TWITTER; // "<img src='".E_16_NAV_LGOT."' alt='".ADLAN_151."' class='icon S16' />"; $tmp[6]['image_large'] = ''; $tmp[6]['image_src'] = ''; $tmp[6]['image_large_src'] = ''; $tmp[6]['link_class'] = ''; $tmp[7]['text'] = "e107 on Facebook"; $tmp[7]['description'] = ''; $tmp[7]['link'] = 'https://www.facebook.com/e107CMS'; $tmp[7]['image'] = E_16_FACEBOOK; // "<img src='".E_16_NAV_LGOT."' alt='".ADLAN_151."' class='icon S16' />"; $tmp[7]['image_large'] = ''; $tmp[7]['image_src'] = ''; $tmp[7]['image_large_src'] = ''; $tmp[7]['link_class'] = ''; $tmp[8]['text'] = "e107 on Github"; $tmp[8]['description'] = ''; $tmp[8]['link'] = 'https://github.com/e107inc'; $tmp[8]['image'] = E_16_GITHUB; // "<img src='".E_16_NAV_LGOT."' alt='".ADLAN_151."' class='icon S16' />"; $tmp[8]['image_large'] = ''; $tmp[8]['image_src'] = ''; $tmp[8]['image_large_src'] = ''; $tmp[8]['link_class'] = ''; $menu_vars['logout']['text'] = ADMINNAME; // ""; // ADMINNAME; $menu_vars['logout']['link'] = '#'; $menu_vars['logout']['image'] = $tp->toGlyph('fa-user'); // "<i class='icon-user'></i>"; // "<img src='".E_16_NAV_LGOT."' alt='".ADLAN_151."' class='icon S16' />"; $menu_vars['logout']['image_src'] = LAN_LOGOUT; $menu_vars['logout']['sub'] = $tmp; } if ($type == 'language') { $slng = e107::getLanguage(); $languages = $slng->installed(); //array('English','French'); $multiDoms = array(); if ($langSubs = explode("\n", e107::getPref('multilanguage_subdomain'))) { foreach ($langSubs as $v) { $multiDoms[] = trim($v); } } sort($languages); if (count($languages) > 1) { $c = 0; foreach ($languages as $lng) { $checked = "<i > </i> "; $code = $slng->convert($lng); if ($lng == e_LANGUAGE) { $checked = $tp->toGlyph('ok') . " "; $link = '#'; } elseif (in_array(e_DOMAIN, $multiDoms)) { $code = $lng == e107::getPref('sitelanguage') ? 'www' : $code; $link = str_replace($_SERVER['HTTP_HOST'], $code . '.' . e_DOMAIN, e_REQUEST_URL); // includes query string } else { $get = $_GET; $get['elan'] = $code; $qry = http_build_query($get); $link = e_REQUEST_SELF . '?' . $qry; } $tmp[$c]['text'] = $lng; $tmp[$c]['description'] = ''; $tmp[$c]['link'] = $link; $tmp[$c]['image'] = $checked; $tmp[$c]['image_large'] = ''; $tmp[$c]['image_src'] = ''; $tmp[$c]['image_large_src'] = ''; $c++; } $menu_vars['language']['text'] = strtoupper(e_LAN); // e_LANGUAGE; $menu_vars['language']['link'] = '#'; $menu_vars['language']['image'] = $tp->toGlyph('fa-globe'); // "<i class='icon-globe'></i>" ; $menu_vars['language']['image_src'] = null; $menu_vars['language']['sub'] = $tmp; } } return $menu_vars; }
/** * Auto-render Form Element * @param string $key * @param mixed $value * @param array $attributes field attributes including render parameters, element options - see e_admin_ui::$fields for required format * #param array (under construction) $required_data required array as defined in e_model/validator * @return string */ function renderElement($key, $value, $attributes, $required_data = array(), $id = 0) { // return print_a($value,true); $parms = vartrue($attributes['writeParms'], array()); $tp = e107::getParser(); if (is_string($parms)) { parse_str($parms, $parms); } if (!empty($attributes['multilan'])) { $value = is_array($value) ? varset($value[e_LANGUAGE], '') : $value; $parms['post'] = "<small class='e-tip admin-multilanguage-field input-group-addon' style='cursor:help; padding-left:10px' title='Multi-language field'>" . $tp->toGlyph('fa-language') . "</small>"; } if (empty($value) && !empty($parms['default'])) { $value = $parms['default']; } // Two modes of read-only. 1 = read-only, but only when there is a value, 2 = read-only regardless. if (vartrue($attributes['readonly']) && (vartrue($value) || vartrue($attributes['readonly']) === 2)) { if (vartrue($attributes['writeParms'])) { $attributes['readParms'] = $attributes['writeParms']; } return $this->renderValue($key, $value, $attributes) . $this->hidden($key, $value); // } // FIXME standard - writeParams['__options'] is introduced for list elements, bundle adding to writeParms is non reliable way $writeParamsOptionable = array('dropdown', 'comma', 'radio', 'lanlist', 'language', 'user'); $writeParamsDisabled = array('layouts', 'templates', 'userclass', 'userclasses'); // FIXME it breaks all list like elements - dropdowns, radio, etc if (vartrue($required_data[0]) || vartrue($attributes['required'])) { // FIXME - another approach, raise standards, remove checks if (in_array($attributes['type'], $writeParamsOptionable)) { $parms['__options']['required'] = 1; } elseif (!in_array($attributes['type'], $writeParamsDisabled)) { $parms['required'] = 1; } } // FIXME it breaks all list like elements - dropdowns, radio, etc if (vartrue($required_data[3]) || vartrue($attributes['pattern'])) { // FIXME - another approach, raise standards, remove checks if (in_array($attributes['type'], $writeParamsOptionable)) { $parms['__options']['pattern'] = vartrue($attributes['pattern'], $required_data[3]); } elseif (!in_array($attributes['type'], $writeParamsDisabled)) { $parms['pattern'] = vartrue($attributes['pattern'], $required_data[3]); } } // XXX Fixes For the above. - use optArray variable. eg. $field['key']['writeParms']['optArray'] = array('one','two','three'); if (($attributes['type'] == 'dropdown' || $attributes['type'] == 'radio' || $attributes['type'] == 'checkboxes') && !empty($parms['optArray'])) { $fopts = $parms; $parms = $fopts['optArray']; unset($fopts['optArray']); $parms['__options'] = $fopts; } $this->renderElementTrigger($key, $value, $parms, $required_data, $id); switch ($attributes['type']) { case 'number': $maxlength = vartrue($parms['maxlength'], 255); unset($parms['maxlength']); if (!vartrue($parms['size'])) { $parms['size'] = 'mini'; } if (!vartrue($parms['class'])) { $parms['class'] = 'tbox number e-spinner'; } if (!$value) { $value = '0'; } $ret = vartrue($parms['pre']) . $this->number($key, $value, $maxlength, $parms) . vartrue($parms['post']); break; case 'ip': $ret = vartrue($parms['pre']) . $this->text($key, e107::getIPHandler()->ipDecode($value), 32, $parms) . vartrue($parms['post']); break; case 'email': $maxlength = vartrue($parms['maxlength'], 255); unset($parms['maxlength']); $ret = vartrue($parms['pre']) . $this->email($key, $value, $maxlength, $parms) . vartrue($parms['post']); // vartrue($parms['__options']) is limited. See 'required'=>true break; case 'url': $maxlength = vartrue($parms['maxlength'], 255); unset($parms['maxlength']); $ret = vartrue($parms['pre']) . $this->url($key, $value, $maxlength, $parms) . vartrue($parms['post']); // vartrue($parms['__options']) is limited. See 'required'=>true break; // case 'email': // case 'email': case 'password': // encrypts to md5 when saved. $maxlength = vartrue($parms['maxlength'], 255); unset($parms['maxlength']); $ret = vartrue($parms['pre']) . $this->password($key, $value, $maxlength, $parms) . vartrue($parms['post']); // vartrue($parms['__options']) is limited. See 'required'=>true break; case 'text': $maxlength = vartrue($parms['maxlength'], 255); unset($parms['maxlength']); if (!empty($parms['password'])) { $ret = vartrue($parms['pre']) . $this->password($key, $value, $maxlength, $parms) . vartrue($parms['post']); } else { $ret = vartrue($parms['pre']) . $this->text($key, $value, $maxlength, $parms) . vartrue($parms['post']); // vartrue($parms['__options']) is limited. See 'required'=>true } if (!empty($attributes['multilan'])) { $ret = "<span class='input-group input-xxlarge'>" . $ret . "</span>"; } break; case 'tags': $maxlength = vartrue($parms['maxlength'], 255); $ret = vartrue($parms['pre']) . $this->tags($key, $value, $maxlength, $parms) . vartrue($parms['post']); // vartrue($parms['__options']) is limited. See 'required'=>true break; case 'textarea': $text = ""; if (vartrue($parms['append']) && vartrue($value)) { $attributes['readParms'] = 'bb=1'; $text = $this->renderValue($key, $value, $attributes); $text .= '<br />'; $value = ""; // Appending needs is performed and customized using function: beforeUpdate($new_data, $old_data, $id) } $text .= vartrue($parms['pre']) . $this->textarea($key, $value, vartrue($parms['rows'], 5), vartrue($parms['cols'], 40), vartrue($parms['__options'], $parms), varset($parms['counter'], false)) . vartrue($parms['post']); $ret = $text; break; case 'bbarea': $options = array('counter' => varset($parms['counter'], false)); // Media = media-category owner used by media-manager. $ret = vartrue($parms['pre']) . $this->bbarea($key, $value, vartrue($parms['template']), vartrue($parms['media']), vartrue($parms['size'], 'medium'), $options) . vartrue($parms['post']); break; case 'image': //TODO - thumb, image list shortcode, js tooltip... $label = varset($parms['label'], 'LAN_EDIT'); unset($parms['label']); $ret = $this->imagepicker($key, $value, defset($label, $label), $parms); break; case 'images': // return print_a($value, true); $ret = ""; $label = varset($parms['label'], 'LAN_EDIT'); for ($i = 0; $i < 5; $i++) { $k = $key . '[' . $i . '][path]'; $ival = $value[$i]['path']; $ret .= $this->imagepicker($k, $ival, defset($label, $label), $parms); } break; case 'files': if ($attributes['data'] == 'array') { $parms['data'] = 'array'; } $ret = '<ol>'; for ($i = 0; $i < 5; $i++) { // $k = $key.'['.$i.'][path]'; // $ival = $value[$i]['path']; $k = $key . '[' . $i . ']'; $ival = $value[$i]; $ret .= '<li>' . $this->filepicker($k, $ival, defset($label, $label), $parms) . '</li>'; } $ret .= '</ol>'; break; case 'file': //TODO - thumb, image list shortcode, js tooltip... $label = varset($parms['label'], 'LAN_EDIT'); unset($parms['label']); $ret = $this->filepicker($key, $value, defset($label, $label), $parms); break; case 'icon': $label = varset($parms['label'], 'LAN_EDIT'); $ajax = varset($parms['ajax'], true) ? true : false; unset($parms['label'], $parms['ajax']); $ret = $this->iconpicker($key, $value, defset($label, $label), $parms, $ajax); break; case 'date': // date will show the datepicker but won't convert the value to unix. ie. string value will be saved. (or may be processed manually with beforeCreate() etc. Format may be determined by $parm. // date will show the datepicker but won't convert the value to unix. ie. string value will be saved. (or may be processed manually with beforeCreate() etc. Format may be determined by $parm. case 'datestamp': // If hidden, value is updated regardless. eg. a 'last updated' field. // If not hidden, and there is a value, it is retained. eg. during the update of an existing record. // otherwise it is added. eg. during the creation of a new record. if (vartrue($parms['auto']) && ($value == null || vartrue($parms['hidden']))) { $value = time(); } if (vartrue($parms['readonly'])) { $ret = $this->renderValue($key, $value, $attributes) . $this->hidden($key, $value); } elseif (vartrue($parms['hidden'])) { $ret = $this->hidden($key, $value); } else { $ret = $this->datepicker($key, $value, $parms); } break; case 'layouts': //to do - exclude param (exact match) $location = varset($parms['plugin']); // empty - core $ilocation = vartrue($parms['id'], $location); // omit if same as plugin name $where = vartrue($parms['area'], 'front'); //default is 'front' $filter = varset($parms['filter']); $merge = vartrue($parms['merge']) ? true : false; $layouts = e107::getLayouts($location, $ilocation, $where, $filter, $merge, true); if (varset($parms['default']) && !isset($layouts[0]['default'])) { $layouts[0] = array('default' => $parms['default']) + $layouts[0]; } $info = array(); if ($layouts[1]) { foreach ($layouts[1] as $k => $info_array) { if (isset($info_array['description'])) { $info[$k] = defset($info_array['description'], $info_array['description']); } } } //$this->selectbox($key, $layouts, $value) $ret = vartrue($parms['raw']) ? $layouts[0] : $this->radio_multi($key, $layouts[0], $value, array('sep' => "<br />"), $info); break; case 'templates': //to do - exclude param (exact match) $templates = array(); if (varset($parms['default'])) { $templates['default'] = defset($parms['default'], $parms['default']); } $location = vartrue($parms['plugin']) ? e_PLUGIN . $parms['plugin'] . '/' : e_THEME; $ilocation = vartrue($parms['location']); $tmp = e107::getFile()->get_files($location . 'templates/' . $ilocation, vartrue($parms['fmask'], '_template\\.php$'), vartrue($parms['omit'], 'standard'), vartrue($parms['recurse_level'], 0)); foreach ($tmp as $files) { $k = str_replace('_template.php', '', $files['fname']); $templates[$k] = implode(' ', array_map('ucfirst', explode('_', $k))); //TODO add LANS? } // override $where = vartrue($parms['area'], 'front'); $location = vartrue($parms['plugin']) ? $parms['plugin'] . '/' : ''; $tmp = e107::getFile()->get_files(e107::getThemeInfo($where, 'rel') . 'templates/' . $location . $ilocation, vartrue($parms['fmask']), vartrue($parms['omit'], 'standard'), vartrue($parms['recurse_level'], 0)); foreach ($tmp as $files) { $k = str_replace('_template.php', '', $files['fname']); $templates[$k] = implode(' ', array_map('ucfirst', explode('_', $k))); //TODO add LANS? } $ret = vartrue($parms['raw']) ? $templates : $this->selectbox($key, $templates, $value); break; case 'checkboxes': if (is_array($parms)) { $eloptions = vartrue($parms['__options'], array()); if (is_string($eloptions)) { parse_str($eloptions, $eloptions); } if ($attributes['type'] === 'comma') { $eloptions['multiple'] = true; } unset($parms['__options']); if (!is_array($value) && !empty($value)) { $value = explode(",", $value); } $ret = vartrue($eloptions['pre']) . $this->checkboxes($key, $parms, $value, $eloptions) . vartrue($eloptions['post']); } return $ret; break; case 'dropdown': case 'comma': $eloptions = vartrue($parms['__options'], array()); if (is_string($eloptions)) { parse_str($eloptions, $eloptions); } if ($attributes['type'] === 'comma') { $eloptions['multiple'] = true; } unset($parms['__options']); if (vartrue($eloptions['multiple']) && !is_array($value)) { $value = explode(',', $value); } $ret = vartrue($eloptions['pre']) . $this->selectbox($key, $parms, $value, $eloptions) . vartrue($eloptions['post']); break; case 'radio': // TODO - more options (multi-line, help) $eloptions = vartrue($parms['__options'], array()); if (is_string($eloptions)) { parse_str($eloptions, $eloptions); } unset($parms['__options']); $ret = vartrue($eloptions['pre']) . $this->radio_multi($key, $parms, $value, $eloptions, false) . vartrue($eloptions['post']); break; case 'userclass': case 'userclasses': $uc_options = vartrue($parms['classlist'], 'public,guest,nobody,member,admin,main,classes'); // defaults to 'public,guest,nobody,member,classes' (userclass handler) unset($parms['classlist']); // $method = ($attributes['type'] == 'userclass') ? 'uc_select' : 'uc_select'; if (vartrue($attributes['type']) == 'userclasses') { $parms['multiple'] = true; } $ret = vartrue($parms['pre']) . $this->uc_select($key, $value, $uc_options, vartrue($parms, array())) . vartrue($parms['post']); break; /*case 'user_name': case 'user_loginname': case 'user_login': case 'user_customtitle': case 'user_email':*/ /*case 'user_name': case 'user_loginname': case 'user_login': case 'user_customtitle': case 'user_email':*/ case 'user': //user_id expected // Just temporary solution, could be changed soon if (!isset($parms['__options'])) { $parms['__options'] = array(); } if (!is_array($parms['__options'])) { parse_str($parms['__options'], $parms['__options']); } if (empty($value) && varset($parms['currentInit'], USERID) !== 0 || vartrue($parms['current'])) { $value = USERID; if (vartrue($parms['current'])) { $parms['__options']['readonly'] = true; } } if (!is_array($value)) { $value = $value ? e107::getSystemUser($value, true)->getUserData() : array(); // e107::user($value); } $colname = vartrue($parms['nameType'], 'user_name'); $parms['__options']['name'] = $colname; if (!$value) { $value = array(); } $uname = varset($value[$colname]); $value = varset($value['user_id'], 0); $ret = $this->userpicker(vartrue($parms['nameField'], $key), $key, $uname, $value, vartrue($parms['__options'])); break; case 'bool': case 'boolean': if (varset($parms['label']) === 'yesno') { $lenabled = 'LAN_YES'; $ldisabled = 'LAN_NO'; } else { $lenabled = vartrue($parms['enabled'], 'LAN_ENABLED'); $ldisabled = vartrue($parms['disabled'], 'LAN_DISABLED'); } unset($parms['enabled'], $parms['disabled'], $parms['label']); $ret = vartrue($parms['pre']) . $this->radio_switch($key, $value, defset($lenabled, $lenabled), defset($ldisabled, $ldisabled), $parms) . vartrue($parms['post']); break; case "checkbox": $value = isset($parms['value']) ? $parms['value'] : $value; $ret = vartrue($parms['pre']) . $this->checkbox($key, 1, $value, $parms) . vartrue($parms['post']); break; case 'method': // Custom Function $meth = !empty($attributes['method']) ? $attributes['method'] : $key; $parms['field'] = $key; $ret = call_user_func_array(array($this, $meth), array($value, 'write', $parms)); break; case 'upload': //TODO - from method // TODO uploadfile SC is now processing uploads as well (add it to admin UI), write/readParms have to be added (see uploadfile.php parms) $disbut = varset($parms['disable_button'], '0'); $ret = $tp->parseTemplate("{UPLOADFILE=" . (vartrue($parms['path']) ? e107::getParser()->replaceConstants($parms['path']) : e_UPLOAD) . "|nowarn&trigger=etrigger_uploadfiles&disable_button={$disbut}}"); break; case 'hidden': $value = isset($parms['value']) ? $parms['value'] : $value; $ret = vartrue($parms['show']) ? $value ? $value : varset($parms['empty'], $value) : ''; $ret = $ret . $this->hidden($key, $value); break; case 'lanlist': // installed languages // installed languages case 'language': // all languages $options = $attributes['type'] === 'language' ? e107::getLanguage()->getList() : e107::getLanguage()->getLanSelectArray(); $eloptions = vartrue($parms['__options'], array()); if (!is_array($eloptions)) { parse_str($eloptions, $eloptions); } unset($parms['__options']); if (vartrue($eloptions['multiple']) && !is_array($value)) { $value = explode(',', $value); } $ret = vartrue($eloptions['pre']) . $this->selectbox($key, $options, $value, $eloptions) . vartrue($eloptions['post']); break; case null: // Possibly used in db but should not be submitted in form. @see news_extended. break; default: // No LAN necessary, debug only. $ret = ADMIN ? "<span class='alert alert-error alert-danger'>" . LAN_ERROR . " Unknown 'type' : " . $attributes['type'] . "</span>" : $value; break; } if (vartrue($parms['expand'])) { $k = "exp-" . $this->name2id($key); $text = "<a class='e-expandit e-tip' href='#{$k}'>" . $parms['expand'] . "</a>"; $text .= vartrue($parms['help']) ? '<div class="field-help">' . $parms['help'] . '</div>' : ''; $text .= "<div id='{$k}' class='e-hideme'>" . $ret . "</div>"; return $text; } else { $ret .= vartrue($parms['help']) ? '<div class="field-help">' . $tp->toHtml($parms['help'], false, 'defs') . '</div>' : ''; } return $ret; }
function renderOnlineUsers($data = false) { $ol = e107::getOnline(); $tp = e107::getParser(); $multilan = e107::getPref('multilanguage'); $panelOnline = "\n\t\t\t\t\n\t\t\t\t<table class='table table-condensed table-striped' >\n\t\t\t\t<colgroup>\n\t\t\t\t\t<col style='width: 10%' />\n\t\t <col style='width: 25%' />\n\t\t\t\t\t<col style='width: 10%' />\n\t\t\t\t\t<col style='width: 40%' />\n\t\t\t\t\t<col style='width: auto' />"; $panelOnline .= !empty($multilan) ? "<col style='width: auto' />" : ""; // TODO LAN $panelOnline .= "\n\n\t\t\t\t</colgroup>\n\t\t\t\t<thead>\n\t\t\t\t\t<tr class='first'>\n\t\t\t\t\t\t<th>Timestamp</th>\n\t\t\t\t\t\t<th>Username</th>\n\t\t\t\t\t\t<th>IP</th>\n\t\t\t\t\t\t<th>Page</th>\n\t\t\t\t\t\t<th class='center'>Agent</th>"; $panelOnline .= !empty($multilan) ? "<th class='center'>Lang.</th>" : ""; $panelOnline .= "\n\t\t\t\t\t</tr>\n\t\t\t\t</thead>\n\t\t\t\t<tbody>"; $online = $ol->userList() + $ol->guestList(); if ($data == 'count') { return count($online); } // echo "Users: ".print_a($online); $lng = e107::getLanguage(); foreach ($online as $val) { $panelOnline .= "\n\t\t\t<tr>\n\t\t\t\t<td class='nowrap'>" . e107::getDateConvert()->convert_date($val['user_currentvisit'], '%H:%M:%S') . "</td>\n\t\t\t\t<td>" . $this->renderOnlineName($val['online_user_id']) . "</td>\n\t\t\t\t<td>" . e107::getIPHandler()->ipDecode($val['user_ip']) . "</td>\n\t\t\t\t<td><a class='e-tip' href='" . $val['user_location'] . "' title='" . $val['user_location'] . "'>" . $tp->html_truncate(basename($val['user_location']), 50, "...") . "</a></td>\n\t\t\t\t<td class='center'><a class='e-tip' href='#' title='" . $val['user_agent'] . "'>" . $this->browserIcon($val) . "</a></td>"; $panelOnline .= !empty($multilan) ? "<td class='center'><a class='e-tip' href='#' title=\"" . $lng->convert($val['user_language']) . "\">" . $val['user_language'] . "</a></td>" : ""; $panelOnline .= "\n\t\t\t</tr>\n\t\t\t"; } $panelOnline .= "</tbody></table>"; return $panelOnline; }
/** * @param $name */ function installContentCheck($name) { $file = e_THEME . $name . "/install/install.xml"; $frm = e107::getForm(); $tp = e107::getParser(); if (!is_readable($file)) { return false; } $mes = e107::getMessage(); $xmlArray = e107::getXml()->loadXMLfile($file, 'advanced'); $text = "\n\t\t<form action='" . e_SELF . "' method='post'>\n\t\t<div>\n\t\t<p>" . TPVLAN_58 . "<br />\n\t\t" . $tp->toHTML(TPVLAN_59, true) . ":<br />\n\t\t</p>\n\n\t\t<ul>"; $lng = e107::getLanguage(); foreach ($xmlArray['database']['dbTable'] as $key => $val) { $count = count($val['item']); $data = array('x' => $count, 'y' => $val['@attributes']['name']); $text .= "<li>" . $tp->lanVars(TPVLAN_60, $data) . "</li>"; } $text .= "</ul>\n\n\t\t<p>" . $tp->toHTML(TPVLAN_61, true) . "</p>\n\n\t\t" . $frm->admin_button('installContent', $name, 'warning', LAN_YES) . "\n\t\t" . $frm->admin_button('dismiss', 0, 'cancel', LAN_NO) . "\n\t\t</div>\n\t\t</form>\n\t\t"; // $text .= print_a($xmlArray, true); $mes->addInfo($text); }
/** * Clear data set via self::setCookie() * @param string $name * @return redirection */ public function clearCookie($name) { $cookiename = e_COOKIE . "_" . $name; $session = e107::getSession(); $session->clear($name)->clear($name . '_expire'); cookie($cookiename, null, null, e_HTTP, e107::getLanguage()->getCookieDomain()); return $this; }
} } else { $newValue = $tp->toDB($value); } $core_pref->update($key, $newValue); /*if($newValue != $core_pref->get($key)) { // Changed value $core_pref->set($key, $newValue); $prefChanges[$key] = $newValue; }*/ } $core_pref->save(false); // special case, do session cleanup, logout, redirect to login screen if ($sessionRegenerate) { // reset cookie cookie($core_pref->get('cookie_name'), $_COOKIE[e_COOKIE], time() + 3600 * 24 * 30, e_HTTP, e107::getLanguage()->getCookieDomain()); cookie(e_COOKIE, null, null); // regenerate session $s = $_SESSION; e107::getSession()->destroy(); $session = new e_core_session(array('name' => $core_pref->get('cookie_name'))); $_SESSION = $s; } } if (e107::isInstalled('alt_auth')) { $authlist[] = "e107"; $handle = opendir(e_PLUGIN . "alt_auth"); while ($file = readdir($handle)) { if (preg_match("/^(.*)_auth\\.php/", $file, $match)) { $authlist[] = $match[1]; }
/** * Auto-render Form Element * @param string $key * @param mixed $value * @param array $attributes field attributes including render parameters, element options - see e_admin_ui::$fields for required format * #param array (under construction) $required_data required array as defined in e_model/validator * @return string */ function renderElement($key, $value, $attributes, $required_data = array()) { $parms = vartrue($attributes['writeParms'], array()); $tp = e107::getParser(); if (is_string($parms)) { parse_str($parms, $parms); } // Two modes of read-only. 1 = read-only, but only when there is a value, 2 = read-only regardless. if (vartrue($attributes['readonly']) && (vartrue($value) || vartrue($attributes['readonly']) == 2)) { if (vartrue($attributes['writeParms'])) { $attributes['readParms'] = $attributes['writeParms']; } return $this->renderValue($key, $value, $attributes) . $this->hidden($key, $value); // } switch ($attributes['type']) { case 'number': $maxlength = vartrue($parms['maxlength'], 255); unset($parms['maxlength']); if (!vartrue($parms['size'])) { $parms['size'] = 15; } if (!vartrue($parms['class'])) { $parms['class'] = 'tbox number e-spinner'; } if (!$value) { $value = '0'; } $ret = vartrue($parms['pre']) . $this->text($key, $value, $maxlength, $parms) . vartrue($parms['post']); break; case 'ip': $ret = $this->text($key, e107::getIPHandler()->ipDecode($value), 32, $parms); break; case 'url': case 'email': case 'text': case 'password': // encrypts to md5 when saved. $maxlength = vartrue($parms['maxlength'], 255); unset($parms['maxlength']); $ret = vartrue($parms['pre']) . $this->text($key, $value, $maxlength, vartrue($parms['__options'])) . vartrue($parms['post']); break; case 'textarea': $text = ""; if ($parms['append']) { $attributes['readParms'] = 'bb=1'; $text = $this->renderValue($key, $value, $attributes) . $this->hidden($key, $value) . '<br />'; $value = ""; } $text .= $this->textarea($key, $value, vartrue($parms['rows'], 5), vartrue($parms['cols'], 40), vartrue($parms['__options']), varset($parms['counter'], false)); $ret = $text; break; case 'bbarea': $options = array('counter' => varset($parms['counter'], false)); $ret = $this->bbarea($key, $value, vartrue($parms['template']), vartrue($parms['helptag']), vartrue($parms['size'], 'medium'), $options); break; case 'image': //TODO - thumb, image list shortcode, js tooltip... $label = varset($parms['label'], 'LAN_EDIT'); unset($parms['label']); $ret = $this->imagepicker($key, $value, defset($label, $label), $parms); break; case 'file': //TODO - thumb, image list shortcode, js tooltip... $label = varset($parms['label'], 'LAN_EDIT'); unset($parms['label']); $ret = $this->filepicker($key, $value, defset($label, $label), $parms); break; case 'icon': $label = varset($parms['label'], 'LAN_EDIT'); $ajax = varset($parms['ajax'], true) ? true : false; unset($parms['label'], $parms['ajax']); $ret = $this->iconpicker($key, $value, defset($label, $label), $parms, $ajax); break; case 'date': // date will show the datepicker but won't convert the value to unix. ie. string value will be saved. (or may be processed manually with beforeCreate() etc. Format may be determined by $parm. // date will show the datepicker but won't convert the value to unix. ie. string value will be saved. (or may be processed manually with beforeCreate() etc. Format may be determined by $parm. case 'datestamp': // If hidden, value is updated regardless. eg. a 'last updated' field. // If not hidden, and there is a value, it is retained. eg. during the update of an existing record. // otherwise it is added. eg. during the creation of a new record. if (vartrue($parms['auto']) && ($value == null || vartrue($parms['hidden']))) { $value = time(); } if (vartrue($parms['hidden'])) { $ret = $this->hidden($key, $value); } else { $ret = $this->datepicker($key, $value, $parms); } break; case 'layouts': //to do - exclude param (exact match) $location = varset($parms['plugin']); // empty - core $ilocation = vartrue($parms['id'], $location); // omit if same as plugin name $where = vartrue($parms['area'], 'front'); //default is 'front' $filter = varset($parms['filter']); $merge = vartrue($parms['merge']) ? true : false; $layouts = e107::getLayouts($location, $ilocation, $where, $filter, $merge, true); if (varset($parms['default']) && !isset($layouts[0]['default'])) { $layouts[0] = array('default' => $parms['default']) + $layouts[0]; } $info = array(); if ($layouts[1]) { foreach ($layouts[1] as $k => $info_array) { if (isset($info_array['description'])) { $info[$k] = defset($info_array['description'], $info_array['description']); } } } //$this->selectbox($key, $layouts, $value) $ret = vartrue($parms['raw']) ? $layouts[0] : $this->radio_multi($key, $layouts[0], $value, true, $info); break; case 'templates': //to do - exclude param (exact match) $templates = array(); if (varset($parms['default'])) { $templates['default'] = defset($parms['default'], $parms['default']); } $location = vartrue($parms['plugin']) ? e_PLUGIN . $parms['plugin'] . '/' : e_THEME; $ilocation = vartrue($parms['location']); $tmp = e107::getFile()->get_files($location . 'templates/' . $ilocation, vartrue($parms['fmask'], '_template\\.php$'), vartrue($parms['omit'], 'standard'), vartrue($parms['recurse_level'], 0)); foreach ($tmp as $files) { $k = str_replace('_template.php', '', $files['fname']); $templates[$k] = implode(' ', array_map('ucfirst', explode('_', $k))); //TODO add LANS? } // override $where = vartrue($parms['area'], 'front'); $location = vartrue($parms['plugin']) ? $parms['plugin'] . '/' : ''; $tmp = e107::getFile()->get_files(e107::getThemeInfo($where, 'rel') . 'templates/' . $location . $ilocation, vartrue($parms['fmask']), vartrue($parms['omit'], 'standard'), vartrue($parms['recurse_level'], 0)); foreach ($tmp as $files) { $k = str_replace('_template.php', '', $files['fname']); $templates[$k] = implode(' ', array_map('ucfirst', explode('_', $k))); //TODO add LANS? } $ret = vartrue($parms['raw']) ? $templates : $this->selectbox($key, $templates, $value); break; case 'dropdown': $eloptions = vartrue($parms['__options'], array()); if (is_string($eloptions)) { parse_str($eloptions, $eloptions); } unset($parms['__options']); if (vartrue($eloptions['multiple']) && !is_array($value)) { $value = explode(',', $value); } $ret = vartrue($eloptions['pre']) . $this->selectbox($key, $parms, $value, $eloptions) . vartrue($eloptions['post']); break; case 'radio': // TODO - more options (multi-line, help) /*$eloptions = vartrue($parms['__options'], array()); if(is_string($eloptions)) parse_str($eloptions, $eloptions); unset($parms['__options']);*/ $ret = vartrue($eloptions['pre']) . $this->radio_multi($key, $parms, $value, false) . vartrue($eloptions['post']); break; case 'userclass': case 'userclasses': $uc_options = vartrue($parms['classlist'], 'public,guest,nobody,member,admin,main,classes'); // defaults to 'public,guest,nobody,member,classes' (userclass handler) unset($parms['classlist']); $method = $attributes['type'] == 'userclass' ? 'uc_select' : 'uc_select'; if ($atrributes['type'] == 'userclasses') { $parms['multiple'] = true; } $ret = $this->{$method}($key, $value, $uc_options, vartrue($parms, array())); break; /*case 'user_name': case 'user_loginname': case 'user_login': case 'user_customtitle': case 'user_email':*/ /*case 'user_name': case 'user_loginname': case 'user_login': case 'user_customtitle': case 'user_email':*/ case 'user': //user_id expected // Just temporary solution, could be changed soon if (!isset($parms['__options'])) { $parms['__options'] = array(); } if (!is_array($parms['__options'])) { parse_str($parms['__options'], $parms['__options']); } if (empty($value) && vartrue($parms['currentInit']) || vartrue($parms['current'])) { $value = USERID; if (vartrue($parms['current'])) { $parms['__options']['readonly'] = true; } } if (!is_array($value)) { $value = $value ? e107::getSystemUser($value, true)->getUserData() : array(); // get_user_data($value); } $colname = vartrue($parms['nameType'], 'user_name'); $parms['__options']['name'] = $colname; if (!$value) { $value = array(); } $uname = varset($value[$colname]); $value = varset($value['user_id'], 0); $ret = $this->userpicker(vartrue($parms['nameField'], $key . '_usersearch'), $key, $uname, $value, vartrue($parms['__options'])); break; case 'bool': case 'boolean': $lenabled = vartrue($parms['enabled'], 'LAN_ENABLED'); $ldisabled = vartrue($parms['disabled'], 'LAN_DISABLED'); unset($parms['enabled'], $parms['disabled']); $ret = $this->radio_switch($key, $value, defset($lenabled, $lenabled), defset($ldisabled, $ldisabled), $parms); break; case 'method': // Custom Function $ret = call_user_func_array(array($this, $key), array($value, 'write', $parms)); break; case 'upload': //TODO - from method // TODO uploadfile SC is now processing uploads as well (add it to admin UI), write/readParms have to be added (see uploadfile.php parms) $disbut = varset($parms['disable_button'], '0'); $ret = $tp->parseTemplate("{UPLOADFILE=" . (vartrue($parms['path']) ? e107::getParser()->replaceConstants($parms['path']) : e_UPLOAD) . "|nowarn&trigger=etrigger_uploadfiles&disable_button={$disbut}}"); break; case 'hidden': $ret = vartrue($parms['show']) ? $value ? $value : varset($parms['empty'], $value) : ''; $value = vartrue($parms['value']) ? $parms['value'] : $value; echo "key=" . $key . "<br />value=" . $value; $ret = $ret . $this->hidden($key, $value); break; case 'lanlist': case 'language': $options = e107::getLanguage()->getLanSelectArray(); $eloptions = vartrue($parms['__options'], array()); if (!is_array($eloptions)) { parse_str($eloptions, $eloptions); } unset($parms['__options']); if (vartrue($eloptions['multiple']) && !is_array($value)) { $value = explode(',', $value); } $ret = vartrue($eloptions['pre']) . $this->selectbox($key, $options, $value, $eloptions) . vartrue($eloptions['post']); break; default: $ret = $value; break; } if (vartrue($parms['expand'])) { $k = "exp-" . $this->name2id($key); $text = "<a class='e-expandit e-tip' href='#{$k}'>" . $parms['expand'] . "</a>"; $text .= vartrue($parms['help']) ? '<div class="field-help">' . $parms['help'] . '</div>' : ''; $text .= "<div id='{$k}' class='e-hideme'>" . $ret . "</div>"; return $text; } else { $ret .= vartrue($parms['help']) ? '<div class="field-help">' . $tp->toHtml($parms['help'], false, 'defs') . '</div>' : ''; } return $ret; }
exit; } define('e_CAPTCHA_FONTCOLOR', '#F9A533'); // Required for a clean v1.x -> v2 upgrade. $core = e107::getConfig('core'); if ($core->get('admintheme') != 'bootstrap' && $core->get('admintheme') != 'bootstrap3') { $core->update('admintheme', 'bootstrap3'); $core->update('adminstyle', 'infopanel'); $core->update('admincss', 'admin_dark.css'); $core->set('e_jslib_core', array('prototype' => 'none', 'jquery' => 'auto')); $core->save(); e107::getRedirect()->redirect(e_SELF); } // Check Admin-Perms for current language and redirect if necessary. if (!getperms('0') && vartrue($pref['multilanguage']) && !getperms(e_LANGUAGE)) { $lng = e107::getLanguage(); $tmp = explode(".", ADMINPERMS); foreach ($tmp as $ln) { if ($lng->isValid($ln)) { $redirect = deftrue("MULTILANG_SUBDOMAIN") ? $lng->subdomainUrl($ln) : e_SELF . "?elan=" . $ln; // echo "redirect to: ".$redirect; e107::getRedirect()->go($redirect); // break; } } } /* done in class2 @include_once(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_admin.php"); @include_once(e_LANGUAGEDIR."English/admin/lan_admin.php"); */ if (ADMIN) {
* * User information * * $URL$ * $Id$ * */ //HCL define('PAGE_NAME', 'Members'); require_once "class2.php"; include_lan(e_LANGUAGEDIR . e_LANGUAGE . '/lan_' . e_PAGE); // Next bit is to fool PM plugin into doing things global $user; $user['user_id'] = USERID; // BC for v1.x template $bcList = array('LAN_112' => 'LAN_USER_60', 'LAN_138' => 'LAN_USER_52', 'LAN_139' => 'LAN_USER_57', "LAN_142" => "LAN_USER_58", "LAN_145" => "LAN_USER_59", "LAN_146" => "LAN_USER_66", "LAN_147" => "LAN_USER_67", "LAN_148" => "LAN_USER_68", "LAN_149" => "LAN_USER_69", "LAN_308" => "LAN_USER_63", "LAN_403" => "LAN_USER_64", "LAN_404" => "LAN_USER_65", "LAN_419" => "LAN_USER_70", "LAN_425" => "LAN_USER_62"); e107::getLanguage()->bcDefs($bcList); if (e_AJAX_REQUEST) { if (vartrue($_POST['q'])) { $q = filter_var($_POST['q'], FILTER_SANITIZE_STRING); $l = vartrue($_POST['l']) ? intval($_POST['l']) : 10; $db = e107::getDb(); if ($db->select("user", "user_id,user_name", "user_name LIKE '" . $q . "%' ORDER BY user_name LIMIT " . $l)) { $data = array(); while ($row = $db->fetch()) { $data[] = array('value' => $row['user_id'], 'label' => $row['user_name']); } if (count($data)) { header('Content-type: application/json'); echo json_encode($data); } }
public function init() { $this->installedLanguages = e107::getLanguage()->installed(); $this->prefs['sitelanguage']['writeParms']['optArray'] = $this->installedLanguages; $this->prefs['adminlanguage']['writeParms']['optArray'] = $this->installedLanguages; }
function sc_admin_lang($parm) { if (!ADMIN || !e107::getPref('multilanguage')) { return ''; } $e107 = e107::getInstance(); $sql = e107::getDb(); $pref = e107::getPref(); e107::plugLan('user_menu', '', true); $params = array(); parse_str($parm, $params); $lanlist = explode(',', e_LANLIST); sort($lanlist); $text = ''; foreach ($lanlist as $langval) { if (getperms($langval)) { $lanperms[] = $langval; } } $slng = e107::getLanguage(); if (!getperms($sql->mySQLlanguage) && $lanperms) { $slng->set($lanperms[0]); if ($pref['user_tracking'] == "session" && $pref['multilanguage_subdomain']) { e107::getRedirect()->redirect($slng->subdomainUrl($lanperms[0])); } /*$sql->mySQLlanguage = ($lanperms[0] != $pref['sitelanguage']) ? $lanperms[0] : ""; if ($pref['user_tracking'] == "session") { $_SESSION['e107language_'.$pref['cookie_name']] = $lanperms[0]; if($pref['multilanguage_subdomain']){ header("Location:".$slng->subdomainUrl($lanperms[0])); } } else { setcookie('e107language_'.$pref['cookie_name'], $lanperms[0], time() + 86400, '/'); $_COOKIE['e107language_'.$pref['cookie_name']]= $lanperms[0]; }*/ } if (varset($GLOBALS['mySQLtablelist'])) { foreach ($GLOBALS['mySQLtablelist'] as $tabs) { $clang = strtolower($sql->mySQLlanguage); if (strpos($tabs, "lan_" . $clang) && $clang != "") { $aff[] = str_replace(MPREFIX . "lan_" . $clang . "_", "", $tabs); } } } $text .= "\n\t\t<div>\n\t\t<img src='" . e_IMAGE_ABS . "admin_images/language_16.png' alt='' /> "; if (isset($aff)) { $text .= $sql->mySQLlanguage; $text .= " (" . $slng->convert($sql->mySQLlanguage) . ")\n\t\t\t: <span class='button' style='cursor: pointer;' onclick='expandit(\"lan_tables\");'><a style='text-decoration:none' title='' href=\"javascript:void(0);\" > " . count($aff) . " " . UTHEME_MENU_L3 . " </a></span><br />\n\t\t\t<span style='display:none' id='lan_tables'>\n\t\t\t"; $text .= implode('<br />', $aff); $text .= '</span>'; } elseif ($sql->mySQLlanguage && $sql->mySQLlanguage != $pref['sitelanguage']) { $text .= $sql->mySQLlanguage; $text .= ' (' . $slng->convert($sql->mySQLlanguage) . '): ' . LAN_INACTIVE; } else { $text .= $pref['sitelanguage']; } $text .= "<br /><br /></div>"; $select = ''; if (isset($pref['multilanguage_subdomain']) && $pref['multilanguage_subdomain']) { // TODO - JS independent $select .= "\n\t\t\t<select class='tbox' name='lang_select' id='sitelanguage' onchange=\"location.href=this.options[selectedIndex].value\">"; foreach ($lanperms as $lng) { $selected = $lng == $sql->mySQLlanguage || $lng == $pref['sitelanguage'] && !$sql->mySQLlanguage ? " selected='selected'" : ""; $urlval = $slng->subdomainUrl($lng); $select .= "<option value='" . $urlval . "'{$selected}>{$lng}</option>\n"; } $select .= "</select>"; } else { $select .= "\n\t\t\t<form method='post' action='" . e_SELF . (e_QUERY ? '?' . e_QUERY : '') . "'>\n\t\t\t<div>\n\t\t\t<select name='sitelanguage' id='sitelanguage' class='tbox' onchange='this.form.submit()'>"; foreach ($lanperms as $lng) { // FIXME - language detection is a mess - db handler, mysql handler, session handler and language handler + constants invlolved // Too complex, doesn't work!!! SIMPLIFY!!! //$langval = ($lng == $pref['sitelanguage'] && $lng == 'English') ? "" : $lng; //$selected = ($lng == $sql->mySQLlanguage || ($lng == $pref['sitelanguage'] && !$sql->mySQLlanguage)) ? " selected='selected'" : ""; //$select .= "<option value='".$langval."'{$selected}>$lng</option>\n"; $selected = $lng == e_LANGUAGE ? " selected='selected'" : ""; $select .= "<option value='" . $lng . "'{$selected}>{$lng}</option>\n"; } $select .= "</select> " . (!isset($params['nobutton']) ? "<button class='update e-hide-if-js' type='submit' name='setlanguage' value='no-value'><span>" . UTHEME_MENU_L1 . "</span></button>" : '') . "\n\t\t\t" . e107::getForm()->hidden('setlanguage', '1') . "\n\t\t\t</div>\n\t\t\t</form>\n\t\t\t"; } if (isset($params['nomenu'])) { return $select; } if ($select) { $text .= "<div class='center'>{$select}</div>"; } return $e107->ns->tablerender(UTHEME_MENU_L2, $text, '', true); }
/** * Constructor - gets language options from the cookie or session * @access public */ public function __construct() { global $pref, $db_defaultPrefix; if (defined('e_PDO') && e_PDO === true) { $this->pdo = true; } e107::getSingleton('e107_traffic')->BumpWho('Create db object', 1); $this->mySQLPrefix = MPREFIX; // Set the default prefix - may be overridden /*$langid = (isset($pref['cookie_name'])) ? 'e107language_'.$pref['cookie_name'] : 'e107language_temp'; if (isset($pref['user_tracking']) && ($pref['user_tracking'] == 'session')) { if (!isset($_SESSION[$langid])) { return; } $this->mySQLlanguage = $_SESSION[$langid]; } else { if (!isset($_COOKIE[$langid])) { return; } $this->mySQLlanguage = $_COOKIE[$langid]; }*/ // Detect is already done in language handler, use it if not too early if (defined('e_LANGUAGE')) { $this->mySQLlanguage = e107::getLanguage()->e_language; } }
} } } } /** * Set the User's Language */ $sql->db_Mark_Time('Start: Set User Language'); // SESSION Needs to be started after: // - Site preferences are available // - Language detection (because of session.cookie_domain) // to avoid multi-language 'access-denied' issues. //session_start(); see e107::getSession() above e107::getSession(); //init core _SESSION - actually here for reference only, it's done by language handler set() method e107::getLanguage()->set(); // set e_LANGUAGE, USERLAN, Language Session / Cookies etc. requires $pref; if (varset($pref['multilanguage']) && e_LANGUAGE != $pref['sitelanguage']) { $sql->mySQLlanguage = e_LANGUAGE; $sql2->mySQLlanguage = e_LANGUAGE; } //do it only once and with the proper function // e107_include_once(e_LANGUAGEDIR.e_LANGUAGE.'/'.e_LANGUAGE.'.php'); // e107_include_once(e_LANGUAGEDIR.e_LANGUAGE.'/'.e_LANGUAGE.'_custom.php'); // v1 Custom language File Path. if (e_ADMIN_AREA === true && !empty($pref['adminlanguage'])) { include e_LANGUAGEDIR . $pref['adminlanguage'] . '/' . $pref['adminlanguage'] . '.php'; } else { include e_LANGUAGEDIR . e_LANGUAGE . '/' . e_LANGUAGE . '.php'; // FASTEST - ALWAYS load }
public function aliasesRows($currentAliases, $modules, $lanDef, $lans) { if (empty($modules)) { return "\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan='3'>" . LAN_EURL_EMPTY . "</td>\n\t\t\t\t</tr>\n\t\t\t"; } $text = ''; $tp = e107::getParser(); $text .= "<tr>\n\t\t\t<th>Module</th>\n\t\t\t<th></th>\n\t\t\t<th></th>\n\t\t</tr>"; $lng = e107::getLanguage(); foreach ($modules as $module => $obj) { $cfg = $obj->config->config(); if (isset($cfg['config']['noSingleEntry']) && $cfg['config']['noSingleEntry']) { continue; } if ($module == 'index') { $text .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t" . LAN_EURL_CORE_INDEX . "\n\t\t\t\t\t</td>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<table class='table table-striped table-bordered' style='margin-bottom:0'>\n\t\t\t\t\t\t<colgroup>\n<col style='width:20%' />\n<col style='width:40%' />\n<col style='width:40%' />\n</colgroup>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colspan='2'>\n\t\t\t\t\t\t\t\t" . LAN_EURL_CORE_INDEX_INFO . "\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t" . e107::getUrl()->create('/', '', array('full' => 1)) . "\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t"; continue; } $help = array(); $admin = $obj->config->admin(); $lan = $lanDef[0]; $url = e107::getUrl()->create($module, '', array('full' => 1, 'encode' => 0)); $defVal = isset($currentAliases[$lan]) && in_array($module, $currentAliases[$lan]) ? array_search($module, $currentAliases[$lan]) : $module; $section = vartrue($admin['labels'], array()); $text .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t" . vartrue($section['name'], ucfirst(str_replace('_', ' ', $obj->module))) . "\n\t\t\t\t\t\t<div class='label-note'>\n\t\t\t\t\t\t" . LAN_EURL_FORM_HELP_ALIAS_0 . " <strong>{$module}</strong><br />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td>\n\t\t\t"; // default language $text .= "<table class='table table-striped table-bordered' style='margin-bottom:0'>\n<colgroup>\n<col style='width:20%' />\n<col style='width:40%' />\n<col style='width:40%' />\n</colgroup>"; $text .= "<tr>\n\t\t\t<th>" . ADLAN_132 . "</th>\n\t\t\t<th>" . LAN_EURL_NAME_ALIASES . "</th>\n\t\t\t<th>" . LAN_EURL_FORM_HELP_EXAMPLE . "</th>\n\t\t</tr>"; $text .= "<tr>"; $text .= "<td>" . $lanDef[1] . "</td>"; $text .= "<td class='form-inline'>"; $text .= $this->text('eurl_aliases[' . $lanDef[0] . '][' . $module . ']', $defVal, 255, 'size=xlarge'); // $text .= ' ['.$lanDef[1].']'; $text .= "</td><td>"; $text .= $this->help(LAN_EURL_FORM_HELP_DEFAULT); $text .= "</td>"; // $help[] = '['.$lanDef[1].'] '.LAN_EURL_FORM_HELP_EXAMPLE.':<br /><strong>'.$url.'</strong>'; $text .= "</tr>"; if (e107::getUrl()->router()->isMainModule($module)) { $help = " <span class='e-tip e-help' title=\"" . LAN_EURL_CORE_MAIN . "\">" . $tp->toGlyph('fa-home') . "</span>"; //$readonly = 1; // may be used later. $readonly = 0; } else { $help = ''; $readonly = 0; } if ($lans) { foreach ($lans as $code => $lan) { $url = e107::getUrl()->create($module, '', array('lan' => $code, 'full' => 1, 'encode' => 0)); $defVal = isset($currentAliases[$code]) && in_array($module, $currentAliases[$code]) ? array_search($module, $currentAliases[$code]) : $module; // $help .= '['.$lan.'] '.LAN_EURL_FORM_HELP_EXAMPLE.':<br /><strong>'.$url.'</strong>'; $text .= "<tr>"; $text .= "<td>" . $lan . "</td>"; $text .= "<td class='form-inline'>" . $this->text('eurl_aliases[' . $code . '][' . $module . ']', $defVal, 255, array('size' => 'xlarge', 'readonly' => $readonly)); $text .= $help; $text .= "</td>"; $text .= "<td>"; // $text .= $this->help(LAN_EURL_FORM_HELP_ALIAS_1.' <strong>'.$lan.'</strong>'); // $text .= $this->help(LAN_EURL_FORM_HELP_ALIAS_1.' <strong>'.$lan.'</strong>'); $url = $lng->subdomainUrl($lan, $url); $text .= $url; $text .= "</td>"; // $text .= "<td>". // $text .= '['.$lan.'] '.LAN_EURL_FORM_HELP_EXAMPLE.':<br /><strong>'.$url.'</strong>'; // $text .= "</td>"; $text .= "</tr>"; } } $text .= "</table>\n\t\t\t\t</td></tr>"; /*$text .= " </td> <td> ".implode("<div class='spacer'><!-- --></div>", $help)." </td> </tr> ";*/ // $text .= "</tr>"; } return $text; }
function renderBatchFilter($type = 'batch', $selected = '') { $optdiz = array('batch' => LAN_BATCH_LABEL_PREFIX . ' ', 'filter' => LAN_FILTER_LABEL_PREFIX . ' '); $table = $this->getController()->getTableName(); $text = ''; $textsingle = ''; foreach ($this->getController()->getFields() as $key => $val) { if (!varset($val[$type])) { continue; } $option = array(); $parms = vartrue($val['writeParms'], array()); if (is_string($parms)) { parse_str($parms, $parms); } switch ($val['type']) { case 'bool': case 'boolean': //TODO modify description based on $val['parm] if (vartrue($parms['reverse'])) { $option['bool__' . $key . '__0'] = LAN_YES; // see newspost.php : news_allow_comments for an example. $option['bool__' . $key . '__1'] = LAN_NO; } else { $option['bool__' . $key . '__1'] = LAN_YES; $option['bool__' . $key . '__0'] = LAN_NO; } if ($type == 'batch') { $option['boolreverse__' . $key] = LAN_BOOL_REVERSE; } break; case 'templates': case 'layouts': $parms['raw'] = true; $val['writeParms'] = $parms; $tmp = $this->renderElement($key, '', $val); foreach ($tmp as $k => $name) { $option[$key . '__' . $k] = $name; } break; case 'dropdown': // use the array $parm; if (!is_array(varset($parms['__options']))) { parse_str($parms['__options'], $parms['__options']); } $opts = $parms['__options']; if (vartrue($opts['multiple'])) { // no batch support for multiple, should have some for filters soon continue; } unset($parms['__options']); //remove element options if any foreach ($parms as $k => $name) { $option[$key . '__' . $k] = $name; } break; case 'lanlist': // use the array $parm; if (!is_array(varset($parms['__options']))) { parse_str($parms['__options'], $parms['__options']); } $opts = $parms['__options']; if (vartrue($opts['multiple'])) { // no batch support for multiple, should have some for filters soon continue; } $options = e107::getLanguage()->getLanSelectArray(); foreach ($options as $code => $name) { $option[$key . '__' . $code] = $name; } break; case 'datestamp': // use $parm to determine unix-style or YYYY-MM-DD //TODO last hour, today, yesterday, this-month, last-month etc. /* foreach($val['parm'] as $k=>$name) { $text .= $frm->option($name, $type.'__'.$key."__".$k); }*/ break; case 'userclass': case 'userclasses': $classes = e107::getUserClass()->uc_required_class_list(vartrue($parms['classlist'], 'public,nobody,guest,admin,main,classes')); foreach ($classes as $k => $name) { $option[$key . '__' . $k] = $name; } break; case 'method': $method = $key; $list = call_user_func_array(array($this, $method), array('', $type, $parms)); if (is_array($list)) { //check for single option if (isset($list['singleOption'])) { $textsingle .= $list['singleOption']; continue; } // non rendered options array foreach ($list as $k => $name) { $option[$key . '__' . $k] = $name; } } elseif (!empty($list)) { $text .= $list; continue; } break; case 'user': // TODO - User Filter //$option[$key.'__'.$k] = $name; break; } if (count($option) > 0) { $text .= "\t" . $this->optgroup_open($optdiz[$type] . defset($val['title'], $val['title']), varset($disabled)) . "\n"; foreach ($option as $okey => $oval) { $text .= $this->option($oval, $okey, $selected == $okey) . "\n"; } $text .= "\t" . $this->optgroup_close() . "\n"; } } return $textsingle . $text; }
function renderBatchFilter($type = 'batch', $selected = '') { $optdiz = array('batch' => LAN_BATCH_LABEL_PREFIX . ' ', 'filter' => LAN_FILTER_LABEL_PREFIX . ' '); $table = $this->getController()->getTableName(); $text = ''; $textsingle = ''; foreach ($this->getController()->getFields() as $key => $val) { if (!varset($val[$type])) { continue; } $option = array(); $parms = vartrue($val['writeParms'], array()); if (is_string($parms)) { parse_str($parms, $parms); } switch ($val['type']) { case 'bool': case 'boolean': //TODO modify description based on $val['parm] if (vartrue($parms['reverse'])) { $option['bool__' . $key . '__0'] = LAN_YES; // see newspost.php : news_allow_comments for an example. $option['bool__' . $key . '__1'] = LAN_NO; } else { $option['bool__' . $key . '__1'] = LAN_YES; $option['bool__' . $key . '__0'] = LAN_NO; } if ($type == 'batch') { $option['boolreverse__' . $key] = LAN_BOOL_REVERSE; } break; case 'checkboxes': case 'comma': // TODO lan if (!isset($parms['__options'])) { $parms['__options'] = array(); } if (!is_array($parms['__options'])) { parse_str($parms['__options'], $parms['__options']); } $opts = $parms['__options']; unset($parms['__options']); //remove element options if any $options = $parms ? $parms : array(); if (empty($options)) { continue; } if ($type == 'batch') { $_option = array(); if (isset($options['addAll'])) { $option['attach_all__' . $key] = vartrue($options['addAll'], '(add all)'); unset($options['addAll']); } if (isset($options['clearAll'])) { $_option['deattach_all__' . $key] = vartrue($options['clearAll'], '(clear all)'); unset($options['clearAll']); } if (vartrue($opts['simple'])) { foreach ($options as $value) { $option['attach__' . $key . '__' . $value] = 'Add ' . $value; $_option['deattach__' . $key . '__' . $value] = 'Remove ' . $value; } } else { foreach ($options as $value => $label) { $option['attach__' . $key . '__' . $value] = 'Add ' . $label; $_option['deattach__' . $key . '__' . $value] = 'Remove ' . $label; } } $option = array_merge($option, $_option); unset($_option); } else { unset($options['addAll'], $options['clearAll']); if (vartrue($opts['simple'])) { foreach ($options as $k) { $option[$key . '__' . $k] = $k; } } else { foreach ($options as $k => $name) { $option[$key . '__' . $k] = $name; } } } break; case 'templates': case 'layouts': $parms['raw'] = true; $val['writeParms'] = $parms; $tmp = $this->renderElement($key, '', $val); if (is_array($tmp)) { foreach ($tmp as $k => $name) { $option[$key . '__' . $k] = $name; } } break; case 'dropdown': // use the array $parm; if (!empty($parms['optArray'])) { $fopts = $parms; $parms = $fopts['optArray']; unset($fopts['optArray']); $parms['__options'] = $fopts; } if (!is_array(varset($parms['__options']))) { parse_str($parms['__options'], $parms['__options']); } $opts = $parms['__options']; if (vartrue($opts['multiple'])) { // no batch support for multiple, should have some for filters soon continue; } unset($parms['__options']); //remove element options if any foreach ($parms as $k => $name) { $option[$key . '__' . $k] = $name; } break; case 'language': // full list of // full list of case 'lanlist': // use the array $parm; if (!is_array(varset($parms['__options']))) { parse_str($parms['__options'], $parms['__options']); } $opts = $parms['__options']; if (vartrue($opts['multiple'])) { // no batch support for multiple, should have some for filters soon continue; } $options = $val['type'] === 'language' ? e107::getLanguage()->getList() : e107::getLanguage()->getLanSelectArray(); foreach ($options as $code => $name) { $option[$key . '__' . $code] = $name; } break; case 'datestamp': //TODO today, yesterday, this-month, last-month . $dateFilters = array('hour' => "Past Hour", "day" => "Past 24 hours", "week" => "Past Week", "month" => "Past Month", "year" => "Past Year"); foreach ($dateFilters as $k => $name) { $option['datestamp__' . $key . '__' . $k] = $name; // $option['bool__'.$key.'__0'] = LAN_NO; // $option[$key.'__'.$k] = $name; } break; case 'userclass': $classes = e107::getUserClass()->uc_required_class_list(vartrue($parms['classlist'], 'public,nobody,guest,admin,main,classes')); foreach ($classes as $k => $name) { $option[$key . '__' . $k] = $name; } break; case 'userclasses': $classes = e107::getUserClass()->uc_required_class_list(vartrue($parms['classlist'], 'public,nobody,guest,admin,main,classes')); $_option = array(); if ($type == 'batch') { // FIXME Lan foreach ($classes as $k => $v) { $option['ucadd__' . $key . '__' . $k] = LAN_ADD . ' ' . $v; $_option['ucremove__' . $key . '__' . $k] = 'Remove ' . $v; } $option['ucaddall__' . $key] = '(add all)'; $_option['ucdelall__' . $key] = '(clear all)'; $option = array_merge($option, $_option); } else { foreach ($classes as $k => $v) { $option[$key . '__' . $k] = $v; } } unset($_option); break; case 'method': $method = $key; $list = call_user_func_array(array($this, $method), array('', $type, $parms)); if (is_array($list)) { //check for single option if (isset($list['singleOption'])) { $textsingle .= $list['singleOption']; continue; } // non rendered options array foreach ($list as $k => $name) { $option[$key . '__' . $k] = $name; } } elseif (!empty($list)) { $text .= $list; continue; } break; case 'user': // TODO - User Filter $sql = e107::getDb(); $field = $val['field']; $query = "SELECT d." . $field . ", u.user_name FROM #" . $val['table'] . " AS d LEFT JOIN #user AS u ON d." . $field . " = u.user_id GROUP BY d." . $field . " ORDER BY u.user_name"; $row = $sql->retrieve($query, true); foreach ($row as $data) { $k = $data[$field]; if ($k == 0) { $option[$key . '__' . $k] = "(" . LAN_ANONYMOUS . ")"; } else { $option[$key . '__' . $k] = vartrue($data['user_name'], 'Unknown'); } } break; } if (count($option) > 0) { $text .= "\t" . $this->optgroup_open($optdiz[$type] . defset($val['title'], $val['title']), varset($disabled)) . "\n"; foreach ($option as $okey => $oval) { $text .= $this->option($oval, $okey, $selected == $okey) . "\n"; } $text .= "\t" . $this->optgroup_close() . "\n"; } } return $textsingle . $text; }
* e107 website system * * Copyright (C) 2008-2014 e107 Inc (e107.org) * Released under the terms and conditions of the * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * Forum View Topic * */ if (!defined('e107_INIT')) { require_once '../../class2.php'; } e107::lan('forum', "front", true); if (!deftrue('BOOTSTRAP')) { $bcDefs = array('LAN_413' => 'LAN_FORUM_2046', 'LAN_400' => 'LAN_EDIT', 'LAN_401' => 'LAN_FORUM_2041', 'LAN_406' => 'LAN_EDIT', 'LAN_435' => 'LAN_DELETE', 'LAN_397' => 'LAN_FORUM_2044', 'LAN_398' => 'LAN_FORUM_4007'); e107::getLanguage()->bcDefs($bcDefs); } define('NAVIGATION_ACTIVE', 'forum'); $e107 = e107::getInstance(); $tp = e107::getParser(); $ns = e107::getRender(); if (!e107::isInstalled('forum')) { e107::redirect(); exit; } $highlight_search = isset($_POST['highlight_search']); if (!e_QUERY) { //No parameters given, redirect to forum home $url = e107::url('forum', 'index', 'full'); e107::getRedirect()->go($url); exit;
} //include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE); e107::coreLan('language', true); $e_sub_cat = 'language'; require_once "auth.php"; $frm = e107::getForm(); $mes = e107::getMessage(); include_lan(e_LANGUAGEDIR . e_LANGUAGE . "/admin/lan_lancheck.php"); require_once e_ADMIN . "lancheck.php"; require_once e_HANDLER . "language_class.php"; // $ln = new language; $ln = $lng; $lck = new lancheck(); $tabs = table_list(); // array("news","content","links"); $lanlist = e107::getLanguage()->installed(); // Bugfix - don't use e_LANLIST as it's cached (SESSION) $message = ''; if (e_QUERY) { $tmp = explode('.', e_QUERY); $action = varset($tmp[0]); $sub_action = varset($tmp[1]); $id = varset($tmp[2]); unset($tmp); } elseif (!getperms('0')) { $action = 'tools'; } if (isset($_POST['submit_prefs']) && isset($_POST['mainsitelanguage']) && getperms('0')) { unset($temp); $changes = array(); $temp['multilanguage'] = $_POST['multilanguage'];
public function renderAliases($aliases) { $ret = array(); $lans = array(); $lng = e107::getLanguage(); $lanList = $lng->installed(); sort($lanList); $lanDef = e107::getPref('sitelanguage') ? e107::getPref('sitelanguage') : e_LANGUAGE; $lanDef = array($lng->convert($lanDef), $lanDef); foreach ($lanList as $index => $lan) { $lanCode = $lng->convert($lan); if ($lanDef[0] == $lanCode) { continue; } $lans[$lanCode] = $lan; } $modules = e107::getPref('url_config'); if (!$modules) { $modules = array(); e107::getConfig()->set('url_aliases', array())->save(false); // do not output message e107::getMessage()->reset(false, 'default'); } foreach ($modules as $module => $location) { $data = new e_vars(); $obj = eDispatcher::getConfigObject($module, $location); if (null === $obj) { $obj = new eurlAdminEmptyConfig(); } $data->module = $module; $data->location = $location; $data->config = $obj; $modules[$module] = $data; } return $this->getUI()->aliasesRows($aliases, $modules, $lanDef, $lans); }