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

@ -8,7 +8,7 @@
* Version: 1.0
* Date: March, 2003
* Purpose: Mark the Template begin and end
* Install: Drop into the plugin directory, call
* Install: Drop into the plugin directory, call
* $smarty->load_filter('post','template_marker');
* from application.
* Author: Erik Seifert <shaggy@gmx.at>
@ -16,6 +16,6 @@
*/
function smarty_postfilter_template_marker($compiled, &$smarty)
{
return '<!-- BEGIN : ' . $smarty->_current_file . ' -->' . $compiled . '<!-- END : ' . $smarty->_current_file . ' -->';
return '<!-- BEGIN : ' . $smarty->_current_file . ' -->' . $compiled . '<!-- END : ' . $smarty->_current_file . ' -->';
}
?>
?>

View File

@ -48,7 +48,7 @@ $mask = array(
'label' => 'Sun',
'groupit' => true
),
array(
array(
'group' => array('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'),
'label' => 'Weeksdays'
),
@ -57,7 +57,7 @@ $mask = array(
'type' => 'date',
'label' => 'Month/Day',
'options' => array(
'format' => 'md',
'format' => 'md',
'addEmptyOption' => true,
'emptyOptionValue' => '*',
'emptyOptionText' => '*'
@ -68,7 +68,7 @@ $mask = array(
'type' => 'date',
'label' => 'Hour/Minute',
'options' => array(
'format' => 'Hi',
'format' => 'Hi',
)
),
array(
@ -76,7 +76,7 @@ $mask = array(
'type' =>'button',
'label' =>'Cancel',
'attributes'=>array('onclick' => 'location.href="'.UI_BROWSER.'?act=BACKUP"'),
'groupit' => TRUE
'groupit' => TRUE
),
array(
'element' =>'Submit',
@ -90,5 +90,4 @@ $mask = array(
),
)
);
?>
?>

View File

@ -849,4 +849,5 @@ $ui_fmask = array(
'group' => array('cancel', 'submitter')
)
)
);
);
?>

View File

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

View File

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

View File

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

View File

