[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [9634] move a local function from booking to api and
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [9634] move a local function from booking to api and move functions from outside the uicommon-class |
Date: |
Wed, 20 Jun 2012 11:35:09 +0000 |
Revision: 9634
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9634
Author: sigurdne
Date: 2012-06-20 11:35:09 +0000 (Wed, 20 Jun 2012)
Log Message:
-----------
move a local function from booking to api and move functions from outside the
uicommon-class
Modified Paths:
--------------
trunk/booking/inc/class.uicommon.inc.php
trunk/phpgwapi/inc/functions.inc.php
Added Paths:
-----------
trunk/booking/inc/functions.inc.php
Modified: trunk/booking/inc/class.uicommon.inc.php
===================================================================
--- trunk/booking/inc/class.uicommon.inc.php 2012-06-20 11:13:45 UTC (rev
9633)
+++ trunk/booking/inc/class.uicommon.inc.php 2012-06-20 11:35:09 UTC (rev
9634)
@@ -1,94 +1,7 @@
<?php
phpgw::import_class('phpgwapi.yui');
- /**
- * Cherry pick selected values into a new array
- *
- * @param array $array input array
- * @param array $keys array of keys to pick
- *
- * @return array containg values from $array for the keys in $keys.
- */
- function extract_values($array, $keys, $options = array())
- {
- static $default_options = array(
- 'prefix' => '',
- 'suffix' => '',
- 'preserve_prefix' => false,
- 'preserve_suffix' => false
- );
-
- $options = array_merge($default_options, $options);
-
- $result = array();
- foreach($keys as $write_key)
- {
- $array_key =
$options['prefix'].$write_key.$options['suffix'];
- if(isset($array[$array_key])) {
- $result[($options['preserve_prefix'] ?
$options['prefix'] : '').$write_key.($options['preserve_suffix'] ?
$options['suffix'] : '')] = $array[$array_key];
- }
- }
- return $result;
- }
- function array_set_default(&$array, $key, $value)
- {
- if(!isset($array[$key])) $array[$key] = $value;
- }
-
- /**
- * Reformat an ISO timestamp into norwegian format
- *
- * @param string $date date
- *
- * @return string containg timestamp in norwegian format
- */
- function pretty_timestamp($date)
- {
- if (empty($date)) return "";
-
- if(is_array($date) && is_object($date[0]) && $date[0]
instanceof DOMNode)
- {
- $date = $date[0]->nodeValue;
- }
- preg_match('/([0-9]{4})-([0-9]{2})-([0-9]{2})(
([0-9]{2}):([0-9]{2}))?/', $date, $match);
-
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- if($match[4])
- {
- $dateformat .= ' H:i';
- $timestamp = mktime($match[5], $match[6], 0, $match[2],
$match[3], $match[1]);
- }
- else
- {
- $timestamp = mktime(0, 0, 0, $match[2], $match[3],
$match[1]);
- }
- $text = date($dateformat,$timestamp);
-
- return $text;
- }
-
- /**
- * Generates a javascript translator object/hash for the specified
fields.
- */
- function js_lang()
- {
- $keys = func_get_args();
- $strings = array();
- foreach($keys as $key) { $strings[$key] = is_string($key) ?
lang($key) : call_user_func_array('lang', $key); }
- return json_encode($strings);
- }
-
- /**
- * Creates an array of translated strings.
- */
- function lang_array()
- {
- $keys = func_get_args();
- foreach($keys as &$key) $key = lang($key);
- return $keys;
- }
-
abstract class booking_uicommon
{
const UI_SESSION_FLASH = 'flash_msgs';
@@ -137,6 +50,17 @@
}
}
+
+ /**
+ * Creates an array of translated strings.
+ */
+ function lang_array()
+ {
+ $keys = func_get_args();
+ foreach($keys as &$key) $key = lang($key);
+ return $keys;
+ }
+
private function get_ui_session_key() {
return $this->ui_session_key;
}
@@ -348,9 +272,9 @@
$data['yui_booking_i18n'] = array(
'Calendar' => array(
- 'WEEKDAYS_SHORT' =>
json_encode(lang_array('Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa')),
- 'WEEKDAYS_FULL' =>
json_encode(lang_array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday',
'Friday', 'Saturday')),
- 'MONTHS_LONG' =>
json_encode(lang_array('January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December')),
+ 'WEEKDAYS_SHORT' =>
json_encode($this->lang_array('Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa')),
+ 'WEEKDAYS_FULL' =>
json_encode($this->lang_array('Sunday', 'Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday', 'Saturday')),
+ 'MONTHS_LONG' =>
json_encode($this->lang_array('January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September', 'October', 'November', 'December')),
),
'DataTable' => array(
'MSG_EMPTY' => json_encode(lang('No
records found.')),
Added: trunk/booking/inc/functions.inc.php
===================================================================
--- trunk/booking/inc/functions.inc.php (rev 0)
+++ trunk/booking/inc/functions.inc.php 2012-06-20 11:35:09 UTC (rev 9634)
@@ -0,0 +1,76 @@
+<?php
+ /**
+ * @package booking
+ * @subpackage utilities
+ * @version $Id: functions.inc.php 9188 2012-04-19 20:13:58Z sigurdne $
+ */
+
+ /**
+ * Cherry pick selected values into a new array
+ *
+ * @param array $array input array
+ * @param array $keys array of keys to pick
+ *
+ * @return array containg values from $array for the keys in $keys.
+ */
+ function extract_values($array, $keys, $options = array())
+ {
+ static $default_options = array(
+ 'prefix' => '',
+ 'suffix' => '',
+ 'preserve_prefix' => false,
+ 'preserve_suffix' => false
+ );
+
+ $options = array_merge($default_options, $options);
+
+ $result = array();
+ foreach($keys as $write_key)
+ {
+ $array_key =
$options['prefix'].$write_key.$options['suffix'];
+ if(isset($array[$array_key])) {
+ $result[($options['preserve_prefix'] ?
$options['prefix'] : '').$write_key.($options['preserve_suffix'] ?
$options['suffix'] : '')] = $array[$array_key];
+ }
+ }
+ return $result;
+ }
+
+ function array_set_default(&$array, $key, $value)
+ {
+ if(!isset($array[$key])) $array[$key] = $value;
+ }
+
+
+ /**
+ * Reformat an ISO timestamp into norwegian format
+ *
+ * @param string $date date
+ *
+ * @return string containg timestamp in norwegian format
+ */
+ function pretty_timestamp($date)
+ {
+ if (empty($date)) return "";
+
+ if(is_array($date) && is_object($date[0]) && $date[0]
instanceof DOMNode)
+ {
+ $date = $date[0]->nodeValue;
+ }
+ preg_match('/([0-9]{4})-([0-9]{2})-([0-9]{2})(
([0-9]{2}):([0-9]{2}))?/', $date, $match);
+
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ if($match[4])
+ {
+ $dateformat .= ' H:i';
+ $timestamp = mktime($match[5], $match[6], 0, $match[2],
$match[3], $match[1]);
+ }
+ else
+ {
+ $timestamp = mktime(0, 0, 0, $match[2], $match[3],
$match[1]);
+ }
+ $text = date($dateformat,$timestamp);
+
+ return $text;
+ }
+
+
Modified: trunk/phpgwapi/inc/functions.inc.php
===================================================================
--- trunk/phpgwapi/inc/functions.inc.php 2012-06-20 11:13:45 UTC (rev
9633)
+++ trunk/phpgwapi/inc/functions.inc.php 2012-06-20 11:35:09 UTC (rev
9634)
@@ -76,7 +76,7 @@
* Generates a javascript translator object/hash for the specified
fields.
*/
- /*
+
function js_lang()
{
$keys = func_get_args();
@@ -87,7 +87,7 @@
}
return json_encode($strings);
}
- */
+
/**
* cleans up a backtrace array and converts it to a string
@@ -828,7 +828,7 @@
* Load the app include files if the exists
*
\*************************************************************************/
/* Then the include file */
- if (! preg_match ("/phpgwapi/i", PHPGW_APP_INC) &&
file_exists(PHPGW_APP_INC . '/functions.inc.php') &&
!isset($GLOBALS['phpgw_info']['menuaction']))
+ if (! preg_match ("/phpgwapi/i", PHPGW_APP_INC) &&
file_exists(PHPGW_APP_INC . '/functions.inc.php') )
{
include_once(PHPGW_APP_INC . '/functions.inc.php');
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [9634] move a local function from booking to api and move functions from outside the uicommon-class,
Sigurd Nes <=