Initial commit

This commit is contained in:
Dan Cryer 2014-12-04 10:23:10 +00:00
parent 43fef1539f
commit 9ceb2841d8
5 changed files with 93 additions and 2 deletions

64
PHPCI/Helper/Lang.php Normal file
View file

@ -0,0 +1,64 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2014, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
namespace PHPCI\Helper;
use b8\Config;
use PHPCI\Model\User;
class Lang
{
protected static $language = null;
protected static $strings = array();
public static function get($string)
{
$vars = func_get_args();
if (array_key_exists($string, self::$strings)) {
$vars[0] = self::$strings[$string];
return call_user_func_array('sprintf', $vars);
}
return '%%MISSING STRING: ' . $string . '%%';
}
public static function getStrings()
{
return self::$strings;
}
public static function init(Config $config)
{
self::$language = $config->get('phpci.default_language', 'en');
self::$strings = self::loadLanguage();
if (is_null(self::$strings)) {
self::$language = 'en';
self::$strings = self::loadLanguage();
}
}
protected static function loadLanguage()
{
$langFile = PHPCI_DIR . 'PHPCI/Languages/lang.' . self::$language . '.php';
if (!file_exists($langFile)) {
return null;
}
require_once($langFile);
if (is_null($strings) || !is_array($strings) || !count($strings)) {
return null;
}
return $strings;
}
}

View file

@ -0,0 +1,14 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2014, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/
$strings = array(
'toggle_navigation' => 'Toggle Navigation',
'n_builds_pending' => '%d builds pending',
'n_builds_running' => '%d builds running',
);

View file

@ -1,3 +1,6 @@
<?php
use PHPCI\Helper\Lang;
?>
<!DOCTYPE html>
<html>
<head>
@ -18,6 +21,7 @@
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.js"></script>
<script src="<?php print PHPCI_URL; ?>assets/js/class.js"></script>
<script src="<?php print PHPCI_URL; ?>assets/js/sprintf.js"></script>
<script src="<?php print PHPCI_URL; ?>assets/js/phpci.js" type="text/javascript"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
@ -26,7 +30,10 @@
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>var PHPCI_URL = '<?php print PHPCI_URL; ?>';</script>
<script>
var PHPCI_URL = '<?php print PHPCI_URL; ?>';
var PHPCI_STRINGS = <?php print json_encode(Lang::getStrings()); ?>;
</script>
<style>
.skin-blue .logo, .skin-blue .logo:hover {
@ -87,7 +94,7 @@
<nav class="navbar navbar-static-top" role="navigation">
<!-- Sidebar toggle button-->
<a href="#" class="navbar-btn sidebar-toggle" data-toggle="offcanvas" role="button">
<span class="sr-only">Toggle navigation</span>
<span class="sr-only"><?php print Lang::get('toggle_navigation'); ?></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>

View file

@ -66,3 +66,5 @@ if (file_exists($configFile)) {
}
require_once(dirname(__FILE__) . '/vars.php');
\PHPCI\Helper\Lang::init($config);

View file

@ -0,0 +1,4 @@
/*! sprintf-js | Alexandru Marasteanu <hello@alexei.ro> (http://alexei.ro/) | BSD-3-Clause */
!function(a){function b(){var a=arguments[0],c=b.cache;return c[a]&&c.hasOwnProperty(a)||(c[a]=b.parse(a)),b.format.call(null,c[a],arguments)}function c(a){return Object.prototype.toString.call(a).slice(8,-1).toLowerCase()}function d(a,b){return Array(b+1).join(a)}var e={not_string:/[^s]/,number:/[dief]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fiosuxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/};b.format=function(a,f){var g,h,i,j,k,l,m,n=1,o=a.length,p="",q=[],r=!0,s="";for(h=0;o>h;h++)if(p=c(a[h]),"string"===p)q[q.length]=a[h];else if("array"===p){if(j=a[h],j[2])for(g=f[n],i=0;i<j[2].length;i++){if(!g.hasOwnProperty(j[2][i]))throw new Error(b("[sprintf] property '%s' does not exist",j[2][i]));g=g[j[2][i]]}else g=j[1]?f[j[1]]:f[n++];if("function"==c(g)&&(g=g()),e.not_string.test(j[8])&&"number"!=c(g)&&isNaN(g))throw new TypeError(b("[sprintf] expecting number but found %s",c(g)));switch(e.number.test(j[8])&&(r=g>=0),j[8]){case"b":g=g.toString(2);break;case"c":g=String.fromCharCode(g);break;case"d":case"i":g=parseInt(g,10);break;case"e":g=j[7]?g.toExponential(j[7]):g.toExponential();break;case"f":g=j[7]?parseFloat(g).toFixed(j[7]):parseFloat(g);break;case"o":g=g.toString(8);break;case"s":g=(g=String(g))&&j[7]?g.substring(0,j[7]):g;break;case"u":g>>>=0;break;case"x":g=g.toString(16);break;case"X":g=g.toString(16).toUpperCase()}!e.number.test(j[8])||r&&!j[3]?s="":(s=r?"+":"-",g=g.toString().replace(e.sign,"")),l=j[4]?"0"===j[4]?"0":j[4].charAt(1):" ",m=j[6]-(s+g).length,k=j[6]&&m>0?d(l,m):"",q[q.length]=j[5]?s+g+k:"0"===l?s+k+g:k+s+g}return q.join("")},b.cache={},b.parse=function(a){for(var b=a,c=[],d=[],f=0;b;){if(null!==(c=e.text.exec(b)))d[d.length]=c[0];else if(null!==(c=e.modulo.exec(b)))d[d.length]="%";else{if(null===(c=e.placeholder.exec(b)))throw new SyntaxError("[sprintf] unexpected placeholder");if(c[2]){f|=1;var g=[],h=c[2],i=[];if(null===(i=e.key.exec(h)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(g[g.length]=i[1];""!==(h=h.substring(i[0].length));)if(null!==(i=e.key_access.exec(h)))g[g.length]=i[1];else{if(null===(i=e.index_access.exec(h)))throw new SyntaxError("[sprintf] failed to parse named argument key");g[g.length]=i[1]}c[2]=g}else f|=2;if(3===f)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");d[d.length]=c}b=b.substring(c[0].length)}return d};var f=function(a,c,d){return d=(c||[]).slice(0),d.splice(0,0,a),b.apply(null,d)};"undefined"!=typeof exports?(exports.sprintf=b,exports.vsprintf=f):(a.sprintf=b,a.vsprintf=f,"function"==typeof define&&define.amd&&define(function(){return{sprintf:b,vsprintf:f}}))}("undefined"==typeof window?this:window);
//# sourceMappingURL=sprintf.min.map