Renamed LiveSupport to Campcaster. Got rid of copyright notice in files, we will just have one that covers all files at the root of the package. Converted comments to Phpdocumentor format. Added @author, @version, @package, and @subpackage doc tags. Reformatted code to Campware PHP coding conventions.

This commit is contained in:
paul 2006-10-16 18:20:28 +00:00
parent a181a9991a
commit 9370f5c88d
36 changed files with 1277 additions and 959 deletions

View file

@ -1,29 +1,6 @@
#!/usr/bin/php
#-------------------------------------------------------------------------------
# Copyright (c) 2004 Media Development Loan Fund
#
# This file is part of the Campcaster project.
# http://campcaster.campware.org/
# To report bugs, send an e-mail to bugs@campware.org
#
# Campcaster is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Campcaster is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Campcaster; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
# Author : $Author$
# Version : $Revision$
# Location : $URL$
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# This script configures php for the htmlUI

View file

@ -8,7 +8,7 @@
<body>
<h1>Preface</h1>
This document is part of the
<a href="http://livesupport.campware.org/">LiveSupport</a>
<a href="http://campcaster.campware.org/">Campcaster</a>
project, Copyright © 2004 <a href="http://www.mdlf.org/">Media
Development Loan Fund</a>, under the GNU <a
href="http://www.gnu.org/licenses/gpl.html">GPL</a>.<br>

View file

@ -91,4 +91,3 @@ $mask = array(
)
);
?>

View file

@ -850,3 +850,4 @@ $ui_fmask = array(
)
)
);
?>

View file

@ -60,3 +60,4 @@ $relations = array(
'ls:url' => 'Stream URL'
);
?>

View file

@ -1,3 +1,3 @@
<?php
header('LOCATION: /livesupport/htmlUI/var/html/ui_browser.php');
header('LOCATION: /campcaster/htmlUI/var/html/ui_browser.php');
?>

View file

