PHP Version Compatibility; removed deprecated constructors

Dieser Commit ist enthalten in:
Oldperl 2018-12-10 12:13:27 +00:00
Ursprung c0415492d2
Commit 3490184008
70 geänderte Dateien mit 5094 neuen und 6044 gelöschten Zeilen

Datei anzeigen

@ -33,12 +33,6 @@ class cApiActionCollection extends ItemCollection {
parent::__construct($cfg['tab']['actions'], 'idaction'); parent::__construct($cfg['tab']['actions'], 'idaction');
$this->_setItemClass("cApiAction"); $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??? // @todo Where is this used???
$this->_wantParameters = array(); $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);
}
} }
?> ?>

Datei anzeigen

@ -41,7 +41,7 @@ class Action {
* Constructor Function * Constructor Function
* @param * @param
*/ */
function Action() { function __construct() {
// empty // empty
} // end function } // end function

Datei anzeigen

@ -38,7 +38,7 @@ class ActiveUsers {
* *
* @return * @return
* */ * */
function ActiveUsers($oDb, $oCfg, $oAuth) { function __construct($oDb, $oCfg, $oAuth) {
$this->oCfg = $oCfg; $this->oCfg = $oCfg;
$this->oAuth = $oAuth; $this->oAuth = $oAuth;

Datei anzeigen

@ -38,7 +38,7 @@ class Area {
* Constructor Function * Constructor Function
* @param * @param
*/ */
function Area() { function __construct() {
// empty // empty
} // end function } // end function

Datei anzeigen

@ -38,7 +38,7 @@ class Art {
* Constructor Function * Constructor Function
* @param * @param
*/ */
function Art() { function __construct() {
// empty // empty
} // end function } // end function

Datei anzeigen

@ -144,12 +144,6 @@ class Article extends Item
$this->loadByPrimaryKey($this->_iIdArtLang); $this->loadByPrimaryKey($this->_iIdArtLang);
$this->_getArticleContent(); $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 * Getter for idartlang of article object
@ -498,13 +492,6 @@ class ArticleCollection
$this->_getArticlesByCatId($this->idcat); $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 * Set the Object properties
* *

Datei anzeigen

@ -46,13 +46,6 @@ class ArtSpecCollection extends ItemCollection
parent::__construct($cfg['tab']['art_spec'], "idartspec"); parent::__construct($cfg['tab']['art_spec'], "idartspec");
$this->_setItemClass("ArtSpecItem"); $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); $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);
}
} }
?> ?>

Datei anzeigen

@ -72,7 +72,7 @@ class Contenido_Backend {
/** /**
* Constructor * Constructor
*/ */
function Contenido_Backend() { function __construct() {
# do nothing # do nothing
} # end function } # end function

Datei anzeigen

@ -38,7 +38,7 @@ class Cat {
* Constructor Function * Constructor Function
* @param * @param
*/ */
function Cat() { function __construct() {
// empty // empty
} // end function } // end function

Datei anzeigen

@ -43,13 +43,6 @@ class CategoryCollection extends ItemCollection
parent::__construct($cfg["tab"]["cat"], "idcat"); parent::__construct($cfg["tab"]["cat"], "idcat");
$this->_setItemClass("CategoryItem"); $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) public function loadByPrimaryKey($key)
{ {
if (parent::loadByPrimaryKey($key)) { if (parent::loadByPrimaryKey($key)) {
@ -101,13 +87,6 @@ class CategoryLanguageCollection extends ItemCollection
parent::__construct($cfg["tab"]["cat_lang"], "idcatlang"); parent::__construct($cfg["tab"]["cat_lang"], "idcatlang");
$this->_setItemClass("CategoryLanguageItem"); $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); $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);
}
}
?>

Datei anzeigen

@ -52,7 +52,7 @@ class cCharacterConverter
var $_aAliasCache; var $_aAliasCache;
var $_aCharCache; var $_aCharCache;
function cCharacterConverter () function __construct ()
{ {
$this->_oDB = new DB_ConLite; $this->_oDB = new DB_ConLite;
$this->_aAliasCache = array(); $this->_aAliasCache = array();
@ -154,5 +154,4 @@ class cCharacterConverter
return $sEncoding; return $sEncoding;
} }
} }
?>

Datei anzeigen

@ -131,7 +131,7 @@ class clDbBackup {
$data = "DROP TABLE IF EXISTS `$sTable`;\n"; $data = "DROP TABLE IF EXISTS `$sTable`;\n";
$this->_oDb->query('SHOW CREATE TABLE `' . $sTable . '`'); $this->_oDb->query('SHOW CREATE TABLE `' . $sTable . '`');
$this->_oDb->next_record(); $this->_oDb->next_record();
$row = $this->_oDb->toArray(); //@mysql_fetch_row($res); $row = $this->_oDb->toArray();
$data .= $row[1] . ';' . "\n\n"; $data .= $row[1] . ';' . "\n\n";
if (!$this->_noTableData($sTable)) { if (!$this->_noTableData($sTable)) {
$data .= "/*!40000 ALTER TABLE `$sTable` DISABLE KEYS */;\n"; $data .= "/*!40000 ALTER TABLE `$sTable` DISABLE KEYS */;\n";
@ -194,7 +194,7 @@ class clDbBackup {
if (!isset($rows[$column])) { if (!isset($rows[$column])) {
$insert.='NULL,'; $insert.='NULL,';
} else if ($rows[$column] != '') { } else if ($rows[$column] != '') {
$insert.='\'' . mysql_escape_string($rows[$column]) . '\','; $insert.='\'' . $this->_oDb->escape($rows[$column]) . '\',';
} else { } else {
$insert.='\'\','; $insert.='\'\',';
} }

Datei anzeigen

@ -38,7 +38,7 @@ class Client {
* Constructor Function * Constructor Function
* @param * @param
*/ */
function Client() { function __construct() {
// empty // empty
} // end function } // end function

Datei anzeigen

@ -47,13 +47,6 @@ class CommunicationCollection extends ItemCollection
$this->_setItemClass("CommunicationItem"); $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 * 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() function store()
{ {
global $auth; global $auth;
@ -106,6 +92,4 @@ class CommunicationItem extends Item
parent::store(); parent::store();
} }
} }
?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -30,52 +31,41 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) { if (!defined('CON_FRAMEWORK')) {
die('Illegal call'); die('Illegal call');
} }
class DBFSCollection extends ItemCollection {
class DBFSCollection extends ItemCollection
{
/** /**
* Constructor Function * Constructor Function
* @param none * @param none
*/ */
public function __construct() public function __construct() {
{
global $cfg; global $cfg;
parent::__construct($cfg["tab"]["dbfs"], "iddbfs"); parent::__construct($cfg["tab"]["dbfs"], "iddbfs");
$this->_setItemClass("DBFSItem"); $this->_setItemClass("DBFSItem");
} }
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ public function outputFile($path) {
public function DBFSCollection()
{
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
$this->__construct();
}
public function outputFile($path)
{
global $client, $auth; global $client, $auth;
$path = Contenido_Security::escapeDB($path, null); $path = Contenido_Security::escapeDB($path, null);
$client = Contenido_Security::toInteger($client); $client = Contenido_Security::toInteger($client);
$path = $this->strip_path($path); $path = $this->strip_path($path);
$dir = dirname($path); $dir = dirname($path);
$file = basename($path); $file = basename($path);
if ($dir == ".") { if ($dir == ".") {
$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()) { if ($item = $this->next()) {
$properties = new PropertyCollection(); $properties = new PropertyCollection();
// Check if we're allowed to access it // 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") { if ($auth->auth["uid"] == "nobody") {
header("HTTP/1.0 403 Forbidden"); header("HTTP/1.0 403 Forbidden");
return; return;
@ -83,10 +73,10 @@ class DBFSCollection extends ItemCollection
} }
$mimetype = $item->get("mimetype"); $mimetype = $item->get("mimetype");
header("Cache-Control: ");// leave blank to avoid IE errors header("Cache-Control: "); // leave blank to avoid IE errors
header("Pragma: ");// leave blank to avoid IE errors header("Pragma: "); // leave blank to avoid IE errors
header("Content-Type: $mimetype"); header("Content-Type: $mimetype");
header("Etag: ".md5(mt_rand())); header("Etag: " . md5(mt_rand()));
// header("Content-Disposition: filename=$file"); // header("Content-Disposition: filename=$file");
header("Content-Disposition: attachment; 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); $targetfile = $this->strip_path($targetfile);
$mimetype = mime_content_type($localfile); $mimetype = mime_content_type($localfile);
$this->write($targetfile, file_get_contents($localfile), $mimetype); $this->write($targetfile, file_get_contents($localfile), $mimetype);
} }
public function writeToFile($sourcefile, $localfile) public function writeToFile($sourcefile, $localfile) {
{
$sourcefile = $this->strip_path($sourcefile); $sourcefile = $this->strip_path($sourcefile);
file_put_contents($localfile, $this->read($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); $file = $this->strip_path($file);
if (!$this->file_exists($file)) { if (!$this->file_exists($file)) {
@ -120,20 +107,19 @@ class DBFSCollection extends ItemCollection
$this->setContent($file, $content); $this->setContent($file, $content);
} }
public function hasFiles($path) public function hasFiles($path) {
{
global $client; global $client;
$path = $this->strip_path($path); $path = $this->strip_path($path);
$client = Contenido_Security::toInteger($client); $client = Contenido_Security::toInteger($client);
/* Are there any subdirs? */ /* 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) { if ($this->count() > 0) {
return true; 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) { if ($this->count() > 1) {
return true; return true;
@ -142,18 +128,16 @@ class DBFSCollection extends ItemCollection
} }
} }
public function read($file) public function read($file) {
{
return ($this->getContent($file)); return ($this->getContent($file));
} }
public function file_exists($path) public function file_exists($path) {
{
global $client; global $client;
$path = $this->strip_path($path); $path = $this->strip_path($path);
$dir = dirname($path); $dir = dirname($path);
$file = basename($path); $file = basename($path);
if ($dir == ".") { if ($dir == ".") {
$dir = ""; $dir = "";
@ -161,7 +145,7 @@ class DBFSCollection extends ItemCollection
$client = Contenido_Security::toInteger($client); $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()) { if ($this->next()) {
return true; return true;
} else { } else {
@ -169,8 +153,7 @@ class DBFSCollection extends ItemCollection
} }
} }
public function dir_exists($path) public function dir_exists($path) {
{
global $client; global $client;
$path = $this->strip_path($path); $path = $this->strip_path($path);
@ -181,7 +164,7 @@ class DBFSCollection extends ItemCollection
$client = Contenido_Security::toInteger($client); $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()) { if ($this->next()) {
return true; return true;
} else { } else {
@ -189,21 +172,19 @@ class DBFSCollection extends ItemCollection
} }
} }
public function parent_dir($path) public function parent_dir($path) {
{
$path = dirname($path); $path = dirname($path);
return $path; return $path;
} }
public function create($path, $mimetype = "", $content = "") public function create($path, $mimetype = "", $content = "") {
{
global $client, $cfg, $auth; global $client, $cfg, $auth;
$client = Contenido_Security::toInteger($client); $client = Contenido_Security::toInteger($client);
if (substr($path,0,1) == "/") { if (substr($path, 0, 1) == "/") {
$path = substr($path,1); $path = substr($path, 1);
} }
$dir = dirname($path); $dir = dirname($path);
@ -220,9 +201,9 @@ class DBFSCollection extends ItemCollection
if ($file != ".") { if ($file != ".") {
if ($dir != "") { if ($dir != "") {
// Check if the directory exists. If not, create it. // 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()) { if (!$this->next()) {
$this->create($dir."/."); $this->create($dir . "/.");
} }
} }
} else { } else {
@ -230,7 +211,7 @@ class DBFSCollection extends ItemCollection
if ($parent != ".") { if ($parent != ".") {
if (!$this->dir_exists($parent)) { if (!$this->dir_exists($parent)) {
$this->create($parent."/."); $this->create($parent . "/.");
} }
} }
} }
@ -254,20 +235,19 @@ class DBFSCollection extends ItemCollection
return ($item); return ($item);
} }
public function setContent($path, $content) public function setContent($path, $content) {
{
global $client; global $client;
$client = Contenido_Security::toInteger($client); $client = Contenido_Security::toInteger($client);
$path = $this->strip_path($path); $path = $this->strip_path($path);
$dirname = dirname($path); $dirname = dirname($path);
$filename = basename($path); $filename = basename($path);
if ($dirname == ".") { if ($dirname == ".") {
$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()) { if ($item = $this->next()) {
$item->set("content", $content); $item->set("content", $content);
$item->set("size", strlen($content)); $item->set("size", strlen($content));
@ -275,70 +255,66 @@ class DBFSCollection extends ItemCollection
} }
} }
public function getSize($path) public function getSize($path) {
{
global $client; global $client;
$client = Contenido_Security::toInteger($client); $client = Contenido_Security::toInteger($client);
$path = $this->strip_path($path); $path = $this->strip_path($path);
$dirname = dirname($path); $dirname = dirname($path);
$filename = basename($path); $filename = basename($path);
if ($dirname == ".") { if ($dirname == ".") {
$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()) { if ($item = $this->next()) {
return $item->get("size"); return $item->get("size");
} }
} }
public function getContent($path) public function getContent($path) {
{
global $client; global $client;
$client = Contenido_Security::toInteger($client); $client = Contenido_Security::toInteger($client);
$dirname = dirname($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()) {
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); $filename = basename($path);
if ($dirname == ".") { if ($dirname == ".") {
$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()) { if ($item = $this->next()) {
$this->delete($item->get("iddbfs")); $this->delete($item->get("iddbfs"));
} }
} }
public function strip_path($path) public function strip_path($path) {
{ if (substr($path, 0, 5) == "dbfs:") {
if (substr($path,0,5) == "dbfs:") { $path = substr($path, 5);
$path = substr($path,5);
} }
if (substr($path,0,1) == "/") { if (substr($path, 0, 1) == "/") {
$path = substr($path,1); $path = substr($path, 1);
} }
return $path; return $path;
@ -349,15 +325,14 @@ class DBFSCollection extends ItemCollection
* @param datatype $sPath * @param datatype $sPath
* @return bool $bAvailable * @return bool $bAvailable
*/ */
public function checkTimeManagement($sPath, $oProperties) public function checkTimeManagement($sPath, $oProperties) {
{
global $contenido; global $contenido;
if ($contenido) { if ($contenido) {
return true; return true;
} }
$sPath = Contenido_Security::toString($sPath); $sPath = Contenido_Security::toString($sPath);
$bAvailable = true; $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) { if ($iTimeMng == 0) {
return true; return true;
} }
@ -366,8 +341,7 @@ class DBFSCollection extends ItemCollection
$iNow = time(); $iNow = time();
if ($iNow < $this->dateToTimestamp($sStartDate) || if ($iNow < $this->dateToTimestamp($sStartDate) || ($iNow > $this->dateToTimestamp($sEndDate) && (int) $this->dateToTimestamp($sEndDate) > 0)) {
($iNow > $this->dateToTimestamp($sEndDate) && (int)$this->dateToTimestamp($sEndDate) > 0)) {
return false; return false;
} }
@ -379,21 +353,19 @@ class DBFSCollection extends ItemCollection
* @param string $sDate * @param string $sDate
* @return int $iTimestamp * @return int $iTimestamp
*/ */
public function dateToTimestamp($sDate) public function dateToTimestamp($sDate) {
{
return strtotime($sDate); return strtotime($sDate);
} }
} }
class DBFSItem extends Item {
class DBFSItem extends Item
{
/** /**
* Constructor Function * Constructor Function
* @param mixed $mId Specifies the ID of item to load * @param mixed $mId Specifies the ID of item to load
*/ */
public function __construct($mId = false) public function __construct($mId = false) {
{
global $cfg; global $cfg;
parent::__construct($cfg["tab"]["dbfs"], "iddbfs"); parent::__construct($cfg["tab"]["dbfs"], "iddbfs");
if ($mId !== false) { if ($mId !== false) {
@ -401,15 +373,7 @@ class DBFSItem extends Item
} }
} }
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ public function store() {
public function DBFSItem($mId = false)
{
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
$this->__construct();
}
public function store()
{
global $auth; global $auth;
$this->set("modified", date("Y-m-d H:i:s"), false); $this->set("modified", date("Y-m-d H:i:s"), false);
@ -418,8 +382,7 @@ class DBFSItem extends Item
parent::store(); parent::store();
} }
public function setField($field, $value, $safe = true) public function setField($field, $value, $safe = true) {
{
if ($field == "dirname" || $field == "filename" || $field == "mimetype") { if ($field == "dirname" || $field == "filename" || $field == "mimetype") {
// Don't do safe encoding // Don't do safe encoding
$safe = false; $safe = false;
@ -430,6 +393,5 @@ class DBFSItem extends Item
parent::setField($field, $value, $safe); parent::setField($field, $value, $safe);
} }
}
?> }

Datei anzeigen

@ -40,7 +40,7 @@ class ExcelWorksheet
var $_title; var $_title;
var $_filename; var $_filename;
function ExcelWorksheet ($title, $filename) function __construct ($title, $filename)
{ {
$this->_title = Contenido_Security::escapeDB($title, null); $this->_title = Contenido_Security::escapeDB($title, null);
$this->_filename = Contenido_Security::escapeDB($filename, null); $this->_filename = Contenido_Security::escapeDB($filename, null);

Datei anzeigen

@ -99,7 +99,7 @@ class Form {
* Constructor Function * Constructor Function
* @param * @param
*/ */
function Form() { function __construct() {
// empty // empty
} // end function } // end function
@ -279,7 +279,7 @@ class Form {
} }
// FormField instance // FormField instance
$field = new FormField; $field = new FormField();
// Get Code for one element // Get Code for one element
$tmp_replacements[] = $field->GenerateCode($this->fields[$i]); $tmp_replacements[] = $field->GenerateCode($this->fields[$i]);
@ -364,7 +364,7 @@ class Form {
foreach ($this->fields as $id => $element) { foreach ($this->fields as $id => $element) {
$check = new FormCheck; $check = new FormCheck();
switch (strtolower($element['checktype'])) { switch (strtolower($element['checktype'])) {
@ -447,7 +447,7 @@ class FormField {
/** /**
* Constructor Function * Constructor Function
*/ */
function FormField() { function __construct() {
// do nothing // do nothing
} // end function } // end function
@ -625,7 +625,7 @@ class FormCheck {
* Constructor function * Constructor function
* @access private * @access private
*/ */
function FormCheck () { function __construct () {
// empty // empty
} // end function } // end function
@ -678,6 +678,4 @@ class FormCheck {
return (preg_match('/^[a-z0-9\.]+@[a-z0-9\.]+\.[a-z]+$/i', $value)) ? true : false; return (preg_match('/^[a-z0-9\.]+@[a-z0-9\.]+\.[a-z]+$/i', $value)) ? true : false;
} // end function } // end function
} // end class } // end class
?>

Datei anzeigen

@ -50,13 +50,6 @@ class FrontendGroupCollection extends ItemCollection
$this->_setItemClass("FrontendGroup"); $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 * Creates a new group
* @param $groupname string Specifies the groupname * @param $groupname string Specifies the groupname
@ -122,13 +115,6 @@ class FrontendGroup extends Item
$this->loadByPrimaryKey($mId); $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"); $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 * Creates a new association
* @param $idfrontendgroup int specifies the frontend group * @param $idfrontendgroup int specifies the frontend group
@ -237,13 +216,4 @@ class FrontendGroupMember extends Item
$this->loadByPrimaryKey($mId); $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);
}
}
?>

Datei anzeigen

@ -54,13 +54,6 @@ class FrontendPermissionCollection extends ItemCollection
$this->_setItemClass("FrontendPermission"); $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 * Creates a new permission entry
* @param $group string Specifies the frontend group * @param $group string Specifies the frontend group
@ -157,13 +150,4 @@ class FrontendPermission extends Item
$this->loadByPrimaryKey($mId); $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);
}
}
?>

Datei anzeigen

@ -50,13 +50,6 @@ class FrontendUserCollection extends ItemCollection
$this->_setItemClass("FrontendUser"); $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 * Checks if a specific user already exists
* @param $sUsername string specifies the username to search for * @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 * Overridden setField method to md5 the password
* Sets the value of a specific field * Sets the value of a specific field

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -29,8 +30,7 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) {
die('Illegal call'); die('Illegal call');
} }
@ -41,8 +41,7 @@ if(!defined('CON_FRAMEWORK')) {
* @version 1.0 * @version 1.0
* @copyright four for business AG 2003 * @copyright four for business AG 2003
*/ */
class Groups class Groups {
{
/** /**
* Storage of the source table to use for the group informations * Storage of the source table to use for the group informations
@ -63,8 +62,7 @@ class Groups
* *
* @param string $table The table to use as information source * @param string $table The table to use as information source
*/ */
function Groups($table = '') function __construct($table = '') {
{
if ($table == '') { if ($table == '') {
global $cfg; global $cfg;
$this->table = $cfg['tab']['groups']; $this->table = $cfg['tab']['groups'];
@ -75,49 +73,43 @@ class Groups
$this->db = new DB_ConLite(); $this->db = new DB_ConLite();
} }
/** /**
* Removes the specified group from the database * Removes the specified group from the database
* *
* @param string $groupid Specifies the group ID * @param string $groupid Specifies the group ID
* @return bool True if the delete was successful * @return bool True if the delete was successful
*/ */
function deleteGroupByID($groupid) function deleteGroupByID($groupid) {
{
$sql = "DELETE FROM " $sql = "DELETE FROM "
.$this->table. . $this->table .
" WHERE group_id = '".Contenido_Security::escapeDB($groupid, $this->db)."'"; " WHERE group_id = '" . Contenido_Security::escapeDB($groupid, $this->db) . "'";
$this->db->query($sql); $this->db->query($sql);
return ($this->db->affected_rows() == 0) ? false : true; return ($this->db->affected_rows() == 0) ? false : true;
} }
/** /**
* Removes the specified group from the database. * Removes the specified group from the database.
* *
* @param string $groupid Specifies the groupname * @param string $groupid Specifies the groupname
* @return bool True if the delete was successful * @return bool True if the delete was successful
*/ */
function deleteGroupByGroupname($groupname) function deleteGroupByGroupname($groupname) {
{
$sql = "DELETE FROM " $sql = "DELETE FROM "
.$this->table. . $this->table .
" WHERE groupname = '".Contenido_Security::escapeDB($groupname, $this->db)."'"; " WHERE groupname = '" . Contenido_Security::escapeDB($groupname, $this->db) . "'";
$this->db->query($sql); $this->db->query($sql);
return ($this->db->affected_rows() == 0) ? false : true; return ($this->db->affected_rows() == 0) ? false : true;
} }
/** /**
* Returns all groups which are accessible by the current group. * Returns all groups which are accessible by the current group.
* *
* @param array $perms * @param array $perms
* @return array Array of group objects * @return array Array of group objects
*/ */
function getAccessibleGroups($perms) function getAccessibleGroups($perms) {
{
global $cfg; global $cfg;
$clientclass = new Client(); $clientclass = new Client();
@ -127,12 +119,12 @@ class Groups
$db = new DB_ConLite(); $db = new DB_ConLite();
foreach ($allClients as $key => $value) { foreach ($allClients as $key => $value) {
if (in_array("client[".$key."]", $perms) || in_array("admin[".$key."]", $perms)) { if (in_array("client[" . $key . "]", $perms) || in_array("admin[" . $key . "]", $perms)) {
$limit[] = 'perms LIKE "%client['.Contenido_Security::escapeDB($key, $db).']%"'; $limit[] = 'perms LIKE "%client[' . Contenido_Security::escapeDB($key, $db) . ']%"';
} }
if (in_array("admin[".$key."]", $perms)) { if (in_array("admin[" . $key . "]", $perms)) {
$limit[] = 'perms LIKE "%admin['.Contenido_Security::escapeDB($key, $db).']%"'; $limit[] = 'perms LIKE "%admin[' . Contenido_Security::escapeDB($key, $db) . ']%"';
} }
} }
@ -147,8 +139,8 @@ class Groups
$sql = "SELECT $sql = "SELECT
group_id, groupname, description group_id, groupname, description
FROM FROM
". $cfg['tab']['groups'] " . $cfg['tab']['groups']
. " WHERE 1 AND " .$limitSQL; . " WHERE 1 AND " . $limitSQL;
$db->query($sql); $db->query($sql);
@ -156,7 +148,7 @@ class Groups
while ($db->next_record()) { while ($db->next_record()) {
$groups[$db->f('group_id')] = array( $groups[$db->f('group_id')] = array(
'groupname' => substr($db->f('groupname'), 4), 'groupname' => substr($db->f('groupname'), 4),
'description' => $db->f('description'), 'description' => $db->f('description'),
); );
} }
@ -173,8 +165,7 @@ class Groups
* @version 1.0 * @version 1.0
* @copyright four for business 2003 * @copyright four for business 2003
*/ */
class Group class Group {
{
/** /**
* Storage of the source table to use for the group informations * 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 * @param string $table The table to use as information source
*/ */
function Group($table = '') function __construct($table = '') {
{
if ($table == '') { if ($table == '') {
global $cfg; global $cfg;
$this->table = $cfg['tab']['groups']; $this->table = $cfg['tab']['groups'];
@ -221,19 +211,17 @@ class Group
$this->db = new DB_ConLite(); $this->db = new DB_ConLite();
} }
/** /**
* Loads a group from the database by its groupname. * Loads a group from the database by its groupname.
* *
* @param string $groupname Specifies the groupname * @param string $groupname Specifies the groupname
* @return bool True if the load was successful * @return bool True if the load was successful
*/ */
function loadGroupByGroupname($groupname) function loadGroupByGroupname($groupname) {
{
// SQL-Statement to select by groupname // SQL-Statement to select by groupname
$sql = "SELECT * FROM ". $sql = "SELECT * FROM " .
$this->table $this->table
." WHERE groupname = '" .Contenido_Security::escapeDB($groupname, $this->db)."'"; . " WHERE groupname = '" . Contenido_Security::escapeDB($groupname, $this->db) . "'";
// Query the database // Query the database
$this->db->query($sql); $this->db->query($sql);
@ -246,19 +234,17 @@ class Group
$this->values = $this->db->toArray(); $this->values = $this->db->toArray();
} }
/** /**
* Loads a group from the database by its groupID. * Loads a group from the database by its groupID.
* *
* @param string $groupid Specifies the groupID * @param string $groupid Specifies the groupID
* @return bool True if the load was successful * @return bool True if the load was successful
*/ */
function loadGroupByGroupID($groupID) function loadGroupByGroupID($groupID) {
{
// SQL-Statement to select by groupID // SQL-Statement to select by groupID
$sql = "SELECT * FROM ". $sql = "SELECT * FROM " .
$this->table $this->table
." WHERE group_id = '" .Contenido_Security::escapeDB($groupID, $this->db)."'"; . " WHERE group_id = '" . Contenido_Security::escapeDB($groupID, $this->db) . "'";
// Query the database // Query the database
$this->db->query($sql); $this->db->query($sql);
@ -271,52 +257,46 @@ class Group
$this->values = $this->db->toArray(); $this->values = $this->db->toArray();
} }
/** /**
* Gets the value of a specific field. * Gets the value of a specific field.
* *
* @param string $field Specifies the field to retrieve * @param string $field Specifies the field to retrieve
* @return mixed Value of the field * @return mixed Value of the field
*/ */
function getField($field) function getField($field) {
{
return ($this->values[$field]); return ($this->values[$field]);
} }
/** /**
* Sets the value of a specific field. * Sets the value of a specific field.
* *
* @param string $field Specifies the field to set * @param string $field Specifies the field to set
* @param string $value Specifies the value to set * @param string $value Specifies the value to set
*/ */
function setField($field, $value) function setField($field, $value) {
{
$this->modifiedValues[$field] = true; $this->modifiedValues[$field] = true;
$this->values[$field] = $value; $this->values[$field] = $value;
} }
/** /**
* Stores the modified group object to the database. * Stores the modified group object to the database.
* *
* @return bool * @return bool
*/ */
function store() function store() {
{ $sql = "UPDATE " . $this->table . " SET ";
$sql = "UPDATE " . $this->table ." SET ";
$first = true; $first = true;
foreach ($this->modifiedValues as $key => $value) { foreach ($this->modifiedValues as $key => $value) {
if ($first == true) { if ($first == true) {
$sql .= "$key = '" . $this->values[$key] ."'"; $sql .= "$key = '" . $this->values[$key] . "'";
} else { } else {
$sql .= ", $key = '" . $this->values[$key] ."'"; $sql .= ", $key = '" . $this->values[$key] . "'";
} }
$first = false; $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); $this->db->query($sql);
@ -328,16 +308,15 @@ class Group
* *
* @return bool * @return bool
*/ */
function insert() function insert() {
{ $sql = "INSERT INTO " . $this->table . " SET ";
$sql = "INSERT INTO " . $this->table ." SET ";
$first = true; $first = true;
foreach ($this->modifiedValues as $key => $value) { foreach ($this->modifiedValues as $key => $value) {
if ($first == true) { if ($first == true) {
$sql .= "$key = '" . $this->values[$key] ."'"; $sql .= "$key = '" . $this->values[$key] . "'";
} else { } else {
$sql .= ", $key = '" . $this->values[$key] ."'"; $sql .= ", $key = '" . $this->values[$key] . "'";
} }
$first = false; $first = false;
} }
@ -345,7 +324,6 @@ class Group
return ($this->db->query($sql)); return ($this->db->query($sql));
} }
/** /**
* Returns the group property * Returns the group property
* *
@ -353,14 +331,13 @@ class Group
* @param string $name Specifies the name of the property to retrieve * @param string $name Specifies the name of the property to retrieve
* @return string The value of the retrieved property * @return string The value of the retrieved property
*/ */
function getGroupProperty($type, $name) function getGroupProperty($type, $name) {
{
global $cfg; global $cfg;
$sql = "SELECT value FROM " .$cfg['tab']['group_prop']." $sql = "SELECT value FROM " . $cfg['tab']['group_prop'] . "
WHERE group_id = '".Contenido_Security::escapeDB($this->values['group_id'], $this->db)."' WHERE group_id = '" . Contenido_Security::escapeDB($this->values['group_id'], $this->db) . "'
AND type = '".Contenido_Security::escapeDB($type, $this->db)."' AND type = '" . Contenido_Security::escapeDB($type, $this->db) . "'
AND name = '".Contenido_Security::escapeDB($name, $this->db)."'"; AND name = '" . Contenido_Security::escapeDB($name, $this->db) . "'";
$this->db->query($sql); $this->db->query($sql);
if ($this->db->next_record()) { if ($this->db->next_record()) {
@ -370,7 +347,6 @@ class Group
} }
} }
/** /**
* Retrieves all available properties of the group. * Retrieves all available properties of the group.
* *
@ -379,14 +355,13 @@ class Group
* - $arr[idgroupprop][type] * - $arr[idgroupprop][type]
* - $arr[idgroupprop][value] * - $arr[idgroupprop][value]
*/ */
function getGroupProperties() function getGroupProperties() {
{
global $cfg; global $cfg;
$aProps = array(); $aProps = array();
$sql = "SELECT idgroupprop, type, name, value FROM " .$cfg['tab']['group_prop']." $sql = "SELECT idgroupprop, type, name, value FROM " . $cfg['tab']['group_prop'] . "
WHERE group_id = '".Contenido_Security::escapeDB($this->values['group_id'], $this->db)."'"; WHERE group_id = '" . Contenido_Security::escapeDB($this->values['group_id'], $this->db) . "'";
$this->db->query($sql); $this->db->query($sql);
if ($this->db->num_rows() == 0) { if ($this->db->num_rows() == 0) {
@ -395,8 +370,8 @@ class Group
while ($this->db->next_record()) { while ($this->db->next_record()) {
$aProps[$this->db->f('idgroupprop')] = array( $aProps[$this->db->f('idgroupprop')] = array(
'name' => $this->db->f('name'), 'name' => $this->db->f('name'),
'type' => $this->db->f('type'), 'type' => $this->db->f('type'),
'value' => $this->db->f('value'), 'value' => $this->db->f('value'),
); );
} }
@ -404,7 +379,6 @@ class Group
return $aProps; return $aProps;
} }
/** /**
* Stores a property to the database. * 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 $name Specifies the name of the property to retrieve
* @param string $value Specifies the value to insert * @param string $value Specifies the value to insert
*/ */
function setGroupProperty($type, $name, $value) function setGroupProperty($type, $name, $value) {
{
global $cfg; global $cfg;
// Check if such an entry already exists // Check if such an entry already exists
if ($this->getGroupProperty($type, $name) !== false) { if ($this->getGroupProperty($type, $name) !== false) {
$sql = "UPDATE ".$cfg['tab']['group_prop']." $sql = "UPDATE " . $cfg['tab']['group_prop'] . "
SET value = '".Contenido_Security::escapeDB($value, $this->db)."' SET value = '" . Contenido_Security::escapeDB($value, $this->db) . "'
WHERE group_id = '".Contenido_Security::escapeDB($this->values['group_id'], $this->db)."' WHERE group_id = '" . Contenido_Security::escapeDB($this->values['group_id'], $this->db) . "'
AND type = '".Contenido_Security::escapeDB($type, $this->db)."' AND type = '" . Contenido_Security::escapeDB($type, $this->db) . "'
AND name = '".Contenido_Security::escapeDB($name, $this->db)."'"; AND name = '" . Contenido_Security::escapeDB($name, $this->db) . "'";
$this->db->query($sql); $this->db->query($sql);
} else { } else {
$sql = "INSERT INTO ".$cfg['tab']['group_prop']." $sql = "INSERT INTO " . $cfg['tab']['group_prop'] . "
SET value = '".Contenido_Security::escapeDB($value, $this->db)."', SET value = '" . Contenido_Security::escapeDB($value, $this->db) . "',
group_id = '".Contenido_Security::escapeDB($this->values['group_id'], $this->db)."', group_id = '" . Contenido_Security::escapeDB($this->values['group_id'], $this->db) . "',
type = '".Contenido_Security::escapeDB($type, $this->db)."', type = '" . Contenido_Security::escapeDB($type, $this->db) . "',
name = '".Contenido_Security::escapeDB($name, $this->db)."', name = '" . Contenido_Security::escapeDB($name, $this->db) . "',
idgroupprop = '".Contenido_Security::toInteger($this->db->nextid($cfg['tab']['group_prop']))."'"; idgroupprop = '" . Contenido_Security::toInteger($this->db->nextid($cfg['tab']['group_prop'])) . "'";
$this->db->query($sql); $this->db->query($sql);
} }
} }
/** /**
* Deletes a group property from the table. * Deletes a group property from the table.
* *
* @param string $type Specifies the type (class, category etc) for the property to retrieve * @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 $name Specifies the name of the property to retrieve
*/ */
function deleteGroupProperty($type, $name) function deleteGroupProperty($type, $name) {
{
global $cfg; global $cfg;
// Check if such an entry already exists // Check if such an entry already exists
$sql = "DELETE FROM ".$cfg['tab']['group_prop']." $sql = "DELETE FROM " . $cfg['tab']['group_prop'] . "
WHERE group_id = '".Contenido_Security::escapeDB($this->values['group_id'], $this->db)."' AND WHERE group_id = '" . Contenido_Security::escapeDB($this->values['group_id'], $this->db) . "' AND
type = '".Contenido_Security::escapeDB($type, $this->db)."' AND type = '" . Contenido_Security::escapeDB($type, $this->db) . "' AND
name = '".Contenido_Security::escapeDB($name, $this->db)."'"; name = '" . Contenido_Security::escapeDB($name, $this->db) . "'";
$this->db->query($sql); $this->db->query($sql);
} }
} }
?>

Datei anzeigen

@ -93,7 +93,7 @@ class HtmlParser {
* Constructs an HtmlParser instance with * Constructs an HtmlParser instance with
* the HTML text given. * the HTML text given.
*/ */
function HtmlParser ($aHtmlText) { function __construct ($aHtmlText) {
$this->iHtmlText = $aHtmlText; $this->iHtmlText = $aHtmlText;
$this->iHtmlTextLength = strlen($aHtmlText); $this->iHtmlTextLength = strlen($aHtmlText);
} }

Datei anzeigen

@ -34,7 +34,7 @@ class cHTMLValidator
var $nestingNodes; var $nestingNodes;
var $_existingTags; var $_existingTags;
function cHTMLValidator() function __construct()
{ {
$this->doubleTags = array ("form", "head", "body", "html", "td", "tr", "table", "a", "tbody", "title", "container", "span", "div"); $this->doubleTags = array ("form", "head", "body", "html", "td", "tr", "table", "a", "tbody", "title", "container", "span", "div");

Datei anzeigen

@ -128,7 +128,7 @@ class HttpInputValidator {
* @param string $sConfigPath * @param string $sConfigPath
* @return HttpInputValidator * @return HttpInputValidator
*/ */
function HttpInputValidator($sConfigPath) { function __construct($sConfigPath) {
// check config and logging path // check config and logging path
if (!empty($sConfigPath) && file_exists($sConfigPath)) { if (!empty($sConfigPath) && file_exists($sConfigPath)) {
$this->sConfigPath = realpath($sConfigPath); $this->sConfigPath = realpath($sConfigPath);

Datei anzeigen

@ -66,7 +66,7 @@ class cIterator
* @param $aItems array Items to add * @param $aItems array Items to add
* @return none * @return none
*/ */
function cIterator ($aItems) function __construct ($aItems)
{ {
if (is_array($aItems)) if (is_array($aItems))
{ {

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -29,7 +30,6 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) { if (!defined('CON_FRAMEWORK')) {
die('Illegal call'); die('Illegal call');
} }
@ -43,21 +43,15 @@ if (!defined('CON_FRAMEWORK')) {
* @copyright four for business 2003 * @copyright four for business 2003
*/ */
class Languages extends cApiLanguageCollection { class Languages extends cApiLanguageCollection {
/** /**
* Constructor * Constructor
* @param none * @param none
*/ */
public function __construct() public function __construct() {
{
parent::__construct(); parent::__construct();
} }
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
public function Languages()
{
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
$this->__construct();
}
} }
/** /**
@ -69,24 +63,17 @@ class Languages extends cApiLanguageCollection {
* @copyright four for business 2003 * @copyright four for business 2003
*/ */
class Language extends cApiLanguage { class Language extends cApiLanguage {
/** /**
* Constructor Function * Constructor Function
* @param mixed $mId Specifies the ID of item to load * @param mixed $mId Specifies the ID of item to load
*/ */
public function __construct($mId = false) public function __construct($mId = false) {
{ if ($mId === false) {
if($mId === false) {
parent::__construct(); parent::__construct();
} else { } else {
parent::__construct($mId); 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);
}
} }
?>

Datei anzeigen

@ -70,7 +70,7 @@ class cMetaObject
var $_payloadObject; var $_payloadObject;
function cMetaObject ($payload = false) function __construct ($payload = false)
{ {
$this->_actions = array(); $this->_actions = array();
$this->_fields = array(); $this->_fields = array();

Datei anzeigen

@ -64,7 +64,7 @@ class Contenido_Navigation {
/** /**
* Constructor. Loads the XML language file using XML_Doc. * Constructor. Loads the XML language file using XML_Doc.
*/ */
function Contenido_Navigation() { function __construct() {
global $cfg, $belang; global $cfg, $belang;
$this->xml = new XML_Doc(); $this->xml = new XML_Doc();

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -28,27 +29,17 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) { if (!defined('CON_FRAMEWORK')) {
die('Illegal call'); die('Illegal call');
} }
class NoteCollection extends CommunicationCollection {
class NoteCollection extends CommunicationCollection public function __construct() {
{
public function __construct()
{
parent::__construct(); parent::__construct();
$this->_setItemClass("NoteItem"); $this->_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 * select: Selects one or more items from the database
* *
@ -58,8 +49,7 @@ class NoteCollection extends CommunicationCollection
* @access public * @access public
* @see ItemCollection * @see ItemCollection
*/ */
public function select($where = "", $group_by = "", $order_by = "", $limit = "") public function select($where = "", $group_by = "", $order_by = "", $limit = "") {
{
if ($where == "") { if ($where == "") {
$where = "comtype='note'"; $where = "comtype='note'";
} else { } else {
@ -80,8 +70,7 @@ class NoteCollection extends CommunicationCollection
* @return object The new item * @return object The new item
* @access public * @access public
*/ */
public function create($itemtype, $itemid, $idlang, $message, $category = "") public function create($itemtype, $itemid, $idlang, $message, $category = "") {
{
$item = parent::createNewItem(); $item = parent::createNewItem();
$item->set("subject", "Note Item"); $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 __construct($sItemType, $sItemId) {
{
public function NoteView($sItemType, $sItemId)
{
global $sess, $cfg; global $sess, $cfg;
cHTMLIFrame::cHTMLIFrame(); parent::__construct();
$this->setSrc($sess->url("main.php?itemtype=$sItemType&itemid=$sItemId&area=note&frame=2")); $this->setSrc($sess->url("main.php?itemtype=$sItemType&itemid=$sItemId&area=note&frame=2"));
$this->setBorder(0); $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 __construct($sItemType, $sItemId) {
{ parent::__construct();
public function NoteList($sItemType, $sItemId)
{
cHTMLDiv::cHTMLDiv();
$this->_sItemType = $sItemType; $this->_sItemType = $sItemType;
$this->_sItemId = $sItemId; $this->_sItemId = $sItemId;
@ -133,13 +118,11 @@ class NoteList extends cHTMLDiv
$this->setStyleDefinition("width", "100%"); $this->setStyleDefinition("width", "100%");
} }
public function setDeleteable($bDeleteable) public function setDeleteable($bDeleteable) {
{
$this->_bDeleteable = $bDeleteable; $this->_bDeleteable = $bDeleteable;
} }
public function toHTML() public function toHTML() {
{
global $cfg, $lang; global $cfg, $lang;
$sItemType = $this->_sItemType; $sItemType = $this->_sItemType;
@ -162,10 +145,10 @@ class NoteList extends cHTMLDiv
$items[] = 0; $items[] = 0;
} }
$oNoteItems->select("idcommunication IN (".implode(", ", $items).')',"", "created DESC"); $oNoteItems->select("idcommunication IN (" . implode(", ", $items) . ')', "", "created DESC");
$i = array(); $i = array();
$dark = false; $dark = false;
while ($oNoteItem = $oNoteItems->next()) { while ($oNoteItem = $oNoteItems->next()) {
if ($oNoteItem->getProperty("note", "itemtype") == $sItemType && $oNoteItem->getProperty("note", "itemid") == $sItemId) { if ($oNoteItem->getProperty("note", "itemtype") == $sItemType && $oNoteItem->getProperty("note", "itemid") == $sItemId) {
$j = new NoteListItem($sItemType, $sItemId, $oNoteItem->get("idcommunication")); $j = new NoteListItem($sItemType, $sItemId, $oNoteItem->get("idcommunication"));
@ -185,16 +168,15 @@ class NoteList extends cHTMLDiv
$result = parent::toHTML(); $result = parent::toHTML();
return ('<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td>'.$result.'</td></tr></table>'); return ('<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td>' . $result . '</td></tr></table>');
} }
} }
class NoteListItem extends cHTMLDiv {
class NoteListItem extends cHTMLDiv public function __construct($sItemType, $sItemId, $iDeleteItem) {
{ parent::__construct();
public function NoteListItem($sItemType, $sItemId, $iDeleteItem)
{
cHTMLDiv::cHTMLDiv();
$this->setStyleDefinition("padding", "2px"); $this->setStyleDefinition("padding", "2px");
$this->setBackground(); $this->setBackground();
$this->setDeleteable(true); $this->setDeleteable(true);
@ -202,16 +184,13 @@ class NoteListItem extends cHTMLDiv
$this->_iDeleteItem = $iDeleteItem; $this->_iDeleteItem = $iDeleteItem;
$this->_sItemType = $sItemType; $this->_sItemType = $sItemType;
$this->_sItemId = $sItemId; $this->_sItemId = $sItemId;
} }
public function setDeleteable($bDeleteable) public function setDeleteable($bDeleteable) {
{
$this->_bDeleteable = $bDeleteable; $this->_bDeleteable = $bDeleteable;
} }
public function setBackground($dark = false) public function setBackground($dark = false) {
{
global $cfg; global $cfg;
if ($dark) { if ($dark) {
@ -221,8 +200,7 @@ class NoteListItem extends cHTMLDiv
} }
} }
public function setAuthor($sAuthor) public function setAuthor($sAuthor) {
{
if (strlen($sAuthor) == 32) { if (strlen($sAuthor) == 32) {
$result = getGroupOrUserName($sAuthor); $result = getGroupOrUserName($sAuthor);
@ -234,8 +212,7 @@ class NoteListItem extends cHTMLDiv
$this->_sAuthor = $sAuthor; $this->_sAuthor = $sAuthor;
} }
public function setDate($iDate) public function setDate($iDate) {
{
$dateformat = getEffectiveSetting("backend", "timeformat", "Y-m-d H:i:s"); $dateformat = getEffectiveSetting("backend", "timeformat", "Y-m-d H:i:s");
if (is_string($iDate)) { if (is_string($iDate)) {
@ -244,31 +221,29 @@ class NoteListItem extends cHTMLDiv
$this->_sDate = date($dateformat, $iDate); $this->_sDate = date($dateformat, $iDate);
} }
public function setMessage($sMessage) public function setMessage($sMessage) {
{
$this->_sMessage = $sMessage; $this->_sMessage = $sMessage;
} }
public function render() public function render() {
{
global $cfg, $sess; global $cfg, $sess;
$itemtype = $this->_sItemType; $itemtype = $this->_sItemType;
$itemid = $this->_sItemId; $itemid = $this->_sItemId;
$deleteitem = $this->_iDeleteItem; $deleteitem = $this->_iDeleteItem;
$table = '<table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td><b>'; $table = '<table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td><b>';
$table .= $this->_sAuthor; $table .= $this->_sAuthor;
$table .= '</b></td><td align="right">'; $table .= '</b></td><td align="right">';
$table .= $this->_sDate; $table .= $this->_sDate;
if ($this->_bDeleteable == true) { if ($this->_bDeleteable == true) {
$oDeleteable = new cHTMLLink(); $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->setContent($oDeletePic);
$oDeleteable->setLink($sess->url("main.php?frame=2&area=note&itemtype=$itemtype&itemid=$itemid&action=note_delete&deleteitem=$deleteitem")); $oDeleteable->setLink($sess->url("main.php?frame=2&area=note&itemtype=$itemtype&itemid=$itemid&action=note_delete&deleteitem=$deleteitem"));
$table .= '</td><td style="padding-left: 4px;" width="1">'.$oDeleteable->render(); $table .= '</td><td style="padding-left: 4px;" width="1">' . $oDeleteable->render();
} }
$table .= '</td></tr></table>'; $table .= '</td></tr></table>';
@ -276,15 +251,15 @@ class NoteListItem extends cHTMLDiv
$oMessage->setContent($this->_sMessage); $oMessage->setContent($this->_sMessage);
$oMessage->setStyle("padding-bottom: 8px;"); $oMessage->setStyle("padding-bottom: 8px;");
$this->setContent(array($table, '<hr style="margin-top: 2px; margin-bottom: 2px; border: 0px; border-top: 1px solid' . $cfg['color']['table_border'].';">',$oMessage)); $this->setContent(array($table, '<hr style="margin-top: 2px; margin-bottom: 2px; border: 0px; border-top: 1px solid' . $cfg['color']['table_border'] . ';">', $oMessage));
return parent::render(); return parent::render();
} }
} }
class NoteLink extends cHTMLLink class NoteLink extends cHTMLLink {
{
/** /**
* @var string Object type * @var string Object type
* @access private * @access private
@ -321,9 +296,8 @@ class NoteLink extends cHTMLLink
* @return none * @return none
* @access public * @access public
*/ */
public function NoteLink($sItemType, $sItemID) public function __construct($sItemType, $sItemID) {
{ parent::__construct();
parent::cHTMLLink();
$img = new cHTMLImage("images/note.gif"); $img = new cHTMLImage("images/note.gif");
$img->setStyle("padding-left: 2px; padding-right: 2px;"); $img->setStyle("padding-left: 2px; padding-right: 2px;");
@ -345,8 +319,7 @@ class NoteLink extends cHTMLLink
* @return none * @return none
* @access public * @access public
*/ */
public function enableHistory() public function enableHistory() {
{
$this->_bShowHistory = true; $this->_bShowHistory = true;
} }
@ -356,8 +329,7 @@ class NoteLink extends cHTMLLink
* @return none * @return none
* @access public * @access public
*/ */
public function disableHistory() public function disableHistory() {
{
$this->_bShowHistory = false; $this->_bShowHistory = false;
} }
@ -367,8 +339,7 @@ class NoteLink extends cHTMLLink
* @return none * @return none
* @access public * @access public
*/ */
public function enableHistoryDelete() public function enableHistoryDelete() {
{
$this->_bDeleteHistoryItems = true; $this->_bDeleteHistoryItems = true;
} }
@ -378,8 +349,7 @@ class NoteLink extends cHTMLLink
* @return none * @return none
* @access public * @access public
*/ */
public function disableHistoryDelete() public function disableHistoryDelete() {
{
$this->_bDeleteHistoryItems = false; $this->_bDeleteHistoryItems = false;
} }
@ -389,16 +359,14 @@ class NoteLink extends cHTMLLink
* @return none * @return none
* @access public * @access public
*/ */
public function render($return = false) public function render($return = false) {
{
global $sess; global $sess;
$itemtype = $this->_sItemType; $itemtype = $this->_sItemType;
$itemid = $this->_sItemID; $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); return parent::render($return);
} }
}
?> }

Datei anzeigen

@ -96,13 +96,6 @@ class PropertyCollection extends ItemCollection
$this->_setItemClass('PropertyItem'); $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. * 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 * Stores changed PropertyItem
*/ */

Datei anzeigen

@ -152,7 +152,7 @@ class RequestPassword {
* @param array $aCfg - The contenido configuration array * @param array $aCfg - The contenido configuration array
* @access public * @access public
*/ */
function RequestPassword ($oDb, $aCfg) { function __construct ($oDb, $aCfg) {
//generate new dbobject, if it does not exist //generate new dbobject, if it does not exist
if (!is_object($oDb)) { if (!is_object($oDb)) {
$this->oDb = new DB_ConLite(); $this->oDb = new DB_ConLite();

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -32,20 +33,18 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) {
die('Illegal call'); die('Illegal call');
} }
/** /**
* Abstract base search class. Provides general properties and functions * Abstract base search class. Provides general properties and functions
* for child implementations. * for child implementations.
* *
* @author Murat Purc <murat@purc.de> * @author Murat Purc <murat@purc.de>
*/ */
abstract class SearchBaseAbstract abstract class SearchBaseAbstract {
{
/** /**
* Contenido database object * Contenido database object
* @var DB_ConLite * @var DB_ConLite
@ -82,12 +81,11 @@ abstract class SearchBaseAbstract
* @param DB_ConLite $oDB Optional database instance * @param DB_ConLite $oDB Optional database instance
* @param bool $bDebug Optional, flag to enable debugging * @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; global $cfg, $lang, $client;
$this->cfg = $cfg; $this->cfg = $cfg;
$this->lang = $lang; $this->lang = $lang;
$this->client = $client; $this->client = $client;
$this->setDebug((bool) $bDebug); $this->setDebug((bool) $bDebug);
@ -104,8 +102,7 @@ abstract class SearchBaseAbstract
* *
* @param bool $bDebug * @param bool $bDebug
*/ */
public function setDebug($bDebug) public function setDebug($bDebug) {
{
$this->bDebug = (bool) $bDebug; $this->bDebug = (bool) $bDebug;
} }
@ -115,8 +112,7 @@ abstract class SearchBaseAbstract
* @param string $msg Some text * @param string $msg Some text
* @param mixed $var The variable to dump * @param mixed $var The variable to dump
*/ */
protected function _debug($msg, $var) protected function _debug($msg, $var) {
{
if (!$this->bDebug) { if (!$this->bDebug) {
return; return;
} }
@ -129,8 +125,8 @@ abstract class SearchBaseAbstract
$dump .= '</pre>' . "\n"; $dump .= '</pre>' . "\n";
echo $dump; echo $dump;
} }
}
}
/** /**
* Contenido API - Index Object * 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. * Keep in mind that class Search and SearchResult uses an instance of object Index.
* Consider character tables in relation 'con_chartable'. * Consider character tables in relation 'con_chartable'.
*/ */
cInclude('includes', 'functions.encoding.php'); cInclude('includes', 'functions.encoding.php');
class Index extends SearchBaseAbstract class Index extends SearchBaseAbstract {
{
/** /**
* the content of the cms-types of an article * the content of the cms-types of an article
* @var array * @var array
@ -243,8 +238,7 @@ class Index extends SearchBaseAbstract
* @param DB_ConLite $oDB Contenido Database object * @param DB_ConLite $oDB Contenido Database object
* @return void * @return void
*/ */
function Index($oDB = null) function __construct($oDB = null) {
{
parent::__construct($oDB); parent::__construct($oDB);
$this->setContentTypes(); $this->setContentTypes();
@ -269,9 +263,8 @@ class Index extends SearchBaseAbstract
* @param array $aStopwords Array with words which should not be indexed. * @param array $aStopwords Array with words which should not be indexed.
* @return void * @return void
*/ */
function start($idart, $aContent, $place = 'auto', $cms_options = array(), $aStopwords = array()) function start($idart, $aContent, $place = 'auto', $cms_options = array(), $aStopwords = array()) {
{ if (!is_int((int) $idart) || $idart < 0) {
if (!is_int((int)$idart) || $idart < 0) {
return null; return null;
} else { } else {
$this->idart = $idart; $this->idart = $idart;
@ -310,16 +303,15 @@ class Index extends SearchBaseAbstract
* @param none * @param none
* @return void * @return void
*/ */
function createKeywords() function createKeywords() {
{
$tmp_keys = array(); $tmp_keys = array();
$replace = array('&nbsp;', '&amp;', '&lt;', '&gt;', '&quot;', '&#039;'); $replace = array('&nbsp;', '&amp;', '&lt;', '&gt;', '&quot;', '&#039;');
// Only create keycodes, if some are available // Only create keycodes, if some are available
if (is_array($this->keycode)) { if (is_array($this->keycode)) {
foreach($this->keycode as $idtype => $data) { foreach ($this->keycode as $idtype => $data) {
if ($this->checkCmsType($idtype)) { if ($this->checkCmsType($idtype)) {
foreach($data as $typeid => $code) { foreach ($data as $typeid => $code) {
$this->_debug('code', $code); $this->_debug('code', $code);
$code = stripslashes($code); // remove backslash $code = stripslashes($code); // remove backslash
@ -342,7 +334,7 @@ class Index extends SearchBaseAbstract
if (strlen($value) > 1) { if (strlen($value) > 1) {
// do not index single characters // 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)" * The index_string looks like "&12=2(CMS_HTMLHEAD-1,CMS_HTML-1)"
* @return void * @return void
*/ */
function saveKeywords() function saveKeywords() {
{
$tmp_count = array(); $tmp_count = array();
foreach ($this->keywords as $keyword => $count) { foreach ($this->keywords as $keyword => $count) {
@ -379,10 +370,10 @@ class Index extends SearchBaseAbstract
$nextid = $this->db->nextid($this->cfg['tab']['keywords']); $nextid = $this->db->nextid($this->cfg['tab']['keywords']);
$sql = "INSERT INTO ".$this->cfg['tab']['keywords']." $sql = "INSERT INTO " . $this->cfg['tab']['keywords'] . "
(keyword, ".$this->place.", idlang, idkeyword) (keyword, " . $this->place . ", idlang, idkeyword)
VALUES 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 { } else {
// if keyword allready exists, create new index_string // if keyword allready exists, create new index_string
if (preg_match("/&$this->idart=/", $this->keywords_old[$keyword])) { 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; $index_string = $this->keywords_old[$keyword] . $index_string;
} }
$sql = "UPDATE ".$this->cfg['tab']['keywords']." $sql = "UPDATE " . $this->cfg['tab']['keywords'] . "
SET ".$this->place." = '".$index_string."' SET " . $this->place . " = '" . $index_string . "'
WHERE idlang='".Contenido_Security::toInteger($this->lang)."' AND keyword='".Contenido_Security::escapeDB($keyword, $this->db)."'"; WHERE idlang='" . Contenido_Security::toInteger($this->lang) . "' AND keyword='" . Contenido_Security::escapeDB($keyword, $this->db) . "'";
} }
$this->_debug('sql', $sql); $this->_debug('sql', $sql);
@ -406,19 +397,18 @@ class Index extends SearchBaseAbstract
* @param none * @param none
* @return void * @return void
*/ */
function deleteKeywords() function deleteKeywords() {
{
foreach ($this->keywords_del as $key_del) { foreach ($this->keywords_del as $key_del) {
$index_string = preg_replace("/&$this->idart=[0-9]+\([\w-,]+\)/", "", $this->keywords_old[$key_del]); $index_string = preg_replace("/&$this->idart=[0-9]+\([\w-,]+\)/", "", $this->keywords_old[$key_del]);
if (strlen($index_string) == 0) { if (strlen($index_string) == 0) {
// keyword is not referenced by any article // keyword is not referenced by any article
$sql = "DELETE FROM ".$this->cfg['tab']['keywords']." $sql = "DELETE FROM " . $this->cfg['tab']['keywords'] . "
WHERE idlang='".Contenido_Security::toInteger($this->lang)."' AND keyword='".Contenido_Security::escapeDB($key_del, $this->db)."'"; WHERE idlang='" . Contenido_Security::toInteger($this->lang) . "' AND keyword='" . Contenido_Security::escapeDB($key_del, $this->db) . "'";
} else { } else {
$sql = "UPDATE ".$this->cfg['tab']['keywords']." $sql = "UPDATE " . $this->cfg['tab']['keywords'] . "
SET ".$this->place." = '".$index_string."' SET " . $this->place . " = '" . $index_string . "'
WHERE idlang='".Contenido_Security::toInteger($this->lang)."' AND keyword='".Contenido_Security::escapeDB($key_del, $this->db)."'"; WHERE idlang='" . Contenido_Security::toInteger($this->lang) . "' AND keyword='" . Contenido_Security::escapeDB($key_del, $this->db) . "'";
} }
$this->_debug('sql', $sql); $this->_debug('sql', $sql);
$this->db->query($sql); $this->db->query($sql);
@ -430,17 +420,16 @@ class Index extends SearchBaseAbstract
* @param none * @param none
* @return void * @return void
*/ */
function getKeywords() function getKeywords() {
{
$keys = implode("','", array_keys($this->keywords)); $keys = implode("','", array_keys($this->keywords));
$sql = "SELECT $sql = "SELECT
keyword, auto, self keyword, auto, self
FROM FROM
".$this->cfg['tab']['keywords']." " . $this->cfg['tab']['keywords'] . "
WHERE WHERE
idlang=".Contenido_Security::toInteger($this->lang)." AND idlang=" . Contenido_Security::toInteger($this->lang) . " AND
(keyword IN ('".$keys."') OR ".$this->place." REGEXP '&".Contenido_Security::toInteger($this->idart)."=')"; (keyword IN ('" . $keys . "') OR " . $this->place . " REGEXP '&" . Contenido_Security::toInteger($this->idart) . "=')";
$this->_debug('sql', $sql); $this->_debug('sql', $sql);
@ -458,10 +447,9 @@ class Index extends SearchBaseAbstract
* @param $key Keyword * @param $key Keyword
* @return $key * @return $key
*/ */
function removeSpecialChars($key) function removeSpecialChars($key) {
{
$aSpecialChars = array( $aSpecialChars = array(
"-", "_", "'", ".", "!", "\"", "#", "$", "%", "&", "(", ")", "*", "+", ",", "/", "-", "_", "'", ".", "!", "\"", "#", "$", "%", "&", "(", ")", "*", "+", ",", "/",
":", ";", "<", "=", ">", "?", "@", "[", "\\", "]", "^", "`", "{", "|", "}", "~" ":", ";", "<", "=", ">", "?", "@", "[", "\\", "]", "^", "`", "{", "|", "}", "~"
); );
@ -481,14 +469,14 @@ class Index extends SearchBaseAbstract
$key = htmlentities_iso88592($key); $key = htmlentities_iso88592($key);
} }
$aUmlautMap = array ( $aUmlautMap = array(
'&Uuml;' => 'ue', '&Uuml;' => 'ue',
'&uuml;' => 'ue', '&uuml;' => 'ue',
'&Auml;' => 'ae', '&Auml;' => 'ae',
'&auml;' => 'ae', '&auml;' => 'ae',
'&Ouml;' => 'oe', '&Ouml;' => 'oe',
'&ouml;' => 'oe', '&ouml;' => 'oe',
'&szlig;' => 'ss' '&szlig;' => 'ss'
); );
foreach ($aUmlautMap as $sUmlaut => $sMapped) { foreach ($aUmlautMap as $sUmlaut => $sMapped) {
@ -508,17 +496,16 @@ class Index extends SearchBaseAbstract
* @param $key Keyword * @param $key Keyword
* @return $key * @return $key
*/ */
function addSpecialUmlauts($key) function addSpecialUmlauts($key) {
{
$key = clHtmlEntities($key, null, getEncodingByLanguage($this->db, $this->lang, $this->cfg)); $key = clHtmlEntities($key, null, getEncodingByLanguage($this->db, $this->lang, $this->cfg));
$aUmlautMap = array ( $aUmlautMap = array(
'ue' => '&Uuml;', 'ue' => '&Uuml;',
'ue' => '&uuml;', 'ue' => '&uuml;',
'ae' => '&Auml;', 'ae' => '&Auml;',
'ae' => '&auml;', 'ae' => '&auml;',
'oe' => '&Ouml;', 'oe' => '&Ouml;',
'oe' => '&ouml;', 'oe' => '&ouml;',
'ss' => '&szlig;' 'ss' => '&szlig;'
); );
foreach ($aUmlautMap as $sUmlaut => $sMapped) { foreach ($aUmlautMap as $sUmlaut => $sMapped) {
@ -534,8 +521,7 @@ class Index extends SearchBaseAbstract
* @param array $aStopwords * @param array $aStopwords
* @return void * @return void
*/ */
function setStopwords ($aStopwords) function setStopwords($aStopwords) {
{
if (is_array($aStopwords) && count($aStopwords) > 0) { if (is_array($aStopwords) && count($aStopwords) > 0) {
$this->stopwords = $aStopwords; $this->stopwords = $aStopwords;
} }
@ -546,9 +532,8 @@ class Index extends SearchBaseAbstract
* @param none * @param none
* @return void * @return void
*/ */
function setContentTypes() function setContentTypes() {
{ $sql = "SELECT type, idtype FROM " . $this->cfg['tab']['type'] . ' ';
$sql = "SELECT type, idtype FROM ".$this->cfg['tab']['type'] . ' ';
$this->_debug('sql', $sql); $this->_debug('sql', $sql);
$this->db->query($sql); $this->db->query($sql);
while ($this->db->next_record()) { while ($this->db->next_record()) {
@ -562,10 +547,9 @@ class Index extends SearchBaseAbstract
* @param none * @param none
* @return void * @return void
*/ */
function setCmsOptions($cms_options) function setCmsOptions($cms_options) {
{
if (is_array($cms_options) && count($cms_options) > 0) { if (is_array($cms_options) && count($cms_options) > 0) {
foreach($cms_options as $opt) { foreach ($cms_options as $opt) {
$opt = strtoupper($opt); $opt = strtoupper($opt);
if (strlen($opt) > 0) { if (strlen($opt) > 0) {
@ -591,15 +575,13 @@ class Index extends SearchBaseAbstract
* *
* @return bolean * @return bolean
*/ */
function checkCmsType($idtype) function checkCmsType($idtype) {
{
$idtype = strtoupper($idtype); $idtype = strtoupper($idtype);
return (in_array($idtype, $this->cms_options)) ? false : true; return (in_array($idtype, $this->cms_options)) ? false : true;
} }
} }
/** /**
* Contenido API - Search Object * Contenido API - Search Object
* *
@ -703,9 +685,7 @@ class Index extends SearchBaseAbstract
* @author Willi Man * @author Willi Man
* @copyright four for business AG <www.4fb.de> * @copyright four for business AG <www.4fb.de>
*/ */
class Search extends SearchBaseAbstract {
class Search extends SearchBaseAbstract
{
/** /**
* Instance of class Index * Instance of class Index
@ -803,8 +783,7 @@ class Search extends SearchBaseAbstract
* @param DB_ConLite $oDB Optional database instance * @param DB_ConLite $oDB Optional database instance
* @return void * @return void
*/ */
function Search($options, $oDB = null) function __construct($options, $oDB = null) {
{
parent::__construct($oDB); parent::__construct($oDB);
$this->index = new Index($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 * @param string $searchwords_exclude The words, which should be excluded from search
* @return void * @return void
*/ */
function searchIndex($searchwords, $searchwords_exclude = '') function searchIndex($searchwords, $searchwords_exclude = '') {
{
if (strlen(trim($searchwords)) > 0) { if (strlen(trim($searchwords)) > 0) {
$this->search_words = $this->stripWords($searchwords); $this->search_words = $this->stripWords($searchwords);
} else { } else {
@ -858,7 +836,7 @@ class Search extends SearchBaseAbstract
} }
if (count($this->search_words_exclude) > 0) { 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') { if ($this->search_option == 'like') {
$word = "'%" . $word . "%'"; $word = "'%" . $word . "%'";
} elseif ($this->search_option == 'exact') { } elseif ($this->search_option == 'exact') {
@ -868,8 +846,9 @@ class Search extends SearchBaseAbstract
array_push($this->search_words, $word); 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') { if ($this->search_option == 'regexp') {
// regexp search // regexp search
@ -884,8 +863,8 @@ class Search extends SearchBaseAbstract
$kwSql = "keyword LIKE '" . $search_exact; $kwSql = "keyword LIKE '" . $search_exact;
} }
$sql = "SELECT keyword, auto FROM " . $this->cfg['tab']['keywords'] $sql = "SELECT keyword, auto FROM " . $this->cfg['tab']['keywords']
. " WHERE idlang=" . Contenido_Security::toInteger($this->lang) . " AND " . $kwSql . " "; . " WHERE idlang=" . Contenido_Security::toInteger($this->lang) . " AND " . $kwSql . " ";
$this->_debug('sql', $sql); $this->_debug('sql', $sql);
$this->db->query($sql); $this->db->query($sql);
@ -897,7 +876,7 @@ class Search extends SearchBaseAbstract
$tmp_index = array(); $tmp_index = array();
foreach ($tmp_index_string as $string) { 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); $tmp_index[] = preg_split('/\s/', $tmp_string, -1, PREG_SPLIT_NO_EMPTY);
} }
$this->_debug('tmp_index', $tmp_index); $this->_debug('tmp_index', $tmp_index);
@ -908,9 +887,9 @@ class Search extends SearchBaseAbstract
// filter nonsearchable articles // filter nonsearchable articles
if (in_array($artid, $this->searchable_arts)) { if (in_array($artid, $this->searchable_arts)) {
$cms_place = $string[2]; $cms_place = $string[2];
$keyword = $this->db->f('keyword'); $keyword = $this->db->f('keyword');
$percent = 0; $percent = 0;
$similarity = 0; $similarity = 0;
foreach ($this->search_words as $word) { foreach ($this->search_words as $word) {
similar_text($word, $keyword, $percent); // computes similarity between searchword and keyword in percent 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 * @param $cms_options The cms-types (htmlhead, html, ...) which should explicitly be searched
* @return void * @return void
*/ */
function setCmsOptions($cms_options) function setCmsOptions($cms_options) {
{
if (is_array($cms_options) && count($cms_options) > 0) { if (is_array($cms_options) && count($cms_options) > 0) {
$this->index->setCmsOptions($cms_options); $this->index->setCmsOptions($cms_options);
} }
@ -992,8 +969,7 @@ class Search extends SearchBaseAbstract
* @param $searchwords The search-words * @param $searchwords The search-words
* @return Array of stripped search-words * @return Array of stripped search-words
*/ */
function stripWords($searchwords) function stripWords($searchwords) {
{
$tmp_words = array(); $tmp_words = array();
$searchwords = stripslashes($searchwords); // remove backslash $searchwords = stripslashes($searchwords); // remove backslash
$searchwords = strip_tags($searchwords); // remove html tags $searchwords = strip_tags($searchwords); // remove html tags
@ -1020,19 +996,18 @@ class Search extends SearchBaseAbstract
* @return array Category Tree * @return array Category Tree
* @todo This is not the job for search, should be oursourced... * @todo This is not the job for search, should be oursourced...
*/ */
function getSubTree($cat_start) function getSubTree($cat_start) {
{
$sql = "SELECT $sql = "SELECT
B.idcat, B.parentid B.idcat, B.parentid
FROM FROM
".$this->cfg['tab']['cat_tree']." AS A, " . $this->cfg['tab']['cat_tree'] . " AS A,
".$this->cfg['tab']['cat']." AS B, " . $this->cfg['tab']['cat'] . " AS B,
".$this->cfg['tab']['cat_lang']." AS C " . $this->cfg['tab']['cat_lang'] . " AS C
WHERE WHERE
A.idcat = B.idcat AND A.idcat = B.idcat AND
B.idcat = C.idcat AND B.idcat = C.idcat AND
C.idlang = '".Contenido_Security::toInteger($this->lang)."' AND C.idlang = '" . Contenido_Security::toInteger($this->lang) . "' AND
B.idclient = '".Contenido_Security::toInteger($this->client)."' B.idclient = '" . Contenido_Security::toInteger($this->client) . "'
ORDER BY ORDER BY
idtree"; idtree";
$this->_debug('sql', $sql); $this->_debug('sql', $sql);
@ -1065,13 +1040,12 @@ class Search extends SearchBaseAbstract
* @param array $search_range * @param array $search_range
* @return array Articles in specified search range * @return array Articles in specified search range
*/ */
function getSearchableArticles($search_range) function getSearchableArticles($search_range) {
{
$cat_range = array(); $cat_range = array();
if (array_key_exists('cat_tree', $search_range) && is_array($search_range['cat_tree'])) { if (array_key_exists('cat_tree', $search_range) && is_array($search_range['cat_tree'])) {
if (count($search_range['cat_tree']) > 0) { 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)); $cat_range = array_merge($cat_range, $this->getSubTree($cat));
} }
} }
@ -1108,18 +1082,18 @@ class Search extends SearchBaseAbstract
if ($this->exclude == true) { if ($this->exclude == true) {
// exclude searchrange // 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 { } else {
// include searchrange // include searchrange
if (strlen($sArtRange) > 0) { 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 { } else {
$sSearchRange = " A.idcat IN ('".$sCatRange."') AND "; $sSearchRange = " A.idcat IN ('" . $sCatRange . "') AND ";
} }
} }
if (count($this->article_specs) > 0) { 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 { } else {
$sArtSpecs = ''; $sArtSpecs = '';
} }
@ -1127,17 +1101,17 @@ class Search extends SearchBaseAbstract
$sql = "SELECT $sql = "SELECT
A.idart A.idart
FROM FROM
".$this->cfg["tab"]["cat_art"]." as A, " . $this->cfg["tab"]["cat_art"] . " as A,
".$this->cfg["tab"]["art_lang"]." as B, " . $this->cfg["tab"]["art_lang"] . " as B,
".$this->cfg["tab"]["cat_lang"]." as C " . $this->cfg["tab"]["cat_lang"] . " as C
WHERE WHERE
".$sSearchRange." " . $sSearchRange . "
B.idlang = '".Contenido_Security::toInteger($this->lang)."' AND B.idlang = '" . Contenido_Security::toInteger($this->lang) . "' AND
C.idlang = '".Contenido_Security::toInteger($this->lang)."' AND C.idlang = '" . Contenido_Security::toInteger($this->lang) . "' AND
A.idart = B.idart AND A.idart = B.idart AND
A.idcat = C.idcat AND A.idcat = C.idcat AND
".$sArtSpecs." " . $sArtSpecs . "
".$protected." "; " . $protected . " ";
$this->_debug('sql', $sql); $this->_debug('sql', $sql);
$this->db->query($sql); $this->db->query($sql);
while ($this->db->next_record()) { while ($this->db->next_record()) {
@ -1151,15 +1125,14 @@ class Search extends SearchBaseAbstract
* *
* @return array Array of article specification Ids * @return array Array of article specification Ids
*/ */
function getArticleSpecifications() function getArticleSpecifications() {
{
$sql = "SELECT $sql = "SELECT
idartspec idartspec
FROM FROM
".$this->cfg['tab']['art_spec']." " . $this->cfg['tab']['art_spec'] . "
WHERE WHERE
client = ".Contenido_Security::toInteger($this->client)." AND client = " . Contenido_Security::toInteger($this->client) . " AND
lang = ".Contenido_Security::toInteger($this->lang)." AND lang = " . Contenido_Security::toInteger($this->lang) . " AND
online = 1 "; online = 1 ";
$this->_debug('sql', $sql); $this->_debug('sql', $sql);
$this->db->query($sql); $this->db->query($sql);
@ -1175,8 +1148,7 @@ class Search extends SearchBaseAbstract
* @param int $iArtspecID * @param int $iArtspecID
* @return void * @return void
*/ */
function setArticleSpecification($iArtspecID) function setArticleSpecification($iArtspecID) {
{
array_push($this->article_specs, $iArtspecID); array_push($this->article_specs, $iArtspecID);
} }
@ -1185,8 +1157,7 @@ class Search extends SearchBaseAbstract
* @param string $sArtSpecName * @param string $sArtSpecName
* @return void * @return void
*/ */
function addArticleSpecificationsByName($sArtSpecName) function addArticleSpecificationsByName($sArtSpecName) {
{
if (!isset($sArtSpecName) || strlen($sArtSpecName) == 0) { if (!isset($sArtSpecName) || strlen($sArtSpecName) == 0) {
return false; return false;
} }
@ -1194,10 +1165,10 @@ class Search extends SearchBaseAbstract
$sql = "SELECT $sql = "SELECT
idartspec idartspec
FROM FROM
".$this->cfg['tab']['art_spec']." " . $this->cfg['tab']['art_spec'] . "
WHERE WHERE
client = ".Contenido_Security::toInteger($this->client)." AND client = " . Contenido_Security::toInteger($this->client) . " AND
artspec = '".Contenido_Security::escapeDB($sArtSpecName, $this->db)."' "; artspec = '" . Contenido_Security::escapeDB($sArtSpecName, $this->db) . "' ";
$this->_debug('sql', $sql); $this->_debug('sql', $sql);
$this->db->query($sql); $this->db->query($sql);
while ($this->db->next_record()) { while ($this->db->next_record()) {
@ -1207,7 +1178,6 @@ class Search extends SearchBaseAbstract
} }
/** /**
* Contenido API - SearchResult Object * Contenido API - SearchResult Object
* *
@ -1241,9 +1211,8 @@ class Search extends SearchBaseAbstract
* @copyright four for business AG <www.4fb.de> * @copyright four for business AG <www.4fb.de>
* *
*/ */
class SearchResult extends SearchBaseAbstract {
class SearchResult extends SearchBaseAbstract
{
/** /**
* Instance of class Index * Instance of class Index
* @var object * @var object
@ -1310,8 +1279,7 @@ class SearchResult extends SearchBaseAbstract
* @param DB_ConLite $oDB Optional db instance * @param DB_ConLite $oDB Optional db instance
* @param bool $bDebug Optional flag to enable debugging * @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); parent::__construct($oDB, $bDebug);
$this->index = new Index($oDB); $this->index = new Index($oDB);
@ -1338,8 +1306,7 @@ class SearchResult extends SearchBaseAbstract
* @param $result_per_page * @param $result_per_page
* @return void * @return void
*/ */
function setOrderedSearchResult($ranked_search, $result_per_page) function setOrderedSearchResult($ranked_search, $result_per_page) {
{
asort($ranked_search); asort($ranked_search);
$sorted_rank = array_reverse($ranked_search, true); $sorted_rank = array_reverse($ranked_search, true);
@ -1358,8 +1325,7 @@ class SearchResult extends SearchBaseAbstract
* @param $art_id Id of an article * @param $art_id Id of an article
* @return Content of an article, specified by it's content type * @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); $article = new Article($art_id, $this->client, $this->lang);
return $article->getContent($cms_type, $id); return $article->getContent($cms_type, $id);
} }
@ -1369,8 +1335,7 @@ class SearchResult extends SearchBaseAbstract
* @param $art_id Id of an article * @param $art_id Id of an article
* @return Content of an article in search result, specified by its type * @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); $cms_type = strtoupper($cms_type);
if (strlen($cms_type) > 0) { if (strlen($cms_type) > 0) {
if (!stristr($cms_type, 'cms_')) { if (!stristr($cms_type, 'cms_')) {
@ -1399,14 +1364,14 @@ class SearchResult extends SearchBaseAbstract
//build consistent escaped string(Timo Trautmann) 2008-04-17 //build consistent escaped string(Timo Trautmann) 2008-04-17
$cms_content = clHtmlEntities(clHtmlEntityDecode(strip_tags($article->getContent($cms_type, $cms_nr)))); $cms_content = clHtmlEntities(clHtmlEntityDecode(strip_tags($article->getContent($cms_type, $cms_nr))));
if (count($this->replacement) == 2) { 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 //build consistent escaped string, replace ae ue .. with original html entities (Timo Trautmann) 2008-04-17
$word = clHtmlEntities(clHtmlEntityDecode($this->index->addSpecialUmlauts($word))); $word = clHtmlEntities(clHtmlEntityDecode($this->index->addSpecialUmlauts($word)));
$match = array(); $match = array();
preg_match("/$word/i", $cms_content, $match); preg_match("/$word/i", $cms_content, $match);
if (isset($match[0])) { if (isset($match[0])) {
$pattern = $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 $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)); $cms_content = strip_tags($article->getContent($cms_type, $id));
if (count($this->replacement) == 2) { if (count($this->replacement) == 2) {
foreach($search_words as $word) { foreach ($search_words as $word) {
preg_match("/$word/i", $cms_content, $match); preg_match("/$word/i", $cms_content, $match);
if (isset($match[0])) { if (isset($match[0])) {
$pattern = $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 $cms_content = preg_replace("/$pattern/i", $replacement, $cms_content); // emphasize located searchwords
} }
} }
@ -1430,7 +1395,6 @@ class SearchResult extends SearchBaseAbstract
$content[] = $cms_content; $content[] = $cms_content;
} }
} }
} else { } else {
// searchword was not found in cms_type // searchword was not found in cms_type
if (isset($cms_nr) && is_numeric($cms_nr)) { if (isset($cms_nr) && is_numeric($cms_nr)) {
@ -1453,8 +1417,7 @@ class SearchResult extends SearchBaseAbstract
* @param int $page_id * @param int $page_id
* @return array Artices in page $page_id * @return array Artices in page $page_id
*/ */
function getSearchResultPage($page_id) function getSearchResultPage($page_id) {
{
$this->result_page = $page_id; $this->result_page = $page_id;
$result_page = $this->ordered_search_result[$page_id - 1]; $result_page = $this->ordered_search_result[$page_id - 1];
return $result_page; return $result_page;
@ -1464,8 +1427,7 @@ class SearchResult extends SearchBaseAbstract
* Returns number of result pages * Returns number of result pages
* @return int * @return int
*/ */
function getNumberOfPages() function getNumberOfPages() {
{
return $this->pages; return $this->pages;
} }
@ -1473,8 +1435,7 @@ class SearchResult extends SearchBaseAbstract
* Returns number of results * Returns number of results
* @return int * @return int
*/ */
function getNumberOfResults() function getNumberOfResults() {
{
return $this->results; return $this->results;
} }
@ -1482,17 +1443,15 @@ class SearchResult extends SearchBaseAbstract
* @param $art_id Id of an article * @param $art_id Id of an article
* @return Similarity between searchword and matching word in article * @return Similarity between searchword and matching word in article
*/ */
function getSimilarity($art_id) function getSimilarity($art_id) {
{ return $this->search_result[$art_id]['similarity'];
return $this->search_result[$art_id]['similarity'];
} }
/** /**
* @param $art_id Id of an article * @param $art_id Id of an article
* @return Number of matching searchwords found in article * @return Number of matching searchwords found in article
*/ */
function getOccurrence($art_id) function getOccurrence($art_id) {
{
$aOccurence = $this->search_result[$art_id]['occurence']; $aOccurence = $this->search_result[$art_id]['occurence'];
$iSumOfOccurence = 0; $iSumOfOccurence = 0;
for ($i = 0; $i < count($aOccurence); $i++) { for ($i = 0; $i < count($aOccurence); $i++) {
@ -1507,8 +1466,7 @@ class SearchResult extends SearchBaseAbstract
* @param string $rep2 The closing html-tag e.g. '</b>' * @param string $rep2 The closing html-tag e.g. '</b>'
* @return void * @return void
*/ */
function setReplacement($rep1, $rep2) function setReplacement($rep1, $rep2) {
{
if (strlen(trim($rep1)) > 0 && strlen(trim($rep2)) > 0) { if (strlen(trim($rep1)) > 0 && strlen(trim($rep2)) > 0) {
array_push($this->replacement, $rep1); array_push($this->replacement, $rep1);
array_push($this->replacement, $rep2); array_push($this->replacement, $rep2);
@ -1520,10 +1478,9 @@ class SearchResult extends SearchBaseAbstract
* @return Category Id * @return Category Id
* @todo Is not job of search, should be outsourced! * @todo Is not job of search, should be outsourced!
*/ */
function getArtCat($artid) function getArtCat($artid) {
{ $sql = "SELECT idcat FROM " . $this->cfg['tab']['cat_art'] . "
$sql = "SELECT idcat FROM ".$this->cfg['tab']['cat_art']." WHERE idart = " . Contenido_Security::toInteger($artid) . " ";
WHERE idart = ".Contenido_Security::toInteger($artid)." ";
$this->db->query($sql); $this->db->query($sql);
if ($this->db->next_record()) { if ($this->db->next_record()) {
return $this->db->f('idcat'); 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) {
}
}
?>

Datei anzeigen

@ -74,7 +74,7 @@ class SMTP
* @access public * @access public
* @return void * @return void
*/ */
function SMTP() { function __construct() {
$this->smtp_conn = 0; $this->smtp_conn = 0;
$this->error = null; $this->error = null;
$this->helo_rply = null; $this->helo_rply = null;

Datei anzeigen

@ -38,7 +38,7 @@ class Structure {
* Constructor Function * Constructor Function
* @param * @param
*/ */
function Structure() { function __construct() {
// empty // empty
} // end function } // end function

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -28,9 +29,8 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
class Table { class Table {
@ -39,84 +39,78 @@ class Table {
* Table border color * Table border color
* @var string * @var string
*/ */
var $border_color = ''; var $border_color = '';
/** /**
* Table border style * Table border style
* @var string * @var string
*/ */
var $border_style = ''; var $border_style = '';
/** /**
* Table cell spacing * Table cell spacing
* @var string * @var string
*/ */
var $cell_spacing = ''; var $cell_spacing = '';
/** /**
* Table cell padding * Table cell padding
* @var string * @var string
*/ */
var $cell_padding = ''; var $cell_padding = '';
/** /**
* Table header color * Table header color
* @var string * @var string
*/ */
var $header_color = ''; var $header_color = '';
/** /**
* Table light row color * Table light row color
* @var string * @var string
*/ */
var $light_color = ''; var $light_color = '';
/** /**
* Table dark row color * Table dark row color
* @var string * @var string
*/ */
var $dark_color = ''; var $dark_color = '';
/** /**
* Internal dark/light row counter * Internal dark/light row counter
* @var bool * @var bool
*/ */
var $dark_row = 0; var $dark_row = 0;
/** /**
* Internal table width counter * Internal table width counter
* @var int * @var int
*/ */
var $table_cols = 0;
var $table_cols = 0;
/** /**
* Internal first cell checker * Internal first cell checker
* @var bool * @var bool
*/ */
var $first_cell = 0; var $first_cell = 0;
/** /**
* Internal full border checker * Internal full border checker
* @var bool * @var bool
*/ */
var $fullborder = false; var $fullborder = false;
/** /**
* Directly output table if true * Directly output table if true
* *
*/ */
var $directoutput = true; var $directoutput = true;
/** /**
* Constructor * Constructor
*/ */
function Table($m_bordercolor = "#EEEEEE", $m_borderstyle = "solid", $m_cellspacing = "0", $m_cellpadding="2", $m_header_color = "#222222", $m_light_color = "#AAAAAA", $m_dark_color = "#777777", $m_fullborder = false, $m_directoutput = true) { function __construct($m_bordercolor = "#EEEEEE", $m_borderstyle = "solid", $m_cellspacing = "0", $m_cellpadding = "2", $m_header_color = "#222222", $m_light_color = "#AAAAAA", $m_dark_color = "#777777", $m_fullborder = false, $m_directoutput = true) {
$this->border_color = $m_bordercolor; $this->border_color = $m_bordercolor;
$this->border_style = $m_borderstyle; $this->border_style = $m_borderstyle;
$this->cellspacing = $m_cellspacing; $this->cellspacing = $m_cellspacing;
@ -126,8 +120,9 @@ class Table {
$this->light_color = $m_light_color; $this->light_color = $m_light_color;
$this->fullborder = $m_fullborder; $this->fullborder = $m_fullborder;
$this->directoutput = $m_directoutput; $this->directoutput = $m_directoutput;
}
} # end function # end function
/** /**
* Begins the new table * Begins the new table
@ -136,43 +131,38 @@ class Table {
*/ */
function start_table() { function start_table() {
if (!$this->fullborder) if (!$this->fullborder) {
{ $starttable = '<table style="border: 0px; border-left:1px; border-bottom: 1px; border-color: ' . $this->border_color . '; border-style: ' . $this->border_style . '" cellspacing="' . $this->cellspacing . '" cellpadding="' . $this->cellpadding . '">';
$starttable = '<table style="border: 0px; border-left:1px; border-bottom: 1px; border-color: ' . $this->border_color . '; border-style: ' . $this->border_style . '" cellspacing="'. $this->cellspacing . '" cellpadding="'. $this->cellpadding . '">';
} else { } else {
$starttable = '<table style="border: 1px; border-color: ' . $this->border_color . '; border-style: ' . $this->border_style . '" cellspacing="'. $this->cellspacing . '" cellpadding="'. $this->cellpadding . '">'; $starttable = '<table style="border: 1px; border-color: ' . $this->border_color . '; border-style: ' . $this->border_style . '" cellspacing="' . $this->cellspacing . '" cellpadding="' . $this->cellpadding . '">';
} }
if ($this->directoutput) if ($this->directoutput) {
{ echo $starttable . "\n";
echo $starttable."\n";
} else { } else {
return $starttable."\n"; return $starttable . "\n";
} }
}
# end function
} # end function
/** /**
* Outputs a header row * Outputs a header row
* @param none * @param none
* @return void * @return void
*/ */
function header_row($additional="") { function header_row($additional = "") {
$headerrow = '<tr class="textw_medium" style="background-color: ' . $this->header_color . '" '.$additional.'>';
if ($this->directoutput) $headerrow = '<tr class="textw_medium" style="background-color: ' . $this->header_color . '" ' . $additional . '>';
{
echo $headerrow."\n";
} else {
return $headerrow."\n";
}
} # end function
if ($this->directoutput) {
echo $headerrow . "\n";
} else {
return $headerrow . "\n";
}
}
# end function
/** /**
* Outputs a regular row * Outputs a regular row
@ -180,27 +170,24 @@ class Table {
* @return void * @return void
*/ */
function row($id = '') { function row($id = '') {
if ($this->dark_row) if ($this->dark_row) {
{ $bgColor = $this->light_color;
$bgColor = $this->light_color; } else {
} else { $bgColor = $this->dark_color;
$bgColor = $this->dark_color; }
}
$this->dark_row = !$this->dark_row; $this->dark_row = !$this->dark_row;
$row = '<tr class="text_medium" style="background-color: ' . $bgColor . '" '.$id.'>';
if ($this->directoutput) $row = '<tr class="text_medium" style="background-color: ' . $bgColor . '" ' . $id . '>';
{
echo $row."\n";
} else {
return $row."\n";
}
} # end function
if ($this->directoutput) {
echo $row . "\n";
} else {
return $row . "\n";
}
}
# end function
/** /**
* Outputs a header cell * Outputs a header cell
@ -209,28 +196,25 @@ class Table {
* @param $valign The vertical alignment of the cell, default "top" * @param $valign The vertical alignment of the cell, default "top"
* @return void * @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 = '<th class="textg_medium" valign="' . $valign . '" style="border: 0px; border-top:'.$borderTop.'px; border-right:1px; border-color: '. $this->border_color . '; border-style: ' . $this->border_style . '" align="' . $align . '"' . $additional . '>' . $content . '</th>'; $header_cell = '<th class="textg_medium" valign="' . $valign . '" style="border: 0px; border-top:' . $borderTop . 'px; border-right:1px; border-color: ' . $this->border_color . '; border-style: ' . $this->border_style . '" align="' . $align . '"' . $additional . '>' . $content . '</th>';
if ($this->first_cell)
{
$this->table_cols = 0;
$this->first_cell = false;
}
$this->table_cols++;
if ($this->directoutput) if ($this->first_cell) {
{ $this->table_cols = 0;
echo $header_cell."\n"; $this->first_cell = false;
} else { }
return $header_cell."\n";
}
} # end function
$this->table_cols++;
if ($this->directoutput) {
echo $header_cell . "\n";
} else {
return $header_cell . "\n";
}
}
# end function
/** /**
* Outputs a regular cell * Outputs a regular cell
@ -239,44 +223,42 @@ class Table {
* @param $valign The vertical alignment of the cell, default "top" * @param $valign The vertical alignment of the cell, default "top"
* @param $additional Additional flags for the table * @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 = "&nbsp;"; $content = "&nbsp;";
} }
$cell = '<td '. $additional; $cell = '<td ' . $additional;
if ($valign != '') {
$cell.=' valign="'.$valign .'"';
}
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 . '"';
}
if ($align != '') {
$cell.=' align="'.$align .'"';
}
$cell.='>'.$content.'</td>';
if ($this->first_cell) if ($valign != '') {
{ $cell .= ' valign="' . $valign . '"';
$this->table_cols = 0; }
$this->first_cell = false;
}
$this->table_cols++;
if ($this->directoutput) 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 . '"';
echo $cell."\n"; }
} else {
return $cell."\n";
}
} # end function if ($align != '') {
$cell .= ' align="' . $align . '"';
}
$cell .= '>' . $content . '</td>';
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 * Outputs a borderless cell
@ -285,94 +267,85 @@ class Table {
* @param $valign The vertical alignment of the cell, default "top" * @param $valign The vertical alignment of the cell, default "top"
* @param $additional Additional flags for the table * @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 = "&nbsp;"; $content = "&nbsp;";
} }
$borderless_cell = '<td '. $additional .' valign="' . $valign . '" align="' . $align . '">' . $content . '</td>'; $borderless_cell = '<td ' . $additional . ' valign="' . $valign . '" align="' . $align . '">' . $content . '</td>';
if ($this->first_cell) if ($this->first_cell) {
{ $this->table_cols = 0;
$this->table_cols = 0; $this->first_cell = false;
$this->first_cell = false; }
}
$this->table_cols++;
if ($this->directoutput) $this->table_cols++;
{
echo $borderless_cell."\n";
} else {
return $borderless_cell."\n";
}
} # end function if ($this->directoutput) {
echo $borderless_cell . "\n";
} else {
return $borderless_cell . "\n";
}
}
# end function
/** /**
* Outputs a sum cell * Outputs a sum cell
* @param $content The content which will fill the cell * @param $content The content which will fill the cell
* @param $align The horizontal alignment of the cell, default "center" * @param $align The horizontal alignment of the cell, default "center"
* @param $valign The vertical alignment of the cell, default "top" * @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 = "&nbsp;"; $content = "&nbsp;";
} }
$sumcell = '<td colspan="'.$this->table_cols.'" valign="' . $valign . '" style="border: 0px; border-top:0px; border-right:1px; border-color: '. $this->border_color . '; border-style: ' . $this->border_style . '" align="' . $align . '">' . $content . '</td>'; $sumcell = '<td colspan="' . $this->table_cols . '" valign="' . $valign . '" style="border: 0px; border-top:0px; border-right:1px; border-color: ' . $this->border_color . '; border-style: ' . $this->border_style . '" align="' . $align . '">' . $content . '</td>';
if ($this->directoutput) if ($this->directoutput) {
{ echo $sumcell . "\n";
echo $sumcell."\n"; } else {
} else { return $sumcell . "\n";
return $sumcell."\n"; }
} }
} # end function
# end function
/** /**
* Ends a row * Ends a row
* @param none * @param none
* @return void * @return void
*/ */
function end_row() {
function end_row() $end_row = '</tr>';
{
$end_row = '</tr>';
$this->first_cell = true; $this->first_cell = true;
if ($this->directoutput) if ($this->directoutput) {
{ echo $end_row . "\n";
echo $end_row."\n";
} else { } else {
return $end_row."\n"; return $end_row . "\n";
} }
} }
/** /**
* Ends a table * Ends a table
* @param none * @param none
* @return void * @return void
*/ */
function end_table(){ function end_table() {
$end_table = '</table>'; $end_table = '</table>';
if ($this->directoutput) if ($this->directoutput) {
{ echo $end_table . "\n";
echo $end_table."\n";
} else { } else {
return $end_table."\n"; return $end_table . "\n";
} }
} # end function }
} # end class Table # end function
}
# end class Table
?> ?>

Datei anzeigen

@ -42,13 +42,6 @@ class TODOCollection extends CommunicationCollection
$this->_setItemClass("TODOItem"); $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 = "") public function select($where = "", $group_by = "", $order_by = "", $limit = "")
{ {
if ($where == "") { if ($where == "") {

Datei anzeigen

@ -129,7 +129,7 @@ class TreeItem
* @param string $id The unique ID of that item * @param string $id The unique ID of that item
* @param boolean $collapsed Is this item collapsed by default * @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->name = $name;
$this->id = $id; $this->id = $id;

Datei anzeigen

@ -38,7 +38,7 @@ class UI_Left_Top {
var $link; var $link;
var $javascripts; var $javascripts;
function UI_Left_Top() { function __construct() {
} }
@ -53,7 +53,7 @@ class UI_Left_Top {
function render() { function render() {
global $sess, $cfg; global $sess, $cfg;
$tpl = new Template; $tpl = new Template();
$tpl->reset(); $tpl->reset();
$tpl->set('s', 'SESSID', $sess->id); $tpl->set('s', 'SESSID', $sess->id);
@ -100,7 +100,7 @@ class UI_Menu {
var $show; var $show;
var $bgColor; var $bgColor;
function UI_Menu() { function __construct() {
$this->padding = 2; $this->padding = 2;
$this->border = 0; $this->border = 0;
$this->rowmark = true; $this->rowmark = true;
@ -147,7 +147,7 @@ class UI_Menu {
function render($print = true) { function render($print = true) {
global $sess, $cfg; global $sess, $cfg;
$tpl = new Template; $tpl = new Template();
$tpl->reset(); $tpl->reset();
$tpl->set('s', 'SID', $sess->id); $tpl->set('s', 'SID', $sess->id);
@ -284,7 +284,7 @@ class UI_Table_Form {
var $accesskey; var $accesskey;
var $width; var $width;
function UI_Table_Form($name, $action = "", $method = "post") { function __construct($name, $action = "", $method = "post") {
global $sess, $cfg; global $sess, $cfg;
$this->formname = $name; $this->formname = $name;
@ -635,7 +635,7 @@ class UI_Page {
var $content; var $content;
var $margin; var $margin;
function UI_Page() { function __construct() {
$this->margin = 10; $this->margin = 10;
} }
@ -674,7 +674,7 @@ class UI_Page {
function render($print = true) { function render($print = true) {
global $sess, $cfg; global $sess, $cfg;
$tpl = new Template; $tpl = new Template();
$scripts = ""; $scripts = "";
@ -848,7 +848,7 @@ class UI_List {
var $solid; var $solid;
var $width; var $width;
function UI_List() { function __construct() {
$this->padding = 2; $this->padding = 2;
$this->border = 0; $this->border = 0;
} }
@ -897,8 +897,8 @@ class UI_List {
function render($print = false) { function render($print = false) {
global $sess, $cfg; global $sess, $cfg;
$tpl = new Template; $tpl = new Template();
$tpl2 = new Template; $tpl2 = new Template();
$tpl->reset(); $tpl->reset();
$tpl->set('s', 'SID', $sess->id); $tpl->set('s', 'SID', $sess->id);
@ -1075,45 +1075,45 @@ class cScrollList {
* *
* @param $defaultstyle boolean use the default style for object initializing? * @param $defaultstyle boolean use the default style for object initializing?
*/ */
function cScrollList($defaultstyle = true, $action = "") { function __construct($defaultstyle = true, $action = "") {
global $cfg, $area, $frame; global $cfg, $area, $frame;
$this->resultsPerPage = 0; $this->resultsPerPage = 0;
$this->listStart = 1; $this->listStart = 1;
$this->sortable = false; $this->sortable = false;
$this->objTable = new cHTMLTable; $this->objTable = new cHTMLTable();
if ($defaultstyle == true) { 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->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->objTable->updateAttributes(array("cellspacing" => 0, "cellpadding" => 2));
} }
$this->objHeaderRow = new cHTMLTableRow; $this->objHeaderRow = new cHTMLTableRow();
if ($defaultstyle == true) { if ($defaultstyle == true) {
$this->objHeaderRow->setClass("text_medium"); $this->objHeaderRow->setClass("text_medium");
$this->objHeaderRow->setStyle("background-color: #E2E2E2;white-space:nowrap;"); $this->objHeaderRow->setStyle("background-color: #E2E2E2;white-space:nowrap;");
} }
$this->objHeaderItem = new cHTMLTableHead; $this->objHeaderItem = new cHTMLTableHead();
if ($defaultstyle == true) { if ($defaultstyle == true) {
$this->objHeaderItem->setClass("textg_medium"); $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->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->objHeaderItem->updateAttributes(array("align" => "left"));
} }
$this->objRow = new cHTMLTableRow; $this->objRow = new cHTMLTableRow();
if ($defaultstyle == true) { if ($defaultstyle == true) {
$this->objRow->setClass("text_medium"); $this->objRow->setClass("text_medium");
} }
$this->objItem = new cHTMLTableData; $this->objItem = new cHTMLTableData();
if ($defaultstyle == true) { if ($defaultstyle == true) {
$this->objItem->setStyle('white-space:nowrap; border: 1px; border-style: solid;border-top:0px;border-color: ' . $cfg["color"]["table_border"] . ';'); $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->setStyle("color: #666666;");
$this->sortlink->setCLink($area, $frame, $action); $this->sortlink->setCLink($area, $frame, $action);
} }
@ -1320,7 +1320,7 @@ class cScrollList {
* @param $return If true, returns the list * @param $return If true, returns the list
*/ */
function render($return = true) { function render($return = true) {
$currentpage = $this->getCurrentPage(); $currentpage = $this->getCurrentPage();
$itemstart = (($currentpage - 1) * $this->resultsPerPage) + 1; $itemstart = (($currentpage - 1) * $this->resultsPerPage) + 1;
@ -1402,5 +1402,5 @@ class cScrollList {
echo $output; echo $output;
} }
} }
} }
?>

Datei anzeigen

@ -691,6 +691,7 @@ class Contenido_UpdateNotifier {
if ($this->sRSSContent != '') { if ($this->sRSSContent != '') {
$oRss = simplexml_load_file($this->sCacheDirectory . $this->sRSSFile); $oRss = simplexml_load_file($this->sCacheDirectory . $this->sRSSFile);
//echo $sFeedContent;
$iCnt = 0; $iCnt = 0;
foreach ($oRss->channel->item as $aItem) { foreach ($oRss->channel->item as $aItem) {
@ -769,4 +770,4 @@ class Contenido_UpdateNotifier {
} }
?> ?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -32,13 +33,11 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) {
die('Illegal call'); die('Illegal call');
} }
class Users class Users {
{
/** /**
* Storage of the source table to use for the user informations * Storage of the source table to use for the user informations
@ -58,8 +57,7 @@ class Users
* Constructor Function * Constructor Function
* @param string $table The table to use as information source * @param string $table The table to use as information source
*/ */
function Users($table = '') function __construct($table = '') {
{
if ($table == '') { if ($table == '') {
global $cfg; global $cfg;
$this->table = $cfg['tab']['phplib_auth_user_md5']; $this->table = $cfg['tab']['phplib_auth_user_md5'];
@ -70,62 +68,55 @@ class Users
$this->db = new DB_ConLite(); $this->db = new DB_ConLite();
} }
/** /**
* Creates a new user by specifying its username. * Creates a new user by specifying its username.
* *
* @param string $username Specifies the username * @param string $username Specifies the username
* @return int Userid of created user * @return int Userid of created user
*/ */
function create($username) function create($username) {
{
$newuserid = md5($username); $newuserid = md5($username);
$sql = "SELECT user_id FROM ".$this->table $sql = "SELECT user_id FROM " . $this->table
. " WHERE user_id = '".Contenido_Security::escapeDB($newuserid, $this->db)."'"; . " WHERE user_id = '" . Contenido_Security::escapeDB($newuserid, $this->db) . "'";
$this->db->query($sql); $this->db->query($sql);
if ($this->db->next_record()) { if ($this->db->next_record()) {
return false; return false;
} }
$sql = "INSERT INTO ".$this->table $sql = "INSERT INTO " . $this->table
. " SET user_id = '".Contenido_Security::escapeDB($newuserid, $this->db)."'," . " SET user_id = '" . Contenido_Security::escapeDB($newuserid, $this->db) . "',"
. " username = '".Contenido_Security::escapeDB($username, $this->db)."'"; . " username = '" . Contenido_Security::escapeDB($username, $this->db) . "'";
$this->db->query($sql); $this->db->query($sql);
return $newuserid; return $newuserid;
} }
/** /**
* Removes the specified user from the database. * Removes the specified user from the database.
* *
* @param string $userid Specifies the user ID * @param string $userid Specifies the user ID
* @return bool True if the delete was successful * @return bool True if the delete was successful
*/ */
function deleteUserByID($userid) function deleteUserByID($userid) {
{
$sql = "DELETE FROM " . $this->table $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); $this->db->query($sql);
return ($this->db->affected_rows() == 0) ? false : true; return ($this->db->affected_rows() == 0) ? false : true;
} }
/** /**
* Removes the specified user from the database. * Removes the specified user from the database.
* *
* @param string $userid Specifies the username * @param string $userid Specifies the username
* @return bool True if the delete was successful * @return bool True if the delete was successful
*/ */
function deleteUserByUsername($username) function deleteUserByUsername($username) {
{
$sql = "DELETE FROM " . $this->table $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); $this->db->query($sql);
return ($this->db->affected_rows() == 0) ? false : true; return ($this->db->affected_rows() == 0) ? false : true;
} }
/** /**
* Returns all users which are accessible by the current user. * 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 * @param bool $includeAdmins Flag to get admins (admin and sysadmin) too
* @return array Array of user objects * @return array Array of user objects
*/ */
function getAccessibleUsers($perms, $includeAdmins = false) function getAccessibleUsers($perms, $includeAdmins = false) {
{
global $cfg; global $cfg;
$clientclass = new Client(); $clientclass = new Client();
@ -142,15 +132,15 @@ class Users
$allClients = $clientclass->getAvailableClients(); $allClients = $clientclass->getAvailableClients();
foreach ($allClients as $key => $value) { foreach ($allClients as $key => $value) {
if (in_array("client[".$key."]", $perms) || in_array("admin[".$key."]", $perms)) { if (in_array("client[" . $key . "]", $perms) || in_array("admin[" . $key . "]", $perms)) {
$limit[] = 'perms LIKE "%client['.$key.']%"'; $limit[] = 'perms LIKE "%client[' . $key . ']%"';
if ($includeAdmins) { if ($includeAdmins) {
$limit[] = 'perms LIKE "%admin['.$key.']%"'; $limit[] = 'perms LIKE "%admin[' . $key . ']%"';
} }
} }
if (in_array("admin[".$key."]", $perms)) { if (in_array("admin[" . $key . "]", $perms)) {
$limit[] = 'perms LIKE "%admin['.$key.']%"'; $limit[] = 'perms LIKE "%admin[' . $key . ']%"';
} }
} }
@ -171,7 +161,7 @@ class Users
$sql = "SELECT $sql = "SELECT
user_id, username, realname user_id, username, realname
FROM 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); $db->query($sql);
@ -186,8 +176,8 @@ class Users
return ($users); return ($users);
} }
}
}
/** /**
* Class User * Class User
@ -196,8 +186,7 @@ class Users
* @version 1.0 * @version 1.0
* @copyright four for business 2003 * @copyright four for business 2003
*/ */
class User class User {
{
/** /**
* Storage of the source table to use for the user informations * 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 * @param string $table The table to use as information source
*/ */
function User($table = '') function __construct($table = '') {
{
if ($table == '') { if ($table == '') {
global $cfg; global $cfg;
$this->table = $cfg['tab']['phplib_auth_user_md5']; $this->table = $cfg['tab']['phplib_auth_user_md5'];
@ -244,18 +232,16 @@ class User
$this->db = new DB_ConLite(); $this->db = new DB_ConLite();
} }
/** /**
* Loads a user from the database by its username. * Loads a user from the database by its username.
* *
* @param string $username Specifies the username * @param string $username Specifies the username
* @return bool True if the load was successful * @return bool True if the load was successful
*/ */
function loadUserByUsername($username) function loadUserByUsername($username) {
{
// SQL-Statement to select by username // SQL-Statement to select by username
$sql = "SELECT * FROM " . $this->table $sql = "SELECT * FROM " . $this->table
. " WHERE username = '".Contenido_Security::escapeDB($username, $this->db)."'"; . " WHERE username = '" . Contenido_Security::escapeDB($username, $this->db) . "'";
// Query the database // Query the database
$this->db->query($sql); $this->db->query($sql);
@ -270,18 +256,16 @@ class User
return true; return true;
} }
/** /**
* Loads a user from the database by its userID. * Loads a user from the database by its userID.
* *
* @param string $userid Specifies the userID * @param string $userid Specifies the userID
* @return bool True if the load was successful * @return bool True if the load was successful
*/ */
function loadUserByUserID($userID) function loadUserByUserID($userID) {
{
// SQL-Statement to select by userID // SQL-Statement to select by userID
$sql = "SELECT * FROM " . $this->table $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 // Query the database
$this->db->query($sql); $this->db->query($sql);
@ -296,15 +280,13 @@ class User
return true; return true;
} }
/** /**
* Function returns effective perms for user including group rights as perm string. * Function returns effective perms for user including group rights as perm string.
* *
* @author Timo Trautmann * @author Timo Trautmann
* @return string Current users permissions * @return string Current users permissions
*/ */
function getEffectiveUserPerms() function getEffectiveUserPerms() {
{
global $cfg, $perm; global $cfg, $perm;
//first get users own permissions and filter them into result array $aUserPerms //first get users own permissions and filter them into result array $aUserPerms
@ -336,51 +318,45 @@ class User
return implode(',', $aUserPerms); return implode(',', $aUserPerms);
} }
/** /**
* Gets the value of a specific field. * Gets the value of a specific field.
* *
* @param string $field Specifies the field to retrieve * @param string $field Specifies the field to retrieve
* @return mixed Value of the field * @return mixed Value of the field
*/ */
function getField($field) function getField($field) {
{
return ($this->values[$field]); return ($this->values[$field]);
} }
/** /**
* Sets the value of a specific field. * Sets the value of a specific field.
* *
* @param string $field Specifies the field to set * @param string $field Specifies the field to set
* @param string $value Specifies the value to set * @param string $value Specifies the value to set
*/ */
function setField($field, $value) function setField($field, $value) {
{
$this->modifiedValues[$field] = true; $this->modifiedValues[$field] = true;
$this->values[$field] = $value; $this->values[$field] = $value;
} }
/** /**
* Stores the modified user object to the database * Stores the modified user object to the database
* @return bool * @return bool
*/ */
function store() function store() {
{ $sql = "UPDATE " . $this->table . " SET ";
$sql = "UPDATE " .$this->table ." SET ";
$first = true; $first = true;
foreach ($this->modifiedValues as $key => $value) { foreach ($this->modifiedValues as $key => $value) {
if ($first == true) { if ($first == true) {
$sql .= "$key = '" . $this->values[$key] ."'"; $sql .= "$key = '" . $this->values[$key] . "'";
$first = false; $first = false;
} else { } 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); $this->db->query($sql);
@ -391,7 +367,6 @@ class User
} }
} }
/** /**
* Stores the modified user object to the database * Stores the modified user object to the database
* @param string type Specifies the type (class, category etc) for the property to retrieve * @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 * @param boolean group Specifies if this function should recursively search in groups
* @return string The value of the retrieved property * @return string The value of the retrieved property
*/ */
function getUserProperty($type, $name, $group = false) function getUserProperty($type, $name, $group = false) {
{
global $cfg, $perm; global $cfg, $perm;
if (!is_object($perm)) { if (!is_object($perm)) {
@ -414,10 +388,10 @@ class User
if (is_array($groups)) { if (is_array($groups)) {
foreach ($groups as $value) { foreach ($groups as $value) {
$sql = "SELECT value FROM " .$cfg['tab']['group_prop']." $sql = "SELECT value FROM " . $cfg['tab']['group_prop'] . "
WHERE group_id = '".Contenido_Security::escapeDB($value, $this->db)."' WHERE group_id = '" . Contenido_Security::escapeDB($value, $this->db) . "'
AND type = '".Contenido_Security::escapeDB($type, $this->db)."' AND type = '" . Contenido_Security::escapeDB($type, $this->db) . "'
AND name = '".Contenido_Security::escapeDB($name, $this->db)."'"; AND name = '" . Contenido_Security::escapeDB($name, $this->db) . "'";
$this->db->query($sql); $this->db->query($sql);
if ($this->db->next_record()) { if ($this->db->next_record()) {
@ -427,10 +401,10 @@ class User
} }
} }
$sql = "SELECT value FROM " .$cfg['tab']['user_prop']." $sql = "SELECT value FROM " . $cfg['tab']['user_prop'] . "
WHERE user_id = '".Contenido_Security::escapeDB($this->values['user_id'], $this->db)."' WHERE user_id = '" . Contenido_Security::escapeDB($this->values['user_id'], $this->db) . "'
AND type = '".Contenido_Security::escapeDB($type, $this->db)."' AND type = '" . Contenido_Security::escapeDB($type, $this->db) . "'
AND name = '".Contenido_Security::escapeDB($name, $this->db)."'"; AND name = '" . Contenido_Security::escapeDB($name, $this->db) . "'";
$this->db->query($sql); $this->db->query($sql);
if ($this->db->next_record()) { if ($this->db->next_record()) {
@ -444,44 +418,42 @@ class User
} }
} }
/** /**
* Stores the modified user object to the database * Stores the modified user object to the database
* *
* @param string sType Specifies the type (class, category etc) for the property to retrieve * @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 * @param boolean bGroup Specifies if this function should recursively search in groups
* @return array The value of the retrieved property * @return array The value of the retrieved property
**/ * */
function getUserPropertiesByType($sType, $bGroup = false) function getUserPropertiesByType($sType, $bGroup = false) {
{ global $cfg, $perm;
global $cfg, $perm;
if (!is_object($perm)) { if (!is_object($perm)) {
$perm = new Contenido_Perm(); $perm = new Contenido_Perm();
} }
$aResult = array(); $aResult = array();
if ($bGroup == true) { if ($bGroup == true) {
$aGroups = $perm->getGroupsForUser($this->values['user_id']); $aGroups = $perm->getGroupsForUser($this->values['user_id']);
if (is_array($aGroups)) { if (is_array($aGroups)) {
foreach ($aGroups as $iID) { foreach ($aGroups as $iID) {
$sSQL = "SELECT name, value FROM " .$cfg['tab']['group_prop']." $sSQL = "SELECT name, value FROM " . $cfg['tab']['group_prop'] . "
WHERE group_id = '".Contenido_Security::escapeDB($iID, $this->db)."' WHERE group_id = '" . Contenido_Security::escapeDB($iID, $this->db) . "'
AND type = '".Contenido_Security::escapeDB($sType, $this->db)."'"; AND type = '" . Contenido_Security::escapeDB($sType, $this->db) . "'";
$this->db->query($sSQL); $this->db->query($sSQL);
while ($this->db->next_record()) { while ($this->db->next_record()) {
$aResult[$this->db->f('name')] = urldecode($this->db->f('value')); $aResult[$this->db->f('name')] = urldecode($this->db->f('value'));
} }
} }
} }
} }
$sSQL = "SELECT name, value FROM " .$cfg['tab']['user_prop']." $sSQL = "SELECT name, value FROM " . $cfg['tab']['user_prop'] . "
WHERE user_id = '".Contenido_Security::escapeDB($this->values['user_id'], $this->db)."' WHERE user_id = '" . Contenido_Security::escapeDB($this->values['user_id'], $this->db) . "'
AND type = '".Contenido_Security::escapeDB($sType, $this->db)."'"; AND type = '" . Contenido_Security::escapeDB($sType, $this->db) . "'";
$this->db->query($sSQL); $this->db->query($sSQL);
while ($this->db->next_record()) { while ($this->db->next_record()) {
@ -491,7 +463,6 @@ class User
return $aResult; return $aResult;
} }
/** /**
* Retrieves all available properties of the user * Retrieves all available properties of the user
* @return array Assoziative properties list as follows: * @return array Assoziative properties list as follows:
@ -499,14 +470,13 @@ class User
* - $arr[iduserprop][type] * - $arr[iduserprop][type]
* - $arr[iduserprop][value] * - $arr[iduserprop][value]
*/ */
function getUserProperties() function getUserProperties() {
{
global $cfg; global $cfg;
$aProps = array(); $aProps = array();
$sql = "SELECT iduserprop, type, name, value FROM " .$cfg['tab']['user_prop']." $sql = "SELECT iduserprop, type, name, value FROM " . $cfg['tab']['user_prop'] . "
WHERE user_id = '".Contenido_Security::escapeDB($this->values['user_id'], $this->db)."'"; WHERE user_id = '" . Contenido_Security::escapeDB($this->values['user_id'], $this->db) . "'";
$this->db->query($sql); $this->db->query($sql);
if ($this->db->num_rows() == 0) { if ($this->db->num_rows() == 0) {
@ -515,8 +485,8 @@ class User
while ($this->db->next_record()) { while ($this->db->next_record()) {
$aProps[$this->db->f('iduserprop')] = array( $aProps[$this->db->f('iduserprop')] = array(
'name' => $this->db->f('name'), 'name' => $this->db->f('name'),
'type' => $this->db->f('type'), 'type' => $this->db->f('type'),
'value' => $this->db->f('value'), 'value' => $this->db->f('value'),
); );
} }
@ -524,65 +494,58 @@ class User
return $aProps; return $aProps;
} }
/** /**
* Stores a property to the database * Stores a property to the database
* @param string type Specifies the type (class, category etc) for the property to retrieve * @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 name Specifies the name of the property to retrieve
* @param string value Specifies the value to insert * @param string value Specifies the value to insert
*/ */
function setUserProperty($type, $name, $value) function setUserProperty($type, $name, $value) {
{
global $cfg; global $cfg;
$value = urlencode($value); $value = urlencode($value);
// Check if such an entry already exists // Check if such an entry already exists
if ($this->getUserProperty($type, $name) !== false) if ($this->getUserProperty($type, $name) !== false) {
{ $sql = "UPDATE " . $cfg['tab']['user_prop'] . "
$sql = "UPDATE ".$cfg['tab']['user_prop']." SET value = '" . Contenido_Security::escapeDB($value, $this->db) . "'
SET value = '".Contenido_Security::escapeDB($value, $this->db)."' WHERE user_id = '" . Contenido_Security::escapeDB($this->values['user_id'], $this->db) . "'
WHERE user_id = '".Contenido_Security::escapeDB($this->values['user_id'], $this->db)."' AND type = '" . Contenido_Security::escapeDB($type, $this->db) . "'
AND type = '".Contenido_Security::escapeDB($type, $this->db)."' AND name = '" . Contenido_Security::escapeDB($name, $this->db) . "'";
AND name = '".Contenido_Security::escapeDB($name, $this->db)."'";
$this->db->query($sql); $this->db->query($sql);
} else { } else {
$sql = "INSERT INTO ".$cfg['tab']['user_prop']." $sql = "INSERT INTO " . $cfg['tab']['user_prop'] . "
SET value = '".Contenido_Security::escapeDB($value, $this->db)."', SET value = '" . Contenido_Security::escapeDB($value, $this->db) . "',
user_id = '".Contenido_Security::escapeDB($this->values['user_id'], $this->db)."', user_id = '" . Contenido_Security::escapeDB($this->values['user_id'], $this->db) . "',
type = '".Contenido_Security::escapeDB($type, $this->db)."', type = '" . Contenido_Security::escapeDB($type, $this->db) . "',
name = '".Contenido_Security::escapeDB($name, $this->db)."', name = '" . Contenido_Security::escapeDB($name, $this->db) . "',
iduserprop = '".Contenido_Security::toInteger($this->db->nextid($cfg['tab']['user_prop']))."'"; iduserprop = '" . Contenido_Security::toInteger($this->db->nextid($cfg['tab']['user_prop'])) . "'";
$this->db->query($sql); $this->db->query($sql);
} }
} }
/** /**
* Deletes a user property from the table * Deletes a user property from the table
* @param string type Specifies the type (class, category etc) for the property to retrieve * @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 name Specifies the name of the property to retrieve
*/ */
function deleteUserProperty($type, $name) function deleteUserProperty($type, $name) {
{
global $cfg; global $cfg;
// Delete record from table // Delete record from table
$sql = "DELETE FROM ".$cfg['tab']['user_prop']." $sql = "DELETE FROM " . $cfg['tab']['user_prop'] . "
WHERE user_id = '".Contenido_Security::escapeDB($this->values['user_id'], $this->db)."' AND WHERE user_id = '" . Contenido_Security::escapeDB($this->values['user_id'], $this->db) . "' AND
type = '".Contenido_Security::escapeDB($type, $this->db)."' AND type = '" . Contenido_Security::escapeDB($type, $this->db) . "' AND
name = '".Contenido_Security::escapeDB($name, $this->db)."'"; name = '" . Contenido_Security::escapeDB($name, $this->db) . "'";
$this->db->query($sql); $this->db->query($sql);
} }
/** /**
* Returns all users available in the system * Returns all users available in the system
* @param string $sort SQL sort part * @param string $sort SQL sort part
* @return array Array with id and name entries * @return array Array with id and name entries
*/ */
function getAvailableUsers($sort = 'ORDER BY realname ASC') function getAvailableUsers($sort = 'ORDER BY realname ASC') {
{
global $cfg; global $cfg;
$db = new DB_ConLite(); $db = new DB_ConLite();
@ -590,7 +553,7 @@ class User
$sql = "SELECT $sql = "SELECT
user_id, username, realname user_id, username, realname
FROM FROM
". $cfg['tab']['phplib_auth_user_md5']. " " . $sort; " . $cfg['tab']['phplib_auth_user_md5'] . " " . $sort;
$db->query($sql); $db->query($sql);
@ -606,14 +569,12 @@ class User
return ($users); return ($users);
} }
/** /**
* Returns all system admins available in the system * Returns all system admins available in the system
* @param boolean $forceActive Is forceActive true return only activ Sysadmins * @param boolean $forceActive Is forceActive true return only activ Sysadmins
* @return array Array with id and name entries * @return array Array with id and name entries
*/ */
function getSystemAdmins($forceActive = false) function getSystemAdmins($forceActive = false) {
{
global $cfg; global $cfg;
$db = new DB_ConLite(); $db = new DB_ConLite();
@ -621,12 +582,12 @@ class User
$sql = "SELECT $sql = "SELECT
user_id, username, realname, email user_id, username, realname, email
FROM FROM
". $cfg['tab']['phplib_auth_user_md5'] ." " . $cfg['tab']['phplib_auth_user_md5'] . "
WHERE WHERE
perms LIKE \"%sysadmin%\""; perms LIKE \"%sysadmin%\"";
if ($forceActive === true) { 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') "; 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( $users[$db->f('user_id')] = array(
'username' => $db->f('username'), 'username' => $db->f('username'),
'realname' => $db->f('realname'), 'realname' => $db->f('realname'),
'email' => $db->f('email'), 'email' => $db->f('email'),
); );
} }
return ($users); return ($users);
} }
/** /**
* Returns all system admins available in the system * Returns all system admins available in the system
* @param int $client * @param int $client
* @return array Array with id and name entries * @return array Array with id and name entries
*/ */
function getClientAdmins($client) function getClientAdmins($client) {
{
global $cfg; global $cfg;
$db = new DB_ConLite(); $db = new DB_ConLite();
@ -662,9 +621,9 @@ class User
$sql = "SELECT $sql = "SELECT
user_id, username, realname, email user_id, username, realname, email
FROM FROM
". $cfg['tab']['phplib_auth_user_md5'] ." " . $cfg['tab']['phplib_auth_user_md5'] . "
WHERE WHERE
perms LIKE \"%admin[".$client."]%\""; perms LIKE \"%admin[" . $client . "]%\"";
$db->query($sql); $db->query($sql);
@ -674,21 +633,19 @@ class User
$users[$db->f('user_id')] = array( $users[$db->f('user_id')] = array(
'username' => $db->f('username'), 'username' => $db->f('username'),
'realname' => $db->f('realname'), 'realname' => $db->f('realname'),
'email' => $db->f('email'), 'email' => $db->f('email'),
); );
} }
return ($users); return ($users);
} }
/** /**
* Returns the username of the given userid * Returns the username of the given userid
* @param int $userid * @param int $userid
* @return string Username if found, or emptry string if not. * @return string Username if found, or emptry string if not.
*/ */
function getUsername($userid) function getUsername($userid) {
{
global $cfg; global $cfg;
$db = new DB_ConLite(); $db = new DB_ConLite();
@ -696,24 +653,22 @@ class User
$sql = "SELECT $sql = "SELECT
username username
FROM FROM
". $cfg['tab']['phplib_auth_user_md5']." " . $cfg['tab']['phplib_auth_user_md5'] . "
WHERE WHERE
user_id = '".Contenido_Security::escapeDB($userid, $db)."'"; user_id = '" . Contenido_Security::escapeDB($userid, $db) . "'";
$db->query($sql); $db->query($sql);
$db->next_record(); $db->next_record();
return ($db->f('username')); return ($db->f('username'));
} }
/** /**
* Returns the realname of the given userid * Returns the realname of the given userid
* @param int $userid * @param int $userid
* @param bool $bAllowFallbackOnUsername * @param bool $bAllowFallbackOnUsername
* @return string Realname if found, or emptry string if not. * @return string Realname if found, or emptry string if not.
*/ */
function getRealname($userid, $bAllowFallbackOnUsername = false) function getRealname($userid, $bAllowFallbackOnUsername = false) {
{
global $cfg; global $cfg;
$db = new DB_ConLite(); $db = new DB_ConLite();
@ -721,9 +676,9 @@ class User
$sql = "SELECT $sql = "SELECT
realname realname
FROM FROM
". $cfg['tab']['phplib_auth_user_md5']." " . $cfg['tab']['phplib_auth_user_md5'] . "
WHERE WHERE
user_id = '".Contenido_Security::escapeDB($userid, $db)."'"; user_id = '" . Contenido_Security::escapeDB($userid, $db) . "'";
$db->query($sql); $db->query($sql);
$db->next_record(); $db->next_record();
@ -735,14 +690,12 @@ class User
} }
} }
/** /**
* Returns the realname of the given username * Returns the realname of the given username
* @param string $username * @param string $username
* @return string Realname if found, or emptry string if not. * @return string Realname if found, or emptry string if not.
*/ */
function getRealnameByUserName($username) function getRealnameByUserName($username) {
{
global $cfg; global $cfg;
$db = new DB_ConLite(); $db = new DB_ConLite();
@ -750,23 +703,21 @@ class User
$sql = "SELECT $sql = "SELECT
realname realname
FROM FROM
". $cfg['tab']['phplib_auth_user_md5']." " . $cfg['tab']['phplib_auth_user_md5'] . "
WHERE WHERE
username = '".Contenido_Security::escapeDB($username, $db)."'"; username = '" . Contenido_Security::escapeDB($username, $db) . "'";
$db->query($sql); $db->query($sql);
$db->next_record(); $db->next_record();
return ($db->f('realname')); return ($db->f('realname'));
} }
/** /**
* Returns the groups a user is in * Returns the groups a user is in
* @param int $userid * @param int $userid
* @return array Real names of groups * @return array Real names of groups
*/ */
function getGroupsByUserID($userid) function getGroupsByUserID($userid) {
{
global $cfg; global $cfg;
$db = new DB_ConLite(); $db = new DB_ConLite();
@ -774,12 +725,12 @@ class User
$sql = "SELECT $sql = "SELECT
a.group_id a.group_id
FROM FROM
".$cfg['tab']['groups']." AS a, " . $cfg['tab']['groups'] . " AS a,
".$cfg['tab']['groupmembers']." AS b " . $cfg['tab']['groupmembers'] . " AS b
WHERE WHERE
(a.group_id = b.group_id) (a.group_id = b.group_id)
AND AND
(b.user_id = '".Contenido_Security::escapeDB($userid, $db)."') (b.user_id = '" . Contenido_Security::escapeDB($userid, $db) . "')
"; ";
$db->query($sql); $db->query($sql);
@ -796,7 +747,7 @@ class User
$sDescription = trim($oGroup->getField('description')); $sDescription = trim($oGroup->getField('description'));
if ($sDescription != '') { if ($sDescription != '') {
$sTemp.=' ('.$sDescription.')'; $sTemp .= ' (' . $sDescription . ')';
} }
$arrGroups[] = $sTemp; $arrGroups[] = $sTemp;
@ -804,14 +755,12 @@ class User
return $arrGroups; return $arrGroups;
} }
/** /**
* Returns the groups a user is in * Returns the groups a user is in
* @param int $userid * @param int $userid
* @return array Ids of groups * @return array Ids of groups
*/ */
function getGroupIDsByUserID($userid) function getGroupIDsByUserID($userid) {
{
global $cfg; global $cfg;
$db = new DB_ConLite(); $db = new DB_ConLite();
@ -819,12 +768,12 @@ class User
$sql = "SELECT $sql = "SELECT
a.group_id a.group_id
FROM FROM
".$cfg['tab']['groups']." AS a, " . $cfg['tab']['groups'] . " AS a,
".$cfg['tab']['groupmembers']." AS b " . $cfg['tab']['groupmembers'] . " AS b
WHERE WHERE
(a.group_id = b.group_id) (a.group_id = b.group_id)
AND AND
(b.user_id = '".Contenido_Security::escapeDB($userid, $db)."') (b.user_id = '" . Contenido_Security::escapeDB($userid, $db) . "')
"; ";
$db->query($sql); $db->query($sql);
@ -838,5 +787,3 @@ class User
} }
} }
?>

Datei anzeigen

@ -41,7 +41,7 @@ class cWYSIWYGEditor
var $_sEditorContent; var $_sEditorContent;
var $_aSettings; var $_aSettings;
function cWYSIWYGEditor ($sEditorName, $sEditorContent) function __construct ($sEditorName, $sEditorContent)
{ {
global $cfg; global $cfg;

Datei anzeigen

@ -83,7 +83,7 @@ class XML_doc {
/** /**
* Class Construcor * Class Construcor
*/ */
function XML_doc() { function __construct() {
global $encoding, $lang; global $encoding, $lang;
$this->sys_encoding = $encoding[$lang]; $this->sys_encoding = $encoding[$lang];

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -27,9 +28,8 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
/** /**
@ -91,526 +91,476 @@ if(!defined('CON_FRAMEWORK')) {
* @copyright four for business AG <www.4fb.de> * @copyright four for business AG <www.4fb.de>
* @version 1.0 * @version 1.0
*/ */
class XmlParser class XmlParser {
{
/** /**
* XML Parser autofree * XML Parser autofree
* *
* @var bool * @var bool
*/ */
var $autofree = true; var $autofree = true;
/** /**
* XML Parser object * XML Parser object
* *
* @var object * @var object
* @access private * @access private
*/ */
var $parser; var $parser;
/** /**
* Error message * Error message
* *
* @var string * @var string
* @access private * @access private
*/ */
var $error = ''; var $error = '';
/** /**
* Element depth * Element depth
* @var int * @var int
* @access private * @access private
*/ */
var $depth = -1; var $depth = -1;
/** /**
* Element counter * Element counter
* @var int * @var int
* @access private * @access private
*/ */
var $count = 0; var $count = 0;
/** /**
* Path counter * Path counter
* @var int * @var int
* @access private * @access private
*/ */
var $pcount = 0; var $pcount = 0;
/** /**
* Array for creating the path * Array for creating the path
* @var array * @var array
* @access private * @access private
*/ */
var $paths = array(); var $paths = array();
/** /**
* Data storage container for the path data * Data storage container for the path data
* @var array * @var array
* @access private * @access private
*/ */
var $pathdata = array(); var $pathdata = array();
/** /**
* String storing the active path * String storing the active path
* @var string * @var string
* @access private * @access private
*/ */
var $activepath = ''; var $activepath = '';
/** /**
* The active node * The active node
* @var string * @var string
* @access private * @access private
*/ */
var $activenode = ''; var $activenode = '';
/** /**
* The defined events * The defined events
* @var array * @var array
* @access private * @access private
*/ */
var $events = array(); var $events = array();
/** /**
* Constructor function * Constructor function
* *
* @access private * @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 * @return void
*/ */
function XmlParser($sEncoding = false) function __construct($sEncoding = false) {
{ if (!$sEncoding) {
if (!$sEncoding) $sEncoding = "UTF-8";
{ }
$sEncoding = "UTF-8";
} $this->_init($sEncoding);
}
$this->_init($sEncoding);
}
/** /**
* Initialize the XML Parser object and sets all options * Initialize the XML Parser object and sets all options
* *
* @access private * @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 * @return void
*/ */
function _init($sEncoding = false) function _init($sEncoding = false) {
{ if (!$sEncoding) {
if (!$sEncoding) $sEncoding = "UTF-8";
{ }
$sEncoding = "UTF-8"; // Create parser instance
}
// Create parser instance
$this->parser = xml_parser_create($sEncoding); $this->parser = xml_parser_create($sEncoding);
// Set parser options // Set parser options
xml_set_object($this->parser, $this); 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_CASE_FOLDING, false);
xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $sEncoding); xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $sEncoding);
xml_set_element_handler($this->parser, '_startElement', '_endElement'); xml_set_element_handler($this->parser, '_startElement', '_endElement');
xml_set_character_data_handler($this->parser, '_characterData'); xml_set_character_data_handler($this->parser, '_characterData');
xml_set_processing_instruction_handler($this->parser, '_processingInstruction'); xml_set_processing_instruction_handler($this->parser, '_processingInstruction');
// Misc stuff
$this->events['paths'] = array(NULL);
}
/** // Misc stuff
* Returns the XML error message $this->events['paths'] = array(NULL);
* }
* @return string XML Error message
* @access private /**
*/ * Returns the XML error message
function _error() *
{ * @return string XML Error message
$this->error = "XML error: ".xml_error_string(xml_get_error_code($this->parser))." at line ".xml_get_current_line_number($this->parser); * @access private
return $this->error; */
} 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.) * Define events for the XML parser
* *
* Example: * 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.)
* 1.) $parser->setEvents(array("startElement" => "myFunction", *
* "endElement" => "myFunction", * Example:
* "characterData" => "myFunction", *
* "processingInstruction" => "myFunction"); * 1.) $parser->setEvents(array("startElement" => "myFunction",
* * "endElement" => "myFunction",
* The value can also be an array with the object reference and the method to call. * "characterData" => "myFunction",
* i.e. "startElement"=>array(&$myObj, "myMethod") instead of "startelement"=>"myFunction" * "processingInstruction" => "myFunction");
* *
* 2.) $parser->setEvents(array("/root/foo/bar"=>"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"
* 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 '/'. * 2.) $parser->setEvents(array("/root/foo/bar"=>"myFunction"));
* *
* The value can also be an array with the object reference and the method to call. * Valid array keys are: 'startElement', 'endElement', 'characterData', 'processingInstruction' and paths
* i.e. "/foo/bar"=>array(&$myObj, "myMethod") instead of "/foo/bar"=>"myFunction" * folowing the scheme '/root/element'. The path MUST begin from the root element and MUST start with '/'.
* *
* @param array Options array, valid keys are 'startElement', 'endElement', 'characterData', 'processingInstruction', or a path * 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"
* @access public *
* @return void * @param array Options array, valid keys are 'startElement', 'endElement', 'characterData', 'processingInstruction', or a path
*/ *
function setEventHandlers($options = array(NULL)) * @access public
{ * @return void
$options = $this->_changeKeyCase($options); */
function setEventHandlers($options = array(NULL)) {
if (array_key_exists('startelement', $options)) $options = $this->_changeKeyCase($options);
{
$this->events['startelement'] = $options['startelement']; if (array_key_exists('startelement', $options)) {
} $this->events['startelement'] = $options['startelement'];
}
if (array_key_exists('endelement', $options))
{ if (array_key_exists('endelement', $options)) {
$this->events['endelement'] = $options['endelement']; $this->events['endelement'] = $options['endelement'];
} }
if (array_key_exists('characterdata', $options)) if (array_key_exists('characterdata', $options)) {
{ $this->events['characterdata'] = $options['characterdata'];
$this->events['characterdata'] = $options['characterdata']; }
}
if (array_key_exists('processinginstruction', $options)) {
if (array_key_exists('processinginstruction', $options)) $this->events['processinginstruction'] = $options['processinginstruction'];
{ }
$this->events['processinginstruction'] = $options['processinginstruction'];
} $paths = $this->_getDefinedPaths($options);
$paths = $this->_getDefinedPaths($options); $this->events['paths'] = $paths;
}
$this->events['paths'] = $paths;
} /**
* Set the processing instruction handler
/** *
* Set the processing instruction handler * @param string Processing instruction handler
* *
* @param string Processing instruction handler * @return void
* * @access private
* @return void */
* @access private function _processingInstruction($parser, $target, $data) {
*/ $handler = $this->_getEventHandler('processinginstruction');
function _processingInstruction($parser, $target, $data)
{ if ($handler) {
$handler = $this->_getEventHandler('processinginstruction'); if (is_array($handler)) {
$handler[0]->$handler[1]($target, $data);
if ($handler) } else {
{ $handler($target, $data);
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
* Change all array keys to lowercase * @access private
* (PHP function change_key_case is available at PHP 4.2 +) */
* function _changeKeyCase($options = array()) {
* @param array Source array $tmp = array();
*
* @return array Array with lowercased keys foreach ($options as $key => $value) {
* @access private $tmp[strtolower($key)] = $value;
*/ }
function _changeKeyCase($options = array())
{ return $tmp;
$tmp = array(); }
foreach ($options as $key => $value) /**
{ * Returns events handlers if set
$tmp[strtolower($key)] = $value; *
} * @param string Event type
*
return $tmp; * @return sring Event handler name
} * @access private
*/
/** function _getEventHandler($event) {
* Returns events handlers if set // Standard events
* if (array_key_exists($event, $this->events)) {
* @param string Event type return $this->events[$event];
* }
* @return sring Event handler name
* @access private // Paths events
*/ if (array_key_exists($event, $this->events['paths'])) {
function _getEventHandler($event) return $this->events['paths'][$event];
{ }
// Standard events
if (array_key_exists($event, $this->events)) // No events found
{ return false;
return $this->events[$event]; }
}
/**
// Paths events * Return all defined paths from the options
if (array_key_exists($event, $this->events['paths'])) * array and returns a new array containing
{ * only the paths to function bindings
return $this->events['paths'][$event]; *
} * @param array Options array
*
// No events found * @return array Paths array
return false; * @access private
} */
function _getDefinedPaths($options) {
/** $tmp = array();
* Return all defined paths from the options
* array and returns a new array containing foreach ($options as $key => $value) {
* only the paths to function bindings if (strstr($key, '/')) {
* $tmp[$key] = $value;
* @param array Options array }
* }
* @return array Paths array
* @access private return $tmp;
*/ }
function _getDefinedPaths($options)
{ /**
$tmp = array(); * Add a path to the stack
*
foreach ($options as $key => $value) * @param string Element node name
{ * @access private
if (strstr($key, '/')) * @return void
{ */
$tmp[$key] = $value; function _addPath($depth, $name) {
} $this->paths[$depth] = $name;
} }
return $tmp; /**
} * Returns the current active path
*
/** * @access private
* Add a path to the stack */
* function _getActivePath() {
* @param string Element node name $tmp = array();
* @access private
* @return void for ($i = 0; $i <= $this->depth; $i++) {
*/ $tmp[] = $this->paths[$i];
function _addPath($depth, $name) }
{
$this->paths[$depth] = $name; $path = '/' . join('/', $tmp);
} return $path;
}
/**
* 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 * XML start element handler
* *
* @param resource XML Parser resource * @param resource XML Parser resource
* @param string XML Element node name * @param string XML Element node name
* @param array XML Element node attributes * @param array XML Element node attributes
* *
* @return void * @return void
* @access private * @access private
*/ */
function _startElement($parser, $name, $attribs) function _startElement($parser, $name, $attribs) {
{ // Increase depth
// Increase depth $this->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;
}
/** // Set active node
* Parse a XML file $this->activenode = $name;
*
* @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 // 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
?> ?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -28,484 +29,452 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
/** /**
* XmlTree class * XmlTree class
* *
* Class to create XML tree structures from * Class to create XML tree structures from
* scratch without the need for a XML DOM * scratch without the need for a XML DOM
* *
* Example: * Example:
* *
* !! Attention, using '=&' is deprecated in PHP >= 5.3 and causes a deprecated runtime error * !! Attention, using '=&' is deprecated in PHP >= 5.3 and causes a deprecated runtime error
* don't use it any more (Ortwin Pinke, 2010-07-03 * don't use it any more (Ortwin Pinke, 2010-07-03
* *
* $tree = new XmlTree('1.0', 'ISO-8859-1'); * $tree = new XmlTree('1.0', 'ISO-8859-1');
* $root =& $tree->addRoot('rootname', 'some content', array('foo'=>'bar')); * $root =& $tree->addRoot('rootname', 'some content', array('foo'=>'bar'));
* *
* This genererates following XML: * This genererates following XML:
* *
* <?xml version="1.0" encoding="ISO-8859-1"?> * <?xml version="1.0" encoding="ISO-8859-1"?>
* <rootname foo="bar">some content</rootname> * <rootname foo="bar">some content</rootname>
* *
* $root now references the 'rootname' node object. * $root now references the 'rootname' node object.
* To append childNodes use the appendChild method. * To append childNodes use the appendChild method.
* *
* $foo =& $root->appendChild('foo', 'bar'); * $foo =& $root->appendChild('foo', 'bar');
* *
* Note: From version 1.1 you can use the $obj->add() method * Note: From version 1.1 you can use the $obj->add() method
* as shortcut to appendchild * as shortcut to appendchild
* *
* <?xml version="1.0" encoding="ISO-8859-1"?> * <?xml version="1.0" encoding="ISO-8859-1"?>
* <rootname foo="bar">some content<foo>bar</foo></rootname> * <rootname foo="bar">some content<foo>bar</foo></rootname>
* *
* !! ALWAYS use '=&' with the addRoot and appendChild methods. !! * !! ALWAYS use '=&' with the addRoot and appendChild methods. !!
* *
*/ */
class XmlTree class XmlTree {
{
/** /**
* XML Version string * XML Version string
* @var string * @var string
* @access private * @access private
*/ */
var $_strXmlVersion; var $_strXmlVersion;
/** /**
* XML Encoding string * XML Encoding string
* @var string * @var string
* @access private * @access private
*/ */
var $_strXmlEncoding; var $_strXmlEncoding;
/** /**
* Root element name * Root element name
* @var string * @var string
* @access private * @access private
*/ */
var $_strRootName; var $_strRootName;
/** /**
* Root content * Root content
* @var string * @var string
* @access private * @access private
*/ */
var $_strRootContent; var $_strRootContent;
/** /**
* Root attributes * Root attributes
* @var array * @var array
* @access private * @access private
*/ */
var $_strRootAttribs; var $_strRootAttribs;
/** /**
* Root node * Root node
* @var object * @var object
* @access private * @access private
*/ */
var $_objRoot; var $_objRoot;
/** /**
* Tree XML string * Tree XML string
* @var string * @var string
* @access private * @access private
*/ */
var $_strXml; var $_strXml;
/** /**
* Indent character * Indent character
* @var string * @var string
* @access private * @access private
*/ */
var $_indentChar = ""; var $_indentChar = "";
/** /**
* Constructor * Constructor
* *
* @param string XML Version i.e. "1.0" * @param string XML Version i.e. "1.0"
* @param string XML Encoding i.e. "UTF-8" * @param string XML Encoding i.e. "UTF-8"
* *
* @return void * @return void
*/ */
function XmlTree($strXmlVersion = '1.0', $strXmlEncoding = 'UTF-8') function __construct($strXmlVersion = '1.0', $strXmlEncoding = 'UTF-8') {
{ $this->_strXmlVersion = 'version="' . $strXmlVersion . '"';
$this->_strXmlVersion = 'version="'.$strXmlVersion.'"'; $this->_strXmlEncoding = 'encoding="' . $strXmlEncoding . '"';
$this->_strXmlEncoding = 'encoding="'.$strXmlEncoding.'"'; }
}
/**
/** * Add a Root element to the XML Tree
* Add a Root element to the XML Tree *
* * @param string XML Node Name
* @param string XML Node Name * @param string XML Node Content
* @param string XML Node Content * @param array Attributes array('name'=>'value')
* @param array Attributes array('name'=>'value') *
* * @return object Reference to the root node object
* @return object Reference to the root node object */
*/ function &addRoot($strNodeName, $strNodeContent = '', $arrNodeAttribs = array()) {
function &addRoot($strNodeName, $strNodeContent = '', $arrNodeAttribs = array()) if (!$strNodeName) {
{ return 'XmlTree::addRoot() -> No node name specified';
if (!$strNodeName) }
{
return 'XmlTree::addRoot() -> No node name specified'; $this->_objRoot = new XmlNode($strNodeName, $strNodeContent, $arrNodeAttribs);
} return $this->_objRoot;
}
$this->_objRoot = new XmlNode($strNodeName, $strNodeContent, $arrNodeAttribs);
return $this->_objRoot; /**
} * Print or Return Tree XML
*
/** * @param boolean Return content
* Print or Return Tree XML *
* * @return string Tree XML
* @param boolean Return content */
* function dump($bolReturn = false) {
* @return string Tree XML if (!is_object($this->_objRoot)) {
*/ return 'XmlTree::dump() -> There is no root node';
function dump($bolReturn = false) }
{
if (!is_object($this->_objRoot)) $this->_objRoot->setIndent($this->_indentChar);
{ $this->_strXml = sprintf("<?xml %s %s?>\n", $this->_strXmlVersion, $this->_strXmlEncoding);
return 'XmlTree::dump() -> There is no root node'; $this->_strXml .= $this->_objRoot->toXml();
}
if ($bolReturn) {
$this->_objRoot->setIndent($this->_indentChar); return $this->_strXml;
$this->_strXml = sprintf("<?xml %s %s?>\n", $this->_strXmlVersion, $this->_strXmlEncoding); }
$this->_strXml .= $this->_objRoot->toXml();
echo $this->_strXml;
if ($bolReturn) }
{
return $this->_strXml; /**
} * Set the indent string
* @param int level
echo $this->_strXml; * @return void
} */
function setIndent($string) {
/** $this->_indentChar = $string;
* Set the indent string }
* @param int level
* @return void }
*/
function setIndent($string) // XmlTree
{
$this->_indentChar = $string;
}
} // XmlTree
/** /**
* XmlNode Object * XmlNode Object
* *
* Object of a XML Tree Node * Object of a XML Tree Node
* *
* @see XmlTree * @see XmlTree
* *
* !! ALWAYS use '=&' with the addRoot and appendChild methods. !! * !! ALWAYS use '=&' with the addRoot and appendChild methods. !!
* *
*/ */
class XmlNode 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<![CDATA[ ";
$content = $this->_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</" . $this->_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
?> /**
* 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<![CDATA[ ";
$content = $this->_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</" . $this->_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;
}
}

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -27,9 +28,8 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
/** /**
@ -49,8 +49,8 @@ if(!defined('CON_FRAMEWORK')) {
* $html = $xslt->process(); * $html = $xslt->process();
* *
*/ */
class XsltProcessor class XsltProcessor {
{
/** /**
* XSML Processor auto-free * XSML Processor auto-free
* @var bool * @var bool
@ -64,7 +64,7 @@ class XsltProcessor
* @access private * @access private
*/ */
var $error = ""; var $error = "";
/** /**
* Error number * Error number
* @var int * @var int
@ -78,14 +78,14 @@ class XsltProcessor
* @access private * @access private
*/ */
var $result = ""; var $result = "";
/** /**
* The XML String for the Transformation * The XML String for the Transformation
* @var string * @var string
* @access private * @access private
*/ */
var $xml = ""; var $xml = "";
/** /**
* The XSLT String for the Transformation * The XSLT String for the Transformation
* @var string * @var string
@ -99,103 +99,95 @@ class XsltProcessor
* @access private * @access private
*/ */
var $processor; var $processor;
/** /**
* XSLT Process arguments array * XSLT Process arguments array
* @var array * @var array
* @access private * @access private
*/ */
var $arguments = array(); var $arguments = array();
/** /**
* XSLT Process parameters array * XSLT Process parameters array
* @var array * @var array
* @access private * @access private
*/ */
var $parameters = array(); var $parameters = array();
/** /**
* Constructor * Constructor
* @access private * @access private
*/ */
function XsltProcessor() function __construct() {
{
$this->_init(); $this->_init();
} }
/** /**
* Initialize the class * Initialize the class
* @access private * @access private
* @return void * @return void
*/ */
function _init() function _init() {
{ if (!function_exists("xslt_create")) {
if (!function_exists("xslt_create")) die("Cannot instantiate XSLT Class \n XSLT not supported");
{
die ("Cannot instantiate XSLT Class \n XSLT not supported");
} }
$this->processor = xslt_create(); $this->processor = xslt_create();
} }
/** /**
* Translate literal to numeric entities to avoid * Translate literal to numeric entities to avoid
* the 'undefined entity error' that a literal * the 'undefined entity error' that a literal
* entity would cause. * entity would cause.
* *
* @param string XML String with literal entities * @param string XML String with literal entities
* @return string XML string with numeric entites * @return string XML string with numeric entites
* @access private * @access private
*/ */
function literal2NumericEntities($stringXml) { function literal2NumericEntities($stringXml) {
$literal2NumericEntity = array(); $literal2NumericEntity = array();
if (empty($literal2NumericEntity)) if (empty($literal2NumericEntity)) {
{
$transTbl = clGetHtmlTranslationTable(HTML_ENTITIES); $transTbl = clGetHtmlTranslationTable(HTML_ENTITIES);
foreach ($transTbl as $char => $entity) foreach ($transTbl as $char => $entity) {
{ if (strpos('&"<>', $char) !== FALSE)
if (strpos('&"<>', $char) !== FALSE) continue; continue;
$literal2NumericEntity[$entity] = '&#'.ord($char).';'; $literal2NumericEntity[$entity] = '&#' . ord($char) . ';';
} }
} }
return strtr($stringXml, $literal2NumericEntity); return strtr($stringXml, $literal2NumericEntity);
} }
/** /**
* Set the XML to be Transformed * Set the XML to be Transformed
* @param string The XML String * @param string The XML String
* @return void * @return void
* @access public * @access public
*/ */
function setXml($xml) function setXml($xml) {
{
$this->arguments["/_xml"] = $this->literal2NumericEntities($xml); $this->arguments["/_xml"] = $this->literal2NumericEntities($xml);
} }
/** /**
* Set the XSLT for the Transformation * Set the XSLT for the Transformation
* @param string The XML String * @param string The XML String
* @return void * @return void
* @access public * @access public
*/ */
function setXsl($xsl) function setXsl($xsl) {
{
$this->arguments["/_xsl"] = $this->literal2NumericEntities($xsl); $this->arguments["/_xsl"] = $this->literal2NumericEntities($xsl);
} }
/** /**
* Set the XML-File to be Transformed * Set the XML-File to be Transformed
* @param string Location of the XML file * @param string Location of the XML file
* @return void * @return void
* @access public * @access public
*/ */
function setXmlFile($file) function setXmlFile($file) {
{
$xml = $this->readFromFile($file); $xml = $this->readFromFile($file);
$this->arguments["/_xml"] = $this->literal2NumericEntities($xml); $this->arguments["/_xml"] = $this->literal2NumericEntities($xml);
} }
@ -204,136 +196,123 @@ class XsltProcessor
* Set the XSL-File for the Transformation * Set the XSL-File for the Transformation
* @param string Location of the XSL file * @param string Location of the XSL file
* @return void * @return void
* @access public * @access public
*/ */
function setXslFile($file) function setXslFile($file) {
{
$xsl = $this->readFromFile($file); $xsl = $this->readFromFile($file);
$this->arguments["/_xsl"] = $this->literal2NumericEntities($xsl); $this->arguments["/_xsl"] = $this->literal2NumericEntities($xsl);
} }
/** /**
* Return the contents of a file if * Return the contents of a file if
* the passed parameter is a file. * the passed parameter is a file.
* *
* @param string File location * @param string File location
* @return string File contents * @return string File contents
* @access private * @access private
*/ */
function readFromFile($file) function readFromFile($file) {
{ if (file_exists($file)) {
if (file_exists($file))
{
$data = file($file); $data = file($file);
$data = join($data, ""); $data = join($data, "");
return $data; return $data;
} }
die ("<span style=\"color: red\"><b>ERROR:</b></span> File not found: <b>$file</b>"); die("<span style=\"color: red\"><b>ERROR:</b></span> File not found: <b>$file</b>");
} }
/** /**
* Pass top level parameters to the XSLT processor. * Pass top level parameters to the XSLT processor.
* The parameters can be accessed in XSL * The parameters can be accessed in XSL
* with <xsl:param name="paramname"/> * with <xsl:param name="paramname"/>
* *
* @param string Name * @param string Name
* @param string Value * @param string Value
* @return void * @return void
*/ */
function setParam($name, $value) function setParam($name, $value) {
{
$this->parameters[$name] = utf8_encode($value); $this->parameters[$name] = utf8_encode($value);
} }
/** /**
* Define external scheme handlers for the XSLT Processor. * Define external scheme handlers for the XSLT Processor.
* *
* Example param array: * Example param array:
* *
* array("get_all", "mySchemeHandler") * array("get_all", "mySchemeHandler")
* *
* Example scheme handler function: * Example scheme handler function:
* *
* function mySchemeHandler($processor, $scheme, $param) * function mySchemeHandler($processor, $scheme, $param)
* { * {
* // to remove the first slash added by Sablotron * // to remove the first slash added by Sablotron
* $param = substr($param, 1); * $param = substr($param, 1);
* *
* if ($scheme == 'file_exists') * if ($scheme == 'file_exists')
* { // result is returned as valid xml string * { // result is returned as valid xml string
* return '<?xml version="1.0" encoding="UTF-8"?><root>'.(file_exists($param) ? "true" : "false")."</root>"; * return '<?xml version="1.0" encoding="UTF-8"?><root>'.(file_exists($param) ? "true" : "false")."</root>";
* } * }
* } * }
* *
* To use the schema handler use: * To use the schema handler use:
* <xsl:if test="document('file_exists:somefile.xml<6D>)/root = 'true'"> * <xsl:if test="document('file_exists:somefile.xml<6D>)/root = 'true'">
* do something * do something
* </xsl:if> * </xsl:if>
* *
* To call the external function use the 'document()' XSLT-Function. * To call the external function use the 'document()' XSLT-Function.
* *
* <xsl:value-of select="document('schemename:parameter')/root"/> * <xsl:value-of select="document('schemename:parameter')/root"/>
* *
* Schemename and parameter will be passed to the handler function as second and third parameter. * 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. * The return value of the function must be valid XML to access it using XPath.
* *
* @param array array("scheme"=>"schemeHandlerName"); * @param array array("scheme"=>"schemeHandlerName");
* @return void * @return void
* @access public * @access public
*/ */
function setSchemeHandlers($aHandlers) function setSchemeHandlers($aHandlers) {
{ xslt_set_scheme_handlers($this->processor, $aHandlers);
xslt_set_scheme_handlers($this->processor, $aHandlers); }
}
/** /**
* Transform the XML data using the XSL and * Transform the XML data using the XSL and
* return the results of the transformation * return the results of the transformation
* *
* @return string Transformed data * @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->result = xslt_process($this->processor, "arg:/_xml", "arg:/_xsl", NULL, $this->arguments, $this->parameters);
$this->error = xslt_error($this->processor); $this->error = xslt_error($this->processor);
$this->errno = xslt_errno($this->processor); $this->errno = xslt_errno($this->processor);
if ($this->autofree) if ($this->autofree) {
{
xslt_free($this->processor); xslt_free($this->processor);
} }
return $this->result; return $this->result;
} }
/** /**
* Prints the Error message and number * Prints the Error message and number
* if an error occured * if an error occured
* *
* @return void * @return void
* @access public * @access public
*/ */
function printErrors() function printErrors() {
{ if ($this->errno > 0) {
if ($this->errno > 0) echo "<b>Error Number: </b><span style=\"color:red\">" . $this->errno . "</span> ";
{ echo "<b>Error Message: </b><span style=\"color:red\">" . $this->error . "</span>";
echo "<b>Error Number: </b><span style=\"color:red\">".$this->errno."</span> ";
echo "<b>Error Message: </b><span style=\"color:red\">".$this->error."</span>";
} }
} }
/** /**
* Manual free of the parser * Manual free of the parser
* @return void * @return void
*/ */
function free() function free() {
{
xslt_free($this->processor); xslt_free($this->processor);
} }
}
} // XSLT_Processor
?>

Datei anzeigen

@ -37,12 +37,6 @@ class cApiModuleCollection extends ItemCollection {
$this->_setItemClass("cApiModule"); $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 * Creates a new communication item
*/ */

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -23,66 +24,59 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
define("cDatatypeCurrency_Left", 1); define("cDatatypeCurrency_Left", 1);
define("cDatatypeCurrency_Right", 2); define("cDatatypeCurrency_Right", 2);
class cDatatypeCurrency extends cDatatypeNumber class cDatatypeCurrency extends cDatatypeNumber {
{
var $_cCurrencyLocation; var $_cCurrencyLocation;
var $_sCurrencySymbol; var $_sCurrencySymbol;
function cDatatypeCurrency () function __construct() {
{ cDatatypeNumber::__construct();
cDatatypeNumber::cDataTypeNumber();
$this->setCurrencySymbolLocation(cDatatypeCurrency_Right);
$this->setCurrencySymbolLocation(cDatatypeCurrency_Right); $this->setCurrencySymbol("<EFBFBD>");
$this->setCurrencySymbol("<EFBFBD>"); }
}
function setCurrencySymbol($sSymbol) {
function setCurrencySymbol ($sSymbol) $this->_sCurrencySymbol = $sSymbol;
{ }
$this->_sCurrencySymbol = $sSymbol;
} function getCurrencySymbol() {
return ($this->_sCurrencySymbol);
function getCurrencySymbol () }
{
return ($this->_sCurrencySymbol); function setCurrencySymbolLocation($cLocation) {
} switch ($cLocation) {
case cDatatypeCurrency_Left:
function setCurrencySymbolLocation ($cLocation) case cDatatypeCurrency_Right:
{ $this->_cCurrencyLocation = $cLocation;
switch ($cLocation) break;
{ default:
case cDatatypeCurrency_Left: cWarning(__FILE__, __LINE__, "Warning: No valid cDatatypeCurrency_* Constant given. Available values: cDatatypeCurrency_Left, cDatatypeCurrency_Right");
case cDatatypeCurrency_Right: return;
$this->_cCurrencyLocation = $cLocation; break;
break; }
default: }
cWarning(__FILE__, __LINE__, "Warning: No valid cDatatypeCurrency_* Constant given. Available values: cDatatypeCurrency_Left, cDatatypeCurrency_Right");
return; function render() {
break; $value = parent::render();
}
} switch ($this->_cCurrencyLocation) {
case cDatatypeCurrency_Left:
function render () return sprintf("%s %s", $this->_sCurrencySymbol, $value);
{ break;
$value = parent::render(); case cDatatypeCurrency_Right:
return sprintf("%s %s", $value, $this->_sCurrencySymbol);
switch ($this->_cCurrencyLocation) break;
{ }
case cDatatypeCurrency_Left: }
return sprintf("%s %s", $this->_sCurrencySymbol, $value);
break;
case cDatatypeCurrency_Right:
return sprintf("%s %s", $value, $this->_sCurrencySymbol);
break;
}
}
} }
?> ?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -25,18 +26,17 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
/* The UNIX Timestamp is the amount of seconds /* The UNIX Timestamp is the amount of seconds
passed since Jan 1 1970 00:00:00 GMT */ passed since Jan 1 1970 00:00:00 GMT */
define("cDateTime_UNIX" , 1); define("cDateTime_UNIX", 1);
/* The ISO Date format is CCYY-MM-DD HH:mm:SS */ /* The ISO Date format is CCYY-MM-DD HH:mm:SS */
define("cDateTime_ISO" , 2); define("cDateTime_ISO", 2);
/* The locale format, as specified in the Contenido backend */ /* The locale format, as specified in the Contenido backend */
define("cDateTime_Locale", 3); define("cDateTime_Locale", 3);
@ -48,10 +48,10 @@ define("cDateTime_Locale_TimeOnly", 4);
define("cDateTime_Locale_DateOnly", 5); define("cDateTime_Locale_DateOnly", 5);
/* The MySQL Timestamp is CCYYMMDDHHmmSS */ /* The MySQL Timestamp is CCYYMMDDHHmmSS */
define("cDateTime_MySQL" , 6); define("cDateTime_MySQL", 6);
/* Custom format */ /* Custom format */
define("cDateTime_Custom" , 99); define("cDateTime_Custom", 99);
define("cDateTime_Sunday", 0); define("cDateTime_Sunday", 0);
define("cDateTime_Monday", 1); define("cDateTime_Monday", 1);
@ -61,516 +61,462 @@ define("cDateTime_Thursday", 4);
define("cDateTime_Friday", 5); define("cDateTime_Friday", 5);
define("cDateTime_Saturday", 6); define("cDateTime_Saturday", 6);
class cDatatypeDateTime extends cDatatype class cDatatypeDateTime extends cDatatype {
{
var $_iFirstDayOfWeek;
/* This datatype stores its date format in ISO */
function cDatatypeDateTime ()
{
$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::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);
}
function setMonth ($iMonth) var $_iFirstDayOfWeek;
{
$this->_iMonth = $iMonth;
}
function getMonth ()
{
return ($this->_iMonth);
}
function setDay ($iDay)
{
$this->_iDay = $iDay;
}
function getDay ()
{
return ($this->_iDay);
}
function getMonthName ($iMonth) /* This datatype stores its date format in ISO */
{
switch ($iMonth) function __construct() {
{ $this->setTargetFormat(cDateTime_Locale);
case 1: return i18n("January"); $this->setSourceFormat(cDateTime_UNIX);
case 2: return i18n("February");
case 3: return i18n("March"); $this->_iYear = 1970;
case 4: return i18n("April"); $this->_iMonth = 1;
case 5: return i18n("May"); $this->_iDay = 1;
case 6: return i18n("June"); $this->_iHour = 0;
case 7: return i18n("July"); $this->_iMinute = 0;
case 8: return i18n("August"); $this->_iSecond = 0;
case 9: return i18n("September");
case 10: return i18n("October"); $this->setFirstDayOfWeek(cDateTime_Monday);
case 11: return i18n("November"); parent::__construct();
case 12: return i18n("December"); }
}
} function setCustomTargetFormat($targetFormat) {
$this->_sCustomTargetFormat = $targetFormat;
function getDayName ($iDayOfWeek) }
{
switch ($iDayOfWeek) function setCustomSourceFormat($sourceFormat) {
{ $this->_sCustomSourceFormat = $sourceFormat;
case 0: return i18n("Sunday"); }
case 1: return i18n("Monday");
case 2: return i18n("Tuesday"); function setSourceFormat($cSourceFormat) {
case 3: return i18n("Wednesday"); $this->_cSourceFormat = $cSourceFormat;
case 4: return i18n("Thursday"); }
case 5: return i18n("Friday");
case 6: return i18n("Saturday"); function setTargetFormat($cTargetFormat) {
case 7: return i18n("Sunday"); $this->_cTargetFormat = $cTargetFormat;
default: return false; }
}
} function setYear($iYear) {
$this->_iYear = $iYear;
function getDayOrder () }
{
$aDays = array(0, 1, 2, 3, 4, 5, 6); function getYear() {
$aRemainderDays = array_splice($aDays, 0, $this->_iFirstDayOfWeek); return ($this->_iYear);
}
$aReturnDays = array_merge($aDays, $aRemainderDays);
function setMonth($iMonth) {
return ($aReturnDays); $this->_iMonth = $iMonth;
} }
function getNumberOfMonthDays ($iMonth = false, $iYear = false) function getMonth() {
{ return ($this->_iMonth);
if ($iMonth === false) }
{
$iMonth = $this->_iMonth; function setDay($iDay) {
} $this->_iDay = $iDay;
}
if ($iYear === false)
{ function getDay() {
$iYear = $this->_iYear; return ($this->_iDay);
} }
return date("t", mktime(0,0,0,$iMonth, 1, $iYear)); function getMonthName($iMonth) {
} switch ($iMonth) {
case 1: return i18n("January");
function setFirstDayOfWeek ($iDay) case 2: return i18n("February");
{ case 3: return i18n("March");
$this->_iFirstDayOfWeek = $iDay; case 4: return i18n("April");
} case 5: return i18n("May");
case 6: return i18n("June");
function getFirstDayOfWeek () case 7: return i18n("July");
{ case 8: return i18n("August");
return $this->_iFirstDayOfWeek; case 9: return i18n("September");
} case 10: return i18n("October");
case 11: return i18n("November");
function getLeapDay () case 12: return i18n("December");
{ }
return end($this->getDayOrder()); }
}
function getDayName($iDayOfWeek) {
function set ($value, $iOverrideFormat = false) switch ($iDayOfWeek) {
{ case 0: return i18n("Sunday");
if ($value == "") case 1: return i18n("Monday");
{ case 2: return i18n("Tuesday");
return; case 3: return i18n("Wednesday");
} case 4: return i18n("Thursday");
case 5: return i18n("Friday");
if ($iOverrideFormat !== false) case 6: return i18n("Saturday");
{ case 7: return i18n("Sunday");
$iFormat = $iOverrideFormat; default: return false;
} else { }
$iFormat = $this->_cSourceFormat; }
}
function getDayOrder() {
switch ($iFormat) $aDays = array(0, 1, 2, 3, 4, 5, 6);
{ $aRemainderDays = array_splice($aDays, 0, $this->_iFirstDayOfWeek);
case cDateTime_UNIX:
$sTemporaryTimestamp = $value; $aReturnDays = array_merge($aDays, $aRemainderDays);
$this->_iYear = date("Y", $sTemporaryTimestamp);
$this->_iMonth = date("m", $sTemporaryTimestamp); return ($aReturnDays);
$this->_iDay = date("d", $sTemporaryTimestamp); }
$this->_iHour = date("H", $sTemporaryTimestamp);
$this->_iMinute = date("i", $sTemporaryTimestamp); function getNumberOfMonthDays($iMonth = false, $iYear = false) {
$this->_iSecond = date("s", $sTemporaryTimestamp); if ($iMonth === false) {
$iMonth = $this->_iMonth;
break; }
case cDateTime_ISO:
$sTemporaryTimestamp = strtotime($value); if ($iYear === false) {
$this->_iYear = date("Y", $sTemporaryTimestamp); $iYear = $this->_iYear;
$this->_iMonth = date("m", $sTemporaryTimestamp); }
$this->_iDay = date("d", $sTemporaryTimestamp);
$this->_iHour = date("H", $sTemporaryTimestamp); return date("t", mktime(0, 0, 0, $iMonth, 1, $iYear));
$this->_iMinute = date("i", $sTemporaryTimestamp); }
$this->_iSecond = date("s", $sTemporaryTimestamp);
break; 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: case cDateTime_MySQL:
$sTimeformat = 'YmdHis'; $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 */ $targetFormat = str_replace('.', '\.', $sTimeformat);
preg_match('/' . $targetFormat . '/', $value, $dateRegs); $targetFormat = str_replace('d', '([0-9]{2,2})', $targetFormat);
$targetFormat = str_replace('m', '([0-9]{2,2})', $targetFormat);
$finalDate = array(); $targetFormat = str_replace('Y', '([0-9]{4,4})', $targetFormat);
$targetFormat = str_replace('H', '([0-9]{2,2})', $targetFormat);
/* Map date entries to placeholders */ $targetFormat = str_replace('i', '([0-9]{2,2})', $targetFormat);
foreach ($placeholderRegs[0] as $key => $placeholderReg) $targetFormat = str_replace('s', '([0-9]{2,2})', $targetFormat);
{ /* Match the placeholders */
if (isset($dateRegs[$key])) preg_match_all('/([a-zA-Z])/', $sTimeformat, $placeholderRegs);
{
$finalDate[$placeholderReg] = $dateRegs[$key+1];
}
}
/* Assign placeholders + data to the object's member variables */ /* Match the date values */
foreach ($finalDate as $placeHolder => $value) preg_match('/' . $targetFormat . '/', $value, $dateRegs);
{
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);
$finalDate = array();
/* 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];
}
}
/* Assign placeholders + data to the object's member variables */ /* Map date entries to placeholders */
foreach ($finalDate as $placeHolder => $value) foreach ($placeholderRegs[0] as $key => $placeholderReg) {
{ if (isset($dateRegs[$key])) {
switch ($placeHolder) $finalDate[$placeholderReg] = $dateRegs[$key + 1];
{ }
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: /* Assign placeholders + data to the object's member variables */
$sTimeformat = getEffectiveSetting("backend", "timeformat_date", "Y-m-d"); foreach ($finalDate as $placeHolder => $value) {
switch ($placeHolder) {
return date($sTimeformat, mktime($this->_iHour, $this->_iMinute, $this->iSecond, $this->_iMonth, $this->_iDay, $this->_iYear)); case "d":
case cDateTime_Locale: $this->_iDay = $value;
$sTimeformat = getEffectiveSetting("backend", "timeformat", "Y-m-d H:i:s"); break;
case "m":
return date($sTimeformat, mktime($this->_iHour, $this->_iMinute, $this->iSecond, $this->_iMonth, $this->_iDay, $this->_iYear)); $this->_iMonth = $value;
case cDateTime_Custom: break;
return strftime($this->_sCustomTargetFormat, mktime($this->_iHour, $this->_iMinute, $this->_iSecond, $this->_iMonth, $this->_iDay, $this->_iYear)); 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;
}
} break;
case cDateTime_Custom:
function parse ($value) /* Build a regular expression */
{
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 */ $sourceFormat = str_replace('.', '\.', $this->_sCustomSourceFormat);
preg_match('/' . $targetFormat . '/', $value, $dateRegs); $sourceFormat = str_replace('%d', '([0-9]{2,2})', $sourceFormat);
$sourceFormat = str_replace('%m', '([0-9]{2,2})', $sourceFormat);
$finalDate = array(); $sourceFormat = str_replace('%Y', '([0-9]{4,4})', $sourceFormat);
/* 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 */ /* Match the placeholders */
foreach ($finalDate as $placeHolder => $value) preg_match_all('/(%[a-zA-Z])/', $this->_sCustomSourceFormat, $placeholderRegs);
{
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 */ /* Match the date values */
foreach ($finalDate as $placeHolder => $value) preg_match('/' . $sourceFormat . '/', $value, $dateRegs);
{
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 */ $finalDate = array();
preg_match('/' . $targetFormat . '/', $value, $dateRegs);
/* Map date entries to placeholders */
$finalDate = array(); foreach ($placeholderRegs[0] as $key => $placeholderReg) {
if (isset($dateRegs[$key])) {
/* Map date entries to placeholders */ $finalDate[$placeholderReg] = $dateRegs[$key + 1];
foreach ($placeholderRegs[0] as $key => $placeholderReg) }
{ }
if (isset($dateRegs[$key]))
{ /* Assign placeholders + data to the object's member variables */
$finalDate[$placeholderReg] = $dateRegs[$key+1]; 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;
}
}
} }
?> ?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -25,84 +26,73 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
class cDatatypeNumber extends cDatatype {
var $_iPrecision;
var $_sThousandSeparatorCharacter;
var $_sDecimalPointCharacter;
function __construct() {
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::__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);
}
} }
?> ?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -25,46 +26,46 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
class cDatatype class cDatatype {
{ /* Effective value */
/* Effective value */
var $_mValue; var $_mValue;
/* Displayed value */ /* Displayed value */
var $_mDisplayedValue; var $_mDisplayedValue;
function cDatatype () function __construct() {
{
} }
/* Sets this datatype to a specific value */ /* Sets this datatype to a specific value */
function set ($value)
{ function set($value) {
} }
/* Parses the given value to transfer into the datatype's format */ /* Parses the given value to transfer into the datatype's format */
function parse ($value)
{ function parse($value) {
} }
/* Returns the effective value */ /* Returns the effective value */
function get ()
{ function get() {
} }
/* Renders the displayed value */ /* Renders the displayed value */
function render ()
{ function render() {
} }
} }
?> ?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* class.template.php * class.template.php
* *
@ -20,9 +21,8 @@
* @link http://www.contenido.org * @link http://www.contenido.org
* @since file available since contenido release <= 4.6 * @since file available since contenido release <= 4.6
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
/** /**
@ -36,84 +36,73 @@ if(!defined('CON_FRAMEWORK')) {
* @version 1.0 * @version 1.0
*/ */
class Template { class Template {
/** /**
* Needles (static) * Needles (static)
* @var array * @var array
*/ */
public $needles = array (); public $needles = array();
/** /**
* Replacements (static) * Replacements (static)
* @var array * @var array
*/ */
public $replacements = array (); public $replacements = array();
/** /**
* Dyn_Needles (dynamic) * Dyn_Needles (dynamic)
* @var array * @var array
*/ */
public $Dyn_needles = array (); public $Dyn_needles = array();
/** /**
* Dyn_Replacements (dynamic) * Dyn_Replacements (dynamic)
* @var array * @var array
*/ */
public $Dyn_replacements = array (); public $Dyn_replacements = array();
/** /**
* Dynamic counter * Dynamic counter
* @var int * @var int
*/ */
public $dyn_cnt = 0; public $dyn_cnt = 0;
/** /**
* Tags array (for dynamic blocks); * Tags array (for dynamic blocks);
* @var array * @var array
*/ */
public $tags = array ('static' => '{%s}', 'start' => '<!-- BEGIN:BLOCK -->', 'end' => '<!-- END:BLOCK -->'); public $tags = array('static' => '{%s}', 'start' => '<!-- BEGIN:BLOCK -->', 'end' => '<!-- END:BLOCK -->');
/** /**
* gettext domain (default: contenido) * gettext domain (default: contenido)
* @var string * @var string
*/ */
protected $_sDomain = "conlite"; protected $_sDomain = "conlite";
var $array_registeredParsers = array(); var $array_registeredParsers = array();
/** /**
* Constructor * Constructor
* *
* @param array $tags * @param array $tags
* @return void * @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 # Needed to block parsers in ConLite's backend and the module-template editor
global $contenido, $changeview; global $contenido, $changeview;
if (is_array($tags)) { if (is_array($tags)) {
$this->tags = $tags; $this->tags = $tags;
} }
$this->setEncoding(""); $this->setEncoding("");
if(is_array($parser)) { if (is_array($parser)) {
$this->array_registeredParsers = $parser; $this->array_registeredParsers = $parser;
} elseif ((!isset($contenido)) || ($changeview == 'edit') || ($changeview == 'prev')) { } elseif ((!isset($contenido)) || ($changeview == 'edit') || ($changeview == 'prev')) {
$this->array_registeredParsers = array( $this->array_registeredParsers = array(
new clStrAPIFunctionsParser(), new clStrAPIFunctionsParser(),
new clCounterFunctionParser(), new clCounterFunctionParser(),
new clIfFunctionParser() 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 * @param string $sDomain Sets the domain to use for template translations
* @return void * @return void
*/ */
public function setDomain($sDomain) { public function setDomain($sDomain) {
$this->_sDomain = $sDomain; $this->_sDomain = $sDomain;
} }
/** /**
* Set Templates placeholders and values * Set Templates placeholders and values
* *
@ -154,11 +143,11 @@ class Template {
* Sets an encoding for the template's head block. * Sets an encoding for the template's head block.
* *
* @param string $encoding Encoding to set * @param string $encoding Encoding to set
*/ */
public function setEncoding($encoding) { public function setEncoding($encoding) {
$this->_encoding = $encoding; $this->_encoding = $encoding;
} }
/** /**
* Iterate internal counter by one * Iterate internal counter by one
* *
@ -175,10 +164,10 @@ class Template {
*/ */
public function reset() { public function reset() {
$this->dyn_cnt = 0; $this->dyn_cnt = 0;
$this->needles = array (); $this->needles = array();
$this->replacements = array (); $this->replacements = array();
$this->Dyn_needles = array (); $this->Dyn_needles = array();
$this->Dyn_replacements = array (); $this->Dyn_replacements = array();
} }
/** /**
@ -193,27 +182,27 @@ class Template {
*/ */
public function generate($template, $return = 0, $note = 0) { public function generate($template, $return = 0, $note = 0) {
global $cCurrentModule; global $cCurrentModule;
$cfg = cRegistry::getConfig(); $cfg = cRegistry::getConfig();
$aCfgClient = cRegistry::getClientConfig(cRegistry::getClientId()); $aCfgClient = cRegistry::getClientConfig(cRegistry::getClientId());
$bModTplUsed = FALSE; $bModTplUsed = FALSE;
if(isset($cCurrentModule) && $cfg['dceModEdit']['use']) { if (isset($cCurrentModule) && $cfg['dceModEdit']['use']) {
cInclude('includes', 'functions.upl.php'); cInclude('includes', 'functions.upl.php');
$tmpModule = new cApiModule; $tmpModule = new cApiModule;
$tmpModule->loadByPrimaryKey($cCurrentModule); $tmpModule->loadByPrimaryKey($cCurrentModule);
$sModName = strtolower(uplCreateFriendlyName($tmpModule->get('name'))); $sModName = strtolower(uplCreateFriendlyName($tmpModule->get('name')));
$aModFileEditConf = $tmpModule->getModFileEditConf(); $aModFileEditConf = $tmpModule->getModFileEditConf();
unset($tmpModule); unset($tmpModule);
$sTmpPath = $aModFileEditConf['modPath'].$sModName."/template/".$template; $sTmpPath = $aModFileEditConf['modPath'] . $sModName . "/template/" . $template;
if(is_readable($sTmpPath)) { if (is_readable($sTmpPath)) {
$template = $sTmpPath; $template = $sTmpPath;
$bModTplUsed = TRUE; $bModTplUsed = TRUE;
} }
} }
if(is_file("templates/".$template) && !$bModTplUsed) { if (is_file("templates/" . $template) && !$bModTplUsed) {
$template = "templates/".$template; $template = "templates/" . $template;
} }
//check if the template is a file or a string //check if the template is a file or a string
@ -222,53 +211,52 @@ class Template {
} else { } else {
$content = implode("", file($template)); //template is a file $content = implode("", file($template)); //template is a file
} }
$content = (($note) ? "<!-- Generated by ConLite ".$cfg['version']."-->\n" : "").$content; $content = (($note) ? "<!-- Generated by ConLite " . $cfg['version'] . "-->\n" : "") . $content;
$pieces = array(); $pieces = array();
//replace i18n strings before replacing other placeholders //replace i18n strings before replacing other placeholders
$this->replacei18n($content, "i18n"); $this->replacei18n($content, "i18n");
$this->replacei18n($content, "trans"); $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 //start block
$content .= str_replace($this->needles, $this->replacements, $pieces[0][0]); $content .= str_replace($this->needles, $this->replacements, $pieces[0][0]);
unset ($pieces[0][0]); unset($pieces[0][0]);
//generate dynamic blocks //generate dynamic blocks
for ($a = 0; $a < $this->dyn_cnt; $a ++) { for ($a = 0; $a < $this->dyn_cnt; $a ++) {
$content .= str_replace($this->Dyn_needles[$a], $this->Dyn_replacements[$a], $pieces[1][0]); $content .= str_replace($this->Dyn_needles[$a], $this->Dyn_replacements[$a], $pieces[1][0]);
} }
unset ($pieces[1][0]); unset($pieces[1][0]);
//end block //end block
$content .= str_replace($this->needles, $this->replacements, $pieces[2][0]); $content .= str_replace($this->needles, $this->replacements, $pieces[2][0]);
unset ($pieces[2][0]); unset($pieces[2][0]);
} else { } else {
$content = str_replace($this->needles, $this->replacements, $content); $content = str_replace($this->needles, $this->replacements, $content);
} }
if ($this->_encoding != "") { if ($this->_encoding != "") {
$content = str_replace("</head>", '<meta http-equiv="Content-Type" content="text/html; charset='.$this->_encoding.'">'."\n".'</head>', $content); $content = str_replace("</head>", '<meta http-equiv="Content-Type" content="text/html; charset=' . $this->_encoding . '">' . "\n" . '</head>', $content);
} }
# ExtendedTemplate # ExtendedTemplate
if (count($this->array_registeredParsers)) { if (count($this->array_registeredParsers)) {
foreach($this->array_registeredParsers as $class) { foreach ($this->array_registeredParsers as $class) {
if (is_string($class)) { if (is_string($class)) {
$classInstance = new $class; $classInstance = new $class;
} elseif(is_object($class)) { } elseif (is_object($class)) {
$classInstance = $class; $classInstance = $class;
} }
if (is_object($classInstance)) { if (is_object($classInstance)) {
if (is_subclass_of($classInstance, "clAbstractTemplateParser")) { if (is_subclass_of($classInstance, "clAbstractTemplateParser")) {
$content = $classInstance->parse($content); $content = $classInstance->parse($content);
@ -279,15 +267,17 @@ class Template {
} }
} }
} }
if ($return) { if ($return) {
return $content; return $content;
} else { } else {
echo $content; echo $content;
} }
} # end function }
/** # end function
/**
* replacei18n() * replacei18n()
* *
* Replaces a named function with the translated variant * 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 $template Contents of the template to translate (it is reference to save memory!!!)
* @param string $functionName Name of the translation function (e.g. i18n) * @param string $functionName Name of the translation function (e.g. i18n)
* @return void * @return void
*/ */
public function replacei18n(& $template, $functionName) { public function replacei18n(& $template, $functionName) {
$container = array(); $container = array();
// Be sure that php code stays unchanged // Be sure that php code stays unchanged
@ -304,37 +294,40 @@ class Template {
$x = 0; $x = 0;
foreach ($php_matches[0] as $php_match) { foreach ($php_matches[0] as $php_match) {
$x++; $x++;
$template = str_replace($php_match , "{PHP#".$x."#PHP}", $template); $template = str_replace($php_match, "{PHP#" . $x . "#PHP}", $template);
$container[$x] = $php_match; $container[$x] = $php_match;
} }
} }
// If template contains functionName + parameter store all matches // If template contains functionName + parameter store all matches
$matches = array(); $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 // Execute the translation code
$matches = array_values(array_unique($matches[2])); $matches = array_values(array_unique($matches[2]));
for ($a = 0; $a < count($matches); $a ++) { 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 // Change back php placeholder
if (count($container)) { if (count($container)) {
foreach ($container as $x => $php_match) { foreach ($container as $x => $php_match) {
// If php code contains functionName + parameter store all matches // If php code contains functionName + parameter store all matches
$matches = array(); $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 // Execute the translation code
$matches = array_values(array_unique($matches[2])); $matches = array_values(array_unique($matches[2]));
for ($a = 0; $a < count($matches); $a ++) { 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
?> ?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -25,45 +26,39 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
/** /**
* class cTree * class cTree
* *
*/ */
class cTree extends cTreeItem class cTree extends cTreeItem {
{
var $_treeIcon;
function cTree ($name = "")
{
/* The root item currently has to be a "0".
* This is a bug, feel free to fix it. */
cTreeItem::cTreeItem(0,$name);
}
/**
* 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 ) var $_treeIcon;
{
$this->_treeIcon = $path;
}
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;
}
}

Datei-Diff unterdrückt, da er zu groß ist Diff laden

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -25,28 +26,28 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
class cViewAdvancedMenu {
function __construct() {
}
function render() {
}
class cViewAdvancedMenu
{
function cViewAdvancedMenu ()
{
}
function render ()
{
}
} }
class cViewItems extends cHTMLIFrame {
function __construct() {
}
class cViewItems extends cHTMLIFrame
{
function cViewItems()
{
}
} }
?> ?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -26,14 +27,13 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) { if (!defined('CON_FRAMEWORK')) {
die('Illegal call'); die('Illegal call');
} }
define("QUESTIONACTION_PROMPT", "prompt"); define("QUESTIONACTION_PROMPT", "prompt");
define("QUESTIONACTION_YESNO" , "yesno"); define("QUESTIONACTION_YESNO", "yesno");
/** /**
* class cApiClickableAction * class cApiClickableAction
@ -42,10 +42,8 @@ define("QUESTIONACTION_YESNO" , "yesno");
* their constructors; on-the-fly-implementations should call it directly after * their constructors; on-the-fly-implementations should call it directly after
* creating an object instance. * creating an object instance.
*/ */
class cApiClickableAction extends cApiAction class cApiClickableAction extends cApiAction {
{ /* * * Attributes: ** */
/*** Attributes: ***/
/** /**
* Help text * Help text
@ -65,19 +63,17 @@ class cApiClickableAction extends cApiAction
*/ */
private $_img; private $_img;
public function __construct() {
public function __construct()
{
global $area; global $area;
parent::__construct(); parent::__construct();
$this->_area = $area; $this->_area = $area;
$this->_frame = 4; $this->_frame = 4;
$this->_target = "right_bottom"; $this->_target = "right_bottom";
$this->_link = new cHTMLLink; $this->_link = new cHTMLLink;
$this->_img = new cHTMLImage; $this->_img = new cHTMLImage;
$this->_img->setBorder(0); $this->_img->setBorder(0);
$this->_img->setStyle("padding-left: 1px; padding-right: 1px;"); $this->_img->setStyle("padding-left: 1px; padding-right: 1px;");
@ -86,26 +82,17 @@ class cApiClickableAction extends cApiAction
$this->setEnabled(); $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. * Sets the action icon for this action.
* *
* @param string icon Path to the icon. Relative to the backend, if not passed as absolute path. * @param string icon Path to the icon. Relative to the backend, if not passed as absolute path.
* @return void * @return void
*/ */
public function setIcon($icon) public function setIcon($icon) {
{
$this->_img->setSrc($icon); $this->_img->setSrc($icon);
} }
public function getIcon() public function getIcon() {
{
return $this->_img; return $this->_img;
} }
@ -116,10 +103,8 @@ class cApiClickableAction extends cApiAction
* using it, otherwise, this method will fail. * using it, otherwise, this method will fail.
* @return void * @return void
*/ */
public function setNamedAction($actionName) public function setNamedAction($actionName) {
{ if ($this->loadBy("name", $actionName) !== false) {
if ($this->loadBy("name", $actionName) !== false)
{
$a = new cApiArea; $a = new cApiArea;
$a->loadByPrimaryKey($this->get("idarea")); $a->loadByPrimaryKey($this->get("idarea"));
@ -131,36 +116,32 @@ class cApiClickableAction extends cApiAction
} }
} }
public function setDisabled() public function setDisabled() {
{
$this->_enabled = false; $this->_enabled = false;
$this->_onDisable(); $this->_onDisable();
} }
public function setEnabled() public function setEnabled() {
{
$this->_enabled = true; $this->_enabled = true;
$this->_onEnable(); $this->_onEnable();
} }
protected function _onDisable() protected function _onDisable() {
{
} }
protected function _onEnable() protected function _onEnable() {
{
} }
/** /**
* Change linked area * Change linked area
*/ */
public function changeArea($sArea) public function changeArea($sArea) {
{
$this->_area = $sArea; $this->_area = $sArea;
} }
public function wantParameter($parameter) public function wantParameter($parameter) {
{
$this->_wantParameters[] = $parameter; $this->_wantParameters[] = $parameter;
$this->_wantParameters = array_unique($this->_wantParameters); $this->_wantParameters = array_unique($this->_wantParameters);
@ -172,29 +153,24 @@ class cApiClickableAction extends cApiAction
* @param string helptext The helptext to apply * @param string helptext The helptext to apply
* @return void * @return void
*/ */
public function setHelpText($helptext) public function setHelpText($helptext) {
{
$this->_helpText = $helptext; $this->_helpText = $helptext;
} }
public function getHelpText() public function getHelpText() {
{
return $this->_helpText; return $this->_helpText;
} }
public function setParameter($name, $value) public function setParameter($name, $value) {
{
$this->_parameters[$name] = $value; $this->_parameters[$name] = $value;
} }
public function process($parameters) public function process($parameters) {
{
echo "Process should be overridden"; echo "Process should be overridden";
return false; return false;
} }
public function render() public function render() {
{
$this->_img->setAlt($this->_helpText); $this->_img->setAlt($this->_helpText);
foreach ($this->_parameters as $name => $value) { foreach ($this->_parameters as $name => $value) {
@ -229,52 +205,39 @@ class cApiClickableAction extends cApiAction
return ($this->_helpText); return ($this->_helpText);
} }
} }
} }
class cApiClickableQuestionAction extends cApiClickableAction {
class cApiClickableQuestionAction extends cApiClickableAction public function __construct() {
{
public function __construct()
{
parent::__construct(); parent::__construct();
} }
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ public function setQuestionMode($mode) {
public function cApiClickableQuestionAction()
{
$this->__construct();
}
public function setQuestionMode($mode)
{
$this->_mode = $mode; $this->_mode = $mode;
} }
public function setQuestion($question) public function setQuestion($question) {
{
$this->_question = $question; $this->_question = $question;
} }
public function setResultVar($var) public function setResultVar($var) {
{
$this->_resultVar = $var; $this->_resultVar = $var;
} }
public function render() public function render() {
{ switch ($this->_mode) {
switch ($this->_mode)
{
case QUESTIONACTION_PROMPT: 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; break;
case QUESTIONACTION_YESNO: case QUESTIONACTION_YESNO:
default: default:
$this->_link->attachEventDefinition("_".get_class($this).rand(), "onclick", 'var answer = confirm("'.clHtmlSpecialChars($this->_question).'");if (answer == false) {return false;} else { return true;}'); $this->_link->attachEventDefinition("_" . get_class($this) . rand(), "onclick", 'var answer = confirm("' . clHtmlSpecialChars($this->_question) . '");if (answer == false) {return false;} else { return true;}');
break; break;
} }
return parent::render(); return parent::render();
} }
}
?> }

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -25,100 +26,87 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
}
class cWidgetMenuActionList extends cFoldingRow
{
function cWidgetMenuActionList($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;
}
}
} }
?> 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;
}
}
}

Datei anzeigen

@ -60,9 +60,9 @@ class cWidgetButton extends cHTMLSpan
* @param $alt string Alternative text * @param $alt string Alternative text
* @param $link string Link * @param $link string Link
*/ */
function cWidgetButton ($img, $alt, $link) function __construct ($img, $alt, $link)
{ {
cHTMLSpan::cHTMLSpan(); cHTMLSpan::__construct();
$this->_img = new cHTMLImage($img); $this->_img = new cHTMLImage($img);
$this->_link = new cHTMLLink($link); $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 $uplink string Link when the button is turned off (=up)
* @param $downlink string Link when the button is turned on (=down) * @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->_img = new cHTMLImage($img);
$this->_link = new cHTMLLink("#"); $this->_link = new cHTMLLink("#");
@ -243,9 +243,9 @@ class cWidgetMultiToggleButton extends cWidgetButton
* @param $alt string Alternative text * @param $alt string Alternative text
* @param $lnik string Link to call when the button is clicked * @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->_img = new cHTMLImage($img);
$this->_link = new cHTMLLink($link); $this->_link = new cHTMLLink($link);

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -25,105 +26,92 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
class cCalendarControl extends cHTMLTable {
class cCalendarControl extends cHTMLTable var $_oDate;
{
var $_oDate;
function cCalendarControl ($initDate = false)
{
parent::cHTMLTable();
$this->_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);
}
}
function __construct($initDate = false) {
function _initFormatting () parent::__construct();
{
$this->setClass("calendar");
$this->setCellSpacing(0);
$this->setCellPadding(0);
}
function _renderHead ()
{
$oHead = new cHTMLTableHeader;
$aDayOrder = $this->_oDate->getDayOrder();
$oRow = new cHTMLTableRow; $this->_initFormatting();
$this->_oDate = new cDatatypeDateTime;
$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('&nbsp;');
$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 () /* Development: Set today's date */
{ $this->_oDate->setSourceFormat(cDateTime_ISO);
$this->_oDate->setSourceFormat(cDateTime_UNIX);
if ($initDate === false) {
$oScript = new cHTMLScript; $this->_oDate->set(date("Y-m-d H:i:s"));
$sScript = ' } 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('&nbsp;');
$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}_markedDay;
var {cid}_markedMonth; var {cid}_markedMonth;
@ -135,7 +123,7 @@ class cCalendarControl extends cHTMLTable
{cid}_setDefaultDay(2006, 03, 30); {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) function {cid}_setDefaultDay (year, month, day)
{ {
@ -150,16 +138,16 @@ class cCalendarControl extends cHTMLTable
var sMarkedID = ""; var sMarkedID = "";
var iRow = 0; var iRow = 0;
var iFirstDayOfWeek = '.$this->_oDate->getFirstDayOfWeek().'; var iFirstDayOfWeek = ' . $this->_oDate->getFirstDayOfWeek() . ';
for (var i=1; i < 32; i++) for (var i=1; i < 32; i++)
{ {
mDate.setDate(i); mDate.setDate(i);
var dayOfWeek = mDate.getDay(); 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++; iRow++;
} }
@ -211,13 +199,13 @@ class cCalendarControl extends cHTMLTable
{cid}_currentMonth = month; {cid}_currentMonth = month;
var iRow = 0; var iRow = 0;
var iFirstDayOfWeek = '.$this->_oDate->getFirstDayOfWeek().'; var iFirstDayOfWeek = ' . $this->_oDate->getFirstDayOfWeek() . ';
for (var i=0; i < 7; i++) for (var i=0; i < 7; i++)
{ {
for (var j=0; j< 6; j++) 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).firstChild.nodeValue = String.fromCharCode(160);
document.getElementById(lid).className = ""; document.getElementById(lid).className = "";
{cid}_detachHandler(document.getElementById(lid)); {cid}_detachHandler(document.getElementById(lid));
@ -229,9 +217,9 @@ class cCalendarControl extends cHTMLTable
mDate.setDate(i); mDate.setDate(i);
var dayOfWeek = mDate.getDay(); 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++; iRow++;
} }
@ -284,16 +272,16 @@ class cCalendarControl extends cHTMLTable
var mDate = new Date(year, month - 1, 1); var mDate = new Date(year, month - 1, 1);
var iRow = 0; var iRow = 0;
var iFirstDayOfWeek = '.$this->_oDate->getFirstDayOfWeek().'; var iFirstDayOfWeek = ' . $this->_oDate->getFirstDayOfWeek() . ';
for (var i=1; i < {cid}_GetMonthLength(year, month) + 1; i++) for (var i=1; i < {cid}_GetMonthLength(year, month) + 1; i++)
{ {
mDate.setDate(i); mDate.setDate(i);
var dayOfWeek = mDate.getDay(); 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++; iRow++;
} }
@ -376,89 +364,85 @@ class cCalendarControl extends cHTMLTable
{ {
switch (iMonth) switch (iMonth)
{ {
case 1: return("'.$this->_oDate->getMonthName(1).'"); break; case 1: return("' . $this->_oDate->getMonthName(1) . '"); break;
case 2: return("'.$this->_oDate->getMonthName(2).'"); break; case 2: return("' . $this->_oDate->getMonthName(2) . '"); break;
case 3: return("'.$this->_oDate->getMonthName(3).'"); break; case 3: return("' . $this->_oDate->getMonthName(3) . '"); break;
case 4: return("'.$this->_oDate->getMonthName(4).'"); break; case 4: return("' . $this->_oDate->getMonthName(4) . '"); break;
case 5: return("'.$this->_oDate->getMonthName(5).'"); break; case 5: return("' . $this->_oDate->getMonthName(5) . '"); break;
case 6: return("'.$this->_oDate->getMonthName(6).'"); break; case 6: return("' . $this->_oDate->getMonthName(6) . '"); break;
case 7: return("'.$this->_oDate->getMonthName(7).'"); break; case 7: return("' . $this->_oDate->getMonthName(7) . '"); break;
case 8: return("'.$this->_oDate->getMonthName(8).'"); break; case 8: return("' . $this->_oDate->getMonthName(8) . '"); break;
case 9: return("'.$this->_oDate->getMonthName(9).'"); break; case 9: return("' . $this->_oDate->getMonthName(9) . '"); break;
case 10: return("'.$this->_oDate->getMonthName(10).'"); break; case 10: return("' . $this->_oDate->getMonthName(10) . '"); break;
case 11: return("'.$this->_oDate->getMonthName(11).'"); break; case 11: return("' . $this->_oDate->getMonthName(11) . '"); break;
case 12: return("'.$this->_oDate->getMonthName(12).'"); break; case 12: return("' . $this->_oDate->getMonthName(12) . '"); break;
} }
} }
'; ';
$sScript = str_replace("{cid}", $this->getId(), $sScript);
$oScript->setContent($sScript);
return $oScript;
}
function _renderMonthDropdown () $sScript = str_replace("{cid}", $this->getId(), $sScript);
{ $oScript->setContent($sScript);
$oMonthSelect = new cHTMLSelectElement($this->getId() . "_monthselect");
$oMonthSelect->setId($this->getId() ."_monthselect");
return $oScript;
$aMonths = array(); }
for ($i=1;$i<13;$i++)
{ function _renderMonthDropdown() {
$aMonths[$i] = $this->_oDate->getMonthName($i); $oMonthSelect = new cHTMLSelectElement($this->getId() . "_monthselect");
} $oMonthSelect->setId($this->getId() . "_monthselect");
$oMonthSelect->autoFill($aMonths); $aMonths = array();
$oMonthSelect->setEvent("change", $this->getId() ."_setCalendar(".$this->getId() ."_currentYear, this.value);"); 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('<table cellspacing="0" cellpadding="0"><tr><td>', $this->_renderMonthPrev(), '</td><td>', $this->_renderMonthDropdown(), '</td><td>', $this->_renderYearControl(), '</td><td>', $this->_renderMonthNext(), '</td></tr></table>'));
return '<table><tr><td align="middle">' . $oSpan->render() . '</td></tr><tr><td align="middle">' . parent::render() . '</td></tr></table>';
}
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('<table cellspacing="0" cellpadding="0"><tr><td>', $this->_renderMonthPrev(), '</td><td>', $this->_renderMonthDropdown(), '</td><td>', $this->_renderYearControl(), '</td><td>', $this->_renderMonthNext(), '</td></tr></table>'));
return '<table><tr><td align="middle">'.$oSpan->render() .'</td></tr><tr><td align="middle">'.parent::render().'</td></tr></table>';
}
} }
?> ?>

Datei anzeigen

@ -5,29 +5,28 @@
* cDataTextWidget generates a textbox widget * cDataTextWidget generates a textbox widget
* for use with the data objects. * for use with the data objects.
*/ */
class cDataTextWidget extends cHTMLTextbox class cDataTextWidget extends cHTMLTextbox {
{
/** /**
* cDataTextWidget: Creates a text box widget * cDataTextWidget: Creates a text box widget
* *
* @param $name Name of the widget * @param $name Name of the widget
* @param $parameters Parameters (see below) * @param $parameters Parameters (see below)
* *
* valid parameters for this control are: * valid parameters for this control are:
* default Default value for this box * default Default value for this box
* *
* @return void * @return void
* @access public * @access public
*/ */
function cDataTextWidget ($name, $parameters) function __construct($name, $parameters) {
{ parent::__construct($name);
cHTMLTextbox::cHTMLTextbox($name);
if (array_key_exists("default", $parameters)) {
if (array_key_exists("default", $parameters)) $this->setValue($parameters["default"]);
{ }
$this->setValue($parameters["default"]); }
}
}
} }
/** /**
@ -35,204 +34,192 @@ class cDataTextWidget extends cHTMLTextbox
* cDataTextareaWidget generates a textarea widget for use with the data objects. * cDataTextareaWidget generates a textarea widget for use with the data objects.
* *
*/ */
class cDataTextareaWidget extends cHTMLTextarea class cDataTextareaWidget extends cHTMLTextarea {
{
/** /**
* cDataTextareaWidget: Creates a text area widget * cDataTextareaWidget: Creates a text area widget
* *
* @param $name Name of the widget * @param $name Name of the widget
* @param $parameters Parameters (see below) * @param $parameters Parameters (see below)
* *
* valid parameters for this control are: * valid parameters for this control are:
* default Default value for this area * default Default value for this area
* *
* @return void * @return void
* @access public * @access public
*/ */
function cDataTextareaWidget ($name, $parameters) function __construct($name, $parameters) {
{ parent::__construct($name);
cHTMLTextarea::cHTMLTextarea($name);
if (array_key_exists("default", $parameters)) {
if (array_key_exists("default", $parameters)) $this->setValue($parameters["default"]);
{ }
$this->setValue($parameters["default"]); }
}
}
} }
/** /**
* class cDataCodeTextareaWidget * class cDataCodeTextareaWidget
* cDataCodeTextareaWidget generates a textarea widget for use with the data objects. * cDataCodeTextareaWidget generates a textarea widget for use with the data objects.
*/ */
class cDataCodeTextareaWidget extends cHTMLTextarea class cDataCodeTextareaWidget extends cHTMLTextarea {
{
/** /**
* cDataTextareaWidget: Creates a text area widget * cDataTextareaWidget: Creates a text area widget
* which can be used for entering code * which can be used for entering code
* *
* @param $name Name of the widget * @param $name Name of the widget
* @param $parameters Parameters (see below) * @param $parameters Parameters (see below)
* *
* valid parameters for this control are: * valid parameters for this control are:
* default Default value for this area * default Default value for this area
* notes Notes for this area * notes Notes for this area
* *
* @return void * @return void
* @access public * @access public
*/ */
function cDataCodeTextareaWidget ($name, $parameters) function __construct($name, $parameters) {
{ parent::__construct($name);
cHTMLTextarea::cHTMLTextarea($name);
if (array_key_exists("default", $parameters)) {
if (array_key_exists("default", $parameters)) $this->setValue($parameters["default"]);
{ }
$this->setValue($parameters["default"]);
} $this->updateAttributes(array("wrap" => "off"));
$this->setStyle("width: 100%; font-family: monospace;");
$this->updateAttributes(array("wrap" => "off")); $this->setWidth(100);
$this->setStyle("width: 100%; font-family: monospace;"); $this->setHeight(20);
$this->setWidth(100);
$this->setHeight(20); if (array_key_exists("notes", $parameters)) {
$this->_notes = $parameters["notes"];
if (array_key_exists("notes", $parameters)) }
{ }
$this->_notes = $parameters["notes"];
} function render() {
} $out = parent::render();
$out .= $this->_notes;
function render ()
{ return ($out);
$out = parent::render(); }
$out .= $this->_notes;
return ($out);
}
} }
/** /**
* class cDataDropdownWidget * class cDataDropdownWidget
* cDataDropdownWidget generates a dropdown widget for use with the data objects. * cDataDropdownWidget generates a dropdown widget for use with the data objects.
*/ */
class cDataDropdownWidget extends cHTMLSelectElement class cDataDropdownWidget extends cHTMLSelectElement {
{
/** /**
* cDataDropdownWidget: Creates a dropdown widget * cDataDropdownWidget: Creates a dropdown widget
* with specific entries * with specific entries
* *
* @param $name Name of the widget * @param $name Name of the widget
* @param $parameters Parameters (see below) * @param $parameters Parameters (see below)
* *
* valid parameters for this control are: * valid parameters for this control are:
* default string Default value which will be selected * default string Default value which will be selected
* choices array Values for filling the dropdown * choices array Values for filling the dropdown
* *
* @return void * @return void
* @access public * @access public
*/ */
function cDataDropdownWidget ($name, $parameters) function __construct($name, $parameters) {
{ parent::__construct($name);
cHTMLSelectElement::cHTMLSelectElement($name);
$this->autoFill($parameters["choices"]);
$this->autoFill($parameters["choices"]);
if (array_key_exists("default", $parameters)) {
if (array_key_exists("default", $parameters)) $this->setDefault($parameters["default"]);
{ }
$this->setDefault($parameters["default"]); }
}
}
} }
/** /**
* class cDataForeignTableDropdownWidget * class cDataForeignTableDropdownWidget
* cDataForeignTableDropdownWidget generates a dropdown widget out of a foreign table. * cDataForeignTableDropdownWidget generates a dropdown widget out of a foreign table.
*/ */
class cDataForeignTableDropdownWidget extends cHTMLSelectElement class cDataForeignTableDropdownWidget extends cHTMLSelectElement {
{
/** /**
* cDataForeignTableDropdownWidget: Creates a dropdown widget * cDataForeignTableDropdownWidget: Creates a dropdown widget
* which fetches its entries from a foreign, linked table * which fetches its entries from a foreign, linked table
* *
* @param $name Name of the widget * @param $name Name of the widget
* @param $parameters Parameters (see below) * @param $parameters Parameters (see below)
* *
* valid parameters for this control are: * valid parameters for this control are:
* foreignClass string Class name of the foreign class * foreignClass string Class name of the foreign class
* default string Default value which will be selected * default string Default value which will be selected
* *
* @return void * @return void
* @access public * @access public
*/ */
function cDataForeignTableDropdownWidget ($name, $parameters) function __construct($name, $parameters) {
{ parent::__construct($name);
cHTMLSelectElement::cHTMLSelectElement($name);
$c = new $parameters["foreignClass"];
$c = new $parameters["foreignClass"]; $c->query();
$c->query();
while ($i = $c->next()) {
while ($i = $c->next()) $meta = $i->getMetaObject();
{
$meta = $i->getMetaObject(); if (is_object($meta)) {
$data[$i->get($i->primaryKey)] = $meta->getName();
if (is_object($meta)) }
{ }
$data[$i->get($i->primaryKey)] = $meta->getName();
} $this->autoFill($data);
}
if (array_key_exists("default", $parameters)) {
$this->autoFill($data); $this->setDefault($parameters["default"]);
}
if (array_key_exists("default", $parameters)) }
{
$this->setDefault($parameters["default"]);
}
}
} }
/** /**
* class cDataCheckboxWidget * class cDataCheckboxWidget
* cDataCheckboxWidget generates a checkbox for use with the dataobjects * cDataCheckboxWidget generates a checkbox for use with the dataobjects
*/ */
class cDataCheckboxWidget extends cHTMLCheckbox class cDataCheckboxWidget extends cHTMLCheckbox {
{
/** /**
* cDataCheckboxWidget: Creates a checkbox widget * cDataCheckboxWidget: Creates a checkbox widget
* *
* @param $name Name of the widget * @param $name Name of the widget
* @param $parameters Parameters (see below) * @param $parameters Parameters (see below)
* *
* valid parameters for this control are: * valid parameters for this control are:
* title string Title of the checkbox label * title string Title of the checkbox label
* default string Checked or not checked * default string Checked or not checked
* *
* @return void * @return void
* @access public * @access public
*/ */
function cDataCheckboxWidget ($name, $parameters) function __construct($name, $parameters) {
{ parent::__construct($name . "_stub", "1");
cHTMLCheckbox::cHTMLCheckbox($name."_stub", "1");
if ($parameters["title"] != "") {
if ($parameters["title"] != "") $this->setLabelText($parameters["title"]);
{ } else {
$this->setLabelText($parameters["title"]); $this->setLabelText(" ");
} else { }
$this->setLabelText(" ");
} $this->setChecked($parameters["default"]);
$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'; }");
$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 * cDataMultiTextboxWidget generates a multi-line textbox widget
*/ */
class cDataMultiTextboxWidget extends cHTMLTable 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();
$this->name = $name; /**
* cDataMultiTextboxWidget: Creates a multi-line textbox widget
if (array_key_exists("title", $parameters)) *
{ * @param $name Name of the widget
$rows[] = $this->addTitle($parameters["title"]); * @param $parameters Parameters (see below)
} *
* valid parameters for this control are:
if (is_array($parameters["default"])) * title string Title of the multi-line textbox widget
{ * default array Values (=lines) to fill
foreach ($parameters["default"] as $i) *
{ * @return void
$rows[] = $this->addRow($i); * @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);
}
} }
?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -25,71 +26,61 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
class cDateChooser extends cDatefield {
class cDateChooser extends cDatefield var $_oCalendar;
{ var $_oImage;
var $_oCalendar; var $_oButton;
var $_oImage;
var $_oButton;
function cDateChooser ($name, $initValue = false)
{
parent::cDatefield($name, "");
$this->_oImage = new cHTMLImage;
$this->_oImage->setSrc("images/pfeil_runter.gif");
$this->_oImage->setStyle("margin-left: 2px; cursor: pointer;");
function __construct($name, $initValue = false) {
$this->_oCalendar = new cCalendarControl; parent::__construct($name, "");
$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->_oImage = new cHTMLImage;
{ $this->_oImage->setSrc("images/pfeil_runter.gif");
$this->_bReadOnly = $bReadOnly; $this->_oImage->setStyle("margin-left: 2px; cursor: pointer;");
}
function render () $this->_oCalendar = new cCalendarControl;
{
if ($this->_bReadOnly) $this->_oDate->setSourceFormat(cDateTime_ISO);
{ $this->_oDate->setTargetFormat(cDateTime_Locale_DateOnly);
$this->updateAttributes(array ("readonly" => "readonly"));
} if ($initValue === false) {
$this->_oDate->set(date("Y-m-d H:i:s"));
$sDatefield = parent::render(); } else {
$sTimeformat = getEffectiveSetting("backend", "timeformat_date", "Y-m-d"); $this->_oDate->set($initValue);
}
$parseScript = '
$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 = '
<script language="JavaScript"> <script language="JavaScript">
function {wid}_passToWidget (dateFormat, date) function {wid}_passToWidget (dateFormat, date)
@ -105,7 +96,7 @@ class cDateChooser extends cDatefield
function {wid}_datefieldSetter () function {wid}_datefieldSetter ()
{ {
document.getElementById("'.$this->getId().'").value = {wid}_renderLocaleDate("'.$sTimeformat.'", {cid}_markedYear, {cid}_markedMonth, {cid}_markedDay); document.getElementById("' . $this->getId() . '").value = {wid}_renderLocaleDate("' . $sTimeformat . '", {cid}_markedYear, {cid}_markedMonth, {cid}_markedDay);
document.getElementById("{did}_display").style.display = "none"; document.getElementById("{did}_display").style.display = "none";
{wid}_hideselects (false); {wid}_hideselects (false);
@ -127,7 +118,7 @@ class cDateChooser extends cDatefield
function {wid}_hideselects (bhide) function {wid}_hideselects (bhide)
{ {
var hide = new Array('.implode(",",$this->_aSelectIDs).'); var hide = new Array(' . implode(",", $this->_aSelectIDs) . ');
for (var i=0; i < hide.length; i++) for (var i=0; i < hide.length; i++)
{ {
@ -185,24 +176,22 @@ class cDateChooser extends cDatefield
} }
</script> </script>
'; ';
$sEventRegister = '<script language="JavaScript">{cid}_attachClickCallback({wid}_datefieldSetter);</script>'; $sEventRegister = '<script language="JavaScript">{cid}_attachClickCallback({wid}_datefieldSetter);</script>';
$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); } }"; $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; $div = new cHTMLDiv;
$this->_oImage->setEvent("click", $clickScript); $this->_oImage->setEvent("click", $clickScript);
$final = $parseScript.'<table cellspacing="0" cellpadding="0"><tr><td>'.$sDatefield.'</td><td>'.$this->_oImage->render().'</td></tr></table><div id="{did}_display" style="background-color: #E8E8EE; display: none; position: absolute; border: 1px solid black;">'.$this->_oCalendar->render().'</div>'.$sEventRegister; $final = $parseScript . '<table cellspacing="0" cellpadding="0"><tr><td>' . $sDatefield . '</td><td>' . $this->_oImage->render() . '</td></tr></table><div id="{did}_display" style="background-color: #E8E8EE; display: none; position: absolute; border: 1px solid black;">' . $this->_oCalendar->render() . '</div>' . $sEventRegister;
$final = str_replace("{wid}", $this->getId(), $final); $final = str_replace("{wid}", $this->getId(), $final);
$final = str_replace("{cid}", $this->_oCalendar->getId(), $final); $final = str_replace("{cid}", $this->_oCalendar->getId(), $final);
$final = str_replace("{did}", $div->getId(), $final); $final = str_replace("{did}", $div->getId(), $final);
return ($final); return ($final);
}
}
} }
?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -25,40 +26,32 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
class cDatefield extends cHTMLTextbox {
var $_oDate;
function __construct($name, $initvalue, $width = 10) {
$this->_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();
}
} }
?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -25,202 +26,178 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
class cDropdownDateSelect {
class cDropdownDateSelect /**
{ * Day, month and year selectors
/**
* Day, month and year selectors
* @var object * @var object
* @access private * @access private
*/ */
var $_daySelect; var $_daySelect;
var $_monthSelect; var $_monthSelect;
var $_yearSelect; var $_yearSelect;
/** /**
* Order of the elements * Order of the elements
* @var string * @var string
* @access private * @access private
*/ */
var $_order; var $_order;
function cDropdownDateSelect ($prefix)
{
$this->_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);
/* Fill months */ function __construct($prefix) {
for ($month = 1; $month < 13; $month++) $this->_daySelect = new cHTMLSelectElement($prefix . "_day");
{ $this->_monthSelect = new cHTMLSelectElement($prefix . "_month");
$months[sprintf("%02d", $month)] = getCanonicalMonth($month); $this->_yearSelect = new cHTMLSelectElement($prefix . "_year");
}
$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"]);
}
if (isset($_POST[$prefix."_month"])) /* Fill days */
{ for ($day = 1; $day < 32; $day++) {
$this->_monthSelect->setDefault($_POST[$prefix."_month"]); $days[sprintf("%02d", $day)] = $day;
} }
if (isset($_POST[$prefix."_year"])) $this->_daySelect->autoFill($days);
{
$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); /* Fill months */
$this->_monthSelect->setDefault($month); for ($month = 1; $month < 13; $month++) {
$this->_yearSelect->setDefault($year); $months[sprintf("%02d", $month)] = getCanonicalMonth($month);
}
}
/** $this->_monthSelect->autoFill($months);
* 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");
}
/** /* Fill years */
* Gets the current timestamp $currentYear = date("Y");
* for ($year = $currentYear - 20; $year < $currentYear + 20; $year++) {
* @param $timestamp int Timestamp to set $years[$year] = $year;
*/ }
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;
}
/** $this->_yearSelect->autoFill($years);
* sets the element to a disabled state
* $this->setTimestamp(time());
* @param none
*/ /* Apply old values */
function setDisabled ($disabled) if (isset($_POST[$prefix . "_day"])) {
{ $this->_daySelect->setDefault($_POST[$prefix . "_day"]);
$this->_daySelect->setDisabled($disabled); }
$this->_monthSelect->setDisabled($disabled);
$this->_yearSelect->setDisabled($disabled); if (isset($_POST[$prefix . "_month"])) {
} $this->_monthSelect->setDefault($_POST[$prefix . "_month"]);
}
/**
* Renders the elements if (isset($_POST[$prefix . "_year"])) {
* $this->_yearSelect->setDefault($_POST[$prefix . "_year"]);
* @param none }
*/
function render () $this->setOrder("dmy");
{ }
$output = "";
/**
for ($char = 0; $char < strlen($this->_order); $char++) * Sets the day, month and year boxes using a timestamp
{ *
$mychar = substr($this->_order, $char, 1); * @param $timestamp int Timestamp to set
*/
switch ($mychar) function setTimestamp($timestamp) {
{ $day = date("d", $timestamp);
case "d": $output .= $this->_daySelect->render(); break; $month = date("m", $timestamp);
case "m": $output .= $this->_monthSelect->render(); break; $year = date("Y", $timestamp);
case "y": $output .= $this->_yearSelect->render(); break;
default: break; $this->_daySelect->setDefault($day);
} $this->_monthSelect->setDefault($month);
} $this->_yearSelect->setDefault($year);
}
return ($output);
} /**
* 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);
}
} }
?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -25,47 +26,45 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
class cFoldingRow extends cHTML {
class cFoldingRow extends cHTML /**
{ * Table row with the header
/**
* Table row with the header
* @var array * @var array
* @access private * @access private
*/ */
var $_headerRow; var $_headerRow;
/** /**
* *
* @var cHTMLTableData * @var cHTMLTableData
*/ */
var $_headerData; var $_headerData;
/** /**
* Table row with the content * Table row with the content
* @var array * @var array
* @access private * @access private
*/ */
var $_contentRow; var $_contentRow;
/** /**
* *
* @var cHTMLTableData * @var cHTMLTableData
*/ */
var $_contentData; var $_contentData;
/** /**
* ID for link that triggers expandCollapse * ID for link that triggers expandCollapse
* @var string * @var string
* @access private * @access private
*/ */
var $_linkId; var $_linkId;
/** /**
* *
* @global type $auth * @global type $auth
@ -74,121 +73,109 @@ class cFoldingRow extends cHTML
* @param type $link_id * @param type $link_id
* @param type $bExpanded * @param type $bExpanded
*/ */
public function cFoldingRow($uuid, $caption = "", $link_id = "", $bExpanded = null) { public function __construct($uuid, $caption = "", $link_id = "", $bExpanded = null) {
global $auth; global $auth;
$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->setCaption($caption);
$this->addRequiredScript("cfoldingrow.js");
$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"]); $user = new cApiUser($auth->auth["uid"]);
if ($bExpanded == null) {
/* Check for expandstate */
if (!$user->virgin) if ($bExpanded == null) {
{ /* Check for expandstate */
if ($user->getProperty("expandstate", $uuid) == "true")
{ if (!$user->virgin) {
$this->setExpanded($user->getProperty("expandstate", $uuid)); if ($user->getProperty("expandstate", $uuid) == "true") {
} $this->setExpanded($user->getProperty("expandstate", $uuid));
} }
} else { }
if ($bExpanded) { } else {
$this->setExpanded(true); if ($bExpanded) {
} else { $this->setExpanded(true);
$this->setExpanded(false); } else {
} $this->setExpanded(false);
} }
} }
}
function setExpanded ($expanded = false)
{ function setExpanded($expanded = false) {
if ($expanded == true) if ($expanded == true) {
{ $this->_foldingImage->setSrc("images/widgets/foldingrow/expanded.gif");
$this->_foldingImage->setSrc("images/widgets/foldingrow/expanded.gif"); $this->_foldingImage->updateAttributes(array("data-folding-row" => "expanded", "alt" => ""));
$this->_foldingImage->updateAttributes(array("data-folding-row" => "expanded", "alt" => "")); $this->_contentRow->setStyle("display: ;");
$this->_contentRow->setStyle("display: ;");
$this->_hiddenField->setValue('expanded'); $this->_hiddenField->setValue('expanded');
} else { } else {
$this->_foldingImage->setSrc("images/widgets/foldingrow/collapsed.gif"); $this->_foldingImage->setSrc("images/widgets/foldingrow/collapsed.gif");
$this->_foldingImage->updateAttributes(array("data-folding-row" => "collapsed", "alt" => "")); $this->_foldingImage->updateAttributes(array("data-folding-row" => "collapsed", "alt" => ""));
$this->_contentRow->setStyle("display: none;"); $this->_contentRow->setStyle("display: none;");
$this->_hiddenField->setValue('collapsed'); $this->_hiddenField->setValue('collapsed');
} }
$this->_expanded = $expanded; $this->_expanded = $expanded;
} }
function setCaption ($caption) function setCaption($caption) {
{ $this->_caption = $caption;
$this->_caption = $caption; }
}
function setHelpContext($context = false) {
function setHelpContext ($context = false) $this->_helpContext = $context;
{ }
$this->_helpContext = $context;
} function setIndent($indent = 0) {
$this->_indent = $indent;
function setIndent ($indent = 0) }
{
$this->_indent = $indent; function setContentData($content) {
} $this->_contentData->setContent($content);
}
function setContentData ($content)
{ function render() {
$this->_contentData->setContent($content); /* Build the expand/collapse link */
}
$this->_link->setClass("foldingrow");
function render () if ($this->_linkId != NULL) {
{ $this->_link->setID($this->_linkId);
/* Build the expand/collapse link */ }
$this->_link->setClass("foldingrow"); $imgid = $this->_foldingImage->getID();
if($this->_linkId != NULL) $rowid = $this->_contentRow->getID();
{ $hiddenid = $this->_hiddenField->getID();
$this->_link->setID($this->_linkId); $uuid = $this->_uuid;
}
$this->_link->setLink("javascript:cFoldingRow_expandCollapse('$imgid', '$rowid', '$hiddenid', '$uuid');");
$imgid = $this->_foldingImage->getID(); $this->_link->setContent($this->_foldingImage->render() . $this->_caption);
$rowid = $this->_contentRow->getID();
$hiddenid = $this->_hiddenField->getID(); $this->_headerData->setContent(array($this->_hiddenField, $this->_link));
$uuid = $this->_uuid; $this->_headerRow->setContent($this->_headerData);
$this->_link->setLink("javascript:cFoldingRow_expandCollapse('$imgid', '$rowid', '$hiddenid', '$uuid');"); $this->_contentRow->setContent($this->_contentData);
$this->_link->setContent($this->_foldingImage->render() . $this->_caption);
$output = $this->_headerRow->render();
$this->_headerData->setContent(array($this->_hiddenField,$this->_link)); $output .= $this->_contentRow->render();
$this->_headerRow->setContent($this->_headerData);
return ($output);
$this->_contentRow->setContent($this->_contentData); }
$output = $this->_headerRow->render();
$output .= $this->_contentRow->render();
return ($output);
}
} }
?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -25,103 +26,87 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
cInclude("plugins", "general/classes/class.datatype.number.php"); cInclude("plugins", "general/classes/class.datatype.number.php");
cInclude("plugins", "general/classes/class.datatype.currency.php"); cInclude("plugins", "general/classes/class.datatype.currency.php");
class cNominalNumberField extends cHTMLTextbox class cNominalNumberField extends cHTMLTextbox {
{
var $_oNumber; var $_oNumber;
var $_bRealtimeNominalFormat; var $_bRealtimeNominalFormat;
function cNominalNumberField ($name, $initvalue, $width) function __construct($name, $initvalue, $width) {
{ global $belang;
global $belang;
$this->_oNumber = new cDatatypeNumber;
$this->_oNumber = new cDatatypeNumber; $this->_oNumber->set($initvalue);
$this->_oNumber->set($initvalue);
$this->disableRealtimeNominalFormat();
$this->disableRealtimeNominalFormat();
parent::__construct($name, $initvalue, $width);
parent::cHTMLTextbox($name, $initvalue, $width); }
}
function enableRealtimeNominalFormat() {
function enableRealtimeNominalFormat () $this->_bRealtimeNominalFormat = true;
{ }
$this->_bRealtimeNominalFormat = true;
} function disableRealtimeNominalFormat() {
$this->_bRealtimeNominalFormat = false;
function disableRealtimeNominalFormat () }
{
$this->_bRealtimeNominalFormat = false; function render() {
} parent::setValue($this->_oNumber->render());
function render () if ($this->_bRealtimeNominalFormat) {
{
parent::setValue($this->_oNumber->render()); $decimalChar = $this->_oNumber->getDecimalPointCharacter();
$thousandChar = $this->_oNumber->getThousandSeparatorCharacter();
if ($this->_bRealtimeNominalFormat)
{ parent::setEvent("change", "nominal_format_custom(this, '" . $decimalChar . "', '" . $thousandChar . "')");
}
$decimalChar = $this->_oNumber->getDecimalPointCharacter(); return parent::render();
$thousandChar = $this->_oNumber->getThousandSeparatorCharacter(); }
parent::setEvent("change", "nominal_format_custom(this, '".$decimalChar."', '".$thousandChar."')");
}
return parent::render();
}
} }
class cNominalCurrencyField extends cNominalNumberField 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);
$this->disableRealtimeNominalFormat(); var $_oNumber;
var $_bRealtimeNominalFormat;
} function __construct($name, $initvalue, $width) {
parent::__construct($name, $initvalue, $width);
function enableRealtimeNominalFormat ()
{ $this->_oNumber = new cDatatypeCurrency;
$this->_bRealtimeNominalFormat = true; $this->_oNumber->set($initvalue);
}
$this->disableRealtimeNominalFormat();
function disableRealtimeNominalFormat () }
{
$this->_bRealtimeNominalFormat = false; function enableRealtimeNominalFormat() {
} $this->_bRealtimeNominalFormat = true;
}
function render ()
{ function disableRealtimeNominalFormat() {
parent::setValue($this->_oNumber->render()); $this->_bRealtimeNominalFormat = false;
}
if ($this->_bRealtimeNominalFormat)
{ function render() {
$decimalChar = $this->_oNumber->getDecimalPointCharacter(); parent::setValue($this->_oNumber->render());
$thousandChar = $this->_oNumber->getThousandSeparatorCharacter();
if ($this->_bRealtimeNominalFormat) {
$currencySign = $this->_oNumber->getCurrencySymbol(); $decimalChar = $this->_oNumber->getDecimalPointCharacter();
$thousandChar = $this->_oNumber->getThousandSeparatorCharacter();
parent::setEvent("change", "nominal_format_custom(this, '".$decimalChar."', '".$thousandChar."', '".$currencySign."')");
} $currencySign = $this->_oNumber->getCurrencySymbol();
return parent::render();
} parent::setEvent("change", "nominal_format_custom(this, '" . $decimalChar . "', '" . $thousandChar . "', '" . $currencySign . "')");
}
return parent::render();
}
} }
?>

Datei anzeigen

@ -78,19 +78,19 @@ class cPage extends cHTML {
* @access private * @access private
*/ */
var $extra; var $extra;
/** /**
* Switch if HTML5 * Switch if HTML5
* @var boolean * @var boolean
*/ */
protected $_isHtml5 = false; protected $_isHtml5 = false;
/** /**
* CSS files to add * CSS files to add
* @var array * @var array
*/ */
protected $_css; protected $_css;
/** /**
* JS files to add * JS files to add
* @var array * @var array
@ -143,20 +143,20 @@ class cPage extends cHTML {
function setMargin($margin) { function setMargin($margin) {
$this->_margin = $margin; $this->_margin = $margin;
} }
/** /**
* *
* @param string $sFile path to file * @param string $sFile path to file
*/ */
public function addCssFile($sFile) { public function addCssFile($sFile) {
if(!is_array($this->_css)) { if (!is_array($this->_css)) {
$this->_css = array(); $this->_css = array();
} }
$this->_css[] = $sFile; $this->_css[] = $sFile;
} }
public function addJsFile($sFile) { public function addJsFile($sFile) {
if(!is_array($this->_css)) { if (!is_array($this->_css)) {
$this->_js = array(); $this->_js = array();
} }
$this->_js[] = $sFile; $this->_js[] = $sFile;
@ -271,7 +271,7 @@ class cPage extends cHTML {
function setEncoding($encoding) { function setEncoding($encoding) {
$this->_encoding = $encoding; $this->_encoding = $encoding;
} }
public function sendNoCacheHeaders() { public function sendNoCacheHeaders() {
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1. header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0. 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)) { if ($this->_object !== false && method_exists($this->_object, "render") && is_array($this->_requiredScripts)) {
foreach ($this->_requiredScripts as $key => $value) { foreach ($this->_requiredScripts as $key => $value) {
$scripts .= '<script type="text/javascript" src="scripts/' . $value . '"></script>'."\n"; $scripts .= '<script type="text/javascript" src="scripts/' . $value . '"></script>' . "\n";
} }
} }
if(is_array($this->_js) && count($this->_js) > 0) { if (is_array($this->_js) && count($this->_js) > 0) {
foreach($this->_js as $sFilename) { foreach ($this->_js as $sFilename) {
$scripts .= '<script type="text/javascript" src="' . $sFilename . '"></script>'."\n"; $scripts .= '<script type="text/javascript" src="' . $sFilename . '"></script>' . "\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 .= 'parent.frames["right_top"].location.href = "' . $sess->url("main.php?area=" . $this->_subnavArea . "&frame=3&" . $this->_subnav) . '";';
$scripts .= '</script>'; $scripts .= '</script>';
} }
$css = ""; $css = "";
if(is_array($this->_css)) { if (is_array($this->_css)) {
foreach($this->_css as $sFilename) { foreach ($this->_css as $sFilename) {
$css .= '<link rel="stylesheet" type="text/css" href="'.$sFilename.'" />'."\n"; $css .= '<link rel="stylesheet" type="text/css" href="' . $sFilename . '" />' . "\n";
} }
} }
$meta = ''; $meta = '';
if ($this->_encoding != "" && !$this->_isHtml5) { if ($this->_encoding != "" && !$this->_isHtml5) {
$meta .= '<meta http-equiv="Content-type" content="text/html;charset=' . $this->_encoding . '">' . "\n"; $meta .= '<meta http-equiv="Content-type" content="text/html;charset=' . $this->_encoding . '">' . "\n";
@ -332,13 +332,13 @@ class cPage extends cHTML {
$this->_content .= "\n" . '<script type="text/javascript" src="scripts/jquery/jquery.js"></script>'; $this->_content .= "\n" . '<script type="text/javascript" src="scripts/jquery/jquery.js"></script>';
$this->_content .= "\n" . '<script type="text/javascript" src="scripts/jquery/jquery-ui.js"></script>'; $this->_content .= "\n" . '<script type="text/javascript" src="scripts/jquery/jquery-ui.js"></script>';
} }
$tpl->set('s', 'META', $meta); $tpl->set('s', 'META', $meta);
$tpl->set('s', 'SCRIPTS', $scripts); $tpl->set('s', 'SCRIPTS', $scripts);
$tpl->set('s', 'CSS', $css); $tpl->set('s', 'CSS', $css);
$tpl->set('s', 'CONTENT', $this->_content); $tpl->set('s', 'CONTENT', $this->_content);
$tpl->set('s', 'MARGIN', $this->_margin); $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); $tpl->set('s', 'SESSION_ID', $sess->id);
if ($print == true) { if ($print == true) {
@ -374,7 +374,7 @@ class cPageLeftTop extends cPage {
* *
* @param $showCloser boolean True if the closer should be shown (default) * @param $showCloser boolean True if the closer should be shown (default)
*/ */
function cPageLeftTop($showCloser = true) { function __construct($showCloser = true) {
$this->showCloser($showCloser); $this->showCloser($showCloser);
} }
@ -390,11 +390,11 @@ class cPageLeftTop extends cPage {
function render($print = true) { function render($print = true) {
global $cfg; global $cfg;
$tpl = new Template; $tpl = new Template();
$tpl->set('s', 'CONTENT', $content); $tpl->set('s', 'CONTENT', $content);
$this->setContent($tpl->generate($cfg['path']['contenido'] . $cfg['path']['templates'] . $cfg['templates']['widgets']['left_top'], true)); $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) * @param $items array All items passed as multi array (see constructor description)
*/ */
function cPageLeftTopMultiPane($items) { function __construct($items) {
$this->_items = $items; $this->_items = $items;
cPageLeftTop::cPageLeftTop(); parent::__construct();
} }
/** /**
@ -494,21 +494,21 @@ class cPageLeftTopMultiPane extends cPageLeftTop {
$tpl->set('s', 'CONTENT', $content); $tpl->set('s', 'CONTENT', $content);
$this->setContent($tpl->generate($cfg['path']['templates'] . $cfg['templates']['widgets']['left_top'], true)); $this->setContent($tpl->generate($cfg['path']['templates'] . $cfg['templates']['widgets']['left_top'], true));
cPage::render(); parent::render();
} }
} }
class cNewPageLeftTopMultiPane extends cPageLeftTopMultiPane { class cNewPageLeftTopMultiPane extends cPageLeftTopMultiPane {
function cNewPageLeftTopMultiPane($items) { function __construct($items) {
cPageLeftTopMultiPane::cPageLeftTopMultiPane($items); parent::__construct($items);
} }
function render($print = true) { function render($print = true) {
global $cfg; global $cfg;
$infodiv = new cHTMLDiv; $infodiv = new cHTMLDiv();
if (count($this->_items) > 0) { if (count($this->_items) > 0) {
foreach ($this->_items as $item) { foreach ($this->_items as $item) {
@ -549,5 +549,3 @@ class cNewPageLeftTopMultiPane extends cPageLeftTopMultiPane {
} }
} }
?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -25,137 +26,126 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
class cObjectPager extends cFoldingRow {
class cObjectPager extends cFoldingRow var $_pagerLink;
{ var $_parameterToAdd;
var $_pagerLink;
var $_parameterToAdd; function __construct($uuid, $items, $itemsperpage, $currentpage, $link, $parameterToAdd, $id = '') {
if ((int) $currentpage == 0) {
function cObjectPager ($uuid, $items, $itemsperpage, $currentpage, $link, $parameterToAdd, $id='') $currentpage = 1;
{ }
if ((int) $currentpage == 0) {
$currentpage = 1; if ($id == '') {
} parent::__construct($uuid, i18n("Paging"));
} else {
if($id == '') parent::__construct($uuid, i18n("Paging"), $id);
{ }
cFoldingRow::cFoldingRow($uuid, i18n("Paging"));
} if (!is_object($link)) {
else cError(__FILE__, __LINE__, "Parameter link is not an object");
{ return false;
cFoldingRow::cFoldingRow($uuid, i18n("Paging"), $id); }
} $this->_cPager = new cPager($items, $itemsperpage, $currentpage);
$this->_pagerLink = $link;
if (!is_object($link)) $this->_parameterToAdd = $parameterToAdd;
{ }
cError(__FILE__, __LINE__, "Parameter link is not an object");
return false; function render($bContentOnly = 0) {
}
$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 #Do not display Page navigation if there is only one Page and we are not in newsletter section
if ($this->_cPager->getMaxPages() == 1) { if ($this->_cPager->getMaxPages() == 1) {
$this->_headerRow->setStyle("display:none"); $this->_headerRow->setStyle("display:none");
$this->_contentRow->setStyle("display:none"); $this->_contentRow->setStyle("display:none");
} }
$items = $this->_cPager->getPagesInRange(); $items = $this->_cPager->getPagesInRange();
//echo '<pre>'; //echo '<pre>';
//print_r($items); //print_r($items);
//echo '</pre>'; //echo '</pre>';
$link = $this->_pagerLink; $link = $this->_pagerLink;
$output = ''; $output = '';
if (!$this->_cPager->isFirstPage()) if (!$this->_cPager->isFirstPage()) {
{ $img = new cHTMLImage("images/paging/first.gif");
$img = new cHTMLImage("images/paging/first.gif");
$link->setAlt(i18n("First page"));
$link->setAlt(i18n("First page")); $link->setContent($img);
$link->setContent($img);
$link->setCustom($this->_parameterToAdd, 1); $link->setCustom($this->_parameterToAdd, 1);
$output .= $link->render(); $output .= $link->render();
$output .= " "; $output .= " ";
$img = new cHTMLImage("images/paging/previous.gif"); $img = new cHTMLImage("images/paging/previous.gif");
$link->setAlt(i18n("Previous page")); $link->setAlt(i18n("Previous page"));
$link->setContent($img); $link->setContent($img);
$link->setCustom($this->_parameterToAdd, $this->_cPager->_currentPage - 1); $link->setCustom($this->_parameterToAdd, $this->_cPager->_currentPage - 1);
$output .= $link->render(); $output .= $link->render();
$output .= " "; $output .= " ";
} else { } else {
$output .= '<img src="images/spacer.gif" width="8" alt=""> '; $output .= '<img src="images/spacer.gif" width="8" alt=""> ';
$output .= '<img src="images/spacer.gif" width="8" alt="">'; $output .= '<img src="images/spacer.gif" width="8" alt="">';
} }
foreach ($items as $key => $item) foreach ($items as $key => $item) {
{ $link->setContent($key);
$link->setContent($key); $link->setAlt(sprintf(i18n("Page %s"), $key));
$link->setAlt(sprintf(i18n("Page %s"), $key));
$link->setCustom($this->_parameterToAdd, $key); $link->setCustom($this->_parameterToAdd, $key);
switch ($item) switch ($item) {
{ case "|": $output .= "...";
case "|": $output .= "..."; break; break;
case "current": $output .= '<span class="cpager_currentitem">'.$key."</span>"; break; case "current": $output .= '<span class="cpager_currentitem">' . $key . "</span>";
default: $output .= $link->render(); break;
} default: $output .= $link->render();
}
$output .= " ";
} $output .= " ";
}
if (!$this->_cPager->isLastPage())
{ if (!$this->_cPager->isLastPage()) {
$img = new cHTMLImage("images/paging/next.gif"); $img = new cHTMLImage("images/paging/next.gif");
$link->setAlt(i18n("Next page")); $link->setAlt(i18n("Next page"));
$link->setContent($img); $link->setContent($img);
$link->setCustom($this->_parameterToAdd, $this->_cPager->_currentPage + 1); $link->setCustom($this->_parameterToAdd, $this->_cPager->_currentPage + 1);
$output .= $link->render(); $output .= $link->render();
$output .= " "; $output .= " ";
$img = new cHTMLImage("images/paging/last.gif"); $img = new cHTMLImage("images/paging/last.gif");
$link->setCustom($this->_parameterToAdd, $this->_cPager->getMaxPages()); $link->setCustom($this->_parameterToAdd, $this->_cPager->getMaxPages());
$link->setAlt(i18n("Last page")); $link->setAlt(i18n("Last page"));
$link->setContent($img); $link->setContent($img);
$output .= $link->render(); $output .= $link->render();
$output .= " "; $output .= " ";
} else { } else {
$output .= '<img src="images/spacer.gif" width="8" alt=""> '; $output .= '<img src="images/spacer.gif" width="8" alt=""> ';
$output .= '<img src="images/spacer.gif" width="8" alt="">'; $output .= '<img src="images/spacer.gif" width="8" alt="">';
} }
$this->_contentData->setStyle("text-align: center;"); $this->_contentData->setStyle("text-align: center;");
$this->_contentData->setClass("foldingrow_content"); $this->_contentData->setClass("foldingrow_content");
#Do not display Page navigation if there is only one Page and we are not in newsletter section #Do not display Page navigation if there is only one Page and we are not in newsletter section
if ($this->_cPager->getMaxPages() == 1) { if ($this->_cPager->getMaxPages() == 1) {
$output = ''; $output = '';
} }
$this->_contentData->setContent($output); $this->_contentData->setContent($output);
if ($bContentOnly) { if ($bContentOnly) {
return $output; return $output;
} else { } else {
return cFoldingRow::render(); return parent::render();
} }
}
}
} }
/** /**
@ -164,179 +154,161 @@ class cObjectPager extends cFoldingRow
* *
* @author Timo A. Hummel <timo.hummel@4fb.de> * @author Timo A. Hummel <timo.hummel@4fb.de>
*/ */
class cPager class cPager {
{
/** /**
* Amount of items * Amount of items
* @var integer * @var integer
* @access private * @access private
*/ */
var $_items; var $_items;
/** /**
* Item padding (before and after the current item) * Item padding (before and after the current item)
* @var integer * @var integer
* @access private * @access private
*/ */
var $_itemPadding; var $_itemPadding;
/** /**
* Items on the left side * Items on the left side
* @var integer * @var integer
* @access private * @access private
*/ */
var $_previousItems; var $_previousItems;
/** /**
* Items on the right side * Items on the right side
* @var integer * @var integer
* @access private * @access private
*/ */
var $_nextItems; var $_nextItems;
/** /**
* Current page * Current page
* @var integer * @var integer
* @access private * @access private
*/ */
var $_currentPage; var $_currentPage;
/** /**
* Items per page * Items per page
* @var integer * @var integer
* @access private * @access private
*/ */
var $_itemsPerPage; var $_itemsPerPage;
/** /**
* Constructor Function * Constructor Function
* Initializes the pager * Initializes the pager
* *
* @param $items int Amount of items * @param $items int Amount of items
* @param $itemsPerPage int Items displayed per page * @param $itemsPerPage int Items displayed per page
* @param $currentPage int Defines the current page * @param $currentPage int Defines the current page
*/ */
function cPager ($items, $itemsPerPage, $currentPage) 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;
}
/** $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. * Returns if the currentPage pointer is the first page.
* *
* @return boolean True if we're on the first page. * @return boolean True if we're on the first page.
*/ */
function isFirstPage () function isFirstPage() {
{ if ($this->_currentPage == 1) {
if ($this->_currentPage == 1) return true;
{ }
return true;
}
return false;
}
/** return false;
}
/**
* Returns if the currentPage pointer is the last page. * Returns if the currentPage pointer is the last page.
* *
* @return boolean True if we're on the last page. * @return boolean True if we're on the last page.
*/ */
function isLastPage () function isLastPage() {
{ if ($this->_currentPage == $this->getMaxPages()) {
if ($this->_currentPage == $this->getMaxPages()) return true;
{ }
return true;
} return false;
}
return false;
} /**
/**
* Returns the amount of pages. * Returns the amount of pages.
* *
* @return int Page count * @return int Page count
*/ */
function getMaxPages () function getMaxPages() {
{ if ($this->_items == 0) {
if ($this->_items == 0){ return 1;
return 1; } else if ($this->_itemsPerPage == 0) {
} else if ($this->_itemsPerPage == 0) {
return 1; return 1;
} else { } else {
return (ceil($this->_items / $this->_itemsPerPage)); return (ceil($this->_items / $this->_itemsPerPage));
} }
} }
/** /**
* Returns an array with the pager structure. * Returns an array with the pager structure.
* *
* Array format: * Array format:
* Key : Page Number * Key : Page Number
* Value: | for "...", "current" for the current item, page number otherwise * Value: | for "...", "current" for the current item, page number otherwise
* *
* @return array Pager structure * @return array Pager structure
*/ */
function getPagesInRange () function getPagesInRange() {
{ $items = array();
$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);
}
} }
?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -25,57 +26,51 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
class cSwitchableDateChooser extends cDateChooser {
class cSwitchableDateChooser extends cDateChooser var $_oCheckBox;
{ var $_bReadOnly;
var $_oCheckBox; var $_bDisabled;
var $_bReadOnly;
var $_bDisabled; function __construct($name, $initValue = false) {
parent::__construct($name, $initValue);
function cSwitchableDateChooser ($name, $initValue = false)
{ $this->_oCheckBox = new cHTMLCheckbox($this->getID() . "_check", "true");
parent::cDateChooser($name, $initValue); $this->_oCheckBox->setLabelText("");
$this->_oCheckBox = new cHTMLCheckbox($this->getID()."_check", "true"); $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->_oCheckBox->setLabelText("");
$this->enable();
$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);
function disable () $this->_oCheckBox->setChecked(false);
{ $this->setClass("textbox_readonly");
$this->_bDisabled = true; $this->_oImage->setStyle("margin-left: 2px; cursor: pointer; visibility: hidden;");
$this->setDisabled(true); }
$this->_oCheckBox->setChecked(false);
$this->setClass("textbox_readonly"); function enable() {
$this->_oImage->setStyle("margin-left: 2px; cursor: pointer; visibility: hidden;"); $this->_bDisabled = false;
} $this->setDisabled(false);
$this->_oCheckBox->setChecked(true);
function enable () $this->setClass("textbox");
{ }
$this->_bDisabled = false;
$this->setDisabled(false); function render() {
$this->_oCheckBox->setChecked(true); $sRender = parent::render();
$this->setClass("textbox");
} $oAlignmentTable = new cHTMLAlignmentTable($this->_oCheckBox->toHtml(false), $sRender);
function render () if ($this->_bDisabled) {
{ $addscript = 'document.getElementById("' . $this->getId() . '").value = "";';
$sRender = parent::render(); }
return $oAlignmentTable->render() . '<script language="JavaScript">' . $addscript . 'x_oldvalue_' . $this->getID() . ' = "' . $this->_oDate->render() . '";</script>';
$oAlignmentTable = new cHTMLAlignmentTable($this->_oCheckBox->toHtml(false), $sRender); }
if ($this->_bDisabled) }
{
$addscript ='document.getElementById("'.$this->getId().'").value = "";';
}
return $oAlignmentTable->render() . '<script language="JavaScript">'.$addscript.'x_oldvalue_'.$this->getID().' = "'.$this->_oDate->render().'";</script>';
}
}

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -25,174 +26,158 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
class cWidgetTableEdit {
function __construct($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, '<b style="margin: 0px 4px 0px 4px;">' . $this->_title . "</b>");
$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, '<b style="margin: 0px 4px 0px 4px;">'.$this->_title."</b>");
$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());
}
} }
?>

Datei anzeigen

@ -1,19 +1,20 @@
<?php <?php
/*****************************************
* File : $RCSfile: class.widgets.treeview.php,v $
* Project : Contenido
* Descr : Visual representation of a cTree
* Modified : $Date: 2012-05-29 14:38:23 +0200 (Tue, 29 May 2012) $
*
* <EFBFBD> four for business AG, www.4fb.de
*
* $Id: class.widgets.treeview.php 80 2012-05-29 12:38:23Z oldperl $
******************************************/
define("TREEVIEW_GRIDLINE_SOLID" , "solid"); /* * ***************************************
* File : $RCSfile: class.widgets.treeview.php,v $
* Project : Contenido
* Descr : Visual representation of a cTree
* Modified : $Date: 2012-05-29 14:38:23 +0200 (Tue, 29 May 2012) $
*
* <EFBFBD> four for business AG, www.4fb.de
*
* $Id: class.widgets.treeview.php 80 2012-05-29 12:38:23Z oldperl $
* **************************************** */
define("TREEVIEW_GRIDLINE_SOLID", "solid");
define("TREEVIEW_GRIDLINE_DASHED", "dashed"); define("TREEVIEW_GRIDLINE_DASHED", "dashed");
define("TREEVIEW_GRIDLINE_DOTTED", "dotted"); define("TREEVIEW_GRIDLINE_DOTTED", "dotted");
define("TREEVIEW_GRIDLINE_NONE" , "none"); define("TREEVIEW_GRIDLINE_NONE", "none");
define("TREEVIEW_BACKGROUND_NONE", "none"); define("TREEVIEW_BACKGROUND_NONE", "none");
define("TREEVIEW_BACKGROUND_SHADED", "shaded"); define("TREEVIEW_BACKGROUND_SHADED", "shaded");
@ -21,502 +22,467 @@ define("TREEVIEW_BACKGROUND_SHADED", "shaded");
define("TREEVIEW_MOUSEOVER_NONE", "none"); define("TREEVIEW_MOUSEOVER_NONE", "none");
define("TREEVIEW_MOUSEOVER_MARK", "mark"); define("TREEVIEW_MOUSEOVER_MARK", "mark");
/** /**
* class cWidgetTreeView * class cWidgetTreeView
* cWidgetTreeView is a visual representation of a cTree. It supports folding, * cWidgetTreeView is a visual representation of a cTree. It supports folding,
* optional gridline marks and item icons. * optional gridline marks and item icons.
*/ */
class cWidgetTreeView extends cTree class cWidgetTreeView extends cTree {
{ /* * * Attributes: ** */
/*** Attributes: ***/ /**
*
* @access private
*/
var $_globalActions;
/** /**
* *
* @access private * @access private
*/ */
var $_globalActions; var $_setItemActions;
/**
*
* @access private
*/
var $_setItemActions;
/**
*
* @access private
*/
var $_unsetItemActions;
/**
*
* @access private
*/
var $_setAttributeActions;
/**
*
* @access private
*/
var $_unsetAttributeActions;
var $_baseLink;
/**
*
* @access private
*/
var $_unsetItemActions;
function cWidgetTreeView ($uuid, $treename = false) /**
{ *
global $cfg, $auth; * @access private
*/
cTree::cTree(); var $_setAttributeActions;
$this->_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
/** /**
* removes the action from all treeitems. *
* * @access private
* @param cApiClickableAction action Removes the action from the global context. */
* @return void var $_unsetAttributeActions;
* @access public var $_baseLink;
*/
function removeGlobalAction( $action )
{
} // end of member function removeGlobalAction
/** function __construct($uuid, $treename = false) {
* flushes all actions global $cfg, $auth;
*
* @return void
* @access public
*/
function flushGlobalActions( )
{
} // end of member function flushGlobalActions
/** parent::__construct();
* 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
/** $this->_uuid = $uuid;
* unsets an action from a specific item. Note that you can unset global actions //$this->setGridlineMode(TREEVIEW_GRIDLINE_DOTTED);
* 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
/** if ($treename != false) {
* flushes all actions for a specific item $this->setTreeName($treename);
* }
* @param mixed item cTreeItem-Object or an id of a TreeItem-Object
* @return void
* @access public
*/
function flushItemActions( $item )
{
} // end of member function flushItemActions
/** $this->setBackgroundColors(array($cfg['color']['table_light'], $cfg['color']['table_dark']));
* 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->_user = new cApiUser($auth->auth["uid"]);
* 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
/** function processParameters() {
* Removes all actions for items with specific attributes if (($items = $this->_user->getUserProperty("expandstate", $this->_uuid)) !== false) {
* $list = unserialize($items);
* @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
/** foreach ($list as $litem) {
* $this->setCollapsed($litem);
* }
* @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) if (!empty($this->_name)) {
{ $treename = $this->_name . "_";
$this->_backgroundMode = $mode; }
}
function setMouseoverMode ($mode)
{
$this->_mouseoverMode = $mode;
}
function setBackgroundColors ($colors)
{
$this->_backgroundColors = $colors;
}
/** if (array_key_exists($treename . "collapse", $_GET)) {
* $this->setCollapsed($_GET[$treename . "collapse"]);
* }
* @return void
* @access public if (array_key_exists($treename . "expand", $_GET)) {
*/ $this->setExpanded($_GET[$treename . "expand"]);
function render ($with_root = true) }
{
$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); $objects = $this->flatTraverse(0);
if ($with_root == false) if ($with_root == false) {
{ unset($objects[0]);
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 = new cHTMLImage;
$img_spacer->updateAttributes(array('width' => '16', 'height' => '20')); $img_spacer->updateAttributes(array('width' => '16', 'height' => '20'));
$img_spacer->setAlt(""); $img_spacer->setAlt("");
$img_spacer->setSrc("images/spacer.gif"); $img_spacer->setSrc("images/spacer.gif");
$img_spacer->advanceID(); $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;
}
}
}
if ($this->_backgroundMode == TREEVIEW_BACKGROUND_SHADED) $r_table->setCellPadding(0);
{ $r_table->setCellSpacing(0);
if (current($this->_backgroundColors) === false) $r_table->setWidth("100%");
{ $r_rightcell->setStyleDefinition("padding-left", "3px");
reset($this->_backgroundColors); $r_rightcell->setVerticalAlignment("middle");
} $r_leftcell->setVerticalAlignment("middle");
$r_leftcell->updateAttributes(array("nowrap" => "nowrap"));
$color = current($this->_backgroundColors); $r_rightcell->updateAttributes(array("nowrap" => "nowrap"));
next($this->_backgroundColors); $r_actioncell->updateAttributes(array("nowrap" => "nowrap"));
$r_leftcell->setWidth("1%");
$r_rightcell->setBackgroundColor($color); $r_rightcell->setWidth("100%");
$r_leftcell->setBackgroundColor($color); $r_actioncell->setAlignment("right");
$r_actioncell->setBackgroundColor($color); $r_actioncell->setWidth("1%");
}
$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(); if (!is_object($this->_baseLink)) {
$this->_baseLink = new cHTMLLink;
unset($out);
} }
return ('<table cellspacing="0" cellpadding="0" width="100%" border="0"><tr><td>'.$result.'</td></tr></table>');
} // end of member function render
function _getExpandCollapseIcon ($object) $lastitem = array();
{ foreach ($objects as $key => $object) {
if ($object->_collapsed == true) $img->setAlt("");
{ $r_table->advanceID();
return ($this->_buildImagePath("grid_expand.gif")); $r_rightcell->advanceID();
} else { $r_leftcell->advanceID();
return ($this->_buildImagePath("grid_collapse.gif")); $r_row->advanceID();
} $r_actioncell->advanceID();
}
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;
}
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 ('<table cellspacing="0" cellpadding="0" width="100%" border="0"><tr><td>' . $result . '</td></tr></table>');
}
// 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;
}
}

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -26,271 +27,230 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
/** /**
* Contenido Table view * Contenido Table view
* *
* @author Timo A. Hummel <timo.hummel@4fb.de> * @author Timo A. Hummel <timo.hummel@4fb.de>
*/ */
class cTableView 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;
$this->tableid = ""; var $items;
$this->tablebordercolor = $cfg['color']['table_border']; var $captions;
$this->setAccessKey('s'); var $id;
$this->custom = array(); 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 UI_Table_Form($name, $action = "", $method = "post") {
global $sess, $cfg;
}
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 = "&nbsp;";
}
if ($caption == "")
{
$caption = "&nbsp;";
}
$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->formname = $name;
{
$this->cancelLink = $link; if ($action == "") {
} $this->formaction = "main.php";
} else {
function addHeader ($header) $this->formaction = $action;
{ }
$this->header = $header;
} $this->formmethod = $method;
function setSubmitJS ($js) $this->tableid = "";
{ $this->tablebordercolor = $cfg['color']['table_border'];
$this->submitjs = $js; $this->setAccessKey('s');
} $this->custom = array();
function setAccessKey ($key) $this->setActionButton("submit", "images/but_ok.gif", i18n("Save changes"), "s");
{ }
$this->accessKey = $key;
} function setVar($name, $value) {
$this->formvars[$name] = $value;
function setActionEvent ($id, $event) }
{
$this->custom[$id]["event"] = $event; function add($caption, $field, $rowname = "") {
} if (is_array($field)) {
function setActionButton ($id, $image, $description = "", $accesskey = false, $action = false) foreach ($field as $value) {
{ if (is_object($value) && method_exists($value, "render")) {
$this->custom[$id]["image"] = $image; $n .= $value->render();
$this->custom[$id]["type"] = "actionsetter"; } else {
$this->custom[$id]["action"] = $action; $n .= $value;
$this->custom[$id]["description"] = $description; }
$this->custom[$id]["accesskey"] = $accesskey; }
$this->custom[$id]["event"] = "";
} $field = $n;
}
function unsetActionButton ($id) if (is_object($field) && method_exists($field, "render")) {
{ $n = $field->render();
unset($this->custom[$id]); $field = $n;
} }
if ($field == "") {
$field = "&nbsp;";
function render ($return = true) }
{
global $sess, $cfg; if ($caption == "") {
$caption = "&nbsp;";
$tpl = new Template; }
$extra = ""; $this->id++;
$this->items[$this->id] = $field;
$this->captions[$this->id] = $caption;
$form = '<form enctype="multipart/form-data" style="margin:0px" name="'.$this->formname.'" method="'.$this->formmethod.'" action="'.$this->formaction.'">'."\n";
$this->formvars["contenido"] = $sess->id; if ($rowname == "") {
$rowname = $this->id;
if (is_array($this->formvars)) }
{
foreach ($this->formvars as $key => $value) $this->rownames[$this->id] = $rowname;
{ }
$form .= '<input type="hidden" name="'.$key.'" value="'.$value.'">'."\n";
} function addCancel($link) {
} $this->cancelLink = $link;
}
if (!array_key_exists("action", $this->formvars))
{ function addHeader($header) {
$form .= '<input type="hidden" name="action" value="">'; $this->header = $header;
} }
$tpl->set('s', 'FORM', $form); function setSubmitJS($js) {
$tpl->set('s', 'ID', $this->tableid); $this->submitjs = $js;
$tpl->set('s', 'BORDERCOLOR', $this->tablebordercolor); }
if ($this->header != "") function setAccessKey($key) {
{ $this->accessKey = $key;
$header = '<tr class="text_medium" style="background-color: '.$cfg["color"]["table_header"].';">'; }
$header .= '<td colspan="2" valign="top" style="border: 0px; border-top:1px; border-right:1px;border-color: '.$cfg["color"]["table_border"].'; border-style: solid;">'.$this->header.'</td></tr>';
} function setActionEvent($id, $event) {
$this->custom[$id]["event"] = $event;
$tpl->set('s', 'HEADER', $header); }
$dark = false; function setActionButton($id, $image, $description = "", $accesskey = false, $action = false) {
$this->custom[$id]["image"] = $image;
if (is_array($this->items)) $this->custom[$id]["type"] = "actionsetter";
{ $this->custom[$id]["action"] = $action;
foreach ($this->items as $key => $value) $this->custom[$id]["description"] = $description;
{ $this->custom[$id]["accesskey"] = $accesskey;
$tpl->set('d', 'CATNAME', $this->captions[$key]); $this->custom[$id]["event"] = "";
$tpl->set('d', 'CATFIELD', $value); }
$tpl->set('d', 'ROWNAME', $this->rownames[$key]);
function unsetActionButton($id) {
$dark = !$dark; unset($this->custom[$id]);
if ($dark) { }
$bgColor = $cfg["color"]["table_dark"];
} else { function render($return = true) {
$bgColor = $cfg["color"]["table_light"]; global $sess, $cfg;
}
$tpl = new Template;
$tpl->set('d', 'BGCOLOR', $bgColor);
$tpl->set('d', 'BORDERCOLOR', $this->tablebordercolor); $extra = "";
$tpl->next();
}
} $form = '<form enctype="multipart/form-data" style="margin:0px" name="' . $this->formname . '" method="' . $this->formmethod . '" action="' . $this->formaction . '">' . "\n";
$this->formvars["contenido"] = $sess->id;
$tpl->set('s', 'CONTENIDOPATH',$cfg["path"]["contenido_fullhtml"]);
if (is_array($this->formvars)) {
foreach ($this->formvars as $key => $value) {
$form .= '<input type="hidden" name="' . $key . '" value="' . $value . '">' . "\n";
}
}
if (!array_key_exists("action", $this->formvars)) {
$form .= '<input type="hidden" name="action" value="">';
}
$tpl->set('s', 'FORM', $form);
$tpl->set('s', 'ID', $this->tableid);
$tpl->set('s', 'BORDERCOLOR', $this->tablebordercolor);
if ($this->header != "") {
$header = '<tr class="text_medium" style="background-color: ' . $cfg["color"]["table_header"] . ';">';
$header .= '<td colspan="2" valign="top" style="border: 0px; border-top:1px; border-right:1px;border-color: ' . $cfg["color"]["table_border"] . '; border-style: solid;">' . $this->header . '</td></tr>';
}
$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 = '<img src="' . $cfg["path"]["contenido_fullhtml"] . 'images/but_cancel.gif" border="0">';
$tpl->set('s', 'CANCELLINK', '<a href="' . $this->cancelLink . '">' . $img . '</a>');
} 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 .= '<input style="margin-left: 5px;" title="' . $value["description"] . '" alt="' . $value["description"] . '" type="image" src="' . $value["image"] . '" name="submit" onclick="' . $onclick . '" ' . $accesskey . '>';
}
$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 = '<img src="'.$cfg["path"]["contenido_fullhtml"].'images/but_cancel.gif" border="0">';
$tpl->set('s', 'CANCELLINK', '<a href="'.$this->cancelLink.'">'.$img.'</a>');
} 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 .= '<input style="margin-left: 5px;" title="'.$value["description"].'" alt="'.$value["description"].'" type="image" src="'.$value["image"].'" name="submit" onclick="'.$onclick.'" '.$accesskey.'>';
}
$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;
}
}
} }
?>