Permalink
Browse files

Merge branch 'master' of git@github.com:habari/system

  • Loading branch information...
2 parents 79f53b1 + 931c4aa commit 3371701f0dbb4ad297c96d77e8c706ae79d0e4be @MattRead MattRead committed Dec 7, 2011
View
2 admin/formcontrols/formcontrol_textarea.php
@@ -1,5 +1,5 @@
<?php if ( !defined( 'HABARI_PATH' ) ) { die('No direct access'); } ?>
-<div<?php echo( isset( $id ) ? " id=\"$id\"" : '' ); ?>>
+<div<?php echo isset( $class ) ? " class=\"$class\"" : ''; ?><?php echo( isset( $id ) ? " id=\"$id\"" : '' ); ?>>
<label<?php if ( isset( $label_title ) ) { ?> title="<?php echo $label_title; ?>"<?php $label_title = ''; } else { echo ( isset( $title ) ? " title=\"$title\"" : '' ); } ?> for="<?php echo $field; ?>">
<?php echo $this->caption; ?></label>
<textarea name="<?php echo $field; ?>" id="<?php echo $field; ?>"<?php echo ( isset( $class ) ? " class=\"$class\"" : '' ) .
View
18 admin/js/admin.js 100755 → 100644
@@ -1,4 +1,4 @@
-// Habari ajax. All Habari Ajax calls should go through here. It allows us to use uniform humanmsg stuff,
+// Habari ajax. All Habari Ajax calls should go through here. It allows us to use uniform humanmsg stuff,
// as well as uniform error handling
var habari_ajax = {
post: function(post_url, post_data, ahah_target, local_cb) {
@@ -56,11 +56,11 @@ var habari_ajax = {
msg = textStatus;
break;
default:
- msg = 'Uh Oh. An error has occurred. Please try again later.';
+ msg = _t('Uh Oh. An error has occurred. Please try again later.');
}
}
else {
- msg = 'Uh Oh. An error has occurred. Please try again later.';
+ msg = _t('Uh Oh. An error has occurred. Please try again later.');
}
spinner.stop();
human_msg.display_msg(msg);
@@ -288,7 +288,7 @@ var itemManage = {
$('.item.controls input[type=checkbox]').each(function() {
this.checked = 1;
});
- $('.item.controls label.selectedtext').removeClass('none').addClass('all').html('All ' + count + ' visible selected (<a href="#all" class="everything">Select all ' + total + '</a>)');
+ $('.item.controls label.selectedtext').removeClass('none').addClass('all').html(_t('All %1$s visible selected (<a href="#all" class="everything">Select all %2$s</a>)', count, total));
$('.item.controls label.selectedtext .everything').click(function() {
itemManage.checkEverything();
@@ -300,16 +300,16 @@ var itemManage = {
}
if ((total == count) || $('.currentposition .total').length === 0) {
- $('.item.controls label.selectedtext').removeClass('none').addClass('all').addClass('total').html('All ' + total + ' selected');
+ $('.item.controls label.selectedtext').removeClass('none').addClass('all').addClass('total').html(_t('All %s selected', total));
}
} else {
$('.item.controls input[type=checkbox]').each(function() {
this.checked = 0;
});
- $('.item.controls label.selectedtext').removeClass('none').removeClass('all').text(count + ' selected');
+ $('.item.controls label.selectedtext').removeClass('none').removeClass('all').text(_t('%s selected', count));
if (visible != count) {
- $('.item.controls label.selectedtext').text(count + ' selected (' + visible + ' visible)');
+ $('.item.controls label.selectedtext').text(_t('%1$s selected (%2$s visible)', count, visible));
}
}
},
@@ -521,7 +521,7 @@ var themeManage = {
window.onbeforeunload = function() {
if (themeManage.changed()) {
spinner.start(); spinner.stop();
- return 'You did not save the changes you made. \nLeaving this page will result in the lose of data.';
+ return _t('You did not save the changes you made. \nLeaving this page will result in the lose of data.');
}
};
},
@@ -875,7 +875,7 @@ var timeline = {
},
updateLoupeInfo: function() {
var loupeInfo = timeline.getLoupeInfo();
- $('.currentposition').html( loupeInfo.start +'-'+ loupeInfo.end +' of <span class="total inline">'+ timeline.totalCount + '</span>');
+ $('.currentposition').html( _t('%1$s-%2$s of <span class="total inline">%3$s</span>', loupeInfo.start, loupeInfo.end, timeline.totalCount));
// Hide 'newer' and 'older' links as necessary
if (loupeInfo.start == 1) {$('.navigator .older').animate({opacity: '0'}, 200);}
View
12 classes/habarilocale.php
@@ -319,6 +319,18 @@ public static function _t( $text, $args = array(), $domain = 'habari' )
}
/**
+ * Return the entire message catalog for a domain as an array
+ *
+ * @static
+ * @param string $domain (optional) The domain to return
+ * @return array The array of locale messages
+ */
+ public static function get_messages($domain = 'habari')
+ {
+ return self::$messages[$domain];
+ }
+
+ /**
* Given a string translated into the current locale, return the untranslated string.
*
* @param string $text The translated string
View
1 classes/rewriterules.php
@@ -57,6 +57,7 @@ public static function add_system_rules( $rules )
array( 'name' => 'display_tags', 'parse_regex' => '#^admin/(?P<page>tags)/?$#i', 'build_str' => 'admin/{$page}', 'handler' => 'AdminTagsHandler', 'action' => 'admin', 'priority' => 4, 'description' => 'Manage tags' ),
array( 'name' => 'display_logs', 'parse_regex' => '#^admin/(?P<page>logs)/?$#i', 'build_str' => 'admin/{$page}', 'handler' => 'AdminLogsHandler', 'action' => 'admin', 'priority' => 4, 'description' => 'Manage logs' ),
array( 'name' => 'display_import', 'parse_regex' => '#^admin/(?P<page>import)/?$#i', 'build_str' => 'admin/{$page}', 'handler' => 'AdminimportHandler', 'action' => 'admin', 'priority' => 4, 'description' => 'Manage importing content' ),
+ array( 'name' => 'get_locale', 'parse_regex' => '#^admin/(?P<page>locale)/?$#i', 'build_str' => 'admin/{$page}', 'handler' => 'AdminLocaleHandler', 'action' => 'admin', 'priority' => 4, 'description' => 'Fetch the locale data as javascript' ),
array( 'name' => 'admin', 'parse_regex' => '#^admin(?:/?$|/(?P<page>[^/]*))/?$#i', 'build_str' => 'admin/({$page})', 'handler' => 'AdminHandler', 'action' => 'admin', 'priority' => 6, 'description' => 'An admin action' ),
View
8 handlers/adminhandler.php
@@ -537,6 +537,9 @@ private function access_allowed( $page, $type )
case 'ajax_save_areas':
$result = true;
break;
+ case 'locale':
+ $result = true;
+ break;
default:
break;
}
@@ -593,8 +596,9 @@ public static function setup_stacks()
Stack::add( 'admin_header_javascript', Site::get_url( 'vendor' ) . "/jquery.ui.nestedSortable.js", 'jquery-nested-sortable', 'jquery.ui' );
Stack::add( 'admin_header_javascript', Site::get_url( 'vendor' ) . "/humanmsg/humanmsg.js", 'humanmsg', 'jquery' );
Stack::add( 'admin_header_javascript', Site::get_url( 'vendor' ) . "/jquery.hotkeys.js", 'jquery.hotkeys', 'jquery' );
- Stack::add( 'admin_header_javascript', Site::get_url( 'admin_theme' ) . "/js/media.js", 'media', 'jquery' );
- Stack::add( 'admin_header_javascript', Site::get_url( 'admin_theme' ) . "/js/admin.js", 'admin', 'jquery' );
+ Stack::add( 'admin_header_javascript', URL::get( 'admin', 'page=locale'), 'locale' );
+ Stack::add( 'admin_header_javascript', Site::get_url( 'admin_theme' ) . "/js/media.js", 'media', array('jquery', 'locale') );
+ Stack::add( 'admin_header_javascript', Site::get_url( 'admin_theme' ) . "/js/admin.js", 'admin', array('jquery', 'locale') );
Stack::add( 'admin_header_javascript', Site::get_url( 'vendor' ) . "/crc32.js", 'crc32' );
}
View
45 handlers/adminlocalehandler.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * @package Habari
+ *
+ */
+
+/**
+ * Habari AdminLocaleHandler Class
+ * Returns locale data as javascript for the admin
+ *
+ */
+class AdminLocaleHandler extends AdminHandler
+{
+ public function get_locale() {
+
+ header('Expires: ' . gmdate('D, d M Y H:i:s ', time() + 432000) . 'GMT');
+ header('content-type: text/javascript');
+
+ $domain = HabariLocale::get_messages();
+ $domain_json = json_encode($domain);
+
+ echo <<< tee
+function _t() {
+ var domain = {$domain_json};
+ var s = arguments[0];
+
+ if(domain[s] != undefined) {
+ s = domain[s][1][0];
+ }
+
+ for(var i = 1; i <= arguments.length; i++) {
+ r = new RegExp('%' + (i) + '\\\$s', 'g');
+ if(!s.match(r)) {
+ r = new RegExp('%s');
+ }
+ s = s.replace(r, arguments[i]);
+ }
+ return s;
+}
+
+tee;
+
+
+ }
+}
View
2 plugins/wpimport/wpimport.plugin.xml
@@ -9,4 +9,4 @@
<url>http://habariproject.org/</url>
<description><![CDATA[Import a Wordpress 2.3+ database.]]></description>
-</pluggable>
+</pluggable>

0 comments on commit 3371701

Please sign in to comment.