@ -1,3 +1,3 @@
<?php
header('LOCATION: ui_browser.php');
?>
?>

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;
}
@ -34,7 +32,7 @@ function login(&$data)
$id = $gb->getObjId($data['PHP_AUTH_USER'], $gb->storId);
if(PEAR::isError($id)) {
if (PEAR::isError($id)) {
return FALSE;
}
@ -52,7 +50,7 @@ function authenticate()
if (!isset($_SERVER['PHP_AUTH_USER'])) {
authenticate();
} elseif (login($_SERVER) !== TRUE) {
} elseif (login($_SERVER) !== TRUE) {
authenticate();
}
?>
?>

View File

@ -1,63 +1,72 @@
<?php
/**
* _parseArr2Form
* Add elements/rules/groups to an given HTML_QuickForm object
*
* 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')
{
foreach($mask as $k=>$v) {
## add elements ########################
if ($v['type']=='radio') {
foreach($v['options'] as $rk=>$rv) {
if ($v['type'] == 'radio') {
foreach ($v['options'] as $rk => $rv) {
$radio[] =& $form->createElement($v['type'], NULL, NULL, $rv, $rk, $v['attributes']);
}
$form->addGroup($radio, $v['element'], tra($v['label']));
unset($radio);
} elseif ($v['type']=='select') {
} 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']]);
} elseif ($v['type']=='date') {
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']]);
} elseif ($v['type']=='checkbox' || $v['type']=='static') {
if (!$v['groupit']) {
$form->addElement($elem[$v['element']]);
}
} 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']),
($v[type]=='text' || $v['type']=='file' || $v['type']=='password') ? array_merge(array('size'=>UI_INPUT_STANDARD_SIZE, 'maxlength'=>UI_INPUT_STANDARD_MAXLENGTH), $v['attributes']) :
($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];
@ -78,7 +87,7 @@ function parseArr2Form(&$form, $mask, $side='client')
}
}
}
$form->validate();
}
@ -101,19 +110,19 @@ function addLanguageFormArr()
'type' => 'text',
'label' => 'English name',
'required' => TRUE
),
),
array(
'element' => 'NativeName',
'type' => 'text',
'label' => 'Native Name',
'required' => TRUE
),
),
array(
'element' => 'Submit',
'type' => 'submit',
'label' => 'Submit',
'groupit' => TRUE
),
),
array(
'element' => 'Cancel',
'type' => 'button',

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

@ -28,9 +28,9 @@ if (window.attachEvent) window.attachEvent("onload", sfHover);
<ul>
<li><a href="{$UI_BROWSER}?id={$START.id}&act=BROWSE">##Browse##</a></li>
<li><a href="{$UI_BROWSER}?id={$START.id}&act=SEARCH">##Search##</a></li>
<li><a href="{$UI_BROWSER}?id={$START.id}&popup[]=HUBBROWSE.getResults">##Hub Browse##</a></li>
<li><a href="{$UI_BROWSER}?id={$START.id}&act=HUBSEARCH">##Hub Search##</a></li>
<li><a href="{$UI_BROWSER}?id={$START.id}&act=TRANSFERS">##Transfers##</a></li>
<li><a href="{$UI_BROWSER}?id={$START.id}&popup[]=HUBBROWSE.getResults">##Hub Browse##</a></li>
<li><a href="{$UI_BROWSER}?id={$START.id}&act=HUBSEARCH">##Hub Search##</a></li>
<li><a href="{$UI_BROWSER}?id={$START.id}&act=TRANSFERS">##Transfers##</a></li>
</ul>
</li>
<li class="nav-main"><a>##Playlists##</a>
@ -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}
@ -92,5 +92,5 @@ if (window.attachEvent) window.attachEvent("onload", sfHover);
</ul>
{/if}
{include file='userinfo.tpl'}
{include file='userinfo.tpl'}
</div>

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,10 +91,10 @@ 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;
adding it to a playlist and removing it from the ScratchPad. &nbsp;
</P>
<H3>ScratchPad</H3>
<P>The ScratchPad provides you with a list of all the files (both
@ -102,7 +102,7 @@ DIV.blockquote
serves as both a &quot;history&quot; as well as a &quot;clipboard&quot;
for working with files between windows. You can listen to a sound
file from the ScratchPad by right-clicking 'Listen', which will send
the sound file to you for playback. &nbsp;
the sound file to you for playback. &nbsp;
</P>
<H3>Playlists and ScratchPad</H3>
<P>Playlists appear in the ScratchPad differently than sound files.
@ -110,10 +110,10 @@ DIV.blockquote
You can 'close' a playlist directly from the ScratchPad (see the
Playlist section for more on opened/closed playlists). A playlist
that is opened by somebody else in marked as locked by small icon,
and this which isn't opened will appear in normal text.
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
@ -123,11 +123,11 @@ DIV.blockquote
<P>You can add a file (either a sound file or a playlist file) from
the ScratchPad to an playlist you opened before by right-clicking it
in the ScratchPad and selecting &quot;Add to playlist&quot;. This
will add it to the end of the playlist. &nbsp;
will add it to the end of the playlist. &nbsp;
</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>
@ -137,7 +137,7 @@ DIV.blockquote
line in the Playlist window and selecting &quot;Change Transition&quot;
for a single transition, or by using the checkboxes in combination
with the &quot;Change fades&rdquo; button. In this popup window, you
can set the length of the transition or fade in/out. &nbsp;
can set the length of the transition or fade in/out. &nbsp;
</P>
<H3>Opening and closing a playlist</H3>
<P>Playlists can have 'opened' status. While a playlist is 'opened',
@ -148,7 +148,7 @@ DIV.blockquote
edited. Playlists can be opened for editing by right-clicking &quot;Edit&quot;
in the ScratchPad menu. This will take you to the playlist editor.
Just after a playlist have closed (and is on the ScratchPad), it
will appear in a list of playlists available for scheduling.
will appear in a list of playlists available for scheduling.
</P>
<H2>Schedule</H2>
<P>Once you've created a playlist, schedule it for playback using
@ -160,24 +160,24 @@ DIV.blockquote
playlist to the schedule by right-clicking and choosing &quot;Insert
playlist here&quot;. A popup window will then appear allowing you to
select the exact start time for your playlist, as well as a
pull-down menu listing available closed playlists. &nbsp;
pull-down menu listing available closed playlists. &nbsp;
</P>
<H3>Removing a playlist from the schedule</H3>
<P>You can remove a playlist from the schedule by right clicking on
its time [soon to be its title] and choosing &quot;Remove Playlist&quot;.
This does not delete the playlist from the database, however. It
will remain in the system.
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.
&quot;Troubleshooting&quot; section if you cannot upload files.
</P>
<H3>Describing your file using metadata</H3>
<P>The second step allows you to edit the information used to
@ -190,13 +190,13 @@ DIV.blockquote
the location the report takes place in. Good metadata will help you
and other colleagues to later find and use the material you upload.
It's in your best interest to be as thorough as possible in
inputting this metadata.
inputting this metadata.
</P>
<H2>Browse and Search</H2>
<P>The browse and search functions are designed to be both easy to
use and powerful, helping you to search not only file titles but
also other metadata. Both browse and search let you search for both
sound files as well as playlists.
sound files as well as playlists.
</P>
<P>Search works more or less like a regular search engine. You can
type in a word to be searched, and the results will appear below the
@ -210,42 +210,42 @@ DIV.blockquote
Under that category, you can choose one of the options that appears
in that category, which refines the number of files displayed. The
second and third columns work in the same ways, and let you continue
to refine your browsing.
to refine your browsing.
</P>
<H3>Using multiple search terms</H3>
<P>Let's say you want to finding all files created by &quot;;John
Doe&quot;; in the year 2005. Do the following:
Doe&quot;; in the year 2005. Do the following:
</P>
<UL>
<LI><P STYLE="margin-bottom: 0in">Select first the field to search
and input its value. In this case it would be to pull down the
&quot;;Creator&quot;; field and type in &quot;;John Doe&quot;; in
the window.
the window.
</P>
<LI><P STYLE="margin-bottom: 0in">Then press the &quot;;Add One
Row&quot;; button and an additional search row appears. Select the
&quot;;Year&quot;; field and type in 2005 in the window.
&quot;;Year&quot;; field and type in 2005 in the window.
</P>
<LI><P>Press &quot;;Submit&quot;; and your results - if any - will
appear below.
appear below.
</P>
</UL>
<H3>Working with the files you find</H3>
<P>You can add the files you find - in both browse and search -
either to your ScratchPad or directly to a new playlist.
Right-clicking on a file in the results window gives you a number of
options, such as:
options, such as:
</P>
<UL>
<LI><P STYLE="margin-bottom: 0in">Add to ScratchPad
<LI><P STYLE="margin-bottom: 0in">Add to ScratchPad
</P>
<LI><P STYLE="margin-bottom: 0in">Listen
<LI><P STYLE="margin-bottom: 0in">Listen
</P>
<LI><P STYLE="margin-bottom: 0in">New playlist using file
<LI><P STYLE="margin-bottom: 0in">New playlist using file
</P>
<LI><P STYLE="margin-bottom: 0in">Edit
<LI><P STYLE="margin-bottom: 0in">Edit
</P>
<LI><P>Delete
<LI><P>Delete
</P>
</UL>
<H2>System Preferences</H2>
@ -254,40 +254,40 @@ DIV.blockquote
Preferences you can:</P>
<UL>
<LI><P STYLE="margin-bottom: 0in">Add your station's logo and
frequency
frequency
</P>
<LI><P STYLE="margin-bottom: 0in">Set the number of items the
ScratchPad displays</P>
<LI><P STYLE="margin-bottom: 0in">Set the maximum file size that
can be uploaded to the system
can be uploaded to the system
</P>
<LI><P>Administer users and groups for the system, including
assigning their access privileges
assigning their access privileges
</P>
</UL>
<H2>Troubleshooting</H2>
<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
manual</A> chapter 4.12.
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'}
<H2>Credits</H2>
<H3>Localization</H3>
<P>The translation to <i>##_Native language name##</i> was done by <i>##_Name of translator##</i>.
</P>
</P>
{/if}
</div>
</div>
</div>

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)
{
@ -366,10 +374,11 @@ class uiBase
/**
* Call getid3 library to analyze media file and show some results
* Call getid3 library to analyze media file and show some results
*
* @param int $id local ID of file
* @param string $format
* @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,13 +1,19 @@
<?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiBrowser extends uiBase {
var $alertMsg;
// --- class constructor ---
/**
* Initialize a new Browser Class.
* Call uiBase constructor.
* Initialize a new Browser Class.
* Call uiBase constructor.
*
* @param $config array, configurartion data
* @param array $config
* configurartion data
*/
function uiBrowser(&$config)
{
@ -16,11 +22,13 @@ class uiBrowser extends uiBase {
/**
* Perform a frontend action.
* Map to a function called action_<actionName>.inc.php
* 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 )
{
@ -37,9 +45,9 @@ class uiBrowser extends uiBase {
// --- error handling ---
/**
* Extracts the error message from the session var.
* Extracts the error message from the session var.
*
* @return string
* @return string
*/
function getAlertMsg()
{
@ -54,10 +62,11 @@ class uiBrowser extends uiBase {
// --- template feed ---
/**
* Create a login-form.
* Create a login-form.
*
* @param array $mask - an array of all webforms in the system
* @return array
* @param array $mask
* an array of all webforms in the system
* @return array
*/
function login($mask)
{
@ -73,9 +82,10 @@ class uiBrowser extends uiBase {
/**
* Get info about logged in user.
* 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)
{
@ -122,10 +134,10 @@ class uiBrowser extends uiBase {
/**
* Create a form for file-upload.
* Create a form for file-upload.
*
* @param array $params
* @return array
* @param array $params
* @return array
*/
function fileForm($parms)
{
@ -149,11 +161,12 @@ class uiBrowser extends uiBase {
/**
* Create a form to add a Webstream.
* 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)
{
@ -195,11 +208,11 @@ class uiBrowser extends uiBase {
/**
* Get permissions for local object ID.
* Get permissions for local object ID.
*
* @param $id int local ID (file/folder)
*
* @return array
* @param int $id
* local ID (file/folder)
* @return array
*/
function permissions($id)
{
@ -214,11 +227,12 @@ class uiBrowser extends uiBase {
/**
* Call access method and show access path.
* Example only - not really useable.
* TODO: resource should be released by release method call
* Call access method and show access path.
* 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)
{
@ -232,12 +246,13 @@ class uiBrowser extends uiBase {
/**
* Get file's metadata as XML
* Get file's metadata as XML
*
* Note: this does not work right with multiple languages
* Note: this does not work right with multiple languages
*
* @param id int, local id of stored file
* @return array
* @param id int
* local id of stored file
* @return array
*/
function getMdata($id)
{
@ -287,10 +302,11 @@ class uiBrowser extends uiBase {
/**
* Create a form to edit Metadata.
* Create a form to edit Metadata.
*
* @param array $parms
* @return string (html)
* @param array $parms
* @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
@ -359,10 +377,11 @@ class uiBrowser extends uiBase {
/**
* Test if URL seems to be valid
* Test if URL seems to be valid
*
* @param url string, full URL to test
* @return array()
* @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;
@ -86,7 +91,7 @@ class uiCalendar
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'));
while ($Day = $Week->fetch()) {
$corrMonth = $Day->thisMonth()<=12 ? sprintf('%02d', $Day->thisMonth()) : '01'; ## due to bug in
@ -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,9 +143,9 @@ 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 = new Calendar_Hour($this->curr['year'], $this->curr['month'], $this->curr['day'], $this->curr['hour']);
$Hour->build();
while ($Min = $Hour->fetch()) {
$this->Hour[] = array(

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
@ -169,4 +171,4 @@ require_once 'HTML/QuickForm.php';
#PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'errCallBack');
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
#PEAR::setErrorHandling(PEAR_ERROR_PRINT);
?>
?>

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
@ -173,4 +174,4 @@ require_once 'HTML/QuickForm.php';
#PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'errCallBack');
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
#PEAR::setErrorHandling(PEAR_ERROR_PRINT);
?>
?>

View File

@ -1,141 +1,146 @@
<?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiExchange
{
var $Base;
var $file;
var $folder;
function uiExchange(&$uiBase)
{
$this->Base =& $uiBase;
$this->file =& $_SESSION['EXCHANGE']['file'];
$this->folder =& $_SESSION['EXCHANGE']['folder'];
$this->Base =& $uiBase;
$this->file =& $_SESSION['EXCHANGE']['file'];
$this->folder =& $_SESSION['EXCHANGE']['folder'];
if (empty($this->folder)) {
$this->folder = '/tmp';
$this->folder = '/tmp';
}
}
// GB wrapper methods
function getBackupToken()
{
$token = $this->Base->gb->loadPref($this->Base->sessid, UI_BACKUPTOKEN_KEY);
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;
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;
}
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 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']);
readfile($check['tmpfile']);
}
function createBackupClose()
{
$token = $this->getBackupToken();
$token = $this->getBackupToken();
if ($token === false) {
$this->Base->_retMsg('Token not available');
return false;
}
$status = $this->Base->gb->createBackupClose($token);
return false;
}
$status = $this->Base->gb->createBackupClose($token);
if (PEAR::isError($status)) {
$this->Base->_retMsg('Error closing backup: $1', $status->getMessage());
return false;
return false;
}
if ($status === true) {
$this->Base->gb->delPref($this->Base->sessid, UI_BACKUPTOKEN_KEY);
$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();
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)) {
$this->folder = $target;
{
if (is_dir($target)) {
$this->folder = $target;
} else {
$pathinfo = pathinfo($target);
$this->folder = $pathinfo['dirname'];
$this->file = $pathinfo['basename'];
}
$this->folder = $pathinfo['dirname'];
$this->file = $pathinfo['basename'];
}
$this->completeTarget();
$target = $this->folder.'/'.$this->file;
if ($this->checkTarget() !== true) {
$this->Base->_retMsg('$1: open: permission denied', $target);
$this->Base->_retMsg('$1: open: permission denied', $target);
return false;
}
$check = $this->createBackupCheck();
if ($check['status'] === 'success') {
if (@copy($check['tmpfile'], $target)) {
@chmod($target,0666);
$this->Base->_retMsg('Copy backup to $1 successfull', $target);
return true;
return true;
}
$this->Base->_retMsg('Unable to copy backup from $1 to $2', $check['tmpfile'], $target);
return false;
@ -143,175 +148,170 @@ class uiExchange
$this->Base->_retMsg('Backup status is $1, not ready', $check['status']);
return false;
}
// Restore methods
function getRestoreToken()
{
$token = $this->Base->gb->loadPref($this->Base->sessid, UI_RESTORETOKEN_KEY);
if (PEAR::isError($token)) {
return false;
return false;
}
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;
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;
}
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 false;
}
return $res;
}
function backupRestoreClose()
{
$token = $this->getRestoreToken();
$token = $this->getRestoreToken();
if ($token === false) {
$this->Base->_retMsg('Backup restore token is not available');
return false;
}
$status = $this->Base->gb->backupRestoreClose($token);
return false;
}
$status = $this->Base->gb->backupRestoreClose($token);
if (PEAR::isError($status)) {
$this->Base->_retMsg('Error closing restore backup: $1', $status->getMessage());
return false;
return false;
}
if ($status === true) {
$this->Base->gb->delPref($this->Base->sessid, UI_RESTORETOKEN_KEY);
$this->Base->gb->delPref($this->Base->sessid, UI_RESTORETOKEN_KEY);
}
return $status;
}
// file browser methods
function setFolder($subfolder)
{
$this->file = false;
$newfolder = realpath($this->folder.'/'.$subfolder);
if (!is_dir($newfolder)) {
# F5 pressed
return false;
return false;
}
if (!is_executable($newfolder)) {
$this->errorMsg = tra('$1: cd: permission denied', $newfolder);
return false;
return false;
}
$this->folder = $newfolder;
$this->folder = $newfolder;
}
function setFile($file)
{
if (is_writable($this->folder.'/'.$file)) {
$this->file = $file;
return true;
}
$this->file = false;
$this->errorMsg = tra('$1: open: permission denied', $file);
return false;
return false;
}
function getPath()
{
$path = $this->folder.'/'.$this->file;
if (is_dir($this->folder)) {
return str_replace('//', '/', $path);
return str_replace('//', '/', $path);
}
return false;
return false;
}
function checkTarget()
{
if (!is_writable($this->folder.'/'.$this->file) && !is_writable($this->folder)) {
return false;
}
return true;
return false;
}
return true;
}
function completeTarget()
{
if (!$this->file) {
$this->file = 'ls-backup_'.date('Y-m-d');
}
$this->file = 'ls-backup_'.date('Y-m-d');
}
}
function listFolder()
{
if (!is_readable($this->folder)) {
if (!is_readable($this->folder)) {
$this->errorMsg = tra('$1: ls: permission denied', $this->folder);
return array('subdirs' => array('..' => array()), 'files' => array());
return array('subdirs' => array('..' => array()), 'files' => array());
}
$d = dir($this->folder);
while (false !== ($entry = $d->read())) {
$d = dir($this->folder);
while (false !== ($entry = $d->read())) {
$loc = $this->folder.'/'.$entry;
if (is_dir($loc)) {
$dirs[$entry] = $this->_getFileProperty($loc);
$dirs[$entry] = $this->_getFileProperty($loc);
} else {
$files[$entry] = $this->_getFileProperty($loc);
}
}
$files[$entry] = $this->_getFileProperty($loc);
}
}
@ksort($dirs);
@ksort($files);
@ksort($files);
return array('subdirs' => $dirs, 'files' => $files);
}
function _getFileProperty($loc)
{
$uarr = posix_getpwuid(fileowner($loc));
$uarr = posix_getpwuid(fileowner($loc));
$user = $uarr['name'];
$grarr = posix_getgrgid(filegroup($loc));
$group = $grarr['name'];
return array(
'r' => is_readable($loc),
'w' => is_writable($loc),
'x' => is_executable($loc),
'x' => is_executable($loc),
'u' => $user,
'g' => $group,
);
'g' => $group,
);
}
}
?>

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
*
* 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
* Login to the storageServer.
* It set sessid to the cookie with name defined in ../conf.php
*/
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
* Logut from storageServer, takes sessid from cookie
*
* @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
*
* 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.');
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;
}
} // 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
*
* 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)
{
@ -225,7 +236,7 @@ class uiHandler extends uiBase {
$r = $this->gb->storeWebstream($folderId, $formdata['title'], NULL, $this->sessid, NULL, $formdata['url']);
if(PEAR::isError($r)) {
if (PEAR::isError($r)) {
$this->_retMsg($r->getMessage());
$this->redirUrl = UI_BROWSER."?act=editWebstream&id=".$id;
return FALSE;
@ -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.');
if (UI_VERBOSE) {
$this->_retMsg('Stream data saved.');
}
return $r;
}
} // fn addWebstream
function editWebstream($formdata, $mask)
@ -257,118 +270,140 @@ 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.');
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'];
foreach ($mask['pages'] as $key=>$val) {
foreach ($mask['pages'][$key] as $k=>$v) {
foreach ($mask['pages'] as $key => $val) {
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;
}
}
if (!count($mData)) return;
if (!count($mData)) {
return;
}
foreach ($mData as $key=>$val) {
foreach ($mData as $key => $val) {
$r = $this->_setMDataValue($id, $key, $val, $curr_langid);
if (PEAR::isError($r)) {
$this->_retMsg('Unable to set "$1" to value "$2".', $key, $val);
}
}
if (UI_VERBOSE) $this->_retMsg('Metadata saved.');
}
if (UI_VERBOSE) {
$this->_retMsg('Metadata saved.');
}
} // fn editMetadata
/**
* newFolder
* Create new folder in the storage
*
* 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;
}
} // fn newFolder
/**
* rename
* Change the name of file or folder
*
* 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());
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
*
* Move file to another folder
* TODO: format of destinantion path should be properly defined
* @todo format of destination path should be properly defined
*
* @param newPath string, destination relative path
* @param id int, destination folder id
* @param string $newPath
* destination relative path
* @param int $id
* destination folder id
*/
function move($newPath, $id)
{
$newPath = urldecode($newPath);
$did = $this->gb->getObjIdFromRelPath($id, $newPath);
$r = $this->gb->moveFile($id, $did, $this->sessid);
if(PEAR::isError($r)){
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)
{
$newPath = urldecode($newPath);
$did = $this->gb->getObjIdFromRelPath($id, $newPath);
$r = $this->gb->copyFile($id, $did, $this->sessid);
if(PEAR::isError($r)){
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') {
@ -393,38 +431,40 @@ class uiHandler extends uiBase {
$r = $this->gb->deleteFile($id, $this->sessid);
}
if(PEAR::isError($r)) {
if (PEAR::isError($r)) {
$this->_retMsg($r->getMessage());
return FALSE;
}
}
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
*
* Call access method and show access path.
* Example only - not really useable.
* 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
*
* 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
*
* 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
*
* 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;
@ -547,7 +595,7 @@ class uiHandler extends uiBase {
$this->_retMsg('Error while saving settings.');
return FALSE;
}
foreach($mask as $key=>$val) {
foreach ($mask as $key => $val) {
if (isset($val['isPref']) && $val['isPref']) {
if (strlen($formdata[$val['element']])) {
if (PEAR::isError($this->gb->saveGroupPref($this->sessid, 'StationPrefs', $val['element'], $formdata[$val['element']])))

View File

@ -1,6 +1,12 @@
<?php
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiHubBrowse extends uiBrowse
{
function uiHubBrowse(&$uiBase)
{
$this->Base =& $uiBase;
@ -10,33 +16,40 @@ 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;
}
return $trtokid;
} // fn searchDB
function getSearchResults($trtokid) {
$this->results = array('page' => $this->criteria['offset']/$this->criteria['limit']);
$results = $this->Base->gb->getSearchResults($trtokid);
if (!is_array($results) || !count($results)) {
return false;
return false;
}
$this->results['cnt'] = $results['cnt'];
foreach ($results['results'] as $rec) {
@ -45,8 +58,9 @@ class uiHubBrowse extends uiBrowse
}
$this->pagination($results);
// echo '<XMP>this->results:'; print_r($this->results); echo "</XMP>\n";
// echo '<XMP>results:'; print_r($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,50 +1,78 @@
<?php
class jscom{
/**
* @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_array($pars)){
foreach($pars as $parname=>$par){
if(!is_null($par)) $this->setPar($parname, $par);
if (!is_null($calls)) {
$this->addCallables($calls);
}
if (is_array($pars)) {
foreach ($pars as $parname=>$par) {
if (!is_null($par)) {
$this->setPar($parname, $par);
}
}
}
}
function noCacheHeader ()
{
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header ("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
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)){
if (in_array($methodName, $this->callables)) {
$res = call_user_func_array($methodName, $args);
}else{
$res = "ERROR: $methodName not callable";
}
if(is_array($res)){
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; ?>";
@ -53,16 +81,16 @@ class jscom{
var co;
try{
co = new ActiveXObject("Msxml2.XMLHTTP");
}catch(err1){
}catch(err1) {
try{
co = new ActiveXObject("Microsoft.XMLHTTP");
}catch(err2) {
co = null;
}
}
if(!co && typeof XMLHttpRequest != "undefined")
if (!co && typeof XMLHttpRequest != "undefined")
co = new XMLHttpRequest();
if(!co){
if (!co) {
alert("Could not create connection object.");
}
return co;
@ -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]); }
if(method == "GET"){
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,27 +122,29 @@ 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"){
if (typeof comObj.callbackOrId == "function") {
callbackOrId(data);
}else if(typeof comObj.callbackOrId == "object"){
} else if (typeof comObj.callbackOrId == "object") {
eval("res="+data);
for(i=0; i<comObj.callbackOrId.length; i++){
for (i = 0; i < comObj.callbackOrId.length; i++) {
setResult(comObj.callbackOrId[i], res[i])
}
}else if(typeof comObj.callbackOrId != "undefined"){
} else if (typeof comObj.callbackOrId != "undefined") {
setResult(comObj.callbackOrId, data)
}else{
} else {
alert('result from server: '+data);
}
}
comObj.send(post_data);
delete comObj;
}
function setResult(id, data){
function setResult(id, data) {
var el = document.getElementById(id) ;
if(el.tagName == 'INPUT'){ el.value = data; }
if (el.tagName == 'INPUT') { el.value = data; }
else{ el.innerHTML = data; }
}
@ -119,18 +153,27 @@ 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) {
switch($parName){
case"method":
case"uri":
function setPar($parName, $value = NULL)
{
switch ($parName) {
case "method":
case "uri":
$this->{$parName} = $value;
break;
}

View File

@ -1,41 +1,62 @@
<?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;
$this->activeId =& $_SESSION[UI_PLAYLIST_SESSNAME]['activeId'];
$this->changed =& $_SESSION[UI_PLAYLIST_SESSNAME]['changed'];
$this->title = $this->Base->_getMDataValue($this->activeId, UI_MDATA_KEY_TITLE);
$this->duration = $this->Base->_getMDataValue($this->activeId, UI_MDATA_KEY_DURATION);
$this->token =& $_SESSION[UI_PLAYLIST_SESSNAME]['token'];
$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';
}
$this->Base =& $uiBase;
$this->activeId =& $_SESSION[UI_PLAYLIST_SESSNAME]['activeId'];
$this->changed =& $_SESSION[UI_PLAYLIST_SESSNAME]['changed'];
$this->title = $this->Base->_getMDataValue($this->activeId, UI_MDATA_KEY_TITLE);
$this->duration = $this->Base->_getMDataValue($this->activeId, UI_MDATA_KEY_DURATION);
$this->token =& $_SESSION[UI_PLAYLIST_SESSNAME]['token'];
$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,51 +84,68 @@ 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 (($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));
}
return FALSE;
}
$token = $this->Base->gb->lockPlaylistForEdit($plid, $this->Base->sessid);
$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
# release PL
# 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 (!$this->token) {
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,77 +154,95 @@ 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 (!$this->token) {
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;
}
$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 (is_string($this->Base->gb->loadPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY))) {
if ($setMsg == TRUE) {
$this->Base->_retMsg('Found locked playlist.');
}
return TRUE;
}
return FALSE;
}
} // fn reportLookedPL
function loadLookedFromPref()
{
$this->changed = TRUE;
if(is_string($saved = $this->Base->gb->loadPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY))) {
$this->changed = TRUE;
if (is_string($saved = $this->Base->gb->loadPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY))) {
list ($plid, $token) = explode (':', $saved);
if (!$this->Base->gb->existsPlaylist($plid, $this->Base->sessid)) {
$this->Base->gb->delPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY);
if (!$this->Base->gb->existsPlaylist($plid, $this->Base->sessid)) {
$this->Base->gb->delPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY);
$this->Base->_retMsg('Playlist not found in database.');
$this->Base->redirUrl = UI_BROWSER.'?popup[]=_2PL.simpleManagement&popup[]=_close';
return FALSE;
return FALSE;
}
$this->activeId = $plid;
$this->token = $token;
$this->token = $token;
$this->Base->redirUrl = UI_BROWSER.'?popup[]=_2PL.simpleManagement&popup[]=_close';
return TRUE;
}
return FALSE;
}
} // fn loadLookedFromPref
function addItem($elemIds, $duration=null)
{
$this->changed = TRUE;
$fadeIn = null;
$fadeOut = null;
$pause = null;
$this->changed = TRUE;
$fadeIn = null;
$fadeOut = null;
$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)) {
@ -193,23 +251,28 @@ class uiPlaylist
if (isset($duration)) {
$length = sprintf('%02d', $duration['H']).':'.sprintf('%02d', $duration['i']).':'.sprintf('%02d', $duration['s']).'.000000';
}
foreach ($elemIds as $elemId) {
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)
{
@ -230,7 +294,7 @@ class uiPlaylist
# activate
# add clip if $id is set
$this->changed = TRUE;
if (is_array($this->activeId)) {
$this->Base->_retMsg('A playlist is already opened.');
return FALSE;
@ -256,26 +320,26 @@ class uiPlaylist
#$this->redirUrl = UI_BRWOSER.'?popup=_2PL.simpleManagement';<br>
return $plid;
}
} // fn create
function getFlat($id)
{
unset($this->flat);
$this->_plwalk($this->getPLArray($id));
if (is_Array($this->flat)) {
reset($this->flat);
$this->flat[key($this->flat)]['firstInList'] = true;
end($this->flat);
$this->flat[key($this->flat)]['lastInList'] = true;
$this->flat[key($this->flat)]['lastInList'] = true;
reset($this->flat);
return $this->flat;
} else {
return array();
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,47 +425,55 @@ 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)
{
$this->changed = TRUE;
$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) {
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,29 +551,30 @@ class uiPlaylist
$renderer =& new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer);
return $renderer->toArray();
}
} // fn changeAllTransitionsForm
function setItemPlaylengthForm($id, $elemId, $mask)
{
if (isset($elemId)) {
if (isset($elemId)) {
$mask['act']['constant'] = 'PL.setItemPlaylength';
$mask['elemId']['constant'] = $elemId;
$mask['elemId']['constant'] = $elemId;
$element = $this->getCurrElement($elemId);
$mask['playlength']['default'] = substr($element['playlength'], 0, 8);
$mask['duration']['constant'] = substr($element['duration'], 0, 8);
$mask['duration']['constant'] = substr($element['duration'], 0, 8);
} else {
$mask['act']['constant'] = 'PL.addItem';
$mask['id']['constant'] = $id;
$mask['playlength']['default'] = substr($this->Base->_getMDataValue($id, UI_MDATA_KEY_DURATION), 0, 8);
$mask['playlength']['default'] = substr($this->Base->_getMDataValue($id, UI_MDATA_KEY_DURATION), 0, 8);
$mask['duration']['constant'] = $mask['playlength']['default'];
}
$form = new HTML_QuickForm('PL_setItemPlaylengthForm', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$this->Base->_parseArr2Form($form, $mask);
$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';
$this->changed = TRUE;
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) {
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)
if ($this->Base->gb->getFileType($id) !== UI_FILETYPE_PLAYLIST) {
return FALSE;
}
if (($userid = $this->Base->gb->playlistIsAvailable($id, $this->Base->sessid)) !== TRUE)
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'];
@ -168,12 +173,12 @@ class uiScheduler extends uiCalendar
$stampTarget = strtotime("-1 day", $stampNow);
}
$this->curr['year'] = strftime("%Y", $stampTarget);
$this->curr['month'] = strftime("%m", $stampTarget);
$this->curr['week'] = strftime("%V", $stampTarget);
$this->curr['day'] = strftime("%d", $stampTarget);
$this->curr['hour'] = strftime("%H", $stampTarget);
$this->curr['dayname'] = strftime("%A", $stampTarget);
$this->curr['year'] = strftime("%Y", $stampTarget);
$this->curr['month'] = strftime("%m", $stampTarget);
$this->curr['week'] = strftime("%V", $stampTarget);
$this->curr['day'] = strftime("%d", $stampTarget);
$this->curr['hour'] = strftime("%H", $stampTarget);
$this->curr['dayname'] = strftime("%A", $stampTarget);
$this->curr['monthname'] = strftime("%B", $stampTarget);
if ($this->curr['year'] === strftime("%Y") && $this->curr['month'] === strftime("%m") && $this->curr['day'] === strftime("%d")) {
@ -181,7 +186,7 @@ class uiScheduler extends uiCalendar
} else {
$this->curr['isToday'] = FALSE;
}
#print_r($this->curr);
//print_r($this->curr);
} // fn set
@ -198,17 +203,17 @@ class uiScheduler extends uiCalendar
{
extract($arr);
$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);
$this->scheduleNext['hour'] = 23;
$this->scheduleNext['minute'] = 59;
$this->scheduleNext['second'] = 59;
$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);
$this->scheduleNext['hour'] = 23;
$this->scheduleNext['minute'] = 59;
$this->scheduleNext['second'] = 59;
if (isset($today)) {
list($year, $month, $day) = explode("-", strftime("%Y-%m-%d"));
@ -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
@ -397,13 +402,13 @@ class uiScheduler extends uiCalendar
return FALSE;
}
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]['creator'] = $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_CREATOR);
$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),
@ -193,7 +169,7 @@ $mdefs = array(
/* ======================================================== class definitions */
class SchedulerPhpClient{
class SchedulerPhpClient {
/**
* Databases object reference
*/
@ -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,37 +217,45 @@ 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
* Factory, create object instance
*
* In fact it doesn't create instance of SchedulerPhpClient, but
* dynamically extend this class with set of methods based on $mdefs array
* (using eval function) and instantiate resulting class
* SchedulerPhpClientCore instead.
* Each new method in this subclass accepts parameters according to $mdefs
* array, call wrapper callMethod(methodname, parameters) and return its
* result.
* In fact it doesn't create instance of SchedulerPhpClient, but
* dynamically extend this class with set of methods based on $mdefs array
* (using eval function) and instantiate resulting class
* SchedulerPhpClientCore instead.
* Each new method in this subclass accepts parameters according to $mdefs
* 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
* @return object, created object instance
* @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){
foreach ($mdefs as $fn => $farr) {
$f .=
' function '.$fn.'(){'."\n".
' $pars = func_get_args();'."\n".
@ -280,25 +268,31 @@ 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.
* 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)
{
$parr = array();
$XML_RPC_val = new XML_RPC_Value;
foreach($this->mdefs[$method]['p'] as $i=>$p){
foreach ($this->mdefs[$method]['p'] as $i => $p) {
$parr[$p] = new XML_RPC_Value;
switch ($this->mdefs[$method]['t'][$i]) { // switch ($parr[$p]->kindOf($gettedPars[$i])) {
/* array type: normal array */
@ -317,7 +311,7 @@ class SchedulerPhpClient{
$XML_RPC_val->addStruct($parr);
$fullmethod = $this->mdefs[$method]['m'];
$msg = new XML_RPC_Message($fullmethod, array($XML_RPC_val));
if($this->verbose){
if ($this->verbose) {
echo "parr:\n";
var_dump($parr);
echo "message:\n";
@ -327,7 +321,7 @@ class SchedulerPhpClient{
if (!$res = $this->client->send($msg)) {
return array('error' => array('code' => -1, 'message' => '##Cannot connect to Scheduler##'));
}
if($res->faultCode() > 0) {
if ($res->faultCode() > 0) {
return array('error' => array('code' => $res->faultCode(), 'message' => $res->faultString())); ## changed by sebastian
/*
tomas<EFBFBD> orig. method
@ -344,7 +338,7 @@ class SchedulerPhpClient{
);
*/
}
if($this->verbose){
if ($this->verbose) {
echo "result:\n";
echo $res->serialize();
}
@ -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) {
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 ###
foreach ($this->items as $val) {
//$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 (!$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.');
}
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);
}
@ -92,21 +102,26 @@ class uiScratchPad
$sp = array_merge(array($item), is_array($sp) ? $sp : NULL);
}
for ($n=0; $n<$this->Base->STATIONPREFS[UI_SCRATCHPAD_MAXLENGTH_KEY]; $n++) {
if (is_array($sp[$n])) $this->items[$n] = $sp[$n];
for ($n=0; $n < $this->Base->STATIONPREFS[UI_SCRATCHPAD_MAXLENGTH_KEY]; $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,21 +134,26 @@ 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';
switch($this->order[$by]) {
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'];
@ -128,14 +138,14 @@ class uiSearch
'op' => $val[1],
'val' => stripslashes($val[2])
);
$this->criteria['form'][$key] = array(0 => $val[0],
1 => $val[1],
2 => stripslashes($val[2])
$this->criteria['form'][$key] = array(0 => $val[0],
1 => $val[1],
2 => stripslashes($val[2])
);
}
}
$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;
}
@ -164,7 +174,7 @@ class uiSearch
$this->criteria['form']['filetype'] = UI_SIMPLESEARCH_FILETYPE;
$this->criteria['form']['limit'] = UI_SIMPLESEARCH_LIMIT;
for ($n = 1; $n<=UI_SIMPLESEARCH_ROWS; $n++) {
for ($n = 1; $n <= UI_SIMPLESEARCH_ROWS; $n++) {
$this->criteria['conditions'][$n] = array('cat' => constant('UI_SIMPLESEARCH_CAT'.$n),
'op' => constant('UI_SIMPLESEARCH_OP'.$n),
'val' => stripslashes($formdata['criterium'])
@ -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

@ -22,10 +22,12 @@ $Smarty->register_function('niceTime', 'S_niceTime');
// --- Smarty Extensions ---
/**
* Repeat given string.
* 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)
@ -58,7 +61,7 @@ function S_getHour($param)
if (!isset($time) || !is_string($time)) {
return 0;
}
list ($h, $m, $s) = explode (':', $time);
list($h, $m, $s) = explode (':', $time);
$curr = mktime($h, $m ,$s);
if ($pause) {
$curr = strtotime(UI_SCHEDULER_PAUSE_PL2PL, $curr);

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)
*
* @return string (html)
* @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)
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)
{
@ -155,7 +174,7 @@ class uiSubjects
} else {
$this->setRedir();
if ($this->Base->login !== $request['login']){
if ($this->Base->login !== $request['login']) {
$this->Base->_retMsg('Access denied.');
return FALSE;
}
@ -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
* @return array
* @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
* @return array
* @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,61 +1,70 @@
<?php
class uiTransfers
/**
* @package Campcaster
* @subpackage htmlUI
* @version $Revision$
*/
class uiTransfers
{
var $Base;
var $allItems;
var $rows;
var $trShowInfo;
var $reloadUrl;
function uiTransfers(&$uiBase)
{
$this->Base =& $uiBase;
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
$this->trShowInfo =& $_SESSION[UI_TRANSFER_SESSNAME]['trShowInfo'];
$this->trShowInfo['limit'] = UI_BROWSE_DEFAULT_LIMIT;
$this->trShowInfo['offset'] = 0;
$this->trShowInfo['desc'] = FALSE;
$this->trShowInfo['orderby'] = FALSE;
$this->Base =& $uiBase;
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
$this->trShowInfo =& $_SESSION[UI_TRANSFER_SESSNAME]['trShowInfo'];
$this->trShowInfo['limit'] = UI_BROWSE_DEFAULT_LIMIT;
$this->trShowInfo['offset'] = 0;
$this->trShowInfo['desc'] = FALSE;
$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";
//echo '<XMP>this:'; print_r($this); echo "</XMP>\n";
}
function getTransfers()
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'];
$data=$this->Base->gb->getTransportInfo($token);
$data = $this->Base->gb->getTransportInfo($token);
if ($data['state']!='finished') {
$this->allItems[]=array_merge($data,array('id' => $token));
$this->allItems[] = array_merge($data,array('id' => $token));
}
}
$this->rows['cnt'] =count($this->allItems);
$this->rows['cnt'] = count($this->allItems);
$this->pagination();
$this->showItems();
//echo '<XMP>this'; print_r($this); echo "</XMP>\n";
//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'];
@ -104,39 +120,44 @@ class uiTransfers
}
$this->setReload();
}
function cmp($a,$b)
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 {
return $this->trShowInfo['desc'] ? -1 : 1;
}
}
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['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);
$type = $this->Base->gb->_getType($gunid);
switch ($type) {
case 'audioClip':
$this->Base->gb->uploadAudioClip2Hub($gunid);
@ -145,12 +166,13 @@ class uiTransfers
$this->Base->gb->uploadPlaylist2Hub($gunid);
break;
default:
// TODO: it is not implemented in gb, and this way maybe impossible
// TODO: it is not implemented in gb, and this way maybe impossible
//$this->Base->gb->uploadFile2Hub($gunid);
return false;
}
}
function downloadFromHub($id,$type)
{
switch ($type) {
@ -161,14 +183,15 @@ class uiTransfers
$this->Base->gb->downloadPlaylistFromHub($id,false);
break;
default:
// TODO: it is not implemented in gb, and this way maybe impossible
// TODO: it is not implemented in gb, and this way maybe impossible
//$this->Base->gb->downloadFileFromHub($gunid);
return false;
}
}
function doTransportAction($trtokens,$action) {
//echo '<XMP>ids:'; print_r($trtokens); echo "</XMP>\n";
//echo '<XMP>ids:'; print_r($trtokens); echo "</XMP>\n";
if (!is_array($trtokens)) {
$trtokens = array ($trtokens);
}