diff --git a/.gitignore b/.gitignore index 347b021bc..3e5766a17 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.* *.*~ *.pyc vendor/* diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..0b62f90a2 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,23 @@ +language: php +php: +- '5.5' +- '5.4' +services: +- postgresql +- rabbitmq +env: + global: + - ENVIRONMENT=testing + - LIBRETIME_CONF_DIR=/tmp/libretime + - LIBRETIME_LOG_DIR=/tmp/log/libretime +install: +- composer install +before_script: +- psql -c 'CREATE DATABASE libretime;' -U postgres +- psql -c "CREATE USER libretime WITH PASSWORD 'libretime';" -U postgres +- psql -c 'GRANT CONNECT ON DATABASE libretime TO libretime;' -U postgres +- psql -c 'ALTER USER libretime CREATEDB;' -U postgres +- mkdir -p /tmp/libretime/testing/ /tmp/log/libretime +- cp airtime_mvc/tests/airtime.conf airtime_mvc/tests/cloud_storage.conf /tmp/libretime/testing/ +script: +- cd airtime_mvc/tests && ../../vendor/bin/phpunit diff --git a/README.md b/README.md index 56da79308..8c464d5af 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # LibreTime +[](https://travis-ci.org/LibreTime/libretime) + LibreTime is a community managed fork of the AirTime project. It is managed by a friendly inclusive community of stations diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php index a4537b4c4..37b2ca3af 100644 --- a/airtime_mvc/application/Bootstrap.php +++ b/airtime_mvc/application/Bootstrap.php @@ -10,57 +10,9 @@ if (!isset($configRun) || !$configRun) { Propel::init(CONFIG_PATH . 'airtime-conf-production.php'); } -//Composer's autoloader -require_once 'autoload.php'; - require_once CONFIG_PATH . "constants.php"; -/* Common */ -require_once "DateHelper.php"; -require_once "LocaleHelper.php"; -require_once "FileDataHelper.php"; -require_once "HTTPHelper.php"; -require_once "FileIO.php"; -require_once "OsPath.php"; -require_once "Database.php"; -require_once "ProvisioningHelper.php"; -require_once "SecurityHelper.php"; -require_once "SessionHelper.php"; -require_once "GoogleAnalytics.php"; -require_once "Timezone.php"; -require_once "CeleryManager.php"; -require_once "TaskManager.php"; -require_once "PodcastManager.php"; -require_once "UsabilityHints.php"; -require_once __DIR__.'/models/formatters/LengthFormatter.php'; -require_once __DIR__.'/common/widgets/Table.php'; -/* Models */ -require_once "Auth.php"; -require_once 'Preference.php'; -require_once 'Locale.php'; -/* Enums */ -require_once "Enum.php"; -require_once "MediaType.php"; -require_once "HttpRequestType.php"; -/* Interfaces */ -require_once "OAuth2.php"; -require_once "OAuth2Controller.php"; -require_once "Publish.php"; -/* Factories */ -require_once __DIR__.'/services/CeleryServiceFactory.php'; -require_once __DIR__.'/services/PublishServiceFactory.php'; -require_once __DIR__.'/forms/helpers/ValidationTypes.php'; -require_once __DIR__.'/forms/helpers/CustomDecorators.php'; -require_once __DIR__.'/controllers/plugins/PageLayoutInitPlugin.php'; -require_once __DIR__.'/controllers/plugins/RabbitMqPlugin.php'; -require_once __DIR__.'/controllers/plugins/Maintenance.php'; -require_once __DIR__.'/controllers/plugins/ConversionTracking.php'; -require_once __DIR__.'/modules/rest/controllers/ShowImageController.php'; -require_once __DIR__.'/modules/rest/controllers/MediaController.php'; -require_once __DIR__.'/upgrade/Upgrades.php'; - -require_once (APPLICATION_PATH . "/logging/Logging.php"); -Logging::setLogPath('/var/log/airtime/zendphp.log'); +Logging::setLogPath(LIBRETIME_LOG_DIR . '/zendphp.log'); // We need to manually route because we can't load Zend without the database being initialized first. if (array_key_exists("REQUEST_URI", $_SERVER) && (stripos($_SERVER["REQUEST_URI"], "/provisioning/create") !== false)) { diff --git a/airtime_mvc/application/airtime-boot.php b/airtime_mvc/application/airtime-boot.php index 5ed3cb4bc..97c00678d 100644 --- a/airtime_mvc/application/airtime-boot.php +++ b/airtime_mvc/application/airtime-boot.php @@ -48,11 +48,6 @@ set_include_path(APPLICATION_PATH . 'controllers' . PATH_SEPARATOR . get_include //Controller plugins. set_include_path(APPLICATION_PATH . 'controllers/plugins' . PATH_SEPARATOR . get_include_path()); -//Zend framework -if (file_exists('/usr/share/php/libzend-framework-php')) { - set_include_path('/usr/share/php/libzend-framework-php' . PATH_SEPARATOR . get_include_path()); -} - //Services. set_include_path(APPLICATION_PATH . '/services/' . PATH_SEPARATOR . get_include_path()); @@ -65,7 +60,8 @@ set_include_path(APPLICATION_PATH . '/upgrade/' . PATH_SEPARATOR . get_include_p //Common directory set_include_path(APPLICATION_PATH . '/common/' . PATH_SEPARATOR . get_include_path()); - +//Composer's autoloader +require_once 'autoload.php'; /** Zend_Application */ require_once 'Zend/Application.php'; @@ -75,7 +71,7 @@ $application = new Zend_Application( ); require_once(APPLICATION_PATH . "logging/Logging.php"); -Logging::setLogPath('/var/log/airtime/zendphp.log'); +Logging::setLogPath(LIBRETIME_LOG_DIR . '/zendphp.log'); Logging::setupParseErrorLogging(); // Create application, bootstrap, and run diff --git a/airtime_mvc/application/cloud_storage/Amazon_S3StorageBackend.php b/airtime_mvc/application/cloud_storage/Amazon_S3StorageBackend.php index 2f023aeea..0145f00af 100644 --- a/airtime_mvc/application/cloud_storage/Amazon_S3StorageBackend.php +++ b/airtime_mvc/application/cloud_storage/Amazon_S3StorageBackend.php @@ -1,8 +1,5 @@ getPodcastEpisodes($podcast->getDbPodcastId()); $episodes = array(); - usort($episodeList, array(static::class, "_sortByEpisodePubDate")); + usort($episodeList, array(__CLASS__, "_sortByEpisodePubDate")); for ($i = 0; $i < sizeof($episodeList); $i++) { $episodeData = $episodeList[$i]; $ts = $podcast->getDbAutoIngestTimestamp(); diff --git a/airtime_mvc/application/common/TaskManager.php b/airtime_mvc/application/common/TaskManager.php index 126060a28..61b84f1a0 100644 --- a/airtime_mvc/application/common/TaskManager.php +++ b/airtime_mvc/application/common/TaskManager.php @@ -351,8 +351,7 @@ class TaskFactory { */ private static function _isTask($c) { $reflect = new ReflectionClass($c); - $clazz = version_compare(phpversion(), '5.5.0', '<') ? "AirtimeTask" : AirtimeTask::class; - return $reflect->implementsInterface($clazz); + return $reflect->implementsInterface('AirtimeTask'); } /** diff --git a/airtime_mvc/application/configs/ACL.php b/airtime_mvc/application/configs/ACL.php index 52ba6fa7b..e7df03065 100644 --- a/airtime_mvc/application/configs/ACL.php +++ b/airtime_mvc/application/configs/ACL.php @@ -1,6 +1,5 @@ '2CLCxcSXYzx7QhhPVHN4A', - 'soundcloud-client-secret' => 'pZ7beWmF06epXLHVUP1ufOg2oEnIt9XhE8l8xt0bBs', - "rootDir" => self::$rootDir ); @@ -23,7 +21,7 @@ class Config { if (getenv('AIRTIME_UNIT_TEST') == '1') { $filename = "airtime.conf"; } else { - $filename = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf"; + $filename = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : LIBRETIME_CONF_DIR . "/airtime.conf"; } $values = parse_ini_file($filename, true); @@ -51,11 +49,11 @@ class Config { } // Parse separate conf file for cloud storage values - $cloudStorageConfig = "/etc/airtime-saas/".$CC_CONFIG['dev_env']."/cloud_storage.conf"; + $cloudStorageConfig = LIBRETIME_CONF_DIR . '/' . $CC_CONFIG['dev_env']."/cloud_storage.conf"; if (!file_exists($cloudStorageConfig)) { // If the dev env specific cloud_storage.conf doesn't exist default // to the production cloud_storage.conf - $cloudStorageConfig = "/etc/airtime-saas/production/cloud_storage.conf"; + $cloudStorageConfig = LIBRETIME_CONF_DIR . "/production/cloud_storage.conf"; } $cloudStorageValues = parse_ini_file($cloudStorageConfig, true); @@ -86,11 +84,11 @@ class Config { $CC_CONFIG['soundcloud-connection-retries'] = $values['soundcloud']['connection_retries']; $CC_CONFIG['soundcloud-connection-wait'] = $values['soundcloud']['time_between_retries']; - $globalAirtimeConfig = "/etc/airtime-saas/".$CC_CONFIG['dev_env']."/airtime.conf"; + $globalAirtimeConfig = LIBRETIME_CONF_DIR . '/' . $CC_CONFIG['dev_env']."/airtime.conf"; if (!file_exists($globalAirtimeConfig)) { // If the dev env specific airtime.conf doesn't exist default // to the production airtime.conf - $globalAirtimeConfig = "/etc/airtime-saas/production/airtime.conf"; + $globalAirtimeConfig = LIBRETIME_CONF_DIR . "/production/airtime.conf"; } $globalAirtimeConfigValues = parse_ini_file($globalAirtimeConfig, true); $CC_CONFIG['soundcloud-client-id'] = $globalAirtimeConfigValues['soundcloud']['soundcloud_client_id']; diff --git a/airtime_mvc/application/configs/constants.php b/airtime_mvc/application/configs/constants.php index ca9b013a0..af84e69cb 100644 --- a/airtime_mvc/application/configs/constants.php +++ b/airtime_mvc/application/configs/constants.php @@ -36,6 +36,10 @@ define('AIRTIME_API_VERSION' , '1.1'); // XXX: it's important that we upgrade this every time we add an upgrade! define('AIRTIME_CODE_VERSION' , '2.5.16'); +// grab values from env (i'll do this everywhere with a small function if we like it) +define('LIBRETIME_CONF_DIR', getenv('LIBRETIME_CONF_DIR') ? getenv('LIBRETIME_CONF_DIR') : '/etc/airtime'); +define('LIBRETIME_LOG_DIR', getenv('LIBRETIME_LOG_DIR') ? getenv('LIBRETIME_LOG_DIR') : '/var/log/airtime'); + // Defaults define('DEFAULT_LOGO_PLACEHOLDER', 1); define('DEFAULT_LOGO_FILE', 'images/airtime_logo.png'); diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 92e370d00..e5545fc5d 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -1,6 +1,4 @@ view->layout()->disableLayout(); - $this->_helper->viewRenderer->setNoRender(true); + if ($this->view) { // skip if already missing (ie in tests) + $this->view->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(true); + } //Ignore API key and session authentication for these APIs: $ignoreAuth = array("live-info", @@ -135,8 +135,7 @@ class ApiController extends Zend_Controller_Action */ public function pollCeleryAction() { $taskManager = TaskManager::getInstance(); - $clazz = version_compare(phpversion(), '5.5.0', '<') ? get_class(new CeleryTask) : CeleryTask::class; - $taskManager->runTask($clazz); + $taskManager->runTask('CeleryTask'); } /** @@ -498,7 +497,7 @@ class ApiController extends Zend_Controller_Action // Sometimes end users may be looking at stale data - if an image is removed // but has been cached in a client's browser this will throw an exception Application_Common_FileIO::smartReadFile($path, filesize($path), $mime_type); - } catch(FileNotFoundException $e) { + } catch(LibreTimeFileNotFoundException $e) { //throw new ZendActionHttpException($this, 404, "ERROR: No image found at $path"); $this->_redirect('api/station-logo'); return; diff --git a/airtime_mvc/application/controllers/BillingController.php b/airtime_mvc/application/controllers/BillingController.php index bf4aafb1d..5a5f7e452 100644 --- a/airtime_mvc/application/controllers/BillingController.php +++ b/airtime_mvc/application/controllers/BillingController.php @@ -1,6 +1,5 @@ isPost()) { if ($form->isValid($request->getPost())) { $query = CcSubjsQuery::create(); - if (empty($form->username->getValue())) { - $query->filterByDbEmail($form->email->getValue()); - } else if (empty($form->email->getValue())) { - $query->filterByDbLogin($form->username->getValue()); + $username = $form->userName->getValue(); + $email = $form->email->getValue(); + + if (empty($username)) { + $query->filterByDbEmail($email); + } else if (empty($email)) { + $query->filterByDbLogin($username); } else { - $query->filterByDbEmail($form->email->getValue()) - ->filterByDbLogin($form->username->getValue()); + $query->filterByDbEmail($email) + ->filterByDbLogin($username); } $user = $query->findOne(); diff --git a/airtime_mvc/application/controllers/ProvisioningController.php b/airtime_mvc/application/controllers/ProvisioningController.php index a230d6ff1..4bc090ac1 100644 --- a/airtime_mvc/application/controllers/ProvisioningController.php +++ b/airtime_mvc/application/controllers/ProvisioningController.php @@ -1,7 +1,5 @@ runTask($clazz); + $taskManager->runTask('UpgradeTask'); // Piggyback the TaskManager onto API calls. This provides guaranteed consistency // (there is at least one API call made from pypo to Airtime every 7 minutes) and diff --git a/airtime_mvc/application/forms/AddShowLiveStream.php b/airtime_mvc/application/forms/AddShowLiveStream.php index 57066db0b..dd532f986 100644 --- a/airtime_mvc/application/forms/AddShowLiveStream.php +++ b/airtime_mvc/application/forms/AddShowLiveStream.php @@ -1,5 +1,4 @@ ; //The DOM elements that these calls depend on exist by this point: diff --git a/airtime_mvc/application/logging/Logging.php b/airtime_mvc/application/logging/Logging.php index 23b377686..4f8d00a79 100644 --- a/airtime_mvc/application/logging/Logging.php +++ b/airtime_mvc/application/logging/Logging.php @@ -1,5 +1,4 @@ setDbMtime($now); $file->save(); } - catch (FileNotFoundException $e) + catch (LibreTimeFileNotFoundException $e) { $file->setDbImportStatus(self::IMPORT_STATUS_FAILED); $file->setDbHidden(true); @@ -258,7 +258,7 @@ class CcFiles extends BaseCcFiles { * @throws DeleteScheduledFileException * @throws Exception * @throws FileNoPermissionException - * @throws FileNotFoundException + * @throws LibreTimeFileNotFoundException * @throws PropelException */ public static function deleteById($id) @@ -269,7 +269,7 @@ class CcFiles extends BaseCcFiles { $storedFile = Application_Model_StoredFile::RecallById($id, $con); $storedFile->delete(); } else { - throw new FileNotFoundException(); + throw new LibreTimeFileNotFoundException(); } } diff --git a/airtime_mvc/application/models/airtime/CloudFile.php b/airtime_mvc/application/models/airtime/CloudFile.php index 56390e28c..8c93fc15f 100644 --- a/airtime_mvc/application/models/airtime/CloudFile.php +++ b/airtime_mvc/application/models/airtime/CloudFile.php @@ -1,7 +1,5 @@ = '2010-01-01 00:00:00.000') " - ." AND (ends <= (TIMESTAMP '2011-01-01 00:00:00.000' + INTERVAL '01:00:00.123456'))"; -$rows1 = $con->query($sql); -var_dump($rows1->fetchAll()); - -$sql2 = "SELECT COUNT(*) FROM cc_playlistcontents"; -$rows2 = $con->query($sql2); -var_dump($rows2->fetchAll()); - -$sql3 = "SELECT TIMESTAMP '2011-01-01 00:00:00.000' + INTERVAL '01:00:00.123456'"; -$result3 = $con->query($sql3); -var_dump($result3->fetchAll()); - - diff --git a/airtime_mvc/application/modules/rest/Bootstrap.php b/airtime_mvc/application/modules/rest/Bootstrap.php index 016c94017..3ad53e846 100644 --- a/airtime_mvc/application/modules/rest/Bootstrap.php +++ b/airtime_mvc/application/modules/rest/Bootstrap.php @@ -1,7 +1,5 @@ _helper->viewRenderer->setNoRender(true); } + + /** + * headAction is needed as it is defined as an abstract function in the base controller + * + * @return void + */ + public function headAction() + { + Logging::info("HEAD action received"); + } public function indexAction() { @@ -76,7 +84,7 @@ class Rest_MediaController extends Zend_Rest_Controller } Application_Service_MediaService::streamFileDownload($id, $inline); } - catch (FileNotFoundException $e) { + catch (LibreTimeFileNotFoundException $e) { $this->fileNotFoundResponse(); Logging::error($e->getMessage()); } @@ -99,7 +107,7 @@ class Rest_MediaController extends Zend_Rest_Controller ->setHttpResponseCode(200) ->appendBody(json_encode(CcFiles::getSanitizedFileById($id))); } - catch (FileNotFoundException $e) { + catch (LibreTimeFileNotFoundException $e) { $this->fileNotFoundResponse(); Logging::error($e->getMessage()); } @@ -160,7 +168,7 @@ class Rest_MediaController extends Zend_Rest_Controller $this->invalidDataResponse(); Logging::error($e->getMessage()); } - catch (FileNotFoundException $e) { + catch (LibreTimeFileNotFoundException $e) { $this->fileNotFoundResponse(); Logging::error($e->getMessage()); } @@ -181,7 +189,7 @@ class Rest_MediaController extends Zend_Rest_Controller $this->getResponse() ->setHttpResponseCode(204); } - catch (FileNotFoundException $e) { + catch (LibreTimeFileNotFoundException $e) { $this->fileNotFoundResponse(); Logging::error($e->getMessage()); } diff --git a/airtime_mvc/application/modules/rest/controllers/PodcastController.php b/airtime_mvc/application/modules/rest/controllers/PodcastController.php index 0ec89f73b..f80b16c34 100644 --- a/airtime_mvc/application/modules/rest/controllers/PodcastController.php +++ b/airtime_mvc/application/modules/rest/controllers/PodcastController.php @@ -1,7 +1,5 @@ view->setScriptPath(APPLICATION_PATH . 'views/scripts/'); } + /** + * headAction is needed as it is defined as an abstract function in the base controller + * + * @return void + */ + public function headAction() + { + Logging::info("HEAD action received"); + } + public function indexAction() { // Check if offset and limit were sent with request. diff --git a/airtime_mvc/application/modules/rest/controllers/PodcastEpisodesController.php b/airtime_mvc/application/modules/rest/controllers/PodcastEpisodesController.php index 7bbf42b1a..1bf85fafc 100644 --- a/airtime_mvc/application/modules/rest/controllers/PodcastEpisodesController.php +++ b/airtime_mvc/application/modules/rest/controllers/PodcastEpisodesController.php @@ -17,6 +17,16 @@ class Rest_PodcastEpisodesController extends Zend_Rest_Controller $this->_service = new Application_Service_PodcastEpisodeService(); } + /** + * headAction is needed as it is defined as an abstract function in the base controller + * + * @return void + */ + public function headAction() + { + Logging::info("HEAD action received"); + } + public function indexAction() { // podcast ID diff --git a/airtime_mvc/application/modules/rest/controllers/ShowImageController.php b/airtime_mvc/application/modules/rest/controllers/ShowImageController.php index 502267920..0e524924f 100644 --- a/airtime_mvc/application/modules/rest/controllers/ShowImageController.php +++ b/airtime_mvc/application/modules/rest/controllers/ShowImageController.php @@ -12,9 +12,6 @@ * @version 1.2.1 */ -$filepath = realpath(__DIR__); -require_once($filepath . "/../helpers/RestAuth.php"); - class Rest_ShowImageController extends Zend_Rest_Controller { public function init() { @@ -24,6 +21,16 @@ class Rest_ShowImageController extends Zend_Rest_Controller { $this->_helper->viewRenderer->setNoRender(true); } + /** + * headAction is needed as it is defined as an abstract function in the base controller + * + * @return void + */ + public function headAction() + { + Logging::info("HEAD action received"); + } + public function indexAction() { Logging::info("INDEX action received"); } diff --git a/airtime_mvc/application/services/HistoryService.php b/airtime_mvc/application/services/HistoryService.php index 33e6c1451..4ac58e2ed 100644 --- a/airtime_mvc/application/services/HistoryService.php +++ b/airtime_mvc/application/services/HistoryService.php @@ -1,7 +1,5 @@ getPropelOrm()->getDbMime(); Application_Common_FileIO::smartReadFile($filePath, $size, $mimeType); break; //Break out of the loop if we successfully read the file! - } catch (FileNotFoundException $e) { + } catch (LibreTimeFileNotFoundException $e) { //If we have no alternate filepaths left, then let the exception bubble up. if (sizeof($filePaths) == 0) { throw $e; @@ -116,7 +113,7 @@ class Application_Service_MediaService exit; } else { - throw new FileNotFoundException($filePath); + throw new LibreTimeFileNotFoundException($filePath); } } diff --git a/airtime_mvc/application/services/PodcastEpisodeService.php b/airtime_mvc/application/services/PodcastEpisodeService.php index 1ceda4829..04aed1a7c 100644 --- a/airtime_mvc/application/services/PodcastEpisodeService.php +++ b/airtime_mvc/application/services/PodcastEpisodeService.php @@ -354,7 +354,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir * * @return array array of episode data * - * @throws CcFiles/FileNotFoundException + * @throws CcFiles/LibreTimeFileNotFoundException */ public function _getImportedPodcastEpisodeArray($podcast, $episodes) { $rss = Application_Service_PodcastService::getPodcastFeed($podcast->getDbUrl()); diff --git a/airtime_mvc/application/services/PodcastService.php b/airtime_mvc/application/services/PodcastService.php index 5f0236306..b6dc72f04 100644 --- a/airtime_mvc/application/services/PodcastService.php +++ b/airtime_mvc/application/services/PodcastService.php @@ -72,9 +72,13 @@ class Application_Service_PodcastService //TODO: why is this so slow? $rss = self::getPodcastFeed($feedUrl); - if (!$rss || !empty($rss->error())) { + if (!$rss) { throw new InvalidPodcastException(); } + $rssErr = $rss->error(); + if (!empty($rssErr)) { + throw new InvalidPodcastException($rssErr); + } // Ensure we are only creating Podcast with the given URL, and excluding // any extra data fields that may have been POSTED @@ -87,7 +91,8 @@ class Application_Service_PodcastService $podcastArray["language"] = htmlspecialchars($rss->get_language()); $podcastArray["copyright"] = htmlspecialchars($rss->get_copyright()); - $name = empty($rss->get_author()) ? "" : $rss->get_author()->get_name(); + $rssAuthor = $rss->getAuthor(); + $name = empty($rssAuthor) ? "" : $rss->rssAuthor->get_name(); $podcastArray["creator"] = htmlspecialchars($name); $categories = array(); diff --git a/airtime_mvc/application/services/SoundcloudService.php b/airtime_mvc/application/services/SoundcloudService.php index 9e3c9e7d2..72c56dbde 100644 --- a/airtime_mvc/application/services/SoundcloudService.php +++ b/airtime_mvc/application/services/SoundcloudService.php @@ -1,7 +1,5 @@ array( - 'Variables' => null, - 'Time' => null, - 'Memory' => null), - 'z-index' => 255, - 'jquery_path' => 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js', - 'image_path' => null - ); - - /** - * Standard plugins - * - * @var array - */ - public static $standardPlugins = array('Cache', 'Html', 'Database', 'Exception', 'File', 'Memory', 'Registry', 'Time', 'Variables'); - - /** - * Debug Bar Version Number - * for internal use only - * - * @var string - */ - protected $_version = '1.5.4'; - - /** - * Creates a new instance of the Debug Bar - * - * @param array|Zend_Config $options - * @throws Zend_Controller_Exception - * @return void - */ - - protected $_closingBracket = null; - - public function __construct($options = null) - { - if (isset($options)) { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } - - /* - * Verify that adapter parameters are in an array. - */ - if (!is_array($options)) { - throw new Zend_Exception('Debug parameters must be in an array or a Zend_Config object'); - } - - $this->setOptions($options); - } - - /** - * Creating ZF Version Tab always shown - */ - $version = new ZFDebug_Controller_Plugin_Debug_Plugin_Text(); - $version->setPanel($this->_getVersionPanel()) - ->setTab($this->_getVersionTab()) - ->setIdentifier('copyright') - ->setIconData('data:image/gif;base64,R0lGODlhEAAQAPcAAPb7/ef2+VepAGKzAIC8SavSiYS9Stvt0uTx4fX6+ur1632+QMLgrGOuApDIZO738drs0Ofz5t7v2MfjtPP6+t7v12SzAcvnyX2+PaPRhH2+Qmy3H3K5LPP6+cXkwIHAR2+4JHi7NePz8YC/Rc3ozfH49XK5KXq9OrzdpNzu1YrEUqrVkdzw5uTw4d/v2dDow5zOeO3279Hq0m+4JqrUhpnMbeHw3N3w6Mflwm22HmazBODy7tfu3un06r7gsuXy4sTisIzGXvH59ny9PdPr1rXZpMzlu36/Q5bLb+Pw3tDnxNHr1Lfbm+b199/x62q1Fp3NcdjszqTPh/L599vt04/GWmazCPb7/LHZnW63I3W6MXa7MmGuAt/y7Gq1E2m0Eb7cp9frzZLJaO/489bu3HW3N7rerN/v2q7WjIjEVuLx343FVrDXj9nt0cTjvW2zIoPBSNjv4OT09IXDUpvLeeHw3dPqyNLpxs/nwHe8OIvFWrPaoGe0C5zMb83mvHm8Oen06a3Xl9XqyoC/Qr/htWe0DofDU4nFWbPYk7ndqZ/PfYPBTMPhrqHRgoLBSujz55PKadHpxfX6+6LNeqPQfNXt2pPIYH2+O7vcoHi4OOf2+PL5+NTs2N3u1mi1E7XZl4zEVJjLaZHGauby5KTShmSzBO/38s/oz3i7MtbrzMHiuYTCT4fDTtXqye327uDv3JDHXu328JnMcu738LLanvD49ZTJYpPKauX19tvv44jBWo7GWpfKZ+Dv27XcpcrluXu8ONTs16zXleT08qfUjKzUlc7pzm63HaTRfZXKZuj06HG4KavViGe0EcDfqcjmxaDQgZrNdOHz77/ep4/HYL3esnW6LobCS3S5K57OctDp0JXKbez17N7x6cbkwLTZlbXXmLrcnrvdodHr06PQe8jkt5jIa93v13m8OI7CW3O6L3a7Nb7gs6nUjmu2GqjTgZjKaKLQeZnMc4LAReL08rTbopbLbuTx4KDOdtbry7DYmrvfrrPaoXK5K5zOegAAACH5BAEAAAAALAAAAAAQABAAAAhMAAEIHEiwoMGDCBMOlCKgoUMuHghInEiggEOHAC5eJNhQ4UAuAjwIJLCR4AEBDQS2uHiAYLGOHjNqlCmgYAONApQ0jBGzp8+fQH8GBAA7'); - $this->registerPlugin($version); - - /** - * Loading aready defined plugins - */ - $this->_loadPlugins(); - } - - /** - * Sets options of the Debug Bar - * - * @param array $options - * @return ZFDebug_Controller_Plugin_Debug - */ - public function setOptions(array $options = array()) - { - if (isset($options['jquery_path'])) { - $this->_options['jquery_path'] = $options['jquery_path']; - } - - if (isset($options['z-index'])) { - $this->_options['z-index'] = $options['z-index']; - } - - if (isset($options['image_path'])) { - $this->_options['image_path'] = $options['image_path']; - } - - if (isset($options['plugins'])) { - $this->_options['plugins'] = $options['plugins']; - } - return $this; - } - - /** - * Register a new plugin in the Debug Bar - * - * @param ZFDebug_Controller_Plugin_Debug_Plugin_Interface - * @return ZFDebug_Controller_Plugin_Debug - */ - public function registerPlugin(ZFDebug_Controller_Plugin_Debug_Plugin_Interface $plugin) - { - $this->_plugins[$plugin->getIdentifier()] = $plugin; - return $this; - } - - /** - * Unregister a plugin in the Debug Bar - * - * @param string $plugin - * @return ZFDebug_Controller_Plugin_Debug - */ - public function unregisterPlugin($plugin) - { - if (false !== strpos($plugin, '_')) { - foreach ($this->_plugins as $key => $_plugin) { - if ($plugin == get_class($_plugin)) { - unset($this->_plugins[$key]); - } - } - } else { - $plugin = strtolower($plugin); - if (isset($this->_plugins[$plugin])) { - unset($this->_plugins[$plugin]); - } - } - return $this; - } - - /** - * Get a registered plugin in the Debug Bar - * - * @param string $identifier - * @return ZFDebug_Controller_Plugin_Debug_Plugin_Interface - */ - public function getPlugin($identifier) - { - $identifier = strtolower($identifier); - if (isset($this->_plugins[$identifier])) { - return $this->_plugins[$identifier]; - } - return false; - } - - /** - * Defined by Zend_Controller_Plugin_Abstract - */ - public function dispatchLoopShutdown() - { - if ($this->getRequest()->isXmlHttpRequest()) { - return; - } - $disable = Zend_Controller_Front::getInstance()->getRequest()->getParam('ZFDEBUG_DISABLE'); - if (isset($disable)) { - return; - } - - $html = ''; - - /** - * Creating menu tab for all registered plugins - */ - foreach ($this->_plugins as $plugin) - { - $panel = $plugin->getPanel(); - if ($panel == '') { - continue; - } - - /* @var $plugin ZFDebug_Controller_Plugin_Debug_Plugin_Interface */ - $html .= '
©2008-2009 Joakim Nygård & Andreas Pankratz
' . - 'The project is hosted at http://zfdebug.googlecode.com and released under the BSD License' . $this->getLinebreak() . - 'Includes images from the Silk Icon set by Mark James
'. - 'Disable ZFDebug temporarily by sending ZFDEBUG_DISABLE as a GET/POST parameter
'; - // $panel .= '