本文整理汇总了PHP中Contao\System::loadLanguageFile方法的典型用法代码示例。如果您正苦于以下问题:PHP System::loadLanguageFile方法的具体用法?PHP System::loadLanguageFile怎么用?PHP System::loadLanguageFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contao\System
的用法示例。
在下文中一共展示了System::loadLanguageFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCurrencies
/**
* @return array
*/
public function getCurrencies()
{
$return = array();
$arrAux = array();
\Contao\System::loadLanguageFile('currencies');
$this->loadCurrencies();
if (is_array($this->arrCurrencies)) {
foreach ($this->arrCurrencies as $strKey => $strName) {
$arrAux[$strKey] = isset($GLOBALS['TL_LANG']['CUR'][$strKey]) ? Utf8::toAscii($GLOBALS['TL_LANG']['CUR'][$strKey]) : $strName;
}
}
asort($arrAux);
if (is_array($arrAux)) {
foreach (array_keys($arrAux) as $strKey) {
$return[$strKey] = isset($GLOBALS['TL_LANG']['CUR'][$strKey]) ? $GLOBALS['TL_LANG']['CUR'][$strKey] : $this->arrCurrencies[$strKey];
}
}
// HOOK: add custom logic
if (isset($GLOBALS['TL_HOOKS']['getCurrencies']) && is_array($GLOBALS['TL_HOOKS']['getCurrencies'])) {
foreach ($GLOBALS['TL_HOOKS']['getCurrencies'] as $callback) {
$return = static::importStatic($callback[0])->{$callback}[1]($return, $this->arrCurrencies);
}
}
return $return;
}
示例2: __construct
/**
* Initialize the controller
*
* 1. Import the user
* 2. Call the parent constructor
* 3. Authenticate the user
* 4. Load the language files
* DO NOT CHANGE THIS ORDER!
*/
public function __construct()
{
$this->import('BackendUser', 'User');
parent::__construct();
$this->User->authenticate();
\System::loadLanguageFile('default');
}
示例3: getButtons
/**
* Get buttons.
*
* @param $articleId
*
* @return string
*/
protected function getButtons($articleId)
{
global $container;
System::loadLanguageFile('tl_article');
$translator = $container['translator'];
$buttons = self::getModalEditButton($articleId, $translator);
$buttons .= self::getModalShowButton($articleId, $translator);
return $buttons;
}
示例4: __construct
/**
* Initialize the controller
*/
public function __construct()
{
$this->import('Config');
$this->import('Session');
\Config::set('showHelp', false);
$this->setStaticUrls();
\System::loadLanguageFile('default');
\System::loadLanguageFile('tl_install');
}
示例5: __construct
/**
* Initialize the controller
*
* 1. Import the user
* 2. Call the parent constructor
* 3. Authenticate the user
* 4. Load the language files
* DO NOT CHANGE THIS ORDER!
*/
public function __construct()
{
$this->import('BackendUser', 'User');
parent::__construct();
$this->User->authenticate();
\System::loadLanguageFile('default');
$strFile = \Input::get('src', true);
$strFile = base64_decode($strFile);
$strFile = preg_replace('@^/+@', '', rawurldecode($strFile));
$this->strFile = $strFile;
}
示例6: generatePurgeField
/**
* Generate the purge cache field
*
* @return string
*/
public function generatePurgeField()
{
System::loadLanguageFile('tl_maintenance');
$template = new BackendTemplate('be_vimeo_rebuilder_user');
$template->elementsCount = count(Rebuilder::getContentElements());
if (($stats = Rebuilder::generateStats()) !== null) {
foreach ($stats as $k => $v) {
$template->{$k} = $v;
}
}
return $template->parse();
}
示例7: addTranslationContentToField
/**
* @param $strField
*/
protected function addTranslationContentToField($strField)
{
if ($this->Config->get($strField) === null) {
$arrValues = array();
System::loadLanguageFile('tl_email', 'de', true);
$arrValues['de'] = $GLOBALS['TL_LANG']['tl_email']['defaultContents'][$strField];
System::loadLanguageFile('tl_email', 'en', true);
$arrValues['en'] = $GLOBALS['TL_LANG']['tl_email']['defaultContents'][$strField];
// Load translation file by current language
System::loadLanguageFile('tl_email', null, true);
$this->Config->persist($strField, TranslationFieldsModel::saveValuesAndReturnFid($arrValues));
}
}
示例8: __construct
/**
* Initialize the controller
*
* 1. Import the user
* 2. Call the parent constructor
* 3. Login the user
* 4. Load the language files
* DO NOT CHANGE THIS ORDER!
*/
public function __construct()
{
$this->import('BackendUser', 'User');
parent::__construct();
// Login
if ($this->User->login()) {
$strUrl = 'contao/main.php';
// Redirect to the last page visited
if (\Input::get('referer', true) != '') {
$strUrl = base64_decode(\Input::get('referer', true));
}
$this->redirect($strUrl);
} elseif (!empty($_POST['username']) && !empty($_POST['password'])) {
$this->reload();
} elseif ($this->User->logout()) {
$this->reload();
}
\System::loadLanguageFile('default');
\System::loadLanguageFile('tl_user');
}
示例9: compile
/**
* Generate the module
*/
protected function compile()
{
/** @var PageModel $objPage */
global $objPage;
$this->import('FrontendUser', 'User');
$GLOBALS['TL_LANGUAGE'] = $objPage->language;
\System::loadLanguageFile('tl_member');
$this->loadDataContainer('tl_member');
// Old password widget
$arrFields['oldPassword'] = array('name' => 'oldpassword', 'label' => &$GLOBALS['TL_LANG']['MSC']['oldPassword'], 'inputType' => 'text', 'eval' => array('mandatory' => true, 'preserveTags' => true, 'hideInput' => true));
// New password widget
$arrFields['newPassword'] = $GLOBALS['TL_DCA']['tl_member']['fields']['password'];
$arrFields['newPassword']['name'] = 'password';
$arrFields['newPassword']['label'] =& $GLOBALS['TL_LANG']['MSC']['newPassword'];
$row = 0;
$strFields = '';
$doNotSubmit = false;
$objMember = \MemberModel::findByPk($this->User->id);
$strFormId = 'tl_change_password_' . $this->id;
$flashBag = \System::getContainer()->get('session')->getFlashBag();
$strTable = $objMember->getTable();
// Initialize the versioning (see #8301)
$objVersions = new \Versions($strTable, $objMember->id);
$objVersions->setUsername($objMember->username);
$objVersions->setUserId(0);
$objVersions->setEditUrl('contao/main.php?do=member&act=edit&id=%s&rt=1');
$objVersions->initialize();
/** @var FormTextField $objOldPassword */
$objOldPassword = null;
/** @var FormPassword $objNewPassword */
$objNewPassword = null;
// Initialize the widgets
foreach ($arrFields as $strKey => $arrField) {
/** @var Widget $strClass */
$strClass = $GLOBALS['TL_FFL'][$arrField['inputType']];
// Continue if the class is not defined
if (!class_exists($strClass)) {
continue;
}
$arrField['eval']['required'] = $arrField['eval']['mandatory'];
/** @var Widget $objWidget */
$objWidget = new $strClass($strClass::getAttributesFromDca($arrField, $arrField['name']));
$objWidget->storeValues = true;
$objWidget->rowClass = 'row_' . $row . ($row == 0 ? ' row_first' : '') . ($row % 2 == 0 ? ' even' : ' odd');
// Increase the row count if it is a password field
if ($objWidget instanceof FormPassword) {
$objWidget->rowClassConfirm = 'row_' . ++$row . ($row % 2 == 0 ? ' even' : ' odd');
}
++$row;
// Store the widget objects
$strVar = 'obj' . ucfirst($strKey);
${$strVar} = $objWidget;
// Validate the widget
if (\Input::post('FORM_SUBMIT') == $strFormId) {
$objWidget->validate();
// Validate the old password
if ($strKey == 'oldPassword') {
if (\Encryption::test($objMember->password)) {
$blnAuthenticated = \Encryption::verify($objWidget->value, $objMember->password);
} else {
list($strPassword, $strSalt) = explode(':', $objMember->password);
$blnAuthenticated = $strSalt == '' ? $strPassword === sha1($objWidget->value) : $strPassword === sha1($strSalt . $objWidget->value);
}
if (!$blnAuthenticated) {
$objWidget->value = '';
$objWidget->addError($GLOBALS['TL_LANG']['MSC']['oldPasswordWrong']);
sleep(2);
// Wait 2 seconds while brute forcing :)
}
}
if ($objWidget->hasErrors()) {
$doNotSubmit = true;
}
}
$strFields .= $objWidget->parse();
}
$this->Template->fields = $strFields;
$this->Template->hasError = $doNotSubmit;
// Store the new password
if (\Input::post('FORM_SUBMIT') == $strFormId && !$doNotSubmit) {
$objMember->tstamp = time();
$objMember->password = $objNewPassword->value;
$objMember->save();
// Create a new version
if ($GLOBALS['TL_DCA'][$strTable]['config']['enableVersioning']) {
$objVersions->create();
}
// HOOK: set new password callback
if (isset($GLOBALS['TL_HOOKS']['setNewPassword']) && is_array($GLOBALS['TL_HOOKS']['setNewPassword'])) {
foreach ($GLOBALS['TL_HOOKS']['setNewPassword'] as $callback) {
$this->import($callback[0]);
$this->{$callback[0]}->{$callback[1]}($objMember, $objNewPassword->value, $this);
}
}
// Check whether there is a jumpTo page
if (($objJumpTo = $this->objModel->getRelated('jumpTo')) instanceof PageModel) {
$this->jumpToOrReload($objJumpTo->row());
//.........这里部分代码省略.........
示例10: compile
/**
* Generate the module
*/
protected function compile()
{
/** @var PageModel $objPage */
global $objPage;
$GLOBALS['TL_LANGUAGE'] = $objPage->language;
\System::loadLanguageFile('tl_member');
$this->loadDataContainer('tl_member');
// Call onload_callback (e.g. to check permissions)
if (is_array($GLOBALS['TL_DCA']['tl_member']['config']['onload_callback'])) {
foreach ($GLOBALS['TL_DCA']['tl_member']['config']['onload_callback'] as $callback) {
if (is_array($callback)) {
$this->import($callback[0]);
$this->{$callback[0]}->{$callback[1]}();
} elseif (is_callable($callback)) {
$callback();
}
}
}
// Activate account
if (\Input::get('token') != '') {
$this->activateAcount();
return;
}
if ($this->memberTpl != '') {
/** @var FrontendTemplate|object $objTemplate */
$objTemplate = new \FrontendTemplate($this->memberTpl);
$this->Template = $objTemplate;
$this->Template->setData($this->arrData);
}
$this->Template->fields = '';
$objCaptcha = null;
$doNotSubmit = false;
$strFormId = 'tl_registration_' . $this->id;
// Predefine the group order (other groups will be appended automatically)
$arrGroups = array('personal' => array(), 'address' => array(), 'contact' => array(), 'login' => array(), 'profile' => array());
// Captcha
if (!$this->disableCaptcha) {
$arrCaptcha = array('id' => 'registration', 'label' => $GLOBALS['TL_LANG']['MSC']['securityQuestion'], 'type' => 'captcha', 'mandatory' => true, 'required' => true);
/** @var FormCaptcha $strClass */
$strClass = $GLOBALS['TL_FFL']['captcha'];
// Fallback to default if the class is not defined
if (!class_exists($strClass)) {
$strClass = 'FormCaptcha';
}
/** @var FormCaptcha $objCaptcha */
$objCaptcha = new $strClass($arrCaptcha);
if (\Input::post('FORM_SUBMIT') == $strFormId) {
$objCaptcha->validate();
if ($objCaptcha->hasErrors()) {
$doNotSubmit = true;
}
}
}
$objMember = null;
// Check for a follow-up registration (see #7992)
if (\Input::post('email', true) != '' && ($objMember = \MemberModel::findUnactivatedByEmail(\Input::post('email', true))) !== null) {
$this->resendActivationMail($objMember);
return;
}
$arrUser = array();
$arrFields = array();
$hasUpload = false;
$i = 0;
// Build form
foreach ($this->editable as $field) {
$arrData = $GLOBALS['TL_DCA']['tl_member']['fields'][$field];
// Map checkboxWizards to regular checkbox widgets
if ($arrData['inputType'] == 'checkboxWizard') {
$arrData['inputType'] = 'checkbox';
}
// Map fileTrees to upload widgets (see #8091)
if ($arrData['inputType'] == 'fileTree') {
$arrData['inputType'] = 'upload';
}
/** @var Widget $strClass */
$strClass = $GLOBALS['TL_FFL'][$arrData['inputType']];
// Continue if the class is not defined
if (!class_exists($strClass)) {
continue;
}
$arrData['eval']['required'] = $arrData['eval']['mandatory'];
// Unset the unique field check upon follow-up registrations
if ($objMember !== null && $arrData['eval']['unique'] && \Input::post($field) == $objMember->{$field}) {
$arrData['eval']['unique'] = false;
}
$objWidget = new $strClass($strClass::getAttributesFromDca($arrData, $field, $arrData['default'], '', '', $this));
$objWidget->storeValues = true;
$objWidget->rowClass = 'row_' . $i . ($i == 0 ? ' row_first' : '') . ($i % 2 == 0 ? ' even' : ' odd');
// Increase the row count if its a password field
if ($objWidget instanceof FormPassword) {
$objWidget->rowClassConfirm = 'row_' . ++$i . ($i % 2 == 0 ? ' even' : ' odd');
}
// Validate input
if (\Input::post('FORM_SUBMIT') == $strFormId) {
$objWidget->validate();
$varValue = $objWidget->value;
// Check whether the password matches the username
//.........这里部分代码省略.........
示例11: createExtract
/**
* Create the extract from the DCA or the database.sql files
*/
protected function createExtract()
{
// Load the default language file (see #7202)
if (empty($GLOBALS['TL_LANG']['MSC'])) {
System::loadLanguageFile('default');
}
// Load the data container
if (!isset($GLOBALS['loadDataContainer'][$this->strTable])) {
$this->loadDataContainer($this->strTable);
}
// Return if the DC type is "File"
if ($GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer'] == 'File') {
return;
}
$blnFromFile = false;
$arrRelations = array();
// Check whether there are fields (see #4826)
if (isset($GLOBALS['TL_DCA'][$this->strTable]['fields'])) {
foreach ($GLOBALS['TL_DCA'][$this->strTable]['fields'] as $field => $config) {
// Check whether all fields have an SQL definition
if (!isset($config['sql']) && isset($config['inputType'])) {
$blnFromFile = true;
}
// Check whether there is a relation (see #6524)
if (isset($config['relation'])) {
$table = substr($config['foreignKey'], 0, strrpos($config['foreignKey'], '.'));
$arrRelations[$field] = array_merge(array('table' => $table, 'field' => 'id'), $config['relation']);
// Table name and field name are mandatory
if (empty($arrRelations[$field]['table']) || empty($arrRelations[$field]['field'])) {
throw new \Exception('Incomplete relation defined for ' . $this->strTable . '.' . $field);
}
}
}
}
$sql = $GLOBALS['TL_DCA'][$this->strTable]['config']['sql'] ?: array();
$fields = $GLOBALS['TL_DCA'][$this->strTable]['fields'] ?: array();
// Deprecated since Contao 4.0, to be removed in Contao 5.0
if ($blnFromFile) {
trigger_error('Using database.sql files has been deprecated and will no longer work in Contao 5.0. Use a DCA file instead.', E_USER_DEPRECATED);
if (!isset(static::$arrSql[$this->strTable])) {
try {
/** @var SplFileInfo[] $files */
$files = \System::getContainer()->get('contao.resource_locator')->locate('config/database.sql', null, false);
} catch (\InvalidArgumentException $e) {
return array();
}
$arrSql = array();
foreach ($files as $file) {
$arrSql = array_merge_recursive($arrSql, \SqlFileParser::parse($file));
}
static::$arrSql = $arrSql;
}
$arrTable = static::$arrSql[$this->strTable];
list($engine, , $charset) = explode(' ', trim($arrTable['TABLE_OPTIONS']));
if ($engine != '') {
$sql['engine'] = str_replace('ENGINE=', '', $engine);
}
if ($charset != '') {
$sql['charset'] = str_replace('CHARSET=', '', $charset);
}
// Fields
if (isset($arrTable['TABLE_FIELDS'])) {
foreach ($arrTable['TABLE_FIELDS'] as $k => $v) {
$fields[$k]['sql'] = str_replace('`' . $k . '` ', '', $v);
}
}
// Keys
if (isset($arrTable['TABLE_CREATE_DEFINITIONS'])) {
foreach ($arrTable['TABLE_CREATE_DEFINITIONS'] as $strKey) {
if (preg_match('/^([A-Z]+ )?KEY .+\\(([^)]+)\\)$/', $strKey, $arrMatches) && preg_match_all('/`([^`]+)`/', $arrMatches[2], $arrFields)) {
$type = trim($arrMatches[1]);
$field = implode(',', $arrFields[1]);
$sql['keys'][$field] = $type != '' ? strtolower($type) : 'index';
}
}
}
}
// Not a database table or no field information
if (empty($sql) || empty($fields)) {
return;
}
// Add the default engine and charset if none is given
if (empty($sql['engine'])) {
$sql['engine'] = 'MyISAM';
}
if (empty($sql['charset'])) {
$sql['charset'] = \Config::get('dbCharset');
}
// Meta
$this->arrMeta = array('engine' => $sql['engine'], 'charset' => $sql['charset']);
// Fields
if (!empty($fields)) {
$this->arrFields = array();
$this->arrOrderFields = array();
foreach ($fields as $field => $config) {
if (isset($config['sql'])) {
$this->arrFields[$field] = $config['sql'];
//.........这里部分代码省略.........
示例12: prepareButtons
/**
* Prepare buttons.
*
* @param $newsId
*
* @return string
*/
protected function prepareButtons($newsId)
{
global $container;
System::loadLanguageFile('tl_calendar_events');
$translator = $container['translator'];
$buttons = self::getModalEditButton($newsId, $translator);
$buttons .= self::getModalShowButton($newsId, $translator);
return $buttons;
}
示例13: run
/**
* Run the controller and parse the template
*
* @return Response
*/
public function run()
{
$table = \Input::get('table');
$field = \Input::get('field');
\System::loadLanguageFile($table);
$this->loadDataContainer($table);
/** @var \BackendTemplate|object $objTemplate */
$objTemplate = new \BackendTemplate('be_help');
$objTemplate->rows = array();
$objTemplate->explanation = '';
$arrData = $GLOBALS['TL_DCA'][$table]['fields'][$field];
// Back end modules
if ($table == 'tl_user_group' && $field == 'modules') {
$rows = array();
foreach (array_keys($GLOBALS['BE_MOD']) as $group) {
$rows[] = array('headspan', $arrData['reference'][$group]);
foreach ($GLOBALS['BE_MOD'][$group] as $module => $class) {
$rows[] = $arrData['reference'][$module];
}
}
$objTemplate->rows = $rows;
} elseif ($table == 'tl_module' && $field == 'type') {
$rows = array();
foreach (array_keys($GLOBALS['FE_MOD']) as $group) {
$rows[] = array('headspan', $arrData['reference'][$group]);
foreach ($GLOBALS['FE_MOD'][$group] as $module => $class) {
$rows[] = $arrData['reference'][$module];
}
}
$objTemplate->rows = $rows;
} elseif ($table == 'tl_content' && $field == 'type') {
$rows = array();
foreach (array_keys($GLOBALS['TL_CTE']) as $group) {
$rows[] = array('headspan', $arrData['reference'][$group]);
foreach ($GLOBALS['TL_CTE'][$group] as $element => $class) {
$rows[] = $arrData['reference'][$element];
}
}
$objTemplate->rows = $rows;
} elseif (!empty($arrData['reference'])) {
$rows = array();
$options = is_array($arrData['options']) ? $arrData['options'] : array_keys($arrData['reference']);
// Unset the predefined image sizes
unset($options['image_sizes']);
foreach ($options as $key => $option) {
if (is_array($option)) {
if (is_array($arrData['reference'][$key])) {
$rows[] = array('headspan', $arrData['reference'][$key][0]);
} else {
$rows[] = array('headspan', $arrData['reference'][$key]);
}
foreach ($option as $opt) {
$rows[] = $arrData['reference'][$opt];
}
} else {
if (!is_array($arrData['reference'][$option])) {
$rows[] = array('headspan', $arrData['reference'][$option]);
} else {
$rows[] = $arrData['reference'][$option];
}
}
}
$objTemplate->rows = $rows;
}
// Add an explanation
if (isset($arrData['explanation'])) {
\System::loadLanguageFile('explain');
$key = $arrData['explanation'];
if (!is_array($GLOBALS['TL_LANG']['XPL'][$key])) {
$objTemplate->explanation = trim($GLOBALS['TL_LANG']['XPL'][$key]);
} else {
$objTemplate->rows = $GLOBALS['TL_LANG']['XPL'][$key];
}
}
$objTemplate->theme = \Backend::getTheme();
$objTemplate->base = \Environment::get('base');
$objTemplate->language = $GLOBALS['TL_LANGUAGE'];
$objTemplate->title = specialchars($GLOBALS['TL_LANG']['MSC']['helpWizardTitle']);
$objTemplate->charset = \Config::get('characterSet');
$objTemplate->headline = $arrData['label'][0] ?: $field;
$objTemplate->helpWizard = $GLOBALS['TL_LANG']['MSC']['helpWizard'];
return $objTemplate->getResponse();
}
示例14: compile
/**
* Generate the module
*/
protected function compile()
{
\System::loadLanguageFile($this->list_table);
$this->loadDataContainer($this->list_table);
// List a single record
if (\Input::get('show')) {
$this->listSingleRecord(\Input::get('show'));
return;
}
/**
* Add the search menu
*/
$strWhere = '';
$varKeyword = '';
$strOptions = '';
$this->Template->searchable = false;
$arrSearchFields = \StringUtil::trimsplit(',', $this->list_search);
if (!empty($arrSearchFields) && is_array($arrSearchFields)) {
$this->Template->searchable = true;
if (\Input::get('search') && \Input::get('for')) {
$varKeyword = '%' . \Input::get('for') . '%';
$strWhere = (!$this->list_where ? " WHERE " : " AND ") . \Input::get('search') . " LIKE ?";
}
foreach ($arrSearchFields as $field) {
$strOptions .= ' <option value="' . $field . '"' . ($field == \Input::get('search') ? ' selected="selected"' : '') . '>' . (strlen($label = $GLOBALS['TL_DCA'][$this->list_table]['fields'][$field]['label'][0]) ? $label : $field) . '</option>' . "\n";
}
}
$this->Template->search_fields = $strOptions;
/**
* Get the total number of records
*/
$strQuery = "SELECT COUNT(*) AS count FROM " . $this->list_table;
if ($this->list_where) {
$strQuery .= " WHERE (" . $this->list_where . ")";
}
$strQuery .= $strWhere;
$objTotal = $this->Database->prepare($strQuery)->execute($varKeyword);
/**
* Validate the page count
*/
$id = 'page_l' . $this->id;
$page = \Input::get($id) !== null ? \Input::get($id) : 1;
$per_page = \Input::get('per_page') ?: $this->perPage;
// Thanks to Hagen Klemp (see #4485)
if ($per_page > 0 && ($page < 1 || $page > max(ceil($objTotal->count / $per_page), 1))) {
throw new PageNotFoundException('Page not found: ' . \Environment::get('uri'));
}
/**
* Get the selected records
*/
$strQuery = "SELECT " . $this->strPk . "," . $this->list_fields;
if ($this->list_info_where) {
$strQuery .= ", (SELECT COUNT(*) FROM " . $this->list_table . " t2 WHERE t2." . $this->strPk . "=t1." . $this->strPk . " AND " . $this->list_info_where . ") AS _details";
}
$strQuery .= " FROM " . $this->list_table . " t1";
if ($this->list_where) {
$strQuery .= " WHERE (" . $this->list_where . ")";
}
$strQuery .= $strWhere;
// Cast date fields to int (see #5609)
$isInt = function ($field) {
return $GLOBALS['TL_DCA'][$this->list_table]['fields'][$field]['eval']['rgxp'] == 'date' || $GLOBALS['TL_DCA'][$this->list_table]['fields'][$field]['eval']['rgxp'] == 'time' || $GLOBALS['TL_DCA'][$this->list_table]['fields'][$field]['eval']['rgxp'] == 'datim';
};
// Order by
if (\Input::get('order_by')) {
if ($isInt(\Input::get('order_by'))) {
$strQuery .= " ORDER BY CAST(" . \Input::get('order_by') . " AS SIGNED) " . \Input::get('sort');
} else {
$strQuery .= " ORDER BY " . \Input::get('order_by') . ' ' . \Input::get('sort');
}
} elseif ($this->list_sort) {
if ($isInt($this->list_sort)) {
$strQuery .= " ORDER BY CAST(" . $this->list_sort . " AS SIGNED)";
} else {
$strQuery .= " ORDER BY " . $this->list_sort;
}
}
$objDataStmt = $this->Database->prepare($strQuery);
// Limit
if (\Input::get('per_page')) {
$objDataStmt->limit(\Input::get('per_page'), ($page - 1) * $per_page);
} elseif ($this->perPage) {
$objDataStmt->limit($this->perPage, ($page - 1) * $per_page);
}
$objData = $objDataStmt->execute($varKeyword);
/**
* Prepare the URL
*/
$strUrl = preg_replace('/\\?.*$/', '', \Environment::get('request'));
$blnQuery = false;
foreach (preg_split('/&(amp;)?/', \Environment::get('queryString')) as $fragment) {
if ($fragment != '' && strncasecmp($fragment, 'order_by', 8) !== 0 && strncasecmp($fragment, 'sort', 4) !== 0 && strncasecmp($fragment, $id, strlen($id)) !== 0) {
$strUrl .= (!$blnQuery ? '?' : '&') . $fragment;
$blnQuery = true;
}
}
$this->Template->url = $strUrl;
//.........这里部分代码省略.........
示例15: compile
/**
* Generate the module
*/
protected function compile()
{
/** @var PageModel $objPage */
global $objPage;
$this->import('FrontendUser', 'User');
$GLOBALS['TL_LANGUAGE'] = $objPage->language;
\System::loadLanguageFile('tl_member');
$this->loadDataContainer('tl_member');
// Call onload_callback (e.g. to check permissions)
if (is_array($GLOBALS['TL_DCA']['tl_member']['config']['onload_callback'])) {
foreach ($GLOBALS['TL_DCA']['tl_member']['config']['onload_callback'] as $callback) {
if (is_array($callback)) {
$this->import($callback[0]);
$this->{$callback[0]}->{$callback[1]}();
} elseif (is_callable($callback)) {
$callback();
}
}
}
$this->Template->fields = '';
$arrFields = array();
$doNotSubmit = false;
$hasUpload = false;
$row = 0;
// Predefine the group order (other groups will be appended automatically)
$arrGroups = array('personal' => array(), 'address' => array(), 'contact' => array(), 'login' => array(), 'profile' => array());
$blnModified = false;
$objMember = \MemberModel::findByPk($this->User->id);
$strTable = $objMember->getTable();
$strFormId = 'tl_member_' . $this->id;
$flashBag = \System::getContainer()->get('session')->getFlashBag();
// Initialize the versioning (see #7415)
$objVersions = new \Versions($strTable, $objMember->id);
$objVersions->setUsername($objMember->username);
$objVersions->setUserId(0);
$objVersions->setEditUrl('contao/main.php?do=member&act=edit&id=%s&rt=1');
$objVersions->initialize();
// Build the form
foreach ($this->editable as $field) {
$arrData =& $GLOBALS['TL_DCA']['tl_member']['fields'][$field];
// Map checkboxWizards to regular checkbox widgets
if ($arrData['inputType'] == 'checkboxWizard') {
$arrData['inputType'] = 'checkbox';
}
// Map fileTrees to upload widgets (see #8091)
if ($arrData['inputType'] == 'fileTree') {
$arrData['inputType'] = 'upload';
}
/** @var Widget $strClass */
$strClass = $GLOBALS['TL_FFL'][$arrData['inputType']];
// Continue if the class does not exist
if (!$arrData['eval']['feEditable'] || !class_exists($strClass)) {
continue;
}
$strGroup = $arrData['eval']['feGroup'];
$arrData['eval']['required'] = false;
// Use strlen() here (see #3277)
if ($arrData['eval']['mandatory']) {
if (is_array($this->User->{$field})) {
if (empty($this->User->{$field})) {
$arrData['eval']['required'] = true;
}
} else {
if (!strlen($this->User->{$field})) {
$arrData['eval']['required'] = true;
}
}
}
$varValue = $this->User->{$field};
// Call the load_callback
if (isset($arrData['load_callback']) && is_array($arrData['load_callback'])) {
foreach ($arrData['load_callback'] as $callback) {
if (is_array($callback)) {
$this->import($callback[0]);
$varValue = $this->{$callback[0]}->{$callback[1]}($varValue, $this->User, $this);
} elseif (is_callable($callback)) {
$varValue = $callback($varValue, $this->User, $this);
}
}
}
/** @var Widget $objWidget */
$objWidget = new $strClass($strClass::getAttributesFromDca($arrData, $field, $varValue, '', '', $this));
$objWidget->storeValues = true;
$objWidget->rowClass = 'row_' . $row . ($row == 0 ? ' row_first' : '') . ($row % 2 == 0 ? ' even' : ' odd');
// Increase the row count if it is a password field
if ($objWidget instanceof FormPassword) {
if ($objMember->password != '') {
$objWidget->mandatory = false;
}
$objWidget->rowClassConfirm = 'row_' . ++$row . ($row % 2 == 0 ? ' even' : ' odd');
}
// Validate the form data
if (\Input::post('FORM_SUBMIT') == $strFormId) {
$objWidget->validate();
$varValue = $objWidget->value;
$rgxp = $arrData['eval']['rgxp'];
// Convert date formats into timestamps (check the eval setting first -> #3063)
//.........这里部分代码省略.........