Skip to content
Snippets Groups Projects
Commit 4d8a41ab authored by Jared Hancock's avatar Jared Hancock
Browse files

i18n: pages: Use vertical tabs UI for translations

parent f0c24dfc
Branches
Tags
No related merge requests found
......@@ -259,14 +259,12 @@ class Internationalization {
if (!$cfg)
return self::availableLanguages();
$langs = array();
$pri = $cfg->getPrimaryLanguage();
$langs = array($pri => self::getLanguageInfo($pri));
// Honor sorting preference of ::availableLanguages()
foreach (self::availableLanguages() as $k=>$l) {
if ($cfg->getPrimaryLanguage() == $l['code']
|| in_array($l['code'], $cfg->getSecondaryLanguages())
) {
$langs[$k] = $l;
}
foreach ($cfg->getSecondaryLanguages() as $l) {
$langs[$l] = self::getLanguageInfo($l);
}
return $langs;
}
......
......@@ -52,7 +52,7 @@ class Page extends VerySimpleModel {
return $this->name;
}
function getLocalName($lang=false) {
return $this->_getLocal('name', $lang);
return $this->getLocal('name', $lang);
}
function getNameAsSlug() {
return urlencode(Format::slugify($this->name));
......@@ -198,7 +198,7 @@ class Page extends VerySimpleModel {
static function lookup($id, $lang=false) {
try {
$qs = self::objects()->filter(array('id'=>$id));
$qs = self::objects()->filter(is_array($id) ? $id : array('id'=>$id));
if ($lang)
$qs = $qs->filter(array('lang'=>$lang));
return $qs->one();
......@@ -277,7 +277,7 @@ class Page extends VerySimpleModel {
$rv = $this->saveTranslations($vars, $errors);
// Attach inline attachments from the editor
$page->attachments->deleteInlines();
$this->attachments->deleteInlines();
$this->attachments->upload(
Draft::getAttachmentIds($vars['body']), true);
......
......@@ -102,8 +102,10 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
<?php echo __('Status'); ?>:
</td>
<td>
<input type="radio" name="isactive" value="1" <?php echo $info['isactive']?'checked="checked"':''; ?>><strong><?php echo __('Active'); ?></strong>
<input type="radio" name="isactive" value="0" <?php echo !$info['isactive']?'checked="checked"':''; ?>><?php echo __('Disabled'); ?>
<input type="radio" name="isactive" value="1" <?php echo $info['isactive']?'checked="checked"':''; ?>>
<strong><?php echo __('Active'); ?></strong>
<input type="radio" name="isactive" value="0" <?php echo !$info['isactive']?'checked="checked"':''; ?>>
<?php echo __('Disabled'); ?>
&nbsp;<span class="error">*&nbsp;<?php echo $errors['isactive']; ?></span>
</td>
</tr>
......@@ -114,31 +116,28 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
<li><a href="#notes"><?php echo __('Internal Notes'); ?></a></li>
</ul>
<div class="tab_content active" id="content">
<?php if ($page && ($langs = $cfg->getSecondaryLanguages())) { ?>
<div class="banner">&nbsp;
<span class="pull-left">
<i class="icon-globe icon-large"></i>
<?php echo __('This content is translatable'); ?>
</span>
<span class="pull-right">
<?php echo __('View'); ?>:
<select onchange="javascript:
$('option', this).each(function(){$($(this).val()).hide()});
$($('option:selected', this).val()).show(); ">
<option value="#reference-text"><?php echo
Internationalization::getLanguageDescription($cfg->getPrimaryLanguage());
?><?php echo __('Primary'); ?></option>
<?php foreach ($langs as $tag) { ?>
<option value="#translation-<?php echo $tag; ?>"><?php echo
Internationalization::getLanguageDescription($tag);
?></option>
<?php } ?>
</select>
</span>
</div>
<div class="clear"></div>
<?php
$langs = Internationalization::getConfiguredSystemLanguages();
if ($page && count($langs) > 1) { ?>
<ul class="vertical left tabs">
<li class="empty"><i class="icon-globe" title="This content is translatable"></i></li>
<?php foreach ($langs as $tag=>$nfo) { ?>
<li class="<?php if ($tag == $cfg->getPrimaryLanguage()) echo "active";
?>"><a href="#translation-<?php echo $tag; ?>" title="<?php
echo Internationalization::getLanguageDescription($tag);
?>"><span class="flag flag-<?php echo strtolower($nfo['flag']); ?>"></span>
</a></li>
<?php } ?>
<div id="reference-text"
</ul>
<?php
} ?>
<div id="msg_info" style="margin:0 55px">
<em><i class="icon-info-sign"></i> <?php
echo __(
'Ticket variables are only supported in thank-you pages.'
); ?></em></div>
<div id="translation-<?php echo $cfg->getPrimaryLanguage(); ?>" class="tab_content" style="margin:0 45px"
lang="<?php echo $cfg->getPrimaryLanguage(); ?>">
<textarea name="body" cols="21" rows="12" style="width:98%;" class="richtext draft"
<?php
......@@ -147,8 +146,11 @@ $($('option:selected', this).val()).show(); ">
</div>
<?php if ($langs && $page) {
foreach ($langs as $tag) { ?>
<div id="translation-<?php echo $tag; ?>" style="display:none" lang="<?php echo $tag; ?>">
foreach ($langs as $tag=>$nfo) {
if ($tag == $cfg->getPrimaryLanguage())
continue; ?>
<div id="translation-<?php echo $tag; ?>" class="tab_content"
style="display:none;margin:0 45px" lang="<?php echo $tag; ?>">
<textarea name="trans[<?php echo $tag; ?>][body]" cols="21" rows="12"
style="width:98%;" class="richtext draft"
<?php
......@@ -158,11 +160,8 @@ $($('option:selected', this).val()).show(); ">
<?php }
} ?>
<div class="error" style="margin: 5px 0"><?php echo $errors['body']; ?></div>
<div id="msg_info"><em><i class="icon-info-sign"></i> <?php
echo __(
'Ticket variables are only supported in thank-you pages.'
); ?></em></div>
<div class="error" style="margin: 5px 55px"><?php echo $errors['body']; ?></div>
<div class="clear"></div>
</div>
<div class="tab_content" style="display:none" id="notes">
<em><strong><?php echo __('Internal Notes'); ?></strong>:
......
......@@ -63,8 +63,6 @@ else
<tbody>
<?php
$total=0;
print $pages->getQuery();
print $pages->count();
$ids=($errors && is_array($_POST['ids']))?$_POST['ids']:null;
$defaultPages=$cfg->getDefaultPages();
foreach ($pages as $page) {
......@@ -78,8 +76,8 @@ print $pages->count();
<input type="checkbox" class="ckb" name="ids[]" value="<?php echo $page->id; ?>"
<?php echo $sel?'checked="checked"':''; ?>>
</td>
<td>&nbsp;<a href="pages.php?id=<?php echo $page->id; ?>"><?php echo Format::htmlchars($page->getLocalName()); ?></a></td>
<td class="faded"><?php echo $row['type']; ?></td>
<td>&nbsp;<a href="pages.php?id=<?php echo $page->id; ?>"><?php echo Format::htmlchars($page->getLocalName() ?: $page->getName()); ?></a></td>
<td class="faded"><?php echo $page->type; ?></td>
<td>
&nbsp;<?php echo $page->isActive()?__('Active'):'<b>'.__('Disabled').'</b>'; ?>
&nbsp;&nbsp;<?php echo $inuse?'<em>'.__('(in-use)').'</em>':''; ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment