diff --git a/trunk/conlite/classes/cApi/class.action.php b/trunk/conlite/classes/cApi/class.action.php index 46674bb..17586c5 100644 --- a/trunk/conlite/classes/cApi/class.action.php +++ b/trunk/conlite/classes/cApi/class.action.php @@ -33,12 +33,6 @@ class cApiActionCollection extends ItemCollection { parent::__construct($cfg['tab']['actions'], 'idaction'); $this->_setItemClass("cApiAction"); } - - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function cApiActionCollection() { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct(); - } /** * @@ -99,11 +93,5 @@ class cApiAction extends Item { // @todo Where is this used??? $this->_wantParameters = array(); } - - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function cApiAction($mId = false) { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct($mId); - } } ?> \ No newline at end of file diff --git a/trunk/conlite/classes/class.action.php b/trunk/conlite/classes/class.action.php index ed78a38..acd6efa 100644 --- a/trunk/conlite/classes/class.action.php +++ b/trunk/conlite/classes/class.action.php @@ -41,7 +41,7 @@ class Action { * Constructor Function * @param */ - function Action() { + function __construct() { // empty } // end function diff --git a/trunk/conlite/classes/class.activeusers.php b/trunk/conlite/classes/class.activeusers.php index 969f868..fafcdcc 100644 --- a/trunk/conlite/classes/class.activeusers.php +++ b/trunk/conlite/classes/class.activeusers.php @@ -38,7 +38,7 @@ class ActiveUsers { * * @return * */ - function ActiveUsers($oDb, $oCfg, $oAuth) { + function __construct($oDb, $oCfg, $oAuth) { $this->oCfg = $oCfg; $this->oAuth = $oAuth; diff --git a/trunk/conlite/classes/class.area.php b/trunk/conlite/classes/class.area.php index aa427c4..cb8f5cd 100644 --- a/trunk/conlite/classes/class.area.php +++ b/trunk/conlite/classes/class.area.php @@ -38,7 +38,7 @@ class Area { * Constructor Function * @param */ - function Area() { + function __construct() { // empty } // end function diff --git a/trunk/conlite/classes/class.art.php b/trunk/conlite/classes/class.art.php index f450950..16cbd01 100644 --- a/trunk/conlite/classes/class.art.php +++ b/trunk/conlite/classes/class.art.php @@ -38,7 +38,7 @@ class Art { * Constructor Function * @param */ - function Art() { + function __construct() { // empty } // end function diff --git a/trunk/conlite/classes/class.article.php b/trunk/conlite/classes/class.article.php index 5edfa0d..0108a13 100644 --- a/trunk/conlite/classes/class.article.php +++ b/trunk/conlite/classes/class.article.php @@ -144,12 +144,6 @@ class Article extends Item $this->loadByPrimaryKey($this->_iIdArtLang); $this->_getArticleContent(); } - - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - function Article($idart, $client, $lang, $idartlang = 0) { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct($idart, $client, $lang, $idartlang); - } /** * Getter for idartlang of article object @@ -498,13 +492,6 @@ class ArticleCollection $this->_getArticlesByCatId($this->idcat); } - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - function ArticleCollection($options) - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct($options); - } - /** * Set the Object properties * diff --git a/trunk/conlite/classes/class.artspec.php b/trunk/conlite/classes/class.artspec.php index e80a118..100e0ba 100644 --- a/trunk/conlite/classes/class.artspec.php +++ b/trunk/conlite/classes/class.artspec.php @@ -46,13 +46,6 @@ class ArtSpecCollection extends ItemCollection parent::__construct($cfg['tab']['art_spec'], "idartspec"); $this->_setItemClass("ArtSpecItem"); } - - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function ArtSpecCollection() - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct(); - } } @@ -73,13 +66,6 @@ class ArtSpecItem extends Item $this->loadByPrimaryKey($mId); } } - - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function ArtSpecItem($mId = false) - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct($mId); - } } ?> \ No newline at end of file diff --git a/trunk/conlite/classes/class.backend.php b/trunk/conlite/classes/class.backend.php index f63c195..fd91a4d 100644 --- a/trunk/conlite/classes/class.backend.php +++ b/trunk/conlite/classes/class.backend.php @@ -72,7 +72,7 @@ class Contenido_Backend { /** * Constructor */ - function Contenido_Backend() { + function __construct() { # do nothing } # end function diff --git a/trunk/conlite/classes/class.cat.php b/trunk/conlite/classes/class.cat.php index 27fbc51..1e9af27 100644 --- a/trunk/conlite/classes/class.cat.php +++ b/trunk/conlite/classes/class.cat.php @@ -38,7 +38,7 @@ class Cat { * Constructor Function * @param */ - function Cat() { + function __construct() { // empty } // end function diff --git a/trunk/conlite/classes/class.category.php b/trunk/conlite/classes/class.category.php index e2b570c..28ba7f5 100644 --- a/trunk/conlite/classes/class.category.php +++ b/trunk/conlite/classes/class.category.php @@ -43,13 +43,6 @@ class CategoryCollection extends ItemCollection parent::__construct($cfg["tab"]["cat"], "idcat"); $this->_setItemClass("CategoryItem"); } - - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function CategoryCollection() - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct(); - } } @@ -69,13 +62,6 @@ class CategoryItem extends Item } } - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function CategoryItem($mId = false) - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct(); - } - public function loadByPrimaryKey($key) { if (parent::loadByPrimaryKey($key)) { @@ -101,13 +87,6 @@ class CategoryLanguageCollection extends ItemCollection parent::__construct($cfg["tab"]["cat_lang"], "idcatlang"); $this->_setItemClass("CategoryLanguageItem"); } - - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function CategoryLanguageCollection() - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct(); - } } @@ -126,13 +105,4 @@ class CategoryLanguageItem extends Item $this->loadByPrimaryKey($mId); } } - - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function CategoryLanguageItem($mId = false) - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct($mId); - } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/trunk/conlite/classes/class.chartable.php b/trunk/conlite/classes/class.chartable.php index 48c8f77..bff1f0c 100644 --- a/trunk/conlite/classes/class.chartable.php +++ b/trunk/conlite/classes/class.chartable.php @@ -52,7 +52,7 @@ class cCharacterConverter var $_aAliasCache; var $_aCharCache; - function cCharacterConverter () + function __construct () { $this->_oDB = new DB_ConLite; $this->_aAliasCache = array(); @@ -154,5 +154,4 @@ class cCharacterConverter return $sEncoding; } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/trunk/conlite/classes/class.cl_db_backup.php b/trunk/conlite/classes/class.cl_db_backup.php index d04c35c..47a0a80 100644 --- a/trunk/conlite/classes/class.cl_db_backup.php +++ b/trunk/conlite/classes/class.cl_db_backup.php @@ -131,7 +131,7 @@ class clDbBackup { $data = "DROP TABLE IF EXISTS `$sTable`;\n"; $this->_oDb->query('SHOW CREATE TABLE `' . $sTable . '`'); $this->_oDb->next_record(); - $row = $this->_oDb->toArray(); //@mysql_fetch_row($res); + $row = $this->_oDb->toArray(); $data .= $row[1] . ';' . "\n\n"; if (!$this->_noTableData($sTable)) { $data .= "/*!40000 ALTER TABLE `$sTable` DISABLE KEYS */;\n"; @@ -194,7 +194,7 @@ class clDbBackup { if (!isset($rows[$column])) { $insert.='NULL,'; } else if ($rows[$column] != '') { - $insert.='\'' . mysql_escape_string($rows[$column]) . '\','; + $insert.='\'' . $this->_oDb->escape($rows[$column]) . '\','; } else { $insert.='\'\','; } diff --git a/trunk/conlite/classes/class.client.php b/trunk/conlite/classes/class.client.php index 166a000..a8b4fbc 100644 --- a/trunk/conlite/classes/class.client.php +++ b/trunk/conlite/classes/class.client.php @@ -38,7 +38,7 @@ class Client { * Constructor Function * @param */ - function Client() { + function __construct() { // empty } // end function diff --git a/trunk/conlite/classes/class.communications.php b/trunk/conlite/classes/class.communications.php index dc0feda..ec4c0b6 100644 --- a/trunk/conlite/classes/class.communications.php +++ b/trunk/conlite/classes/class.communications.php @@ -47,13 +47,6 @@ class CommunicationCollection extends ItemCollection $this->_setItemClass("CommunicationItem"); } - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function CommunicationCollection() - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct(); - } - /** * Creates a new communication item */ @@ -91,13 +84,6 @@ class CommunicationItem extends Item } } - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function CommunicationItem($mId = false) - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct($mId); - } - function store() { global $auth; @@ -106,6 +92,4 @@ class CommunicationItem extends Item parent::store(); } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/trunk/conlite/classes/class.dbfs.php b/trunk/conlite/classes/class.dbfs.php index 8e2d442..463ce55 100644 --- a/trunk/conlite/classes/class.dbfs.php +++ b/trunk/conlite/classes/class.dbfs.php @@ -1,4 +1,5 @@ _setItemClass("DBFSItem"); } - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function DBFSCollection() - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct(); - } - - public function outputFile($path) - { + public function outputFile($path) { global $client, $auth; - $path = Contenido_Security::escapeDB($path, null); + $path = Contenido_Security::escapeDB($path, null); $client = Contenido_Security::toInteger($client); - $path = $this->strip_path($path); - $dir = dirname($path); - $file = basename($path); + $path = $this->strip_path($path); + $dir = dirname($path); + $file = basename($path); if ($dir == ".") { $dir = ""; } - $this->select("dirname = '".$dir."' AND filename = '".$file."' AND idclient = '".$client."' LIMIT 1"); + $this->select("dirname = '" . $dir . "' AND filename = '" . $file . "' AND idclient = '" . $client . "' LIMIT 1"); if ($item = $this->next()) { $properties = new PropertyCollection(); // Check if we're allowed to access it - if ($properties->getValue("upload", "dbfs:/".$dir."/".$file, "file", "protected") == "1") { + if ($properties->getValue("upload", "dbfs:/" . $dir . "/" . $file, "file", "protected") == "1") { if ($auth->auth["uid"] == "nobody") { header("HTTP/1.0 403 Forbidden"); return; @@ -83,10 +73,10 @@ class DBFSCollection extends ItemCollection } $mimetype = $item->get("mimetype"); - header("Cache-Control: ");// leave blank to avoid IE errors - header("Pragma: ");// leave blank to avoid IE errors + header("Cache-Control: "); // leave blank to avoid IE errors + header("Pragma: "); // leave blank to avoid IE errors header("Content-Type: $mimetype"); - header("Etag: ".md5(mt_rand())); + header("Etag: " . md5(mt_rand())); // header("Content-Disposition: filename=$file"); header("Content-Disposition: attachment; filename=$file"); @@ -95,23 +85,20 @@ class DBFSCollection extends ItemCollection } } - public function writeFromFile($localfile, $targetfile) - { + public function writeFromFile($localfile, $targetfile) { $targetfile = $this->strip_path($targetfile); - $mimetype = mime_content_type($localfile); + $mimetype = mime_content_type($localfile); $this->write($targetfile, file_get_contents($localfile), $mimetype); } - public function writeToFile($sourcefile, $localfile) - { + public function writeToFile($sourcefile, $localfile) { $sourcefile = $this->strip_path($sourcefile); file_put_contents($localfile, $this->read($sourcefile)); } - public function write($file, $content = "", $mimetype = "") - { + public function write($file, $content = "", $mimetype = "") { $file = $this->strip_path($file); if (!$this->file_exists($file)) { @@ -120,20 +107,19 @@ class DBFSCollection extends ItemCollection $this->setContent($file, $content); } - public function hasFiles($path) - { + public function hasFiles($path) { global $client; - $path = $this->strip_path($path); + $path = $this->strip_path($path); $client = Contenido_Security::toInteger($client); /* Are there any subdirs? */ - $this->select("dirname LIKE '".$path."/%' AND idclient = '".$client."' LIMIT 1"); + $this->select("dirname LIKE '" . $path . "/%' AND idclient = '" . $client . "' LIMIT 1"); if ($this->count() > 0) { return true; } - $this->select("dirname LIKE '".$path."%' AND idclient = '".$client."' LIMIT 2"); + $this->select("dirname LIKE '" . $path . "%' AND idclient = '" . $client . "' LIMIT 2"); if ($this->count() > 1) { return true; @@ -142,18 +128,16 @@ class DBFSCollection extends ItemCollection } } - public function read($file) - { + public function read($file) { return ($this->getContent($file)); } - public function file_exists($path) - { + public function file_exists($path) { global $client; - $path = $this->strip_path($path); - $dir = dirname($path); - $file = basename($path); + $path = $this->strip_path($path); + $dir = dirname($path); + $file = basename($path); if ($dir == ".") { $dir = ""; @@ -161,7 +145,7 @@ class DBFSCollection extends ItemCollection $client = Contenido_Security::toInteger($client); - $this->select("dirname = '".$dir."' AND filename = '".$file."' AND idclient = '".$client."' LIMIT 1"); + $this->select("dirname = '" . $dir . "' AND filename = '" . $file . "' AND idclient = '" . $client . "' LIMIT 1"); if ($this->next()) { return true; } else { @@ -169,8 +153,7 @@ class DBFSCollection extends ItemCollection } } - public function dir_exists($path) - { + public function dir_exists($path) { global $client; $path = $this->strip_path($path); @@ -181,7 +164,7 @@ class DBFSCollection extends ItemCollection $client = Contenido_Security::toInteger($client); - $this->select("dirname = '".$path."' AND filename = '.' AND idclient = '".$client."' LIMIT 1"); + $this->select("dirname = '" . $path . "' AND filename = '.' AND idclient = '" . $client . "' LIMIT 1"); if ($this->next()) { return true; } else { @@ -189,21 +172,19 @@ class DBFSCollection extends ItemCollection } } - public function parent_dir($path) - { + public function parent_dir($path) { $path = dirname($path); return $path; } - public function create($path, $mimetype = "", $content = "") - { + public function create($path, $mimetype = "", $content = "") { global $client, $cfg, $auth; $client = Contenido_Security::toInteger($client); - if (substr($path,0,1) == "/") { - $path = substr($path,1); + if (substr($path, 0, 1) == "/") { + $path = substr($path, 1); } $dir = dirname($path); @@ -220,9 +201,9 @@ class DBFSCollection extends ItemCollection if ($file != ".") { if ($dir != "") { // Check if the directory exists. If not, create it. - $this->select("dirname = '".$dir."' AND filename = '.' AND idclient = '".$client."' LIMIT 1"); + $this->select("dirname = '" . $dir . "' AND filename = '.' AND idclient = '" . $client . "' LIMIT 1"); if (!$this->next()) { - $this->create($dir."/."); + $this->create($dir . "/."); } } } else { @@ -230,7 +211,7 @@ class DBFSCollection extends ItemCollection if ($parent != ".") { if (!$this->dir_exists($parent)) { - $this->create($parent."/."); + $this->create($parent . "/."); } } } @@ -254,20 +235,19 @@ class DBFSCollection extends ItemCollection return ($item); } - public function setContent($path, $content) - { + public function setContent($path, $content) { global $client; - $client = Contenido_Security::toInteger($client); - $path = $this->strip_path($path); - $dirname = dirname($path); - $filename = basename($path); + $client = Contenido_Security::toInteger($client); + $path = $this->strip_path($path); + $dirname = dirname($path); + $filename = basename($path); if ($dirname == ".") { $dirname = ""; } - $this->select("dirname = '".$dirname."' AND filename = '".$filename."' AND idclient = '".$client."' LIMIT 1"); + $this->select("dirname = '" . $dirname . "' AND filename = '" . $filename . "' AND idclient = '" . $client . "' LIMIT 1"); if ($item = $this->next()) { $item->set("content", $content); $item->set("size", strlen($content)); @@ -275,70 +255,66 @@ class DBFSCollection extends ItemCollection } } - public function getSize($path) - { + public function getSize($path) { global $client; - $client = Contenido_Security::toInteger($client); - $path = $this->strip_path($path); - $dirname = dirname($path); + $client = Contenido_Security::toInteger($client); + $path = $this->strip_path($path); + $dirname = dirname($path); $filename = basename($path); if ($dirname == ".") { $dirname = ""; } - $this->select("dirname = '".$dirname."' AND filename = '".$filename."' AND idclient = '".$client."' LIMIT 1"); + $this->select("dirname = '" . $dirname . "' AND filename = '" . $filename . "' AND idclient = '" . $client . "' LIMIT 1"); if ($item = $this->next()) { return $item->get("size"); } } - public function getContent($path) - { + public function getContent($path) { global $client; - $client = Contenido_Security::toInteger($client); - $dirname = dirname($path); - $filename = basename($path); - - if ($dirname == ".") { - $dirname = ""; - } - - $this->select("dirname = '".$dirname."' AND filename = '".$filename."' AND idclient = '".$client."' LIMIT 1"); - if ($item = $this->next()) { - return ($item->get("content")); - } - } - - public function remove($path) - { - global $client; - - $client = Contenido_Security::toInteger($client); - $path = $this->strip_path($path); - $dirname = dirname($path); + $client = Contenido_Security::toInteger($client); + $dirname = dirname($path); $filename = basename($path); if ($dirname == ".") { $dirname = ""; } - $this->select("dirname = '".$dirname."' AND filename = '".$filename."' AND idclient = '".$client."' LIMIT 1"); + $this->select("dirname = '" . $dirname . "' AND filename = '" . $filename . "' AND idclient = '" . $client . "' LIMIT 1"); + if ($item = $this->next()) { + return ($item->get("content")); + } + } + + public function remove($path) { + global $client; + + $client = Contenido_Security::toInteger($client); + $path = $this->strip_path($path); + $dirname = dirname($path); + $filename = basename($path); + + if ($dirname == ".") { + $dirname = ""; + } + + $this->select("dirname = '" . $dirname . "' AND filename = '" . $filename . "' AND idclient = '" . $client . "' LIMIT 1"); if ($item = $this->next()) { $this->delete($item->get("iddbfs")); } } - public function strip_path($path) - { - if (substr($path,0,5) == "dbfs:") { - $path = substr($path,5); + public function strip_path($path) { + if (substr($path, 0, 5) == "dbfs:") { + $path = substr($path, 5); } - if (substr($path,0,1) == "/") { - $path = substr($path,1); + if (substr($path, 0, 1) == "/") { + $path = substr($path, 1); } return $path; @@ -349,15 +325,14 @@ class DBFSCollection extends ItemCollection * @param datatype $sPath * @return bool $bAvailable */ - public function checkTimeManagement($sPath, $oProperties) - { + public function checkTimeManagement($sPath, $oProperties) { global $contenido; if ($contenido) { return true; } - $sPath = Contenido_Security::toString($sPath); + $sPath = Contenido_Security::toString($sPath); $bAvailable = true; - $iTimeMng = Contenido_Security::toInteger($oProperties->getValue("upload", $sPath, "file", "timemgmt")); + $iTimeMng = Contenido_Security::toInteger($oProperties->getValue("upload", $sPath, "file", "timemgmt")); if ($iTimeMng == 0) { return true; } @@ -366,8 +341,7 @@ class DBFSCollection extends ItemCollection $iNow = time(); - if ($iNow < $this->dateToTimestamp($sStartDate) || - ($iNow > $this->dateToTimestamp($sEndDate) && (int)$this->dateToTimestamp($sEndDate) > 0)) { + if ($iNow < $this->dateToTimestamp($sStartDate) || ($iNow > $this->dateToTimestamp($sEndDate) && (int) $this->dateToTimestamp($sEndDate) > 0)) { return false; } @@ -379,21 +353,19 @@ class DBFSCollection extends ItemCollection * @param string $sDate * @return int $iTimestamp */ - public function dateToTimestamp($sDate) - { + public function dateToTimestamp($sDate) { return strtotime($sDate); } + } +class DBFSItem extends Item { -class DBFSItem extends Item -{ /** * Constructor Function * @param mixed $mId Specifies the ID of item to load */ - public function __construct($mId = false) - { + public function __construct($mId = false) { global $cfg; parent::__construct($cfg["tab"]["dbfs"], "iddbfs"); if ($mId !== false) { @@ -401,15 +373,7 @@ class DBFSItem extends Item } } - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function DBFSItem($mId = false) - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct(); - } - - public function store() - { + public function store() { global $auth; $this->set("modified", date("Y-m-d H:i:s"), false); @@ -418,8 +382,7 @@ class DBFSItem extends Item parent::store(); } - public function setField($field, $value, $safe = true) - { + public function setField($field, $value, $safe = true) { if ($field == "dirname" || $field == "filename" || $field == "mimetype") { // Don't do safe encoding $safe = false; @@ -430,6 +393,5 @@ class DBFSItem extends Item parent::setField($field, $value, $safe); } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/trunk/conlite/classes/class.excel.php b/trunk/conlite/classes/class.excel.php index 34af9db..245a7b3 100644 --- a/trunk/conlite/classes/class.excel.php +++ b/trunk/conlite/classes/class.excel.php @@ -40,7 +40,7 @@ class ExcelWorksheet var $_title; var $_filename; - function ExcelWorksheet ($title, $filename) + function __construct ($title, $filename) { $this->_title = Contenido_Security::escapeDB($title, null); $this->_filename = Contenido_Security::escapeDB($filename, null); diff --git a/trunk/conlite/classes/class.form.php b/trunk/conlite/classes/class.form.php index b698a49..1fbb5f5 100644 --- a/trunk/conlite/classes/class.form.php +++ b/trunk/conlite/classes/class.form.php @@ -99,7 +99,7 @@ class Form { * Constructor Function * @param */ - function Form() { + function __construct() { // empty } // end function @@ -279,7 +279,7 @@ class Form { } // FormField instance - $field = new FormField; + $field = new FormField(); // Get Code for one element $tmp_replacements[] = $field->GenerateCode($this->fields[$i]); @@ -364,7 +364,7 @@ class Form { foreach ($this->fields as $id => $element) { - $check = new FormCheck; + $check = new FormCheck(); switch (strtolower($element['checktype'])) { @@ -447,7 +447,7 @@ class FormField { /** * Constructor Function */ - function FormField() { + function __construct() { // do nothing } // end function @@ -625,7 +625,7 @@ class FormCheck { * Constructor function * @access private */ - function FormCheck () { + function __construct () { // empty } // end function @@ -678,6 +678,4 @@ class FormCheck { return (preg_match('/^[a-z0-9\.]+@[a-z0-9\.]+\.[a-z]+$/i', $value)) ? true : false; } // end function -} // end class - -?> +} // end class \ No newline at end of file diff --git a/trunk/conlite/classes/class.frontend.groups.php b/trunk/conlite/classes/class.frontend.groups.php index 8946241..0437ca4 100644 --- a/trunk/conlite/classes/class.frontend.groups.php +++ b/trunk/conlite/classes/class.frontend.groups.php @@ -50,13 +50,6 @@ class FrontendGroupCollection extends ItemCollection $this->_setItemClass("FrontendGroup"); } - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function FrontendGroupCollection() - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct(); - } - /** * Creates a new group * @param $groupname string Specifies the groupname @@ -122,13 +115,6 @@ class FrontendGroup extends Item $this->loadByPrimaryKey($mId); } } - - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function FrontendGroup($mId = false) - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct(); - } } @@ -150,13 +136,6 @@ class FrontendGroupMemberCollection extends ItemCollection $this->_setItemClass("FrontendGroupMember"); } - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function FrontendGroupMemberCollection() - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct(); - } - /** * Creates a new association * @param $idfrontendgroup int specifies the frontend group @@ -237,13 +216,4 @@ class FrontendGroupMember extends Item $this->loadByPrimaryKey($mId); } } - - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function FrontendGroupMember($mId = false) - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct($mId); - } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/trunk/conlite/classes/class.frontend.permissions.php b/trunk/conlite/classes/class.frontend.permissions.php index a77c7a8..ae6c2d4 100644 --- a/trunk/conlite/classes/class.frontend.permissions.php +++ b/trunk/conlite/classes/class.frontend.permissions.php @@ -54,13 +54,6 @@ class FrontendPermissionCollection extends ItemCollection $this->_setItemClass("FrontendPermission"); } - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function FrontendPermissionCollection() - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct(); - } - /** * Creates a new permission entry * @param $group string Specifies the frontend group @@ -157,13 +150,4 @@ class FrontendPermission extends Item $this->loadByPrimaryKey($mId); } } - - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function FrontendPermission($mId = false) - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct($mId); - } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/trunk/conlite/classes/class.frontend.users.php b/trunk/conlite/classes/class.frontend.users.php index cb3748b..0395608 100644 --- a/trunk/conlite/classes/class.frontend.users.php +++ b/trunk/conlite/classes/class.frontend.users.php @@ -50,13 +50,6 @@ class FrontendUserCollection extends ItemCollection $this->_setItemClass("FrontendUser"); } - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function FrontendUserCollection() - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct(); - } - /** * Checks if a specific user already exists * @param $sUsername string specifies the username to search for @@ -157,13 +150,6 @@ class FrontendUser extends Item } } - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function FrontendUser($mId = false) - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct($mId); - } - /** * Overridden setField method to md5 the password * Sets the value of a specific field diff --git a/trunk/conlite/classes/class.group.php b/trunk/conlite/classes/class.group.php index fd09d86..8320650 100644 --- a/trunk/conlite/classes/class.group.php +++ b/trunk/conlite/classes/class.group.php @@ -1,4 +1,5 @@ table = $cfg['tab']['groups']; @@ -75,49 +73,43 @@ class Groups $this->db = new DB_ConLite(); } - /** * Removes the specified group from the database * * @param string $groupid Specifies the group ID * @return bool True if the delete was successful */ - function deleteGroupByID($groupid) - { + function deleteGroupByID($groupid) { $sql = "DELETE FROM " - .$this->table. - " WHERE group_id = '".Contenido_Security::escapeDB($groupid, $this->db)."'"; + . $this->table . + " WHERE group_id = '" . Contenido_Security::escapeDB($groupid, $this->db) . "'"; $this->db->query($sql); return ($this->db->affected_rows() == 0) ? false : true; } - /** * Removes the specified group from the database. * * @param string $groupid Specifies the groupname * @return bool True if the delete was successful */ - function deleteGroupByGroupname($groupname) - { + function deleteGroupByGroupname($groupname) { $sql = "DELETE FROM " - .$this->table. - " WHERE groupname = '".Contenido_Security::escapeDB($groupname, $this->db)."'"; + . $this->table . + " WHERE groupname = '" . Contenido_Security::escapeDB($groupname, $this->db) . "'"; $this->db->query($sql); return ($this->db->affected_rows() == 0) ? false : true; } - /** * Returns all groups which are accessible by the current group. * * @param array $perms * @return array Array of group objects */ - function getAccessibleGroups($perms) - { + function getAccessibleGroups($perms) { global $cfg; $clientclass = new Client(); @@ -127,12 +119,12 @@ class Groups $db = new DB_ConLite(); foreach ($allClients as $key => $value) { - if (in_array("client[".$key."]", $perms) || in_array("admin[".$key."]", $perms)) { - $limit[] = 'perms LIKE "%client['.Contenido_Security::escapeDB($key, $db).']%"'; + if (in_array("client[" . $key . "]", $perms) || in_array("admin[" . $key . "]", $perms)) { + $limit[] = 'perms LIKE "%client[' . Contenido_Security::escapeDB($key, $db) . ']%"'; } - if (in_array("admin[".$key."]", $perms)) { - $limit[] = 'perms LIKE "%admin['.Contenido_Security::escapeDB($key, $db).']%"'; + if (in_array("admin[" . $key . "]", $perms)) { + $limit[] = 'perms LIKE "%admin[' . Contenido_Security::escapeDB($key, $db) . ']%"'; } } @@ -147,8 +139,8 @@ class Groups $sql = "SELECT group_id, groupname, description FROM - ". $cfg['tab']['groups'] - . " WHERE 1 AND " .$limitSQL; + " . $cfg['tab']['groups'] + . " WHERE 1 AND " . $limitSQL; $db->query($sql); @@ -156,7 +148,7 @@ class Groups while ($db->next_record()) { $groups[$db->f('group_id')] = array( - 'groupname' => substr($db->f('groupname'), 4), + 'groupname' => substr($db->f('groupname'), 4), 'description' => $db->f('description'), ); } @@ -173,8 +165,7 @@ class Groups * @version 1.0 * @copyright four for business 2003 */ -class Group -{ +class Group { /** * Storage of the source table to use for the group informations @@ -209,8 +200,7 @@ class Group * * @param string $table The table to use as information source */ - function Group($table = '') - { + function __construct($table = '') { if ($table == '') { global $cfg; $this->table = $cfg['tab']['groups']; @@ -221,19 +211,17 @@ class Group $this->db = new DB_ConLite(); } - /** * Loads a group from the database by its groupname. * * @param string $groupname Specifies the groupname * @return bool True if the load was successful */ - function loadGroupByGroupname($groupname) - { + function loadGroupByGroupname($groupname) { // SQL-Statement to select by groupname - $sql = "SELECT * FROM ". + $sql = "SELECT * FROM " . $this->table - ." WHERE groupname = '" .Contenido_Security::escapeDB($groupname, $this->db)."'"; + . " WHERE groupname = '" . Contenido_Security::escapeDB($groupname, $this->db) . "'"; // Query the database $this->db->query($sql); @@ -246,19 +234,17 @@ class Group $this->values = $this->db->toArray(); } - /** * Loads a group from the database by its groupID. * * @param string $groupid Specifies the groupID * @return bool True if the load was successful */ - function loadGroupByGroupID($groupID) - { + function loadGroupByGroupID($groupID) { // SQL-Statement to select by groupID - $sql = "SELECT * FROM ". + $sql = "SELECT * FROM " . $this->table - ." WHERE group_id = '" .Contenido_Security::escapeDB($groupID, $this->db)."'"; + . " WHERE group_id = '" . Contenido_Security::escapeDB($groupID, $this->db) . "'"; // Query the database $this->db->query($sql); @@ -271,52 +257,46 @@ class Group $this->values = $this->db->toArray(); } - /** * Gets the value of a specific field. * * @param string $field Specifies the field to retrieve * @return mixed Value of the field */ - function getField($field) - { + function getField($field) { return ($this->values[$field]); } - /** * Sets the value of a specific field. * * @param string $field Specifies the field to set * @param string $value Specifies the value to set */ - function setField($field, $value) - { + function setField($field, $value) { $this->modifiedValues[$field] = true; $this->values[$field] = $value; } - /** * Stores the modified group object to the database. * * @return bool */ - function store() - { - $sql = "UPDATE " . $this->table ." SET "; + function store() { + $sql = "UPDATE " . $this->table . " SET "; $first = true; foreach ($this->modifiedValues as $key => $value) { if ($first == true) { - $sql .= "$key = '" . $this->values[$key] ."'"; + $sql .= "$key = '" . $this->values[$key] . "'"; } else { - $sql .= ", $key = '" . $this->values[$key] ."'"; + $sql .= ", $key = '" . $this->values[$key] . "'"; } $first = false; } - $sql .= " WHERE group_id = '" .Contenido_Security::escapeDB($this->values['group_id'], $this->db)."'"; + $sql .= " WHERE group_id = '" . Contenido_Security::escapeDB($this->values['group_id'], $this->db) . "'"; $this->db->query($sql); @@ -328,16 +308,15 @@ class Group * * @return bool */ - function insert() - { - $sql = "INSERT INTO " . $this->table ." SET "; + function insert() { + $sql = "INSERT INTO " . $this->table . " SET "; $first = true; foreach ($this->modifiedValues as $key => $value) { if ($first == true) { - $sql .= "$key = '" . $this->values[$key] ."'"; + $sql .= "$key = '" . $this->values[$key] . "'"; } else { - $sql .= ", $key = '" . $this->values[$key] ."'"; + $sql .= ", $key = '" . $this->values[$key] . "'"; } $first = false; } @@ -345,7 +324,6 @@ class Group return ($this->db->query($sql)); } - /** * Returns the group property * @@ -353,14 +331,13 @@ class Group * @param string $name Specifies the name of the property to retrieve * @return string The value of the retrieved property */ - function getGroupProperty($type, $name) - { + function getGroupProperty($type, $name) { global $cfg; - $sql = "SELECT value FROM " .$cfg['tab']['group_prop']." - WHERE group_id = '".Contenido_Security::escapeDB($this->values['group_id'], $this->db)."' - AND type = '".Contenido_Security::escapeDB($type, $this->db)."' - AND name = '".Contenido_Security::escapeDB($name, $this->db)."'"; + $sql = "SELECT value FROM " . $cfg['tab']['group_prop'] . " + WHERE group_id = '" . Contenido_Security::escapeDB($this->values['group_id'], $this->db) . "' + AND type = '" . Contenido_Security::escapeDB($type, $this->db) . "' + AND name = '" . Contenido_Security::escapeDB($name, $this->db) . "'"; $this->db->query($sql); if ($this->db->next_record()) { @@ -370,7 +347,6 @@ class Group } } - /** * Retrieves all available properties of the group. * @@ -379,14 +355,13 @@ class Group * - $arr[idgroupprop][type] * - $arr[idgroupprop][value] */ - function getGroupProperties() - { + function getGroupProperties() { global $cfg; $aProps = array(); - $sql = "SELECT idgroupprop, type, name, value FROM " .$cfg['tab']['group_prop']." - WHERE group_id = '".Contenido_Security::escapeDB($this->values['group_id'], $this->db)."'"; + $sql = "SELECT idgroupprop, type, name, value FROM " . $cfg['tab']['group_prop'] . " + WHERE group_id = '" . Contenido_Security::escapeDB($this->values['group_id'], $this->db) . "'"; $this->db->query($sql); if ($this->db->num_rows() == 0) { @@ -395,8 +370,8 @@ class Group while ($this->db->next_record()) { $aProps[$this->db->f('idgroupprop')] = array( - 'name' => $this->db->f('name'), - 'type' => $this->db->f('type'), + 'name' => $this->db->f('name'), + 'type' => $this->db->f('type'), 'value' => $this->db->f('value'), ); } @@ -404,7 +379,6 @@ class Group return $aProps; } - /** * Stores a property to the database. * @@ -412,48 +386,43 @@ class Group * @param string $name Specifies the name of the property to retrieve * @param string $value Specifies the value to insert */ - function setGroupProperty($type, $name, $value) - { + function setGroupProperty($type, $name, $value) { global $cfg; // Check if such an entry already exists if ($this->getGroupProperty($type, $name) !== false) { - $sql = "UPDATE ".$cfg['tab']['group_prop']." - SET value = '".Contenido_Security::escapeDB($value, $this->db)."' - WHERE group_id = '".Contenido_Security::escapeDB($this->values['group_id'], $this->db)."' - AND type = '".Contenido_Security::escapeDB($type, $this->db)."' - AND name = '".Contenido_Security::escapeDB($name, $this->db)."'"; + $sql = "UPDATE " . $cfg['tab']['group_prop'] . " + SET value = '" . Contenido_Security::escapeDB($value, $this->db) . "' + WHERE group_id = '" . Contenido_Security::escapeDB($this->values['group_id'], $this->db) . "' + AND type = '" . Contenido_Security::escapeDB($type, $this->db) . "' + AND name = '" . Contenido_Security::escapeDB($name, $this->db) . "'"; $this->db->query($sql); } else { - $sql = "INSERT INTO ".$cfg['tab']['group_prop']." - SET value = '".Contenido_Security::escapeDB($value, $this->db)."', - group_id = '".Contenido_Security::escapeDB($this->values['group_id'], $this->db)."', - type = '".Contenido_Security::escapeDB($type, $this->db)."', - name = '".Contenido_Security::escapeDB($name, $this->db)."', - idgroupprop = '".Contenido_Security::toInteger($this->db->nextid($cfg['tab']['group_prop']))."'"; + $sql = "INSERT INTO " . $cfg['tab']['group_prop'] . " + SET value = '" . Contenido_Security::escapeDB($value, $this->db) . "', + group_id = '" . Contenido_Security::escapeDB($this->values['group_id'], $this->db) . "', + type = '" . Contenido_Security::escapeDB($type, $this->db) . "', + name = '" . Contenido_Security::escapeDB($name, $this->db) . "', + idgroupprop = '" . Contenido_Security::toInteger($this->db->nextid($cfg['tab']['group_prop'])) . "'"; $this->db->query($sql); } } - /** * Deletes a group property from the table. * * @param string $type Specifies the type (class, category etc) for the property to retrieve * @param string $name Specifies the name of the property to retrieve */ - function deleteGroupProperty($type, $name) - { + function deleteGroupProperty($type, $name) { global $cfg; // Check if such an entry already exists - $sql = "DELETE FROM ".$cfg['tab']['group_prop']." - WHERE group_id = '".Contenido_Security::escapeDB($this->values['group_id'], $this->db)."' AND - type = '".Contenido_Security::escapeDB($type, $this->db)."' AND - name = '".Contenido_Security::escapeDB($name, $this->db)."'"; + $sql = "DELETE FROM " . $cfg['tab']['group_prop'] . " + WHERE group_id = '" . Contenido_Security::escapeDB($this->values['group_id'], $this->db) . "' AND + type = '" . Contenido_Security::escapeDB($type, $this->db) . "' AND + name = '" . Contenido_Security::escapeDB($name, $this->db) . "'"; $this->db->query($sql); } } - -?> \ No newline at end of file diff --git a/trunk/conlite/classes/class.htmlparser.php b/trunk/conlite/classes/class.htmlparser.php index abba85e..249d388 100644 --- a/trunk/conlite/classes/class.htmlparser.php +++ b/trunk/conlite/classes/class.htmlparser.php @@ -93,7 +93,7 @@ class HtmlParser { * Constructs an HtmlParser instance with * the HTML text given. */ - function HtmlParser ($aHtmlText) { + function __construct ($aHtmlText) { $this->iHtmlText = $aHtmlText; $this->iHtmlTextLength = strlen($aHtmlText); } diff --git a/trunk/conlite/classes/class.htmlvalidator.php b/trunk/conlite/classes/class.htmlvalidator.php index bfea83c..9d7ce8e 100644 --- a/trunk/conlite/classes/class.htmlvalidator.php +++ b/trunk/conlite/classes/class.htmlvalidator.php @@ -34,7 +34,7 @@ class cHTMLValidator var $nestingNodes; var $_existingTags; - function cHTMLValidator() + function __construct() { $this->doubleTags = array ("form", "head", "body", "html", "td", "tr", "table", "a", "tbody", "title", "container", "span", "div"); diff --git a/trunk/conlite/classes/class.httpinputvalidator.php b/trunk/conlite/classes/class.httpinputvalidator.php index 24cfa66..ee7eaff 100644 --- a/trunk/conlite/classes/class.httpinputvalidator.php +++ b/trunk/conlite/classes/class.httpinputvalidator.php @@ -128,7 +128,7 @@ class HttpInputValidator { * @param string $sConfigPath * @return HttpInputValidator */ - function HttpInputValidator($sConfigPath) { + function __construct($sConfigPath) { // check config and logging path if (!empty($sConfigPath) && file_exists($sConfigPath)) { $this->sConfigPath = realpath($sConfigPath); diff --git a/trunk/conlite/classes/class.iterator.php b/trunk/conlite/classes/class.iterator.php index 01e3932..25e1831 100644 --- a/trunk/conlite/classes/class.iterator.php +++ b/trunk/conlite/classes/class.iterator.php @@ -66,7 +66,7 @@ class cIterator * @param $aItems array Items to add * @return none */ - function cIterator ($aItems) + function __construct ($aItems) { if (is_array($aItems)) { diff --git a/trunk/conlite/classes/class.lang.php b/trunk/conlite/classes/class.lang.php index a94ebf1..cc05f33 100644 --- a/trunk/conlite/classes/class.lang.php +++ b/trunk/conlite/classes/class.lang.php @@ -1,4 +1,5 @@ __construct(); - } } /** @@ -69,24 +63,17 @@ class Languages extends cApiLanguageCollection { * @copyright four for business 2003 */ class Language extends cApiLanguage { + /** * Constructor Function * @param mixed $mId Specifies the ID of item to load */ - public function __construct($mId = false) - { - if($mId === false) { + public function __construct($mId = false) { + if ($mId === false) { parent::__construct(); } else { parent::__construct($mId); } } - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function Language($mId = false) - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct($mId); - } } -?> \ No newline at end of file diff --git a/trunk/conlite/classes/class.metaobject.php b/trunk/conlite/classes/class.metaobject.php index 50f5d02..e2a818b 100644 --- a/trunk/conlite/classes/class.metaobject.php +++ b/trunk/conlite/classes/class.metaobject.php @@ -70,7 +70,7 @@ class cMetaObject var $_payloadObject; - function cMetaObject ($payload = false) + function __construct ($payload = false) { $this->_actions = array(); $this->_fields = array(); diff --git a/trunk/conlite/classes/class.navigation.php b/trunk/conlite/classes/class.navigation.php index 42bafd4..1c48254 100644 --- a/trunk/conlite/classes/class.navigation.php +++ b/trunk/conlite/classes/class.navigation.php @@ -64,7 +64,7 @@ class Contenido_Navigation { /** * Constructor. Loads the XML language file using XML_Doc. */ - function Contenido_Navigation() { + function __construct() { global $cfg, $belang; $this->xml = new XML_Doc(); diff --git a/trunk/conlite/classes/class.note.php b/trunk/conlite/classes/class.note.php index 1a49b80..812b51c 100644 --- a/trunk/conlite/classes/class.note.php +++ b/trunk/conlite/classes/class.note.php @@ -1,4 +1,5 @@ _setItemClass("NoteItem"); } - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - function NoteCollection() - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct(); - } - /** * select: Selects one or more items from the database * @@ -58,8 +49,7 @@ class NoteCollection extends CommunicationCollection * @access public * @see ItemCollection */ - public function select($where = "", $group_by = "", $order_by = "", $limit = "") - { + public function select($where = "", $group_by = "", $order_by = "", $limit = "") { if ($where == "") { $where = "comtype='note'"; } else { @@ -80,8 +70,7 @@ class NoteCollection extends CommunicationCollection * @return object The new item * @access public */ - public function create($itemtype, $itemid, $idlang, $message, $category = "") - { + public function create($itemtype, $itemid, $idlang, $message, $category = "") { $item = parent::createNewItem(); $item->set("subject", "Note Item"); @@ -102,30 +91,26 @@ class NoteCollection extends CommunicationCollection } -class NoteItem extends CommunicationItem -{ - +class NoteItem extends CommunicationItem { + } +class NoteView extends cHTMLIFrame { -class NoteView extends cHTMLIFrame -{ - public function NoteView($sItemType, $sItemId) - { + public function __construct($sItemType, $sItemId) { global $sess, $cfg; - cHTMLIFrame::cHTMLIFrame(); + parent::__construct(); $this->setSrc($sess->url("main.php?itemtype=$sItemType&itemid=$sItemId&area=note&frame=2")); $this->setBorder(0); - $this->setStyleDefinition("border", "1px solid ".$cfg['color']['table_border']); + $this->setStyleDefinition("border", "1px solid " . $cfg['color']['table_border']); } + } +class NoteList extends cHTMLDiv { -class NoteList extends cHTMLDiv -{ - public function NoteList($sItemType, $sItemId) - { - cHTMLDiv::cHTMLDiv(); + public function __construct($sItemType, $sItemId) { + parent::__construct(); $this->_sItemType = $sItemType; $this->_sItemId = $sItemId; @@ -133,13 +118,11 @@ class NoteList extends cHTMLDiv $this->setStyleDefinition("width", "100%"); } - public function setDeleteable($bDeleteable) - { + public function setDeleteable($bDeleteable) { $this->_bDeleteable = $bDeleteable; } - public function toHTML() - { + public function toHTML() { global $cfg, $lang; $sItemType = $this->_sItemType; @@ -162,10 +145,10 @@ class NoteList extends cHTMLDiv $items[] = 0; } - $oNoteItems->select("idcommunication IN (".implode(", ", $items).')',"", "created DESC"); + $oNoteItems->select("idcommunication IN (" . implode(", ", $items) . ')', "", "created DESC"); - $i = array(); - $dark = false; + $i = array(); + $dark = false; while ($oNoteItem = $oNoteItems->next()) { if ($oNoteItem->getProperty("note", "itemtype") == $sItemType && $oNoteItem->getProperty("note", "itemid") == $sItemId) { $j = new NoteListItem($sItemType, $sItemId, $oNoteItem->get("idcommunication")); @@ -185,16 +168,15 @@ class NoteList extends cHTMLDiv $result = parent::toHTML(); - return ('
'.$result.'
'); + return ('
' . $result . '
'); } + } +class NoteListItem extends cHTMLDiv { -class NoteListItem extends cHTMLDiv -{ - public function NoteListItem($sItemType, $sItemId, $iDeleteItem) - { - cHTMLDiv::cHTMLDiv(); + public function __construct($sItemType, $sItemId, $iDeleteItem) { + parent::__construct(); $this->setStyleDefinition("padding", "2px"); $this->setBackground(); $this->setDeleteable(true); @@ -202,16 +184,13 @@ class NoteListItem extends cHTMLDiv $this->_iDeleteItem = $iDeleteItem; $this->_sItemType = $sItemType; $this->_sItemId = $sItemId; - } - public function setDeleteable($bDeleteable) - { + public function setDeleteable($bDeleteable) { $this->_bDeleteable = $bDeleteable; } - public function setBackground($dark = false) - { + public function setBackground($dark = false) { global $cfg; if ($dark) { @@ -221,8 +200,7 @@ class NoteListItem extends cHTMLDiv } } - public function setAuthor($sAuthor) - { + public function setAuthor($sAuthor) { if (strlen($sAuthor) == 32) { $result = getGroupOrUserName($sAuthor); @@ -234,8 +212,7 @@ class NoteListItem extends cHTMLDiv $this->_sAuthor = $sAuthor; } - public function setDate($iDate) - { + public function setDate($iDate) { $dateformat = getEffectiveSetting("backend", "timeformat", "Y-m-d H:i:s"); if (is_string($iDate)) { @@ -244,31 +221,29 @@ class NoteListItem extends cHTMLDiv $this->_sDate = date($dateformat, $iDate); } - public function setMessage($sMessage) - { + public function setMessage($sMessage) { $this->_sMessage = $sMessage; } - public function render() - { + public function render() { global $cfg, $sess; $itemtype = $this->_sItemType; $itemid = $this->_sItemId; $deleteitem = $this->_iDeleteItem; - $table = ''; - $header .= ''; - } - - $tpl->set('s', 'HEADER', $header); - - $dark = false; - - if (is_array($this->items)) - { - foreach ($this->items as $key => $value) - { - $tpl->set('d', 'CATNAME', $this->captions[$key]); - $tpl->set('d', 'CATFIELD', $value); - $tpl->set('d', 'ROWNAME', $this->rownames[$key]); - - $dark = !$dark; - if ($dark) { - $bgColor = $cfg["color"]["table_dark"]; - } else { - $bgColor = $cfg["color"]["table_light"]; - } - - $tpl->set('d', 'BGCOLOR', $bgColor); - $tpl->set('d', 'BORDERCOLOR', $this->tablebordercolor); - $tpl->next(); - } - } - - $tpl->set('s', 'CONTENIDOPATH',$cfg["path"]["contenido_fullhtml"]); + $this->formname = $name; + + if ($action == "") { + $this->formaction = "main.php"; + } else { + $this->formaction = $action; + } + + $this->formmethod = $method; + + $this->tableid = ""; + $this->tablebordercolor = $cfg['color']['table_border']; + $this->setAccessKey('s'); + $this->custom = array(); + + $this->setActionButton("submit", "images/but_ok.gif", i18n("Save changes"), "s"); + } + + function setVar($name, $value) { + $this->formvars[$name] = $value; + } + + function add($caption, $field, $rowname = "") { + if (is_array($field)) { + + foreach ($field as $value) { + if (is_object($value) && method_exists($value, "render")) { + $n .= $value->render(); + } else { + $n .= $value; + } + } + + $field = $n; + } + if (is_object($field) && method_exists($field, "render")) { + $n = $field->render(); + $field = $n; + } + if ($field == "") { + $field = " "; + } + + if ($caption == "") { + $caption = " "; + } + + $this->id++; + $this->items[$this->id] = $field; + $this->captions[$this->id] = $caption; + + if ($rowname == "") { + $rowname = $this->id; + } + + $this->rownames[$this->id] = $rowname; + } + + function addCancel($link) { + $this->cancelLink = $link; + } + + function addHeader($header) { + $this->header = $header; + } + + function setSubmitJS($js) { + $this->submitjs = $js; + } + + function setAccessKey($key) { + $this->accessKey = $key; + } + + function setActionEvent($id, $event) { + $this->custom[$id]["event"] = $event; + } + + function setActionButton($id, $image, $description = "", $accesskey = false, $action = false) { + $this->custom[$id]["image"] = $image; + $this->custom[$id]["type"] = "actionsetter"; + $this->custom[$id]["action"] = $action; + $this->custom[$id]["description"] = $description; + $this->custom[$id]["accesskey"] = $accesskey; + $this->custom[$id]["event"] = ""; + } + + function unsetActionButton($id) { + unset($this->custom[$id]); + } + + function render($return = true) { + global $sess, $cfg; + + $tpl = new Template; + + $extra = ""; + + + $form = '' . "\n"; + $this->formvars["contenido"] = $sess->id; + + if (is_array($this->formvars)) { + foreach ($this->formvars as $key => $value) { + $form .= '' . "\n"; + } + } + + if (!array_key_exists("action", $this->formvars)) { + $form .= ''; + } + + $tpl->set('s', 'FORM', $form); + $tpl->set('s', 'ID', $this->tableid); + $tpl->set('s', 'BORDERCOLOR', $this->tablebordercolor); + + if ($this->header != "") { + $header = ''; + $header .= ''; + } + + $tpl->set('s', 'HEADER', $header); + + $dark = false; + + if (is_array($this->items)) { + foreach ($this->items as $key => $value) { + $tpl->set('d', 'CATNAME', $this->captions[$key]); + $tpl->set('d', 'CATFIELD', $value); + $tpl->set('d', 'ROWNAME', $this->rownames[$key]); + + $dark = !$dark; + if ($dark) { + $bgColor = $cfg["color"]["table_dark"]; + } else { + $bgColor = $cfg["color"]["table_light"]; + } + + $tpl->set('d', 'BGCOLOR', $bgColor); + $tpl->set('d', 'BORDERCOLOR', $this->tablebordercolor); + $tpl->next(); + } + } + + $tpl->set('s', 'CONTENIDOPATH', $cfg["path"]["contenido_fullhtml"]); + + if ($this->cancelLink != "") { + $img = ''; + + $tpl->set('s', 'CANCELLINK', '' . $img . ''); + } else { + $tpl->set('s', 'CANCELLINK', ''); + } + + if ($this->submitjs != "") { + $extra .= 'onclick="' . $this->submitjs . '"'; + } + + if ($this->accesskey != "") { + $tpl->set('s', 'KEY', $this->accesskey); + } else { + $tpl->set('s', 'KEY', ''); + } + + $tpl->set('s', 'EXTRA', $extra); + + $custombuttons = ""; + + foreach ($this->custom as $key => $value) { + if ($value["accesskey"] != "") { + $accesskey = 'accesskey="' . $value["accesskey"] . '"'; + } else { + $accesskey = ""; + } + + $onclick = ""; + if ($value["action"] !== false) { + $onclick = 'document.forms[\'' . $this->formname . '\'].elements[\'action\'].value = \'' . $value["action"] . '\';'; + } + + if ($value["event"] != "") { + $onclick .= $value["event"]; + } + + $custombuttons .= ''; + } + + $tpl->set('s', 'EXTRABUTTONS', $custombuttons); + + $rendered = $tpl->generate($cfg["path"]["contenido"] . $cfg['path']['templates'] . $cfg['templates']['generic_table_form'], true); + + if ($return == true) { + return ($rendered); + } else { + echo $rendered; + } + } - if ($this->cancelLink != "") - { - $img = ''; - - $tpl->set('s', 'CANCELLINK', ''.$img.''); - } else { - $tpl->set('s', 'CANCELLINK',''); - } - - if ($this->submitjs != "") - { - $extra .= 'onclick="'.$this->submitjs.'"'; - } - - if ($this->accesskey != "") - { - $tpl->set('s', 'KEY', $this->accesskey); - } else { - $tpl->set('s', 'KEY', ''); - } - - $tpl->set('s', 'EXTRA', $extra); - - $custombuttons = ""; - - foreach ($this->custom as $key => $value) - { - if ($value["accesskey"] != "") - { - $accesskey = 'accesskey="'.$value["accesskey"].'"'; - } else { - $accesskey = ""; - } - - $onclick = ""; - if ($value["action"] !== false) - { - $onclick = 'document.forms[\''.$this->formname.'\'].elements[\'action\'].value = \''.$value["action"].'\';'; - } - - if ($value["event"] != "") - { - $onclick .= $value["event"]; - } - - $custombuttons .= ''; - } - - $tpl->set('s', 'EXTRABUTTONS', $custombuttons); - - $rendered = $tpl->generate($cfg["path"]["contenido"].$cfg['path']['templates'] . $cfg['templates']['generic_table_form'],true); - - if ($return == true) - { - return ($rendered); - } else { - echo $rendered; - } - } } -?> \ No newline at end of file
'; + $table = '
'; $table .= $this->_sAuthor; $table .= ''; $table .= $this->_sDate; if ($this->_bDeleteable == true) { $oDeleteable = new cHTMLLink(); - $oDeletePic = new cHTMLImage($cfg["path"]["contenido_fullhtml"]."/images/delete.gif"); + $oDeletePic = new cHTMLImage($cfg["path"]["contenido_fullhtml"] . "/images/delete.gif"); $oDeleteable->setContent($oDeletePic); $oDeleteable->setLink($sess->url("main.php?frame=2&area=note&itemtype=$itemtype&itemid=$itemid&action=note_delete&deleteitem=$deleteitem")); - $table .= ''.$oDeleteable->render(); + $table .= '' . $oDeleteable->render(); } $table .= '
'; @@ -276,15 +251,15 @@ class NoteListItem extends cHTMLDiv $oMessage->setContent($this->_sMessage); $oMessage->setStyle("padding-bottom: 8px;"); - $this->setContent(array($table, '
',$oMessage)); + $this->setContent(array($table, '
', $oMessage)); return parent::render(); } } -class NoteLink extends cHTMLLink -{ +class NoteLink extends cHTMLLink { + /** * @var string Object type * @access private @@ -321,9 +296,8 @@ class NoteLink extends cHTMLLink * @return none * @access public */ - public function NoteLink($sItemType, $sItemID) - { - parent::cHTMLLink(); + public function __construct($sItemType, $sItemID) { + parent::__construct(); $img = new cHTMLImage("images/note.gif"); $img->setStyle("padding-left: 2px; padding-right: 2px;"); @@ -345,8 +319,7 @@ class NoteLink extends cHTMLLink * @return none * @access public */ - public function enableHistory() - { + public function enableHistory() { $this->_bShowHistory = true; } @@ -356,8 +329,7 @@ class NoteLink extends cHTMLLink * @return none * @access public */ - public function disableHistory() - { + public function disableHistory() { $this->_bShowHistory = false; } @@ -367,8 +339,7 @@ class NoteLink extends cHTMLLink * @return none * @access public */ - public function enableHistoryDelete() - { + public function enableHistoryDelete() { $this->_bDeleteHistoryItems = true; } @@ -378,8 +349,7 @@ class NoteLink extends cHTMLLink * @return none * @access public */ - public function disableHistoryDelete() - { + public function disableHistoryDelete() { $this->_bDeleteHistoryItems = false; } @@ -389,16 +359,14 @@ class NoteLink extends cHTMLLink * @return none * @access public */ - public function render($return = false) - { + public function render($return = false) { global $sess; $itemtype = $this->_sItemType; $itemid = $this->_sItemID; - $this->setEvent("click", 'javascript:window.open('."'".$sess->url("main.php?area=note&frame=1&itemtype=$itemtype&itemid=$itemid")."', 'todo', 'resizable=yes, scrollbars=yes, height=360, width=550');"); + $this->setEvent("click", 'javascript:window.open(' . "'" . $sess->url("main.php?area=note&frame=1&itemtype=$itemtype&itemid=$itemid") . "', 'todo', 'resizable=yes, scrollbars=yes, height=360, width=550');"); return parent::render($return); } -} -?> \ No newline at end of file +} diff --git a/trunk/conlite/classes/class.properties.php b/trunk/conlite/classes/class.properties.php index fe967d0..b243b31 100644 --- a/trunk/conlite/classes/class.properties.php +++ b/trunk/conlite/classes/class.properties.php @@ -96,13 +96,6 @@ class PropertyCollection extends ItemCollection $this->_setItemClass('PropertyItem'); } - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function PropertyCollection() - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct(); - } - /** * Creates a new property item. * @@ -432,13 +425,6 @@ class PropertyItem extends Item } } - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function PropertyItem($mId = false) - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct($mId); - } - /** * Stores changed PropertyItem */ diff --git a/trunk/conlite/classes/class.request.password.php b/trunk/conlite/classes/class.request.password.php index f10eafa..b582d99 100644 --- a/trunk/conlite/classes/class.request.password.php +++ b/trunk/conlite/classes/class.request.password.php @@ -152,7 +152,7 @@ class RequestPassword { * @param array $aCfg - The contenido configuration array * @access public */ - function RequestPassword ($oDb, $aCfg) { + function __construct ($oDb, $aCfg) { //generate new dbobject, if it does not exist if (!is_object($oDb)) { $this->oDb = new DB_ConLite(); diff --git a/trunk/conlite/classes/class.search.php b/trunk/conlite/classes/class.search.php index f76739e..bbe5f3b 100644 --- a/trunk/conlite/classes/class.search.php +++ b/trunk/conlite/classes/class.search.php @@ -1,4 +1,5 @@ */ -abstract class SearchBaseAbstract -{ +abstract class SearchBaseAbstract { + /** * Contenido database object * @var DB_ConLite @@ -82,12 +81,11 @@ abstract class SearchBaseAbstract * @param DB_ConLite $oDB Optional database instance * @param bool $bDebug Optional, flag to enable debugging */ - protected function __construct($oDB = null, $bDebug = false) - { + protected function __construct($oDB = null, $bDebug = false) { global $cfg, $lang, $client; - $this->cfg = $cfg; - $this->lang = $lang; + $this->cfg = $cfg; + $this->lang = $lang; $this->client = $client; $this->setDebug((bool) $bDebug); @@ -104,8 +102,7 @@ abstract class SearchBaseAbstract * * @param bool $bDebug */ - public function setDebug($bDebug) - { + public function setDebug($bDebug) { $this->bDebug = (bool) $bDebug; } @@ -115,8 +112,7 @@ abstract class SearchBaseAbstract * @param string $msg Some text * @param mixed $var The variable to dump */ - protected function _debug($msg, $var) - { + protected function _debug($msg, $var) { if (!$this->bDebug) { return; } @@ -129,8 +125,8 @@ abstract class SearchBaseAbstract $dump .= '' . "\n"; echo $dump; } -} +} /** * Contenido API - Index Object @@ -162,11 +158,10 @@ abstract class SearchBaseAbstract * Keep in mind that class Search and SearchResult uses an instance of object Index. * Consider character tables in relation 'con_chartable'. */ - cInclude('includes', 'functions.encoding.php'); -class Index extends SearchBaseAbstract -{ +class Index extends SearchBaseAbstract { + /** * the content of the cms-types of an article * @var array @@ -243,8 +238,7 @@ class Index extends SearchBaseAbstract * @param DB_ConLite $oDB Contenido Database object * @return void */ - function Index($oDB = null) - { + function __construct($oDB = null) { parent::__construct($oDB); $this->setContentTypes(); @@ -269,9 +263,8 @@ class Index extends SearchBaseAbstract * @param array $aStopwords Array with words which should not be indexed. * @return void */ - function start($idart, $aContent, $place = 'auto', $cms_options = array(), $aStopwords = array()) - { - if (!is_int((int)$idart) || $idart < 0) { + function start($idart, $aContent, $place = 'auto', $cms_options = array(), $aStopwords = array()) { + if (!is_int((int) $idart) || $idart < 0) { return null; } else { $this->idart = $idart; @@ -310,16 +303,15 @@ class Index extends SearchBaseAbstract * @param none * @return void */ - function createKeywords() - { + function createKeywords() { $tmp_keys = array(); $replace = array(' ', '&', '<', '>', '"', '''); // Only create keycodes, if some are available if (is_array($this->keycode)) { - foreach($this->keycode as $idtype => $data) { + foreach ($this->keycode as $idtype => $data) { if ($this->checkCmsType($idtype)) { - foreach($data as $typeid => $code) { + foreach ($data as $typeid => $code) { $this->_debug('code', $code); $code = stripslashes($code); // remove backslash @@ -342,7 +334,7 @@ class Index extends SearchBaseAbstract if (strlen($value) > 1) { // do not index single characters - $this->keywords[$value] = $this->keywords[$value] . $idtype . '-' . $typeid . ' '; + $this->keywords[$value] = $this->keywords[$value] . $idtype . '-' . $typeid . ' '; } } } @@ -361,8 +353,7 @@ class Index extends SearchBaseAbstract * The index_string looks like "&12=2(CMS_HTMLHEAD-1,CMS_HTML-1)" * @return void */ - function saveKeywords() - { + function saveKeywords() { $tmp_count = array(); foreach ($this->keywords as $keyword => $count) { @@ -379,10 +370,10 @@ class Index extends SearchBaseAbstract $nextid = $this->db->nextid($this->cfg['tab']['keywords']); - $sql = "INSERT INTO ".$this->cfg['tab']['keywords']." - (keyword, ".$this->place.", idlang, idkeyword) + $sql = "INSERT INTO " . $this->cfg['tab']['keywords'] . " + (keyword, " . $this->place . ", idlang, idkeyword) VALUES - ('".Contenido_Security::escapeDB($keyword, $this->db)."', '".Contenido_Security::escapeDB($index_string, $this->db)."', ".Contenido_Security::toInteger($this->lang).", ".Contenido_Security::toInteger($nextid).")"; + ('" . Contenido_Security::escapeDB($keyword, $this->db) . "', '" . Contenido_Security::escapeDB($index_string, $this->db) . "', " . Contenido_Security::toInteger($this->lang) . ", " . Contenido_Security::toInteger($nextid) . ")"; } else { // if keyword allready exists, create new index_string if (preg_match("/&$this->idart=/", $this->keywords_old[$keyword])) { @@ -391,9 +382,9 @@ class Index extends SearchBaseAbstract $index_string = $this->keywords_old[$keyword] . $index_string; } - $sql = "UPDATE ".$this->cfg['tab']['keywords']." - SET ".$this->place." = '".$index_string."' - WHERE idlang='".Contenido_Security::toInteger($this->lang)."' AND keyword='".Contenido_Security::escapeDB($keyword, $this->db)."'"; + $sql = "UPDATE " . $this->cfg['tab']['keywords'] . " + SET " . $this->place . " = '" . $index_string . "' + WHERE idlang='" . Contenido_Security::toInteger($this->lang) . "' AND keyword='" . Contenido_Security::escapeDB($keyword, $this->db) . "'"; } $this->_debug('sql', $sql); @@ -406,19 +397,18 @@ class Index extends SearchBaseAbstract * @param none * @return void */ - function deleteKeywords() - { + function deleteKeywords() { foreach ($this->keywords_del as $key_del) { $index_string = preg_replace("/&$this->idart=[0-9]+\([\w-,]+\)/", "", $this->keywords_old[$key_del]); if (strlen($index_string) == 0) { // keyword is not referenced by any article - $sql = "DELETE FROM ".$this->cfg['tab']['keywords']." - WHERE idlang='".Contenido_Security::toInteger($this->lang)."' AND keyword='".Contenido_Security::escapeDB($key_del, $this->db)."'"; + $sql = "DELETE FROM " . $this->cfg['tab']['keywords'] . " + WHERE idlang='" . Contenido_Security::toInteger($this->lang) . "' AND keyword='" . Contenido_Security::escapeDB($key_del, $this->db) . "'"; } else { - $sql = "UPDATE ".$this->cfg['tab']['keywords']." - SET ".$this->place." = '".$index_string."' - WHERE idlang='".Contenido_Security::toInteger($this->lang)."' AND keyword='".Contenido_Security::escapeDB($key_del, $this->db)."'"; + $sql = "UPDATE " . $this->cfg['tab']['keywords'] . " + SET " . $this->place . " = '" . $index_string . "' + WHERE idlang='" . Contenido_Security::toInteger($this->lang) . "' AND keyword='" . Contenido_Security::escapeDB($key_del, $this->db) . "'"; } $this->_debug('sql', $sql); $this->db->query($sql); @@ -430,17 +420,16 @@ class Index extends SearchBaseAbstract * @param none * @return void */ - function getKeywords() - { + function getKeywords() { $keys = implode("','", array_keys($this->keywords)); $sql = "SELECT keyword, auto, self FROM - ".$this->cfg['tab']['keywords']." + " . $this->cfg['tab']['keywords'] . " WHERE - idlang=".Contenido_Security::toInteger($this->lang)." AND - (keyword IN ('".$keys."') OR ".$this->place." REGEXP '&".Contenido_Security::toInteger($this->idart)."=')"; + idlang=" . Contenido_Security::toInteger($this->lang) . " AND + (keyword IN ('" . $keys . "') OR " . $this->place . " REGEXP '&" . Contenido_Security::toInteger($this->idart) . "=')"; $this->_debug('sql', $sql); @@ -458,10 +447,9 @@ class Index extends SearchBaseAbstract * @param $key Keyword * @return $key */ - function removeSpecialChars($key) - { + function removeSpecialChars($key) { $aSpecialChars = array( - "-", "_", "'", ".", "!", "\"", "#", "$", "%", "&", "(", ")", "*", "+", ",", "/", + "-", "_", "'", ".", "!", "\"", "#", "$", "%", "&", "(", ")", "*", "+", ",", "/", ":", ";", "<", "=", ">", "?", "@", "[", "\\", "]", "^", "`", "{", "|", "}", "~" ); @@ -481,14 +469,14 @@ class Index extends SearchBaseAbstract $key = htmlentities_iso88592($key); } - $aUmlautMap = array ( - 'Ü' => 'ue', - 'ü' => 'ue', - 'Ä' => 'ae', - 'ä' => 'ae', - 'Ö' => 'oe', - 'ö' => 'oe', - 'ß' => 'ss' + $aUmlautMap = array( + 'Ü' => 'ue', + 'ü' => 'ue', + 'Ä' => 'ae', + 'ä' => 'ae', + 'Ö' => 'oe', + 'ö' => 'oe', + 'ß' => 'ss' ); foreach ($aUmlautMap as $sUmlaut => $sMapped) { @@ -508,17 +496,16 @@ class Index extends SearchBaseAbstract * @param $key Keyword * @return $key */ - function addSpecialUmlauts($key) - { + function addSpecialUmlauts($key) { $key = clHtmlEntities($key, null, getEncodingByLanguage($this->db, $this->lang, $this->cfg)); - $aUmlautMap = array ( - 'ue' => 'Ü', - 'ue' => 'ü', - 'ae' => 'Ä', - 'ae' => 'ä', - 'oe' => 'Ö', - 'oe' => 'ö', - 'ss' => 'ß' + $aUmlautMap = array( + 'ue' => 'Ü', + 'ue' => 'ü', + 'ae' => 'Ä', + 'ae' => 'ä', + 'oe' => 'Ö', + 'oe' => 'ö', + 'ss' => 'ß' ); foreach ($aUmlautMap as $sUmlaut => $sMapped) { @@ -534,8 +521,7 @@ class Index extends SearchBaseAbstract * @param array $aStopwords * @return void */ - function setStopwords ($aStopwords) - { + function setStopwords($aStopwords) { if (is_array($aStopwords) && count($aStopwords) > 0) { $this->stopwords = $aStopwords; } @@ -546,9 +532,8 @@ class Index extends SearchBaseAbstract * @param none * @return void */ - function setContentTypes() - { - $sql = "SELECT type, idtype FROM ".$this->cfg['tab']['type'] . ' '; + function setContentTypes() { + $sql = "SELECT type, idtype FROM " . $this->cfg['tab']['type'] . ' '; $this->_debug('sql', $sql); $this->db->query($sql); while ($this->db->next_record()) { @@ -562,10 +547,9 @@ class Index extends SearchBaseAbstract * @param none * @return void */ - function setCmsOptions($cms_options) - { + function setCmsOptions($cms_options) { if (is_array($cms_options) && count($cms_options) > 0) { - foreach($cms_options as $opt) { + foreach ($cms_options as $opt) { $opt = strtoupper($opt); if (strlen($opt) > 0) { @@ -591,15 +575,13 @@ class Index extends SearchBaseAbstract * * @return bolean */ - function checkCmsType($idtype) - { + function checkCmsType($idtype) { $idtype = strtoupper($idtype); return (in_array($idtype, $this->cms_options)) ? false : true; } } - /** * Contenido API - Search Object * @@ -703,9 +685,7 @@ class Index extends SearchBaseAbstract * @author Willi Man * @copyright four for business AG */ - -class Search extends SearchBaseAbstract -{ +class Search extends SearchBaseAbstract { /** * Instance of class Index @@ -803,8 +783,7 @@ class Search extends SearchBaseAbstract * @param DB_ConLite $oDB Optional database instance * @return void */ - function Search($options, $oDB = null) - { + function __construct($options, $oDB = null) { parent::__construct($oDB); $this->index = new Index($oDB); @@ -835,8 +814,7 @@ class Search extends SearchBaseAbstract * @param string $searchwords_exclude The words, which should be excluded from search * @return void */ - function searchIndex($searchwords, $searchwords_exclude = '') - { + function searchIndex($searchwords, $searchwords_exclude = '') { if (strlen(trim($searchwords)) > 0) { $this->search_words = $this->stripWords($searchwords); } else { @@ -858,7 +836,7 @@ class Search extends SearchBaseAbstract } if (count($this->search_words_exclude) > 0) { - foreach($this->search_words_exclude as $word) { + foreach ($this->search_words_exclude as $word) { if ($this->search_option == 'like') { $word = "'%" . $word . "%'"; } elseif ($this->search_option == 'exact') { @@ -868,8 +846,9 @@ class Search extends SearchBaseAbstract array_push($this->search_words, $word); } } - - if(count($tmp_searchwords) == 0) return false; + + if (count($tmp_searchwords) == 0) + return false; if ($this->search_option == 'regexp') { // regexp search @@ -884,8 +863,8 @@ class Search extends SearchBaseAbstract $kwSql = "keyword LIKE '" . $search_exact; } - $sql = "SELECT keyword, auto FROM " . $this->cfg['tab']['keywords'] - . " WHERE idlang=" . Contenido_Security::toInteger($this->lang) . " AND " . $kwSql . " "; + $sql = "SELECT keyword, auto FROM " . $this->cfg['tab']['keywords'] + . " WHERE idlang=" . Contenido_Security::toInteger($this->lang) . " AND " . $kwSql . " "; $this->_debug('sql', $sql); $this->db->query($sql); @@ -897,7 +876,7 @@ class Search extends SearchBaseAbstract $tmp_index = array(); foreach ($tmp_index_string as $string) { - $tmp_string = preg_replace('/[=\(\)]/', ' ', $string); + $tmp_string = preg_replace('/[=\(\)]/', ' ', $string); $tmp_index[] = preg_split('/\s/', $tmp_string, -1, PREG_SPLIT_NO_EMPTY); } $this->_debug('tmp_index', $tmp_index); @@ -908,9 +887,9 @@ class Search extends SearchBaseAbstract // filter nonsearchable articles if (in_array($artid, $this->searchable_arts)) { - $cms_place = $string[2]; - $keyword = $this->db->f('keyword'); - $percent = 0; + $cms_place = $string[2]; + $keyword = $this->db->f('keyword'); + $percent = 0; $similarity = 0; foreach ($this->search_words as $word) { similar_text($word, $keyword, $percent); // computes similarity between searchword and keyword in percent @@ -946,7 +925,6 @@ class Search extends SearchBaseAbstract } } } - } } } @@ -981,8 +959,7 @@ class Search extends SearchBaseAbstract * @param $cms_options The cms-types (htmlhead, html, ...) which should explicitly be searched * @return void */ - function setCmsOptions($cms_options) - { + function setCmsOptions($cms_options) { if (is_array($cms_options) && count($cms_options) > 0) { $this->index->setCmsOptions($cms_options); } @@ -992,8 +969,7 @@ class Search extends SearchBaseAbstract * @param $searchwords The search-words * @return Array of stripped search-words */ - function stripWords($searchwords) - { + function stripWords($searchwords) { $tmp_words = array(); $searchwords = stripslashes($searchwords); // remove backslash $searchwords = strip_tags($searchwords); // remove html tags @@ -1020,19 +996,18 @@ class Search extends SearchBaseAbstract * @return array Category Tree * @todo This is not the job for search, should be oursourced... */ - function getSubTree($cat_start) - { + function getSubTree($cat_start) { $sql = "SELECT B.idcat, B.parentid FROM - ".$this->cfg['tab']['cat_tree']." AS A, - ".$this->cfg['tab']['cat']." AS B, - ".$this->cfg['tab']['cat_lang']." AS C + " . $this->cfg['tab']['cat_tree'] . " AS A, + " . $this->cfg['tab']['cat'] . " AS B, + " . $this->cfg['tab']['cat_lang'] . " AS C WHERE A.idcat = B.idcat AND B.idcat = C.idcat AND - C.idlang = '".Contenido_Security::toInteger($this->lang)."' AND - B.idclient = '".Contenido_Security::toInteger($this->client)."' + C.idlang = '" . Contenido_Security::toInteger($this->lang) . "' AND + B.idclient = '" . Contenido_Security::toInteger($this->client) . "' ORDER BY idtree"; $this->_debug('sql', $sql); @@ -1065,13 +1040,12 @@ class Search extends SearchBaseAbstract * @param array $search_range * @return array Articles in specified search range */ - function getSearchableArticles($search_range) - { + function getSearchableArticles($search_range) { $cat_range = array(); if (array_key_exists('cat_tree', $search_range) && is_array($search_range['cat_tree'])) { if (count($search_range['cat_tree']) > 0) { - foreach($search_range['cat_tree'] as $cat) { + foreach ($search_range['cat_tree'] as $cat) { $cat_range = array_merge($cat_range, $this->getSubTree($cat)); } } @@ -1108,18 +1082,18 @@ class Search extends SearchBaseAbstract if ($this->exclude == true) { // exclude searchrange - $sSearchRange = " A.idcat NOT IN ('".$sCatRange."') AND B.idart NOT IN ('".$sArtRange."') AND "; + $sSearchRange = " A.idcat NOT IN ('" . $sCatRange . "') AND B.idart NOT IN ('" . $sArtRange . "') AND "; } else { // include searchrange if (strlen($sArtRange) > 0) { - $sSearchRange = " A.idcat IN ('".$sCatRange."') AND B.idart IN ('".$sArtRange."') AND "; + $sSearchRange = " A.idcat IN ('" . $sCatRange . "') AND B.idart IN ('" . $sArtRange . "') AND "; } else { - $sSearchRange = " A.idcat IN ('".$sCatRange."') AND "; + $sSearchRange = " A.idcat IN ('" . $sCatRange . "') AND "; } } if (count($this->article_specs) > 0) { - $sArtSpecs = " B.artspec IN ('".implode("','", $this->article_specs)."') AND "; + $sArtSpecs = " B.artspec IN ('" . implode("','", $this->article_specs) . "') AND "; } else { $sArtSpecs = ''; } @@ -1127,17 +1101,17 @@ class Search extends SearchBaseAbstract $sql = "SELECT A.idart FROM - ".$this->cfg["tab"]["cat_art"]." as A, - ".$this->cfg["tab"]["art_lang"]." as B, - ".$this->cfg["tab"]["cat_lang"]." as C + " . $this->cfg["tab"]["cat_art"] . " as A, + " . $this->cfg["tab"]["art_lang"] . " as B, + " . $this->cfg["tab"]["cat_lang"] . " as C WHERE - ".$sSearchRange." - B.idlang = '".Contenido_Security::toInteger($this->lang)."' AND - C.idlang = '".Contenido_Security::toInteger($this->lang)."' AND + " . $sSearchRange . " + B.idlang = '" . Contenido_Security::toInteger($this->lang) . "' AND + C.idlang = '" . Contenido_Security::toInteger($this->lang) . "' AND A.idart = B.idart AND A.idcat = C.idcat AND - ".$sArtSpecs." - ".$protected." "; + " . $sArtSpecs . " + " . $protected . " "; $this->_debug('sql', $sql); $this->db->query($sql); while ($this->db->next_record()) { @@ -1151,15 +1125,14 @@ class Search extends SearchBaseAbstract * * @return array Array of article specification Ids */ - function getArticleSpecifications() - { + function getArticleSpecifications() { $sql = "SELECT idartspec FROM - ".$this->cfg['tab']['art_spec']." + " . $this->cfg['tab']['art_spec'] . " WHERE - client = ".Contenido_Security::toInteger($this->client)." AND - lang = ".Contenido_Security::toInteger($this->lang)." AND + client = " . Contenido_Security::toInteger($this->client) . " AND + lang = " . Contenido_Security::toInteger($this->lang) . " AND online = 1 "; $this->_debug('sql', $sql); $this->db->query($sql); @@ -1175,8 +1148,7 @@ class Search extends SearchBaseAbstract * @param int $iArtspecID * @return void */ - function setArticleSpecification($iArtspecID) - { + function setArticleSpecification($iArtspecID) { array_push($this->article_specs, $iArtspecID); } @@ -1185,8 +1157,7 @@ class Search extends SearchBaseAbstract * @param string $sArtSpecName * @return void */ - function addArticleSpecificationsByName($sArtSpecName) - { + function addArticleSpecificationsByName($sArtSpecName) { if (!isset($sArtSpecName) || strlen($sArtSpecName) == 0) { return false; } @@ -1194,10 +1165,10 @@ class Search extends SearchBaseAbstract $sql = "SELECT idartspec FROM - ".$this->cfg['tab']['art_spec']." + " . $this->cfg['tab']['art_spec'] . " WHERE - client = ".Contenido_Security::toInteger($this->client)." AND - artspec = '".Contenido_Security::escapeDB($sArtSpecName, $this->db)."' "; + client = " . Contenido_Security::toInteger($this->client) . " AND + artspec = '" . Contenido_Security::escapeDB($sArtSpecName, $this->db) . "' "; $this->_debug('sql', $sql); $this->db->query($sql); while ($this->db->next_record()) { @@ -1207,7 +1178,6 @@ class Search extends SearchBaseAbstract } - /** * Contenido API - SearchResult Object * @@ -1241,9 +1211,8 @@ class Search extends SearchBaseAbstract * @copyright four for business AG * */ +class SearchResult extends SearchBaseAbstract { -class SearchResult extends SearchBaseAbstract -{ /** * Instance of class Index * @var object @@ -1310,8 +1279,7 @@ class SearchResult extends SearchBaseAbstract * @param DB_ConLite $oDB Optional db instance * @param bool $bDebug Optional flag to enable debugging */ - function SearchResult($search_result, $result_per_page, $oDB = null, $bDebug = false) - { + function __construct($search_result, $result_per_page, $oDB = null, $bDebug = false) { parent::__construct($oDB, $bDebug); $this->index = new Index($oDB); @@ -1338,8 +1306,7 @@ class SearchResult extends SearchBaseAbstract * @param $result_per_page * @return void */ - function setOrderedSearchResult($ranked_search, $result_per_page) - { + function setOrderedSearchResult($ranked_search, $result_per_page) { asort($ranked_search); $sorted_rank = array_reverse($ranked_search, true); @@ -1358,8 +1325,7 @@ class SearchResult extends SearchBaseAbstract * @param $art_id Id of an article * @return Content of an article, specified by it's content type */ - function getContent($art_id, $cms_type, $id = 0) - { + function getContent($art_id, $cms_type, $id = 0) { $article = new Article($art_id, $this->client, $this->lang); return $article->getContent($cms_type, $id); } @@ -1369,8 +1335,7 @@ class SearchResult extends SearchBaseAbstract * @param $art_id Id of an article * @return Content of an article in search result, specified by its type */ - function getSearchContent($art_id, $cms_type, $cms_nr = NULL) - { + function getSearchContent($art_id, $cms_type, $cms_nr = NULL) { $cms_type = strtoupper($cms_type); if (strlen($cms_type) > 0) { if (!stristr($cms_type, 'cms_')) { @@ -1399,14 +1364,14 @@ class SearchResult extends SearchBaseAbstract //build consistent escaped string(Timo Trautmann) 2008-04-17 $cms_content = clHtmlEntities(clHtmlEntityDecode(strip_tags($article->getContent($cms_type, $cms_nr)))); if (count($this->replacement) == 2) { - foreach($search_words as $word) { + foreach ($search_words as $word) { //build consistent escaped string, replace ae ue .. with original html entities (Timo Trautmann) 2008-04-17 $word = clHtmlEntities(clHtmlEntityDecode($this->index->addSpecialUmlauts($word))); $match = array(); preg_match("/$word/i", $cms_content, $match); if (isset($match[0])) { $pattern = $match[0]; - $replacement = $this->replacement[0].$pattern.$this->replacement[1]; + $replacement = $this->replacement[0] . $pattern . $this->replacement[1]; $cms_content = preg_replace("/$pattern/i", $replacement, $cms_content); // emphasize located searchwords } } @@ -1418,11 +1383,11 @@ class SearchResult extends SearchBaseAbstract $cms_content = strip_tags($article->getContent($cms_type, $id)); if (count($this->replacement) == 2) { - foreach($search_words as $word) { + foreach ($search_words as $word) { preg_match("/$word/i", $cms_content, $match); if (isset($match[0])) { $pattern = $match[0]; - $replacement = $this->replacement[0].$pattern.$this->replacement[1]; + $replacement = $this->replacement[0] . $pattern . $this->replacement[1]; $cms_content = preg_replace("/$pattern/i", $replacement, $cms_content); // emphasize located searchwords } } @@ -1430,7 +1395,6 @@ class SearchResult extends SearchBaseAbstract $content[] = $cms_content; } } - } else { // searchword was not found in cms_type if (isset($cms_nr) && is_numeric($cms_nr)) { @@ -1453,8 +1417,7 @@ class SearchResult extends SearchBaseAbstract * @param int $page_id * @return array Artices in page $page_id */ - function getSearchResultPage($page_id) - { + function getSearchResultPage($page_id) { $this->result_page = $page_id; $result_page = $this->ordered_search_result[$page_id - 1]; return $result_page; @@ -1464,8 +1427,7 @@ class SearchResult extends SearchBaseAbstract * Returns number of result pages * @return int */ - function getNumberOfPages() - { + function getNumberOfPages() { return $this->pages; } @@ -1473,8 +1435,7 @@ class SearchResult extends SearchBaseAbstract * Returns number of results * @return int */ - function getNumberOfResults() - { + function getNumberOfResults() { return $this->results; } @@ -1482,17 +1443,15 @@ class SearchResult extends SearchBaseAbstract * @param $art_id Id of an article * @return Similarity between searchword and matching word in article */ - function getSimilarity($art_id) - { - return $this->search_result[$art_id]['similarity']; + function getSimilarity($art_id) { + return $this->search_result[$art_id]['similarity']; } /** * @param $art_id Id of an article * @return Number of matching searchwords found in article */ - function getOccurrence($art_id) - { + function getOccurrence($art_id) { $aOccurence = $this->search_result[$art_id]['occurence']; $iSumOfOccurence = 0; for ($i = 0; $i < count($aOccurence); $i++) { @@ -1507,8 +1466,7 @@ class SearchResult extends SearchBaseAbstract * @param string $rep2 The closing html-tag e.g. '
' * @return void */ - function setReplacement($rep1, $rep2) - { + function setReplacement($rep1, $rep2) { if (strlen(trim($rep1)) > 0 && strlen(trim($rep2)) > 0) { array_push($this->replacement, $rep1); array_push($this->replacement, $rep2); @@ -1520,10 +1478,9 @@ class SearchResult extends SearchBaseAbstract * @return Category Id * @todo Is not job of search, should be outsourced! */ - function getArtCat($artid) - { - $sql = "SELECT idcat FROM ".$this->cfg['tab']['cat_art']." - WHERE idart = ".Contenido_Security::toInteger($artid)." "; + function getArtCat($artid) { + $sql = "SELECT idcat FROM " . $this->cfg['tab']['cat_art'] . " + WHERE idart = " . Contenido_Security::toInteger($artid) . " "; $this->db->query($sql); if ($this->db->next_record()) { return $this->db->f('idcat'); @@ -1531,18 +1488,3 @@ class SearchResult extends SearchBaseAbstract } } - -/** - * @deprecated - * @since 2008-07-11 - * - */ -class Search_helper { - - var $oDb = NULL; - - function search_helper ($oDb, $lang, $client) { - } -} - -?> \ No newline at end of file diff --git a/trunk/conlite/classes/class.smtp.php b/trunk/conlite/classes/class.smtp.php index 6900671..239e14f 100644 --- a/trunk/conlite/classes/class.smtp.php +++ b/trunk/conlite/classes/class.smtp.php @@ -74,7 +74,7 @@ class SMTP * @access public * @return void */ - function SMTP() { + function __construct() { $this->smtp_conn = 0; $this->error = null; $this->helo_rply = null; diff --git a/trunk/conlite/classes/class.structure.php b/trunk/conlite/classes/class.structure.php index ac9e8d5..aaacdf4 100644 --- a/trunk/conlite/classes/class.structure.php +++ b/trunk/conlite/classes/class.structure.php @@ -38,7 +38,7 @@ class Structure { * Constructor Function * @param */ - function Structure() { + function __construct() { // empty } // end function diff --git a/trunk/conlite/classes/class.table.php b/trunk/conlite/classes/class.table.php index e425fd6..5625a3e 100644 --- a/trunk/conlite/classes/class.table.php +++ b/trunk/conlite/classes/class.table.php @@ -1,4 +1,5 @@ border_color = $m_bordercolor; $this->border_style = $m_borderstyle; $this->cellspacing = $m_cellspacing; @@ -126,8 +120,9 @@ class Table { $this->light_color = $m_light_color; $this->fullborder = $m_fullborder; $this->directoutput = $m_directoutput; + } - } # end function +# end function /** * Begins the new table @@ -136,43 +131,38 @@ class Table { */ function start_table() { - if (!$this->fullborder) - { - $starttable = ''; + if (!$this->fullborder) { + $starttable = '
'; } else { - $starttable = '
'; + $starttable = '
'; } - if ($this->directoutput) - { - echo $starttable."\n"; + if ($this->directoutput) { + echo $starttable . "\n"; } else { - return $starttable."\n"; + return $starttable . "\n"; } + } - - } # end function - - +# end function /** * Outputs a header row * @param none * @return void */ - function header_row($additional="") { - - $headerrow = ''; + function header_row($additional = "") { - if ($this->directoutput) - { - echo $headerrow."\n"; - } else { - return $headerrow."\n"; - } - } # end function + $headerrow = ''; + if ($this->directoutput) { + echo $headerrow . "\n"; + } else { + return $headerrow . "\n"; + } + } +# end function /** * Outputs a regular row @@ -180,27 +170,24 @@ class Table { * @return void */ function row($id = '') { - if ($this->dark_row) - { - $bgColor = $this->light_color; - } else { - $bgColor = $this->dark_color; - } + if ($this->dark_row) { + $bgColor = $this->light_color; + } else { + $bgColor = $this->dark_color; + } - $this->dark_row = !$this->dark_row; - - $row = ''; + $this->dark_row = !$this->dark_row; - if ($this->directoutput) - { - echo $row."\n"; - } else { - return $row."\n"; - } - - } # end function + $row = ''; + if ($this->directoutput) { + echo $row . "\n"; + } else { + return $row . "\n"; + } + } +# end function /** * Outputs a header cell @@ -209,28 +196,25 @@ class Table { * @param $valign The vertical alignment of the cell, default "top" * @return void */ - function header_cell($content, $align="center", $valign="top", $additional="", $borderTop = 1){ + function header_cell($content, $align = "center", $valign = "top", $additional = "", $borderTop = 1) { - $header_cell = ''; - - if ($this->first_cell) - { - $this->table_cols = 0; - $this->first_cell = false; - } - - $this->table_cols++; + $header_cell = ''; - if ($this->directoutput) - { - echo $header_cell."\n"; - } else { - return $header_cell."\n"; - } - - } # end function + if ($this->first_cell) { + $this->table_cols = 0; + $this->first_cell = false; + } + $this->table_cols++; + if ($this->directoutput) { + echo $header_cell . "\n"; + } else { + return $header_cell . "\n"; + } + } + +# end function /** * Outputs a regular cell @@ -239,44 +223,42 @@ class Table { * @param $valign The vertical alignment of the cell, default "top" * @param $additional Additional flags for the table */ - function cell($content, $align="center", $valign="top", $additional = "", $bSetStyle = true){ + function cell($content, $align = "center", $valign = "top", $additional = "", $bSetStyle = true) { - if (strlen($content) == 0) - { + if (strlen($content) == 0) { $content = " "; - } - $cell = ''; + } + $cell = ''; + + if ($this->first_cell) { + $this->table_cols = 0; + $this->first_cell = false; + } + + $this->table_cols++; + + if ($this->directoutput) { + echo $cell . "\n"; + } else { + return $cell . "\n"; + } + } + +# end function /** * Outputs a borderless cell @@ -285,94 +267,85 @@ class Table { * @param $valign The vertical alignment of the cell, default "top" * @param $additional Additional flags for the table */ - function borderless_cell($content, $align="center", $valign="top", $additional = ""){ + function borderless_cell($content, $align = "center", $valign = "top", $additional = "") { - if (strlen($content) == 0) - { + if (strlen($content) == 0) { $content = " "; - } - $borderless_cell = ''; + } + $borderless_cell = ''; - if ($this->first_cell) - { - $this->table_cols = 0; - $this->first_cell = false; - } - - $this->table_cols++; + if ($this->first_cell) { + $this->table_cols = 0; + $this->first_cell = false; + } - if ($this->directoutput) - { - echo $borderless_cell."\n"; - } else { - return $borderless_cell."\n"; - } + $this->table_cols++; - } # end function + if ($this->directoutput) { + echo $borderless_cell . "\n"; + } else { + return $borderless_cell . "\n"; + } + } + +# end function - /** * Outputs a sum cell * @param $content The content which will fill the cell * @param $align The horizontal alignment of the cell, default "center" * @param $valign The vertical alignment of the cell, default "top" */ - function sumcell($content, $align="center", $valign="top"){ + function sumcell($content, $align = "center", $valign = "top") { - if (strlen($content) == 0) - { + if (strlen($content) == 0) { $content = " "; - } - $sumcell = ''; + } + $sumcell = ''; - if ($this->directoutput) - { - echo $sumcell."\n"; - } else { - return $sumcell."\n"; - } - - } # end function + if ($this->directoutput) { + echo $sumcell . "\n"; + } else { + return $sumcell . "\n"; + } + } +# end function /** * Ends a row * @param none * @return void */ - - function end_row() - { - $end_row = ''; + function end_row() { + $end_row = ''; - $this->first_cell = true; + $this->first_cell = true; - if ($this->directoutput) - { - echo $end_row."\n"; + if ($this->directoutput) { + echo $end_row . "\n"; } else { - return $end_row."\n"; + return $end_row . "\n"; } - } - /** * Ends a table * @param none * @return void */ - function end_table(){ + function end_table() { $end_table = '
' . $content . '' . $content . 'border_color . '; border-style: ' . $this->border_style . '"'; - } - - if ($align != '') { - $cell.=' align="'.$align .'"'; - } - - $cell.='>'.$content.'first_cell) - { - $this->table_cols = 0; - $this->first_cell = false; - } - - $this->table_cols++; + if ($valign != '') { + $cell .= ' valign="' . $valign . '"'; + } - if ($this->directoutput) - { - echo $cell."\n"; - } else { - return $cell."\n"; - } + if ($bSetStyle) { + $cell .= ' style="border: 0px; border-bottom:1px; border-top:0px; border-right:1px; border-color: ' . $this->border_color . '; border-style: ' . $this->border_style . '"'; + } - } # end function + if ($align != '') { + $cell .= ' align="' . $align . '"'; + } + + $cell .= '>' . $content . '' . $content . '' . $content . '' . $content . '' . $content . '
'; - if ($this->directoutput) - { - echo $end_table."\n"; + if ($this->directoutput) { + echo $end_table . "\n"; } else { - return $end_table."\n"; + return $end_table . "\n"; } - } # end function + } -} # end class Table +# end function +} +# end class Table ?> diff --git a/trunk/conlite/classes/class.todo.php b/trunk/conlite/classes/class.todo.php index b5215a8..94353f2 100644 --- a/trunk/conlite/classes/class.todo.php +++ b/trunk/conlite/classes/class.todo.php @@ -42,13 +42,6 @@ class TODOCollection extends CommunicationCollection $this->_setItemClass("TODOItem"); } - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function TODOCollection() - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct(); - } - public function select($where = "", $group_by = "", $order_by = "", $limit = "") { if ($where == "") { diff --git a/trunk/conlite/classes/class.treeitem.php b/trunk/conlite/classes/class.treeitem.php index da0856a..06c2cd8 100644 --- a/trunk/conlite/classes/class.treeitem.php +++ b/trunk/conlite/classes/class.treeitem.php @@ -129,7 +129,7 @@ class TreeItem * @param string $id The unique ID of that item * @param boolean $collapsed Is this item collapsed by default */ - function TreeItem($name ="", $id="", $collapsed = false) + function __construct($name ="", $id="", $collapsed = false) { $this->name = $name; $this->id = $id; diff --git a/trunk/conlite/classes/class.ui.php b/trunk/conlite/classes/class.ui.php index 08363be..086a3ca 100644 --- a/trunk/conlite/classes/class.ui.php +++ b/trunk/conlite/classes/class.ui.php @@ -38,7 +38,7 @@ class UI_Left_Top { var $link; var $javascripts; - function UI_Left_Top() { + function __construct() { } @@ -53,7 +53,7 @@ class UI_Left_Top { function render() { global $sess, $cfg; - $tpl = new Template; + $tpl = new Template(); $tpl->reset(); $tpl->set('s', 'SESSID', $sess->id); @@ -100,7 +100,7 @@ class UI_Menu { var $show; var $bgColor; - function UI_Menu() { + function __construct() { $this->padding = 2; $this->border = 0; $this->rowmark = true; @@ -147,7 +147,7 @@ class UI_Menu { function render($print = true) { global $sess, $cfg; - $tpl = new Template; + $tpl = new Template(); $tpl->reset(); $tpl->set('s', 'SID', $sess->id); @@ -284,7 +284,7 @@ class UI_Table_Form { var $accesskey; var $width; - function UI_Table_Form($name, $action = "", $method = "post") { + function __construct($name, $action = "", $method = "post") { global $sess, $cfg; $this->formname = $name; @@ -635,7 +635,7 @@ class UI_Page { var $content; var $margin; - function UI_Page() { + function __construct() { $this->margin = 10; } @@ -674,7 +674,7 @@ class UI_Page { function render($print = true) { global $sess, $cfg; - $tpl = new Template; + $tpl = new Template(); $scripts = ""; @@ -848,7 +848,7 @@ class UI_List { var $solid; var $width; - function UI_List() { + function __construct() { $this->padding = 2; $this->border = 0; } @@ -897,8 +897,8 @@ class UI_List { function render($print = false) { global $sess, $cfg; - $tpl = new Template; - $tpl2 = new Template; + $tpl = new Template(); + $tpl2 = new Template(); $tpl->reset(); $tpl->set('s', 'SID', $sess->id); @@ -1075,45 +1075,45 @@ class cScrollList { * * @param $defaultstyle boolean use the default style for object initializing? */ - function cScrollList($defaultstyle = true, $action = "") { + function __construct($defaultstyle = true, $action = "") { global $cfg, $area, $frame; $this->resultsPerPage = 0; $this->listStart = 1; $this->sortable = false; - $this->objTable = new cHTMLTable; + $this->objTable = new cHTMLTable(); if ($defaultstyle == true) { $this->objTable->setStyle('border-collapse:collapse;border: 1px; border-style: solid; border-top:0px;border-color: ' . $cfg["color"]["table_border"] . ';'); $this->objTable->updateAttributes(array("cellspacing" => 0, "cellpadding" => 2)); } - $this->objHeaderRow = new cHTMLTableRow; + $this->objHeaderRow = new cHTMLTableRow(); if ($defaultstyle == true) { $this->objHeaderRow->setClass("text_medium"); $this->objHeaderRow->setStyle("background-color: #E2E2E2;white-space:nowrap;"); } - $this->objHeaderItem = new cHTMLTableHead; + $this->objHeaderItem = new cHTMLTableHead(); if ($defaultstyle == true) { $this->objHeaderItem->setClass("textg_medium"); $this->objHeaderItem->setStyle('white-space:nowrap; border: 1px; border-style: solid;border-bottom: 0px;border-color: ' . $cfg["color"]["table_border"] . ';'); $this->objHeaderItem->updateAttributes(array("align" => "left")); } - $this->objRow = new cHTMLTableRow; + $this->objRow = new cHTMLTableRow(); if ($defaultstyle == true) { $this->objRow->setClass("text_medium"); } - $this->objItem = new cHTMLTableData; + $this->objItem = new cHTMLTableData(); if ($defaultstyle == true) { $this->objItem->setStyle('white-space:nowrap; border: 1px; border-style: solid;border-top:0px;border-color: ' . $cfg["color"]["table_border"] . ';'); } - $this->sortlink = new cHTMLLink; + $this->sortlink = new cHTMLLink(); $this->sortlink->setStyle("color: #666666;"); $this->sortlink->setCLink($area, $frame, $action); } @@ -1320,7 +1320,7 @@ class cScrollList { * @param $return If true, returns the list */ function render($return = true) { - + $currentpage = $this->getCurrentPage(); $itemstart = (($currentpage - 1) * $this->resultsPerPage) + 1; @@ -1402,5 +1402,5 @@ class cScrollList { echo $output; } } + } -?> \ No newline at end of file diff --git a/trunk/conlite/classes/class.update.notifier.php b/trunk/conlite/classes/class.update.notifier.php index d7771ef..2e0bba4 100644 --- a/trunk/conlite/classes/class.update.notifier.php +++ b/trunk/conlite/classes/class.update.notifier.php @@ -691,6 +691,7 @@ class Contenido_UpdateNotifier { if ($this->sRSSContent != '') { $oRss = simplexml_load_file($this->sCacheDirectory . $this->sRSSFile); + //echo $sFeedContent; $iCnt = 0; foreach ($oRss->channel->item as $aItem) { @@ -769,4 +770,4 @@ class Contenido_UpdateNotifier { } -?> \ No newline at end of file +?> diff --git a/trunk/conlite/classes/class.user.php b/trunk/conlite/classes/class.user.php index d448d6e..e55fb76 100644 --- a/trunk/conlite/classes/class.user.php +++ b/trunk/conlite/classes/class.user.php @@ -1,4 +1,5 @@ table = $cfg['tab']['phplib_auth_user_md5']; @@ -70,62 +68,55 @@ class Users $this->db = new DB_ConLite(); } - /** * Creates a new user by specifying its username. * * @param string $username Specifies the username * @return int Userid of created user */ - function create($username) - { + function create($username) { $newuserid = md5($username); - $sql = "SELECT user_id FROM ".$this->table - . " WHERE user_id = '".Contenido_Security::escapeDB($newuserid, $this->db)."'"; + $sql = "SELECT user_id FROM " . $this->table + . " WHERE user_id = '" . Contenido_Security::escapeDB($newuserid, $this->db) . "'"; $this->db->query($sql); if ($this->db->next_record()) { return false; } - $sql = "INSERT INTO ".$this->table - . " SET user_id = '".Contenido_Security::escapeDB($newuserid, $this->db)."'," - . " username = '".Contenido_Security::escapeDB($username, $this->db)."'"; + $sql = "INSERT INTO " . $this->table + . " SET user_id = '" . Contenido_Security::escapeDB($newuserid, $this->db) . "'," + . " username = '" . Contenido_Security::escapeDB($username, $this->db) . "'"; $this->db->query($sql); return $newuserid; } - /** * Removes the specified user from the database. * * @param string $userid Specifies the user ID * @return bool True if the delete was successful */ - function deleteUserByID($userid) - { + function deleteUserByID($userid) { $sql = "DELETE FROM " . $this->table - . " WHERE user_id = '" . Contenido_Security::escapeDB($userid, $this->db) . "'"; + . " WHERE user_id = '" . Contenido_Security::escapeDB($userid, $this->db) . "'"; $this->db->query($sql); return ($this->db->affected_rows() == 0) ? false : true; } - /** * Removes the specified user from the database. * * @param string $userid Specifies the username * @return bool True if the delete was successful */ - function deleteUserByUsername($username) - { + function deleteUserByUsername($username) { $sql = "DELETE FROM " . $this->table - . " WHERE username = '" . Contenido_Security::escapeDB($username, $this->db) . "'"; + . " WHERE username = '" . Contenido_Security::escapeDB($username, $this->db) . "'"; $this->db->query($sql); return ($this->db->affected_rows() == 0) ? false : true; } - /** * Returns all users which are accessible by the current user. * @@ -133,8 +124,7 @@ class Users * @param bool $includeAdmins Flag to get admins (admin and sysadmin) too * @return array Array of user objects */ - function getAccessibleUsers($perms, $includeAdmins = false) - { + function getAccessibleUsers($perms, $includeAdmins = false) { global $cfg; $clientclass = new Client(); @@ -142,15 +132,15 @@ class Users $allClients = $clientclass->getAvailableClients(); foreach ($allClients as $key => $value) { - if (in_array("client[".$key."]", $perms) || in_array("admin[".$key."]", $perms)) { - $limit[] = 'perms LIKE "%client['.$key.']%"'; + if (in_array("client[" . $key . "]", $perms) || in_array("admin[" . $key . "]", $perms)) { + $limit[] = 'perms LIKE "%client[' . $key . ']%"'; if ($includeAdmins) { - $limit[] = 'perms LIKE "%admin['.$key.']%"'; + $limit[] = 'perms LIKE "%admin[' . $key . ']%"'; } } - if (in_array("admin[".$key."]", $perms)) { - $limit[] = 'perms LIKE "%admin['.$key.']%"'; + if (in_array("admin[" . $key . "]", $perms)) { + $limit[] = 'perms LIKE "%admin[' . $key . ']%"'; } } @@ -171,7 +161,7 @@ class Users $sql = "SELECT user_id, username, realname FROM - ". $cfg['tab']['phplib_auth_user_md5']. " WHERE 1 AND ".$limitSQL." ORDER BY realname, username"; + " . $cfg['tab']['phplib_auth_user_md5'] . " WHERE 1 AND " . $limitSQL . " ORDER BY realname, username"; $db->query($sql); @@ -186,8 +176,8 @@ class Users return ($users); } -} +} /** * Class User @@ -196,8 +186,7 @@ class Users * @version 1.0 * @copyright four for business 2003 */ -class User -{ +class User { /** * Storage of the source table to use for the user informations @@ -232,8 +221,7 @@ class User * * @param string $table The table to use as information source */ - function User($table = '') - { + function __construct($table = '') { if ($table == '') { global $cfg; $this->table = $cfg['tab']['phplib_auth_user_md5']; @@ -244,18 +232,16 @@ class User $this->db = new DB_ConLite(); } - /** * Loads a user from the database by its username. * * @param string $username Specifies the username * @return bool True if the load was successful */ - function loadUserByUsername($username) - { + function loadUserByUsername($username) { // SQL-Statement to select by username $sql = "SELECT * FROM " . $this->table - . " WHERE username = '".Contenido_Security::escapeDB($username, $this->db)."'"; + . " WHERE username = '" . Contenido_Security::escapeDB($username, $this->db) . "'"; // Query the database $this->db->query($sql); @@ -270,18 +256,16 @@ class User return true; } - /** * Loads a user from the database by its userID. * * @param string $userid Specifies the userID * @return bool True if the load was successful */ - function loadUserByUserID($userID) - { + function loadUserByUserID($userID) { // SQL-Statement to select by userID $sql = "SELECT * FROM " . $this->table - . " WHERE user_id = '".Contenido_Security::escapeDB($userID, $this->db)."'"; + . " WHERE user_id = '" . Contenido_Security::escapeDB($userID, $this->db) . "'"; // Query the database $this->db->query($sql); @@ -296,15 +280,13 @@ class User return true; } - /** * Function returns effective perms for user including group rights as perm string. * * @author Timo Trautmann * @return string Current users permissions */ - function getEffectiveUserPerms() - { + function getEffectiveUserPerms() { global $cfg, $perm; //first get users own permissions and filter them into result array $aUserPerms @@ -336,51 +318,45 @@ class User return implode(',', $aUserPerms); } - /** * Gets the value of a specific field. * * @param string $field Specifies the field to retrieve * @return mixed Value of the field */ - function getField($field) - { + function getField($field) { return ($this->values[$field]); } - /** * Sets the value of a specific field. * * @param string $field Specifies the field to set * @param string $value Specifies the value to set */ - function setField($field, $value) - { + function setField($field, $value) { $this->modifiedValues[$field] = true; $this->values[$field] = $value; } - /** * Stores the modified user object to the database * @return bool */ - function store() - { - $sql = "UPDATE " .$this->table ." SET "; + function store() { + $sql = "UPDATE " . $this->table . " SET "; $first = true; foreach ($this->modifiedValues as $key => $value) { if ($first == true) { - $sql .= "$key = '" . $this->values[$key] ."'"; + $sql .= "$key = '" . $this->values[$key] . "'"; $first = false; } else { - $sql .= ", $key = '" . $this->values[$key] ."'"; + $sql .= ", $key = '" . $this->values[$key] . "'"; } } - $sql .= " WHERE user_id = '".Contenido_Security::escapeDB($this->values['user_id'], $this->db)."'"; + $sql .= " WHERE user_id = '" . Contenido_Security::escapeDB($this->values['user_id'], $this->db) . "'"; $this->db->query($sql); @@ -391,7 +367,6 @@ class User } } - /** * Stores the modified user object to the database * @param string type Specifies the type (class, category etc) for the property to retrieve @@ -399,8 +374,7 @@ class User * @param boolean group Specifies if this function should recursively search in groups * @return string The value of the retrieved property */ - function getUserProperty($type, $name, $group = false) - { + function getUserProperty($type, $name, $group = false) { global $cfg, $perm; if (!is_object($perm)) { @@ -414,10 +388,10 @@ class User if (is_array($groups)) { foreach ($groups as $value) { - $sql = "SELECT value FROM " .$cfg['tab']['group_prop']." - WHERE group_id = '".Contenido_Security::escapeDB($value, $this->db)."' - AND type = '".Contenido_Security::escapeDB($type, $this->db)."' - AND name = '".Contenido_Security::escapeDB($name, $this->db)."'"; + $sql = "SELECT value FROM " . $cfg['tab']['group_prop'] . " + WHERE group_id = '" . Contenido_Security::escapeDB($value, $this->db) . "' + AND type = '" . Contenido_Security::escapeDB($type, $this->db) . "' + AND name = '" . Contenido_Security::escapeDB($name, $this->db) . "'"; $this->db->query($sql); if ($this->db->next_record()) { @@ -427,10 +401,10 @@ class User } } - $sql = "SELECT value FROM " .$cfg['tab']['user_prop']." - WHERE user_id = '".Contenido_Security::escapeDB($this->values['user_id'], $this->db)."' - AND type = '".Contenido_Security::escapeDB($type, $this->db)."' - AND name = '".Contenido_Security::escapeDB($name, $this->db)."'"; + $sql = "SELECT value FROM " . $cfg['tab']['user_prop'] . " + WHERE user_id = '" . Contenido_Security::escapeDB($this->values['user_id'], $this->db) . "' + AND type = '" . Contenido_Security::escapeDB($type, $this->db) . "' + AND name = '" . Contenido_Security::escapeDB($name, $this->db) . "'"; $this->db->query($sql); if ($this->db->next_record()) { @@ -444,44 +418,42 @@ class User } } - /** * Stores the modified user object to the database * * @param string sType Specifies the type (class, category etc) for the property to retrieve * @param boolean bGroup Specifies if this function should recursively search in groups * @return array The value of the retrieved property - **/ - function getUserPropertiesByType($sType, $bGroup = false) - { - global $cfg, $perm; + * */ + function getUserPropertiesByType($sType, $bGroup = false) { + global $cfg, $perm; - if (!is_object($perm)) { - $perm = new Contenido_Perm(); - } + if (!is_object($perm)) { + $perm = new Contenido_Perm(); + } - $aResult = array(); + $aResult = array(); - if ($bGroup == true) { - $aGroups = $perm->getGroupsForUser($this->values['user_id']); + if ($bGroup == true) { + $aGroups = $perm->getGroupsForUser($this->values['user_id']); - if (is_array($aGroups)) { - foreach ($aGroups as $iID) { - $sSQL = "SELECT name, value FROM " .$cfg['tab']['group_prop']." - WHERE group_id = '".Contenido_Security::escapeDB($iID, $this->db)."' - AND type = '".Contenido_Security::escapeDB($sType, $this->db)."'"; + if (is_array($aGroups)) { + foreach ($aGroups as $iID) { + $sSQL = "SELECT name, value FROM " . $cfg['tab']['group_prop'] . " + WHERE group_id = '" . Contenido_Security::escapeDB($iID, $this->db) . "' + AND type = '" . Contenido_Security::escapeDB($sType, $this->db) . "'"; $this->db->query($sSQL); while ($this->db->next_record()) { $aResult[$this->db->f('name')] = urldecode($this->db->f('value')); } } - } - } + } + } - $sSQL = "SELECT name, value FROM " .$cfg['tab']['user_prop']." - WHERE user_id = '".Contenido_Security::escapeDB($this->values['user_id'], $this->db)."' - AND type = '".Contenido_Security::escapeDB($sType, $this->db)."'"; + $sSQL = "SELECT name, value FROM " . $cfg['tab']['user_prop'] . " + WHERE user_id = '" . Contenido_Security::escapeDB($this->values['user_id'], $this->db) . "' + AND type = '" . Contenido_Security::escapeDB($sType, $this->db) . "'"; $this->db->query($sSQL); while ($this->db->next_record()) { @@ -491,7 +463,6 @@ class User return $aResult; } - /** * Retrieves all available properties of the user * @return array Assoziative properties list as follows: @@ -499,14 +470,13 @@ class User * - $arr[iduserprop][type] * - $arr[iduserprop][value] */ - function getUserProperties() - { + function getUserProperties() { global $cfg; $aProps = array(); - $sql = "SELECT iduserprop, type, name, value FROM " .$cfg['tab']['user_prop']." - WHERE user_id = '".Contenido_Security::escapeDB($this->values['user_id'], $this->db)."'"; + $sql = "SELECT iduserprop, type, name, value FROM " . $cfg['tab']['user_prop'] . " + WHERE user_id = '" . Contenido_Security::escapeDB($this->values['user_id'], $this->db) . "'"; $this->db->query($sql); if ($this->db->num_rows() == 0) { @@ -515,8 +485,8 @@ class User while ($this->db->next_record()) { $aProps[$this->db->f('iduserprop')] = array( - 'name' => $this->db->f('name'), - 'type' => $this->db->f('type'), + 'name' => $this->db->f('name'), + 'type' => $this->db->f('type'), 'value' => $this->db->f('value'), ); } @@ -524,65 +494,58 @@ class User return $aProps; } - /** * Stores a property to the database * @param string type Specifies the type (class, category etc) for the property to retrieve * @param string name Specifies the name of the property to retrieve * @param string value Specifies the value to insert */ - function setUserProperty($type, $name, $value) - { + function setUserProperty($type, $name, $value) { global $cfg; $value = urlencode($value); // Check if such an entry already exists - if ($this->getUserProperty($type, $name) !== false) - { - $sql = "UPDATE ".$cfg['tab']['user_prop']." - SET value = '".Contenido_Security::escapeDB($value, $this->db)."' - WHERE user_id = '".Contenido_Security::escapeDB($this->values['user_id'], $this->db)."' - AND type = '".Contenido_Security::escapeDB($type, $this->db)."' - AND name = '".Contenido_Security::escapeDB($name, $this->db)."'"; + if ($this->getUserProperty($type, $name) !== false) { + $sql = "UPDATE " . $cfg['tab']['user_prop'] . " + SET value = '" . Contenido_Security::escapeDB($value, $this->db) . "' + WHERE user_id = '" . Contenido_Security::escapeDB($this->values['user_id'], $this->db) . "' + AND type = '" . Contenido_Security::escapeDB($type, $this->db) . "' + AND name = '" . Contenido_Security::escapeDB($name, $this->db) . "'"; $this->db->query($sql); } else { - $sql = "INSERT INTO ".$cfg['tab']['user_prop']." - SET value = '".Contenido_Security::escapeDB($value, $this->db)."', - user_id = '".Contenido_Security::escapeDB($this->values['user_id'], $this->db)."', - type = '".Contenido_Security::escapeDB($type, $this->db)."', - name = '".Contenido_Security::escapeDB($name, $this->db)."', - iduserprop = '".Contenido_Security::toInteger($this->db->nextid($cfg['tab']['user_prop']))."'"; + $sql = "INSERT INTO " . $cfg['tab']['user_prop'] . " + SET value = '" . Contenido_Security::escapeDB($value, $this->db) . "', + user_id = '" . Contenido_Security::escapeDB($this->values['user_id'], $this->db) . "', + type = '" . Contenido_Security::escapeDB($type, $this->db) . "', + name = '" . Contenido_Security::escapeDB($name, $this->db) . "', + iduserprop = '" . Contenido_Security::toInteger($this->db->nextid($cfg['tab']['user_prop'])) . "'"; $this->db->query($sql); } } - /** * Deletes a user property from the table * @param string type Specifies the type (class, category etc) for the property to retrieve * @param string name Specifies the name of the property to retrieve */ - function deleteUserProperty($type, $name) - { + function deleteUserProperty($type, $name) { global $cfg; // Delete record from table - $sql = "DELETE FROM ".$cfg['tab']['user_prop']." - WHERE user_id = '".Contenido_Security::escapeDB($this->values['user_id'], $this->db)."' AND - type = '".Contenido_Security::escapeDB($type, $this->db)."' AND - name = '".Contenido_Security::escapeDB($name, $this->db)."'"; + $sql = "DELETE FROM " . $cfg['tab']['user_prop'] . " + WHERE user_id = '" . Contenido_Security::escapeDB($this->values['user_id'], $this->db) . "' AND + type = '" . Contenido_Security::escapeDB($type, $this->db) . "' AND + name = '" . Contenido_Security::escapeDB($name, $this->db) . "'"; $this->db->query($sql); } - /** * Returns all users available in the system * @param string $sort SQL sort part * @return array Array with id and name entries */ - function getAvailableUsers($sort = 'ORDER BY realname ASC') - { + function getAvailableUsers($sort = 'ORDER BY realname ASC') { global $cfg; $db = new DB_ConLite(); @@ -590,7 +553,7 @@ class User $sql = "SELECT user_id, username, realname FROM - ". $cfg['tab']['phplib_auth_user_md5']. " " . $sort; + " . $cfg['tab']['phplib_auth_user_md5'] . " " . $sort; $db->query($sql); @@ -606,14 +569,12 @@ class User return ($users); } - /** * Returns all system admins available in the system * @param boolean $forceActive Is forceActive true return only activ Sysadmins * @return array Array with id and name entries */ - function getSystemAdmins($forceActive = false) - { + function getSystemAdmins($forceActive = false) { global $cfg; $db = new DB_ConLite(); @@ -621,12 +582,12 @@ class User $sql = "SELECT user_id, username, realname, email FROM - ". $cfg['tab']['phplib_auth_user_md5'] ." + " . $cfg['tab']['phplib_auth_user_md5'] . " WHERE perms LIKE \"%sysadmin%\""; if ($forceActive === true) { - $sql.= " AND (valid_from <= NOW() OR valid_from = '0000-00-00' OR valid_from = '1000-01-01') + $sql .= " AND (valid_from <= NOW() OR valid_from = '0000-00-00' OR valid_from = '1000-01-01') AND (valid_to >= NOW() OR valid_to = '0000-00-00' OR valid_to = '1000-01-01') "; } @@ -638,21 +599,19 @@ class User $users[$db->f('user_id')] = array( 'username' => $db->f('username'), 'realname' => $db->f('realname'), - 'email' => $db->f('email'), + 'email' => $db->f('email'), ); } return ($users); } - /** * Returns all system admins available in the system * @param int $client * @return array Array with id and name entries */ - function getClientAdmins($client) - { + function getClientAdmins($client) { global $cfg; $db = new DB_ConLite(); @@ -662,9 +621,9 @@ class User $sql = "SELECT user_id, username, realname, email FROM - ". $cfg['tab']['phplib_auth_user_md5'] ." + " . $cfg['tab']['phplib_auth_user_md5'] . " WHERE - perms LIKE \"%admin[".$client."]%\""; + perms LIKE \"%admin[" . $client . "]%\""; $db->query($sql); @@ -674,21 +633,19 @@ class User $users[$db->f('user_id')] = array( 'username' => $db->f('username'), 'realname' => $db->f('realname'), - 'email' => $db->f('email'), + 'email' => $db->f('email'), ); } return ($users); } - /** * Returns the username of the given userid * @param int $userid * @return string Username if found, or emptry string if not. */ - function getUsername($userid) - { + function getUsername($userid) { global $cfg; $db = new DB_ConLite(); @@ -696,24 +653,22 @@ class User $sql = "SELECT username FROM - ". $cfg['tab']['phplib_auth_user_md5']." + " . $cfg['tab']['phplib_auth_user_md5'] . " WHERE - user_id = '".Contenido_Security::escapeDB($userid, $db)."'"; + user_id = '" . Contenido_Security::escapeDB($userid, $db) . "'"; $db->query($sql); $db->next_record(); return ($db->f('username')); } - /** * Returns the realname of the given userid * @param int $userid * @param bool $bAllowFallbackOnUsername * @return string Realname if found, or emptry string if not. */ - function getRealname($userid, $bAllowFallbackOnUsername = false) - { + function getRealname($userid, $bAllowFallbackOnUsername = false) { global $cfg; $db = new DB_ConLite(); @@ -721,9 +676,9 @@ class User $sql = "SELECT realname FROM - ". $cfg['tab']['phplib_auth_user_md5']." + " . $cfg['tab']['phplib_auth_user_md5'] . " WHERE - user_id = '".Contenido_Security::escapeDB($userid, $db)."'"; + user_id = '" . Contenido_Security::escapeDB($userid, $db) . "'"; $db->query($sql); $db->next_record(); @@ -735,14 +690,12 @@ class User } } - /** * Returns the realname of the given username * @param string $username * @return string Realname if found, or emptry string if not. */ - function getRealnameByUserName($username) - { + function getRealnameByUserName($username) { global $cfg; $db = new DB_ConLite(); @@ -750,23 +703,21 @@ class User $sql = "SELECT realname FROM - ". $cfg['tab']['phplib_auth_user_md5']." + " . $cfg['tab']['phplib_auth_user_md5'] . " WHERE - username = '".Contenido_Security::escapeDB($username, $db)."'"; + username = '" . Contenido_Security::escapeDB($username, $db) . "'"; $db->query($sql); $db->next_record(); return ($db->f('realname')); } - /** * Returns the groups a user is in * @param int $userid * @return array Real names of groups */ - function getGroupsByUserID($userid) - { + function getGroupsByUserID($userid) { global $cfg; $db = new DB_ConLite(); @@ -774,12 +725,12 @@ class User $sql = "SELECT a.group_id FROM - ".$cfg['tab']['groups']." AS a, - ".$cfg['tab']['groupmembers']." AS b + " . $cfg['tab']['groups'] . " AS a, + " . $cfg['tab']['groupmembers'] . " AS b WHERE (a.group_id = b.group_id) AND - (b.user_id = '".Contenido_Security::escapeDB($userid, $db)."') + (b.user_id = '" . Contenido_Security::escapeDB($userid, $db) . "') "; $db->query($sql); @@ -796,7 +747,7 @@ class User $sDescription = trim($oGroup->getField('description')); if ($sDescription != '') { - $sTemp.=' ('.$sDescription.')'; + $sTemp .= ' (' . $sDescription . ')'; } $arrGroups[] = $sTemp; @@ -804,14 +755,12 @@ class User return $arrGroups; } - /** * Returns the groups a user is in * @param int $userid * @return array Ids of groups */ - function getGroupIDsByUserID($userid) - { + function getGroupIDsByUserID($userid) { global $cfg; $db = new DB_ConLite(); @@ -819,12 +768,12 @@ class User $sql = "SELECT a.group_id FROM - ".$cfg['tab']['groups']." AS a, - ".$cfg['tab']['groupmembers']." AS b + " . $cfg['tab']['groups'] . " AS a, + " . $cfg['tab']['groupmembers'] . " AS b WHERE (a.group_id = b.group_id) AND - (b.user_id = '".Contenido_Security::escapeDB($userid, $db)."') + (b.user_id = '" . Contenido_Security::escapeDB($userid, $db) . "') "; $db->query($sql); @@ -838,5 +787,3 @@ class User } } - -?> \ No newline at end of file diff --git a/trunk/conlite/classes/class.wysiwyg_editor.php b/trunk/conlite/classes/class.wysiwyg_editor.php index a51fe3f..ef1e537 100644 --- a/trunk/conlite/classes/class.wysiwyg_editor.php +++ b/trunk/conlite/classes/class.wysiwyg_editor.php @@ -41,7 +41,7 @@ class cWYSIWYGEditor var $_sEditorContent; var $_aSettings; - function cWYSIWYGEditor ($sEditorName, $sEditorContent) + function __construct ($sEditorName, $sEditorContent) { global $cfg; diff --git a/trunk/conlite/classes/class.xml.php b/trunk/conlite/classes/class.xml.php index af67635..b6b1471 100644 --- a/trunk/conlite/classes/class.xml.php +++ b/trunk/conlite/classes/class.xml.php @@ -83,7 +83,7 @@ class XML_doc { /** * Class Construcor */ - function XML_doc() { + function __construct() { global $encoding, $lang; $this->sys_encoding = $encoding[$lang]; diff --git a/trunk/conlite/classes/class.xmlparser.php b/trunk/conlite/classes/class.xmlparser.php index 5ad9126..5060cb1 100644 --- a/trunk/conlite/classes/class.xmlparser.php +++ b/trunk/conlite/classes/class.xmlparser.php @@ -1,4 +1,5 @@ * @version 1.0 */ -class XmlParser -{ - /** +class XmlParser { + + /** * XML Parser autofree - * + * * @var bool */ - var $autofree = true; - + var $autofree = true; + /** * XML Parser object - * + * * @var object - * @access private + * @access private */ - var $parser; + var $parser; /** * Error message - * + * * @var string - * @access private + * @access private */ - var $error = ''; + var $error = ''; /** * Element depth * @var int - * @access private + * @access private */ - var $depth = -1; - - /** - * Element counter - * @var int - * @access private - */ - var $count = 0; - - /** - * Path counter - * @var int - * @access private - */ - var $pcount = 0; - - /** - * Array for creating the path - * @var array - * @access private - */ - var $paths = array(); - - /** - * Data storage container for the path data - * @var array - * @access private - */ - var $pathdata = array(); - - /** - * String storing the active path - * @var string - * @access private - */ - var $activepath = ''; - - /** - * The active node - * @var string - * @access private - */ - var $activenode = ''; - - /** - * The defined events - * @var array - * @access private - */ - var $events = array(); - - /** - * Constructor function - * - * @access private - * @param string $sEncoding Encoding used when parsing files (default: UTF-8, as in PHP5) - * @return void - */ - function XmlParser($sEncoding = false) - { - if (!$sEncoding) - { - $sEncoding = "UTF-8"; - } - - $this->_init($sEncoding); - } + var $depth = -1; + + /** + * Element counter + * @var int + * @access private + */ + var $count = 0; + + /** + * Path counter + * @var int + * @access private + */ + var $pcount = 0; + + /** + * Array for creating the path + * @var array + * @access private + */ + var $paths = array(); + + /** + * Data storage container for the path data + * @var array + * @access private + */ + var $pathdata = array(); + + /** + * String storing the active path + * @var string + * @access private + */ + var $activepath = ''; + + /** + * The active node + * @var string + * @access private + */ + var $activenode = ''; + + /** + * The defined events + * @var array + * @access private + */ + var $events = array(); + + /** + * Constructor function + * + * @access private + * @param string $sEncoding Encoding used when parsing files (default: UTF-8, as in PHP5) + * @return void + */ + function __construct($sEncoding = false) { + if (!$sEncoding) { + $sEncoding = "UTF-8"; + } + + $this->_init($sEncoding); + } /** * Initialize the XML Parser object and sets all options * * @access private - * @param string $sEncoding Encoding used when parsing files (default: UTF-8, as in PHP5) + * @param string $sEncoding Encoding used when parsing files (default: UTF-8, as in PHP5) * @return void */ - function _init($sEncoding = false) - { - if (!$sEncoding) - { - $sEncoding = "UTF-8"; - } - // Create parser instance + function _init($sEncoding = false) { + if (!$sEncoding) { + $sEncoding = "UTF-8"; + } + // Create parser instance $this->parser = xml_parser_create($sEncoding); - + // Set parser options xml_set_object($this->parser, $this); - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false); - xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $sEncoding); - - xml_set_element_handler($this->parser, '_startElement', '_endElement'); + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false); + xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $sEncoding); + + xml_set_element_handler($this->parser, '_startElement', '_endElement'); xml_set_character_data_handler($this->parser, '_characterData'); xml_set_processing_instruction_handler($this->parser, '_processingInstruction'); - - // Misc stuff - $this->events['paths'] = array(NULL); - } - /** - * Returns the XML error message - * - * @return string XML Error message - * @access private - */ - function _error() - { - $this->error = "XML error: ".xml_error_string(xml_get_error_code($this->parser))." at line ".xml_get_current_line_number($this->parser); - return $this->error; - } - - /** - * Define events for the XML parser - * - * You can define handler functions/objects for start, end, PI and data sections (1.) or - * your can define path which will trigger the defined event when encountered (2.) - * - * Example: - * - * 1.) $parser->setEvents(array("startElement" => "myFunction", - * "endElement" => "myFunction", - * "characterData" => "myFunction", - * "processingInstruction" => "myFunction"); - * - * The value can also be an array with the object reference and the method to call. - * i.e. "startElement"=>array(&$myObj, "myMethod") instead of "startelement"=>"myFunction" - * - * 2.) $parser->setEvents(array("/root/foo/bar"=>"myFunction")); - * - * Valid array keys are: 'startElement', 'endElement', 'characterData', 'processingInstruction' and paths - * folowing the scheme '/root/element'. The path MUST begin from the root element and MUST start with '/'. - * - * The value can also be an array with the object reference and the method to call. - * i.e. "/foo/bar"=>array(&$myObj, "myMethod") instead of "/foo/bar"=>"myFunction" - * - * @param array Options array, valid keys are 'startElement', 'endElement', 'characterData', 'processingInstruction', or a path - * - * @access public - * @return void - */ - function setEventHandlers($options = array(NULL)) - { - $options = $this->_changeKeyCase($options); - - if (array_key_exists('startelement', $options)) - { - $this->events['startelement'] = $options['startelement']; - } - - if (array_key_exists('endelement', $options)) - { - $this->events['endelement'] = $options['endelement']; - } - - if (array_key_exists('characterdata', $options)) - { - $this->events['characterdata'] = $options['characterdata']; - } - - if (array_key_exists('processinginstruction', $options)) - { - $this->events['processinginstruction'] = $options['processinginstruction']; - } - - $paths = $this->_getDefinedPaths($options); - - $this->events['paths'] = $paths; - } - - /** - * Set the processing instruction handler - * - * @param string Processing instruction handler - * - * @return void - * @access private - */ - function _processingInstruction($parser, $target, $data) - { - $handler = $this->_getEventHandler('processinginstruction'); - - if ($handler) - { - if (is_array($handler)) - { - $handler[0]->$handler[1]($target, $data); - } else - { - $handler($target, $data); - } - } - } - - /** - * Change all array keys to lowercase - * (PHP function change_key_case is available at PHP 4.2 +) - * - * @param array Source array - * - * @return array Array with lowercased keys - * @access private - */ - function _changeKeyCase($options = array()) - { - $tmp = array(); - - foreach ($options as $key => $value) - { - $tmp[strtolower($key)] = $value; - } - - return $tmp; - } - - /** - * Returns events handlers if set - * - * @param string Event type - * - * @return sring Event handler name - * @access private - */ - function _getEventHandler($event) - { - // Standard events - if (array_key_exists($event, $this->events)) - { - return $this->events[$event]; - } - - // Paths events - if (array_key_exists($event, $this->events['paths'])) - { - return $this->events['paths'][$event]; - } - - // No events found - return false; - } - - /** - * Return all defined paths from the options - * array and returns a new array containing - * only the paths to function bindings - * - * @param array Options array - * - * @return array Paths array - * @access private - */ - function _getDefinedPaths($options) - { - $tmp = array(); - - foreach ($options as $key => $value) - { - if (strstr($key, '/')) - { - $tmp[$key] = $value; - } - } - - return $tmp; - } - - /** - * Add a path to the stack - * - * @param string Element node name - * @access private - * @return void - */ - function _addPath($depth, $name) - { - $this->paths[$depth] = $name; - } - - /** - * Returns the current active path - * - * @access private - */ - function _getActivePath() - { - $tmp = array(); - - for ($i=0; $i<=$this->depth; $i++) - { - $tmp[] = $this->paths[$i]; - } - - $path = '/' . join('/', $tmp); - return $path; - } - - /** + // Misc stuff + $this->events['paths'] = array(NULL); + } + + /** + * Returns the XML error message + * + * @return string XML Error message + * @access private + */ + function _error() { + $this->error = "XML error: " . xml_error_string(xml_get_error_code($this->parser)) . " at line " . xml_get_current_line_number($this->parser); + return $this->error; + } + + /** + * Define events for the XML parser + * + * You can define handler functions/objects for start, end, PI and data sections (1.) or + * your can define path which will trigger the defined event when encountered (2.) + * + * Example: + * + * 1.) $parser->setEvents(array("startElement" => "myFunction", + * "endElement" => "myFunction", + * "characterData" => "myFunction", + * "processingInstruction" => "myFunction"); + * + * The value can also be an array with the object reference and the method to call. + * i.e. "startElement"=>array(&$myObj, "myMethod") instead of "startelement"=>"myFunction" + * + * 2.) $parser->setEvents(array("/root/foo/bar"=>"myFunction")); + * + * Valid array keys are: 'startElement', 'endElement', 'characterData', 'processingInstruction' and paths + * folowing the scheme '/root/element'. The path MUST begin from the root element and MUST start with '/'. + * + * The value can also be an array with the object reference and the method to call. + * i.e. "/foo/bar"=>array(&$myObj, "myMethod") instead of "/foo/bar"=>"myFunction" + * + * @param array Options array, valid keys are 'startElement', 'endElement', 'characterData', 'processingInstruction', or a path + * + * @access public + * @return void + */ + function setEventHandlers($options = array(NULL)) { + $options = $this->_changeKeyCase($options); + + if (array_key_exists('startelement', $options)) { + $this->events['startelement'] = $options['startelement']; + } + + if (array_key_exists('endelement', $options)) { + $this->events['endelement'] = $options['endelement']; + } + + if (array_key_exists('characterdata', $options)) { + $this->events['characterdata'] = $options['characterdata']; + } + + if (array_key_exists('processinginstruction', $options)) { + $this->events['processinginstruction'] = $options['processinginstruction']; + } + + $paths = $this->_getDefinedPaths($options); + + $this->events['paths'] = $paths; + } + + /** + * Set the processing instruction handler + * + * @param string Processing instruction handler + * + * @return void + * @access private + */ + function _processingInstruction($parser, $target, $data) { + $handler = $this->_getEventHandler('processinginstruction'); + + if ($handler) { + if (is_array($handler)) { + $handler[0]->$handler[1]($target, $data); + } else { + $handler($target, $data); + } + } + } + + /** + * Change all array keys to lowercase + * (PHP function change_key_case is available at PHP 4.2 +) + * + * @param array Source array + * + * @return array Array with lowercased keys + * @access private + */ + function _changeKeyCase($options = array()) { + $tmp = array(); + + foreach ($options as $key => $value) { + $tmp[strtolower($key)] = $value; + } + + return $tmp; + } + + /** + * Returns events handlers if set + * + * @param string Event type + * + * @return sring Event handler name + * @access private + */ + function _getEventHandler($event) { + // Standard events + if (array_key_exists($event, $this->events)) { + return $this->events[$event]; + } + + // Paths events + if (array_key_exists($event, $this->events['paths'])) { + return $this->events['paths'][$event]; + } + + // No events found + return false; + } + + /** + * Return all defined paths from the options + * array and returns a new array containing + * only the paths to function bindings + * + * @param array Options array + * + * @return array Paths array + * @access private + */ + function _getDefinedPaths($options) { + $tmp = array(); + + foreach ($options as $key => $value) { + if (strstr($key, '/')) { + $tmp[$key] = $value; + } + } + + return $tmp; + } + + /** + * Add a path to the stack + * + * @param string Element node name + * @access private + * @return void + */ + function _addPath($depth, $name) { + $this->paths[$depth] = $name; + } + + /** + * Returns the current active path + * + * @access private + */ + function _getActivePath() { + $tmp = array(); + + for ($i = 0; $i <= $this->depth; $i++) { + $tmp[] = $this->paths[$i]; + } + + $path = '/' . join('/', $tmp); + return $path; + } + + /** * XML start element handler * * @param resource XML Parser resource * @param string XML Element node name * @param array XML Element node attributes - * + * * @return void - * @access private + * @access private */ - function _startElement($parser, $name, $attribs) - { - // Increase depth - $this->depth ++; - - // Set active node - $this->activenode = $name; - - // Increase element counter - if ($this->activenode == $this->pathdata[$this->activepath][$this->count]['name']) - { - $this->count ++; - } else - { - $this->count = 0; - } - - // Entering element context, add subpath - $this->_addPath($this->depth, $name); - - // Get the handler for this event - $handler = $this->_getEventHandler('startelement'); - - // If a handler is defined call it - if ($handler) - { - if (is_array($handler)) - { - $handler[0]->$handler[1]($name, $attribs); - } else - { - $handler($name, $attribs); - } - } - - // Check for defined path handlers - $this->activepath = $this->_getActivePath(); - - // Save path data - $this->pathdata[$this->activepath][$this->count] = array('name'=>$name, 'attribs'=>$attribs); - } - - /** - * XML character data handler - * - * @param resource XML Parser resource - * @param string XML node data - * - * @return void - * @access private - */ - function _characterData($parser, $data) - { - // Reset node count - if ($this->activenode != $this->pathdata[$this->activepath][$this->count]['name']) - { - $this->count = 0; - } - - // Save path data - $this->pathdata[$this->activepath][$this->count]['content'] .= $data; - - // Get the handler for this event - $handler = $this->_getEventHandler('characterdata'); - - // If a handler is defined call it - if ($handler) - { - if (is_array($handler)) - { - $handler[0]->$handler[1]($data); - } else - { - $handler($data); - } - } - } - - /** - * XML end element handler - * - * @param resource XML Parser resource - * @param string XML Element node name - * - * @return void - * @access private - */ - function _endElement($parser, $name) - { - // Get the handler for this event - $handler = $this->_getEventHandler('endelement'); - - // Call Element handler - if ($handler) - { - if (is_array($handler)) - { - $handler[0]->$handler[1]($name); - } else - { - $handler($name); - } - } - - // Reset the active path - $this->activepath = $this->_getActivePath(); - - // Get handler for the active path - $handler = $this->_getEventHandler($this->activepath); - - // Call path handler - if ($handler) - { - if (is_array($handler)) - { // Handler is an object method - $handler[0]->$handler[1]($this->pathdata[$this->activepath][$this->count]['name'], - $this->pathdata[$this->activepath][$this->count]['attribs'], - $this->pathdata[$this->activepath][$this->count]['content']); - } else - { // Handler is a function - $handler($this->pathdata[$this->activepath][$this->count]['name'], - $this->pathdata[$this->activepath][$this->count]['attribs'], - $this->pathdata[$this->activepath][$this->count]['content']); - } - } - - // Decrease depth - $this->depth --; - } - - /** - * Parse a XML string - * - * @param string XML data - * - * @return bool - * @access public - */ - function parse($data, $final = false) - { - $success = xml_parse($this->parser, trim($data), $final); - - if ($final && $this->autofree) - { - xml_parser_free($this->parser); - } - - if (!$success) - { - return $this->_error(); - } - - return $success; - } + function _startElement($parser, $name, $attribs) { + // Increase depth + $this->depth ++; - /** - * Parse a XML file - * - * @param string File location - * - * @return bool - * @access public - */ - function parseFile($file) - { - if (!($fp = fopen($file, "rb"))) - { - - } - - while ($sData = fread($fp, 4096)) - { - if (!xml_parse($this->parser, $sData, feof($fp))) - { - $this->_error(); - return false; - } - } - - if ($this->autofree) - { - xml_parser_free($this->parser); - } - - return true; - } + // Set active node + $this->activenode = $name; -} // XML_Parser + // Increase element counter + if ($this->activenode == $this->pathdata[$this->activepath][$this->count]['name']) { + $this->count ++; + } else { + $this->count = 0; + } + // Entering element context, add subpath + $this->_addPath($this->depth, $name); + + // Get the handler for this event + $handler = $this->_getEventHandler('startelement'); + + // If a handler is defined call it + if ($handler) { + if (is_array($handler)) { + $handler[0]->$handler[1]($name, $attribs); + } else { + $handler($name, $attribs); + } + } + + // Check for defined path handlers + $this->activepath = $this->_getActivePath(); + + // Save path data + $this->pathdata[$this->activepath][$this->count] = array('name' => $name, 'attribs' => $attribs); + } + + /** + * XML character data handler + * + * @param resource XML Parser resource + * @param string XML node data + * + * @return void + * @access private + */ + function _characterData($parser, $data) { + // Reset node count + if ($this->activenode != $this->pathdata[$this->activepath][$this->count]['name']) { + $this->count = 0; + } + + // Save path data + $this->pathdata[$this->activepath][$this->count]['content'] .= $data; + + // Get the handler for this event + $handler = $this->_getEventHandler('characterdata'); + + // If a handler is defined call it + if ($handler) { + if (is_array($handler)) { + $handler[0]->$handler[1]($data); + } else { + $handler($data); + } + } + } + + /** + * XML end element handler + * + * @param resource XML Parser resource + * @param string XML Element node name + * + * @return void + * @access private + */ + function _endElement($parser, $name) { + // Get the handler for this event + $handler = $this->_getEventHandler('endelement'); + + // Call Element handler + if ($handler) { + if (is_array($handler)) { + $handler[0]->$handler[1]($name); + } else { + $handler($name); + } + } + + // Reset the active path + $this->activepath = $this->_getActivePath(); + + // Get handler for the active path + $handler = $this->_getEventHandler($this->activepath); + + // Call path handler + if ($handler) { + if (is_array($handler)) { // Handler is an object method + $handler[0]->$handler[1]($this->pathdata[$this->activepath][$this->count]['name'], + $this->pathdata[$this->activepath][$this->count]['attribs'], + $this->pathdata[$this->activepath][$this->count]['content']); + } else { // Handler is a function + $handler($this->pathdata[$this->activepath][$this->count]['name'], + $this->pathdata[$this->activepath][$this->count]['attribs'], + $this->pathdata[$this->activepath][$this->count]['content']); + } + } + + // Decrease depth + $this->depth --; + } + + /** + * Parse a XML string + * + * @param string XML data + * + * @return bool + * @access public + */ + function parse($data, $final = false) { + $success = xml_parse($this->parser, trim($data), $final); + + if ($final && $this->autofree) { + xml_parser_free($this->parser); + } + + if (!$success) { + return $this->_error(); + } + + return $success; + } + + /** + * Parse a XML file + * + * @param string File location + * + * @return bool + * @access public + */ + function parseFile($file) { + if (!($fp = fopen($file, "rb"))) { + + } + + while ($sData = fread($fp, 4096)) { + if (!xml_parse($this->parser, $sData, feof($fp))) { + $this->_error(); + return false; + } + } + + if ($this->autofree) { + xml_parser_free($this->parser); + } + + return true; + } + +} + +// XML_Parser ?> \ No newline at end of file diff --git a/trunk/conlite/classes/class.xmltree.php b/trunk/conlite/classes/class.xmltree.php index fe3a475..0ee5990 100644 --- a/trunk/conlite/classes/class.xmltree.php +++ b/trunk/conlite/classes/class.xmltree.php @@ -1,4 +1,5 @@ = 5.3 and causes a deprecated runtime error * don't use it any more (Ortwin Pinke, 2010-07-03 -* -* $tree = new XmlTree('1.0', 'ISO-8859-1'); -* $root =& $tree->addRoot('rootname', 'some content', array('foo'=>'bar')); -* -* This genererates following XML: -* -* -* some content -* -* $root now references the 'rootname' node object. -* To append childNodes use the appendChild method. -* -* $foo =& $root->appendChild('foo', 'bar'); -* -* Note: From version 1.1 you can use the $obj->add() method -* as shortcut to appendchild -* -* -* some contentbar -* -* !! ALWAYS use '=&' with the addRoot and appendChild methods. !! -* -*/ -class XmlTree -{ - /** - * XML Version string - * @var string - * @access private - */ - var $_strXmlVersion; - - /** - * XML Encoding string - * @var string - * @access private - */ - var $_strXmlEncoding; - - /** - * Root element name - * @var string - * @access private - */ - var $_strRootName; - - /** - * Root content - * @var string - * @access private - */ - var $_strRootContent; - - /** - * Root attributes - * @var array - * @access private - */ - var $_strRootAttribs; - - /** - * Root node - * @var object - * @access private - */ - var $_objRoot; - - /** - * Tree XML string - * @var string - * @access private - */ - var $_strXml; - - /** - * Indent character - * @var string - * @access private - */ - var $_indentChar = ""; - - /** - * Constructor - * - * @param string XML Version i.e. "1.0" - * @param string XML Encoding i.e. "UTF-8" - * - * @return void - */ - function XmlTree($strXmlVersion = '1.0', $strXmlEncoding = 'UTF-8') - { - $this->_strXmlVersion = 'version="'.$strXmlVersion.'"'; - $this->_strXmlEncoding = 'encoding="'.$strXmlEncoding.'"'; - } - - /** - * Add a Root element to the XML Tree - * - * @param string XML Node Name - * @param string XML Node Content - * @param array Attributes array('name'=>'value') - * - * @return object Reference to the root node object - */ - function &addRoot($strNodeName, $strNodeContent = '', $arrNodeAttribs = array()) - { - if (!$strNodeName) - { - return 'XmlTree::addRoot() -> No node name specified'; - } - - $this->_objRoot = new XmlNode($strNodeName, $strNodeContent, $arrNodeAttribs); - return $this->_objRoot; - } - - /** - * Print or Return Tree XML - * - * @param boolean Return content - * - * @return string Tree XML - */ - function dump($bolReturn = false) - { - if (!is_object($this->_objRoot)) - { - return 'XmlTree::dump() -> There is no root node'; - } - - $this->_objRoot->setIndent($this->_indentChar); - $this->_strXml = sprintf("\n", $this->_strXmlVersion, $this->_strXmlEncoding); - $this->_strXml .= $this->_objRoot->toXml(); - - if ($bolReturn) - { - return $this->_strXml; - } - - echo $this->_strXml; - } - - /** - * Set the indent string - * @param int level - * @return void - */ - function setIndent($string) - { - $this->_indentChar = $string; - } - -} // XmlTree + * + * $tree = new XmlTree('1.0', 'ISO-8859-1'); + * $root =& $tree->addRoot('rootname', 'some content', array('foo'=>'bar')); + * + * This genererates following XML: + * + * + * some content + * + * $root now references the 'rootname' node object. + * To append childNodes use the appendChild method. + * + * $foo =& $root->appendChild('foo', 'bar'); + * + * Note: From version 1.1 you can use the $obj->add() method + * as shortcut to appendchild + * + * + * some contentbar + * + * !! ALWAYS use '=&' with the addRoot and appendChild methods. !! + * + */ +class XmlTree { + + /** + * XML Version string + * @var string + * @access private + */ + var $_strXmlVersion; + + /** + * XML Encoding string + * @var string + * @access private + */ + var $_strXmlEncoding; + + /** + * Root element name + * @var string + * @access private + */ + var $_strRootName; + + /** + * Root content + * @var string + * @access private + */ + var $_strRootContent; + + /** + * Root attributes + * @var array + * @access private + */ + var $_strRootAttribs; + + /** + * Root node + * @var object + * @access private + */ + var $_objRoot; + + /** + * Tree XML string + * @var string + * @access private + */ + var $_strXml; + + /** + * Indent character + * @var string + * @access private + */ + var $_indentChar = ""; + + /** + * Constructor + * + * @param string XML Version i.e. "1.0" + * @param string XML Encoding i.e. "UTF-8" + * + * @return void + */ + function __construct($strXmlVersion = '1.0', $strXmlEncoding = 'UTF-8') { + $this->_strXmlVersion = 'version="' . $strXmlVersion . '"'; + $this->_strXmlEncoding = 'encoding="' . $strXmlEncoding . '"'; + } + + /** + * Add a Root element to the XML Tree + * + * @param string XML Node Name + * @param string XML Node Content + * @param array Attributes array('name'=>'value') + * + * @return object Reference to the root node object + */ + function &addRoot($strNodeName, $strNodeContent = '', $arrNodeAttribs = array()) { + if (!$strNodeName) { + return 'XmlTree::addRoot() -> No node name specified'; + } + + $this->_objRoot = new XmlNode($strNodeName, $strNodeContent, $arrNodeAttribs); + return $this->_objRoot; + } + + /** + * Print or Return Tree XML + * + * @param boolean Return content + * + * @return string Tree XML + */ + function dump($bolReturn = false) { + if (!is_object($this->_objRoot)) { + return 'XmlTree::dump() -> There is no root node'; + } + + $this->_objRoot->setIndent($this->_indentChar); + $this->_strXml = sprintf("\n", $this->_strXmlVersion, $this->_strXmlEncoding); + $this->_strXml .= $this->_objRoot->toXml(); + + if ($bolReturn) { + return $this->_strXml; + } + + echo $this->_strXml; + } + + /** + * Set the indent string + * @param int level + * @return void + */ + function setIndent($string) { + $this->_indentChar = $string; + } + +} + +// XmlTree /** -* XmlNode Object -* -* Object of a XML Tree Node -* -* @see XmlTree -* -* !! ALWAYS use '=&' with the addRoot and appendChild methods. !! -* -*/ -class XmlNode -{ - /** - * Indenting character - * @var string - */ - var $_indentChar; - - /** - * Node name - * @var string - * @access private - */ - var $_strNodeName; - - /** - * Node content - * @var string - * @access private - */ - var $_strNodeContent; - - /** - * Added content - * @var string - * @access private - */ - var $_strNodeContentAdded; - - /** - * Node attributes - * @var array - * @access private - */ - var $_arrNodeAttribs; - - /** - * Enclose node content in a cdata section - * @var boolean - * @access private - */ - var $_cdata; - - /** - * XML for this node - * @var string - * @access private - */ - var $_strXml; - - /** - * Child count - * @var int - * @access private - */ - var $_intChildCount = 0; - - /** - * Parent Node - * @var object - */ - var $parentNode = 0; - - /** - * Childnodes - * @var array - * @access private - */ - var $childNodes = array(); - - /** - * Class Constructor - * - * @param string XML Node Name - * @param string XML Node Content - * @param array Attributes array('name'=>'value') - * - * @return void - */ - function XmlNode($strNodeName, $strNodeContent = '', $arrNodeAttribs = array(), $cdata = false) - { - if (!$strNodeName) - { - return $this->_throwError($this, '%s::Construtctor() : No node name specified.'); - } - - $this->_cdata = $cdata; - - $this->setNodeName($strNodeName); - $this->setNodeContent($strNodeContent); - $this->setNodeAttribs($arrNodeAttribs); - } - - /** - * Set a node name - * - * @param string Node name - * - * @return void - */ - function setNodeName($strNodeName) - { - $this->_strNodeName = $strNodeName; - } - - /** - * Set node content - * - * @param string Node content - * - * @return void - */ - function setNodeContent($strNodeContent) - { - $this->_strNodeContent = $strNodeContent; - } - - /** - * Set the node attributes - * - * @param array Node attributes array('name'=>'value') - * - * @return void - */ - function setNodeAttribs($arrNodeAttribs) - { - $this->_arrNodeAttribs = $arrNodeAttribs; - } - - /** - * Set the node parent - * - * @param object Reference to the parent object - * - * @return void - */ - function setNodeParent(&$objParent) - { - $this->parentNode = $objParent; - } - - /** - * Add content to the node - * - * @param string Content - * - * @return void - */ - function addNodeContent($strNodeContent) - { - $this->_strNodeContentAdded = $strNodeContent; - } - - /** - * Check if the node has childs - * - * @return boolean - */ - function hasChilds() - { - return ($this->_intChildCount > 0) ? true : false; - } - - /** - * Add a child child node - * - * @param string XML Node Name - * @param string XML Node Content - * @param array Attributes array('name'=>'value') - * @param bool CDATA Section - * - * @return object Reference to the new node object - */ - function &appendChild($strNodeName, $strNodeContent = '', $arrNodeAttribs = array(), $cdata = false) - { - if (!$strNodeName) - { - return $this->_throwError($this, '%s::appendChild() : No node name specified'); - } - - $pos = $this->_intChildCount ++; - - $this->childNodes[$pos] = new XmlNode($strNodeName, $strNodeContent, $arrNodeAttribs, $cdata); - $this->childNodes[$pos]->setNodeParent($this); - - return $this->childNodes[$pos]; - } - - /** - * Short for appendChild method - * - * @see appendChild - */ - function &add($strNodeName, $strNodeContent = '', $arrNodeAttribs = array(), $cdata = false) - { - return $this->appendChild($strNodeName, $strNodeContent , $arrNodeAttribs , $cdata); - } - - /** - * Builds the XML string for the node using the - * node properties - * - * @return string XML String - * @access private - */ - function toXml($indent = 0) - { - // Indent for nodes markub - $sp = $this->_getIndent($indent); - - // Indent for content - $csp = $this->_getIndent($indent ++); - - // Increment indent - //$indent ++; - - $this->_strXml = "$sp<".$this->_strNodeName.$this->_parseAttributes($this->_arrNodeAttribs); - - $maxNodes = count($this->childNodes); - - if ($this->_strNodeContent != '' || $this->_strNodeContentAdded != '' || $maxNodes > 0) - { - $this->_strXml .= ">"; - - if ($this->_cdata) - { - $this->_strXml .= "$csp_strNodeContent . $this->_strNodeContentAdded; - $this->_strXml .= $content; - - } else { - $content = $this->_strNodeContent . $this->_strNodeContentAdded; - $this->_strXml .= ($content != "") ? "$content" : $content; - } - - if ($this->_cdata) - { - $this->_strXml .= " ]]>"; - } - - for ($i=0; $i<$maxNodes; $i++) - { - $this->childNodes[$i]->setIndent($this->_indentChar); - $this->_strXml .= $this->childNodes[$i]->toXml($indent); - } - - $this->_strXml .= "$sp_strNodeName . ">\n"; - - } else - { - $this->_strXml .= "/>\n"; - } - - return $this->_strXml; - } - - /** - * Builds a string from the attributes array - * - * @param array Attributes array('name'=>'value') - * - * @return string Attribute string - * @access private - */ - function _parseAttributes($arrAttributes = array()) - { - $strAttributes = ''; - - if (is_array($arrAttributes)) - { - foreach ($arrAttributes as $name => $value) - { - $strAttributes .= ' '.$name.'="'.$value.'"'; - } - } - - return $strAttributes; - } - - /** - * Get indent string - * @param int level - * @return string indent string - */ - function _getIndent($level) - { - return $this->_strXml .= str_repeat($this->_indentChar, $level); - } - - /** - * Set the indent string - * @param int level - * @return void - */ - function setIndent($string = "") - { - $this->_indentChar = $string; - } - -} // XmlNode + * XmlNode Object + * + * Object of a XML Tree Node + * + * @see XmlTree + * + * !! ALWAYS use '=&' with the addRoot and appendChild methods. !! + * + */ +class XmlNode { -?> \ No newline at end of file + /** + * Indenting character + * @var string + */ + var $_indentChar; + + /** + * Node name + * @var string + * @access private + */ + var $_strNodeName; + + /** + * Node content + * @var string + * @access private + */ + var $_strNodeContent; + + /** + * Added content + * @var string + * @access private + */ + var $_strNodeContentAdded; + + /** + * Node attributes + * @var array + * @access private + */ + var $_arrNodeAttribs; + + /** + * Enclose node content in a cdata section + * @var boolean + * @access private + */ + var $_cdata; + + /** + * XML for this node + * @var string + * @access private + */ + var $_strXml; + + /** + * Child count + * @var int + * @access private + */ + var $_intChildCount = 0; + + /** + * Parent Node + * @var object + */ + var $parentNode = 0; + + /** + * Childnodes + * @var array + * @access private + */ + var $childNodes = array(); + + /** + * Class Constructor + * + * @param string XML Node Name + * @param string XML Node Content + * @param array Attributes array('name'=>'value') + * + * @return void + */ + function __construct($strNodeName, $strNodeContent = '', $arrNodeAttribs = array(), $cdata = false) { + if (!$strNodeName) { + return $this->_throwError($this, '%s::Construtctor() : No node name specified.'); + } + + $this->_cdata = $cdata; + + $this->setNodeName($strNodeName); + $this->setNodeContent($strNodeContent); + $this->setNodeAttribs($arrNodeAttribs); + } + + /** + * Set a node name + * + * @param string Node name + * + * @return void + */ + function setNodeName($strNodeName) { + $this->_strNodeName = $strNodeName; + } + + /** + * Set node content + * + * @param string Node content + * + * @return void + */ + function setNodeContent($strNodeContent) { + $this->_strNodeContent = $strNodeContent; + } + + /** + * Set the node attributes + * + * @param array Node attributes array('name'=>'value') + * + * @return void + */ + function setNodeAttribs($arrNodeAttribs) { + $this->_arrNodeAttribs = $arrNodeAttribs; + } + + /** + * Set the node parent + * + * @param object Reference to the parent object + * + * @return void + */ + function setNodeParent(&$objParent) { + $this->parentNode = $objParent; + } + + /** + * Add content to the node + * + * @param string Content + * + * @return void + */ + function addNodeContent($strNodeContent) { + $this->_strNodeContentAdded = $strNodeContent; + } + + /** + * Check if the node has childs + * + * @return boolean + */ + function hasChilds() { + return ($this->_intChildCount > 0) ? true : false; + } + + /** + * Add a child child node + * + * @param string XML Node Name + * @param string XML Node Content + * @param array Attributes array('name'=>'value') + * @param bool CDATA Section + * + * @return object Reference to the new node object + */ + function &appendChild($strNodeName, $strNodeContent = '', $arrNodeAttribs = array(), $cdata = false) { + if (!$strNodeName) { + return $this->_throwError($this, '%s::appendChild() : No node name specified'); + } + + $pos = $this->_intChildCount ++; + + $this->childNodes[$pos] = new XmlNode($strNodeName, $strNodeContent, $arrNodeAttribs, $cdata); + $this->childNodes[$pos]->setNodeParent($this); + + return $this->childNodes[$pos]; + } + + /** + * Short for appendChild method + * + * @see appendChild + */ + function &add($strNodeName, $strNodeContent = '', $arrNodeAttribs = array(), $cdata = false) { + return $this->appendChild($strNodeName, $strNodeContent, $arrNodeAttribs, $cdata); + } + + /** + * Builds the XML string for the node using the + * node properties + * + * @return string XML String + * @access private + */ + function toXml($indent = 0) { + // Indent for nodes markub + $sp = $this->_getIndent($indent); + + // Indent for content + $csp = $this->_getIndent($indent ++); + + // Increment indent + //$indent ++; + + $this->_strXml = "$sp<" . $this->_strNodeName . $this->_parseAttributes($this->_arrNodeAttribs); + + $maxNodes = count($this->childNodes); + + if ($this->_strNodeContent != '' || $this->_strNodeContentAdded != '' || $maxNodes > 0) { + $this->_strXml .= ">"; + + if ($this->_cdata) { + $this->_strXml .= "$csp_strNodeContent . $this->_strNodeContentAdded; + $this->_strXml .= $content; + } else { + $content = $this->_strNodeContent . $this->_strNodeContentAdded; + $this->_strXml .= ($content != "") ? "$content" : $content; + } + + if ($this->_cdata) { + $this->_strXml .= " ]]>"; + } + + for ($i = 0; $i < $maxNodes; $i++) { + $this->childNodes[$i]->setIndent($this->_indentChar); + $this->_strXml .= $this->childNodes[$i]->toXml($indent); + } + + $this->_strXml .= "$sp_strNodeName . ">\n"; + } else { + $this->_strXml .= "/>\n"; + } + + return $this->_strXml; + } + + /** + * Builds a string from the attributes array + * + * @param array Attributes array('name'=>'value') + * + * @return string Attribute string + * @access private + */ + function _parseAttributes($arrAttributes = array()) { + $strAttributes = ''; + + if (is_array($arrAttributes)) { + foreach ($arrAttributes as $name => $value) { + $strAttributes .= ' ' . $name . '="' . $value . '"'; + } + } + + return $strAttributes; + } + + /** + * Get indent string + * @param int level + * @return string indent string + */ + function _getIndent($level) { + return $this->_strXml .= str_repeat($this->_indentChar, $level); + } + + /** + * Set the indent string + * @param int level + * @return void + */ + function setIndent($string = "") { + $this->_indentChar = $string; + } + +} diff --git a/trunk/conlite/classes/class.xsltprocessor.php b/trunk/conlite/classes/class.xsltprocessor.php index a6780f9..7d779e4 100644 --- a/trunk/conlite/classes/class.xsltprocessor.php +++ b/trunk/conlite/classes/class.xsltprocessor.php @@ -1,4 +1,5 @@ process(); * */ -class XsltProcessor -{ +class XsltProcessor { + /** * XSML Processor auto-free * @var bool @@ -64,7 +64,7 @@ class XsltProcessor * @access private */ var $error = ""; - + /** * Error number * @var int @@ -78,14 +78,14 @@ class XsltProcessor * @access private */ var $result = ""; - + /** * The XML String for the Transformation * @var string * @access private */ var $xml = ""; - + /** * The XSLT String for the Transformation * @var string @@ -99,103 +99,95 @@ class XsltProcessor * @access private */ var $processor; - + /** * XSLT Process arguments array * @var array * @access private */ var $arguments = array(); - + /** * XSLT Process parameters array * @var array * @access private */ var $parameters = array(); - + /** * Constructor * @access private */ - function XsltProcessor() - { + function __construct() { $this->_init(); } - + /** * Initialize the class * @access private * @return void */ - function _init() - { - if (!function_exists("xslt_create")) - { - die ("Cannot instantiate XSLT Class \n XSLT not supported"); + function _init() { + if (!function_exists("xslt_create")) { + die("Cannot instantiate XSLT Class \n XSLT not supported"); } - + $this->processor = xslt_create(); } - + /** * Translate literal to numeric entities to avoid * the 'undefined entity error' that a literal * entity would cause. - * + * * @param string XML String with literal entities * @return string XML string with numeric entites - * @access private + * @access private */ function literal2NumericEntities($stringXml) { $literal2NumericEntity = array(); - if (empty($literal2NumericEntity)) - { + if (empty($literal2NumericEntity)) { $transTbl = clGetHtmlTranslationTable(HTML_ENTITIES); - foreach ($transTbl as $char => $entity) - { - if (strpos('&"<>', $char) !== FALSE) continue; - $literal2NumericEntity[$entity] = '&#'.ord($char).';'; + foreach ($transTbl as $char => $entity) { + if (strpos('&"<>', $char) !== FALSE) + continue; + $literal2NumericEntity[$entity] = '&#' . ord($char) . ';'; } } return strtr($stringXml, $literal2NumericEntity); } - - + /** * Set the XML to be Transformed * @param string The XML String * @return void - * @access public + * @access public */ - function setXml($xml) - { + function setXml($xml) { $this->arguments["/_xml"] = $this->literal2NumericEntities($xml); } - + /** * Set the XSLT for the Transformation * @param string The XML String * @return void - * @access public + * @access public */ - function setXsl($xsl) - { + function setXsl($xsl) { $this->arguments["/_xsl"] = $this->literal2NumericEntities($xsl); } - - /** + + /** * Set the XML-File to be Transformed * @param string Location of the XML file * @return void - * @access public + * @access public */ - function setXmlFile($file) - { + function setXmlFile($file) { $xml = $this->readFromFile($file); $this->arguments["/_xml"] = $this->literal2NumericEntities($xml); } @@ -204,136 +196,123 @@ class XsltProcessor * Set the XSL-File for the Transformation * @param string Location of the XSL file * @return void - * @access public + * @access public */ - function setXslFile($file) - { + function setXslFile($file) { $xsl = $this->readFromFile($file); $this->arguments["/_xsl"] = $this->literal2NumericEntities($xsl); } - + /** * Return the contents of a file if * the passed parameter is a file. - * + * * @param string File location * @return string File contents - * @access private + * @access private */ - function readFromFile($file) - { - if (file_exists($file)) - { + function readFromFile($file) { + if (file_exists($file)) { $data = file($file); $data = join($data, ""); return $data; } - die ("ERROR: File not found: $file"); + die("ERROR: File not found: $file"); } - + /** * Pass top level parameters to the XSLT processor. - * The parameters can be accessed in XSL - * with - * + * The parameters can be accessed in XSL + * with + * * @param string Name * @param string Value * @return void */ - function setParam($name, $value) - { + function setParam($name, $value) { $this->parameters[$name] = utf8_encode($value); } - + /** - * Define external scheme handlers for the XSLT Processor. - * - * Example param array: - * - * array("get_all", "mySchemeHandler") - * - * Example scheme handler function: - * - * function mySchemeHandler($processor, $scheme, $param) - * { - * // to remove the first slash added by Sablotron - * $param = substr($param, 1); - * - * if ($scheme == 'file_exists') - * { // result is returned as valid xml string - * return ''.(file_exists($param) ? "true" : "false").""; - * } - * } - * - * To use the schema handler use: - * - * do something - * - * - * To call the external function use the 'document()' XSLT-Function. - * - * - * - * Schemename and parameter will be passed to the handler function as second and third parameter. - * The return value of the function must be valid XML to access it using XPath. - * - * @param array array("scheme"=>"schemeHandlerName"); - * @return void - * @access public - */ - function setSchemeHandlers($aHandlers) - { - xslt_set_scheme_handlers($this->processor, $aHandlers); - } + * Define external scheme handlers for the XSLT Processor. + * + * Example param array: + * + * array("get_all", "mySchemeHandler") + * + * Example scheme handler function: + * + * function mySchemeHandler($processor, $scheme, $param) + * { + * // to remove the first slash added by Sablotron + * $param = substr($param, 1); + * + * if ($scheme == 'file_exists') + * { // result is returned as valid xml string + * return ''.(file_exists($param) ? "true" : "false").""; + * } + * } + * + * To use the schema handler use: + * + * do something + * + * + * To call the external function use the 'document()' XSLT-Function. + * + * + * + * Schemename and parameter will be passed to the handler function as second and third parameter. + * The return value of the function must be valid XML to access it using XPath. + * + * @param array array("scheme"=>"schemeHandlerName"); + * @return void + * @access public + */ + function setSchemeHandlers($aHandlers) { + xslt_set_scheme_handlers($this->processor, $aHandlers); + } /** * Transform the XML data using the XSL and - * return the results of the transformation - * + * return the results of the transformation + * * @return string Transformed data - * @access public + * @access public */ - function process() - { + function process() { $this->result = xslt_process($this->processor, "arg:/_xml", "arg:/_xsl", NULL, $this->arguments, $this->parameters); $this->error = xslt_error($this->processor); $this->errno = xslt_errno($this->processor); - - if ($this->autofree) - { + + if ($this->autofree) { xslt_free($this->processor); } - + return $this->result; } - + /** * Prints the Error message and number * if an error occured - * + * * @return void - * @access public + * @access public */ - function printErrors() - { - if ($this->errno > 0) - { - echo "Error Number: ".$this->errno." "; - echo "Error Message: ".$this->error.""; + function printErrors() { + if ($this->errno > 0) { + echo "Error Number: " . $this->errno . " "; + echo "Error Message: " . $this->error . ""; } } - + /** * Manual free of the parser * @return void */ - function free() - { + function free() { xslt_free($this->processor); } - -} // XSLT_Processor - -?> +} diff --git a/trunk/conlite/classes/contenido/class.module.php b/trunk/conlite/classes/contenido/class.module.php index 4742a0d..99725b9 100644 --- a/trunk/conlite/classes/contenido/class.module.php +++ b/trunk/conlite/classes/contenido/class.module.php @@ -37,12 +37,6 @@ class cApiModuleCollection extends ItemCollection { $this->_setItemClass("cApiModule"); } - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function cApiModuleCollection() { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct(); - } - /** * Creates a new communication item */ diff --git a/trunk/conlite/classes/datatypes/class.datatype.currency.php b/trunk/conlite/classes/datatypes/class.datatype.currency.php index 1bcdd21..7f0cc82 100644 --- a/trunk/conlite/classes/datatypes/class.datatype.currency.php +++ b/trunk/conlite/classes/datatypes/class.datatype.currency.php @@ -1,4 +1,5 @@ setCurrencySymbolLocation(cDatatypeCurrency_Right); - $this->setCurrencySymbol("�"); - } - - function setCurrencySymbol ($sSymbol) - { - $this->_sCurrencySymbol = $sSymbol; - } - - function getCurrencySymbol () - { - return ($this->_sCurrencySymbol); - } - - function setCurrencySymbolLocation ($cLocation) - { - switch ($cLocation) - { - case cDatatypeCurrency_Left: - case cDatatypeCurrency_Right: - $this->_cCurrencyLocation = $cLocation; - break; - default: - cWarning(__FILE__, __LINE__, "Warning: No valid cDatatypeCurrency_* Constant given. Available values: cDatatypeCurrency_Left, cDatatypeCurrency_Right"); - return; - break; - } - } - - function render () - { - $value = parent::render(); - - switch ($this->_cCurrencyLocation) - { - case cDatatypeCurrency_Left: - return sprintf("%s %s", $this->_sCurrencySymbol, $value); - break; - case cDatatypeCurrency_Right: - return sprintf("%s %s", $value, $this->_sCurrencySymbol); - break; - } - } - +class cDatatypeCurrency extends cDatatypeNumber { + + var $_cCurrencyLocation; + var $_sCurrencySymbol; + + function __construct() { + cDatatypeNumber::__construct(); + + $this->setCurrencySymbolLocation(cDatatypeCurrency_Right); + $this->setCurrencySymbol("�"); + } + + function setCurrencySymbol($sSymbol) { + $this->_sCurrencySymbol = $sSymbol; + } + + function getCurrencySymbol() { + return ($this->_sCurrencySymbol); + } + + function setCurrencySymbolLocation($cLocation) { + switch ($cLocation) { + case cDatatypeCurrency_Left: + case cDatatypeCurrency_Right: + $this->_cCurrencyLocation = $cLocation; + break; + default: + cWarning(__FILE__, __LINE__, "Warning: No valid cDatatypeCurrency_* Constant given. Available values: cDatatypeCurrency_Left, cDatatypeCurrency_Right"); + return; + break; + } + } + + function render() { + $value = parent::render(); + + switch ($this->_cCurrencyLocation) { + case cDatatypeCurrency_Left: + return sprintf("%s %s", $this->_sCurrencySymbol, $value); + break; + case cDatatypeCurrency_Right: + return sprintf("%s %s", $value, $this->_sCurrencySymbol); + break; + } + } + } + ?> \ No newline at end of file diff --git a/trunk/conlite/classes/datatypes/class.datatype.datetime.php b/trunk/conlite/classes/datatypes/class.datatype.datetime.php index 9dc96b0..cdad28d 100644 --- a/trunk/conlite/classes/datatypes/class.datatype.datetime.php +++ b/trunk/conlite/classes/datatypes/class.datatype.datetime.php @@ -1,4 +1,5 @@ setTargetFormat(cDateTime_Locale); - $this->setSourceFormat(cDateTime_UNIX); - - $this->_iYear = 1970; - $this->_iMonth = 1; - $this->_iDay = 1; - $this->_iHour = 0; - $this->_iMinute = 0; - $this->_iSecond = 0; - - $this->setFirstDayOfWeek(cDateTime_Monday); - parent::cDatatype(); - } - - function setCustomTargetFormat ($targetFormat) - { - $this->_sCustomTargetFormat = $targetFormat; - } - - function setCustomSourceFormat ($sourceFormat) - { - $this->_sCustomSourceFormat = $sourceFormat; - } - - function setSourceFormat ($cSourceFormat) - { - $this->_cSourceFormat = $cSourceFormat; - } - - function setTargetFormat ($cTargetFormat) - { - $this->_cTargetFormat = $cTargetFormat; - } - - function setYear ($iYear) - { - $this->_iYear = $iYear; - } - - function getYear () - { - return ($this->_iYear); - } +class cDatatypeDateTime extends cDatatype { - function setMonth ($iMonth) - { - $this->_iMonth = $iMonth; - } - - function getMonth () - { - return ($this->_iMonth); - } - - function setDay ($iDay) - { - $this->_iDay = $iDay; - } - - function getDay () - { - return ($this->_iDay); - } + var $_iFirstDayOfWeek; - function getMonthName ($iMonth) - { - switch ($iMonth) - { - case 1: return i18n("January"); - case 2: return i18n("February"); - case 3: return i18n("March"); - case 4: return i18n("April"); - case 5: return i18n("May"); - case 6: return i18n("June"); - case 7: return i18n("July"); - case 8: return i18n("August"); - case 9: return i18n("September"); - case 10: return i18n("October"); - case 11: return i18n("November"); - case 12: return i18n("December"); - } - } - - function getDayName ($iDayOfWeek) - { - switch ($iDayOfWeek) - { - case 0: return i18n("Sunday"); - case 1: return i18n("Monday"); - case 2: return i18n("Tuesday"); - case 3: return i18n("Wednesday"); - case 4: return i18n("Thursday"); - case 5: return i18n("Friday"); - case 6: return i18n("Saturday"); - case 7: return i18n("Sunday"); - default: return false; - } - } - - function getDayOrder () - { - $aDays = array(0, 1, 2, 3, 4, 5, 6); - $aRemainderDays = array_splice($aDays, 0, $this->_iFirstDayOfWeek); - - $aReturnDays = array_merge($aDays, $aRemainderDays); - - return ($aReturnDays); - } - - function getNumberOfMonthDays ($iMonth = false, $iYear = false) - { - if ($iMonth === false) - { - $iMonth = $this->_iMonth; - } - - if ($iYear === false) - { - $iYear = $this->_iYear; - } - - return date("t", mktime(0,0,0,$iMonth, 1, $iYear)); - } - - function setFirstDayOfWeek ($iDay) - { - $this->_iFirstDayOfWeek = $iDay; - } - - function getFirstDayOfWeek () - { - return $this->_iFirstDayOfWeek; - } - - function getLeapDay () - { - return end($this->getDayOrder()); - } - - function set ($value, $iOverrideFormat = false) - { - if ($value == "") - { - return; - } - - if ($iOverrideFormat !== false) - { - $iFormat = $iOverrideFormat; - } else { - $iFormat = $this->_cSourceFormat; - } - - switch ($iFormat) - { - case cDateTime_UNIX: - $sTemporaryTimestamp = $value; - $this->_iYear = date("Y", $sTemporaryTimestamp); - $this->_iMonth = date("m", $sTemporaryTimestamp); - $this->_iDay = date("d", $sTemporaryTimestamp); - $this->_iHour = date("H", $sTemporaryTimestamp); - $this->_iMinute = date("i", $sTemporaryTimestamp); - $this->_iSecond = date("s", $sTemporaryTimestamp); - - break; - case cDateTime_ISO: - $sTemporaryTimestamp = strtotime($value); - $this->_iYear = date("Y", $sTemporaryTimestamp); - $this->_iMonth = date("m", $sTemporaryTimestamp); - $this->_iDay = date("d", $sTemporaryTimestamp); - $this->_iHour = date("H", $sTemporaryTimestamp); - $this->_iMinute = date("i", $sTemporaryTimestamp); - $this->_iSecond = date("s", $sTemporaryTimestamp); - break; + /* This datatype stores its date format in ISO */ + + function __construct() { + $this->setTargetFormat(cDateTime_Locale); + $this->setSourceFormat(cDateTime_UNIX); + + $this->_iYear = 1970; + $this->_iMonth = 1; + $this->_iDay = 1; + $this->_iHour = 0; + $this->_iMinute = 0; + $this->_iSecond = 0; + + $this->setFirstDayOfWeek(cDateTime_Monday); + parent::__construct(); + } + + function setCustomTargetFormat($targetFormat) { + $this->_sCustomTargetFormat = $targetFormat; + } + + function setCustomSourceFormat($sourceFormat) { + $this->_sCustomSourceFormat = $sourceFormat; + } + + function setSourceFormat($cSourceFormat) { + $this->_cSourceFormat = $cSourceFormat; + } + + function setTargetFormat($cTargetFormat) { + $this->_cTargetFormat = $cTargetFormat; + } + + function setYear($iYear) { + $this->_iYear = $iYear; + } + + function getYear() { + return ($this->_iYear); + } + + function setMonth($iMonth) { + $this->_iMonth = $iMonth; + } + + function getMonth() { + return ($this->_iMonth); + } + + function setDay($iDay) { + $this->_iDay = $iDay; + } + + function getDay() { + return ($this->_iDay); + } + + function getMonthName($iMonth) { + switch ($iMonth) { + case 1: return i18n("January"); + case 2: return i18n("February"); + case 3: return i18n("March"); + case 4: return i18n("April"); + case 5: return i18n("May"); + case 6: return i18n("June"); + case 7: return i18n("July"); + case 8: return i18n("August"); + case 9: return i18n("September"); + case 10: return i18n("October"); + case 11: return i18n("November"); + case 12: return i18n("December"); + } + } + + function getDayName($iDayOfWeek) { + switch ($iDayOfWeek) { + case 0: return i18n("Sunday"); + case 1: return i18n("Monday"); + case 2: return i18n("Tuesday"); + case 3: return i18n("Wednesday"); + case 4: return i18n("Thursday"); + case 5: return i18n("Friday"); + case 6: return i18n("Saturday"); + case 7: return i18n("Sunday"); + default: return false; + } + } + + function getDayOrder() { + $aDays = array(0, 1, 2, 3, 4, 5, 6); + $aRemainderDays = array_splice($aDays, 0, $this->_iFirstDayOfWeek); + + $aReturnDays = array_merge($aDays, $aRemainderDays); + + return ($aReturnDays); + } + + function getNumberOfMonthDays($iMonth = false, $iYear = false) { + if ($iMonth === false) { + $iMonth = $this->_iMonth; + } + + if ($iYear === false) { + $iYear = $this->_iYear; + } + + return date("t", mktime(0, 0, 0, $iMonth, 1, $iYear)); + } + + function setFirstDayOfWeek($iDay) { + $this->_iFirstDayOfWeek = $iDay; + } + + function getFirstDayOfWeek() { + return $this->_iFirstDayOfWeek; + } + + function getLeapDay() { + return end($this->getDayOrder()); + } + + function set($value, $iOverrideFormat = false) { + if ($value == "") { + return; + } + + if ($iOverrideFormat !== false) { + $iFormat = $iOverrideFormat; + } else { + $iFormat = $this->_cSourceFormat; + } + + switch ($iFormat) { + case cDateTime_UNIX: + $sTemporaryTimestamp = $value; + $this->_iYear = date("Y", $sTemporaryTimestamp); + $this->_iMonth = date("m", $sTemporaryTimestamp); + $this->_iDay = date("d", $sTemporaryTimestamp); + $this->_iHour = date("H", $sTemporaryTimestamp); + $this->_iMinute = date("i", $sTemporaryTimestamp); + $this->_iSecond = date("s", $sTemporaryTimestamp); + + break; + case cDateTime_ISO: + $sTemporaryTimestamp = strtotime($value); + $this->_iYear = date("Y", $sTemporaryTimestamp); + $this->_iMonth = date("m", $sTemporaryTimestamp); + $this->_iDay = date("d", $sTemporaryTimestamp); + $this->_iHour = date("H", $sTemporaryTimestamp); + $this->_iMinute = date("i", $sTemporaryTimestamp); + $this->_iSecond = date("s", $sTemporaryTimestamp); + break; case cDateTime_MySQL: $sTimeformat = 'YmdHis'; - - $targetFormat = str_replace('.', '\.', $sTimeformat); - $targetFormat = str_replace('d', '([0-9]{2,2})', $targetFormat); - $targetFormat = str_replace('m', '([0-9]{2,2})', $targetFormat); - $targetFormat = str_replace('Y', '([0-9]{4,4})', $targetFormat); - $targetFormat = str_replace('H', '([0-9]{2,2})', $targetFormat); - $targetFormat = str_replace('i', '([0-9]{2,2})', $targetFormat); - $targetFormat = str_replace('s', '([0-9]{2,2})', $targetFormat); - /* Match the placeholders */ - preg_match_all('/([a-zA-Z])/', $sTimeformat, $placeholderRegs); - /* Match the date values */ - preg_match('/' . $targetFormat . '/', $value, $dateRegs); - - $finalDate = array(); - - /* Map date entries to placeholders */ - foreach ($placeholderRegs[0] as $key => $placeholderReg) - { - if (isset($dateRegs[$key])) - { - $finalDate[$placeholderReg] = $dateRegs[$key+1]; - } - } + $targetFormat = str_replace('.', '\.', $sTimeformat); + $targetFormat = str_replace('d', '([0-9]{2,2})', $targetFormat); + $targetFormat = str_replace('m', '([0-9]{2,2})', $targetFormat); + $targetFormat = str_replace('Y', '([0-9]{4,4})', $targetFormat); + $targetFormat = str_replace('H', '([0-9]{2,2})', $targetFormat); + $targetFormat = str_replace('i', '([0-9]{2,2})', $targetFormat); + $targetFormat = str_replace('s', '([0-9]{2,2})', $targetFormat); + /* Match the placeholders */ + preg_match_all('/([a-zA-Z])/', $sTimeformat, $placeholderRegs); - /* Assign placeholders + data to the object's member variables */ - foreach ($finalDate as $placeHolder => $value) - { - switch ($placeHolder) - { - case "d": - $this->_iDay = $value; - break; - case "m": - $this->_iMonth = $value; - break; - case "Y": - $this->_iYear = $value; - break; - case "H": - $this->_iHour = $value; - break; - case "i": - $this->_iMinute = $value; - break; - case "s": - $this->_iSecond = $value; - break; - default: - break; - } - } - - - break; - case cDateTime_Custom: - /* Build a regular expression */ - - $sourceFormat = str_replace('.', '\.', $this->_sCustomSourceFormat); - $sourceFormat = str_replace('%d', '([0-9]{2,2})', $sourceFormat); - $sourceFormat = str_replace('%m', '([0-9]{2,2})', $sourceFormat); - $sourceFormat = str_replace('%Y', '([0-9]{4,4})', $sourceFormat); - - /* Match the placeholders */ - preg_match_all('/(%[a-zA-Z])/', $this->_sCustomSourceFormat, $placeholderRegs); + /* Match the date values */ + preg_match('/' . $targetFormat . '/', $value, $dateRegs); - - /* Match the date values */ - preg_match('/' . $sourceFormat . '/', $value, $dateRegs); - - $finalDate = array(); - - /* Map date entries to placeholders */ - foreach ($placeholderRegs[0] as $key => $placeholderReg) - { - if (isset($dateRegs[$key])) - { - $finalDate[$placeholderReg] = $dateRegs[$key+1]; - } - } + $finalDate = array(); - /* Assign placeholders + data to the object's member variables */ - foreach ($finalDate as $placeHolder => $value) - { - switch ($placeHolder) - { - case "%d": - $this->_iDay = $value; - break; - case "%m": - $this->_iMonth = $value; - break; - case "%Y": - $this->_iYear = $value; - break; - default: - break; - } - } - break; - default: - break; - } - } - - function get ($iOverrideFormat = false) - { - if ($iOverrideFormat !== false) - { - $iFormat = $iOverrideFormat; - } else { - $iFormat = $this->_cSourceFormat; - } - - - switch ($iFormat) - { - case cDateTime_ISO: - $sTemporaryTimestamp = mktime($this->_iHour, $this->_iMinute, $this->_iSecond , $this->_iMonth, $this->_iDay, $this->_iYear); - return date("Y-m-d H:i:s", $sTemporaryTimestamp); - break; - case cDateTime_UNIX: - $sTemporaryTimestamp = mktime($this->_iHour, $this->_iMinute, $this->_iSecond , $this->_iMonth, $this->_iDay, $this->_iYear); - return ($sTemporaryTimestamp); - break; - case cDateTime_Custom: - return strftime($this->_sCustomSourceFormat, mktime($this->_iHour, $this->_iMinute, $this->_iSecond, $this->_iMonth, $this->_iDay, $this->_iYear)); - break; - case cDateTime_MySQL: - $sTemporaryTimestamp = mktime($this->_iHour, $this->_iMinute, $this->_iSecond , $this->_iMonth, $this->_iDay, $this->_iYear); - return date("YmdHis", $sTemporaryTimestamp); - break; - default: - cError(__FILE__, __LINE__, "Not supported yet"); - break; - } - } - - function render ($iOverrideFormat = false) - { - if ($iOverrideFormat !== false) - { - $iFormat = $iOverrideFormat; - } else { - $iFormat = $this->_cTargetFormat; - } - - switch ($iFormat) - { - case cDateTime_Locale_TimeOnly: - $sTimeformat = getEffectiveSetting("backend", "timeformat_time", "H:i:s"); - - return date($sTimeformat, mktime($this->_iHour, $this->_iMinute, $this->iSecond, $this->_iMonth, $this->_iDay, $this->_iYear)); + /* Map date entries to placeholders */ + foreach ($placeholderRegs[0] as $key => $placeholderReg) { + if (isset($dateRegs[$key])) { + $finalDate[$placeholderReg] = $dateRegs[$key + 1]; + } + } - case cDateTime_Locale_DateOnly: - $sTimeformat = getEffectiveSetting("backend", "timeformat_date", "Y-m-d"); - - return date($sTimeformat, mktime($this->_iHour, $this->_iMinute, $this->iSecond, $this->_iMonth, $this->_iDay, $this->_iYear)); - case cDateTime_Locale: - $sTimeformat = getEffectiveSetting("backend", "timeformat", "Y-m-d H:i:s"); - - return date($sTimeformat, mktime($this->_iHour, $this->_iMinute, $this->iSecond, $this->_iMonth, $this->_iDay, $this->_iYear)); - case cDateTime_Custom: - return strftime($this->_sCustomTargetFormat, mktime($this->_iHour, $this->_iMinute, $this->_iSecond, $this->_iMonth, $this->_iDay, $this->_iYear)); + /* Assign placeholders + data to the object's member variables */ + foreach ($finalDate as $placeHolder => $value) { + switch ($placeHolder) { + case "d": + $this->_iDay = $value; + break; + case "m": + $this->_iMonth = $value; + break; + case "Y": + $this->_iYear = $value; + break; + case "H": + $this->_iHour = $value; + break; + case "i": + $this->_iMinute = $value; + break; + case "s": + $this->_iSecond = $value; + break; + default: + break; + } + } - break; - } - } - - function parse ($value) - { - if ($value == "") - { return; - } - switch ($this->_cTargetFormat) - { - case cDateTime_ISO: - $sTemporaryTimestamp = strtotime($value); - $this->_iYear = date("Y", $sTemporaryTimestamp); - $this->_iMonth = date("m", $sTemporaryTimestamp); - $this->_iDay = date("d", $sTemporaryTimestamp); - $this->_iHour = date("H", $sTemporaryTimestamp); - $this->_iMinute = date("i", $sTemporaryTimestamp); - $this->_iSecond = date("s", $sTemporaryTimestamp); - break; - case cDateTime_Locale_DateOnly: - $sTimeformat = getEffectiveSetting('backend', 'timeformat_date', 'Y-m-d'); - - $targetFormat = str_replace('.', '\.', $sTimeformat); - $targetFormat = str_replace('d', '([0-9]{2,2})', $targetFormat); - $targetFormat = str_replace('m', '([0-9]{2,2})', $targetFormat); - $targetFormat = str_replace('Y', '([0-9]{4,4})', $targetFormat); - - /* Match the placeholders */ - preg_match_all('/([a-zA-Z])/', $sTimeformat, $placeholderRegs); + break; + case cDateTime_Custom: + /* Build a regular expression */ - /* Match the date values */ - preg_match('/' . $targetFormat . '/', $value, $dateRegs); - - $finalDate = array(); - - /* Map date entries to placeholders */ - foreach ($placeholderRegs[0] as $key => $placeholderReg) - { - if (isset($dateRegs[$key])) - { - $finalDate[$placeholderReg] = $dateRegs[$key+1]; - } - } + $sourceFormat = str_replace('.', '\.', $this->_sCustomSourceFormat); + $sourceFormat = str_replace('%d', '([0-9]{2,2})', $sourceFormat); + $sourceFormat = str_replace('%m', '([0-9]{2,2})', $sourceFormat); + $sourceFormat = str_replace('%Y', '([0-9]{4,4})', $sourceFormat); - /* Assign placeholders + data to the object's member variables */ - foreach ($finalDate as $placeHolder => $value) - { - switch ($placeHolder) - { - case "d": - $this->_iDay = $value; - break; - case "m": - $this->_iMonth = $value; - break; - case "Y": - $this->_iYear = $value; - break; - default: - break; - } - } - - - break; - case cDateTime_Locale: - $sTimeformat = getEffectiveSetting('backend', 'timeformat', 'Y-m-d H:i:s'); - - $targetFormat = str_replace('.', '\.', $sTimeformat); - $targetFormat = str_replace('d', '([0-9]{2,2})', $targetFormat); - $targetFormat = str_replace('m', '([0-9]{2,2})', $targetFormat); - $targetFormat = str_replace('Y', '([0-9]{4,4})', $targetFormat); - - /* Match the placeholders */ - preg_match_all('/(%[a-zA-Z])/', $this->_sCustomTargetFormat, $placeholderRegs); + /* Match the placeholders */ + preg_match_all('/(%[a-zA-Z])/', $this->_sCustomSourceFormat, $placeholderRegs); - /* Match the date values */ - preg_match('/' . $targetFormat . '/', $value, $dateRegs); - - $finalDate = array(); - - /* Map date entries to placeholders */ - foreach ($placeholderRegs[0] as $key => $placeholderReg) - { - if (isset($dateRegs[$key])) - { - $finalDate[$placeholderReg] = $dateRegs[$key+1]; - } - } - /* Assign placeholders + data to the object's member variables */ - foreach ($finalDate as $placeHolder => $value) - { - switch ($placeHolder) - { - case "%d": - $this->_iDay = $value; - break; - case "%m": - $this->_iMonth = $value; - break; - case "%Y": - $this->_iYear = $value; - break; - default: - break; - } - } - - - break; - case cDateTime_Custom: - /* Build a regular expression */ - - $targetFormat = str_replace('.', '\.', $this->_sCustomTargetFormat); - $targetFormat = str_replace('%d', '([0-9]{2,2})', $targetFormat); - $targetFormat = str_replace('%m', '([0-9]{2,2})', $targetFormat); - $targetFormat = str_replace('%Y', '([0-9]{4,4})', $targetFormat); - - /* Match the placeholders */ - preg_match_all('/(%[a-zA-Z])/', $this->_sCustomTargetFormat, $placeholderRegs); + /* Match the date values */ + preg_match('/' . $sourceFormat . '/', $value, $dateRegs); - /* Match the date values */ - preg_match('/' . $targetFormat . '/', $value, $dateRegs); - - $finalDate = array(); - - /* Map date entries to placeholders */ - foreach ($placeholderRegs[0] as $key => $placeholderReg) - { - if (isset($dateRegs[$key])) - { - $finalDate[$placeholderReg] = $dateRegs[$key+1]; - } - } + $finalDate = array(); + + /* Map date entries to placeholders */ + foreach ($placeholderRegs[0] as $key => $placeholderReg) { + if (isset($dateRegs[$key])) { + $finalDate[$placeholderReg] = $dateRegs[$key + 1]; + } + } + + /* Assign placeholders + data to the object's member variables */ + foreach ($finalDate as $placeHolder => $value) { + switch ($placeHolder) { + case "%d": + $this->_iDay = $value; + break; + case "%m": + $this->_iMonth = $value; + break; + case "%Y": + $this->_iYear = $value; + break; + default: + break; + } + } + break; + default: + break; + } + } + + function get($iOverrideFormat = false) { + if ($iOverrideFormat !== false) { + $iFormat = $iOverrideFormat; + } else { + $iFormat = $this->_cSourceFormat; + } + + + switch ($iFormat) { + case cDateTime_ISO: + $sTemporaryTimestamp = mktime($this->_iHour, $this->_iMinute, $this->_iSecond, $this->_iMonth, $this->_iDay, $this->_iYear); + return date("Y-m-d H:i:s", $sTemporaryTimestamp); + break; + case cDateTime_UNIX: + $sTemporaryTimestamp = mktime($this->_iHour, $this->_iMinute, $this->_iSecond, $this->_iMonth, $this->_iDay, $this->_iYear); + return ($sTemporaryTimestamp); + break; + case cDateTime_Custom: + return strftime($this->_sCustomSourceFormat, mktime($this->_iHour, $this->_iMinute, $this->_iSecond, $this->_iMonth, $this->_iDay, $this->_iYear)); + break; + case cDateTime_MySQL: + $sTemporaryTimestamp = mktime($this->_iHour, $this->_iMinute, $this->_iSecond, $this->_iMonth, $this->_iDay, $this->_iYear); + return date("YmdHis", $sTemporaryTimestamp); + break; + default: + cError(__FILE__, __LINE__, "Not supported yet"); + break; + } + } + + function render($iOverrideFormat = false) { + if ($iOverrideFormat !== false) { + $iFormat = $iOverrideFormat; + } else { + $iFormat = $this->_cTargetFormat; + } + + switch ($iFormat) { + case cDateTime_Locale_TimeOnly: + $sTimeformat = getEffectiveSetting("backend", "timeformat_time", "H:i:s"); + + return date($sTimeformat, mktime($this->_iHour, $this->_iMinute, $this->iSecond, $this->_iMonth, $this->_iDay, $this->_iYear)); + + case cDateTime_Locale_DateOnly: + $sTimeformat = getEffectiveSetting("backend", "timeformat_date", "Y-m-d"); + + return date($sTimeformat, mktime($this->_iHour, $this->_iMinute, $this->iSecond, $this->_iMonth, $this->_iDay, $this->_iYear)); + case cDateTime_Locale: + $sTimeformat = getEffectiveSetting("backend", "timeformat", "Y-m-d H:i:s"); + + return date($sTimeformat, mktime($this->_iHour, $this->_iMinute, $this->iSecond, $this->_iMonth, $this->_iDay, $this->_iYear)); + case cDateTime_Custom: + return strftime($this->_sCustomTargetFormat, mktime($this->_iHour, $this->_iMinute, $this->_iSecond, $this->_iMonth, $this->_iDay, $this->_iYear)); + + break; + } + } + + function parse($value) { + if ($value == "") { + return; + } + switch ($this->_cTargetFormat) { + case cDateTime_ISO: + $sTemporaryTimestamp = strtotime($value); + $this->_iYear = date("Y", $sTemporaryTimestamp); + $this->_iMonth = date("m", $sTemporaryTimestamp); + $this->_iDay = date("d", $sTemporaryTimestamp); + $this->_iHour = date("H", $sTemporaryTimestamp); + $this->_iMinute = date("i", $sTemporaryTimestamp); + $this->_iSecond = date("s", $sTemporaryTimestamp); + break; + case cDateTime_Locale_DateOnly: + $sTimeformat = getEffectiveSetting('backend', 'timeformat_date', 'Y-m-d'); + + $targetFormat = str_replace('.', '\.', $sTimeformat); + $targetFormat = str_replace('d', '([0-9]{2,2})', $targetFormat); + $targetFormat = str_replace('m', '([0-9]{2,2})', $targetFormat); + $targetFormat = str_replace('Y', '([0-9]{4,4})', $targetFormat); + + /* Match the placeholders */ + preg_match_all('/([a-zA-Z])/', $sTimeformat, $placeholderRegs); + + /* Match the date values */ + preg_match('/' . $targetFormat . '/', $value, $dateRegs); + + $finalDate = array(); + + /* Map date entries to placeholders */ + foreach ($placeholderRegs[0] as $key => $placeholderReg) { + if (isset($dateRegs[$key])) { + $finalDate[$placeholderReg] = $dateRegs[$key + 1]; + } + } + + /* Assign placeholders + data to the object's member variables */ + foreach ($finalDate as $placeHolder => $value) { + switch ($placeHolder) { + case "d": + $this->_iDay = $value; + break; + case "m": + $this->_iMonth = $value; + break; + case "Y": + $this->_iYear = $value; + break; + default: + break; + } + } + + + break; + case cDateTime_Locale: + $sTimeformat = getEffectiveSetting('backend', 'timeformat', 'Y-m-d H:i:s'); + + $targetFormat = str_replace('.', '\.', $sTimeformat); + $targetFormat = str_replace('d', '([0-9]{2,2})', $targetFormat); + $targetFormat = str_replace('m', '([0-9]{2,2})', $targetFormat); + $targetFormat = str_replace('Y', '([0-9]{4,4})', $targetFormat); + + /* Match the placeholders */ + preg_match_all('/(%[a-zA-Z])/', $this->_sCustomTargetFormat, $placeholderRegs); + + /* Match the date values */ + preg_match('/' . $targetFormat . '/', $value, $dateRegs); + + $finalDate = array(); + + /* Map date entries to placeholders */ + foreach ($placeholderRegs[0] as $key => $placeholderReg) { + if (isset($dateRegs[$key])) { + $finalDate[$placeholderReg] = $dateRegs[$key + 1]; + } + } + + /* Assign placeholders + data to the object's member variables */ + foreach ($finalDate as $placeHolder => $value) { + switch ($placeHolder) { + case "%d": + $this->_iDay = $value; + break; + case "%m": + $this->_iMonth = $value; + break; + case "%Y": + $this->_iYear = $value; + break; + default: + break; + } + } + + + break; + case cDateTime_Custom: + /* Build a regular expression */ + + $targetFormat = str_replace('.', '\.', $this->_sCustomTargetFormat); + $targetFormat = str_replace('%d', '([0-9]{2,2})', $targetFormat); + $targetFormat = str_replace('%m', '([0-9]{2,2})', $targetFormat); + $targetFormat = str_replace('%Y', '([0-9]{4,4})', $targetFormat); + + /* Match the placeholders */ + preg_match_all('/(%[a-zA-Z])/', $this->_sCustomTargetFormat, $placeholderRegs); + + /* Match the date values */ + preg_match('/' . $targetFormat . '/', $value, $dateRegs); + + $finalDate = array(); + + /* Map date entries to placeholders */ + foreach ($placeholderRegs[0] as $key => $placeholderReg) { + if (isset($dateRegs[$key])) { + $finalDate[$placeholderReg] = $dateRegs[$key + 1]; + } + } + + /* Assign placeholders + data to the object's member variables */ + foreach ($finalDate as $placeHolder => $value) { + switch ($placeHolder) { + case "%d": + $this->_iDay = $value; + break; + case "%m": + $this->_iMonth = $value; + break; + case "%Y": + $this->_iYear = $value; + break; + default: + break; + } + } + break; + default: + break; + } + } - /* Assign placeholders + data to the object's member variables */ - foreach ($finalDate as $placeHolder => $value) - { - switch ($placeHolder) - { - case "%d": - $this->_iDay = $value; - break; - case "%m": - $this->_iMonth = $value; - break; - case "%Y": - $this->_iYear = $value; - break; - default: - break; - } - } - break; - default: - break; - } - } } ?> \ No newline at end of file diff --git a/trunk/conlite/classes/datatypes/class.datatype.number.php b/trunk/conlite/classes/datatypes/class.datatype.number.php index 9421ca4..5b47a66 100644 --- a/trunk/conlite/classes/datatypes/class.datatype.number.php +++ b/trunk/conlite/classes/datatypes/class.datatype.number.php @@ -1,4 +1,5 @@ setDecimalPointCharacter($aLocaleSettings["mon_decimal_point"]); + $this->setThousandSeparatorCharacter($aLocaleSettings["mon_thousands_sep"]); + + cDatatype::__construct(); + } + + function set($value) { + $this->_mValue = floatval($value); + } + + function get() { + return $this->_mValue; + } + + function setPrecision($iPrecision) { + $this->_iPrecision = $iPrecision; + } + + function setDecimalPointCharacter($sCharacter) { + $this->_sDecimalPointCharacter = $sCharacter; + } + + function getDecimalPointCharacter() { + return ($this->_sDecimalPointCharacter); + } + + function setThousandSeparatorCharacter($sCharacter) { + $this->_sThousandSeparatorCharacter = $sCharacter; + } + + function getThousandSeparatorCharacter() { + return($this->_sThousandSeparatorCharacter); + } + + function parse($value) { + if ($this->_sDecimalPointCharacter == $this->_sThousandSeparatorCharacter) { + cWarning(__FILE__, __LINE__, "Decimal point character cannot be the same as the thousand separator character. Current decimal point character is '{$this->_sDecimalPointCharacter}', current thousand separator character is '{$this->_sThousandSeparatorCharacter}'"); + return; + } + + /* Convert to standard english format */ + $value = str_replace($this->_sThousandSeparatorCharacter, "", $value); + $value = str_replace($this->_sDecimalPointCharacter, ".", $value); + + $this->_mValue = floatval($value); + } + + function render() { + return number_format($this->_mValue, $this->_iPrecision, $this->_sDecimalPointCharacter, $this->_sThousandSeparatorCharacter); + } -class cDatatypeNumber extends cDatatype -{ - var $_iPrecision; - var $_sThousandSeparatorCharacter; - var $_sDecimalPointCharacter; - - function cDatatypeNumber () - { - global $i18nLanguage; - - /* Try to find out the current locale settings */ - $aLocaleSettings = cLocaleConv($i18nLanguage); - - $this->setDecimalPointCharacter($aLocaleSettings["mon_decimal_point"]); - $this->setThousandSeparatorCharacter($aLocaleSettings["mon_thousands_sep"]); - - cDatatype::cDatatype(); - } - - function set ($value) - { - $this->_mValue = floatval($value); - } - - function get () - { - return $this->_mValue; - } - - function setPrecision ($iPrecision) - { - $this->_iPrecision = $iPrecision; - } - - function setDecimalPointCharacter ($sCharacter) - { - $this->_sDecimalPointCharacter = $sCharacter; - } - - function getDecimalPointCharacter () - { - return ($this->_sDecimalPointCharacter); - } - - function setThousandSeparatorCharacter ($sCharacter) - { - $this->_sThousandSeparatorCharacter = $sCharacter; - } - - function getThousandSeparatorCharacter () - { - return($this->_sThousandSeparatorCharacter); - } - - function parse ($value) - { - if ($this->_sDecimalPointCharacter == $this->_sThousandSeparatorCharacter) - { - cWarning(__FILE__, __LINE__, "Decimal point character cannot be the same as the thousand separator character. Current decimal point character is '{$this->_sDecimalPointCharacter}', current thousand separator character is '{$this->_sThousandSeparatorCharacter}'"); - return; - } - - /* Convert to standard english format */ - $value = str_replace($this->_sThousandSeparatorCharacter, "", $value); - $value = str_replace($this->_sDecimalPointCharacter, ".", $value); - - $this->_mValue = floatval($value); - } - - function render () - { - return number_format($this->_mValue, $this->_iPrecision, $this->_sDecimalPointCharacter, $this->_sThousandSeparatorCharacter); - } } + ?> \ No newline at end of file diff --git a/trunk/conlite/classes/datatypes/class.datatype.php b/trunk/conlite/classes/datatypes/class.datatype.php index 260e04b..646fe6c 100644 --- a/trunk/conlite/classes/datatypes/class.datatype.php +++ b/trunk/conlite/classes/datatypes/class.datatype.php @@ -1,4 +1,5 @@ \ No newline at end of file diff --git a/trunk/conlite/classes/template/class.template.php b/trunk/conlite/classes/template/class.template.php index c93c68e..84c2231 100644 --- a/trunk/conlite/classes/template/class.template.php +++ b/trunk/conlite/classes/template/class.template.php @@ -1,4 +1,5 @@ '{%s}', 'start' => '', 'end' => ''); + * Tags array (for dynamic blocks); + * @var array + */ + public $tags = array('static' => '{%s}', 'start' => '', 'end' => ''); /** * gettext domain (default: contenido) * @var string */ protected $_sDomain = "conlite"; - var $array_registeredParsers = array(); - + /** * Constructor * * @param array $tags * @return void */ - public function __construct($tags = false, $parser = false) { + public function __construct($tags = false, $parser = false) { # Needed to block parsers in ConLite's backend and the module-template editor global $contenido, $changeview; - + if (is_array($tags)) { $this->tags = $tags; } $this->setEncoding(""); - if(is_array($parser)) { + if (is_array($parser)) { $this->array_registeredParsers = $parser; } elseif ((!isset($contenido)) || ($changeview == 'edit') || ($changeview == 'prev')) { $this->array_registeredParsers = array( - new clStrAPIFunctionsParser(), - new clCounterFunctionParser(), - new clIfFunctionParser() - ); + new clStrAPIFunctionsParser(), + new clCounterFunctionParser(), + new clIfFunctionParser() + ); } - } // end function - - /** - * Old deprecated constructor - * - * @deprecated since version 2.0 Beta - * @param array $tags - */ - public function Template($tags = false) { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct($tags); } /** @@ -123,11 +112,11 @@ class Template { * * @param string $sDomain Sets the domain to use for template translations * @return void - */ + */ public function setDomain($sDomain) { $this->_sDomain = $sDomain; } - + /** * Set Templates placeholders and values * @@ -154,11 +143,11 @@ class Template { * Sets an encoding for the template's head block. * * @param string $encoding Encoding to set - */ + */ public function setEncoding($encoding) { $this->_encoding = $encoding; } - + /** * Iterate internal counter by one * @@ -175,10 +164,10 @@ class Template { */ public function reset() { $this->dyn_cnt = 0; - $this->needles = array (); - $this->replacements = array (); - $this->Dyn_needles = array (); - $this->Dyn_replacements = array (); + $this->needles = array(); + $this->replacements = array(); + $this->Dyn_needles = array(); + $this->Dyn_replacements = array(); } /** @@ -193,27 +182,27 @@ class Template { */ public function generate($template, $return = 0, $note = 0) { global $cCurrentModule; - + $cfg = cRegistry::getConfig(); $aCfgClient = cRegistry::getClientConfig(cRegistry::getClientId()); $bModTplUsed = FALSE; - - if(isset($cCurrentModule) && $cfg['dceModEdit']['use']) { + + if (isset($cCurrentModule) && $cfg['dceModEdit']['use']) { cInclude('includes', 'functions.upl.php'); $tmpModule = new cApiModule; $tmpModule->loadByPrimaryKey($cCurrentModule); $sModName = strtolower(uplCreateFriendlyName($tmpModule->get('name'))); $aModFileEditConf = $tmpModule->getModFileEditConf(); unset($tmpModule); - $sTmpPath = $aModFileEditConf['modPath'].$sModName."/template/".$template; - if(is_readable($sTmpPath)) { + $sTmpPath = $aModFileEditConf['modPath'] . $sModName . "/template/" . $template; + if (is_readable($sTmpPath)) { $template = $sTmpPath; $bModTplUsed = TRUE; } } - - if(is_file("templates/".$template) && !$bModTplUsed) { - $template = "templates/".$template; + + if (is_file("templates/" . $template) && !$bModTplUsed) { + $template = "templates/" . $template; } //check if the template is a file or a string @@ -222,53 +211,52 @@ class Template { } else { $content = implode("", file($template)); //template is a file } - - $content = (($note) ? "\n" : "").$content; - + + $content = (($note) ? "\n" : "") . $content; + $pieces = array(); //replace i18n strings before replacing other placeholders $this->replacei18n($content, "i18n"); $this->replacei18n($content, "trans"); - - //if content has dynamic blocks - if (preg_match("/^.*".preg_quote($this->tags['start'], "/").".*?".preg_quote($this->tags['end'], "/").".*$/s", $content)) { - //split everything into an array - preg_match_all("/^(.*)".preg_quote($this->tags['start'], "/")."(.*?)".preg_quote($this->tags['end'], "/")."(.*)$/s", $content, $pieces); - //safe memory - array_shift($pieces); - $content = ""; - //now combine pieces together + //if content has dynamic blocks + if (preg_match("/^.*" . preg_quote($this->tags['start'], "/") . ".*?" . preg_quote($this->tags['end'], "/") . ".*$/s", $content)) { + //split everything into an array + preg_match_all("/^(.*)" . preg_quote($this->tags['start'], "/") . "(.*?)" . preg_quote($this->tags['end'], "/") . "(.*)$/s", $content, $pieces); + //safe memory + array_shift($pieces); + $content = ""; + //now combine pieces together //start block - $content .= str_replace($this->needles, $this->replacements, $pieces[0][0]); - unset ($pieces[0][0]); + $content .= str_replace($this->needles, $this->replacements, $pieces[0][0]); + unset($pieces[0][0]); //generate dynamic blocks - for ($a = 0; $a < $this->dyn_cnt; $a ++) { - $content .= str_replace($this->Dyn_needles[$a], $this->Dyn_replacements[$a], $pieces[1][0]); + for ($a = 0; $a < $this->dyn_cnt; $a ++) { + $content .= str_replace($this->Dyn_needles[$a], $this->Dyn_replacements[$a], $pieces[1][0]); } - unset ($pieces[1][0]); + unset($pieces[1][0]); //end block $content .= str_replace($this->needles, $this->replacements, $pieces[2][0]); - unset ($pieces[2][0]); + unset($pieces[2][0]); } else { $content = str_replace($this->needles, $this->replacements, $content); } - + if ($this->_encoding != "") { - $content = str_replace("", ''."\n".'', $content); + $content = str_replace("", '' . "\n" . '', $content); } - + # ExtendedTemplate if (count($this->array_registeredParsers)) { - foreach($this->array_registeredParsers as $class) { + foreach ($this->array_registeredParsers as $class) { if (is_string($class)) { $classInstance = new $class; - } elseif(is_object($class)) { + } elseif (is_object($class)) { $classInstance = $class; } - + if (is_object($classInstance)) { if (is_subclass_of($classInstance, "clAbstractTemplateParser")) { $content = $classInstance->parse($content); @@ -279,15 +267,17 @@ class Template { } } } - + if ($return) { return $content; } else { echo $content; } - } # end function + } - /** +# end function + + /** * replacei18n() * * Replaces a named function with the translated variant @@ -295,7 +285,7 @@ class Template { * @param string $template Contents of the template to translate (it is reference to save memory!!!) * @param string $functionName Name of the translation function (e.g. i18n) * @return void - */ + */ public function replacei18n(& $template, $functionName) { $container = array(); // Be sure that php code stays unchanged @@ -304,37 +294,40 @@ class Template { $x = 0; foreach ($php_matches[0] as $php_match) { $x++; - $template = str_replace($php_match , "{PHP#".$x."#PHP}", $template); + $template = str_replace($php_match, "{PHP#" . $x . "#PHP}", $template); $container[$x] = $php_match; } } // If template contains functionName + parameter store all matches $matches = array(); - preg_match_all("/".preg_quote($functionName, "/")."\\(([\\\"\\'])(.*?)\\1\\)/s", $template, $matches); - + preg_match_all("/" . preg_quote($functionName, "/") . "\\(([\\\"\\'])(.*?)\\1\\)/s", $template, $matches); + // Execute the translation code $matches = array_values(array_unique($matches[2])); for ($a = 0; $a < count($matches); $a ++) { - $template = preg_replace("/".preg_quote($functionName, "/")."\\([\\\"\\']".preg_quote($matches[$a], "/")."[\\\"\\']\\)/s", i18n($matches[$a], $this->_sDomain), $template); + $template = preg_replace("/" . preg_quote($functionName, "/") . "\\([\\\"\\']" . preg_quote($matches[$a], "/") . "[\\\"\\']\\)/s", i18n($matches[$a], $this->_sDomain), $template); } - + // Change back php placeholder if (count($container)) { foreach ($container as $x => $php_match) { // If php code contains functionName + parameter store all matches $matches = array(); - preg_match_all("/".preg_quote($functionName, "/")."\\(([\\\"\\'])(.*?)\\1\\)/s", $php_match, $matches); - + preg_match_all("/" . preg_quote($functionName, "/") . "\\(([\\\"\\'])(.*?)\\1\\)/s", $php_match, $matches); + // Execute the translation code $matches = array_values(array_unique($matches[2])); for ($a = 0; $a < count($matches); $a ++) { - $php_match = preg_replace("/".preg_quote($functionName, "/")."\\([\\\"\\']".preg_quote($matches[$a], "/")."[\\\"\\']\\)/s", '"' . i18n($matches[$a] . '"', $this->_sDomain), $php_match); + $php_match = preg_replace("/" . preg_quote($functionName, "/") . "\\([\\\"\\']" . preg_quote($matches[$a], "/") . "[\\\"\\']\\)/s", '"' . i18n($matches[$a] . '"', $this->_sDomain), $php_match); } - - $template = str_replace("{PHP#".$x."#PHP}" , $php_match, $template); + + $template = str_replace("{PHP#" . $x . "#PHP}", $php_match, $template); } } } -} # end class + +} + +# end class ?> \ No newline at end of file diff --git a/trunk/conlite/classes/tree/class.ctree.php b/trunk/conlite/classes/tree/class.ctree.php index 08292de..4573efd 100644 --- a/trunk/conlite/classes/tree/class.ctree.php +++ b/trunk/conlite/classes/tree/class.ctree.php @@ -1,4 +1,5 @@ setName($name); - } // end of member function setTreeName +class cTree extends cTreeItem { - function setIcon ( $path ) - { - $this->_treeIcon = $path; - } + var $_treeIcon; + function __construct($name = "") { + /* The root item currently has to be a "0". + * This is a bug, feel free to fix it. */ + cTreeItem::__construct(0, $name); + } -} // end of cTree -?> + /** + * sets a new name for the tree. + * + * @param string name Name of the tree + * @return void + * @access public + */ + function setTreeName($name) { + $this->setName($name); + } + +// end of member function setTreeName + + function setIcon($path) { + $this->_treeIcon = $path; + } + +} diff --git a/trunk/conlite/classes/tree/class.ctreeitem.php b/trunk/conlite/classes/tree/class.ctreeitem.php index cd4422d..4d22b85 100644 --- a/trunk/conlite/classes/tree/class.ctreeitem.php +++ b/trunk/conlite/classes/tree/class.ctreeitem.php @@ -1,4 +1,5 @@ _id = $id; - $this->_name = $name; - $this->_collapsed = $collapsed; - $this->_subitems = array(); - $this->_parent = false; - $this->_next = false; - $this->_previous = false; - $this->_attributes = array(); - } - /** - * Imports a table from an array of arrays. Array format: - * array( - * array("id" => "Item ID", "name" => "Item name", "level" => 1, "collapsed" => true|false, "attributes" => array("attr_name" => "attr_value")) - * ); - * - * The entries "collapsed" and "attributes" are optional! - * - * @param array flat_array See above - * @return void - * @access public - */ - function importTable( $flat_array ) - { - $lastobj[0] = $this->_id; - $currentlevel = 1; - - if (!is_array($flat_array)) - { - return false; - } - - foreach ($flat_array as $item) - { - $mitem[$item["id"]] = new cTreeItem($item["id"], $item["name"]); - - if ($item["level"] > $currentlevel) - { - $currentlevel++; - } - - if ($item["level"] < $currentlevel) - { - $currentlevel= $item["level"]; - } - - if (is_array($item["attributes"])) - { - $mitem[$item["id"]]->setAttributes($item["attributes"]); - } - - if (array_key_exists("collapsed", $item)) - { - $mitem[$item["id"]]->setCollapsed($item["collapsed"]); - } + function __construct($id = "", $name = "", $collapsed = false) { + $this->_id = $id; + $this->_name = $name; + $this->_collapsed = $collapsed; + $this->_subitems = array(); + $this->_parent = false; + $this->_next = false; + $this->_previous = false; + $this->_attributes = array(); + } - /* Set payload object */ - if (array_key_exists("payload", $item)) - { - $mitem[$item["id"]]->setPayloadObject($item["payload"]); - } - - - if (is_object($mitem[$lastobj[$currentlevel-1]])) - { - $mitem[$lastobj[$currentlevel-1]]->addItem($mitem[$item["id"]]); - } else { - $this->addItemToID($lastobj[$currentlevel-1], $mitem[$item["id"]]); - } + /** + * Imports a table from an array of arrays. Array format: + * array( + * array("id" => "Item ID", "name" => "Item name", "level" => 1, "collapsed" => true|false, "attributes" => array("attr_name" => "attr_value")) + * ); + * + * The entries "collapsed" and "attributes" are optional! + * + * @param array flat_array See above + * @return void + * @access public + */ + function importTable($flat_array) { + $lastobj[0] = $this->_id; + $currentlevel = 1; - $lastobj[$currentlevel] = $item["id"]; - - } - - } // end of member function importTree + if (!is_array($flat_array)) { + return false; + } - function importStructuredArray ($array) - { - $i = array(); - - $lastid = 1; - $level = 1; - - $this->_flattenArray($array, $i, $lastid, $level); - - - $this->importTable($i); - - } - - function _flattenArray ($sourcearray, &$destarray, &$lastid, &$level) - { - if ($lastid == false) - { - $lastid = 1; - } - - if ($level == false) - { - $level = 1; - } - - if (!is_array($sourcearray)) - { - return false; - } - - foreach ($sourcearray as $id => $item) - { - $lastid++; - $destarray[$lastid]["id"] = $item["class"].".".$id; - - /* Name should be fetched via the meta object */ - $meta = $item["object"]->getMetaObject(); - - if (is_object($meta)) - { - $destarray[$lastid]["name"] = $meta->getName(); - } - - $destarray[$lastid]["level"] = $level; - $destarray[$lastid]["payload"] = $item["object"]; - - if (count($item["items"]) > 0) - { - $level++; - $this->_flattenArray($item["items"], $destarray, $lastid, $level); - $level--; - } - } - } - /** - * Exports a tree as an array of arrays. Array format: - * array( - * array("id" => "Item ID", "name" => "Item name", "level" => 1, "attributes" => array("attr_name" => "attr_value")) - * ); - * - * @return array - * @access public - */ - function exportTree( ) - { - /* TODO: Function can't work... work in progress... - $myobj->traverse($objlist); - */ - } // end of member function exportTree + foreach ($flat_array as $item) { + $mitem[$item["id"]] = new cTreeItem($item["id"], $item["name"]); - /** - * adds an item as a subitem to the current item - * - * @param cTreeItem item item object to add - * @return void - * @access public - */ - function addItem( &$item ) - { - /* Update last item */ - if ($lastitem = end($this->_subitems) !== false) - { - $this->_subitems[key($this->_subitems)]->_next = $item->_id; - } - - $this->_subitems[count($this->_subitems)] = &$item; - $item->_parent = $this->_id; - $item->_previous = $lastitem->_id; - } // end of member function addItem + if ($item["level"] > $currentlevel) { + $currentlevel++; + } - /** - * adds an item to a specific ID - * - * @param string id ID to add the item to - * @param cTreeItem item Item to add - * @return void - * @access public - */ - function addItemToID( $id, &$item ) - { - if ($this->_id == $id) - { - - /* Update last item */ - if ($lastitem = end($this->_subitems) !== false) - { - $this->_subitems[key($this->_subitems)]->_next = $item->_id; - } - - $this->_subitems[count($this->_subitems)] = &$item; - $item->_parent = $this->_id; - $item->_previous = $lastitem->_id; - return true; - - } else { - foreach (array_keys($this->_subitems) as $key) - { - $result = $this->_subitems[$key]->addItemToID($id, $item); - - if ($result == true) - { - return true; - } - } - } - - return false; - - } // end of member function addItemToID + if ($item["level"] < $currentlevel) { + $currentlevel = $item["level"]; + } - /** - * moves an item to another object - * - * @param cTreeItem targetItem Item to move the subitem to - * @param mixed itemToMove cTreeItem-Object or id of object to move - * @return void - * @access public - */ - function moveItem( $targetItem, $itemToMove ) - { - - } // end of member function moveItem + if (is_array($item["attributes"])) { + $mitem[$item["id"]]->setAttributes($item["attributes"]); + } - /** - * deletes a subitem - * - * @param mixed item object or ID to delete - * @return deleted object - * @access public - */ - function deleteItem( $id ) - { - foreach (array_keys($this->_subitems) as $key) - { - if ($this->_subitems[$key]->_id == $id) - { - /* Fetch next item, reset to current item */ - $nextitem = next($this->_subitems); - $nkey = key($this->_subitems); - prev($this->_subitems); - - $previtem = &prev($this->_subitems); - $pkey = key($this->_subitems); - next($this->_subitems); - - - if ($nextitem !== false) - { - if ($previtem !== false) - { - $this->_subitems[$nkey]->_previous = $this->_subitems[$pkey]->_id; - } - } - - if ($previtem !== false) - { - if ($nextitem !== false) - { - $this->_subitems[$pkey]->_next = $this->_subitems[$nkey]->_id; - } - } - - $itemcopy = $this->_subitems[$key]; - unset($this->_subitems[$key]); - - return ($itemcopy); - } else { - $this->_subitems[$key]->deleteItem($id); - } - } - } // end of member function deleteItem + if (array_key_exists("collapsed", $item)) { + $mitem[$item["id"]]->setCollapsed($item["collapsed"]); + } - /** - * Retrieves a specific item by its ID. Note that this - * function traverses all subitems to find the correct item. - * - * @param string id ID to retrieve - * @return cTreeItem - * @access public - */ - function &getItemByID( $id ) - { - if ($this->_id == $id) - { - return ($this); - } else { - foreach (array_keys($this->_subitems) as $key) - { - $retObj = &$this->_subitems[$key]->getItemByID($id); - if ($retObj->_id == $id) - { - return ($retObj); - } - } - } - - return false; - } // end of member function getItemByID - - /** - * sets a custom attribute for this TreeItem - * - * @param string attributeName - * @param array attributeValue The value(s) of the attribute - * @return void - * @access public - */ - function setAttribute( $attributeName, $attributeValue ) - { - $this->_attributes[$attributeName] = $attributeValue; - } // end of member function setAttribute - - /** - * sets a bunch of attributes - * - * @param string attributeName - * @param array attributeValue The value(s) of the attribute - * @return void - * @access public - */ - function setAttributes( $aAttributeArray ) - { - $this->_attributes = array_merge($aAttributeArray, $this->_attributes); - } // end of member function setAttribute - - /** - * returns an attribute - * - * @param string attributeName - * @return mixed - * @access public - */ - function getAttribute( $attributeName ) - { - if (array_key_exists($attributeName, $this->_attributes)) - { - return ($this->_attributes[$attributeName]); - } else { - return false; - } - } // end of member function getAttribute - - /** - * deletes an attribute - * - * @param string attributeName - * @return void - * @access public - */ - function deleteAttribute( $attributeName ) - { - if (array_key_exists($attributeName, $this->_attributes)) - { - unset($this->_attributes[$attributeName]); - return true; - } else { - return false; - } - } // end of member function deleteAttribute - - function hasAttribute ($attributeName, $bRecursive = false) - { - if (array_key_exists($attributeName, $this->_attributes)) - { - return true; - } else { - if ($bRecursive == true) - { - if (count($this->_subitems) > 0) - { - foreach ($this->_subitems as $oSubitem) - { - $bFound = $oSubitem->hasAttribute($attributeName, true); - - if ($bFound == true) - { - return true; - } - } - } - - return false; - } else { - return false; - } - } - } - /** - * - * - * @param mixed expand ID of item to expand or array of item ID's to expand - * @return void - * @access public - */ - function setExpanded( $id ) - { - if (is_array($id)) - { - if (in_array($this->_id, $id, true)) - { - $this->_collapsed = false; - } - - foreach (array_keys($this->_subitems) as $key) - { - $this->_subitems[$key]->setExpanded($id); - } - } else { - if ($this->_id === $id) - { - $this->_collapsed = false; - return true; - } else { - foreach (array_keys($this->_subitems) as $key) - { - $this->_subitems[$key]->setExpanded($id); - } - } - } - } // end of member function setExpanded - - /** - * - * - * @param mixed collapse ID to collapse or an array with items to collapse - * @return void - * @access public - */ - function setCollapsed( $id ) - { - if (is_array($id)) - { - if (in_array($this->_id, $id, true)) - { - $this->_collapsed = true; - } - - foreach (array_keys($this->_subitems) as $key) - { - $this->_subitems[$key]->setCollapsed($id); - } - } else { - if ($this->_id === $id) - { - $this->_collapsed = true; - return true; - } else { - foreach (array_keys($this->_subitems) as $key) - { - $this->_subitems[$key]->setCollapsed($id); - } - } - } - } // end of member function setCollapsed - - /** - * - * - * @param int leveloffset Level offset. Ignores all expand operations below the offset. - * @return void - * @access public - */ - function expandBelowLevel ($leveloffset) - { - if ($leveloffset > 0) - { - $leveloffset--; - } else { - $this->_collapsed = false; - } - - foreach (array_keys($this->_subitems) as $key) - { - $this->_subitems[$key]->expandBelowLevel($leveloffset); - } - } // end of member function expandBelowLevel - - /** - * - * - * @param int leveloffset Level offset. Ignores all expand operations below the offset. - * @return void - * @access public - */ - function collapseBelowLevel ($leveloffset) - { - if ($leveloffset > 0) - { - $leveloffset--; - } else { - $this->_collapsed = true; - } - - foreach (array_keys($this->_subitems) as $key) - { - $this->_subitems[$key]->collapseBelowLevel($leveloffset); - } - } // end of member function expandBelowLevel + /* Set payload object */ + if (array_key_exists("payload", $item)) { + $mitem[$item["id"]]->setPayloadObject($item["payload"]); + } - /** - * - * - * @param int leveloffset Level offset. Ignores all expand operations below the offset. - * @return void - * @access public - */ - function expandBelowID ($id, $found = false) - { - if ($found === true) - { - $this->_collapsed = false; - } - - if ($this->_id == $id) - { - $found = true; - $this->_collapsed = false; - } - - foreach (array_keys($this->_subitems) as $key) - { - $this->_subitems[$key]->expandBelowID($id, $found); - } - } // end of member function expandBelowLevel + if (is_object($mitem[$lastobj[$currentlevel - 1]])) { + $mitem[$lastobj[$currentlevel - 1]]->addItem($mitem[$item["id"]]); + } else { + $this->addItemToID($lastobj[$currentlevel - 1], $mitem[$item["id"]]); + } - /** - * - * - * @param int leveloffset Level offset. Ignores all expand operations below the offset. - * @return void - * @access public - */ - function collapseBelowID ($id, $found = false) - { - if ($found === true) - { - $this->_collapsed = true; - } - - if ($this->_id == $id) - { - $found = true; - $this->_collapsed = true; - } - - foreach (array_keys($this->_subitems) as $key) - { - $this->_subitems[$key]->collapseBelowID($id, $found); - } - } // end of member function expandBelowLevel + $lastobj[$currentlevel] = $item["id"]; + } + } - /** +// end of member function importTree + + function importStructuredArray($array) { + $i = array(); + + $lastid = 1; + $level = 1; + + $this->_flattenArray($array, $i, $lastid, $level); + + + $this->importTable($i); + } + + function _flattenArray($sourcearray, &$destarray, &$lastid, &$level) { + if ($lastid == false) { + $lastid = 1; + } + + if ($level == false) { + $level = 1; + } + + if (!is_array($sourcearray)) { + return false; + } + + foreach ($sourcearray as $id => $item) { + $lastid++; + $destarray[$lastid]["id"] = $item["class"] . "." . $id; + + /* Name should be fetched via the meta object */ + $meta = $item["object"]->getMetaObject(); + + if (is_object($meta)) { + $destarray[$lastid]["name"] = $meta->getName(); + } + + $destarray[$lastid]["level"] = $level; + $destarray[$lastid]["payload"] = $item["object"]; + + if (count($item["items"]) > 0) { + $level++; + $this->_flattenArray($item["items"], $destarray, $lastid, $level); + $level--; + } + } + } + + /** + * Exports a tree as an array of arrays. Array format: + * array( + * array("id" => "Item ID", "name" => "Item name", "level" => 1, "attributes" => array("attr_name" => "attr_value")) + * ); + * + * @return array + * @access public + */ + function exportTree() { + /* TODO: Function can't work... work in progress... + $myobj->traverse($objlist); + */ + } + +// end of member function exportTree + + /** + * adds an item as a subitem to the current item + * + * @param cTreeItem item item object to add + * @return void + * @access public + */ + function addItem(&$item) { + /* Update last item */ + if ($lastitem = end($this->_subitems) !== false) { + $this->_subitems[key($this->_subitems)]->_next = $item->_id; + } + + $this->_subitems[count($this->_subitems)] = &$item; + $item->_parent = $this->_id; + $item->_previous = $lastitem->_id; + } + +// end of member function addItem + + /** + * adds an item to a specific ID + * + * @param string id ID to add the item to + * @param cTreeItem item Item to add + * @return void + * @access public + */ + function addItemToID($id, &$item) { + if ($this->_id == $id) { + + /* Update last item */ + if ($lastitem = end($this->_subitems) !== false) { + $this->_subitems[key($this->_subitems)]->_next = $item->_id; + } + + $this->_subitems[count($this->_subitems)] = &$item; + $item->_parent = $this->_id; + $item->_previous = $lastitem->_id; + return true; + } else { + foreach (array_keys($this->_subitems) as $key) { + $result = $this->_subitems[$key]->addItemToID($id, $item); + + if ($result == true) { + return true; + } + } + } + + return false; + } + +// end of member function addItemToID + + /** + * moves an item to another object + * + * @param cTreeItem targetItem Item to move the subitem to + * @param mixed itemToMove cTreeItem-Object or id of object to move + * @return void + * @access public + */ + function moveItem($targetItem, $itemToMove) { + + } + +// end of member function moveItem + + /** + * deletes a subitem + * + * @param mixed item object or ID to delete + * @return deleted object + * @access public + */ + function deleteItem($id) { + foreach (array_keys($this->_subitems) as $key) { + if ($this->_subitems[$key]->_id == $id) { + /* Fetch next item, reset to current item */ + $nextitem = next($this->_subitems); + $nkey = key($this->_subitems); + prev($this->_subitems); + + $previtem = &prev($this->_subitems); + $pkey = key($this->_subitems); + next($this->_subitems); + + + if ($nextitem !== false) { + if ($previtem !== false) { + $this->_subitems[$nkey]->_previous = $this->_subitems[$pkey]->_id; + } + } + + if ($previtem !== false) { + if ($nextitem !== false) { + $this->_subitems[$pkey]->_next = $this->_subitems[$nkey]->_id; + } + } + + $itemcopy = $this->_subitems[$key]; + unset($this->_subitems[$key]); + + return ($itemcopy); + } else { + $this->_subitems[$key]->deleteItem($id); + } + } + } + +// end of member function deleteItem + + /** + * Retrieves a specific item by its ID. Note that this + * function traverses all subitems to find the correct item. + * + * @param string id ID to retrieve + * @return cTreeItem + * @access public + */ + function &getItemByID($id) { + if ($this->_id == $id) { + return ($this); + } else { + foreach (array_keys($this->_subitems) as $key) { + $retObj = &$this->_subitems[$key]->getItemByID($id); + if ($retObj->_id == $id) { + return ($retObj); + } + } + } + + return false; + } + +// end of member function getItemByID + + /** + * sets a custom attribute for this TreeItem + * + * @param string attributeName + * @param array attributeValue The value(s) of the attribute + * @return void + * @access public + */ + function setAttribute($attributeName, $attributeValue) { + $this->_attributes[$attributeName] = $attributeValue; + } + +// end of member function setAttribute + + /** + * sets a bunch of attributes + * + * @param string attributeName + * @param array attributeValue The value(s) of the attribute + * @return void + * @access public + */ + function setAttributes($aAttributeArray) { + $this->_attributes = array_merge($aAttributeArray, $this->_attributes); + } + +// end of member function setAttribute + + /** + * returns an attribute + * + * @param string attributeName + * @return mixed + * @access public + */ + function getAttribute($attributeName) { + if (array_key_exists($attributeName, $this->_attributes)) { + return ($this->_attributes[$attributeName]); + } else { + return false; + } + } + +// end of member function getAttribute + + /** + * deletes an attribute + * + * @param string attributeName + * @return void + * @access public + */ + function deleteAttribute($attributeName) { + if (array_key_exists($attributeName, $this->_attributes)) { + unset($this->_attributes[$attributeName]); + return true; + } else { + return false; + } + } + +// end of member function deleteAttribute + + function hasAttribute($attributeName, $bRecursive = false) { + if (array_key_exists($attributeName, $this->_attributes)) { + return true; + } else { + if ($bRecursive == true) { + if (count($this->_subitems) > 0) { + foreach ($this->_subitems as $oSubitem) { + $bFound = $oSubitem->hasAttribute($attributeName, true); + + if ($bFound == true) { + return true; + } + } + } + + return false; + } else { + return false; + } + } + } + + /** + * + * + * @param mixed expand ID of item to expand or array of item ID's to expand + * @return void + * @access public + */ + function setExpanded($id) { + if (is_array($id)) { + if (in_array($this->_id, $id, true)) { + $this->_collapsed = false; + } + + foreach (array_keys($this->_subitems) as $key) { + $this->_subitems[$key]->setExpanded($id); + } + } else { + if ($this->_id === $id) { + $this->_collapsed = false; + return true; + } else { + foreach (array_keys($this->_subitems) as $key) { + $this->_subitems[$key]->setExpanded($id); + } + } + } + } + +// end of member function setExpanded + + /** + * + * + * @param mixed collapse ID to collapse or an array with items to collapse + * @return void + * @access public + */ + function setCollapsed($id) { + if (is_array($id)) { + if (in_array($this->_id, $id, true)) { + $this->_collapsed = true; + } + + foreach (array_keys($this->_subitems) as $key) { + $this->_subitems[$key]->setCollapsed($id); + } + } else { + if ($this->_id === $id) { + $this->_collapsed = true; + return true; + } else { + foreach (array_keys($this->_subitems) as $key) { + $this->_subitems[$key]->setCollapsed($id); + } + } + } + } + +// end of member function setCollapsed + + /** + * + * + * @param int leveloffset Level offset. Ignores all expand operations below the offset. + * @return void + * @access public + */ + function expandBelowLevel($leveloffset) { + if ($leveloffset > 0) { + $leveloffset--; + } else { + $this->_collapsed = false; + } + + foreach (array_keys($this->_subitems) as $key) { + $this->_subitems[$key]->expandBelowLevel($leveloffset); + } + } + +// end of member function expandBelowLevel + + /** + * + * + * @param int leveloffset Level offset. Ignores all expand operations below the offset. + * @return void + * @access public + */ + function collapseBelowLevel($leveloffset) { + if ($leveloffset > 0) { + $leveloffset--; + } else { + $this->_collapsed = true; + } + + foreach (array_keys($this->_subitems) as $key) { + $this->_subitems[$key]->collapseBelowLevel($leveloffset); + } + } + +// end of member function expandBelowLevel + + /** + * + * + * @param int leveloffset Level offset. Ignores all expand operations below the offset. + * @return void + * @access public + */ + function expandBelowID($id, $found = false) { + if ($found === true) { + $this->_collapsed = false; + } + + if ($this->_id == $id) { + $found = true; + $this->_collapsed = false; + } + + foreach (array_keys($this->_subitems) as $key) { + $this->_subitems[$key]->expandBelowID($id, $found); + } + } + +// end of member function expandBelowLevel + + /** + * + * + * @param int leveloffset Level offset. Ignores all expand operations below the offset. + * @return void + * @access public + */ + function collapseBelowID($id, $found = false) { + if ($found === true) { + $this->_collapsed = true; + } + + if ($this->_id == $id) { + $found = true; + $this->_collapsed = true; + } + + foreach (array_keys($this->_subitems) as $key) { + $this->_subitems[$key]->collapseBelowID($id, $found); + } + } + +// end of member function expandBelowLevel + + /** * getCollapsedList - * Returns all items (as ID array) which are collapsed. - * @param array $list Contains the list with all collapsed items - */ - function getCollapsedList (&$list) - { - if (!is_array($list)) - { - $list = array(); - } - - if ($this->_collapsed == true) - { - $list[] = $this->_id; - } - - foreach (array_keys($this->_subitems) as $key) - { - $this->_subitems[$key]->getCollapsedList($list); - } - } + * Returns all items (as ID array) which are collapsed. + * @param array $list Contains the list with all collapsed items + */ + function getCollapsedList(&$list) { + if (!is_array($list)) { + $list = array(); + } - /** + if ($this->_collapsed == true) { + $list[] = $this->_id; + } + + foreach (array_keys($this->_subitems) as $key) { + $this->_subitems[$key]->getCollapsedList($list); + } + } + + /** * getExpandedList - * Returns all items (as ID array) which are expanded. - * @param array $list Contains the list with all expanded items - */ - function getExpandedList (&$list) - { - if (!is_array($list)) - { - $list = array(); - } - - if ($this->_collapsed == false && !in_array($this->_id, $list)) - { - $list[] = $this->_id; - } - - foreach (array_keys($this->_subitems) as $key) - { - $this->_subitems[$key]->getExpandedList($list); - } - } - - /** - * sets a payload object for later reference - * - * @param object payload The object to payload - * @return void - * @access public - */ - function setPayloadObject ($payload) - { - $this->payload = $payload; - } // end of member function setPayloadObject + * Returns all items (as ID array) which are expanded. + * @param array $list Contains the list with all expanded items + */ + function getExpandedList(&$list) { + if (!is_array($list)) { + $list = array(); + } - /** - * unsets a payload object - * - * @return object - * @access public - */ - function unsetPayloadObject( ) - { - - } // end of member function unsetPayloadObject + if ($this->_collapsed == false && !in_array($this->_id, $list)) { + $list[] = $this->_id; + } + foreach (array_keys($this->_subitems) as $key) { + $this->_subitems[$key]->getExpandedList($list); + } + } - /** + /** + * sets a payload object for later reference + * + * @param object payload The object to payload + * @return void + * @access public + */ + function setPayloadObject($payload) { + $this->payload = $payload; + } + +// end of member function setPayloadObject + + /** + * unsets a payload object + * + * @return object + * @access public + */ + function unsetPayloadObject() { + + } + +// end of member function unsetPayloadObject + + /** * traverse - * traverses the tree starting from this item, and returning - * all objects as $objects in a nested array. - * @param object $objects all found objects - * @param integer $level Level to start on - */ - function traverse (&$objects, $level = 0) - { - $objects[count($objects)] = &$this; - $this->_level = $level; - - if ($this->_collapsed == false) - { - foreach (array_keys($this->_subitems) as $key) - { - $this->_subitems[$key]->traverse($objects, $level + 1); - } - } - - } - - /** + * traverses the tree starting from this item, and returning + * all objects as $objects in a nested array. + * @param object $objects all found objects + * @param integer $level Level to start on + */ + function traverse(&$objects, $level = 0) { + $objects[count($objects)] = &$this; + $this->_level = $level; + + if ($this->_collapsed == false) { + foreach (array_keys($this->_subitems) as $key) { + $this->_subitems[$key]->traverse($objects, $level + 1); + } + } + } + + /** * flatTraverse - * traverses the tree starting from this item, and returning - * all objects as $objects in a flat array. - * @param object $objects all found objects - * @param integer $level Level to start on - */ - function flatTraverse ($level = 0) - { - $objects[] = &$this; - $this->_level = $level; - - if ($this->_collapsed == false) - { - foreach (array_keys($this->_subitems) as $key) - { - $objects = array_merge($objects, $this->_subitems[$key]->flatTraverse($level + 1)); - } - } - - return $objects; - - } + * traverses the tree starting from this item, and returning + * all objects as $objects in a flat array. + * @param object $objects all found objects + * @param integer $level Level to start on + */ + function flatTraverse($level = 0) { + $objects[] = &$this; + $this->_level = $level; - /** + if ($this->_collapsed == false) { + foreach (array_keys($this->_subitems) as $key) { + $objects = array_merge($objects, $this->_subitems[$key]->flatTraverse($level + 1)); + } + } + + return $objects; + } + + /** * setName - * sets the Name for this item. - * @param string $name New name for this item - * @return none - */ - function setName ($name) - { - $this->_name = $name; - } + * sets the Name for this item. + * @param string $name New name for this item + * @return none + */ + function setName($name) { + $this->_name = $name; + } +} -} // end of cTreeItem +// end of cTreeItem ?> \ No newline at end of file diff --git a/trunk/conlite/classes/widgets/class.views.advancedmenu.php b/trunk/conlite/classes/widgets/class.views.advancedmenu.php index 95245a8..a9dd73b 100644 --- a/trunk/conlite/classes/widgets/class.views.advancedmenu.php +++ b/trunk/conlite/classes/widgets/class.views.advancedmenu.php @@ -1,4 +1,5 @@ \ No newline at end of file diff --git a/trunk/conlite/classes/widgets/class.widgets.actionbutton.php b/trunk/conlite/classes/widgets/class.widgets.actionbutton.php index 3eada28..03258b3 100644 --- a/trunk/conlite/classes/widgets/class.widgets.actionbutton.php +++ b/trunk/conlite/classes/widgets/class.widgets.actionbutton.php @@ -1,4 +1,5 @@ _area = $area; + $this->_area = $area; $this->_frame = 4; $this->_target = "right_bottom"; $this->_link = new cHTMLLink; - $this->_img = new cHTMLImage; + $this->_img = new cHTMLImage; $this->_img->setBorder(0); $this->_img->setStyle("padding-left: 1px; padding-right: 1px;"); @@ -86,26 +82,17 @@ class cApiClickableAction extends cApiAction $this->setEnabled(); } - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function cApiClickableAction() - { - cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); - $this->__construct(); - } - /** * Sets the action icon for this action. * * @param string icon Path to the icon. Relative to the backend, if not passed as absolute path. * @return void */ - public function setIcon($icon) - { + public function setIcon($icon) { $this->_img->setSrc($icon); } - public function getIcon() - { + public function getIcon() { return $this->_img; } @@ -116,10 +103,8 @@ class cApiClickableAction extends cApiAction * using it, otherwise, this method will fail. * @return void */ - public function setNamedAction($actionName) - { - if ($this->loadBy("name", $actionName) !== false) - { + public function setNamedAction($actionName) { + if ($this->loadBy("name", $actionName) !== false) { $a = new cApiArea; $a->loadByPrimaryKey($this->get("idarea")); @@ -131,36 +116,32 @@ class cApiClickableAction extends cApiAction } } - public function setDisabled() - { + public function setDisabled() { $this->_enabled = false; $this->_onDisable(); } - public function setEnabled() - { + public function setEnabled() { $this->_enabled = true; $this->_onEnable(); } - protected function _onDisable() - { + protected function _onDisable() { + } - protected function _onEnable() - { + protected function _onEnable() { + } /** * Change linked area */ - public function changeArea($sArea) - { + public function changeArea($sArea) { $this->_area = $sArea; } - public function wantParameter($parameter) - { + public function wantParameter($parameter) { $this->_wantParameters[] = $parameter; $this->_wantParameters = array_unique($this->_wantParameters); @@ -172,29 +153,24 @@ class cApiClickableAction extends cApiAction * @param string helptext The helptext to apply * @return void */ - public function setHelpText($helptext) - { + public function setHelpText($helptext) { $this->_helpText = $helptext; } - public function getHelpText() - { + public function getHelpText() { return $this->_helpText; } - public function setParameter($name, $value) - { + public function setParameter($name, $value) { $this->_parameters[$name] = $value; } - public function process($parameters) - { + public function process($parameters) { echo "Process should be overridden"; return false; } - public function render() - { + public function render() { $this->_img->setAlt($this->_helpText); foreach ($this->_parameters as $name => $value) { @@ -229,52 +205,39 @@ class cApiClickableAction extends cApiAction return ($this->_helpText); } } + } +class cApiClickableQuestionAction extends cApiClickableAction { -class cApiClickableQuestionAction extends cApiClickableAction -{ - public function __construct() - { + public function __construct() { parent::__construct(); } - /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function cApiClickableQuestionAction() - { - $this->__construct(); - } - - public function setQuestionMode($mode) - { + public function setQuestionMode($mode) { $this->_mode = $mode; } - public function setQuestion($question) - { + public function setQuestion($question) { $this->_question = $question; } - public function setResultVar($var) - { + public function setResultVar($var) { $this->_resultVar = $var; } - public function render() - { - switch ($this->_mode) - { + public function render() { + switch ($this->_mode) { case QUESTIONACTION_PROMPT: - $this->_link->attachEventDefinition("_".get_class($this).rand(), "onclick", 'var answer = prompt("'.clHtmlSpecialChars($this->_question).'");if (answer == null) {return false;} else { this.href = this.href + "&'.$this->_resultVar.'="+answer; return true;}'); + $this->_link->attachEventDefinition("_" . get_class($this) . rand(), "onclick", 'var answer = prompt("' . clHtmlSpecialChars($this->_question) . '");if (answer == null) {return false;} else { this.href = this.href + "&' . $this->_resultVar . '="+answer; return true;}'); break; case QUESTIONACTION_YESNO: default: - $this->_link->attachEventDefinition("_".get_class($this).rand(), "onclick", 'var answer = confirm("'.clHtmlSpecialChars($this->_question).'");if (answer == false) {return false;} else { return true;}'); - break; + $this->_link->attachEventDefinition("_" . get_class($this) . rand(), "onclick", 'var answer = confirm("' . clHtmlSpecialChars($this->_question) . '");if (answer == false) {return false;} else { return true;}'); + break; } return parent::render(); } -} -?> \ No newline at end of file +} diff --git a/trunk/conlite/classes/widgets/class.widgets.actionlist.php b/trunk/conlite/classes/widgets/class.widgets.actionlist.php index cf55cad..b1b69e7 100644 --- a/trunk/conlite/classes/widgets/class.widgets.actionlist.php +++ b/trunk/conlite/classes/widgets/class.widgets.actionlist.php @@ -1,4 +1,5 @@ _metaClass = $dataClass->getMetaObject(); - } - - cFoldingRow::cFoldingRow($uuid, $title); - - $this->_headerData->setBackgroundColor($cfg['color']['table_subheader']); - $this->_headerData->setStyle("font-weight: bold; text-decoration: none; border-bottom: 1px solid ".$cfg['color']['table_border'].";"); - $this->_headerData->setHeight(18); - $this->_headerData->setWidth("100%"); - $this->_contentData->setWidth("100%"); - $this->_link->setStyle("text-decoration: none;"); - $this->_contentData->setStyle("font-weight: bold; border-bottom: 1px solid ".$cfg['color']['table_border'].";"); - - $this->_dark = true; - - - $actions = array($this->_metaClass->_createAction); - - $row = array(); - - foreach ($actions as $action) - { - $row[] = $this->buildAction($action); - } - $t = new cHTMLTable; - $t->setContent($row); - $t->setWidth("100%"); - - $this->_contentData->setContent($t); - - } - - function buildAction ($action) - { - global $cfg; - - if (class_exists($action)) - { - $this->_dark = !$this->_dark; - $class = $this->_metaClass->getAction($action); - - $row = new cHTMLTableRow; - $l = new cHTMLTableData; - $r = new cHTMLTableData; - - $l->setContent($class->render()); - $r->setContent($class->renderText()); - $l->setStyle("padding-left: 14px"); - $r->setStyle("padding-left: 4px"); - $l->setHeight(18); - $r->setHeight(18); - $r->setWidth("100%"); - - if ($this->_dark) - { - $l->setBackgroundColor($cfg["color"]["table_dark"]); - $r->setBackgroundColor($cfg["color"]["table_dark"]); - } else { - $l->setBackgroundColor($cfg["color"]["table_light"]); - $r->setBackgroundColor($cfg["color"]["table_light"]); - } - - $row->setContent(array($l,$r)); - - return $row; - - } - } - - - +if (!defined('CON_FRAMEWORK')) { + die('Illegal call'); } -?> \ No newline at end of file +class cWidgetMenuActionList extends cFoldingRow { + + function __construct($uuid, $title, $dataClassName) { + global $cfg; + + if (!class_exists($dataClassName)) { + cWarning(__FILE__, __LINE__, "Could not instanciate class [$dataClassName] for use in class " . get_class($this)); + return false; + } else { + $dataClass = new $dataClassName; + + if (!is_subclass_of($dataClass, "Item")) { + cWarning(__FILE__, __LINE__, "Passed class [$dataClassName] should be a subclass of [Item]. Parent class is " . get_parent_class($dataClass)); + return; + } + + $this->_metaClass = $dataClass->getMetaObject(); + } + + cFoldingRow::cFoldingRow($uuid, $title); + + $this->_headerData->setBackgroundColor($cfg['color']['table_subheader']); + $this->_headerData->setStyle("font-weight: bold; text-decoration: none; border-bottom: 1px solid " . $cfg['color']['table_border'] . ";"); + $this->_headerData->setHeight(18); + $this->_headerData->setWidth("100%"); + $this->_contentData->setWidth("100%"); + $this->_link->setStyle("text-decoration: none;"); + $this->_contentData->setStyle("font-weight: bold; border-bottom: 1px solid " . $cfg['color']['table_border'] . ";"); + + $this->_dark = true; + + + $actions = array($this->_metaClass->_createAction); + + $row = array(); + + foreach ($actions as $action) { + $row[] = $this->buildAction($action); + } + $t = new cHTMLTable; + $t->setContent($row); + $t->setWidth("100%"); + + $this->_contentData->setContent($t); + } + + function buildAction($action) { + global $cfg; + + if (class_exists($action)) { + $this->_dark = !$this->_dark; + $class = $this->_metaClass->getAction($action); + + $row = new cHTMLTableRow; + $l = new cHTMLTableData; + $r = new cHTMLTableData; + + $l->setContent($class->render()); + $r->setContent($class->renderText()); + $l->setStyle("padding-left: 14px"); + $r->setStyle("padding-left: 4px"); + $l->setHeight(18); + $r->setHeight(18); + $r->setWidth("100%"); + + if ($this->_dark) { + $l->setBackgroundColor($cfg["color"]["table_dark"]); + $r->setBackgroundColor($cfg["color"]["table_dark"]); + } else { + $l->setBackgroundColor($cfg["color"]["table_light"]); + $r->setBackgroundColor($cfg["color"]["table_light"]); + } + + $row->setContent(array($l, $r)); + + return $row; + } + } + +} \ No newline at end of file diff --git a/trunk/conlite/classes/widgets/class.widgets.buttons.php b/trunk/conlite/classes/widgets/class.widgets.buttons.php index ab98fbf..78158ad 100644 --- a/trunk/conlite/classes/widgets/class.widgets.buttons.php +++ b/trunk/conlite/classes/widgets/class.widgets.buttons.php @@ -60,9 +60,9 @@ class cWidgetButton extends cHTMLSpan * @param $alt string Alternative text * @param $link string Link */ - function cWidgetButton ($img, $alt, $link) + function __construct ($img, $alt, $link) { - cHTMLSpan::cHTMLSpan(); + cHTMLSpan::__construct(); $this->_img = new cHTMLImage($img); $this->_link = new cHTMLLink($link); @@ -167,9 +167,9 @@ class cWidgetToggleButton extends cWidgetButton * @param $uplink string Link when the button is turned off (=up) * @param $downlink string Link when the button is turned on (=down) */ - function cWidgetToggleButton ($img, $alt, $uplink, $downlink) + function __construct ($img, $alt, $uplink, $downlink) { - cHTMLSpan::cHTMLSpan(); + cHTMLSpan::__construct(); $this->_img = new cHTMLImage($img); $this->_link = new cHTMLLink("#"); @@ -243,9 +243,9 @@ class cWidgetMultiToggleButton extends cWidgetButton * @param $alt string Alternative text * @param $lnik string Link to call when the button is clicked */ - function cWidgetMultiToggleButton ($img, $alt, $link) + function __construct ($img, $alt, $link) { - cHTMLSpan::cHTMLSpan(); + cHTMLSpan::__construct(); $this->_img = new cHTMLImage($img); $this->_link = new cHTMLLink($link); diff --git a/trunk/conlite/classes/widgets/class.widgets.calendar.php b/trunk/conlite/classes/widgets/class.widgets.calendar.php index 7c35798..06229cc 100644 --- a/trunk/conlite/classes/widgets/class.widgets.calendar.php +++ b/trunk/conlite/classes/widgets/class.widgets.calendar.php @@ -1,4 +1,5 @@ _initFormatting(); - $this->_oDate = new cDatatypeDateTime; - - /* Development: Set today's date */ - $this->_oDate->setSourceFormat(cDateTime_ISO); - - if ($initDate === false) - { - $this->_oDate->set(date("Y-m-d H:i:s")); - } else { - $this->_oDate->set($initDate); - } - } - + var $_oDate; - - function _initFormatting () - { - $this->setClass("calendar"); - $this->setCellSpacing(0); - $this->setCellPadding(0); - } - - function _renderHead () - { - $oHead = new cHTMLTableHeader; - - $aDayOrder = $this->_oDate->getDayOrder(); + function __construct($initDate = false) { + parent::__construct(); - $oRow = new cHTMLTableRow; - - $aData = array(); - - foreach ($aDayOrder as $iDay) - { - $oData = new cHTMLTableData; - $oData->setContent(substr($this->_oDate->getDayName($iDay),0,2)); - - $aData[] = $oData; - } - - $oRow->setContent($aData); - $oHead->setContent($oRow); - - return ($oHead); - } - - function _renderBody () - { - $iRows = 6; - $iDaysPerWeek = 7; - - $oHead = new cHTMLTableBody; - - $aRowData = array(); - - for ($iRow = 0; $iRow < $iRows; $iRow++) - { - $oRow = new cHTMLTableRow; - $aData = array(); - $aDayOrder = $this->_oDate->getDayOrder(); - - foreach ($aDayOrder as $iDay) - { - $oData = new cHTMLTableData; - $oData->setContent(' '); - $oData->setStyle("border: 1px solid white"); - $oData->setId("cal_".$this->getId()."_".$iRow . "_".$iDay); - $aData[] = $oData; - } - $oRow->setContent($aData); - $aRowData[] = $oRow; - } - - $oHead->setContent($aRowData); - - return ($oHead); - } + $this->_initFormatting(); + $this->_oDate = new cDatatypeDateTime; - function _renderJS () - { - $this->_oDate->setSourceFormat(cDateTime_UNIX); - - $oScript = new cHTMLScript; - $sScript = ' + /* Development: Set today's date */ + $this->_oDate->setSourceFormat(cDateTime_ISO); + + if ($initDate === false) { + $this->_oDate->set(date("Y-m-d H:i:s")); + } else { + $this->_oDate->set($initDate); + } + } + + function _initFormatting() { + $this->setClass("calendar"); + $this->setCellSpacing(0); + $this->setCellPadding(0); + } + + function _renderHead() { + $oHead = new cHTMLTableHeader; + + $aDayOrder = $this->_oDate->getDayOrder(); + + $oRow = new cHTMLTableRow; + + $aData = array(); + + foreach ($aDayOrder as $iDay) { + $oData = new cHTMLTableData; + $oData->setContent(substr($this->_oDate->getDayName($iDay), 0, 2)); + + $aData[] = $oData; + } + + $oRow->setContent($aData); + $oHead->setContent($oRow); + + return ($oHead); + } + + function _renderBody() { + $iRows = 6; + $iDaysPerWeek = 7; + + $oHead = new cHTMLTableBody; + + $aRowData = array(); + + for ($iRow = 0; $iRow < $iRows; $iRow++) { + $oRow = new cHTMLTableRow; + $aData = array(); + $aDayOrder = $this->_oDate->getDayOrder(); + + foreach ($aDayOrder as $iDay) { + $oData = new cHTMLTableData; + $oData->setContent(' '); + $oData->setStyle("border: 1px solid white"); + $oData->setId("cal_" . $this->getId() . "_" . $iRow . "_" . $iDay); + $aData[] = $oData; + } + $oRow->setContent($aData); + $aRowData[] = $oRow; + } + + $oHead->setContent($aRowData); + + return ($oHead); + } + + function _renderJS() { + $this->_oDate->setSourceFormat(cDateTime_UNIX); + + $oScript = new cHTMLScript; + $sScript = ' var {cid}_markedDay; var {cid}_markedMonth; @@ -135,7 +123,7 @@ class cCalendarControl extends cHTMLTable {cid}_setDefaultDay(2006, 03, 30); - {cid}_setCalendar('.$this->_oDate->getYear().', '. $this->_oDate->getMonth(). ', '. $this->_oDate->getDay().'); + {cid}_setCalendar(' . $this->_oDate->getYear() . ', ' . $this->_oDate->getMonth() . ', ' . $this->_oDate->getDay() . '); function {cid}_setDefaultDay (year, month, day) { @@ -150,16 +138,16 @@ class cCalendarControl extends cHTMLTable var sMarkedID = ""; var iRow = 0; - var iFirstDayOfWeek = '.$this->_oDate->getFirstDayOfWeek().'; + var iFirstDayOfWeek = ' . $this->_oDate->getFirstDayOfWeek() . '; for (var i=1; i < 32; i++) { mDate.setDate(i); var dayOfWeek = mDate.getDay(); - var lid = "cal_'.$this->getId().'_" + iRow + "_" + dayOfWeek; + var lid = "cal_' . $this->getId() . '_" + iRow + "_" + dayOfWeek; - if (dayOfWeek == '.$this->_oDate->getLeapDay().') + if (dayOfWeek == ' . $this->_oDate->getLeapDay() . ') { iRow++; } @@ -211,13 +199,13 @@ class cCalendarControl extends cHTMLTable {cid}_currentMonth = month; var iRow = 0; - var iFirstDayOfWeek = '.$this->_oDate->getFirstDayOfWeek().'; + var iFirstDayOfWeek = ' . $this->_oDate->getFirstDayOfWeek() . '; for (var i=0; i < 7; i++) { for (var j=0; j< 6; j++) { - var lid = "cal_'.$this->getId().'_" + j + "_" + i; + var lid = "cal_' . $this->getId() . '_" + j + "_" + i; document.getElementById(lid).firstChild.nodeValue = String.fromCharCode(160); document.getElementById(lid).className = ""; {cid}_detachHandler(document.getElementById(lid)); @@ -229,9 +217,9 @@ class cCalendarControl extends cHTMLTable mDate.setDate(i); var dayOfWeek = mDate.getDay(); - var lid = "cal_'.$this->getId().'_" + iRow + "_" + dayOfWeek; + var lid = "cal_' . $this->getId() . '_" + iRow + "_" + dayOfWeek; - if (dayOfWeek == '.$this->_oDate->getLeapDay().') + if (dayOfWeek == ' . $this->_oDate->getLeapDay() . ') { iRow++; } @@ -284,16 +272,16 @@ class cCalendarControl extends cHTMLTable var mDate = new Date(year, month - 1, 1); var iRow = 0; - var iFirstDayOfWeek = '.$this->_oDate->getFirstDayOfWeek().'; + var iFirstDayOfWeek = ' . $this->_oDate->getFirstDayOfWeek() . '; for (var i=1; i < {cid}_GetMonthLength(year, month) + 1; i++) { mDate.setDate(i); var dayOfWeek = mDate.getDay(); - var lid = "cal_'.$this->getId().'_" + iRow + "_" + dayOfWeek; + var lid = "cal_' . $this->getId() . '_" + iRow + "_" + dayOfWeek; - if (dayOfWeek == '.$this->_oDate->getLeapDay().') + if (dayOfWeek == ' . $this->_oDate->getLeapDay() . ') { iRow++; } @@ -376,89 +364,85 @@ class cCalendarControl extends cHTMLTable { switch (iMonth) { - case 1: return("'.$this->_oDate->getMonthName(1).'"); break; - case 2: return("'.$this->_oDate->getMonthName(2).'"); break; - case 3: return("'.$this->_oDate->getMonthName(3).'"); break; - case 4: return("'.$this->_oDate->getMonthName(4).'"); break; - case 5: return("'.$this->_oDate->getMonthName(5).'"); break; - case 6: return("'.$this->_oDate->getMonthName(6).'"); break; - case 7: return("'.$this->_oDate->getMonthName(7).'"); break; - case 8: return("'.$this->_oDate->getMonthName(8).'"); break; - case 9: return("'.$this->_oDate->getMonthName(9).'"); break; - case 10: return("'.$this->_oDate->getMonthName(10).'"); break; - case 11: return("'.$this->_oDate->getMonthName(11).'"); break; - case 12: return("'.$this->_oDate->getMonthName(12).'"); break; + case 1: return("' . $this->_oDate->getMonthName(1) . '"); break; + case 2: return("' . $this->_oDate->getMonthName(2) . '"); break; + case 3: return("' . $this->_oDate->getMonthName(3) . '"); break; + case 4: return("' . $this->_oDate->getMonthName(4) . '"); break; + case 5: return("' . $this->_oDate->getMonthName(5) . '"); break; + case 6: return("' . $this->_oDate->getMonthName(6) . '"); break; + case 7: return("' . $this->_oDate->getMonthName(7) . '"); break; + case 8: return("' . $this->_oDate->getMonthName(8) . '"); break; + case 9: return("' . $this->_oDate->getMonthName(9) . '"); break; + case 10: return("' . $this->_oDate->getMonthName(10) . '"); break; + case 11: return("' . $this->_oDate->getMonthName(11) . '"); break; + case 12: return("' . $this->_oDate->getMonthName(12) . '"); break; } } '; - - $sScript = str_replace("{cid}", $this->getId(), $sScript); - $oScript->setContent($sScript); - - - return $oScript; - } - function _renderMonthDropdown () - { - $oMonthSelect = new cHTMLSelectElement($this->getId() . "_monthselect"); - $oMonthSelect->setId($this->getId() ."_monthselect"); - - $aMonths = array(); - for ($i=1;$i<13;$i++) - { - $aMonths[$i] = $this->_oDate->getMonthName($i); - } - - $oMonthSelect->autoFill($aMonths); - $oMonthSelect->setEvent("change", $this->getId() ."_setCalendar(".$this->getId() ."_currentYear, this.value);"); + $sScript = str_replace("{cid}", $this->getId(), $sScript); + $oScript->setContent($sScript); + + + return $oScript; + } + + function _renderMonthDropdown() { + $oMonthSelect = new cHTMLSelectElement($this->getId() . "_monthselect"); + $oMonthSelect->setId($this->getId() . "_monthselect"); + + $aMonths = array(); + for ($i = 1; $i < 13; $i++) { + $aMonths[$i] = $this->_oDate->getMonthName($i); + } + + $oMonthSelect->autoFill($aMonths); + $oMonthSelect->setEvent("change", $this->getId() . "_setCalendar(" . $this->getId() . "_currentYear, this.value);"); + + return ($oMonthSelect); + } + + function _renderMonthPrev() { + $oMonthLeft = new cHTMLImage; + $oMonthLeft->setSrc("images/month_prev.gif"); + $oMonthLeft->setStyle("border: 0px solid black; cursor: pointer;"); + $oMonthLeft->setEvent("click", $this->getId() . "_monthprev();"); + return $oMonthLeft; + } + + function _renderMonthNext() { + $oMonthLeft = new cHTMLImage; + $oMonthLeft->setSrc("images/month_next.gif"); + $oMonthLeft->setStyle("border: 0px solid black; cursor: pointer;"); + $oMonthLeft->setEvent("click", $this->getId() . "_monthnext();"); + return $oMonthLeft; + } + + function _renderYearControl() { + $oYear = new cHTMLTextbox($this->getId() . "_yearbox", "", 4, 4); + $oYear->setId($this->getId() . "_yearbox"); + $oYear->setEvent("change", $this->getId() . "_setCalendar(this.value, " . $this->getId() . "_currentMonth);"); + + return $oYear; + } + + function render() { + $this->setContent(array($this->_renderHead(), $this->_renderBody(), $this->_renderJS())); + + $oSpan = new cHTMLSpan; + $oSpan->setContent(array('
', $this->_renderMonthPrev(), '', $this->_renderMonthDropdown(), '', $this->_renderYearControl(), '', $this->_renderMonthNext(), '
')); + + + + + + + + return '
' . $oSpan->render() . '
' . parent::render() . '
'; + } - return ($oMonthSelect); - } - - function _renderMonthPrev () - { - $oMonthLeft = new cHTMLImage; - $oMonthLeft->setSrc("images/month_prev.gif"); - $oMonthLeft->setStyle("border: 0px solid black; cursor: pointer;"); - $oMonthLeft->setEvent("click", $this->getId() ."_monthprev();"); - return $oMonthLeft; - } - - function _renderMonthNext () - { - $oMonthLeft = new cHTMLImage; - $oMonthLeft->setSrc("images/month_next.gif"); - $oMonthLeft->setStyle("border: 0px solid black; cursor: pointer;"); - $oMonthLeft->setEvent("click", $this->getId() ."_monthnext();"); - return $oMonthLeft; - } - - function _renderYearControl () - { - $oYear = new cHTMLTextbox ($this->getId() ."_yearbox", "" ,4, 4); - $oYear->setId($this->getId() ."_yearbox"); - $oYear->setEvent("change", $this->getId() ."_setCalendar(this.value, ".$this->getId() ."_currentMonth);"); - - return $oYear; - } - - function render () - { - $this->setContent(array($this->_renderHead(), $this->_renderBody(), $this->_renderJS())); - - $oSpan = new cHTMLSpan; - $oSpan->setContent(array('
', $this->_renderMonthPrev(), '', $this->_renderMonthDropdown(), '', $this->_renderYearControl(), '', $this->_renderMonthNext(), '
')); - - - - - - - - return '
'.$oSpan->render() .'
'.parent::render().'
'; - } } + ?> \ No newline at end of file diff --git a/trunk/conlite/classes/widgets/class.widgets.datawidgets.php b/trunk/conlite/classes/widgets/class.widgets.datawidgets.php index a8f106f..e23066c 100644 --- a/trunk/conlite/classes/widgets/class.widgets.datawidgets.php +++ b/trunk/conlite/classes/widgets/class.widgets.datawidgets.php @@ -5,29 +5,28 @@ * cDataTextWidget generates a textbox widget * for use with the data objects. */ -class cDataTextWidget extends cHTMLTextbox -{ - /** - * cDataTextWidget: Creates a text box widget - * - * @param $name Name of the widget - * @param $parameters Parameters (see below) - * - * valid parameters for this control are: - * default Default value for this box - * - * @return void - * @access public - */ - function cDataTextWidget ($name, $parameters) - { - cHTMLTextbox::cHTMLTextbox($name); - - if (array_key_exists("default", $parameters)) - { - $this->setValue($parameters["default"]); - } - } +class cDataTextWidget extends cHTMLTextbox { + + /** + * cDataTextWidget: Creates a text box widget + * + * @param $name Name of the widget + * @param $parameters Parameters (see below) + * + * valid parameters for this control are: + * default Default value for this box + * + * @return void + * @access public + */ + function __construct($name, $parameters) { + parent::__construct($name); + + if (array_key_exists("default", $parameters)) { + $this->setValue($parameters["default"]); + } + } + } /** @@ -35,204 +34,192 @@ class cDataTextWidget extends cHTMLTextbox * cDataTextareaWidget generates a textarea widget for use with the data objects. * */ -class cDataTextareaWidget extends cHTMLTextarea -{ - /** - * cDataTextareaWidget: Creates a text area widget - * - * @param $name Name of the widget - * @param $parameters Parameters (see below) - * - * valid parameters for this control are: - * default Default value for this area - * - * @return void - * @access public - */ - function cDataTextareaWidget ($name, $parameters) - { - cHTMLTextarea::cHTMLTextarea($name); - - if (array_key_exists("default", $parameters)) - { - $this->setValue($parameters["default"]); - } +class cDataTextareaWidget extends cHTMLTextarea { + + /** + * cDataTextareaWidget: Creates a text area widget + * + * @param $name Name of the widget + * @param $parameters Parameters (see below) + * + * valid parameters for this control are: + * default Default value for this area + * + * @return void + * @access public + */ + function __construct($name, $parameters) { + parent::__construct($name); + + if (array_key_exists("default", $parameters)) { + $this->setValue($parameters["default"]); + } + } - } } /** * class cDataCodeTextareaWidget * cDataCodeTextareaWidget generates a textarea widget for use with the data objects. */ -class cDataCodeTextareaWidget extends cHTMLTextarea -{ - /** - * cDataTextareaWidget: Creates a text area widget - * which can be used for entering code - * - * @param $name Name of the widget - * @param $parameters Parameters (see below) - * - * valid parameters for this control are: - * default Default value for this area - * notes Notes for this area - * - * @return void - * @access public - */ - function cDataCodeTextareaWidget ($name, $parameters) - { - cHTMLTextarea::cHTMLTextarea($name); - - if (array_key_exists("default", $parameters)) - { - $this->setValue($parameters["default"]); - } - - $this->updateAttributes(array("wrap" => "off")); - $this->setStyle("width: 100%; font-family: monospace;"); - $this->setWidth(100); - $this->setHeight(20); - - if (array_key_exists("notes", $parameters)) - { - $this->_notes = $parameters["notes"]; - } - } - - function render () - { - $out = parent::render(); - $out .= $this->_notes; - - return ($out); - } +class cDataCodeTextareaWidget extends cHTMLTextarea { + + /** + * cDataTextareaWidget: Creates a text area widget + * which can be used for entering code + * + * @param $name Name of the widget + * @param $parameters Parameters (see below) + * + * valid parameters for this control are: + * default Default value for this area + * notes Notes for this area + * + * @return void + * @access public + */ + function __construct($name, $parameters) { + parent::__construct($name); + + if (array_key_exists("default", $parameters)) { + $this->setValue($parameters["default"]); + } + + $this->updateAttributes(array("wrap" => "off")); + $this->setStyle("width: 100%; font-family: monospace;"); + $this->setWidth(100); + $this->setHeight(20); + + if (array_key_exists("notes", $parameters)) { + $this->_notes = $parameters["notes"]; + } + } + + function render() { + $out = parent::render(); + $out .= $this->_notes; + + return ($out); + } + } /** * class cDataDropdownWidget * cDataDropdownWidget generates a dropdown widget for use with the data objects. */ -class cDataDropdownWidget extends cHTMLSelectElement -{ - /** - * cDataDropdownWidget: Creates a dropdown widget - * with specific entries - * - * @param $name Name of the widget - * @param $parameters Parameters (see below) - * - * valid parameters for this control are: - * default string Default value which will be selected - * choices array Values for filling the dropdown - * - * @return void - * @access public - */ - function cDataDropdownWidget ($name, $parameters) - { - cHTMLSelectElement::cHTMLSelectElement($name); - - $this->autoFill($parameters["choices"]); - - if (array_key_exists("default", $parameters)) - { - $this->setDefault($parameters["default"]); - } - } +class cDataDropdownWidget extends cHTMLSelectElement { + + /** + * cDataDropdownWidget: Creates a dropdown widget + * with specific entries + * + * @param $name Name of the widget + * @param $parameters Parameters (see below) + * + * valid parameters for this control are: + * default string Default value which will be selected + * choices array Values for filling the dropdown + * + * @return void + * @access public + */ + function __construct($name, $parameters) { + parent::__construct($name); + + $this->autoFill($parameters["choices"]); + + if (array_key_exists("default", $parameters)) { + $this->setDefault($parameters["default"]); + } + } + } /** * class cDataForeignTableDropdownWidget * cDataForeignTableDropdownWidget generates a dropdown widget out of a foreign table. */ -class cDataForeignTableDropdownWidget extends cHTMLSelectElement -{ - /** - * cDataForeignTableDropdownWidget: Creates a dropdown widget - * which fetches its entries from a foreign, linked table - * - * @param $name Name of the widget - * @param $parameters Parameters (see below) - * - * valid parameters for this control are: - * foreignClass string Class name of the foreign class - * default string Default value which will be selected - * - * @return void - * @access public - */ - function cDataForeignTableDropdownWidget ($name, $parameters) - { - cHTMLSelectElement::cHTMLSelectElement($name); - - $c = new $parameters["foreignClass"]; - $c->query(); - - while ($i = $c->next()) - { - $meta = $i->getMetaObject(); - - if (is_object($meta)) - { - $data[$i->get($i->primaryKey)] = $meta->getName(); - } - } - - $this->autoFill($data); - - if (array_key_exists("default", $parameters)) - { - $this->setDefault($parameters["default"]); - } +class cDataForeignTableDropdownWidget extends cHTMLSelectElement { + + /** + * cDataForeignTableDropdownWidget: Creates a dropdown widget + * which fetches its entries from a foreign, linked table + * + * @param $name Name of the widget + * @param $parameters Parameters (see below) + * + * valid parameters for this control are: + * foreignClass string Class name of the foreign class + * default string Default value which will be selected + * + * @return void + * @access public + */ + function __construct($name, $parameters) { + parent::__construct($name); + + $c = new $parameters["foreignClass"]; + $c->query(); + + while ($i = $c->next()) { + $meta = $i->getMetaObject(); + + if (is_object($meta)) { + $data[$i->get($i->primaryKey)] = $meta->getName(); + } + } + + $this->autoFill($data); + + if (array_key_exists("default", $parameters)) { + $this->setDefault($parameters["default"]); + } + } - } } /** * class cDataCheckboxWidget * cDataCheckboxWidget generates a checkbox for use with the dataobjects */ -class cDataCheckboxWidget extends cHTMLCheckbox -{ - /** - * cDataCheckboxWidget: Creates a checkbox widget - * - * @param $name Name of the widget - * @param $parameters Parameters (see below) - * - * valid parameters for this control are: - * title string Title of the checkbox label - * default string Checked or not checked - * - * @return void - * @access public - */ - function cDataCheckboxWidget ($name, $parameters) - { - cHTMLCheckbox::cHTMLCheckbox($name."_stub", "1"); - - if ($parameters["title"] != "") - { - $this->setLabelText($parameters["title"]); - } else { - $this->setLabelText(" "); - } - - $this->setChecked($parameters["default"]); - - $this->_hfield = new cHTMLHiddenField($name, $parameters["default"]); - $this->setEvent("click", "if (this.checked == true) { document.getElementById('".$this->_hfield->getId()."').value = '1'; } else { document.getElementById('".$this->_hfield->getId()."').value = '0'; }"); - } +class cDataCheckboxWidget extends cHTMLCheckbox { + + /** + * cDataCheckboxWidget: Creates a checkbox widget + * + * @param $name Name of the widget + * @param $parameters Parameters (see below) + * + * valid parameters for this control are: + * title string Title of the checkbox label + * default string Checked or not checked + * + * @return void + * @access public + */ + function __construct($name, $parameters) { + parent::__construct($name . "_stub", "1"); + + if ($parameters["title"] != "") { + $this->setLabelText($parameters["title"]); + } else { + $this->setLabelText(" "); + } + + $this->setChecked($parameters["default"]); + + $this->_hfield = new cHTMLHiddenField($name, $parameters["default"]); + $this->setEvent("click", "if (this.checked == true) { document.getElementById('" . $this->_hfield->getId() . "').value = '1'; } else { document.getElementById('" . $this->_hfield->getId() . "').value = '0'; }"); + } + + function render() { + $out = $this->_hfield->render(); + $out .= parent::render(); + + return ($out); + } - function render () - { - $out = $this->_hfield->render(); - $out .= parent::render(); - - return ($out); - } } /** @@ -240,94 +227,85 @@ class cDataCheckboxWidget extends cHTMLCheckbox * cDataMultiTextboxWidget generates a multi-line textbox widget */ -class cDataMultiTextboxWidget extends cHTMLTable -{ - /** - * cDataMultiTextboxWidget: Creates a multi-line textbox widget - * - * @param $name Name of the widget - * @param $parameters Parameters (see below) - * - * valid parameters for this control are: - * title string Title of the multi-line textbox widget - * default array Values (=lines) to fill - * - * @return void - * @access public - */ - function cDataMultiTextboxWidget ($name, $parameters) - { - cHTMLTable::cHTMLTable(); +class cDataMultiTextboxWidget extends cHTMLTable { - $this->name = $name; - - if (array_key_exists("title", $parameters)) - { - $rows[] = $this->addTitle($parameters["title"]); - } - - if (is_array($parameters["default"])) - { - foreach ($parameters["default"] as $i) - { - $rows[] = $this->addRow($i); - } - } - + /** + * cDataMultiTextboxWidget: Creates a multi-line textbox widget + * + * @param $name Name of the widget + * @param $parameters Parameters (see below) + * + * valid parameters for this control are: + * title string Title of the multi-line textbox widget + * default array Values (=lines) to fill + * + * @return void + * @access public + */ + function __construct($name, $parameters) { + parent::__construct(); + + $this->name = $name; + + if (array_key_exists("title", $parameters)) { + $rows[] = $this->addTitle($parameters["title"]); + } + + if (is_array($parameters["default"])) { + foreach ($parameters["default"] as $i) { + $rows[] = $this->addRow($i); + } + } + + + + $rows[] = $this->addRow(""); + $this->setPadding(1); + + $this->setContent($rows); + } + + function addTitle($title) { + $row = new cHTMLTableRow; + $data = new cHTMLTableData; + $data->setColSpan(2); + $data->setContent($title); + $row->setContent($data); + + return ($row); + } + + function addRow($data) { + $row = new cHTMLTableRow; + $l = new cHTMLTableData; + $r = new cHTMLTableData; + + $l->setVerticalAlignment("middle"); + $r->setVerticalAlignment("middle"); + + $textbox = new cHTMLTextbox($this->name . "[]", $data); + $r->setContent($textbox); + + $clearlink = new cHTMLLink; + + $clearimage = new cHTMLImage; + $clearimage->setSrc("images/actions/clear_right.gif"); + + $clearlink->setAlt(i18n("Clear contents")); + $clearimage->setAlt(i18n("Clear contents")); + + $clearlink->setContent($clearimage); + + $i = $textbox->getId(); + + $clearlink->setEvent("click", "document.getElementById('$i').value = ''; return false;"); + $clearlink->setLink("#"); + + $l->setContent($clearlink); + + $row->setContent(array($l, $r)); + + return ($row); + } - - $rows[] = $this->addRow(""); - $this->setPadding(1); - - $this->setContent($rows); - - } - - function addTitle ($title) - { - $row = new cHTMLTableRow; - $data = new cHTMLTableData; - $data->setColSpan(2); - $data->setContent($title); - $row->setContent($data); - - return ($row); - } - - function addRow ($data) - { - $row = new cHTMLTableRow; - $l = new cHTMLTableData; - $r = new cHTMLTableData; - - $l->setVerticalAlignment("middle"); - $r->setVerticalAlignment("middle"); - - $textbox = new cHTMLTextbox($this->name."[]", $data); - $r->setContent($textbox); - - $clearlink = new cHTMLLink; - - $clearimage = new cHTMLImage; - $clearimage->setSrc("images/actions/clear_right.gif"); - - $clearlink->setAlt(i18n("Clear contents")); - $clearimage->setAlt(i18n("Clear contents")); - - $clearlink->setContent($clearimage); - - $i = $textbox->getId(); - - $clearlink->setEvent("click", "document.getElementById('$i').value = ''; return false;"); - $clearlink->setLink("#"); - - $l->setContent($clearlink); - - $row->setContent(array($l, $r)); - - return ($row); - } } - - -?> \ No newline at end of file diff --git a/trunk/conlite/classes/widgets/class.widgets.datechooser.php b/trunk/conlite/classes/widgets/class.widgets.datechooser.php index b597592..6a9349a 100644 --- a/trunk/conlite/classes/widgets/class.widgets.datechooser.php +++ b/trunk/conlite/classes/widgets/class.widgets.datechooser.php @@ -1,4 +1,5 @@ _oImage = new cHTMLImage; - $this->_oImage->setSrc("images/pfeil_runter.gif"); - $this->_oImage->setStyle("margin-left: 2px; cursor: pointer;"); + var $_oCalendar; + var $_oImage; + var $_oButton; - - $this->_oCalendar = new cCalendarControl; - - $this->_oDate->setSourceFormat(cDateTime_ISO); - $this->_oDate->setTargetFormat(cDateTime_Locale_DateOnly); - - if ($initValue === false) - { - $this->_oDate->set(date("Y-m-d H:i:s")); - } else { - $this->_oDate->set($initValue); - } - - $this->_aSelectIDs = array(); - } - - function setSelectsToHide ($aSelectIDs) - { - if (!is_array($aSelectIDs)) - { - return; - } - foreach ($aSelectIDs as $key => $data) - { - $aSelectIDs[$key] = '"'.$data.'"'; - } - $this->_aSelectIDs = $aSelectIDs; - } + function __construct($name, $initValue = false) { + parent::__construct($name, ""); - function setReadOnly ($bReadOnly = true) - { - $this->_bReadOnly = $bReadOnly; - } - - function render () - { - if ($this->_bReadOnly) - { - $this->updateAttributes(array ("readonly" => "readonly")); - } - - $sDatefield = parent::render(); - $sTimeformat = getEffectiveSetting("backend", "timeformat_date", "Y-m-d"); - - $parseScript = ' + $this->_oImage = new cHTMLImage; + $this->_oImage->setSrc("images/pfeil_runter.gif"); + $this->_oImage->setStyle("margin-left: 2px; cursor: pointer;"); + + + $this->_oCalendar = new cCalendarControl; + + $this->_oDate->setSourceFormat(cDateTime_ISO); + $this->_oDate->setTargetFormat(cDateTime_Locale_DateOnly); + + if ($initValue === false) { + $this->_oDate->set(date("Y-m-d H:i:s")); + } else { + $this->_oDate->set($initValue); + } + + $this->_aSelectIDs = array(); + } + + function setSelectsToHide($aSelectIDs) { + if (!is_array($aSelectIDs)) { + return; + } + foreach ($aSelectIDs as $key => $data) { + $aSelectIDs[$key] = '"' . $data . '"'; + } + $this->_aSelectIDs = $aSelectIDs; + } + + function setReadOnly($bReadOnly = true) { + $this->_bReadOnly = $bReadOnly; + } + + function render() { + if ($this->_bReadOnly) { + $this->updateAttributes(array("readonly" => "readonly")); + } + + $sDatefield = parent::render(); + $sTimeformat = getEffectiveSetting("backend", "timeformat_date", "Y-m-d"); + + $parseScript = ' '; - - $sEventRegister = ''; - $clickScript = "if (!document.getElementById('{wid}').disabled) { if (document.getElementById('{did}_display').style.display == 'none') { {wid}_passToWidget('".getEffectiveSetting("backend", "timeformat_date", "Y-m-d")."', document.getElementById('".$this->getId()."').value); document.getElementById('{did}_display').style.display = 'block'; {wid}_hideselects(true); } else { document.getElementById('{did}_display').style.display = 'none'; {wid}_hideselects(false); } }"; - - $div = new cHTMLDiv; - - $this->_oImage->setEvent("click", $clickScript); - - $final = $parseScript.'
'.$sDatefield.''.$this->_oImage->render().'
'.$sEventRegister; - - $final = str_replace("{wid}", $this->getId(), $final); - $final = str_replace("{cid}", $this->_oCalendar->getId(), $final); - - $final = str_replace("{did}", $div->getId(), $final); - - return ($final); - - - } + + $sEventRegister = ''; + $clickScript = "if (!document.getElementById('{wid}').disabled) { if (document.getElementById('{did}_display').style.display == 'none') { {wid}_passToWidget('" . getEffectiveSetting("backend", "timeformat_date", "Y-m-d") . "', document.getElementById('" . $this->getId() . "').value); document.getElementById('{did}_display').style.display = 'block'; {wid}_hideselects(true); } else { document.getElementById('{did}_display').style.display = 'none'; {wid}_hideselects(false); } }"; + + $div = new cHTMLDiv; + + $this->_oImage->setEvent("click", $clickScript); + + $final = $parseScript . '
' . $sDatefield . '' . $this->_oImage->render() . '
' . $sEventRegister; + + $final = str_replace("{wid}", $this->getId(), $final); + $final = str_replace("{cid}", $this->_oCalendar->getId(), $final); + + $final = str_replace("{did}", $div->getId(), $final); + + return ($final); + } + } -?> \ No newline at end of file diff --git a/trunk/conlite/classes/widgets/class.widgets.datefield.php b/trunk/conlite/classes/widgets/class.widgets.datefield.php index 2fbc025..016eb76 100644 --- a/trunk/conlite/classes/widgets/class.widgets.datefield.php +++ b/trunk/conlite/classes/widgets/class.widgets.datefield.php @@ -1,4 +1,5 @@ _oDate = new cDatatypeDateTime; + + $this->_oDate->set($initvalue); + + parent::__construct($name, $initvalue, $width); + } + + function render() { + if ($this->_oDate->get(cDateTime_ISO) != "1970-01-01") { + if ($this->_oDate->_cTargetFormat == cDateTime_Custom) { + parent::setValue($this->_oDate->render()); + } else { + parent::setValue($this->_oDate->render(cDateTime_Locale_DateOnly)); + } + } + + return parent::render(); + } -class cDatefield extends cHTMLTextbox -{ - var $_oDate; - - function cDatefield ($name, $initvalue, $width = 10) - { - $this->_oDate = new cDatatypeDateTime; - - $this->_oDate->set($initvalue); - - parent::cHTMLTextbox($name, $initvalue, $width); - - } - - function render () - { - if ($this->_oDate->get(cDateTime_ISO) != "1970-01-01") - { - if ($this->_oDate->_cTargetFormat == cDateTime_Custom) - { - parent::setValue($this->_oDate->render()); - } else { - parent::setValue($this->_oDate->render(cDateTime_Locale_DateOnly)); - } - } - - return parent::render(); - } - } -?> \ No newline at end of file diff --git a/trunk/conlite/classes/widgets/class.widgets.dateselect.php b/trunk/conlite/classes/widgets/class.widgets.dateselect.php index fc4b4a7..296c1bb 100644 --- a/trunk/conlite/classes/widgets/class.widgets.dateselect.php +++ b/trunk/conlite/classes/widgets/class.widgets.dateselect.php @@ -1,4 +1,5 @@ _daySelect = new cHTMLSelectElement($prefix."_day"); - $this->_monthSelect = new cHTMLSelectElement($prefix."_month"); - $this->_yearSelect = new cHTMLSelectElement($prefix."_year"); - - /* Fill days */ - for ($day = 1; $day < 32; $day++) - { - $days[sprintf("%02d", $day)] = $day; - } - - $this->_daySelect->autoFill($days); + */ + var $_order; - /* Fill months */ - for ($month = 1; $month < 13; $month++) - { - $months[sprintf("%02d", $month)] = getCanonicalMonth($month); - } - - $this->_monthSelect->autoFill($months); - - /* Fill years */ - $currentYear = date("Y"); - for ($year = $currentYear-20; $year < $currentYear +20; $year++) - { - $years[$year] = $year; - } - - $this->_yearSelect->autoFill($years); - - $this->setTimestamp(time()); - - /* Apply old values */ - if (isset($_POST[$prefix."_day"])) - { - $this->_daySelect->setDefault($_POST[$prefix."_day"]); - } + function __construct($prefix) { + $this->_daySelect = new cHTMLSelectElement($prefix . "_day"); + $this->_monthSelect = new cHTMLSelectElement($prefix . "_month"); + $this->_yearSelect = new cHTMLSelectElement($prefix . "_year"); - if (isset($_POST[$prefix."_month"])) - { - $this->_monthSelect->setDefault($_POST[$prefix."_month"]); - } + /* Fill days */ + for ($day = 1; $day < 32; $day++) { + $days[sprintf("%02d", $day)] = $day; + } - if (isset($_POST[$prefix."_year"])) - { - $this->_yearSelect->setDefault($_POST[$prefix."_year"]); - } - - $this->setOrder("dmy"); - - } - - /** - * Sets the day, month and year boxes using a timestamp - * - * @param $timestamp int Timestamp to set - */ - function setTimestamp ($timestamp) - { - $day = date("d", $timestamp); - $month = date("m", $timestamp); - $year = date("Y", $timestamp); + $this->_daySelect->autoFill($days); - $this->_daySelect->setDefault($day); - $this->_monthSelect->setDefault($month); - $this->_yearSelect->setDefault($year); - - } + /* Fill months */ + for ($month = 1; $month < 13; $month++) { + $months[sprintf("%02d", $month)] = getCanonicalMonth($month); + } - /** - * Sets the ID for all three select boxes. - * - * Note: The parameter id is only the prefix. Your ID is postfixed - * by _day, _month and _year for each select box. - * - * @param $id string Prefix ID to set - */ - function setId ($id) - { - $this->_daySelect->setId($id."_day"); - $this->_monthSelect->setId($id."_month"); - $this->_yearSelect->setId($id."_year"); - } + $this->_monthSelect->autoFill($months); - /** - * Gets the current timestamp - * - * @param $timestamp int Timestamp to set - */ - function getTimestamp ($prefix = false) - { - if (!is_object($this->_daySelect)) - { - /* Called statically */ - if (isset($_POST[$prefix."_day"])) - { - $day = $_POST[$prefix."_day"]; - } - - if (isset($_POST[$prefix."_month"])) - { - $month = $_POST[$prefix."_month"]; - } - - if (isset($_POST[$prefix."_year"])) - { - $year = $_POST[$prefix."_year"]; - } - } else { - $day = $this->_daySelect->getDefault(); - $month = $this->_monthSelect->getDefault(); - $year = $this->_yearSelect->getDefault(); - } - - return mktime(0,0,0, $month, $day, $year); - } - - /** - * Sets the order of the day, month and year boxes - * - * Pass a string with "d", "m" and "y" in the desired order. - * - * Example: - * $test->setOrder("mdy"); - * - * @param $order string Order with the keys "d", "m" and "y" - */ - function setOrder ($order) - { - $this->_order = $order; - } + /* Fill years */ + $currentYear = date("Y"); + for ($year = $currentYear - 20; $year < $currentYear + 20; $year++) { + $years[$year] = $year; + } - /** - * sets the element to a disabled state - * - * @param none - */ - function setDisabled ($disabled) - { - $this->_daySelect->setDisabled($disabled); - $this->_monthSelect->setDisabled($disabled); - $this->_yearSelect->setDisabled($disabled); - } - - /** - * Renders the elements - * - * @param none - */ - function render () - { - $output = ""; - - for ($char = 0; $char < strlen($this->_order); $char++) - { - $mychar = substr($this->_order, $char, 1); - - switch ($mychar) - { - case "d": $output .= $this->_daySelect->render(); break; - case "m": $output .= $this->_monthSelect->render(); break; - case "y": $output .= $this->_yearSelect->render(); break; - default: break; - } - } - - return ($output); - } - + $this->_yearSelect->autoFill($years); + + $this->setTimestamp(time()); + + /* Apply old values */ + if (isset($_POST[$prefix . "_day"])) { + $this->_daySelect->setDefault($_POST[$prefix . "_day"]); + } + + if (isset($_POST[$prefix . "_month"])) { + $this->_monthSelect->setDefault($_POST[$prefix . "_month"]); + } + + if (isset($_POST[$prefix . "_year"])) { + $this->_yearSelect->setDefault($_POST[$prefix . "_year"]); + } + + $this->setOrder("dmy"); + } + + /** + * Sets the day, month and year boxes using a timestamp + * + * @param $timestamp int Timestamp to set + */ + function setTimestamp($timestamp) { + $day = date("d", $timestamp); + $month = date("m", $timestamp); + $year = date("Y", $timestamp); + + $this->_daySelect->setDefault($day); + $this->_monthSelect->setDefault($month); + $this->_yearSelect->setDefault($year); + } + + /** + * Sets the ID for all three select boxes. + * + * Note: The parameter id is only the prefix. Your ID is postfixed + * by _day, _month and _year for each select box. + * + * @param $id string Prefix ID to set + */ + function setId($id) { + $this->_daySelect->setId($id . "_day"); + $this->_monthSelect->setId($id . "_month"); + $this->_yearSelect->setId($id . "_year"); + } + + /** + * Gets the current timestamp + * + * @param $timestamp int Timestamp to set + */ + function getTimestamp($prefix = false) { + if (!is_object($this->_daySelect)) { + /* Called statically */ + if (isset($_POST[$prefix . "_day"])) { + $day = $_POST[$prefix . "_day"]; + } + + if (isset($_POST[$prefix . "_month"])) { + $month = $_POST[$prefix . "_month"]; + } + + if (isset($_POST[$prefix . "_year"])) { + $year = $_POST[$prefix . "_year"]; + } + } else { + $day = $this->_daySelect->getDefault(); + $month = $this->_monthSelect->getDefault(); + $year = $this->_yearSelect->getDefault(); + } + + return mktime(0, 0, 0, $month, $day, $year); + } + + /** + * Sets the order of the day, month and year boxes + * + * Pass a string with "d", "m" and "y" in the desired order. + * + * Example: + * $test->setOrder("mdy"); + * + * @param $order string Order with the keys "d", "m" and "y" + */ + function setOrder($order) { + $this->_order = $order; + } + + /** + * sets the element to a disabled state + * + * @param none + */ + function setDisabled($disabled) { + $this->_daySelect->setDisabled($disabled); + $this->_monthSelect->setDisabled($disabled); + $this->_yearSelect->setDisabled($disabled); + } + + /** + * Renders the elements + * + * @param none + */ + function render() { + $output = ""; + + for ($char = 0; $char < strlen($this->_order); $char++) { + $mychar = substr($this->_order, $char, 1); + + switch ($mychar) { + case "d": $output .= $this->_daySelect->render(); + break; + case "m": $output .= $this->_monthSelect->render(); + break; + case "y": $output .= $this->_yearSelect->render(); + break; + default: break; + } + } + + return ($output); + } } - -?> \ No newline at end of file diff --git a/trunk/conlite/classes/widgets/class.widgets.foldingrow.php b/trunk/conlite/classes/widgets/class.widgets.foldingrow.php index ecd3839..d483e7c 100644 --- a/trunk/conlite/classes/widgets/class.widgets.foldingrow.php +++ b/trunk/conlite/classes/widgets/class.widgets.foldingrow.php @@ -1,4 +1,5 @@ setCaption($caption); - - $this->_headerRow = new cHTMLTableRow; - - $this->_headerData = new cHTMLTableData; - $this->_contentRow = new cHTMLTableRow; - $this->_contentRow->updateAttributes(array ("id" => $uuid)); - $this->_contentData = new cHTMLTableData; - $this->_uuid = $uuid; - - $this->_link = new cHTMLLink; - $this->_linkId = $link_id; - - $this->_headerData->setClass("foldingrow"); - - $this->_hiddenField = new cHTMLHiddenField("expandstate_".$this->_contentRow->getID()); - - $this->_foldingImage = new cHTMLImage; - $this->_foldingImage->setStyle("margin-right: 4px;"); - - $this->setExpanded(false); - $this->addRequiredScript("parameterCollector.js"); - $this->addRequiredScript("cfoldingrow.js"); - + $this->setCaption($caption); + + $this->_headerRow = new cHTMLTableRow; + + $this->_headerData = new cHTMLTableData; + $this->_contentRow = new cHTMLTableRow; + $this->_contentRow->updateAttributes(array("id" => $uuid)); + $this->_contentData = new cHTMLTableData; + $this->_uuid = $uuid; + + $this->_link = new cHTMLLink; + $this->_linkId = $link_id; + + $this->_headerData->setClass("foldingrow"); + + $this->_hiddenField = new cHTMLHiddenField("expandstate_" . $this->_contentRow->getID()); + + $this->_foldingImage = new cHTMLImage; + $this->_foldingImage->setStyle("margin-right: 4px;"); + + $this->setExpanded(false); + + $this->addRequiredScript("parameterCollector.js"); + $this->addRequiredScript("cfoldingrow.js"); + $user = new cApiUser($auth->auth["uid"]); - - if ($bExpanded == null) { - /* Check for expandstate */ - if (!$user->virgin) - { - if ($user->getProperty("expandstate", $uuid) == "true") - { - $this->setExpanded($user->getProperty("expandstate", $uuid)); - } - } - } else { - if ($bExpanded) { - $this->setExpanded(true); - } else { - $this->setExpanded(false); - } - } - } - - function setExpanded ($expanded = false) - { - if ($expanded == true) - { - $this->_foldingImage->setSrc("images/widgets/foldingrow/expanded.gif"); - $this->_foldingImage->updateAttributes(array("data-folding-row" => "expanded", "alt" => "")); - $this->_contentRow->setStyle("display: ;"); + if ($bExpanded == null) { + /* Check for expandstate */ + + if (!$user->virgin) { + if ($user->getProperty("expandstate", $uuid) == "true") { + $this->setExpanded($user->getProperty("expandstate", $uuid)); + } + } + } else { + if ($bExpanded) { + $this->setExpanded(true); + } else { + $this->setExpanded(false); + } + } + } + + function setExpanded($expanded = false) { + if ($expanded == true) { + $this->_foldingImage->setSrc("images/widgets/foldingrow/expanded.gif"); + $this->_foldingImage->updateAttributes(array("data-folding-row" => "expanded", "alt" => "")); + $this->_contentRow->setStyle("display: ;"); $this->_hiddenField->setValue('expanded'); - } else { - $this->_foldingImage->setSrc("images/widgets/foldingrow/collapsed.gif"); - $this->_foldingImage->updateAttributes(array("data-folding-row" => "collapsed", "alt" => "")); - $this->_contentRow->setStyle("display: none;"); + } else { + $this->_foldingImage->setSrc("images/widgets/foldingrow/collapsed.gif"); + $this->_foldingImage->updateAttributes(array("data-folding-row" => "collapsed", "alt" => "")); + $this->_contentRow->setStyle("display: none;"); $this->_hiddenField->setValue('collapsed'); - } - $this->_expanded = $expanded; - } - - function setCaption ($caption) - { - $this->_caption = $caption; - } - - function setHelpContext ($context = false) - { - $this->_helpContext = $context; - } - - function setIndent ($indent = 0) - { - $this->_indent = $indent; - } - - function setContentData ($content) - { - $this->_contentData->setContent($content); - } - - function render () - { - /* Build the expand/collapse link */ - - $this->_link->setClass("foldingrow"); - if($this->_linkId != NULL) - { - $this->_link->setID($this->_linkId); - } - - $imgid = $this->_foldingImage->getID(); - $rowid = $this->_contentRow->getID(); - $hiddenid = $this->_hiddenField->getID(); - $uuid = $this->_uuid; - - $this->_link->setLink("javascript:cFoldingRow_expandCollapse('$imgid', '$rowid', '$hiddenid', '$uuid');"); - $this->_link->setContent($this->_foldingImage->render() . $this->_caption); - - $this->_headerData->setContent(array($this->_hiddenField,$this->_link)); - $this->_headerRow->setContent($this->_headerData); - - $this->_contentRow->setContent($this->_contentData); - - $output = $this->_headerRow->render(); - $output .= $this->_contentRow->render(); - - return ($output); - } - + } + $this->_expanded = $expanded; + } + + function setCaption($caption) { + $this->_caption = $caption; + } + + function setHelpContext($context = false) { + $this->_helpContext = $context; + } + + function setIndent($indent = 0) { + $this->_indent = $indent; + } + + function setContentData($content) { + $this->_contentData->setContent($content); + } + + function render() { + /* Build the expand/collapse link */ + + $this->_link->setClass("foldingrow"); + if ($this->_linkId != NULL) { + $this->_link->setID($this->_linkId); + } + + $imgid = $this->_foldingImage->getID(); + $rowid = $this->_contentRow->getID(); + $hiddenid = $this->_hiddenField->getID(); + $uuid = $this->_uuid; + + $this->_link->setLink("javascript:cFoldingRow_expandCollapse('$imgid', '$rowid', '$hiddenid', '$uuid');"); + $this->_link->setContent($this->_foldingImage->render() . $this->_caption); + + $this->_headerData->setContent(array($this->_hiddenField, $this->_link)); + $this->_headerRow->setContent($this->_headerData); + + $this->_contentRow->setContent($this->_contentData); + + $output = $this->_headerRow->render(); + $output .= $this->_contentRow->render(); + + return ($output); + } + } - -?> \ No newline at end of file diff --git a/trunk/conlite/classes/widgets/class.widgets.nominaltextfield.php b/trunk/conlite/classes/widgets/class.widgets.nominaltextfield.php index 337fb1b..3034938 100644 --- a/trunk/conlite/classes/widgets/class.widgets.nominaltextfield.php +++ b/trunk/conlite/classes/widgets/class.widgets.nominaltextfield.php @@ -1,4 +1,5 @@ _oNumber = new cDatatypeNumber; - $this->_oNumber->set($initvalue); - - $this->disableRealtimeNominalFormat(); - - parent::cHTMLTextbox($name, $initvalue, $width); - } - - function enableRealtimeNominalFormat () - { - $this->_bRealtimeNominalFormat = true; - } - - function disableRealtimeNominalFormat () - { - $this->_bRealtimeNominalFormat = false; - } - - function render () - { - parent::setValue($this->_oNumber->render()); - - if ($this->_bRealtimeNominalFormat) - { - - $decimalChar = $this->_oNumber->getDecimalPointCharacter(); - $thousandChar = $this->_oNumber->getThousandSeparatorCharacter(); - - parent::setEvent("change", "nominal_format_custom(this, '".$decimalChar."', '".$thousandChar."')"); - } - return parent::render(); - } - +class cNominalNumberField extends cHTMLTextbox { + + var $_oNumber; + var $_bRealtimeNominalFormat; + + function __construct($name, $initvalue, $width) { + global $belang; + + $this->_oNumber = new cDatatypeNumber; + $this->_oNumber->set($initvalue); + + $this->disableRealtimeNominalFormat(); + + parent::__construct($name, $initvalue, $width); + } + + function enableRealtimeNominalFormat() { + $this->_bRealtimeNominalFormat = true; + } + + function disableRealtimeNominalFormat() { + $this->_bRealtimeNominalFormat = false; + } + + function render() { + parent::setValue($this->_oNumber->render()); + + if ($this->_bRealtimeNominalFormat) { + + $decimalChar = $this->_oNumber->getDecimalPointCharacter(); + $thousandChar = $this->_oNumber->getThousandSeparatorCharacter(); + + parent::setEvent("change", "nominal_format_custom(this, '" . $decimalChar . "', '" . $thousandChar . "')"); + } + return parent::render(); + } } -class cNominalCurrencyField extends cNominalNumberField -{ - var $_oNumber; - var $_bRealtimeNominalFormat; - - function cNominalCurrencyField ($name, $initvalue, $width) - { - parent::cNominalNumberField($name, $initvalue, $width); - - $this->_oNumber = new cDatatypeCurrency; - $this->_oNumber->set($initvalue); +class cNominalCurrencyField extends cNominalNumberField { - $this->disableRealtimeNominalFormat(); - + var $_oNumber; + var $_bRealtimeNominalFormat; - } - - function enableRealtimeNominalFormat () - { - $this->_bRealtimeNominalFormat = true; - } - - function disableRealtimeNominalFormat () - { - $this->_bRealtimeNominalFormat = false; - } - - function render () - { - parent::setValue($this->_oNumber->render()); - - if ($this->_bRealtimeNominalFormat) - { - $decimalChar = $this->_oNumber->getDecimalPointCharacter(); - $thousandChar = $this->_oNumber->getThousandSeparatorCharacter(); - - $currencySign = $this->_oNumber->getCurrencySymbol(); - - parent::setEvent("change", "nominal_format_custom(this, '".$decimalChar."', '".$thousandChar."', '".$currencySign."')"); - } - return parent::render(); - } - + function __construct($name, $initvalue, $width) { + parent::__construct($name, $initvalue, $width); + + $this->_oNumber = new cDatatypeCurrency; + $this->_oNumber->set($initvalue); + + $this->disableRealtimeNominalFormat(); + } + + function enableRealtimeNominalFormat() { + $this->_bRealtimeNominalFormat = true; + } + + function disableRealtimeNominalFormat() { + $this->_bRealtimeNominalFormat = false; + } + + function render() { + parent::setValue($this->_oNumber->render()); + + if ($this->_bRealtimeNominalFormat) { + $decimalChar = $this->_oNumber->getDecimalPointCharacter(); + $thousandChar = $this->_oNumber->getThousandSeparatorCharacter(); + + $currencySign = $this->_oNumber->getCurrencySymbol(); + + parent::setEvent("change", "nominal_format_custom(this, '" . $decimalChar . "', '" . $thousandChar . "', '" . $currencySign . "')"); + } + return parent::render(); + } } -?> \ No newline at end of file diff --git a/trunk/conlite/classes/widgets/class.widgets.page.php b/trunk/conlite/classes/widgets/class.widgets.page.php index ae6d464..f95eb04 100644 --- a/trunk/conlite/classes/widgets/class.widgets.page.php +++ b/trunk/conlite/classes/widgets/class.widgets.page.php @@ -78,19 +78,19 @@ class cPage extends cHTML { * @access private */ var $extra; - + /** * Switch if HTML5 * @var boolean */ protected $_isHtml5 = false; - + /** * CSS files to add * @var array */ protected $_css; - + /** * JS files to add * @var array @@ -143,20 +143,20 @@ class cPage extends cHTML { function setMargin($margin) { $this->_margin = $margin; } - + /** * * @param string $sFile path to file */ public function addCssFile($sFile) { - if(!is_array($this->_css)) { + if (!is_array($this->_css)) { $this->_css = array(); } $this->_css[] = $sFile; } - + public function addJsFile($sFile) { - if(!is_array($this->_css)) { + if (!is_array($this->_css)) { $this->_js = array(); } $this->_js[] = $sFile; @@ -271,7 +271,7 @@ class cPage extends cHTML { function setEncoding($encoding) { $this->_encoding = $encoding; } - + public function sendNoCacheHeaders() { header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1. header("Pragma: no-cache"); // HTTP 1.0. @@ -296,13 +296,13 @@ class cPage extends cHTML { if ($this->_object !== false && method_exists($this->_object, "render") && is_array($this->_requiredScripts)) { foreach ($this->_requiredScripts as $key => $value) { - $scripts .= ''."\n"; + $scripts .= '' . "\n"; } } - - if(is_array($this->_js) && count($this->_js) > 0) { - foreach($this->_js as $sFilename) { - $scripts .= ''."\n"; + + if (is_array($this->_js) && count($this->_js) > 0) { + foreach ($this->_js as $sFilename) { + $scripts .= '' . "\n"; } } @@ -311,14 +311,14 @@ class cPage extends cHTML { $scripts .= 'parent.frames["right_top"].location.href = "' . $sess->url("main.php?area=" . $this->_subnavArea . "&frame=3&" . $this->_subnav) . '";'; $scripts .= ''; } - + $css = ""; - if(is_array($this->_css)) { - foreach($this->_css as $sFilename) { - $css .= ''."\n"; + if (is_array($this->_css)) { + foreach ($this->_css as $sFilename) { + $css .= '' . "\n"; } } - + $meta = ''; if ($this->_encoding != "" && !$this->_isHtml5) { $meta .= '' . "\n"; @@ -332,13 +332,13 @@ class cPage extends cHTML { $this->_content .= "\n" . ''; $this->_content .= "\n" . ''; } - + $tpl->set('s', 'META', $meta); $tpl->set('s', 'SCRIPTS', $scripts); $tpl->set('s', 'CSS', $css); $tpl->set('s', 'CONTENT', $this->_content); $tpl->set('s', 'MARGIN', $this->_margin); - $tpl->set('s', 'EXTRA', $this->extra); + $tpl->set('s', 'EXTRA', $this->extra); $tpl->set('s', 'SESSION_ID', $sess->id); if ($print == true) { @@ -374,7 +374,7 @@ class cPageLeftTop extends cPage { * * @param $showCloser boolean True if the closer should be shown (default) */ - function cPageLeftTop($showCloser = true) { + function __construct($showCloser = true) { $this->showCloser($showCloser); } @@ -390,11 +390,11 @@ class cPageLeftTop extends cPage { function render($print = true) { global $cfg; - $tpl = new Template; + $tpl = new Template(); $tpl->set('s', 'CONTENT', $content); $this->setContent($tpl->generate($cfg['path']['contenido'] . $cfg['path']['templates'] . $cfg['templates']['widgets']['left_top'], true)); - cPage::render($print); + parent::render($print); } } @@ -429,10 +429,10 @@ class cPageLeftTopMultiPane extends cPageLeftTop { * * @param $items array All items passed as multi array (see constructor description) */ - function cPageLeftTopMultiPane($items) { + function __construct($items) { $this->_items = $items; - cPageLeftTop::cPageLeftTop(); + parent::__construct(); } /** @@ -494,21 +494,21 @@ class cPageLeftTopMultiPane extends cPageLeftTop { $tpl->set('s', 'CONTENT', $content); $this->setContent($tpl->generate($cfg['path']['templates'] . $cfg['templates']['widgets']['left_top'], true)); - cPage::render(); + parent::render(); } } class cNewPageLeftTopMultiPane extends cPageLeftTopMultiPane { - function cNewPageLeftTopMultiPane($items) { - cPageLeftTopMultiPane::cPageLeftTopMultiPane($items); + function __construct($items) { + parent::__construct($items); } function render($print = true) { global $cfg; - $infodiv = new cHTMLDiv; + $infodiv = new cHTMLDiv(); if (count($this->_items) > 0) { foreach ($this->_items as $item) { @@ -549,5 +549,3 @@ class cNewPageLeftTopMultiPane extends cPageLeftTopMultiPane { } } - -?> \ No newline at end of file diff --git a/trunk/conlite/classes/widgets/class.widgets.pager.php b/trunk/conlite/classes/widgets/class.widgets.pager.php index 2c445ee..3e51c85 100644 --- a/trunk/conlite/classes/widgets/class.widgets.pager.php +++ b/trunk/conlite/classes/widgets/class.widgets.pager.php @@ -1,4 +1,5 @@ _cPager = new cPager($items, $itemsperpage, $currentpage); - $this->_pagerLink = $link; - $this->_parameterToAdd = $parameterToAdd; - - } - - function render ($bContentOnly = 0) - { + var $_pagerLink; + var $_parameterToAdd; + + function __construct($uuid, $items, $itemsperpage, $currentpage, $link, $parameterToAdd, $id = '') { + if ((int) $currentpage == 0) { + $currentpage = 1; + } + + if ($id == '') { + parent::__construct($uuid, i18n("Paging")); + } else { + parent::__construct($uuid, i18n("Paging"), $id); + } + + if (!is_object($link)) { + cError(__FILE__, __LINE__, "Parameter link is not an object"); + return false; + } + $this->_cPager = new cPager($items, $itemsperpage, $currentpage); + $this->_pagerLink = $link; + $this->_parameterToAdd = $parameterToAdd; + } + + function render($bContentOnly = 0) { #Do not display Page navigation if there is only one Page and we are not in newsletter section if ($this->_cPager->getMaxPages() == 1) { $this->_headerRow->setStyle("display:none"); $this->_contentRow->setStyle("display:none"); } - - $items = $this->_cPager->getPagesInRange(); - //echo '
';
+
+        $items = $this->_cPager->getPagesInRange();
+        //echo '
';
         //print_r($items);
         //echo '
'; - $link = $this->_pagerLink; - - $output = ''; - - if (!$this->_cPager->isFirstPage()) - { - $img = new cHTMLImage("images/paging/first.gif"); - - $link->setAlt(i18n("First page")); - $link->setContent($img); + $link = $this->_pagerLink; + + $output = ''; + + if (!$this->_cPager->isFirstPage()) { + $img = new cHTMLImage("images/paging/first.gif"); + + $link->setAlt(i18n("First page")); + $link->setContent($img); $link->setCustom($this->_parameterToAdd, 1); - $output .= $link->render(); - $output .= " "; - - $img = new cHTMLImage("images/paging/previous.gif"); - $link->setAlt(i18n("Previous page")); - $link->setContent($img); - + $output .= $link->render(); + $output .= " "; + + $img = new cHTMLImage("images/paging/previous.gif"); + $link->setAlt(i18n("Previous page")); + $link->setContent($img); + $link->setCustom($this->_parameterToAdd, $this->_cPager->_currentPage - 1); - - $output .= $link->render(); - $output .= " "; - } else { - $output .= ' '; - $output .= ''; - } - foreach ($items as $key => $item) - { - $link->setContent($key); - $link->setAlt(sprintf(i18n("Page %s"), $key)); + + $output .= $link->render(); + $output .= " "; + } else { + $output .= ' '; + $output .= ''; + } + foreach ($items as $key => $item) { + $link->setContent($key); + $link->setAlt(sprintf(i18n("Page %s"), $key)); $link->setCustom($this->_parameterToAdd, $key); - - switch ($item) - { - case "|": $output .= "..."; break; - case "current": $output .= ''.$key.""; break; - default: $output .= $link->render(); - } - - $output .= " "; - } - - if (!$this->_cPager->isLastPage()) - { - $img = new cHTMLImage("images/paging/next.gif"); - $link->setAlt(i18n("Next page")); - $link->setContent($img); + + switch ($item) { + case "|": $output .= "..."; + break; + case "current": $output .= '' . $key . ""; + break; + default: $output .= $link->render(); + } + + $output .= " "; + } + + if (!$this->_cPager->isLastPage()) { + $img = new cHTMLImage("images/paging/next.gif"); + $link->setAlt(i18n("Next page")); + $link->setContent($img); $link->setCustom($this->_parameterToAdd, $this->_cPager->_currentPage + 1); - - $output .= $link->render(); - $output .= " "; - - $img = new cHTMLImage("images/paging/last.gif"); - + + $output .= $link->render(); + $output .= " "; + + $img = new cHTMLImage("images/paging/last.gif"); + $link->setCustom($this->_parameterToAdd, $this->_cPager->getMaxPages()); - $link->setAlt(i18n("Last page")); - $link->setContent($img); - - $output .= $link->render(); - $output .= " "; - } else { - $output .= ' '; - $output .= ''; - } - - $this->_contentData->setStyle("text-align: center;"); - $this->_contentData->setClass("foldingrow_content"); - + $link->setAlt(i18n("Last page")); + $link->setContent($img); + + $output .= $link->render(); + $output .= " "; + } else { + $output .= ' '; + $output .= ''; + } + + $this->_contentData->setStyle("text-align: center;"); + $this->_contentData->setClass("foldingrow_content"); + #Do not display Page navigation if there is only one Page and we are not in newsletter section if ($this->_cPager->getMaxPages() == 1) { $output = ''; } - - $this->_contentData->setContent($output); - + + $this->_contentData->setContent($output); + if ($bContentOnly) { return $output; } else { - return cFoldingRow::render(); + return parent::render(); } - - } + } + } /** @@ -164,179 +154,161 @@ class cObjectPager extends cFoldingRow * * @author Timo A. Hummel */ -class cPager -{ - /** - * Amount of items +class cPager { + + /** + * Amount of items * @var integer * @access private - */ - var $_items; - - /** - * Item padding (before and after the current item) + */ + var $_items; + + /** + * Item padding (before and after the current item) * @var integer * @access private - */ - var $_itemPadding; - - /** - * Items on the left side + */ + var $_itemPadding; + + /** + * Items on the left side * @var integer * @access private - */ - var $_previousItems; - - /** - * Items on the right side + */ + var $_previousItems; + + /** + * Items on the right side * @var integer * @access private - */ - var $_nextItems; - - /** - * Current page + */ + var $_nextItems; + + /** + * Current page * @var integer * @access private - */ - var $_currentPage; - - /** - * Items per page + */ + var $_currentPage; + + /** + * Items per page * @var integer * @access private - */ - var $_itemsPerPage; - - /** + */ + var $_itemsPerPage; + + /** * Constructor Function - * Initializes the pager - * + * Initializes the pager + * * @param $items int Amount of items - * @param $itemsPerPage int Items displayed per page - * @param $currentPage int Defines the current page - */ - function cPager ($items, $itemsPerPage, $currentPage) - { - - $this->_items = $items; - $this->_itemsPerPage = $itemsPerPage; - $this->_currentPage = $currentPage; - - /* Default values. */ - $this->_itemPadding = 2; - $this->_previousItems = 2; - $this->_nextItems = 2; - } + * @param $itemsPerPage int Items displayed per page + * @param $currentPage int Defines the current page + */ + function __construct($items, $itemsPerPage, $currentPage) { - /** + $this->_items = $items; + $this->_itemsPerPage = $itemsPerPage; + $this->_currentPage = $currentPage; + + /* Default values. */ + $this->_itemPadding = 2; + $this->_previousItems = 2; + $this->_nextItems = 2; + } + + /** * Returns if the currentPage pointer is the first page. - * - * @return boolean True if we're on the first page. - */ - function isFirstPage () - { - if ($this->_currentPage == 1) - { - return true; - } - - return false; - } + * + * @return boolean True if we're on the first page. + */ + function isFirstPage() { + if ($this->_currentPage == 1) { + return true; + } - /** + return false; + } + + /** * Returns if the currentPage pointer is the last page. - * - * @return boolean True if we're on the last page. - */ - function isLastPage () - { - if ($this->_currentPage == $this->getMaxPages()) - { - return true; - } - - return false; - } - - /** + * + * @return boolean True if we're on the last page. + */ + function isLastPage() { + if ($this->_currentPage == $this->getMaxPages()) { + return true; + } + + return false; + } + + /** * Returns the amount of pages. - * - * @return int Page count - */ - function getMaxPages () - { - if ($this->_items == 0){ - return 1; - } else if ($this->_itemsPerPage == 0) { + * + * @return int Page count + */ + function getMaxPages() { + if ($this->_items == 0) { + return 1; + } else if ($this->_itemsPerPage == 0) { return 1; } else { - return (ceil($this->_items / $this->_itemsPerPage)); - } - } + return (ceil($this->_items / $this->_itemsPerPage)); + } + } - /** + /** * Returns an array with the pager structure. - * - * Array format: - * Key : Page Number - * Value: | for "...", "current" for the current item, page number otherwise - * - * @return array Pager structure - */ - function getPagesInRange () - { - $items = array(); + * + * Array format: + * Key : Page Number + * Value: | for "...", "current" for the current item, page number otherwise + * + * @return array Pager structure + */ + function getPagesInRange() { + $items = array(); + + $maxPages = $this->getMaxPages(); + + if (($this->_itemPadding * 3) + $this->_previousItems + $this->_nextItems > $maxPages) { + /* Disable item padding */ + for ($i = 1; $i < $this->getMaxPages() + 1; $i++) { + $items[$i] = $i; + } + } else { + for ($i = 1; $i < $this->_previousItems + 1; $i++) { + if ($i <= $maxPages && $i >= 1) { + $items[$i] = $i; + } + + if ($i + 1 <= $maxPages && $i >= 2) { + $items[$i + 1] = "|"; + } + } + + for ($i = $this->_currentPage - $this->_itemPadding; $i < $this->_currentPage + $this->_itemPadding + 1; $i++) { + if ($i <= $maxPages && $i >= 1) { + $items[$i] = $i; + } + + if ($i + 1 <= $maxPages && $i >= 2) { + $items[$i + 1] = "|"; + } + } + + for ($i = ($this->getMaxPages() - $this->_nextItems) + 1; $i < $this->getMaxPages() + 1; $i++) { + if ($i <= $maxPages && $i >= 2) { + $items[$i] = $i; + } + } + } + + $items[$this->_currentPage] = 'current'; + + return ($items); + } - $maxPages = $this->getMaxPages(); - - if (($this->_itemPadding * 3) + $this->_previousItems + $this->_nextItems > $maxPages) - { - /* Disable item padding */ - for ($i = 1; $i < $this->getMaxPages() + 1; $i++) - { - $items[$i] = $i; - } - } else { - for ($i=1;$i<$this->_previousItems+1; $i++) - { - if ($i <= $maxPages && $i >= 1) - { - $items[$i] = $i; - } - - if ($i+1 <= $maxPages && $i >= 2) - { - $items[$i+1] = "|"; - } - } - - for ($i = $this->_currentPage - $this->_itemPadding; $i< $this->_currentPage + $this->_itemPadding + 1; $i++) - { - if ($i <= $maxPages && $i >= 1) - { - $items[$i] = $i; - } - - if ($i+1 <= $maxPages && $i >= 2) - { - $items[$i+1] = "|"; - } - } - - for ($i=($this->getMaxPages()-$this->_nextItems)+1; $i < $this->getMaxPages()+1; $i++) - { - if ($i <= $maxPages && $i >= 2) - { - $items[$i] = $i; - } - } - } - - $items[$this->_currentPage] = 'current'; - - return ($items); - } - } -?> diff --git a/trunk/conlite/classes/widgets/class.widgets.switchabledatechooser.php b/trunk/conlite/classes/widgets/class.widgets.switchabledatechooser.php index b887c2d..7c5e0ab 100644 --- a/trunk/conlite/classes/widgets/class.widgets.switchabledatechooser.php +++ b/trunk/conlite/classes/widgets/class.widgets.switchabledatechooser.php @@ -1,4 +1,5 @@ _oCheckBox = new cHTMLCheckbox($this->getID()."_check", "true"); - $this->_oCheckBox->setLabelText(""); - - $this->_oCheckBox->setEvent("click", 'document.getElementById("'.$this->getId().'").disabled = !this.checked; var jstyle = document.getElementById("'.$this->getId().'"); if (this.checked) { jstyle.className = "textbox"; if (x_oldvalue_'.$this->getID().') { jstyle.value = x_oldvalue_'.$this->getID().';} document.getElementById("'.$this->_oImage->getId().'").style.visibility = "";} else { jstyle.className = "textbox_readonly"; x_oldvalue_'.$this->getID().' = jstyle.value; jstyle.value = ""; document.getElementById("'.$this->_oImage->getId().'").style.visibility = "hidden";}'); - - $this->enable(); - } - - function disable () - { - $this->_bDisabled = true; - $this->setDisabled(true); - $this->_oCheckBox->setChecked(false); - $this->setClass("textbox_readonly"); - $this->_oImage->setStyle("margin-left: 2px; cursor: pointer; visibility: hidden;"); - } - - function enable () - { - $this->_bDisabled = false; - $this->setDisabled(false); - $this->_oCheckBox->setChecked(true); - $this->setClass("textbox"); - } - - function render () - { - $sRender = parent::render(); - - $oAlignmentTable = new cHTMLAlignmentTable($this->_oCheckBox->toHtml(false), $sRender); - - if ($this->_bDisabled) - { - $addscript ='document.getElementById("'.$this->getId().'").value = "";'; - } - return $oAlignmentTable->render() . ''; - } -} \ No newline at end of file + var $_oCheckBox; + var $_bReadOnly; + var $_bDisabled; + + function __construct($name, $initValue = false) { + parent::__construct($name, $initValue); + + $this->_oCheckBox = new cHTMLCheckbox($this->getID() . "_check", "true"); + $this->_oCheckBox->setLabelText(""); + + $this->_oCheckBox->setEvent("click", 'document.getElementById("' . $this->getId() . '").disabled = !this.checked; var jstyle = document.getElementById("' . $this->getId() . '"); if (this.checked) { jstyle.className = "textbox"; if (x_oldvalue_' . $this->getID() . ') { jstyle.value = x_oldvalue_' . $this->getID() . ';} document.getElementById("' . $this->_oImage->getId() . '").style.visibility = "";} else { jstyle.className = "textbox_readonly"; x_oldvalue_' . $this->getID() . ' = jstyle.value; jstyle.value = ""; document.getElementById("' . $this->_oImage->getId() . '").style.visibility = "hidden";}'); + + $this->enable(); + } + + function disable() { + $this->_bDisabled = true; + $this->setDisabled(true); + $this->_oCheckBox->setChecked(false); + $this->setClass("textbox_readonly"); + $this->_oImage->setStyle("margin-left: 2px; cursor: pointer; visibility: hidden;"); + } + + function enable() { + $this->_bDisabled = false; + $this->setDisabled(false); + $this->_oCheckBox->setChecked(true); + $this->setClass("textbox"); + } + + function render() { + $sRender = parent::render(); + + $oAlignmentTable = new cHTMLAlignmentTable($this->_oCheckBox->toHtml(false), $sRender); + + if ($this->_bDisabled) { + $addscript = 'document.getElementById("' . $this->getId() . '").value = "";'; + } + return $oAlignmentTable->render() . ''; + } + +} diff --git a/trunk/conlite/classes/widgets/class.widgets.tableedit.php b/trunk/conlite/classes/widgets/class.widgets.tableedit.php index 2ae9efa..0705abb 100644 --- a/trunk/conlite/classes/widgets/class.widgets.tableedit.php +++ b/trunk/conlite/classes/widgets/class.widgets.tableedit.php @@ -1,4 +1,5 @@ _metaobject = $metaobject; + $this->_title = $title; + + if ($_GET["edit"] == get_class($this->_metaobject->_payloadObject)) { + $this->_metaobject->processEdit(); + } + } + + function render() { + global $cfg, $sess, $action, $area, $frame; + + if ($this->_metaobject->_objectInvalid) { + return; + } + $this->_metaobject->defineFields(); + + $form = new cHTMLForm; + $form->setVar("contenido", $sess->id); + + /* Fetch the edit action from the metaobject */ + $editaction = $this->_metaobject->getAction($this->_metaobject->_editAction); + + $form->setVar("action", $editaction->_namedAction); + $form->setVar("area", $area); + $form->setVar("frame", $frame); + $form->setVar("edit", get_class($this->_metaobject->_payloadObject)); + $form->setVar($this->_metaobject->_payloadObject->primaryKey, $this->_metaobject->_payloadObject->get($this->_metaobject->_payloadObject->primaryKey)); + + + $table = new cHTMLTable; + $table->setStyle("border: 1px solid " . $cfg['color']['table_border'] . ";"); + $row = new cHTMLTableRow; + + $row->setContent($this->renderHeader()); + + $out = ""; + + if (count($this->_metaobject->_fields) == 1) { + foreach ($this->_metaobject->_fields as $key => $value) { + $out .= $this->renderRows($key, $this->_iconWidth + 6); + } + } else { + foreach ($this->_metaobject->_fields as $key => $value) { + $out .= $this->renderGroup($key); + } + } + + $out .= $this->renderButtons(); + + + $table->setContent($row->render() . $out); + + $form->setContent($table); + + return ($form->render()); + } + + function renderHeader() { + global $cfg; + $td = new cHTMLTableData; + $td->setColSpan(2); + $td->setVerticalAlignment("middle"); + + /* Check for icon */ + if ($this->_metaobject->getIcon() != "") { + $img = new cHTMLImage; + $img->setSrc($this->_metaobject->getIcon()); + $img->applyDimensions(); + $this->_iconWidth = $img->_width; + $img->setAlignment("absmiddle"); + $image = $img->render(); + } + $td->setStyle("padding-left: 2px;"); + + $a = new cHTMLAlignmentTable($image, '' . $this->_title . ""); + + $td->setContent($a); + $td->setHeight(18); + $td->setBackgroundColor($cfg['color']['table_header']); + + return ($td); + } + + function renderGroup($group) { + return renderRows($group); + } + + function renderRows($group, $padding = 2) { + global $cfg; + + foreach ($this->_metaobject->_fields[$group] as $field => $parameters) { + $this->_darkShading = !$this->_darkShading; + + $c = new cHTMLTableRow; + $b = new cHTMLTableData; + $l = new cHTMLTableData; + $r = new cHTMLTableData; + + $l->setContent($parameters["name"]); + $paramname = get_class($this->_metaobject) . "_" . $field; + + $widget = new $parameters["editwidget"]($paramname, $parameters["parameters"]); + + $r->setContent($widget); + + $r->setStyle("padding: 2px; border-top: 1px solid " . $cfg["color"]["table_border"]); + $l->setStyle("padding: 4px; padding-left: {$padding}px; border-top: 1px solid " . $cfg["color"]["table_border"] . "; border-right: 1px solid " . $cfg["color"]["table_border"]); + $l->setVerticalAlignment("top"); + if ($this->_darkShading) { + $l->setBackgroundColor($cfg["color"]["table_dark"]); + $r->setBackgroundColor($cfg["color"]["table_dark"]); + } else { + $l->setBackgroundColor($cfg["color"]["table_light"]); + $r->setBackgroundColor($cfg["color"]["table_light"]); + } + + $c->setContent(array($l, $r)); + + $out .= $c->render(); + } + + return $out; + } + + function renderButtons() { + global $cfg; + + $c = new cHTMLTableRow; + $b = new cHTMLTableData; + + $b->setStyle("padding: 2px; border-top: 1px solid " . $cfg["color"]["table_border"]); + $b->setAlignment("right"); + + $submit = new cHTMLButton("submit"); + $submit->setMode("image"); + $submit->setAccessKey("s"); + $submit->setImageSource("images/buttons/but_ok.gif"); + $submit->setStyle("margin: 0px 1px 0px 1px;"); + $submit->setAlt(i18n("Save changes")); + + $b->setColSpan(2); + $b->setContent($submit); + $c->setContent($b); + + return ($c->render()); + } -class cWidgetTableEdit -{ - function cWidgetTableEdit ($metaobject, $title) - { - $this->_metaobject = $metaobject; - $this->_title = $title; - - if ($_GET["edit"] == get_class($this->_metaobject->_payloadObject)) - { - $this->_metaobject->processEdit(); - } - } - - function render () - { - global $cfg, $sess, $action, $area, $frame; - - if ($this->_metaobject->_objectInvalid) { return; } - $this->_metaobject->defineFields(); - - $form = new cHTMLForm; - $form->setVar("contenido", $sess->id); - - /* Fetch the edit action from the metaobject */ - $editaction = $this->_metaobject->getAction($this->_metaobject->_editAction); - - $form->setVar("action", $editaction->_namedAction); - $form->setVar("area", $area); - $form->setVar("frame", $frame); - $form->setVar("edit", get_class($this->_metaobject->_payloadObject)); - $form->setVar($this->_metaobject->_payloadObject->primaryKey, $this->_metaobject->_payloadObject->get($this->_metaobject->_payloadObject->primaryKey)); - - - $table = new cHTMLTable; - $table->setStyle("border: 1px solid ".$cfg['color']['table_border'].";"); - $row = new cHTMLTableRow; - - $row->setContent($this->renderHeader()); - - $out = ""; - - if (count($this->_metaobject->_fields) == 1) - { - foreach ($this->_metaobject->_fields as $key => $value) - { - $out .= $this->renderRows($key,$this->_iconWidth+6); - } - } else { - foreach ($this->_metaobject->_fields as $key => $value) - { - $out .= $this->renderGroup($key); - } - } - - $out .= $this->renderButtons(); - - - $table->setContent($row->render() . $out); - - $form->setContent($table); - - return ($form->render()); - } - - function renderHeader () - { - global $cfg; - $td = new cHTMLTableData; - $td->setColSpan(2); - $td->setVerticalAlignment("middle"); - - /* Check for icon */ - if ($this->_metaobject->getIcon() != "") - { - $img = new cHTMLImage; - $img->setSrc($this->_metaobject->getIcon()); - $img->applyDimensions(); - $this->_iconWidth = $img->_width; - $img->setAlignment("absmiddle"); - $image = $img->render(); - } - $td->setStyle("padding-left: 2px;"); - - $a = new cHTMLAlignmentTable($image, ''.$this->_title.""); - - $td->setContent($a); - $td->setHeight(18); - $td->setBackgroundColor($cfg['color']['table_header']); - - return ($td); - - } - - function renderGroup ($group) - { - return renderRows($group); - - } - - function renderRows ($group, $padding = 2) - { - global $cfg; - - foreach ($this->_metaobject->_fields[$group] as $field => $parameters) - { - $this->_darkShading = ! $this->_darkShading; - - $c = new cHTMLTableRow; - $b = new cHTMLTableData; - $l = new cHTMLTableData; - $r = new cHTMLTableData; - - $l->setContent($parameters["name"]); - $paramname = get_class($this->_metaobject)."_".$field; - - $widget = new $parameters["editwidget"]($paramname, $parameters["parameters"]); - - $r->setContent($widget); - - $r->setStyle("padding: 2px; border-top: 1px solid ". $cfg["color"]["table_border"]); - $l->setStyle("padding: 4px; padding-left: {$padding}px; border-top: 1px solid ". $cfg["color"]["table_border"]."; border-right: 1px solid ". $cfg["color"]["table_border"]); - $l->setVerticalAlignment("top"); - if ($this->_darkShading) - { - $l->setBackgroundColor($cfg["color"]["table_dark"]); - $r->setBackgroundColor($cfg["color"]["table_dark"]); - } else { - $l->setBackgroundColor($cfg["color"]["table_light"]); - $r->setBackgroundColor($cfg["color"]["table_light"]); - } - - $c->setContent(array($l, $r)); - - $out .= $c->render(); - } - - return $out; - } - - function renderButtons () - { - global $cfg; - - $c = new cHTMLTableRow; - $b = new cHTMLTableData; - - $b->setStyle("padding: 2px; border-top: 1px solid ".$cfg["color"]["table_border"]); - $b->setAlignment("right"); - - $submit = new cHTMLButton("submit"); - $submit->setMode("image"); - $submit->setAccessKey("s"); - $submit->setImageSource("images/buttons/but_ok.gif"); - $submit->setStyle("margin: 0px 1px 0px 1px;"); - $submit->setAlt(i18n("Save changes")); - - $b->setColSpan(2); - $b->setContent($submit); - $c->setContent($b); - - return ($c->render()); - - } } -?> \ No newline at end of file diff --git a/trunk/conlite/classes/widgets/class.widgets.treeview.php b/trunk/conlite/classes/widgets/class.widgets.treeview.php index 096a187..5f140d9 100644 --- a/trunk/conlite/classes/widgets/class.widgets.treeview.php +++ b/trunk/conlite/classes/widgets/class.widgets.treeview.php @@ -1,19 +1,20 @@ _uuid = $uuid; - //$this->setGridlineMode(TREEVIEW_GRIDLINE_DOTTED); - - if ($treename != false) - { - $this->setTreeName($treename); - } - - $this->setBackgroundColors(array($cfg['color']['table_light'], $cfg['color']['table_dark'])); - - $this->_user = new cApiUser($auth->auth["uid"]); - - } - - function processParameters () - { - if (($items = $this->_user->getUserProperty("expandstate", $this->_uuid)) !== false) - { - $list = unserialize($items); - - foreach ($list as $litem) - { - $this->setCollapsed($litem); - } - } - - if (!empty($this->_name)) - { - $treename = $this->_name."_"; - } - - if (array_key_exists($treename."collapse",$_GET)) - { - $this->setCollapsed($_GET[$treename."collapse"]); - } - - if (array_key_exists($treename."expand",$_GET)) - { - $this->setExpanded($_GET[$treename."expand"]); - } - - $xlist = array(); // Define variable before using it by reference... - $this->getCollapsedList($xlist); - $slist = serialize($xlist); - - $this->_user->setUserProperty("expandstate", $this->_uuid, $slist); - } - - /** - * applies an action to all items in the tree. - * - * @param cApiClickableAction action action object - * @return void - * @access public - */ - function applyGlobalAction( $action ) - { - - } // end of member function applyGlobalAction + /** + * + * @access private + */ + var $_setAttributeActions; - /** - * removes the action from all treeitems. - * - * @param cApiClickableAction action Removes the action from the global context. - * @return void - * @access public - */ - function removeGlobalAction( $action ) - { - - } // end of member function removeGlobalAction + /** + * + * @access private + */ + var $_unsetAttributeActions; + var $_baseLink; - /** - * flushes all actions - * - * @return void - * @access public - */ - function flushGlobalActions( ) - { - - } // end of member function flushGlobalActions + function __construct($uuid, $treename = false) { + global $cfg, $auth; - /** - * sets an action to a specific item. - * - * @param mixed item cTreeItem-Object or an id of a TreeItem-Object - * @param cApiClickableAction action - * @return void - * @access public - */ - function applyItemAction( $item, $action ) - { - - } // end of member function applyItemAction + parent::__construct(); - /** - * unsets an action from a specific item. Note that you can unset global actions - * using this method! - * - * @param mixed item cTreeItem-Object or an id of a TreeItem-Object - * @param cApiClickableAction action Action to unset - * @return void - * @access public - */ - function removeItemAction( $item, $action ) - { - - } // end of member function removeItemAction + $this->_uuid = $uuid; + //$this->setGridlineMode(TREEVIEW_GRIDLINE_DOTTED); - /** - * flushes all actions for a specific item - * - * @param mixed item cTreeItem-Object or an id of a TreeItem-Object - * @return void - * @access public - */ - function flushItemActions( $item ) - { - - } // end of member function flushItemActions + if ($treename != false) { + $this->setTreeName($treename); + } - /** - * Applies an action to all items with a certain attribute set. - * - * @param array attributes Values which need to match. The array key is the attribute name. Multiple array -entries are connected with "AND". - * @param cApiClickableAction action Action to apply - * @return void - * @access public - */ - function applyActionByItemAttribute( $attributes, $action ) - { - - } // end of member function applyActionByItemAttribute + $this->setBackgroundColors(array($cfg['color']['table_light'], $cfg['color']['table_dark'])); - /** - * Removes an action from all items with a certain attribute set. - * - * @param array attributes Values which need to match. The array key is the attribute name. Multiple array -entries are connected with "AND". - * @param cApiClickableAction action Action to remove - * @return void - * @access public - */ - function removeActionByItemAttribute( $attributes, $action ) - { - - } // end of member function removeActionByItemAttribute + $this->_user = new cApiUser($auth->auth["uid"]); + } - /** - * Removes all actions for items with specific attributes - * - * @param array attributes Values which need to match. The array key is the attribute name. Multiple array -entries are connected with "AND". - * @return void - * @access public - */ - function flushActionByItemAttribute( $attributes ) - { - - } // end of member function flushActionByItemAttribute + function processParameters() { + if (($items = $this->_user->getUserProperty("expandstate", $this->_uuid)) !== false) { + $list = unserialize($items); - /** - * - * - * @param int mode Sets the gridline mode to one of the following values: - * TREEVIEW_GRIDLINE_SOLID - * TREEVIEW_GRIDLINE_DASHED - * TREEVIEW_GRIDLINE_DOTTED - * TREEVIEW_GRIDLINE_NONE - * - * @return void - * @access public - */ - function setGridlineMode( $mode ) - { - $this->_gridlineMode = $mode; - } // end of member function setGridlineMode + foreach ($list as $litem) { + $this->setCollapsed($litem); + } + } - function setBackgroundMode ($mode) - { - $this->_backgroundMode = $mode; - } - - function setMouseoverMode ($mode) - { - $this->_mouseoverMode = $mode; - } - - function setBackgroundColors ($colors) - { - $this->_backgroundColors = $colors; - } + if (!empty($this->_name)) { + $treename = $this->_name . "_"; + } - /** - * - * - * @return void - * @access public - */ - function render ($with_root = true) - { + if (array_key_exists($treename . "collapse", $_GET)) { + $this->setCollapsed($_GET[$treename . "collapse"]); + } + + if (array_key_exists($treename . "expand", $_GET)) { + $this->setExpanded($_GET[$treename . "expand"]); + } + + $xlist = array(); // Define variable before using it by reference... + $this->getCollapsedList($xlist); + $slist = serialize($xlist); + + $this->_user->setUserProperty("expandstate", $this->_uuid, $slist); + } + + /** + * applies an action to all items in the tree. + * + * @param cApiClickableAction action action object + * @return void + * @access public + */ + function applyGlobalAction($action) { + + } + +// end of member function applyGlobalAction + + /** + * removes the action from all treeitems. + * + * @param cApiClickableAction action Removes the action from the global context. + * @return void + * @access public + */ + function removeGlobalAction($action) { + + } + +// end of member function removeGlobalAction + + /** + * flushes all actions + * + * @return void + * @access public + */ + function flushGlobalActions() { + + } + +// end of member function flushGlobalActions + + /** + * sets an action to a specific item. + * + * @param mixed item cTreeItem-Object or an id of a TreeItem-Object + * @param cApiClickableAction action + * @return void + * @access public + */ + function applyItemAction($item, $action) { + + } + +// end of member function applyItemAction + + /** + * unsets an action from a specific item. Note that you can unset global actions + * using this method! + * + * @param mixed item cTreeItem-Object or an id of a TreeItem-Object + * @param cApiClickableAction action Action to unset + * @return void + * @access public + */ + function removeItemAction($item, $action) { + + } + +// end of member function removeItemAction + + /** + * flushes all actions for a specific item + * + * @param mixed item cTreeItem-Object or an id of a TreeItem-Object + * @return void + * @access public + */ + function flushItemActions($item) { + + } + +// end of member function flushItemActions + + /** + * Applies an action to all items with a certain attribute set. + * + * @param array attributes Values which need to match. The array key is the attribute name. Multiple array + entries are connected with "AND". + * @param cApiClickableAction action Action to apply + * @return void + * @access public + */ + function applyActionByItemAttribute($attributes, $action) { + + } + +// end of member function applyActionByItemAttribute + + /** + * Removes an action from all items with a certain attribute set. + * + * @param array attributes Values which need to match. The array key is the attribute name. Multiple array + entries are connected with "AND". + * @param cApiClickableAction action Action to remove + * @return void + * @access public + */ + function removeActionByItemAttribute($attributes, $action) { + + } + +// end of member function removeActionByItemAttribute + + /** + * Removes all actions for items with specific attributes + * + * @param array attributes Values which need to match. The array key is the attribute name. Multiple array + entries are connected with "AND". + * @return void + * @access public + */ + function flushActionByItemAttribute($attributes) { + + } + +// end of member function flushActionByItemAttribute + + /** + * + * + * @param int mode Sets the gridline mode to one of the following values: + * TREEVIEW_GRIDLINE_SOLID + * TREEVIEW_GRIDLINE_DASHED + * TREEVIEW_GRIDLINE_DOTTED + * TREEVIEW_GRIDLINE_NONE + * + * @return void + * @access public + */ + function setGridlineMode($mode) { + $this->_gridlineMode = $mode; + } + +// end of member function setGridlineMode + + function setBackgroundMode($mode) { + $this->_backgroundMode = $mode; + } + + function setMouseoverMode($mode) { + $this->_mouseoverMode = $mode; + } + + function setBackgroundColors($colors) { + $this->_backgroundColors = $colors; + } + + /** + * + * + * @return void + * @access public + */ + function render($with_root = true) { $objects = $this->flatTraverse(0); - if ($with_root == false) - { - unset($objects[0]); - } + if ($with_root == false) { + unset($objects[0]); + } + + $img = new cHTMLImage; + $r_table = new cHTMLTable; + $r_row = new cHTMLTableRow; + $r_leftcell = new cHTMLTableData; + $r_rightcell = new cHTMLTableData; + $r_actioncell = new cHTMLTableData; - $img = new cHTMLImage; - $r_table = new cHTMLTable; - $r_row = new cHTMLTableRow; - $r_leftcell = new cHTMLTableData; - $r_rightcell = new cHTMLTableData; - $r_actioncell = new cHTMLTableData; - $img_spacer = new cHTMLImage; $img_spacer->updateAttributes(array('width' => '16', 'height' => '20')); $img_spacer->setAlt(""); $img_spacer->setSrc("images/spacer.gif"); - $img_spacer->advanceID(); - - $r_table->setCellPadding(0); - $r_table->setCellSpacing(0); - $r_table->setWidth("100%"); - $r_rightcell->setStyleDefinition("padding-left", "3px"); - $r_rightcell->setVerticalAlignment("middle"); - $r_leftcell->setVerticalAlignment("middle"); - $r_leftcell->updateAttributes(array("nowrap" => "nowrap")); - $r_rightcell->updateAttributes(array("nowrap" => "nowrap")); - $r_actioncell->updateAttributes(array("nowrap" => "nowrap")); - $r_leftcell->setWidth("1%"); - $r_rightcell->setWidth("100%"); - $r_actioncell->setAlignment("right"); - $r_actioncell->setWidth("1%"); - - if (!is_object($this->_baseLink)) - { - $this->_baseLink = new cHTMLLink; - } - - $lastitem = array(); - foreach ($objects as $key => $object) - { - $img->setAlt(""); - $r_table->advanceID(); - $r_rightcell->advanceID(); - $r_leftcell->advanceID(); - $r_row->advanceID(); - $r_actioncell->advanceID(); - - for ($level = 1; $level < $object->_level + 1; $level++) - { - if ($object->_level == $level) - { - if ($object->_next === false) - { - if (count($object->_subitems) > 0) - { - $link = $this->_setExpandCollapseLink($this->_baseLink, $object); - $link->advanceID(); - $img->setSrc($this->_getExpandCollapseIcon($object)); - $img->advanceID(); - $link->setContent($img); - $out .= $link->render(); - } else { - if ($level == 1 && $with_root == false) - { - $out .= $img_spacer->render(); - } else { - $img->setSrc($this->_buildImagePath("grid_linedownrightend.gif")); - $img->advanceID(); - $out .= $img->render(); - } - } - $lastitem[$level] = true; - } else { - if (count($object->_subitems) > 0) - { - $link = $this->_setExpandCollapseLink($this->_baseLink, $object); - $link->advanceID(); - $img->setSrc($this->_getExpandCollapseIcon($object)); - $img->advanceID(); - $link->setContent($img); - $out .= $link->render(); - } else { - if ($level == 1 && $with_root == false) - { - $out .= $img_spacer->render(); - } else { - $img->setSrc($this->_buildImagePath("grid_linedownright.gif")); - $out .= $img->render(); - } - } - - $lastitem[$level] = false; - } - } else { - if ($lastitem[$level] == true) - { - $out .= $img_spacer->render(); - } else { - if ($level == 1 && $with_root == false) - { - $out .= $img_spacer->render(); - } else { - $img->setSrc($this->_buildImagePath("/grid_linedown.gif")); - $img->advanceID(); - $out .= $img->render(); - } - } - } - } - - /* Fetch Render icon from the meta object */ - if (is_object($object->payload)) - { - /* Fetch payload object */ - $meta = $object->payload->getMetaObject(); - - if (is_object($meta)) - { - $icon = $meta->getIcon(); - $actions = $meta->getActions(); - - $r_actioncell->setContent($actions); - - $img->setAlt($meta->getDescription()); - $img->advanceID(); - - /* Check if we've got an edit link */ - if (count($meta->_editAction) > 0) - { - $meta->defineActions(); - - $edit = $meta->getAction($meta->_editAction); - - $edit->setIcon($icon); - - $renderedIcon = $edit->render(); - - $edit->_link->setContent($object->_name); - $edit->_link->advanceID(); - $renderedName = $edit->_link->render(); - } else { - $img->setSrc($icon); - $renderedIcon = $img->render(); - $renderedName = $object->_name; - } - } - } else { - if (isset($object->_attributes["icon"])) - { - $img->setSrc($object->_attributes["icon"]); - $renderedIcon = $img->render(); - $renderedName = $object->_name; - } else { - /* Fetch tree icon */ - if ($object->_id == 0) - { - $icon = $object->_treeIcon; - $img->setSrc($icon); - $renderedIcon = $img->render(); - $renderedName = $object->_name; - } else { - $icon = $object->_treeIcon; - $img->setSrc($icon); - $renderedIcon = $img->render(); - $renderedName = $object->_name; - } - } - } + $img_spacer->advanceID(); - if ($this->_backgroundMode == TREEVIEW_BACKGROUND_SHADED) - { - if (current($this->_backgroundColors) === false) - { - reset($this->_backgroundColors); - } - - $color = current($this->_backgroundColors); - next($this->_backgroundColors); - - $r_rightcell->setBackgroundColor($color); - $r_leftcell->setBackgroundColor($color); - $r_actioncell->setBackgroundColor($color); - } - - $img->setSrc($icon); - $r_leftcell->setContent($out . $renderedIcon); - $r_rightcell->setContent($renderedName); - - $r_row->setContent(array($r_leftcell, $r_rightcell, $r_actioncell)); - - $r_table->setContent($r_row); + $r_table->setCellPadding(0); + $r_table->setCellSpacing(0); + $r_table->setWidth("100%"); + $r_rightcell->setStyleDefinition("padding-left", "3px"); + $r_rightcell->setVerticalAlignment("middle"); + $r_leftcell->setVerticalAlignment("middle"); + $r_leftcell->updateAttributes(array("nowrap" => "nowrap")); + $r_rightcell->updateAttributes(array("nowrap" => "nowrap")); + $r_actioncell->updateAttributes(array("nowrap" => "nowrap")); + $r_leftcell->setWidth("1%"); + $r_rightcell->setWidth("100%"); + $r_actioncell->setAlignment("right"); + $r_actioncell->setWidth("1%"); - $result .= $r_table->render(); - - unset($out); + if (!is_object($this->_baseLink)) { + $this->_baseLink = new cHTMLLink; } - - return ('
'.$result.'
'); - } // end of member function render - function _getExpandCollapseIcon ($object) - { - if ($object->_collapsed == true) - { - return ($this->_buildImagePath("grid_expand.gif")); - } else { - return ($this->_buildImagePath("grid_collapse.gif")); - } - } - - function _setExpandCollapseLink ($link, $object) - { - if (!empty($this->_name)) - { - $treename = $this->_name."_"; - } - - unset($link->_custom[$treename."expand"]); - unset($link->_custom[$treename."collapse"]); - - if ($object->_collapsed == true) - { - $link->setCustom($treename."expand", $object->_id); - } else { - $link->setCustom($treename."collapse", $object->_id); - } - - return ($link); - } - - function _buildImagePath($image) - { - return ("./images/".$this->_gridlineMode."/".$image); - } - - function setBaseLink ($link) - { - $this->_baseLink = $link; - } + $lastitem = array(); + foreach ($objects as $key => $object) { + $img->setAlt(""); + $r_table->advanceID(); + $r_rightcell->advanceID(); + $r_leftcell->advanceID(); + $r_row->advanceID(); + $r_actioncell->advanceID(); + for ($level = 1; $level < $object->_level + 1; $level++) { + if ($object->_level == $level) { + if ($object->_next === false) { + if (count($object->_subitems) > 0) { + $link = $this->_setExpandCollapseLink($this->_baseLink, $object); + $link->advanceID(); + $img->setSrc($this->_getExpandCollapseIcon($object)); + $img->advanceID(); + $link->setContent($img); + $out .= $link->render(); + } else { + if ($level == 1 && $with_root == false) { + $out .= $img_spacer->render(); + } else { + $img->setSrc($this->_buildImagePath("grid_linedownrightend.gif")); + $img->advanceID(); + $out .= $img->render(); + } + } + $lastitem[$level] = true; + } else { + if (count($object->_subitems) > 0) { + $link = $this->_setExpandCollapseLink($this->_baseLink, $object); + $link->advanceID(); + $img->setSrc($this->_getExpandCollapseIcon($object)); + $img->advanceID(); + $link->setContent($img); + $out .= $link->render(); + } else { + if ($level == 1 && $with_root == false) { + $out .= $img_spacer->render(); + } else { + $img->setSrc($this->_buildImagePath("grid_linedownright.gif")); + $out .= $img->render(); + } + } -} // end of cWidgetTreeView -?> + $lastitem[$level] = false; + } + } else { + if ($lastitem[$level] == true) { + $out .= $img_spacer->render(); + } else { + if ($level == 1 && $with_root == false) { + $out .= $img_spacer->render(); + } else { + $img->setSrc($this->_buildImagePath("/grid_linedown.gif")); + $img->advanceID(); + $out .= $img->render(); + } + } + } + } + + /* Fetch Render icon from the meta object */ + if (is_object($object->payload)) { + /* Fetch payload object */ + $meta = $object->payload->getMetaObject(); + + if (is_object($meta)) { + $icon = $meta->getIcon(); + $actions = $meta->getActions(); + + $r_actioncell->setContent($actions); + + $img->setAlt($meta->getDescription()); + $img->advanceID(); + + /* Check if we've got an edit link */ + if (count($meta->_editAction) > 0) { + $meta->defineActions(); + + $edit = $meta->getAction($meta->_editAction); + + $edit->setIcon($icon); + + $renderedIcon = $edit->render(); + + $edit->_link->setContent($object->_name); + $edit->_link->advanceID(); + $renderedName = $edit->_link->render(); + } else { + $img->setSrc($icon); + $renderedIcon = $img->render(); + $renderedName = $object->_name; + } + } + } else { + if (isset($object->_attributes["icon"])) { + $img->setSrc($object->_attributes["icon"]); + $renderedIcon = $img->render(); + $renderedName = $object->_name; + } else { + /* Fetch tree icon */ + if ($object->_id == 0) { + $icon = $object->_treeIcon; + $img->setSrc($icon); + $renderedIcon = $img->render(); + $renderedName = $object->_name; + } else { + $icon = $object->_treeIcon; + $img->setSrc($icon); + $renderedIcon = $img->render(); + $renderedName = $object->_name; + } + } + } + + if ($this->_backgroundMode == TREEVIEW_BACKGROUND_SHADED) { + if (current($this->_backgroundColors) === false) { + reset($this->_backgroundColors); + } + + $color = current($this->_backgroundColors); + next($this->_backgroundColors); + + $r_rightcell->setBackgroundColor($color); + $r_leftcell->setBackgroundColor($color); + $r_actioncell->setBackgroundColor($color); + } + + $img->setSrc($icon); + $r_leftcell->setContent($out . $renderedIcon); + $r_rightcell->setContent($renderedName); + + $r_row->setContent(array($r_leftcell, $r_rightcell, $r_actioncell)); + + $r_table->setContent($r_row); + + $result .= $r_table->render(); + + unset($out); + } + + return ('
' . $result . '
'); + } + +// end of member function render + + function _getExpandCollapseIcon($object) { + if ($object->_collapsed == true) { + return ($this->_buildImagePath("grid_expand.gif")); + } else { + return ($this->_buildImagePath("grid_collapse.gif")); + } + } + + function _setExpandCollapseLink($link, $object) { + if (!empty($this->_name)) { + $treename = $this->_name . "_"; + } + + unset($link->_custom[$treename . "expand"]); + unset($link->_custom[$treename . "collapse"]); + + if ($object->_collapsed == true) { + $link->setCustom($treename . "expand", $object->_id); + } else { + $link->setCustom($treename . "collapse", $object->_id); + } + + return ($link); + } + + function _buildImagePath($image) { + return ("./images/" . $this->_gridlineMode . "/" . $image); + } + + function setBaseLink($link) { + $this->_baseLink = $link; + } + +} diff --git a/trunk/conlite/classes/widgets/class.widgets.views.php b/trunk/conlite/classes/widgets/class.widgets.views.php index f99d16e..6708139 100644 --- a/trunk/conlite/classes/widgets/class.widgets.views.php +++ b/trunk/conlite/classes/widgets/class.widgets.views.php @@ -1,4 +1,5 @@ */ -class cTableView -{ - var $items; - var $captions; - var $id; - var $rownames; - - var $formname; - var $formmethod; - var $formaction; - var $formvars; - - var $tableid; - var $tablebordercolor; - - var $header; - var $cancelLink; - var $submitjs; - - - function UI_Table_Form ($name, $action = "", $method = "post") - { - global $sess, $cfg; - - $this->formname = $name; - - if ($action == "") - { - $this->formaction = "main.php"; - } else { - $this->formaction = $action; - } - - $this->formmethod = $method; +class cTableView { - $this->tableid = ""; - $this->tablebordercolor = $cfg['color']['table_border']; - $this->setAccessKey('s'); - $this->custom = array(); + var $items; + var $captions; + var $id; + var $rownames; + var $formname; + var $formmethod; + var $formaction; + var $formvars; + var $tableid; + var $tablebordercolor; + var $header; + var $cancelLink; + var $submitjs; - $this->setActionButton("submit", "images/but_ok.gif", i18n("Save changes"), "s"); - - } - - function setVar ($name, $value) - { - $this->formvars[$name] = $value; - } - - function add ($caption, $field, $rowname = "") - { - if (is_array($field)) - { - - foreach ($field as $value) - { - if (is_object($value) && method_exists($value, "render")) - { - $n .= $value->render(); - } else { - $n .= $value; - } - } - - $field = $n; - } - if (is_object($field) && method_exists($field, "render")) - { - $n = $field->render(); - $field = $n; - } - if ($field == "") - { - $field = " "; - } - - if ($caption == "") - { - $caption = " "; - } - - $this->id++; - $this->items[$this->id] = $field; - $this->captions[$this->id] = $caption; - - if ($rowname == "") - { - $rowname = $this->id; - } - - $this->rownames[$this->id] = $rowname; - } + function UI_Table_Form($name, $action = "", $method = "post") { + global $sess, $cfg; - function addCancel ($link) - { - $this->cancelLink = $link; - } - - function addHeader ($header) - { - $this->header = $header; - } - - function setSubmitJS ($js) - { - $this->submitjs = $js; - } - - function setAccessKey ($key) - { - $this->accessKey = $key; - } - - function setActionEvent ($id, $event) - { - $this->custom[$id]["event"] = $event; - } - - function setActionButton ($id, $image, $description = "", $accesskey = false, $action = false) - { - $this->custom[$id]["image"] = $image; - $this->custom[$id]["type"] = "actionsetter"; - $this->custom[$id]["action"] = $action; - $this->custom[$id]["description"] = $description; - $this->custom[$id]["accesskey"] = $accesskey; - $this->custom[$id]["event"] = ""; - } - - function unsetActionButton ($id) - { - unset($this->custom[$id]); - } - - - function render ($return = true) - { - global $sess, $cfg; - - $tpl = new Template; - - $extra = ""; - - - $form = '
'."\n"; - $this->formvars["contenido"] = $sess->id; - - if (is_array($this->formvars)) - { - foreach ($this->formvars as $key => $value) - { - $form .= ''."\n"; - } - } - - if (!array_key_exists("action", $this->formvars)) - { - $form .= ''; - } - - $tpl->set('s', 'FORM', $form); - $tpl->set('s', 'ID', $this->tableid); - $tpl->set('s', 'BORDERCOLOR', $this->tablebordercolor); - - if ($this->header != "") - { - $header = '
'.$this->header.'
' . $this->header . '