[44] | 1 | <?php
|
---|
| 2 | /**
|
---|
| 3 | * Copyright 2006, 2007, 2008, 2009 Eric D. Hough (http://ehough.com)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of TubePress (http://tubepress.org)
|
---|
| 6 | *
|
---|
| 7 | * TubePress is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * TubePress is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with TubePress. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | *
|
---|
| 20 | */
|
---|
| 21 |
|
---|
| 22 | /**
|
---|
| 23 | * Performs various debugging functions
|
---|
| 24 | *
|
---|
| 25 | */
|
---|
| 26 | class org_tubepress_util_Debug
|
---|
| 27 | {
|
---|
| 28 | /**
|
---|
| 29 | * Executes the debugging. Amazing!
|
---|
| 30 | *
|
---|
| 31 | * @param org_tubepress_options_manager_OptionsManager $tpom The TubePress options manager
|
---|
| 32 | * @param org_tubepress_options_storage_StorageManager $tpsm The TubePress storage manager
|
---|
| 33 | *
|
---|
| 34 | * @return void
|
---|
| 35 | */
|
---|
| 36 | public static final function execute(org_tubepress_ioc_IocService $iocContainer)
|
---|
| 37 | {
|
---|
| 38 | global $tubepress_base_url;
|
---|
| 39 |
|
---|
| 40 | /* load up the debug template */
|
---|
| 41 | $tpl = new net_php_pear_HTML_Template_IT(dirname(__FILE__) . "/../../../../ui/gallery/html_templates");
|
---|
| 42 | if (!$tpl->loadTemplatefile("debug_blurb.tpl.html", true, true)) {
|
---|
| 43 | print "Could not load debug template!";
|
---|
| 44 | return;
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | $builder = $iocContainer->get(org_tubepress_ioc_IocService::URL_BUILDER);
|
---|
| 48 | $qss = $iocContainer->get(org_tubepress_ioc_IocService::QUERY_STR);
|
---|
| 49 | $currentPage = $qss->getPageNum($_GET);
|
---|
| 50 | $debugStuff = array("tubepress_base_url" => $tubepress_base_url,
|
---|
| 51 | "IOC" => print_r($iocContainer, true),
|
---|
| 52 | "YouTube connection test" => "Click <a href=\"" . $tubepress_base_url .
|
---|
| 53 | "/classes/org/tubepress/gdata/retrieval/ConnectionTest.php\">" .
|
---|
| 54 | "here</a> to view results",
|
---|
| 55 | "Request URL" => $builder->buildGalleryUrl($currentPage));
|
---|
| 56 |
|
---|
| 57 | foreach ($debugStuff as $key => $val) {
|
---|
| 58 | $tpl->setVariable("ELEMENT_TITLE", $key);
|
---|
| 59 | $tpl->setVariable("ELEMENT_VALUE", $val);
|
---|
| 60 | $tpl->parse("debugElement");
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | $tpl->show();
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | /**
|
---|
| 67 | * Determines if we are in debug mode
|
---|
| 68 | *
|
---|
| 69 | * @param org_tubepress_options_manager_OptionsManager $tpom The TubePress options manager
|
---|
| 70 | *
|
---|
| 71 | * @return boolean True if we're in debug mode, false otherwise
|
---|
| 72 | */
|
---|
| 73 | public static final function areWeDebugging(org_tubepress_options_manager_OptionsManager $tpom)
|
---|
| 74 | {
|
---|
| 75 | $enabled = $tpom->get(org_tubepress_options_category_Advanced::DEBUG_ON);
|
---|
| 76 | return $enabled
|
---|
| 77 | && isset($_GET['tubepress_debug'])
|
---|
| 78 | && ($_GET['tubepress_debug'] == 'true');
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | }
|
---|