From 3c181054dbe60467cc744c447010f525a862c26e Mon Sep 17 00:00:00 2001 From: mensonge Date: Fri, 21 Nov 2008 10:44:28 +0000 Subject: Refactoring: improve debug_mode, constants and other stuff git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@168 b3834d28-1941-0410-a4f8-b48e95affb8f --- config.inc.php.example | 3 ++- constants.inc.php | 28 +++++++++++++++++++++++- debug.inc.php | 16 -------------- functions.inc.php | 12 +++++------ gsearch/context.php | 2 +- gsearch/index.php | 2 +- header.inc.php | 44 +++++++++++++++++--------------------- index.php | 1 + jsScuttle.php | 12 +++++------ rss.php | 2 +- services/userservice.php | 13 +++++------ templates/bookmarks.tpl.php | 2 +- templates/editbookmark.tpl.php | 2 +- templates/login.tpl.php | 2 +- templates/sidebar.block.recent.php | 7 +++--- templates/toolbar.inc.php | 2 +- templates/top.inc.php | 8 +++---- upgrade.txt | 12 ++++++++++- 18 files changed, 95 insertions(+), 75 deletions(-) delete mode 100644 debug.inc.php diff --git a/config.inc.php.example b/config.inc.php.example index 47e314e..a8aa847 100644 --- a/config.inc.php.example +++ b/config.inc.php.example @@ -15,6 +15,7 @@ $usecache = false; # use cache ? {true,false} $dir_cache = dirname(__FILE__) .'/cache/'; # directory where cache files will be stored $cleanurls = false; # Use mod_rewrite to hide PHP extensions {true,false[default]} # be cautious, doesn't work for all hosts, you may need to modify the .htaccess file +$debugMode = false; # if true, show debug messages #### Database #### $dbtype = 'mysql4'; # Database driver {mysql, mysqli, mysql4, oracle, postgres, sqlite, db2, firebird, mssql, mssq-odbc} @@ -85,5 +86,5 @@ $menu2Tags = array('example', 'of', 'menu', 'tags'); # list of tags used by menu $sizeSearchHistory = 10; # number of users' searches that are saved {1..10[Default]..-1[Unlimited]} $enableGoogleCustomSearch = true; #Enable Google Search Engine into "gsearch/" folder -include_once('debug.inc.php'); + ?> diff --git a/constants.inc.php b/constants.inc.php index 824561f..e779852 100644 --- a/constants.inc.php +++ b/constants.inc.php @@ -1,4 +1,30 @@ diff --git a/debug.inc.php b/debug.inc.php deleted file mode 100644 index 8bd7f33..0000000 --- a/debug.inc.php +++ /dev/null @@ -1,16 +0,0 @@ - \ No newline at end of file diff --git a/functions.inc.php b/functions.inc.php index 35f0fed..93821fd 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -85,11 +85,11 @@ function multi_array_search($needle, $haystack) { } function createURL($page = '', $ending = '') { - global $cleanurls, $root; + global $cleanurls; if (!$cleanurls && $page != '') { $page .= '.php'; } - return $root . $page .'/'. $ending; + return ROOT . $page .'/'. $ending; } /* Shorten a string like a URL for example by cutting the middle of it */ @@ -112,7 +112,7 @@ function message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', // Get SQL error if we are debugging. Do this as soon as possible to prevent // subsequent queries from overwriting the status of sql_error() - if (DEBUG && ($msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR)) { + if (DEBUG_MODE && ($msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR)) { $sql_error = is_null($db) ? '' : $db->sql_error(); $debug_text = ''; @@ -157,10 +157,10 @@ function message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', break; } - // Add on DEBUG info if we've enabled debug mode and this is an error. This - // prevents debug info being output for general messages should DEBUG be + // Add on DEBUG_MODE info if we've enabled debug mode and this is an error. This + // prevents debug info being output for general messages should DEBUG_MODE be // set TRUE by accident (preventing confusion for the end user!) - if (DEBUG && ($msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR)) { + if (DEBUG_MODE && ($msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR)) { if ($debug_text != '') $msg_text = $msg_text . '

