Speedups for HTML interface by only creating the HUBBROWSE object on

demand instead of on every single page load - this object took the
longest to create.  Started to convert code to PHP5 using
public/private/protected/static and __construct() method, got rid
of =& when constructing objects.  Fixed a number of functions that were
marked as private that were actually public.  Fixed names of a couple
functions to be more readable.  Commented out functions that are no
longer in use.
This commit is contained in:
paul 2006-11-14 18:43:57 +00:00
parent bd70c879bc
commit bed878246d
28 changed files with 812 additions and 776 deletions

View file

@ -72,7 +72,7 @@ if (isset($_REQUEST['popup']) && is_array($_REQUEST['popup'])){
$Smarty->assign('filecount', count($_REQUEST['id'])); $Smarty->assign('filecount', count($_REQUEST['id']));
$Smarty->assign('idstr', $idstr); $Smarty->assign('idstr', $idstr);
} else { } else {
$Smarty->assign('filename', $uiBrowser->_getMDataValue($_REQUEST['id'], UI_MDATA_KEY_TITLE)); $Smarty->assign('filename', $uiBrowser->getMetadataValue($_REQUEST['id'], UI_MDATA_KEY_TITLE));
} }
$Smarty->display('popup/deleteItem.tpl'); $Smarty->display('popup/deleteItem.tpl');
break; break;
@ -140,7 +140,7 @@ if (isset($_REQUEST['popup']) && is_array($_REQUEST['popup'])){
break; break;
case "SCHEDULER.removeItem": case "SCHEDULER.removeItem":
$Smarty->assign('playlistName', $uiBrowser->_getMDataValue($_REQUEST['playlistId'], UI_MDATA_KEY_TITLE)); $Smarty->assign('playlistName', $uiBrowser->getMetadataValue($_REQUEST['playlistId'], UI_MDATA_KEY_TITLE));
$Smarty->display('popup/SCHEDULER.removeItem.tpl'); $Smarty->display('popup/SCHEDULER.removeItem.tpl');
break; break;
@ -214,19 +214,21 @@ if (isset($_REQUEST['popup']) && is_array($_REQUEST['popup'])){
break; break;
case 'HUBBROWSE.getResults': case 'HUBBROWSE.getResults':
$HUBBROWSE = new uiHubBrowse($uiBrowser);
if (isset($_REQUEST['trtokid'])) { if (isset($_REQUEST['trtokid'])) {
$Smarty->assign('trtokid',$_REQUEST['trtokid']); $Smarty->assign('trtokid', $_REQUEST['trtokid']);
if ($uiBrowser->HUBBROWSE->getSearchResults($_REQUEST['trtokid'])) { if ($HUBBROWSE->getSearchResults($_REQUEST['trtokid'])) {
$Smarty->assign('results',true); $Smarty->assign('results', true);
} else { } else {
$Smarty->assign('results',false); $Smarty->assign('results', false);
} }
} else { } else {
$Smarty->assign('trtokid',$uiBrowser->HUBBROWSE->searchDB()); $Smarty->assign('trtokid', $HUBBROWSE->searchDB());
$Smarty->assign('results',false); $Smarty->assign('results', false);
} }
$Smarty->assign('polling_frequency',UI_HUB_POLLING_FREQUENCY); $Smarty->assign('polling_frequency', UI_HUB_POLLING_FREQUENCY);
$Smarty->assign('_prefix','HUBBROWSE'); $Smarty->assign('_prefix', 'HUBBROWSE');
$Smarty->display('popup/HUB.getResults.tpl'); $Smarty->display('popup/HUB.getResults.tpl');
break; break;
@ -320,7 +322,8 @@ if ($uiBrowser->userid) {
break; break;
case "HUBBROWSE": case "HUBBROWSE":
$Smarty->assign('hubBrowseForm', $uiBrowser->HUBBROWSE->browseForm($uiBrowser->id, $ui_fmask)); $HUBBROWSE = new uiHubBrowse($uiBrowser);
$Smarty->assign('hubBrowseForm', $HUBBROWSE->browseForm($uiBrowser->id, $ui_fmask));
$Smarty->assign('showLibrary', TRUE); $Smarty->assign('showLibrary', TRUE);
$Smarty->assign('isHub', TRUE); $Smarty->assign('isHub', TRUE);
break; break;
@ -341,7 +344,7 @@ if ($uiBrowser->userid) {
break; break;
case "_analyzeFile": case "_analyzeFile":
$Smarty->assign('_analyzeFile', $uiBrowser->_analyzeFile($uiBrowser->id, 'text')); $Smarty->assign('_analyzeFile', $uiBrowser->analyzeFile($uiBrowser->id, 'text'));
$Smarty->assign('showFile', TRUE); $Smarty->assign('showFile', TRUE);
break; break;

View file

@ -1,6 +1,10 @@
<?php <?php
require(dirname(__FILE__).'/../ui_handler_init.php'); require(dirname(__FILE__).'/../ui_handler_init.php');
if (strstr($_REQUEST['act'], "HUBBROWSE")) {
$HUBBROWSE = new uiHubBrowse($uiHandler);
}
switch ($_REQUEST['act']) { switch ($_REQUEST['act']) {
case "login": case "login":
@ -167,31 +171,31 @@ switch ($_REQUEST['act']) {
break; break;
case "HUBBROWSE.setCategory": case "HUBBROWSE.setCategory":
$uiHandler->HUBBROWSE->setCategory($_REQUEST); $HUBBROWSE->setCategory($_REQUEST);
break; break;
case "HUBBROWSE.setValue": case "HUBBROWSE.setValue":
$uiHandler->HUBBROWSE->setValue($_REQUEST); $HUBBROWSE->setValue($_REQUEST);
break; break;
case "HUBBROWSE.reOrder": case "HUBBROWSE.reOrder":
$uiHandler->HUBBROWSE->reOrder($_REQUEST['by']); $HUBBROWSE->reOrder($_REQUEST['by']);
break; break;
case "HUBBROWSE.setDefaults": case "HUBBROWSE.setDefaults":
$uiHandler->HUBBROWSE->setDefaults(TRUE); $HUBBROWSE->setDefaults(TRUE);
break; break;
case "HUBBROWSE.setOffset": case "HUBBROWSE.setOffset":
$uiHandler->HUBBROWSE->setOffset($_REQUEST['page']); $HUBBROWSE->setOffset($_REQUEST['page']);
break; break;
case "HUBBROWSE.setLimit": case "HUBBROWSE.setLimit":
$uiHandler->HUBBROWSE->setLimit($_REQUEST['limit']); $HUBBROWSE->setLimit($_REQUEST['limit']);
break; break;
case "HUBBROWSE.setFiletype": case "HUBBROWSE.setFiletype":
$uiHandler->HUBBROWSE->setFiletype($_REQUEST['filetype']); $HUBBROWSE->setFiletype($_REQUEST['filetype']);
break; break;
case "HUBSEARCH.newSearch": case "HUBSEARCH.newSearch":

View file

@ -5,7 +5,7 @@
* be fast (it gets loaded for every hit to the admin screen), we put it * be fast (it gets loaded for every hit to the admin screen), we put it
* all in one file. * all in one file.
*/ */
/** /**
* Includes * Includes
*/ */
@ -24,11 +24,11 @@ require_once dirname(__FILE__).'/LanguageMetadata.php';
* *
* @return void * @return void
*/ */
function putGS($p_translateString) function putGS($p_translateString)
{ {
$args = func_get_args(); $args = func_get_args();
echo call_user_func_array('getGS', $args); echo call_user_func_array('getGS', $args);
} // fn putGS } // fn putGS
/** /**
@ -40,7 +40,7 @@ function putGS($p_translateString)
* *
* @return string * @return string
*/ */
function getGS($p_translateString) function getGS($p_translateString)
{ {
global $g_translationStrings, $TOL_Language; global $g_translationStrings, $TOL_Language;
$numFunctionArgs = func_num_args(); $numFunctionArgs = func_num_args();
@ -68,7 +68,7 @@ function getGS($p_translateString)
* @param string $p_key * @param string $p_key
* @return void * @return void
*/ */
function regGS($p_key, $p_value) function regGS($p_key, $p_value)
{ {
global $g_translationStrings; global $g_translationStrings;
if (isset($g_translationStrings[$p_key])) { if (isset($g_translationStrings[$p_key])) {
@ -87,7 +87,7 @@ function regGS($p_key, $p_value)
/** /**
* The Localizer class handles groups of translation tables (LocalizerLanguages). * The Localizer class handles groups of translation tables (LocalizerLanguages).
* This class simply acts as a namespace for a group of static methods. * This class simply acts as a namespace for a group of static methods.
* @package Campware * @package Campware
*/ */
class Localizer { class Localizer {
@ -100,13 +100,13 @@ class Localizer {
* @return mixed * @return mixed
* Will return 'gs' or 'xml' on success, or NULL on failure. * Will return 'gs' or 'xml' on success, or NULL on failure.
*/ */
function GetMode() function GetMode()
{ {
global $g_localizerConfig; global $g_localizerConfig;
if ($g_localizerConfig['DEFAULT_FILE_TYPE'] != '') { if ($g_localizerConfig['DEFAULT_FILE_TYPE'] != '') {
return $g_localizerConfig['DEFAULT_FILE_TYPE']; return $g_localizerConfig['DEFAULT_FILE_TYPE'];
} }
$defaultLang =& new LocalizerLanguage('globals', $defaultLang = new LocalizerLanguage('globals',
$g_localizerConfig['DEFAULT_LANGUAGE']); $g_localizerConfig['DEFAULT_LANGUAGE']);
if ($defaultLang->loadGsFile()) { if ($defaultLang->loadGsFile()) {
return 'gs'; return 'gs';
@ -118,8 +118,8 @@ class Localizer {
return null; return null;
} }
} // fn GetMode } // fn GetMode
/** /**
* Load the translation strings into a global variable and return them. * Load the translation strings into a global variable and return them.
* *
@ -132,29 +132,29 @@ class Localizer {
* *
* @return void * @return void
*/ */
function LoadLanguageFiles($p_prefix, $p_languageCode = null, $p_return = false) function LoadLanguageFiles($p_prefix, $p_languageCode = null, $p_return = false)
{ {
global $g_localizerConfig; global $g_localizerConfig;
if ($p_return) { if ($p_return) {
static $g_translationStrings; static $g_translationStrings;
} else { } else {
global $g_translationStrings; global $g_translationStrings;
} }
if (is_null($p_languageCode)){ if (is_null($p_languageCode)){
$p_languageCode = $g_localizerConfig['DEFAULT_LANGUAGE']; $p_languageCode = $g_localizerConfig['DEFAULT_LANGUAGE'];
} }
if (!isset($g_translationStrings)) { if (!isset($g_translationStrings)) {
$g_translationStrings = array(); $g_translationStrings = array();
} }
$key = $p_prefix."_".$g_localizerConfig['DEFAULT_LANGUAGE']; $key = $p_prefix."_".$g_localizerConfig['DEFAULT_LANGUAGE'];
if (!isset($g_localizerConfig['LOADED_FILES'][$key])) { if (!isset($g_localizerConfig['LOADED_FILES'][$key])) {
$defaultLang =& new LocalizerLanguage($p_prefix, $g_localizerConfig['DEFAULT_LANGUAGE']); $defaultLang = new LocalizerLanguage($p_prefix, $g_localizerConfig['DEFAULT_LANGUAGE']);
$defaultLang->loadFile(Localizer::GetMode()); $defaultLang->loadFile(Localizer::GetMode());
$defaultLangStrings = $defaultLang->getTranslationTable(); $defaultLangStrings = $defaultLang->getTranslationTable();
// Merge default language strings into the translation array. // Merge default language strings into the translation array.
#$g_translationStrings = array_merge($g_translationStrings, $defaultLangStrings); #$g_translationStrings = array_merge($g_translationStrings, $defaultLangStrings);
$g_translationStrings = Localizer::_arrayValuesMerge($g_translationStrings, $defaultLangStrings); $g_translationStrings = Localizer::_arrayValuesMerge($g_translationStrings, $defaultLangStrings);
@ -162,31 +162,31 @@ class Localizer {
} }
$key = $p_prefix."_".$p_languageCode; $key = $p_prefix."_".$p_languageCode;
if (!isset($g_localizerConfig['LOADED_FILES'][$key])) { if (!isset($g_localizerConfig['LOADED_FILES'][$key])) {
$userLang =& new LocalizerLanguage($p_prefix, $p_languageCode); $userLang = new LocalizerLanguage($p_prefix, $p_languageCode);
$userLang->loadFile(Localizer::GetMode()); $userLang->loadFile(Localizer::GetMode());
$userLangStrings = $userLang->getTranslationTable(); $userLangStrings = $userLang->getTranslationTable();
// Merge user strings into translation array. // Merge user strings into translation array.
#$g_translationStrings = array_merge($g_translationStrings, $userLangStrings); #$g_translationStrings = array_merge($g_translationStrings, $userLangStrings);
$g_translationStrings = Localizer::_arrayValuesMerge($g_translationStrings, $userLangStrings); $g_translationStrings = Localizer::_arrayValuesMerge($g_translationStrings, $userLangStrings);
$g_localizerConfig['LOADED_FILES'][$key] = true; $g_localizerConfig['LOADED_FILES'][$key] = true;
} }
if ($p_return) { if ($p_return) {
return $g_translationStrings; return $g_translationStrings;
} }
} // fn LoadLanguageFiles } // fn LoadLanguageFiles
function _arrayValuesMerge($arr1, $arr2) function _arrayValuesMerge($arr1, $arr2)
{ {
foreach ($arr2 as $k=>$v) { foreach ($arr2 as $k=>$v) {
if (strlen($v)) { if (strlen($v)) {
$arr1[$k] = $v; $arr1[$k] = $v;
} }
} }
return $arr1; return $arr1;
} }
/** /**
* Compare a particular language's keys with the default language set. * Compare a particular language's keys with the default language set.
* *
@ -202,13 +202,13 @@ class Localizer {
* *
* @return array * @return array
*/ */
function CompareKeys($p_prefix, $p_data, $p_findExistingKeys = true) function CompareKeys($p_prefix, $p_data, $p_findExistingKeys = true)
{ {
global $g_localizerConfig; global $g_localizerConfig;
$localData =& new LocalizerLanguage($p_prefix, $localData = new LocalizerLanguage($p_prefix,
$g_localizerConfig['DEFAULT_LANGUAGE']); $g_localizerConfig['DEFAULT_LANGUAGE']);
$localData->loadFile(Localizer::GetMode()); $localData->loadFile(Localizer::GetMode());
$globaldata =& new LocalizerLanguage($g_localizerConfig['FILENAME_PREFIX_GLOBAL'], $globaldata = new LocalizerLanguage($g_localizerConfig['FILENAME_PREFIX_GLOBAL'],
$g_localizerConfig['DEFAULT_LANGUAGE']); $g_localizerConfig['DEFAULT_LANGUAGE']);
$globaldata->loadFile(Localizer::GetMode()); $globaldata->loadFile(Localizer::GetMode());
@ -227,58 +227,58 @@ class Localizer {
return $returnValue; return $returnValue;
} // fn CompareKeys } // fn CompareKeys
/** /**
* Search through PHP files and find all the strings that need to be translated. * Search through PHP files and find all the strings that need to be translated.
* @param string $p_directory - * @param string $p_directory -
* @return array * @return array
*/ */
function FindTranslationStrings($p_prefix, $p_depth=0) function FindTranslationStrings($p_prefix, $p_depth=0)
{ {
global $g_localizerConfig; global $g_localizerConfig;
//Start search here //Start search here
$dir = $g_localizerConfig["mapPrefixToDir"][$p_prefix]['path']; $dir = $g_localizerConfig["mapPrefixToDir"][$p_prefix]['path'];
$depth = $g_localizerConfig["mapPrefixToDir"][$p_prefix]['depth']; $depth = $g_localizerConfig["mapPrefixToDir"][$p_prefix]['depth'];
// Scan which files // Scan which files
$filePatterns = $g_localizerConfig['mapPrefixToDir'][$p_prefix]['filePatterns']; $filePatterns = $g_localizerConfig['mapPrefixToDir'][$p_prefix]['filePatterns'];
$execludePattern = $g_localizerConfig['mapPrefixToDir'][$p_prefix]['execlPattern']; $execludePattern = $g_localizerConfig['mapPrefixToDir'][$p_prefix]['execlPattern'];
if ($g_localizerConfig['DEBUG']) echo "<br>Scan files match ".print_r($filePatterns, 1); if ($g_localizerConfig['DEBUG']) echo "<br>Scan files match ".print_r($filePatterns, 1);
// Scan for what // Scan for what
$funcPatterns = $g_localizerConfig['mapPrefixToDir'][$p_prefix]['funcPatterns']; $funcPatterns = $g_localizerConfig['mapPrefixToDir'][$p_prefix]['funcPatterns'];
if ($g_localizerConfig['DEBUG']) echo "<br>Scan for ".print_r($funcPatterns, 1); if ($g_localizerConfig['DEBUG']) echo "<br>Scan for ".print_r($funcPatterns, 1);
// Get all files in this directory // Get all files in this directory
if ($g_localizerConfig['DEBUG']) echo "<br>Search in: {$g_localizerConfig['BASE_DIR']}$dir Depth: {$depth}"; if ($g_localizerConfig['DEBUG']) echo "<br>Search in: {$g_localizerConfig['BASE_DIR']}$dir Depth: {$depth}";
$files = File_Find::mapTreeMultiple($g_localizerConfig['BASE_DIR'].$dir, $depth); $files = File_Find::mapTreeMultiple($g_localizerConfig['BASE_DIR'].$dir, $depth);
$files = Localizer::_flatFileList($files); $files = Localizer::_flatFileList($files);
#print_r($files); #print_r($files);
// Get all the Matching files // Get all the Matching files
foreach ($filePatterns as $fp) { foreach ($filePatterns as $fp) {
foreach ($files as $name) { foreach ($files as $name) {
if (preg_match($fp, $name) && !preg_match($execludePattern, $name)) { if (preg_match($fp, $name) && !preg_match($execludePattern, $name)) {
$filelist[] = $name; $filelist[] = $name;
} }
} }
reset($files); reset($files);
} }
#print_r($filelist); #print_r($filelist);
// Read in all the PHP files. // Read in all the PHP files.
$data = array(); $data = array();
foreach ($filelist as $name) { foreach ($filelist as $name) {
$data = array_merge($data, file($g_localizerConfig['BASE_DIR'].$dir.'/'.$name)); $data = array_merge($data, file($g_localizerConfig['BASE_DIR'].$dir.'/'.$name));
} }
#print_r($data); #print_r($data);
// Collect all matches // Collect all matches
$matches = array(); $matches = array();
foreach ($data as $line) { foreach ($data as $line) {
foreach ($funcPatterns as $fp => $pos) { foreach ($funcPatterns as $fp => $pos) {
if (preg_match_all($fp, $line, $m)) { if (preg_match_all($fp, $line, $m)) {
foreach ($m[$pos] as $match) { foreach ($m[$pos] as $match) {
#$match = str_replace("\\\\", "\\", $match); #$match = str_replace("\\\\", "\\", $match);
if (strlen($match)) $matches[$match] = $match; if (strlen($match)) $matches[$match] = $match;
@ -289,63 +289,63 @@ class Localizer {
} }
asort($matches); asort($matches);
#print_r($matches); #print_r($matches);
return $matches; return $matches;
} // fn FindTranslationStrings } // fn FindTranslationStrings
function _flatFileList($files, $appdir='', $init=TRUE) function _flatFileList($files, $appdir='', $init=TRUE)
{ {
static $_flatList; static $_flatList;
if ($init === TRUE) $_flatList = array(); if ($init === TRUE) $_flatList = array();
foreach ($files as $dir => $name) { foreach ($files as $dir => $name) {
if (is_array($name)) { if (is_array($name)) {
Localizer::_flatFileList($name, $appdir.'/'.$dir, FALSE); Localizer::_flatFileList($name, $appdir.'/'.$dir, FALSE);
} else { } else {
$_flatList[] = $appdir.'/'.$name; $_flatList[] = $appdir.'/'.$name;
} }
} }
return $_flatList; return $_flatList;
} }
/** /**
* Return the set of strings in the code that are not in the translation files. * Return the set of strings in the code that are not in the translation files.
* @param string $p_directory - * @param string $p_directory -
* @return array * @return array
*/ */
function FindMissingStrings($p_prefix) function FindMissingStrings($p_prefix)
{ {
global $g_localizerConfig; global $g_localizerConfig;
if (empty($p_prefix)) { if (empty($p_prefix)) {
return array(); return array();
} }
$newKeys =& Localizer::FindTranslationStrings($p_prefix); $newKeys =& Localizer::FindTranslationStrings($p_prefix);
$missingKeys =& Localizer::CompareKeys($p_prefix, $newKeys, false); $missingKeys =& Localizer::CompareKeys($p_prefix, $newKeys, false);
$missingKeys = array_unique($missingKeys); $missingKeys = array_unique($missingKeys);
return $missingKeys; return $missingKeys;
} // fn FindMissingStrings } // fn FindMissingStrings
/** /**
* Return the set of strings in the translation files that are not used in the code. * Return the set of strings in the translation files that are not used in the code.
* @param string $p_prefix * @param string $p_prefix
* @param string $p_directory - * @param string $p_directory -
* @return array * @return array
*/ */
function FindUnusedStrings($p_prefix) function FindUnusedStrings($p_prefix)
{ {
global $g_localizerConfig; global $g_localizerConfig;
if (empty($p_prefix)) { if (empty($p_prefix)) {
return array(); return array();
} }
$existingKeys =& Localizer::FindTranslationStrings($p_prefix); $existingKeys =& Localizer::FindTranslationStrings($p_prefix);
$localData =& new LocalizerLanguage($p_prefix, $g_localizerConfig['DEFAULT_LANGUAGE']); $localData = new LocalizerLanguage($p_prefix, $g_localizerConfig['DEFAULT_LANGUAGE']);
$localData->loadFile(Localizer::GetMode()); $localData->loadFile(Localizer::GetMode());
$localTable = $localData->getTranslationTable(); $localTable = $localData->getTranslationTable();
$unusedKeys = array(); $unusedKeys = array();
@ -357,8 +357,8 @@ class Localizer {
$unusedKeys = array_unique($unusedKeys); $unusedKeys = array_unique($unusedKeys);
return $unusedKeys; return $unusedKeys;
} // fn FindUnusedStrings } // fn FindUnusedStrings
/** /**
* Update a set of strings in a language file. * Update a set of strings in a language file.
* @param string $p_prefix * @param string $p_prefix
@ -367,7 +367,7 @@ class Localizer {
* *
* @return void * @return void
*/ */
function ModifyStrings($p_prefix, $p_languageId, $p_data) function ModifyStrings($p_prefix, $p_languageId, $p_data)
{ {
global $g_localizerConfig; global $g_localizerConfig;
// If we change a string in the default language, // If we change a string in the default language,
@ -375,11 +375,11 @@ class Localizer {
if ($p_languageId == $g_localizerConfig['DEFAULT_LANGUAGE']) { if ($p_languageId == $g_localizerConfig['DEFAULT_LANGUAGE']) {
$languages = Localizer::GetAllLanguages(); $languages = Localizer::GetAllLanguages();
foreach ($languages as $language) { foreach ($languages as $language) {
// Load the language file // Load the language file
$source =& new LocalizerLanguage($p_prefix, $language->getLanguageId()); $source = new LocalizerLanguage($p_prefix, $language->getLanguageId());
$source->loadFile(Localizer::GetMode()); $source->loadFile(Localizer::GetMode());
// For the default language, we set the key & value to be the same. // For the default language, we set the key & value to be the same.
if ($p_languageId == $language->getLanguageId()) { if ($p_languageId == $language->getLanguageId()) {
foreach ($p_data as $pair) { foreach ($p_data as $pair) {
@ -392,7 +392,7 @@ class Localizer {
$source->updateString($pair['key'], $pair['value']); $source->updateString($pair['key'], $pair['value']);
} }
} }
// Save the file // Save the file
$source->saveFile(Localizer::GetMode()); $source->saveFile(Localizer::GetMode());
} }
@ -400,33 +400,33 @@ class Localizer {
// We only need to change the values in one file. // We only need to change the values in one file.
else { else {
// Load the language file // Load the language file
$source =& new LocalizerLanguage($p_prefix, $p_languageId); $source = new LocalizerLanguage($p_prefix, $p_languageId);
$source->loadFile(Localizer::GetMode()); $source->loadFile(Localizer::GetMode());
foreach ($p_data as $pair) { foreach ($p_data as $pair) {
$source->updateString($pair['key'], $pair['key'], $pair['value']); $source->updateString($pair['key'], $pair['key'], $pair['value']);
} }
// Save the file // Save the file
$source->saveFile(Localizer::GetMode()); $source->saveFile(Localizer::GetMode());
} }
} // fn ModifyStrings } // fn ModifyStrings
/** /**
* Synchronize the positions of the strings to the default language file order. * Synchronize the positions of the strings to the default language file order.
* @param string $p_prefix * @param string $p_prefix
* @return void * @return void
*/ */
function FixPositions($p_prefix) function FixPositions($p_prefix)
{ {
global $g_localizerConfig; global $g_localizerConfig;
$defaultLanguage =& new LocalizerLanguage($p_prefix, $g_localizerConfig['DEFAULT_LANGUAGE']); $defaultLanguage = new LocalizerLanguage($p_prefix, $g_localizerConfig['DEFAULT_LANGUAGE']);
$defaultLanguage->loadFile(Localizer::GetMode()); $defaultLanguage->loadFile(Localizer::GetMode());
$defaultTranslationTable = $defaultLanguage->getTranslationTable(); $defaultTranslationTable = $defaultLanguage->getTranslationTable();
$languageIds = Localizer::GetAllLanguages(); $languageIds = Localizer::GetAllLanguages();
foreach ($languageIds as $languageId) { foreach ($languageIds as $languageId) {
// Load the language file // Load the language file
$source =& new LocalizerLanguage($p_prefix, $languageId); $source = new LocalizerLanguage($p_prefix, $languageId);
$source->loadFile(Localizer::GetMode()); $source->loadFile(Localizer::GetMode());
$count = 0; $count = 0;
@ -434,13 +434,13 @@ class Localizer {
$source->moveString($key, $count); $source->moveString($key, $count);
$count++; $count++;
} }
// Save the file // Save the file
$source->saveFile(Localizer::GetMode()); $source->saveFile(Localizer::GetMode());
} }
} // fn FixPositions } // fn FixPositions
/** /**
* Go through all files matching $p_prefix in $p_directory and add entry(s). * Go through all files matching $p_prefix in $p_directory and add entry(s).
* *
@ -450,12 +450,12 @@ class Localizer {
* *
* @return void * @return void
*/ */
function AddStringAtPosition($p_prefix, $p_position, $p_newKey) function AddStringAtPosition($p_prefix, $p_position, $p_newKey)
{ {
global $g_localizerConfig; global $g_localizerConfig;
$languages = Localizer::GetAllLanguages(); $languages = Localizer::GetAllLanguages();
foreach ($languages as $language) { foreach ($languages as $language) {
$source =& new LocalizerLanguage($p_prefix, $language->getLanguageId()); $source = new LocalizerLanguage($p_prefix, $language->getLanguageId());
$source->loadFile(Localizer::GetMode()); $source->loadFile(Localizer::GetMode());
if (is_array($p_newKey)) { if (is_array($p_newKey)) {
foreach (array_reverse($p_newKey) as $key) { foreach (array_reverse($p_newKey) as $key) {
@ -472,7 +472,7 @@ class Localizer {
$source->addString($p_newKey, $p_newKey, $p_position); $source->addString($p_newKey, $p_newKey, $p_position);
} }
else { else {
$source->addString($p_newKey, '', $p_position); $source->addString($p_newKey, '', $p_position);
} }
} }
$source->saveFile(Localizer::GetMode()); $source->saveFile(Localizer::GetMode());
@ -487,12 +487,12 @@ class Localizer {
* Can be a string or an array of strings. * Can be a string or an array of strings.
* @return void * @return void
*/ */
function RemoveString($p_prefix, $p_key) function RemoveString($p_prefix, $p_key)
{ {
$languages = Localizer::GetAllLanguages(); $languages = Localizer::GetAllLanguages();
foreach ($languages as $language) { foreach ($languages as $language) {
$target =& new LocalizerLanguage($p_prefix, $language->getLanguageId()); $target = new LocalizerLanguage($p_prefix, $language->getLanguageId());
$target->loadFile(Localizer::GetMode()); $target->loadFile(Localizer::GetMode());
if (is_array($p_key)) { if (is_array($p_key)) {
foreach ($p_key as $key) { foreach ($p_key as $key) {
@ -506,7 +506,7 @@ class Localizer {
} }
} // fn RemoveString } // fn RemoveString
/** /**
* Go through all files matching $p_prefix swap selected entrys. * Go through all files matching $p_prefix swap selected entrys.
* *
@ -516,18 +516,18 @@ class Localizer {
* *
* @return void * @return void
*/ */
function MoveString($p_prefix, $p_pos1, $p_pos2) function MoveString($p_prefix, $p_pos1, $p_pos2)
{ {
$languages = Localizer::GetAllLanguages(); $languages = Localizer::GetAllLanguages();
foreach ($languages as $language) { foreach ($languages as $language) {
$target =& new LocalizerLanguage($p_prefix, $language->getLanguageId()); $target = new LocalizerLanguage($p_prefix, $language->getLanguageId());
$target->loadFile(Localizer::GetMode()); $target->loadFile(Localizer::GetMode());
$success = $target->moveString($p_pos1, $p_pos2); $success = $target->moveString($p_pos1, $p_pos2);
$target->saveFile(Localizer::GetMode()); $target->saveFile(Localizer::GetMode());
} }
} // fn MoveString } // fn MoveString
/** /**
* Get all the languages that the interface supports. * Get all the languages that the interface supports.
* *
@ -540,21 +540,21 @@ class Localizer {
* @return array * @return array
* An array of LanguageMetadata objects. * An array of LanguageMetadata objects.
*/ */
function GetAllLanguages($p_mode = null, $p_default=TRUE, $p_completed_only=FALSE) function GetAllLanguages($p_mode = null, $p_default=TRUE, $p_completed_only=FALSE)
{ {
if (is_null($p_mode)) { if (is_null($p_mode)) {
$p_mode = Localizer::GetMode(); $p_mode = Localizer::GetMode();
} }
$className = "LocalizerFileFormat_".strtoupper($p_mode); $className = "LocalizerFileFormat_".strtoupper($p_mode);
if (class_exists($className)) { if (class_exists($className)) {
$object =& new $className(); $object = new $className();
if (method_exists($object, "getLanguages")) { if (method_exists($object, "getLanguages")) {
$languages = $object->getLanguages($p_default, $p_completed_only); $languages = $object->getLanguages($p_default, $p_completed_only);
} }
} }
//$this->m_languageDefs =& $languages; //$this->m_languageDefs =& $languages;
return $languages; return $languages;
} // fn GetAllLanguages } // fn GetAllLanguages
/** /**
@ -564,7 +564,7 @@ class Localizer {
* @param string $p_pattern * @param string $p_pattern
* @return array * @return array
*/ */
function SearchFilesRecursive($p_startdir, $p_pattern) function SearchFilesRecursive($p_startdir, $p_pattern)
{ {
$structure = File_Find::mapTreeMultiple($p_startdir); $structure = File_Find::mapTreeMultiple($p_startdir);
@ -573,9 +573,9 @@ class Localizer {
foreach ($structure as $dir => $file) { foreach ($structure as $dir => $file) {
// it's a directory // it's a directory
if (is_array($file)) { if (is_array($file)) {
$filelist = array_merge($filelist, $filelist = array_merge($filelist,
Localizer::SearchFilesRecursive($p_startdir.'/'.$dir, $p_pattern)); Localizer::SearchFilesRecursive($p_startdir.'/'.$dir, $p_pattern));
} }
else { else {
// it's a file // it's a file
if (preg_match($p_pattern, $file)) { if (preg_match($p_pattern, $file)) {
@ -592,17 +592,17 @@ class Localizer {
* @param string $p_languageId * @param string $p_languageId
* @return void * @return void
*/ */
function CreateLanguageFiles($p_languageId) function CreateLanguageFiles($p_languageId)
{ {
global $g_localizerConfig; global $g_localizerConfig;
// Make new directory // Make new directory
if (!mkdir($g_localizerConfig['TRANSLATION_DIR']."/".$p_languageId)) { if (!mkdir($g_localizerConfig['TRANSLATION_DIR']."/".$p_languageId)) {
return; return;
} }
// Copy files from reference language // Copy files from reference language
// $className = "LocalizerFileFormat_".strtoupper(Localizer::GetMode()); // $className = "LocalizerFileFormat_".strtoupper(Localizer::GetMode());
// foreach ($files as $pathname) { // foreach ($files as $pathname) {
// if ($pathname) { // if ($pathname) {
@ -610,7 +610,7 @@ class Localizer {
// $base = $fileNameParts[0]; // $base = $fileNameParts[0];
// $dir = str_replace($g_localizerConfig['BASE_DIR'], '', dirname($pathname)); // $dir = str_replace($g_localizerConfig['BASE_DIR'], '', dirname($pathname));
// // read the default file // // read the default file
// $defaultLang =& new LocalizerLanguage($base, $g_localizerConfig['DEFAULT_LANGUAGE']); // $defaultLang = new LocalizerLanguage($base, $g_localizerConfig['DEFAULT_LANGUAGE']);
// $defaultLang->loadFile(Localizer::GetMode()); // $defaultLang->loadFile(Localizer::GetMode());
// $defaultLang->clearValues(); // $defaultLang->clearValues();
// $defaultLang->setLanguageId($p_languageId); // $defaultLang->setLanguageId($p_languageId);
@ -622,13 +622,13 @@ class Localizer {
// } // }
} // fn CreateLanguageFiles } // fn CreateLanguageFiles
/** /**
* Go through subdirectorys and delete language files for given Id. * Go through subdirectorys and delete language files for given Id.
* @param string $p_languageId * @param string $p_languageId
* @return void * @return void
*/ */
function DeleteLanguageFiles($p_languageId) function DeleteLanguageFiles($p_languageId)
{ {
global $g_localizerConfig; global $g_localizerConfig;
$langDir = $g_localizerConfig['TRANSLATION_DIR'].'/'.$p_languageId; $langDir = $g_localizerConfig['TRANSLATION_DIR'].'/'.$p_languageId;
@ -644,6 +644,6 @@ class Localizer {
} }
} }
} // fn DeleteLanguageFiles } // fn DeleteLanguageFiles
} // class Localizer } // class Localizer
?> ?>

View file

@ -128,7 +128,7 @@ class LocalizerFileFormat_GS extends LocalizerFileFormat {
$metadata = array(); $metadata = array();
foreach ($languages as $language) { foreach ($languages as $language) {
$tmpMetadata =& new LanguageMetadata(); $tmpMetadata = new LanguageMetadata();
$tmpMetadata->m_englishName = $language['Name']; $tmpMetadata->m_englishName = $language['Name'];
$tmpMetadata->m_nativeName = $language['NativeName']; $tmpMetadata->m_nativeName = $language['NativeName'];
$tmpMetadata->m_languageCode = $language['LanguageCode']; $tmpMetadata->m_languageCode = $language['LanguageCode'];
@ -195,7 +195,7 @@ class LocalizerFileFormat_XML extends LocalizerFileFormat {
if (file_exists($filePath)) { if (file_exists($filePath)) {
$xml = File::readAll($filePath); $xml = File::readAll($filePath);
File::close($filePath, FILE_MODE_READ); File::close($filePath, FILE_MODE_READ);
$unserializer =& new XML_Unserializer($this->m_unserializeOptions); $unserializer = new XML_Unserializer($this->m_unserializeOptions);
$unserializer->unserialize($xml); $unserializer->unserialize($xml);
$translationArray = $unserializer->getUnserializedData(); $translationArray = $unserializer->getUnserializedData();
@ -233,7 +233,7 @@ class LocalizerFileFormat_XML extends LocalizerFileFormat {
} }
$saveData = array_merge($saveData, $saveTranslationTable); $saveData = array_merge($saveData, $saveTranslationTable);
$serializer =& new XML_Serializer($this->m_serializeOptions); $serializer = new XML_Serializer($this->m_serializeOptions);
$serializer->serialize($saveData); $serializer->serialize($saveData);
$xml = $serializer->getSerializedData(); $xml = $serializer->getSerializedData();
@ -289,7 +289,7 @@ class LocalizerFileFormat_XML extends LocalizerFileFormat {
$xml = File::readAll($fileName); $xml = File::readAll($fileName);
File::rewind($fileName, FILE_MODE_READ); File::rewind($fileName, FILE_MODE_READ);
$handle =& new XML_Unserializer($this->l_unserializeOptions); $handle = new XML_Unserializer($this->l_unserializeOptions);
$handle->unserialize($xml); $handle->unserialize($xml);
$arr = $handle->getUnserializedData(); $arr = $handle->getUnserializedData();
@ -303,7 +303,7 @@ class LocalizerFileFormat_XML extends LocalizerFileFormat {
// just display default language in maintainance mode // just display default language in maintainance mode
if ($p_default || $language['Id'] !== $g_localizerConfig['DEFAULT_LANGUAGE']) { if ($p_default || $language['Id'] !== $g_localizerConfig['DEFAULT_LANGUAGE']) {
list ($langCode, $countryCode) = explode('_', $language['Id']); list ($langCode, $countryCode) = explode('_', $language['Id']);
$languageDef =& new LanguageMetadata(); $languageDef = new LanguageMetadata();
$languageDef->m_languageId = $language['Id']; $languageDef->m_languageId = $language['Id'];
$languageDef->m_languageCode = $langCode; $languageDef->m_languageCode = $langCode;
$languageDef->m_countryCode = $countryCode; $languageDef->m_countryCode = $countryCode;
@ -330,7 +330,7 @@ class LocalizerFileFormat_XML extends LocalizerFileFormat {
$xml = File::readAll($fileName); $xml = File::readAll($fileName);
File::rewind($fileName, FILE_MODE_READ); File::rewind($fileName, FILE_MODE_READ);
$handle =& new XML_Unserializer($this->l_unserializeOptions); $handle = new XML_Unserializer($this->l_unserializeOptions);
$handle->unserialize($xml); $handle->unserialize($xml);
$arr = $handle->getUnserializedData(); $arr = $handle->getUnserializedData();
@ -346,7 +346,7 @@ class LocalizerFileFormat_XML extends LocalizerFileFormat {
'NativeName' => $new['NativeName'] 'NativeName' => $new['NativeName']
); );
$languages = $this->_xSortArray($languages, 'Id'); $languages = $this->_xSortArray($languages, 'Id');
$handle =& new XML_Serializer($this->l_serializeOptions); $handle = new XML_Serializer($this->l_serializeOptions);
$handle->serialize($languages); $handle->serialize($languages);
if (!$xml = $handle->getSerializedData()) { if (!$xml = $handle->getSerializedData()) {

View file

@ -21,11 +21,11 @@ class LocalizerLanguage {
var $m_mode = ''; var $m_mode = '';
var $m_prefix = ''; var $m_prefix = '';
var $m_filePath = ''; var $m_filePath = '';
/** /**
* A LocalizerLanguage is basically a translation table. * A LocalizerLanguage is basically a translation table.
* *
* You can use this class to manipulate the translation table: * You can use this class to manipulate the translation table:
* such as add, delete, and move strings. * such as add, delete, and move strings.
* *
* @param string $p_prefix * @param string $p_prefix
@ -40,49 +40,49 @@ class LocalizerLanguage {
* 2) The two-letter language code, underscore, two-letter country code * 2) The two-letter language code, underscore, two-letter country code
* (e.g. "en_US") * (e.g. "en_US")
*/ */
function LocalizerLanguage($p_prefix, $p_languageId = null) function LocalizerLanguage($p_prefix, $p_languageId = null)
{ {
if (!is_null($p_languageId)) { if (!is_null($p_languageId)) {
$this->setLanguageId($p_languageId); $this->setLanguageId($p_languageId);
} }
$this->m_prefix = $p_prefix; $this->m_prefix = $p_prefix;
} // constructor } // constructor
/** /**
* Return the filename prefix. * Return the filename prefix.
* @return string * @return string
*/ */
function getPrefix() function getPrefix()
{ {
return $this->m_prefix; return $this->m_prefix;
} // fn getPrefix } // fn getPrefix
/** /**
* This will return 'gs' or 'xml' * This will return 'gs' or 'xml'
* @return string * @return string
*/ */
function getMode() function getMode()
{ {
return $this->m_mode; return $this->m_mode;
} // fn getMode } // fn getMode
/** /**
* Set the mode to be 'xml' or 'gs'. * Set the mode to be 'xml' or 'gs'.
* @param string $p_value * @param string $p_value
* @return void * @return void
*/ */
function setMode($p_value) function setMode($p_value)
{ {
$p_value = strtolower($p_value); $p_value = strtolower($p_value);
if (($p_value == 'xml') || ($p_value == 'gs')) { if (($p_value == 'xml') || ($p_value == 'gs')) {
$this->m_mode = $p_value; $this->m_mode = $p_value;
} }
} // fn setMode } // fn setMode
/** /**
* Set the language code - this can take either the two-letter language code * Set the language code - this can take either the two-letter language code
* or the LL_CC extended version , where LL is the language code and CC * or the LL_CC extended version , where LL is the language code and CC
@ -91,8 +91,8 @@ class LocalizerLanguage {
* @param string $p_languageId * @param string $p_languageId
* @return void * @return void
*/ */
function setLanguageId($p_languageId) function setLanguageId($p_languageId)
{ {
if (strlen($p_languageId) > 2) { if (strlen($p_languageId) > 2) {
list ($this->m_languageCode, $this->m_countryCode) = explode('_', $p_languageId); list ($this->m_languageCode, $this->m_countryCode) = explode('_', $p_languageId);
$this->m_languageId = $p_languageId; $this->m_languageId = $p_languageId;
@ -100,17 +100,17 @@ class LocalizerLanguage {
else { else {
$this->m_languageCode = $p_languageId; $this->m_languageCode = $p_languageId;
$this->m_languageId = $p_languageId; $this->m_languageId = $p_languageId;
} }
} // fn setLanguageId } // fn setLanguageId
/** /**
* Register a string in the translation table. * Register a string in the translation table.
* @param string $p_key * @param string $p_key
* @param string $p_value * @param string $p_value
* @return void * @return void
*/ */
function registerString($p_key, $p_value) function registerString($p_key, $p_value)
{ {
if (substr($p_value, strlen($p_value)-3) == ":en"){ if (substr($p_value, strlen($p_value)-3) == ":en"){
$p_value = substr($p_value, 0, strlen($p_value)-3); $p_value = substr($p_value, 0, strlen($p_value)-3);
@ -123,63 +123,63 @@ class LocalizerLanguage {
* Return the total number of strings in the translation table. * Return the total number of strings in the translation table.
* @return int * @return int
*/ */
function getNumStrings() function getNumStrings()
{ {
return count($this->m_translationTable); return count($this->m_translationTable);
} // fn getNumStrings } // fn getNumStrings
/** /**
* Get the language code that is in the form <two_letter_language_code>_<english_name_of_language>. * Get the language code that is in the form <two_letter_language_code>_<english_name_of_language>.
* *
* @return string * @return string
*/ */
function getLanguageId() function getLanguageId()
{ {
return $this->m_languageId; return $this->m_languageId;
} // fn getLanguageId } // fn getLanguageId
/** /**
* Get the two-letter language code for the translation table. * Get the two-letter language code for the translation table.
* @return string * @return string
*/ */
function getLanguageCode() function getLanguageCode()
{ {
return $this->m_languageCode; return $this->m_languageCode;
} // fn getLanguageCode } // fn getLanguageCode
/** /**
* Get the two-letter country code. * Get the two-letter country code.
* @return string * @return string
*/ */
function getCountryCode() function getCountryCode()
{ {
return $this->m_countryCode; return $this->m_countryCode;
} // fn getCountryCode } // fn getCountryCode
/** /**
* Return the file path for the last file loaded. * Return the file path for the last file loaded.
* @return string * @return string
*/ */
function getSourceFile() function getSourceFile()
{ {
return $this->m_filePath; return $this->m_filePath;
} // fn getSourceFile } // fn getSourceFile
/** /**
* This is only for use by the LocalizerFileFormat functions. * This is only for use by the LocalizerFileFormat functions.
* @access private * @access private
*/ */
function _setSourceFile($p_value) function _setSourceFile($p_value)
{ {
$this->m_filePath = $p_value; $this->m_filePath = $p_value;
} // fn _setSourceFile } // fn _setSourceFile
/** /**
* Return true if this LocalizerLanguage has the exact same * Return true if this LocalizerLanguage has the exact same
* translation strings as the given LocalizerLanguage. * translation strings as the given LocalizerLanguage.
@ -187,7 +187,7 @@ class LocalizerLanguage {
* @param LocalizerLanguage $p_localizerLanguage * @param LocalizerLanguage $p_localizerLanguage
* @return boolean * @return boolean
*/ */
function equal($p_localizerLanguage) function equal($p_localizerLanguage)
{ {
if (count($this->m_translationTable) != count($p_localizerLanguage->m_translationTable)) { if (count($this->m_translationTable) != count($p_localizerLanguage->m_translationTable)) {
return false; return false;
@ -204,20 +204,20 @@ class LocalizerLanguage {
} }
return true; return true;
} // fn equal } // fn equal
/** /**
* Return a table indexed by the english language name, with the value being the * Return a table indexed by the english language name, with the value being the
* target language equivalent. * target language equivalent.
* *
* @return array * @return array
*/ */
function getTranslationTable() function getTranslationTable()
{ {
return $this->m_translationTable; return $this->m_translationTable;
} }
/** /**
* Get the full path to the translation file. * Get the full path to the translation file.
* *
@ -225,12 +225,12 @@ class LocalizerLanguage {
* Either 'gs' or 'xml'. * Either 'gs' or 'xml'.
* @return string * @return string
*/ */
function getFilePath($p_mode = null) function getFilePath($p_mode = null)
{ {
global $g_localizerConfig; global $g_localizerConfig;
if (is_null($p_mode)) { if (is_null($p_mode)) {
$p_mode = $this->m_mode; $p_mode = $this->m_mode;
} }
if ($p_mode == 'xml') { if ($p_mode == 'xml') {
$relativePath = '/'.$this->m_languageId.'/'.$this->m_prefix.'.xml'; $relativePath = '/'.$this->m_languageId.'/'.$this->m_prefix.'.xml';
} }
@ -240,7 +240,7 @@ class LocalizerLanguage {
return $g_localizerConfig['TRANSLATION_DIR'].$relativePath; return $g_localizerConfig['TRANSLATION_DIR'].$relativePath;
} // fn getFilePath } // fn getFilePath
/** /**
* Return TRUE if the given string exists in the translation table. * Return TRUE if the given string exists in the translation table.
* *
@ -248,12 +248,12 @@ class LocalizerLanguage {
* *
* @return boolean * @return boolean
*/ */
function keyExists($p_string) function keyExists($p_string)
{ {
return (isset($this->m_translationTable[$p_string])); return (isset($this->m_translationTable[$p_string]));
} // fn stringExists } // fn stringExists
/** /**
* Add a string to the translation table. * Add a string to the translation table.
* *
@ -265,15 +265,15 @@ class LocalizerLanguage {
* value as the key. * value as the key.
* *
* @param int $p_position * @param int $p_position
* Optional. By default the string will be added to the end of the * Optional. By default the string will be added to the end of the
* translation table. * translation table.
* *
* @return boolean * @return boolean
*/ */
function addString($p_key, $p_value = null, $p_position = null) function addString($p_key, $p_value = null, $p_position = null)
{ {
if (!is_null($p_position) if (!is_null($p_position)
&& (!is_numeric($p_position) || ($p_position < 0) && (!is_numeric($p_position) || ($p_position < 0)
|| ($p_position > count($this->m_translationTable)))) { || ($p_position > count($this->m_translationTable)))) {
return false; return false;
} }
@ -304,8 +304,8 @@ class LocalizerLanguage {
return true; return true;
} }
} // fn addString } // fn addString
/** /**
* Get the position of a key or a value. * Get the position of a key or a value.
* @param string $p_key * @param string $p_key
@ -313,7 +313,7 @@ class LocalizerLanguage {
* @return mixed * @return mixed
* The position of the key/value in the array, FALSE if not found. * The position of the key/value in the array, FALSE if not found.
*/ */
function getPosition($p_key = null, $p_value = null) function getPosition($p_key = null, $p_value = null)
{ {
$position = 0; $position = 0;
if (!is_null($p_key)) { if (!is_null($p_key)) {
@ -330,11 +330,11 @@ class LocalizerLanguage {
return $position; return $position;
} }
$position++; $position++;
} }
} }
return false; return false;
} // fn getPosition } // fn getPosition
/** /**
* Get the string at the given position. * Get the string at the given position.
@ -343,9 +343,9 @@ class LocalizerLanguage {
* An array of two elements, the first is the key, the second is the value. * An array of two elements, the first is the key, the second is the value.
* They are indexed by 'key' and 'value'. * They are indexed by 'key' and 'value'.
*/ */
function getStringAtPosition($p_position) function getStringAtPosition($p_position)
{ {
if (is_null($p_position) || !is_numeric($p_position) || ($p_position < 0) if (is_null($p_position) || !is_numeric($p_position) || ($p_position < 0)
|| ($p_position > count($this->m_translationTable))) { || ($p_position > count($this->m_translationTable))) {
return false; return false;
} }
@ -355,10 +355,10 @@ class LocalizerLanguage {
$value = array_pop($returnValue); $value = array_pop($returnValue);
return array('key' => $key, 'value' => $value); return array('key' => $key, 'value' => $value);
} // fn getStringAtPosition } // fn getStringAtPosition
/** /**
* Change the key and optionally the value of the * Change the key and optionally the value of the
* translation string. If the value isnt specified, * translation string. If the value isnt specified,
* it is not changed. If the key does not exist, * it is not changed. If the key does not exist,
* it will be added. In this case, you can use p_position * it will be added. In this case, you can use p_position
@ -370,7 +370,7 @@ class LocalizerLanguage {
* @param int $p_position * @param int $p_position
* @return boolean * @return boolean
*/ */
function updateString($p_oldKey, $p_newKey, $p_value = null, $p_position = null) function updateString($p_oldKey, $p_newKey, $p_value = null, $p_position = null)
{ {
if (!is_string($p_oldKey) || !is_string($p_newKey)) { if (!is_string($p_oldKey) || !is_string($p_newKey)) {
return false; return false;
@ -390,7 +390,7 @@ class LocalizerLanguage {
return true; return true;
} }
} }
// Updating the key (and possibly the value) // Updating the key (and possibly the value)
if (is_null($p_value)) { if (is_null($p_value)) {
$p_value = $this->m_translationTable[$p_oldKey]; $p_value = $this->m_translationTable[$p_oldKey];
@ -400,8 +400,8 @@ class LocalizerLanguage {
$success &= $this->addString($p_newKey, $p_value, $position); $success &= $this->addString($p_newKey, $p_value, $position);
return $success; return $success;
} // fn updateString } // fn updateString
/** /**
* Move a string to a different position in the translation array. * Move a string to a different position in the translation array.
* This allows similiar strings to be grouped together. * This allows similiar strings to be grouped together.
@ -412,10 +412,10 @@ class LocalizerLanguage {
* @return boolean * @return boolean
* TRUE on success, FALSE on failure. * TRUE on success, FALSE on failure.
*/ */
function moveString($p_startPositionOrKey, $p_endPosition) function moveString($p_startPositionOrKey, $p_endPosition)
{ {
// Check parameters // Check parameters
if (is_numeric($p_startPositionOrKey) && (($p_startPositionOrKey < 0) if (is_numeric($p_startPositionOrKey) && (($p_startPositionOrKey < 0)
|| ($p_startPositionOrKey > count($this->m_translationTable)))) { || ($p_startPositionOrKey > count($this->m_translationTable)))) {
return false; return false;
} }
@ -436,11 +436,11 @@ class LocalizerLanguage {
else { else {
return false; return false;
} }
// Success if we dont have to move the string anywhere // Success if we dont have to move the string anywhere
if ($startPosition == $p_endPosition) { if ($startPosition == $p_endPosition) {
return true; return true;
} }
// Delete the string in the old position // Delete the string in the old position
$result = $this->deleteStringAtPosition($startPosition); $result = $this->deleteStringAtPosition($startPosition);
if (!$result) { if (!$result) {
@ -448,7 +448,7 @@ class LocalizerLanguage {
} }
$key = $result['key']; $key = $result['key'];
$value = $result['value']; $value = $result['value'];
// Add the string in the new position // Add the string in the new position
$result = $this->addString($key, $value, $p_endPosition); $result = $this->addString($key, $value, $p_endPosition);
if (!$result) { if (!$result) {
@ -456,8 +456,8 @@ class LocalizerLanguage {
} }
return true; return true;
} // fn moveString } // fn moveString
/** /**
* Delete the string given by $p_key. * Delete the string given by $p_key.
* @param string $p_key * @param string $p_key
@ -465,7 +465,7 @@ class LocalizerLanguage {
* The deleted string as array('key' => $key, 'value' => $value) on success, * The deleted string as array('key' => $key, 'value' => $value) on success,
* FALSE if it didnt exist. * FALSE if it didnt exist.
*/ */
function deleteString($p_key) function deleteString($p_key)
{ {
if (isset($this->m_translationTable[$p_key])) { if (isset($this->m_translationTable[$p_key])) {
$value = $this->m_translationTable[$p_key]; $value = $this->m_translationTable[$p_key];
@ -474,17 +474,17 @@ class LocalizerLanguage {
} }
return false; return false;
} // fn deleteString } // fn deleteString
/** /**
* Delete a string at a specific position in the array. * Delete a string at a specific position in the array.
* @param int $p_position * @param int $p_position
* @return mixed * @return mixed
* The deleted string as array($key, $value) on success, FALSE on failure. * The deleted string as array($key, $value) on success, FALSE on failure.
*/ */
function deleteStringAtPosition($p_position) function deleteStringAtPosition($p_position)
{ {
if (!is_numeric($p_position) || ($p_position < 0) if (!is_numeric($p_position) || ($p_position < 0)
|| ($p_position > count($this->m_translationTable))) { || ($p_position > count($this->m_translationTable))) {
return false; return false;
} }
@ -494,16 +494,16 @@ class LocalizerLanguage {
$value = array_pop($returnValue); $value = array_pop($returnValue);
return array('key' => $key, 'value' => $value); return array('key' => $key, 'value' => $value);
} // fn deleteStringAtPosition } // fn deleteStringAtPosition
/** /**
* Synchronize the positions of the strings in the translation table * Synchronize the positions of the strings in the translation table
* with the positions of the string in the default language translation table. * with the positions of the string in the default language translation table.
*/ */
function fixPositions() function fixPositions()
{ {
global $g_localizerConfig; global $g_localizerConfig;
$defaultLanguage =& new LocalizerLanguage($this->m_prefix, $defaultLanguage = new LocalizerLanguage($this->m_prefix,
$g_localizerConfig['DEFAULT_LANGUAGE']); $g_localizerConfig['DEFAULT_LANGUAGE']);
$defaultLanguage->loadFile(Localizer::GetMode()); $defaultLanguage->loadFile(Localizer::GetMode());
$defaultTranslationTable = $defaultLanguage->getTranslationTable(); $defaultTranslationTable = $defaultLanguage->getTranslationTable();
@ -518,43 +518,43 @@ class LocalizerLanguage {
} }
return $modified; return $modified;
} // fn fixPositions } // fn fixPositions
/** /**
* Sync with the default language file. This means * Sync with the default language file. This means
* adding any missing strings and fixing the positions of the strings to * adding any missing strings and fixing the positions of the strings to
* be the same as the default language file. * be the same as the default language file.
*/ */
function syncToDefault() function syncToDefault()
{ {
global $g_localizerConfig; global $g_localizerConfig;
$defaultLanguage =& new LocalizerLanguage($this->m_prefix, $defaultLanguage = new LocalizerLanguage($this->m_prefix,
$g_localizerConfig['DEFAULT_LANGUAGE']); $g_localizerConfig['DEFAULT_LANGUAGE']);
$defaultLanguage->loadFile(Localizer::GetMode()); $defaultLanguage->loadFile(Localizer::GetMode());
$defaultTranslationTable = $defaultLanguage->getTranslationTable(); $defaultTranslationTable = $defaultLanguage->getTranslationTable();
$count = 0; $count = 0;
$modified = false; $modified = false;
foreach ($defaultTranslationTable as $key => $value) { foreach ($defaultTranslationTable as $key => $value) {
if (!isset($this->m_translationTable[$key])) { if (!isset($this->m_translationTable[$key])) {
$this->addString($key, '', $count); $this->addString($key, '', $count);
$modified = true; $modified = true;
} }
$count++; $count++;
} }
if ($g_localizerConfig['DELETE_UNUSED_ON_SYNC'] === true) { if ($g_localizerConfig['DELETE_UNUSED_ON_SYNC'] === true) {
foreach ($this->m_translationTable as $key => $value) { foreach ($this->m_translationTable as $key => $value) {
if (!isset($defaultTranslationTable[$key])) { if (!isset($defaultTranslationTable[$key])) {
$this->deleteString($key, '', $count); $this->deleteString($key, '', $count);
$modified = true; $modified = true;
} }
$count++; $count++;
} }
} }
return ($this->fixPositions() || $modified); return ($this->fixPositions() || $modified);
} // fn syncToDefault } // fn syncToDefault
/** /**
* Find the keys/values that match the given keyword. * Find the keys/values that match the given keyword.
* *
@ -562,7 +562,7 @@ class LocalizerLanguage {
* *
* @return array * @return array
*/ */
function search($p_keyword) function search($p_keyword)
{ {
$matches = array(); $matches = array();
foreach ($this->m_translationTable as $key => $value) { foreach ($this->m_translationTable as $key => $value) {
@ -572,8 +572,8 @@ class LocalizerLanguage {
} }
return $matches; return $matches;
} // fn search } // fn search
/** /**
* Load a language file of the given type. * Load a language file of the given type.
* *
@ -582,7 +582,7 @@ class LocalizerLanguage {
* *
* @return boolean * @return boolean
*/ */
function loadFile($p_type = null) function loadFile($p_type = null)
{ {
if (is_null($p_type)) { if (is_null($p_type)) {
if (!empty($this->m_mode)) { if (!empty($this->m_mode)) {
@ -597,15 +597,15 @@ class LocalizerLanguage {
} }
$className = 'LocalizerFileFormat_'.strtoupper($p_type); $className = 'LocalizerFileFormat_'.strtoupper($p_type);
if (class_exists($className)) { if (class_exists($className)) {
$object =& new $className(); $object = new $className();
if (method_exists($object, 'load')) { if (method_exists($object, 'load')) {
return $object->load($this); return $object->load($this);
} }
} }
return false; return false;
} // fn loadFile } // fn loadFile
/** /**
* Save the translation table as the given type. * Save the translation table as the given type.
* *
@ -614,7 +614,7 @@ class LocalizerLanguage {
* *
* @return boolean * @return boolean
*/ */
function saveFile($p_type = null) function saveFile($p_type = null)
{ {
// Figure out the current mode. // Figure out the current mode.
if (is_null($p_type)) { if (is_null($p_type)) {
@ -631,33 +631,33 @@ class LocalizerLanguage {
// Save in the requested mode. // Save in the requested mode.
$className = 'LocalizerFileFormat_'.strtoupper($p_type); $className = 'LocalizerFileFormat_'.strtoupper($p_type);
if (class_exists($className)) { if (class_exists($className)) {
$object =& new $className(); $object = new $className();
if (method_exists($object, 'save')) { if (method_exists($object, 'save')) {
return $object->save($this); return $object->save($this);
} }
} }
return false; return false;
} // fn saveFile } // fn saveFile
/** /**
* Erase all the values in the translation table, but * Erase all the values in the translation table, but
* keep the keys. * keep the keys.
* @return void * @return void
*/ */
function clearValues() function clearValues()
{ {
foreach ($this->m_translationTable as $key => $value) { foreach ($this->m_translationTable as $key => $value) {
$this->m_translationTable[$key] = ''; $this->m_translationTable[$key] = '';
} }
} // fn clearValues } // fn clearValues
/** /**
* For debugging purposes, displays the the translation table * For debugging purposes, displays the the translation table
* in an HTML table. * in an HTML table.
*/ */
function dumpToHtml() function dumpToHtml()
{ {
echo "<pre>"; echo "<pre>";
if (!empty($this->m_filePath)) { if (!empty($this->m_filePath)) {
@ -671,7 +671,7 @@ class LocalizerLanguage {
echo "</table>"; echo "</table>";
echo "</pre>"; echo "</pre>";
} // fn dumpToHtml } // fn dumpToHtml
} // class LocalizerLanguage } // class LocalizerLanguage
?> ?>

View file

@ -12,7 +12,7 @@ function login(&$data)
} }
$dbc->setFetchMode(DB_FETCHMODE_ASSOC); $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$gb =& new GreenBox($dbc, $config); $gb = new GreenBox($dbc, $config);
if (!$data['PHP_AUTH_USER'] || !$data['PHP_AUTH_PW']) { if (!$data['PHP_AUTH_USER'] || !$data['PHP_AUTH_PW']) {
return FALSE; return FALSE;

View file

@ -1,10 +1,10 @@
<?php <?php
function phtml($str) { function phtml($str) {
echo htmlspecialchars($str); echo htmlspecialchars($str);
} }
class Maintenance { class Maintenance {
function listLanguages() function listLanguages()
{ {
$mode = Localizer::GetMode(); $mode = Localizer::GetMode();
$languages = Localizer::getAllLanguages($mode); $languages = Localizer::getAllLanguages($mode);
@ -16,27 +16,27 @@ class Maintenance {
?> ?>
<tr><td><?php phtml($l->m_languageId); ?></td><td><?php phtml($l->m_englishName); ?></td><td><?php phtml($l->m_nativeName); ?></td><td><?php phtml('Edit'); ?></td> <tr><td><?php phtml($l->m_languageId); ?></td><td><?php phtml($l->m_englishName); ?></td><td><?php phtml($l->m_nativeName); ?></td><td><?php phtml('Edit'); ?></td>
<?php <?php
} }
?> ?>
</table> </table>
<?php <?php
} }
function languageForm($validate=FALSE) function languageForm($validate=FALSE)
{ {
require_once 'HTML/QuickForm.php'; require_once 'HTML/QuickForm.php';
require_once 'form_function.php'; require_once 'form_function.php';
$form =& new HTML_QuickForm(); $form = new HTML_QuickForm();
parseArr2Form($form, addLanguageFormArr()); parseArr2Form($form, addLanguageFormArr());
if ($validate) { if ($validate) {
if ($form->validate()) { if ($form->validate()) {
return $form->getSubmitValues(); return $form->getSubmitValues();
} else { } else {
return FALSE; return FALSE;
} }
} }
?> ?>
<table style="background-color: #d5e2ee; border: 1px solid #8baed1; margin-left: 10px; margin-top: 5px;" width="700px;"> <table style="background-color: #d5e2ee; border: 1px solid #8baed1; margin-left: 10px; margin-top: 5px;" width="700px;">
<tr><th>Add language</th></tr> <tr><th>Add language</th></tr>
@ -44,25 +44,25 @@ class Maintenance {
</table> </table>
<?php <?php
} }
function doAddLanguage() function doAddLanguage()
{ {
if ($values = Maintenance::languageForm(TRUE)) { if ($values = Maintenance::languageForm(TRUE)) {
// store from here // store from here
global $g_localizerConfig; global $g_localizerConfig;
$className = "LocalizerFileFormat_".strtoupper($g_localizerConfig['DEFAULT_FILE_TYPE']); $className = "LocalizerFileFormat_".strtoupper($g_localizerConfig['DEFAULT_FILE_TYPE']);
$storage =& new $className(); $storage = new $className();
if ($storage->addLanguage($values)) { if ($storage->addLanguage($values)) {
return TRUE; return TRUE;
} }
} }
return FALSE; return FALSE;
} }
} }
if ($g_localizerConfig['MAINTENANCE']) { if ($g_localizerConfig['MAINTENANCE']) {
?> ?>
<table> <table>
<tr><td valign="top"> <!-- Begin top control panel --> <tr><td valign="top"> <!-- Begin top control panel -->
@ -74,17 +74,17 @@ if ($g_localizerConfig['MAINTENANCE']) {
</td></tr> </td></tr>
</table> </table>
<? <?
switch ($action) { switch ($action) {
case 'list_languages': case 'list_languages':
Maintenance::listLanguages(); Maintenance::listLanguages();
break; break;
case 'add_language': case 'add_language':
Maintenance::languageForm(); Maintenance::languageForm();
break; break;
case 'do_add_language': case 'do_add_language':
if (Maintenance::doAddLanguage()) { if (Maintenance::doAddLanguage()) {
Maintenance::listLanguages(); Maintenance::listLanguages();
} }

View file

@ -1,4 +1,4 @@
<?php <?php
/** /**
* Display a drop-down list of languages. * Display a drop-down list of languages.
@ -7,47 +7,47 @@
* @return string * @return string
* HTML string of <options>. * HTML string of <options>.
*/ */
function LanguageMenu($p_languageMetadata, $p_selectedValue) function LanguageMenu($p_languageMetadata, $p_selectedValue)
{ {
$options = ''; $options = '';
foreach($p_languageMetadata as $language) { foreach($p_languageMetadata as $language) {
if ($p_selectedValue == $language->getLanguageId()) { if ($p_selectedValue == $language->getLanguageId()) {
$selectedString = 'selected'; $selectedString = 'selected';
} }
else { else {
$selectedString = ''; $selectedString = '';
} }
$options .= '<option value="'.$language->getLanguageId().'" '.$selectedString.'>'.$language->getNativeName().'</option>'; $options .= '<option value="'.$language->getLanguageId().'" '.$selectedString.'>'.$language->getNativeName().'</option>';
} }
return $options; return $options;
} // fn LanguageMenu } // fn LanguageMenu
/** /**
* Creates a form for translation. * Creates a form for translation.
* @param array $p_request * @param array $p_request
*/ */
function translationForm($p_request) function translationForm($p_request)
{ {
global $g_localizerConfig; global $g_localizerConfig;
$localizerTargetLanguage = Input::Get('localizer_target_language', 'string', $localizerTargetLanguage = Input::Get('localizer_target_language', 'string',
'', true); '', true);
$localizerSourceLanguage = Input::Get('localizer_source_language', 'string', $localizerSourceLanguage = Input::Get('localizer_source_language', 'string',
$g_localizerConfig['DEFAULT_LANGUAGE'], true); $g_localizerConfig['DEFAULT_LANGUAGE'], true);
if (empty($localizerSourceLanguage)) { if (empty($localizerSourceLanguage)) {
$tmpLanguage =& new LocalizerLanguage(null, $p_request['TOL_Language']); $tmpLanguage = new LocalizerLanguage(null, $p_request['TOL_Language']);
$localizerSourceLanguage = $tmpLanguage->getLanguageId(); $localizerSourceLanguage = $tmpLanguage->getLanguageId();
} }
$prefix = Input::Get('prefix', 'string', '', true); $prefix = Input::Get('prefix', 'string', '', true);
$screenDropDownSelection = $prefix; $screenDropDownSelection = $prefix;
// Load the language files. // Load the language files.
//echo "Prefix: $prefix<br>"; //echo "Prefix: $prefix<br>";
$sourceLang =& new LocalizerLanguage($prefix, $localizerSourceLanguage); $sourceLang = new LocalizerLanguage($prefix, $localizerSourceLanguage);
$targetLang =& new LocalizerLanguage($prefix, $localizerTargetLanguage); $targetLang = new LocalizerLanguage($prefix, $localizerTargetLanguage);
$defaultLang =& new LocalizerLanguage($prefix, $g_localizerConfig['DEFAULT_LANGUAGE']); $defaultLang = new LocalizerLanguage($prefix, $g_localizerConfig['DEFAULT_LANGUAGE']);
$mode = Localizer::GetMode(); $mode = Localizer::GetMode();
if (!empty($prefix)) { if (!empty($prefix)) {
// If the language files do not exist, create them. // If the language files do not exist, create them.
@ -60,7 +60,7 @@ function translationForm($p_request)
if (!$targetLang->loadFile($mode)) { if (!$targetLang->loadFile($mode)) {
$targetLang->saveFile($mode); $targetLang->saveFile($mode);
} }
// Make sure that the languages have the same strings and are in the same // Make sure that the languages have the same strings and are in the same
// order as the default language file. // order as the default language file.
$modified = $sourceLang->syncToDefault(); $modified = $sourceLang->syncToDefault();
@ -70,10 +70,10 @@ function translationForm($p_request)
$modified = $targetLang->syncToDefault(); $modified = $targetLang->syncToDefault();
if ($modified) { if ($modified) {
$targetLang->saveFile($mode); $targetLang->saveFile($mode);
} }
} }
$defaultStrings = $defaultLang->getTranslationTable(); $defaultStrings = $defaultLang->getTranslationTable();
$searchString = Input::Get('search_string', 'string', '', true); $searchString = Input::Get('search_string', 'string', '', true);
if (!empty($searchString)) { if (!empty($searchString)) {
@ -88,8 +88,8 @@ function translationForm($p_request)
$missingStrings = Localizer::FindMissingStrings($prefix); $missingStrings = Localizer::FindMissingStrings($prefix);
$unusedStrings = Localizer::FindUnusedStrings($prefix); $unusedStrings = Localizer::FindUnusedStrings($prefix);
} }
// Mapping of language prefixes to human-readable strings. // Mapping of language prefixes to human-readable strings.
$mapPrefixToDisplay[] = ''; $mapPrefixToDisplay[] = '';
@ -99,14 +99,14 @@ function translationForm($p_request)
// Whether to show translated strings or not. // Whether to show translated strings or not.
$hideTranslated = ''; $hideTranslated = '';
if (isset($p_request['hide_translated'])) { if (isset($p_request['hide_translated'])) {
$hideTranslated = "CHECKED"; $hideTranslated = "CHECKED";
} }
?> ?>
<table> <table>
<tr> <tr>
<td valign="top"> <!-- Begin top control panel --> <td valign="top"> <!-- Begin top control panel -->
<table border="0" style="background-color: #d5e2ee; border: 1px solid #8baed1; margin-left: 10px; margin-top: 5px;" width="700px;"> <table border="0" style="background-color: #d5e2ee; border: 1px solid #8baed1; margin-left: 10px; margin-top: 5px;" width="700px;">
<form action="index.php" method="post"> <form action="index.php" method="post">
<INPUT TYPE="hidden" name="action" value="translate"> <INPUT TYPE="hidden" name="action" value="translate">
@ -148,7 +148,7 @@ function translationForm($p_request)
</tr> </tr>
</table> </table>
</td> </td>
<td> <td>
<table> <table>
<tr> <tr>
@ -176,20 +176,20 @@ function translationForm($p_request)
<tr> <tr>
<td> <td>
<input type="checkbox" name="hide_translated" value="" <?php echo $hideTranslated; ?> class="input_checkbox" onchange="this.form.submit();"><?php putGS('Hide translated strings?'); ?> <input type="checkbox" name="hide_translated" value="" <?php echo $hideTranslated; ?> class="input_checkbox" onchange="this.form.submit();"><?php putGS('Hide translated strings?'); ?>
</td> </td>
</tr> </tr>
</table> </table>
</td> </td>
</tr> </tr>
</form> </form>
</table> </table>
</td><!-- End top controls --> </td><!-- End top controls -->
</tr> </tr>
<!-- Begin search dialog --> <!-- Begin search dialog -->
<tr> <tr>
<td valign="top"> <td valign="top">
<table border="0" style="background-color: #FAEFFF; border: 1px solid black; margin-left: 10px;" width="700px;" align="center"> <table border="0" style="background-color: #FAEFFF; border: 1px solid black; margin-left: 10px;" width="700px;" align="center">
<form> <form>
<input type="hidden" name="action" value="translate"> <input type="hidden" name="action" value="translate">
@ -203,7 +203,7 @@ function translationForm($p_request)
<td width="1%" style="padding-left: 5px;"> <td width="1%" style="padding-left: 5px;">
<img src="<?php echo $g_localizerConfig['ICONS_DIR']; ?>/preview.png"> <img src="<?php echo $g_localizerConfig['ICONS_DIR']; ?>/preview.png">
</td> </td>
<td style="padding-left: 10px;"> <td style="padding-left: 10px;">
<input type="text" name="search_string" value="<?php echo $searchString; ?>" class="input_text" size="50"> <input type="text" name="search_string" value="<?php echo $searchString; ?>" class="input_text" size="50">
</td> </td>
@ -216,12 +216,12 @@ function translationForm($p_request)
</table> </table>
</td> </td>
</tr> </tr>
<!-- Begin Missing and Unused Strings popups --> <!-- Begin Missing and Unused Strings popups -->
<tr> <tr>
<td valign="top"> <td valign="top">
<?PHP <?PHP
if ((count($missingStrings) > 0) && ($screenDropDownSelection != 'globals')) { if ((count($missingStrings) > 0) && ($screenDropDownSelection != 'globals')) {
?> ?>
<table align="center" style="background-color: #EDFFDF; border: 1px solid #357654; margin-left: 10px;" width="700px"> <table align="center" style="background-color: #EDFFDF; border: 1px solid #357654; margin-left: 10px;" width="700px">
@ -237,7 +237,7 @@ function translationForm($p_request)
<td> <td>
<img src="<?php echo $g_localizerConfig['ICONS_DIR']; ?>/add.png"> <img src="<?php echo $g_localizerConfig['ICONS_DIR']; ?>/add.png">
</td> </td>
<td> <td>
<?php putGS("The following strings are missing from the translation files:"); ?> <?php putGS("The following strings are missing from the translation files:"); ?>
<div style="overflow: auto; height: 50px; background-color: #EEEEEE; border: 1px solid black; padding-left: 3px;"> <div style="overflow: auto; height: 50px; background-color: #EEEEEE; border: 1px solid black; padding-left: 3px;">
@ -248,16 +248,16 @@ function translationForm($p_request)
?> ?>
</div> </div>
</td> </td>
<td> <td>
<input type="submit" value="<?php putGS("Add"); ?>" class="button"> <input type="submit" value="<?php putGS("Add"); ?>" class="button">
</td> </td>
</tr> </tr>
</form> </form>
</table> </table>
<?php <?php
} }
if ((count($unusedStrings) > 0) && ($screenDropDownSelection != 'globals')) { if ((count($unusedStrings) > 0) && ($screenDropDownSelection != 'globals')) {
?> ?>
<table style="background-color: #FFE0DF; border: 1px solid #C51325; margin-top: 3px; margin-left: 10px; margin-bottom: 5px;" width="700px"> <table style="background-color: #FFE0DF; border: 1px solid #C51325; margin-top: 3px; margin-left: 10px; margin-bottom: 5px;" width="700px">
@ -273,7 +273,7 @@ function translationForm($p_request)
<td> <td>
<img src="<?php echo $g_localizerConfig['ICONS_DIR']; ?>/delete.png"> <img src="<?php echo $g_localizerConfig['ICONS_DIR']; ?>/delete.png">
</td> </td>
<td> <td>
<?php putGS("The following strings are not used:"); ?> <?php putGS("The following strings are not used:"); ?>
<div style="overflow: auto; height: 50px; background-color: #EEEEEE; border: 1px solid black; padding-left: 3px;"> <div style="overflow: auto; height: 50px; background-color: #EEEEEE; border: 1px solid black; padding-left: 3px;">
@ -284,15 +284,15 @@ function translationForm($p_request)
?> ?>
</div> </div>
</td> </td>
<td> <td>
<input type="submit" value="<?php putGS("Delete"); ?>" class="button"> <input type="submit" value="<?php putGS("Delete"); ?>" class="button">
</td> </td>
</tr> </tr>
</form> </form>
</table> </table>
<?php <?php
} }
?> ?>
<!-- Begin translated strings box --> <!-- Begin translated strings box -->
<table border="0" class="table_input" style="padding-left: 10px; padding-bottom: 10px; margin-left: 10px;" width="700px"> <table border="0" class="table_input" style="padding-left: 10px; padding-bottom: 10px; margin-left: 10px;" width="700px">
@ -305,11 +305,11 @@ function translationForm($p_request)
<INPUT TYPE="hidden" name="localizer_target_language" value="<?php echo $targetLang->getLanguageId(); ?>"> <INPUT TYPE="hidden" name="localizer_target_language" value="<?php echo $targetLang->getLanguageId(); ?>">
<INPUT TYPE="hidden" name="localizer_source_language" value="<?php echo $sourceLang->getLanguageId(); ?>"> <INPUT TYPE="hidden" name="localizer_source_language" value="<?php echo $sourceLang->getLanguageId(); ?>">
<INPUT TYPE="hidden" name="search_string" value="<?php echo $searchString; ?>"> <INPUT TYPE="hidden" name="search_string" value="<?php echo $searchString; ?>">
<?PHP <?PHP
$foundUntranslatedString = false; $foundUntranslatedString = false;
$count = 0; $count = 0;
foreach ($sourceStrings as $sourceKey => $sourceValue) { foreach ($sourceStrings as $sourceKey => $sourceValue) {
if (!empty($targetStrings[$sourceKey])) { if (!empty($targetStrings[$sourceKey])) {
#$targetValueDisplay = str_replace('"', '&#34;', $targetStrings[$sourceKey]); #$targetValueDisplay = str_replace('"', '&#34;', $targetStrings[$sourceKey]);
#$targetValueDisplay = str_replace("\\", "\\\\", $targetValueDisplay); #$targetValueDisplay = str_replace("\\", "\\\\", $targetValueDisplay);
@ -321,31 +321,31 @@ function translationForm($p_request)
$pre = '<FONT COLOR="red">'; $pre = '<FONT COLOR="red">';
$post = '</FONT>'; $post = '</FONT>';
} }
$sourceKeyDisplay = htmlspecialchars(str_replace("\\", "\\\\", $sourceKey)); $sourceKeyDisplay = htmlspecialchars(str_replace("\\", "\\\\", $sourceKey));
// Dont display translated strings // Dont display translated strings
if (isset($p_request['hide_translated']) && !empty($targetStrings[$sourceKey])) { if (isset($p_request['hide_translated']) && !empty($targetStrings[$sourceKey])) {
?> ?>
<input name="data[<?php echo $count; ?>][key]" type="hidden" value="<?php echo $sourceKeyDisplay; ?>"> <input name="data[<?php echo $count; ?>][key]" type="hidden" value="<?php echo $sourceKeyDisplay; ?>">
<input name="data[<?php echo $count; ?>][value]" type="hidden" value="<?php echo $targetValueDisplay; ?>"> <input name="data[<?php echo $count; ?>][value]" type="hidden" value="<?php echo $targetValueDisplay; ?>">
<?php <?php
} }
else { else {
// Display the interface for translating a string. // Display the interface for translating a string.
$foundUntranslatedString = true; $foundUntranslatedString = true;
// Display string // Display string
?> ?>
<tr> <tr>
<td style="padding-top: 7px;" width="500px"> <td style="padding-top: 7px;" width="500px">
<?php <?php
// If the string exists in the target language, display that // If the string exists in the target language, display that
if (!empty($sourceValue)) { if (!empty($sourceValue)) {
?> ?>
<b><?php echo $sourceLang->getLanguageId(); ?>:</b> <?php echo $pre.htmlspecialchars(str_replace("\\", "\\\\", $sourceValue)).$post; ?> <b><?php echo $sourceLang->getLanguageId(); ?>:</b> <?php echo $pre.htmlspecialchars(str_replace("\\", "\\\\", $sourceValue)).$post; ?>
<?php <?php
} }
// Otherwise, display it in the default language. // Otherwise, display it in the default language.
else { else {
// If key is translated in default lang, display that // If key is translated in default lang, display that
@ -357,8 +357,8 @@ function translationForm($p_request)
} else { } else {
?> ?>
<b>Key:</b> <?php echo $pre.$sourceKey.$post; ?> <b>Key:</b> <?php echo $pre.$sourceKey.$post; ?>
<?php <?php
} }
} }
?> ?>
</td> </td>
@ -377,31 +377,31 @@ function translationForm($p_request)
<?php <?php
// default language => can change keys // default language => can change keys
if ($targetLang->getLanguageId() == $g_localizerConfig['DEFAULT_LANGUAGE']) { if ($targetLang->getLanguageId() == $g_localizerConfig['DEFAULT_LANGUAGE']) {
$fileparms = "localizer_target_language=".$targetLang->getLanguageId() $fileparms = "localizer_target_language=".$targetLang->getLanguageId()
."&localizer_source_language=".$sourceLang->getLanguageId() ."&localizer_source_language=".$sourceLang->getLanguageId()
."&prefix=".urlencode($screenDropDownSelection) ."&prefix=".urlencode($screenDropDownSelection)
."&search_string=".urlencode($searchString); ."&search_string=".urlencode($searchString);
if (!empty($hideTranslated)) { if (!empty($hideTranslated)) {
$fileparms .= "&hide_translated=on"; $fileparms .= "&hide_translated=on";
} }
if ($count == 0) { if ($count == 0) {
// swap last and first entry // swap last and first entry
$prev = count($sourceStrings)-1; $prev = count($sourceStrings)-1;
$next = $count+1; $next = $count+1;
} }
elseif ($count == count($sourceStrings)-1) { elseif ($count == count($sourceStrings)-1) {
// swap last and first entry // swap last and first entry
$prev = $count-1; $prev = $count-1;
$next = 0; $next = 0;
} }
else { else {
// swap entrys linear // swap entrys linear
$prev = $count-1; $prev = $count-1;
$next = $count+1; $next = $count+1;
} }
$removeLink = "?action=remove_string&pos=$count&$fileparms" $removeLink = "?action=remove_string&pos=$count&$fileparms"
."&string=".urlencode($sourceKey); ."&string=".urlencode($sourceKey);
$moveUpLink = "?action=move_string&pos1=$count&pos2=$prev&$fileparms"; $moveUpLink = "?action=move_string&pos1=$count&pos2=$prev&$fileparms";
@ -420,13 +420,13 @@ function translationForm($p_request)
<td style="padding-left: 3px;"> <td style="padding-left: 3px;">
<a href="<?php echo $removeLink; ?>" onClick="return confirm('<?php putGS('Are you sure you want to delete this entry?'); ?>');"><img src="<?php echo $g_localizerConfig['ICONS_DIR']; ?>/delete.png" border="0" vspace="4"></a> <a href="<?php echo $removeLink; ?>" onClick="return confirm('<?php putGS('Are you sure you want to delete this entry?'); ?>');"><img src="<?php echo $g_localizerConfig['ICONS_DIR']; ?>/delete.png" border="0" vspace="4"></a>
</td> </td>
<?php <?php
} }
?> ?>
</tr> </tr>
</table> </table>
</td> </td>
</tr> </tr>
<?php <?php
} }
@ -441,24 +441,24 @@ function translationForm($p_request)
else { else {
?> ?>
<tr><td align="center" style="padding-top: 10px; font-weight: bold;"><?php putGS("No matches found.");?> </td></tr> <tr><td align="center" style="padding-top: 10px; font-weight: bold;"><?php putGS("No matches found.");?> </td></tr>
<?php <?php
} }
} }
elseif (!$foundUntranslatedString) { elseif (!$foundUntranslatedString) {
if (empty($searchString)) { if (empty($searchString)) {
?> ?>
<tr><td align="center" style="padding-top: 10px; font-weight: bold;"><?php putGS("All strings have been translated."); ?></td></tr> <tr><td align="center" style="padding-top: 10px; font-weight: bold;"><?php putGS("All strings have been translated."); ?></td></tr>
<?php <?php
} }
else { else {
?> ?>
<tr><td align="center" style="padding-top: 10px; font-weight: bold;"><?php putGS("No matches found.");?> </td></tr> <tr><td align="center" style="padding-top: 10px; font-weight: bold;"><?php putGS("No matches found.");?> </td></tr>
<?php <?php
} }
} }
?> ?>
</table> </table>
<table style="margin-left: 8px; margin-top: 5px;"> <table style="margin-left: 8px; margin-top: 5px;">
<tr> <tr>
<td> <td>
@ -467,7 +467,7 @@ function translationForm($p_request)
</tr> </tr>
</table> </table>
</form> </form>
</td> <!-- End translate strings box --> </td> <!-- End translate strings box -->
</tr> </tr>
</table> </table>

View file

@ -115,56 +115,48 @@ function _getNumArr($start, $end, $step=1)
*/ */
class uiBase class uiBase
{ {
var $redirUrl; public $gb; // GreenBox
var $alertMsg; public $STATIONPREFS;
var $dbc; public $SCRATCHPAD;
var $gb; // GreenBox public $SEARCH;
var $config; public $BROWSE;
var $sessid; // Note: loading HUBBROWSE on every page load slows things down
var $userid; // a lot. we only load it on demand.
var $login; //public $HUBBROWSE;
var $langid; public $HUBSEARCH;
var $id; public $PLAYLIST;
var $pid; public $SCHEDULER;
var $type; public $SUBJECTS;
var $fid; public $EXCHANGE;
var $homeid; public $TRANSFERS;
var $InputTextStandardAttrib; public $redirUrl;
var $STATIONPREFS; public $dbc;
var $SCRATCHPAD; public $config;
var $SEARCH; public $sessid;
var $BROWSE; public $userid;
var $HUBBROWSE; public $login;
var $HUBSEARCH; public $id;
var $PLAYLIST; public $langid;
var $SCHEDULER; public $pid;
var $SUBJECTS; public $type;
var $EXCHANGE; public $fid;
var $TRANSFERS; public $homeid;
var $_self_; public $alertMsg;
/** /**
* uiBase * @param array $config
*
* Initialize a new Basis Class including:
* - database initialation
* - GreenBox initialation
*
* @param array $config
* configurartion data * configurartion data
*/ */
function uiBase(&$config) public function __construct(&$config)
{ {
$this->dbc = DB::connect($config['dsn'], TRUE); $this->dbc = DB::connect($config['dsn'], TRUE);
if (DB::isError($this->dbc)) { if (DB::isError($this->dbc)) {
die($this->dbc->getMessage()); die($this->dbc->getMessage());
} }
$this->dbc->setFetchMode(DB_FETCHMODE_ASSOC); $this->dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$this->gb =& new GreenBox($this->dbc, $config); $this->gb = new GreenBox($this->dbc, $config);
$this->config =& $config; $this->config =& $config;
$this->config['accessRawAudioUrl'] = $config['storageUrlPath'].'/xmlrpc/simpleGet.php'; $this->config['accessRawAudioUrl'] = $config['storageUrlPath'].'/xmlrpc/simpleGet.php';
$this->sessid = isset($_REQUEST[$config['authCookieName']]) ? $this->sessid = isset($_REQUEST[$config['authCookieName']]) ?
$_REQUEST[$config['authCookieName']] : null; $_REQUEST[$config['authCookieName']] : null;
$this->userid = $this->gb->getSessUserId($this->sessid); $this->userid = $this->gb->getSessUserId($this->sessid);
@ -187,21 +179,23 @@ class uiBase
$this->homeid = $this->gb->getObjId($this->login, $this->gb->storId); $this->homeid = $this->gb->getObjId($this->login, $this->gb->storId);
} }
$this->InputTextStandardAttrib = array('size'=>UI_INPUT_STANDARD_SIZE, }
'maxlength'=>UI_INPUT_STANDARD_MAXLENGTH);
public function init()
{
$this->STATIONPREFS =& $_SESSION[UI_STATIONINFO_SESSNAME]; $this->STATIONPREFS =& $_SESSION[UI_STATIONINFO_SESSNAME];
$this->SCRATCHPAD =& new uiScratchPad($this); $this->SCRATCHPAD = new uiScratchPad($this);
$this->SEARCH =& new uiSearch($this); $this->SEARCH = new uiSearch($this);
$this->BROWSE =& new uiBrowse($this); $this->BROWSE = new uiBrowse($this);
$this->HUBBROWSE =& new uiHubBrowse($this); //$this->HUBBROWSE = new uiHubBrowse($this);
$this->HUBSEARCH =& new uiHubSearch($this); $this->HUBSEARCH = new uiHubSearch($this);
$this->PLAYLIST =& new uiPlaylist($this); $this->PLAYLIST = new uiPlaylist($this);
$this->SCHEDULER =& new uiScheduler($this); $this->SCHEDULER = new uiScheduler($this);
$this->SUBJECTS =& new uiSubjects($this); $this->SUBJECTS = new uiSubjects($this);
$this->EXCHANGE =& new uiExchange($this); $this->EXCHANGE = new uiExchange($this);
$this->TRANSFERS =& new uiTransfers($this); $this->TRANSFERS = new uiTransfers($this);
$this->_self_ =& $this; }
} // fn uiBase
/** /**
@ -210,7 +204,7 @@ class uiBase
* @param array $mask * @param array $mask
* @param boolean $reload * @param boolean $reload
*/ */
function loadStationPrefs(&$mask, $reload=FALSE) public function loadStationPrefs(&$mask, $reload=FALSE)
{ {
if (!is_array($this->STATIONPREFS) || ($reload === TRUE) ) { if (!is_array($this->STATIONPREFS) || ($reload === TRUE) ) {
$this->STATIONPREFS = array(); $this->STATIONPREFS = array();
@ -230,8 +224,6 @@ class uiBase
/** /**
* _parseArr2Form
*
* Add elements/rules/groups to an given HTML_QuickForm object * Add elements/rules/groups to an given HTML_QuickForm object
* *
* @param HTML_Quickform $form * @param HTML_Quickform $form
@ -241,7 +233,7 @@ class uiBase
* @param string $side * @param string $side
* can be 'client' or 'server' - this is where the form validation occurs. * can be 'client' or 'server' - this is where the form validation occurs.
*/ */
function _parseArr2Form(&$form, &$mask, $side='client') public static function parseArrayToForm(&$form, &$mask, $side='client')
{ {
foreach ($mask as $v) { foreach ($mask as $v) {
$attrs = isset($v['attributes']) ? $v['attributes'] : null; $attrs = isset($v['attributes']) ? $v['attributes'] : null;
@ -347,7 +339,7 @@ class uiBase
reset($mask); reset($mask);
$form->validate(); $form->validate();
} // fn _parseArr2Form } // fn parseArrayToForm
/** /**
@ -356,21 +348,21 @@ class uiBase
* @param array $input * @param array $input
* array of form-elements * array of form-elements
*/ */
function _dateArr2Str(&$input) // function _dateArr2Str(&$input)
{ // {
foreach ($input as $k => $v){ // foreach ($input as $k => $v){
if (is_array($v)) { // if (is_array($v)) {
if ( ( isset($v['d']) ) && ( isset($v['M']) || isset($v['m']) ) && ( isset($v['Y']) || isset($v['y']) ) ) { // if ( ( isset($v['d']) ) && ( isset($v['M']) || isset($v['m']) ) && ( isset($v['Y']) || isset($v['y']) ) ) {
$input[$k] = $v['Y'].$v['y'].'-'.sprintf('%02d', $v['M'].$v['m']).'-'.sprintf('%02d', $v['d']); // $input[$k] = $v['Y'].$v['y'].'-'.sprintf('%02d', $v['M'].$v['m']).'-'.sprintf('%02d', $v['d']);
} // }
if ( ( isset($v['H']) ) || isset($v['h'] ) && ( isset($v['i']) ) && ( isset($v['s']) ) ) { // if ( ( isset($v['H']) ) || isset($v['h'] ) && ( isset($v['i']) ) && ( isset($v['s']) ) ) {
$input[$k] = sprintf('%02d', $v['H'].$v['h']).':'.sprintf('%02d', $v['i']).':'.sprintf('%02d', $v['s']); // $input[$k] = sprintf('%02d', $v['H'].$v['h']).':'.sprintf('%02d', $v['i']).':'.sprintf('%02d', $v['s']);
} // }
} // }
} // }
//
return $input; // return $input;
} // fn _dateArr2Str // } // fn _dateArr2Str
/** /**
@ -380,7 +372,7 @@ class uiBase
* local ID of file * local ID of file
* @param string $format * @param string $format
*/ */
function _analyzeFile($id, $format) public function analyzeFile($id, $format)
{ {
$ia = $this->gb->analyzeFile($id, $this->sessid); $ia = $this->gb->analyzeFile($id, $this->sessid);
$s = $ia['playtime_seconds']; $s = $ia['playtime_seconds'];
@ -404,23 +396,23 @@ class uiBase
</audioClip>'; </audioClip>';
} }
return FALSE; return FALSE;
} // fn _analyzeFile } // fn analyzeFile
function _toHex($gunid) public function toHex($gunid)
{ {
$res = $this->dbc->query("SELECT to_hex($gunid)"); $res = $this->dbc->query("SELECT to_hex($gunid)");
$row = $res->fetchRow(); $row = $res->fetchRow();
return $row['to_hex']; return $row['to_hex'];
} // fn _toHex } // fn toHex
function _toInt8($gunid) public function toInt8($gunid)
{ {
$res = $this->dbc->query("SELECT x'$gunid'::bigint"); $res = $this->dbc->query("SELECT x'$gunid'::bigint");
$row = $res->fetchRow(); $row = $res->fetchRow();
return $row['int8']; return $row['int8'];
} // fn _toInt8 } // fn toInt8
/** /**
@ -438,7 +430,7 @@ class uiBase
* @param string $p8 * @param string $p8
* @param string $p9 * @param string $p9
*/ */
function _retMsg($msg, $p1=NULL, $p2=NULL, $p3=NULL, $p4=NULL, $p5=NULL, $p6=NULL, $p7=NULL, $p8=NULL, $p9=NULL) public function _retMsg($msg, $p1=NULL, $p2=NULL, $p3=NULL, $p4=NULL, $p5=NULL, $p6=NULL, $p7=NULL, $p8=NULL, $p9=NULL)
{ {
if (!isset($_SESSION['alertMsg'])) { if (!isset($_SESSION['alertMsg'])) {
$_SESSION['alertMsg'] = ''; $_SESSION['alertMsg'] = '';
@ -447,22 +439,22 @@ class uiBase
} // fn _retMsg } // fn _retMsg
function _getMetaInfo($id) public function getMetaInfo($id)
{ {
$type = strtolower($this->gb->getFileType($id)); $type = strtolower($this->gb->getFileType($id));
$data = array('id' => $id, $data = array('id' => $id,
'gunid' => $this->gb->_gunidFromId($id), 'gunid' => $this->gb->_gunidFromId($id),
'title' => $this->_getMDataValue($id, UI_MDATA_KEY_TITLE), 'title' => $this->getMetadataValue($id, UI_MDATA_KEY_TITLE),
'creator' => $this->_getMDataValue($id, UI_MDATA_KEY_CREATOR), 'creator' => $this->getMetadataValue($id, UI_MDATA_KEY_CREATOR),
'duration' => $this->_getMDataValue($id, UI_MDATA_KEY_DURATION), 'duration' => $this->getMetadataValue($id, UI_MDATA_KEY_DURATION),
'type' => $type, 'type' => $type,
#'isAvailable' => $type == 'playlist' ? $this->gb->playlistIsAvailable($id, $this->sessid) : NULL, #'isAvailable' => $type == 'playlist' ? $this->gb->playlistIsAvailable($id, $this->sessid) : NULL,
); );
return ($data); return ($data);
} // fn _getMetaInfo } // fn getMetaInfo
function _getMDataValue($id, $key, $langid=NULL, $deflangid=UI_DEFAULT_LANGID) public function getMetadataValue($id, $key, $langid=NULL, $deflangid=UI_DEFAULT_LANGID)
{ {
if (!$langid) { if (!$langid) {
$langid = $_SESSION['langid']; $langid = $_SESSION['langid'];
@ -473,10 +465,10 @@ class uiBase
return $value['value']; return $value['value'];
} }
return FALSE; return FALSE;
} // fn _getMDataValue } // fn getMetadataValue
function _setMDataValue($id, $key, $value, $langid=NULL) public function setMetadataValue($id, $key, $value, $langid=NULL)
{ {
if (!$langid) { if (!$langid) {
$langid = UI_DEFAULT_LANGID; $langid = UI_DEFAULT_LANGID;
@ -489,16 +481,14 @@ class uiBase
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} // fn _setMDataValue } // fn setMetadataValue
/** /**
* Enter description here...
*
* @param unknown_type $id * @param unknown_type $id
* @return string/FALSE * @return string/FALSE
*/ */
function _getFileTitle($id) private function _getFileTitle($id)
{ {
if (is_array($arr = $this->gb->getPath($id))) { if (is_array($arr = $this->gb->getPath($id))) {
$file = array_pop($arr); $file = array_pop($arr);
@ -508,29 +498,29 @@ class uiBase
} // fn _getFileTitle } // fn _getFileTitle
function _isFolder($id) // function _isFolder($id)
{ // {
if (strtolower($this->gb->getFileType($id)) != 'folder') { // if (strtolower($this->gb->getFileType($id)) != 'folder') {
return FALSE; // return FALSE;
} // }
return TRUE; // return TRUE;
} // fn _isFolder // } // fn _isFolder
function _formElementEncode($str) public static function formElementEncode($str)
{ {
$str = str_replace(':', '__', $str); $str = str_replace(':', '__', $str);
#$str = str_replace('.', '_', $str); #$str = str_replace('.', '_', $str);
return $str; return $str;
} // fn _formElementEncode } // fn formElementEncode
function _formElementDecode($str) public static function formElementDecode($str)
{ {
$str = str_replace('__', ':', $str); $str = str_replace('__', ':', $str);
#$str = str_replace('_', '.', $str); #$str = str_replace('_', '.', $str);
return $str; return $str;
} // fn _formElementDecode } // fn formElementDecode
} // class uiBase } // class uiBase
?> ?>

View file

@ -6,31 +6,31 @@
*/ */
class uiBrowse class uiBrowse
{ {
var $Base; // uiBase object public $Base; // uiBase object
var $prefix; private $prefix;
var $col; private $col;
var $criteria; private $criteria;
var $reloadUrl; private $reloadUrl;
function uiBrowse(&$uiBase) public function __construct(&$uiBase)
{ {
$this->Base =& $uiBase; $this->Base =& $uiBase;
$this->prefix = 'BROWSE'; $this->prefix = 'BROWSE';
$this->col =& $_SESSION[constant('UI_'.$this->prefix.'_SESSNAME')]['col']; $this->col =& $_SESSION[constant('UI_'.$this->prefix.'_SESSNAME')]['col'];
$this->criteria =& $_SESSION[constant('UI_'.$this->prefix.'_SESSNAME')]['criteria']; $this->criteria =& $_SESSION[constant('UI_'.$this->prefix.'_SESSNAME')]['criteria'];
#$this->results =& $_SESSION[constant('UI_'.$this->prefix.'_SESSNAME')]['results']; //$this->results =& $_SESSION[constant('UI_'.$this->prefix.'_SESSNAME')]['results'];
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close'; $this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
if (empty($this->criteria['limit'])) { if (empty($this->criteria['limit'])) {
$this->criteria['limit'] = UI_BROWSE_DEFAULT_LIMIT; $this->criteria['limit'] = UI_BROWSE_DEFAULT_LIMIT;
} }
if (empty($this->criteria['filetype'])) { if (empty($this->criteria['filetype'])) {
$this->criteria['filetype'] = UI_FILETYPE_ANY; $this->criteria['filetype'] = UI_FILETYPE_ANY;
} }
if (!is_array($this->col)) { if (!is_array($this->col)) {
## init Categorys // init Categorys
$this->setDefaults(); $this->setDefaults();
} }
} // constructor } // constructor
@ -89,7 +89,7 @@ class uiBrowse
foreach ($mask['pages'] as $key => $val) { foreach ($mask['pages'] as $key => $val) {
foreach ($mask['pages'][$key] as $v){ foreach ($mask['pages'][$key] as $v){
if (isset($v['type']) && $v['type']) { if (isset($v['type']) && $v['type']) {
$tmp = $this->Base->_formElementEncode($v['element']); $tmp = uiBase::formElementEncode($v['element']);
$mask2['browse_columns']['category']['options'][$tmp] = tra($v['label']); $mask2['browse_columns']['category']['options'][$tmp] = tra($v['label']);
} }
} }
@ -99,22 +99,22 @@ class uiBrowse
$form = new HTML_QuickForm('col'.$n, UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('col'.$n, UI_STANDARD_FORM_METHOD, UI_HANDLER);
$form->setConstants(array('id' => $id, $form->setConstants(array('id' => $id,
'col' => $n, 'col' => $n,
'category' => $this->Base->_formElementEncode($this->col[$n]['category']))); 'category' => uiBase::formElementEncode($this->col[$n]['category'])));
$mask2['browse_columns']['value']['options'] = $this->options($this->col[$n]['values']['results']); $mask2['browse_columns']['value']['options'] = $this->options($this->col[$n]['values']['results']);
$mask2['browse_columns']['value']['default'] = $this->col[$n]['form_value']; $mask2['browse_columns']['value']['default'] = $this->col[$n]['form_value'];
$this->Base->_parseArr2Form($form, $mask2['browse_columns']); uiBase::parseArrayToForm($form, $mask2['browse_columns']);
$form->validate(); $form->validate();
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
$output['col'.$n]['dynform'] = $renderer->toArray(); $output['col'.$n]['dynform'] = $renderer->toArray();
} }
## form to change limit and file-type ## form to change limit and file-type
$form = new HTML_QuickForm('switch', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('switch', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$this->Base->_parseArr2Form($form, $mask2['browse_global']); uiBase::parseArrayToForm($form, $mask2['browse_global']);
$form->setDefaults(array('limit' => $this->criteria['limit'], $form->setDefaults(array('limit' => $this->criteria['limit'],
'filetype' => $this->criteria['filetype'])); 'filetype' => $this->criteria['filetype']));
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
$output['global']['dynform'] = $renderer->toArray(); $output['global']['dynform'] = $renderer->toArray();
@ -123,19 +123,31 @@ class uiBrowse
/** /**
* Set the category for audio file browser. There are three columns
* you can set the category for.
*
* @param array $parm * @param array $parm
* Has keys:
* int 'col' - the column you are setting the category for
* string 'category' - the category for the given column
* string 'value' - the
* @return void * @return void
*/ */
function setCategory($parm) public function setCategory($parm)
{ {
$which = $parm['col']; // $reflect = new ReflectionProperty('uiBrowse', 'Base');
$this->col[$which]['category'] = $this->Base->_formElementDecode($parm['category']); // echo "<pre>";print_r(Reflection::getModifierNames($reflect->getModifiers()));echo "</pre>";
$criteria = isset($this->col[$which]['criteria']) ? $this->col[$which]['criteria'] : null;
$this->col[$which]['values'] = $this->Base->gb->browseCategory($this->col[$which]['category'], $criteria, $this->Base->sessid); $columnNumber = $parm['col'];
$category = $parm['category'];
$this->col[$columnNumber]['category'] = uiBase::formElementDecode($category);
$criteria = isset($this->col[$columnNumber]['criteria']) ? $this->col[$columnNumber]['criteria'] : null;
// print_r($this->Base->gb);
$this->col[$columnNumber]['values'] = $this->Base->gb->browseCategory($this->col[$columnNumber]['category'], $criteria, $this->Base->sessid);
$this->Base->redirUrl = UI_BROWSER.'?act='.$this->prefix; $this->Base->redirUrl = UI_BROWSER.'?act='.$this->prefix;
$this->clearHierarchy($columnNumber);
$this->clearHierarchy($which);
#print_r($this->col); #print_r($this->col);
} // fn setCategory } // fn setCategory
@ -150,7 +162,8 @@ class uiBrowse
$next = $which + 1; $next = $which + 1;
$this->col[$which]['form_value'] = $parm['value'][0]; $this->col[$which]['form_value'] = $parm['value'][0];
if ($parm['value'][0] == '%%all%%') { if ($parm['value'][0] == '%%all%%') {
$this->col[$next]['criteria'] = array('operator' => 'and', 'filetype' => $this->criteria['filetype']); $this->col[$next]['criteria'] = array('operator' => 'and',
'filetype' => $this->criteria['filetype']);
} else { } else {
$this->col[$next]['criteria'] = array( $this->col[$next]['criteria'] = array(
'operator' => 'and', 'operator' => 'and',
@ -158,7 +171,7 @@ class uiBrowse
'conditions' => array_merge( 'conditions' => array_merge(
is_array($this->col[$which]['criteria']['conditions']) ? $this->col[$which]['criteria']['conditions'] : array(), is_array($this->col[$which]['criteria']['conditions']) ? $this->col[$which]['criteria']['conditions'] : array(),
array( array(
array('cat' => $this->Base->_formElementDecode($parm['category']), array('cat' => uiBase::formElementDecode($parm['category']),
'op' => '=', 'op' => '=',
'val' => $parm['value'][0] 'val' => $parm['value'][0]
) )
@ -232,7 +245,7 @@ class uiBrowse
$this->results['cnt'] = $results['cnt']; $this->results['cnt'] = $results['cnt'];
foreach ($results['results'] as $rec) { foreach ($results['results'] as $rec) {
$tmpId = $this->Base->gb->_idFromGunid($rec["gunid"]); $tmpId = $this->Base->gb->_idFromGunid($rec["gunid"]);
$this->results['items'][] = $this->Base->_getMetaInfo($tmpId); $this->results['items'][] = $this->Base->getMetaInfo($tmpId);
} }
/* /*

View file

@ -5,7 +5,6 @@
* @version $Revision$ * @version $Revision$
*/ */
class uiBrowser extends uiBase { class uiBrowser extends uiBase {
var $alertMsg;
// --- class constructor --- // --- class constructor ---
/** /**
@ -15,9 +14,9 @@ class uiBrowser extends uiBase {
* @param array $config * @param array $config
* configurartion data * configurartion data
*/ */
function uiBrowser(&$config) public function __construct(&$config)
{ {
$this->uiBase($config); parent::__construct($config);
} // constructor } // constructor
@ -71,12 +70,10 @@ class uiBrowser extends uiBase {
function login($mask) function login($mask)
{ {
$form = new HTML_QuickForm('login', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('login', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$this->_parseArr2Form($form, $mask['languages']); uiBase::parseArrayToForm($form, $mask['languages']);
$this->_parseArr2Form($form, $mask['login']); uiBase::parseArrayToForm($form, $mask['login']);
$renderer = new HTML_QuickForm_Renderer_Array(true, true);
$renderer =& new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
return $renderer->toArray(); return $renderer->toArray();
} // fn login } // fn login
@ -123,7 +120,7 @@ class uiBrowser extends uiBase {
} }
foreach ($data['listdata'] as $key=>$val) { foreach ($data['listdata'] as $key=>$val) {
if ($val['type'] != 'Folder') { if ($val['type'] != 'Folder') {
$data['listdata'][$key]['title'] = $this->_getMDataValue($val['id'], UI_MDATA_KEY_TITLE); $data['listdata'][$key]['title'] = $this->getMetadataValue($val['id'], UI_MDATA_KEY_TITLE);
} else { } else {
$data['listdata'][$key]['title'] = $val['name']; $data['listdata'][$key]['title'] = $val['name'];
} }
@ -153,8 +150,8 @@ class uiBrowser extends uiBase {
$form->setConstants(array('folderId' => $folderId, $form->setConstants(array('folderId' => $folderId,
'id' => $id, 'id' => $id,
'act' => $id ? 'editItem' : 'addFileData')); 'act' => $id ? 'editItem' : 'addFileData'));
$this->_parseArr2Form($form, $mask); uiBase::parseArrayToForm($form, $mask);
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
return $renderer->toArray(); return $renderer->toArray();
} // fn fileForm } // fn fileForm
@ -177,12 +174,12 @@ class uiBrowser extends uiBase {
$const = array('folderId' => $folderId, $const = array('folderId' => $folderId,
'id' => $id, 'id' => $id,
'act' => $id ? 'editWebstreamData' : 'addWebstreamData', 'act' => $id ? 'editWebstreamData' : 'addWebstreamData',
'title' => $id ? $this->_getMDataValue($id, UI_MDATA_KEY_TITLE) : NULL, 'title' => $id ? $this->getMetadataValue($id, UI_MDATA_KEY_TITLE) : NULL,
'url' => $id ? $this->_getMDataValue($id, UI_MDATA_KEY_URL) : 'http://', 'url' => $id ? $this->getMetadataValue($id, UI_MDATA_KEY_URL) : 'http://',
'length' => $id ? preg_replace("/\.[0-9]{1,6}/", "", $this->_getMDataValue($id, UI_MDATA_KEY_DURATION)) : NULL 'length' => $id ? preg_replace("/\.[0-9]{1,6}/", "", $this->getMetadataValue($id, UI_MDATA_KEY_DURATION)) : NULL
); );
$form->setConstants($const); $form->setConstants($const);
$this->_parseArr2Form($form, $mask); uiBase::parseArrayToForm($form, $mask);
/* /*
$form->addGroupRule('grp', $form->addGroupRule('grp',
@ -201,7 +198,7 @@ class uiBrowser extends uiBase {
$form->_rules['grp[url]'][1][validation] = 'client'; $form->_rules['grp[url]'][1][validation] = 'client';
*/ */
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
return $renderer->toArray(); return $renderer->toArray();
} // fn webstreamForm } // fn webstreamForm
@ -294,7 +291,7 @@ class uiBrowser extends uiBase {
$arr[tra($key)] = $val; $arr[tra($key)] = $val;
} }
} }
$arr[$relations[UI_MDATA_KEY_TITLE]] = $this->_getMDataValue($id, UI_MDATA_KEY_TITLE); $arr[$relations[UI_MDATA_KEY_TITLE]] = $this->getMetadataValue($id, UI_MDATA_KEY_TITLE);
ksort($arr); ksort($arr);
return array('metadata' => $arr); return array('metadata' => $arr);
@ -316,14 +313,14 @@ class uiBrowser extends uiBase {
$langid = $langid ? $langid : UI_DEFAULT_LANGID; $langid = $langid ? $langid : UI_DEFAULT_LANGID;
$form = new HTML_QuickForm('langswitch', UI_STANDARD_FORM_METHOD, UI_BROWSER); $form = new HTML_QuickForm('langswitch', UI_STANDARD_FORM_METHOD, UI_BROWSER);
$this->_parseArr2Form($form, $mask['langswitch']); uiBase::parseArrayToForm($form, $mask['langswitch']);
$form->setConstants(array('target_langid' => $langid)); $form->setConstants(array('target_langid' => $langid));
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
$output['langswitch'] = $renderer->toArray(); $output['langswitch'] = $renderer->toArray();
$form = new HTML_QuickForm('editMetaData', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('editMetaData', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$this->_parseArr2Form($form, $mask['basics']); uiBase::parseArrayToForm($form, $mask['basics']);
$form->setConstants(array('act' => 'editMetaData', $form->setConstants(array('act' => 'editMetaData',
'id' => $id, 'id' => $id,
'curr_langid' => $langid, 'curr_langid' => $langid,
@ -338,20 +335,20 @@ class uiBrowser extends uiBase {
if (!is_array($mask['pages'][$key][$k]['attributes'])) { if (!is_array($mask['pages'][$key][$k]['attributes'])) {
$mask['pages'][$key][$k]['attributes'] = array(); $mask['pages'][$key][$k]['attributes'] = array();
} }
$mask['pages'][$key][$k]['element'] = $key.'___'.$this->_formElementEncode($v['element']); $mask['pages'][$key][$k]['element'] = $key.'___'.uiBase::formElementEncode($v['element']);
$mask['pages'][$key][$k]['attributes'] = array_merge($mask['pages'][$key][$k]['attributes'], array('onChange' => "spread(this, '".$this->_formElementEncode($v['element'])."')")); $mask['pages'][$key][$k]['attributes'] = array_merge($mask['pages'][$key][$k]['attributes'], array('onChange' => "spread(this, '".uiBase::formElementEncode($v['element'])."')"));
## load data from GreenBox ## load data from GreenBox
if ($getval = $this->_getMDataValue($id, $v['element'], $langid, NULL)) { if ($getval = $this->getMetadataValue($id, $v['element'], $langid, NULL)) {
$mask['pages'][$key][$k]['default'] = $getval; $mask['pages'][$key][$k]['default'] = $getval;
$mask['pages'][$key][$k]['attributes']['onFocus'] = 'MData_confirmChange(this)'; $mask['pages'][$key][$k]['attributes']['onFocus'] = 'MData_confirmChange(this)';
} }
} }
$form->addElement('static', NULL, NULL, "<div id='div_$key'>"); $form->addElement('static', NULL, NULL, "<div id='div_$key'>");
$this->_parseArr2Form($form, $mask['pages'][$key]); uiBase::parseArrayToForm($form, $mask['pages'][$key]);
$this->_parseArr2Form($form, $mask['buttons']); uiBase::parseArrayToForm($form, $mask['buttons']);
$form->addElement('static', NULL, NULL, "</div id='div_$key'>"); $form->addElement('static', NULL, NULL, "</div id='div_$key'>");
} }
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
$output['pages'][] = $renderer->toArray(); $output['pages'][] = $renderer->toArray();
#print_r($output); #print_r($output);
@ -369,8 +366,8 @@ class uiBrowser extends uiBase {
$mask[$key]['default'] = $p; $mask[$key]['default'] = $p;
} }
} }
$this->_parseArr2Form($form, $mask); uiBase::parseArrayToForm($form, $mask);
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
return $renderer->toArray(); return $renderer->toArray();
} // fn changeStationPrefs } // fn changeStationPrefs
@ -456,7 +453,7 @@ class uiBrowser extends uiBase {
if (strtolower($type) === strtolower(UI_FILETYPE_AUDIOCLIP)) { if (strtolower($type) === strtolower(UI_FILETYPE_AUDIOCLIP)) {
$m3u = "http://{$_SERVER['SERVER_NAME']}".$this->config['accessRawAudioUrl']."?sessid={$this->sessid}&id=$clipid\n"; $m3u = "http://{$_SERVER['SERVER_NAME']}".$this->config['accessRawAudioUrl']."?sessid={$this->sessid}&id=$clipid\n";
} else { } else {
$m3u = $this->_getMDataValue($id, UI_MDATA_KEY_URL); $m3u = $this->getMetadataValue($id, UI_MDATA_KEY_URL);
} }
touch(UI_TESTSTREAM_MU3_TMP); touch(UI_TESTSTREAM_MU3_TMP);
$handle = fopen(UI_TESTSTREAM_MU3_TMP, "w"); $handle = fopen(UI_TESTSTREAM_MU3_TMP, "w");

View file

@ -3,24 +3,26 @@ header("Content-type: text/html; charset=utf-8");
session_start(); session_start();
## LS classes/functions ############################################# ## LS classes/functions #############################################
require_once dirname(__FILE__).'/ui_conf.php'; require_once(dirname(__FILE__).'/ui_conf.php');
require_once dirname(__FILE__).'/ui_browser.class.php'; require_once(dirname(__FILE__).'/ui_browser.class.php');
## well known classes ############################################### ## well known classes ###############################################
require_once dirname(__FILE__).'/Smarty/libs/Smarty.class.php'; require_once(dirname(__FILE__).'/Smarty/libs/Smarty.class.php');
require_once 'HTML/QuickForm/Renderer/ArraySmarty.php'; require_once('HTML/QuickForm/Renderer/ArraySmarty.php');
## initialize objects ############################################### ## initialize objects ###############################################
$Smarty =& new Smarty; $Smarty = new Smarty;
$uiBrowser =& new uiBrowser($config); $uiBrowser = new uiBrowser($config);
$uiBase =& $uiBrowser; $uiBrowser->init();
$jscom =& new jscom(array("jscom_wrapper"));
$uiBase =& $uiBrowser;
$jscom = new jscom(array("jscom_wrapper"));
$jscom->handler(); $jscom->handler();
## load Smarty+filters ############################################## ## load Smarty+filters ##############################################
require_once dirname(__FILE__).'/ui_smartyExtensions.inc.php'; require_once(dirname(__FILE__).'/ui_smartyExtensions.inc.php');
#$Smarty->load_filter('output', 'trimwhitespace'); #$Smarty->load_filter('output', 'trimwhitespace');
#$Smarty->load_filter('post', 'template_marker'); #$Smarty->load_filter('post', 'template_marker');
$Smarty->load_filter('output', 'localizer'); $Smarty->load_filter('output', 'localizer');

View file

@ -6,21 +6,23 @@
*/ */
class uiCalendar class uiCalendar
{ {
var $Decade; public $Decade;
var $Year; public $Year;
var $Month; public $Month;
var $Week; public $Week;
var $Day; public $Day;
var $Hour; public $Hour;
function uiCalendar() public function __construct()
{ {
} }
function buildDecade() function buildDecade()
{ {
if (is_array($this->Decade)) return; if (is_array($this->Decade)) {
return;
}
for ($Year = $this->curr['year']-5; $Year<=$this->curr['year']+5; $Year++) { for ($Year = $this->curr['year']-5; $Year<=$this->curr['year']+5; $Year++) {
$this->Decade[] = array( $this->Decade[] = array(
@ -34,14 +36,16 @@ class uiCalendar
function buildYear() function buildYear()
{ {
if (is_array($this->Year)) return; if (is_array($this->Year)) {
return;
}
require_once 'Calendar/Year.php'; require_once('Calendar/Year.php');
require_once 'Calendar/Month.php'; require_once('Calendar/Month.php');
$Year = new Calendar_Year($this->curr['year']); $Year = new Calendar_Year($this->curr['year']);
# mark current month # mark current month
$sel = new Calendar_Month($this->curr['year'], $this->curr['month']); $sel = new Calendar_Month($this->curr['year'], $this->curr['month']);
$selections = array($sel); $selections = array($sel);
$Year->build($selections, UI_SCHEDULER_FIRSTWEEKDAY); $Year->build($selections, UI_SCHEDULER_FIRSTWEEKDAY);
@ -57,16 +61,20 @@ class uiCalendar
function buildMonth() function buildMonth()
{ {
if (is_array($this->Month)) return; if (is_array($this->Month)) {
return;
}
require_once 'Calendar/Month/Weekdays.php'; require_once('Calendar/Month/Weekdays.php');
require_once 'Calendar/Day.php'; require_once('Calendar/Day.php');
$Month = new Calendar_Month_Weekdays($this->curr['year'], $this->curr['month'], UI_SCHEDULER_FIRSTWEEKDAY); $Month = new Calendar_Month_Weekdays($this->curr['year'], $this->curr['month'], UI_SCHEDULER_FIRSTWEEKDAY);
$Month->build($this->_scheduledDays('month')); ## scheduled days are selected // scheduled days are selected
$Month->build($this->_scheduledDays('month'));
while ($Day = $Month->fetch()) { while ($Day = $Month->fetch()) {
$corrMonth = $Day->thisMonth()<=12 ? sprintf('%02d', $Day->thisMonth()) : '01'; ## due to bug in // Next 2 lines are due to a bug in Calendar_Month_Weekdays
$corrYear = $Day->thisMonth()<=12 ? $Day->thisYear() : $Day->thisYear()+1; ## Calendar_Month_Weekdays $corrMonth = $Day->thisMonth()<=12 ? sprintf('%02d', $Day->thisMonth()) : '01';
$corrYear = $Day->thisMonth()<=12 ? $Day->thisYear() : $Day->thisYear()+1;
$this->Month[] = array( $this->Month[] = array(
'day' => sprintf('%02d', $Day->thisDay()), 'day' => sprintf('%02d', $Day->thisDay()),
'week' => $this->_getWeekNr($Day), 'week' => $this->_getWeekNr($Day),
@ -87,9 +95,11 @@ class uiCalendar
function buildWeek() function buildWeek()
{ {
if (is_array($this->Week)) return; if (is_array($this->Week)) {
return;
}
require_once 'Calendar/Week.php'; require_once('Calendar/Week.php');
$Week = new Calendar_Week($this->curr['year'], $this->curr['month'], $this->curr['day'], UI_SCHEDULER_FIRSTWEEKDAY); $Week = new Calendar_Week($this->curr['year'], $this->curr['month'], $this->curr['day'], UI_SCHEDULER_FIRSTWEEKDAY);
$Week->build($this->_scheduledDays('week')); $Week->build($this->_scheduledDays('week'));
@ -122,8 +132,9 @@ class uiCalendar
$Day = new Calendar_Day ($this->curr['year'], $this->curr['month'], $this->curr['day']); $Day = new Calendar_Day ($this->curr['year'], $this->curr['month'], $this->curr['day']);
$Day->build(); $Day->build();
while ($Hour = $Day->fetch()) { while ($Hour = $Day->fetch()) {
$corrMonth = $Hour->thisMonth()<=12 ? sprintf('%02d', $Hour->thisMonth()) : '01'; ## due to bug in // Next two lines are due to a bug in Calendar_Month_Weekdays
$corrYear = $Hour->thisMonth()<=12 ? $Day->thisYear() : $Hour->thisYear()+1; ## Calendar_Month_Weekdays $corrMonth = $Hour->thisMonth()<=12 ? sprintf('%02d', $Hour->thisMonth()) : '01';
$corrYear = $Hour->thisMonth()<=12 ? $Day->thisYear() : $Hour->thisYear()+1;
$this->Day[] = array( $this->Day[] = array(
'day' => sprintf('%02d', $Hour->thisDay()), 'day' => sprintf('%02d', $Hour->thisDay()),
'week' => $this->_getWeekNr($Hour), 'week' => $this->_getWeekNr($Hour),
@ -141,7 +152,9 @@ class uiCalendar
function buildHour() function buildHour()
{ {
if (is_array($this->Hour)) return; if (is_array($this->Hour)) {
return;
}
require_once('Calendar/Hour.php'); require_once('Calendar/Hour.php');

View file

@ -124,7 +124,9 @@ $config = array_merge($config,
'file_types' => array( 'file_types' => array(
'.mp3', '.mp3',
'.wav', '.wav',
'.ogg' '.ogg',
'.flac',
'.aac'
), ),
'stream_types' => array( 'stream_types' => array(
'application/ogg', 'application/ogg',

View file

@ -6,11 +6,11 @@
*/ */
class uiExchange class uiExchange
{ {
var $Base; private $Base;
var $file; private $file;
var $folder; private $folder;
function uiExchange(&$uiBase) public function __construct(&$uiBase)
{ {
$this->Base =& $uiBase; $this->Base =& $uiBase;
$this->file =& $_SESSION['EXCHANGE']['file']; $this->file =& $_SESSION['EXCHANGE']['file'];
@ -103,8 +103,8 @@ class uiExchange
{ {
include('formmask/exchange.inc.php'); include('formmask/exchange.inc.php');
$form = new HTML_QuickForm('BACKUP_Schedule', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('BACKUP_Schedule', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$this->Base->_parseArr2Form($form, $mask['BACKUP.schedule']); uiBase::parseArrayToForm($form, $mask['BACKUP.schedule']);
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
return $renderer->toArray(); return $renderer->toArray();
} }
@ -113,7 +113,8 @@ class uiExchange
/** /**
* Copy a file or directory. * Copy a file or directory.
* *
* @param string $target - path to file or directory * @param string $target
* path to file or directory
* @return boolean * @return boolean
*/ */
function copy2target($target) function copy2target($target)

View file

@ -9,8 +9,8 @@ define('ACTION_BASE', '/actions' ) ;
* @version $Revision$ * @version $Revision$
*/ */
class uiHandler extends uiBase { class uiHandler extends uiBase {
var $uiBase; public $uiBase;
var $redirUrl; public $redirUrl;
/** /**
* Initialize a new Browser Class * Initialize a new Browser Class
@ -19,9 +19,9 @@ class uiHandler extends uiBase {
* @param array $config * @param array $config
* configurartion data * configurartion data
*/ */
function uiHandler($config) public function __construct($config)
{ {
$this->uiBase($config); parent::__construct($config);
} // constructor } // constructor
@ -152,12 +152,12 @@ class uiHandler extends uiBase {
return FALSE; return FALSE;
} }
$this->_setMDataValue($r, UI_MDATA_KEY_TITLE, $formdata['mediafile']['name']); $this->setMetadataValue($r, UI_MDATA_KEY_TITLE, $formdata['mediafile']['name']);
$this->transMData($r); $this->transMData($r);
// set records in default language too // set records in default language too
if (UI_UPLOAD_LANGID !== UI_DEFAULT_LANGID) { if (UI_UPLOAD_LANGID !== UI_DEFAULT_LANGID) {
$this->_setMDataValue($r, UI_MDATA_KEY_TITLE, $formdata['mediafile']['name'], UI_UPLOAD_LANGID); $this->setMetadataValue($r, UI_MDATA_KEY_TITLE, $formdata['mediafile']['name'], UI_UPLOAD_LANGID);
$this->transMData($r, UI_UPLOAD_LANGID); $this->transMData($r, UI_UPLOAD_LANGID);
} }
@ -196,20 +196,20 @@ class uiHandler extends uiBase {
return; return;
} }
$this->_setMdataValue($id, UI_MDATA_KEY_DURATION, $this->gb->_secsToPlTime($ia['playtime_seconds'])); $this->_setMdataValue($id, UI_MDATA_KEY_DURATION, $this->gb->_secsToPlTime($ia['playtime_seconds']));
$this->_setMDataValue($id, UI_MDATA_KEY_FORMAT, UI_MDATA_VALUE_FORMAT_FILE); $this->setMetadataValue($id, UI_MDATA_KEY_FORMAT, UI_MDATA_VALUE_FORMAT_FILE);
// some data from raw audio // some data from raw audio
if (isset($ia['audio']['channels'])) { if (isset($ia['audio']['channels'])) {
$this->_setMDataValue($id, UI_MDATA_KEY_CHANNELS, $ia['audio']['channels']); $this->setMetadataValue($id, UI_MDATA_KEY_CHANNELS, $ia['audio']['channels']);
} }
if (isset($ia['audio']['sample_rate'])) { if (isset($ia['audio']['sample_rate'])) {
$this->_setMDataValue($id, UI_MDATA_KEY_SAMPLERATE, $ia['audio']['sample_rate']); $this->setMetadataValue($id, UI_MDATA_KEY_SAMPLERATE, $ia['audio']['sample_rate']);
} }
if (isset($ia['audio']['bitrate'])) { if (isset($ia['audio']['bitrate'])) {
$this->_setMDataValue($id, UI_MDATA_KEY_BITRATE, $ia['audio']['bitrate']); $this->setMetadataValue($id, UI_MDATA_KEY_BITRATE, $ia['audio']['bitrate']);
} }
if (isset($ia['audio']['codec'])) { if (isset($ia['audio']['codec'])) {
$this->_setMDataValue($id, UI_MDATA_KEY_ENCODER, $ia['audio']['codec']); $this->setMetadataValue($id, UI_MDATA_KEY_ENCODER, $ia['audio']['codec']);
} }
// from id3 Tags // from id3 Tags
@ -256,9 +256,9 @@ class uiHandler extends uiBase {
$extent = sprintf('%02d', $formdata['length']['H']).':'.sprintf('%02d', $formdata['length']['i']).':'.sprintf('%02d', $formdata['length']['s']).'.000000'; $extent = sprintf('%02d', $formdata['length']['H']).':'.sprintf('%02d', $formdata['length']['i']).':'.sprintf('%02d', $formdata['length']['s']).'.000000';
$this->_setMDataValue($r, UI_MDATA_KEY_TITLE, $formdata['title']); $this->setMetadataValue($r, UI_MDATA_KEY_TITLE, $formdata['title']);
$this->_setMDataValue($r, UI_MDATA_KEY_DURATION, $extent); $this->setMetadataValue($r, UI_MDATA_KEY_DURATION, $extent);
$this->_setMDataValue($r, UI_MDATA_KEY_FORMAT, UI_MDATA_VALUE_FORMAT_STREAM); $this->setMetadataValue($r, UI_MDATA_KEY_FORMAT, UI_MDATA_VALUE_FORMAT_STREAM);
$this->redirUrl = UI_BROWSER."?act=addWebstreamMData&id=$r"; $this->redirUrl = UI_BROWSER."?act=addWebstreamMData&id=$r";
if (UI_VERBOSE) { if (UI_VERBOSE) {
@ -277,9 +277,9 @@ class uiHandler extends uiBase {
} }
$extent = sprintf('%02d', $formdata['length']['H']).':'.sprintf('%02d', $formdata['length']['i']).':'.sprintf('%02d', $formdata['length']['s']).'.000000'; $extent = sprintf('%02d', $formdata['length']['H']).':'.sprintf('%02d', $formdata['length']['i']).':'.sprintf('%02d', $formdata['length']['s']).'.000000';
$this->_setMDataValue($id, UI_MDATA_KEY_TITLE, $formdata['title']); $this->setMetadataValue($id, UI_MDATA_KEY_TITLE, $formdata['title']);
$this->_setMDataValue($id, UI_MDATA_KEY_URL, $formdata['url']); $this->setMetadataValue($id, UI_MDATA_KEY_URL, $formdata['url']);
$this->_setMDataValue($id, UI_MDATA_KEY_DURATION, $extent); $this->setMetadataValue($id, UI_MDATA_KEY_DURATION, $extent);
$this->redirUrl = UI_BROWSER.'?act=editItem&id='.$formdata['id']; $this->redirUrl = UI_BROWSER.'?act=editItem&id='.$formdata['id'];
if (UI_VERBOSE) { if (UI_VERBOSE) {
@ -302,7 +302,7 @@ class uiHandler extends uiBase {
foreach ($mask['pages'] as $key => $val) { foreach ($mask['pages'] as $key => $val) {
foreach ($mask['pages'][$key] as $k => $v) { foreach ($mask['pages'][$key] as $k => $v) {
$formdata[$key.'___'.$this->_formElementEncode($v['element'])] ? $mData[$this->_formElementDecode($v['element'])] = $formdata[$key.'___'.$this->_formElementEncode($v['element'])] : NULL; $formdata[$key.'___'.uiBase::formElementEncode($v['element'])] ? $mData[uiBase::formElementDecode($v['element'])] = $formdata[$key.'___'.uiBase::formElementEncode($v['element'])] : NULL;
} }
} }
@ -311,7 +311,7 @@ class uiHandler extends uiBase {
} }
foreach ($mData as $key => $val) { foreach ($mData as $key => $val) {
$r = $this->_setMDataValue($id, $key, $val, $curr_langid); $r = $this->setMetadataValue($id, $key, $val, $curr_langid);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
$this->_retMsg('Unable to set "$1" to value "$2".', $key, $val); $this->_retMsg('Unable to set "$1" to value "$2".', $key, $val);
} }
@ -542,7 +542,7 @@ class uiHandler extends uiBase {
function _validateForm($formdata, $mask) function _validateForm($formdata, $mask)
{ {
$form = new HTML_QuickForm('validation', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('validation', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$this->_parseArr2Form($form, $mask, 'server'); uiBase::parseArrayToForm($form, $mask, 'server');
if (!$form->validate()) { if (!$form->validate()) {
$_SESSION['retransferFormData'] = $_REQUEST; $_SESSION['retransferFormData'] = $_REQUEST;
return FALSE; return FALSE;

View file

@ -7,7 +7,8 @@ require_once(dirname(__FILE__).'/ui_conf.php');
require_once(dirname(__FILE__).'/ui_handler.class.php'); require_once(dirname(__FILE__).'/ui_handler.class.php');
## initialize objects ############################################### ## initialize objects ###############################################
$uiHandler =& new uiHandler($config); $uiHandler = new uiHandler($config);
$uiHandler->init();
$uiBase =& $uiHandler; $uiBase =& $uiHandler;
include("../templates/loader/index.tpl"); include("../templates/loader/index.tpl");

View file

@ -7,17 +7,17 @@
class uiHubBrowse extends uiBrowse class uiHubBrowse extends uiBrowse
{ {
function uiHubBrowse(&$uiBase) public function __construct(&$uiBase)
{ {
$this->Base =& $uiBase; $this->Base =& $uiBase;
$this->prefix = 'HUBBROWSE'; $this->prefix = 'HUBBROWSE';
$this->col =& $_SESSION[UI_HUBBROWSE_SESSNAME]['col']; $this->col =& $_SESSION[UI_HUBBROWSE_SESSNAME]['col'];
$this->criteria =& $_SESSION[UI_HUBBROWSE_SESSNAME]['criteria']; $this->criteria =& $_SESSION[UI_HUBBROWSE_SESSNAME]['criteria'];
#$this->results =& $_SESSION[UI_HUBBROWSE_SESSNAME]['results']; #$this->results =& $_SESSION[UI_HUBBROWSE_SESSNAME]['results'];
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close'; $this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
if (empty($this->criteria['limit'])) { if (empty($this->criteria['limit'])) {
$this->criteria['limit'] = UI_BROWSE_DEFAULT_LIMIT; $this->criteria['limit'] = UI_BROWSE_DEFAULT_LIMIT;
} }
if (empty($this->criteria['filetype'])) { if (empty($this->criteria['filetype'])) {
$this->criteria['filetype'] = UI_FILETYPE_ANY; $this->criteria['filetype'] = UI_FILETYPE_ANY;
@ -53,8 +53,8 @@ class uiHubBrowse extends uiBrowse
} }
$this->results['cnt'] = $results['cnt']; $this->results['cnt'] = $results['cnt'];
foreach ($results['results'] as $rec) { foreach ($results['results'] as $rec) {
// TODO: maybe this _getMetaInfo is not correct for the remote results // TODO: maybe this getMetaInfo is not correct for the remote results
$this->results['items'][] = $this->Base->_getMetaInfo($this->Base->gb->_idFromGunid($rec)); $this->results['items'][] = $this->Base->getMetaInfo($this->Base->gb->_idFromGunid($rec));
} }
$this->pagination($results); $this->pagination($results);
// echo '<XMP>this->results:'; print_r($this->results); echo "</XMP>\n"; // echo '<XMP>this->results:'; print_r($this->results); echo "</XMP>\n";

View file

@ -6,13 +6,13 @@
*/ */
class uiHubSearch extends uiSearch { class uiHubSearch extends uiSearch {
function uiHubSearch(&$uiBase) public function __construct(&$uiBase)
{ {
$this->Base =& $uiBase; $this->Base =& $uiBase;
$this->prefix = 'HUBSEARCH'; $this->prefix = 'HUBSEARCH';
#$this->results =& $_SESSION[UI_HUBSEARCH_SESSNAME]['results']; #$this->results =& $_SESSION[UI_HUBSEARCH_SESSNAME]['results'];
$this->criteria =& $_SESSION[UI_HUBSEARCH_SESSNAME]['criteria']; $this->criteria =& $_SESSION[UI_HUBSEARCH_SESSNAME]['criteria'];
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close'; $this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
if (empty($this->criteria['limit'])) { if (empty($this->criteria['limit'])) {
$this->criteria['limit'] = UI_BROWSE_DEFAULT_LIMIT; $this->criteria['limit'] = UI_BROWSE_DEFAULT_LIMIT;
@ -33,24 +33,24 @@ class uiHubSearch extends uiSearch {
function newSearch(&$formdata) function newSearch(&$formdata)
{ {
$this->results = NULL; $this->results = NULL;
$this->criteria['conditions'] = NULL; $this->criteria['conditions'] = NULL;
$this->criteria['offset'] = NULL; $this->criteria['offset'] = NULL;
$this->criteria['form'] = NULL; $this->criteria['form'] = NULL;
$this->criteria['operator'] = $formdata['operator']; $this->criteria['operator'] = $formdata['operator'];
$this->criteria['filetype'] = $formdata['filetype']; $this->criteria['filetype'] = $formdata['filetype'];
$this->criteria['limit'] = $formdata['limit']; $this->criteria['limit'] = $formdata['limit'];
$this->criteria['counter'] = 0; $this->criteria['counter'] = 0;
// $criteria['form'] is used for retransfer to form // $criteria['form'] is used for retransfer to form
$this->criteria['form']['operator'] = $formdata['operator']; $this->criteria['form']['operator'] = $formdata['operator'];
$this->criteria['form']['filetype'] = $formdata['filetype']; $this->criteria['form']['filetype'] = $formdata['filetype'];
$this->criteria['form']['limit'] = $formdata['limit']; $this->criteria['form']['limit'] = $formdata['limit'];
foreach ($formdata as $key=>$val) { foreach ($formdata as $key => $val) {
if (is_array($val) && $val['active']) { if (is_array($val) && $val['active']) {
$this->criteria['counter']++; $this->criteria['counter']++;
$this->criteria['conditions'][$key] = array('cat' => $this->Base->_formElementDecode($val[0]), $this->criteria['conditions'][$key] = array('cat' => uiBase::formElementDecode($val[0]),
'op' => $val[1], 'op' => $val[1],
'val' => stripslashes($val[2]) 'val' => stripslashes($val[2])
); );
@ -83,7 +83,7 @@ class uiHubSearch extends uiSearch {
} }
foreach ($results['results'] as $rec) { foreach ($results['results'] as $rec) {
$tmpId = $this->Base->gb->_idFromGunid($rec["gunid"]); $tmpId = $this->Base->gb->_idFromGunid($rec["gunid"]);
$this->results['items'][] = $this->Base->_getMetaInfo($tmpId); $this->results['items'][] = $this->Base->getMetaInfo($tmpId);
} }
$this->results['cnt'] = $results['cnt']; $this->results['cnt'] = $results['cnt'];
@ -94,16 +94,18 @@ class uiHubSearch extends uiSearch {
} // fn searchDB } // fn searchDB
function getSearchResults($trtokid) { function getSearchResults($trtokid)
{
$this->results = array('page' => $this->criteria['offset']/$this->criteria['limit']); $this->results = array('page' => $this->criteria['offset']/$this->criteria['limit']);
$results = $this->Base->gb->getSearchResults($trtokid); $results = $this->Base->gb->getSearchResults($trtokid);
//echo"<pre><b>RESULTS:</b><br>";print_r($results);echo "</pre>";
if (!is_array($results) || !count($results)) { if (!is_array($results) || !count($results)) {
return false; return false;
} }
$this->results['cnt'] = $results['cnt']; $this->results['cnt'] = $results['cnt'];
foreach ($results['results'] as $rec) { foreach ($results['results'] as $rec) {
// TODO: maybe this _getMetaInfo is not correct for the remote results // TODO: maybe this getMetaInfo is not correct for the remote results
$this->results['items'][] = $this->Base->_getMetaInfo($this->Base->gb->_idFromGunid($rec)); $this->results['items'][] = $this->Base->getMetaInfo($this->Base->gb->_idFromGunid($rec));
} }
$this->pagination($results); $this->pagination($results);
//echo '<XMP>this->results:'; print_r($this->results); echo "</XMP>\n"; //echo '<XMP>this->results:'; print_r($this->results); echo "</XMP>\n";

View file

@ -6,12 +6,12 @@
* @version $Revision$ * @version $Revision$
*/ */
class jscom { class jscom {
var $prefix = 'jsc_'; private $prefix = 'jsc_';
var $callables = array(); private $callables = array();
var $method = 'POST'; private $method = 'POST';
var $uri = ''; private $uri = '';
function jscom($calls = NULL, $pars = NULL) public function __construct($calls = NULL, $pars = NULL)
{ {
$this->uri = $_SERVER['REQUEST_URI']; $this->uri = $_SERVER['REQUEST_URI'];
if (!is_null($calls)) { if (!is_null($calls)) {

View file

@ -6,23 +6,25 @@
*/ */
class uiPlaylist class uiPlaylist
{ {
var $Base; public $activeId;
var $activeId; public $title;
var $changed; public $duration;
var $title; public $changed;
var $duration; public $token;
var $token;
var $reloadUrl;
var $redirectUrl;
var $returnUrl;
function uiPlaylist(&$uiBase) private $Base;
private $reloadUrl;
private $redirectUrl;
private $returnUrl;
private $flat;
public function __construct(&$uiBase)
{ {
$this->Base =& $uiBase; $this->Base =& $uiBase;
$this->activeId =& $_SESSION[UI_PLAYLIST_SESSNAME]['activeId']; $this->activeId =& $_SESSION[UI_PLAYLIST_SESSNAME]['activeId'];
$this->changed =& $_SESSION[UI_PLAYLIST_SESSNAME]['changed']; $this->changed =& $_SESSION[UI_PLAYLIST_SESSNAME]['changed'];
$this->title = $this->Base->_getMDataValue($this->activeId, UI_MDATA_KEY_TITLE); $this->title = $this->Base->getMetadataValue($this->activeId, UI_MDATA_KEY_TITLE);
$this->duration = $this->Base->_getMDataValue($this->activeId, UI_MDATA_KEY_DURATION); $this->duration = $this->Base->getMetadataValue($this->activeId, UI_MDATA_KEY_DURATION);
$this->token =& $_SESSION[UI_PLAYLIST_SESSNAME]['token']; $this->token =& $_SESSION[UI_PLAYLIST_SESSNAME]['token'];
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close'; $this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
$this->redirectUrl = UI_BROWSER.'?popup[]=_2PL.simpleManagement&popup[]=_close'; $this->redirectUrl = UI_BROWSER.'?popup[]=_2PL.simpleManagement&popup[]=_close';
@ -100,14 +102,14 @@ class uiPlaylist
if (UI_VERBOSE === TRUE) { if (UI_VERBOSE === TRUE) {
print_r($token); print_r($token);
} }
$this->Base->_retMsg('Unable to open playlist "$1".', $this->Base->_getMDataValue($plid, UI_MDATA_KEY_TITLE)); $this->Base->_retMsg('Unable to open playlist "$1".', $this->Base->getMetadataValue($plid, UI_MDATA_KEY_TITLE));
return FALSE; return FALSE;
} }
$this->token = $token; $this->token = $token;
$this->Base->gb->savePref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY, $plid.':'.$this->token); $this->Base->gb->savePref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY, $plid.':'.$this->token);
$this->activeId = $plid; $this->activeId = $plid;
if ($msg && UI_VERBOSE) { if ($msg && UI_VERBOSE) {
$this->Base->_retMsg('Playlist "$1" opened.', $this->Base->_getMDataValue($plid, UI_MDATA_KEY_TITLE)); $this->Base->_retMsg('Playlist "$1" opened.', $this->Base->getMetadataValue($plid, UI_MDATA_KEY_TITLE));
} }
return TRUE; return TRUE;
@ -137,7 +139,7 @@ class uiPlaylist
return FALSE; return FALSE;
} }
if ($msg && UI_VERBOSE) { if ($msg && UI_VERBOSE) {
$this->Base->_retMsg('Playlist "$1" released.', $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($plgunid), UI_MDATA_KEY_TITLE)); $this->Base->_retMsg('Playlist "$1" released.', $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($plgunid), UI_MDATA_KEY_TITLE));
} }
$this->activeId = NULL; $this->activeId = NULL;
$this->token = NULL; $this->token = NULL;
@ -155,7 +157,7 @@ class uiPlaylist
$this->activate($tmpid, FALSE); $this->activate($tmpid, FALSE);
$this->changed = FALSE; $this->changed = FALSE;
if (UI_VERBOSE) { if (UI_VERBOSE) {
$this->Base->_retMsg('Playlist "$1" saved.', $this->Base->_getMDataValue($tmpid, UI_MDATA_KEY_TITLE)); $this->Base->_retMsg('Playlist "$1" saved.', $this->Base->getMetadataValue($tmpid, UI_MDATA_KEY_TITLE));
} }
return $this->activeId; return $this->activeId;
@ -181,7 +183,7 @@ class uiPlaylist
return FALSE; return FALSE;
} }
if (UI_VERBOSE) { if (UI_VERBOSE) {
$this->Base->_retMsg('Playlist "$1" reverted.', $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($plgunid), UI_MDATA_KEY_TITLE)); $this->Base->_retMsg('Playlist "$1" reverted.', $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($plgunid), UI_MDATA_KEY_TITLE));
} }
$this->activeId = NULL; $this->activeId = NULL;
$this->token = NULL; $this->token = NULL;
@ -306,8 +308,8 @@ class uiPlaylist
return FALSE; return FALSE;
} }
$this->Base->_setMDataValue($plid, UI_MDATA_KEY_CREATOR, $this->Base->login); $this->Base->setMetadataValue($plid, UI_MDATA_KEY_CREATOR, $this->Base->login);
$this->Base->_setMDataValue($plid, UI_MDATA_KEY_DESCRIPTION, tra('created at $1', $datetime)); $this->Base->setMetadataValue($plid, UI_MDATA_KEY_DESCRIPTION, tra('created at $1', $datetime));
if ($this->activate($plid)===FALSE) { if ($this->activate($plid)===FALSE) {
return FALSE; return FALSE;
@ -323,18 +325,16 @@ class uiPlaylist
} // fn create } // fn create
function getFlat($id) public function getFlat($id)
{ {
unset($this->flat);
$this->_plwalk($this->getPLArray($id)); $this->_plwalk($this->getPLArray($id));
if (is_Array($this->flat)) { if (count($this->flat) > 0) {
reset($this->flat); reset($this->flat);
$this->flat[key($this->flat)]['firstInList'] = true; $this->flat[key($this->flat)]['firstInList'] = true;
end($this->flat); end($this->flat);
$this->flat[key($this->flat)]['lastInList'] = true; $this->flat[key($this->flat)]['lastInList'] = true;
reset($this->flat); reset($this->flat);
return $this->flat; return $this->flat;
} else { } else {
return array(); return array();
@ -342,16 +342,17 @@ class uiPlaylist
} // fn getFlat } // fn getFlat
function _plwalk($arr, $parent=0, $attrs=0) private function _plwalk($arr, $parent=0, $attrs=0)
{ {
foreach ($arr['children'] as $node=>$sub) { $this->flat = array();
foreach ($arr['children'] as $node => $sub) {
if ($sub['elementname']===UI_PL_ELEM_PLAYLIST) { if ($sub['elementname']===UI_PL_ELEM_PLAYLIST) {
$this->_plwalk($sub, $node, $sub['attrs']); $this->_plwalk($sub, $node, $sub['attrs']);
} }
if ($sub['elementname']===UI_FILETYPE_AUDIOCLIP || $sub['elementname']===UI_FILETYPE_PLAYLIST) { if ($sub['elementname']===UI_FILETYPE_AUDIOCLIP || $sub['elementname']===UI_FILETYPE_PLAYLIST) {
#$this->flat["$parent.$node"] = $sub['attrs']; #$this->flat["$parent.$node"] = $sub['attrs'];
#$this->flat["$parent.$node"]['type'] = $sub['elementname']; #$this->flat["$parent.$node"]['type'] = $sub['elementname'];
$this->flat[$parent] = $this->Base->_getMetaInfo($this->Base->gb->_idFromGunid($sub['attrs']['id'])); $this->flat[$parent] = $this->Base->getMetaInfo($this->Base->gb->_idFromGunid($sub['attrs']['id']));
$this->flat[$parent]['attrs'] = $attrs; $this->flat[$parent]['attrs'] = $attrs;
$this->flat[$parent]['playlength'] = $sub['attrs']['playlength']; $this->flat[$parent]['playlength'] = $sub['attrs']['playlength'];
} }
@ -535,9 +536,9 @@ class uiPlaylist
$form->setConstants(array('id' => $id, $form->setConstants(array('id' => $id,
'duration' => $duration) 'duration' => $duration)
); );
$this->Base->_parseArr2Form($form, $mask[$type]); uiBase::parseArrayToForm($form, $mask[$type]);
$this->Base->_parseArr2Form($form, $mask['all']); uiBase::parseArrayToForm($form, $mask['all']);
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
return $renderer->toArray(); return $renderer->toArray();
} // fn changeTransitionForm } // fn changeTransitionForm
@ -546,9 +547,9 @@ class uiPlaylist
function changeAllTransitionsForm($mask) function changeAllTransitionsForm($mask)
{ {
$form = new HTML_QuickForm('PL_changeTransition', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('PL_changeTransition', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$this->Base->_parseArr2Form($form, $mask['transition']); uiBase::parseArrayToForm($form, $mask['transition']);
$this->Base->_parseArr2Form($form, $mask['all']); uiBase::parseArrayToForm($form, $mask['all']);
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
return $renderer->toArray(); return $renderer->toArray();
} // fn changeAllTransitionsForm } // fn changeAllTransitionsForm
@ -565,13 +566,13 @@ class uiPlaylist
} else { } else {
$mask['act']['constant'] = 'PL.addItem'; $mask['act']['constant'] = 'PL.addItem';
$mask['id']['constant'] = $id; $mask['id']['constant'] = $id;
$mask['playlength']['default'] = substr($this->Base->_getMDataValue($id, UI_MDATA_KEY_DURATION), 0, 8); $mask['playlength']['default'] = substr($this->Base->getMetadataValue($id, UI_MDATA_KEY_DURATION), 0, 8);
$mask['duration']['constant'] = $mask['playlength']['default']; $mask['duration']['constant'] = $mask['playlength']['default'];
} }
$form = new HTML_QuickForm('PL_setItemPlaylengthForm', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('PL_setItemPlaylengthForm', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$this->Base->_parseArr2Form($form, $mask); uiBase::parseArrayToForm($form, $mask);
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
return $renderer->toArray(); return $renderer->toArray();
} // fn setItemPlaylengthForm } // fn setItemPlaylengthForm
@ -584,29 +585,29 @@ class uiPlaylist
$langid = $langid ? $langid : UI_DEFAULT_LANGID; $langid = $langid ? $langid : UI_DEFAULT_LANGID;
foreach ($mask['playlist'] as $k=>$v) { foreach ($mask['playlist'] as $k=>$v) {
$mask['playlist'][$k]['element'] = $this->Base->_formElementEncode($v['element']); $mask['playlist'][$k]['element'] = uiBase::formElementEncode($v['element']);
if ($getval = $this->Base->_getMDataValue($id, $v['element'], $langid)) { if ($getval = $this->Base->getMetadataValue($id, $v['element'], $langid)) {
$mask['playlist'][$k]['default'] = $getval; $mask['playlist'][$k]['default'] = $getval;
$mask['playlist'][$k]['attributes']['onFocus'] = 'MData_confirmChange(this)'; $mask['playlist'][$k]['attributes']['onFocus'] = 'MData_confirmChange(this)';
}; };
} }
$form = new HTML_QuickForm('editMetaData', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('editMetaData', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$this->Base->_parseArr2Form($form, $mask['basics']); uiBase::parseArrayToForm($form, $mask['basics']);
$this->Base->_parseArr2Form($form, $mask['playlist']); uiBase::parseArrayToForm($form, $mask['playlist']);
$this->Base->_parseArr2Form($form, $mask['buttons']); uiBase::parseArrayToForm($form, $mask['buttons']);
$form->setConstants(array('act' => 'PL.editMetaData', $form->setConstants(array('act' => 'PL.editMetaData',
'id' => $id, 'id' => $id,
'curr_langid' => $langid 'curr_langid' => $langid
) )
); );
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
$output['main'] = $renderer->toArray(); $output['main'] = $renderer->toArray();
$form = new HTML_QuickForm('langswitch', UI_STANDARD_FORM_METHOD, UI_BROWSER); $form = new HTML_QuickForm('langswitch', UI_STANDARD_FORM_METHOD, UI_BROWSER);
$this->Base->_parseArr2Form($form, $mask['langswitch']); uiBase::parseArrayToForm($form, $mask['langswitch']);
$form->setConstants(array('target_langid' => $langid)); $form->setConstants(array('target_langid' => $langid));
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
$output['langswitch'] = $renderer->toArray(); $output['langswitch'] = $renderer->toArray();
@ -632,7 +633,7 @@ class uiPlaylist
} }
foreach ($mask['playlist'] as $k=>$v) { foreach ($mask['playlist'] as $k=>$v) {
$formdata[$this->Base->_formElementEncode($v['element'])] ? $mData[$this->Base->_formElementDecode($v['element'])] = $formdata[$this->Base->_formElementEncode($v['element'])] : NULL; $formdata[uiBase::formElementEncode($v['element'])] ? $mData[uiBase::formElementDecode($v['element'])] = $formdata[uiBase::formElementEncode($v['element'])] : NULL;
} }
if (!count($mData)) { if (!count($mData)) {
@ -699,8 +700,8 @@ class uiPlaylist
$mask['act']['constant'] = 'PL.export'; $mask['act']['constant'] = 'PL.export';
$mask['id']['constant'] = $id; $mask['id']['constant'] = $id;
$form = new HTML_QuickForm('PL_exportForm', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('PL_exportForm', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$this->Base->_parseArr2Form($form, $mask); uiBase::parseArrayToForm($form, $mask);
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
return $renderer->toArray(); return $renderer->toArray();
} // fn exportForm } // fn exportForm
@ -710,8 +711,8 @@ class uiPlaylist
{ {
$form = new HTML_QuickForm('PL_importForm', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('PL_importForm', UI_STANDARD_FORM_METHOD, UI_HANDLER);
//print_r($mask); //print_r($mask);
$this->Base->_parseArr2Form($form, $mask); uiBase::parseArrayToForm($form, $mask);
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
return $renderer->toArray(); return $renderer->toArray();
} // fn importForm } // fn importForm

View file

@ -5,45 +5,42 @@
* @version $Revision$ * @version $Revision$
*/ */
class uiScheduler extends uiCalendar { class uiScheduler extends uiCalendar {
var $curr; public $curr;
var $scheduleAtTime; private $scheduleAtTime;
var $schedulePrev; private $schedulePrev;
var $scheduleNext; private $scheduleNext;
var $error; private $error;
var $Base; private $Base;
var $reloadUrl; private $reloadUrl;
var $closeUrl; private $closeUrl;
var $firstDayOfWeek; private $firstDayOfWeek;
function uiScheduler(&$uiBase) public function __construct(&$uiBase)
{ {
$this->curr =& $_SESSION[UI_CALENDAR_SESSNAME]['current']; $this->curr =& $_SESSION[UI_CALENDAR_SESSNAME]['current'];
$this->scheduleAtTime =& $_SESSION[UI_CALENDAR_SESSNAME]['scheduleAtTime']; $this->scheduleAtTime =& $_SESSION[UI_CALENDAR_SESSNAME]['scheduleAtTime'];
$this->schedulePrev =& $_SESSION[UI_CALENDAR_SESSNAME]['schedulePrev']; $this->schedulePrev =& $_SESSION[UI_CALENDAR_SESSNAME]['schedulePrev'];
$this->scheduleNext =& $_SESSION[UI_CALENDAR_SESSNAME]['scheduleNext']; $this->scheduleNext =& $_SESSION[UI_CALENDAR_SESSNAME]['scheduleNext'];
$this->error =& $_SESSION['SCHEDULER']['error']; $this->error =& $_SESSION['SCHEDULER']['error'];
$this->error =& $_SESSION['SCHEDULER']['error'];
if (!is_array($this->curr)) { if (!is_array($this->curr)) {
$this->curr['view'] = UI_SCHEDULER_DEFAULT_VIEW; $this->curr['view'] = UI_SCHEDULER_DEFAULT_VIEW;
$this->curr['year'] = strftime("%Y"); $this->curr['year'] = strftime("%Y");
$this->curr['month'] = strftime("%m"); $this->curr['month'] = strftime("%m");
$this->curr['week'] = strftime("%V"); $this->curr['week'] = strftime("%V");
$this->curr['day'] = strftime("%d"); $this->curr['day'] = strftime("%d");
$this->curr['hour'] = strftime("%H"); $this->curr['hour'] = strftime("%H");
$this->curr['dayname'] = strftime("%A"); $this->curr['dayname'] = strftime("%A");
$this->curr['monthname'] = strftime("%B"); $this->curr['monthname'] = strftime("%B");
$this->curr['isToday'] = TRUE; $this->curr['isToday'] = TRUE;
} }
$this->Base =& $uiBase; $this->Base =& $uiBase;
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close'; $this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
$this->closeUrl = UI_BROWSER.'?popup[]=_close'; $this->closeUrl = UI_BROWSER.'?popup[]=_close';
parent::__construct();
$this->uiCalendar();
$this->initXmlRpc(); $this->initXmlRpc();
//$this->startDaemon(); //$this->startDaemon();
} // constructor } // constructor
@ -298,8 +295,8 @@ class uiScheduler extends uiCalendar {
'end' => substr($val['end'], strpos($val['end'], 'T')+1), 'end' => substr($val['end'], strpos($val['end'], 'T')+1),
'start_stamp' => $this->_datetime2timestamp($val['start']), 'start_stamp' => $this->_datetime2timestamp($val['start']),
'end_stamp' => $this->_datetime2timestamp($val['end']), 'end_stamp' => $this->_datetime2timestamp($val['end']),
'title' => $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE), 'title' => $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE),
'creator' => $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_CREATOR), 'creator' => $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_CREATOR),
'type' => 'Playlist' 'type' => 'Playlist'
); );
} }
@ -338,8 +335,8 @@ class uiScheduler extends uiCalendar {
'scheduleid'=> $val['id'], 'scheduleid'=> $val['id'],
'start' => substr($val['start'], strpos($val['start'], 'T')+1), 'start' => substr($val['start'], strpos($val['start'], 'T')+1),
'end' => substr($val['end'], strpos($val['end'], 'T') + 1), 'end' => substr($val['end'], strpos($val['end'], 'T') + 1),
'title' => $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE), 'title' => $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE),
'creator' => $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_CREATOR), 'creator' => $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_CREATOR),
'type' => 'Playlist', 'type' => 'Playlist',
'endstoday' => strftime('%d', $start) === strftime('%d', $end) ? TRUE : FALSE, 'endstoday' => strftime('%d', $start) === strftime('%d', $end) ? TRUE : FALSE,
'endshere' => strftime('%H', $start) === strftime('%H', $end) ? TRUE : FALSE 'endshere' => strftime('%H', $start) === strftime('%H', $end) ? TRUE : FALSE
@ -360,8 +357,8 @@ class uiScheduler extends uiCalendar {
'scheduleid'=> $val['id'], 'scheduleid'=> $val['id'],
'start' => substr($val['start'], strpos($val['start'], 'T')+1), 'start' => substr($val['start'], strpos($val['start'], 'T')+1),
'end' => substr($val['end'], strpos($val['end'], 'T') + 1), 'end' => substr($val['end'], strpos($val['end'], 'T') + 1),
'title' => $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE), 'title' => $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE),
'creator' => $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_CREATOR), 'creator' => $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_CREATOR),
'type' => 'Playlist', 'type' => 'Playlist',
'startsyesterday' => strftime('%d', $start) === strftime('%d', $end) ? FALSE : TRUE, 'startsyesterday' => strftime('%d', $start) === strftime('%d', $end) ? FALSE : TRUE,
); );
@ -383,8 +380,8 @@ class uiScheduler extends uiCalendar {
$items[date('H', $this->_datetime2timestamp($val['start']))][]= array ( $items[date('H', $this->_datetime2timestamp($val['start']))][]= array (
'start' => substr($val['start'], strpos($val['start'], 'T')+1), 'start' => substr($val['start'], strpos($val['start'], 'T')+1),
'end' => substr($val['end'], strpos($val['end'], 'T') + 1), 'end' => substr($val['end'], strpos($val['end'], 'T') + 1),
'title' => $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE), 'title' => $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE),
'creator' => $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_CREATOR), 'creator' => $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_CREATOR),
); );
} }
#print_r($items); #print_r($items);
@ -403,8 +400,8 @@ class uiScheduler extends uiCalendar {
} }
foreach ($arr as $key => $val) { foreach ($arr as $key => $val) {
$arr[$key]['title'] = $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE); $arr[$key]['title'] = $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE);
$arr[$key]['creator'] = $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_CREATOR); $arr[$key]['creator'] = $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_CREATOR);
$arr[$key]['pos'] = $this->_datetime2timestamp($val['start']); $arr[$key]['pos'] = $this->_datetime2timestamp($val['start']);
$arr[$key]['span'] = date('H', $this->_datetime2timestamp($val['end'])) - date('H', $this->_datetime2timestamp($val['start'])) +1; $arr[$key]['span'] = date('H', $this->_datetime2timestamp($val['end'])) - date('H', $this->_datetime2timestamp($val['start'])) +1;
} }
@ -446,7 +443,7 @@ class uiScheduler extends uiCalendar {
//print_r($ui_fmask['schedule']); //print_r($ui_fmask['schedule']);
$form = new HTML_QuickForm('schedule', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('schedule', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$this->Base->_parseArr2Form($form, $ui_fmask['schedule']); uiBase::parseArrayToForm($form, $ui_fmask['schedule']);
$settime = array('H' => $this->scheduleAtTime['hour'], $settime = array('H' => $this->scheduleAtTime['hour'],
'i' => $this->scheduleAtTime['minute'], 'i' => $this->scheduleAtTime['minute'],
's' => $this->scheduleAtTime['second'] 's' => $this->scheduleAtTime['second']
@ -459,7 +456,7 @@ class uiScheduler extends uiCalendar {
'date' => $setdate, 'date' => $setdate,
)); ));
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
$output = $renderer->toArray(); $output = $renderer->toArray();
//print_r($output); //print_r($output);
@ -473,8 +470,8 @@ class uiScheduler extends uiCalendar {
$this->Base->SCRATCHPAD->addItem($id); $this->Base->SCRATCHPAD->addItem($id);
$this->availablePlaylists[] = array( $this->availablePlaylists[] = array(
'gunid' => $this->Base->gb->_gunidFromId($id), 'gunid' => $this->Base->gb->_gunidFromId($id),
'title' => $this->Base->_getMDataValue($id, UI_MDATA_KEY_TITLE), 'title' => $this->Base->getMetadataValue($id, UI_MDATA_KEY_TITLE),
'duration' => $this->Base->_getMDataValue($id, UI_MDATA_KEY_DURATION), 'duration' => $this->Base->getMetadataValue($id, UI_MDATA_KEY_DURATION),
); );
return TRUE; return TRUE;
} else { } else {
@ -643,6 +640,7 @@ class uiScheduler extends uiCalendar {
return array(FALSE); return array(FALSE);
} }
$pStampArr = null;
foreach ($pArr as $val) { foreach ($pArr as $val) {
#print_r($val); #print_r($val);
$pStampArr[] = array('start' => $this->_datetime2timestamp($val['start']), $pStampArr[] = array('start' => $this->_datetime2timestamp($val['start']),

View file

@ -171,45 +171,55 @@ $mdefs = array(
class SchedulerPhpClient { class SchedulerPhpClient {
/** /**
* Databases object reference * Databases object reference
* @var DB
*/ */
var $dbc = NULL; private $dbc = NULL;
/**
* Array with methods description
*/
var $mdefs = array();
/**
* Confiduration array from ../conf.php
*/
var $config = array();
/**
* XMLRPC client object reference
*/
var $client = NULL;
/**
* Verbosity flag
*/
var $verbose = FALSE;
/**
* XMLRPC debug flag
*/
var $debug = 0;
/** /**
* Constructor - please DON'T CALL IT, use factory method instead * Array with methods description
* @var array
*/
private $mdefs = array();
/**
* Confiduration array from ../conf.php
* @var array
*/
private $config = array();
/**
* XMLRPC client object reference
* @var XMLRPC_Client
*/
private $client = NULL;
/**
* Verbosity flag
* @var boolean
*/
private $verbose = FALSE;
/**
* XMLRPC debug flag
* @var boolean
*/
private $debug = 0;
/**
* Constructor - please DON'T CALL IT, use factory method instead
* *
* @param DB $dbc * @param DB $dbc
* @param array $mdefs * @param array $mdefs
* hash array with methods description * hash array with methods description
* @param array $config * @param array $config
* hash array with configuration * hash array with configuration
* @param int $debug * @param int $debug
* XMLRPC debug flag * XMLRPC debug flag
* @param boolean $verbose * @param boolean $verbose
* verbosity flag * verbosity flag
*/ */
function SchedulerPhpClient( public function __construct(&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE)
&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE)
{ {
$this->dbc = $dbc; $this->dbc = $dbc;
$this->mdefs = $mdefs; $this->mdefs = $mdefs;
@ -252,7 +262,7 @@ class SchedulerPhpClient {
* verbosity flag * verbosity flag
* @return object, created object instance * @return object, created object instance
*/ */
function &factory(&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE) public function &factory(&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE)
{ {
$f = ''; $f = '';
foreach ($mdefs as $fn => $farr) { foreach ($mdefs as $fn => $farr) {
@ -271,7 +281,7 @@ class SchedulerPhpClient {
if (FALSE === eval($e)) { if (FALSE === eval($e)) {
return $dbc->raiseError("Eval failed"); return $dbc->raiseError("Eval failed");
} }
$spc =& new SchedulerPhpClientCore( $spc = new SchedulerPhpClientCore(
$dbc, $mdefs, $config, $debug, $verbose); $dbc, $mdefs, $config, $debug, $verbose);
return $spc; return $spc;
} // fn factory } // fn factory
@ -288,7 +298,7 @@ class SchedulerPhpClient {
* @return array * @return array
* PHP hash with response * PHP hash with response
*/ */
function callMethod($method, $gettedPars) public function callMethod($method, $gettedPars)
{ {
$parr = array(); $parr = array();
$XML_RPC_val = new XML_RPC_Value; $XML_RPC_val = new XML_RPC_Value;

View file

@ -6,14 +6,14 @@
*/ */
class uiScratchPad class uiScratchPad
{ {
var $Base; private $Base;
var $items; private $items;
var $order; private $order;
var $reloadUrl; private $reloadUrl;
function uiScratchPad(&$uiBase) public function __construct(&$uiBase)
{ {
$this->Base =& $uiBase; $this->Base =& $uiBase;
$this->items =& $_SESSION[UI_SCRATCHPAD_SESSNAME]['content']; $this->items =& $_SESSION[UI_SCRATCHPAD_SESSNAME]['content'];
$this->order =& $_SESSION[UI_SCRATCHPAD_SESSNAME]['order']; $this->order =& $_SESSION[UI_SCRATCHPAD_SESSNAME]['order'];
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close'; $this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
@ -46,8 +46,8 @@ class uiScratchPad
foreach ($arr as $gunid) { foreach ($arr as $gunid) {
if (preg_match('/[0-9]{1,20}/', $gunid)) { if (preg_match('/[0-9]{1,20}/', $gunid)) {
if ($this->Base->gb->_idFromGunid($this->Base->_toHex($gunid)) != FALSE) { if ($this->Base->gb->_idFromGunid($this->Base->toHex($gunid)) != FALSE) {
if ($i = $this->Base->_getMetaInfo($this->Base->gb->_idFromGunid($this->Base->_toHex($gunid)))) { if ($i = $this->Base->getMetaInfo($this->Base->gb->_idFromGunid($this->Base->toHex($gunid)))) {
$this->items[] = $i; $this->items[] = $i;
} }
} }
@ -61,7 +61,7 @@ class uiScratchPad
{ {
foreach ($this->items as $val) { foreach ($this->items as $val) {
//$str .= $val['gunid'].':'.$val['added'].' '; ## new format ### //$str .= $val['gunid'].':'.$val['added'].' '; ## new format ###
$str .= $this->Base->_toInt8($val['gunid']).' '; ## Akos<6F> old format ### $str .= $this->Base->toInt8($val['gunid']).' '; ## Akos<6F> old format ###
} }
$this->Base->gb->savePref($this->Base->sessid, UI_SCRATCHPAD_KEY, $str); $this->Base->gb->savePref($this->Base->sessid, UI_SCRATCHPAD_KEY, $str);
} // fn save } // fn save
@ -87,7 +87,7 @@ class uiScratchPad
$sp = $this->get(); $sp = $this->get();
foreach ($ids as $id) { foreach ($ids as $id) {
$item = $this->Base->_getMetaInfo($id); $item = $this->Base->getMetaInfo($id);
foreach ($sp as $key=>$val) { foreach ($sp as $key=>$val) {
if ($val['id'] == $item['id']) { if ($val['id'] == $item['id']) {
@ -167,7 +167,7 @@ class uiScratchPad
function reLoadM() function reLoadM()
{ {
foreach($this->items as $key=>$val) { foreach($this->items as $key=>$val) {
$this->items[$key] = $this->Base->_getMetaInfo($val['id']); $this->items[$key] = $this->Base->getMetaInfo($val['id']);
} }
} }
} // class uiScratchPad } // class uiScratchPad

View file

@ -6,21 +6,21 @@
*/ */
class uiSearch class uiSearch
{ {
var $Base; private $Base;
var $prefix; private $prefix;
var $criteria; private $criteria;
var $reloadUrl; private $reloadUrl;
var $results; private $results;
function uiSearch(&$uiBase) public function __construct(&$uiBase)
{ {
$this->Base =& $uiBase; $this->Base =& $uiBase;
$this->prefix = 'SEARCH'; $this->prefix = 'SEARCH';
//$this->results =& $_SESSION[UI_SEARCH_SESSNAME]['results']; //$this->results =& $_SESSION[UI_SEARCH_SESSNAME]['results'];
$this->criteria =& $_SESSION[UI_SEARCH_SESSNAME]['criteria']; $this->criteria =& $_SESSION[UI_SEARCH_SESSNAME]['criteria'];
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close'; $this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
if (empty($this->criteria['limit'])) { if (empty($this->criteria['limit'])) {
$this->criteria['limit'] = UI_BROWSE_DEFAULT_LIMIT; $this->criteria['limit'] = UI_BROWSE_DEFAULT_LIMIT;
} }
} }
@ -47,7 +47,7 @@ class uiSearch
function searchForm($id, $mask2) function searchForm($id, $mask2)
{ {
//print_r($this->criteria['form']); //print_r($this->criteria['form']);
include dirname(__FILE__).'/formmask/metadata.inc.php'; include(dirname(__FILE__).'/formmask/metadata.inc.php');
$form = new HTML_QuickForm('search', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('search', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$counter = isset($this->criteria['counter']) ? $this->criteria['counter'] : 1; $counter = isset($this->criteria['counter']) ? $this->criteria['counter'] : 1;
$form->setConstants(array('id'=>$id, 'counter'=>$counter)); $form->setConstants(array('id'=>$id, 'counter'=>$counter));
@ -55,11 +55,11 @@ class uiSearch
foreach ($mask['pages'] as $key=>$val) { foreach ($mask['pages'] as $key=>$val) {
foreach ($mask['pages'][$key] as $v){ foreach ($mask['pages'][$key] as $v){
if (isset($v['type']) && $v['type']) { if (isset($v['type']) && $v['type']) {
$col1[$this->Base->_formElementEncode($v['element'])] = tra($v['label']); $col1[uiBase::formElementEncode($v['element'])] = tra($v['label']);
if (isset($val['relation'])) { if (isset($val['relation'])) {
$col2[$this->Base->_formElementEncode($v['element'])] = $mask2['relations'][$v['relation']]; $col2[uiBase::formElementEncode($v['element'])] = $mask2['relations'][$v['relation']];
} else { } else {
$col2[$this->Base->_formElementEncode($v['element'])] = $mask2['relations']['standard']; $col2[uiBase::formElementEncode($v['element'])] = $mask2['relations']['standard'];
} }
} }
}; };
@ -101,11 +101,11 @@ class uiSearch
$form->addElement('static', 's2', NULL, "</div id='searchRow_$n'>"); $form->addElement('static', 's2', NULL, "</div id='searchRow_$n'>");
} }
$this->Base->_parseArr2Form($form, $mask2['search']); uiBase::parseArrayToForm($form, $mask2['search']);
$constants = isset($this->criteria['form']) ? $this->criteria['form'] : null; $constants = isset($this->criteria['form']) ? $this->criteria['form'] : null;
$form->setConstants($constants); $form->setConstants($constants);
$form->validate(); $form->validate();
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
$output['dynform'] = $renderer->toArray(); $output['dynform'] = $renderer->toArray();
//print_r($output); //print_r($output);
@ -134,7 +134,7 @@ class uiSearch
foreach ($formdata as $key=>$val) { foreach ($formdata as $key=>$val) {
if (is_array($val) && $val['active']) { if (is_array($val) && $val['active']) {
$this->criteria['counter']++; $this->criteria['counter']++;
$this->criteria['conditions'][$key] = array('cat' => $this->Base->_formElementDecode($val[0]), $this->criteria['conditions'][$key] = array('cat' => uiBase::formElementDecode($val[0]),
'op' => $val[1], 'op' => $val[1],
'val' => stripslashes($val[2]) 'val' => stripslashes($val[2])
); );
@ -152,8 +152,8 @@ class uiSearch
function simpleSearchForm($mask) function simpleSearchForm($mask)
{ {
$form = new HTML_QuickForm('simplesearch', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('simplesearch', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$this->Base->_parseArr2Form($form, $mask); uiBase::parseArrayToForm($form, $mask);
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
$output = $renderer->toArray(); $output = $renderer->toArray();
//print_r($output); //print_r($output);
@ -179,7 +179,7 @@ class uiSearch
'op' => constant('UI_SIMPLESEARCH_OP'.$n), 'op' => constant('UI_SIMPLESEARCH_OP'.$n),
'val' => stripslashes($formdata['criterium']) 'val' => stripslashes($formdata['criterium'])
); );
$this->criteria['form']['row_'.$n]= array(0 => $this->Base->_formElementEncode(constant('UI_SIMPLESEARCH_CAT'.$n)), $this->criteria['form']['row_'.$n]= array(0 => uiBase::formElementEncode(constant('UI_SIMPLESEARCH_CAT'.$n)),
1 => constant('UI_SIMPLESEARCH_OP'.$n), 1 => constant('UI_SIMPLESEARCH_OP'.$n),
2 => stripslashes($formdata['criterium']) 2 => stripslashes($formdata['criterium'])
); );
@ -206,7 +206,7 @@ class uiSearch
} }
foreach ($results['results'] as $rec) { foreach ($results['results'] as $rec) {
$tmpId = $this->Base->gb->_idFromGunid($rec["gunid"]); $tmpId = $this->Base->gb->_idFromGunid($rec["gunid"]);
$this->results['items'][] = $this->Base->_getMetaInfo($tmpId); $this->results['items'][] = $this->Base->getMetaInfo($tmpId);
} }
$this->results['cnt'] = $results['cnt']; $this->results['cnt'] = $results['cnt'];

View file

@ -1,7 +1,7 @@
<?php <?php
$Smarty->register_object('UIBROWSER', $uiBrowser); $Smarty->register_object('UIBROWSER', $uiBrowser);
$Smarty->register_object('BROWSE', $uiBrowser->BROWSE); $Smarty->register_object('BROWSE', $uiBrowser->BROWSE);
$Smarty->register_object('HUBBROWSE', $uiBrowser->HUBBROWSE); $Smarty->register_object('HUBBROWSE', $HUBBROWSE);
$Smarty->register_object('SEARCH', $uiBrowser->SEARCH); $Smarty->register_object('SEARCH', $uiBrowser->SEARCH);
$Smarty->register_object('HUBSEARCH', $uiBrowser->HUBSEARCH); $Smarty->register_object('HUBSEARCH', $uiBrowser->HUBSEARCH);
$Smarty->register_object('TRANSFERS', $uiBrowser->TRANSFERS); $Smarty->register_object('TRANSFERS', $uiBrowser->TRANSFERS);

View file

@ -6,18 +6,17 @@
*/ */
class uiSubjects class uiSubjects
{ {
public $Base;
private $reloadUrl;
private $suRedirUrl;
private $redirUrl;
var $Base; public function __construct(&$uiBase)
var $reloadUrl;
var $suRedirUrl;
var $redirUrl;
function uiSubjects(&$uiBase)
{ {
$this->Base =& $uiBase; $this->Base =& $uiBase;
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close'; $this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
$this->suRedirUrl = UI_BROWSER.'?act=SUBJECTS'; $this->suRedirUrl = UI_BROWSER.'?act=SUBJECTS';
$this->redirUrl = UI_BROWSER.'?act=SUBJECTS'; $this->redirUrl = UI_BROWSER.'?act=SUBJECTS';
} }
@ -50,8 +49,8 @@ class uiSubjects
include(dirname(__FILE__). '/formmask/subjects.inc.php'); include(dirname(__FILE__). '/formmask/subjects.inc.php');
$form = new HTML_QuickForm('addSubject', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('addSubject', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$this->Base->_parseArr2Form($form, $mask[$type]); uiBase::parseArrayToForm($form, $mask[$type]);
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
return $renderer->toArray(); return $renderer->toArray();
} }
@ -145,9 +144,9 @@ class uiSubjects
} else { } else {
$mask['chgPasswd']['cancel']['attributes'] = array('onClick' => 'location.href="'.UI_BROWSER.'"'); $mask['chgPasswd']['cancel']['attributes'] = array('onClick' => 'location.href="'.UI_BROWSER.'"');
} }
$this->Base->_parseArr2Form($form, $mask['chgPasswd']); uiBase::parseArrayToForm($form, $mask['chgPasswd']);
$form->setConstants(array('login' => $login)); $form->setConstants(array('login' => $login));
$renderer =& new HTML_QuickForm_Renderer_Array(true, true); $renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer); $form->accept($renderer);
return $renderer->toArray(); return $renderer->toArray();
} }

View file

@ -7,14 +7,14 @@
*/ */
class uiTransfers class uiTransfers
{ {
var $Base; private $Base;
var $allItems; private $allItems;
var $rows; private $rows;
var $trShowInfo; private $trShowInfo;
var $reloadUrl; private $reloadUrl;
function uiTransfers(&$uiBase) public function __construct(&$uiBase)
{ {
$this->Base =& $uiBase; $this->Base =& $uiBase;
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close'; $this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';