Skip to content

Commit

Permalink
Merge pull request netPhotoGraphics#197 from sbillard/master
Browse files Browse the repository at this point in the history
11.6.2014
  • Loading branch information
sbillard committed Nov 6, 2014
2 parents 5309bc9 + f3b058d commit 5d252af
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 73 deletions.
4 changes: 2 additions & 2 deletions plugins/cacheHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
* any caching agent in the path.
*
* @author Stephen Billard (sbillard)
*
*
* @package plugins
* @subpackage example
* @category package
*/
$plugin_is_filter = 9 | ADMIN_PLUGIN | THEME_PLUGIN;
$plugin_description = gettext('Outputs a "Cache-control" header with selected caching options for all class-page pages.');
$plugin_description = gettext('Outputs a "Cache-control" header with selected caching options.');
$plugin_author = "Stephen Billard (sbillard)";
$option_interface = 'cacheHeader_options';

Expand Down
46 changes: 30 additions & 16 deletions zp-core/admin-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function printAdminFooter($addl = '') {
}

function datepickerJS() {
$lang = str_replace('_', '-', LOCALE_OPTION);
$lang = str_replace('_', '-', getOption('locale'));
if (!file_exists(SERVERPATH . '/' . ZENFOLDER . '/js/jqueryui/i18n/datepicker-' . $lang . '.js')) {
$lang = substr($lang, 0, 2);
if (!file_exists(SERVERPATH . '/' . ZENFOLDER . '/js/jqueryui/i18n/datepicker-' . $lang . '.js')) {
Expand Down Expand Up @@ -270,7 +270,7 @@ function printTabs() {
foreach ($zenphoto_tabs as $atab) {
$chars = $chars + mb_strlen($atab['text']);
}
switch (LOCALE_OPTION) {
switch (getOption('locale')) {
case 'zh_CN':
case 'zh_TW':
case 'ja_JP':
Expand Down Expand Up @@ -397,7 +397,7 @@ function printSubtabs() {
foreach ($tabs as $atab => $val) {
$chars = $chars + mb_strlen($atab);
}
switch (LOCALE_OPTION) {
switch (getOption('locale')) {
case 'zh_CN':
case 'zh_TW':
case 'ja_JP':
Expand Down Expand Up @@ -1442,7 +1442,7 @@ function printAlbumEditForm($index, $album, $buttons = true) {
name="disclose_password<?php echo $suffix; ?>"
id="disclose_password<?php echo $suffix; ?>"
onclick="passwordClear('<?php echo $suffix; ?>');
togglePassword('<?php echo $suffix; ?>');" /><?php echo addslashes(gettext('Show password')); ?>
togglePassword('<?php echo $suffix; ?>');" /><?php echo addslashes(gettext('Show password')); ?>
</label>
</td>
<td>
Expand Down Expand Up @@ -1929,7 +1929,7 @@ class="passignore<?php echo $suffix; ?> ignoredirty" autocomplete="off"
} else {
?>
onclick="toggleAlbumMCR('<?php echo $prefix; ?>', '');
deleteConfirm('Delete-<?php echo $prefix; ?>', '<?php echo $prefix; ?>', deleteAlbum1);"
deleteConfirm('Delete-<?php echo $prefix; ?>', '<?php echo $prefix; ?>', deleteAlbum1);"
<?php
}
?> />
Expand Down Expand Up @@ -4620,6 +4620,7 @@ function getPluginTabs() {

$classXlate = array(
'all' => gettext('all'),
'thirdparty' => gettext('3rd party'),
'enabled' => gettext('enabled'),
'admin' => gettext('admin'),
'demo' => gettext('demo'),
Expand All @@ -4635,20 +4636,27 @@ function getPluginTabs() {
);
zp_apply_filter('plugin_tabs', $classXlate);

$classes = $member = array();
$classes = $member = $thirdparty = array();
foreach ($paths as $plugin => $path) {
$p = file_get_contents($path);
$i = strpos($p, '* @subpackage');
if (($key = $i) !== false) {
$key = strtolower(trim(substr($p, $i + 13, strpos($p, "\n", $i) - $i - 13)));
}
if (empty($key)) {
$key = 'misc';
$key = 'misc';
if ($str = isolate('@subpackage', $p)) {
preg_match('|@subpackage\s+(.*)\s|', $str, $matches);
if (isset($matches[1])) {
$key = strtolower(trim($matches[1]));
}
}
$classes[$key]['list'][] = $plugin;

$classes[$key][] = $plugin;
if (extensionEnabled($plugin)) {
$active[$plugin] = $path;
}
if ($str = isolate('@category', $p)) {
preg_match('|@category\s+(.*)\s|', $str, $matches);
if (!isset($matches[1]) || $matches[1] != 'package')
$thirdparty[$plugin] = $path;
}

if (array_key_exists($key, $classXlate)) {
$local = $classXlate[$key];
} else {
Expand All @@ -4659,14 +4667,20 @@ function getPluginTabs() {

ksort($classes);
$tabs[$classXlate['all']] = 'admin-plugins.php?page=plugins&tab=all';
$tabs[$classXlate['enabled']] = 'admin-plugins.php?page=plugins&tab=active';
if (!empty($thirdparty))
$tabs[$classXlate['thirdparty']] = 'admin-plugins.php?page=plugins&tab=thirdparty';
if (!empty($active))
$tabs[$classXlate['enabled']] = 'admin-plugins.php?page=plugins&tab=active';
switch ($default) {
case 'all':
$currentlist = array_keys($paths);
break;
case 'active':
$currentlist = array_keys($active);
break;
case'thirdparty':
$currentlist = array_keys($thirdparty);
break;
default:
$currentlist = array();
break;
Expand All @@ -4676,7 +4690,7 @@ function getPluginTabs() {
foreach ($classes as $class => $list) {
$tabs[$classXlate[$class]] = 'admin-plugins.php?page=plugins&tab=' . $class;
if ($class == $default) {
$currentlist = $list['list'];
$currentlist = $list;
}
}
return array($tabs, $default, $currentlist, $paths, $member);
Expand Down Expand Up @@ -4996,7 +5010,7 @@ function linkPickerIcon($obj, $id = NULL, $extra = NULL) {
}
?>
<a onclick="<?php echo $clickid; ?>$('.pickedObject').removeClass('pickedObject');
$('#<?php echo $iconid; ?>').addClass('pickedObject');<?php linkPickerPick($obj, $id, $extra); ?>" title="<?php echo gettext('pick source'); ?>">
$('#<?php echo $iconid; ?>').addClass('pickedObject');<?php linkPickerPick($obj, $id, $extra); ?>" title="<?php echo gettext('pick source'); ?>">
<img src="<?php echo WEBPATH . '/' . ZENFOLDER; ?>/images/add.png" alt="" id="<?php echo $iconid; ?>">
</a>
<?php
Expand Down
2 changes: 1 addition & 1 deletion zp-core/class-feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function __construct($options) {
if (isset($this->options['lang'])) {
$this->locale = $this->options['lang'];
} else {
$this->locale = LOCALE_OPTION;
$this->locale = getOption('locale');
}
$this->locale_xml = strtr($this->locale, '_', '-');
if (isset($this->options['sortdir'])) {
Expand Down
2 changes: 1 addition & 1 deletion zp-core/functions-basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ function getAlbumInherited($folder, $field, &$id) {
$folders = explode('/', filesystemToInternal($folder));
$album = array_shift($folders);
$like = ' LIKE ' . db_quote(db_LIKE_escape($album));
while (count($folders) > 0) {
while (!empty($folders)) {
$album .= '/' . array_shift($folders);
$like .= ' OR `folder` LIKE ' . db_quote(db_LIKE_escape($album));
}
Expand Down
2 changes: 1 addition & 1 deletion zp-core/functions-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ function getSerializedArray($string) {
} else {
return array();
}
} else if (strlen($string) == 0 && !is_bool($string)) {
} else if (!$string && !is_bool($string)) {
return array();
} else {
return array($string);
Expand Down
61 changes: 30 additions & 31 deletions zp-core/functions-i18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @package core
*/
// force UTF-8 Ø
define('LOCALE_OPTION', getOption('locale'));

function getLanguageArray() {
return array(
Expand Down Expand Up @@ -300,12 +299,12 @@ function setupDomain($domain = NULL, $type = NULL) {
break;
}
bindtextdomain($domain, $domainpath);
// function only since php 4.2.0
// function only since php 4.2.0
if (function_exists('bind_textdomain_codeset')) {
bind_textdomain_codeset($domain, 'UTF-8');
}
textdomain($domain);
//invalidate because the locale was not setup until now
//invalidate because the locale was not setup until now
$_zp_active_languages = $_zp_all_languages = NULL;
}

Expand All @@ -318,20 +317,20 @@ function setupDomain($domain = NULL, $type = NULL) {
*/
function setupCurrentLocale($override = NULL) {
if (is_null($override)) {
$locale = LOCALE_OPTION;
$locale = getOption('locale');
} else {
$locale = $override;
}
if (getOption('disallow_' . $locale)) {
if (DEBUG_LOCALE)
debugLogBacktrace("setupCurrentLocale($override): $locale denied by option.");
$locale = LOCALE_OPTION;
$locale = getOption('locale');
if (empty($locale) || getOption('disallow_' . $locale)) {
$languages = generateLanguageList();
$locale = array_shift($languages);
}
}
// gettext setup
// gettext setup
@putenv("LANG=$locale"); // Windows ???
@putenv("LANGUAGE=$locale"); // Windows ???
$result = i18nSetLocale($locale);
Expand Down Expand Up @@ -361,37 +360,37 @@ function setupCurrentLocale($override = NULL) {
* @return array
*/
function parseHttpAcceptLanguage($str = NULL) {
// getting http instruction if not provided
// getting http instruction if not provided
if (!$str) {
$str = @$_SERVER['HTTP_ACCEPT_LANGUAGE'];
}
if (!is_string($str)) {
return array();
}
$langs = explode(',', $str);
// creating output list
// creating output list
$accepted = array();
foreach ($langs as $lang) {
// parsing language preference instructions
// 2_digit_code[-longer_code][;q=coefficient]
// parsing language preference instructions
// 2_digit_code[-longer_code][;q=coefficient]
if (preg_match('/([A-Za-z]{1,2})(-([A-Za-z0-9]+))?(;q=([0-9\.]+))?/', $lang, $found)) {
// 2 digit lang code
// 2 digit lang code
$code = $found[1];
// lang code complement
// lang code complement
$morecode = array_key_exists(3, $found) ? $found[3] : false;
// full lang code
// full lang code
$fullcode = $morecode ? $code . '_' . $morecode : $code;
// coefficient (preference value, will be used in sorting the list)
// coefficient (preference value, will be used in sorting the list)
$coef = sprintf('%3.1f', array_key_exists(5, $found) ? $found[5] : '1');
// for sorting by coefficient
// for sorting by coefficient
if ($coef) { // q=0 means do not supply this language
// adding
// adding
$accepted[$coef . '-' . $code] = array('code' => $code, 'coef' => $coef, 'morecode' => $morecode, 'fullcode' => $fullcode);
}
}
}

// sorting the list by coefficient desc
// sorting the list by coefficient desc
krsort($accepted);
if (DEBUG_LOCALE) {
debugLog("parseHttpAcceptLanguage($str)");
Expand Down Expand Up @@ -469,7 +468,7 @@ function getUserLocale() {
}

if (!$_zp_current_locale) {
$localeOption = LOCALE_OPTION;
$localeOption = getOption('locale');
$_zp_current_locale = zp_getCookie('dynamic_locale');

if (DEBUG_LOCALE)
Expand All @@ -491,7 +490,7 @@ function getUserLocale() {
}

if (empty($_zp_current_locale)) {
// return "default" language, English if allowed, otherwise whatever is the "first" allowed language
// return "default" language, English if allowed, otherwise whatever is the "first" allowed language
$languageSupport = generateLanguageList();
if (empty($languageSupport) || in_array('en_US', $languageSupport)) {
$_zp_current_locale = 'en_US';
Expand Down Expand Up @@ -519,16 +518,16 @@ function getUserLocale() {
*/
function get_language_string($dbstring, $locale = NULL) {
$strings = getSerializedArray($dbstring);
if (is_null($locale))
$locale = LOCALE_OPTION;
if (isset($strings[$locale])) {
return $strings[$locale];
}
if (isset($strings[LOCALE_OPTION])) {
return $strings[LOCALE_OPTION];
}
if (isset($strings['en_US'])) {
return $strings['en_US'];
if (count($strings) > 1) {
if (!empty($locale) && isset($strings[$locale])) {
return $strings[$locale];
}
if (isset($strings[$locale = getOption('locale')])) {
return $strings[$locale];
}
if (isset($strings['en_US'])) {
return $strings['en_US'];
}
}
return array_shift($strings);
}
Expand All @@ -553,10 +552,10 @@ function getTimezones() {
}
}
}
// Only keep one city (the first and also most important) for each set of possibilities.
// Only keep one city (the first and also most important) for each set of possibilities.
$cities = array_unique($cities);

// Sort by area/city name.
// Sort by area/city name.
ksort($cities, SORT_LOCALE_STRING);
}
return $cities;
Expand Down
8 changes: 4 additions & 4 deletions zp-core/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
* */
function parseAllowedTags(&$source) {
$source = trim($source);
if (substr($source, 0, 1) != "(") {
if (@$source{0} != "(") {
return false;
}
$source = substr($source, 1); //strip off the open paren
$a = array();
while ((strlen($source) > 1) && (substr($source, 0, 1) != ")")) {
while (strlen($source) > 1 && $source{0} != ")") {
$i = strpos($source, '=>');
if ($i === false) {
return false;
Expand All @@ -69,7 +69,7 @@ function parseAllowedTags(&$source) {
return 0;
}
$source = trim(substr($source, $i + 2));
if (substr($source, 0, 1) != "(") {
if (@$source{0} != "(") {
return false;
}
$x = parseAllowedTags($source);
Expand All @@ -78,7 +78,7 @@ function parseAllowedTags(&$source) {
}
$a[$tag] = $x;
}
if (substr($source, 0, 1) != ')') {
if (@$source{0} != ')') {
return false;
}
$source = trim(substr($source, 1)); //strip the close paren
Expand Down
2 changes: 1 addition & 1 deletion zp-core/githead
Original file line number Diff line number Diff line change
@@ -1 +1 @@
943237af7b227bcb3ffed8985b51dba83d99a485
92b99be0f0c004c9f38ec172c43a0e393dd1b0e8
Loading

0 comments on commit 5d252af

Please sign in to comment.