Commit f0de6cc5 authored by lphuberdeau's avatar lphuberdeau

[MOD] Cleanup database abstraction layer to ease unit testing, cleanup constructors

parent 4ed0f272
......@@ -1527,6 +1527,11 @@ lib/core/lib/Multilingual/Aligner/BilingualAligner.php -text
lib/core/lib/Multilingual/Aligner/SentenceSegmentor.php -text
lib/core/lib/Multilingual/Aligner/ShortestPathFinder.php -text
lib/core/lib/Multilingual/MachineTranslation/GoogleTranslateWrapper.php -text
lib/core/lib/TikiDb.php -text
lib/core/lib/TikiDb/Adodb.php -text
lib/core/lib/TikiDb/ErrorHandler.php -text
lib/core/lib/TikiDb/Exception.php -text
lib/core/lib/TikiDb/Pdo.php -text
lib/core/lib/TikiFilter.php -text
lib/core/lib/TikiFilter/Callback.php -text
lib/core/lib/TikiFilter/PreventXss.php -text
......@@ -2866,10 +2871,6 @@ lib/tikiaccesslib.php -text
lib/tikidate-pear-date.php -text
lib/tikidate-php5.php -text
lib/tikidate.php -text
lib/tikidblib-adodb.php -text
lib/tikidblib-debug.php -text
lib/tikidblib-pdo.php -text
lib/tikidblib.php -text
lib/tikifck.php -text
lib/tikihelp/content.html -text
lib/tikihelp/css/index.php -text
......
......@@ -13,7 +13,7 @@ require_once ('tiki-setup.php');
include_once ('lib/banners/bannerlib.php');
if (!isset($bannerlib)) {
$bannerlib = new BannerLib($dbTiki);
$bannerlib = new BannerLib;
}
// CHECK FEATURE BANNERS HERE
......
......@@ -45,7 +45,7 @@ if (is_file($bannercachefile) and (!isset($_REQUEST["reload"]))) {
} else {
include_once ('lib/banners/bannerlib.php');
if (!isset($bannerlib)) {
$bannerlib = new BannerLib($dbTiki);
$bannerlib = new BannerLib;
}
$data = $bannerlib->get_banner($_REQUEST["id"]);
if (!$data) {
......
......@@ -20,7 +20,7 @@ $access->check_permission(array('tiki_p_edit_copyrights'), tra("Copyright manage
include_once ("lib/copyrights/copyrightslib.php");
global $dbTiki;
$copyrightslib = new CopyrightsLib($dbTiki);
$copyrightslib = new CopyrightsLib;
if (!isset($_REQUEST["page"])) {
$smarty->assign('msg', tra("No page indicated"));
......
......@@ -79,3 +79,6 @@ function close_connection() {
global $dbTiki;
$dbTiki->Close();
}
require_once 'TikiDb/Adodb.php';
TikiDb::set( new TikiDb_Adodb( $dbTiki ) );
......@@ -82,3 +82,6 @@ function close_connection() {
global $dbTiki;
$dbTiki= NULL;
}
require_once 'TikiDb/Pdo.php';
TikiDb::set( new TikiDb_Pdo( $dbTiki ) );
......@@ -22,7 +22,7 @@ include_once('lib/init/tra.php');
// Otherwise you will be ok.
//$api_tiki = 'pear';
//$api_tiki = 'pdo';
$api_tiki = 'adodb';
$api_tiki = 'pdo';
$db_tiki = 'mysql';
$dbversion_tiki = '2.0';
$host_tiki = 'localhost';
......@@ -112,3 +112,102 @@ unset ($host_tiki);
unset ($user_tiki);
unset ($pass_tiki);
unset ($dbs_tiki);
class TikiDb_LegacyErrorHandler implements TikiDb_ErrorHandler
{
function handle( TikiDb $db, $query, $values, $result ) // {{{
{
global $smarty, $prefs, $ajaxlib;
trigger_error($db->getServerType . " error: " . htmlspecialchars($db->getErrorMessage()). " in query:<br /><pre>\n" . htmlspecialchars($query) . "\n</pre><br />", E_USER_WARNING);
// only for debugging.
$outp = "<div class='simplebox'><b>".htmlspecialchars(tra("An error occured in a database query!"))."</b></div>";
$outp.= "<br /><table class='form'>";
$outp.= "<tr class='heading'><td colspan='2'>Context:</td></tr>";
$outp.= "<tr class='formcolor'><td>File</td><td>".htmlspecialchars(basename($_SERVER['SCRIPT_NAME']))."</td></tr>";
$outp.= "<tr class='formcolor'><td>Url</td><td>".htmlspecialchars(basename($_SERVER['REQUEST_URI']))."</td></tr>";
$outp.= "<tr class='heading'><td colspan='2'>Query:</td></tr>";
$outp.= "<tr class='formcolor'><td colspan='2'><tt>".htmlspecialchars($query)."</tt></td></tr>";
$outp.= "<tr class='heading'><td colspan='2'>Values:</td></tr>";
foreach ($values as $k=>$v) {
if (is_null($v)) $v='<i>NULL</i>';
else $v=htmlspecialchars($v);
$outp.= "<tr class='formcolor'><td>".htmlspecialchars($k)."</td><td>$v</td></tr>";
}
$outp.= "<tr class='heading'><td colspan='2'>Message:</td></tr><tr class='formcolor'><td colspan='2'>".htmlspecialchars($db->getErrorMessage())."</td></tr>\n";
$q=$query;
foreach($values as $v) {
if (is_null($v)) $v='NULL';
else $v="'".addslashes($v)."'";
$pos=strpos($q, '?');
if ($pos !== FALSE)
$q=substr($q, 0, $pos)."$v".substr($q, $pos+1);
}
$outp.= "<tr class='heading'><td colspan='2'>Built query was probably:</td></tr><tr class='formcolor'><td colspan='2'>".htmlspecialchars($q)."</td></tr>\n";
if (function_exists('xdebug_get_function_stack')) {
function mydumpstack($stack) {
$o='';
foreach($stack as $line) {
$o.='* '.$line['file']." : ".$line['line']." -> ".$line['function']."(".var_export($line['params'], true).")<br />";
}
return $o;
}
$outp.= "<tr class='heading'><th>Stack Trace</th><td>".mydumpstack(xdebug_get_function_stack())."</td></tr>";
}
$outp.= "</table>";
//if($result===false) echo "<br>\$result is false";
//if($result===null) echo "<br>\$result is null";
//if(empty($result)) echo "<br>\$result is empty";
$showviaajax=false;
if ($prefs['feature_ajax'] == 'y') {
global $ajaxlib;
include_once('lib/ajax/xajax/xajax_core/xajaxAIO.inc.php');
if ($ajaxlib && $ajaxlib->canProcessRequest()) {
// this was a xajax request -> return a xajax answer
$objResponse = new xajaxResponse();
$page ="<html><head>";
$page.=" <title>Tiki SQL Error (xajax)</title>";
$page.=" <link rel='stylesheet' href='styles/tikineat.css' type='text/css' />";
$page.="</head><body>$outp</body></html>";
$page=addslashes(str_replace(array("\n", "\r"), array(' ', ' '), $page));
$objResponse->script("bugwin=window.open('', 'tikierror', 'width=760,height=500,scrollbars=1,resizable=1');".
"bugwin.document.write('$page');");
echo $objResponse->getOutput();
die();
}
}
if ( ! isset($_SESSION['fatal_error']) ) {
// Do not show the error if an error has already occured during the same script execution (error.tpl already called),
// because tiki should have died before another error.
// This happens when error.tpl is called by tiki.sql... and tiki.sql is also called again in error.tpl, entering in an infinite loop.
require_once('tiki-setup.php');
if ( $smarty ) {
$smarty->assign('msg', $outp);
$_SESSION['fatal_error'] = 'y';
$smarty->display('error.tpl');
unset($_SESSION['fatal_error']);
} else {
echo $outp;
}
die;
}
} // }}}
}
global $db_table_prefix, $common_users_table_prefix;
$db = TikiDb::get();
$db->setErrorHandler( new TikiDb_LegacyErrorHandler );
if( isset( $db_table_prefix ) )
$db->setTablePrefix( $db_table_prefix );
if( isset( $common_users_table_prefix ) )
$db->setUsersTablePrefix( $common_users_table_prefix );
......@@ -19,7 +19,7 @@ require_once ('tiki-setup.php');
include_once ('lib/banners/bannerlib.php');
if (!isset($bannerlib)) {
$bannerlib = new BannerLib($dbTiki);
$bannerlib = new BannerLib;
}
// CHECK FEATURE BANNERS HERE
......
......@@ -9,7 +9,7 @@ require_once("lib/structures/structlib.php");
function tra($s) { return $s; }
$tikilib = new TikiLib($dbTiki);
$tikilib = new TikiLib;
$categId = '113';
$structId = '160';
......
......@@ -13,8 +13,8 @@ require_once("db/tiki-db.php");
require_once("lib/tikilib.php");
require_once("lib/userslib.php");
$tikilib = new TikiLib($dbTiki);
$userlib = new UsersLib($dbTiki);
$tikilib = new TikiLib;
$userlib = new UsersLib;
$users = $userlib->get_group_users('CC');
......
......@@ -301,8 +301,7 @@ if ( $script_mode ) {
if ( file_exists('db/local.php') ) {
require_once('db/tiki-db.php');
require_once('lib/tikidblib.php');
$tikilib = new TikiDB($dbTiki);
$tikilib = TikiDb::get();
} else {
require_once('lib/setup/prefs.php'); // Used to get default prefs
}
......
......@@ -753,9 +753,9 @@ if ( isset($dbTiki) && is_object($dbTiki) && isset($_SESSION["install-logged-$mu
$smarty->assign('dbdone', 'y');
$install_type = 'scratch';
require_once 'lib/tikilib.php';
$tikilib = new TikiLib( $dbTiki );
$tikilib = new TikiLib;
require_once 'lib/userslib.php';
$userlib = new UsersLib( $dbTiki );
$userlib = new UsersLib;
require_once 'lib/profilelib/profilelib.php';
require_once 'lib/profilelib/installlib.php';
require_once 'lib/setup/compat.php';
......
......@@ -7,9 +7,6 @@ if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
}
class AdminLib extends TikiLib {
function AdminLib($db) {
$this->TikiLib($db);
}
function list_dsn($offset, $maxRecords, $sort_mode, $find) {
......@@ -23,7 +20,7 @@ class AdminLib extends TikiLib {
$mid = "";
}
$query = "select * from `tiki_dsn` $mid order by ".$this->convert_sortmode($sort_mode);
$query = "select * from `tiki_dsn` $mid order by ".$this->convertSortMode($sort_mode);
$query_cant = "select count(*) from `tiki_dsn` $mid";
$result = $this->query($query,$bindvars,$maxRecords,$offset);
$cant = $this->getOne($query_cant,$bindvars);
......@@ -98,7 +95,7 @@ class AdminLib extends TikiLib {
$mid = "";
}
$query = "select * from `tiki_extwiki` $mid order by ".$this->convert_sortmode($sort_mode);
$query = "select * from `tiki_extwiki` $mid order by ".$this->convertSortMode($sort_mode);
$query_cant = "select count(*) from `tiki_extwiki` $mid";
$result = $this->query($query,$bindvars,$maxRecords,$offset);
$cant = $this->getOne($query_cant,$bindvars);
......@@ -444,5 +441,4 @@ class AdminLib extends TikiLib {
}
}
global $dbTiki;
$adminlib = new AdminLib($dbTiki);
$adminlib = new AdminLib;
......@@ -13,9 +13,8 @@ include_once ("lib/commentslib.php");
include_once ("lib/logs/logslib.php");
class MagicLib extends TikiLib {
function MagicLib($db) {
$this->TikiLib($db);
function __construct() {
parent::__construct();
global $prefs;
$lastLoad = $prefs['magic_last_load'];
$lastMod = filemtime( 'db/features.csv' );
......@@ -304,5 +303,4 @@ class MagicLib extends TikiLib {
return $slide_styles;
}
}
global $dbTiki;
$magiclib = new MagicLib($dbTiki);
$magiclib = new MagicLib;
......@@ -23,16 +23,6 @@ if ($prefs['feature_ajax'] == 'y') {
var $deniedFunctions;
/**
* PHP4 constructor.
*
* @access public
* @return void
*/
function TikiAjax() {
TikiAjax::__construct();
}
/**
* PHP 5 constructor.
*
......@@ -40,7 +30,7 @@ if ($prefs['feature_ajax'] == 'y') {
* @return void
*/
function __construct() {
xajax::xajax();
parent::__construct();
$this->aTemplates = array();
$this->deniedFunctions = array();
......
......@@ -7,10 +7,6 @@ if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
}
class ArtLib extends TikiLib {
function ArtLib($db) {
$this->TikiLib($db);
}
//Special parsing for multipage articles
function get_number_of_pages($data) {
$parts = explode("...page...", $data);
......@@ -701,5 +697,4 @@ $show_expdate, $show_reads, $show_size, $show_topline, $show_subtitle, $show_lin
}
global $dbTiki;
$artlib = new ArtLib($dbTiki);
$artlib = new ArtLib;
......@@ -12,8 +12,8 @@ class bablotron extends TikiLib {
var $lan;
var $tbl;
function bablotron($db, $lan) {
$this->TikiLib($db);
function __construct($db, $lan) {
parent::__construct();
$this->lan = preg_replace('/-/','_',$lan);
$this->tbl = 'babl_words_' . $this->lan;
}
......
......@@ -7,10 +7,6 @@ if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
}
class BanLib extends TikiLib {
function BanLib($db) {
$this->TikiLib($db);
}
function get_rule($banId) {
$query = "select * from `tiki_banning` where `banId`=?";
......@@ -58,7 +54,7 @@ class BanLib extends TikiLib {
}
}
$query = "select * from `tiki_banning` $mid order by ".$this->convert_sortmode($sort_mode);
$query = "select * from `tiki_banning` $mid order by ".$this->convertSortMode($sort_mode);
$query_cant = "select count(*) from `tiki_banning` $mid";
$result = $this->query($query,$bindvars,$maxRecords,$offset);
$cant = $this->getOne($query_cant,$bindvars);
......@@ -142,5 +138,4 @@ class BanLib extends TikiLib {
}
}
}
global $dbTiki;
$banlib = new BanLib($dbTiki);
$banlib = new BanLib;
......@@ -7,9 +7,6 @@ if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
}
class BannerLib extends TikiLib {
function BannerLib($db) {
$this->TikiLib($db);
}
function select_banner($zone, $target='_blank') {
global $prefs;
......@@ -45,7 +42,7 @@ class BannerLib extends TikiLib {
$query = "select * from `tiki_banners` where $dw = ? and `hourFrom`<=? and `hourTo`>=? and
( ((`useDates` = ?) and (`fromDate`<=? and `toDate`>=?)) or (`useDates` = ?) ) and
(`impressions`<`maxImpressions` or `maxImpressions`=?) and (`clicks`<`maxClicks` or `maxClicks`=? or `maxClicks` is NULL) and `zone`=? order by ".$this->convert_sortmode('random');
(`impressions`<`maxImpressions` or `maxImpressions`=?) and (`clicks`<`maxClicks` or `maxClicks`=? or `maxClicks` is NULL) and `zone`=? order by ".$this->convertSortMode('random');
$result = $this->query($query,$bindvars,1,0);
if (!($res = $result->fetchRow())) {
return false;
......@@ -139,7 +136,7 @@ class BannerLib extends TikiLib {
}
}
$query = "select * from `tiki_banners` $mid order by ".$this->convert_sortmode($sort_mode);
$query = "select * from `tiki_banners` $mid order by ".$this->convertSortMode($sort_mode);
$query_cant = "select count(*) from `tiki_banners` $mid";
$result = $this->query($query,$bindvars,$maxRecords,$offset);
$cant = $this->getOne($query_cant,$bindvars);
......@@ -290,5 +287,4 @@ class BannerLib extends TikiLib {
return true;
}
}
global $dbTiki;
$bannerlib = new BannerLib($dbTiki);
$bannerlib = new BannerLib;
......@@ -7,9 +7,6 @@ if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
}
class BlogLib extends TikiLib {
function BlogLib($db) {
$this->TikiLib($db);
}
//Special parsing for multipage articles
function get_number_of_pages($data) {
......@@ -130,7 +127,7 @@ class BlogLib extends TikiLib {
}
$mid = empty($mid) ? '' : 'where ' . implode(' and ', $mid);
$query = "select * from `tiki_blog_posts` $mid order by ".$this->convert_sortmode($sort_mode);
$query = "select * from `tiki_blog_posts` $mid order by ".$this->convertSortMode($sort_mode);
$query_cant = "select count(*) from `tiki_blog_posts` $mid";
$result = $this->query($query, $bindvars, $maxRecords, $offset);
$cant = $this->getOne($query_cant, $bindvars);
......@@ -213,7 +210,7 @@ class BlogLib extends TikiLib {
}
}
$query = "select * from `tiki_blog_posts` $mid order by ".$this->convert_sortmode($sort_mode);
$query = "select * from `tiki_blog_posts` $mid order by ".$this->convertSortMode($sort_mode);
$query_cant = "select count(*) from `tiki_blog_posts` $mid";
$result = $this->query($query,$bindvars,$maxRecords,$offset);
$cant = $this->getOne($query_cant,$bindvars);
......@@ -416,7 +413,7 @@ class BlogLib extends TikiLib {
$bindvars=array($user);
}
$query = "select * from `tiki_blog_posts` $mid order by ".$this->convert_sortmode($sort_mode);
$query = "select * from `tiki_blog_posts` $mid order by ".$this->convertSortMode($sort_mode);
$query_cant = "select count(*) from `tiki_blog_posts` $mid";
$result = $this->query($query,$bindvars,$maxRecords,$offset);
$cant = $this->getOne($query_cant,$bindvars);
......@@ -484,5 +481,4 @@ class BlogLib extends TikiLib {
return $this->getOne($query, array((int)$blogId));
}
}
global $dbTiki;
$bloglib = new BlogLib($dbTiki);
$bloglib = new BlogLib;
......@@ -7,10 +7,6 @@ if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
}
class BookmarkLib extends TikiLib {
function BookmarkLib($db) {
$this->TikiLib($db);
}
function get_folder_path($folderId, $user) {
$path = '';
......@@ -136,7 +132,7 @@ class BookmarkLib extends TikiLib {
$bindvars=array($folderId,$user);
}
$query = "select * from `tiki_user_bookmarks_urls` where `folderId`=? and `user`=? $mid order by ".$this->convert_sortmode($sort_mode);
$query = "select * from `tiki_user_bookmarks_urls` where `folderId`=? and `user`=? $mid order by ".$this->convertSortMode($sort_mode);
$query_cant = "select count(*) from `tiki_user_bookmarks_urls` where `folderId`=? and `user`=? $mid";
$result = $this->query($query,$bindvars,$maxRecords,$offset);
$cant = $this->getOne($query_cant,$bindvars);
......@@ -170,5 +166,4 @@ class BookmarkLib extends TikiLib {
return $ret;
}
}
global $dbTiki;
$bookmarklib = new BookmarkLib($dbTiki);
$bookmarklib = new BookmarkLib;
......@@ -9,19 +9,15 @@ if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
if (!defined('weekInSeconds')) define('weekInSeconds', 604800);
class CalendarLib extends TikiLib {
function convert_sortmode($sort_mode) {
function convertSortMode($sort_mode) {
$tmp = explode("_",$sort_mode);
if (count($tmp) == 2) {
if ($tmp[0] == "categoryName" || $tmp[0] == "locationName")
return "name " . $tmp[1];
}
return parent::convert_sortmode($sort_mode);
return parent::convertSortMode($sort_mode);
}
function CalendarLib($db) {
$this->TikiLib($db);
}
function list_calendars($offset = 0, $maxRecords = -1, $sort_mode = 'name_asc', $find = '') {
$mid = '';
$res = array();
......@@ -30,7 +26,7 @@ class CalendarLib extends TikiLib {
$mid = "where `name` like ?";
$bindvars[] = '%'.$find.'%';
}
$query = "select * from `tiki_calendars` $mid order by ".$this->convert_sortmode($sort_mode);
$query = "select * from `tiki_calendars` $mid order by ".$this->convertSortMode($sort_mode);
$result = $this->query($query,$bindvars,$maxRecords,$offset);
$query_cant = "select count(*) from `tiki_calendars` $mid";
$cant = $this->getOne($query_cant,$bindvars);
......@@ -198,7 +194,7 @@ class CalendarLib extends TikiLib {
$joinCompl = " on i.locationId = compl.callocid ";
$tblRef = "compl.";
}
$query .= "from " . $queryCompl . "`tiki_calendar_items` as i ".$joinCompl." left join `tiki_calendars` as c on i.`calendarId`=c.`calendarId` where ($cond) order by ". $tblRef . $this->convert_sortmode("$sort_mode");
$query .= "from " . $queryCompl . "`tiki_calendar_items` as i ".$joinCompl." left join `tiki_calendars` as c on i.`calendarId`=c.`calendarId` where ($cond) order by ". $tblRef . $this->convertSortMode("$sort_mode");
$result = $this->query($query, $bindvars, $maxRecords, $offset);
$ret = array();
while ($res = $result->fetchRow()) {
......@@ -568,7 +564,7 @@ class CalendarLib extends TikiLib {
$bindvars = array();
}
$query = "select `start`, `name`, `calitemId`, `calendarId`, `user`, `lastModif` from `tiki_calendar_items` ".$cond."order by ".$this->convert_sortmode('lastModif_desc');
$query = "select `start`, `name`, `calitemId`, `calendarId`, `user`, `lastModif` from `tiki_calendar_items` ".$cond."order by ".$this->convertSortMode('lastModif_desc');
$result = $this->query($query,$bindvars,$maxrows,0);
......@@ -634,7 +630,7 @@ class CalendarLib extends TikiLib {
$cond .= " and `end` <= (unix_timestamp(now())) +".$maxSeconds;
}
$ljoin = "left join `tiki_calendar_locations` as l on i.`locationId`=l.`callocId` left join `tiki_calendar_categories` as c on i.`categoryId`=c.`calcatId`";
$query = "select i.`start`, i.`end`, i.`name`, i.`description`, i.`calitemId`, i.`calendarId`, i.`user`, i.`lastModif`, i.`url`, l.`name` as location, i.`allday`, c.`name` as category from `tiki_calendar_items` i $ljoin where 1=1 ".$cond." order by ".$this->convert_sortmode($order);
$query = "select i.`start`, i.`end`, i.`name`, i.`description`, i.`calitemId`, i.`calendarId`, i.`user`, i.`lastModif`, i.`url`, l.`name` as location, i.`allday`, c.`name` as category from `tiki_calendar_items` i $ljoin where 1=1 ".$cond." order by ".$this->convertSortMode($order);
$result = $this->query($query,$bindvars,$maxrows,0);
$ret = array();
......@@ -811,5 +807,4 @@ class CalendarLib extends TikiLib {
);
}
}
global $dbTiki;
$calendarlib = new CalendarLib($dbTiki);
$calendarlib = new CalendarLib;
......@@ -37,8 +37,7 @@ class CalRecurrence extends TikiLib {
private $lastModif;
public function CalRecurrence($param = -1) {
global $dbTiki;
parent::__construct($dbTiki);
parent::__construct();
if ($param > 0)
$this->setId($param);
$this->load();
......
......@@ -5,10 +5,6 @@ require_once('calendarlib.php');
class TikiCalendarLib extends CalendarLib {
function TikiCalendarLib($db) {
parent::CalendarLib($db);
}
function list_items_by_day($tikiobj, $user, $tstart, $tstop, $offset, $maxRecords, $sort_mode = 'name_desc', $find = '') {
return $this->list_tiki_items($tikiobj, $user, $tstart, $tstop, $offset, $maxRecords, $sort_mode, $find);
}
......@@ -166,5 +162,4 @@ class TikiCalendarLib extends CalendarLib {
return ( $with_infos ? $return : array_keys($return) );
}
}
global $dbTiki;
$tikicalendarlib = new TikiCalendarLib($dbTiki);
$tikicalendarlib = new TikiCalendarLib;
......@@ -16,10 +16,6 @@ global $objectlib;require_once("lib/objectlib.php");
class CategLib extends ObjectLib {
function CategLib($db) {
parent::ObjectLib($db);
}
function list_categs($categId=0) {
global $cachelib;
if (!$cachelib->isCached('allcategs')) {
......@@ -56,7 +52,7 @@ class CategLib extends ObjectLib {
$mid = "";
}
$query = "select * from `tiki_categories` $mid order by ".$this->convert_sortmode($sort_mode);
$query = "select * from `tiki_categories` $mid order by ".$this->convertSortMode($sort_mode);
$query_cant = "select count(*) from `tiki_categories` $mid";
$result = $this->query($query,$bindvals,$maxRecords,$offset);
$cant = $this->getOne($query_cant,$bindvals);
......@@ -443,7 +439,7 @@ class CategLib extends ObjectLib {
$orderBy = '';
if ($sort_mode) {
if ($sort_mode != 'shuffle') {
$orderBy = " ORDER BY ".$this->convert_sortmode($sort_mode);
$orderBy = " ORDER BY ".$this->convertSortMode($sort_mode);
}
}
......@@ -1213,7 +1209,7 @@ class CategLib extends ObjectLib {
$bindvars[] = $type;
}
$sort_mode = "created_desc";
$query = "select co.`catObjectId`, `categId`, `type`, `name`, `href` from `tiki_category_objects` co, `tiki_categorized_objects` cdo, `tiki_objects` o where co.`catObjectId`=cdo.`catObjectId` and o.`objectId`=cdo.`catObjectId` $mid order by o.".$this->convert_sortmode($sort_mode);
$query = "select co.`catObjectId`, `categId`, `type`, `name`, `href` from `tiki_category_objects` co, `tiki_categorized_objects` cdo, `tiki_objects` o where co.`catObjectId`=cdo.`catObjectId` and o.`objectId`=cdo.`catObjectId` $mid order by o.".$this->convertSortMode($sort_mode);
$result = $this->query($query,$bindvars,$maxRecords,0);
$ret = array('data'=>array());
......@@ -1560,5 +1556,4 @@ class CategLib extends ObjectLib {
}
}
global $dbTiki;
$categlib = new CategLib($dbTiki);
$categlib = new CategLib;
......@@ -7,10 +7,6 @@ if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
}
class ChartLib extends TikiLib {
function ChartLib($db) {
$this->TikiLib($db);
}
function add_chart_hit($chartId) {
global $prefs, $user;
......@@ -438,7 +434,7 @@ class ChartLib extends TikiLib {
}
}
$query = "select * from `tiki_charts` $mid order by ".$this->convert_sortmode($sort_mode);
$query = "select * from `tiki_charts` $mid order by ".$this->convertSortMode($sort_mode);
$query_cant = "select count(*) from `tiki_charts` $mid";
$result = $this->query($query,$bindvars,$maxRecords,$offset);
$cant = $this->getOne($query_cant,$bindvars);
......@@ -480,7 +476,7 @@ class ChartLib extends TikiLib {
}
}
$query = "select * from `tiki_chart_items` $mid order by ".$this->convert_sortmode($sort_mode);
$query = "select * from `tiki_chart_items` $mid order by ".$this->convertSortMode($sort_mode);
$query_cant = "select count(*) from `tiki_chart_items` $mid";
$result = $this->query($query,$bindvars,$maxRecords,$offset);
$cant = $this->getOne($query_cant,$bindvars);
......@@ -496,5 +492,4 @@ class ChartLib extends TikiLib {
return $retval;
}
}
global $dbTiki;
$chartlib = new ChartLib($dbTiki);
$chartlib = new ChartLib;
......@@ -7,9 +7,6 @@ if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
}
class CommLib extends TikiLib {
function CommLib($db) {
$this->TikiLib($db);
}
function accept_page($receivedPageId) {
$info = $this->get_received_page($receivedPageId);
......@@ -82,7 +79,7 @@ class CommLib extends TikiLib {
$mid = "";
}
$query = "select * from `tiki_received_articles` $mid order by ".$this->convert_sortmode($sort_mode);
$query = "select * from `tiki_received_articles` $mid order by ".$this->convertSortMode($sort_mode);
$query_cant = "select count(*) from `tiki_received_articles` $mid";
$result = $this->query($query,$bindvars,$maxRecords,$offset);
$cant = $this->getOne($query_cant,$bindvars);
......@@ -194,5 +191,4 @@ class CommLib extends TikiLib {
// Functions for the communication center end ////
}
global $dbTiki;
$commlib = new CommLib($dbTiki);
$commlib = new CommLib;