@ -1,10 +1,9 @@
<?php
function login(&$data)
{
include dirname(__FILE__).'/../../../storageServer/var/conf.php';
include_once dirname(__FILE__).'/../../../storageServer/var/GreenBox.php';
include_once 'DB.php';
include(dirname(__FILE__).'/../../../storageServer/var/conf.php');
include_once(dirname(__FILE__).'/../../../storageServer/var/GreenBox.php');
include_once('DB.php');
$dbc = DB::connect($config['dsn'], TRUE);
@ -15,7 +14,6 @@ function login(&$data)
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$gb =& new GreenBox($dbc, $config);
if (!$data['PHP_AUTH_USER'] || !$data['PHP_AUTH_PW']) {
return FALSE;
}

View file

@ -1,12 +1,12 @@
<?php
/**
* _parseArr2Form
*
* Add elements/rules/groups to an given HTML_QuickForm object
*
* @param form object, reference to HTML_QuickForm object
* @param mask array, reference to array defining to form elements
* @param side string, side where the validation should beeing
* @param HTML_Quickform $form
* @param array $mask
* array defining form elements
* @param string $sid
* side where the validation should happen ('client', 'server')
*/
function parseArr2Form(&$form, $mask, $side='client')
{
@ -22,16 +22,23 @@ function parseArr2Form(&$form, $mask, $side='client')
} elseif ($v['type'] == 'select') {
$elem[$v['element']] =& $form->createElement($v['type'], $v['element'], tra($v['label']), $v['options'], $v['attributes']);
$elem[$v['element']]->setMultiple($v['multiple']);
if (isset($v['selected'])) $elem[$v['element']]->setSelected($v['selected']);
if (!$v['groupit']) $form->addElement($elem[$v['element']]);
if (isset($v['selected'])) {
$elem[$v['element']]->setSelected($v['selected']);
}
if (!$v['groupit']) {
$form->addElement($elem[$v['element']]);
}
} elseif ($v['type'] == 'date') {
$elem[$v['element']] =& $form->createElement($v['type'], $v['element'], tra($v['label']), $v['options'], $v['attributes']);
if (!$v['groupit']) $form->addElement($elem[$v['element']]);
if (!$v['groupit']) {
$form->addElement($elem[$v['element']]);
}
} elseif ($v['type']=='checkbox' || $v['type']=='static') {
} elseif (($v['type'] == 'checkbox') || ($v['type'] == 'static')) {
$elem[$v['element']] =& $form->createElement($v['type'], $v['element'], tra($v['label']), $v['text'], $v['attributes']);
if (!$v['groupit']) $form->addElement($elem[$v['element']]);
if (!$v['groupit']) {
$form->addElement($elem[$v['element']]);
}
} elseif (isset($v['type'])) {
$elem[$v['element']] =& $form->createElement($v['type'], $v['element'], tra($v['label']),
@ -39,25 +46,27 @@ function parseArr2Form(&$form, $mask, $side='client')
($v['type']=='textarea' ? array_merge(array('rows'=>UI_TEXTAREA_STANDART_ROWS, 'cols'=>UI_TEXTAREA_STANDART_COLS), $v['attributes']) :
($v['type']=='button' || $v['type']=='submit' || $v['type']=='reset' ? array_merge(array('class'=>UI_BUTTON_STYLE), $v['attributes']) : $v['attributes']))
);
if (!$v['groupit']) $form->addElement($elem[$v['element']]);
if (!$v['groupit']) {
$form->addElement($elem[$v['element']]);
}
## add required rule ###################
}
// add required rule ###################
if ($v['required']) {
$form->addRule($v['element'], isset($v['requiredmsg']) ? tra($v['requiredmsg']) : tra('Missing value for $1', tra($v['label'])), 'required', NULL, $side);
}
## add constant value ##################
// add constant value ##################
if (isset($v['constant'])) {
$form->setConstants(array($v['element']=>$v['constant']));
}
## add default value ###################
// add default value ###################
if (isset($v['default'])) {
$form->setDefaults(array($v['element']=>$v['default']));
}
## add other rules #####################
// add other rules #####################
if ($v['rule']) {
$form->addRule($v['element'], isset($v['rulemsg']) ? tra($v['rulemsg']) : tra('$1 must be $2', tra($v['element']), tra($v['rule'])), $v['rule'] ,$v['format'], $side);
}
## add group ###########################
// add group ###########################
if (is_array($v['group'])) {
foreach($v['group'] as $val) {
$groupthose[] =& $elem[$val];

View file

@ -1,3 +1,3 @@
<?php
header('LOCATION: /livesupport/htmlUI/var/html/ui_browser.php');
header('LOCATION: /campcaster/htmlUI/var/html/ui_browser.php');
?>

View file

@ -3,7 +3,7 @@
<html>
<head>
<title>LIVESUPPORT</title>
<title>Campcaster</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
{* <link rel="stylesheet" href="styles.css"> *}

View file

@ -71,11 +71,11 @@ if (window.attachEvent) window.attachEvent("onload", sfHover);
{if $SUBJECTS->isMemberOf('StationPrefs')}
<li><a href="{$UI_BROWSER}?act=changeStationPrefs">##Station Settings##</a></li>
{/if}
{if $SUBJECTS->isMemberOf('Subjects')}
{*if $SUBJECTS->isMemberOf('Subjects')*}
<li><a href="{$UI_BROWSER}?act=SUBJECTS">##User/Groups##</a></li>
{else}
{*else*}
<li><a href="{$UI_BROWSER}?act=SUBJECTS.chgPasswd&id={$USER.userid}">##Change Password##</a></li>
{/if}
{*/if*}
{if $SUBJECTS->isMemberOf('Admins')}
<li><a href="{$UI_BROWSER}?act=fileList&id={$START.fid}">##File List##</a></li>
{/if}

View file

@ -3,7 +3,7 @@
<html>
<head>
<title>LIVESUPPORT</title>
<title>Campcaster</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="styles_popup.css" rel="stylesheet" type="text/css" />

View file

@ -2,7 +2,7 @@
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<title>LiveSupport Help</title>
<title>Campcaster Help</title>
<style>
{literal}
@ -91,7 +91,7 @@ DIV.blockquote
<H2>Navigation</H2>
<H3>Context menus</H3>
<P>The LiveSupport web client uses context menus extensively
<P>The Campcaster web client uses context menus extensively
throughout the program. For example, by clicking on the ScratchPad,
you can perform a number of operations on your file, including
adding it to a playlist and removing it from the ScratchPad. &nbsp;
@ -113,7 +113,7 @@ DIV.blockquote
and this which isn't opened will appear in normal text.
</P>
<H2>Playlists</H2>
<P>Playlists are at the core of how LiveSupport works. You add sound
<P>Playlists are at the core of how Campcaster works. You add sound
files to a playlist, and then schedule that playlist to be played at
a date and time of your choosing. Playlists are edited in the
Playlist Editor. You can include an unlimited number of playlists
@ -127,7 +127,7 @@ DIV.blockquote
</P>
<H3>Changing file order in the playlist</H3>
<P>You can change a file's order in the playlist by clicking on the
up or down arrows on the right.<BR>As of LiveSupport 1.0.1, you can
up or down arrows on the right.<BR>As of Campcaster 1.0.1, you can
drag and drop playlist items to change their order. This can be done
by &quot;;Re-arrange playlist&quot;; in the playlist editor. &nbsp;
</P>
@ -169,13 +169,13 @@ DIV.blockquote
will remain in the system.
</P>
<H2>Files</H2>
<P>Sound files are added to the LiveSupport system in two steps.</P>
<P>Sound files are added to the Campcaster system in two steps.</P>
<H3>Uploading and analyzing</H3>
<P>The first step is to select the sound file you want to upload
into the LiveSupport system. This is handled in the Upload -&gt; New
into the Campcaster system. This is handled in the Upload -&gt; New
file menu. You select the file to upload by clicking on the &quot;Browse&quot;
button, choosing your sound file, then clicking &quot;Submit&quot;.
LiveSupport automatically analyzes the sound file for any
Campcaster automatically analyzes the sound file for any
information that may be stored in ID3 tags.<BR>See the
&quot;Troubleshooting&quot; section if you cannot upload files.
</P>
@ -270,15 +270,15 @@ DIV.blockquote
<H3>File Upload</H3>
<P>If you encounter the message <i>The uploadet filer is bigger than allowed in system settings.</i> most probably the file size is bigger than
allowed in the PHP system settings of the machine you are running
LiveSupport on. Please increase the settings of
Campcaster on. Please increase the settings of
&quot;upload_max_filesize&quot; and &quot;post_max_size&quot; in
php.ini. For more information, consult the <A HREF="http://code.campware.org/manuals/livesupport/1.0/index.php?id=42" TARGET="_blank">LiveSupport
php.ini. For more information, consult the <A HREF="http://code.campware.org/manuals/campcaster/1.0/index.php?id=42" TARGET="_blank">Campcaster
manual</A> chapter 4.12.
</P>
<H2>Where to go for help</H2>
<P>LiveSupport has a mailing list for support-related questions at
<P>Campcaster has a mailing list for support-related questions at
<A HREF="mailto:ls-support@campware.org">ls-support@campware.org</A>,
or you can visit the LiveSupport forums at <A HREF="http://www.campware.org/" TARGET="_blank">http://www.campware.org</A></P>
or you can visit the Campcaster forums at <A HREF="http://www.campware.org/" TARGET="_blank">http://www.campware.org</A></P>
</P>
{if tra('_Name of translator') !== '_Name of translator'}

View file

@ -7,6 +7,7 @@ function jscom_wrapper($object, $parent, $method) {
return call_user_func_array(array(&$GLOBALS[$object]->$parent, "$method"), $args);
}
function errCallBack($err)
{
echo "<pre>gm:\n".$err->getMessage()."\ndi:\n".$err->getDebugInfo()."\nui:\n".$err->getUserInfo()."\n";
@ -32,11 +33,14 @@ function _getLanguages()
return $languages;
}
/**
* Translate the given string using localisation files.
* Translate the given string using localization files.
*
* @param string $input - string to translate
* @return string, translated string
* @param string $input
* string to translate
* @return string
* translated string
*/
function tra($input)
{
@ -104,23 +108,13 @@ function _getNumArr($start, $end, $step=1)
/**
* uiBase class
*
* LiveSupport HTML User Interface module
*
* HTML User Interface module
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiBase
{
// --- class constructor ---
/**
* uiBase
*
* Initialize a new Basis Class including:
* - database initialation
* - GreenBox initialation
*
* @param $config array, configurartion data
*/
var $redirUrl;
var $alertMsg;
var $dbc;
@ -149,6 +143,16 @@ class uiBase
var $TRANSFERS;
var $_self_;
/**
* uiBase
*
* Initialize a new Basis Class including:
* - database initialation
* - GreenBox initialation
*
* @param array $config
* configurartion data
*/
function uiBase(&$config)
{
$this->dbc = DB::connect($config['dsn'], TRUE);
@ -230,9 +234,12 @@ class uiBase
*
* Add elements/rules/groups to an given HTML_QuickForm object
*
* @param HTML_Quickform $form - reference to HTML_QuickForm object
* @param array $mask - reference to array defining the form elements
* @param string $side - can be 'client' or 'server' - this is where the form validation occurs.
* @param HTML_Quickform $form
* reference to HTML_QuickForm object
* @param array $mask
* reference to array defining the form elements
* @param string $side
* can be 'client' or 'server' - this is where the form validation occurs.
*/
function _parseArr2Form(&$form, &$mask, $side='client')
{
@ -346,7 +353,8 @@ class uiBase
/**
* Converts date-array from form into string
*
* @param array $input - array of form-elements
* @param array $input
* array of form-elements
*/
function _dateArr2Str(&$input)
{
@ -368,7 +376,8 @@ class uiBase
/**
* Call getid3 library to analyze media file and show some results
*
* @param int $id local ID of file
* @param int $id
* local ID of file
* @param string $format
*/
function _analyzeFile($id, $format)
@ -387,7 +396,7 @@ class uiBase
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:ls="http://mdlf.org/livesupport/elements/1.0/"
xmlns:ls="http://mdlf.org/campcaster/elements/1.0/"
>
<dc:title>'.$this->_getFileTitle($id).'</dc:title>
<dcterms:extent>'.$extent.'</dcterms:extent>
@ -416,6 +425,7 @@ class uiBase
/**
* Add an alert message to the session var.
* @todo Fix this to use call_user_func()
*
* @param string $msg
* @param string $p1

View file

@ -1,4 +1,9 @@
<?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiBrowse
{
var $Base; // uiBase object
@ -7,6 +12,7 @@ class uiBrowse
var $criteria;
var $reloadUrl;
function uiBrowse(&$uiBase)
{
$this->Base =& $uiBase;
@ -135,8 +141,6 @@ class uiBrowse
/**
* Enter description here...
*
* @param array $parm
*/
function setValue($parm)

View file

@ -1,4 +1,9 @@
<?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiBrowser extends uiBase {
var $alertMsg;
@ -7,7 +12,8 @@ class uiBrowser extends uiBase {
* Initialize a new Browser Class.
* Call uiBase constructor.
*
* @param $config array, configurartion data
* @param array $config
* configurartion data
*/
function uiBrowser(&$config)
{
@ -19,8 +25,10 @@ class uiBrowser extends uiBase {
* Perform a frontend action.
* Map to a function called action_<actionName>.inc.php
*
* @param string $actionName - name of an action
* @param array $params - request vars
* @param string $actionName
* name of an action
* @param array $params
* request vars
*/
function performAction( $actionName, $params )
{
@ -56,7 +64,8 @@ class uiBrowser extends uiBase {
/**
* Create a login-form.
*
* @param array $mask - an array of all webforms in the system
* @param array $mask
* an array of all webforms in the system
* @return array
*/
function login($mask)
@ -75,7 +84,8 @@ class uiBrowser extends uiBase {
/**
* Get info about logged in user.
*
* @return array (uname=>user_name, uid=>user_id)
* @return array
* (uname=>user_name, uid=>user_id)
*/
function getUserInfo()
{
@ -87,8 +97,10 @@ class uiBrowser extends uiBase {
/**
* Get directory-structure
*
* @param int $id - local ID of start-directory
* @return array - tree of directory with subs
* @param int $id
* local ID of start-directory
* @return array
* tree of directory with subs
*/
function getStructure($id)
{
@ -151,9 +163,10 @@ class uiBrowser extends uiBase {
/**
* Create a form to add a Webstream.
*
* @param int local $id of directory to store stream
*
* @eturn string (html)
* @param int $id
* local of directory to store stream
* @return string
* HTML string
*/
function webstreamForm($parms)
{
@ -197,8 +210,8 @@ class uiBrowser extends uiBase {
/**
* Get permissions for local object ID.
*
* @param $id int local ID (file/folder)
*
* @param int $id
* local ID (file/folder)
* @return array
*/
function permissions($id)
@ -218,7 +231,8 @@ class uiBrowser extends uiBase {
* Example only - not really useable.
* TODO: resource should be released by release method call
*
* @param id int, local id of accessed file
* @param id int
* local id of accessed file
*/
function getFile($id)
{
@ -236,7 +250,8 @@ class uiBrowser extends uiBase {
*
* Note: this does not work right with multiple languages
*
* @param id int, local id of stored file
* @param id int
* local id of stored file
* @return array
*/
function getMdata($id)
@ -290,7 +305,8 @@ class uiBrowser extends uiBase {
* Create a form to edit Metadata.
*
* @param array $parms
* @return string (html)
* @return string
* HTML string
*/
function metaDataForm($parms)
{
@ -319,7 +335,9 @@ class uiBrowser extends uiBase {
// values from database.
foreach ($mask['pages'] as $key => $val) {
foreach ($mask['pages'][$key] as $k=>$v) {
if (!is_array($mask['pages'][$key][$k]['attributes'])) $mask['pages'][$key][$k]['attributes'] = array();
if (!is_array($mask['pages'][$key][$k]['attributes'])) {
$mask['pages'][$key][$k]['attributes'] = array();
}
$mask['pages'][$key][$k]['element'] = $key.'___'.$this->_formElementEncode($v['element']);
$mask['pages'][$key][$k]['attributes'] = array_merge($mask['pages'][$key][$k]['attributes'], array('onChange' => "spread(this, '".$this->_formElementEncode($v['element'])."')"));
## load data from GreenBox
@ -361,7 +379,8 @@ class uiBrowser extends uiBase {
/**
* Test if URL seems to be valid
*
* @param url string, full URL to test
* @param url string
* full URL to test
* @return array()
*/
function testStream($url)

View file

@ -1,4 +1,9 @@
<?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiCalendar
{
var $Decade;
@ -112,7 +117,7 @@ class uiCalendar
return;
}
require_once 'Calendar/Day.php';
require_once('Calendar/Day.php');
$Day = new Calendar_Day ($this->curr['year'], $this->curr['month'], $this->curr['day']);
$Day->build();
@ -138,7 +143,7 @@ class uiCalendar
{
if (is_array($this->Hour)) return;
require_once 'Calendar/Hour.php';
require_once('Calendar/Hour.php');
$Hour = new Calendar_Hour($this->curr['year'], $this->curr['month'], $this->curr['day'], $this->curr['hour']);
$Hour->build();

View file

@ -7,11 +7,13 @@ define('UI_VERBOSE', FALSE);
define('UI_WARNING', TRUE);
define('UI_ERROR', TRUE);
if (UI_DEBUG) error_reporting(E_ALL);
if (UI_DEBUG) {
error_reporting(E_ALL);
}
define('UI_VERSION', 'LiveSupport 1.1.0');
define('UI_VERSION_FULLNAME', 'LiveSupport 1.1.0');
define('UI_VERSION', 'Campcaster 1.1.0');
define('UI_VERSION_FULLNAME', 'Campcaster 1.1.0');
define('UI_TESTSTREAM_MU3_TMP', 'img/listen.m3u');
## Local settings

View file

@ -7,15 +7,16 @@ define('UI_VERBOSE', FALSE);
define('UI_WARNING', TRUE);
define('UI_ERROR', TRUE);
if (UI_DEBUG) error_reporting(E_ALL);
if (UI_DEBUG) {
error_reporting(E_ALL);
}
define('UI_VERSION', 'LiveSupport 1.1.0');
define('UI_VERSION_FULLNAME', 'LiveSupport 1.1.0');
define('UI_VERSION', 'Campcaster 1.1.0');
define('UI_VERSION_FULLNAME', 'Campcaster 1.1.0');
define('UI_TESTSTREAM_MU3_TMP', 'img/listen.m3u');
## Scheduler
define('UI_SCHEDULER_DAEMON_CMD', '/etc/init.d/livesupport-station start >/tmp/scheduler.log 2>&1 &'); ## adjust the start-command here
define('UI_SCHEDULER_DAEMON_CMD', '/etc/init.d/campcaster-station start >/tmp/scheduler.log 2>&1 &'); ## adjust the start-command here
define('UI_SCHEDULER_DAEMON_NAME', 'scheduler'); ## this is name of scheduler process to grep in process list for it
## Local settings

View file

@ -1,6 +1,15 @@
<?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiExchange
{
var $Base;
var $file;
var $folder;
function uiExchange(&$uiBase)
{
$this->Base =& $uiBase;
@ -20,60 +29,52 @@ class uiExchange
if (PEAR::isError($token)) {
return false;
}
return $token;
}
function createBackupOpen()
{
$criteria = array('filetype' => UI_FILETYPE_ANY);
$token = $this->Base->gb->createBackupOpen($this->Base->sessid, $criteria);
if (PEAR::isError($token)) {
$this->Base->_retMsg('Error initializing backup: $1', $token->getMessage());
return false;
}
$this->createBackupCheck();
$this->Base->gb->savePref($this->Base->sessid, UI_BACKUPTOKEN_KEY, $token['token']);
return true;
}
function createBackupCheck()
{
$token = $this->getBackupToken();
if ($token === false) {
return false;
}
$res = $this->Base->gb->createBackupCheck($token);
if (PEAR::isError($res)) {
$this->Base->_retMsg('Unable to check backup status: $1', $res->getMessage());
return false;
}
return $res;
}
// Download the backup
function createBackupDownload()
{
$check = $this->createBackupCheck();
header('Content-Length: '.filesize($check['tmpfile']));
header("Content-Transfer-Encoding: binary");
$newname='backup_'.date("Ymd", filectime($check['tmpfile'])).'.tar';
header('Content-Disposition: attachment; filename="'.$newname.'"');
readfile($check['tmpfile']);
}
function createBackupClose()
{
$token = $this->getBackupToken();
@ -82,34 +83,39 @@ class uiExchange
$this->Base->_retMsg('Token not available');
return false;
}
$status = $this->Base->gb->createBackupClose($token);
if (PEAR::isError($status)) {
$this->Base->_retMsg('Error closing backup: $1', $status->getMessage());
return false;
}
if ($status === true) {
$this->Base->gb->delPref($this->Base->sessid, UI_BACKUPTOKEN_KEY);
}
return $status;
}
// backup schduler methods
/**
* @return array
*/
function getScheduleBackupForm()
{
include 'formmask/exchange.inc.php';
include('formmask/exchange.inc.php');
$form = new HTML_QuickForm('BACKUP_Schedule', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$this->Base->_parseArr2Form($form, $mask['BACKUP.schedule']);
$renderer =& new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer);
return $renderer->toArray();
}
/**
* Copy a file or directory.
*
* @param string $target - path to file or directory
* @return boolean
*/
function copy2target($target)
{
if (is_dir($target)) {
@ -128,7 +134,6 @@ class uiExchange
return false;
}
$check = $this->createBackupCheck();
if ($check['status'] === 'success') {
@ -154,60 +159,54 @@ class uiExchange
return $token;
}
/**
* @param unknown_type $backupFile
* @return boolean
*/
function backupRestoreOpen($backupFile)
{
$token = $this->Base->gb->backupRestoreOpen($this->Base->sessid,$backupFile);
if (PEAR::isError($token)) {
$this->Base->_retMsg('Error initializing backup restore: $1', $token->getMessage());
return false;
}
#$this->backupRestoreCheck(); //?
$this->Base->gb->savePref($this->Base->sessid, UI_RESTORETOKEN_KEY, $token['token']);
return true;
}
function backupRestoreCheck()
{
$token = $this->getRestoreToken();
if ($token === false) {
return false;
}
$res = $this->Base->gb->backupRestoreCheck($token);
if (PEAR::isError($res)) {
$this->Base->_retMsg('Unable to check backup restore status: $1', $res->getMessage());
return false;
}
return $res;
}
function backupRestoreClose()
{
$token = $this->getRestoreToken();
if ($token === false) {
$this->Base->_retMsg('Backup restore token is not available');
return false;
}
$status = $this->Base->gb->backupRestoreClose($token);
if (PEAR::isError($status)) {
$this->Base->_retMsg('Error closing restore backup: $1', $status->getMessage());
return false;
}
if ($status === true) {
$this->Base->gb->delPref($this->Base->sessid, UI_RESTORETOKEN_KEY);
}
return $status;
}
@ -231,6 +230,7 @@ class uiExchange
$this->folder = $newfolder;
}
function setFile($file)
{
if (is_writable($this->folder.'/'.$file)) {

View file

@ -3,38 +3,32 @@
define('ACTION_BASE', '/actions' ) ;
/**
* uiHandler class
*
* Campcaster HTML User Interface module
* HTML User Interface module
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiHandler extends uiBase {
# var $redirUrl;
# var $alertMsg;
var $uiBase;
var $redirUrl;
// --- class constructor ---
/**
* uiBrowser
*
* Initialize a new Browser Class
* Call uiBase constructor
*
* @param $config array, configurartion data
* @param array $config
* configurartion data
*/
function uiHandler($config)
{
$this->uiBase($config);
}
} // constructor
// --- authentication ---
/**
* login
*
* Login to the storageServer.
* It set sessid to the cookie with name defined in ../conf.php
*
* @param login string, username
* @param pass string, password
*/
function login($formdata, $mask)
{
@ -77,15 +71,14 @@ class uiHandler extends uiBase {
$this->redirUrl = UI_BROWSER.'?popup[]=_2SCHEDULER&popup[]=_close';
return TRUE;
}
} // fn login
/**
* logout
*
* Logut from storageServer, takes sessid from cookie
*
* @param $trigger_login boolean, trigger login popup after logout
*
* @param boolean $trigger_login
* trigger login popup after logout
*/
function logout($trigger_login = FALSE)
{
@ -95,24 +88,27 @@ class uiHandler extends uiBase {
ob_clean();
session_destroy();
if ($trigger_login)
if ($trigger_login) {
$this->redirUrl = UI_BROWSER.'?popup[]=_clear_parent&popup[]=login';
else $this->redirUrl = UI_BROWSER.'?popup[]=_clear_parent&popup[]=_close';
} else {
$this->redirUrl = UI_BROWSER.'?popup[]=_clear_parent&popup[]=_close';
}
} // fn logout
// --- files ---
/**
* uploadFile
*
* Provides file upload and store it to the storage
*
* @param formdata array, submitted text and file
* @param id int, destination folder id
* @param array $formdata
* submitted text and file
*/
function uploadFile($formdata, $mask, $replace=NULL)
{
if ($this->test4audioType($formdata['mediafile']['name']) === FALSE) {
if (UI_ERROR) $this->_retMsg('"$1" uses an unsupported file type.', $formdata['mediafile']['name']);
if (UI_ERROR) {
$this->_retMsg('"$1" uses an unsupported file type.', $formdata['mediafile']['name']);
}
$this->redirUrl = UI_BROWSER."?act=addFileData&folderId=".$formdata['folderId'];
return FALSE;
}
@ -148,28 +144,37 @@ class uiHandler extends uiBase {
$this->_setMDataValue($r, UI_MDATA_KEY_TITLE, $formdata['mediafile']['name']);
$this->transMData($r);
if (UI_UPLOAD_LANGID !== UI_DEFAULT_LANGID) { // set records in default language too
// set records in default language too
if (UI_UPLOAD_LANGID !== UI_DEFAULT_LANGID) {
$this->_setMDataValue($r, UI_MDATA_KEY_TITLE, $formdata['mediafile']['name'], UI_UPLOAD_LANGID);
$this->transMData($r, UI_UPLOAD_LANGID);
}
$this->redirUrl = UI_BROWSER."?act=addFileMData&id=$r";
if (UI_VERBOSE) $this->_retMsg('Data of audiclip saved.');
return $r;
if (UI_VERBOSE) {
$this->_retMsg('Data of audiclip saved.');
}
return $r;
} // fn uploadFile
function test4audioType($filename)
{
foreach ($this->config['file_types'] as $t) {
if (preg_match('/'.str_replace('/', '\/', $t).'$/i', $filename))
if (preg_match('/'.str_replace('/', '\/', $t).'$/i', $filename)) {
return TRUE;
}
return FALSE;
}
return FALSE;
} // fn test4AudioType
/**
* @todo Rename this function.
* @param unknown_type $id
* @param unknown_type $langid
* @return void
*/
function transMData($id, $langid=UI_DEFAULT_LANGID)
{
include dirname(__FILE__).'/formmask/metadata.inc.php';
@ -179,10 +184,18 @@ class uiHandler extends uiBase {
$this->_setMDataValue($id, UI_MDATA_KEY_FORMAT, UI_MDATA_VALUE_FORMAT_FILE);
// some data from raw audio
if ($ia['audio']['channels']) $this->_setMDataValue($id, UI_MDATA_KEY_CHANNELS, $ia['audio']['channels']);
if ($ia['audio']['sample_rate'])$this->_setMDataValue($id, UI_MDATA_KEY_SAMPLERATE, $ia['audio']['sample_rate']);
if ($ia['audio']['bitrate']) $this->_setMDataValue($id, UI_MDATA_KEY_BITRATE, $ia['audio']['bitrate']);
if ($ia['audio']['codec']) $this->_setMDataValue($id, UI_MDATA_KEY_ENCODER, $ia['audio']['codec']);
if ($ia['audio']['channels']) {
$this->_setMDataValue($id, UI_MDATA_KEY_CHANNELS, $ia['audio']['channels']);
}
if ($ia['audio']['sample_rate']) {
$this->_setMDataValue($id, UI_MDATA_KEY_SAMPLERATE, $ia['audio']['sample_rate']);
}
if ($ia['audio']['bitrate']) {
$this->_setMDataValue($id, UI_MDATA_KEY_BITRATE, $ia['audio']['bitrate']);
}
if ($ia['audio']['codec']) {
$this->_setMDataValue($id, UI_MDATA_KEY_ENCODER, $ia['audio']['codec']);
}
// from id3 Tags
foreach ($mask['pages'] as $key=>$val) { ## loop main, music, talk
@ -201,12 +214,10 @@ class uiHandler extends uiBase {
/**
* addWebstream
*
* Provides file upload and store it to the storage
*
* @param formdata array, submitted text and file
* @param id int, destination folder id
* @param array $formdata, submitted text and file
* @param unknown $mask
*/
function addWebstream($formdata, $mask)
{
@ -238,9 +249,11 @@ class uiHandler extends uiBase {
$this->_setMDataValue($r, UI_MDATA_KEY_FORMAT, UI_MDATA_VALUE_FORMAT_STREAM);
$this->redirUrl = UI_BROWSER."?act=addWebstreamMData&id=$r";
if (UI_VERBOSE) $this->_retMsg('Stream data saved.');
return $r;
if (UI_VERBOSE) {
$this->_retMsg('Stream data saved.');
}
return $r;
} // fn addWebstream
function editWebstream($formdata, $mask)
@ -257,15 +270,20 @@ class uiHandler extends uiBase {
$this->_setMDataValue($id, UI_MDATA_KEY_DURATION, $extent);
$this->redirUrl = UI_BROWSER.'?act=editItem&id='.$formdata['id'];
if (UI_VERBOSE) $this->_retMsg('Stream data saved.');
return TRUE;
if (UI_VERBOSE) {
$this->_retMsg('Stream data saved.');
}
return TRUE;
} // fn editWebstream
/**
* @todo Rename this function to "editMetadata".
* @param unknown_type $formdata
*/
function editMetaData($formdata)
{
include dirname(__FILE__).'/formmask/metadata.inc.php';
include(dirname(__FILE__).'/formmask/metadata.inc.php');
$id = $formdata['id'];
$curr_langid = $formdata['curr_langid'];
$this->redirUrl = UI_BROWSER."?act=editItem&id=$id&curr_langid=".$formdata['target_langid'];
@ -276,7 +294,9 @@ class uiHandler extends uiBase {
}
}
if (!count($mData)) return;
if (!count($mData)) {
return;
}
foreach ($mData as $key => $val) {
$r = $this->_setMDataValue($id, $key, $val, $curr_langid);
@ -285,49 +305,57 @@ class uiHandler extends uiBase {
}
}
if (UI_VERBOSE) $this->_retMsg('Metadata saved.');
if (UI_VERBOSE) {
$this->_retMsg('Metadata saved.');
}
} // fn editMetadata
/**
* newFolder
*
* Create new folder in the storage
*
* @param newname string, name for the new folder
* @param id int, local id to create folder in
* @param string $name
* name for the new folder
* @param int $id
* local id to create folder in
*/
function newFolder($name, $id)
{
$r = $this->gb->createFolder($id, $name, $this->sessid);
if(PEAR::isError($r))
if (PEAR::isError($r)) {
$this->_retMsg($r->getMessage());
$this->redirUrl = UI_BROWSER.'?act=fileList&id='.$this->id;
}
$this->redirUrl = UI_BROWSER.'?act=fileList&id='.$this->id;
} // fn newFolder
/**
* rename
*
* Change the name of file or folder
*
* @param newname string, new name for the file or folder
* @param id int, destination folder id
* @param string $newname
* new name for the file or folder
* @param int $id
* destination folder id
*/
function rename($newname, $id)
{
$r = $this->gb->renameFile($id, $newname, $this->sessid);
if(PEAR::isError($r)) $this->_retMsg($r->getMessage());
$this->redirUrl = UI_BROWSER."?act=fileList&id=".$this->pid;
if (PEAR::isError($r)) {
$this->_retMsg($r->getMessage());
}
$this->redirUrl = UI_BROWSER."?act=fileList&id=".$this->pid;
} // fn rename
/**
* move
*
* Move file to another folder
* TODO: format of destinantion path should be properly defined
*
* @param newPath string, destination relative path
* @param id int, destination folder id
* @todo format of destination path should be properly defined
*
* @param string $newPath
* destination relative path
* @param int $id
* destination folder id
*/
function move($newPath, $id)
{
@ -337,18 +365,21 @@ class uiHandler extends uiBase {
if (PEAR::isError($r)) {
$this->_retMsg($r->getMessage());
$this->redirUrl = UI_BROWSER."?act=fileList&id=".$this->pid;
} else {
$this->redirUrl = UI_BROWSER."?act=fileList&id=".$did;
}
else $this->redirUrl = UI_BROWSER."?act=fileList&id=".$did;
}
} // fn move
/**
* copy
*
* Copy file to another folder
* TODO: format of destinantion path should be properly defined
*
* @param newPath string, destination relative path
* @param id int, destination folder id
* @todo format of destinantion path should be properly defined
*
* @param string $newPath
* destination relative path
* @param int $id
* destination folder id
*/
function copy($newPath, $id)
{
@ -358,17 +389,21 @@ class uiHandler extends uiBase {
if (PEAR::isError($r)) {
$this->_retMsg($r->getMessage());
$this->redirUrl = UI_BROWSER."?act=fileList&id=".$this->pid;
} else {
$this->redirUrl = UI_BROWSER."?act=fileList&id=".$did;
}
else $this->redirUrl = UI_BROWSER."?act=fileList&id=".$did;
}
} // fn copy
/**
* delete
* Delete a stored file.
*
* Delete of stored file
*
* @param id int, local id of deleted file or folder
* @param delOverride int, local id od folder which can deleted if not empty
* @param mixed $id
* either an int or an array of ints which are
* IDs of files or folders to delete.
* @param boolean $delOverride
* this parameter is not used
* @return boolean
*/
function delete($id, $delOverride=FALSE)
{
@ -383,8 +418,11 @@ class uiHandler extends uiBase {
}
*/
if (is_array($id)) $ids = $id;
else $ids[] = $id;
if (is_array($id)) {
$ids = $id;
} else {
$ids[] = $id;
}
foreach ($ids as $id) {
if ($this->gb->getFileType($id) == 'playlist') {
@ -400,31 +438,33 @@ class uiHandler extends uiBase {
}
return TRUE;
}
} // fn delete
/**
* getFile
*
* Call access method and show access path.
* Example only - not really useable.
* TODO: resource should be released by release method call
* @todo resource should be released by release method call
*
* @param id int, local id of accessed file
* @param int $id
* local id of accessed file
*/
function getFile($id)
{
$r = $this->gb->access($id, $this->sessid);
if(PEAR::isError($r)) $this->_retMsg($r->getMessage());
else echo $r;
if (PEAR::isError($r)) {
$this->_retMsg($r->getMessage());
} else {
echo $r;
}
} // fn getFile
/**
* getMdata
*
* Show file's metadata as XML
*
* @param id int, local id of stored file
* @param int $id
* local id of stored file
*/
function getMdata($id)
{
@ -433,16 +473,20 @@ class uiHandler extends uiBase {
print_r($r);
}
// --- perms ---
/**
* addPerm
*
* Add new permission record
*
* @param subj int, local user/group id
* @param permAction string, type of action from set predefined in conf.php
* @param id int, local id of file/object
* @param allowDeny char, A or D
* @param int $subj
* local user/group id
* @param string $permAction
* type of action from set predefined in conf.php
* @param int $id
* local id of file/object
* @param char $allowDeny
* 'A' or 'D'
* @return boolean
*/
function addPerm($subj, $permAction, $id, $allowDeny)
{
@ -456,15 +500,16 @@ class uiHandler extends uiBase {
}
$this->redirUrl = UI_BROWSER.'?act=permissions&id='.$id;
return TRUE;
}
} // fn addPerm
/**
* removePerm
*
* Remove permission record
*
* @param permid int, local id of permission record
* @param oid int, local id of object to handle
* @param int $permid
* local id of permission record
* @param int $oid
* local id of object to handle
*/
function removePerm($permid, $oid)
{
@ -474,12 +519,10 @@ class uiHandler extends uiBase {
}
$this->redirUrl = UI_BROWSER.'?act=permissions&id='.$oid;
return TRUE;
}
} // fn removePerm
/**
* Enter description here...
*
* @param unknown_type $formdata
* @param array $mask
* @return boolean
@ -536,9 +579,14 @@ class uiHandler extends uiBase {
}
} */
return TRUE;
}
} // fn _validateForm
/**
* @param unknown_type $formdata
* @param unknown_type $mask
* @return boolean
*/
function changeStationPrefs($formdata, $mask)
{
$this->redirUrl = UI_BROWSER;

View file

@ -1,6 +1,12 @@
<?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiHubBrowse extends uiBrowse
{
function uiHubBrowse(&$uiBase)
{
$this->Base =& $uiBase;
@ -10,27 +16,34 @@ class uiHubBrowse extends uiBrowse
#$this->results =& $_SESSION[UI_HUBBROWSE_SESSNAME]['results'];
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
if (empty($this->criteria['limit'])) $this->criteria['limit'] = UI_BROWSE_DEFAULT_LIMIT;
if (empty($this->criteria['filetype'])) $this->criteria['filetype'] = UI_FILETYPE_ANY;
if (empty($this->criteria['limit'])) {
$this->criteria['limit'] = UI_BROWSE_DEFAULT_LIMIT;
}
if (empty($this->criteria['filetype'])) {
$this->criteria['filetype'] = UI_FILETYPE_ANY;
}
if (!is_array($this->col)) {
## init Categorys
$this->setDefaults();
}
}
} // constructor
function getResult()
{
$this->getSearchResults($this->searchDB());
//return $this->searchDB();
return $this->results;
}
} // fn getResult
function searchDB()
{
$trtokid = $this->Base->gb->globalSearch($this->criteria);
return $trtokid;
}
} // fn searchDB
function getSearchResults($trtokid) {
$this->results = array('page' => $this->criteria['offset']/$this->criteria['limit']);
@ -47,6 +60,7 @@ class uiHubBrowse extends uiBrowse
// echo '<XMP>this->results:'; print_r($this->results); echo "</XMP>\n";
// echo '<XMP>results:'; print_r($results); echo "</XMP>\n";
return is_array($results);
}
}
} // fn getSearchResults
} // fn uiHubBrowse
?>

View file

@ -1,6 +1,11 @@
<?php
class uiHubSearch extends uiSearch
{
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiHubSearch extends uiSearch {
function uiHubSearch(&$uiBase)
{
$this->Base =& $uiBase;
@ -9,8 +14,11 @@ class uiHubSearch extends uiSearch
$this->criteria =& $_SESSION[UI_HUBSEARCH_SESSNAME]['criteria'];
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
if (empty($this->criteria['limit'])) $this->criteria['limit'] = UI_BROWSE_DEFAULT_LIMIT;
if (empty($this->criteria['limit'])) {
$this->criteria['limit'] = UI_BROWSE_DEFAULT_LIMIT;
}
} // constructor
function getResult()
{
@ -20,7 +28,8 @@ class uiHubSearch extends uiSearch
return $this->results;
}
return false;
}
} // fn getResult
function newSearch(&$formdata)
{
@ -33,8 +42,8 @@ class uiHubSearch extends uiSearch
$this->criteria['limit'] = $formdata['limit'];
$this->criteria['counter'] = 0;
$this->criteria['form']['operator'] = $formdata['operator']; ## $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']['filetype'] = $formdata['filetype'];
$this->criteria['form']['limit'] = $formdata['limit'];
@ -56,17 +65,17 @@ class uiHubSearch extends uiSearch
$trtokid = $this->Base->gb->globalSearch($this->criteria);
$this->Base->redirUrl = UI_BROWSER.'?popup[]='.$this->prefix.'.getResults&trtokid='.$trtokid;
}
} // fn newSearch
function searchDB()
{
if (count($this->criteria) === 0)
if (count($this->criteria) === 0) {
return FALSE;
}
$this->results = array('page' => $this->criteria['offset'] / $this->criteria['limit']);
#print_r($this->criteria);
//print_r($this->criteria);
$results = $this->Base->gb->localSearch($this->criteria, $this->Base->sessid);
if (PEAR::isError($results)) {
#print_r($results);
@ -78,11 +87,12 @@ class uiHubSearch extends uiSearch
}
$this->results['cnt'] = $results['cnt'];
#print_r($this->results);
//print_r($this->results);
$this->pagination($results);
return TRUE;
}
} // fn searchDB
function getSearchResults($trtokid) {
$this->results = array('page' => $this->criteria['offset']/$this->criteria['limit']);
@ -99,7 +109,7 @@ class uiHubSearch extends uiSearch
//echo '<XMP>this->results:'; print_r($this->results); echo "</XMP>\n";
//echo '<XMP>results:'; print_r($results); echo "</XMP>\n";
return is_array($results);
}
} // fn getSearchResults
}
} // class uiHubSearch
?>

View file

@ -1,20 +1,32 @@
<?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class jscom {
var $prefix = 'jsc_';
var $callables = array();
var $method = 'POST';
var $uri = '';
function jscom($calls = NULL, $pars = NULL){
function jscom($calls = NULL, $pars = NULL)
{
$this->uri = $_SERVER['REQUEST_URI'];
if(!is_null($calls)) $this->addCallables($calls);
if (!is_null($calls)) {
$this->addCallables($calls);
}
if (is_array($pars)) {
foreach ($pars as $parname=>$par) {
if(!is_null($par)) $this->setPar($parname, $par);
if (!is_null($par)) {
$this->setPar($parname, $par);
}
}
}
}
function noCacheHeader ()
{
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
@ -22,13 +34,24 @@ class jscom{
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
}
function handler()
{
$args = array();
$mode = '';
if(!empty($_GET[$this->prefix."mn"])){ $mode = 'get'; $rqst = $_GET; $this->noCacheHeader(); }
if(!empty($_POST[$this->prefix."mn"])){ $mode = 'post'; $rqst = $_POST; }
if(empty($mode)){ return; }
if (!empty($_GET[$this->prefix."mn"])) {
$mode = 'get';
$rqst = $_GET;
$this->noCacheHeader();
}
if (!empty($_POST[$this->prefix."mn"])) {
$mode = 'post';
$rqst = $_POST;
}
if (empty($mode)) {
return;
}
$methodName = $rqst[$this->prefix.'mn'];
$args = $rqst[$this->prefix.'args'];
if (in_array($methodName, $this->callables)) {
@ -38,13 +61,18 @@ class jscom{
}
if (is_array($res)) {
$r = array();
foreach($res as $k=>$v){ $r[] = "'$v'"; }
foreach ($res as $k=>$v) {
$r[] = "'$v'";
}
$res = "[".join(', ', $r)."]";
}
echo $res;
exit;
}
function genJsCode(){
function genJsCode()
{
ob_start();
?>
var method = "<?php echo $this->method; ?>";
@ -76,11 +104,15 @@ class jscom{
uri = "<?php echo $this->uri; ?>";
arstr = "<?php echo$this->prefix; ?>mn="+escape(methodName);
for (i = 0; i < args.length; i++){ arstr += "&<?php echo$this->prefix; ?>args[]=" + escape(args[i]); }
for (i = 0; i < args.length; i++) {
arstr += "&<?php echo$this->prefix; ?>args[]=" + escape(args[i]);
}
if (method == "GET") {
uri += ((uri.indexOf("?") == -1) ? "?" : "&" ) + arstr;
uri += "&<?php echo$this->prefix; ?>x=" + new Date().getTime();
}else{ post_data = arstr; }
} else {
post_data = arstr;
}
comObj = createComObj();
comObj.callbackOrId = callbackOrId;
@ -90,7 +122,9 @@ class jscom{
comObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
}
comObj.onreadystatechange = function() {
if(comObj.readyState != 4) return;
if (comObj.readyState != 4) {
return;
}
var data = comObj.responseText;
if (typeof comObj.callbackOrId == "function") {
callbackOrId(data);
@ -119,15 +153,24 @@ class jscom{
ob_end_clean();
return $code;
}
function addCallables() {
function addCallables()
{
$n = func_num_args();
for ($i = 0; $i < $n; $i++) {
$a = func_get_arg($i);
if(is_array($a)) $this->callables = array_merge($this->callables, $a);
else $this->callables[] = $a;
if (is_array($a)) {
$this->callables = array_merge($this->callables, $a);
} else {
$this->callables[] = $a;
}
}
function setPar($parName, $value = NULL) {
}
function setPar($parName, $value = NULL)
{
switch ($parName) {
case "method":
case "uri":

View file

@ -1,6 +1,21 @@
<?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiPlaylist
{
var $Base;
var $activeId;
var $changed;
var $title;
var $duration;
var $token;
var $reloadUrl;
var $redirectUrl;
var $returnUrl;
function uiPlaylist(&$uiBase)
{
$this->Base =& $uiBase;
@ -12,30 +27,36 @@ class uiPlaylist
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
$this->redirectUrl = UI_BROWSER.'?popup[]=_2PL.simpleManagement&popup[]=_close';
$this->returnUrl = UI_BROWSER.'?act=PL.simpleManagement';
}
} // constructor
function setReload()
{
$this->Base->redirUrl = $this->reloadUrl;
}
} // fn setReload
function setRedirect($target=FALSE)
{
if ($target!==FALSE)
if ($target !== FALSE) {
$this->Base->redirUrl = UI_BROWSER."?popup[]=$target&popup[]=_close";
else
} else {
$this->Base->redirUrl = $this->redirectUrl;
}
} // fn setRedirect
function setReturn()
{
$this->Base->redirUrl = $this->returnUrl;
}
} // fn setReturn
function getPLArray($id)
{
return $this->Base->gb->getPlaylistArray($id, $this->Base->sessid);
}
} // fn getPLArray
function getActiveArr()
{
@ -44,7 +65,8 @@ class uiPlaylist
}
#echo '<pre><div align="left">'; print_r( $this->Base->gb->getPlaylistArray($this->activeId, $this->Base->sessid)); echo '</div></pre>';
return $this->getPLArray($this->activeId);
}
} // fn getActiveArr
function getActiveId()
{
@ -52,7 +74,8 @@ class uiPlaylist
return FALSE;
}
return $this->activeId;
}
} // fn getActiveId
function activate($plid, $msg=TRUE)
{
@ -61,27 +84,36 @@ class uiPlaylist
# store access token to ls_pref abd session
# load PL into session
if ($this->token) {
if (UI_WARNING) $this->Base->_retMsg('You already have an open playlist. Close it first.');
if (UI_WARNING) {
$this->Base->_retMsg('You already have an open playlist. Close it first.');
}
return FALSE;
}
if (($userid = $this->Base->gb->playlistIsAvailable($plid, $this->Base->sessid)) !== TRUE) {
if (UI_WARNING) $this->Base->_retMsg('Playlist has been locked by "$1".', $this->Base->gb->getSubjName($userid));
if (UI_WARNING) {
$this->Base->_retMsg('Playlist has been locked by "$1".', $this->Base->gb->getSubjName($userid));
}
return FALSE;
}
$token = $this->Base->gb->lockPlaylistForEdit($plid, $this->Base->sessid);
if (PEAR::isError($token)) {
if (UI_VERBOSE === TRUE) print_r($token);
if (UI_VERBOSE === TRUE) {
print_r($token);
}
$this->Base->_retMsg('Unable to open playlist "$1".', $this->Base->_getMDataValue($plid, UI_MDATA_KEY_TITLE));
return FALSE;
}
$this->token = $token;
$this->Base->gb->savePref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY, $plid.':'.$this->token);
$this->activeId = $plid;
if ($msg && UI_VERBOSE) $this->Base->_retMsg('Playlist "$1" opened.', $this->Base->_getMDataValue($plid, UI_MDATA_KEY_TITLE));
if ($msg && UI_VERBOSE) {
$this->Base->_retMsg('Playlist "$1" opened.', $this->Base->_getMDataValue($plid, UI_MDATA_KEY_TITLE));
}
return TRUE;
}
function release($msg=TRUE)
{
# get token from ls_pref
@ -89,23 +121,31 @@ class uiPlaylist
# delete PL from session
# remove token from ls_pref
if (!$this->token) {
if (UI_WARNING) $this->Base->_retMsg('There is no playlist available to unlock.');
if (UI_WARNING) {
$this->Base->_retMsg('There is no playlist available to unlock.');
}
return FALSE;
}
$plgunid = $this->Base->gb->releaseLockedPlaylist($this->token, $this->Base->sessid);
if (PEAR::isError($plgunid)) {
if (UI_VERBOSE === TRUE) print_r($plgunid);
if (UI_WARNING) $this->Base->_retMsg('Unable to release playlist.');
if (UI_VERBOSE === TRUE) {
print_r($plgunid);
}
if (UI_WARNING) {
$this->Base->_retMsg('Unable to release playlist.');
}
return FALSE;
}
if ($msg && UI_VERBOSE) $this->Base->_retMsg('Playlist "$1" released.', $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($plgunid), UI_MDATA_KEY_TITLE));
if ($msg && UI_VERBOSE) {
$this->Base->_retMsg('Playlist "$1" released.', $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($plgunid), UI_MDATA_KEY_TITLE));
}
$this->activeId = NULL;
$this->token = NULL;
$this->Base->gb->delPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY);
$this->changed = FALSE;
return TRUE;
}
} // fn release
function save()
@ -114,45 +154,60 @@ class uiPlaylist
$this->release(FALSE);
$this->activate($tmpid, FALSE);
$this->changed = FALSE;
if (UI_VERBOSE) $this->Base->_retMsg('Playlist "$1" saved.', $this->Base->_getMDataValue($tmpid, UI_MDATA_KEY_TITLE));
if (UI_VERBOSE) {
$this->Base->_retMsg('Playlist "$1" saved.', $this->Base->_getMDataValue($tmpid, UI_MDATA_KEY_TITLE));
}
return $this->activeId;
}
} // fn save
function revert()
{
if (!$this->token) {
if (UI_WARNING) $this->Base->_retMsg('No playlists have been locked by you.');
if (UI_WARNING) {
$this->Base->_retMsg('No playlists have been locked by you.');
}
return FALSE;
}
$plgunid = $this->Base->gb->revertEditedPlaylist($this->token, $this->Base->sessid);
if (PEAR::isError($plgunid)) {
if (UI_VERBOSE === TRUE) print_r($plgunid);
if (UI_WARNING) $this->Base->_retMsg('Unable to revert to locked state.');
if (UI_VERBOSE === TRUE) {
print_r($plgunid);
}
if (UI_WARNING) {
$this->Base->_retMsg('Unable to revert to locked state.');
}
return FALSE;
}
if (UI_VERBOSE) $this->Base->_retMsg('Playlist "$1" reverted.', $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($plgunid), UI_MDATA_KEY_TITLE));
if (UI_VERBOSE) {
$this->Base->_retMsg('Playlist "$1" reverted.', $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($plgunid), UI_MDATA_KEY_TITLE));
}
$this->activeId = NULL;
$this->token = NULL;
$this->Base->gb->delPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY);
if ($this->activate($this->Base->gb->_idFromGunid($plgunid), FALSE) !== TRUE)
if ($this->activate($this->Base->gb->_idFromGunid($plgunid), FALSE) !== TRUE) {
return FALSE;
}
$this->changed = FALSE;
return $this->activeId;
}
} // fn revert
function reportLookedPL($setMsg=FALSE)
{
if (is_string($this->Base->gb->loadPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY))) {
if ($setMsg == TRUE) $this->Base->_retMsg('Found locked playlist.');
if ($setMsg == TRUE) {
$this->Base->_retMsg('Found locked playlist.');
}
return TRUE;
}
return FALSE;
}
} // fn reportLookedPL
function loadLookedFromPref()
{
@ -174,7 +229,8 @@ class uiPlaylist
return TRUE;
}
return FALSE;
}
} // fn loadLookedFromPref
function addItem($elemIds, $duration=null)
{
@ -184,7 +240,9 @@ class uiPlaylist
$pause = null;
if (!$elemIds) {
if (UI_WARNING) $this->Base->_retMsg('No item(s) selected.');
if (UI_WARNING) {
$this->Base->_retMsg('No item(s) selected.');
}
return FALSE;
}
if (!is_array($elemIds)) {
@ -196,20 +254,25 @@ class uiPlaylist
foreach ($elemIds as $elemId) {
$r = $this->Base->gb->addAudioClipToPlaylist($this->token, $elemId, $this->Base->sessid, $fadeIn, $fadeOut, $length, $pause);
if (PEAR::isError($r)) {
if (UI_VERBOSE === TRUE) print_r($r);
if (UI_VERBOSE === TRUE) {
print_r($r);
}
$this->Base->_retMsg('Error while trying to add item to playlist.');
return FALSE;
}
}
return TRUE;
}
} // fn addItem
function removeItem($elemIds)
{
$this->changed = TRUE;
if (!$elemIds) {
if (UI_WARNING) $this->Base->_retMsg('No item(s) selected.');
if (UI_WARNING) {
$this->Base->_retMsg('No item(s) selected.');
}
return FALSE;
}
if (!is_array($elemIds))
@ -222,7 +285,8 @@ class uiPlaylist
}
}
return TRUE;
}
} // fn removeItem
function create($ids)
{
@ -256,7 +320,7 @@ class uiPlaylist
#$this->redirUrl = UI_BRWOSER.'?popup=_2PL.simpleManagement';<br>
return $plid;
}
} // fn create
function getFlat($id)
@ -275,7 +339,7 @@ class uiPlaylist
} else {
return array();
}
}
} // fn getFlat
function _plwalk($arr, $parent=0, $attrs=0)
@ -298,7 +362,7 @@ class uiPlaylist
$this->flat[$parent]['fadeout_ms'] = $sub['attrs'][UI_PL_ELEM_FADEOUT] ? GreenBox::_plTimeToSecs($sub['attrs'][UI_PL_ELEM_FADEOUT]) * 1000 : 0;
}
}
}
} // fn _plwalk
function changeTransition($id, $type, $duration)
@ -348,7 +412,9 @@ class uiPlaylist
$r = $this->Base->gb->changeFadeInfo($this->token, $i, $val[UI_PL_ELEM_FADEIN], $val[UI_PL_ELEM_FADEOUT], $this->Base->sessid);
#print_r($r);
if (PEAR::isError($r)) {
if (UI_VERBOSE === TRUE) print_r($r);
if (UI_VERBOSE === TRUE) {
print_r($r);
}
$this->Base->_retMsg('Changing fade information failed.');
return FALSE;
}
@ -359,14 +425,16 @@ class uiPlaylist
$r = $this->Base->gb->changeFadeInfo($this->token, $v['attrs']['id'], $type==='pause'?$pause:$xfade, $type==='pause'?$pause:$xfade, $this->Base->sessid);
#print_r($r);
if (PEAR::isError($r)) {
if (UI_VERBOSE === TRUE) print_r($r);
if (UI_VERBOSE === TRUE) {
print_r($r);
}
$this->Base->_retMsg('Changing fade information failed.');
return FALSE;
}
}
}
return TRUE;
}
} // fn changeTransition
function moveItem($id, $pos)
@ -375,31 +443,37 @@ class uiPlaylist
$r = $this->Base->gb->moveAudioClipInPlaylist($this->token, $id, $pos, $this->Base->sessid);
if (PEAR::isError($r)) {
if (UI_VERBOSE === TRUE) print_r($r);
if (UI_VERBOSE === TRUE) {
print_r($r);
}
$this->Base->_retMsg('Cannot move item.');
return FALSE;
}
return TRUE;
}
} // fn moveItem
function reOrder($items)
{
$this->changed = TRUE;
asort($items); # just to be sure items are in right order
// just to be sure items are in right order
asort($items);
$pos = 0;
foreach ($items as $id => $v) {
$pos++;
$r = $this->Base->gb->moveAudioClipInPlaylist($this->token, $id, $pos, $this->Base->sessid);
if (PEAR::isError($r)) {
if (UI_VERBOSE === TRUE) print_r($r);
if (UI_VERBOSE === TRUE) {
print_r($r);
}
$this->Base->_retMsg('Cannot move item.');
return FALSE;
}
}
return TRUE;
}
} // fn reorder
function getCurrElement($id)
{
@ -410,7 +484,7 @@ class uiPlaylist
}
next($arr);
}
}
} // fn getCurrElement
function getPrevElement($id)
@ -422,7 +496,7 @@ class uiPlaylist
}
next($arr);
}
}
} // fn getPrevElement
function getNextElement($id)
@ -434,7 +508,7 @@ class uiPlaylist
}
next($arr);
}
}
} // fn getNextElement
function changeTransitionForm($id, $type, $mask)
@ -466,7 +540,7 @@ class uiPlaylist
$renderer =& new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer);
return $renderer->toArray();
}
} // fn changeTransitionForm
function changeAllTransitionsForm($mask)
@ -477,7 +551,8 @@ class uiPlaylist
$renderer =& new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer);
return $renderer->toArray();
}
} // fn changeAllTransitionsForm
function setItemPlaylengthForm($id, $elemId, $mask)
{
@ -499,7 +574,7 @@ class uiPlaylist
$renderer =& new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer);
return $renderer->toArray();
}
} // fn setItemPlaylengthForm
function metaDataForm($langid)
@ -537,74 +612,88 @@ class uiPlaylist
#print_r($output);
return $output;
}
} // fn metadataForm
function editMetaData($formdata)
{
$this->changed = TRUE;
include dirname(__FILE__).'/formmask/metadata.inc.php';
include(dirname(__FILE__).'/formmask/metadata.inc.php');
$id = $this->activeId;
$curr_langid = $formdata['curr_langid'];
## if language switched stay on metadataform ##
if ($curr_langid === $formdata['target_langid'])
if ($curr_langid === $formdata['target_langid']) {
$this->Base->redirUrl = UI_BROWSER."?act=PL.simpleManagement";
else
} else {
$this->Base->redirUrl = UI_BROWSER."?act=PL.editMetaData&id=$id&curr_langid=".$formdata['target_langid'];
}
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;
}
if (!count($mData)) return;
if (!count($mData)) {
return;
}
foreach ($mData as $key => $val) {
$r = $this->Base->gb->setMDataValue($id, $key, $this->Base->sessid, $val, $curr_langid);
if (PEAR::isError($r)) {
if (UI_VERBOSE === TRUE) print_r($r);
if (UI_VERBOSE === TRUE) {
print_r($r);
}
$this->Base->_retMsg('Unable to set "$1" to value "$2".', $key, $val);
}
}
if (UI_VERBOSE) $this->Base->_retMsg('Metadata saved.');
if (UI_VERBOSE) {
$this->Base->_retMsg('Metadata saved.');
}
} // fn editMetadata
function deleteActive()
{
$id = $this->activeId;
$this->release(FALSE);
if ($this->Base->delete($id))
if ($this->Base->delete($id)) {
return $id;
}
$this->Base->_retMsg('Cannot delete this playlist.');
return FALSE;
}
} // fn deleteActive
function isAvailable($id)
{
if ($this->Base->gb->getFileType($id) !== UI_FILETYPE_PLAYLIST)
if ($this->Base->gb->getFileType($id) !== UI_FILETYPE_PLAYLIST) {
return TRUE;
}
if ($this->Base->gb->playlistIsAvailable($id, $this->Base->sessid) === TRUE)
if ($this->Base->gb->playlistIsAvailable($id, $this->Base->sessid) === TRUE) {
return TRUE;
}
return FALSE;
}
} // fn isAvailable
function isUsedBy($id)
{
if ($this->Base->gb->getFileType($id) !== UI_FILETYPE_PLAYLIST)
return FALSE;
if (($userid = $this->Base->gb->playlistIsAvailable($id, $this->Base->sessid)) !== TRUE)
return $this->Base->gb->getSubjName($userid);
if ($this->Base->gb->getFileType($id) !== UI_FILETYPE_PLAYLIST) {
return FALSE;
}
if (($userid = $this->Base->gb->playlistIsAvailable($id, $this->Base->sessid)) !== TRUE) {
return $this->Base->gb->getSubjName($userid);
}
return FALSE;
} // fn isUsedBy
function exportForm($id,$mask)
{
$mask['act']['constant'] = 'PL.export';
@ -614,7 +703,8 @@ class uiPlaylist
$renderer =& new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer);
return $renderer->toArray();
}
} // fn exportForm
function importForm($id, $mask)
{
@ -624,6 +714,7 @@ class uiPlaylist
$renderer =& new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer);
return $renderer->toArray();
}
}
} // fn importForm
} // class uiPlaylist
?>

