diff --git a/include/class.i18n.php b/include/class.i18n.php index 2aff09521ee3bd8ea61f717459bbe0f93d2da485..d5d524a9782d7d6ecd97d2e912937a5318476a0d 100644 --- a/include/class.i18n.php +++ b/include/class.i18n.php @@ -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; } diff --git a/include/class.page.php b/include/class.page.php index e843a15aad7a6cfeb311c6bd43bfc13afcfce90a..d4fd340a1708d0097e56ea910dec71fb41629e4e 100644 --- a/include/class.page.php +++ b/include/class.page.php @@ -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); diff --git a/include/staff/page.inc.php b/include/staff/page.inc.php index 301374b1a7872e8ddfb6f84e230ef2889b5bdfbf..35b5f2c50acfe5d6319cc14790887553e492baa7 100644 --- a/include/staff/page.inc.php +++ b/include/staff/page.inc.php @@ -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'); ?> <span class="error">* <?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"> - <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>: diff --git a/include/staff/pages.inc.php b/include/staff/pages.inc.php index 2dfc48676682923a9bb006c78d596787b4b32026..6fbd8af00f883083023792023ccb8f896dc6f848 100644 --- a/include/staff/pages.inc.php +++ b/include/staff/pages.inc.php @@ -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> <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> <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> <?php echo $page->isActive()?__('Active'):'<b>'.__('Disabled').'</b>'; ?> <?php echo $inuse?'<em>'.__('(in-use)').'</em>':''; ?>