Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
2ef6d230f9
3265 changed files with 71990 additions and 782867 deletions
25
CREDITS
25
CREDITS
|
@ -1,11 +1,32 @@
|
|||
=======
|
||||
CREDITS
|
||||
=======
|
||||
Version 2.0.1
|
||||
-------------
|
||||
Naomi Aro (naomi.aro@sourcefabric.org)
|
||||
Role: Software Developer
|
||||
|
||||
Martin Konecny (martin.konecny@sourcefabric.org)
|
||||
Role: Software Developer
|
||||
|
||||
James Moon (james.moon@sourcefabric.org)
|
||||
Role: Software Developer
|
||||
|
||||
Daniel Franklin (daniel.franklin@sourcefabric.org)
|
||||
Role: Software Developer
|
||||
|
||||
Ofir Gal (ofir.gal@sourcefabric.org)
|
||||
Role: QA
|
||||
|
||||
Daniel James (daniel.james@sourcefabric.org)
|
||||
Role: Documentor & QA
|
||||
|
||||
Paul Baranowski (paul.baranowski@sourcefabric.org)
|
||||
Role: Project Manager
|
||||
|
||||
|
||||
Version 2.0.0
|
||||
-------------
|
||||
Welcome to Yuchen Wang!
|
||||
|
||||
Naomi Aro (naomi.aro@sourcefabric.org)
|
||||
Role: Software Developer
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|||
|
||||
$view = $this->getResource('view');
|
||||
$baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl();
|
||||
$baseDir = dirname($_SERVER['SCRIPT_FILENAME']);
|
||||
|
||||
$view->headLink()->appendStylesheet($baseUrl.'/css/redmond/jquery-ui-1.8.8.custom.css?'.$CC_CONFIG['airtime_version']);
|
||||
$view->headLink()->appendStylesheet($baseUrl.'/css/pro_dropdown_3.css?'.$CC_CONFIG['airtime_version']);
|
||||
|
@ -69,6 +70,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|||
|
||||
$view = $this->getResource('view');
|
||||
$baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl();
|
||||
$baseDir = dirname($_SERVER['SCRIPT_FILENAME']);
|
||||
|
||||
$view->headScript()->appendFile('https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js');
|
||||
$view->headScript()->appendFile('https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js');
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
[production]
|
||||
phpSettings.display_startup_errors = 0
|
||||
phpSettings.display_errors = 0
|
||||
includePaths.library = APPLICATION_PATH "/../library"
|
||||
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
|
||||
bootstrap.class = "Bootstrap"
|
||||
appnamespace = "Application"
|
||||
|
|
|
@ -17,9 +17,7 @@ $CC_CONFIG = array(
|
|||
'soundcloud-client-id' => '2CLCxcSXYzx7QhhPVHN4A',
|
||||
'soundcloud-client-secret' => 'pZ7beWmF06epXLHVUP1ufOg2oEnIt9XhE8l8xt0bBs',
|
||||
|
||||
"rootDir" => __DIR__."/../..",
|
||||
'pearPath' => dirname(__FILE__).'/../../library/pear',
|
||||
'zendPath' => dirname(__FILE__).'/../../library/Zend'
|
||||
"rootDir" => __DIR__."/../.."
|
||||
);
|
||||
|
||||
|
||||
|
@ -50,12 +48,6 @@ $CC_CONFIG['permSequence'] = $CC_CONFIG['permTable'].'_id';
|
|||
$CC_CONFIG['subjSequence'] = $CC_CONFIG['subjTable'].'_id';
|
||||
$CC_CONFIG['smembSequence'] = $CC_CONFIG['smembTable'].'_id';
|
||||
|
||||
// Add libs to the PHP path
|
||||
$old_include_path = get_include_path();
|
||||
set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath']
|
||||
.PATH_SEPARATOR.$CC_CONFIG['zendPath']
|
||||
.PATH_SEPARATOR.$old_include_path);
|
||||
|
||||
class Config {
|
||||
public static function loadConfig($p_path) {
|
||||
global $CC_CONFIG;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
define('AIRTIME_COPYRIGHT_DATE', '2010-2011');
|
||||
define('AIRTIME_REST_VERSION', '1.1');
|
||||
define('AIRTIME_API_VERSION', '1.0');
|
||||
|
||||
// Metadata Keys for files
|
||||
define('MDATA_KEY_FILEPATH', 'filepath');
|
||||
|
|
|
@ -217,7 +217,8 @@ class ApiController extends Zend_Controller_Action
|
|||
"currentShow"=>Application_Model_Show::GetCurrentShow($utcTimeNow),
|
||||
"nextShow"=>Application_Model_Show::GetNextShows($utcTimeNow, $limit, $utcTimeEnd),
|
||||
"timezone"=> date("T"),
|
||||
"timezoneOffset"=> date("Z"));
|
||||
"timezoneOffset"=> date("Z"),
|
||||
"AIRTIME_API_VERSION"=>AIRTIME_API_VERSION); //used by caller to determine if the airtime they are running or widgets in use is out of date.
|
||||
|
||||
//Convert from UTC to localtime for user.
|
||||
Application_Model_Show::ConvertToLocalTimeZone($result["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
|
||||
|
@ -256,7 +257,7 @@ class ApiController extends Zend_Controller_Action
|
|||
|
||||
$result[$dow[$i]] = $shows;
|
||||
}
|
||||
|
||||
$result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; //used by caller to determine if the airtime they are running or widgets in use is out of date.
|
||||
header("Content-type: text/javascript");
|
||||
echo $_GET['callback'].'('.json_encode($result).')';
|
||||
} else {
|
||||
|
@ -406,7 +407,10 @@ class ApiController extends Zend_Controller_Action
|
|||
$tempFileName = basename($tempFilePath);
|
||||
|
||||
$fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
|
||||
Application_Model_StoredFile::copyFileToStor($upload_dir, $fileName, $tempFileName);
|
||||
$result = Application_Model_StoredFile::copyFileToStor($upload_dir, $fileName, $tempFileName);
|
||||
if (isset($result)){
|
||||
die('{"jsonrpc" : "2.0", "error" : {"code": '.$result[code].', "message" : "'.$result[message].'"}}');
|
||||
}
|
||||
}
|
||||
|
||||
public function uploadRecordedAction()
|
||||
|
|
|
@ -37,6 +37,8 @@ class LibraryController extends Zend_Controller_Action
|
|||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
$this->_helper->viewRenderer->setResponseSegment('library');
|
||||
|
||||
$request = $this->getRequest();
|
||||
$baseUrl = $request->getBaseUrl();
|
||||
|
||||
|
@ -56,16 +58,6 @@ class LibraryController extends Zend_Controller_Action
|
|||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']);
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']);
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/TableTools.css?'.$CC_CONFIG['airtime_version']);
|
||||
|
||||
$this->_helper->viewRenderer->setResponseSegment('library');
|
||||
|
||||
$form = new Application_Form_AdvancedSearch();
|
||||
$form->addGroup(1, 1);
|
||||
|
||||
$this->search_sess->next_group = 2;
|
||||
$this->search_sess->next_row[1] = 2;
|
||||
$this->view->form = $form;
|
||||
$this->view->md = $this->search_sess->md;
|
||||
}
|
||||
|
||||
public function contextMenuAction()
|
||||
|
|
|
@ -38,8 +38,10 @@ class PluploadController extends Zend_Controller_Action
|
|||
$upload_dir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
|
||||
$filename = $this->_getParam('name');
|
||||
$tempname = $this->_getParam('tempname');
|
||||
Application_Model_StoredFile::copyFileToStor($upload_dir, $filename, $tempname);
|
||||
|
||||
$result = Application_Model_StoredFile::copyFileToStor($upload_dir, $filename, $tempname);
|
||||
if (isset($result)){
|
||||
die('{"jsonrpc" : "2.0", "error" : {"code": '.$result[code].', "message" : "'.$result[message].'"}}');
|
||||
}
|
||||
die('{"jsonrpc" : "2.0"}');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,20 +198,20 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$showStartLocalDT = Application_Model_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceStart());
|
||||
$showEndLocalDT = Application_Model_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceEnd());
|
||||
|
||||
/*
|
||||
if ($epochNow < $showStartDateHelper->getTimestamp()) {
|
||||
if ($epochNow < $showStartLocalDT->getTimestamp()) {
|
||||
|
||||
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId()) && !$show->isRecorded() && !$show->isRebroadcast()) {
|
||||
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST), $instance->getShowId())
|
||||
&& !$instance->isRecorded()
|
||||
&& !$instance->isRebroadcast()) {
|
||||
|
||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/schedule-show-dialog'.$params,
|
||||
'callback' => 'window["buildScheduleDialog"]'), 'title' => 'Add / Remove Content');
|
||||
$menu["schedule"] = array("name"=> "Add / Remove Content",
|
||||
"url" => "/showbuilder/index/");
|
||||
|
||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/clear-show'.$params,
|
||||
'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Remove All Content');
|
||||
$menu["clear"] = array("name"=> "Remove All Content", "icon" => "delete",
|
||||
"url" => "/schedule/clear-show");
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
if (!$instance->isRecorded()) {
|
||||
|
||||
|
|
|
@ -25,17 +25,36 @@ class ShowbuilderController extends Zend_Controller_Action
|
|||
|
||||
public function builderAction() {
|
||||
|
||||
$this->_helper->viewRenderer->setResponseSegment('builder');
|
||||
|
||||
$request = $this->getRequest();
|
||||
$baseUrl = $request->getBaseUrl();
|
||||
|
||||
$now = time();
|
||||
$from = $request->getParam("from", $now);
|
||||
$to = $request->getParam("to", $now+(24*60*60));
|
||||
|
||||
$start = DateTime::createFromFormat("U", $from, new DateTimeZone("UTC"));
|
||||
$start->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
$end = DateTime::createFromFormat("U", $to, new DateTimeZone("UTC"));
|
||||
$end->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
|
||||
$form = new Application_Form_ShowBuilder();
|
||||
$form->populate(array(
|
||||
'sb_date_start' => $start->format("Y-m-d"),
|
||||
'sb_time_start' => $start->format("H:i"),
|
||||
'sb_date_end' => $end->format("Y-m-d"),
|
||||
'sb_time_end' => $end->format("H:i")
|
||||
));
|
||||
|
||||
$this->view->sb_form = $form;
|
||||
|
||||
$this->view->headScript()->appendScript("var serverTimezoneOffset = ".date("Z")."; //in seconds");
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/timepicker/jquery.ui.timepicker.js','text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/showbuilder/builder.js','text/javascript');
|
||||
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.ui.timepicker.css');
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/showbuilder.css');
|
||||
|
||||
$this->_helper->viewRenderer->setResponseSegment('builder');
|
||||
}
|
||||
|
||||
public function builderFeedAction() {
|
||||
|
@ -46,6 +65,8 @@ class ShowbuilderController extends Zend_Controller_Action
|
|||
$starts_epoch = $request->getParam("start", $current_time);
|
||||
//default ends is 24 hours after starts.
|
||||
$ends_epoch = $request->getParam("end", $current_time + (60*60*24));
|
||||
$show_filter = intval($request->getParam("showFilter", 0));
|
||||
$my_shows = intval($request->getParam("myShows", 0));
|
||||
|
||||
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
|
||||
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
|
||||
|
@ -53,7 +74,8 @@ class ShowbuilderController extends Zend_Controller_Action
|
|||
Logging::log("showbuilder starts {$startsDT->format("Y-m-d H:i:s")}");
|
||||
Logging::log("showbuilder ends {$endsDT->format("Y-m-d H:i:s")}");
|
||||
|
||||
$showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT);
|
||||
$opts = array("myShows" => $my_shows, "showFilter" => $show_filter);
|
||||
$showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts);
|
||||
|
||||
$this->view->schedule = $showBuilder->GetItems();
|
||||
}
|
||||
|
@ -61,21 +83,24 @@ class ShowbuilderController extends Zend_Controller_Action
|
|||
public function scheduleAddAction() {
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
$mediaItems = $request->getParam("mediaIds", null);
|
||||
$scheduledIds = $request->getParam("schedIds", null);
|
||||
|
||||
$json = array();
|
||||
|
||||
try {
|
||||
$scheduler = new Application_Model_Scheduler();
|
||||
$scheduler->scheduleAfter($scheduledIds, $mediaItems);
|
||||
|
||||
$json["message"]="success... maybe";
|
||||
}
|
||||
catch (OutDatedScheduleException $e) {
|
||||
$this->view->error = $e->getMessage();
|
||||
Logging::log($e->getMessage());
|
||||
Logging::log("{$e->getFile()}");
|
||||
Logging::log("{$e->getLine()}");
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$json["message"]=$e->getMessage();
|
||||
$this->view->error = $e->getMessage();
|
||||
Logging::log($e->getMessage());
|
||||
Logging::log("{$e->getFile()}");
|
||||
Logging::log("{$e->getLine()}");
|
||||
}
|
||||
|
||||
$this->view->data = $json;
|
||||
|
@ -84,45 +109,98 @@ class ShowbuilderController extends Zend_Controller_Action
|
|||
public function scheduleRemoveAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$ids = $request->getParam("ids", null);
|
||||
|
||||
$json = array();
|
||||
$items = $request->getParam("items", null);
|
||||
|
||||
try {
|
||||
$scheduler = new Application_Model_Scheduler();
|
||||
$scheduler->removeItems($ids);
|
||||
|
||||
$json["message"]="success... maybe";
|
||||
$scheduler->removeItems($items);
|
||||
}
|
||||
catch (OutDatedScheduleException $e) {
|
||||
$this->view->error = $e->getMessage();
|
||||
Logging::log($e->getMessage());
|
||||
Logging::log("{$e->getFile()}");
|
||||
Logging::log("{$e->getLine()}");
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$json["message"]=$e->getMessage();
|
||||
$this->view->error = $e->getMessage();
|
||||
Logging::log($e->getMessage());
|
||||
Logging::log("{$e->getFile()}");
|
||||
Logging::log("{$e->getLine()}");
|
||||
}
|
||||
|
||||
$this->view->data = $json;
|
||||
}
|
||||
|
||||
public function scheduleMoveAction() {
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
$selectedItem = $request->getParam("selectedItem");
|
||||
$afterItem = $request->getParam("afterItem");
|
||||
|
||||
$json = array();
|
||||
|
||||
try {
|
||||
$scheduler = new Application_Model_Scheduler();
|
||||
$scheduler->moveItem($selectedItem, $afterItem);
|
||||
|
||||
$json["message"]="success... maybe";
|
||||
}
|
||||
catch (OutDatedScheduleException $e) {
|
||||
$this->view->error = $e->getMessage();
|
||||
Logging::log($e->getMessage());
|
||||
Logging::log("{$e->getFile()}");
|
||||
Logging::log("{$e->getLine()}");
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$json["message"]=$e->getMessage();
|
||||
$this->view->error = $e->getMessage();
|
||||
Logging::log($e->getMessage());
|
||||
Logging::log("{$e->getFile()}");
|
||||
Logging::log("{$e->getLine()}");
|
||||
}
|
||||
|
||||
$this->view->data = $json;
|
||||
}
|
||||
|
||||
public function scheduleReorderAction() {
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
$showInstance = $request->getParam("instanceId");
|
||||
}
|
||||
|
||||
/*
|
||||
* make sure any incoming requests for scheduling are ligit.
|
||||
*
|
||||
* @param array $items, an array containing pks of cc_schedule items.
|
||||
*/
|
||||
private function filterSelected($items) {
|
||||
|
||||
$allowed = array();
|
||||
$user = Application_Model_User::GetCurrentUser();
|
||||
$type = $user->getType();
|
||||
|
||||
//item must be within the host's show.
|
||||
if ($type === UTYPE_HOST) {
|
||||
|
||||
$hosted = CcShowHostsQuery::create()
|
||||
->filterByDbHost($user->getId())
|
||||
->find();
|
||||
|
||||
$allowed_shows = array();
|
||||
foreach ($hosted as $host) {
|
||||
$allowed_shows[] = $host->getDbShow();
|
||||
}
|
||||
|
||||
for ($i = 0; $i < count($items); $i++) {
|
||||
|
||||
$instance = $items[$i]["instance"];
|
||||
|
||||
if (in_array($instance, $allowed_shows)) {
|
||||
$allowed[] = $items[$i];
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->shows = $res;
|
||||
}
|
||||
//they can schedule anything.
|
||||
else if ($type === UTYPE_ADMIN || $type === UTYPE_PROGRAM_MANAGER) {
|
||||
$allowed = $items;
|
||||
}
|
||||
|
||||
return $allowed;
|
||||
}
|
||||
}
|
|
@ -4,6 +4,8 @@ class SystemstatusController extends Zend_Controller_Action
|
|||
{
|
||||
public function init()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
$request = $this->getRequest();
|
||||
$baseUrl = $request->getBaseUrl();
|
||||
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Application_Form_AdvancedSearch extends Zend_Form
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
// Add the add button
|
||||
$this->addElement('button', 'search_add_group', array(
|
||||
'ignore' => true,
|
||||
'label' => 'Add',
|
||||
'order' => '-2'
|
||||
));
|
||||
$this->getElement('search_add_group')->removeDecorator('DtDdWrapper');
|
||||
|
||||
// Add the submit button
|
||||
$this->addElement('button', 'search_submit', array(
|
||||
'ignore' => true,
|
||||
'label' => 'Save',
|
||||
'order' => '-1'
|
||||
));
|
||||
$this->getElement('search_submit')->removeDecorator('DtDdWrapper');
|
||||
}
|
||||
|
||||
public function addGroup($group_id, $row_id=null) {
|
||||
|
||||
$this->addSubForm(new Application_Form_AdvancedSearchGroup(), 'group_'.$group_id, $group_id);
|
||||
$this->getSubForm('group_'.$group_id)->removeDecorator('DtDdWrapper');
|
||||
|
||||
if(!is_null($row_id)) {
|
||||
$subGroup = $this->getSubForm('group_'.$group_id);
|
||||
$subGroup->addRow($row_id);
|
||||
}
|
||||
}
|
||||
|
||||
public function preValidation(array $data) {
|
||||
|
||||
function findId($name) {
|
||||
$t = explode("_", $name);
|
||||
return $t[1];
|
||||
}
|
||||
|
||||
function findFields($field) {
|
||||
return strpos($field, 'group') !== false;
|
||||
}
|
||||
|
||||
$groups = array_filter(array_keys($data), 'findFields');
|
||||
|
||||
foreach ($groups as $group) {
|
||||
|
||||
$group_id = findId($group);
|
||||
$this->addGroup($group_id);
|
||||
|
||||
$subGroup = $this->getSubForm($group);
|
||||
|
||||
foreach (array_keys($data[$group]) as $row) {
|
||||
|
||||
$row_id = findId($row);
|
||||
$subGroup->addRow($row_id, $data[$group][$row]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Application_Form_AdvancedSearchGroup extends Zend_Form_SubForm
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
// Add the add button
|
||||
$this->addElement('button', 'search_add_row', array(
|
||||
'ignore' => true,
|
||||
'label' => 'Add',
|
||||
'order' => '-2'
|
||||
));
|
||||
$this->getElement('search_add_row')->removeDecorator('DtDdWrapper');
|
||||
|
||||
// Add the add button
|
||||
$this->addElement('button', 'search_remove_group', array(
|
||||
'ignore' => true,
|
||||
'label' => 'Remove',
|
||||
'order' => '-1'
|
||||
));
|
||||
$this->getElement('search_remove_group')->removeDecorator('DtDdWrapper');
|
||||
}
|
||||
|
||||
public function addRow($row_id, $data=null) {
|
||||
|
||||
$this->addSubForm(new Application_Form_AdvancedSearchRow(), 'row_'.$row_id, $row_id);
|
||||
$row = $this->getSubForm('row_'.$row_id);
|
||||
$row->removeDecorator('DtDdWrapper');
|
||||
|
||||
if(!is_null($data)) {
|
||||
$row->setDefaults($data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Application_Form_AdvancedSearchRow extends Zend_Form_SubForm
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$this->addElement(
|
||||
'select',
|
||||
'metadata',
|
||||
array(
|
||||
'required' => true,
|
||||
'multiOptions' => array(
|
||||
"dc:title" => "Title",
|
||||
"dc:format" => "Format",
|
||||
"dc:creator" => "Artist/Creator",
|
||||
"dc:source" => "Album",
|
||||
"ls:bitrate" => "Bitrate",
|
||||
"ls:samplerate" => "Samplerate",
|
||||
"dcterms:extent" => "Length",
|
||||
"dc:description" => "Comments",
|
||||
"dc:type" => "Genre",
|
||||
"ls:channels" => "channels",
|
||||
"ls:year" => "Year",
|
||||
"ls:track_num" => "track_number",
|
||||
"ls:mood" => "mood",
|
||||
"ls:bpm" => "BPM",
|
||||
"ls:rating" => "rating",
|
||||
"ls:encoded_by" => "encoded_by",
|
||||
"dc:publisher" => "label",
|
||||
"ls:composer" => "Composer",
|
||||
"ls:encoder" => "Encoder",
|
||||
"ls:lyrics" => "lyrics",
|
||||
"ls:orchestra" => "orchestra",
|
||||
"ls:conductor" => "conductor",
|
||||
"ls:lyricist" => "lyricist",
|
||||
"ls:originallyricist" => "original_lyricist",
|
||||
"ls:isrcnumber" => "isrc_number",
|
||||
"dc:language" => "Language",
|
||||
),
|
||||
)
|
||||
);
|
||||
$this->getElement('metadata')->removeDecorator('Label')->removeDecorator('HtmlTag');
|
||||
|
||||
$this->addElement(
|
||||
'select',
|
||||
'match',
|
||||
array(
|
||||
'required' => true,
|
||||
'multiOptions' => array(
|
||||
"0" => "partial",
|
||||
"1" => "=",
|
||||
"2" => "<",
|
||||
"3" => "<=",
|
||||
"4" => ">",
|
||||
"5" => ">=",
|
||||
"6" => "!=",
|
||||
),
|
||||
)
|
||||
);
|
||||
$this->getElement('match')->removeDecorator('Label')->removeDecorator('HtmlTag');
|
||||
|
||||
$this->addElement('text', 'search', array(
|
||||
'required' => true,
|
||||
));
|
||||
$this->getElement('search')->removeDecorator('Label')->removeDecorator('HtmlTag');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ class Application_Form_EditAudioMD extends Zend_Form
|
|||
|
||||
// Add artist field
|
||||
$this->addElement('text', 'artist_name', array(
|
||||
'label' => 'Artist:',
|
||||
'label' => 'Creator:',
|
||||
'class' => 'input_text',
|
||||
'filters' => array('StringTrim'),
|
||||
));
|
||||
|
|
|
@ -71,8 +71,10 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
|||
'Africa' => DateTimeZone::AFRICA,
|
||||
'America' => DateTimeZone::AMERICA,
|
||||
'Antarctica' => DateTimeZone::ANTARCTICA,
|
||||
'Arctic' => DateTimeZone::ARCTIC,
|
||||
'Asia' => DateTimeZone::ASIA,
|
||||
'Atlantic' => DateTimeZone::ATLANTIC,
|
||||
'Australia' => DateTimeZone::AUSTRALIA,
|
||||
'Europe' => DateTimeZone::EUROPE,
|
||||
'Indian' => DateTimeZone::INDIAN,
|
||||
'Pacific' => DateTimeZone::PACIFIC
|
||||
|
|
104
airtime_mvc/application/forms/ShowBuilder.php
Normal file
104
airtime_mvc/application/forms/ShowBuilder.php
Normal file
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
|
||||
class Application_Form_ShowBuilder extends Zend_Form_SubForm
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$user = Application_Model_User::GetCurrentUser();
|
||||
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/showbuilder.phtml'))
|
||||
));
|
||||
|
||||
// Add start date element
|
||||
$startDate = new Zend_Form_Element_Text('sb_date_start');
|
||||
$startDate->class = 'input_text';
|
||||
$startDate->setRequired(true)
|
||||
->setLabel('Date Start:')
|
||||
->setValue(date("Y-m-d"))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
'NotEmpty',
|
||||
array('date', false, array('YYYY-MM-DD'))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$startDate->setAttrib('alt', 'date');
|
||||
$this->addElement($startDate);
|
||||
|
||||
// Add start time element
|
||||
$startTime = new Zend_Form_Element_Text('sb_time_start');
|
||||
$startTime->class = 'input_text';
|
||||
$startTime->setRequired(true)
|
||||
->setValue('00:00')
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
'NotEmpty',
|
||||
array('date', false, array('HH:mm')),
|
||||
array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered'))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$startTime->setAttrib('alt', 'time');
|
||||
$this->addElement($startTime);
|
||||
|
||||
// Add end date element
|
||||
$endDate = new Zend_Form_Element_Text('sb_date_end');
|
||||
$endDate->class = 'input_text';
|
||||
$endDate->setRequired(true)
|
||||
->setLabel('Date End:')
|
||||
->setValue(date("Y-m-d"))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
'NotEmpty',
|
||||
array('date', false, array('YYYY-MM-DD'))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$endDate->setAttrib('alt', 'date');
|
||||
$this->addElement($endDate);
|
||||
|
||||
// Add end time element
|
||||
$endTime = new Zend_Form_Element_Text('sb_time_end');
|
||||
$endTime->class = 'input_text';
|
||||
$endTime->setRequired(true)
|
||||
->setValue('01:00')
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
'NotEmpty',
|
||||
array('date', false, array('HH:mm')),
|
||||
array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered'))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$endTime->setAttrib('alt', 'time');
|
||||
$this->addElement($endTime);
|
||||
|
||||
|
||||
// add a select to choose a show.
|
||||
$showSelect = new Zend_Form_Element_Select("sb_show_filter");
|
||||
$showSelect->setLabel("Filter By Show:");
|
||||
$showSelect->setMultiOptions($this->getShowNames());
|
||||
$showSelect->setValue(null);
|
||||
$showSelect->setDecorators(array('ViewHelper'));
|
||||
$this->addElement($showSelect);
|
||||
|
||||
if ($user->getType() === 'H') {
|
||||
$myShows = new Zend_Form_Element_Checkbox('sb_my_shows');
|
||||
$myShows->setLabel('All My Shows')
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$this->addElement($myShows);
|
||||
}
|
||||
}
|
||||
|
||||
private function getShowNames() {
|
||||
|
||||
$showNames = array("0" => "-------------------------");
|
||||
|
||||
$shows = CcShowQuery::create()
|
||||
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
|
||||
->orderByDbName()
|
||||
->find();
|
||||
|
||||
foreach ($shows as $show) {
|
||||
|
||||
$showNames[$show->getDbId()] = $show->getDbName();
|
||||
}
|
||||
|
||||
return $showNames;
|
||||
}
|
||||
|
||||
}
|
|
@ -39,12 +39,14 @@ class Application_Form_StreamSetting extends Zend_Form
|
|||
}
|
||||
|
||||
# tooltip
|
||||
$description = 'VLC and mplayer have a serious bug when playing an OGG/VORBIS
|
||||
stream that has metadata information enabled (stream metadata is the
|
||||
track title, show name, etc displayed in the audio player): they will
|
||||
disconnect from the stream after every song if this option is enabled.
|
||||
If your listeners do not require support for these audio players,
|
||||
then you should enable this option.';
|
||||
$description = 'This option enables metadata for OGG streams (stream
|
||||
metadata is the track title, artist, and show name that is
|
||||
displayed in an audio player). VLC and mplayer have a
|
||||
serious bug when playing an OGG/VORBIS stream that has
|
||||
metadata information enabled: they will disconnect from the
|
||||
stream after every song. If you are using an OGG stream and
|
||||
your listeners do not require support for these audio
|
||||
players, then feel free to enable this option.';
|
||||
|
||||
$icecast_vorbis_metadata = new Zend_Form_Element_Checkbox('icecast_vorbis_metadata');
|
||||
$icecast_vorbis_metadata->setLabel('Icecast Vorbis Metadata')
|
||||
|
|
|
@ -39,7 +39,7 @@ class Application_Model_Nowplaying
|
|||
//format duration
|
||||
$duration = explode('.', $dbRow['clip_length']);
|
||||
$formatted = self::FormatDuration($duration[0]);
|
||||
$dataTablesRows[] = array($type, $showStarts, $itemStarts, $itemEnds,
|
||||
$dataTablesRows[] = array($type, $itemStarts, $itemStarts, $itemEnds,
|
||||
$formatted, $dbRow['track_title'], $dbRow['artist_name'], $dbRow['album_title'],
|
||||
$dbRow['playlist_name'], $dbRow['show_name'], $status);
|
||||
}
|
||||
|
|
|
@ -768,4 +768,4 @@ class Application_Model_Playlist {
|
|||
} // class Playlist
|
||||
|
||||
class PlaylistNotFoundException extends Exception {}
|
||||
class OutDatedException extends Exception {}
|
||||
class PlaylistOutDatedException extends Exception {}
|
||||
|
|
|
@ -102,7 +102,6 @@ class Application_Model_Preference
|
|||
|
||||
public static function SetHeadTitle($title, $view=null){
|
||||
self::SetValue("station_name", $title);
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
|
||||
// in case this is called from airtime-saas script
|
||||
if($view !== null){
|
||||
|
@ -111,6 +110,11 @@ class Application_Model_Preference
|
|||
$view->headTitle()->exchangeArray(array()); //clear headTitle ArrayObject
|
||||
$view->headTitle(self::GetHeadTitle());
|
||||
}
|
||||
|
||||
$eventType = "update_station_name";
|
||||
$md = array("station_name"=>$title);
|
||||
|
||||
Application_Model_RabbitMq::SendMessageToPypo($eventType, $md);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -153,7 +157,11 @@ class Application_Model_Preference
|
|||
|
||||
public static function SetStreamLabelFormat($type){
|
||||
self::SetValue("stream_label_format", $type);
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
|
||||
$eventType = "update_stream_format";
|
||||
$md = array("stream_format"=>$type);
|
||||
|
||||
Application_Model_RabbitMq::SendMessageToPypo($eventType, $md);
|
||||
}
|
||||
|
||||
public static function GetStreamLabelFormat(){
|
||||
|
|
|
@ -46,7 +46,8 @@ class Application_Model_RabbitMq
|
|||
$conn = new AMQPConnection($CC_CONFIG["rabbitmq"]["host"],
|
||||
$CC_CONFIG["rabbitmq"]["port"],
|
||||
$CC_CONFIG["rabbitmq"]["user"],
|
||||
$CC_CONFIG["rabbitmq"]["password"]);
|
||||
$CC_CONFIG["rabbitmq"]["password"],
|
||||
$CC_CONFIG["rabbitmq"]["vhost"]);
|
||||
$channel = $conn->channel();
|
||||
$channel->access_request($CC_CONFIG["rabbitmq"]["vhost"], false, false, true, true);
|
||||
|
||||
|
@ -68,7 +69,8 @@ class Application_Model_RabbitMq
|
|||
$conn = new AMQPConnection($CC_CONFIG["rabbitmq"]["host"],
|
||||
$CC_CONFIG["rabbitmq"]["port"],
|
||||
$CC_CONFIG["rabbitmq"]["user"],
|
||||
$CC_CONFIG["rabbitmq"]["password"]);
|
||||
$CC_CONFIG["rabbitmq"]["password"],
|
||||
$CC_CONFIG["rabbitmq"]["vhost"]);
|
||||
$channel = $conn->channel();
|
||||
$channel->access_request($CC_CONFIG["rabbitmq"]["vhost"], false, false, true, true);
|
||||
|
||||
|
|
|
@ -303,7 +303,7 @@ class Application_Model_Schedule {
|
|||
* @return array $scheduledItems
|
||||
*
|
||||
*/
|
||||
public static function GetScheduleDetailItems($p_startDateTime, $p_endDateTime)
|
||||
public static function GetScheduleDetailItems($p_startDateTime, $p_endDateTime, $p_shows)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
|
@ -313,7 +313,7 @@ class Application_Model_Schedule {
|
|||
showt.background_color AS show_background_colour, showt.id AS show_id,
|
||||
|
||||
si.starts AS si_starts, si.ends AS si_ends, si.time_filled AS si_time_filled,
|
||||
si.record AS si_record, si.rebroadcast AS si_rebroadcast, si.id AS si_id,
|
||||
si.record AS si_record, si.rebroadcast AS si_rebroadcast, si.id AS si_id, si.last_scheduled AS si_last_scheduled,
|
||||
|
||||
sched.starts AS sched_starts, sched.ends AS sched_ends, sched.id AS sched_id,
|
||||
|
||||
|
@ -328,11 +328,15 @@ class Application_Model_Schedule {
|
|||
|
||||
WHERE si.modified_instance = false AND
|
||||
|
||||
si.starts >= '{$p_startDateTime}' AND si.starts <= '{$p_endDateTime}'
|
||||
si.starts >= '{$p_startDateTime}' AND si.starts < '{$p_endDateTime}'";
|
||||
|
||||
ORDER BY si.starts, sched.starts;";
|
||||
if (count($p_shows) > 0) {
|
||||
$sql .= " AND show_id IN (".implode(",", $p_shows).")";
|
||||
}
|
||||
|
||||
//Logging::log($sql);
|
||||
$sql .= " ORDER BY si.starts, sched.starts;";
|
||||
|
||||
Logging::log($sql);
|
||||
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
return $rows;
|
||||
|
|
|
@ -31,12 +31,17 @@ class Application_Model_Scheduler {
|
|||
if ($type === "audioclip") {
|
||||
$file = CcFilesQuery::create()->findPK($id, $this->con);
|
||||
|
||||
if (is_null($file) || !$file->getDbFileExists()) {
|
||||
throw new Exception("A selected File does not exist!");
|
||||
}
|
||||
else {
|
||||
$data = $this->fileInfo;
|
||||
$data["id"] = $id;
|
||||
$data["cliplength"] = $file->getDbLength();
|
||||
|
||||
$files[] = $data;
|
||||
}
|
||||
}
|
||||
else if ($type === "playlist") {
|
||||
|
||||
$contents = CcPlaylistcontentsQuery::create()
|
||||
|
@ -44,8 +49,15 @@ class Application_Model_Scheduler {
|
|||
->filterByDbPlaylistId($id)
|
||||
->find($this->con);
|
||||
|
||||
if (is_null($contents)) {
|
||||
throw new Exception("A selected Playlist does not exist!");
|
||||
}
|
||||
|
||||
foreach ($contents as $plItem) {
|
||||
|
||||
$file = $plItem->getCcFiles($this->con);
|
||||
if (isset($file) && $file->getDbFileExists()) {
|
||||
|
||||
$data = $this->fileInfo;
|
||||
$data["id"] = $plItem->getDbFileId();
|
||||
$data["cliplength"] = $plItem->getDbCliplength();
|
||||
|
@ -57,6 +69,7 @@ class Application_Model_Scheduler {
|
|||
$files[] = $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
@ -68,7 +81,7 @@ class Application_Model_Scheduler {
|
|||
*
|
||||
* @return DateTime endDT in UTC
|
||||
*/
|
||||
private function findEndTime($p_startDT, $p_duration) {
|
||||
public static function findEndTime($p_startDT, $p_duration) {
|
||||
|
||||
$startEpoch = $p_startDT->format("U.u");
|
||||
$durationSeconds = Application_Model_Playlist::playlistTimeToSeconds($p_duration);
|
||||
|
@ -98,6 +111,8 @@ class Application_Model_Scheduler {
|
|||
|
||||
try {
|
||||
|
||||
$affectedShowInstances = array();
|
||||
|
||||
//dont want to recalculate times for moved items.
|
||||
$excludeIds = array();
|
||||
foreach ($schedFiles as $file) {
|
||||
|
@ -108,34 +123,42 @@ class Application_Model_Scheduler {
|
|||
|
||||
foreach ($scheduleItems as $schedule) {
|
||||
$id = intval($schedule["id"]);
|
||||
$ts = intval($schedule["timestamp"]);
|
||||
|
||||
Logging::log("scheduling after scheduled item: ".$id);
|
||||
Logging::log("in show: ".intval($schedule["instance"]));
|
||||
|
||||
if ($id !== 0) {
|
||||
$schedItem = CcScheduleQuery::create()->findPK($id, $this->con);
|
||||
$instance = $schedItem->getDbInstanceId();
|
||||
|
||||
//user has an old copy of the time line opened.
|
||||
if ($instance !== intval($schedule["instance"])) {
|
||||
Logging::log("items have been since updated");
|
||||
return;
|
||||
$instance = $schedItem->getCcShowInstances($this->con);
|
||||
if (intval($schedule["instance"]) !== $instance->getDbId()) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
}
|
||||
|
||||
$nextStartDT = $schedItem->getDbEnds(null);
|
||||
}
|
||||
//selected empty row to add after
|
||||
else {
|
||||
$showInstance = CcShowInstancesQuery::create()->findPK($schedule["instance"], $this->con);
|
||||
$nextStartDT = $showInstance->getDbStarts(null);
|
||||
$instance = intval($schedule["instance"]);
|
||||
$instance = CcShowInstancesQuery::create()->findPK($schedule["instance"], $this->con);
|
||||
$nextStartDT = $instance->getDbStarts(null);
|
||||
}
|
||||
|
||||
$currTs = intval($instance->getDbLastScheduled("U")) ? : 0;
|
||||
//user has an old copy of the time line opened.
|
||||
if ($ts !== $currTs) {
|
||||
Logging::log("currTs {$currTs}, ts {$ts}");
|
||||
$show = $instance->getCcShow($this->con);
|
||||
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
|
||||
}
|
||||
|
||||
if (!in_array($instance->getDbId(), $affectedShowInstances)) {
|
||||
$affectedShowInstances[] = $instance->getDbId();
|
||||
}
|
||||
|
||||
Logging::log("finding items >= {$nextStartDT->format("Y-m-d H:i:s.u")}");
|
||||
if ($adjustSched === true) {
|
||||
$followingSchedItems = CcScheduleQuery::create()
|
||||
->filterByDBStarts($nextStartDT->format("Y-m-d H:i:s.u"), Criteria::GREATER_EQUAL)
|
||||
->filterByDbInstanceId($instance)
|
||||
->filterByDbInstanceId($instance->getDbId())
|
||||
->filterByDbId($excludeIds, Criteria::NOT_IN)
|
||||
->orderByDbStarts()
|
||||
->find($this->con);
|
||||
|
@ -149,7 +172,7 @@ class Application_Model_Scheduler {
|
|||
|
||||
Logging::log("adding file with id: ".$file["id"]);
|
||||
|
||||
$endTimeDT = $this->findEndTime($nextStartDT, $file['cliplength']);
|
||||
$endTimeDT = self::findEndTime($nextStartDT, $file['cliplength']);
|
||||
|
||||
//item existed previously and is being moved.
|
||||
//need to keep same id for resources if we want REST.
|
||||
|
@ -171,7 +194,7 @@ class Application_Model_Scheduler {
|
|||
$sched->setDbFadeIn($file['fadein']);
|
||||
$sched->setDbFadeOut($file['fadeout']);
|
||||
$sched->setDbClipLength($file['cliplength']);
|
||||
$sched->setDbInstanceId($instance);
|
||||
$sched->setDbInstanceId($instance->getDbId());
|
||||
$sched->save($this->con);
|
||||
|
||||
$nextStartDT = $endTimeDT;
|
||||
|
@ -184,7 +207,7 @@ class Application_Model_Scheduler {
|
|||
|
||||
Logging::log("adjusting iterm {$item->getDbId()}");
|
||||
|
||||
$endTimeDT = $this->findEndTime($nextStartDT, $item->getDbClipLength());
|
||||
$endTimeDT = self::findEndTime($nextStartDT, $item->getDbClipLength());
|
||||
|
||||
$item->setDbStarts($nextStartDT);
|
||||
$item->setDbEnds($endTimeDT);
|
||||
|
@ -195,6 +218,10 @@ class Application_Model_Scheduler {
|
|||
}
|
||||
}
|
||||
|
||||
//update the last scheduled timestamp.
|
||||
CcShowInstancesQuery::create()
|
||||
->filterByPrimaryKeys($affectedShowInstances)
|
||||
->update(array('DbLastScheduled' => new DateTime("now", new DateTimeZone("UTC"))), $this->con);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
throw $e;
|
||||
|
@ -236,36 +263,53 @@ class Application_Model_Scheduler {
|
|||
* @param array $selectedItem
|
||||
* @param array $afterItem
|
||||
*/
|
||||
public function moveItem($selectedItem, $afterItem, $adjustSched = true) {
|
||||
public function moveItem($selectedItems, $afterItems, $adjustSched = true) {
|
||||
|
||||
$this->con->beginTransaction();
|
||||
|
||||
try {
|
||||
|
||||
$origSelIns = intval($selectedItem[0]["instance"]);
|
||||
$origAfterIns = intval($afterItem[0]["instance"]);
|
||||
$origSelTs = intval($selectedItems[0]["timestamp"]);
|
||||
$origAfterTs = intval($afterItems[0]["timestamp"]);
|
||||
|
||||
Logging::log("Moving item {$selectedItem[0]["id"]}");
|
||||
Logging::log("After {$afterItem[0]["id"]}");
|
||||
Logging::log("Moving item {$selectedItems[0]["id"]}");
|
||||
Logging::log("After {$afterItems[0]["id"]}");
|
||||
|
||||
$selected = CcScheduleQuery::create()->findPk($selectedItem[0]["id"]);
|
||||
$after = CcScheduleQuery::create()->findPk($afterItem[0]["id"]);
|
||||
|
||||
/*
|
||||
if (isset($after) && $origSelIns !== $selected->getDBInstanceId()
|
||||
|| $origAfterIns !== $after->getDBInstanceId()) {
|
||||
|
||||
Logging::log("items have been since updated");
|
||||
return;
|
||||
$selected = CcScheduleQuery::create()->findPk($selectedItems[0]["id"], $this->con);
|
||||
if (is_null($selected)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
}
|
||||
*/
|
||||
$selectedInstance = $selected->getCcShowInstances($this->con);
|
||||
|
||||
$this->removeGaps($origSelIns, $selected->getDbId());
|
||||
|
||||
//moved to another show, remove gaps from original show.
|
||||
if ($adjustSched === true && $origSelIns !== $origAfterIns) {
|
||||
if (intval($afterItems[0]["id"]) === 0) {
|
||||
|
||||
$afterInstance = CcShowInstancesQuery::create()->findPK($afterItems[0]["instance"], $this->con);
|
||||
}
|
||||
else {
|
||||
$after = CcScheduleQuery::create()->findPk($afterItems[0]["id"], $this->con);
|
||||
if (is_null($after)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
}
|
||||
$afterInstance = $after->getCcShowInstances($this->con);
|
||||
}
|
||||
|
||||
if (is_null($selectedInstance) || is_null($afterInstance)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
}
|
||||
|
||||
$currTs = intval($selectedInstance->getDbLastScheduled("U")) ? : 0;
|
||||
if ($origSelTs !== $currTs) {
|
||||
$show = $selectedInstance->getCcShow($this->con);
|
||||
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
|
||||
}
|
||||
|
||||
$currTs = intval($afterInstance->getDbLastScheduled("U")) ? : 0;
|
||||
if ($origAfterTs !== $currTs) {
|
||||
$show = $afterInstance->getCcShow($this->con);
|
||||
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
|
||||
}
|
||||
|
||||
$this->removeGaps($selectedInstance->getDbId(), $selected->getDbId());
|
||||
|
||||
$data = $this->fileInfo;
|
||||
$data["id"] = $selected->getDbFileId();
|
||||
|
@ -276,7 +320,7 @@ class Application_Model_Scheduler {
|
|||
$data["fadeout"] = $selected->getDbFadeOut();
|
||||
$data["sched_id"] = $selected->getDbId();
|
||||
|
||||
$this->insertAfter($afterItem, array($data), $adjustSched);
|
||||
$this->insertAfter($afterItems, array($data), $adjustSched);
|
||||
|
||||
$this->con->commit();
|
||||
|
||||
|
@ -288,14 +332,35 @@ class Application_Model_Scheduler {
|
|||
}
|
||||
}
|
||||
|
||||
public function removeItems($scheduledIds, $adjustSched = true) {
|
||||
public function removeItems($scheduledItems, $adjustSched = true) {
|
||||
|
||||
$showInstances = array();
|
||||
$this->con->beginTransaction();
|
||||
|
||||
try {
|
||||
|
||||
$removedItems = CcScheduleQuery::create()->findPks($scheduledIds);
|
||||
$scheduledIds = array();
|
||||
foreach ($scheduledItems as $item) {
|
||||
$scheduledIds[$item["id"]] = intval($item["timestamp"]);
|
||||
}
|
||||
|
||||
$removedItems = CcScheduleQuery::create()->findPks(array_keys($scheduledIds));
|
||||
|
||||
//check to make sure all items selected are up to date
|
||||
foreach ($removedItems as $removedItem) {
|
||||
$ts = $scheduledIds[$removedItem->getDbId()];
|
||||
$instance = $removedItem->getCcShowInstances($this->con);
|
||||
if (is_null($instance)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
}
|
||||
$currTs = intval($instance->getDbLastScheduled("U")) ? : 0;
|
||||
|
||||
if ($ts !== $currTs) {
|
||||
$show = $instance->getCcShow($this->con);
|
||||
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
|
||||
}
|
||||
}
|
||||
|
||||
$removedItems->delete($this->con);
|
||||
|
||||
if ($adjustSched === true) {
|
||||
|
@ -313,6 +378,11 @@ class Application_Model_Scheduler {
|
|||
}
|
||||
}
|
||||
|
||||
//update the last scheduled timestamp.
|
||||
CcShowInstancesQuery::create()
|
||||
->filterByPrimaryKeys($showInstances)
|
||||
->update(array('DbLastScheduled' => new DateTime("now", new DateTimeZone("UTC"))), $this->con);
|
||||
|
||||
$this->con->commit();
|
||||
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
|
@ -328,11 +398,15 @@ class Application_Model_Scheduler {
|
|||
* @param array $exclude
|
||||
* ids of sched items to remove from the calulation.
|
||||
*/
|
||||
public function removeGaps($showInstance, $exclude=null) {
|
||||
private function removeGaps($showInstance, $exclude=null) {
|
||||
|
||||
Logging::log("removing gaps from show instance #".$showInstance);
|
||||
|
||||
$instance = CcShowInstancesQuery::create()->findPK($showInstance, $this->con);
|
||||
if (is_null($instance)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
}
|
||||
|
||||
$itemStartDT = $instance->getDbStarts(null);
|
||||
|
||||
$schedule = CcScheduleQuery::create()
|
||||
|
@ -346,7 +420,7 @@ class Application_Model_Scheduler {
|
|||
|
||||
Logging::log("adjusting item #".$item->getDbId());
|
||||
|
||||
$itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength());
|
||||
$itemEndDT = self::findEndTime($itemStartDT, $item->getDbClipLength());
|
||||
|
||||
$item->setDbStarts($itemStartDT);
|
||||
$item->setDbEnds($itemEndDT);
|
||||
|
@ -356,3 +430,5 @@ class Application_Model_Scheduler {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
class OutDatedScheduleException extends Exception {}
|
|
@ -356,9 +356,11 @@ class Application_Model_Show {
|
|||
|
||||
if (!is_null($showDaysRow)){
|
||||
return ($showDaysRow->getDbRepeatType() != -1);
|
||||
} else
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the repeat type of the show. Show can have repeat
|
||||
|
@ -1164,9 +1166,11 @@ class Application_Model_Show {
|
|||
|
||||
Logging::log('$start time of non repeating record '.$start);
|
||||
|
||||
if ($newInstance){
|
||||
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a 1 or more than 1 show instances (user has stated this show repeats). If the show
|
||||
|
@ -1392,7 +1396,7 @@ class Application_Model_Show {
|
|||
Application_Model_Preference::SetShowsPopulatedUntil($end_timestamp);
|
||||
}
|
||||
|
||||
$sql = "SELECT starts, ends, record, rebroadcast, instance_id, show_id, name, description,
|
||||
$sql = "SELECT starts, ends, record, rebroadcast, instance_id, show_id, name,
|
||||
color, background_color, file_id, cc_show_instances.id AS instance_id
|
||||
FROM cc_show_instances
|
||||
LEFT JOIN cc_show ON cc_show.id = cc_show_instances.show_id
|
||||
|
@ -1455,17 +1459,17 @@ class Application_Model_Show {
|
|||
$endTimeString = $p_endTimestamp->format("Y-m-d H:i:s");
|
||||
if (!is_null($p_startTimestamp)) {
|
||||
$startTimeString = $p_startTimestamp->format("Y-m-d H:i:s");
|
||||
$sql = "SELECT * FROM cc_show_days
|
||||
WHERE last_show IS NULL
|
||||
OR first_show < '{$endTimeString}' AND last_show > '{$startTimeString}'";
|
||||
}
|
||||
else {
|
||||
$today_timestamp = new DateTime("now", new DateTimeZone("UTC"));
|
||||
$today_timestamp_string = $today_timestamp->format("Y-m-d H:i:s");
|
||||
$startTimeString = $today_timestamp->format("Y-m-d H:i:s");
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM cc_show_days
|
||||
WHERE last_show IS NULL
|
||||
OR first_show < '{$endTimeString}' AND last_show > '{$today_timestamp_string}'";
|
||||
}
|
||||
OR first_show < '{$endTimeString}' AND last_show > '{$startTimeString}'";
|
||||
|
||||
Logging::log($sql);
|
||||
|
||||
$res = $CC_DBC->GetAll($sql);
|
||||
|
||||
|
@ -1527,13 +1531,15 @@ class Application_Model_Show {
|
|||
$endDateTime = new DateTime($show["ends"], new DateTimeZone("UTC"));
|
||||
$endDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
|
||||
$event["id"] = $show["instance_id"];
|
||||
$event["id"] = intval($show["instance_id"]);
|
||||
$event["title"] = $show["name"];
|
||||
$event["start"] = $startDateTime->format("Y-m-d H:i:s");
|
||||
$event["startUnix"] = $startDateTime->format("U");
|
||||
$event["end"] = $endDateTime->format("Y-m-d H:i:s");
|
||||
$event["endUnix"] = $endDateTime->format("U");
|
||||
$event["allDay"] = false;
|
||||
$event["description"] = $show["description"];
|
||||
$event["showId"] = $show["show_id"];
|
||||
$event["showId"] = intval($show["show_id"]);
|
||||
$event["record"] = intval($show["record"]);
|
||||
$event["rebroadcast"] = intval($show["rebroadcast"]);
|
||||
|
||||
|
|
|
@ -6,6 +6,9 @@ class Application_Model_ShowBuilder {
|
|||
private $startDT;
|
||||
private $endDT;
|
||||
private $user;
|
||||
private $opts;
|
||||
|
||||
private $contentDT;
|
||||
|
||||
private $defaultRowArray = array(
|
||||
"header" => false,
|
||||
|
@ -15,25 +18,25 @@ class Application_Model_ShowBuilder {
|
|||
"id" => 0,
|
||||
"instance" => "",
|
||||
"starts" => "",
|
||||
"startsUnix" => null,
|
||||
"ends" => "",
|
||||
"endsUnix" => null,
|
||||
"runtime" => "",
|
||||
"title" => "",
|
||||
"creator" => "",
|
||||
"album" => ""
|
||||
"album" => "",
|
||||
"timestamp" => null
|
||||
);
|
||||
|
||||
/*
|
||||
* @param DateTime $p_startsDT
|
||||
* @param DateTime $p_endsDT
|
||||
*/
|
||||
public function __construct($p_startDT, $p_endDT) {
|
||||
public function __construct($p_startDT, $p_endDT, $p_opts) {
|
||||
|
||||
$this->startDT = $p_startDT;
|
||||
$this->endDT = $p_endDT;
|
||||
$this->timezone = date_default_timezone_get();
|
||||
$this->user = Application_Model_User::GetCurrentUser();
|
||||
$this->opts = $p_opts;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -56,17 +59,64 @@ class Application_Model_ShowBuilder {
|
|||
return $runtime;
|
||||
}
|
||||
|
||||
private function makeFooterRow() {
|
||||
private function formatTimeFilled($p_sec) {
|
||||
|
||||
$formatted = "";
|
||||
$sign = ($p_sec < 0) ? "-" : "+";
|
||||
|
||||
$time = Application_Model_Playlist::secondsToPlaylistTime(abs($p_sec));
|
||||
Logging::log("time is: ".$time);
|
||||
$info = explode(":", $time);
|
||||
|
||||
$formatted .= $sign;
|
||||
|
||||
if ($info[0] > 0) {
|
||||
$formatted .= " {$info[0]}h";
|
||||
}
|
||||
|
||||
if ($info[1] > 0) {
|
||||
$formatted .= " {$info[1]}m";
|
||||
}
|
||||
|
||||
if ($info[2] > 0) {
|
||||
$sec = round($info[2], 0);
|
||||
$formatted .= " {$sec}s";
|
||||
}
|
||||
|
||||
return $formatted;
|
||||
}
|
||||
|
||||
private function makeFooterRow($p_item) {
|
||||
|
||||
$row = $this->defaultRowArray;
|
||||
$row["footer"] = true;
|
||||
|
||||
$showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC"));
|
||||
$contentDT = $this->contentDT;
|
||||
|
||||
$runtime = bcsub($contentDT->format("U.u"), $showEndDT->format("U.u"), 6);
|
||||
$row["runtime"] = $runtime;
|
||||
$row["fRuntime"] = $this->formatTimeFilled($runtime);
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
private function getRowTimestamp($p_item, &$row) {
|
||||
|
||||
if (is_null($p_item["si_last_scheduled"])) {
|
||||
$ts = 0;
|
||||
}
|
||||
else {
|
||||
$dt = new DateTime($p_item["si_last_scheduled"], new DateTimeZone("UTC"));
|
||||
$ts = intval($dt->format("U"));
|
||||
}
|
||||
$row["timestamp"] = $ts;
|
||||
}
|
||||
|
||||
private function makeHeaderRow($p_item) {
|
||||
|
||||
$row = $this->defaultRowArray;
|
||||
$this->getRowTimestamp($p_item, &$row);
|
||||
|
||||
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
|
||||
$showStartDT->setTimezone(new DateTimeZone($this->timezone));
|
||||
|
@ -80,13 +130,20 @@ class Application_Model_ShowBuilder {
|
|||
$row["title"] = $p_item["show_name"];
|
||||
$row["instance"] = intval($p_item["si_id"]);
|
||||
|
||||
$this->contentDT = $showStartDT;
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
private function makeScheduledItemRow($p_item) {
|
||||
$row = $this->defaultRowArray;
|
||||
$epoch_now = time();
|
||||
|
||||
if ($this->user->canSchedule($item["show_id"]) == true) {
|
||||
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
|
||||
$this->getRowTimestamp($p_item, &$row);
|
||||
|
||||
//can only schedule the show if it hasn't started and you are allowed.
|
||||
if ($epoch_now < $showStartDT->format('U') && $this->user->canSchedule($p_item["show_id"]) == true) {
|
||||
$row["checkbox"] = true;
|
||||
}
|
||||
|
||||
|
@ -107,6 +164,8 @@ class Application_Model_ShowBuilder {
|
|||
$row["title"] = $p_item["file_track_title"];
|
||||
$row["creator"] = $p_item["file_artist_name"];
|
||||
$row["album"] = $p_item["file_album_title"];
|
||||
|
||||
$this->contentDT = $schedEndDT;
|
||||
}
|
||||
//show is empty
|
||||
else {
|
||||
|
@ -123,16 +182,35 @@ class Application_Model_ShowBuilder {
|
|||
$current_id = -1;
|
||||
$display_items = array();
|
||||
|
||||
$scheduled_items = Application_Model_Schedule::GetScheduleDetailItems($this->startDT->format("Y-m-d H:i:s"), $this->endDT->format("Y-m-d H:i:s"));
|
||||
$shows = array();
|
||||
if ($this->opts["myShows"] === 1) {
|
||||
|
||||
foreach ($scheduled_items as $item) {
|
||||
$host_shows = CcShowHostsQuery::create()
|
||||
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
|
||||
->filterByDbHost($this->user->getId())
|
||||
->find();
|
||||
|
||||
foreach ($host_shows as $host_show) {
|
||||
$shows[] = $host_show->getDbShow();
|
||||
}
|
||||
}
|
||||
else if ($this->opts["showFilter"] !== 0) {
|
||||
$shows[] = $this->opts["showFilter"];
|
||||
}
|
||||
|
||||
$scheduled_items = Application_Model_Schedule::GetScheduleDetailItems($this->startDT->format("Y-m-d H:i:s"), $this->endDT->format("Y-m-d H:i:s"), $shows);
|
||||
|
||||
for ($i = 0, $rows = count($scheduled_items); $i < $rows; $i++) {
|
||||
|
||||
$item = $scheduled_items[$i];
|
||||
|
||||
//make a header row.
|
||||
if ($current_id !== $item["si_id"]) {
|
||||
|
||||
//make a footer row.
|
||||
if ($current_id !== -1) {
|
||||
$display_items[] = $this->makeFooterRow();
|
||||
//pass in the previous row as it's the last row for the previous show.
|
||||
$display_items[] = $this->makeFooterRow($scheduled_items[$i-1]);
|
||||
}
|
||||
|
||||
$display_items[] = $this->makeHeaderRow($item);
|
||||
|
@ -146,7 +224,7 @@ class Application_Model_ShowBuilder {
|
|||
|
||||
//make the last footer if there were any scheduled items.
|
||||
if (count($scheduled_items) > 0) {
|
||||
$display_items[] = $this->makeFooterRow();
|
||||
$display_items[] = $this->makeFooterRow($scheduled_items[count($scheduled_items)-1]);
|
||||
}
|
||||
|
||||
return $display_items;
|
||||
|
|
|
@ -58,21 +58,19 @@ class Application_Model_ShowInstance {
|
|||
/**
|
||||
* Return the start time of the Show (UTC time)
|
||||
* @return string in format "Y-m-d H:i:s" (PHP time notation)
|
||||
* TODO: make this function return a DateTime object instead.
|
||||
*/
|
||||
public function getShowInstanceStart()
|
||||
public function getShowInstanceStart($format="Y-m-d H:i:s")
|
||||
{
|
||||
return $this->_showInstance->getDbStarts();
|
||||
return $this->_showInstance->getDbStarts($format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the end time of the Show (UTC time)
|
||||
* @return string in format "Y-m-d H:i:s" (PHP time notation)
|
||||
* TODO: make this function return a DateTime object instead.
|
||||
*/
|
||||
public function getShowInstanceEnd()
|
||||
public function getShowInstanceEnd($format="Y-m-d H:i:s")
|
||||
{
|
||||
return $this->_showInstance->getDbEnds();
|
||||
return $this->_showInstance->getDbEnds($format);
|
||||
}
|
||||
|
||||
public function getStartDate()
|
||||
|
@ -444,6 +442,81 @@ class Application_Model_ShowInstance {
|
|||
$this->updateScheduledTime();
|
||||
}
|
||||
|
||||
private function checkToDeleteShow($showId)
|
||||
{
|
||||
//UTC DateTime object
|
||||
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
|
||||
|
||||
$showDays = CcShowDaysQuery::create()
|
||||
->filterByDbShowId($showId)
|
||||
->findOne();
|
||||
|
||||
$showEnd = $showDays->getDbLastShow();
|
||||
|
||||
//there will always be more shows populated.
|
||||
if (is_null($showEnd)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$lastShowStartDateTime = new DateTime("{$showEnd} {$showDays->getDbStartTime()}", new DateTimeZone($showDays->getDbTimezone()));
|
||||
//end dates were non inclusive.
|
||||
$lastShowStartDateTime = self::addDeltas($lastShowStartDateTime, -1, 0);
|
||||
|
||||
//there's still some shows left to be populated.
|
||||
if ($lastShowStartDateTime->getTimestamp() > $showsPopUntil->getTimestamp()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check if there are any non deleted show instances remaining.
|
||||
$showInstances = CcShowInstancesQuery::create()
|
||||
->filterByDbShowId($showId)
|
||||
->filterByDbModifiedInstance(false)
|
||||
->filterByDbRebroadcast(0)
|
||||
->find();
|
||||
|
||||
if (is_null($showInstances)){
|
||||
return true;
|
||||
}
|
||||
//only 1 show instance left of the show, make it non repeating.
|
||||
else if (count($showInstances) === 1) {
|
||||
$showInstance = $showInstances[0];
|
||||
|
||||
$showDaysOld = CcShowDaysQuery::create()
|
||||
->filterByDbShowId($showId)
|
||||
->find();
|
||||
|
||||
$tz = $showDaysOld[0]->getDbTimezone();
|
||||
|
||||
$startDate = new DateTime($showInstance->getDbStarts(), new DateTimeZone("UTC"));
|
||||
$startDate->setTimeZone(new DateTimeZone($tz));
|
||||
$endDate = self::addDeltas($startDate, 1, 0);
|
||||
|
||||
//make a new rule for a non repeating show.
|
||||
$showDayNew = new CcShowDays();
|
||||
$showDayNew->setDbFirstShow($startDate->format("Y-m-d"));
|
||||
$showDayNew->setDbLastShow($endDate->format("Y-m-d"));
|
||||
$showDayNew->setDbStartTime($startDate->format("H:i:s"));
|
||||
$showDayNew->setDbTimezone($tz);
|
||||
$showDayNew->setDbDay($startDate->format('w'));
|
||||
$showDayNew->setDbDuration($showDaysOld[0]->getDbDuration());
|
||||
$showDayNew->setDbRepeatType(-1);
|
||||
$showDayNew->setDbShowId($showDaysOld[0]->getDbShowId());
|
||||
$showDayNew->setDbRecord($showDaysOld[0]->getDbRecord());
|
||||
$showDayNew->save();
|
||||
|
||||
//delete the old rules for repeating shows
|
||||
$showDaysOld->delete();
|
||||
|
||||
//remove the old repeating deleted instances.
|
||||
$showInstances = CcShowInstancesQuery::create()
|
||||
->filterByDbShowId($showId)
|
||||
->filterByDbModifiedInstance(true)
|
||||
->delete();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
@ -465,6 +538,10 @@ class Application_Model_ShowInstance {
|
|||
->setDbModifiedInstance(true)
|
||||
->save();
|
||||
|
||||
if ($this->isRebroadcast()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//delete the rebroadcasts of the removed recorded show.
|
||||
if ($recording) {
|
||||
CcShowInstancesQuery::create()
|
||||
|
@ -477,17 +554,8 @@ class Application_Model_ShowInstance {
|
|||
->filterByDbInstanceId($this->_instanceId)
|
||||
->delete();
|
||||
|
||||
// check if we can safely delete the show
|
||||
$showInstancesRow = CcShowInstancesQuery::create()
|
||||
->filterByDbShowId($showId)
|
||||
->filterByDbModifiedInstance(false)
|
||||
->findOne();
|
||||
|
||||
/* If we didn't find any instances of the show that haven't
|
||||
* been deleted, then just erase everything related to that show.
|
||||
* We can just delete, the show and the foreign key-constraint should
|
||||
* take care of deleting all of its instances. */
|
||||
if(is_null($showInstancesRow)){
|
||||
if ($this->checkToDeleteShow($showId)){
|
||||
CcShowQuery::create()
|
||||
->filterByDbId($showId)
|
||||
->delete();
|
||||
|
@ -537,20 +605,26 @@ class Application_Model_ShowInstance {
|
|||
return $time;
|
||||
}
|
||||
|
||||
|
||||
public function getTimeScheduledSecs()
|
||||
{
|
||||
$time_filled = $this->getTimeScheduled();
|
||||
return Application_Model_Schedule::WallTimeToMillisecs($time_filled) / 1000;
|
||||
}
|
||||
|
||||
public function getDurationSecs()
|
||||
{
|
||||
$ends = $this->getShowInstanceEnd(null);
|
||||
$starts = $this->getShowInstanceStart(null);
|
||||
return $ends->format('U') - $starts->format('U');
|
||||
}
|
||||
|
||||
public function getPercentScheduled()
|
||||
{
|
||||
$start_timestamp = $this->getShowInstanceStart();
|
||||
$end_timestamp = $this->getShowInstanceEnd();
|
||||
$time_filled = $this->getTimeScheduled();
|
||||
$durationSeconds = $this->getDurationSecs();
|
||||
$timeSeconds = $this->getTimeScheduledSecs();
|
||||
|
||||
$s_epoch = strtotime($start_timestamp);
|
||||
$e_epoch = strtotime($end_timestamp);
|
||||
$i_epoch = Application_Model_Schedule::WallTimeToMillisecs($time_filled) / 1000;
|
||||
|
||||
$percent = ceil(($i_epoch / ($e_epoch - $s_epoch)) * 100);
|
||||
|
||||
if ($percent > 100)
|
||||
$percent = 100;
|
||||
$percent = ceil(($timeSeconds / $durationSeconds) * 100);
|
||||
|
||||
return $percent;
|
||||
}
|
||||
|
@ -714,6 +788,7 @@ class Application_Model_ShowInstance {
|
|||
$sql = "SELECT si.id"
|
||||
." FROM $CC_CONFIG[showInstances] si"
|
||||
." WHERE si.ends < TIMESTAMP '$p_timeNow'"
|
||||
." AND si.modified_instance = 'f'"
|
||||
." ORDER BY si.ends DESC"
|
||||
." LIMIT 1";
|
||||
|
||||
|
@ -728,10 +803,18 @@ class Application_Model_ShowInstance {
|
|||
public static function GetCurrentShowInstance($p_timeNow){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
/* Orderby si.starts descending, because in some cases
|
||||
* we can have multiple shows overlapping each other. In
|
||||
* this case, the show that started later is the one that
|
||||
* is actually playing, and so this is the one we want.
|
||||
*/
|
||||
|
||||
$sql = "SELECT si.id"
|
||||
." FROM $CC_CONFIG[showInstances] si"
|
||||
." WHERE si.starts <= TIMESTAMP '$p_timeNow'"
|
||||
." AND si.ends > TIMESTAMP '$p_timeNow'"
|
||||
." AND si.modified_instance = 'f'"
|
||||
." ORDER BY si.starts DESC"
|
||||
." LIMIT 1";
|
||||
|
||||
$id = $CC_DBC->GetOne($sql);
|
||||
|
@ -748,6 +831,7 @@ class Application_Model_ShowInstance {
|
|||
$sql = "SELECT si.id"
|
||||
." FROM $CC_CONFIG[showInstances] si"
|
||||
." WHERE si.starts > TIMESTAMP '$p_timeNow'"
|
||||
." AND si.modified_instance = 'f'"
|
||||
." ORDER BY si.starts"
|
||||
." LIMIT 1";
|
||||
|
||||
|
|
|
@ -583,7 +583,7 @@ class Application_Model_StoredFile {
|
|||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
$displayData = array("track_title", "artist_name", "album_title", "genre", "length", "year", "utime", "mtime", "ftype");
|
||||
$displayData = array("track_title", "artist_name", "album_title", "genre", "length", "year", "utime", "mtime", "ftype", "track_number");
|
||||
|
||||
$plSelect = "SELECT ";
|
||||
$fileSelect = "SELECT ";
|
||||
|
@ -610,6 +610,9 @@ class Application_Model_StoredFile {
|
|||
} else if ($key === "mtime") {
|
||||
$plSelect .= $key.", ";
|
||||
$fileSelect .= $key.", ";
|
||||
} else if ($key === "track_number") {
|
||||
$plSelect .= "NULL AS ".$key.", ";
|
||||
$fileSelect .= $key.", ";
|
||||
} else {
|
||||
$plSelect .= "NULL AS ".$key.", ";
|
||||
$fileSelect .= $key.", ";
|
||||
|
@ -623,6 +626,7 @@ class Application_Model_StoredFile {
|
|||
|
||||
$results = Application_Model_StoredFile::searchFiles($fromTable, $datatables);
|
||||
|
||||
|
||||
foreach($results['aaData'] as &$row){
|
||||
|
||||
$row['id'] = intval($row['id']);
|
||||
|
@ -733,6 +737,7 @@ class Application_Model_StoredFile {
|
|||
$sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"];
|
||||
}
|
||||
|
||||
//display sql executed in airtime log for testing
|
||||
//Logging::log($sql);
|
||||
|
||||
$results = $CC_DBC->getAll($sql);
|
||||
|
@ -852,10 +857,12 @@ class Application_Model_StoredFile {
|
|||
$fileSize = filesize($audio_file);
|
||||
|
||||
if ( $freeSpace < $fileSize){
|
||||
$freeSpace = floor($freeSpace/1024/1024);
|
||||
$fileSize = floor($fileSize/1024/1024);
|
||||
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "The file was not uploaded, there was '.$freeSpace.'MB disk space left the file you are uploadings size is '.$fileSize.'MB."}}');
|
||||
$freeSpace = ceil($freeSpace/1024/1024);
|
||||
$fileSize = ceil($fileSize/1024/1024);
|
||||
$result = array("code" => 107, "message" => "The file was not uploaded, there is ".$freeSpace."MB of disk space left and the file you are uploading has a size of ".$fileSize."MB.");
|
||||
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function copyFileToStor($p_targetDir, $fileName, $tempname){
|
||||
|
@ -865,20 +872,21 @@ class Application_Model_StoredFile {
|
|||
$duplicate = Application_Model_StoredFile::RecallByMd5($md5);
|
||||
if ($duplicate) {
|
||||
if (PEAR::isError($duplicate)) {
|
||||
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' . $duplicate->getMessage() .'}}');
|
||||
$result = array("code" => 105, "message" => $duplicate->getMessage());
|
||||
}
|
||||
if (file_exists($duplicate->getFilePath())) {
|
||||
$duplicateName = $duplicate->getMetadataValue('MDATA_KEY_TITLE');
|
||||
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "An identical audioclip named \"' . $duplicateName . '\" already exists on the server."}}');
|
||||
$result = array( "code" => 106, "message" => "An identical audioclip named '$duplicateName' already exists on the server.");
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($result)){//The file has no duplicate, so procceed to copy.
|
||||
$storDir = Application_Model_MusicDir::getStorDir();
|
||||
$stor = $storDir->getDirectory();
|
||||
|
||||
//check to see if there is enough space in $stor to continue.
|
||||
Application_Model_StoredFile::checkForEnoughDiskSpaceToCopy($stor, $audio_file);
|
||||
|
||||
$result = Application_Model_StoredFile::checkForEnoughDiskSpaceToCopy($stor, $audio_file);
|
||||
if (!isset($result)){//if result not set then there's enough disk space to copy the file over
|
||||
$stor .= "/organize";
|
||||
$audio_stor = $stor . DIRECTORY_SEPARATOR . $fileName;
|
||||
|
||||
|
@ -890,11 +898,12 @@ class Application_Model_StoredFile {
|
|||
#something went wrong likely there wasn't enough space in the audio_stor to move the file too.
|
||||
#warn the user that the file wasn't uploaded and they should check if there is enough disk space.
|
||||
unlink($audio_file);//remove the file from the organize after failed rename
|
||||
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "The file was not uploaded, this error will occur if the computer hard drive does not have enough disk space."}}');
|
||||
}
|
||||
$result = array("code" => 108, "message" => "The file was not uploaded, this error will occur if the computer hard drive does not have enough disk space.");
|
||||
|
||||
//$r = @copy($audio_file, $audio_stor);
|
||||
//$r = @unlink($audio_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1028,3 +1037,4 @@ class Application_Model_StoredFile {
|
|||
}
|
||||
|
||||
class DeleteScheduledFileException extends Exception {}
|
||||
class FileDoesNotExistException extends Exception {}
|
||||
|
|
|
@ -84,7 +84,11 @@ class Application_Model_StreamSetting {
|
|||
} else if ($key == "output_sound_device_type") {
|
||||
$sql = "UPDATE cc_stream_setting SET value='$d' WHERE keyname='$key'";
|
||||
$CC_DBC->query($sql);
|
||||
} else {
|
||||
} else if ($key == "streamFormat"){
|
||||
// this goes into cc_pref table
|
||||
Logging::log("Insert stream label format $d");
|
||||
Application_Model_Preference::SetStreamLabelFormat($d);
|
||||
} else if (is_array($d)) {
|
||||
$temp = explode('_', $key);
|
||||
$prefix = $temp[0];
|
||||
foreach ($d as $k=>$v) {
|
||||
|
@ -96,6 +100,8 @@ class Application_Model_StreamSetting {
|
|||
$sql = "UPDATE cc_stream_setting SET value='$v' WHERE keyname='$keyname'";
|
||||
$CC_DBC->query($sql);
|
||||
}
|
||||
} else {
|
||||
Logging::log("Warning unexpected value: ".$key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,6 +120,9 @@ class Application_Model_Systemstatus
|
|||
public static function GetPypoStatus(){
|
||||
|
||||
$component = CcServiceRegisterQuery::create()->findOneByDbName("pypo");
|
||||
if (is_null($component)){
|
||||
return null;
|
||||
} else {
|
||||
$ip = $component->getDbIp();
|
||||
|
||||
$docRoot = self::GetMonitStatus($ip);
|
||||
|
@ -127,10 +130,14 @@ class Application_Model_Systemstatus
|
|||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetLiquidsoapStatus(){
|
||||
|
||||
$component = CcServiceRegisterQuery::create()->findOneByDbName("pypo");
|
||||
if (is_null($component)){
|
||||
return null;
|
||||
} else {
|
||||
$ip = $component->getDbIp();
|
||||
|
||||
$docRoot = self::GetMonitStatus($ip);
|
||||
|
@ -138,6 +145,7 @@ class Application_Model_Systemstatus
|
|||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetShowRecorderStatus(){
|
||||
|
||||
|
|
|
@ -76,4 +76,35 @@ class CcShowInstances extends BaseCcShowInstances {
|
|||
return $dt->format($format);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [optionally formatted] temporal [last_scheduled] column value.
|
||||
*
|
||||
*
|
||||
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
||||
* If format is NULL, then the raw DateTime object will be returned.
|
||||
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
||||
* @throws PropelException - if unable to parse/validate the date/time value.
|
||||
*/
|
||||
public function getDbLastScheduled($format = 'Y-m-d H:i:s')
|
||||
{
|
||||
if ($this->last_scheduled === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
$dt = new DateTime($this->last_scheduled, new DateTimeZone("UTC"));
|
||||
} catch (Exception $x) {
|
||||
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->last_scheduled, true), $x);
|
||||
}
|
||||
|
||||
if ($format === null) {
|
||||
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
|
||||
return $dt;
|
||||
} elseif (strpos($format, '%') !== false) {
|
||||
return strftime($format, $dt->format('U'));
|
||||
} else {
|
||||
return $dt->format($format);
|
||||
}
|
||||
}
|
||||
} // CcShowInstances
|
||||
|
|
|
@ -46,7 +46,8 @@ class CcShowInstancesTableMap extends TableMap {
|
|||
$this->addColumn('REBROADCAST', 'DbRebroadcast', 'TINYINT', false, null, 0);
|
||||
$this->addForeignKey('INSTANCE_ID', 'DbOriginalShow', 'INTEGER', 'cc_show_instances', 'ID', false, null, null);
|
||||
$this->addForeignKey('FILE_ID', 'DbRecordedFile', 'INTEGER', 'cc_files', 'ID', false, null, null);
|
||||
$this->addColumn('TIME_FILLED', 'DbTimeFilled', 'TIME', false, null, null);
|
||||
$this->addColumn('TIME_FILLED', 'DbTimeFilled', 'VARCHAR', false, null, '00:00:00');
|
||||
$this->addColumn('LAST_SCHEDULED', 'DbLastScheduled', 'TIMESTAMP', false, null, null);
|
||||
$this->addColumn('MODIFIED_INSTANCE', 'DbModifiedInstance', 'BOOLEAN', true, null, false);
|
||||
// validators
|
||||
} // initialize()
|
||||
|
|
|
@ -289,6 +289,8 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
try {
|
||||
$dt = new DateTime($this->fadein);
|
||||
} catch (Exception $x) {
|
||||
|
|
|
@ -76,10 +76,17 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
|
||||
/**
|
||||
* The value for the time_filled field.
|
||||
* Note: this column has a database default value of: '00:00:00'
|
||||
* @var string
|
||||
*/
|
||||
protected $time_filled;
|
||||
|
||||
/**
|
||||
* The value for the last_scheduled field.
|
||||
* @var string
|
||||
*/
|
||||
protected $last_scheduled;
|
||||
|
||||
/**
|
||||
* The value for the modified_instance field.
|
||||
* Note: this column has a database default value of: false
|
||||
|
@ -136,6 +143,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
{
|
||||
$this->record = 0;
|
||||
$this->rebroadcast = 0;
|
||||
$this->time_filled = '00:00:00';
|
||||
$this->modified_instance = false;
|
||||
}
|
||||
|
||||
|
@ -276,7 +284,17 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the [optionally formatted] temporal [time_filled] column value.
|
||||
* Get the [time_filled] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDbTimeFilled()
|
||||
{
|
||||
return $this->time_filled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [optionally formatted] temporal [last_scheduled] column value.
|
||||
*
|
||||
*
|
||||
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
||||
|
@ -284,18 +302,18 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
||||
* @throws PropelException - if unable to parse/validate the date/time value.
|
||||
*/
|
||||
public function getDbTimeFilled($format = '%X')
|
||||
public function getDbLastScheduled($format = 'Y-m-d H:i:s')
|
||||
{
|
||||
if ($this->time_filled === null) {
|
||||
if ($this->last_scheduled === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
try {
|
||||
$dt = new DateTime($this->time_filled);
|
||||
$dt = new DateTime($this->last_scheduled);
|
||||
} catch (Exception $x) {
|
||||
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->time_filled, true), $x);
|
||||
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->last_scheduled, true), $x);
|
||||
}
|
||||
|
||||
if ($format === null) {
|
||||
|
@ -549,13 +567,33 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
} // setDbRecordedFile()
|
||||
|
||||
/**
|
||||
* Sets the value of [time_filled] column to a normalized version of the date/time value specified.
|
||||
* Set the value of [time_filled] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return CcShowInstances The current object (for fluent API support)
|
||||
*/
|
||||
public function setDbTimeFilled($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->time_filled !== $v || $this->isNew()) {
|
||||
$this->time_filled = $v;
|
||||
$this->modifiedColumns[] = CcShowInstancesPeer::TIME_FILLED;
|
||||
}
|
||||
|
||||
return $this;
|
||||
} // setDbTimeFilled()
|
||||
|
||||
/**
|
||||
* Sets the value of [last_scheduled] column to a normalized version of the date/time value specified.
|
||||
*
|
||||
* @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
|
||||
* be treated as NULL for temporal objects.
|
||||
* @return CcShowInstances The current object (for fluent API support)
|
||||
*/
|
||||
public function setDbTimeFilled($v)
|
||||
public function setDbLastScheduled($v)
|
||||
{
|
||||
// we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
|
||||
// -- which is unexpected, to say the least.
|
||||
|
@ -580,22 +618,22 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
}
|
||||
}
|
||||
|
||||
if ( $this->time_filled !== null || $dt !== null ) {
|
||||
if ( $this->last_scheduled !== null || $dt !== null ) {
|
||||
// (nested ifs are a little easier to read in this case)
|
||||
|
||||
$currNorm = ($this->time_filled !== null && $tmpDt = new DateTime($this->time_filled)) ? $tmpDt->format('H:i:s') : null;
|
||||
$newNorm = ($dt !== null) ? $dt->format('H:i:s') : null;
|
||||
$currNorm = ($this->last_scheduled !== null && $tmpDt = new DateTime($this->last_scheduled)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null;
|
||||
$newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null;
|
||||
|
||||
if ( ($currNorm !== $newNorm) // normalized values don't match
|
||||
)
|
||||
{
|
||||
$this->time_filled = ($dt ? $dt->format('H:i:s') : null);
|
||||
$this->modifiedColumns[] = CcShowInstancesPeer::TIME_FILLED;
|
||||
$this->last_scheduled = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null);
|
||||
$this->modifiedColumns[] = CcShowInstancesPeer::LAST_SCHEDULED;
|
||||
}
|
||||
} // if either are not null
|
||||
|
||||
return $this;
|
||||
} // setDbTimeFilled()
|
||||
} // setDbLastScheduled()
|
||||
|
||||
/**
|
||||
* Set the value of [modified_instance] column.
|
||||
|
@ -635,6 +673,10 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
return false;
|
||||
}
|
||||
|
||||
if ($this->time_filled !== '00:00:00') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->modified_instance !== false) {
|
||||
return false;
|
||||
}
|
||||
|
@ -670,7 +712,8 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
$this->instance_id = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
|
||||
$this->file_id = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
|
||||
$this->time_filled = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
|
||||
$this->modified_instance = ($row[$startcol + 9] !== null) ? (boolean) $row[$startcol + 9] : null;
|
||||
$this->last_scheduled = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
|
||||
$this->modified_instance = ($row[$startcol + 10] !== null) ? (boolean) $row[$startcol + 10] : null;
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
|
@ -679,7 +722,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 10; // 10 = CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
return $startcol + 11; // 11 = CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating CcShowInstances object", $e);
|
||||
|
@ -1104,6 +1147,9 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
return $this->getDbTimeFilled();
|
||||
break;
|
||||
case 9:
|
||||
return $this->getDbLastScheduled();
|
||||
break;
|
||||
case 10:
|
||||
return $this->getDbModifiedInstance();
|
||||
break;
|
||||
default:
|
||||
|
@ -1139,7 +1185,8 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
$keys[6] => $this->getDbOriginalShow(),
|
||||
$keys[7] => $this->getDbRecordedFile(),
|
||||
$keys[8] => $this->getDbTimeFilled(),
|
||||
$keys[9] => $this->getDbModifiedInstance(),
|
||||
$keys[9] => $this->getDbLastScheduled(),
|
||||
$keys[10] => $this->getDbModifiedInstance(),
|
||||
);
|
||||
if ($includeForeignObjects) {
|
||||
if (null !== $this->aCcShow) {
|
||||
|
@ -1210,6 +1257,9 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
$this->setDbTimeFilled($value);
|
||||
break;
|
||||
case 9:
|
||||
$this->setDbLastScheduled($value);
|
||||
break;
|
||||
case 10:
|
||||
$this->setDbModifiedInstance($value);
|
||||
break;
|
||||
} // switch()
|
||||
|
@ -1245,7 +1295,8 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
if (array_key_exists($keys[6], $arr)) $this->setDbOriginalShow($arr[$keys[6]]);
|
||||
if (array_key_exists($keys[7], $arr)) $this->setDbRecordedFile($arr[$keys[7]]);
|
||||
if (array_key_exists($keys[8], $arr)) $this->setDbTimeFilled($arr[$keys[8]]);
|
||||
if (array_key_exists($keys[9], $arr)) $this->setDbModifiedInstance($arr[$keys[9]]);
|
||||
if (array_key_exists($keys[9], $arr)) $this->setDbLastScheduled($arr[$keys[9]]);
|
||||
if (array_key_exists($keys[10], $arr)) $this->setDbModifiedInstance($arr[$keys[10]]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1266,6 +1317,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
if ($this->isColumnModified(CcShowInstancesPeer::INSTANCE_ID)) $criteria->add(CcShowInstancesPeer::INSTANCE_ID, $this->instance_id);
|
||||
if ($this->isColumnModified(CcShowInstancesPeer::FILE_ID)) $criteria->add(CcShowInstancesPeer::FILE_ID, $this->file_id);
|
||||
if ($this->isColumnModified(CcShowInstancesPeer::TIME_FILLED)) $criteria->add(CcShowInstancesPeer::TIME_FILLED, $this->time_filled);
|
||||
if ($this->isColumnModified(CcShowInstancesPeer::LAST_SCHEDULED)) $criteria->add(CcShowInstancesPeer::LAST_SCHEDULED, $this->last_scheduled);
|
||||
if ($this->isColumnModified(CcShowInstancesPeer::MODIFIED_INSTANCE)) $criteria->add(CcShowInstancesPeer::MODIFIED_INSTANCE, $this->modified_instance);
|
||||
|
||||
return $criteria;
|
||||
|
@ -1336,6 +1388,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
$copyObj->setDbOriginalShow($this->instance_id);
|
||||
$copyObj->setDbRecordedFile($this->file_id);
|
||||
$copyObj->setDbTimeFilled($this->time_filled);
|
||||
$copyObj->setDbLastScheduled($this->last_scheduled);
|
||||
$copyObj->setDbModifiedInstance($this->modified_instance);
|
||||
|
||||
if ($deepCopy) {
|
||||
|
@ -1854,6 +1907,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
$this->instance_id = null;
|
||||
$this->file_id = null;
|
||||
$this->time_filled = null;
|
||||
$this->last_scheduled = null;
|
||||
$this->modified_instance = null;
|
||||
$this->alreadyInSave = false;
|
||||
$this->alreadyInValidation = false;
|
||||
|
|
|
@ -26,7 +26,7 @@ abstract class BaseCcShowInstancesPeer {
|
|||
const TM_CLASS = 'CcShowInstancesTableMap';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 10;
|
||||
const NUM_COLUMNS = 11;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
@ -58,6 +58,9 @@ abstract class BaseCcShowInstancesPeer {
|
|||
/** the column name for the TIME_FILLED field */
|
||||
const TIME_FILLED = 'cc_show_instances.TIME_FILLED';
|
||||
|
||||
/** the column name for the LAST_SCHEDULED field */
|
||||
const LAST_SCHEDULED = 'cc_show_instances.LAST_SCHEDULED';
|
||||
|
||||
/** the column name for the MODIFIED_INSTANCE field */
|
||||
const MODIFIED_INSTANCE = 'cc_show_instances.MODIFIED_INSTANCE';
|
||||
|
||||
|
@ -77,12 +80,12 @@ abstract class BaseCcShowInstancesPeer {
|
|||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbShowId', 'DbRecord', 'DbRebroadcast', 'DbOriginalShow', 'DbRecordedFile', 'DbTimeFilled', 'DbModifiedInstance', ),
|
||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbShowId', 'dbRecord', 'dbRebroadcast', 'dbOriginalShow', 'dbRecordedFile', 'dbTimeFilled', 'dbModifiedInstance', ),
|
||||
BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::SHOW_ID, self::RECORD, self::REBROADCAST, self::INSTANCE_ID, self::FILE_ID, self::TIME_FILLED, self::MODIFIED_INSTANCE, ),
|
||||
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'SHOW_ID', 'RECORD', 'REBROADCAST', 'INSTANCE_ID', 'FILE_ID', 'TIME_FILLED', 'MODIFIED_INSTANCE', ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'show_id', 'record', 'rebroadcast', 'instance_id', 'file_id', 'time_filled', 'modified_instance', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
|
||||
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbShowId', 'DbRecord', 'DbRebroadcast', 'DbOriginalShow', 'DbRecordedFile', 'DbTimeFilled', 'DbLastScheduled', 'DbModifiedInstance', ),
|
||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbShowId', 'dbRecord', 'dbRebroadcast', 'dbOriginalShow', 'dbRecordedFile', 'dbTimeFilled', 'dbLastScheduled', 'dbModifiedInstance', ),
|
||||
BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::SHOW_ID, self::RECORD, self::REBROADCAST, self::INSTANCE_ID, self::FILE_ID, self::TIME_FILLED, self::LAST_SCHEDULED, self::MODIFIED_INSTANCE, ),
|
||||
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'SHOW_ID', 'RECORD', 'REBROADCAST', 'INSTANCE_ID', 'FILE_ID', 'TIME_FILLED', 'LAST_SCHEDULED', 'MODIFIED_INSTANCE', ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'show_id', 'record', 'rebroadcast', 'instance_id', 'file_id', 'time_filled', 'last_scheduled', 'modified_instance', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, )
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -92,12 +95,12 @@ abstract class BaseCcShowInstancesPeer {
|
|||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbShowId' => 3, 'DbRecord' => 4, 'DbRebroadcast' => 5, 'DbOriginalShow' => 6, 'DbRecordedFile' => 7, 'DbTimeFilled' => 8, 'DbModifiedInstance' => 9, ),
|
||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbShowId' => 3, 'dbRecord' => 4, 'dbRebroadcast' => 5, 'dbOriginalShow' => 6, 'dbRecordedFile' => 7, 'dbTimeFilled' => 8, 'dbModifiedInstance' => 9, ),
|
||||
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::SHOW_ID => 3, self::RECORD => 4, self::REBROADCAST => 5, self::INSTANCE_ID => 6, self::FILE_ID => 7, self::TIME_FILLED => 8, self::MODIFIED_INSTANCE => 9, ),
|
||||
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'SHOW_ID' => 3, 'RECORD' => 4, 'REBROADCAST' => 5, 'INSTANCE_ID' => 6, 'FILE_ID' => 7, 'TIME_FILLED' => 8, 'MODIFIED_INSTANCE' => 9, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'show_id' => 3, 'record' => 4, 'rebroadcast' => 5, 'instance_id' => 6, 'file_id' => 7, 'time_filled' => 8, 'modified_instance' => 9, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
|
||||
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbShowId' => 3, 'DbRecord' => 4, 'DbRebroadcast' => 5, 'DbOriginalShow' => 6, 'DbRecordedFile' => 7, 'DbTimeFilled' => 8, 'DbLastScheduled' => 9, 'DbModifiedInstance' => 10, ),
|
||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbShowId' => 3, 'dbRecord' => 4, 'dbRebroadcast' => 5, 'dbOriginalShow' => 6, 'dbRecordedFile' => 7, 'dbTimeFilled' => 8, 'dbLastScheduled' => 9, 'dbModifiedInstance' => 10, ),
|
||||
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::SHOW_ID => 3, self::RECORD => 4, self::REBROADCAST => 5, self::INSTANCE_ID => 6, self::FILE_ID => 7, self::TIME_FILLED => 8, self::LAST_SCHEDULED => 9, self::MODIFIED_INSTANCE => 10, ),
|
||||
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'SHOW_ID' => 3, 'RECORD' => 4, 'REBROADCAST' => 5, 'INSTANCE_ID' => 6, 'FILE_ID' => 7, 'TIME_FILLED' => 8, 'LAST_SCHEDULED' => 9, 'MODIFIED_INSTANCE' => 10, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'show_id' => 3, 'record' => 4, 'rebroadcast' => 5, 'instance_id' => 6, 'file_id' => 7, 'time_filled' => 8, 'last_scheduled' => 9, 'modified_instance' => 10, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, )
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -178,6 +181,7 @@ abstract class BaseCcShowInstancesPeer {
|
|||
$criteria->addSelectColumn(CcShowInstancesPeer::INSTANCE_ID);
|
||||
$criteria->addSelectColumn(CcShowInstancesPeer::FILE_ID);
|
||||
$criteria->addSelectColumn(CcShowInstancesPeer::TIME_FILLED);
|
||||
$criteria->addSelectColumn(CcShowInstancesPeer::LAST_SCHEDULED);
|
||||
$criteria->addSelectColumn(CcShowInstancesPeer::MODIFIED_INSTANCE);
|
||||
} else {
|
||||
$criteria->addSelectColumn($alias . '.ID');
|
||||
|
@ -189,6 +193,7 @@ abstract class BaseCcShowInstancesPeer {
|
|||
$criteria->addSelectColumn($alias . '.INSTANCE_ID');
|
||||
$criteria->addSelectColumn($alias . '.FILE_ID');
|
||||
$criteria->addSelectColumn($alias . '.TIME_FILLED');
|
||||
$criteria->addSelectColumn($alias . '.LAST_SCHEDULED');
|
||||
$criteria->addSelectColumn($alias . '.MODIFIED_INSTANCE');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
* @method CcShowInstancesQuery orderByDbOriginalShow($order = Criteria::ASC) Order by the instance_id column
|
||||
* @method CcShowInstancesQuery orderByDbRecordedFile($order = Criteria::ASC) Order by the file_id column
|
||||
* @method CcShowInstancesQuery orderByDbTimeFilled($order = Criteria::ASC) Order by the time_filled column
|
||||
* @method CcShowInstancesQuery orderByDbLastScheduled($order = Criteria::ASC) Order by the last_scheduled column
|
||||
* @method CcShowInstancesQuery orderByDbModifiedInstance($order = Criteria::ASC) Order by the modified_instance column
|
||||
*
|
||||
* @method CcShowInstancesQuery groupByDbId() Group by the id column
|
||||
|
@ -26,6 +27,7 @@
|
|||
* @method CcShowInstancesQuery groupByDbOriginalShow() Group by the instance_id column
|
||||
* @method CcShowInstancesQuery groupByDbRecordedFile() Group by the file_id column
|
||||
* @method CcShowInstancesQuery groupByDbTimeFilled() Group by the time_filled column
|
||||
* @method CcShowInstancesQuery groupByDbLastScheduled() Group by the last_scheduled column
|
||||
* @method CcShowInstancesQuery groupByDbModifiedInstance() Group by the modified_instance column
|
||||
*
|
||||
* @method CcShowInstancesQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
|
@ -64,6 +66,7 @@
|
|||
* @method CcShowInstances findOneByDbOriginalShow(int $instance_id) Return the first CcShowInstances filtered by the instance_id column
|
||||
* @method CcShowInstances findOneByDbRecordedFile(int $file_id) Return the first CcShowInstances filtered by the file_id column
|
||||
* @method CcShowInstances findOneByDbTimeFilled(string $time_filled) Return the first CcShowInstances filtered by the time_filled column
|
||||
* @method CcShowInstances findOneByDbLastScheduled(string $last_scheduled) Return the first CcShowInstances filtered by the last_scheduled column
|
||||
* @method CcShowInstances findOneByDbModifiedInstance(boolean $modified_instance) Return the first CcShowInstances filtered by the modified_instance column
|
||||
*
|
||||
* @method array findByDbId(int $id) Return CcShowInstances objects filtered by the id column
|
||||
|
@ -75,6 +78,7 @@
|
|||
* @method array findByDbOriginalShow(int $instance_id) Return CcShowInstances objects filtered by the instance_id column
|
||||
* @method array findByDbRecordedFile(int $file_id) Return CcShowInstances objects filtered by the file_id column
|
||||
* @method array findByDbTimeFilled(string $time_filled) Return CcShowInstances objects filtered by the time_filled column
|
||||
* @method array findByDbLastScheduled(string $last_scheduled) Return CcShowInstances objects filtered by the last_scheduled column
|
||||
* @method array findByDbModifiedInstance(boolean $modified_instance) Return CcShowInstances objects filtered by the modified_instance column
|
||||
*
|
||||
* @package propel.generator.airtime.om
|
||||
|
@ -422,22 +426,44 @@ abstract class BaseCcShowInstancesQuery extends ModelCriteria
|
|||
/**
|
||||
* Filter the query on the time_filled column
|
||||
*
|
||||
* @param string|array $dbTimeFilled The value to use as filter.
|
||||
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
|
||||
* @param string $dbTimeFilled The value to use as filter.
|
||||
* Accepts wildcards (* and % trigger a LIKE)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return CcShowInstancesQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByDbTimeFilled($dbTimeFilled = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($dbTimeFilled)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $dbTimeFilled)) {
|
||||
$dbTimeFilled = str_replace('*', '%', $dbTimeFilled);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
return $this->addUsingAlias(CcShowInstancesPeer::TIME_FILLED, $dbTimeFilled, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the last_scheduled column
|
||||
*
|
||||
* @param string|array $dbLastScheduled The value to use as filter.
|
||||
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return CcShowInstancesQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByDbLastScheduled($dbLastScheduled = null, $comparison = null)
|
||||
{
|
||||
if (is_array($dbLastScheduled)) {
|
||||
$useMinMax = false;
|
||||
if (isset($dbTimeFilled['min'])) {
|
||||
$this->addUsingAlias(CcShowInstancesPeer::TIME_FILLED, $dbTimeFilled['min'], Criteria::GREATER_EQUAL);
|
||||
if (isset($dbLastScheduled['min'])) {
|
||||
$this->addUsingAlias(CcShowInstancesPeer::LAST_SCHEDULED, $dbLastScheduled['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($dbTimeFilled['max'])) {
|
||||
$this->addUsingAlias(CcShowInstancesPeer::TIME_FILLED, $dbTimeFilled['max'], Criteria::LESS_EQUAL);
|
||||
if (isset($dbLastScheduled['max'])) {
|
||||
$this->addUsingAlias(CcShowInstancesPeer::LAST_SCHEDULED, $dbLastScheduled['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
|
@ -447,7 +473,7 @@ abstract class BaseCcShowInstancesQuery extends ModelCriteria
|
|||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
return $this->addUsingAlias(CcShowInstancesPeer::TIME_FILLED, $dbTimeFilled, $comparison);
|
||||
return $this->addUsingAlias(CcShowInstancesPeer::LAST_SCHEDULED, $dbLastScheduled, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
$path = dirname(__FILE__).'/../../../library/pear';
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
|
||||
$WHITE_SCREEN_OF_DEATH = false;
|
||||
|
||||
|
|
16
airtime_mvc/application/views/scripts/form/showbuilder.phtml
Normal file
16
airtime_mvc/application/views/scripts/form/showbuilder.phtml
Normal file
|
@ -0,0 +1,16 @@
|
|||
<div class="sb-timerange">
|
||||
<?php echo $this->element->getElement('sb_date_start') ?>
|
||||
<?php echo $this->element->getElement('sb_time_start') ?>
|
||||
<?php echo $this->element->getElement('sb_date_end') ?>
|
||||
<?php echo $this->element->getElement('sb_time_end') ?>
|
||||
<input type="button" id="sb_submit" class="ui-button ui-state-default" value="GO"></input>
|
||||
</div>
|
||||
<div class="sb-advanced-options">
|
||||
<label><?php echo $this->element->getElement('sb_show_filter')->getLabel() ?></label>
|
||||
<?php echo $this->element->getElement('sb_show_filter') ?>
|
||||
|
||||
<?php if ($this->element->getElement('sb_my_shows')):?>
|
||||
<label><?php echo $this->element->getElement('sb_my_shows')->getLabel(); ?></label>
|
||||
<?php echo $this->element->getElement('sb_my_shows'); ?>
|
||||
<?php endif;?>
|
||||
</div>
|
|
@ -3,7 +3,5 @@
|
|||
</ul>
|
||||
<div id="simpleSearch">
|
||||
<div id="import_status" style="visibility:hidden">File import in progress...</div>
|
||||
<table id="library_display" cellpadding="0" cellspacing="0" class="datatable">
|
||||
|
||||
</table>
|
||||
<table id="library_display" cellpadding="0" cellspacing="0" class="datatable"></table>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,2 @@
|
|||
<input type="text" id="show_builder_datepicker_start" class="input_text"></input>
|
||||
<input type="text" id="show_builder_timepicker_start" class="input_text"></input>
|
||||
<input type="text" id="show_builder_datepicker_end" class="input_text"></input>
|
||||
<input type="text" id="show_builder_timepicker_end" class="input_text"></input>
|
||||
<input type="button" id="show_builder_timerange_button" class="ui-button ui-state-default" value="GO"></input>
|
||||
<?php echo $this->sb_form; ?>
|
||||
<table id="show_builder_table" cellpadding="0" cellspacing="0" class="datatable"></table>
|
||||
|
|
|
@ -156,7 +156,8 @@
|
|||
<column name="rebroadcast" phpName="DbRebroadcast" type="TINYINT" required="false" defaultValue="0"/>
|
||||
<column name="instance_id" phpName="DbOriginalShow" type="INTEGER" required="false"/>
|
||||
<column name="file_id" phpName="DbRecordedFile" type="INTEGER" required="false"/>
|
||||
<column name="time_filled" phpName="DbTimeFilled" type="TIME" />
|
||||
<column name="time_filled" phpName="DbTimeFilled" type="VARCHAR" sqlType="interval" defaultValue="00:00:00" />
|
||||
<column name="last_scheduled" phpName="DbLastScheduled" type="TIMESTAMP" required="false"/>
|
||||
<!-- The purpose of the modified_instance column is to mark a show instance that was
|
||||
deleted when it was part of repeating show. This is useful because the way shows work,
|
||||
instances can be regenerated if we edit the show, which is unwanted behaviour. This column serves
|
||||
|
|
|
@ -202,7 +202,8 @@ CREATE TABLE "cc_show_instances"
|
|||
"rebroadcast" INT2 default 0,
|
||||
"instance_id" INTEGER,
|
||||
"file_id" INTEGER,
|
||||
"time_filled" TIME,
|
||||
"time_filled" interval default '00:00:00',
|
||||
"last_scheduled" TIMESTAMP,
|
||||
"modified_instance" BOOLEAN default 'f' NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,64 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Acl
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @see Zend_Acl
|
||||
*/
|
||||
require_once 'Zend/Acl.php';
|
||||
|
||||
|
||||
/**
|
||||
* @see Zend_Acl_Role_Interface
|
||||
*/
|
||||
require_once 'Zend/Acl/Role/Interface.php';
|
||||
|
||||
|
||||
/**
|
||||
* @see Zend_Acl_Resource_Interface
|
||||
*/
|
||||
require_once 'Zend/Acl/Resource/Interface.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Acl
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
interface Zend_Acl_Assert_Interface
|
||||
{
|
||||
/**
|
||||
* Returns true if and only if the assertion conditions are met
|
||||
*
|
||||
* This method is passed the ACL, Role, Resource, and privilege to which the authorization query applies. If the
|
||||
* $role, $resource, or $privilege parameters are null, it means that the query applies to all Roles, Resources, or
|
||||
* privileges, respectively.
|
||||
*
|
||||
* @param Zend_Acl $acl
|
||||
* @param Zend_Acl_Role_Interface $role
|
||||
* @param Zend_Acl_Resource_Interface $resource
|
||||
* @param string $privilege
|
||||
* @return boolean
|
||||
*/
|
||||
public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null,
|
||||
$privilege = null);
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Acl
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @see Zend_Exception
|
||||
*/
|
||||
require_once 'Zend/Exception.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Acl
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Acl_Exception extends Zend_Exception
|
||||
{}
|
|
@ -1,75 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Acl
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Resource.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @see Zend_Acl_Resource_Interface
|
||||
*/
|
||||
require_once 'Zend/Acl/Resource/Interface.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Acl
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Acl_Resource implements Zend_Acl_Resource_Interface
|
||||
{
|
||||
/**
|
||||
* Unique id of Resource
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_resourceId;
|
||||
|
||||
/**
|
||||
* Sets the Resource identifier
|
||||
*
|
||||
* @param string $resourceId
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($resourceId)
|
||||
{
|
||||
$this->_resourceId = (string) $resourceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Acl_Resource_Interface; returns the Resource identifier
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceId()
|
||||
{
|
||||
return $this->_resourceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Acl_Resource_Interface; returns the Resource identifier
|
||||
* Proxies to getResourceId()
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getResourceId();
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Acl
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Acl
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
interface Zend_Acl_Resource_Interface
|
||||
{
|
||||
/**
|
||||
* Returns the string identifier of the Resource
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceId();
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Acl
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Role.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @see Zend_Acl_Role_Interface
|
||||
*/
|
||||
require_once 'Zend/Acl/Role/Interface.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Acl
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Acl_Role implements Zend_Acl_Role_Interface
|
||||
{
|
||||
/**
|
||||
* Unique id of Role
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_roleId;
|
||||
|
||||
/**
|
||||
* Sets the Role identifier
|
||||
*
|
||||
* @param string $id
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($roleId)
|
||||
{
|
||||
$this->_roleId = (string) $roleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Acl_Role_Interface; returns the Role identifier
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRoleId()
|
||||
{
|
||||
return $this->_roleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Acl_Role_Interface; returns the Role identifier
|
||||
* Proxies to getRoleId()
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getRoleId();
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Acl
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Acl
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
interface Zend_Acl_Role_Interface
|
||||
{
|
||||
/**
|
||||
* Returns the string identifier of the Role
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRoleId();
|
||||
}
|
|
@ -1,271 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Acl
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Registry.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @see Zend_Acl_Role_Interface
|
||||
*/
|
||||
require_once 'Zend/Acl/Role/Interface.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Acl
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Acl_Role_Registry
|
||||
{
|
||||
/**
|
||||
* Internal Role registry data storage
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_roles = array();
|
||||
|
||||
/**
|
||||
* Adds a Role having an identifier unique to the registry
|
||||
*
|
||||
* The $parents parameter may be a reference to, or the string identifier for,
|
||||
* a Role existing in the registry, or $parents may be passed as an array of
|
||||
* these - mixing string identifiers and objects is ok - to indicate the Roles
|
||||
* from which the newly added Role will directly inherit.
|
||||
*
|
||||
* In order to resolve potential ambiguities with conflicting rules inherited
|
||||
* from different parents, the most recently added parent takes precedence over
|
||||
* parents that were previously added. In other words, the first parent added
|
||||
* will have the least priority, and the last parent added will have the
|
||||
* highest priority.
|
||||
*
|
||||
* @param Zend_Acl_Role_Interface $role
|
||||
* @param Zend_Acl_Role_Interface|string|array $parents
|
||||
* @throws Zend_Acl_Role_Registry_Exception
|
||||
* @return Zend_Acl_Role_Registry Provides a fluent interface
|
||||
*/
|
||||
public function add(Zend_Acl_Role_Interface $role, $parents = null)
|
||||
{
|
||||
$roleId = $role->getRoleId();
|
||||
|
||||
if ($this->has($roleId)) {
|
||||
/**
|
||||
* @see Zend_Acl_Role_Registry_Exception
|
||||
*/
|
||||
require_once 'Zend/Acl/Role/Registry/Exception.php';
|
||||
throw new Zend_Acl_Role_Registry_Exception("Role id '$roleId' already exists in the registry");
|
||||
}
|
||||
|
||||
$roleParents = array();
|
||||
|
||||
if (null !== $parents) {
|
||||
if (!is_array($parents)) {
|
||||
$parents = array($parents);
|
||||
}
|
||||
/**
|
||||
* @see Zend_Acl_Role_Registry_Exception
|
||||
*/
|
||||
require_once 'Zend/Acl/Role/Registry/Exception.php';
|
||||
foreach ($parents as $parent) {
|
||||
try {
|
||||
if ($parent instanceof Zend_Acl_Role_Interface) {
|
||||
$roleParentId = $parent->getRoleId();
|
||||
} else {
|
||||
$roleParentId = $parent;
|
||||
}
|
||||
$roleParent = $this->get($roleParentId);
|
||||
} catch (Zend_Acl_Role_Registry_Exception $e) {
|
||||
throw new Zend_Acl_Role_Registry_Exception("Parent Role id '$roleParentId' does not exist", 0, $e);
|
||||
}
|
||||
$roleParents[$roleParentId] = $roleParent;
|
||||
$this->_roles[$roleParentId]['children'][$roleId] = $role;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_roles[$roleId] = array(
|
||||
'instance' => $role,
|
||||
'parents' => $roleParents,
|
||||
'children' => array()
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the identified Role
|
||||
*
|
||||
* The $role parameter can either be a Role or a Role identifier.
|
||||
*
|
||||
* @param Zend_Acl_Role_Interface|string $role
|
||||
* @throws Zend_Acl_Role_Registry_Exception
|
||||
* @return Zend_Acl_Role_Interface
|
||||
*/
|
||||
public function get($role)
|
||||
{
|
||||
if ($role instanceof Zend_Acl_Role_Interface) {
|
||||
$roleId = $role->getRoleId();
|
||||
} else {
|
||||
$roleId = (string) $role;
|
||||
}
|
||||
|
||||
if (!$this->has($role)) {
|
||||
/**
|
||||
* @see Zend_Acl_Role_Registry_Exception
|
||||
*/
|
||||
require_once 'Zend/Acl/Role/Registry/Exception.php';
|
||||
throw new Zend_Acl_Role_Registry_Exception("Role '$roleId' not found");
|
||||
}
|
||||
|
||||
return $this->_roles[$roleId]['instance'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if and only if the Role exists in the registry
|
||||
*
|
||||
* The $role parameter can either be a Role or a Role identifier.
|
||||
*
|
||||
* @param Zend_Acl_Role_Interface|string $role
|
||||
* @return boolean
|
||||
*/
|
||||
public function has($role)
|
||||
{
|
||||
if ($role instanceof Zend_Acl_Role_Interface) {
|
||||
$roleId = $role->getRoleId();
|
||||
} else {
|
||||
$roleId = (string) $role;
|
||||
}
|
||||
|
||||
return isset($this->_roles[$roleId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of an existing Role's parents
|
||||
*
|
||||
* The array keys are the identifiers of the parent Roles, and the values are
|
||||
* the parent Role instances. The parent Roles are ordered in this array by
|
||||
* ascending priority. The highest priority parent Role, last in the array,
|
||||
* corresponds with the parent Role most recently added.
|
||||
*
|
||||
* If the Role does not have any parents, then an empty array is returned.
|
||||
*
|
||||
* @param Zend_Acl_Role_Interface|string $role
|
||||
* @uses Zend_Acl_Role_Registry::get()
|
||||
* @return array
|
||||
*/
|
||||
public function getParents($role)
|
||||
{
|
||||
$roleId = $this->get($role)->getRoleId();
|
||||
|
||||
return $this->_roles[$roleId]['parents'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if and only if $role inherits from $inherit
|
||||
*
|
||||
* Both parameters may be either a Role or a Role identifier. If
|
||||
* $onlyParents is true, then $role must inherit directly from
|
||||
* $inherit in order to return true. By default, this method looks
|
||||
* through the entire inheritance DAG to determine whether $role
|
||||
* inherits from $inherit through its ancestor Roles.
|
||||
*
|
||||
* @param Zend_Acl_Role_Interface|string $role
|
||||
* @param Zend_Acl_Role_Interface|string $inherit
|
||||
* @param boolean $onlyParents
|
||||
* @throws Zend_Acl_Role_Registry_Exception
|
||||
* @return boolean
|
||||
*/
|
||||
public function inherits($role, $inherit, $onlyParents = false)
|
||||
{
|
||||
/**
|
||||
* @see Zend_Acl_Role_Registry_Exception
|
||||
*/
|
||||
require_once 'Zend/Acl/Role/Registry/Exception.php';
|
||||
try {
|
||||
$roleId = $this->get($role)->getRoleId();
|
||||
$inheritId = $this->get($inherit)->getRoleId();
|
||||
} catch (Zend_Acl_Role_Registry_Exception $e) {
|
||||
throw new Zend_Acl_Role_Registry_Exception($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
|
||||
$inherits = isset($this->_roles[$roleId]['parents'][$inheritId]);
|
||||
|
||||
if ($inherits || $onlyParents) {
|
||||
return $inherits;
|
||||
}
|
||||
|
||||
foreach ($this->_roles[$roleId]['parents'] as $parentId => $parent) {
|
||||
if ($this->inherits($parentId, $inheritId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the Role from the registry
|
||||
*
|
||||
* The $role parameter can either be a Role or a Role identifier.
|
||||
*
|
||||
* @param Zend_Acl_Role_Interface|string $role
|
||||
* @throws Zend_Acl_Role_Registry_Exception
|
||||
* @return Zend_Acl_Role_Registry Provides a fluent interface
|
||||
*/
|
||||
public function remove($role)
|
||||
{
|
||||
/**
|
||||
* @see Zend_Acl_Role_Registry_Exception
|
||||
*/
|
||||
require_once 'Zend/Acl/Role/Registry/Exception.php';
|
||||
try {
|
||||
$roleId = $this->get($role)->getRoleId();
|
||||
} catch (Zend_Acl_Role_Registry_Exception $e) {
|
||||
throw new Zend_Acl_Role_Registry_Exception($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
|
||||
foreach ($this->_roles[$roleId]['children'] as $childId => $child) {
|
||||
unset($this->_roles[$childId]['parents'][$roleId]);
|
||||
}
|
||||
foreach ($this->_roles[$roleId]['parents'] as $parentId => $parent) {
|
||||
unset($this->_roles[$parentId]['children'][$roleId]);
|
||||
}
|
||||
|
||||
unset($this->_roles[$roleId]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all Roles from the registry
|
||||
*
|
||||
* @return Zend_Acl_Role_Registry Provides a fluent interface
|
||||
*/
|
||||
public function removeAll()
|
||||
{
|
||||
$this->_roles = array();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRoles()
|
||||
{
|
||||
return $this->_roles;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Acl
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @see Zend_Acl_Exception
|
||||
*/
|
||||
require_once 'Zend/Acl/Exception.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Acl
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Acl_Role_Registry_Exception extends Zend_Acl_Exception
|
||||
{}
|
|
@ -1,133 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Auth.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/** @see Zend_Amf_Auth_Abstract */
|
||||
require_once 'Zend/Amf/Auth/Abstract.php';
|
||||
|
||||
/** @see Zend_Acl */
|
||||
require_once 'Zend/Acl.php';
|
||||
|
||||
/** @see Zend_Auth_Result */
|
||||
require_once 'Zend/Auth/Result.php';
|
||||
|
||||
/**
|
||||
* This class implements authentication against XML file with roles for Flex Builder.
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Adobe
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Adobe_Auth extends Zend_Amf_Auth_Abstract
|
||||
{
|
||||
|
||||
/**
|
||||
* ACL for authorization
|
||||
*
|
||||
* @var Zend_Acl
|
||||
*/
|
||||
protected $_acl;
|
||||
|
||||
/**
|
||||
* Username/password array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_users = array();
|
||||
|
||||
/**
|
||||
* Create auth adapter
|
||||
*
|
||||
* @param string $rolefile File containing XML with users and roles
|
||||
*/
|
||||
public function __construct($rolefile)
|
||||
{
|
||||
$this->_acl = new Zend_Acl();
|
||||
$xml = simplexml_load_file($rolefile);
|
||||
/*
|
||||
Roles file format:
|
||||
<roles>
|
||||
<role id=”admin”>
|
||||
<user name=”user1” password=”pwd”/>
|
||||
</role>
|
||||
<role id=”hr”>
|
||||
<user name=”user2” password=”pwd2”/>
|
||||
</role>
|
||||
</roles>
|
||||
*/
|
||||
foreach($xml->role as $role) {
|
||||
$this->_acl->addRole(new Zend_Acl_Role((string)$role["id"]));
|
||||
foreach($role->user as $user) {
|
||||
$this->_users[(string)$user["name"]] = array("password" => (string)$user["password"],
|
||||
"role" => (string)$role["id"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ACL with roles from XML file
|
||||
*
|
||||
* @return Zend_Acl
|
||||
*/
|
||||
public function getAcl()
|
||||
{
|
||||
return $this->_acl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform authentication
|
||||
*
|
||||
* @throws Zend_Auth_Adapter_Exception
|
||||
* @return Zend_Auth_Result
|
||||
* @see Zend_Auth_Adapter_Interface#authenticate()
|
||||
*/
|
||||
public function authenticate()
|
||||
{
|
||||
if (empty($this->_username) ||
|
||||
empty($this->_password)) {
|
||||
/**
|
||||
* @see Zend_Auth_Adapter_Exception
|
||||
*/
|
||||
require_once 'Zend/Auth/Adapter/Exception.php';
|
||||
throw new Zend_Auth_Adapter_Exception('Username/password should be set');
|
||||
}
|
||||
|
||||
if(!isset($this->_users[$this->_username])) {
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND,
|
||||
null,
|
||||
array('Username not found')
|
||||
);
|
||||
}
|
||||
|
||||
$user = $this->_users[$this->_username];
|
||||
if($user["password"] != $this->_password) {
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID,
|
||||
null,
|
||||
array('Authentication failed')
|
||||
);
|
||||
}
|
||||
|
||||
$id = new stdClass();
|
||||
$id->role = $user["role"];
|
||||
$id->name = $this->_username;
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $id);
|
||||
}
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: DbInspector.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class implements authentication against XML file with roles for Flex Builder.
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Adobe
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Adobe_DbInspector
|
||||
{
|
||||
|
||||
/**
|
||||
* Connect to the database
|
||||
*
|
||||
* @param string $dbType Database adapter type for Zend_Db
|
||||
* @param array|object $dbDescription Adapter-specific connection settings
|
||||
* @return Zend_Db_Adapter_Abstract
|
||||
* @see Zend_Db::factory()
|
||||
*/
|
||||
protected function _connect($dbType, $dbDescription)
|
||||
{
|
||||
if(is_object($dbDescription)) {
|
||||
$dbDescription = get_object_vars($dbDescription);
|
||||
}
|
||||
return Zend_Db::factory($dbType, $dbDescription);
|
||||
}
|
||||
|
||||
/**
|
||||
* Describe database object.
|
||||
*
|
||||
* Usage example:
|
||||
* $inspector->describeTable('Pdo_Mysql',
|
||||
* array(
|
||||
* 'host' => '127.0.0.1',
|
||||
* 'username' => 'webuser',
|
||||
* 'password' => 'xxxxxxxx',
|
||||
* 'dbname' => 'test'
|
||||
* ),
|
||||
* 'mytable'
|
||||
* );
|
||||
*
|
||||
* @param string $dbType Database adapter type for Zend_Db
|
||||
* @param array|object $dbDescription Adapter-specific connection settings
|
||||
* @param string $tableName Table name
|
||||
* @return array Table description
|
||||
* @see Zend_Db::describeTable()
|
||||
* @see Zend_Db::factory()
|
||||
*/
|
||||
public function describeTable($dbType, $dbDescription, $tableName)
|
||||
{
|
||||
$db = $this->_connect($dbType, $dbDescription);
|
||||
return $db->describeTable($tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test database connection
|
||||
*
|
||||
* @param string $dbType Database adapter type for Zend_Db
|
||||
* @param array|object $dbDescription Adapter-specific connection settings
|
||||
* @return bool
|
||||
* @see Zend_Db::factory()
|
||||
*/
|
||||
public function connect($dbType, $dbDescription)
|
||||
{
|
||||
$db = $this->_connect($dbType, $dbDescription);
|
||||
$db->listTables();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of database tables
|
||||
*
|
||||
* @param string $dbType Database adapter type for Zend_Db
|
||||
* @param array|object $dbDescription Adapter-specific connection settings
|
||||
* @return array List of the tables
|
||||
*/
|
||||
public function getTables($dbType, $dbDescription)
|
||||
{
|
||||
$db = $this->_connect($dbType, $dbDescription);
|
||||
return $db->listTables();
|
||||
}
|
||||
}
|
|
@ -1,313 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Introspector.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/** @see Zend_Amf_Parse_TypeLoader */
|
||||
require_once 'Zend/Amf/Parse/TypeLoader.php';
|
||||
|
||||
/** @see Zend_Reflection_Class */
|
||||
require_once 'Zend/Reflection/Class.php';
|
||||
|
||||
/** @see Zend_Server_Reflection */
|
||||
require_once 'Zend/Server/Reflection.php';
|
||||
|
||||
/**
|
||||
* This class implements a service for generating AMF service descriptions as XML.
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Adobe
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Adobe_Introspector
|
||||
{
|
||||
/**
|
||||
* Options used:
|
||||
* - server: instance of Zend_Amf_Server to use
|
||||
* - directories: directories where class files may be looked up
|
||||
*
|
||||
* @var array Introspector options
|
||||
*/
|
||||
protected $_options;
|
||||
|
||||
/**
|
||||
* @var DOMElement DOM element to store types
|
||||
*/
|
||||
protected $_types;
|
||||
|
||||
/**
|
||||
* @var array Map of the known types
|
||||
*/
|
||||
protected $_typesMap = array();
|
||||
|
||||
/**
|
||||
* @var DOMDocument XML document to store data
|
||||
*/
|
||||
protected $_xml;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_xml = new DOMDocument('1.0', 'utf-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create XML definition on an AMF service class
|
||||
*
|
||||
* @param string $serviceClass Service class name
|
||||
* @param array $options invocation options
|
||||
* @return string XML with service class introspection
|
||||
*/
|
||||
public function introspect($serviceClass, $options = array())
|
||||
{
|
||||
$this->_options = $options;
|
||||
|
||||
if (strpbrk($serviceClass, '\\/<>')) {
|
||||
return $this->_returnError('Invalid service name');
|
||||
}
|
||||
|
||||
// Transform com.foo.Bar into com_foo_Bar
|
||||
$serviceClass = str_replace('.' , '_', $serviceClass);
|
||||
|
||||
// Introspect!
|
||||
if (!class_exists($serviceClass)) {
|
||||
require_once 'Zend/Loader.php';
|
||||
Zend_Loader::loadClass($serviceClass, $this->_getServicePath());
|
||||
}
|
||||
|
||||
$serv = $this->_xml->createElement('service-description');
|
||||
$serv->setAttribute('xmlns', 'http://ns.adobe.com/flex/service-description/2008');
|
||||
|
||||
$this->_types = $this->_xml->createElement('types');
|
||||
$this->_ops = $this->_xml->createElement('operations');
|
||||
|
||||
$r = Zend_Server_Reflection::reflectClass($serviceClass);
|
||||
$this->_addService($r, $this->_ops);
|
||||
|
||||
$serv->appendChild($this->_types);
|
||||
$serv->appendChild($this->_ops);
|
||||
$this->_xml->appendChild($serv);
|
||||
|
||||
return $this->_xml->saveXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* Authentication handler
|
||||
*
|
||||
* @param Zend_Acl $acl
|
||||
* @return unknown_type
|
||||
*/
|
||||
public function initAcl(Zend_Acl $acl)
|
||||
{
|
||||
return false; // we do not need auth for this class
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate map of public class attributes
|
||||
*
|
||||
* @param string $typename type name
|
||||
* @param DOMElement $typexml target XML element
|
||||
* @return void
|
||||
*/
|
||||
protected function _addClassAttributes($typename, DOMElement $typexml)
|
||||
{
|
||||
// Do not try to autoload here because _phpTypeToAS should
|
||||
// have already attempted to load this class
|
||||
if (!class_exists($typename, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$rc = new Zend_Reflection_Class($typename);
|
||||
foreach ($rc->getProperties() as $prop) {
|
||||
if (!$prop->isPublic()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$propxml = $this->_xml->createElement('property');
|
||||
$propxml->setAttribute('name', $prop->getName());
|
||||
|
||||
$type = $this->_registerType($this->_getPropertyType($prop));
|
||||
$propxml->setAttribute('type', $type);
|
||||
|
||||
$typexml->appendChild($propxml);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build XML service description from reflection class
|
||||
*
|
||||
* @param Zend_Server_Reflection_Class $refclass
|
||||
* @param DOMElement $target target XML element
|
||||
* @return void
|
||||
*/
|
||||
protected function _addService(Zend_Server_Reflection_Class $refclass, DOMElement $target)
|
||||
{
|
||||
foreach ($refclass->getMethods() as $method) {
|
||||
if (!$method->isPublic()
|
||||
|| $method->isConstructor()
|
||||
|| ('__' == substr($method->name, 0, 2))
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($method->getPrototypes() as $proto) {
|
||||
$op = $this->_xml->createElement('operation');
|
||||
$op->setAttribute('name', $method->getName());
|
||||
|
||||
$rettype = $this->_registerType($proto->getReturnType());
|
||||
$op->setAttribute('returnType', $rettype);
|
||||
|
||||
foreach ($proto->getParameters() as $param) {
|
||||
$arg = $this->_xml->createElement('argument');
|
||||
$arg->setAttribute('name', $param->getName());
|
||||
|
||||
$type = $param->getType();
|
||||
if ($type == 'mixed' && ($pclass = $param->getClass())) {
|
||||
$type = $pclass->getName();
|
||||
}
|
||||
|
||||
$ptype = $this->_registerType($type);
|
||||
$arg->setAttribute('type', $ptype);
|
||||
|
||||
if($param->isDefaultValueAvailable()) {
|
||||
$arg->setAttribute('defaultvalue', $param->getDefaultValue());
|
||||
}
|
||||
|
||||
$op->appendChild($arg);
|
||||
}
|
||||
|
||||
$target->appendChild($op);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract type of the property from DocBlock
|
||||
*
|
||||
* @param Zend_Reflection_Property $prop reflection property object
|
||||
* @return string Property type
|
||||
*/
|
||||
protected function _getPropertyType(Zend_Reflection_Property $prop)
|
||||
{
|
||||
$docBlock = $prop->getDocComment();
|
||||
|
||||
if (!$docBlock) {
|
||||
return 'Unknown';
|
||||
}
|
||||
|
||||
if (!$docBlock->hasTag('var')) {
|
||||
return 'Unknown';
|
||||
}
|
||||
|
||||
$tag = $docBlock->getTag('var');
|
||||
return trim($tag->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array of service directories
|
||||
*
|
||||
* @return array Service class directories
|
||||
*/
|
||||
protected function _getServicePath()
|
||||
{
|
||||
if (isset($this->_options['server'])) {
|
||||
return $this->_options['server']->getDirectory();
|
||||
}
|
||||
|
||||
if (isset($this->_options['directories'])) {
|
||||
return $this->_options['directories'];
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Map from PHP type name to AS type name
|
||||
*
|
||||
* @param string $typename PHP type name
|
||||
* @return string AS type name
|
||||
*/
|
||||
protected function _phpTypeToAS($typename)
|
||||
{
|
||||
if (class_exists($typename)) {
|
||||
$vars = get_class_vars($typename);
|
||||
|
||||
if (isset($vars['_explicitType'])) {
|
||||
return $vars['_explicitType'];
|
||||
}
|
||||
}
|
||||
|
||||
if (false !== ($asname = Zend_Amf_Parse_TypeLoader::getMappedClassName($typename))) {
|
||||
return $asname;
|
||||
}
|
||||
|
||||
return $typename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register new type on the system
|
||||
*
|
||||
* @param string $typename type name
|
||||
* @return string New type name
|
||||
*/
|
||||
protected function _registerType($typename)
|
||||
{
|
||||
// Known type - return its AS name
|
||||
if (isset($this->_typesMap[$typename])) {
|
||||
return $this->_typesMap[$typename];
|
||||
}
|
||||
|
||||
// Standard types
|
||||
if (in_array($typename, array('void', 'null', 'mixed', 'unknown_type'))) {
|
||||
return 'Unknown';
|
||||
}
|
||||
|
||||
if (in_array($typename, array('int', 'integer', 'bool', 'boolean', 'float', 'string', 'object', 'Unknown', 'stdClass', 'array'))) {
|
||||
return $typename;
|
||||
}
|
||||
|
||||
// Resolve and store AS name
|
||||
$asTypeName = $this->_phpTypeToAS($typename);
|
||||
$this->_typesMap[$typename] = $asTypeName;
|
||||
|
||||
// Create element for the name
|
||||
$typeEl = $this->_xml->createElement('type');
|
||||
$typeEl->setAttribute('name', $asTypeName);
|
||||
$this->_addClassAttributes($typename, $typeEl);
|
||||
$this->_types->appendChild($typeEl);
|
||||
|
||||
return $asTypeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return error with error message
|
||||
*
|
||||
* @param string $msg Error message
|
||||
* @return string
|
||||
*/
|
||||
protected function _returnError($msg)
|
||||
{
|
||||
return 'ERROR: $msg';
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/** @see Zend_Auth_Adapter_Interface */
|
||||
require_once 'Zend/Auth/Adapter/Interface.php';
|
||||
|
||||
/**
|
||||
* Base abstract class for AMF authentication implementation
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Auth
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Amf_Auth_Abstract implements Zend_Auth_Adapter_Interface
|
||||
{
|
||||
protected $_username;
|
||||
protected $_password;
|
||||
|
||||
public function setCredentials($username, $password) {
|
||||
$this->_username = $username;
|
||||
$this->_password = $password;
|
||||
}
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Constants.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* The following constants are used throughout serialization and
|
||||
* deserialization to detect the AMF marker and encoding types.
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
final class Zend_Amf_Constants
|
||||
{
|
||||
const AMF0_NUMBER = 0x00;
|
||||
const AMF0_BOOLEAN = 0x01;
|
||||
const AMF0_STRING = 0x02;
|
||||
const AMF0_OBJECT = 0x03;
|
||||
const AMF0_MOVIECLIP = 0x04;
|
||||
const AMF0_NULL = 0x05;
|
||||
const AMF0_UNDEFINED = 0x06;
|
||||
const AMF0_REFERENCE = 0x07;
|
||||
const AMF0_MIXEDARRAY = 0x08;
|
||||
const AMF0_OBJECTTERM = 0x09;
|
||||
const AMF0_ARRAY = 0x0a;
|
||||
const AMF0_DATE = 0x0b;
|
||||
const AMF0_LONGSTRING = 0x0c;
|
||||
const AMF0_UNSUPPORTED = 0x0e;
|
||||
const AMF0_XML = 0x0f;
|
||||
const AMF0_TYPEDOBJECT = 0x10;
|
||||
const AMF0_AMF3 = 0x11;
|
||||
const AMF0_OBJECT_ENCODING = 0x00;
|
||||
|
||||
const AMF3_UNDEFINED = 0x00;
|
||||
const AMF3_NULL = 0x01;
|
||||
const AMF3_BOOLEAN_FALSE = 0x02;
|
||||
const AMF3_BOOLEAN_TRUE = 0x03;
|
||||
const AMF3_INTEGER = 0x04;
|
||||
const AMF3_NUMBER = 0x05;
|
||||
const AMF3_STRING = 0x06;
|
||||
const AMF3_XML = 0x07;
|
||||
const AMF3_DATE = 0x08;
|
||||
const AMF3_ARRAY = 0x09;
|
||||
const AMF3_OBJECT = 0x0A;
|
||||
const AMF3_XMLSTRING = 0x0B;
|
||||
const AMF3_BYTEARRAY = 0x0C;
|
||||
const AMF3_OBJECT_ENCODING = 0x03;
|
||||
|
||||
// Object encodings for AMF3 object types
|
||||
const ET_PROPLIST = 0x00;
|
||||
const ET_EXTERNAL = 0x01;
|
||||
const ET_DYNAMIC = 0x02;
|
||||
const ET_PROXY = 0x03;
|
||||
|
||||
const FMS_OBJECT_ENCODING = 0x01;
|
||||
|
||||
/**
|
||||
* Special content length value that indicates "unknown" content length
|
||||
* per AMF Specification
|
||||
*/
|
||||
const UNKNOWN_CONTENT_LENGTH = -1;
|
||||
const URL_APPEND_HEADER = 'AppendToGatewayUrl';
|
||||
const RESULT_METHOD = '/onResult';
|
||||
const STATUS_METHOD = '/onStatus';
|
||||
const CREDENTIALS_HEADER = 'Credentials';
|
||||
const PERSISTENT_HEADER = 'RequestPersistentHeader';
|
||||
const DESCRIBE_HEADER = 'DescribeService';
|
||||
|
||||
const GUEST_ROLE = 'anonymous';
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Exception
|
||||
*/
|
||||
require_once 'Zend/Exception.php';
|
||||
|
||||
/**
|
||||
* @package Zend_Amf
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Exception extends Zend_Exception
|
||||
{
|
||||
}
|
|
@ -1,306 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse_Amf0
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Deserializer.php 21210 2010-02-27 10:37:39Z yoshida@zend.co.jp $
|
||||
*/
|
||||
|
||||
/** Zend_Amf_Constants */
|
||||
require_once 'Zend/Amf/Constants.php';
|
||||
|
||||
/** @see Zend_Amf_Parse_Deserializer */
|
||||
require_once 'Zend/Amf/Parse/Deserializer.php';
|
||||
|
||||
/**
|
||||
* Read an AMF0 input stream and convert it into PHP data types
|
||||
*
|
||||
* @todo Implement Typed Object Class Mapping
|
||||
* @todo Class could be implemented as Factory Class with each data type it's own class
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse_Amf0
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Parse_Amf0_Deserializer extends Zend_Amf_Parse_Deserializer
|
||||
{
|
||||
/**
|
||||
* An array of objects used for recursively deserializing an object.
|
||||
* @var array
|
||||
*/
|
||||
protected $_reference = array();
|
||||
|
||||
/**
|
||||
* If AMF3 serialization occurs, update to AMF0 0x03
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_objectEncoding = Zend_Amf_Constants::AMF0_OBJECT_ENCODING;
|
||||
|
||||
/**
|
||||
* Read AMF markers and dispatch for deserialization
|
||||
*
|
||||
* Checks for AMF marker types and calls the appropriate methods
|
||||
* for deserializing those marker types. Markers are the data type of
|
||||
* the following value.
|
||||
*
|
||||
* @param integer $typeMarker
|
||||
* @return mixed whatever the data type is of the marker in php
|
||||
* @throws Zend_Amf_Exception for invalid type
|
||||
*/
|
||||
public function readTypeMarker($typeMarker = null)
|
||||
{
|
||||
if ($typeMarker === null) {
|
||||
$typeMarker = $this->_stream->readByte();
|
||||
}
|
||||
|
||||
switch($typeMarker) {
|
||||
// number
|
||||
case Zend_Amf_Constants::AMF0_NUMBER:
|
||||
return $this->_stream->readDouble();
|
||||
|
||||
// boolean
|
||||
case Zend_Amf_Constants::AMF0_BOOLEAN:
|
||||
return (boolean) $this->_stream->readByte();
|
||||
|
||||
// string
|
||||
case Zend_Amf_Constants::AMF0_STRING:
|
||||
return $this->_stream->readUTF();
|
||||
|
||||
// object
|
||||
case Zend_Amf_Constants::AMF0_OBJECT:
|
||||
return $this->readObject();
|
||||
|
||||
// null
|
||||
case Zend_Amf_Constants::AMF0_NULL:
|
||||
return null;
|
||||
|
||||
// undefined
|
||||
case Zend_Amf_Constants::AMF0_UNDEFINED:
|
||||
return null;
|
||||
|
||||
// Circular references are returned here
|
||||
case Zend_Amf_Constants::AMF0_REFERENCE:
|
||||
return $this->readReference();
|
||||
|
||||
// mixed array with numeric and string keys
|
||||
case Zend_Amf_Constants::AMF0_MIXEDARRAY:
|
||||
return $this->readMixedArray();
|
||||
|
||||
// array
|
||||
case Zend_Amf_Constants::AMF0_ARRAY:
|
||||
return $this->readArray();
|
||||
|
||||
// date
|
||||
case Zend_Amf_Constants::AMF0_DATE:
|
||||
return $this->readDate();
|
||||
|
||||
// longString strlen(string) > 2^16
|
||||
case Zend_Amf_Constants::AMF0_LONGSTRING:
|
||||
return $this->_stream->readLongUTF();
|
||||
|
||||
//internal AS object, not supported
|
||||
case Zend_Amf_Constants::AMF0_UNSUPPORTED:
|
||||
return null;
|
||||
|
||||
// XML
|
||||
case Zend_Amf_Constants::AMF0_XML:
|
||||
return $this->readXmlString();
|
||||
|
||||
// typed object ie Custom Class
|
||||
case Zend_Amf_Constants::AMF0_TYPEDOBJECT:
|
||||
return $this->readTypedObject();
|
||||
|
||||
//AMF3-specific
|
||||
case Zend_Amf_Constants::AMF0_AMF3:
|
||||
return $this->readAmf3TypeMarker();
|
||||
|
||||
default:
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Unsupported marker type: ' . $typeMarker);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read AMF objects and convert to PHP objects
|
||||
*
|
||||
* Read the name value pair objects form the php message and convert them to
|
||||
* a php object class.
|
||||
*
|
||||
* Called when the marker type is 3.
|
||||
*
|
||||
* @param array|null $object
|
||||
* @return object
|
||||
*/
|
||||
public function readObject($object = null)
|
||||
{
|
||||
if ($object === null) {
|
||||
$object = array();
|
||||
}
|
||||
|
||||
while (true) {
|
||||
$key = $this->_stream->readUTF();
|
||||
$typeMarker = $this->_stream->readByte();
|
||||
if ($typeMarker != Zend_Amf_Constants::AMF0_OBJECTTERM ){
|
||||
//Recursivly call readTypeMarker to get the types of properties in the object
|
||||
$object[$key] = $this->readTypeMarker($typeMarker);
|
||||
} else {
|
||||
//encountered AMF object terminator
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->_reference[] = $object;
|
||||
return (object) $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read reference objects
|
||||
*
|
||||
* Used to gain access to the private array of reference objects.
|
||||
* Called when marker type is 7.
|
||||
*
|
||||
* @return object
|
||||
* @throws Zend_Amf_Exception for invalid reference keys
|
||||
*/
|
||||
public function readReference()
|
||||
{
|
||||
$key = $this->_stream->readInt();
|
||||
if (!array_key_exists($key, $this->_reference)) {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Invalid reference key: '. $key);
|
||||
}
|
||||
return $this->_reference[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an array with numeric and string indexes.
|
||||
*
|
||||
* Called when marker type is 8
|
||||
*
|
||||
* @todo As of Flash Player 9 there is not support for mixed typed arrays
|
||||
* so we handle this as an object. With the introduction of vectors
|
||||
* in Flash Player 10 this may need to be reconsidered.
|
||||
* @return array
|
||||
*/
|
||||
public function readMixedArray()
|
||||
{
|
||||
$length = $this->_stream->readLong();
|
||||
return $this->readObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts numerically indexed actiosncript arrays into php arrays.
|
||||
*
|
||||
* Called when marker type is 10
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function readArray()
|
||||
{
|
||||
$length = $this->_stream->readLong();
|
||||
$array = array();
|
||||
while ($length--) {
|
||||
$array[] = $this->readTypeMarker();
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert AS Date to Zend_Date
|
||||
*
|
||||
* @return Zend_Date
|
||||
*/
|
||||
public function readDate()
|
||||
{
|
||||
// get the unix time stamp. Not sure why ActionScript does not use
|
||||
// milliseconds
|
||||
$timestamp = floor($this->_stream->readDouble() / 1000);
|
||||
|
||||
// The timezone offset is never returned to the server; it is always 0,
|
||||
// so read and ignore.
|
||||
$offset = $this->_stream->readInt();
|
||||
|
||||
require_once 'Zend/Date.php';
|
||||
$date = new Zend_Date($timestamp);
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert XML to SimpleXml
|
||||
* If user wants DomDocument they can use dom_import_simplexml
|
||||
*
|
||||
* @return SimpleXml Object
|
||||
*/
|
||||
public function readXmlString()
|
||||
{
|
||||
$string = $this->_stream->readLongUTF();
|
||||
return simplexml_load_string($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Class that is to be mapped to a server class.
|
||||
*
|
||||
* Commonly used for Value Objects on the server
|
||||
*
|
||||
* @todo implement Typed Class mapping
|
||||
* @return object|array
|
||||
* @throws Zend_Amf_Exception if unable to load type
|
||||
*/
|
||||
public function readTypedObject()
|
||||
{
|
||||
require_once 'Zend/Amf/Parse/TypeLoader.php';
|
||||
// get the remote class name
|
||||
$className = $this->_stream->readUTF();
|
||||
$loader = Zend_Amf_Parse_TypeLoader::loadType($className);
|
||||
$returnObject = new $loader();
|
||||
$properties = get_object_vars($this->readObject());
|
||||
foreach($properties as $key=>$value) {
|
||||
if($key) {
|
||||
$returnObject->$key = $value;
|
||||
}
|
||||
}
|
||||
if($returnObject instanceof Zend_Amf_Value_Messaging_ArrayCollection) {
|
||||
$returnObject = get_object_vars($returnObject);
|
||||
}
|
||||
return $returnObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* AMF3 data type encountered load AMF3 Deserializer to handle
|
||||
* type markers.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function readAmf3TypeMarker()
|
||||
{
|
||||
require_once 'Zend/Amf/Parse/Amf3/Deserializer.php';
|
||||
$deserializer = new Zend_Amf_Parse_Amf3_Deserializer($this->_stream);
|
||||
$this->_objectEncoding = Zend_Amf_Constants::AMF3_OBJECT_ENCODING;
|
||||
return $deserializer->readTypeMarker();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the object encoding to check if an AMF3 object
|
||||
* is going to be return.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getObjectEncoding()
|
||||
{
|
||||
return $this->_objectEncoding;
|
||||
}
|
||||
}
|
|
@ -1,349 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse_Amf0
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Serializer.php 21210 2010-02-27 10:37:39Z yoshida@zend.co.jp $
|
||||
*/
|
||||
|
||||
/** Zend_Amf_Constants */
|
||||
require_once 'Zend/Amf/Constants.php';
|
||||
|
||||
/** @see Zend_Amf_Parse_Serializer */
|
||||
require_once 'Zend/Amf/Parse/Serializer.php';
|
||||
|
||||
/**
|
||||
* Serializer PHP misc types back to there corresponding AMF0 Type Marker.
|
||||
*
|
||||
* @uses Zend_Amf_Parse_Serializer
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse_Amf0
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Parse_Amf0_Serializer extends Zend_Amf_Parse_Serializer
|
||||
{
|
||||
/**
|
||||
* @var string Name of the class to be returned
|
||||
*/
|
||||
protected $_className = '';
|
||||
|
||||
/**
|
||||
* An array of reference objects
|
||||
* @var array
|
||||
*/
|
||||
protected $_referenceObjects = array();
|
||||
|
||||
/**
|
||||
* Determine type and serialize accordingly
|
||||
*
|
||||
* Checks to see if the type was declared and then either
|
||||
* auto negotiates the type or relies on the user defined markerType to
|
||||
* serialize the data into amf
|
||||
*
|
||||
* @param misc $data
|
||||
* @param misc $markerType
|
||||
* @return Zend_Amf_Parse_Amf0_Serializer
|
||||
* @throws Zend_Amf_Exception for unrecognized types or data
|
||||
*/
|
||||
public function writeTypeMarker($data, $markerType = null)
|
||||
{
|
||||
if (null !== $markerType) {
|
||||
//try to reference the given object
|
||||
if( !$this->writeObjectReference($data, $markerType) ) {
|
||||
|
||||
// Write the Type Marker to denote the following action script data type
|
||||
$this->_stream->writeByte($markerType);
|
||||
switch($markerType) {
|
||||
case Zend_Amf_Constants::AMF0_NUMBER:
|
||||
$this->_stream->writeDouble($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_BOOLEAN:
|
||||
$this->_stream->writeByte($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_STRING:
|
||||
$this->_stream->writeUTF($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_OBJECT:
|
||||
$this->writeObject($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_NULL:
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_REFERENCE:
|
||||
$this->_stream->writeInt($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_MIXEDARRAY:
|
||||
// Write length of numeric keys as zero.
|
||||
$this->_stream->writeLong(0);
|
||||
$this->writeObject($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_ARRAY:
|
||||
$this->writeArray($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_DATE:
|
||||
$this->writeDate($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_LONGSTRING:
|
||||
$this->_stream->writeLongUTF($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_TYPEDOBJECT:
|
||||
$this->writeTypedObject($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_AMF3:
|
||||
$this->writeAmf3TypeMarker($data);
|
||||
break;
|
||||
default:
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception("Unknown Type Marker: " . $markerType);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(is_resource($data)) {
|
||||
$data = Zend_Amf_Parse_TypeLoader::handleResource($data);
|
||||
}
|
||||
switch (true) {
|
||||
case (is_int($data) || is_float($data)):
|
||||
$markerType = Zend_Amf_Constants::AMF0_NUMBER;
|
||||
break;
|
||||
case (is_bool($data)):
|
||||
$markerType = Zend_Amf_Constants::AMF0_BOOLEAN;
|
||||
break;
|
||||
case (is_string($data) && (strlen($data) > 65536)):
|
||||
$markerType = Zend_Amf_Constants::AMF0_LONGSTRING;
|
||||
break;
|
||||
case (is_string($data)):
|
||||
$markerType = Zend_Amf_Constants::AMF0_STRING;
|
||||
break;
|
||||
case (is_object($data)):
|
||||
if (($data instanceof DateTime) || ($data instanceof Zend_Date)) {
|
||||
$markerType = Zend_Amf_Constants::AMF0_DATE;
|
||||
} else {
|
||||
|
||||
if($className = $this->getClassName($data)){
|
||||
//Object is a Typed object set classname
|
||||
$markerType = Zend_Amf_Constants::AMF0_TYPEDOBJECT;
|
||||
$this->_className = $className;
|
||||
} else {
|
||||
// Object is a generic classname
|
||||
$markerType = Zend_Amf_Constants::AMF0_OBJECT;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case (null === $data):
|
||||
$markerType = Zend_Amf_Constants::AMF0_NULL;
|
||||
break;
|
||||
case (is_array($data)):
|
||||
// check if it is an associative array
|
||||
$i = 0;
|
||||
foreach (array_keys($data) as $key) {
|
||||
// check if it contains non-integer keys
|
||||
if (!is_numeric($key) || intval($key) != $key) {
|
||||
$markerType = Zend_Amf_Constants::AMF0_OBJECT;
|
||||
break;
|
||||
// check if it is a sparse indexed array
|
||||
} else if ($key != $i) {
|
||||
$markerType = Zend_Amf_Constants::AMF0_MIXEDARRAY;
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
// Dealing with a standard numeric array
|
||||
if(!$markerType){
|
||||
$markerType = Zend_Amf_Constants::AMF0_ARRAY;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Unsupported data type: ' . gettype($data));
|
||||
}
|
||||
|
||||
$this->writeTypeMarker($data, $markerType);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given object is in the reference table, write the reference if it exists,
|
||||
* otherwise add the object to the reference table
|
||||
*
|
||||
* @param mixed $object object to check for reference
|
||||
* @param $markerType AMF type of the object to write
|
||||
* @return Boolean true, if the reference was written, false otherwise
|
||||
*/
|
||||
protected function writeObjectReference($object, $markerType){
|
||||
if( $markerType == Zend_Amf_Constants::AMF0_OBJECT ||
|
||||
$markerType == Zend_Amf_Constants::AMF0_MIXEDARRAY ||
|
||||
$markerType == Zend_Amf_Constants::AMF0_ARRAY ||
|
||||
$markerType == Zend_Amf_Constants::AMF0_TYPEDOBJECT ) {
|
||||
|
||||
$ref = array_search($object, $this->_referenceObjects,true);
|
||||
//handle object reference
|
||||
if($ref !== false){
|
||||
$this->writeTypeMarker($ref,Zend_Amf_Constants::AMF0_REFERENCE);
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->_referenceObjects[] = $object;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a PHP array with string or mixed keys.
|
||||
*
|
||||
* @param object $data
|
||||
* @return Zend_Amf_Parse_Amf0_Serializer
|
||||
*/
|
||||
public function writeObject($object)
|
||||
{
|
||||
// Loop each element and write the name of the property.
|
||||
foreach ($object as $key => $value) {
|
||||
// skip variables starting with an _ private transient
|
||||
if( $key[0] == "_") continue;
|
||||
$this->_stream->writeUTF($key);
|
||||
$this->writeTypeMarker($value);
|
||||
}
|
||||
|
||||
// Write the end object flag
|
||||
$this->_stream->writeInt(0);
|
||||
$this->_stream->writeByte(Zend_Amf_Constants::AMF0_OBJECTTERM);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a standard numeric array to the output stream. If a mixed array
|
||||
* is encountered call writeTypeMarker with mixed array.
|
||||
*
|
||||
* @param array $array
|
||||
* @return Zend_Amf_Parse_Amf0_Serializer
|
||||
*/
|
||||
public function writeArray($array)
|
||||
{
|
||||
$length = count($array);
|
||||
if (!$length < 0) {
|
||||
// write the length of the array
|
||||
$this->_stream->writeLong(0);
|
||||
} else {
|
||||
// Write the length of the numeric array
|
||||
$this->_stream->writeLong($length);
|
||||
for ($i=0; $i<$length; $i++) {
|
||||
$value = isset($array[$i]) ? $array[$i] : null;
|
||||
$this->writeTypeMarker($value);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the DateTime into an AMF Date
|
||||
*
|
||||
* @param DateTime|Zend_Date $data
|
||||
* @return Zend_Amf_Parse_Amf0_Serializer
|
||||
*/
|
||||
public function writeDate($data)
|
||||
{
|
||||
if ($data instanceof DateTime) {
|
||||
$dateString = $data->format('U');
|
||||
} elseif ($data instanceof Zend_Date) {
|
||||
$dateString = $data->toString('U');
|
||||
} else {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Invalid date specified; must be a DateTime or Zend_Date object');
|
||||
}
|
||||
$dateString *= 1000;
|
||||
|
||||
// Make the conversion and remove milliseconds.
|
||||
$this->_stream->writeDouble($dateString);
|
||||
|
||||
// Flash does not respect timezone but requires it.
|
||||
$this->_stream->writeInt(0);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a class mapped object to the output stream.
|
||||
*
|
||||
* @param object $data
|
||||
* @return Zend_Amf_Parse_Amf0_Serializer
|
||||
*/
|
||||
public function writeTypedObject($data)
|
||||
{
|
||||
$this->_stream->writeUTF($this->_className);
|
||||
$this->writeObject($data);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encountered and AMF3 Type Marker use AMF3 serializer. Once AMF3 is
|
||||
* encountered it will not return to AMf0.
|
||||
*
|
||||
* @param string $data
|
||||
* @return Zend_Amf_Parse_Amf0_Serializer
|
||||
*/
|
||||
public function writeAmf3TypeMarker($data)
|
||||
{
|
||||
require_once 'Zend/Amf/Parse/Amf3/Serializer.php';
|
||||
$serializer = new Zend_Amf_Parse_Amf3_Serializer($this->_stream);
|
||||
$serializer->writeTypeMarker($data);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find if the class name is a class mapped name and return the
|
||||
* respective classname if it is.
|
||||
*
|
||||
* @param object $object
|
||||
* @return false|string $className
|
||||
*/
|
||||
protected function getClassName($object)
|
||||
{
|
||||
require_once 'Zend/Amf/Parse/TypeLoader.php';
|
||||
//Check to see if the object is a typed object and we need to change
|
||||
$className = '';
|
||||
switch (true) {
|
||||
// the return class mapped name back to actionscript class name.
|
||||
case Zend_Amf_Parse_TypeLoader::getMappedClassName(get_class($object)):
|
||||
$className = Zend_Amf_Parse_TypeLoader::getMappedClassName(get_class($object));
|
||||
break;
|
||||
// Check to see if the user has defined an explicit Action Script type.
|
||||
case isset($object->_explicitType):
|
||||
$className = $object->_explicitType;
|
||||
break;
|
||||
// Check if user has defined a method for accessing the Action Script type
|
||||
case method_exists($object, 'getASClassName'):
|
||||
$className = $object->getASClassName();
|
||||
break;
|
||||
// No return class name is set make it a generic object
|
||||
case ($object instanceof stdClass):
|
||||
$className = '';
|
||||
break;
|
||||
// By default, use object's class name
|
||||
default:
|
||||
$className = get_class($object);
|
||||
break;
|
||||
}
|
||||
if(!$className == '') {
|
||||
return $className;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,424 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse_Amf3
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Deserializer.php 21210 2010-02-27 10:37:39Z yoshida@zend.co.jp $
|
||||
*/
|
||||
|
||||
/** Zend_Amf_Constants */
|
||||
require_once 'Zend/Amf/Constants.php';
|
||||
|
||||
/** Zend_Amf_Parse_Deserializer */
|
||||
require_once 'Zend/Amf/Parse/Deserializer.php';
|
||||
|
||||
/** Zend_Amf_Parse_TypeLoader */
|
||||
require_once 'Zend/Amf/Parse/TypeLoader.php';
|
||||
|
||||
/**
|
||||
* Read an AMF3 input stream and convert it into PHP data types.
|
||||
*
|
||||
* @todo readObject to handle Typed Objects
|
||||
* @todo readXMLStrimg to be implemented.
|
||||
* @todo Class could be implemented as Factory Class with each data type it's own class.
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse_Amf3
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Parse_Amf3_Deserializer extends Zend_Amf_Parse_Deserializer
|
||||
{
|
||||
/**
|
||||
* Total number of objects in the referenceObject array
|
||||
* @var int
|
||||
*/
|
||||
protected $_objectCount;
|
||||
|
||||
/**
|
||||
* An array of reference objects per amf body
|
||||
* @var array
|
||||
*/
|
||||
protected $_referenceObjects = array();
|
||||
|
||||
/**
|
||||
* An array of reference strings per amf body
|
||||
* @var array
|
||||
*/
|
||||
protected $_referenceStrings = array();
|
||||
|
||||
/**
|
||||
* An array of reference class definitions per body
|
||||
* @var array
|
||||
*/
|
||||
protected $_referenceDefinitions = array();
|
||||
|
||||
/**
|
||||
* Read AMF markers and dispatch for deserialization
|
||||
*
|
||||
* Checks for AMF marker types and calls the appropriate methods
|
||||
* for deserializing those marker types. markers are the data type of
|
||||
* the following value.
|
||||
*
|
||||
* @param integer $typeMarker
|
||||
* @return mixed Whatever the corresponding PHP data type is
|
||||
* @throws Zend_Amf_Exception for unidentified marker type
|
||||
*/
|
||||
public function readTypeMarker($typeMarker = null)
|
||||
{
|
||||
if(null === $typeMarker) {
|
||||
$typeMarker = $this->_stream->readByte();
|
||||
}
|
||||
|
||||
switch($typeMarker) {
|
||||
case Zend_Amf_Constants::AMF3_UNDEFINED:
|
||||
return null;
|
||||
case Zend_Amf_Constants::AMF3_NULL:
|
||||
return null;
|
||||
case Zend_Amf_Constants::AMF3_BOOLEAN_FALSE:
|
||||
return false;
|
||||
case Zend_Amf_Constants::AMF3_BOOLEAN_TRUE:
|
||||
return true;
|
||||
case Zend_Amf_Constants::AMF3_INTEGER:
|
||||
return $this->readInteger();
|
||||
case Zend_Amf_Constants::AMF3_NUMBER:
|
||||
return $this->_stream->readDouble();
|
||||
case Zend_Amf_Constants::AMF3_STRING:
|
||||
return $this->readString();
|
||||
case Zend_Amf_Constants::AMF3_DATE:
|
||||
return $this->readDate();
|
||||
case Zend_Amf_Constants::AMF3_ARRAY:
|
||||
return $this->readArray();
|
||||
case Zend_Amf_Constants::AMF3_OBJECT:
|
||||
return $this->readObject();
|
||||
case Zend_Amf_Constants::AMF3_XML:
|
||||
case Zend_Amf_Constants::AMF3_XMLSTRING:
|
||||
return $this->readXmlString();
|
||||
case Zend_Amf_Constants::AMF3_BYTEARRAY:
|
||||
return $this->readString();
|
||||
default:
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Unsupported type marker: ' . $typeMarker);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read and deserialize an integer
|
||||
*
|
||||
* AMF 3 represents smaller integers with fewer bytes using the most
|
||||
* significant bit of each byte. The worst case uses 32-bits
|
||||
* to represent a 29-bit number, which is what we would have
|
||||
* done with no compression.
|
||||
* - 0x00000000 - 0x0000007F : 0xxxxxxx
|
||||
* - 0x00000080 - 0x00003FFF : 1xxxxxxx 0xxxxxxx
|
||||
* - 0x00004000 - 0x001FFFFF : 1xxxxxxx 1xxxxxxx 0xxxxxxx
|
||||
* - 0x00200000 - 0x3FFFFFFF : 1xxxxxxx 1xxxxxxx 1xxxxxxx xxxxxxxx
|
||||
* - 0x40000000 - 0xFFFFFFFF : throw range exception
|
||||
*
|
||||
* 0x04 -> integer type code, followed by up to 4 bytes of data.
|
||||
*
|
||||
* Parsing integers on OSFlash for the AMF3 integer data format:
|
||||
* @link http://osflash.org/amf3/parsing_integers
|
||||
* @return int|float
|
||||
*/
|
||||
public function readInteger()
|
||||
{
|
||||
$count = 1;
|
||||
$intReference = $this->_stream->readByte();
|
||||
$result = 0;
|
||||
while ((($intReference & 0x80) != 0) && $count < 4) {
|
||||
$result <<= 7;
|
||||
$result |= ($intReference & 0x7f);
|
||||
$intReference = $this->_stream->readByte();
|
||||
$count++;
|
||||
}
|
||||
if ($count < 4) {
|
||||
$result <<= 7;
|
||||
$result |= $intReference;
|
||||
} else {
|
||||
// Use all 8 bits from the 4th byte
|
||||
$result <<= 8;
|
||||
$result |= $intReference;
|
||||
|
||||
// Check if the integer should be negative
|
||||
if (($result & 0x10000000) != 0) {
|
||||
//and extend the sign bit
|
||||
$result |= ~0xFFFFFFF;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read and deserialize a string
|
||||
*
|
||||
* Strings can be sent as a reference to a previously
|
||||
* occurring String by using an index to the implicit string reference table.
|
||||
* Strings are encoding using UTF-8 - however the header may either
|
||||
* describe a string literal or a string reference.
|
||||
*
|
||||
* - string = 0x06 string-data
|
||||
* - string-data = integer-data [ modified-utf-8 ]
|
||||
* - modified-utf-8 = *OCTET
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public function readString()
|
||||
{
|
||||
$stringReference = $this->readInteger();
|
||||
|
||||
//Check if this is a reference string
|
||||
if (($stringReference & 0x01) == 0) {
|
||||
// reference string
|
||||
$stringReference = $stringReference >> 1;
|
||||
if ($stringReference >= count($this->_referenceStrings)) {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Undefined string reference: ' . $stringReference);
|
||||
}
|
||||
// reference string found
|
||||
return $this->_referenceStrings[$stringReference];
|
||||
}
|
||||
|
||||
$length = $stringReference >> 1;
|
||||
if ($length) {
|
||||
$string = $this->_stream->readBytes($length);
|
||||
$this->_referenceStrings[] = $string;
|
||||
} else {
|
||||
$string = "";
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read and deserialize a date
|
||||
*
|
||||
* Data is the number of milliseconds elapsed since the epoch
|
||||
* of midnight, 1st Jan 1970 in the UTC time zone.
|
||||
* Local time zone information is not sent to flash.
|
||||
*
|
||||
* - date = 0x08 integer-data [ number-data ]
|
||||
*
|
||||
* @return Zend_Date
|
||||
*/
|
||||
public function readDate()
|
||||
{
|
||||
$dateReference = $this->readInteger();
|
||||
if (($dateReference & 0x01) == 0) {
|
||||
$dateReference = $dateReference >> 1;
|
||||
if ($dateReference>=count($this->_referenceObjects)) {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Undefined date reference: ' . $dateReference);
|
||||
}
|
||||
return $this->_referenceObjects[$dateReference];
|
||||
}
|
||||
|
||||
$timestamp = floor($this->_stream->readDouble() / 1000);
|
||||
|
||||
require_once 'Zend/Date.php';
|
||||
$dateTime = new Zend_Date((int) $timestamp);
|
||||
$this->_referenceObjects[] = $dateTime;
|
||||
return $dateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read amf array to PHP array
|
||||
*
|
||||
* - array = 0x09 integer-data ( [ 1OCTET *amf3-data ] | [OCTET *amf3-data 1] | [ OCTET *amf-data ] )
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function readArray()
|
||||
{
|
||||
$arrayReference = $this->readInteger();
|
||||
if (($arrayReference & 0x01)==0){
|
||||
$arrayReference = $arrayReference >> 1;
|
||||
if ($arrayReference>=count($this->_referenceObjects)) {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Unknow array reference: ' . $arrayReference);
|
||||
}
|
||||
return $this->_referenceObjects[$arrayReference];
|
||||
}
|
||||
|
||||
// Create a holder for the array in the reference list
|
||||
$data = array();
|
||||
$this->_referenceObjects[] =& $data;
|
||||
$key = $this->readString();
|
||||
|
||||
// Iterating for string based keys.
|
||||
while ($key != '') {
|
||||
$data[$key] = $this->readTypeMarker();
|
||||
$key = $this->readString();
|
||||
}
|
||||
|
||||
$arrayReference = $arrayReference >>1;
|
||||
|
||||
//We have a dense array
|
||||
for ($i=0; $i < $arrayReference; $i++) {
|
||||
$data[] = $this->readTypeMarker();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read an object from the AMF stream and convert it into a PHP object
|
||||
*
|
||||
* @todo Rather than using an array of traitsInfo create Zend_Amf_Value_TraitsInfo
|
||||
* @return object|array
|
||||
*/
|
||||
public function readObject()
|
||||
{
|
||||
$traitsInfo = $this->readInteger();
|
||||
$storedObject = ($traitsInfo & 0x01)==0;
|
||||
$traitsInfo = $traitsInfo >> 1;
|
||||
|
||||
// Check if the Object is in the stored Objects reference table
|
||||
if ($storedObject) {
|
||||
$ref = $traitsInfo;
|
||||
if (!isset($this->_referenceObjects[$ref])) {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Unknown Object reference: ' . $ref);
|
||||
}
|
||||
$returnObject = $this->_referenceObjects[$ref];
|
||||
} else {
|
||||
// Check if the Object is in the stored Definitions reference table
|
||||
$storedClass = ($traitsInfo & 0x01) == 0;
|
||||
$traitsInfo = $traitsInfo >> 1;
|
||||
if ($storedClass) {
|
||||
$ref = $traitsInfo;
|
||||
if (!isset($this->_referenceDefinitions[$ref])) {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Unknows Definition reference: '. $ref);
|
||||
}
|
||||
// Populate the reference attributes
|
||||
$className = $this->_referenceDefinitions[$ref]['className'];
|
||||
$encoding = $this->_referenceDefinitions[$ref]['encoding'];
|
||||
$propertyNames = $this->_referenceDefinitions[$ref]['propertyNames'];
|
||||
} else {
|
||||
// The class was not in the reference tables. Start reading rawdata to build traits.
|
||||
// Create a traits table. Zend_Amf_Value_TraitsInfo would be ideal
|
||||
$className = $this->readString();
|
||||
$encoding = $traitsInfo & 0x03;
|
||||
$propertyNames = array();
|
||||
$traitsInfo = $traitsInfo >> 2;
|
||||
}
|
||||
|
||||
// We now have the object traits defined in variables. Time to go to work:
|
||||
if (!$className) {
|
||||
// No class name generic object
|
||||
$returnObject = new stdClass();
|
||||
} else {
|
||||
// Defined object
|
||||
// Typed object lookup against registered classname maps
|
||||
if ($loader = Zend_Amf_Parse_TypeLoader::loadType($className)) {
|
||||
$returnObject = new $loader();
|
||||
} else {
|
||||
//user defined typed object
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Typed object not found: '. $className . ' ');
|
||||
}
|
||||
}
|
||||
|
||||
// Add the Object to the reference table
|
||||
$this->_referenceObjects[] = $returnObject;
|
||||
|
||||
$properties = array(); // clear value
|
||||
// Check encoding types for additional processing.
|
||||
switch ($encoding) {
|
||||
case (Zend_Amf_Constants::ET_EXTERNAL):
|
||||
// Externalizable object such as {ArrayCollection} and {ObjectProxy}
|
||||
if (!$storedClass) {
|
||||
$this->_referenceDefinitions[] = array(
|
||||
'className' => $className,
|
||||
'encoding' => $encoding,
|
||||
'propertyNames' => $propertyNames,
|
||||
);
|
||||
}
|
||||
$returnObject->externalizedData = $this->readTypeMarker();
|
||||
break;
|
||||
case (Zend_Amf_Constants::ET_DYNAMIC):
|
||||
// used for Name-value encoding
|
||||
if (!$storedClass) {
|
||||
$this->_referenceDefinitions[] = array(
|
||||
'className' => $className,
|
||||
'encoding' => $encoding,
|
||||
'propertyNames' => $propertyNames,
|
||||
);
|
||||
}
|
||||
// not a reference object read name value properties from byte stream
|
||||
do {
|
||||
$property = $this->readString();
|
||||
if ($property != "") {
|
||||
$propertyNames[] = $property;
|
||||
$properties[$property] = $this->readTypeMarker();
|
||||
}
|
||||
} while ($property !="");
|
||||
break;
|
||||
default:
|
||||
// basic property list object.
|
||||
if (!$storedClass) {
|
||||
$count = $traitsInfo; // Number of properties in the list
|
||||
for($i=0; $i< $count; $i++) {
|
||||
$propertyNames[] = $this->readString();
|
||||
}
|
||||
// Add a reference to the class.
|
||||
$this->_referenceDefinitions[] = array(
|
||||
'className' => $className,
|
||||
'encoding' => $encoding,
|
||||
'propertyNames' => $propertyNames,
|
||||
);
|
||||
}
|
||||
foreach ($propertyNames as $property) {
|
||||
$properties[$property] = $this->readTypeMarker();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Add properties back to the return object.
|
||||
foreach($properties as $key=>$value) {
|
||||
if($key) {
|
||||
$returnObject->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if($returnObject instanceof Zend_Amf_Value_Messaging_ArrayCollection) {
|
||||
if(isset($returnObject->externalizedData)) {
|
||||
$returnObject = $returnObject->externalizedData;
|
||||
} else {
|
||||
$returnObject = get_object_vars($returnObject);
|
||||
}
|
||||
}
|
||||
|
||||
return $returnObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert XML to SimpleXml
|
||||
* If user wants DomDocument they can use dom_import_simplexml
|
||||
*
|
||||
* @return SimpleXml Object
|
||||
*/
|
||||
public function readXmlString()
|
||||
{
|
||||
$xmlReference = $this->readInteger();
|
||||
$length = $xmlReference >> 1;
|
||||
$string = $this->_stream->readBytes($length);
|
||||
return simplexml_load_string($string);
|
||||
}
|
||||
}
|
|
@ -1,507 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse_Amf3
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Serializer.php 20392 2010-01-18 18:34:23Z stas $
|
||||
*/
|
||||
|
||||
/** Zend_Amf_Constants */
|
||||
require_once 'Zend/Amf/Constants.php';
|
||||
|
||||
/** Zend_Amf_Parse_Serializer */
|
||||
require_once 'Zend/Amf/Parse/Serializer.php';
|
||||
|
||||
/** Zend_Amf_Parse_TypeLoader */
|
||||
require_once 'Zend/Amf/Parse/TypeLoader.php';
|
||||
|
||||
/**
|
||||
* Detect PHP object type and convert it to a corresponding AMF3 object type
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse_Amf3
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
|
||||
{
|
||||
/**
|
||||
* An array of reference objects per amf body
|
||||
* @var array
|
||||
*/
|
||||
protected $_referenceObjects = array();
|
||||
|
||||
/**
|
||||
* An array of reference strings per amf body
|
||||
* @var array
|
||||
*/
|
||||
protected $_referenceStrings = array();
|
||||
|
||||
/**
|
||||
* An array of reference class definitions, indexed by classname
|
||||
* @var array
|
||||
*/
|
||||
protected $_referenceDefinitions = array();
|
||||
|
||||
/**
|
||||
* Serialize PHP types to AMF3 and write to stream
|
||||
*
|
||||
* Checks to see if the type was declared and then either
|
||||
* auto negotiates the type or use the user defined markerType to
|
||||
* serialize the data from php back to AMF3
|
||||
*
|
||||
* @param mixed $content
|
||||
* @param int $markerType
|
||||
* @return void
|
||||
*/
|
||||
public function writeTypeMarker($data, $markerType=null)
|
||||
{
|
||||
if (null !== $markerType) {
|
||||
// Write the Type Marker to denote the following action script data type
|
||||
$this->_stream->writeByte($markerType);
|
||||
|
||||
switch ($markerType) {
|
||||
case Zend_Amf_Constants::AMF3_NULL:
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF3_BOOLEAN_FALSE:
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF3_BOOLEAN_TRUE:
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF3_INTEGER:
|
||||
$this->writeInteger($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF3_NUMBER:
|
||||
$this->_stream->writeDouble($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF3_STRING:
|
||||
$this->writeString($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF3_DATE:
|
||||
$this->writeDate($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF3_ARRAY:
|
||||
$this->writeArray($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF3_OBJECT:
|
||||
$this->writeObject($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF3_BYTEARRAY:
|
||||
$this->writeByteArray($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF3_XMLSTRING;
|
||||
$this->writeXml($data);
|
||||
break;
|
||||
default:
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Unknown Type Marker: ' . $markerType);
|
||||
}
|
||||
} else {
|
||||
// Detect Type Marker
|
||||
if(is_resource($data)) {
|
||||
$data = Zend_Amf_Parse_TypeLoader::handleResource($data);
|
||||
}
|
||||
switch (true) {
|
||||
case (null === $data):
|
||||
$markerType = Zend_Amf_Constants::AMF3_NULL;
|
||||
break;
|
||||
case (is_bool($data)):
|
||||
if ($data){
|
||||
$markerType = Zend_Amf_Constants::AMF3_BOOLEAN_TRUE;
|
||||
} else {
|
||||
$markerType = Zend_Amf_Constants::AMF3_BOOLEAN_FALSE;
|
||||
}
|
||||
break;
|
||||
case (is_int($data)):
|
||||
if (($data > 0xFFFFFFF) || ($data < -268435456)) {
|
||||
$markerType = Zend_Amf_Constants::AMF3_NUMBER;
|
||||
} else {
|
||||
$markerType = Zend_Amf_Constants::AMF3_INTEGER;
|
||||
}
|
||||
break;
|
||||
case (is_float($data)):
|
||||
$markerType = Zend_Amf_Constants::AMF3_NUMBER;
|
||||
break;
|
||||
case (is_string($data)):
|
||||
$markerType = Zend_Amf_Constants::AMF3_STRING;
|
||||
break;
|
||||
case (is_array($data)):
|
||||
$markerType = Zend_Amf_Constants::AMF3_ARRAY;
|
||||
break;
|
||||
case (is_object($data)):
|
||||
// Handle object types.
|
||||
if (($data instanceof DateTime) || ($data instanceof Zend_Date)) {
|
||||
$markerType = Zend_Amf_Constants::AMF3_DATE;
|
||||
} else if ($data instanceof Zend_Amf_Value_ByteArray) {
|
||||
$markerType = Zend_Amf_Constants::AMF3_BYTEARRAY;
|
||||
} else if (($data instanceof DOMDocument) || ($data instanceof SimpleXMLElement)) {
|
||||
$markerType = Zend_Amf_Constants::AMF3_XMLSTRING;
|
||||
} else {
|
||||
$markerType = Zend_Amf_Constants::AMF3_OBJECT;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Unsupported data type: ' . gettype($data));
|
||||
}
|
||||
$this->writeTypeMarker($data, $markerType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write an AMF3 integer
|
||||
*
|
||||
* @param int|float $data
|
||||
* @return Zend_Amf_Parse_Amf3_Serializer
|
||||
*/
|
||||
public function writeInteger($int)
|
||||
{
|
||||
if (($int & 0xffffff80) == 0) {
|
||||
$this->_stream->writeByte($int & 0x7f);
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (($int & 0xffffc000) == 0 ) {
|
||||
$this->_stream->writeByte(($int >> 7 ) | 0x80);
|
||||
$this->_stream->writeByte($int & 0x7f);
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (($int & 0xffe00000) == 0) {
|
||||
$this->_stream->writeByte(($int >> 14 ) | 0x80);
|
||||
$this->_stream->writeByte(($int >> 7 ) | 0x80);
|
||||
$this->_stream->writeByte($int & 0x7f);
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->_stream->writeByte(($int >> 22 ) | 0x80);
|
||||
$this->_stream->writeByte(($int >> 15 ) | 0x80);
|
||||
$this->_stream->writeByte(($int >> 8 ) | 0x80);
|
||||
$this->_stream->writeByte($int & 0xff);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send string to output stream, without trying to reference it.
|
||||
* The string is prepended with strlen($string) << 1 | 0x01
|
||||
*
|
||||
* @param string $string
|
||||
* @return Zend_Amf_Parse_Amf3_Serializer
|
||||
*/
|
||||
protected function writeBinaryString($string){
|
||||
$ref = strlen($string) << 1 | 0x01;
|
||||
$this->writeInteger($ref);
|
||||
$this->_stream->writeBytes($string);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send string to output stream
|
||||
*
|
||||
* @param string $string
|
||||
* @return Zend_Amf_Parse_Amf3_Serializer
|
||||
*/
|
||||
public function writeString($string)
|
||||
{
|
||||
$len = strlen($string);
|
||||
if(!$len){
|
||||
$this->writeInteger(0x01);
|
||||
return $this;
|
||||
}
|
||||
|
||||
$ref = array_search($string, $this->_referenceStrings, true);
|
||||
if($ref === false){
|
||||
$this->_referenceStrings[] = $string;
|
||||
$this->writeBinaryString($string);
|
||||
} else {
|
||||
$ref <<= 1;
|
||||
$this->writeInteger($ref);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send ByteArray to output stream
|
||||
*
|
||||
* @param string|Zend_Amf_Value_ByteArray $data
|
||||
* @return Zend_Amf_Parse_Amf3_Serializer
|
||||
*/
|
||||
public function writeByteArray($data){
|
||||
if($this->writeObjectReference($data)){
|
||||
return $this;
|
||||
}
|
||||
|
||||
if(is_string($data)) {
|
||||
//nothing to do
|
||||
} else if ($data instanceof Zend_Amf_Value_ByteArray) {
|
||||
$data = $data->getData();
|
||||
} else {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Invalid ByteArray specified; must be a string or Zend_Amf_Value_ByteArray');
|
||||
}
|
||||
|
||||
$this->writeBinaryString($data);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send xml to output stream
|
||||
*
|
||||
* @param DOMDocument|SimpleXMLElement $xml
|
||||
* @return Zend_Amf_Parse_Amf3_Serializer
|
||||
*/
|
||||
public function writeXml($xml)
|
||||
{
|
||||
if($this->writeObjectReference($xml)){
|
||||
return $this;
|
||||
}
|
||||
|
||||
if(is_string($xml)) {
|
||||
//nothing to do
|
||||
} else if ($xml instanceof DOMDocument) {
|
||||
$xml = $xml->saveXml();
|
||||
} else if ($xml instanceof SimpleXMLElement) {
|
||||
$xml = $xml->asXML();
|
||||
} else {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Invalid xml specified; must be a DOMDocument or SimpleXMLElement');
|
||||
}
|
||||
|
||||
$this->writeBinaryString($xml);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert DateTime/Zend_Date to AMF date
|
||||
*
|
||||
* @param DateTime|Zend_Date $date
|
||||
* @return Zend_Amf_Parse_Amf3_Serializer
|
||||
*/
|
||||
public function writeDate($date)
|
||||
{
|
||||
if($this->writeObjectReference($date)){
|
||||
return $this;
|
||||
}
|
||||
|
||||
if ($date instanceof DateTime) {
|
||||
$dateString = $date->format('U') * 1000;
|
||||
} elseif ($date instanceof Zend_Date) {
|
||||
$dateString = $date->toString('U') * 1000;
|
||||
} else {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Invalid date specified; must be a string DateTime or Zend_Date object');
|
||||
}
|
||||
|
||||
$this->writeInteger(0x01);
|
||||
// write time to stream minus milliseconds
|
||||
$this->_stream->writeDouble($dateString);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a PHP array back to the amf output stream
|
||||
*
|
||||
* @param array $array
|
||||
* @return Zend_Amf_Parse_Amf3_Serializer
|
||||
*/
|
||||
public function writeArray(array $array)
|
||||
{
|
||||
// arrays aren't reference here but still counted
|
||||
$this->_referenceObjects[] = $array;
|
||||
|
||||
// have to seperate mixed from numberic keys.
|
||||
$numeric = array();
|
||||
$string = array();
|
||||
foreach ($array as $key => $value) {
|
||||
if (is_int($key)) {
|
||||
$numeric[] = $value;
|
||||
} else {
|
||||
$string[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// write the preamble id of the array
|
||||
$length = count($numeric);
|
||||
$id = ($length << 1) | 0x01;
|
||||
$this->writeInteger($id);
|
||||
|
||||
//Write the mixed type array to the output stream
|
||||
foreach($string as $key => $value) {
|
||||
$this->writeString($key)
|
||||
->writeTypeMarker($value);
|
||||
}
|
||||
$this->writeString('');
|
||||
|
||||
// Write the numeric array to ouput stream
|
||||
foreach($numeric as $value) {
|
||||
$this->writeTypeMarker($value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given object is in the reference table, write the reference if it exists,
|
||||
* otherwise add the object to the reference table
|
||||
*
|
||||
* @param mixed $object object to check for reference
|
||||
* @return Boolean true, if the reference was written, false otherwise
|
||||
*/
|
||||
protected function writeObjectReference($object)
|
||||
{
|
||||
$ref = array_search($object, $this->_referenceObjects,true);
|
||||
//quickly handle object references
|
||||
if($ref !== false){
|
||||
$ref <<= 1;
|
||||
$this->writeInteger($ref);
|
||||
return true;
|
||||
}
|
||||
$this->_referenceObjects[] = $object;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write object to ouput stream
|
||||
*
|
||||
* @param mixed $data
|
||||
* @return Zend_Amf_Parse_Amf3_Serializer
|
||||
*/
|
||||
public function writeObject($object)
|
||||
{
|
||||
if($this->writeObjectReference($object)){
|
||||
return $this;
|
||||
}
|
||||
|
||||
$className = '';
|
||||
|
||||
//Check to see if the object is a typed object and we need to change
|
||||
switch (true) {
|
||||
// the return class mapped name back to actionscript class name.
|
||||
case ($className = Zend_Amf_Parse_TypeLoader::getMappedClassName(get_class($object))):
|
||||
break;
|
||||
|
||||
// Check to see if the user has defined an explicit Action Script type.
|
||||
case isset($object->_explicitType):
|
||||
$className = $object->_explicitType;
|
||||
break;
|
||||
|
||||
// Check if user has defined a method for accessing the Action Script type
|
||||
case method_exists($object, 'getASClassName'):
|
||||
$className = $object->getASClassName();
|
||||
break;
|
||||
|
||||
// No return class name is set make it a generic object
|
||||
case ($object instanceof stdClass):
|
||||
$className = '';
|
||||
break;
|
||||
|
||||
// By default, use object's class name
|
||||
default:
|
||||
$className = get_class($object);
|
||||
break;
|
||||
}
|
||||
|
||||
$writeTraits = true;
|
||||
|
||||
//check to see, if we have a corresponding definition
|
||||
if(array_key_exists($className, $this->_referenceDefinitions)){
|
||||
$traitsInfo = $this->_referenceDefinitions[$className]['id'];
|
||||
$encoding = $this->_referenceDefinitions[$className]['encoding'];
|
||||
$propertyNames = $this->_referenceDefinitions[$className]['propertyNames'];
|
||||
|
||||
$traitsInfo = ($traitsInfo << 2) | 0x01;
|
||||
|
||||
$writeTraits = false;
|
||||
} else {
|
||||
$propertyNames = array();
|
||||
|
||||
if($className == ''){
|
||||
//if there is no className, we interpret the class as dynamic without any sealed members
|
||||
$encoding = Zend_Amf_Constants::ET_DYNAMIC;
|
||||
} else {
|
||||
$encoding = Zend_Amf_Constants::ET_PROPLIST;
|
||||
|
||||
foreach($object as $key => $value) {
|
||||
if( $key[0] != "_") {
|
||||
$propertyNames[] = $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->_referenceDefinitions[$className] = array(
|
||||
'id' => count($this->_referenceDefinitions),
|
||||
'encoding' => $encoding,
|
||||
'propertyNames' => $propertyNames,
|
||||
);
|
||||
|
||||
$traitsInfo = Zend_Amf_Constants::AMF3_OBJECT_ENCODING;
|
||||
$traitsInfo |= $encoding << 2;
|
||||
$traitsInfo |= (count($propertyNames) << 4);
|
||||
}
|
||||
|
||||
$this->writeInteger($traitsInfo);
|
||||
|
||||
if($writeTraits){
|
||||
$this->writeString($className);
|
||||
foreach ($propertyNames as $value) {
|
||||
$this->writeString($value);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
switch($encoding) {
|
||||
case Zend_Amf_Constants::ET_PROPLIST:
|
||||
//Write the sealed values to the output stream.
|
||||
foreach ($propertyNames as $key) {
|
||||
$this->writeTypeMarker($object->$key);
|
||||
}
|
||||
break;
|
||||
case Zend_Amf_Constants::ET_DYNAMIC:
|
||||
//Write the sealed values to the output stream.
|
||||
foreach ($propertyNames as $key) {
|
||||
$this->writeTypeMarker($object->$key);
|
||||
}
|
||||
|
||||
//Write remaining properties
|
||||
foreach($object as $key => $value){
|
||||
if(!in_array($key,$propertyNames) && $key[0] != "_"){
|
||||
$this->writeString($key);
|
||||
$this->writeTypeMarker($value);
|
||||
}
|
||||
}
|
||||
|
||||
//Write an empty string to end the dynamic part
|
||||
$this->writeString('');
|
||||
break;
|
||||
case Zend_Amf_Constants::ET_EXTERNAL:
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('External Object Encoding not implemented');
|
||||
break;
|
||||
default:
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Unknown Object Encoding type: ' . $encoding);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Unable to writeObject output: ' . $e->getMessage(), 0, $e);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Deserializer.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Abstract cass that all deserializer must implement.
|
||||
*
|
||||
* Logic for deserialization of the AMF envelop is based on resources supplied
|
||||
* by Adobe Blaze DS. For and example of deserialization please review the BlazeDS
|
||||
* source tree.
|
||||
*
|
||||
* @see http://opensource.adobe.com/svn/opensource/blazeds/trunk/modules/core/src/java/flex/messaging/io/amf/
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Amf_Parse_Deserializer
|
||||
{
|
||||
/**
|
||||
* The raw string that represents the AMF request.
|
||||
*
|
||||
* @var Zend_Amf_Parse_InputStream
|
||||
*/
|
||||
protected $_stream;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Zend_Amf_Parse_InputStream $stream
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Zend_Amf_Parse_InputStream $stream)
|
||||
{
|
||||
$this->_stream = $stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for AMF marker types and calls the appropriate methods
|
||||
* for deserializing those marker types. Markers are the data type of
|
||||
* the following value.
|
||||
*
|
||||
* @param int $typeMarker
|
||||
* @return mixed Whatever the data type is of the marker in php
|
||||
*/
|
||||
public abstract function readTypeMarker($markerType = null);
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: InputStream.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/** Zend_Amf_Util_BinaryStream */
|
||||
require_once 'Zend/Amf/Util/BinaryStream.php';
|
||||
|
||||
/**
|
||||
* InputStream is used to iterate at a binary level through the AMF request.
|
||||
*
|
||||
* InputStream extends BinaryStream as eventually BinaryStream could be placed
|
||||
* outside of Zend_Amf in order to allow other packages to use the class.
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Parse_InputStream extends Zend_Amf_Util_BinaryStream
|
||||
{
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: OutputStream.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/** Zend_Amf_Util_BinaryStream */
|
||||
require_once 'Zend/Amf/Util/BinaryStream.php';
|
||||
|
||||
/**
|
||||
* Iterate at a binary level through the AMF response
|
||||
*
|
||||
* OutputStream extends BinaryStream as eventually BinaryStream could be placed
|
||||
* outside of Zend_Amf in order to allow other packages to use the class.
|
||||
*
|
||||
* @uses Zend_Amf_Util_BinaryStream
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Parse_OutputStream extends Zend_Amf_Util_BinaryStream
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('');
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: MysqlResult.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class will convert mysql result resource to array suitable for passing
|
||||
* to the external entities.
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Parse_Resource_MysqlResult
|
||||
{
|
||||
/**
|
||||
* @var array List of Mysql types with PHP counterparts
|
||||
*
|
||||
* Key => Value is Mysql type (exact string) => PHP type
|
||||
*/
|
||||
static public $fieldTypes = array(
|
||||
"int" => "int",
|
||||
"timestamp" => "int",
|
||||
"year" => "int",
|
||||
"real" => "float",
|
||||
);
|
||||
/**
|
||||
* Parse resource into array
|
||||
*
|
||||
* @param resource $resource
|
||||
* @return array
|
||||
*/
|
||||
public function parse($resource) {
|
||||
$result = array();
|
||||
$fieldcnt = mysql_num_fields($resource);
|
||||
$fields_transform = array();
|
||||
for($i=0;$i<$fieldcnt;$i++) {
|
||||
$type = mysql_field_type($resource, $i);
|
||||
if(isset(self::$fieldTypes[$type])) {
|
||||
$fields_transform[mysql_field_name($resource, $i)] = self::$fieldTypes[$type];
|
||||
}
|
||||
}
|
||||
|
||||
while($row = mysql_fetch_object($resource)) {
|
||||
foreach($fields_transform as $fieldname => $fieldtype) {
|
||||
settype($row->$fieldname, $fieldtype);
|
||||
}
|
||||
$result[] = $row;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
|
@ -1,128 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: MysqliResult.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class will convert mysql result resource to array suitable for passing
|
||||
* to the external entities.
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Parse_Resource_MysqliResult
|
||||
{
|
||||
|
||||
/**
|
||||
* mapping taken from http://forums.mysql.com/read.php?52,255868,255895#msg-255895
|
||||
*/
|
||||
static public $mysqli_type = array(
|
||||
0 => "MYSQLI_TYPE_DECIMAL",
|
||||
1 => "MYSQLI_TYPE_TINYINT",
|
||||
2 => "MYSQLI_TYPE_SMALLINT",
|
||||
3 => "MYSQLI_TYPE_INTEGER",
|
||||
4 => "MYSQLI_TYPE_FLOAT",
|
||||
5 => "MYSQLI_TYPE_DOUBLE",
|
||||
7 => "MYSQLI_TYPE_TIMESTAMP",
|
||||
8 => "MYSQLI_TYPE_BIGINT",
|
||||
9 => "MYSQLI_TYPE_MEDIUMINT",
|
||||
10 => "MYSQLI_TYPE_DATE",
|
||||
11 => "MYSQLI_TYPE_TIME",
|
||||
12 => "MYSQLI_TYPE_DATETIME",
|
||||
13 => "MYSQLI_TYPE_YEAR",
|
||||
14 => "MYSQLI_TYPE_DATE",
|
||||
16 => "MYSQLI_TYPE_BIT",
|
||||
246 => "MYSQLI_TYPE_DECIMAL",
|
||||
247 => "MYSQLI_TYPE_ENUM",
|
||||
248 => "MYSQLI_TYPE_SET",
|
||||
249 => "MYSQLI_TYPE_TINYBLOB",
|
||||
250 => "MYSQLI_TYPE_MEDIUMBLOB",
|
||||
251 => "MYSQLI_TYPE_LONGBLOB",
|
||||
252 => "MYSQLI_TYPE_BLOB",
|
||||
253 => "MYSQLI_TYPE_VARCHAR",
|
||||
254 => "MYSQLI_TYPE_CHAR",
|
||||
255 => "MYSQLI_TYPE_GEOMETRY",
|
||||
);
|
||||
|
||||
// Build an associative array for a type look up
|
||||
static $mysqli_to_php = array(
|
||||
"MYSQLI_TYPE_DECIMAL" => 'float',
|
||||
"MYSQLI_TYPE_NEWDECIMAL" => 'float',
|
||||
"MYSQLI_TYPE_BIT" => 'integer',
|
||||
"MYSQLI_TYPE_TINYINT" => 'integer',
|
||||
"MYSQLI_TYPE_SMALLINT" => 'integer',
|
||||
"MYSQLI_TYPE_MEDIUMINT" => 'integer',
|
||||
"MYSQLI_TYPE_BIGINT" => 'integer',
|
||||
"MYSQLI_TYPE_INTEGER" => 'integer',
|
||||
"MYSQLI_TYPE_FLOAT" => 'float',
|
||||
"MYSQLI_TYPE_DOUBLE" => 'float',
|
||||
"MYSQLI_TYPE_NULL" => 'null',
|
||||
"MYSQLI_TYPE_TIMESTAMP" => 'string',
|
||||
"MYSQLI_TYPE_INT24" => 'integer',
|
||||
"MYSQLI_TYPE_DATE" => 'string',
|
||||
"MYSQLI_TYPE_TIME" => 'string',
|
||||
"MYSQLI_TYPE_DATETIME" => 'string',
|
||||
"MYSQLI_TYPE_YEAR" => 'string',
|
||||
"MYSQLI_TYPE_NEWDATE" => 'string',
|
||||
"MYSQLI_TYPE_ENUM" => 'string',
|
||||
"MYSQLI_TYPE_SET" => 'string',
|
||||
"MYSQLI_TYPE_TINYBLOB" => 'object',
|
||||
"MYSQLI_TYPE_MEDIUMBLOB" => 'object',
|
||||
"MYSQLI_TYPE_LONGBLOB" => 'object',
|
||||
"MYSQLI_TYPE_BLOB" => 'object',
|
||||
"MYSQLI_TYPE_CHAR" => 'string',
|
||||
"MYSQLI_TYPE_VARCHAR" => 'string',
|
||||
"MYSQLI_TYPE_GEOMETRY" => 'object',
|
||||
"MYSQLI_TYPE_BIT" => 'integer',
|
||||
);
|
||||
|
||||
/**
|
||||
* Parse resource into array
|
||||
*
|
||||
* @param resource $resource
|
||||
* @return array
|
||||
*/
|
||||
public function parse($resource) {
|
||||
|
||||
$result = array();
|
||||
$fieldcnt = mysqli_num_fields($resource);
|
||||
|
||||
|
||||
$fields_transform = array();
|
||||
|
||||
for($i=0;$i<$fieldcnt;$i++) {
|
||||
$finfo = mysqli_fetch_field_direct($resource, $i);
|
||||
|
||||
if(isset(self::$mysqli_type[$finfo->type])) {
|
||||
$fields_transform[$finfo->name] = self::$mysqli_to_php[self::$mysqli_type[$finfo->type]];
|
||||
}
|
||||
}
|
||||
|
||||
while($row = mysqli_fetch_assoc($resource)) {
|
||||
foreach($fields_transform as $fieldname => $fieldtype) {
|
||||
settype($row[$fieldname], $fieldtype);
|
||||
}
|
||||
$result[] = $row;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Stream.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class will convert stream resource to string by just reading it
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Parse_Resource_Stream
|
||||
{
|
||||
/**
|
||||
* Parse resource into string
|
||||
*
|
||||
* @param resource $resource Stream resource
|
||||
* @return array
|
||||
*/
|
||||
public function parse($resource) {
|
||||
return stream_get_contents($resource);
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Serializer.php 21210 2010-02-27 10:37:39Z yoshida@zend.co.jp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base abstract class for all AMF serializers.
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Amf_Parse_Serializer
|
||||
{
|
||||
/**
|
||||
* Reference to the current output stream being constructed
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_stream;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Zend_Amf_Parse_OutputStream $stream
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Zend_Amf_Parse_OutputStream $stream)
|
||||
{
|
||||
$this->_stream = $stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the PHP object type and convert it into an AMF object type
|
||||
*
|
||||
* @param mixed $content
|
||||
* @param int $markerType
|
||||
* @return void
|
||||
*/
|
||||
public abstract function writeTypeMarker($content, $markerType=null);
|
||||
}
|
|
@ -1,231 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: TypeLoader.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Amf_Value_Messaging_AcknowledgeMessage
|
||||
*/
|
||||
require_once 'Zend/Amf/Value/Messaging/AcknowledgeMessage.php';
|
||||
/**
|
||||
* @see Zend_Amf_Value_Messaging_AsyncMessage
|
||||
*/
|
||||
require_once 'Zend/Amf/Value/Messaging/AsyncMessage.php';
|
||||
/**
|
||||
* @see Zend_Amf_Value_Messaging_CommandMessage
|
||||
*/
|
||||
require_once 'Zend/Amf/Value/Messaging/CommandMessage.php';
|
||||
/**
|
||||
* @see Zend_Amf_Value_Messaging_ErrorMessage
|
||||
*/
|
||||
require_once 'Zend/Amf/Value/Messaging/ErrorMessage.php';
|
||||
/**
|
||||
* @see Zend_Amf_Value_Messaging_RemotingMessage
|
||||
*/
|
||||
require_once 'Zend/Amf/Value/Messaging/RemotingMessage.php';
|
||||
|
||||
/**
|
||||
* Loads a local class and executes the instantiation of that class.
|
||||
*
|
||||
* @todo PHP 5.3 can drastically change this class w/ namespace and the new call_user_func w/ namespace
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
final class Zend_Amf_Parse_TypeLoader
|
||||
{
|
||||
/**
|
||||
* @var string callback class
|
||||
*/
|
||||
public static $callbackClass;
|
||||
|
||||
/**
|
||||
* @var array AMF class map
|
||||
*/
|
||||
public static $classMap = array (
|
||||
'flex.messaging.messages.AcknowledgeMessage' => 'Zend_Amf_Value_Messaging_AcknowledgeMessage',
|
||||
'flex.messaging.messages.ErrorMessage' => 'Zend_Amf_Value_Messaging_AsyncMessage',
|
||||
'flex.messaging.messages.CommandMessage' => 'Zend_Amf_Value_Messaging_CommandMessage',
|
||||
'flex.messaging.messages.ErrorMessage' => 'Zend_Amf_Value_Messaging_ErrorMessage',
|
||||
'flex.messaging.messages.RemotingMessage' => 'Zend_Amf_Value_Messaging_RemotingMessage',
|
||||
'flex.messaging.io.ArrayCollection' => 'Zend_Amf_Value_Messaging_ArrayCollection',
|
||||
);
|
||||
|
||||
/**
|
||||
* @var array Default class map
|
||||
*/
|
||||
protected static $_defaultClassMap = array(
|
||||
'flex.messaging.messages.AcknowledgeMessage' => 'Zend_Amf_Value_Messaging_AcknowledgeMessage',
|
||||
'flex.messaging.messages.ErrorMessage' => 'Zend_Amf_Value_Messaging_AsyncMessage',
|
||||
'flex.messaging.messages.CommandMessage' => 'Zend_Amf_Value_Messaging_CommandMessage',
|
||||
'flex.messaging.messages.ErrorMessage' => 'Zend_Amf_Value_Messaging_ErrorMessage',
|
||||
'flex.messaging.messages.RemotingMessage' => 'Zend_Amf_Value_Messaging_RemotingMessage',
|
||||
'flex.messaging.io.ArrayCollection' => 'Zend_Amf_Value_Messaging_ArrayCollection',
|
||||
);
|
||||
|
||||
/**
|
||||
* @var Zend_Loader_PluginLoader_Interface
|
||||
*/
|
||||
protected static $_resourceLoader = null;
|
||||
|
||||
|
||||
/**
|
||||
* Load the mapped class type into a callback.
|
||||
*
|
||||
* @param string $className
|
||||
* @return object|false
|
||||
*/
|
||||
public static function loadType($className)
|
||||
{
|
||||
$class = self::getMappedClassName($className);
|
||||
if(!$class) {
|
||||
$class = str_replace('.', '_', $className);
|
||||
}
|
||||
if (!class_exists($class)) {
|
||||
return "stdClass";
|
||||
}
|
||||
return $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks up the supplied call name to its mapped class name
|
||||
*
|
||||
* @param string $className
|
||||
* @return string
|
||||
*/
|
||||
public static function getMappedClassName($className)
|
||||
{
|
||||
$mappedName = array_search($className, self::$classMap);
|
||||
|
||||
if ($mappedName) {
|
||||
return $mappedName;
|
||||
}
|
||||
|
||||
$mappedName = array_search($className, array_flip(self::$classMap));
|
||||
|
||||
if ($mappedName) {
|
||||
return $mappedName;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map PHP class names to ActionScript class names
|
||||
*
|
||||
* Allows users to map the class names of there action script classes
|
||||
* to the equivelent php class name. Used in deserialization to load a class
|
||||
* and serialiation to set the class name of the returned object.
|
||||
*
|
||||
* @param string $asClassName
|
||||
* @param string $phpClassName
|
||||
* @return void
|
||||
*/
|
||||
public static function setMapping($asClassName, $phpClassName)
|
||||
{
|
||||
self::$classMap[$asClassName] = $phpClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset type map
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function resetMap()
|
||||
{
|
||||
self::$classMap = self::$_defaultClassMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set loader for resource type handlers
|
||||
*
|
||||
* @param Zend_Loader_PluginLoader_Interface $loader
|
||||
*/
|
||||
public static function setResourceLoader(Zend_Loader_PluginLoader_Interface $loader)
|
||||
{
|
||||
self::$_resourceLoader = $loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add directory to the list of places where to look for resource handlers
|
||||
*
|
||||
* @param string $prefix
|
||||
* @param string $dir
|
||||
*/
|
||||
public static function addResourceDirectory($prefix, $dir)
|
||||
{
|
||||
if(self::$_resourceLoader) {
|
||||
self::$_resourceLoader->addPrefixPath($prefix, $dir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plugin class that handles this resource
|
||||
*
|
||||
* @param resource $resource Resource type
|
||||
* @return string Class name
|
||||
*/
|
||||
public static function getResourceParser($resource)
|
||||
{
|
||||
if(self::$_resourceLoader) {
|
||||
$type = preg_replace("/[^A-Za-z0-9_]/", " ", get_resource_type($resource));
|
||||
$type = str_replace(" ","", ucwords($type));
|
||||
return self::$_resourceLoader->load($type);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert resource to a serializable object
|
||||
*
|
||||
* @param resource $resource
|
||||
* @return mixed
|
||||
*/
|
||||
public static function handleResource($resource)
|
||||
{
|
||||
if(!self::$_resourceLoader) {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Unable to handle resources - resource plugin loader not set');
|
||||
}
|
||||
try {
|
||||
while(is_resource($resource)) {
|
||||
$resclass = self::getResourceParser($resource);
|
||||
if(!$resclass) {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Can not serialize resource type: '. get_resource_type($resource));
|
||||
}
|
||||
$parser = new $resclass();
|
||||
if(is_callable(array($parser, 'parse'))) {
|
||||
$resource = $parser->parse($resource);
|
||||
} else {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception("Could not call parse() method on class $resclass");
|
||||
}
|
||||
}
|
||||
return $resource;
|
||||
} catch(Zend_Amf_Exception $e) {
|
||||
throw new Zend_Amf_Exception($e->getMessage(), $e->getCode(), $e);
|
||||
} catch(Exception $e) {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Can not serialize resource type: '. get_resource_type($resource), 0, $e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,251 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Request.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/** @see Zend_Amf_Parse_InputStream */
|
||||
require_once 'Zend/Amf/Parse/InputStream.php';
|
||||
|
||||
/** @see Zend_Amf_Parse_Amf0_Deserializer */
|
||||
require_once 'Zend/Amf/Parse/Amf0/Deserializer.php';
|
||||
|
||||
/** @see Zend_Amf_Constants */
|
||||
require_once 'Zend/Amf/Constants.php';
|
||||
|
||||
/** @see Zend_Amf_Value_MessageHeader */
|
||||
require_once 'Zend/Amf/Value/MessageHeader.php';
|
||||
|
||||
/** @see Zend_Amf_Value_MessageBody */
|
||||
require_once 'Zend/Amf/Value/MessageBody.php';
|
||||
|
||||
/**
|
||||
* Handle the incoming AMF request by deserializing the data to php object
|
||||
* types and storing the data for Zend_Amf_Server to handle for processing.
|
||||
*
|
||||
* @todo Currently not checking if the object needs to be Type Mapped to a server object.
|
||||
* @package Zend_Amf
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Request
|
||||
{
|
||||
/**
|
||||
* @var int AMF client type (AMF0, AMF3)
|
||||
*/
|
||||
protected $_clientType = 0; // default AMF0
|
||||
|
||||
/**
|
||||
* @var array Message bodies
|
||||
*/
|
||||
protected $_bodies = array();
|
||||
|
||||
/**
|
||||
* @var array Message headers
|
||||
*/
|
||||
protected $_headers = array();
|
||||
|
||||
/**
|
||||
* @var int Message encoding to use for objects in response
|
||||
*/
|
||||
protected $_objectEncoding = 0;
|
||||
|
||||
/**
|
||||
* @var Zend_Amf_Parse_InputStream
|
||||
*/
|
||||
protected $_inputStream;
|
||||
|
||||
/**
|
||||
* @var Zend_Amf_Parse_AMF0_Deserializer
|
||||
*/
|
||||
protected $_deserializer;
|
||||
|
||||
/**
|
||||
* Time of the request
|
||||
* @var mixed
|
||||
*/
|
||||
protected $_time;
|
||||
|
||||
/**
|
||||
* Prepare the AMF InputStream for parsing.
|
||||
*
|
||||
* @param string $request
|
||||
* @return Zend_Amf_Request
|
||||
*/
|
||||
public function initialize($request)
|
||||
{
|
||||
$this->_inputStream = new Zend_Amf_Parse_InputStream($request);
|
||||
$this->_deserializer = new Zend_Amf_Parse_Amf0_Deserializer($this->_inputStream);
|
||||
$this->readMessage($this->_inputStream);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes the raw AMF input stream and converts it into valid PHP objects
|
||||
*
|
||||
* @param Zend_Amf_Parse_InputStream
|
||||
* @return Zend_Amf_Request
|
||||
*/
|
||||
public function readMessage(Zend_Amf_Parse_InputStream $stream)
|
||||
{
|
||||
$clientVersion = $stream->readUnsignedShort();
|
||||
if (($clientVersion != Zend_Amf_Constants::AMF0_OBJECT_ENCODING)
|
||||
&& ($clientVersion != Zend_Amf_Constants::AMF3_OBJECT_ENCODING)
|
||||
&& ($clientVersion != Zend_Amf_Constants::FMS_OBJECT_ENCODING)
|
||||
) {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Unknown Player Version ' . $clientVersion);
|
||||
}
|
||||
|
||||
$this->_bodies = array();
|
||||
$this->_headers = array();
|
||||
$headerCount = $stream->readInt();
|
||||
|
||||
// Iterate through the AMF envelope header
|
||||
while ($headerCount--) {
|
||||
$this->_headers[] = $this->readHeader();
|
||||
}
|
||||
|
||||
// Iterate through the AMF envelope body
|
||||
$bodyCount = $stream->readInt();
|
||||
while ($bodyCount--) {
|
||||
$this->_bodies[] = $this->readBody();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize a message header from the input stream.
|
||||
*
|
||||
* A message header is structured as:
|
||||
* - NAME String
|
||||
* - MUST UNDERSTAND Boolean
|
||||
* - LENGTH Int
|
||||
* - DATA Object
|
||||
*
|
||||
* @return Zend_Amf_Value_MessageHeader
|
||||
*/
|
||||
public function readHeader()
|
||||
{
|
||||
$name = $this->_inputStream->readUTF();
|
||||
$mustRead = (bool)$this->_inputStream->readByte();
|
||||
$length = $this->_inputStream->readLong();
|
||||
|
||||
try {
|
||||
$data = $this->_deserializer->readTypeMarker();
|
||||
} catch (Exception $e) {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Unable to parse ' . $name . ' header data: ' . $e->getMessage() . ' '. $e->getLine(), 0, $e);
|
||||
}
|
||||
|
||||
$header = new Zend_Amf_Value_MessageHeader($name, $mustRead, $data, $length);
|
||||
return $header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize a message body from the input stream
|
||||
*
|
||||
* @return Zend_Amf_Value_MessageBody
|
||||
*/
|
||||
public function readBody()
|
||||
{
|
||||
$targetURI = $this->_inputStream->readUTF();
|
||||
$responseURI = $this->_inputStream->readUTF();
|
||||
$length = $this->_inputStream->readLong();
|
||||
|
||||
try {
|
||||
$data = $this->_deserializer->readTypeMarker();
|
||||
} catch (Exception $e) {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Unable to parse ' . $targetURI . ' body data ' . $e->getMessage(), 0, $e);
|
||||
}
|
||||
|
||||
// Check for AMF3 objectEncoding
|
||||
if ($this->_deserializer->getObjectEncoding() == Zend_Amf_Constants::AMF3_OBJECT_ENCODING) {
|
||||
/*
|
||||
* When and AMF3 message is sent to the server it is nested inside
|
||||
* an AMF0 array called Content. The following code gets the object
|
||||
* out of the content array and sets it as the message data.
|
||||
*/
|
||||
if(is_array($data) && $data[0] instanceof Zend_Amf_Value_Messaging_AbstractMessage){
|
||||
$data = $data[0];
|
||||
}
|
||||
|
||||
// set the encoding so we return our message in AMF3
|
||||
$this->_objectEncoding = Zend_Amf_Constants::AMF3_OBJECT_ENCODING;
|
||||
}
|
||||
|
||||
$body = new Zend_Amf_Value_MessageBody($targetURI, $responseURI, $data);
|
||||
return $body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of the body objects that were found in the amf request.
|
||||
*
|
||||
* @return array {target, response, length, content}
|
||||
*/
|
||||
public function getAmfBodies()
|
||||
{
|
||||
return $this->_bodies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessor to private array of message bodies.
|
||||
*
|
||||
* @param Zend_Amf_Value_MessageBody $message
|
||||
* @return Zend_Amf_Request
|
||||
*/
|
||||
public function addAmfBody(Zend_Amf_Value_MessageBody $message)
|
||||
{
|
||||
$this->_bodies[] = $message;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of headers that were found in the amf request.
|
||||
*
|
||||
* @return array {operation, mustUnderstand, length, param}
|
||||
*/
|
||||
public function getAmfHeaders()
|
||||
{
|
||||
return $this->_headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the either 0 or 3 for respect AMF version
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getObjectEncoding()
|
||||
{
|
||||
return $this->_objectEncoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the object response encoding
|
||||
*
|
||||
* @param mixed $int
|
||||
* @return Zend_Amf_Request
|
||||
*/
|
||||
public function setObjectEncoding($int)
|
||||
{
|
||||
$this->_objectEncoding = $int;
|
||||
return $this;
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Request
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Http.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/** @see Zend_Amf_Request */
|
||||
require_once 'Zend/Amf/Request.php';
|
||||
|
||||
/**
|
||||
* AMF Request object -- Request via HTTP
|
||||
*
|
||||
* Extends {@link Zend_Amf_Request} to accept a request via HTTP. Request is
|
||||
* built at construction time using a raw POST; if no data is available, the
|
||||
* request is declared a fault.
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Request
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Request_Http extends Zend_Amf_Request
|
||||
{
|
||||
/**
|
||||
* Raw AMF request
|
||||
* @var string
|
||||
*/
|
||||
protected $_rawRequest;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Attempts to read from php://input to get raw POST request; if an error
|
||||
* occurs in doing so, or if the AMF body is invalid, the request is declared a
|
||||
* fault.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// php://input allows you to read raw POST data. It is a less memory
|
||||
// intensive alternative to $HTTP_RAW_POST_DATA and does not need any
|
||||
// special php.ini directives
|
||||
$amfRequest = file_get_contents('php://input');
|
||||
|
||||
// Check to make sure that we have data on the input stream.
|
||||
if ($amfRequest != '') {
|
||||
$this->_rawRequest = $amfRequest;
|
||||
$this->initialize($amfRequest);
|
||||
} else {
|
||||
echo '<p>Zend Amf Endpoint</p>' ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve raw AMF Request
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRawRequest()
|
||||
{
|
||||
return $this->_rawRequest;
|
||||
}
|
||||
}
|
|
@ -1,194 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Response.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/** @see Zend_Amf_Constants */
|
||||
require_once 'Zend/Amf/Constants.php';
|
||||
|
||||
/** @see Zend_Amf_Parse_OutputStream */
|
||||
require_once 'Zend/Amf/Parse/OutputStream.php';
|
||||
|
||||
/** @see Zend_Amf_Parse_Amf0_Serializer */
|
||||
require_once 'Zend/Amf/Parse/Amf0/Serializer.php';
|
||||
|
||||
/**
|
||||
* Handles converting the PHP object ready for response back into AMF
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Response
|
||||
{
|
||||
/**
|
||||
* @var int Object encoding for response
|
||||
*/
|
||||
protected $_objectEncoding = 0;
|
||||
|
||||
/**
|
||||
* Array of Zend_Amf_Value_MessageBody objects
|
||||
* @var array
|
||||
*/
|
||||
protected $_bodies = array();
|
||||
|
||||
/**
|
||||
* Array of Zend_Amf_Value_MessageHeader objects
|
||||
* @var array
|
||||
*/
|
||||
protected $_headers = array();
|
||||
|
||||
/**
|
||||
* @var Zend_Amf_Parse_OutputStream
|
||||
*/
|
||||
protected $_outputStream;
|
||||
|
||||
/**
|
||||
* Instantiate new output stream and start serialization
|
||||
*
|
||||
* @return Zend_Amf_Response
|
||||
*/
|
||||
public function finalize()
|
||||
{
|
||||
$this->_outputStream = new Zend_Amf_Parse_OutputStream();
|
||||
$this->writeMessage($this->_outputStream);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the PHP data types back into Actionscript and
|
||||
* create and AMF stream.
|
||||
*
|
||||
* @param Zend_Amf_Parse_OutputStream $stream
|
||||
* @return Zend_Amf_Response
|
||||
*/
|
||||
public function writeMessage(Zend_Amf_Parse_OutputStream $stream)
|
||||
{
|
||||
$objectEncoding = $this->_objectEncoding;
|
||||
|
||||
//Write encoding to start of stream. Preamble byte is written of two byte Unsigned Short
|
||||
$stream->writeByte(0x00);
|
||||
$stream->writeByte($objectEncoding);
|
||||
|
||||
// Loop through the AMF Headers that need to be returned.
|
||||
$headerCount = count($this->_headers);
|
||||
$stream->writeInt($headerCount);
|
||||
foreach ($this->getAmfHeaders() as $header) {
|
||||
$serializer = new Zend_Amf_Parse_Amf0_Serializer($stream);
|
||||
$stream->writeUTF($header->name);
|
||||
$stream->writeByte($header->mustRead);
|
||||
$stream->writeLong(Zend_Amf_Constants::UNKNOWN_CONTENT_LENGTH);
|
||||
$serializer->writeTypeMarker($header->data);
|
||||
}
|
||||
|
||||
// loop through the AMF bodies that need to be returned.
|
||||
$bodyCount = count($this->_bodies);
|
||||
$stream->writeInt($bodyCount);
|
||||
foreach ($this->_bodies as $body) {
|
||||
$serializer = new Zend_Amf_Parse_Amf0_Serializer($stream);
|
||||
$stream->writeUTF($body->getTargetURI());
|
||||
$stream->writeUTF($body->getResponseURI());
|
||||
$stream->writeLong(Zend_Amf_Constants::UNKNOWN_CONTENT_LENGTH);
|
||||
if($this->_objectEncoding == Zend_Amf_Constants::AMF0_OBJECT_ENCODING) {
|
||||
$serializer->writeTypeMarker($body->getData());
|
||||
} else {
|
||||
// Content is AMF3
|
||||
$serializer->writeTypeMarker($body->getData(),Zend_Amf_Constants::AMF0_AMF3);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the output stream content
|
||||
*
|
||||
* @return string The contents of the output stream
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
return $this->_outputStream->getStream();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the output stream content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an AMF body to be sent to the Flash Player
|
||||
*
|
||||
* @param Zend_Amf_Value_MessageBody $body
|
||||
* @return Zend_Amf_Response
|
||||
*/
|
||||
public function addAmfBody(Zend_Amf_Value_MessageBody $body)
|
||||
{
|
||||
$this->_bodies[] = $body;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of AMF bodies to be serialized
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAmfBodies()
|
||||
{
|
||||
return $this->_bodies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an AMF Header to be sent back to the flash player
|
||||
*
|
||||
* @param Zend_Amf_Value_MessageHeader $header
|
||||
* @return Zend_Amf_Response
|
||||
*/
|
||||
public function addAmfHeader(Zend_Amf_Value_MessageHeader $header)
|
||||
{
|
||||
$this->_headers[] = $header;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve attached AMF message headers
|
||||
*
|
||||
* @return array Array of Zend_Amf_Value_MessageHeader objects
|
||||
*/
|
||||
public function getAmfHeaders()
|
||||
{
|
||||
return $this->_headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the AMF encoding that will be used for serialization
|
||||
*
|
||||
* @param int $encoding
|
||||
* @return Zend_Amf_Response
|
||||
*/
|
||||
public function setObjectEncoding($encoding)
|
||||
{
|
||||
$this->_objectEncoding = $encoding;
|
||||
return $this;
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Response
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Http.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/** Zend_Amf_Response */
|
||||
require_once 'Zend/Amf/Response.php';
|
||||
|
||||
/**
|
||||
* Creates the proper http headers and send the serialized AMF stream to standard out.
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Response
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Response_Http extends Zend_Amf_Response
|
||||
{
|
||||
/**
|
||||
* Create the application response header for AMF and sends the serialized AMF string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
if (!headers_sent()) {
|
||||
header('Cache-Control: cache, must-revalidate');
|
||||
header('Pragma: public');
|
||||
header('Content-Type: application/x-amf');
|
||||
}
|
||||
return parent::getResponse();
|
||||
}
|
||||
}
|
|
@ -1,933 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Server.php 21210 2010-02-27 10:37:39Z yoshida@zend.co.jp $
|
||||
*/
|
||||
|
||||
/** @see Zend_Server_Interface */
|
||||
require_once 'Zend/Server/Interface.php';
|
||||
|
||||
/** @see Zend_Server_Reflection */
|
||||
require_once 'Zend/Server/Reflection.php';
|
||||
|
||||
/** @see Zend_Amf_Constants */
|
||||
require_once 'Zend/Amf/Constants.php';
|
||||
|
||||
/** @see Zend_Amf_Value_MessageBody */
|
||||
require_once 'Zend/Amf/Value/MessageBody.php';
|
||||
|
||||
/** @see Zend_Amf_Value_MessageHeader */
|
||||
require_once 'Zend/Amf/Value/MessageHeader.php';
|
||||
|
||||
/** @see Zend_Amf_Value_Messaging_CommandMessage */
|
||||
require_once 'Zend/Amf/Value/Messaging/CommandMessage.php';
|
||||
|
||||
/** @see Zend_Loader_PluginLoader */
|
||||
require_once 'Zend/Loader/PluginLoader.php';
|
||||
|
||||
/** @see Zend_Amf_Parse_TypeLoader */
|
||||
require_once 'Zend/Amf/Parse/TypeLoader.php';
|
||||
|
||||
/** @see Zend_Auth */
|
||||
require_once 'Zend/Auth.php';
|
||||
/**
|
||||
* An AMF gateway server implementation to allow the connection of the Adobe Flash Player to
|
||||
* Zend Framework
|
||||
*
|
||||
* @todo Make the reflection methods cache and autoload.
|
||||
* @package Zend_Amf
|
||||
* @subpackage Server
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Server implements Zend_Server_Interface
|
||||
{
|
||||
/**
|
||||
* Array of dispatchables
|
||||
* @var array
|
||||
*/
|
||||
protected $_methods = array();
|
||||
|
||||
/**
|
||||
* Array of classes that can be called without being explicitly loaded
|
||||
*
|
||||
* Keys are class names.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_classAllowed = array();
|
||||
|
||||
/**
|
||||
* Loader for classes in added directories
|
||||
* @var Zend_Loader_PluginLoader
|
||||
*/
|
||||
protected $_loader;
|
||||
|
||||
/**
|
||||
* @var bool Production flag; whether or not to return exception messages
|
||||
*/
|
||||
protected $_production = true;
|
||||
|
||||
/**
|
||||
* Request processed
|
||||
* @var null|Zend_Amf_Request
|
||||
*/
|
||||
protected $_request = null;
|
||||
|
||||
/**
|
||||
* Class to use for responses
|
||||
* @var null|Zend_Amf_Response
|
||||
*/
|
||||
protected $_response;
|
||||
|
||||
/**
|
||||
* Dispatch table of name => method pairs
|
||||
* @var array
|
||||
*/
|
||||
protected $_table = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @var bool session flag; whether or not to add a session to each response.
|
||||
*/
|
||||
protected $_session = false;
|
||||
|
||||
/**
|
||||
* Namespace allows all AMF calls to not clobber other php session variables
|
||||
* @var Zend_Session_NameSpace default session namespace zend_amf
|
||||
*/
|
||||
protected $_sesionNamespace = 'zend_amf';
|
||||
|
||||
/**
|
||||
* Set the default session.name if php_
|
||||
* @var string
|
||||
*/
|
||||
protected $_sessionName = 'PHPSESSID';
|
||||
|
||||
/**
|
||||
* Authentication handler object
|
||||
*
|
||||
* @var Zend_Amf_Auth_Abstract
|
||||
*/
|
||||
protected $_auth;
|
||||
/**
|
||||
* ACL handler object
|
||||
*
|
||||
* @var Zend_Acl
|
||||
*/
|
||||
protected $_acl;
|
||||
/**
|
||||
* The server constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
Zend_Amf_Parse_TypeLoader::setResourceLoader(new Zend_Loader_PluginLoader(array("Zend_Amf_Parse_Resource" => "Zend/Amf/Parse/Resource")));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set authentication adapter
|
||||
*
|
||||
* @param Zend_Amf_Auth_Abstract $auth
|
||||
* @return Zend_Amf_Server
|
||||
*/
|
||||
public function setAuth(Zend_Amf_Auth_Abstract $auth)
|
||||
{
|
||||
$this->_auth = $auth;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Get authentication adapter
|
||||
*
|
||||
* @return Zend_Amf_Auth_Abstract
|
||||
*/
|
||||
public function getAuth()
|
||||
{
|
||||
return $this->_auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ACL adapter
|
||||
*
|
||||
* @param Zend_Acl $acl
|
||||
* @return Zend_Amf_Server
|
||||
*/
|
||||
public function setAcl(Zend_Acl $acl)
|
||||
{
|
||||
$this->_acl = $acl;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Get ACL adapter
|
||||
*
|
||||
* @return Zend_Acl
|
||||
*/
|
||||
public function getAcl()
|
||||
{
|
||||
return $this->_acl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set production flag
|
||||
*
|
||||
* @param bool $flag
|
||||
* @return Zend_Amf_Server
|
||||
*/
|
||||
public function setProduction($flag)
|
||||
{
|
||||
$this->_production = (bool) $flag;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not the server is in production
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isProduction()
|
||||
{
|
||||
return $this->_production;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param namespace of all incoming sessions defaults to Zend_Amf
|
||||
* @return Zend_Amf_Server
|
||||
*/
|
||||
public function setSession($namespace = 'Zend_Amf')
|
||||
{
|
||||
require_once 'Zend/Session.php';
|
||||
$this->_session = true;
|
||||
$this->_sesionNamespace = new Zend_Session_Namespace($namespace);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether of not the server is using sessions
|
||||
* @return bool
|
||||
*/
|
||||
public function isSession()
|
||||
{
|
||||
return $this->_session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the ACL allows accessing the function or method
|
||||
*
|
||||
* @param string|object $object Object or class being accessed
|
||||
* @param string $function Function or method being accessed
|
||||
* @return unknown_type
|
||||
*/
|
||||
protected function _checkAcl($object, $function)
|
||||
{
|
||||
if(!$this->_acl) {
|
||||
return true;
|
||||
}
|
||||
if($object) {
|
||||
$class = is_object($object)?get_class($object):$object;
|
||||
if(!$this->_acl->has($class)) {
|
||||
require_once 'Zend/Acl/Resource.php';
|
||||
$this->_acl->add(new Zend_Acl_Resource($class));
|
||||
}
|
||||
$call = array($object, "initAcl");
|
||||
if(is_callable($call) && !call_user_func($call, $this->_acl)) {
|
||||
// if initAcl returns false, no ACL check
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
$class = null;
|
||||
}
|
||||
|
||||
$auth = Zend_Auth::getInstance();
|
||||
if($auth->hasIdentity()) {
|
||||
$role = $auth->getIdentity()->role;
|
||||
} else {
|
||||
if($this->_acl->hasRole(Zend_Amf_Constants::GUEST_ROLE)) {
|
||||
$role = Zend_Amf_Constants::GUEST_ROLE;
|
||||
} else {
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception("Unauthenticated access not allowed");
|
||||
}
|
||||
}
|
||||
if($this->_acl->isAllowed($role, $class, $function)) {
|
||||
return true;
|
||||
} else {
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception("Access not allowed");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PluginLoader for the Server
|
||||
*
|
||||
* @return Zend_Loader_PluginLoader
|
||||
*/
|
||||
protected function getLoader()
|
||||
{
|
||||
if(empty($this->_loader)) {
|
||||
require_once 'Zend/Loader/PluginLoader.php';
|
||||
$this->_loader = new Zend_Loader_PluginLoader();
|
||||
}
|
||||
return $this->_loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a remote class or method and executes the function and returns
|
||||
* the result
|
||||
*
|
||||
* @param string $method Is the method to execute
|
||||
* @param mixed $param values for the method
|
||||
* @return mixed $response the result of executing the method
|
||||
* @throws Zend_Amf_Server_Exception
|
||||
*/
|
||||
protected function _dispatch($method, $params = null, $source = null)
|
||||
{
|
||||
if($source) {
|
||||
if(($mapped = Zend_Amf_Parse_TypeLoader::getMappedClassName($source)) !== false) {
|
||||
$source = $mapped;
|
||||
}
|
||||
}
|
||||
$qualifiedName = empty($source) ? $method : $source.".".$method;
|
||||
|
||||
if (!isset($this->_table[$qualifiedName])) {
|
||||
// if source is null a method that was not defined was called.
|
||||
if ($source) {
|
||||
$className = str_replace(".", "_", $source);
|
||||
if(class_exists($className, false) && !isset($this->_classAllowed[$className])) {
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception('Can not call "' . $className . '" - use setClass()');
|
||||
}
|
||||
try {
|
||||
$this->getLoader()->load($className);
|
||||
} catch (Exception $e) {
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception('Class "' . $className . '" does not exist: '.$e->getMessage(), 0, $e);
|
||||
}
|
||||
// Add the new loaded class to the server.
|
||||
$this->setClass($className, $source);
|
||||
} else {
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception('Method "' . $method . '" does not exist');
|
||||
}
|
||||
}
|
||||
|
||||
$info = $this->_table[$qualifiedName];
|
||||
$argv = $info->getInvokeArguments();
|
||||
|
||||
if (0 < count($argv)) {
|
||||
$params = array_merge($params, $argv);
|
||||
}
|
||||
|
||||
if ($info instanceof Zend_Server_Reflection_Function) {
|
||||
$func = $info->getName();
|
||||
$this->_checkAcl(null, $func);
|
||||
$return = call_user_func_array($func, $params);
|
||||
} elseif ($info instanceof Zend_Server_Reflection_Method) {
|
||||
// Get class
|
||||
$class = $info->getDeclaringClass()->getName();
|
||||
if ('static' == $info->isStatic()) {
|
||||
// for some reason, invokeArgs() does not work the same as
|
||||
// invoke(), and expects the first argument to be an object.
|
||||
// So, using a callback if the method is static.
|
||||
$this->_checkAcl($class, $info->getName());
|
||||
$return = call_user_func_array(array($class, $info->getName()), $params);
|
||||
} else {
|
||||
// Object methods
|
||||
try {
|
||||
$object = $info->getDeclaringClass()->newInstance();
|
||||
} catch (Exception $e) {
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception('Error instantiating class ' . $class . ' to invoke method ' . $info->getName() . ': '.$e->getMessage(), 621, $e);
|
||||
}
|
||||
$this->_checkAcl($object, $info->getName());
|
||||
$return = $info->invokeArgs($object, $params);
|
||||
}
|
||||
} else {
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception('Method missing implementation ' . get_class($info));
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles each of the 11 different command message types.
|
||||
*
|
||||
* A command message is a flex.messaging.messages.CommandMessage
|
||||
*
|
||||
* @see Zend_Amf_Value_Messaging_CommandMessage
|
||||
* @param Zend_Amf_Value_Messaging_CommandMessage $message
|
||||
* @return Zend_Amf_Value_Messaging_AcknowledgeMessage
|
||||
*/
|
||||
protected function _loadCommandMessage(Zend_Amf_Value_Messaging_CommandMessage $message)
|
||||
{
|
||||
require_once 'Zend/Amf/Value/Messaging/AcknowledgeMessage.php';
|
||||
switch($message->operation) {
|
||||
case Zend_Amf_Value_Messaging_CommandMessage::DISCONNECT_OPERATION :
|
||||
case Zend_Amf_Value_Messaging_CommandMessage::CLIENT_PING_OPERATION :
|
||||
$return = new Zend_Amf_Value_Messaging_AcknowledgeMessage($message);
|
||||
break;
|
||||
case Zend_Amf_Value_Messaging_CommandMessage::LOGIN_OPERATION :
|
||||
$data = explode(':', base64_decode($message->body));
|
||||
$userid = $data[0];
|
||||
$password = isset($data[1])?$data[1]:"";
|
||||
if(empty($userid)) {
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception('Login failed: username not supplied');
|
||||
}
|
||||
if(!$this->_handleAuth($userid, $password)) {
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception('Authentication failed');
|
||||
}
|
||||
$return = new Zend_Amf_Value_Messaging_AcknowledgeMessage($message);
|
||||
break;
|
||||
case Zend_Amf_Value_Messaging_CommandMessage::LOGOUT_OPERATION :
|
||||
if($this->_auth) {
|
||||
Zend_Auth::getInstance()->clearIdentity();
|
||||
}
|
||||
$return = new Zend_Amf_Value_Messaging_AcknowledgeMessage($message);
|
||||
break;
|
||||
default :
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception('CommandMessage::' . $message->operation . ' not implemented');
|
||||
break;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create appropriate error message
|
||||
*
|
||||
* @param int $objectEncoding Current AMF encoding
|
||||
* @param string $message Message that was being processed when error happened
|
||||
* @param string $description Error description
|
||||
* @param mixed $detail Detailed data about the error
|
||||
* @param int $code Error code
|
||||
* @param int $line Error line
|
||||
* @return Zend_Amf_Value_Messaging_ErrorMessage|array
|
||||
*/
|
||||
protected function _errorMessage($objectEncoding, $message, $description, $detail, $code, $line)
|
||||
{
|
||||
$return = null;
|
||||
switch ($objectEncoding) {
|
||||
case Zend_Amf_Constants::AMF0_OBJECT_ENCODING :
|
||||
return array (
|
||||
'description' => ($this->isProduction ()) ? '' : $description,
|
||||
'detail' => ($this->isProduction ()) ? '' : $detail,
|
||||
'line' => ($this->isProduction ()) ? 0 : $line,
|
||||
'code' => $code
|
||||
);
|
||||
case Zend_Amf_Constants::AMF3_OBJECT_ENCODING :
|
||||
require_once 'Zend/Amf/Value/Messaging/ErrorMessage.php';
|
||||
$return = new Zend_Amf_Value_Messaging_ErrorMessage ( $message );
|
||||
$return->faultString = $this->isProduction () ? '' : $description;
|
||||
$return->faultCode = $code;
|
||||
$return->faultDetail = $this->isProduction () ? '' : $detail;
|
||||
break;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle AMF authentication
|
||||
*
|
||||
* @param string $userid
|
||||
* @param string $password
|
||||
* @return boolean
|
||||
*/
|
||||
protected function _handleAuth( $userid, $password)
|
||||
{
|
||||
if (!$this->_auth) {
|
||||
return true;
|
||||
}
|
||||
$this->_auth->setCredentials($userid, $password);
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$result = $auth->authenticate($this->_auth);
|
||||
if ($result->isValid()) {
|
||||
if (!$this->isSession()) {
|
||||
$this->setSession();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
// authentication failed, good bye
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception(
|
||||
"Authentication failed: " . join("\n",
|
||||
$result->getMessages()), $result->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes the deserialized AMF request and performs any operations.
|
||||
*
|
||||
* @todo should implement and SPL observer pattern for custom AMF headers
|
||||
* @todo DescribeService support
|
||||
* @param Zend_Amf_Request $request
|
||||
* @return Zend_Amf_Response
|
||||
* @throws Zend_Amf_server_Exception|Exception
|
||||
*/
|
||||
protected function _handle(Zend_Amf_Request $request)
|
||||
{
|
||||
// Get the object encoding of the request.
|
||||
$objectEncoding = $request->getObjectEncoding();
|
||||
|
||||
// create a response object to place the output from the services.
|
||||
$response = $this->getResponse();
|
||||
|
||||
// set response encoding
|
||||
$response->setObjectEncoding($objectEncoding);
|
||||
|
||||
$responseBody = $request->getAmfBodies();
|
||||
|
||||
$handleAuth = false;
|
||||
if ($this->_auth) {
|
||||
$headers = $request->getAmfHeaders();
|
||||
if (isset($headers[Zend_Amf_Constants::CREDENTIALS_HEADER]) &&
|
||||
isset($headers[Zend_Amf_Constants::CREDENTIALS_HEADER]->userid)) {
|
||||
$handleAuth = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate through each of the service calls in the AMF request
|
||||
foreach($responseBody as $body)
|
||||
{
|
||||
try {
|
||||
if ($handleAuth) {
|
||||
if ($this->_handleAuth(
|
||||
$headers[Zend_Amf_Constants::CREDENTIALS_HEADER]->userid,
|
||||
$headers[Zend_Amf_Constants::CREDENTIALS_HEADER]->password)) {
|
||||
// use RequestPersistentHeader to clear credentials
|
||||
$response->addAmfHeader(
|
||||
new Zend_Amf_Value_MessageHeader(
|
||||
Zend_Amf_Constants::PERSISTENT_HEADER,
|
||||
false,
|
||||
new Zend_Amf_Value_MessageHeader(
|
||||
Zend_Amf_Constants::CREDENTIALS_HEADER,
|
||||
false, null)));
|
||||
$handleAuth = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($objectEncoding == Zend_Amf_Constants::AMF0_OBJECT_ENCODING) {
|
||||
// AMF0 Object Encoding
|
||||
$targetURI = $body->getTargetURI();
|
||||
$message = '';
|
||||
|
||||
// Split the target string into its values.
|
||||
$source = substr($targetURI, 0, strrpos($targetURI, '.'));
|
||||
|
||||
if ($source) {
|
||||
// Break off method name from namespace into source
|
||||
$method = substr(strrchr($targetURI, '.'), 1);
|
||||
$return = $this->_dispatch($method, $body->getData(), $source);
|
||||
} else {
|
||||
// Just have a method name.
|
||||
$return = $this->_dispatch($targetURI, $body->getData());
|
||||
}
|
||||
} else {
|
||||
// AMF3 read message type
|
||||
$message = $body->getData();
|
||||
if ($message instanceof Zend_Amf_Value_Messaging_CommandMessage) {
|
||||
// async call with command message
|
||||
$return = $this->_loadCommandMessage($message);
|
||||
} elseif ($message instanceof Zend_Amf_Value_Messaging_RemotingMessage) {
|
||||
require_once 'Zend/Amf/Value/Messaging/AcknowledgeMessage.php';
|
||||
$return = new Zend_Amf_Value_Messaging_AcknowledgeMessage($message);
|
||||
$return->body = $this->_dispatch($message->operation, $message->body, $message->source);
|
||||
} else {
|
||||
// Amf3 message sent with netConnection
|
||||
$targetURI = $body->getTargetURI();
|
||||
|
||||
// Split the target string into its values.
|
||||
$source = substr($targetURI, 0, strrpos($targetURI, '.'));
|
||||
|
||||
if ($source) {
|
||||
// Break off method name from namespace into source
|
||||
$method = substr(strrchr($targetURI, '.'), 1);
|
||||
$return = $this->_dispatch($method, $body->getData(), $source);
|
||||
} else {
|
||||
// Just have a method name.
|
||||
$return = $this->_dispatch($targetURI, $body->getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
$responseType = Zend_AMF_Constants::RESULT_METHOD;
|
||||
} catch (Exception $e) {
|
||||
$return = $this->_errorMessage($objectEncoding, $message,
|
||||
$e->getMessage(), $e->getTraceAsString(),$e->getCode(), $e->getLine());
|
||||
$responseType = Zend_AMF_Constants::STATUS_METHOD;
|
||||
}
|
||||
|
||||
$responseURI = $body->getResponseURI() . $responseType;
|
||||
$newBody = new Zend_Amf_Value_MessageBody($responseURI, null, $return);
|
||||
$response->addAmfBody($newBody);
|
||||
}
|
||||
// Add a session header to the body if session is requested.
|
||||
if($this->isSession()) {
|
||||
$currentID = session_id();
|
||||
$joint = "?";
|
||||
if(isset($_SERVER['QUERY_STRING'])) {
|
||||
if(!strpos($_SERVER['QUERY_STRING'], $currentID) !== FALSE) {
|
||||
if(strrpos($_SERVER['QUERY_STRING'], "?") !== FALSE) {
|
||||
$joint = "&";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// create a new AMF message header with the session id as a variable.
|
||||
$sessionValue = $joint . $this->_sessionName . "=" . $currentID;
|
||||
$sessionHeader = new Zend_Amf_Value_MessageHeader(Zend_Amf_Constants::URL_APPEND_HEADER, false, $sessionValue);
|
||||
$response->addAmfHeader($sessionHeader);
|
||||
}
|
||||
|
||||
// serialize the response and return serialized body.
|
||||
$response->finalize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an AMF call from the gateway.
|
||||
*
|
||||
* @param null|Zend_Amf_Request $request Optional
|
||||
* @return Zend_Amf_Response
|
||||
*/
|
||||
public function handle($request = null)
|
||||
{
|
||||
// Check if request was passed otherwise get it from the server
|
||||
if (is_null($request) || !$request instanceof Zend_Amf_Request) {
|
||||
$request = $this->getRequest();
|
||||
} else {
|
||||
$this->setRequest($request);
|
||||
}
|
||||
if ($this->isSession()) {
|
||||
// Check if a session is being sent from the amf call
|
||||
if (isset($_COOKIE[$this->_sessionName])) {
|
||||
session_id($_COOKIE[$this->_sessionName]);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for errors that may have happend in deserialization of Request.
|
||||
try {
|
||||
// Take converted PHP objects and handle service call.
|
||||
// Serialize to Zend_Amf_response for output stream
|
||||
$this->_handle($request);
|
||||
$response = $this->getResponse();
|
||||
} catch (Exception $e) {
|
||||
// Handle any errors in the serialization and service calls.
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception('Handle error: ' . $e->getMessage() . ' ' . $e->getLine(), 0, $e);
|
||||
}
|
||||
|
||||
// Return the Amf serialized output string
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set request object
|
||||
*
|
||||
* @param string|Zend_Amf_Request $request
|
||||
* @return Zend_Amf_Server
|
||||
*/
|
||||
public function setRequest($request)
|
||||
{
|
||||
if (is_string($request) && class_exists($request)) {
|
||||
$request = new $request();
|
||||
if (!$request instanceof Zend_Amf_Request) {
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception('Invalid request class');
|
||||
}
|
||||
} elseif (!$request instanceof Zend_Amf_Request) {
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception('Invalid request object');
|
||||
}
|
||||
$this->_request = $request;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return currently registered request object
|
||||
*
|
||||
* @return null|Zend_Amf_Request
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
if (null === $this->_request) {
|
||||
require_once 'Zend/Amf/Request/Http.php';
|
||||
$this->setRequest(new Zend_Amf_Request_Http());
|
||||
}
|
||||
|
||||
return $this->_request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Public access method to private Zend_Amf_Server_Response reference
|
||||
*
|
||||
* @param string|Zend_Amf_Server_Response $response
|
||||
* @return Zend_Amf_Server
|
||||
*/
|
||||
public function setResponse($response)
|
||||
{
|
||||
if (is_string($response) && class_exists($response)) {
|
||||
$response = new $response();
|
||||
if (!$response instanceof Zend_Amf_Response) {
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception('Invalid response class');
|
||||
}
|
||||
} elseif (!$response instanceof Zend_Amf_Response) {
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception('Invalid response object');
|
||||
}
|
||||
$this->_response = $response;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get a reference to the Zend_Amf_response instance
|
||||
*
|
||||
* @return Zend_Amf_Server_Response
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
if (null === ($response = $this->_response)) {
|
||||
require_once 'Zend/Amf/Response/Http.php';
|
||||
$this->setResponse(new Zend_Amf_Response_Http());
|
||||
}
|
||||
return $this->_response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach a class or object to the server
|
||||
*
|
||||
* Class may be either a class name or an instantiated object. Reflection
|
||||
* is done on the class or object to determine the available public
|
||||
* methods, and each is attached to the server as and available method. If
|
||||
* a $namespace has been provided, that namespace is used to prefix
|
||||
* AMF service call.
|
||||
*
|
||||
* @param string|object $class
|
||||
* @param string $namespace Optional
|
||||
* @param mixed $arg Optional arguments to pass to a method
|
||||
* @return Zend_Amf_Server
|
||||
* @throws Zend_Amf_Server_Exception on invalid input
|
||||
*/
|
||||
public function setClass($class, $namespace = '', $argv = null)
|
||||
{
|
||||
if (is_string($class) && !class_exists($class)){
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception('Invalid method or class');
|
||||
} elseif (!is_string($class) && !is_object($class)) {
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception('Invalid method or class; must be a classname or object');
|
||||
}
|
||||
|
||||
$argv = null;
|
||||
if (2 < func_num_args()) {
|
||||
$argv = array_slice(func_get_args(), 2);
|
||||
}
|
||||
|
||||
// Use the class name as the name space by default.
|
||||
|
||||
if ($namespace == '') {
|
||||
$namespace = is_object($class) ? get_class($class) : $class;
|
||||
}
|
||||
|
||||
$this->_classAllowed[is_object($class) ? get_class($class) : $class] = true;
|
||||
|
||||
$this->_methods[] = Zend_Server_Reflection::reflectClass($class, $argv, $namespace);
|
||||
$this->_buildDispatchTable();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach a function to the server
|
||||
*
|
||||
* Additional arguments to pass to the function at dispatch may be passed;
|
||||
* any arguments following the namespace will be aggregated and passed at
|
||||
* dispatch time.
|
||||
*
|
||||
* @param string|array $function Valid callback
|
||||
* @param string $namespace Optional namespace prefix
|
||||
* @return Zend_Amf_Server
|
||||
* @throws Zend_Amf_Server_Exception
|
||||
*/
|
||||
public function addFunction($function, $namespace = '')
|
||||
{
|
||||
if (!is_string($function) && !is_array($function)) {
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception('Unable to attach function');
|
||||
}
|
||||
|
||||
$argv = null;
|
||||
if (2 < func_num_args()) {
|
||||
$argv = array_slice(func_get_args(), 2);
|
||||
}
|
||||
|
||||
$function = (array) $function;
|
||||
foreach ($function as $func) {
|
||||
if (!is_string($func) || !function_exists($func)) {
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception('Unable to attach function');
|
||||
}
|
||||
$this->_methods[] = Zend_Server_Reflection::reflectFunction($func, $argv, $namespace);
|
||||
}
|
||||
|
||||
$this->_buildDispatchTable();
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates an array of directories in which services can reside.
|
||||
* TODO: add support for prefixes?
|
||||
*
|
||||
* @param string $dir
|
||||
*/
|
||||
public function addDirectory($dir)
|
||||
{
|
||||
$this->getLoader()->addPrefixPath("", $dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of directories that can hold services.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDirectory()
|
||||
{
|
||||
return $this->getLoader()->getPaths("");
|
||||
}
|
||||
|
||||
/**
|
||||
* (Re)Build the dispatch table
|
||||
*
|
||||
* The dispatch table consists of a an array of method name =>
|
||||
* Zend_Server_Reflection_Function_Abstract pairs
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _buildDispatchTable()
|
||||
{
|
||||
$table = array();
|
||||
foreach ($this->_methods as $key => $dispatchable) {
|
||||
if ($dispatchable instanceof Zend_Server_Reflection_Function_Abstract) {
|
||||
$ns = $dispatchable->getNamespace();
|
||||
$name = $dispatchable->getName();
|
||||
$name = empty($ns) ? $name : $ns . '.' . $name;
|
||||
|
||||
if (isset($table[$name])) {
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception('Duplicate method registered: ' . $name);
|
||||
}
|
||||
$table[$name] = $dispatchable;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($dispatchable instanceof Zend_Server_Reflection_Class) {
|
||||
foreach ($dispatchable->getMethods() as $method) {
|
||||
$ns = $method->getNamespace();
|
||||
$name = $method->getName();
|
||||
$name = empty($ns) ? $name : $ns . '.' . $name;
|
||||
|
||||
if (isset($table[$name])) {
|
||||
require_once 'Zend/Amf/Server/Exception.php';
|
||||
throw new Zend_Amf_Server_Exception('Duplicate method registered: ' . $name);
|
||||
}
|
||||
$table[$name] = $method;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->_table = $table;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Raise a server fault
|
||||
*
|
||||
* Unimplemented
|
||||
*
|
||||
* @param string|Exception $fault
|
||||
* @return void
|
||||
*/
|
||||
public function fault($fault = null, $code = 404)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of registered methods
|
||||
*
|
||||
* Returns an array of dispatchables (Zend_Server_Reflection_Function,
|
||||
* _Method, and _Class items).
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return $this->_table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set server persistence
|
||||
*
|
||||
* Unimplemented
|
||||
*
|
||||
* @param mixed $mode
|
||||
* @return void
|
||||
*/
|
||||
public function setPersistence($mode)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Load server definition
|
||||
*
|
||||
* Unimplemented
|
||||
*
|
||||
* @param array $definition
|
||||
* @return void
|
||||
*/
|
||||
public function loadFunctions($definition)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Map ActionScript classes to PHP classes
|
||||
*
|
||||
* @param string $asClass
|
||||
* @param string $phpClass
|
||||
* @return Zend_Amf_Server
|
||||
*/
|
||||
public function setClassMap($asClass, $phpClass)
|
||||
{
|
||||
require_once 'Zend/Amf/Parse/TypeLoader.php';
|
||||
Zend_Amf_Parse_TypeLoader::setMapping($asClass, $phpClass);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* List all available methods
|
||||
*
|
||||
* Returns an array of method names.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listMethods()
|
||||
{
|
||||
return array_keys($this->_table);
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Server
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/** Zend_Amf_Exception */
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
|
||||
/**
|
||||
* Zend_Amf_Server_Exception
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Server
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Server_Exception extends Zend_Amf_Exception
|
||||
{
|
||||
}
|
|
@ -1,285 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Util
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: BinaryStream.php 21210 2010-02-27 10:37:39Z yoshida@zend.co.jp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Utility class to walk through a data stream byte by byte with conventional names
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Util
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Util_BinaryStream
|
||||
{
|
||||
/**
|
||||
* @var string Byte stream
|
||||
*/
|
||||
protected $_stream;
|
||||
|
||||
/**
|
||||
* @var int Length of stream
|
||||
*/
|
||||
protected $_streamLength;
|
||||
|
||||
/**
|
||||
* @var bool BigEndian encoding?
|
||||
*/
|
||||
protected $_bigEndian;
|
||||
|
||||
/**
|
||||
* @var int Current position in stream
|
||||
*/
|
||||
protected $_needle;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Create a reference to a byte stream that is going to be parsed or created
|
||||
* by the methods in the class. Detect if the class should use big or
|
||||
* little Endian encoding.
|
||||
*
|
||||
* @param string $stream use '' if creating a new stream or pass a string if reading.
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($stream)
|
||||
{
|
||||
if (!is_string($stream)) {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Inputdata is not of type String');
|
||||
}
|
||||
|
||||
$this->_stream = $stream;
|
||||
$this->_needle = 0;
|
||||
$this->_streamLength = strlen($stream);
|
||||
$this->_bigEndian = (pack('l', 1) === "\x00\x00\x00\x01");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current stream
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStream()
|
||||
{
|
||||
return $this->_stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the number of bytes in a row for the length supplied.
|
||||
*
|
||||
* @todo Should check that there are enough bytes left in the stream we are about to read.
|
||||
* @param int $length
|
||||
* @return string
|
||||
* @throws Zend_Amf_Exception for buffer underrun
|
||||
*/
|
||||
public function readBytes($length)
|
||||
{
|
||||
if (($length + $this->_needle) > $this->_streamLength) {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Buffer underrun at needle position: ' . $this->_needle . ' while requesting length: ' . $length);
|
||||
}
|
||||
$bytes = substr($this->_stream, $this->_needle, $length);
|
||||
$this->_needle+= $length;
|
||||
return $bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write any length of bytes to the stream
|
||||
*
|
||||
* Usually a string.
|
||||
*
|
||||
* @param string $bytes
|
||||
* @return Zend_Amf_Util_BinaryStream
|
||||
*/
|
||||
public function writeBytes($bytes)
|
||||
{
|
||||
$this->_stream.= $bytes;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a signed byte
|
||||
*
|
||||
* @return int Value is in the range of -128 to 127.
|
||||
*/
|
||||
public function readByte()
|
||||
{
|
||||
if (($this->_needle + 1) > $this->_streamLength) {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Buffer underrun at needle position: ' . $this->_needle . ' while requesting length: ' . $length);
|
||||
}
|
||||
|
||||
return ord($this->_stream{$this->_needle++});
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the passed string into a signed byte on the stream.
|
||||
*
|
||||
* @param string $stream
|
||||
* @return Zend_Amf_Util_BinaryStream
|
||||
*/
|
||||
public function writeByte($stream)
|
||||
{
|
||||
$this->_stream.= pack('c', $stream);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a signed 32-bit integer from the data stream.
|
||||
*
|
||||
* @return int Value is in the range of -2147483648 to 2147483647
|
||||
*/
|
||||
public function readInt()
|
||||
{
|
||||
return ($this->readByte() << 8) + $this->readByte();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write an the integer to the output stream as a 32 bit signed integer
|
||||
*
|
||||
* @param int $stream
|
||||
* @return Zend_Amf_Util_BinaryStream
|
||||
*/
|
||||
public function writeInt($stream)
|
||||
{
|
||||
$this->_stream.= pack('n', $stream);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a UTF-8 string from the data stream
|
||||
*
|
||||
* @return string A UTF-8 string produced by the byte representation of characters
|
||||
*/
|
||||
public function readUtf()
|
||||
{
|
||||
$length = $this->readInt();
|
||||
return $this->readBytes($length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wite a UTF-8 string to the outputstream
|
||||
*
|
||||
* @param string $stream
|
||||
* @return Zend_Amf_Util_BinaryStream
|
||||
*/
|
||||
public function writeUtf($stream)
|
||||
{
|
||||
$this->writeInt(strlen($stream));
|
||||
$this->_stream.= $stream;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a long UTF string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function readLongUtf()
|
||||
{
|
||||
$length = $this->readLong();
|
||||
return $this->readBytes($length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a long UTF string to the buffer
|
||||
*
|
||||
* @param string $stream
|
||||
* @return Zend_Amf_Util_BinaryStream
|
||||
*/
|
||||
public function writeLongUtf($stream)
|
||||
{
|
||||
$this->writeLong(strlen($stream));
|
||||
$this->_stream.= $stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a long numeric value
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public function readLong()
|
||||
{
|
||||
return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write long numeric value to output stream
|
||||
*
|
||||
* @param int|string $stream
|
||||
* @return Zend_Amf_Util_BinaryStream
|
||||
*/
|
||||
public function writeLong($stream)
|
||||
{
|
||||
$this->_stream.= pack('N', $stream);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a 16 bit unsigned short.
|
||||
*
|
||||
* @todo This could use the unpack() w/ S,n, or v
|
||||
* @return double
|
||||
*/
|
||||
public function readUnsignedShort()
|
||||
{
|
||||
$byte1 = $this->readByte();
|
||||
$byte2 = $this->readByte();
|
||||
return (($byte1 << 8) | $byte2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an IEEE 754 double-precision floating point number from the data stream.
|
||||
*
|
||||
* @return double Floating point number
|
||||
*/
|
||||
public function readDouble()
|
||||
{
|
||||
$bytes = substr($this->_stream, $this->_needle, 8);
|
||||
$this->_needle+= 8;
|
||||
|
||||
if (!$this->_bigEndian) {
|
||||
$bytes = strrev($bytes);
|
||||
}
|
||||
|
||||
$double = unpack('dflt', $bytes);
|
||||
return $double['flt'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an IEEE 754 double-precision floating point number from the data stream.
|
||||
*
|
||||
* @param string|double $stream
|
||||
* @return Zend_Amf_Util_BinaryStream
|
||||
*/
|
||||
public function writeDouble($stream)
|
||||
{
|
||||
$stream = pack('d', $stream);
|
||||
if (!$this->_bigEndian) {
|
||||
$stream = strrev($stream);
|
||||
}
|
||||
$this->_stream.= $stream;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: ByteArray.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Wrapper class to store an AMF3 flash.utils.ByteArray
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Value_ByteArray
|
||||
{
|
||||
/**
|
||||
* @var string ByteString Data
|
||||
*/
|
||||
protected $_data = '';
|
||||
|
||||
/**
|
||||
* Create a ByteArray
|
||||
*
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->_data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the byte stream
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->_data;
|
||||
}
|
||||
}
|
|
@ -1,182 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: MessageBody.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* An AMF Message contains information about the actual individual
|
||||
* transaction that is to be performed. It specifies the remote
|
||||
* operation that is to be performed; a local (client) operation
|
||||
* to be invoked upon success; and, the data to be used in the
|
||||
* operation.
|
||||
* <p/>
|
||||
* This Message structure defines how a local client would
|
||||
* invoke a method/operation on a remote server. Additionally,
|
||||
* the response from the Server is structured identically.
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Value_MessageBody
|
||||
{
|
||||
/**
|
||||
* A string describing which operation, function, or method
|
||||
* is to be remotley invoked.
|
||||
* @var string
|
||||
*/
|
||||
protected $_targetUri = "";
|
||||
|
||||
/**
|
||||
* Universal Resource Identifier that uniquely targets the originator's
|
||||
* Object that should receive the server's response. The server will
|
||||
* use this path specification to target the "OnResult()" or "onStatus()"
|
||||
* handlers within the client. For Flash, it specifies an ActionScript
|
||||
* Object path only. The NetResponse object pointed to by the Response Uri
|
||||
* contains the connection state information. Passing/specifying this
|
||||
* provides a convenient mechanism for the client/server to share access
|
||||
* to an object that is managing the state of the shared connection.
|
||||
*
|
||||
* Since the server will use this field in the event of an error,
|
||||
* this field is required even if a successful server request would
|
||||
* not be expected to return a value to the client.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_responseUri = "";
|
||||
|
||||
/**
|
||||
* Contains the actual data associated with the operation. It contains
|
||||
* the client's parameter data that is passed to the server's operation/method.
|
||||
* When serializing a root level data type or a parameter list array, no
|
||||
* name field is included. That is, the data is anonomously represented
|
||||
* as "Type Marker"/"Value" pairs. When serializing member data, the data is
|
||||
* represented as a series of "Name"/"Type"/"Value" combinations.
|
||||
*
|
||||
* For server generated responses, it may contain any ActionScript
|
||||
* data/objects that the server was expected to provide.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_data;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $targetUri
|
||||
* @param string $responseUri
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($targetUri, $responseUri, $data)
|
||||
{
|
||||
$this->setTargetUri($targetUri);
|
||||
$this->setResponseUri($responseUri);
|
||||
$this->setData($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve target Uri
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTargetUri()
|
||||
{
|
||||
return $this->_targetUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set target Uri
|
||||
*
|
||||
* @param string $targetUri
|
||||
* @return Zend_Amf_Value_MessageBody
|
||||
*/
|
||||
public function setTargetUri($targetUri)
|
||||
{
|
||||
if (null === $targetUri) {
|
||||
$targetUri = '';
|
||||
}
|
||||
$this->_targetUri = (string) $targetUri;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get target Uri
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResponseUri()
|
||||
{
|
||||
return $this->_responseUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set response Uri
|
||||
*
|
||||
* @param string $responseUri
|
||||
* @return Zend_Amf_Value_MessageBody
|
||||
*/
|
||||
public function setResponseUri($responseUri)
|
||||
{
|
||||
if (null === $responseUri) {
|
||||
$responseUri = '';
|
||||
}
|
||||
$this->_responseUri = $responseUri;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve response data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set response data
|
||||
*
|
||||
* @param mixed $data
|
||||
* @return Zend_Amf_Value_MessageBody
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->_data = $data;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set reply method
|
||||
*
|
||||
* @param string $methodName
|
||||
* @return Zend_Amf_Value_MessageBody
|
||||
*/
|
||||
public function setReplyMethod($methodName)
|
||||
{
|
||||
if (!preg_match('#^[/?]#', $methodName)) {
|
||||
$this->_targetUri = rtrim($this->_targetUri, '/') . '/';
|
||||
}
|
||||
$this->_targetUri = $this->_targetUri . $methodName;
|
||||
return $this;
|
||||
}
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: MessageHeader.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Message Headers provide context for the processing of the
|
||||
* the AMF Packet and all subsequent Messages.
|
||||
*
|
||||
* Multiple Message Headers may be included within an AMF Packet.
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Value_MessageHeader
|
||||
{
|
||||
/**
|
||||
* Name of the header
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* Flag if the data has to be parsed on return
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $mustRead;
|
||||
|
||||
/**
|
||||
* Length of the data field
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $length;
|
||||
|
||||
/**
|
||||
* Data sent with the header name
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Used to create and store AMF Header data.
|
||||
*
|
||||
* @param String $name
|
||||
* @param Boolean $mustRead
|
||||
* @param misc $content
|
||||
* @param integer $length
|
||||
*/
|
||||
public function __construct($name, $mustRead, $data, $length=null)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->mustRead = (bool) $mustRead;
|
||||
$this->data = $data;
|
||||
if (null !== $length) {
|
||||
$this->length = (int) $length;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: AbstractMessage.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is the default Implementation of Message, which provides
|
||||
* a convenient base for behavior and association of common endpoints
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Value_Messaging_AbstractMessage
|
||||
{
|
||||
/**
|
||||
* @var string Client identifier
|
||||
*/
|
||||
public $clientId;
|
||||
|
||||
/**
|
||||
* @var string Destination
|
||||
*/
|
||||
public $destination;
|
||||
|
||||
/**
|
||||
* @var string Message identifier
|
||||
*/
|
||||
public $messageId;
|
||||
|
||||
/**
|
||||
* @var int Message timestamp
|
||||
*/
|
||||
public $timestamp;
|
||||
|
||||
/**
|
||||
* @var int Message TTL
|
||||
*/
|
||||
public $timeToLive;
|
||||
|
||||
/**
|
||||
* @var object Message headers
|
||||
*/
|
||||
public $headers;
|
||||
|
||||
/**
|
||||
* @var string Message body
|
||||
*/
|
||||
public $body;
|
||||
|
||||
/**
|
||||
* generate a unique id
|
||||
*
|
||||
* Format is: ########-####-####-####-############
|
||||
* Where # is an uppercase letter or number
|
||||
* example: 6D9DC7EC-A273-83A9-ABE3-00005FD752D6
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateId()
|
||||
{
|
||||
return sprintf(
|
||||
'%08X-%04X-%04X-%02X%02X-%012X',
|
||||
mt_rand(),
|
||||
mt_rand(0, 65535),
|
||||
bindec(substr_replace(
|
||||
sprintf('%016b', mt_rand(0, 65535)), '0100', 11, 4)
|
||||
),
|
||||
bindec(substr_replace(sprintf('%08b', mt_rand(0, 255)), '01', 5, 2)),
|
||||
mt_rand(0, 255),
|
||||
mt_rand()
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: AcknowledgeMessage.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/** Zend_Amf_Value_Messaging_AsyncMessage */
|
||||
require_once 'Zend/Amf/Value/Messaging/AsyncMessage.php';
|
||||
|
||||
/**
|
||||
* This is the type of message returned by the MessageBroker
|
||||
* to endpoints after the broker has routed an endpoint's message
|
||||
* to a service.
|
||||
*
|
||||
* flex.messaging.messages.AcknowledgeMessage
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Value_Messaging_AcknowledgeMessage extends Zend_Amf_Value_Messaging_AsyncMessage
|
||||
{
|
||||
/**
|
||||
* Create a new Acknowledge Message
|
||||
*
|
||||
* @param unknown_type $message
|
||||
*/
|
||||
public function __construct($message)
|
||||
{
|
||||
$this->clientId = $this->generateId();
|
||||
$this->destination = null;
|
||||
$this->messageId = $this->generateId();
|
||||
$this->timestamp = time().'00';
|
||||
$this->timeToLive = 0;
|
||||
$this->headers = new STDClass();
|
||||
$this->body = null;
|
||||
|
||||
// correleate the two messages
|
||||
if ($message && isset($message->messageId)) {
|
||||
$this->correlationId = $message->messageId;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: ArrayCollection.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Type encapsulating Flex ArrayCollection
|
||||
*
|
||||
* Corresponds to flex.messaging.io.ArrayCollection
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Value_Messaging_ArrayCollection
|
||||
{
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: AsyncMessage.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
|
||||
/** Zend_Amf_Value_Messaging_AbstractMessage */
|
||||
require_once 'Zend/Amf/Value/Messaging/AbstractMessage.php';
|
||||
|
||||
/**
|
||||
* This type of message contains information necessary to perform
|
||||
* point-to-point or publish-subscribe messaging.
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Value_Messaging_AsyncMessage extends Zend_Amf_Value_Messaging_AbstractMessage
|
||||
{
|
||||
/**
|
||||
* The message id to be responded to.
|
||||
* @var String
|
||||
*/
|
||||
public $correlationId;
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: CommandMessage.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Amf_Value_Messaging_AsyncMessage
|
||||
*/
|
||||
require_once 'Zend/Amf/Value/Messaging/AsyncMessage.php';
|
||||
|
||||
/**
|
||||
* A message that represents an infrastructure command passed between
|
||||
* client and server. Subscribe/unsubscribe operations result in
|
||||
* CommandMessage transmissions, as do polling operations.
|
||||
*
|
||||
* Corresponds to flex.messaging.messages.CommandMessage
|
||||
*
|
||||
* Note: THESE VALUES MUST BE THE SAME ON CLIENT AND SERVER
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Value_Messaging_CommandMessage extends Zend_Amf_Value_Messaging_AsyncMessage
|
||||
{
|
||||
/**
|
||||
* This operation is used to subscribe to a remote destination.
|
||||
*/
|
||||
const SUBSCRIBE_OPERATION = 0;
|
||||
|
||||
/**
|
||||
* This operation is used to unsubscribe from a remote destination.
|
||||
*/
|
||||
const UNSUSBSCRIBE_OPERATION = 1;
|
||||
|
||||
/**
|
||||
* This operation is used to poll a remote destination for pending,
|
||||
* undelivered messages.
|
||||
*/
|
||||
const POLL_OPERATION = 2;
|
||||
|
||||
/**
|
||||
* This operation is used by a remote destination to sync missed or cached messages
|
||||
* back to a client as a result of a client issued poll command.
|
||||
*/
|
||||
const CLIENT_SYNC_OPERATION = 4;
|
||||
|
||||
/**
|
||||
* This operation is used to test connectivity over the current channel to
|
||||
* the remote endpoint.
|
||||
*/
|
||||
const CLIENT_PING_OPERATION = 5;
|
||||
|
||||
/**
|
||||
* This operation is used to request a list of failover endpoint URIs
|
||||
* for the remote destination based on cluster membership.
|
||||
*/
|
||||
const CLUSTER_REQUEST_OPERATION = 7;
|
||||
|
||||
/**
|
||||
* This operation is used to send credentials to the endpoint so that
|
||||
* the user can be logged in over the current channel.
|
||||
* The credentials need to be Base64 encoded and stored in the <code>body</code>
|
||||
* of the message.
|
||||
*/
|
||||
const LOGIN_OPERATION = 8;
|
||||
|
||||
/**
|
||||
* This operation is used to log the user out of the current channel, and
|
||||
* will invalidate the server session if the channel is HTTP based.
|
||||
*/
|
||||
const LOGOUT_OPERATION = 9;
|
||||
|
||||
/**
|
||||
* This operation is used to indicate that the client's subscription to a
|
||||
* remote destination has been invalidated.
|
||||
*/
|
||||
const SESSION_INVALIDATE_OPERATION = 10;
|
||||
|
||||
/**
|
||||
* This operation is used by the MultiTopicConsumer to subscribe/unsubscribe
|
||||
* from multiple subtopics/selectors in the same message.
|
||||
*/
|
||||
const MULTI_SUBSCRIBE_OPERATION = 11;
|
||||
|
||||
/**
|
||||
* This operation is used to indicate that a channel has disconnected
|
||||
*/
|
||||
const DISCONNECT_OPERATION = 12;
|
||||
|
||||
/**
|
||||
* This is the default operation for new CommandMessage instances.
|
||||
*/
|
||||
const UNKNOWN_OPERATION = 10000;
|
||||
|
||||
/**
|
||||
* The operation to execute for messages of this type
|
||||
* @var int
|
||||
*/
|
||||
public $operation = self::UNKNOWN_OPERATION;
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: ErrorMessage.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/** @see Zend_Amf_Value_Messaging_AcknowledgeMessage */
|
||||
require_once 'Zend/Amf/Value/Messaging/AcknowledgeMessage.php';
|
||||
|
||||
/**
|
||||
* Creates the error message to report to flex the issue with the call
|
||||
*
|
||||
* Corresponds to flex.messaging.messages.ErrorMessage
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Value_Messaging_ErrorMessage extends Zend_Amf_Value_Messaging_AcknowledgeMessage
|
||||
{
|
||||
/**
|
||||
* Additional data with error
|
||||
* @var object
|
||||
*/
|
||||
public $extendedData = null;
|
||||
|
||||
/**
|
||||
* Error code number
|
||||
* @var string
|
||||
*/
|
||||
public $faultCode;
|
||||
|
||||
/**
|
||||
* Description as to the cause of the error
|
||||
* @var string
|
||||
*/
|
||||
public $faultDetail;
|
||||
|
||||
/**
|
||||
* Short description of error
|
||||
* @var string
|
||||
*/
|
||||
public $faultString = '';
|
||||
|
||||
/**
|
||||
* root cause of error
|
||||
* @var object
|
||||
*/
|
||||
public $rootCause = null;
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: RemotingMessage.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/** Zend_Amf_Value_Messaging_AbstractMessage */
|
||||
require_once 'Zend/Amf/Value/Messaging/AbstractMessage.php';
|
||||
|
||||
/**
|
||||
* This type of message contains information needed to perform
|
||||
* a Remoting invocation.
|
||||
*
|
||||
* Corresponds to flex.messaging.messages.RemotingMessage
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Value_Messaging_RemotingMessage extends Zend_Amf_Value_Messaging_AbstractMessage
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of the service to be called including package name
|
||||
* @var String
|
||||
*/
|
||||
public $source;
|
||||
|
||||
/**
|
||||
* The name of the method to be called
|
||||
* @var string
|
||||
*/
|
||||
public $operation;
|
||||
|
||||
/**
|
||||
* The arguments to call the mathod with
|
||||
* @var array
|
||||
*/
|
||||
public $parameters;
|
||||
|
||||
/**
|
||||
* Create a new Remoting Message
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->clientId = $this->generateId();
|
||||
$this->destination = null;
|
||||
$this->messageId = $this->generateId();
|
||||
$this->timestamp = time().'00';
|
||||
$this->timeToLive = 0;
|
||||
$this->headers = new stdClass();
|
||||
$this->body = null;
|
||||
}
|
||||
}
|
|
@ -1,154 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: TraitsInfo.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Zend_Amf_Value_TraitsInfo
|
||||
*
|
||||
* @package Zend_Amf
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Value_TraitsInfo
|
||||
{
|
||||
/**
|
||||
* @var string Class name
|
||||
*/
|
||||
protected $_className;
|
||||
|
||||
/**
|
||||
* @var bool Whether or not this is a dynamic class
|
||||
*/
|
||||
protected $_dynamic;
|
||||
|
||||
/**
|
||||
* @var bool Whether or not the class is externalizable
|
||||
*/
|
||||
protected $_externalizable;
|
||||
|
||||
/**
|
||||
* @var array Class properties
|
||||
*/
|
||||
protected $_properties;
|
||||
|
||||
/**
|
||||
* Used to keep track of all class traits of an AMF3 object
|
||||
*
|
||||
* @param string $className
|
||||
* @param boolean $dynamic
|
||||
* @param boolean $externalizable
|
||||
* @param boolean $properties
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($className, $dynamic=false, $externalizable=false, $properties=null)
|
||||
{
|
||||
$this->_className = $className;
|
||||
$this->_dynamic = $dynamic;
|
||||
$this->_externalizable = $externalizable;
|
||||
$this->_properties = $properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the class is a dynamic class
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDynamic()
|
||||
{
|
||||
return $this->_dynamic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if class is externalizable
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isExternalizable()
|
||||
{
|
||||
return $this->_externalizable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of properties in the class
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function length()
|
||||
{
|
||||
return count($this->_properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName()
|
||||
{
|
||||
return $this->_className;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an additional property
|
||||
*
|
||||
* @param string $name
|
||||
* @return Zend_Amf_Value_TraitsInfo
|
||||
*/
|
||||
public function addProperty($name)
|
||||
{
|
||||
$this->_properties[] = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add all properties of the class.
|
||||
*
|
||||
* @param array $props
|
||||
* @return Zend_Amf_Value_TraitsInfo
|
||||
*/
|
||||
public function addAllProperties(array $props)
|
||||
{
|
||||
$this->_properties = $props;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the property at a given index
|
||||
*
|
||||
* @param int $index
|
||||
* @return string
|
||||
*/
|
||||
public function getProperty($index)
|
||||
{
|
||||
return $this->_properties[(int) $index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all properties of the class.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAllProperties()
|
||||
{
|
||||
return $this->_properties;
|
||||
}
|
||||
}
|
|
@ -1,405 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Application.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Application
|
||||
{
|
||||
/**
|
||||
* Autoloader to use
|
||||
*
|
||||
* @var Zend_Loader_Autoloader
|
||||
*/
|
||||
protected $_autoloader;
|
||||
|
||||
/**
|
||||
* Bootstrap
|
||||
*
|
||||
* @var Zend_Application_Bootstrap_BootstrapAbstract
|
||||
*/
|
||||
protected $_bootstrap;
|
||||
|
||||
/**
|
||||
* Application environment
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_environment;
|
||||
|
||||
/**
|
||||
* Flattened (lowercase) option keys
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_optionKeys = array();
|
||||
|
||||
/**
|
||||
* Options for Zend_Application
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_options = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Initialize application. Potentially initializes include_paths, PHP
|
||||
* settings, and bootstrap class.
|
||||
*
|
||||
* @param string $environment
|
||||
* @param string|array|Zend_Config $options String path to configuration file, or array/Zend_Config of configuration options
|
||||
* @throws Zend_Application_Exception When invalid options are provided
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($environment, $options = null)
|
||||
{
|
||||
$this->_environment = (string) $environment;
|
||||
|
||||
require_once 'Zend/Loader/Autoloader.php';
|
||||
$this->_autoloader = Zend_Loader_Autoloader::getInstance();
|
||||
|
||||
if (null !== $options) {
|
||||
if (is_string($options)) {
|
||||
$options = $this->_loadConfig($options);
|
||||
} elseif ($options instanceof Zend_Config) {
|
||||
$options = $options->toArray();
|
||||
} elseif (!is_array($options)) {
|
||||
throw new Zend_Application_Exception('Invalid options provided; must be location of config file, a config object, or an array');
|
||||
}
|
||||
|
||||
$this->setOptions($options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve current environment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEnvironment()
|
||||
{
|
||||
return $this->_environment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve autoloader instance
|
||||
*
|
||||
* @return Zend_Loader_Autoloader
|
||||
*/
|
||||
public function getAutoloader()
|
||||
{
|
||||
return $this->_autoloader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set application options
|
||||
*
|
||||
* @param array $options
|
||||
* @throws Zend_Application_Exception When no bootstrap path is provided
|
||||
* @throws Zend_Application_Exception When invalid bootstrap information are provided
|
||||
* @return Zend_Application
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
if (!empty($options['config'])) {
|
||||
if (is_array($options['config'])) {
|
||||
$_options = array();
|
||||
foreach ($options['config'] as $tmp) {
|
||||
$_options = $this->mergeOptions($_options, $this->_loadConfig($tmp));
|
||||
}
|
||||
$options = $this->mergeOptions($_options, $options);
|
||||
} else {
|
||||
$options = $this->mergeOptions($this->_loadConfig($options['config']), $options);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_options = $options;
|
||||
|
||||
$options = array_change_key_case($options, CASE_LOWER);
|
||||
|
||||
$this->_optionKeys = array_keys($options);
|
||||
|
||||
if (!empty($options['phpsettings'])) {
|
||||
$this->setPhpSettings($options['phpsettings']);
|
||||
}
|
||||
|
||||
if (!empty($options['includepaths'])) {
|
||||
$this->setIncludePaths($options['includepaths']);
|
||||
}
|
||||
|
||||
if (!empty($options['autoloadernamespaces'])) {
|
||||
$this->setAutoloaderNamespaces($options['autoloadernamespaces']);
|
||||
}
|
||||
|
||||
if (!empty($options['autoloaderzfpath'])) {
|
||||
$autoloader = $this->getAutoloader();
|
||||
if (method_exists($autoloader, 'setZfPath')) {
|
||||
$zfPath = $options['autoloaderzfpath'];
|
||||
$zfVersion = !empty($options['autoloaderzfversion'])
|
||||
? $options['autoloaderzfversion']
|
||||
: 'latest';
|
||||
$autoloader->setZfPath($zfPath, $zfVersion);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($options['bootstrap'])) {
|
||||
$bootstrap = $options['bootstrap'];
|
||||
|
||||
if (is_string($bootstrap)) {
|
||||
$this->setBootstrap($bootstrap);
|
||||
} elseif (is_array($bootstrap)) {
|
||||
if (empty($bootstrap['path'])) {
|
||||
throw new Zend_Application_Exception('No bootstrap path provided');
|
||||
}
|
||||
|
||||
$path = $bootstrap['path'];
|
||||
$class = null;
|
||||
|
||||
if (!empty($bootstrap['class'])) {
|
||||
$class = $bootstrap['class'];
|
||||
}
|
||||
|
||||
$this->setBootstrap($path, $class);
|
||||
} else {
|
||||
throw new Zend_Application_Exception('Invalid bootstrap information provided');
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve application options (for caching)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
return $this->_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is an option present?
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function hasOption($key)
|
||||
{
|
||||
return in_array(strtolower($key), $this->_optionKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single option
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOption($key)
|
||||
{
|
||||
if ($this->hasOption($key)) {
|
||||
$options = $this->getOptions();
|
||||
$options = array_change_key_case($options, CASE_LOWER);
|
||||
return $options[strtolower($key)];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge options recursively
|
||||
*
|
||||
* @param array $array1
|
||||
* @param mixed $array2
|
||||
* @return array
|
||||
*/
|
||||
public function mergeOptions(array $array1, $array2 = null)
|
||||
{
|
||||
if (is_array($array2)) {
|
||||
foreach ($array2 as $key => $val) {
|
||||
if (is_array($array2[$key])) {
|
||||
$array1[$key] = (array_key_exists($key, $array1) && is_array($array1[$key]))
|
||||
? $this->mergeOptions($array1[$key], $array2[$key])
|
||||
: $array2[$key];
|
||||
} else {
|
||||
$array1[$key] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $array1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set PHP configuration settings
|
||||
*
|
||||
* @param array $settings
|
||||
* @param string $prefix Key prefix to prepend to array values (used to map . separated INI values)
|
||||
* @return Zend_Application
|
||||
*/
|
||||
public function setPhpSettings(array $settings, $prefix = '')
|
||||
{
|
||||
foreach ($settings as $key => $value) {
|
||||
$key = empty($prefix) ? $key : $prefix . $key;
|
||||
if (is_scalar($value)) {
|
||||
ini_set($key, $value);
|
||||
} elseif (is_array($value)) {
|
||||
$this->setPhpSettings($value, $key . '.');
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set include path
|
||||
*
|
||||
* @param array $paths
|
||||
* @return Zend_Application
|
||||
*/
|
||||
public function setIncludePaths(array $paths)
|
||||
{
|
||||
$path = implode(PATH_SEPARATOR, $paths);
|
||||
set_include_path($path . PATH_SEPARATOR . get_include_path());
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set autoloader namespaces
|
||||
*
|
||||
* @param array $namespaces
|
||||
* @return Zend_Application
|
||||
*/
|
||||
public function setAutoloaderNamespaces(array $namespaces)
|
||||
{
|
||||
$autoloader = $this->getAutoloader();
|
||||
|
||||
foreach ($namespaces as $namespace) {
|
||||
$autoloader->registerNamespace($namespace);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bootstrap path/class
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $class
|
||||
* @return Zend_Application
|
||||
*/
|
||||
public function setBootstrap($path, $class = null)
|
||||
{
|
||||
// setOptions() can potentially send a null value; specify default
|
||||
// here
|
||||
if (null === $class) {
|
||||
$class = 'Bootstrap';
|
||||
}
|
||||
|
||||
if (!class_exists($class, false)) {
|
||||
require_once $path;
|
||||
if (!class_exists($class, false)) {
|
||||
throw new Zend_Application_Exception('Bootstrap class not found');
|
||||
}
|
||||
}
|
||||
$this->_bootstrap = new $class($this);
|
||||
|
||||
if (!$this->_bootstrap instanceof Zend_Application_Bootstrap_Bootstrapper) {
|
||||
throw new Zend_Application_Exception('Bootstrap class does not implement Zend_Application_Bootstrap_Bootstrapper');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bootstrap object
|
||||
*
|
||||
* @return Zend_Application_Bootstrap_BootstrapAbstract
|
||||
*/
|
||||
public function getBootstrap()
|
||||
{
|
||||
if (null === $this->_bootstrap) {
|
||||
$this->_bootstrap = new Zend_Application_Bootstrap_Bootstrap($this);
|
||||
}
|
||||
return $this->_bootstrap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap application
|
||||
*
|
||||
* @param null|string|array $resource
|
||||
* @return Zend_Application
|
||||
*/
|
||||
public function bootstrap($resource = null)
|
||||
{
|
||||
$this->getBootstrap()->bootstrap($resource);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the application
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->getBootstrap()->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load configuration file of options
|
||||
*
|
||||
* @param string $file
|
||||
* @throws Zend_Application_Exception When invalid configuration file is provided
|
||||
* @return array
|
||||
*/
|
||||
protected function _loadConfig($file)
|
||||
{
|
||||
$environment = $this->getEnvironment();
|
||||
$suffix = strtolower(pathinfo($file, PATHINFO_EXTENSION));
|
||||
|
||||
switch ($suffix) {
|
||||
case 'ini':
|
||||
$config = new Zend_Config_Ini($file, $environment);
|
||||
break;
|
||||
|
||||
case 'xml':
|
||||
$config = new Zend_Config_Xml($file, $environment);
|
||||
break;
|
||||
|
||||
case 'php':
|
||||
case 'inc':
|
||||
$config = include $file;
|
||||
if (!is_array($config)) {
|
||||
throw new Zend_Application_Exception('Invalid configuration file provided; PHP file does not return array value');
|
||||
}
|
||||
return $config;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Zend_Application_Exception('Invalid configuration file provided; unknown config type');
|
||||
}
|
||||
|
||||
return $config->toArray();
|
||||
}
|
||||
}
|
|
@ -1,156 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Bootstrap
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Bootstrap.php 20886 2010-02-03 19:36:06Z matthew $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Concrete base class for bootstrap classes
|
||||
*
|
||||
* Registers and utilizes Zend_Controller_Front by default.
|
||||
*
|
||||
* @uses Zend_Application_Bootstrap_Bootstrap
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Bootstrap
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Application_Bootstrap_Bootstrap
|
||||
extends Zend_Application_Bootstrap_BootstrapAbstract
|
||||
{
|
||||
/**
|
||||
* Application resource namespace
|
||||
* @var false|string
|
||||
*/
|
||||
protected $_appNamespace = false;
|
||||
|
||||
/**
|
||||
* Application resource autoloader
|
||||
* @var Zend_Loader_Autoloader_Resource
|
||||
*/
|
||||
protected $_resourceLoader;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Ensure FrontController resource is registered
|
||||
*
|
||||
* @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($application)
|
||||
{
|
||||
parent::__construct($application);
|
||||
|
||||
if ($application->hasOption('resourceloader')) {
|
||||
$this->setOptions(array(
|
||||
'resourceloader' => $application->getOption('resourceloader')
|
||||
));
|
||||
}
|
||||
$this->getResourceLoader();
|
||||
|
||||
if (!$this->hasPluginResource('FrontController')) {
|
||||
$this->registerPluginResource('FrontController');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the application
|
||||
*
|
||||
* Checks to see that we have a default controller directory. If not, an
|
||||
* exception is thrown.
|
||||
*
|
||||
* If so, it registers the bootstrap with the 'bootstrap' parameter of
|
||||
* the front controller, and dispatches the front controller.
|
||||
*
|
||||
* @return mixed
|
||||
* @throws Zend_Application_Bootstrap_Exception
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$front = $this->getResource('FrontController');
|
||||
$default = $front->getDefaultModule();
|
||||
if (null === $front->getControllerDirectory($default)) {
|
||||
throw new Zend_Application_Bootstrap_Exception(
|
||||
'No default controller directory registered with front controller'
|
||||
);
|
||||
}
|
||||
|
||||
$front->setParam('bootstrap', $this);
|
||||
$response = $front->dispatch();
|
||||
if ($front->returnResponse()) {
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set module resource loader
|
||||
*
|
||||
* @param Zend_Loader_Autoloader_Resource $loader
|
||||
* @return Zend_Application_Module_Bootstrap
|
||||
*/
|
||||
public function setResourceLoader(Zend_Loader_Autoloader_Resource $loader)
|
||||
{
|
||||
$this->_resourceLoader = $loader;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve module resource loader
|
||||
*
|
||||
* @return Zend_Loader_Autoloader_Resource
|
||||
*/
|
||||
public function getResourceLoader()
|
||||
{
|
||||
if ((null === $this->_resourceLoader)
|
||||
&& (false !== ($namespace = $this->getAppNamespace()))
|
||||
) {
|
||||
$r = new ReflectionClass($this);
|
||||
$path = $r->getFileName();
|
||||
$this->setResourceLoader(new Zend_Application_Module_Autoloader(array(
|
||||
'namespace' => $namespace,
|
||||
'basePath' => dirname($path),
|
||||
)));
|
||||
}
|
||||
return $this->_resourceLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get application namespace (used for module autoloading)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAppNamespace()
|
||||
{
|
||||
return $this->_appNamespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set application namespace (for module autoloading)
|
||||
*
|
||||
* @param string
|
||||
* @return Zend_Application_Bootstrap_Bootstrap
|
||||
*/
|
||||
public function setAppNamespace($value)
|
||||
{
|
||||
$this->_appNamespace = (string) $value;
|
||||
return $this;
|
||||
}
|
||||
}
|
|
@ -1,768 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Bootstrap
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: BootstrapAbstract.php 20988 2010-02-08 16:44:44Z matthew $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Abstract base class for bootstrap classes
|
||||
*
|
||||
* @uses Zend_Application_Bootstrap_Bootstrapper
|
||||
* @uses Zend_Application_Bootstrap_ResourceBootstrapper
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Bootstrap
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Application_Bootstrap_BootstrapAbstract
|
||||
implements Zend_Application_Bootstrap_Bootstrapper,
|
||||
Zend_Application_Bootstrap_ResourceBootstrapper
|
||||
{
|
||||
/**
|
||||
* @var Zend_Application|Zend_Application_Bootstrap_Bootstrapper
|
||||
*/
|
||||
protected $_application;
|
||||
|
||||
/**
|
||||
* @var array Internal resource methods (resource/method pairs)
|
||||
*/
|
||||
protected $_classResources;
|
||||
|
||||
/**
|
||||
* @var object Resource container
|
||||
*/
|
||||
protected $_container;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_environment;
|
||||
|
||||
/**
|
||||
* Flattened (lowercase) option keys used for lookups
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_optionKeys = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_options = array();
|
||||
|
||||
/**
|
||||
* @var Zend_Loader_PluginLoader_Interface
|
||||
*/
|
||||
protected $_pluginLoader;
|
||||
|
||||
/**
|
||||
* @var array Class-based resource plugins
|
||||
*/
|
||||
protected $_pluginResources = array();
|
||||
|
||||
/**
|
||||
* @var array Initializers that have been run
|
||||
*/
|
||||
protected $_run = array();
|
||||
|
||||
/**
|
||||
* @var array Initializers that have been started but not yet completed (circular dependency detection)
|
||||
*/
|
||||
protected $_started = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Sets application object, initializes options, and prepares list of
|
||||
* initializer methods.
|
||||
*
|
||||
* @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
|
||||
* @return void
|
||||
* @throws Zend_Application_Bootstrap_Exception When invalid applicaiton is provided
|
||||
*/
|
||||
public function __construct($application)
|
||||
{
|
||||
$this->setApplication($application);
|
||||
$options = $application->getOptions();
|
||||
$this->setOptions($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set class state
|
||||
*
|
||||
* @param array $options
|
||||
* @return Zend_Application_Bootstrap_BootstrapAbstract
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
$this->_options = $this->mergeOptions($this->_options, $options);
|
||||
|
||||
$options = array_change_key_case($options, CASE_LOWER);
|
||||
$this->_optionKeys = array_merge($this->_optionKeys, array_keys($options));
|
||||
|
||||
$methods = get_class_methods($this);
|
||||
foreach ($methods as $key => $method) {
|
||||
$methods[$key] = strtolower($method);
|
||||
}
|
||||
|
||||
if (array_key_exists('pluginpaths', $options)) {
|
||||
$pluginLoader = $this->getPluginLoader();
|
||||
|
||||
foreach ($options['pluginpaths'] as $prefix => $path) {
|
||||
$pluginLoader->addPrefixPath($prefix, $path);
|
||||
}
|
||||
unset($options['pluginpaths']);
|
||||
}
|
||||
|
||||
foreach ($options as $key => $value) {
|
||||
$method = 'set' . strtolower($key);
|
||||
|
||||
if (in_array($method, $methods)) {
|
||||
$this->$method($value);
|
||||
} elseif ('resources' == $key) {
|
||||
foreach ($value as $resource => $resourceOptions) {
|
||||
$this->registerPluginResource($resource, $resourceOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current options from bootstrap
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
return $this->_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is an option present?
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function hasOption($key)
|
||||
{
|
||||
return in_array($key, $this->_optionKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single option
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOption($key)
|
||||
{
|
||||
if ($this->hasOption($key)) {
|
||||
$options = $this->getOptions();
|
||||
$options = array_change_key_case($options, CASE_LOWER);
|
||||
return $options[strtolower($key)];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge options recursively
|
||||
*
|
||||
* @param array $array1
|
||||
* @param mixed $array2
|
||||
* @return array
|
||||
*/
|
||||
public function mergeOptions(array $array1, $array2 = null)
|
||||
{
|
||||
if (is_array($array2)) {
|
||||
foreach ($array2 as $key => $val) {
|
||||
if (is_array($array2[$key])) {
|
||||
$array1[$key] = (array_key_exists($key, $array1) && is_array($array1[$key]))
|
||||
? $this->mergeOptions($array1[$key], $array2[$key])
|
||||
: $array2[$key];
|
||||
} else {
|
||||
$array1[$key] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $array1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get class resources (as resource/method pairs)
|
||||
*
|
||||
* Uses get_class_methods() by default, reflection on prior to 5.2.6,
|
||||
* as a bug prevents the usage of get_class_methods() there.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getClassResources()
|
||||
{
|
||||
if (null === $this->_classResources) {
|
||||
if (version_compare(PHP_VERSION, '5.2.6') === -1) {
|
||||
$class = new ReflectionObject($this);
|
||||
$classMethods = $class->getMethods();
|
||||
$methodNames = array();
|
||||
|
||||
foreach ($classMethods as $method) {
|
||||
$methodNames[] = $method->getName();
|
||||
}
|
||||
} else {
|
||||
$methodNames = get_class_methods($this);
|
||||
}
|
||||
|
||||
$this->_classResources = array();
|
||||
foreach ($methodNames as $method) {
|
||||
if (5 < strlen($method) && '_init' === substr($method, 0, 5)) {
|
||||
$this->_classResources[strtolower(substr($method, 5))] = $method;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_classResources;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get class resource names
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getClassResourceNames()
|
||||
{
|
||||
$resources = $this->getClassResources();
|
||||
return array_keys($resources);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new resource plugin
|
||||
*
|
||||
* @param string|Zend_Application_Resource_Resource $resource
|
||||
* @param mixed $options
|
||||
* @return Zend_Application_Bootstrap_BootstrapAbstract
|
||||
* @throws Zend_Application_Bootstrap_Exception When invalid resource is provided
|
||||
*/
|
||||
public function registerPluginResource($resource, $options = null)
|
||||
{
|
||||
if ($resource instanceof Zend_Application_Resource_Resource) {
|
||||
$resource->setBootstrap($this);
|
||||
$pluginName = $this->_resolvePluginResourceName($resource);
|
||||
$this->_pluginResources[$pluginName] = $resource;
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!is_string($resource)) {
|
||||
throw new Zend_Application_Bootstrap_Exception('Invalid resource provided to ' . __METHOD__);
|
||||
}
|
||||
|
||||
$this->_pluginResources[$resource] = $options;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a resource from the bootstrap
|
||||
*
|
||||
* @param string|Zend_Application_Resource_Resource $resource
|
||||
* @return Zend_Application_Bootstrap_BootstrapAbstract
|
||||
* @throws Zend_Application_Bootstrap_Exception When unknown resource type is provided
|
||||
*/
|
||||
public function unregisterPluginResource($resource)
|
||||
{
|
||||
if ($resource instanceof Zend_Application_Resource_Resource) {
|
||||
if ($index = array_search($resource, $this->_pluginResources, true)) {
|
||||
unset($this->_pluginResources[$index]);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!is_string($resource)) {
|
||||
throw new Zend_Application_Bootstrap_Exception('Unknown resource type provided to ' . __METHOD__);
|
||||
}
|
||||
|
||||
$resource = strtolower($resource);
|
||||
if (array_key_exists($resource, $this->_pluginResources)) {
|
||||
unset($this->_pluginResources[$resource]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the requested plugin resource registered?
|
||||
*
|
||||
* @param string $resource
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPluginResource($resource)
|
||||
{
|
||||
return (null !== $this->getPluginResource($resource));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a registered plugin resource
|
||||
*
|
||||
* @param string $resourceName
|
||||
* @return Zend_Application_Resource_Resource
|
||||
*/
|
||||
public function getPluginResource($resource)
|
||||
{
|
||||
if (array_key_exists(strtolower($resource), $this->_pluginResources)) {
|
||||
$resource = strtolower($resource);
|
||||
if (!$this->_pluginResources[$resource] instanceof Zend_Application_Resource_Resource) {
|
||||
$resourceName = $this->_loadPluginResource($resource, $this->_pluginResources[$resource]);
|
||||
if (!$resourceName) {
|
||||
throw new Zend_Application_Bootstrap_Exception(sprintf('Unable to resolve plugin "%s"; no corresponding plugin with that name', $resource));
|
||||
}
|
||||
$resource = $resourceName;
|
||||
}
|
||||
return $this->_pluginResources[$resource];
|
||||
}
|
||||
|
||||
foreach ($this->_pluginResources as $plugin => $spec) {
|
||||
if ($spec instanceof Zend_Application_Resource_Resource) {
|
||||
$pluginName = $this->_resolvePluginResourceName($spec);
|
||||
if (0 === strcasecmp($resource, $pluginName)) {
|
||||
unset($this->_pluginResources[$plugin]);
|
||||
$this->_pluginResources[$pluginName] = $spec;
|
||||
return $spec;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (false !== $pluginName = $this->_loadPluginResource($plugin, $spec)) {
|
||||
if (0 === strcasecmp($resource, $pluginName)) {
|
||||
return $this->_pluginResources[$pluginName];
|
||||
}
|
||||
}
|
||||
|
||||
if (class_exists($plugin)) { //@SEE ZF-7550
|
||||
$spec = (array) $spec;
|
||||
$spec['bootstrap'] = $this;
|
||||
$instance = new $plugin($spec);
|
||||
$pluginName = $this->_resolvePluginResourceName($instance);
|
||||
unset($this->_pluginResources[$plugin]);
|
||||
$this->_pluginResources[$pluginName] = $instance;
|
||||
|
||||
if (0 === strcasecmp($resource, $pluginName)) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all plugin resources
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPluginResources()
|
||||
{
|
||||
foreach (array_keys($this->_pluginResources) as $resource) {
|
||||
$this->getPluginResource($resource);
|
||||
}
|
||||
return $this->_pluginResources;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve plugin resource names
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPluginResourceNames()
|
||||
{
|
||||
$this->getPluginResources();
|
||||
return array_keys($this->_pluginResources);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set plugin loader for loading resources
|
||||
*
|
||||
* @param Zend_Loader_PluginLoader_Interface $loader
|
||||
* @return Zend_Application_Bootstrap_BootstrapAbstract
|
||||
*/
|
||||
public function setPluginLoader(Zend_Loader_PluginLoader_Interface $loader)
|
||||
{
|
||||
$this->_pluginLoader = $loader;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin loader for resources
|
||||
*
|
||||
* @return Zend_Loader_PluginLoader_Interface
|
||||
*/
|
||||
public function getPluginLoader()
|
||||
{
|
||||
if ($this->_pluginLoader === null) {
|
||||
$options = array(
|
||||
'Zend_Application_Resource' => 'Zend/Application/Resource'
|
||||
);
|
||||
|
||||
$this->_pluginLoader = new Zend_Loader_PluginLoader($options);
|
||||
}
|
||||
|
||||
return $this->_pluginLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set application/parent bootstrap
|
||||
*
|
||||
* @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
|
||||
* @return Zend_Application_Bootstrap_BootstrapAbstract
|
||||
*/
|
||||
public function setApplication($application)
|
||||
{
|
||||
if (($application instanceof Zend_Application)
|
||||
|| ($application instanceof Zend_Application_Bootstrap_Bootstrapper)
|
||||
) {
|
||||
if ($application === $this) {
|
||||
throw new Zend_Application_Bootstrap_Exception('Cannot set application to same object; creates recursion');
|
||||
}
|
||||
$this->_application = $application;
|
||||
} else {
|
||||
throw new Zend_Application_Bootstrap_Exception('Invalid application provided to bootstrap constructor (received "' . get_class($application) . '" instance)');
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve parent application instance
|
||||
*
|
||||
* @return Zend_Application|Zend_Application_Bootstrap_Bootstrapper
|
||||
*/
|
||||
public function getApplication()
|
||||
{
|
||||
return $this->_application;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve application environment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEnvironment()
|
||||
{
|
||||
if (null === $this->_environment) {
|
||||
$this->_environment = $this->getApplication()->getEnvironment();
|
||||
}
|
||||
return $this->_environment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set resource container
|
||||
*
|
||||
* By default, if a resource callback has a non-null return value, this
|
||||
* value will be stored in a container using the resource name as the
|
||||
* key.
|
||||
*
|
||||
* Containers must be objects, and must allow setting public properties.
|
||||
*
|
||||
* @param object $container
|
||||
* @return Zend_Application_Bootstrap_BootstrapAbstract
|
||||
*/
|
||||
public function setContainer($container)
|
||||
{
|
||||
if (!is_object($container)) {
|
||||
throw new Zend_Application_Bootstrap_Exception('Resource containers must be objects');
|
||||
}
|
||||
$this->_container = $container;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve resource container
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function getContainer()
|
||||
{
|
||||
if (null === $this->_container) {
|
||||
$this->setContainer(new Zend_Registry());
|
||||
}
|
||||
return $this->_container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a resource has been stored in the container
|
||||
*
|
||||
* During bootstrap resource initialization, you may return a value. If
|
||||
* you do, it will be stored in the {@link setContainer() container}.
|
||||
* You can use this method to determine if a value was stored.
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function hasResource($name)
|
||||
{
|
||||
$resource = strtolower($name);
|
||||
$container = $this->getContainer();
|
||||
return isset($container->{$resource});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a resource from the container
|
||||
*
|
||||
* During bootstrap resource initialization, you may return a value. If
|
||||
* you do, it will be stored in the {@link setContainer() container}.
|
||||
* You can use this method to retrieve that value.
|
||||
*
|
||||
* If no value was returned, this will return a null value.
|
||||
*
|
||||
* @param string $name
|
||||
* @return null|mixed
|
||||
*/
|
||||
public function getResource($name)
|
||||
{
|
||||
$resource = strtolower($name);
|
||||
$container = $this->getContainer();
|
||||
if ($this->hasResource($resource)) {
|
||||
return $container->{$resource};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP's magic to retrieve a ressource
|
||||
* in the bootstrap
|
||||
*
|
||||
* @param string $prop
|
||||
* @return null|mixed
|
||||
*/
|
||||
public function __get($prop)
|
||||
{
|
||||
return $this->getResource($prop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP's magic to ask for the
|
||||
* existence of a ressource in the bootstrap
|
||||
*
|
||||
* @param string $prop
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset($prop)
|
||||
{
|
||||
return $this->hasResource($prop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap individual, all, or multiple resources
|
||||
*
|
||||
* Marked as final to prevent issues when subclassing and naming the
|
||||
* child class 'Bootstrap' (in which case, overriding this method
|
||||
* would result in it being treated as a constructor).
|
||||
*
|
||||
* If you need to override this functionality, override the
|
||||
* {@link _bootstrap()} method.
|
||||
*
|
||||
* @param null|string|array $resource
|
||||
* @return Zend_Application_Bootstrap_BootstrapAbstract
|
||||
* @throws Zend_Application_Bootstrap_Exception When invalid argument was passed
|
||||
*/
|
||||
final public function bootstrap($resource = null)
|
||||
{
|
||||
$this->_bootstrap($resource);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloading: intercept calls to bootstrap<resourcename>() methods
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $args
|
||||
* @return void
|
||||
* @throws Zend_Application_Bootstrap_Exception On invalid method name
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
if (9 < strlen($method) && 'bootstrap' === substr($method, 0, 9)) {
|
||||
$resource = substr($method, 9);
|
||||
return $this->bootstrap($resource);
|
||||
}
|
||||
|
||||
throw new Zend_Application_Bootstrap_Exception('Invalid method "' . $method . '"');
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap implementation
|
||||
*
|
||||
* This method may be overridden to provide custom bootstrapping logic.
|
||||
* It is the sole method called by {@link bootstrap()}.
|
||||
*
|
||||
* @param null|string|array $resource
|
||||
* @return void
|
||||
* @throws Zend_Application_Bootstrap_Exception When invalid argument was passed
|
||||
*/
|
||||
protected function _bootstrap($resource = null)
|
||||
{
|
||||
if (null === $resource) {
|
||||
foreach ($this->getClassResourceNames() as $resource) {
|
||||
$this->_executeResource($resource);
|
||||
}
|
||||
|
||||
foreach ($this->getPluginResourceNames() as $resource) {
|
||||
$this->_executeResource($resource);
|
||||
}
|
||||
} elseif (is_string($resource)) {
|
||||
$this->_executeResource($resource);
|
||||
} elseif (is_array($resource)) {
|
||||
foreach ($resource as $r) {
|
||||
$this->_executeResource($r);
|
||||
}
|
||||
} else {
|
||||
throw new Zend_Application_Bootstrap_Exception('Invalid argument passed to ' . __METHOD__);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a resource
|
||||
*
|
||||
* Checks to see if the resource has already been run. If not, it searches
|
||||
* first to see if a local method matches the resource, and executes that.
|
||||
* If not, it checks to see if a plugin resource matches, and executes that
|
||||
* if found.
|
||||
*
|
||||
* Finally, if not found, it throws an exception.
|
||||
*
|
||||
* @param string $resource
|
||||
* @return void
|
||||
* @throws Zend_Application_Bootstrap_Exception When resource not found
|
||||
*/
|
||||
protected function _executeResource($resource)
|
||||
{
|
||||
$resourceName = strtolower($resource);
|
||||
|
||||
if (in_array($resourceName, $this->_run)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($this->_started[$resourceName]) && $this->_started[$resourceName]) {
|
||||
throw new Zend_Application_Bootstrap_Exception('Circular resource dependency detected');
|
||||
}
|
||||
|
||||
$classResources = $this->getClassResources();
|
||||
if (array_key_exists($resourceName, $classResources)) {
|
||||
$this->_started[$resourceName] = true;
|
||||
$method = $classResources[$resourceName];
|
||||
$return = $this->$method();
|
||||
unset($this->_started[$resourceName]);
|
||||
$this->_markRun($resourceName);
|
||||
|
||||
if (null !== $return) {
|
||||
$this->getContainer()->{$resourceName} = $return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->hasPluginResource($resource)) {
|
||||
$this->_started[$resourceName] = true;
|
||||
$plugin = $this->getPluginResource($resource);
|
||||
$return = $plugin->init();
|
||||
unset($this->_started[$resourceName]);
|
||||
$this->_markRun($resourceName);
|
||||
|
||||
if (null !== $return) {
|
||||
$this->getContainer()->{$resourceName} = $return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Zend_Application_Bootstrap_Exception('Resource matching "' . $resource . '" not found');
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a plugin resource
|
||||
*
|
||||
* @param string $resource
|
||||
* @param array|object|null $options
|
||||
* @return string|false
|
||||
*/
|
||||
protected function _loadPluginResource($resource, $options)
|
||||
{
|
||||
$options = (array) $options;
|
||||
$options['bootstrap'] = $this;
|
||||
$className = $this->getPluginLoader()->load(strtolower($resource), false);
|
||||
|
||||
if (!$className) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$instance = new $className($options);
|
||||
|
||||
unset($this->_pluginResources[$resource]);
|
||||
|
||||
if (isset($instance->_explicitType)) {
|
||||
$resource = $instance->_explicitType;
|
||||
}
|
||||
$resource = strtolower($resource);
|
||||
$this->_pluginResources[$resource] = $instance;
|
||||
|
||||
return $resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a resource as having run
|
||||
*
|
||||
* @param string $resource
|
||||
* @return void
|
||||
*/
|
||||
protected function _markRun($resource)
|
||||
{
|
||||
if (!in_array($resource, $this->_run)) {
|
||||
$this->_run[] = $resource;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a plugin resource name
|
||||
*
|
||||
* Uses, in order of preference
|
||||
* - $_explicitType property of resource
|
||||
* - Short name of resource (if a matching prefix path is found)
|
||||
* - class name (if none of the above are true)
|
||||
*
|
||||
* The name is then cast to lowercase.
|
||||
*
|
||||
* @param Zend_Application_Resource_Resource $resource
|
||||
* @return string
|
||||
*/
|
||||
protected function _resolvePluginResourceName($resource)
|
||||
{
|
||||
if (isset($resource->_explicitType)) {
|
||||
$pluginName = $resource->_explicitType;
|
||||
} else {
|
||||
$className = get_class($resource);
|
||||
$pluginName = $className;
|
||||
$loader = $this->getPluginLoader();
|
||||
foreach ($loader->getPaths() as $prefix => $paths) {
|
||||
if (0 === strpos($className, $prefix)) {
|
||||
$pluginName = substr($className, strlen($prefix));
|
||||
$pluginName = trim($pluginName, '_');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$pluginName = strtolower($pluginName);
|
||||
return $pluginName;
|
||||
}
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Bootstrap
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Bootstrapper.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface for bootstrap classes
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Bootstrap
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
interface Zend_Application_Bootstrap_Bootstrapper
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Zend_Application $application
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($application);
|
||||
|
||||
/**
|
||||
* Set bootstrap options
|
||||
*
|
||||
* @param array $options
|
||||
* @return Zend_Application_Bootstrap_Bootstrapper
|
||||
*/
|
||||
public function setOptions(array $options);
|
||||
|
||||
/**
|
||||
* Retrieve application object
|
||||
*
|
||||
* @return Zend_Application|Zend_Application_Bootstrap_Bootstrapper
|
||||
*/
|
||||
public function getApplication();
|
||||
|
||||
/**
|
||||
* Retrieve application environment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEnvironment();
|
||||
|
||||
/**
|
||||
* Retrieve list of class resource initializers (_init* methods). Returns
|
||||
* as resource/method pairs.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getClassResources();
|
||||
|
||||
/**
|
||||
* Retrieve list of class resource initializer names (resource names only,
|
||||
* no method names)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getClassResourceNames();
|
||||
|
||||
/**
|
||||
* Bootstrap application or individual resource
|
||||
*
|
||||
* @param null|string $resource
|
||||
* @return mixed
|
||||
*/
|
||||
public function bootstrap($resource = null);
|
||||
|
||||
/**
|
||||
* Run the application
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run();
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Application_Exception
|
||||
*/
|
||||
require_once 'Zend/Application/Exception.php';
|
||||
|
||||
/**
|
||||
* Exception class for Zend_Application
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @uses Zend_Application_Exception
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Application_Bootstrap_Exception extends Zend_Application_Exception
|
||||
{
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Bootstrap
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: ResourceBootstrapper.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface for bootstrap classes that utilize resource plugins
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Bootstrap
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
interface Zend_Application_Bootstrap_ResourceBootstrapper
|
||||
{
|
||||
/**
|
||||
* Register a resource with the bootstrap
|
||||
*
|
||||
* @param string|Zend_Application_Resource_Resource $resource
|
||||
* @param null|array|Zend_Config $options
|
||||
* @return Zend_Application_Bootstrap_ResourceBootstrapper
|
||||
*/
|
||||
public function registerPluginResource($resource, $options = null);
|
||||
|
||||
/**
|
||||
* Unregister a resource from the bootstrap
|
||||
*
|
||||
* @param string|Zend_Application_Resource_Resource $resource
|
||||
* @return Zend_Application_Bootstrap_ResourceBootstrapper
|
||||
*/
|
||||
public function unregisterPluginResource($resource);
|
||||
|
||||
/**
|
||||
* Is the requested resource registered?
|
||||
*
|
||||
* @param string $resource
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPluginResource($resource);
|
||||
|
||||
/**
|
||||
* Retrieve resource
|
||||
*
|
||||
* @param string $resource
|
||||
* @return Zend_Application_Resource_Resource
|
||||
*/
|
||||
public function getPluginResource($resource);
|
||||
|
||||
/**
|
||||
* Get all resources
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPluginResources();
|
||||
|
||||
/**
|
||||
* Get just resource names
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPluginResourceNames();
|
||||
|
||||
/**
|
||||
* Set plugin loader to use to fetch resources
|
||||
*
|
||||
* @param Zend_Loader_PluginLoader_Interface Zend_Loader_PluginLoader
|
||||
* @return Zend_Application_Bootstrap_ResourceBootstrapper
|
||||
*/
|
||||
public function setPluginLoader(Zend_Loader_PluginLoader_Interface $loader);
|
||||
|
||||
/**
|
||||
* Retrieve plugin loader for resources
|
||||
*
|
||||
* @return Zend_Loader_PluginLoader
|
||||
*/
|
||||
public function getPluginLoader();
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Exception
|
||||
*/
|
||||
require_once 'Zend/Exception.php';
|
||||
|
||||
/**
|
||||
* Exception class for Zend_Application
|
||||
*
|
||||
* @uses Zend_Exception
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Application_Exception extends Zend_Exception
|
||||
{
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Module
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @version $Id: Autoloader.php 20250 2010-01-12 22:15:20Z dasprid $
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
/** @see Zend_Loader_Autoloader_Resource */
|
||||
require_once 'Zend/Loader/Autoloader/Resource.php';
|
||||
|
||||
/**
|
||||
* Resource loader for application module classes
|
||||
*
|
||||
* @uses Zend_Loader_Autoloader_Resource
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Module
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Application_Module_Autoloader extends Zend_Loader_Autoloader_Resource
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array|Zend_Config $options
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($options)
|
||||
{
|
||||
parent::__construct($options);
|
||||
$this->initDefaultResourceTypes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize default resource types for module resource classes
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initDefaultResourceTypes()
|
||||
{
|
||||
$basePath = $this->getBasePath();
|
||||
$this->addResourceTypes(array(
|
||||
'dbtable' => array(
|
||||
'namespace' => 'Model_DbTable',
|
||||
'path' => 'models/DbTable',
|
||||
),
|
||||
'mappers' => array(
|
||||
'namespace' => 'Model_Mapper',
|
||||
'path' => 'models/mappers',
|
||||
),
|
||||
'form' => array(
|
||||
'namespace' => 'Form',
|
||||
'path' => 'forms',
|
||||
),
|
||||
'model' => array(
|
||||
'namespace' => 'Model',
|
||||
'path' => 'models',
|
||||
),
|
||||
'plugin' => array(
|
||||
'namespace' => 'Plugin',
|
||||
'path' => 'plugins',
|
||||
),
|
||||
'service' => array(
|
||||
'namespace' => 'Service',
|
||||
'path' => 'services',
|
||||
),
|
||||
'viewhelper' => array(
|
||||
'namespace' => 'View_Helper',
|
||||
'path' => 'views/helpers',
|
||||
),
|
||||
'viewfilter' => array(
|
||||
'namespace' => 'View_Filter',
|
||||
'path' => 'views/filters',
|
||||
),
|
||||
));
|
||||
$this->setDefaultResourceType('model');
|
||||
}
|
||||
}
|
|
@ -1,128 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Module
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @version $Id: Bootstrap.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Application_Bootstrap_Bootstrap
|
||||
*/
|
||||
require_once 'Zend/Application/Bootstrap/Bootstrap.php';
|
||||
|
||||
/**
|
||||
* Base bootstrap class for modules
|
||||
*
|
||||
* @uses Zend_Loader_Autoloader_Resource
|
||||
* @uses Zend_Application_Bootstrap_Bootstrap
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Module
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Application_Module_Bootstrap
|
||||
extends Zend_Application_Bootstrap_Bootstrap
|
||||
{
|
||||
/**
|
||||
* Set this explicitly to reduce impact of determining module name
|
||||
* @var string
|
||||
*/
|
||||
protected $_moduleName;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($application)
|
||||
{
|
||||
$this->setApplication($application);
|
||||
|
||||
// Use same plugin loader as parent bootstrap
|
||||
if ($application instanceof Zend_Application_Bootstrap_ResourceBootstrapper) {
|
||||
$this->setPluginLoader($application->getPluginLoader());
|
||||
}
|
||||
|
||||
$key = strtolower($this->getModuleName());
|
||||
if ($application->hasOption($key)) {
|
||||
// Don't run via setOptions() to prevent duplicate initialization
|
||||
$this->setOptions($application->getOption($key));
|
||||
}
|
||||
|
||||
if ($application->hasOption('resourceloader')) {
|
||||
$this->setOptions(array(
|
||||
'resourceloader' => $application->getOption('resourceloader')
|
||||
));
|
||||
}
|
||||
$this->initResourceLoader();
|
||||
|
||||
// ZF-6545: ensure front controller resource is loaded
|
||||
if (!$this->hasPluginResource('FrontController')) {
|
||||
$this->registerPluginResource('FrontController');
|
||||
}
|
||||
|
||||
// ZF-6545: prevent recursive registration of modules
|
||||
if ($this->hasPluginResource('modules')) {
|
||||
$this->unregisterPluginResource('modules');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure resource loader is loaded
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initResourceLoader()
|
||||
{
|
||||
$this->getResourceLoader();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default application namespace
|
||||
*
|
||||
* Proxies to {@link getModuleName()}, and returns the current module
|
||||
* name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAppNamespace()
|
||||
{
|
||||
return $this->getModuleName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve module name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModuleName()
|
||||
{
|
||||
if (empty($this->_moduleName)) {
|
||||
$class = get_class($this);
|
||||
if (preg_match('/^([a-z][a-z0-9]*)_/i', $class, $matches)) {
|
||||
$prefix = $matches[1];
|
||||
} else {
|
||||
$prefix = $class;
|
||||
}
|
||||
$this->_moduleName = $prefix;
|
||||
}
|
||||
return $this->_moduleName;
|
||||
}
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
require_once 'Zend/Application/Resource/ResourceAbstract.php';
|
||||
|
||||
/**
|
||||
* Cache Manager resource
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Application_Resource_Cachemanager extends Zend_Application_Resource_ResourceAbstract
|
||||
{
|
||||
/**
|
||||
* @var Zend_Cache_Manager
|
||||
*/
|
||||
protected $_manager = null;
|
||||
|
||||
/**
|
||||
* Initialize Cache_Manager
|
||||
*
|
||||
* @return Zend_Cache_Manager
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
return $this->getCacheManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve Zend_Cache_Manager instance
|
||||
*
|
||||
* @return Zend_Cache_Manager
|
||||
*/
|
||||
public function getCacheManager()
|
||||
{
|
||||
if (null === $this->_manager) {
|
||||
$this->_manager = new Zend_Cache_Manager;
|
||||
|
||||
$options = $this->getOptions();
|
||||
foreach ($options as $key => $value) {
|
||||
if ($this->_manager->hasCacheTemplate($key)) {
|
||||
$this->_manager->setTemplateOptions($key, $value);
|
||||
} else {
|
||||
$this->_manager->setCacheTemplate($key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_manager;
|
||||
}
|
||||
}
|
|
@ -1,161 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Db.php 20816 2010-02-01 21:13:54Z freak $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Application_Resource_ResourceAbstract
|
||||
*/
|
||||
require_once 'Zend/Application/Resource/ResourceAbstract.php';
|
||||
|
||||
/**
|
||||
* Resource for creating database adapter
|
||||
*
|
||||
* @uses Zend_Application_Resource_ResourceAbstract
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Application_Resource_Db extends Zend_Application_Resource_ResourceAbstract
|
||||
{
|
||||
/**
|
||||
* Adapter to use
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_adapter = null;
|
||||
|
||||
/**
|
||||
* @var Zend_Db_Adapter_Interface
|
||||
*/
|
||||
protected $_db;
|
||||
|
||||
/**
|
||||
* Parameters to use
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_params = array();
|
||||
|
||||
/**
|
||||
* Wether to register the created adapter as default table adapter
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_isDefaultTableAdapter = true;
|
||||
|
||||
/**
|
||||
* Set the adapter
|
||||
*
|
||||
* @param $adapter string
|
||||
* @return Zend_Application_Resource_Db
|
||||
*/
|
||||
public function setAdapter($adapter)
|
||||
{
|
||||
$this->_adapter = $adapter;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapter type to use
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAdapter()
|
||||
{
|
||||
return $this->_adapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the adapter params
|
||||
*
|
||||
* @param $adapter string
|
||||
* @return Zend_Application_Resource_Db
|
||||
*/
|
||||
public function setParams(array $params)
|
||||
{
|
||||
$this->_params = $params;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapter parameters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getParams()
|
||||
{
|
||||
return $this->_params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to use this as default table adapter
|
||||
*
|
||||
* @param boolean $defaultTableAdapter
|
||||
* @return Zend_Application_Resource_Db
|
||||
*/
|
||||
public function setIsDefaultTableAdapter($isDefaultTableAdapter)
|
||||
{
|
||||
$this->_isDefaultTableAdapter = $isDefaultTableAdapter;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this adapter the default table adapter?
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function isDefaultTableAdapter()
|
||||
{
|
||||
return $this->_isDefaultTableAdapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve initialized DB connection
|
||||
*
|
||||
* @return null|Zend_Db_Adapter_Interface
|
||||
*/
|
||||
public function getDbAdapter()
|
||||
{
|
||||
if ((null === $this->_db)
|
||||
&& (null !== ($adapter = $this->getAdapter()))
|
||||
) {
|
||||
$this->_db = Zend_Db::factory($adapter, $this->getParams());
|
||||
}
|
||||
return $this->_db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Application_Resource_Resource
|
||||
*
|
||||
* @return Zend_Db_Adapter_Abstract|null
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
if (null !== ($db = $this->getDbAdapter())) {
|
||||
if ($this->isDefaultTableAdapter()) {
|
||||
Zend_Db_Table::setDefaultAdapter($db);
|
||||
}
|
||||
return $db;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Layout.php 17687 2009-08-20 12:55:34Z thomas $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Application_Resource_ResourceAbstract
|
||||
*/
|
||||
require_once 'Zend/Application/Resource/ResourceAbstract.php';
|
||||
|
||||
|
||||
/**
|
||||
* Resource for settings Dojo options
|
||||
*
|
||||
* @uses Zend_Application_Resource_ResourceAbstract
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Application_Resource_Dojo
|
||||
extends Zend_Application_Resource_ResourceAbstract
|
||||
{
|
||||
/**
|
||||
* @var Zend_Dojo_View_Helper_Dojo_Container
|
||||
*/
|
||||
protected $_dojo;
|
||||
|
||||
/**
|
||||
* Defined by Zend_Application_Resource_Resource
|
||||
*
|
||||
* @return Zend_Dojo_View_Helper_Dojo_Container
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
return $this->getDojo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve Dojo View Helper
|
||||
*
|
||||
* @return Zend_Dojo_View_Dojo_Container
|
||||
*/
|
||||
public function getDojo()
|
||||
{
|
||||
if (null === $this->_dojo) {
|
||||
$this->getBootstrap()->bootstrap('view');
|
||||
$view = $this->getBootstrap()->view;
|
||||
|
||||
Zend_Dojo::enableView($view);
|
||||
$view->dojo()->setOptions($this->getOptions());
|
||||
|
||||
$this->_dojo = $view->dojo();
|
||||
}
|
||||
|
||||
return $this->_dojo;
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Exception class for Zend_Application
|
||||
*
|
||||
* @uses Zend_Application_Exception
|
||||
* @category Zend
|
||||
* @package Zend_Application
|
||||
* @subpackage Resource
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Application_Resource_Exception extends Zend_Application_Exception
|
||||
{
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue