本文整理匯總了PHP中languages函數的典型用法代碼示例。如果您正苦於以下問題:PHP languages函數的具體用法?PHP languages怎麽用?PHP languages使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了languages函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: summary
public function summary($field, $data, $object)
{
$languages = languages();
$fieldname = strval($field['name']);
if (isset($languages[$data->{$fieldname}])) {
return $languages[$data->{$fieldname}];
}
return '';
}
示例2: l
function l($input, $lang = false)
{
if (!is_array($input)) {
return l(array_combine(array_slice(array_keys(languages()), 0, func_num_args()), func_get_args()));
}
if (!$lang) {
$lang = language();
}
return isset($input[$lang]) ? $input[$lang] : current($input);
}
示例3: get_slugs
public function get_slugs($field, $data, $object)
{
if (isset($data->id)) {
$slugs = array();
$object_language = language();
$parent_id = 0;
foreach ($object->children() as $sibling) {
if ($sibling->getName() == 'slug') {
$source = false;
foreach ($object->children() as $child) {
if (strval($child['name']) == strval($sibling['source'])) {
$source = $child;
}
}
if ($source) {
$name = isset($sibling['name']) ? strval($sibling['name']) : 'slug';
if (isset($source['translatable']) && $source['translatable']) {
foreach (languages() as $code => $lang) {
$fieldname = $name . '_' . $code;
$slugs[$code] = $data->{$fieldname};
}
} else {
$slugs[] = $data->{$name};
}
}
} else {
if ($sibling->getName() == 'language') {
$language = strval($sibling['name']);
$object_language = $data->{$language};
} else {
if ($sibling->getName() == 'recursive' && isset($data->parent_id) && $data->parent_id) {
$parent_id = $data->parent_id;
}
}
}
}
foreach ($slugs as $language => $slug) {
if (!is_string($language)) {
$slugs[$object_language] = $slug;
unset($slugs[$language]);
}
}
if ($parent_id) {
$parent_slugs = self::get_slugs($field, where('id = %d', $parent_id)->get_row($object['stack']), $object);
foreach ($parent_slugs as $key => $parent_slug) {
if (isset($slugs[$key])) {
$slugs[$key] = $parent_slug . '/' . $slugs[$key];
}
}
}
return $slugs;
} else {
return array();
}
}
示例4: language
/**
* Loads a language based on input data
* @param string $language language to grab.
* @return string
*/
function language($language)
{
if (in_array($language, languages())) {
// Include language
include 'include/languages/' . $language . '.php';
} else {
// Include language
include 'include/languages/en.php';
}
// Return language
return $lang;
}
示例5: language
/**
* Loads a language based on input data
* @param string $language language to grab.
* @return string
*/
function language($language)
{
if (in_array($language, languages())) {
// Include language
include BASEPATH . 'languages/' . $language . EXT;
} else {
// Include language
include BASEPATH . 'languages/en' . EXT;
}
// Return language
return $lang;
}
示例6: pCell
function pCell($item, $var, $format, $size = "", $nohelp = "")
{
$var = stripslashes($var);
$out = tda(gTxt($item), ' style="text-align:right;vertical-align:middle"');
switch ($format) {
case "radio":
$in = yesnoradio($item, $var);
break;
case "input":
$in = text_input($item, $var, $size);
break;
case "timeoffset":
$in = timeoffset_select($item, $var);
break;
case 'commentmode':
$in = commentmode($item, $var);
break;
case 'cases':
$in = cases($item, $var);
break;
case 'dateformats':
$in = dateformats($item, $var);
break;
case 'weeks':
$in = weeks($item, $var);
break;
case 'logging':
$in = logging($item, $var);
break;
case 'languages':
$in = languages($item, $var);
break;
case 'text':
$in = text($item, $var);
break;
case 'urlmodes':
$in = urlmodes($item, $var);
}
$out .= td($in);
$out .= $nohelp != 1 ? tda(popHelp($item), ' style="vertical-align:middle"') : td();
return tr($out);
}
示例7: base_url
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="1200">
<?php
}
?>
<meta property="og:url" content="<?php
echo base_url();
?>
">
<link rel="canonical" href="<?php
echo base_url();
?>
">
<?php
foreach (languages() as $lang) {
if ($lang['folder'] != current_lang('folder')) {
?>
<link rel="alternate" hreflang="<?php
echo $lang['code'];
?>
" href="<?php
echo site_url('process/lang/' . $lang['code'] . '?redirect=' . urlencode(current_url()));
?>
">
<?php
}
/* endif */
}
/* endforeach */
?>
示例8: edited
public function edited($field, $data, $object)
{
$fieldname = strval($field['name']);
$newtags = explode(',', $_POST[$fieldname]);
if (isset($field['translatable'])) {
$translated = array();
foreach (languages() as $lang => $langname) {
if (isset($_POST[$fieldname . '_' . $lang])) {
$translated[$lang] = explode(',', $_POST[$fieldname . '_' . $lang]);
}
}
}
if (isset($data->id)) {
foreach ($data->{$fieldname} as $tag) {
$index = array_search($tag->tag, $newtags);
if ($index !== false) {
if (isset($field['translatable'])) {
$to_update = array();
foreach (languages() as $lang => $langname) {
if ($lang != language()) {
$fieldn = 'tag_' . $lang;
if ($tag->{$fieldn} != trim($translated[$lang][$index])) {
$to_update[$fieldn] = trim($translated[$lang][$index]);
$to_update['slug_' . $lang] = strtolower(preg_replace('/\\s+/is', '-', trim(preg_replace('/[^a-z0-9\\s]/is', '', str_replace('-', ' ', remove_accents($to_update[$fieldn]))))));
}
unset($translated[$lang][$index]);
}
}
if (count($to_update)) {
where('id = %d', $tag->id)->update($object['stack'] . '>' . $field['name'], $to_update);
}
}
unset($newtags[$index]);
} else {
where(strval($object['name']) . ' = %d AND ' . strval($field['name']) . '_id = %d', $data->id, $tag->id)->delete($object['stack'] . '>' . $field['name'] . '>relation');
if (where(strval($field['name']) . '_id = %d', $tag->id)->get($object['stack'] . '>' . $field['name'] . '>relation')->count() == 0) {
where('id = %d', $tag->id)->delete($object['stack'] . '>' . $field['name']);
}
}
}
}
foreach ($newtags as $index => $tag) {
$existing = where('tag = %s', $tag)->get_row($object['stack'] . '>' . $fieldname);
if ($existing) {
$tag_id = $existing->id;
if (isset($field['translatable'])) {
$to_update = array();
foreach (languages() as $lang => $langname) {
if ($lang != language()) {
$fieldn = 'tag_' . $lang;
if ($existing->{$fieldn} != trim($translated[$lang][$index])) {
$to_update[$fieldn] = trim($translated[$lang][$index]);
$to_update['slug_' . $lang] = strtolower(preg_replace('/\\s+/is', '-', trim(preg_replace('/[^a-z0-9\\s]/is', '', str_replace('-', ' ', remove_accents($to_update[$fieldn]))))));
}
unset($translated[$lang][$index]);
}
}
if (count($to_update)) {
where('id = %d', $existing->id)->update($object['stack'] . '>' . $field['name'], $to_update);
}
}
} else {
$to_insert = array('tag' => $tag, 'slug' => strtolower(preg_replace('/\\s+/is', '-', trim(preg_replace('/[^a-z0-9\\s]/is', '', str_replace('-', ' ', remove_accents($tag)))))));
if (isset($field['translatable'])) {
foreach (languages() as $lang => $langname) {
if ($lang != language()) {
$to_insert['tag_' . $lang] = trim($translated[$lang][$index]);
$to_insert['slug_' . $lang] = strtolower(preg_replace('/\\s+/is', '-', trim(preg_replace('/[^a-z0-9\\s]/is', '', str_replace('-', ' ', remove_accents($to_insert['tag_' . $lang]))))));
}
}
}
$tag_id = insert($object['stack'] . '>' . $fieldname, $to_insert);
}
insert($object['stack'] . '>' . $fieldname . '>relation', array($fieldname . '_id' => $tag_id, strval($object['name']) => $data->id));
}
}
示例9: print_row
//.........這裏部分代碼省略.........
}
} else {
if ($subfield->getName() == "text") {
if (isset($row->{$name})) {
if ($subfield['summary'] == 'bool') {
if (trim($row->{$name})) {
?>
<img src="<?php
echo url(ADMINRESOURCES . 'images/tick.png');
?>
" class="bool" width="16" height="16"/>
<?php
} else {
?>
<img src="<?php
echo url(ADMINRESOURCES . 'images/cross.png');
?>
" class="bool" width="16" height="16"/>
<?php
}
} else {
echo excerpt($row->{$name}, 50);
}
}
} else {
if ($subfield->getName() == "slug") {
foreach ($field->children() as $child) {
$childname = strval($child['name']);
if (is_numeric($row->{$childname}) && isset($subfield['format_' . $child['name'] . '_' . $row->{$childname}])) {
if (!$name) {
$name = 'slug';
}
$i = 0;
foreach (languages() as $key => $lang) {
$childlang = $name . '_' . $key;
if ($i++ != 0) {
echo ' • ';
}
$link = url((count(languages()) > 1 ? $key . '/' : '') . str_replace('$slug', $row->{$childlang}, $subfield['format_' . $child['name'] . '_' . $row->{$childname}]), false);
if (count(languages()) > 1) {
echo '<a href="' . $link . '">' . strtoupper($key) . '</a>';
} else {
echo '<a href="' . $link . '">' . $link . '</a>';
}
}
$currentslug = str_replace('$slug', $row->{$name}, $subfield['format_' . $child['name'] . '_' . $row->{$childname}]) . '/';
}
}
} else {
if ($type = $typemanager->get_type(strval($subfield->getName()))) {
echo $type->summary($subfield, $row, $object);
} else {
echo htmlentities_all($row->{$name});
}
}
}
}
}
}
}
?>
</div></td>
<?php
}
?>
<?php
示例10: account
//.........這裏部分代碼省略.........
// set upload config
$this->uploads->allowedTypes = 'gif|jpg|png';
$this->uploads->uploadsPath .= '/avatars';
$this->uploads->maxSize = '100000';
$this->uploads->maxWidth = '2000';
$this->uploads->maxHeight = '2000';
// upload logo
if ($imageData = $this->uploads->upload_image(FALSE, NULL, 'logo')) {
$this->core->set['companyLogo'] = $imageData['file_name'];
}
// set error
$error = $this->uploads->errors ? 'Problem with your logo: ' . $this->uploads->errors : '';
}
// get image errors if there are any
if ($error) {
$this->form_validation->set_error($error);
} else {
// security check
if ($this->input->post('username')) {
$this->core->set['username'] = $data['username'];
}
if ($this->input->post('subscribed')) {
$this->core->set['subscribed'] = $data['subscribed'];
}
if ($this->input->post('siteID')) {
$this->core->set['siteID'] = $this->siteID;
}
if ($this->input->post('userID')) {
$this->core->set['userID'] = $data['userID'];
}
if ($this->input->post('resellerID')) {
$this->core->set['resellerID'] = $data['resellerID'];
}
if ($this->input->post('kudos')) {
$this->core->set['kudos'] = $data['kudos'];
}
if ($this->input->post('posts')) {
$this->core->set['posts'] = $data['posts'];
}
// update
if ($this->core->update('users', $objectID)) {
// get updated row
$row = $this->core->viewall('users', $objectID, NULL, 1);
// remove the password field
unset($row['users'][0]['password']);
// set session data
$this->session->set_userdata($row['users'][0]);
// update image data in session
if (isset($imageData)) {
$this->session->set_userdata('avatar', $imageData['file_name']);
}
// set success message
$this->session->set_flashdata('success', 'Your details have been updated.');
// redirect
if ($redirect) {
redirect('/users/' . $redirect);
} else {
redirect('/users/account');
}
}
}
}
// set title
$output['page:title'] = $this->site->config['siteName'] . ' - Account';
// load errors
$output['errors'] = validation_errors() ? validation_errors() : FALSE;
// if reverted show a message
if ($message = $this->session->flashdata('success')) {
$output['message'] = $message;
}
// populate template
$output['user:avatar'] = anchor('/users/profile/' . $data['userID'], display_image($this->users->get_avatar($data['avatar']), 'User Avatar', 150, 'class="bordered"', base_url() . $this->config->item('staticPath') . '/images/noavatar.gif'));
$output['user:logo'] = anchor('/users/profile/' . $data['userID'], display_image($this->users->get_avatar($data['companyLogo']), 'Company Logo', 150, 'class="bordered"'));
$output['form:email'] = set_value('email', $data['email']);
$output['form:displayName'] = set_value('displayName', $data['displayName']);
$output['form:firstName'] = set_value('firstName', $data['firstName']);
$output['form:lastName'] = set_value('lastName', $data['lastName']);
$output['form:bio'] = set_value('bio', $data['bio']);
$output['form:website'] = set_value('website', $data['website']);
$output['form:signature'] = set_value('signature', $data['signature']);
$output['form:companyName'] = set_value('companyName', $data['companyName']);
$output['form:companyEmail'] = set_value('companyEmail', $data['companyEmail']);
$output['form:companyWebsite'] = set_value('companyWebsite', $data['companyWebsite']);
$output['form:companyDescription'] = set_value('companyDescription', $data['companyDescription']);
$output['form:address1'] = set_value('address1', $data['address1']);
$output['form:address2'] = set_value('address2', $data['address2']);
$output['form:address3'] = set_value('address3', $data['address3']);
$output['form:city'] = set_value('city', $data['city']);
$output['form:postcode'] = set_value('postcode', $data['postcode']);
$output['form:phone'] = set_value('phone', $data['phone']);
$output['select:country'] = @display_countries('country', set_value('country', $data['country']), 'id="country" class="formelement"');
$values = array('V' => 'Everyone can see my profile', 'H' => 'Hide my profile and feed');
$output['select:privacy'] = @form_dropdown('privacy', $values, set_value('privacy', $data['privacy']), 'id="privacy" class="formelement"');
$values = array(0 => 'No', 1 => 'Yes');
$output['select:notifications'] = @form_dropdown('notifications', $values, set_value('notifications', $data['notifications']), 'id="notifications" class="formelement"');
$output['select:currency'] = @form_dropdown('currency', currencies(), set_value('currency', $data['currency']), 'id="currency" class="formelement"');
$output['select:language'] = @form_dropdown('language', languages(), set_value('language', $data['language']), 'id="language" class="formelement"');
// display with cms layer
$this->pages->view('community_account', $output, 'community');
}
示例11: reload_site
public static function reload_site()
{
$db = FW4_Db::get_instance();
$site = false;
if (!$site) {
try {
if (count(languages()) > 1) {
$query = from('site')->where('url LIKE %s', $_SERVER['HTTP_HOST'] . '%');
$language_codes = array_keys(languages());
if ($countries = Config::countries()) {
$language_codes = array_keys($countries);
}
foreach ($language_codes as $code) {
$query->or_where('`url_' . $code . '` LIKE %s', $_SERVER['HTTP_HOST'] . '%');
}
$site = $query->get_row();
} else {
$site = from('site')->where('url LIKE %s', $_SERVER['HTTP_HOST'] . '%')->get_row();
}
} catch (PDOException $exception) {
FW4_Structure::check_structure('', true);
}
if (!$site) {
if (!($site = get_row('site'))) {
$name = str_ireplace('www.', '', $_SERVER['HTTP_HOST']);
$name = ucfirst(substr($name, 0, strpos($name, '.')));
$url = $_SERVER['HTTP_HOST'];
if (stristr(getcwd(), 'httpdocs')) {
$url .= substr(getcwd(), stripos(getcwd(), 'httpdocs') + strlen('httpdocs'));
}
insert('site', array("url" => $url, "name" => $name));
FW4_Structure::check_structure();
$site = where('url LIKE %s', $_SERVER['HTTP_HOST'])->get_row('site');
} else {
$domain_handled = false;
// Process minisites
$types = FW4_Type_Manager::get_instance()->get_types();
foreach ($types as $typename => $type) {
if (method_exists($type, 'handle_domain')) {
if (!$site->structure_xml_expanded) {
FW4_Structure::check_structure("", true);
return self::reload_site();
}
$structure = new SimpleXMLElement($site->structure_xml_expanded);
$fields = $structure->xpath('//*[@type_name="' . $typename . '"]');
if (count($fields)) {
$prev = self::$current;
self::$current = $site;
if (call_user_func_array(array($type, 'handle_domain'), array($_SERVER['HTTP_HOST'], $fields))) {
$domain_handled = true;
break;
}
self::$current = $prev;
}
}
}
// Process subdomains
foreach (Config::subdomains() as $subdomain => $handler) {
//if () Router::set_content_prefix($handler);
}
if (!$domain_handled && $site->live) {
redirect((Config::https() ? 'https' : 'http') . '://' . $site->url . $_SERVER['REQUEST_URI']);
}
}
}
}
if (!$site->live && false === stristr($_SERVER['HTTP_HOST'], '.fw4.') && false === stristr($_SERVER['HTTP_HOST'], 'local')) {
$db->query("UPDATE site SET live = 1 WHERE id = " . $site->id);
if (stristr($site->url, '.fw4.be')) {
where('id = %d', $site->id)->update('site', array('url' => $_SERVER['HTTP_HOST']));
}
}
self::$current = $site;
return $site;
}
示例12: switchs
?>
</dt>
<dd><input type="text" name="site_name" value="<?php
echo switchs($_POST['site_name'], $config['site_name']);
?>
" class="border" style="width: 40%" /></dd>
</dl>
<dl class="input">
<dt>
<?php
echo lang('site_language');
?>
</dt>
<dd><?php
languages(true);
?>
</dd>
</dl>
<dl class="input">
<dt>
<?php
echo lang('site_theme');
?>
</dt>
<dd><?php
themes(true);
?>
</dd>
</dl>
示例13: list_languages
function list_languages($message = '')
{
global $prefs, $locale, $txpcfg, $textarray;
require_once txpath . '/lib/IXRClass.php';
// Select and save active language
if (!$message && ps('step') == 'list_languages' && ps('language')) {
$locale = doSlash(getlocale(ps('language')));
safe_update("txp_prefs", "val='" . doSlash(ps('language')) . "'", "name='language'");
safe_update("txp_prefs", "val='" . $locale . "'", "name='locale'");
$textarray = load_lang(doSlash(ps('language')));
$locale = setlocale(LC_ALL, $locale);
$message = gTxt('preferences_saved');
}
$active_lang = safe_field('val', 'txp_prefs', "name='language'");
$lang_form = tda(form(gTxt('active_language') . ' ' . languages('language', $active_lang) . ' ' . fInput('submit', 'Submit', gTxt('save_button'), '') . eInput('prefs') . sInput('list_languages'), 'display:inline;'), ' style="text-align:center" colspan="3"');
$client = new IXR_Client(RPC_SERVER);
#$client->debug = true;
$available_lang = array();
$rpc_connect = false;
$show_files = false;
# Get items from RPC
@set_time_limit(90);
if (gps('force') != 'file' && $client->query('tups.listLanguages', $prefs['blog_uid'])) {
$rpc_connect = true;
$response = $client->getResponse();
foreach ($response as $language) {
$available_lang[$language['language']]['rpc_lastmod'] = gmmktime($language['lastmodified']->hour, $language['lastmodified']->minute, $language['lastmodified']->second, $language['lastmodified']->month, $language['lastmodified']->day, $language['lastmodified']->year);
}
} elseif (gps('force') != 'file') {
$msg = gTxt('rpc_connect_error') . "<!--" . $client->getErrorCode() . ' ' . $client->getErrorMessage() . "-->";
}
# Get items from Filesystem
$files = get_lang_files();
if (gps('force') == 'file' || !$rpc_connect) {
$show_files = true;
}
if ($show_files && is_array($files) && !empty($files)) {
foreach ($files as $file) {
if ($fp = @fopen(txpath . DS . 'lang' . DS . $file, 'r')) {
$name = str_replace('.txt', '', $file);
$firstline = fgets($fp, 4069);
fclose($fp);
if (strpos($firstline, '#@version') !== false) {
@(list($fversion, $ftime) = explode(';', trim(substr($firstline, strpos($firstline, ' ', 1)))));
} else {
$fversion = $ftime = NULL;
}
$available_lang[$name]['file_note'] = isset($fversion) ? $fversion : 0;
$available_lang[$name]['file_lastmod'] = isset($ftime) ? $ftime : 0;
}
}
}
# Get installed items from the database
# I'm affraid we need a value here for the language itself, not for each one of the rows
$rows = safe_rows('lang, UNIX_TIMESTAMP(MAX(lastmod)) as lastmod', 'txp_lang', "1 GROUP BY lang ORDER BY lastmod DESC");
foreach ($rows as $language) {
$available_lang[$language['lang']]['db_lastmod'] = $language['lastmod'];
}
$list = '';
# Show the language table
foreach ($available_lang as $langname => $langdat) {
$file_updated = isset($langdat['db_lastmod']) && @$langdat['file_lastmod'] > $langdat['db_lastmod'];
$rpc_updated = @$langdat['rpc_lastmod'] > @$langdat['db_lastmod'];
$rpc_install = tda(strong(eLink('prefs', 'get_language', 'lang_code', $langname, isset($langdat['db_lastmod']) ? gTxt('update') : gTxt('install'), 'updating', isset($langdat['db_lastmod']))) . br . safe_strftime('%d %b %Y %X', @$langdat['rpc_lastmod']), isset($langdat['db_lastmod']) ? ' style="color:red;text-align:center;background-color:#FFFFCC;"' : ' style="color:#667;vertical-align:middle;text-align:center"');
$list .= tr(tda(gTxt($langname) . tag(isset($langdat['db_lastmod']) ? br . ' ' . safe_strftime('%d %b %Y %X', $langdat['db_lastmod']) : '', 'span', ' style="color:#aaa;font-style:italic"'), isset($langdat['db_lastmod']) && $rpc_updated ? ' nowrap="nowrap" style="color:red;background-color:#FFFFCC;"' : ' nowrap="nowrap" style="vertical-align:middle"') . n . ($rpc_updated ? $rpc_install : tda(isset($langdat['rpc_lastmod']) ? gTxt('updated') : '-', ' style="vertical-align:middle;text-align:center"')) . n . ($show_files ? tda(tag(isset($langdat['file_lastmod']) ? eLink('prefs', 'get_language', 'lang_code', $langname, $file_updated ? gTxt('update') : gTxt('install'), 'force', 'file') . br . ' ' . safe_strftime($prefs['archive_dateformat'], $langdat['file_lastmod']) : ' ', 'span', $file_updated ? ' style="color:#667;"' : ' style="color:#aaa;font-style:italic"'), ' class="langfile" style="text-align:center;vertical-align:middle"') . n : '')) . n . n;
}
// Output Table + Content
pagetop(gTxt('update_languages'), $message);
if (isset($msg) && $msg) {
echo tag($msg, 'p', ' style="text-align:center;color:red;width:50%;margin: 2em auto"');
}
echo startTable('list'), tr(tdcs(hed(gTxt('manage_languages'), 1), 3)), tr(tdcs(sLink('prefs', 'prefs_list', gTxt('site_prefs'), 'navlink') . sp . sLink('prefs', 'advanced_prefs', gTxt('advanced_preferences'), 'navlink') . sp . sLink('prefs', 'list_languages', gTxt('manage_languages'), 'navlink-active'), '3')), tr(tda(' ', ' colspan="3" style="font-size:0.25em"')), tr($lang_form), tr(tda(' ', ' colspan="3" style="font-size:0.25em"')), tr(tda(gTxt('language')) . tda(gTxt('from_server')) . ($show_files ? tda(gTxt('from_file')) : ''), ' style="font-weight:bold"');
echo $list;
if (!$show_files) {
$linktext = gTxt('from_file') . ' (' . gTxt('experts_only') . ')';
echo tr(tda(' ', ' colspan="3" style="font-size:0.25em"')) . tr(tda(strong(eLink('prefs', 'list_languages', 'force', 'file', $linktext)), ' colspan="3" style="text-align:center"'));
} elseif (gps('force') == 'file') {
echo tr(tda(' ', ' colspan="3" style="font-size:0.25em"')) . tr(tda(sLink('prefs', 'list_languages', strong(gTxt('from_server'))), ' colspan="3" style="text-align:center"'));
}
echo endTable();
$install_langfile = gTxt('install_langfile', array('{url}' => strong('<a href="' . RPC_SERVER . '/lang/">' . RPC_SERVER . '/lang/</a>')));
if ($install_langfile == 'install_langfile') {
$install_langfile = 'To install new languages from file you can download them from <b><a href="' . RPC_SERVER . '/lang/">' . RPC_SERVER . '/lang/</a></b> and place them inside your ./textpattern/lang/ directory.';
}
echo tag($install_langfile, 'p', ' style="text-align:center;width:50%;margin: 2em auto"');
}
示例14: insert
public function insert($objectname, $data)
{
if (!$this->structure) {
$this->structure = FW4_Structure::get_object_structure($this->objectname_prefix . $objectname);
}
if ($this->structure) {
$language_field = false;
$language = language();
$is_recursive = false;
// Translate data
foreach ($this->structure->children() as $child) {
if (in_array($child->getName(), array('string', 'text')) && isset($child['translatable']) && $child['translatable'] && $child['translatable'] != 'false') {
if (isset($data[strval($child['name'])])) {
$data[strval($child['name']) . '_' . language()] = $data[strval($child['name'])];
unset($data[strval($child['name'])]);
}
} else {
if ($child->getName() == 'slug') {
// Setup slugs
if (!isset($child['name'])) {
$child['name'] = 'slug';
}
if (!isset($data[strval($child['name'])])) {
$slugdata = array();
if (!isset($child['format']) && isset($child['source'])) {
$child['format'] = '[' . $child['source'] . ']';
}
preg_match_all('/\\[([a-z0-9\\_]+)\\]/is', strval($child['format']), $matches, PREG_SET_ORDER);
$name = strval($child['name']);
$translatable = $invalid = false;
$slug_fields = array();
foreach ($matches as $match) {
$source = false;
foreach ($this->structure->children() as $subchild) {
if (strval($subchild['name']) == $match[1]) {
$source = $subchild;
}
}
if ($source) {
$slug_fields[strval($source['name'])] = $source;
if (isset($source['translatable']) && $source['translatable']) {
$translatable = true;
}
} else {
$slug_fields[$match[1]] = false;
}
}
if ($translatable) {
foreach (languages() as $code => $lang) {
$slugdata[$name . '_' . $code] = strval($child['format']);
}
} else {
$slugdata[$name] = strval($child['format']);
}
foreach ($slug_fields as $slug_name => $slug_field) {
if ($translatable) {
foreach (languages() as $code => $lang) {
$slugnamecode = $slug_name . '_' . $code;
$namecode = $name . '_' . $code;
if (isset($data[$slugnamecode])) {
$slugdata[$name . '_' . $code] = str_ireplace('[' . $slug_name . ']', $data[$slugnamecode], $slugdata[$namecode]);
}
}
} else {
if (isset($data[$slug_name])) {
$slugdata[$name] = str_ireplace('[' . $slug_name . ']', $data[$slug_name], $slugdata[$name]);
} else {
unset($slugdata[$name]);
$invalid = true;
}
}
}
if ($invalid) {
continue;
}
if ($translatable) {
foreach (languages() as $code => $lang) {
$namecode = $name . '_' . $code;
$slugdata[$namecode] = strtolower(preg_replace('/\\s+/is', '-', trim(preg_replace('/[^a-z0-9\\s]/is', '', remove_accents($slugdata[$name . '_' . $code])))));
if (!isset($data[$namecode])) {
$data[$namecode] = $slugdata[$namecode];
}
}
unset($data[$name]);
} else {
$slugdata[$name] = strtolower(preg_replace('/\\s+/is', '-', trim(preg_replace('/[^a-z0-9\\s]/is', '', str_replace('-', ' ', remove_accents($slugdata[$name]))))));
if (!isset($data[$name])) {
$data[$name] = $slugdata[$name];
}
}
}
} else {
if ($child->getName() == 'language') {
$language_field = $child;
$language = 0;
} else {
if ($child->getName() == 'recursive') {
if (isset($data['parent_id']) && $data['parent_id']) {
$is_recursive = true;
}
//.........這裏部分代碼省略.........
示例15: print_field
//.........這裏部分代碼省略.........
if (isset($data->id)) {
$object = FW4_Structure::get_object_structure(strval($field['object']));
if (!$object) {
return false;
}
foreach ($field->attributes() as $key => $val) {
$object->addAttribute($key, $val);
}
$query = new Query();
if (isset($field['order_field'])) {
$query->order_by(strval($field['order_field']));
}
if (isset($field['where'])) {
foreach (explode(',', strval($field['where'])) as $item) {
$item = explode(':', $item);
$query->where($item[0] . ' = %s', $item[1]);
}
}
$allow_edit = true;
if (isset($field['allow_edit']) && ($field['allow_edit'] == 'false' || !$field['allow_edit'])) {
$allow_edit = false;
}
$rows = $query->load_children(true)->get(strval($field['object']));
self::print_object_list($object, $rows, count($rows), $data->id, true, $allow_edit);
}
return false;
case 'string':
case 'email':
if (isset($field['readonly']) && isset($data->id) || isset($structure['editing_disabled'])) {
echo '<div class="input"><label for="' . $field['name'] . '" class="for-input">' . $field['label'] . '</label><div class="value">' . (isset($data->{$fieldname}) && $data->{$fieldname} ? self::placeholder_decode($data->{$fieldname}, $field) : '-') . '</div></div>';
} else {
if (isset($field['translatable']) && $field['translatable']) {
echo '<div class="' . (FW4_Admin::$in_fieldset ? 'field' : 'input') . '"><label' . (isset($field['invalid']) && $field['invalid'] ? ' class="invalid"' : '') . '>' . $field['label'] . '</label> ';
foreach (languages() as $key => $lang) {
$fieldlang = $fieldname . '_' . $key;
echo '<div class="language"><input type="text" class="' . (count(languages()) > 1 ? 'with_lang_label lowmargin' : '') . (isset($field['required']) && $field['required'] ? ' required' : '') . '' . (isset($field['wide']) ? ' wide' : '') . '" name="' . $field['name'] . '_' . $key . '" value="' . htmlentities_all(isset($data->{$fieldlang}) ? $data->{$fieldlang} : '') . '" maxlength="' . (isset($field['length']) ? $field['length'] : 150) . '"' . (isset($field['visible_condition']) ? ' data-visible-condition="' . $field['visible_condition'] . '"' : '') . ' />' . (count(languages()) > 1 ? '<span class="lang_label">' . strtoupper($key) . '</span>' : '') . '</div>';
}
echo '<br/></div>';
} else {
echo '<div class="' . (FW4_Admin::$in_fieldset ? 'field' : 'input') . '"><label for="' . $field['name'] . '" class="for-input">' . $field['label'] . '</label> <input class="' . (isset($field['required']) && $field['required'] ? 'required' : '') . '' . (isset($field['wide']) ? ' wide' : '') . '" type="text" id="input-' . $field['name'] . '" name="' . $field['name'] . '" value="' . htmlspecialchars(isset($data->{$fieldname}) ? $data->{$fieldname} : '') . '" maxlength="' . (isset($field['length']) ? $field['length'] : 150) . '"' . (isset($field['visible_condition']) ? ' data-visible-condition="' . $field['visible_condition'] . '"' : '') . ' /></div>';
}
}
return true;
case 'number':
if (isset($field['readonly']) && $field['readonly'] || isset($structure['editing_disabled'])) {
if (isset($data->id)) {
echo '<div class="input"><label for="' . $field['name'] . '"' . (isset($field['invalid']) && $field['invalid'] ? ' class="invalid"' : '') . '>' . $field['label'] . '</label> <div class="value">' . (isset($data->{$fieldname}) ? $data->{$fieldname} : '') . '</div></div>';
}
} else {
echo '<div class="input"><label for="' . $field['name'] . '"' . (isset($field['invalid']) && $field['invalid'] ? ' class="invalid"' : '') . '>' . $field['label'] . '</label> <input class="number' . (isset($field['required']) && $field['required'] ? ' required' : '') . '" type="text" name="' . $field['name'] . '" value="' . (isset($data->{$fieldname}) ? $data->{$fieldname} : '') . '" maxlength="' . (isset($field['length']) ? $field['length'] : 20) . '" /></div>';
}
return true;
case 'float':
if (isset($field['readonly']) && $field['readonly'] || isset($structure['editing_disabled'])) {
if (isset($data->id)) {
echo '<div class="input"><label for="' . $field['name'] . '"' . (isset($field['invalid']) && $field['invalid'] ? ' class="invalid"' : '') . '>' . $field['label'] . '</label> <div class="value">' . (isset($data->{$fieldname}) ? trim(trim(number_format($data->{$fieldname}, 2, ',', '.'), '0'), ',') : '') . '</div></div>';
}
} else {
echo '<div class="input"><label for="' . $field['name'] . '"' . (isset($field['invalid']) && $field['invalid'] ? ' class="invalid"' : '') . '>' . $field['label'] . '</label> <input class="float' . (isset($field['required']) && $field['required'] ? ' required' : '') . '" type="text" name="' . $field['name'] . '" value="' . (isset($data->{$fieldname}) ? trim(trim(number_format($data->{$fieldname}, 2, ',', '.'), '0'), ',') : '') . '" maxlength="' . (isset($field['length']) ? $field['length'] : 20) . '" /></div>';
}
return true;
case 'password':
if (isset($field['readonly']) && isset($data->id) || isset($structure['editing_disabled'])) {
return false;
} else {
echo '<div class="input"><label for="' . $field['name'] . '"' . (isset($field['invalid']) && $field['invalid'] ? ' class="invalid"' : '') . '>' . $field['label'] . '</label> <input type="password"' . (isset($field['required']) && $field['required'] && !isset($data->id) ? ' class="required"' : '') . ' name="' . $field['name'] . '" maxlength="' . (isset($field['length']) ? $field['length'] : 150) . '" /></div>';