'. T_('DEBUG MODE') .''. $debug_text; } diff --git a/gsearch/context.php b/gsearch/context.php index a48179f..1a65063 100644 --- a/gsearch/context.php +++ b/gsearch/context.php @@ -14,7 +14,7 @@ - + diff --git a/gsearch/index.php b/gsearch/index.php index d4f596d..e7011bf 100644 --- a/gsearch/index.php +++ b/gsearch/index.php @@ -14,7 +14,7 @@ if($GLOBALS['enableGoogleCustomSearch']==false) {
- +
diff --git a/header.inc.php b/header.inc.php index 820b5f9..f94ce0d 100644 --- a/header.inc.php +++ b/header.inc.php @@ -1,35 +1,31 @@ diff --git a/index.php b/index.php index 2b5eda2..0a2b483 100644 --- a/index.php +++ b/index.php @@ -20,6 +20,7 @@ ***************************************************************************/ require_once('header.inc.php'); + $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService'); $templateservice =& ServiceFactory::getServiceInstance('TemplateService'); $userservice =& ServiceFactory::getServiceInstance('UserService'); diff --git a/jsScuttle.php b/jsScuttle.php index 53356aa..222b91d 100644 --- a/jsScuttle.php +++ b/jsScuttle.php @@ -2,7 +2,7 @@ header('Content-Type: text/javascript'); require_once('header.inc.php'); require_once('functions.inc.php'); -$player_root = $root .'includes/player/'; +$player_root = ROOT .'includes/player/'; ?> function _playerAdd(anchor) { @@ -41,7 +41,7 @@ function deleteConfirmed(ele, input, response) { post.style.display = 'none'; deleted = false; } else { - loadXMLDoc('ajaxDelete.php?id=' + input); + loadXMLDoc('ajaxDelete.php?id=' + input); post.style.display = 'none'; } @@ -62,7 +62,7 @@ function isAvailable(input, response){ username = username.trim(); var availability = document.getElementById("availability"); if (username != '') { - usernameField.style.backgroundImage = 'url(images/loading.gif)'; + usernameField.style.backgroundImage = 'url(images/loading.gif)'; if (response != '') { usernameField.style.backgroundImage = 'none'; if (response == 'true') { @@ -73,7 +73,7 @@ function isAvailable(input, response){ availability.innerHTML = ''; } } else { - loadXMLDoc('ajaxIsAvailable.php?username=' + username); + loadXMLDoc('ajaxIsAvailable.php?username=' + username); } } } @@ -92,12 +92,12 @@ function useAddress(ele) { function getTitle(input, response){ var title = document.getElementById('titleField'); if (title.value == '') { - title.style.backgroundImage = 'url(images/loading.gif)'; + title.style.backgroundImage = 'url(images/loading.gif)'; if (response != null) { title.style.backgroundImage = 'none'; title.value = response; } else if (input.indexOf('http') > -1) { - loadXMLDoc('ajaxGetTitle.php?url=' + input); + loadXMLDoc('ajaxGetTitle.php?url=' + input); } else { return false; } diff --git a/rss.php b/rss.php index fc35e40..476a28d 100644 --- a/rss.php +++ b/rss.php @@ -75,7 +75,7 @@ if ($cat) { } $tplVars['feedtitle'] = filter($GLOBALS['sitename'] . (isset($pagetitle) ? $pagetitle : '')); -$tplVars['feedlink'] = $GLOBALS['root']; +$tplVars['feedlink'] = ROOT; $tplVars['feeddescription'] = sprintf(T_('Recent bookmarks posted to %s'), $GLOBALS['sitename']); $bookmarks =& $bookmarkservice->getBookmarks(0, 15, $userid, $cat, NULL, getSortOrder(), $watchlist); diff --git a/services/userservice.php b/services/userservice.php index 9b295da..e611cb8 100644 --- a/services/userservice.php +++ b/services/userservice.php @@ -23,8 +23,8 @@ class UserService { function UserService(& $db) { $this->db =& $db; $this->tablename = $GLOBALS['tableprefix'] .'users'; - $this->sessionkey = $GLOBALS['cookieprefix'].INSTALLATION_ID.'-currentuserid'; - $this->cookiekey = $GLOBALS['cookieprefix'].INSTALLATION_ID.'-login'; + $this->sessionkey = INSTALLATION_ID.'-currentuserid'; + $this->cookiekey = INSTALLATION_ID.'-login'; $this->profileurl = createURL('profile', '%2$s'); } @@ -124,10 +124,11 @@ class UserService { if (!is_null($newval)) //internal use only: reset currentuser $currentuser = $newval; else if ($refresh || !isset($currentuser)) { - if ($id = $this->getCurrentUserId()) - $currentuser = $this->getUser($id); - else - return null; + if ($id = $this->getCurrentUserId()) { + $currentuser = $this->getUser($id); + } else { + $currentuser = null; + } } return $currentuser; } diff --git a/templates/bookmarks.tpl.php b/templates/bookmarks.tpl.php index 27dfb6e..5567d7b 100644 --- a/templates/bookmarks.tpl.php +++ b/templates/bookmarks.tpl.php @@ -257,7 +257,7 @@ window.onload = playerLoad; $brss = ''; $size = count($rsschannels); for ($i = 0; $i < $size; $i++) { - $brss = ''. $rsschannels[$i][0] .''; + $brss = ''. $rsschannels[$i][0] .''; } echo '

'. $bfirst .' / '. $bprev .' / '. $bnext .' / '. $blast .' / '. sprintf(T_('Page %d of %d'), $page, $totalpages) ." ". $brss ."

\n"; diff --git a/templates/editbookmark.tpl.php b/templates/editbookmark.tpl.php index f6affc4..c947ec3 100644 --- a/templates/editbookmark.tpl.php +++ b/templates/editbookmark.tpl.php @@ -43,7 +43,7 @@ switch ($row['bStatus']) { - + diff --git a/templates/login.tpl.php b/templates/login.tpl.php index 6137dc0..def2d72 100644 --- a/templates/login.tpl.php +++ b/templates/login.tpl.php @@ -27,7 +27,7 @@ window.onload = function() { -

»

+

»

0) { '; - if(strlen($user)==0) { - $cat_url = createURL('tags', '%2$s'); + if(!isset($user)) { + $user = ''; + $cat_url = createURL('tags', '%2$s'); } - foreach ($recentTags as $row) { + foreach ($recentTags as $row) { $entries = T_ngettext('bookmark', 'bookmarks', $row['bCount']); $contents .= ' '; } diff --git a/templates/toolbar.inc.php b/templates/toolbar.inc.php index 92d8d59..0b052e0 100644 --- a/templates/toolbar.inc.php +++ b/templates/toolbar.inc.php @@ -13,7 +13,7 @@ if ($userservice->isLoggedOn()) {
  • -
  • ()
  • +
  • ()
  • diff --git a/templates/top.inc.php b/templates/top.inc.php index 88a949a..0d59dfb 100644 --- a/templates/top.inc.php +++ b/templates/top.inc.php @@ -5,9 +5,9 @@ <?php echo filter($GLOBALS['sitename'] . (isset($pagetitle) ? ': ' . $pagetitle : '')); ?> + href="icon.png" /> + href="scuttle.css" /> + src="jsScuttle.php"> @@ -50,7 +50,7 @@ if(isset($_GET['popup'])) { ?>