View file

@ -1,6 +1,10 @@
<?php
class uiScheduler extends uiCalendar
{
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiScheduler extends uiCalendar {
var $curr;
var $scheduleAtTime;
var $schedulePrev;
@ -11,6 +15,7 @@ class uiScheduler extends uiCalendar
var $closeUrl;
var $firstDayOfWeek;
function uiScheduler(&$uiBase)
{
$this->curr =& $_SESSION[UI_CALENDAR_SESSNAME]['current'];
@ -181,7 +186,7 @@ class uiScheduler extends uiCalendar
} else {
$this->curr['isToday'] = FALSE;
}
#print_r($this->curr);
//print_r($this->curr);
} // fn set
@ -201,11 +206,11 @@ class uiScheduler extends uiCalendar
$this->schedulePrev['hour'] = 0;
$this->schedulePrev['minute'] = 0;
$this->schedulePrev['second'] = 0;
#$thisDay = $this->scheduleAtTime['year']."-".$this->scheduleAtTime['month']."-".$this->scheduleAtTime['day'];
#$nextDayStamp = strtotime('+1 day', strtotime($thisDay));
#$this->scheduleNext['year'] = strftime('%Y', $nextDayStamp);
#$this->scheduleNext['month'] = strftime('%m', $nextDayStamp);;
#$this->scheduleNext['day'] = strftime('%d', $nextDayStamp);
//$thisDay = $this->scheduleAtTime['year']."-".$this->scheduleAtTime['month']."-".$this->scheduleAtTime['day'];
//$nextDayStamp = strtotime('+1 day', strtotime($thisDay));
//$this->scheduleNext['year'] = strftime('%Y', $nextDayStamp);
//$this->scheduleNext['month'] = strftime('%m', $nextDayStamp);;
//$this->scheduleNext['day'] = strftime('%d', $nextDayStamp);
$this->scheduleNext['hour'] = 23;
$this->scheduleNext['minute'] = 59;
$this->scheduleNext['second'] = 59;
@ -237,7 +242,7 @@ class uiScheduler extends uiCalendar
if (is_array($week = $this->getWeekEntrys())) {
## search for previous entry
// search for previous entry
if (count($week[$this->scheduleAtTime['day']]) >= 1) {
foreach (array_reverse($week[$this->scheduleAtTime['day']]) as $hourly) {
foreach (array_reverse($hourly) as $entry) {
@ -253,7 +258,7 @@ class uiScheduler extends uiCalendar
reset($week);
## search for next entry
// search for next entry
if (count($week[$this->scheduleAtTime['day']]) >= 1) {
foreach ($week[$this->scheduleAtTime['day']] as $hourly) {
foreach ($hourly as $entry) {
@ -267,19 +272,19 @@ class uiScheduler extends uiCalendar
}
}
#print_r($this->schedulePrev);
#print_r($this->scheduleNext);
//print_r($this->schedulePrev);
//print_r($this->scheduleNext);
} // fn setScheduleAtTime
function getWeekEntrys()
{
## build array within all entrys of current week ##
// build array within all entrys of current week ##
$this->buildWeek();
$thisWeekStart = strftime("%Y%m%d", $this->Week[0]['timestamp']);
$nextWeekStart = strftime("%Y%m%d", $this->Week[6]['timestamp'] + 86400);
$arr = $this->displayScheduleMethod($thisWeekStart.'T00:00:00', $nextWeekStart.'T00:00:00');
#print_r($arr);
//print_r($arr);
if (!is_array($arr)) {
return FALSE;
@ -299,19 +304,19 @@ class uiScheduler extends uiCalendar
);
}
#print_r($items);
//print_r($items);
return $items;
} // fn getWeekEntrys
function getDayEntrys()
{
## build array within all entrys of current day ##
// build array within all entrys of current day ##
$this->buildDay();
$thisDay = strftime("%Y%m%d", $this->Day[0]['timestamp']);
$nextDay = strftime("%Y%m%d", $this->Day[0]['timestamp'] + 86400);
$arr = $this->displayScheduleMethod($thisDay.'T00:00:00', $nextDay.'T00:00:00');
#print_r($arr);
//print_r($arr);
if (!is_array($arr)) {
return FALSE;
@ -326,7 +331,7 @@ class uiScheduler extends uiCalendar
$h = number_format(strftime('%H', $start));
$M = number_format(strftime('%i', $start));
## item starts today
// item starts today
if (strftime('%Y%m%d', $start) === $thisDay) {
$items[number_format(strftime('%H', $start))]['start'][] = array(
'id' => $this->Base->gb->_idFromGunid($val['playlistId']),
@ -347,7 +352,7 @@ class uiScheduler extends uiCalendar
}
*/
## item ends today
// item ends today
if (strftime('%Y%m%d', $end) === $thisDay && strftime('%H', $start) !== strftime('%H', $end)) {
$items[number_format(strftime('%H', $end))]['end'][] =
array(
@ -363,7 +368,7 @@ class uiScheduler extends uiCalendar
}
}
#print_r($items);
//print_r($items);
return $items;
} // fn getDayEntrys
@ -403,7 +408,7 @@ class uiScheduler extends uiCalendar
$arr[$key]['pos'] = $this->_datetime2timestamp($val['start']);
$arr[$key]['span'] = date('H', $this->_datetime2timestamp($val['end'])) - date('H', $this->_datetime2timestamp($val['start'])) +1;
}
#print_r($arr);
//print_r($arr);
return $arr;
} // fn getDayUsage
@ -434,11 +439,11 @@ class uiScheduler extends uiCalendar
function getScheduleForm()
{
global $ui_fmask;
#print_r($this->availablePlaylists);
//print_r($this->availablePlaylists);
foreach ($this->availablePlaylists as $val) {
$ui_fmask['schedule']['gunid_duration']['options'][$val['gunid'].'|'.$val['duration']] = $val['title'];
}
#print_r($ui_fmask['schedule']);
//print_r($ui_fmask['schedule']);
$form = new HTML_QuickForm('schedule', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$this->Base->_parseArr2Form($form, $ui_fmask['schedule']);
@ -457,7 +462,7 @@ class uiScheduler extends uiCalendar
$renderer =& new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer);
$output = $renderer->toArray();
#print_r($output);
//print_r($output);
return $output;
} // fn getScheduleForm
@ -495,7 +500,7 @@ class uiScheduler extends uiCalendar
function getNowNextClip($distance=0)
{
## just use methods which work without valid authentification
// just use methods which work without valid authentification
$datetime = strftime('%Y-%m-%dT%H:%M:%S');
$xmldatetime = str_replace('-', '', $datetime);
@ -506,7 +511,8 @@ class uiScheduler extends uiCalendar
}
$pl = current($pl);
$offset = strftime('%H:%M:%S', time() - $this->_datetime2timestamp($pl['start']) - 3600 * strftime('%H', 0)); ## subtract difference to UTC
// subtract difference to UTC
$offset = strftime('%H:%M:%S', time() - $this->_datetime2timestamp($pl['start']) - 3600 * strftime('%H', 0));
$clip = $this->Base->gb->displayPlaylistClipAtOffset($this->Base->sessid, $pl['playlistId'], $offset, $distance, $_SESSION['langid'], UI_DEFAULT_LANGID);
@ -535,7 +541,7 @@ class uiScheduler extends uiCalendar
function getNowNextClip4jscom()
{
## just use methods which work without valid authentification
// just use methods which work without valid authentification
if ($curr = $this->getNowNextClip()) {
$next = $this->getNowNextClip(1);
@ -563,7 +569,7 @@ class uiScheduler extends uiCalendar
{
$i = str_replace('T', ' ', $i);
$formatted = $i[0].$i[1].$i[2].$i[3].'-'.$i[4].$i[5].'-'.$i[6].$i[7].strrchr($i, ' ');
#echo "input: $i formatted:".$formatted;
//echo "input: $i formatted:".$formatted;
return $this->_strtotime($formatted);
} // fn _datetime2timestamp
@ -691,15 +697,15 @@ class uiScheduler extends uiCalendar
function uploadPlaylistMethod(&$formdata)
{
#$gunid = $formdata['gunid'];
#$datetime = $this->curr['year'].$this->curr['month'].$this->curr['day'].'T'.$formdata['time'];
//$gunid = $formdata['gunid'];
//$datetime = $this->curr['year'].$this->curr['month'].$this->curr['day'].'T'.$formdata['time'];
$gunid = $formdata['playlist'];
$datetime = $formdata['date']['Y'].sprintf('%02d', $formdata['date']['m']).sprintf('%02d', $formdata['date']['d']).'T'.sprintf('%02d', $formdata['time']['H']).':'.sprintf('%02d', $formdata['time']['i']).':'.sprintf('%02d', $formdata['time']['s']);
#echo "Schedule Gunid: $gunid At: ".$datetime;
//echo "Schedule Gunid: $gunid At: ".$datetime;
$r = $this->spc->UploadPlaylistMethod($this->Base->sessid, $gunid, $datetime);
#print_r($r);
//print_r($r);
if ($this->_isError($r)) {
return FALSE;
}
@ -711,9 +717,9 @@ class uiScheduler extends uiCalendar
function removeFromScheduleMethod($id)
{
#echo "Unschedule Gunid: $gunid";
//echo "Unschedule Gunid: $gunid";
$r = $this->spc->removeFromScheduleMethod($this->Base->sessid, $id);
#print_r($r);
//print_r($r);
if ($this->_isError($r)) {
return FALSE;
}
@ -725,7 +731,7 @@ class uiScheduler extends uiCalendar
function displayScheduleMethod($from, $to)
{
#echo $from.$to;
//echo $from.$to;
$r = $this->spc->displayScheduleMethod($this->Base->sessid, $from, $to);
if ($this->_isError($r)) {
return FALSE;

View file

@ -1,33 +1,4 @@
<?php
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the Campcaster project.
http://campcaster.campware.org/
To report bugs, send an e-mail to bugs@campware.org
Campcaster is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Campcaster is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Campcaster; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author$
Version : $Revision$
Location : $URL$
------------------------------------------------------------------------------*/
/* ================================================================= includes */
#require_once 'DB.php';
#require_once "XML/RPC.php";
@ -45,6 +16,11 @@
* <li>r</li> array of result element names (not used there at present)
* <li>e</li> array of error codes/messages (not used there at present)
* </ul>
*
* @package Campcaster
* @subpackage htmlUI
* @author $Author$
* @version $Revision$
*/
$mdefs = array(
"listMethods" => array('m'=>"system.listMethods", 'p'=>NULL, 't'=>NULL),
@ -218,15 +194,19 @@ class SchedulerPhpClient{
* XMLRPC debug flag
*/
var $debug = 0;
/**
* Constructor - pelase DON'T CALL IT, use factory method instead
* Constructor - please DON'T CALL IT, use factory method instead
*
* @param dbc object, database object reference
* @param mdefs array, hash array with methods description
* @param config array, hash array with configuration
* @param debug int, XMLRPC debug flag
* @param verbose boolean, verbosity flag
* @return this
* @param DB $dbc
* @param array $mdefs
* hash array with methods description
* @param array $config
* hash array with configuration
* @param int $debug
* XMLRPC debug flag
* @param boolean $verbose
* verbosity flag
*/
function SchedulerPhpClient(
&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE)
@ -237,15 +217,18 @@ class SchedulerPhpClient{
$this->debug = $debug;
$this->verbose = $verbose;
$confPrefix = "scheduler";
# $confPrefix = "storage";
//$confPrefix = "storage";
$serverPath =
"http://{$config["{$confPrefix}UrlHost"]}:{$config["{$confPrefix}UrlPort"]}".
"{$config["{$confPrefix}UrlPath"]}/{$config["{$confPrefix}XMLRPC"]}";
#$serverPath = "http://localhost:80/livesupportStorageServerCVS/xmlrpc/xrLocStor.php";
if($this->verbose) echo "serverPath: $serverPath\n";
//$serverPath = "http://localhost:80/campcasterStorageServerCVS/xmlrpc/xrLocStor.php";
if ($this->verbose) {
echo "serverPath: $serverPath\n";
}
$url = parse_url($serverPath);
$this->client = new XML_RPC_Client($url['path'], $url['host'], $url['port']);
}
} // constructor
/**
* Factory, create object instance
@ -258,14 +241,19 @@ class SchedulerPhpClient{
* array, call wrapper callMethod(methodname, parameters) and return its
* result.
*
* @param dbc object, database object reference
* @param mdefs array, hash array with methods description
* @param config array, hash array with configuration
* @param debug int, XMLRPC debug flag
* @param verbose boolean, verbosity flag
* @param DB $dbc
* @param array $mdefs
* hash array with methods description
* @param array $config
* hash array with configuration
* @param int $debug
* XMLRPC debug flag
* @param boolean $verbose
* verbosity flag
* @return object, created object instance
*/
function &factory(&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE){
function &factory(&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE)
{
$f = '';
foreach ($mdefs as $fn => $farr) {
$f .=
@ -280,19 +268,25 @@ class SchedulerPhpClient{
"$f\n".
"}\n";
# echo $e;
if(FALSE === eval($e)) return $dbc->raiseError("Eval failed");
if (FALSE === eval($e)) {
return $dbc->raiseError("Eval failed");
}
$spc =& new SchedulerPhpClientCore(
$dbc, $mdefs, $config, $debug, $verbose);
return $spc;
}
} // fn factory
/**
* XMLRPC methods wrapper
* Encode XMLRPC request message, send it, receive and decode response.
*
* @param method string, method name
* @param gettedPars array, returned by func_get_args() in called method
* @return array, PHP hash with response
* @param string $method
* method name
* @param array $gettedPars
* returned by func_get_args() in called method
* @return array
* PHP hash with response
*/
function callMethod($method, $gettedPars)
{
@ -352,9 +346,9 @@ class SchedulerPhpClient{
# echo"<pre>\n"; var_dump($val); exit;
$resp = XML_RPC_decode($res->value());
return $resp;
}
} // fn callMethod
}
} // class SchedulerPhpClient
/* ======================================================== class definitions */
?>

View file

@ -1,6 +1,16 @@
<?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiScratchPad
{
var $Base;
var $items;
var $order;
var $reloadUrl;
function uiScratchPad(&$uiBase)
{
$this->Base =& $uiBase;
@ -9,73 +19,71 @@ class uiScratchPad
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
}
function setReload()
{
$this->Base->redirUrl = $this->reloadUrl;
}
function &get()
{
if (!is_array($this->items))
if (!is_array($this->items)) {
$this->_load();
#print_r($this->items);
}
//print_r($this->items);
return $this->items;
}
function _load()
{
$this->items = array();
$spData = $this->Base->gb->loadPref($this->Base->sessid, UI_SCRATCHPAD_KEY);
if (!PEAR::isError($spData)) {
## ScratchPad found in DB
// ScratchPad found in DB
$arr = explode(' ', $spData);
/*
## Akos old format #####################################
foreach($arr as $val) {
if (preg_match(UI_SCRATCHPAD_REGEX, $val)) {
list ($gunid, $date) = explode(':', $val);
if ($this->Base->gb->_idFromGunid($gunid) != FALSE) {
$res[] = array_merge($this->Base->_getMetaInfo($this->Base->gb->_idFromGunid($gunid)), array('added' => $date));
}
}
}
*/
## new format ##########################################
foreach ($arr as $gunid) {
if (preg_match('/[0-9]{1,20}/', $gunid)) {
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;
}
}
}
}
}
} // fn _load
function save()
{
foreach ($this->items as $val) {
#$str .= $val['gunid'].':'.$val['added'].' '; ## new format ###
$str .= $this->Base->_toInt8($val['gunid']).' '; ## Akos´ old format ###
//$str .= $val['gunid'].':'.$val['added'].' '; ## new format ###
$str .= $this->Base->_toInt8($val['gunid']).' '; ## Akos<EFBFBD> old format ###
}
$this->Base->gb->savePref($this->Base->sessid, UI_SCRATCHPAD_KEY, $str);
}
} // fn save
function addItem($ids)
{
if (!$this->Base->STATIONPREFS[UI_SCRATCHPAD_MAXLENGTH_KEY]) {
if (UI_WARNING) $this->Base->_retMsg('The scratchpad length is not set in system preferences, so it cannot be used.');
if (UI_WARNING) {
$this->Base->_retMsg('The scratchpad length is not set in system preferences, so it cannot be used.');
}
return false;
}
if (!$ids) {
if (UI_WARNING) $this->Base->_retMsg('No item(s) selected.');
if (UI_WARNING) {
$this->Base->_retMsg('No item(s) selected.');
}
return FALSE;
}
if (!is_array($ids))
if (!is_array($ids)) {
$ids = array($ids);
}
$sp = $this->get();
foreach ($ids as $id) {
@ -84,7 +92,9 @@ class uiScratchPad
foreach ($sp as $key=>$val) {
if ($val['id'] == $item['id']) {
unset($sp[$key]);
if (UI_VERBOSE) $this->Base->_retMsg('Entry $1 is already on the scratchpad. It has been moved to the top of the list.', $item['title'], $val['added']);
if (UI_VERBOSE) {
$this->Base->_retMsg('Entry $1 is already on the scratchpad. It has been moved to the top of the list.', $item['title'], $val['added']);
}
} else {
#$this->Base->incAccessCounter($id);
}
@ -93,20 +103,25 @@ class uiScratchPad
}
for ($n=0; $n < $this->Base->STATIONPREFS[UI_SCRATCHPAD_MAXLENGTH_KEY]; $n++) {
if (is_array($sp[$n])) $this->items[$n] = $sp[$n];
if (is_array($sp[$n])) {
$this->items[$n] = $sp[$n];
}
}
ksort($this->items);
}
} // fn addItem
function removeItems($ids)
{
if (!$ids) {
if (UI_WARNING) $this->Base->_retMsg('No item(s) selected.');
if (UI_WARNING) {
$this->Base->_retMsg('No item(s) selected.');
}
return FALSE;
}
if (!is_array($ids))
if (!is_array($ids)) {
$ids = array($ids);
}
foreach ($ids as $id) {
$sp =& $this->get();
@ -119,20 +134,25 @@ class uiScratchPad
}
return TRUE;
}
} // fn removeItems
function reOrder($by)
{
if (count($this->items) == 0)
if (count($this->items) == 0) {
return FALSE;
}
foreach ($this->items as $key=>$val) {
$s[$key] = $val[$by];
}
$curr = $this->order[$by];
$this->order = array();
(is_null($curr) || $curr=='DESC') ? $this->order[$by] = 'ASC' : $this->order[$by] = 'DESC';
if (is_null($curr) || $curr=='DESC') {
$this->order[$by] = 'ASC';
} else {
$this->order[$by] = 'DESC';
}
switch ($this->order[$by]) {
case "ASC": asort($s); break;
case "DESC": arsort($s); break;
@ -146,8 +166,9 @@ class uiScratchPad
function reLoadM()
{
foreach($this->items as $key=>$val)
foreach($this->items as $key=>$val) {
$this->items[$key] = $this->Base->_getMetaInfo($val['id']);
}
}
} // class uiScratchPad
?>

View file

@ -1,4 +1,9 @@
<?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiSearch
{
var $Base;
@ -11,7 +16,7 @@ class uiSearch
{
$this->Base =& $uiBase;
$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->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
if (empty($this->criteria['limit'])) {
@ -19,25 +24,29 @@ class uiSearch
}
}
function setReload()
{
$this->Base->redirUrl = $this->reloadUrl;
}
function getResult()
{
$this->searchDB();
return $this->results;
}
function getCriteria()
{
return $this->criteria;
}
function searchForm($id, $mask2)
{
#print_r($this->criteria['form']);
//print_r($this->criteria['form']);
include dirname(__FILE__).'/formmask/metadata.inc.php';
$form = new HTML_QuickForm('search', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$counter = isset($this->criteria['counter']) ? $this->criteria['counter'] : 1;
@ -99,8 +108,8 @@ class uiSearch
$renderer =& new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer);
$output['dynform'] = $renderer->toArray();
#print_r($output);
#echo '<XMP>output:'; print_r($output); echo "</XMP>\n";
//print_r($output);
//echo '<XMP>output:'; print_r($output); echo "</XMP>\n";
return $output;
}
@ -117,7 +126,8 @@ class uiSearch
$this->criteria['limit'] = $formdata['limit'];
$this->criteria['counter'] = 0;
$this->criteria['form']['operator'] = $formdata['operator']; ## $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']['filetype'] = $formdata['filetype'];
$this->criteria['form']['limit'] = $formdata['limit'];
@ -135,7 +145,7 @@ class uiSearch
}
}
$this->Base->redirUrl = UI_BROWSER.'?act='.$this->prefix;
#$this->searchDB();
//$this->searchDB();
}
@ -146,7 +156,7 @@ class uiSearch
$renderer =& new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer);
$output = $renderer->toArray();
#print_r($output);
//print_r($output);
return $output;
}
@ -218,7 +228,7 @@ class uiSearch
## end test
*/
#print_r($this->results);
//print_r($this->results);
$this->pagination($results);
return TRUE;
@ -231,8 +241,8 @@ class uiSearch
return FALSE;
}
$offset = isset($this->criteria['offset']) ? $this->criteria['offset'] : 0;
$currp = ($offset / $this->criteria['limit']) + 1; # current page
$maxp = ceil($results['cnt'] / $this->criteria['limit']); # maximum page
$currp = ($offset / $this->criteria['limit']) + 1; // current page
$maxp = ceil($results['cnt'] / $this->criteria['limit']); // maximum page
/*
for ($n = 1; $n <= $maxp; $n = $n+$width) {
@ -246,12 +256,12 @@ class uiSearch
$start = $currp;
if ($start + $maxp > 0) {
$deltaLower += $start - $maxp; ## correct lower boarder if page is near end
$deltaLower += $start - $maxp; // correct lower boarder if page is near end
}
for ($n = $start-$deltaLower; $n <= $start+$deltaUpper; $n++) {
if ($n <= 0) {
$deltaUpper++; ## correct upper boarder if page is near zero
$deltaUpper++; // correct upper boarder if page is near zero
} elseif ($n <= $maxp) {
$this->results['pagination'][$n] = $n;
}
@ -279,18 +289,19 @@ class uiSearch
}
$this->criteria['orderby'] = $by;
$this->setReload();
#$this->searchDB();
//$this->searchDB();
}
function clear()
{
#$this->results = NULL;
//$this->results = NULL;
$this->criteria['form'] = NULL;
$this->criteria['counter'] = NULL;
$this->setReload();
}
function setOffset($page)
{
$o =& $this->criteria['offset'];
@ -304,7 +315,8 @@ class uiSearch
$o = $l * ($page-1);
}
$this->setReload();
#$this->searchDB();
}
//$this->searchDB();
}
} // class uiSearch
?>

View file

@ -24,8 +24,10 @@ $Smarty->register_function('niceTime', 'S_niceTime');
/**
* Repeat given string.
*
* @param array $param - must have the key values "str" and "count"
* @return string, repeated string
* @param array $param
* must have the key values "str" and "count"
* @return string
* repeated string
*/
function S_str_repeat($param)
{
@ -37,7 +39,8 @@ function S_str_repeat($param)
/**
* Translate given string.
*
* @param array $in, array of strings to be outputted translated
* @param array $in
* array of strings to be outputted translated
* @return string
*/
function S_tra($in)

View file

@ -1,6 +1,17 @@
<?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiSubjects
{
var $Base;
var $reloadUrl;
var $suRedirUrl;
var $redirUrl;
function uiSubjects(&$uiBase)
{
$this->Base =& $uiBase;
@ -9,31 +20,34 @@ class uiSubjects
$this->redirUrl = UI_BROWSER.'?act=SUBJECTS';
}
function setReload()
{
$this->Base->redirUrl = $this->reloadUrl;
}
function setSuRedir()
{
$this->Base->redirUrl = $this->suRedirUrl;
}
function setRedir()
{
$this->Base->redirUrl = $this->redirUrl;
}
/**
* getAddSubjectForm
*
* create a form to add GreenBox subjects (users/groups)
* Create a form to add GreenBox subjects (users/groups).
*
* @param unknown $type
* @return string (html)
*/
function getAddSubjForm($type)
{
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);
$this->Base->_parseArr2Form($form, $mask[$type]);
@ -44,11 +58,13 @@ class uiSubjects
/**
* addSubj
* Create a new user or group (empty password => create group).
*
* Create new user or group (empty pass => create group)
*
* @param formdata array('login', 'pass')
* @param array $request
* Must have keys -> value:
* login - string
* passwd - string
* @return string
*/
function addSubj($request)
{
@ -82,12 +98,15 @@ class uiSubjects
return TRUE;
}
/**
* removeSubj
* Remove an existing user or group.
*
* Remove existing user or group
*
* @param login string, login name of removed user
* @todo Renamed this function to "removeSubject".
* @param array $request
* must contain the "login" key,
* a string, the login name of removed user
* @return boolean
*/
function removeSubj($request)
{
@ -107,15 +126,17 @@ class uiSubjects
/**
* getChgPasswdForm
* Create a form to change user-passwords in GreenBox.
*
* create a form to change user-passwords in GreenBox
*
* @return string (html)
* @param string $login
* @param boolean $su
* this parameter isnt used
* @return string
* HTML string
*/
function getChgPasswdForm($login, $su = FALSE)
{
include dirname(__FILE__). '/formmask/subjects.inc.php';
include(dirname(__FILE__). '/formmask/subjects.inc.php');
$form = new HTML_QuickForm('chgPasswd', UI_STANDARD_FORM_METHOD, UI_HANDLER);
if ($this->Base->gb->checkPerm($this->Base->userid, 'subjects') === TRUE) {
@ -133,14 +154,12 @@ class uiSubjects
/**
* chgPasswd
* Change password for specified user.
*
* Change password for specified user
*
* @param uid int, local user id
* @param oldpass string, old user password
* @param pass string, new password
* @param pass2 string, retype of new password
* @todo Rename this function to "changePassword".
* @param array $request
* Required array keys: passwd, passwd2, login, oldpasswd
* @return boolean
*/
function chgPasswd($request)
{
@ -179,61 +198,64 @@ class uiSubjects
/**
* getSubjects
* Get all GreenBox subjects (users/groups)
*
* get all GreenBox subjects (users/groups)
*
* @return array subj=>unique id of subject, loggedAs=>corresponding login name
* @todo Rename this function.
* @return array
* subj=>unique id of subject
* loggedAs=>corresponding login name
*/
function getSubjectsWCnt()
{
return $this->Base->gb->getSubjectsWCnt();
}
/**
* getGroupMember
* Get a list of groups that the user belongs to.
*
* get a list of members in given group
*
* @parm $id int local user ID
* @todo Rename this function to "getGroupMembers"
* @param int $id
* local user ID
* @return array
*/
function getGroupMember($id)
{
return $this->Base->gb->listGroup($id);
}
} // fn getGroupMember
/**
* getNonGroupMember
* Get a list of groups that the user does not belong to.
*
* get a list of groups where user is member of
*
* @parm $id int local user ID
* @param int $id
* Local user ID
* @return array
*/
function getNonGroupMember($id)
{
foreach($this->Base->gb->listGroup($id) as $val1)
foreach ($this->Base->gb->listGroup($id) as $val1) {
$members[$val1['id']] = TRUE;
}
$all = $this->Base->gb->getSubjectsWCnt();
foreach($all as $key2=>$val2)
if($members[$val2['id']])
foreach ($all as $key2=>$val2) {
if ($members[$val2['id']]) {
unset($all[$key2]);
}
}
return $all;
}
} // fn getNonGroupMember
/**
* addSubj2Group
* Add a subject to a group.
*
* Add {login} and direct/indirect members to {gname} and to groups,
* where {gname} is [in]direct member
*
* @param login string
* @param gname string
* @param reid string, local id of managed group, just needed for redirect
* @todo Rename this function to "addSubjectToGroup"
* @param array $request
* Required array keys: login, id, gname
* @return boolean
*/
function addSubj2Gr(&$request)
{
@ -244,7 +266,7 @@ class uiSubjects
return FALSE;
}
## loop for multiple action
// loop for multiple action
if (is_array($request['id'])) {
foreach ($request['id'] as $val) {
$req = array('login' => $this->Base->gb->getSubjName($val), 'gname' => $request['gname']);
@ -265,14 +287,13 @@ class uiSubjects
return TRUE;
}
/**
* removeGroupMember
* Remove a subject from a group.
*
* Remove subject from group
*
* @param login string
* @param gname string
* @param reid string, local id of managed group, just needed for redirect
* @param array $request
* Required keys: login, id, gname
* @return boolean
*/
function removeSubjFromGr(&$request)
{
@ -283,7 +304,7 @@ class uiSubjects
return FALSE;
}
## loop for multiple action
// loop for multiple action
if (is_array($request['id'])) {
foreach ($request['id'] as $val) {
$req = array('login' => $this->Base->gb->getSubjName($val), 'gname' => $request['gname']);
@ -305,6 +326,12 @@ class uiSubjects
}
/**
* Return true if the subject is a member of the given group.
*
* @param string $groupname
* @return boolean
*/
function isMemberOf($groupname)
{
if ($gid = $this->Base->gb->getSubjId($groupname)) {
@ -318,8 +345,8 @@ class uiSubjects
}
}
return false;
}
}
} // fn isMemberOf
} // class uiSubjects
?>

View file

@ -1,5 +1,10 @@
<?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiTransfers
{
var $Base;
@ -20,28 +25,31 @@ class uiTransfers
$this->trShowInfo['orderby'] = FALSE;
}
function reOrder($by)
{
$this->trShowInfo['offset'] = NULL;
if ($this->trShowInfo['orderby'] == $by && !$this->trShowInfo['desc'])
if ($this->trShowInfo['orderby'] == $by && !$this->trShowInfo['desc']) {
$this->trShowInfo['desc'] = TRUE;
else
} else {
$this->trShowInfo['desc'] = FALSE;
}
$this->trShowInfo['orderby'] = $by;
$this->setReload();
//echo '<XMP>this:'; print_r($this); echo "</XMP>\n";
}
function getTransfers()
{
$this->buildList();
return $this->rows;
}
function buildList() {
# set items
// set items
$transfers = $this->Base->gb->getHubInitiatedTransfers();
foreach ($transfers as $transfer) {
$token = $transfer['trtok'];
@ -56,6 +64,7 @@ class uiTransfers
//echo '<XMP>this'; print_r($this); echo "</XMP>\n";
}
function pagination()
{
if (sizeof($this->allItems) == 0) {
@ -70,11 +79,16 @@ class uiTransfers
$deltaUpper = UI_BROWSERESULTS_DELTA;
$start = $currp;
if ($start+$delta-$maxp > 0) $deltaLower += $start+$delta-$maxp; ## correct lower boarder if page is near end
if ($start+$delta-$maxp > 0) {
$deltaLower += $start+$delta-$maxp; ## correct lower boarder if page is near end
}
for ($n = $start-$deltaLower; $n <= $start+$deltaUpper; $n++) {
if ($n <= 0) $deltaUpper++; ## correct upper boarder if page is near zero
elseif ($n <= $maxp) $this->rows['pagination'][$n] = $n;
if ($n <= 0) {
$deltaUpper++; ## correct upper boarder if page is near zero
} elseif ($n <= $maxp) {
$this->rows['pagination'][$n] = $n;
}
}
$this->rows['pagination'][1] ? NULL : $this->rows['pagination'][1] = '|<<';
@ -82,16 +96,18 @@ class uiTransfers
$this->rows['next'] = $this->rows['cnt'] > $this->trShowInfo['offset'] + $this->trShowInfo['limit'] ? TRUE : FALSE;
$this->rows['prev'] = $this->trShowInfo['offset'] > 0 ? TRUE : FALSE;
ksort($this->rows['pagination']);
}
} // fn pagination
function setReload()
{
$this->Base->redirUrl = $this->reloadUrl;
}
function setOffset($page)
{
#echo '<XMP>page:'; print_r($page); echo "</XMP>\n";
//echo '<XMP>page:'; print_r($page); echo "</XMP>\n";
$o =& $this->trShowInfo['offset'];
$l =& $this->trShowInfo['limit'];
@ -105,10 +121,13 @@ class uiTransfers
$this->setReload();
}
function cmp($a, $b)
{
#echo '<XMP>cmp:'; echo($a[$this->trShowInfo['orderby']].' - '.$b[$this->trShowInfo['orderby']]); echo "</XMP>\n";
if ($a[$this->trShowInfo['orderby']] == $b[$this->trShowInfo['orderby']]) return 0;
//echo '<XMP>cmp:'; echo($a[$this->trShowInfo['orderby']].' - '.$b[$this->trShowInfo['orderby']]); echo "</XMP>\n";
if ($a[$this->trShowInfo['orderby']] == $b[$this->trShowInfo['orderby']]) {
return 0;
}
if ($a[$this->trShowInfo['orderby']] < $b[$this->trShowInfo['orderby']]) {
return $this->trShowInfo['desc'] ? 1 : -1;
} else {
@ -116,22 +135,24 @@ class uiTransfers
}
}
function showItems()
{
# array sort
// array sort
if (is_array($this->allItems) && $this->trShowInfo['orderby']!==FALSE) {
usort($this->allItems,array($this,'cmp'));
}
# pagination
// pagination
for ($i=$this->trShowInfo['offset'];$i<$this->trShowInfo['offset']+$this->trShowInfo['limit'];$i++) {
if (!is_null($this->allItems[$i])) {
$this->rows['items'][]=$this->allItems[$i];
}
}
#$this->rows['page'] = $this->trShowInfo['offset'] % $this->trShowInfo['limit'];
//$this->rows['page'] = $this->trShowInfo['offset'] % $this->trShowInfo['limit'];
}
function upload2Hub($id)
{
$gunid = $this->Base->gb->_gunidFromId($id);
@ -151,6 +172,7 @@ class uiTransfers
}
}
function downloadFromHub($id,$type)
{
switch ($type) {
@ -167,6 +189,7 @@ class uiTransfers
}
}
function doTransportAction($trtokens,$action) {
//echo '<XMP>ids:'; print_r($trtokens); echo "</XMP>\n";
if (!is_array($trtokens)) {