PHP Version Compatibility; removed deprecated constructors
Dieser Commit ist enthalten in:
Ursprung
c0415492d2
Commit
3490184008
|
@ -33,12 +33,6 @@ class cApiActionCollection extends ItemCollection {
|
|||
parent::__construct($cfg['tab']['actions'], 'idaction');
|
||||
$this->_setItemClass("cApiAction");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function cApiActionCollection() {
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -99,11 +93,5 @@ class cApiAction extends Item {
|
|||
// @todo Where is this used???
|
||||
$this->_wantParameters = array();
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function cApiAction($mId = false) {
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct($mId);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -41,7 +41,7 @@ class Action {
|
|||
* Constructor Function
|
||||
* @param
|
||||
*/
|
||||
function Action() {
|
||||
function __construct() {
|
||||
// empty
|
||||
} // end function
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class ActiveUsers {
|
|||
*
|
||||
* @return
|
||||
* */
|
||||
function ActiveUsers($oDb, $oCfg, $oAuth) {
|
||||
function __construct($oDb, $oCfg, $oAuth) {
|
||||
|
||||
$this->oCfg = $oCfg;
|
||||
$this->oAuth = $oAuth;
|
||||
|
|
|
@ -38,7 +38,7 @@ class Area {
|
|||
* Constructor Function
|
||||
* @param
|
||||
*/
|
||||
function Area() {
|
||||
function __construct() {
|
||||
// empty
|
||||
} // end function
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class Art {
|
|||
* Constructor Function
|
||||
* @param
|
||||
*/
|
||||
function Art() {
|
||||
function __construct() {
|
||||
// empty
|
||||
} // end function
|
||||
|
||||
|
|
|
@ -144,12 +144,6 @@ class Article extends Item
|
|||
$this->loadByPrimaryKey($this->_iIdArtLang);
|
||||
$this->_getArticleContent();
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
function Article($idart, $client, $lang, $idartlang = 0) {
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct($idart, $client, $lang, $idartlang);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for idartlang of article object
|
||||
|
@ -498,13 +492,6 @@ class ArticleCollection
|
|||
$this->_getArticlesByCatId($this->idcat);
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
function ArticleCollection($options)
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Object properties
|
||||
*
|
||||
|
|
|
@ -46,13 +46,6 @@ class ArtSpecCollection extends ItemCollection
|
|||
parent::__construct($cfg['tab']['art_spec'], "idartspec");
|
||||
$this->_setItemClass("ArtSpecItem");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function ArtSpecCollection()
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,13 +66,6 @@ class ArtSpecItem extends Item
|
|||
$this->loadByPrimaryKey($mId);
|
||||
}
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function ArtSpecItem($mId = false)
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct($mId);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -72,7 +72,7 @@ class Contenido_Backend {
|
|||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function Contenido_Backend() {
|
||||
function __construct() {
|
||||
# do nothing
|
||||
} # end function
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class Cat {
|
|||
* Constructor Function
|
||||
* @param
|
||||
*/
|
||||
function Cat() {
|
||||
function __construct() {
|
||||
// empty
|
||||
} // end function
|
||||
|
||||
|
|
|
@ -43,13 +43,6 @@ class CategoryCollection extends ItemCollection
|
|||
parent::__construct($cfg["tab"]["cat"], "idcat");
|
||||
$this->_setItemClass("CategoryItem");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function CategoryCollection()
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -69,13 +62,6 @@ class CategoryItem extends Item
|
|||
}
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function CategoryItem($mId = false)
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
public function loadByPrimaryKey($key)
|
||||
{
|
||||
if (parent::loadByPrimaryKey($key)) {
|
||||
|
@ -101,13 +87,6 @@ class CategoryLanguageCollection extends ItemCollection
|
|||
parent::__construct($cfg["tab"]["cat_lang"], "idcatlang");
|
||||
$this->_setItemClass("CategoryLanguageItem");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function CategoryLanguageCollection()
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -126,13 +105,4 @@ class CategoryLanguageItem extends Item
|
|||
$this->loadByPrimaryKey($mId);
|
||||
}
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function CategoryLanguageItem($mId = false)
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct($mId);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
|
@ -52,7 +52,7 @@ class cCharacterConverter
|
|||
var $_aAliasCache;
|
||||
var $_aCharCache;
|
||||
|
||||
function cCharacterConverter ()
|
||||
function __construct ()
|
||||
{
|
||||
$this->_oDB = new DB_ConLite;
|
||||
$this->_aAliasCache = array();
|
||||
|
@ -154,5 +154,4 @@ class cCharacterConverter
|
|||
|
||||
return $sEncoding;
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
|
@ -131,7 +131,7 @@ class clDbBackup {
|
|||
$data = "DROP TABLE IF EXISTS `$sTable`;\n";
|
||||
$this->_oDb->query('SHOW CREATE TABLE `' . $sTable . '`');
|
||||
$this->_oDb->next_record();
|
||||
$row = $this->_oDb->toArray(); //@mysql_fetch_row($res);
|
||||
$row = $this->_oDb->toArray();
|
||||
$data .= $row[1] . ';' . "\n\n";
|
||||
if (!$this->_noTableData($sTable)) {
|
||||
$data .= "/*!40000 ALTER TABLE `$sTable` DISABLE KEYS */;\n";
|
||||
|
@ -194,7 +194,7 @@ class clDbBackup {
|
|||
if (!isset($rows[$column])) {
|
||||
$insert.='NULL,';
|
||||
} else if ($rows[$column] != '') {
|
||||
$insert.='\'' . mysql_escape_string($rows[$column]) . '\',';
|
||||
$insert.='\'' . $this->_oDb->escape($rows[$column]) . '\',';
|
||||
} else {
|
||||
$insert.='\'\',';
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class Client {
|
|||
* Constructor Function
|
||||
* @param
|
||||
*/
|
||||
function Client() {
|
||||
function __construct() {
|
||||
// empty
|
||||
} // end function
|
||||
|
||||
|
|
|
@ -47,13 +47,6 @@ class CommunicationCollection extends ItemCollection
|
|||
$this->_setItemClass("CommunicationItem");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function CommunicationCollection()
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new communication item
|
||||
*/
|
||||
|
@ -91,13 +84,6 @@ class CommunicationItem extends Item
|
|||
}
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function CommunicationItem($mId = false)
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct($mId);
|
||||
}
|
||||
|
||||
function store()
|
||||
{
|
||||
global $auth;
|
||||
|
@ -106,6 +92,4 @@ class CommunicationItem extends Item
|
|||
|
||||
parent::store();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -30,52 +31,41 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
class DBFSCollection extends ItemCollection {
|
||||
|
||||
class DBFSCollection extends ItemCollection
|
||||
{
|
||||
/**
|
||||
* Constructor Function
|
||||
* @param none
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
global $cfg;
|
||||
parent::__construct($cfg["tab"]["dbfs"], "iddbfs");
|
||||
$this->_setItemClass("DBFSItem");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function DBFSCollection()
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
public function outputFile($path)
|
||||
{
|
||||
public function outputFile($path) {
|
||||
global $client, $auth;
|
||||
|
||||
$path = Contenido_Security::escapeDB($path, null);
|
||||
$path = Contenido_Security::escapeDB($path, null);
|
||||
$client = Contenido_Security::toInteger($client);
|
||||
$path = $this->strip_path($path);
|
||||
$dir = dirname($path);
|
||||
$file = basename($path);
|
||||
$path = $this->strip_path($path);
|
||||
$dir = dirname($path);
|
||||
$file = basename($path);
|
||||
|
||||
if ($dir == ".") {
|
||||
$dir = "";
|
||||
}
|
||||
|
||||
$this->select("dirname = '".$dir."' AND filename = '".$file."' AND idclient = '".$client."' LIMIT 1");
|
||||
$this->select("dirname = '" . $dir . "' AND filename = '" . $file . "' AND idclient = '" . $client . "' LIMIT 1");
|
||||
|
||||
if ($item = $this->next()) {
|
||||
$properties = new PropertyCollection();
|
||||
// Check if we're allowed to access it
|
||||
if ($properties->getValue("upload", "dbfs:/".$dir."/".$file, "file", "protected") == "1") {
|
||||
if ($properties->getValue("upload", "dbfs:/" . $dir . "/" . $file, "file", "protected") == "1") {
|
||||
if ($auth->auth["uid"] == "nobody") {
|
||||
header("HTTP/1.0 403 Forbidden");
|
||||
return;
|
||||
|
@ -83,10 +73,10 @@ class DBFSCollection extends ItemCollection
|
|||
}
|
||||
$mimetype = $item->get("mimetype");
|
||||
|
||||
header("Cache-Control: ");// leave blank to avoid IE errors
|
||||
header("Pragma: ");// leave blank to avoid IE errors
|
||||
header("Cache-Control: "); // leave blank to avoid IE errors
|
||||
header("Pragma: "); // leave blank to avoid IE errors
|
||||
header("Content-Type: $mimetype");
|
||||
header("Etag: ".md5(mt_rand()));
|
||||
header("Etag: " . md5(mt_rand()));
|
||||
|
||||
// header("Content-Disposition: filename=$file");
|
||||
header("Content-Disposition: attachment; filename=$file");
|
||||
|
@ -95,23 +85,20 @@ class DBFSCollection extends ItemCollection
|
|||
}
|
||||
}
|
||||
|
||||
public function writeFromFile($localfile, $targetfile)
|
||||
{
|
||||
public function writeFromFile($localfile, $targetfile) {
|
||||
$targetfile = $this->strip_path($targetfile);
|
||||
$mimetype = mime_content_type($localfile);
|
||||
$mimetype = mime_content_type($localfile);
|
||||
|
||||
$this->write($targetfile, file_get_contents($localfile), $mimetype);
|
||||
}
|
||||
|
||||
public function writeToFile($sourcefile, $localfile)
|
||||
{
|
||||
public function writeToFile($sourcefile, $localfile) {
|
||||
$sourcefile = $this->strip_path($sourcefile);
|
||||
|
||||
file_put_contents($localfile, $this->read($sourcefile));
|
||||
}
|
||||
|
||||
public function write($file, $content = "", $mimetype = "")
|
||||
{
|
||||
public function write($file, $content = "", $mimetype = "") {
|
||||
$file = $this->strip_path($file);
|
||||
|
||||
if (!$this->file_exists($file)) {
|
||||
|
@ -120,20 +107,19 @@ class DBFSCollection extends ItemCollection
|
|||
$this->setContent($file, $content);
|
||||
}
|
||||
|
||||
public function hasFiles($path)
|
||||
{
|
||||
public function hasFiles($path) {
|
||||
global $client;
|
||||
|
||||
$path = $this->strip_path($path);
|
||||
$path = $this->strip_path($path);
|
||||
$client = Contenido_Security::toInteger($client);
|
||||
|
||||
/* Are there any subdirs? */
|
||||
$this->select("dirname LIKE '".$path."/%' AND idclient = '".$client."' LIMIT 1");
|
||||
$this->select("dirname LIKE '" . $path . "/%' AND idclient = '" . $client . "' LIMIT 1");
|
||||
if ($this->count() > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->select("dirname LIKE '".$path."%' AND idclient = '".$client."' LIMIT 2");
|
||||
$this->select("dirname LIKE '" . $path . "%' AND idclient = '" . $client . "' LIMIT 2");
|
||||
|
||||
if ($this->count() > 1) {
|
||||
return true;
|
||||
|
@ -142,18 +128,16 @@ class DBFSCollection extends ItemCollection
|
|||
}
|
||||
}
|
||||
|
||||
public function read($file)
|
||||
{
|
||||
public function read($file) {
|
||||
return ($this->getContent($file));
|
||||
}
|
||||
|
||||
public function file_exists($path)
|
||||
{
|
||||
public function file_exists($path) {
|
||||
global $client;
|
||||
|
||||
$path = $this->strip_path($path);
|
||||
$dir = dirname($path);
|
||||
$file = basename($path);
|
||||
$path = $this->strip_path($path);
|
||||
$dir = dirname($path);
|
||||
$file = basename($path);
|
||||
|
||||
if ($dir == ".") {
|
||||
$dir = "";
|
||||
|
@ -161,7 +145,7 @@ class DBFSCollection extends ItemCollection
|
|||
|
||||
$client = Contenido_Security::toInteger($client);
|
||||
|
||||
$this->select("dirname = '".$dir."' AND filename = '".$file."' AND idclient = '".$client."' LIMIT 1");
|
||||
$this->select("dirname = '" . $dir . "' AND filename = '" . $file . "' AND idclient = '" . $client . "' LIMIT 1");
|
||||
if ($this->next()) {
|
||||
return true;
|
||||
} else {
|
||||
|
@ -169,8 +153,7 @@ class DBFSCollection extends ItemCollection
|
|||
}
|
||||
}
|
||||
|
||||
public function dir_exists($path)
|
||||
{
|
||||
public function dir_exists($path) {
|
||||
global $client;
|
||||
|
||||
$path = $this->strip_path($path);
|
||||
|
@ -181,7 +164,7 @@ class DBFSCollection extends ItemCollection
|
|||
|
||||
$client = Contenido_Security::toInteger($client);
|
||||
|
||||
$this->select("dirname = '".$path."' AND filename = '.' AND idclient = '".$client."' LIMIT 1");
|
||||
$this->select("dirname = '" . $path . "' AND filename = '.' AND idclient = '" . $client . "' LIMIT 1");
|
||||
if ($this->next()) {
|
||||
return true;
|
||||
} else {
|
||||
|
@ -189,21 +172,19 @@ class DBFSCollection extends ItemCollection
|
|||
}
|
||||
}
|
||||
|
||||
public function parent_dir($path)
|
||||
{
|
||||
public function parent_dir($path) {
|
||||
$path = dirname($path);
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
public function create($path, $mimetype = "", $content = "")
|
||||
{
|
||||
public function create($path, $mimetype = "", $content = "") {
|
||||
global $client, $cfg, $auth;
|
||||
|
||||
$client = Contenido_Security::toInteger($client);
|
||||
|
||||
if (substr($path,0,1) == "/") {
|
||||
$path = substr($path,1);
|
||||
if (substr($path, 0, 1) == "/") {
|
||||
$path = substr($path, 1);
|
||||
}
|
||||
|
||||
$dir = dirname($path);
|
||||
|
@ -220,9 +201,9 @@ class DBFSCollection extends ItemCollection
|
|||
if ($file != ".") {
|
||||
if ($dir != "") {
|
||||
// Check if the directory exists. If not, create it.
|
||||
$this->select("dirname = '".$dir."' AND filename = '.' AND idclient = '".$client."' LIMIT 1");
|
||||
$this->select("dirname = '" . $dir . "' AND filename = '.' AND idclient = '" . $client . "' LIMIT 1");
|
||||
if (!$this->next()) {
|
||||
$this->create($dir."/.");
|
||||
$this->create($dir . "/.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -230,7 +211,7 @@ class DBFSCollection extends ItemCollection
|
|||
|
||||
if ($parent != ".") {
|
||||
if (!$this->dir_exists($parent)) {
|
||||
$this->create($parent."/.");
|
||||
$this->create($parent . "/.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -254,20 +235,19 @@ class DBFSCollection extends ItemCollection
|
|||
return ($item);
|
||||
}
|
||||
|
||||
public function setContent($path, $content)
|
||||
{
|
||||
public function setContent($path, $content) {
|
||||
global $client;
|
||||
|
||||
$client = Contenido_Security::toInteger($client);
|
||||
$path = $this->strip_path($path);
|
||||
$dirname = dirname($path);
|
||||
$filename = basename($path);
|
||||
$client = Contenido_Security::toInteger($client);
|
||||
$path = $this->strip_path($path);
|
||||
$dirname = dirname($path);
|
||||
$filename = basename($path);
|
||||
|
||||
if ($dirname == ".") {
|
||||
$dirname = "";
|
||||
}
|
||||
|
||||
$this->select("dirname = '".$dirname."' AND filename = '".$filename."' AND idclient = '".$client."' LIMIT 1");
|
||||
$this->select("dirname = '" . $dirname . "' AND filename = '" . $filename . "' AND idclient = '" . $client . "' LIMIT 1");
|
||||
if ($item = $this->next()) {
|
||||
$item->set("content", $content);
|
||||
$item->set("size", strlen($content));
|
||||
|
@ -275,70 +255,66 @@ class DBFSCollection extends ItemCollection
|
|||
}
|
||||
}
|
||||
|
||||
public function getSize($path)
|
||||
{
|
||||
public function getSize($path) {
|
||||
global $client;
|
||||
|
||||
$client = Contenido_Security::toInteger($client);
|
||||
$path = $this->strip_path($path);
|
||||
$dirname = dirname($path);
|
||||
$client = Contenido_Security::toInteger($client);
|
||||
$path = $this->strip_path($path);
|
||||
$dirname = dirname($path);
|
||||
$filename = basename($path);
|
||||
|
||||
if ($dirname == ".") {
|
||||
$dirname = "";
|
||||
}
|
||||
|
||||
$this->select("dirname = '".$dirname."' AND filename = '".$filename."' AND idclient = '".$client."' LIMIT 1");
|
||||
$this->select("dirname = '" . $dirname . "' AND filename = '" . $filename . "' AND idclient = '" . $client . "' LIMIT 1");
|
||||
if ($item = $this->next()) {
|
||||
return $item->get("size");
|
||||
}
|
||||
}
|
||||
|
||||
public function getContent($path)
|
||||
{
|
||||
public function getContent($path) {
|
||||
global $client;
|
||||
|
||||
$client = Contenido_Security::toInteger($client);
|
||||
$dirname = dirname($path);
|
||||
$filename = basename($path);
|
||||
|
||||
if ($dirname == ".") {
|
||||
$dirname = "";
|
||||
}
|
||||
|
||||
$this->select("dirname = '".$dirname."' AND filename = '".$filename."' AND idclient = '".$client."' LIMIT 1");
|
||||
if ($item = $this->next()) {
|
||||
return ($item->get("content"));
|
||||
}
|
||||
}
|
||||
|
||||
public function remove($path)
|
||||
{
|
||||
global $client;
|
||||
|
||||
$client = Contenido_Security::toInteger($client);
|
||||
$path = $this->strip_path($path);
|
||||
$dirname = dirname($path);
|
||||
$client = Contenido_Security::toInteger($client);
|
||||
$dirname = dirname($path);
|
||||
$filename = basename($path);
|
||||
|
||||
if ($dirname == ".") {
|
||||
$dirname = "";
|
||||
}
|
||||
|
||||
$this->select("dirname = '".$dirname."' AND filename = '".$filename."' AND idclient = '".$client."' LIMIT 1");
|
||||
$this->select("dirname = '" . $dirname . "' AND filename = '" . $filename . "' AND idclient = '" . $client . "' LIMIT 1");
|
||||
if ($item = $this->next()) {
|
||||
return ($item->get("content"));
|
||||
}
|
||||
}
|
||||
|
||||
public function remove($path) {
|
||||
global $client;
|
||||
|
||||
$client = Contenido_Security::toInteger($client);
|
||||
$path = $this->strip_path($path);
|
||||
$dirname = dirname($path);
|
||||
$filename = basename($path);
|
||||
|
||||
if ($dirname == ".") {
|
||||
$dirname = "";
|
||||
}
|
||||
|
||||
$this->select("dirname = '" . $dirname . "' AND filename = '" . $filename . "' AND idclient = '" . $client . "' LIMIT 1");
|
||||
if ($item = $this->next()) {
|
||||
$this->delete($item->get("iddbfs"));
|
||||
}
|
||||
}
|
||||
|
||||
public function strip_path($path)
|
||||
{
|
||||
if (substr($path,0,5) == "dbfs:") {
|
||||
$path = substr($path,5);
|
||||
public function strip_path($path) {
|
||||
if (substr($path, 0, 5) == "dbfs:") {
|
||||
$path = substr($path, 5);
|
||||
}
|
||||
|
||||
if (substr($path,0,1) == "/") {
|
||||
$path = substr($path,1);
|
||||
if (substr($path, 0, 1) == "/") {
|
||||
$path = substr($path, 1);
|
||||
}
|
||||
|
||||
return $path;
|
||||
|
@ -349,15 +325,14 @@ class DBFSCollection extends ItemCollection
|
|||
* @param datatype $sPath
|
||||
* @return bool $bAvailable
|
||||
*/
|
||||
public function checkTimeManagement($sPath, $oProperties)
|
||||
{
|
||||
public function checkTimeManagement($sPath, $oProperties) {
|
||||
global $contenido;
|
||||
if ($contenido) {
|
||||
return true;
|
||||
}
|
||||
$sPath = Contenido_Security::toString($sPath);
|
||||
$sPath = Contenido_Security::toString($sPath);
|
||||
$bAvailable = true;
|
||||
$iTimeMng = Contenido_Security::toInteger($oProperties->getValue("upload", $sPath, "file", "timemgmt"));
|
||||
$iTimeMng = Contenido_Security::toInteger($oProperties->getValue("upload", $sPath, "file", "timemgmt"));
|
||||
if ($iTimeMng == 0) {
|
||||
return true;
|
||||
}
|
||||
|
@ -366,8 +341,7 @@ class DBFSCollection extends ItemCollection
|
|||
|
||||
$iNow = time();
|
||||
|
||||
if ($iNow < $this->dateToTimestamp($sStartDate) ||
|
||||
($iNow > $this->dateToTimestamp($sEndDate) && (int)$this->dateToTimestamp($sEndDate) > 0)) {
|
||||
if ($iNow < $this->dateToTimestamp($sStartDate) || ($iNow > $this->dateToTimestamp($sEndDate) && (int) $this->dateToTimestamp($sEndDate) > 0)) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -379,21 +353,19 @@ class DBFSCollection extends ItemCollection
|
|||
* @param string $sDate
|
||||
* @return int $iTimestamp
|
||||
*/
|
||||
public function dateToTimestamp($sDate)
|
||||
{
|
||||
public function dateToTimestamp($sDate) {
|
||||
return strtotime($sDate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class DBFSItem extends Item {
|
||||
|
||||
class DBFSItem extends Item
|
||||
{
|
||||
/**
|
||||
* Constructor Function
|
||||
* @param mixed $mId Specifies the ID of item to load
|
||||
*/
|
||||
public function __construct($mId = false)
|
||||
{
|
||||
public function __construct($mId = false) {
|
||||
global $cfg;
|
||||
parent::__construct($cfg["tab"]["dbfs"], "iddbfs");
|
||||
if ($mId !== false) {
|
||||
|
@ -401,15 +373,7 @@ class DBFSItem extends Item
|
|||
}
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function DBFSItem($mId = false)
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
public function store() {
|
||||
global $auth;
|
||||
|
||||
$this->set("modified", date("Y-m-d H:i:s"), false);
|
||||
|
@ -418,8 +382,7 @@ class DBFSItem extends Item
|
|||
parent::store();
|
||||
}
|
||||
|
||||
public function setField($field, $value, $safe = true)
|
||||
{
|
||||
public function setField($field, $value, $safe = true) {
|
||||
if ($field == "dirname" || $field == "filename" || $field == "mimetype") {
|
||||
// Don't do safe encoding
|
||||
$safe = false;
|
||||
|
@ -430,6 +393,5 @@ class DBFSItem extends Item
|
|||
|
||||
parent::setField($field, $value, $safe);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
|
@ -40,7 +40,7 @@ class ExcelWorksheet
|
|||
var $_title;
|
||||
var $_filename;
|
||||
|
||||
function ExcelWorksheet ($title, $filename)
|
||||
function __construct ($title, $filename)
|
||||
{
|
||||
$this->_title = Contenido_Security::escapeDB($title, null);
|
||||
$this->_filename = Contenido_Security::escapeDB($filename, null);
|
||||
|
|
|
@ -99,7 +99,7 @@ class Form {
|
|||
* Constructor Function
|
||||
* @param
|
||||
*/
|
||||
function Form() {
|
||||
function __construct() {
|
||||
// empty
|
||||
} // end function
|
||||
|
||||
|
@ -279,7 +279,7 @@ class Form {
|
|||
}
|
||||
|
||||
// FormField instance
|
||||
$field = new FormField;
|
||||
$field = new FormField();
|
||||
|
||||
// Get Code for one element
|
||||
$tmp_replacements[] = $field->GenerateCode($this->fields[$i]);
|
||||
|
@ -364,7 +364,7 @@ class Form {
|
|||
|
||||
foreach ($this->fields as $id => $element) {
|
||||
|
||||
$check = new FormCheck;
|
||||
$check = new FormCheck();
|
||||
|
||||
switch (strtolower($element['checktype'])) {
|
||||
|
||||
|
@ -447,7 +447,7 @@ class FormField {
|
|||
/**
|
||||
* Constructor Function
|
||||
*/
|
||||
function FormField() {
|
||||
function __construct() {
|
||||
// do nothing
|
||||
} // end function
|
||||
|
||||
|
@ -625,7 +625,7 @@ class FormCheck {
|
|||
* Constructor function
|
||||
* @access private
|
||||
*/
|
||||
function FormCheck () {
|
||||
function __construct () {
|
||||
// empty
|
||||
} // end function
|
||||
|
||||
|
@ -678,6 +678,4 @@ class FormCheck {
|
|||
return (preg_match('/^[a-z0-9\.]+@[a-z0-9\.]+\.[a-z]+$/i', $value)) ? true : false;
|
||||
} // end function
|
||||
|
||||
} // end class
|
||||
|
||||
?>
|
||||
} // end class
|
|
@ -50,13 +50,6 @@ class FrontendGroupCollection extends ItemCollection
|
|||
$this->_setItemClass("FrontendGroup");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function FrontendGroupCollection()
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new group
|
||||
* @param $groupname string Specifies the groupname
|
||||
|
@ -122,13 +115,6 @@ class FrontendGroup extends Item
|
|||
$this->loadByPrimaryKey($mId);
|
||||
}
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function FrontendGroup($mId = false)
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -150,13 +136,6 @@ class FrontendGroupMemberCollection extends ItemCollection
|
|||
$this->_setItemClass("FrontendGroupMember");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function FrontendGroupMemberCollection()
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new association
|
||||
* @param $idfrontendgroup int specifies the frontend group
|
||||
|
@ -237,13 +216,4 @@ class FrontendGroupMember extends Item
|
|||
$this->loadByPrimaryKey($mId);
|
||||
}
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function FrontendGroupMember($mId = false)
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct($mId);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
|
@ -54,13 +54,6 @@ class FrontendPermissionCollection extends ItemCollection
|
|||
$this->_setItemClass("FrontendPermission");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function FrontendPermissionCollection()
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new permission entry
|
||||
* @param $group string Specifies the frontend group
|
||||
|
@ -157,13 +150,4 @@ class FrontendPermission extends Item
|
|||
$this->loadByPrimaryKey($mId);
|
||||
}
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function FrontendPermission($mId = false)
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct($mId);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
|
@ -50,13 +50,6 @@ class FrontendUserCollection extends ItemCollection
|
|||
$this->_setItemClass("FrontendUser");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function FrontendUserCollection()
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a specific user already exists
|
||||
* @param $sUsername string specifies the username to search for
|
||||
|
@ -157,13 +150,6 @@ class FrontendUser extends Item
|
|||
}
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function FrontendUser($mId = false)
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct($mId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden setField method to md5 the password
|
||||
* Sets the value of a specific field
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -29,8 +30,7 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
@ -41,8 +41,7 @@ if(!defined('CON_FRAMEWORK')) {
|
|||
* @version 1.0
|
||||
* @copyright four for business AG 2003
|
||||
*/
|
||||
class Groups
|
||||
{
|
||||
class Groups {
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
function Groups($table = '')
|
||||
{
|
||||
function __construct($table = '') {
|
||||
if ($table == '') {
|
||||
global $cfg;
|
||||
$this->table = $cfg['tab']['groups'];
|
||||
|
@ -75,49 +73,43 @@ class Groups
|
|||
$this->db = new DB_ConLite();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes the specified group from the database
|
||||
*
|
||||
* @param string $groupid Specifies the group ID
|
||||
* @return bool True if the delete was successful
|
||||
*/
|
||||
function deleteGroupByID($groupid)
|
||||
{
|
||||
function deleteGroupByID($groupid) {
|
||||
$sql = "DELETE FROM "
|
||||
.$this->table.
|
||||
" WHERE group_id = '".Contenido_Security::escapeDB($groupid, $this->db)."'";
|
||||
. $this->table .
|
||||
" WHERE group_id = '" . Contenido_Security::escapeDB($groupid, $this->db) . "'";
|
||||
|
||||
$this->db->query($sql);
|
||||
return ($this->db->affected_rows() == 0) ? false : true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes the specified group from the database.
|
||||
*
|
||||
* @param string $groupid Specifies the groupname
|
||||
* @return bool True if the delete was successful
|
||||
*/
|
||||
function deleteGroupByGroupname($groupname)
|
||||
{
|
||||
function deleteGroupByGroupname($groupname) {
|
||||
$sql = "DELETE FROM "
|
||||
.$this->table.
|
||||
" WHERE groupname = '".Contenido_Security::escapeDB($groupname, $this->db)."'";
|
||||
. $this->table .
|
||||
" WHERE groupname = '" . Contenido_Security::escapeDB($groupname, $this->db) . "'";
|
||||
|
||||
$this->db->query($sql);
|
||||
return ($this->db->affected_rows() == 0) ? false : true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns all groups which are accessible by the current group.
|
||||
*
|
||||
* @param array $perms
|
||||
* @return array Array of group objects
|
||||
*/
|
||||
function getAccessibleGroups($perms)
|
||||
{
|
||||
function getAccessibleGroups($perms) {
|
||||
global $cfg;
|
||||
|
||||
$clientclass = new Client();
|
||||
|
@ -127,12 +119,12 @@ class Groups
|
|||
$db = new DB_ConLite();
|
||||
|
||||
foreach ($allClients as $key => $value) {
|
||||
if (in_array("client[".$key."]", $perms) || in_array("admin[".$key."]", $perms)) {
|
||||
$limit[] = 'perms LIKE "%client['.Contenido_Security::escapeDB($key, $db).']%"';
|
||||
if (in_array("client[" . $key . "]", $perms) || in_array("admin[" . $key . "]", $perms)) {
|
||||
$limit[] = 'perms LIKE "%client[' . Contenido_Security::escapeDB($key, $db) . ']%"';
|
||||
}
|
||||
|
||||
if (in_array("admin[".$key."]", $perms)) {
|
||||
$limit[] = 'perms LIKE "%admin['.Contenido_Security::escapeDB($key, $db).']%"';
|
||||
if (in_array("admin[" . $key . "]", $perms)) {
|
||||
$limit[] = 'perms LIKE "%admin[' . Contenido_Security::escapeDB($key, $db) . ']%"';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,8 +139,8 @@ class Groups
|
|||
$sql = "SELECT
|
||||
group_id, groupname, description
|
||||
FROM
|
||||
". $cfg['tab']['groups']
|
||||
. " WHERE 1 AND " .$limitSQL;
|
||||
" . $cfg['tab']['groups']
|
||||
. " WHERE 1 AND " . $limitSQL;
|
||||
|
||||
$db->query($sql);
|
||||
|
||||
|
@ -156,7 +148,7 @@ class Groups
|
|||
|
||||
while ($db->next_record()) {
|
||||
$groups[$db->f('group_id')] = array(
|
||||
'groupname' => substr($db->f('groupname'), 4),
|
||||
'groupname' => substr($db->f('groupname'), 4),
|
||||
'description' => $db->f('description'),
|
||||
);
|
||||
}
|
||||
|
@ -173,8 +165,7 @@ class Groups
|
|||
* @version 1.0
|
||||
* @copyright four for business 2003
|
||||
*/
|
||||
class Group
|
||||
{
|
||||
class Group {
|
||||
|
||||
/**
|
||||
* Storage of the source table to use for the group informations
|
||||
|
@ -209,8 +200,7 @@ class Group
|
|||
*
|
||||
* @param string $table The table to use as information source
|
||||
*/
|
||||
function Group($table = '')
|
||||
{
|
||||
function __construct($table = '') {
|
||||
if ($table == '') {
|
||||
global $cfg;
|
||||
$this->table = $cfg['tab']['groups'];
|
||||
|
@ -221,19 +211,17 @@ class Group
|
|||
$this->db = new DB_ConLite();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads a group from the database by its groupname.
|
||||
*
|
||||
* @param string $groupname Specifies the groupname
|
||||
* @return bool True if the load was successful
|
||||
*/
|
||||
function loadGroupByGroupname($groupname)
|
||||
{
|
||||
function loadGroupByGroupname($groupname) {
|
||||
// SQL-Statement to select by groupname
|
||||
$sql = "SELECT * FROM ".
|
||||
$sql = "SELECT * FROM " .
|
||||
$this->table
|
||||
." WHERE groupname = '" .Contenido_Security::escapeDB($groupname, $this->db)."'";
|
||||
. " WHERE groupname = '" . Contenido_Security::escapeDB($groupname, $this->db) . "'";
|
||||
|
||||
// Query the database
|
||||
$this->db->query($sql);
|
||||
|
@ -246,19 +234,17 @@ class Group
|
|||
$this->values = $this->db->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads a group from the database by its groupID.
|
||||
*
|
||||
* @param string $groupid Specifies the groupID
|
||||
* @return bool True if the load was successful
|
||||
*/
|
||||
function loadGroupByGroupID($groupID)
|
||||
{
|
||||
function loadGroupByGroupID($groupID) {
|
||||
// SQL-Statement to select by groupID
|
||||
$sql = "SELECT * FROM ".
|
||||
$sql = "SELECT * FROM " .
|
||||
$this->table
|
||||
." WHERE group_id = '" .Contenido_Security::escapeDB($groupID, $this->db)."'";
|
||||
. " WHERE group_id = '" . Contenido_Security::escapeDB($groupID, $this->db) . "'";
|
||||
|
||||
// Query the database
|
||||
$this->db->query($sql);
|
||||
|
@ -271,52 +257,46 @@ class Group
|
|||
$this->values = $this->db->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the value of a specific field.
|
||||
*
|
||||
* @param string $field Specifies the field to retrieve
|
||||
* @return mixed Value of the field
|
||||
*/
|
||||
function getField($field)
|
||||
{
|
||||
function getField($field) {
|
||||
return ($this->values[$field]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the value of a specific field.
|
||||
*
|
||||
* @param string $field Specifies the field to set
|
||||
* @param string $value Specifies the value to set
|
||||
*/
|
||||
function setField($field, $value)
|
||||
{
|
||||
function setField($field, $value) {
|
||||
$this->modifiedValues[$field] = true;
|
||||
$this->values[$field] = $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stores the modified group object to the database.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function store()
|
||||
{
|
||||
$sql = "UPDATE " . $this->table ." SET ";
|
||||
function store() {
|
||||
$sql = "UPDATE " . $this->table . " SET ";
|
||||
$first = true;
|
||||
|
||||
foreach ($this->modifiedValues as $key => $value) {
|
||||
if ($first == true) {
|
||||
$sql .= "$key = '" . $this->values[$key] ."'";
|
||||
$sql .= "$key = '" . $this->values[$key] . "'";
|
||||
} else {
|
||||
$sql .= ", $key = '" . $this->values[$key] ."'";
|
||||
$sql .= ", $key = '" . $this->values[$key] . "'";
|
||||
}
|
||||
$first = false;
|
||||
}
|
||||
|
||||
$sql .= " WHERE group_id = '" .Contenido_Security::escapeDB($this->values['group_id'], $this->db)."'";
|
||||
$sql .= " WHERE group_id = '" . Contenido_Security::escapeDB($this->values['group_id'], $this->db) . "'";
|
||||
|
||||
$this->db->query($sql);
|
||||
|
||||
|
@ -328,16 +308,15 @@ class Group
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
function insert()
|
||||
{
|
||||
$sql = "INSERT INTO " . $this->table ." SET ";
|
||||
function insert() {
|
||||
$sql = "INSERT INTO " . $this->table . " SET ";
|
||||
$first = true;
|
||||
|
||||
foreach ($this->modifiedValues as $key => $value) {
|
||||
if ($first == true) {
|
||||
$sql .= "$key = '" . $this->values[$key] ."'";
|
||||
$sql .= "$key = '" . $this->values[$key] . "'";
|
||||
} else {
|
||||
$sql .= ", $key = '" . $this->values[$key] ."'";
|
||||
$sql .= ", $key = '" . $this->values[$key] . "'";
|
||||
}
|
||||
$first = false;
|
||||
}
|
||||
|
@ -345,7 +324,6 @@ class Group
|
|||
return ($this->db->query($sql));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the group property
|
||||
*
|
||||
|
@ -353,14 +331,13 @@ class Group
|
|||
* @param string $name Specifies the name of the property to retrieve
|
||||
* @return string The value of the retrieved property
|
||||
*/
|
||||
function getGroupProperty($type, $name)
|
||||
{
|
||||
function getGroupProperty($type, $name) {
|
||||
global $cfg;
|
||||
|
||||
$sql = "SELECT value FROM " .$cfg['tab']['group_prop']."
|
||||
WHERE group_id = '".Contenido_Security::escapeDB($this->values['group_id'], $this->db)."'
|
||||
AND type = '".Contenido_Security::escapeDB($type, $this->db)."'
|
||||
AND name = '".Contenido_Security::escapeDB($name, $this->db)."'";
|
||||
$sql = "SELECT value FROM " . $cfg['tab']['group_prop'] . "
|
||||
WHERE group_id = '" . Contenido_Security::escapeDB($this->values['group_id'], $this->db) . "'
|
||||
AND type = '" . Contenido_Security::escapeDB($type, $this->db) . "'
|
||||
AND name = '" . Contenido_Security::escapeDB($name, $this->db) . "'";
|
||||
$this->db->query($sql);
|
||||
|
||||
if ($this->db->next_record()) {
|
||||
|
@ -370,7 +347,6 @@ class Group
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves all available properties of the group.
|
||||
*
|
||||
|
@ -379,14 +355,13 @@ class Group
|
|||
* - $arr[idgroupprop][type]
|
||||
* - $arr[idgroupprop][value]
|
||||
*/
|
||||
function getGroupProperties()
|
||||
{
|
||||
function getGroupProperties() {
|
||||
global $cfg;
|
||||
|
||||
$aProps = array();
|
||||
|
||||
$sql = "SELECT idgroupprop, type, name, value FROM " .$cfg['tab']['group_prop']."
|
||||
WHERE group_id = '".Contenido_Security::escapeDB($this->values['group_id'], $this->db)."'";
|
||||
$sql = "SELECT idgroupprop, type, name, value FROM " . $cfg['tab']['group_prop'] . "
|
||||
WHERE group_id = '" . Contenido_Security::escapeDB($this->values['group_id'], $this->db) . "'";
|
||||
$this->db->query($sql);
|
||||
|
||||
if ($this->db->num_rows() == 0) {
|
||||
|
@ -395,8 +370,8 @@ class Group
|
|||
|
||||
while ($this->db->next_record()) {
|
||||
$aProps[$this->db->f('idgroupprop')] = array(
|
||||
'name' => $this->db->f('name'),
|
||||
'type' => $this->db->f('type'),
|
||||
'name' => $this->db->f('name'),
|
||||
'type' => $this->db->f('type'),
|
||||
'value' => $this->db->f('value'),
|
||||
);
|
||||
}
|
||||
|
@ -404,7 +379,6 @@ class Group
|
|||
return $aProps;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stores a property to the database.
|
||||
*
|
||||
|
@ -412,48 +386,43 @@ class Group
|
|||
* @param string $name Specifies the name of the property to retrieve
|
||||
* @param string $value Specifies the value to insert
|
||||
*/
|
||||
function setGroupProperty($type, $name, $value)
|
||||
{
|
||||
function setGroupProperty($type, $name, $value) {
|
||||
global $cfg;
|
||||
|
||||
// Check if such an entry already exists
|
||||
if ($this->getGroupProperty($type, $name) !== false) {
|
||||
$sql = "UPDATE ".$cfg['tab']['group_prop']."
|
||||
SET value = '".Contenido_Security::escapeDB($value, $this->db)."'
|
||||
WHERE group_id = '".Contenido_Security::escapeDB($this->values['group_id'], $this->db)."'
|
||||
AND type = '".Contenido_Security::escapeDB($type, $this->db)."'
|
||||
AND name = '".Contenido_Security::escapeDB($name, $this->db)."'";
|
||||
$sql = "UPDATE " . $cfg['tab']['group_prop'] . "
|
||||
SET value = '" . Contenido_Security::escapeDB($value, $this->db) . "'
|
||||
WHERE group_id = '" . Contenido_Security::escapeDB($this->values['group_id'], $this->db) . "'
|
||||
AND type = '" . Contenido_Security::escapeDB($type, $this->db) . "'
|
||||
AND name = '" . Contenido_Security::escapeDB($name, $this->db) . "'";
|
||||
$this->db->query($sql);
|
||||
} else {
|
||||
$sql = "INSERT INTO ".$cfg['tab']['group_prop']."
|
||||
SET value = '".Contenido_Security::escapeDB($value, $this->db)."',
|
||||
group_id = '".Contenido_Security::escapeDB($this->values['group_id'], $this->db)."',
|
||||
type = '".Contenido_Security::escapeDB($type, $this->db)."',
|
||||
name = '".Contenido_Security::escapeDB($name, $this->db)."',
|
||||
idgroupprop = '".Contenido_Security::toInteger($this->db->nextid($cfg['tab']['group_prop']))."'";
|
||||
$sql = "INSERT INTO " . $cfg['tab']['group_prop'] . "
|
||||
SET value = '" . Contenido_Security::escapeDB($value, $this->db) . "',
|
||||
group_id = '" . Contenido_Security::escapeDB($this->values['group_id'], $this->db) . "',
|
||||
type = '" . Contenido_Security::escapeDB($type, $this->db) . "',
|
||||
name = '" . Contenido_Security::escapeDB($name, $this->db) . "',
|
||||
idgroupprop = '" . Contenido_Security::toInteger($this->db->nextid($cfg['tab']['group_prop'])) . "'";
|
||||
$this->db->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes a group property from the table.
|
||||
*
|
||||
* @param string $type Specifies the type (class, category etc) for the property to retrieve
|
||||
* @param string $name Specifies the name of the property to retrieve
|
||||
*/
|
||||
function deleteGroupProperty($type, $name)
|
||||
{
|
||||
function deleteGroupProperty($type, $name) {
|
||||
global $cfg;
|
||||
|
||||
// Check if such an entry already exists
|
||||
$sql = "DELETE FROM ".$cfg['tab']['group_prop']."
|
||||
WHERE group_id = '".Contenido_Security::escapeDB($this->values['group_id'], $this->db)."' AND
|
||||
type = '".Contenido_Security::escapeDB($type, $this->db)."' AND
|
||||
name = '".Contenido_Security::escapeDB($name, $this->db)."'";
|
||||
$sql = "DELETE FROM " . $cfg['tab']['group_prop'] . "
|
||||
WHERE group_id = '" . Contenido_Security::escapeDB($this->values['group_id'], $this->db) . "' AND
|
||||
type = '" . Contenido_Security::escapeDB($type, $this->db) . "' AND
|
||||
name = '" . Contenido_Security::escapeDB($name, $this->db) . "'";
|
||||
$this->db->query($sql);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -93,7 +93,7 @@ class HtmlParser {
|
|||
* Constructs an HtmlParser instance with
|
||||
* the HTML text given.
|
||||
*/
|
||||
function HtmlParser ($aHtmlText) {
|
||||
function __construct ($aHtmlText) {
|
||||
$this->iHtmlText = $aHtmlText;
|
||||
$this->iHtmlTextLength = strlen($aHtmlText);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class cHTMLValidator
|
|||
var $nestingNodes;
|
||||
var $_existingTags;
|
||||
|
||||
function cHTMLValidator()
|
||||
function __construct()
|
||||
{
|
||||
$this->doubleTags = array ("form", "head", "body", "html", "td", "tr", "table", "a", "tbody", "title", "container", "span", "div");
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ class HttpInputValidator {
|
|||
* @param string $sConfigPath
|
||||
* @return HttpInputValidator
|
||||
*/
|
||||
function HttpInputValidator($sConfigPath) {
|
||||
function __construct($sConfigPath) {
|
||||
// check config and logging path
|
||||
if (!empty($sConfigPath) && file_exists($sConfigPath)) {
|
||||
$this->sConfigPath = realpath($sConfigPath);
|
||||
|
|
|
@ -66,7 +66,7 @@ class cIterator
|
|||
* @param $aItems array Items to add
|
||||
* @return none
|
||||
*/
|
||||
function cIterator ($aItems)
|
||||
function __construct ($aItems)
|
||||
{
|
||||
if (is_array($aItems))
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -29,7 +30,6 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
@ -43,21 +43,15 @@ if (!defined('CON_FRAMEWORK')) {
|
|||
* @copyright four for business 2003
|
||||
*/
|
||||
class Languages extends cApiLanguageCollection {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param none
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
public function __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
|
||||
*/
|
||||
class Language extends cApiLanguage {
|
||||
|
||||
/**
|
||||
* Constructor Function
|
||||
* @param mixed $mId Specifies the ID of item to load
|
||||
*/
|
||||
public function __construct($mId = false)
|
||||
{
|
||||
if($mId === false) {
|
||||
public function __construct($mId = false) {
|
||||
if ($mId === false) {
|
||||
parent::__construct();
|
||||
} else {
|
||||
parent::__construct($mId);
|
||||
}
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function Language($mId = false)
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct($mId);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -70,7 +70,7 @@ class cMetaObject
|
|||
|
||||
var $_payloadObject;
|
||||
|
||||
function cMetaObject ($payload = false)
|
||||
function __construct ($payload = false)
|
||||
{
|
||||
$this->_actions = array();
|
||||
$this->_fields = array();
|
||||
|
|
|
@ -64,7 +64,7 @@ class Contenido_Navigation {
|
|||
/**
|
||||
* Constructor. Loads the XML language file using XML_Doc.
|
||||
*/
|
||||
function Contenido_Navigation() {
|
||||
function __construct() {
|
||||
global $cfg, $belang;
|
||||
|
||||
$this->xml = new XML_Doc();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -28,27 +29,17 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
class NoteCollection extends CommunicationCollection {
|
||||
|
||||
class NoteCollection extends CommunicationCollection
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$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
|
||||
*
|
||||
|
@ -58,8 +49,7 @@ class NoteCollection extends CommunicationCollection
|
|||
* @access public
|
||||
* @see ItemCollection
|
||||
*/
|
||||
public function select($where = "", $group_by = "", $order_by = "", $limit = "")
|
||||
{
|
||||
public function select($where = "", $group_by = "", $order_by = "", $limit = "") {
|
||||
if ($where == "") {
|
||||
$where = "comtype='note'";
|
||||
} else {
|
||||
|
@ -80,8 +70,7 @@ class NoteCollection extends CommunicationCollection
|
|||
* @return object The new item
|
||||
* @access public
|
||||
*/
|
||||
public function create($itemtype, $itemid, $idlang, $message, $category = "")
|
||||
{
|
||||
public function create($itemtype, $itemid, $idlang, $message, $category = "") {
|
||||
$item = parent::createNewItem();
|
||||
|
||||
$item->set("subject", "Note Item");
|
||||
|
@ -102,30 +91,26 @@ class NoteCollection extends CommunicationCollection
|
|||
|
||||
}
|
||||
|
||||
class NoteItem extends CommunicationItem
|
||||
{
|
||||
|
||||
class NoteItem extends CommunicationItem {
|
||||
|
||||
}
|
||||
|
||||
class NoteView extends cHTMLIFrame {
|
||||
|
||||
class NoteView extends cHTMLIFrame
|
||||
{
|
||||
public function NoteView($sItemType, $sItemId)
|
||||
{
|
||||
public function __construct($sItemType, $sItemId) {
|
||||
global $sess, $cfg;
|
||||
cHTMLIFrame::cHTMLIFrame();
|
||||
parent::__construct();
|
||||
$this->setSrc($sess->url("main.php?itemtype=$sItemType&itemid=$sItemId&area=note&frame=2"));
|
||||
$this->setBorder(0);
|
||||
$this->setStyleDefinition("border", "1px solid ".$cfg['color']['table_border']);
|
||||
$this->setStyleDefinition("border", "1px solid " . $cfg['color']['table_border']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class NoteList extends cHTMLDiv {
|
||||
|
||||
class NoteList extends cHTMLDiv
|
||||
{
|
||||
public function NoteList($sItemType, $sItemId)
|
||||
{
|
||||
cHTMLDiv::cHTMLDiv();
|
||||
public function __construct($sItemType, $sItemId) {
|
||||
parent::__construct();
|
||||
|
||||
$this->_sItemType = $sItemType;
|
||||
$this->_sItemId = $sItemId;
|
||||
|
@ -133,13 +118,11 @@ class NoteList extends cHTMLDiv
|
|||
$this->setStyleDefinition("width", "100%");
|
||||
}
|
||||
|
||||
public function setDeleteable($bDeleteable)
|
||||
{
|
||||
public function setDeleteable($bDeleteable) {
|
||||
$this->_bDeleteable = $bDeleteable;
|
||||
}
|
||||
|
||||
public function toHTML()
|
||||
{
|
||||
public function toHTML() {
|
||||
global $cfg, $lang;
|
||||
|
||||
$sItemType = $this->_sItemType;
|
||||
|
@ -162,10 +145,10 @@ class NoteList extends cHTMLDiv
|
|||
$items[] = 0;
|
||||
}
|
||||
|
||||
$oNoteItems->select("idcommunication IN (".implode(", ", $items).')',"", "created DESC");
|
||||
$oNoteItems->select("idcommunication IN (" . implode(", ", $items) . ')', "", "created DESC");
|
||||
|
||||
$i = array();
|
||||
$dark = false;
|
||||
$i = array();
|
||||
$dark = false;
|
||||
while ($oNoteItem = $oNoteItems->next()) {
|
||||
if ($oNoteItem->getProperty("note", "itemtype") == $sItemType && $oNoteItem->getProperty("note", "itemid") == $sItemId) {
|
||||
$j = new NoteListItem($sItemType, $sItemId, $oNoteItem->get("idcommunication"));
|
||||
|
@ -185,16 +168,15 @@ class NoteList extends cHTMLDiv
|
|||
|
||||
$result = parent::toHTML();
|
||||
|
||||
return ('<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 NoteListItem($sItemType, $sItemId, $iDeleteItem)
|
||||
{
|
||||
cHTMLDiv::cHTMLDiv();
|
||||
public function __construct($sItemType, $sItemId, $iDeleteItem) {
|
||||
parent::__construct();
|
||||
$this->setStyleDefinition("padding", "2px");
|
||||
$this->setBackground();
|
||||
$this->setDeleteable(true);
|
||||
|
@ -202,16 +184,13 @@ class NoteListItem extends cHTMLDiv
|
|||
$this->_iDeleteItem = $iDeleteItem;
|
||||
$this->_sItemType = $sItemType;
|
||||
$this->_sItemId = $sItemId;
|
||||
|
||||
}
|
||||
|
||||
public function setDeleteable($bDeleteable)
|
||||
{
|
||||
public function setDeleteable($bDeleteable) {
|
||||
$this->_bDeleteable = $bDeleteable;
|
||||
}
|
||||
|
||||
public function setBackground($dark = false)
|
||||
{
|
||||
public function setBackground($dark = false) {
|
||||
global $cfg;
|
||||
|
||||
if ($dark) {
|
||||
|
@ -221,8 +200,7 @@ class NoteListItem extends cHTMLDiv
|
|||
}
|
||||
}
|
||||
|
||||
public function setAuthor($sAuthor)
|
||||
{
|
||||
public function setAuthor($sAuthor) {
|
||||
if (strlen($sAuthor) == 32) {
|
||||
$result = getGroupOrUserName($sAuthor);
|
||||
|
||||
|
@ -234,8 +212,7 @@ class NoteListItem extends cHTMLDiv
|
|||
$this->_sAuthor = $sAuthor;
|
||||
}
|
||||
|
||||
public function setDate($iDate)
|
||||
{
|
||||
public function setDate($iDate) {
|
||||
$dateformat = getEffectiveSetting("backend", "timeformat", "Y-m-d H:i:s");
|
||||
|
||||
if (is_string($iDate)) {
|
||||
|
@ -244,31 +221,29 @@ class NoteListItem extends cHTMLDiv
|
|||
$this->_sDate = date($dateformat, $iDate);
|
||||
}
|
||||
|
||||
public function setMessage($sMessage)
|
||||
{
|
||||
public function setMessage($sMessage) {
|
||||
$this->_sMessage = $sMessage;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
public function render() {
|
||||
global $cfg, $sess;
|
||||
|
||||
$itemtype = $this->_sItemType;
|
||||
$itemid = $this->_sItemId;
|
||||
$deleteitem = $this->_iDeleteItem;
|
||||
|
||||
$table = '<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 .= '</b></td><td align="right">';
|
||||
$table .= $this->_sDate;
|
||||
|
||||
if ($this->_bDeleteable == true) {
|
||||
$oDeleteable = new cHTMLLink();
|
||||
$oDeletePic = new cHTMLImage($cfg["path"]["contenido_fullhtml"]."/images/delete.gif");
|
||||
$oDeletePic = new cHTMLImage($cfg["path"]["contenido_fullhtml"] . "/images/delete.gif");
|
||||
$oDeleteable->setContent($oDeletePic);
|
||||
$oDeleteable->setLink($sess->url("main.php?frame=2&area=note&itemtype=$itemtype&itemid=$itemid&action=note_delete&deleteitem=$deleteitem"));
|
||||
|
||||
$table .= '</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>';
|
||||
|
||||
|
@ -276,15 +251,15 @@ class NoteListItem extends cHTMLDiv
|
|||
$oMessage->setContent($this->_sMessage);
|
||||
$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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class NoteLink extends cHTMLLink
|
||||
{
|
||||
class NoteLink extends cHTMLLink {
|
||||
|
||||
/**
|
||||
* @var string Object type
|
||||
* @access private
|
||||
|
@ -321,9 +296,8 @@ class NoteLink extends cHTMLLink
|
|||
* @return none
|
||||
* @access public
|
||||
*/
|
||||
public function NoteLink($sItemType, $sItemID)
|
||||
{
|
||||
parent::cHTMLLink();
|
||||
public function __construct($sItemType, $sItemID) {
|
||||
parent::__construct();
|
||||
|
||||
$img = new cHTMLImage("images/note.gif");
|
||||
$img->setStyle("padding-left: 2px; padding-right: 2px;");
|
||||
|
@ -345,8 +319,7 @@ class NoteLink extends cHTMLLink
|
|||
* @return none
|
||||
* @access public
|
||||
*/
|
||||
public function enableHistory()
|
||||
{
|
||||
public function enableHistory() {
|
||||
$this->_bShowHistory = true;
|
||||
}
|
||||
|
||||
|
@ -356,8 +329,7 @@ class NoteLink extends cHTMLLink
|
|||
* @return none
|
||||
* @access public
|
||||
*/
|
||||
public function disableHistory()
|
||||
{
|
||||
public function disableHistory() {
|
||||
$this->_bShowHistory = false;
|
||||
}
|
||||
|
||||
|
@ -367,8 +339,7 @@ class NoteLink extends cHTMLLink
|
|||
* @return none
|
||||
* @access public
|
||||
*/
|
||||
public function enableHistoryDelete()
|
||||
{
|
||||
public function enableHistoryDelete() {
|
||||
$this->_bDeleteHistoryItems = true;
|
||||
}
|
||||
|
||||
|
@ -378,8 +349,7 @@ class NoteLink extends cHTMLLink
|
|||
* @return none
|
||||
* @access public
|
||||
*/
|
||||
public function disableHistoryDelete()
|
||||
{
|
||||
public function disableHistoryDelete() {
|
||||
$this->_bDeleteHistoryItems = false;
|
||||
}
|
||||
|
||||
|
@ -389,16 +359,14 @@ class NoteLink extends cHTMLLink
|
|||
* @return none
|
||||
* @access public
|
||||
*/
|
||||
public function render($return = false)
|
||||
{
|
||||
public function render($return = false) {
|
||||
global $sess;
|
||||
|
||||
$itemtype = $this->_sItemType;
|
||||
$itemid = $this->_sItemID;
|
||||
|
||||
$this->setEvent("click", 'javascript:window.open('."'".$sess->url("main.php?area=note&frame=1&itemtype=$itemtype&itemid=$itemid")."', 'todo', 'resizable=yes, scrollbars=yes, height=360, width=550');");
|
||||
$this->setEvent("click", 'javascript:window.open(' . "'" . $sess->url("main.php?area=note&frame=1&itemtype=$itemtype&itemid=$itemid") . "', 'todo', 'resizable=yes, scrollbars=yes, height=360, width=550');");
|
||||
return parent::render($return);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
||||
|
|
|
@ -96,13 +96,6 @@ class PropertyCollection extends ItemCollection
|
|||
$this->_setItemClass('PropertyItem');
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function PropertyCollection()
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new property item.
|
||||
*
|
||||
|
@ -432,13 +425,6 @@ class PropertyItem extends Item
|
|||
}
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function PropertyItem($mId = false)
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct($mId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores changed PropertyItem
|
||||
*/
|
||||
|
|
|
@ -152,7 +152,7 @@ class RequestPassword {
|
|||
* @param array $aCfg - The contenido configuration array
|
||||
* @access public
|
||||
*/
|
||||
function RequestPassword ($oDb, $aCfg) {
|
||||
function __construct ($oDb, $aCfg) {
|
||||
//generate new dbobject, if it does not exist
|
||||
if (!is_object($oDb)) {
|
||||
$this->oDb = new DB_ConLite();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -32,20 +33,18 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Abstract base search class. Provides general properties and functions
|
||||
* for child implementations.
|
||||
*
|
||||
* @author Murat Purc <murat@purc.de>
|
||||
*/
|
||||
abstract class SearchBaseAbstract
|
||||
{
|
||||
abstract class SearchBaseAbstract {
|
||||
|
||||
/**
|
||||
* Contenido database object
|
||||
* @var DB_ConLite
|
||||
|
@ -82,12 +81,11 @@ abstract class SearchBaseAbstract
|
|||
* @param DB_ConLite $oDB Optional database instance
|
||||
* @param bool $bDebug Optional, flag to enable debugging
|
||||
*/
|
||||
protected function __construct($oDB = null, $bDebug = false)
|
||||
{
|
||||
protected function __construct($oDB = null, $bDebug = false) {
|
||||
global $cfg, $lang, $client;
|
||||
|
||||
$this->cfg = $cfg;
|
||||
$this->lang = $lang;
|
||||
$this->cfg = $cfg;
|
||||
$this->lang = $lang;
|
||||
$this->client = $client;
|
||||
|
||||
$this->setDebug((bool) $bDebug);
|
||||
|
@ -104,8 +102,7 @@ abstract class SearchBaseAbstract
|
|||
*
|
||||
* @param bool $bDebug
|
||||
*/
|
||||
public function setDebug($bDebug)
|
||||
{
|
||||
public function setDebug($bDebug) {
|
||||
$this->bDebug = (bool) $bDebug;
|
||||
}
|
||||
|
||||
|
@ -115,8 +112,7 @@ abstract class SearchBaseAbstract
|
|||
* @param string $msg Some text
|
||||
* @param mixed $var The variable to dump
|
||||
*/
|
||||
protected function _debug($msg, $var)
|
||||
{
|
||||
protected function _debug($msg, $var) {
|
||||
if (!$this->bDebug) {
|
||||
return;
|
||||
}
|
||||
|
@ -129,8 +125,8 @@ abstract class SearchBaseAbstract
|
|||
$dump .= '</pre>' . "\n";
|
||||
echo $dump;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Contenido API - Index Object
|
||||
|
@ -162,11 +158,10 @@ abstract class SearchBaseAbstract
|
|||
* Keep in mind that class Search and SearchResult uses an instance of object Index.
|
||||
* Consider character tables in relation 'con_chartable'.
|
||||
*/
|
||||
|
||||
cInclude('includes', 'functions.encoding.php');
|
||||
|
||||
class Index extends SearchBaseAbstract
|
||||
{
|
||||
class Index extends SearchBaseAbstract {
|
||||
|
||||
/**
|
||||
* the content of the cms-types of an article
|
||||
* @var array
|
||||
|
@ -243,8 +238,7 @@ class Index extends SearchBaseAbstract
|
|||
* @param DB_ConLite $oDB Contenido Database object
|
||||
* @return void
|
||||
*/
|
||||
function Index($oDB = null)
|
||||
{
|
||||
function __construct($oDB = null) {
|
||||
parent::__construct($oDB);
|
||||
|
||||
$this->setContentTypes();
|
||||
|
@ -269,9 +263,8 @@ class Index extends SearchBaseAbstract
|
|||
* @param array $aStopwords Array with words which should not be indexed.
|
||||
* @return void
|
||||
*/
|
||||
function start($idart, $aContent, $place = 'auto', $cms_options = array(), $aStopwords = array())
|
||||
{
|
||||
if (!is_int((int)$idart) || $idart < 0) {
|
||||
function start($idart, $aContent, $place = 'auto', $cms_options = array(), $aStopwords = array()) {
|
||||
if (!is_int((int) $idart) || $idart < 0) {
|
||||
return null;
|
||||
} else {
|
||||
$this->idart = $idart;
|
||||
|
@ -310,16 +303,15 @@ class Index extends SearchBaseAbstract
|
|||
* @param none
|
||||
* @return void
|
||||
*/
|
||||
function createKeywords()
|
||||
{
|
||||
function createKeywords() {
|
||||
$tmp_keys = array();
|
||||
$replace = array(' ', '&', '<', '>', '"', ''');
|
||||
|
||||
// Only create keycodes, if some are available
|
||||
if (is_array($this->keycode)) {
|
||||
foreach($this->keycode as $idtype => $data) {
|
||||
foreach ($this->keycode as $idtype => $data) {
|
||||
if ($this->checkCmsType($idtype)) {
|
||||
foreach($data as $typeid => $code) {
|
||||
foreach ($data as $typeid => $code) {
|
||||
$this->_debug('code', $code);
|
||||
|
||||
$code = stripslashes($code); // remove backslash
|
||||
|
@ -342,7 +334,7 @@ class Index extends SearchBaseAbstract
|
|||
|
||||
if (strlen($value) > 1) {
|
||||
// do not index single characters
|
||||
$this->keywords[$value] = $this->keywords[$value] . $idtype . '-' . $typeid . ' ';
|
||||
$this->keywords[$value] = $this->keywords[$value] . $idtype . '-' . $typeid . ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -361,8 +353,7 @@ class Index extends SearchBaseAbstract
|
|||
* The index_string looks like "&12=2(CMS_HTMLHEAD-1,CMS_HTML-1)"
|
||||
* @return void
|
||||
*/
|
||||
function saveKeywords()
|
||||
{
|
||||
function saveKeywords() {
|
||||
$tmp_count = array();
|
||||
|
||||
foreach ($this->keywords as $keyword => $count) {
|
||||
|
@ -379,10 +370,10 @@ class Index extends SearchBaseAbstract
|
|||
|
||||
$nextid = $this->db->nextid($this->cfg['tab']['keywords']);
|
||||
|
||||
$sql = "INSERT INTO ".$this->cfg['tab']['keywords']."
|
||||
(keyword, ".$this->place.", idlang, idkeyword)
|
||||
$sql = "INSERT INTO " . $this->cfg['tab']['keywords'] . "
|
||||
(keyword, " . $this->place . ", idlang, idkeyword)
|
||||
VALUES
|
||||
('".Contenido_Security::escapeDB($keyword, $this->db)."', '".Contenido_Security::escapeDB($index_string, $this->db)."', ".Contenido_Security::toInteger($this->lang).", ".Contenido_Security::toInteger($nextid).")";
|
||||
('" . Contenido_Security::escapeDB($keyword, $this->db) . "', '" . Contenido_Security::escapeDB($index_string, $this->db) . "', " . Contenido_Security::toInteger($this->lang) . ", " . Contenido_Security::toInteger($nextid) . ")";
|
||||
} else {
|
||||
// if keyword allready exists, create new index_string
|
||||
if (preg_match("/&$this->idart=/", $this->keywords_old[$keyword])) {
|
||||
|
@ -391,9 +382,9 @@ class Index extends SearchBaseAbstract
|
|||
$index_string = $this->keywords_old[$keyword] . $index_string;
|
||||
}
|
||||
|
||||
$sql = "UPDATE ".$this->cfg['tab']['keywords']."
|
||||
SET ".$this->place." = '".$index_string."'
|
||||
WHERE idlang='".Contenido_Security::toInteger($this->lang)."' AND keyword='".Contenido_Security::escapeDB($keyword, $this->db)."'";
|
||||
$sql = "UPDATE " . $this->cfg['tab']['keywords'] . "
|
||||
SET " . $this->place . " = '" . $index_string . "'
|
||||
WHERE idlang='" . Contenido_Security::toInteger($this->lang) . "' AND keyword='" . Contenido_Security::escapeDB($keyword, $this->db) . "'";
|
||||
}
|
||||
$this->_debug('sql', $sql);
|
||||
|
||||
|
@ -406,19 +397,18 @@ class Index extends SearchBaseAbstract
|
|||
* @param none
|
||||
* @return void
|
||||
*/
|
||||
function deleteKeywords()
|
||||
{
|
||||
function deleteKeywords() {
|
||||
foreach ($this->keywords_del as $key_del) {
|
||||
$index_string = preg_replace("/&$this->idart=[0-9]+\([\w-,]+\)/", "", $this->keywords_old[$key_del]);
|
||||
|
||||
if (strlen($index_string) == 0) {
|
||||
// keyword is not referenced by any article
|
||||
$sql = "DELETE FROM ".$this->cfg['tab']['keywords']."
|
||||
WHERE idlang='".Contenido_Security::toInteger($this->lang)."' AND keyword='".Contenido_Security::escapeDB($key_del, $this->db)."'";
|
||||
$sql = "DELETE FROM " . $this->cfg['tab']['keywords'] . "
|
||||
WHERE idlang='" . Contenido_Security::toInteger($this->lang) . "' AND keyword='" . Contenido_Security::escapeDB($key_del, $this->db) . "'";
|
||||
} else {
|
||||
$sql = "UPDATE ".$this->cfg['tab']['keywords']."
|
||||
SET ".$this->place." = '".$index_string."'
|
||||
WHERE idlang='".Contenido_Security::toInteger($this->lang)."' AND keyword='".Contenido_Security::escapeDB($key_del, $this->db)."'";
|
||||
$sql = "UPDATE " . $this->cfg['tab']['keywords'] . "
|
||||
SET " . $this->place . " = '" . $index_string . "'
|
||||
WHERE idlang='" . Contenido_Security::toInteger($this->lang) . "' AND keyword='" . Contenido_Security::escapeDB($key_del, $this->db) . "'";
|
||||
}
|
||||
$this->_debug('sql', $sql);
|
||||
$this->db->query($sql);
|
||||
|
@ -430,17 +420,16 @@ class Index extends SearchBaseAbstract
|
|||
* @param none
|
||||
* @return void
|
||||
*/
|
||||
function getKeywords()
|
||||
{
|
||||
function getKeywords() {
|
||||
$keys = implode("','", array_keys($this->keywords));
|
||||
|
||||
$sql = "SELECT
|
||||
keyword, auto, self
|
||||
FROM
|
||||
".$this->cfg['tab']['keywords']."
|
||||
" . $this->cfg['tab']['keywords'] . "
|
||||
WHERE
|
||||
idlang=".Contenido_Security::toInteger($this->lang)." AND
|
||||
(keyword IN ('".$keys."') OR ".$this->place." REGEXP '&".Contenido_Security::toInteger($this->idart)."=')";
|
||||
idlang=" . Contenido_Security::toInteger($this->lang) . " AND
|
||||
(keyword IN ('" . $keys . "') OR " . $this->place . " REGEXP '&" . Contenido_Security::toInteger($this->idart) . "=')";
|
||||
|
||||
$this->_debug('sql', $sql);
|
||||
|
||||
|
@ -458,10 +447,9 @@ class Index extends SearchBaseAbstract
|
|||
* @param $key Keyword
|
||||
* @return $key
|
||||
*/
|
||||
function removeSpecialChars($key)
|
||||
{
|
||||
function removeSpecialChars($key) {
|
||||
$aSpecialChars = array(
|
||||
"-", "_", "'", ".", "!", "\"", "#", "$", "%", "&", "(", ")", "*", "+", ",", "/",
|
||||
"-", "_", "'", ".", "!", "\"", "#", "$", "%", "&", "(", ")", "*", "+", ",", "/",
|
||||
":", ";", "<", "=", ">", "?", "@", "[", "\\", "]", "^", "`", "{", "|", "}", "~"
|
||||
);
|
||||
|
||||
|
@ -481,14 +469,14 @@ class Index extends SearchBaseAbstract
|
|||
$key = htmlentities_iso88592($key);
|
||||
}
|
||||
|
||||
$aUmlautMap = array (
|
||||
'Ü' => 'ue',
|
||||
'ü' => 'ue',
|
||||
'Ä' => 'ae',
|
||||
'ä' => 'ae',
|
||||
'Ö' => 'oe',
|
||||
'ö' => 'oe',
|
||||
'ß' => 'ss'
|
||||
$aUmlautMap = array(
|
||||
'Ü' => 'ue',
|
||||
'ü' => 'ue',
|
||||
'Ä' => 'ae',
|
||||
'ä' => 'ae',
|
||||
'Ö' => 'oe',
|
||||
'ö' => 'oe',
|
||||
'ß' => 'ss'
|
||||
);
|
||||
|
||||
foreach ($aUmlautMap as $sUmlaut => $sMapped) {
|
||||
|
@ -508,17 +496,16 @@ class Index extends SearchBaseAbstract
|
|||
* @param $key Keyword
|
||||
* @return $key
|
||||
*/
|
||||
function addSpecialUmlauts($key)
|
||||
{
|
||||
function addSpecialUmlauts($key) {
|
||||
$key = clHtmlEntities($key, null, getEncodingByLanguage($this->db, $this->lang, $this->cfg));
|
||||
$aUmlautMap = array (
|
||||
'ue' => 'Ü',
|
||||
'ue' => 'ü',
|
||||
'ae' => 'Ä',
|
||||
'ae' => 'ä',
|
||||
'oe' => 'Ö',
|
||||
'oe' => 'ö',
|
||||
'ss' => 'ß'
|
||||
$aUmlautMap = array(
|
||||
'ue' => 'Ü',
|
||||
'ue' => 'ü',
|
||||
'ae' => 'Ä',
|
||||
'ae' => 'ä',
|
||||
'oe' => 'Ö',
|
||||
'oe' => 'ö',
|
||||
'ss' => 'ß'
|
||||
);
|
||||
|
||||
foreach ($aUmlautMap as $sUmlaut => $sMapped) {
|
||||
|
@ -534,8 +521,7 @@ class Index extends SearchBaseAbstract
|
|||
* @param array $aStopwords
|
||||
* @return void
|
||||
*/
|
||||
function setStopwords ($aStopwords)
|
||||
{
|
||||
function setStopwords($aStopwords) {
|
||||
if (is_array($aStopwords) && count($aStopwords) > 0) {
|
||||
$this->stopwords = $aStopwords;
|
||||
}
|
||||
|
@ -546,9 +532,8 @@ class Index extends SearchBaseAbstract
|
|||
* @param none
|
||||
* @return void
|
||||
*/
|
||||
function setContentTypes()
|
||||
{
|
||||
$sql = "SELECT type, idtype FROM ".$this->cfg['tab']['type'] . ' ';
|
||||
function setContentTypes() {
|
||||
$sql = "SELECT type, idtype FROM " . $this->cfg['tab']['type'] . ' ';
|
||||
$this->_debug('sql', $sql);
|
||||
$this->db->query($sql);
|
||||
while ($this->db->next_record()) {
|
||||
|
@ -562,10 +547,9 @@ class Index extends SearchBaseAbstract
|
|||
* @param none
|
||||
* @return void
|
||||
*/
|
||||
function setCmsOptions($cms_options)
|
||||
{
|
||||
function setCmsOptions($cms_options) {
|
||||
if (is_array($cms_options) && count($cms_options) > 0) {
|
||||
foreach($cms_options as $opt) {
|
||||
foreach ($cms_options as $opt) {
|
||||
$opt = strtoupper($opt);
|
||||
|
||||
if (strlen($opt) > 0) {
|
||||
|
@ -591,15 +575,13 @@ class Index extends SearchBaseAbstract
|
|||
*
|
||||
* @return bolean
|
||||
*/
|
||||
function checkCmsType($idtype)
|
||||
{
|
||||
function checkCmsType($idtype) {
|
||||
$idtype = strtoupper($idtype);
|
||||
return (in_array($idtype, $this->cms_options)) ? false : true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Contenido API - Search Object
|
||||
*
|
||||
|
@ -703,9 +685,7 @@ class Index extends SearchBaseAbstract
|
|||
* @author Willi Man
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
*/
|
||||
|
||||
class Search extends SearchBaseAbstract
|
||||
{
|
||||
class Search extends SearchBaseAbstract {
|
||||
|
||||
/**
|
||||
* Instance of class Index
|
||||
|
@ -803,8 +783,7 @@ class Search extends SearchBaseAbstract
|
|||
* @param DB_ConLite $oDB Optional database instance
|
||||
* @return void
|
||||
*/
|
||||
function Search($options, $oDB = null)
|
||||
{
|
||||
function __construct($options, $oDB = null) {
|
||||
parent::__construct($oDB);
|
||||
|
||||
$this->index = new Index($oDB);
|
||||
|
@ -835,8 +814,7 @@ class Search extends SearchBaseAbstract
|
|||
* @param string $searchwords_exclude The words, which should be excluded from search
|
||||
* @return void
|
||||
*/
|
||||
function searchIndex($searchwords, $searchwords_exclude = '')
|
||||
{
|
||||
function searchIndex($searchwords, $searchwords_exclude = '') {
|
||||
if (strlen(trim($searchwords)) > 0) {
|
||||
$this->search_words = $this->stripWords($searchwords);
|
||||
} else {
|
||||
|
@ -858,7 +836,7 @@ class Search extends SearchBaseAbstract
|
|||
}
|
||||
|
||||
if (count($this->search_words_exclude) > 0) {
|
||||
foreach($this->search_words_exclude as $word) {
|
||||
foreach ($this->search_words_exclude as $word) {
|
||||
if ($this->search_option == 'like') {
|
||||
$word = "'%" . $word . "%'";
|
||||
} elseif ($this->search_option == 'exact') {
|
||||
|
@ -868,8 +846,9 @@ class Search extends SearchBaseAbstract
|
|||
array_push($this->search_words, $word);
|
||||
}
|
||||
}
|
||||
|
||||
if(count($tmp_searchwords) == 0) return false;
|
||||
|
||||
if (count($tmp_searchwords) == 0)
|
||||
return false;
|
||||
|
||||
if ($this->search_option == 'regexp') {
|
||||
// regexp search
|
||||
|
@ -884,8 +863,8 @@ class Search extends SearchBaseAbstract
|
|||
$kwSql = "keyword LIKE '" . $search_exact;
|
||||
}
|
||||
|
||||
$sql = "SELECT keyword, auto FROM " . $this->cfg['tab']['keywords']
|
||||
. " WHERE idlang=" . Contenido_Security::toInteger($this->lang) . " AND " . $kwSql . " ";
|
||||
$sql = "SELECT keyword, auto FROM " . $this->cfg['tab']['keywords']
|
||||
. " WHERE idlang=" . Contenido_Security::toInteger($this->lang) . " AND " . $kwSql . " ";
|
||||
$this->_debug('sql', $sql);
|
||||
$this->db->query($sql);
|
||||
|
||||
|
@ -897,7 +876,7 @@ class Search extends SearchBaseAbstract
|
|||
|
||||
$tmp_index = array();
|
||||
foreach ($tmp_index_string as $string) {
|
||||
$tmp_string = preg_replace('/[=\(\)]/', ' ', $string);
|
||||
$tmp_string = preg_replace('/[=\(\)]/', ' ', $string);
|
||||
$tmp_index[] = preg_split('/\s/', $tmp_string, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
$this->_debug('tmp_index', $tmp_index);
|
||||
|
@ -908,9 +887,9 @@ class Search extends SearchBaseAbstract
|
|||
// filter nonsearchable articles
|
||||
if (in_array($artid, $this->searchable_arts)) {
|
||||
|
||||
$cms_place = $string[2];
|
||||
$keyword = $this->db->f('keyword');
|
||||
$percent = 0;
|
||||
$cms_place = $string[2];
|
||||
$keyword = $this->db->f('keyword');
|
||||
$percent = 0;
|
||||
$similarity = 0;
|
||||
foreach ($this->search_words as $word) {
|
||||
similar_text($word, $keyword, $percent); // computes similarity between searchword and keyword in percent
|
||||
|
@ -946,7 +925,6 @@ class Search extends SearchBaseAbstract
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -981,8 +959,7 @@ class Search extends SearchBaseAbstract
|
|||
* @param $cms_options The cms-types (htmlhead, html, ...) which should explicitly be searched
|
||||
* @return void
|
||||
*/
|
||||
function setCmsOptions($cms_options)
|
||||
{
|
||||
function setCmsOptions($cms_options) {
|
||||
if (is_array($cms_options) && count($cms_options) > 0) {
|
||||
$this->index->setCmsOptions($cms_options);
|
||||
}
|
||||
|
@ -992,8 +969,7 @@ class Search extends SearchBaseAbstract
|
|||
* @param $searchwords The search-words
|
||||
* @return Array of stripped search-words
|
||||
*/
|
||||
function stripWords($searchwords)
|
||||
{
|
||||
function stripWords($searchwords) {
|
||||
$tmp_words = array();
|
||||
$searchwords = stripslashes($searchwords); // remove backslash
|
||||
$searchwords = strip_tags($searchwords); // remove html tags
|
||||
|
@ -1020,19 +996,18 @@ class Search extends SearchBaseAbstract
|
|||
* @return array Category Tree
|
||||
* @todo This is not the job for search, should be oursourced...
|
||||
*/
|
||||
function getSubTree($cat_start)
|
||||
{
|
||||
function getSubTree($cat_start) {
|
||||
$sql = "SELECT
|
||||
B.idcat, B.parentid
|
||||
FROM
|
||||
".$this->cfg['tab']['cat_tree']." AS A,
|
||||
".$this->cfg['tab']['cat']." AS B,
|
||||
".$this->cfg['tab']['cat_lang']." AS C
|
||||
" . $this->cfg['tab']['cat_tree'] . " AS A,
|
||||
" . $this->cfg['tab']['cat'] . " AS B,
|
||||
" . $this->cfg['tab']['cat_lang'] . " AS C
|
||||
WHERE
|
||||
A.idcat = B.idcat AND
|
||||
B.idcat = C.idcat AND
|
||||
C.idlang = '".Contenido_Security::toInteger($this->lang)."' AND
|
||||
B.idclient = '".Contenido_Security::toInteger($this->client)."'
|
||||
C.idlang = '" . Contenido_Security::toInteger($this->lang) . "' AND
|
||||
B.idclient = '" . Contenido_Security::toInteger($this->client) . "'
|
||||
ORDER BY
|
||||
idtree";
|
||||
$this->_debug('sql', $sql);
|
||||
|
@ -1065,13 +1040,12 @@ class Search extends SearchBaseAbstract
|
|||
* @param array $search_range
|
||||
* @return array Articles in specified search range
|
||||
*/
|
||||
function getSearchableArticles($search_range)
|
||||
{
|
||||
function getSearchableArticles($search_range) {
|
||||
|
||||
$cat_range = array();
|
||||
if (array_key_exists('cat_tree', $search_range) && is_array($search_range['cat_tree'])) {
|
||||
if (count($search_range['cat_tree']) > 0) {
|
||||
foreach($search_range['cat_tree'] as $cat) {
|
||||
foreach ($search_range['cat_tree'] as $cat) {
|
||||
$cat_range = array_merge($cat_range, $this->getSubTree($cat));
|
||||
}
|
||||
}
|
||||
|
@ -1108,18 +1082,18 @@ class Search extends SearchBaseAbstract
|
|||
|
||||
if ($this->exclude == true) {
|
||||
// exclude searchrange
|
||||
$sSearchRange = " A.idcat NOT IN ('".$sCatRange."') AND B.idart NOT IN ('".$sArtRange."') AND ";
|
||||
$sSearchRange = " A.idcat NOT IN ('" . $sCatRange . "') AND B.idart NOT IN ('" . $sArtRange . "') AND ";
|
||||
} else {
|
||||
// include searchrange
|
||||
if (strlen($sArtRange) > 0) {
|
||||
$sSearchRange = " A.idcat IN ('".$sCatRange."') AND B.idart IN ('".$sArtRange."') AND ";
|
||||
$sSearchRange = " A.idcat IN ('" . $sCatRange . "') AND B.idart IN ('" . $sArtRange . "') AND ";
|
||||
} else {
|
||||
$sSearchRange = " A.idcat IN ('".$sCatRange."') AND ";
|
||||
$sSearchRange = " A.idcat IN ('" . $sCatRange . "') AND ";
|
||||
}
|
||||
}
|
||||
|
||||
if (count($this->article_specs) > 0) {
|
||||
$sArtSpecs = " B.artspec IN ('".implode("','", $this->article_specs)."') AND ";
|
||||
$sArtSpecs = " B.artspec IN ('" . implode("','", $this->article_specs) . "') AND ";
|
||||
} else {
|
||||
$sArtSpecs = '';
|
||||
}
|
||||
|
@ -1127,17 +1101,17 @@ class Search extends SearchBaseAbstract
|
|||
$sql = "SELECT
|
||||
A.idart
|
||||
FROM
|
||||
".$this->cfg["tab"]["cat_art"]." as A,
|
||||
".$this->cfg["tab"]["art_lang"]." as B,
|
||||
".$this->cfg["tab"]["cat_lang"]." as C
|
||||
" . $this->cfg["tab"]["cat_art"] . " as A,
|
||||
" . $this->cfg["tab"]["art_lang"] . " as B,
|
||||
" . $this->cfg["tab"]["cat_lang"] . " as C
|
||||
WHERE
|
||||
".$sSearchRange."
|
||||
B.idlang = '".Contenido_Security::toInteger($this->lang)."' AND
|
||||
C.idlang = '".Contenido_Security::toInteger($this->lang)."' AND
|
||||
" . $sSearchRange . "
|
||||
B.idlang = '" . Contenido_Security::toInteger($this->lang) . "' AND
|
||||
C.idlang = '" . Contenido_Security::toInteger($this->lang) . "' AND
|
||||
A.idart = B.idart AND
|
||||
A.idcat = C.idcat AND
|
||||
".$sArtSpecs."
|
||||
".$protected." ";
|
||||
" . $sArtSpecs . "
|
||||
" . $protected . " ";
|
||||
$this->_debug('sql', $sql);
|
||||
$this->db->query($sql);
|
||||
while ($this->db->next_record()) {
|
||||
|
@ -1151,15 +1125,14 @@ class Search extends SearchBaseAbstract
|
|||
*
|
||||
* @return array Array of article specification Ids
|
||||
*/
|
||||
function getArticleSpecifications()
|
||||
{
|
||||
function getArticleSpecifications() {
|
||||
$sql = "SELECT
|
||||
idartspec
|
||||
FROM
|
||||
".$this->cfg['tab']['art_spec']."
|
||||
" . $this->cfg['tab']['art_spec'] . "
|
||||
WHERE
|
||||
client = ".Contenido_Security::toInteger($this->client)." AND
|
||||
lang = ".Contenido_Security::toInteger($this->lang)." AND
|
||||
client = " . Contenido_Security::toInteger($this->client) . " AND
|
||||
lang = " . Contenido_Security::toInteger($this->lang) . " AND
|
||||
online = 1 ";
|
||||
$this->_debug('sql', $sql);
|
||||
$this->db->query($sql);
|
||||
|
@ -1175,8 +1148,7 @@ class Search extends SearchBaseAbstract
|
|||
* @param int $iArtspecID
|
||||
* @return void
|
||||
*/
|
||||
function setArticleSpecification($iArtspecID)
|
||||
{
|
||||
function setArticleSpecification($iArtspecID) {
|
||||
array_push($this->article_specs, $iArtspecID);
|
||||
}
|
||||
|
||||
|
@ -1185,8 +1157,7 @@ class Search extends SearchBaseAbstract
|
|||
* @param string $sArtSpecName
|
||||
* @return void
|
||||
*/
|
||||
function addArticleSpecificationsByName($sArtSpecName)
|
||||
{
|
||||
function addArticleSpecificationsByName($sArtSpecName) {
|
||||
if (!isset($sArtSpecName) || strlen($sArtSpecName) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1194,10 +1165,10 @@ class Search extends SearchBaseAbstract
|
|||
$sql = "SELECT
|
||||
idartspec
|
||||
FROM
|
||||
".$this->cfg['tab']['art_spec']."
|
||||
" . $this->cfg['tab']['art_spec'] . "
|
||||
WHERE
|
||||
client = ".Contenido_Security::toInteger($this->client)." AND
|
||||
artspec = '".Contenido_Security::escapeDB($sArtSpecName, $this->db)."' ";
|
||||
client = " . Contenido_Security::toInteger($this->client) . " AND
|
||||
artspec = '" . Contenido_Security::escapeDB($sArtSpecName, $this->db) . "' ";
|
||||
$this->_debug('sql', $sql);
|
||||
$this->db->query($sql);
|
||||
while ($this->db->next_record()) {
|
||||
|
@ -1207,7 +1178,6 @@ class Search extends SearchBaseAbstract
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Contenido API - SearchResult Object
|
||||
*
|
||||
|
@ -1241,9 +1211,8 @@ class Search extends SearchBaseAbstract
|
|||
* @copyright four for business AG <www.4fb.de>
|
||||
*
|
||||
*/
|
||||
class SearchResult extends SearchBaseAbstract {
|
||||
|
||||
class SearchResult extends SearchBaseAbstract
|
||||
{
|
||||
/**
|
||||
* Instance of class Index
|
||||
* @var object
|
||||
|
@ -1310,8 +1279,7 @@ class SearchResult extends SearchBaseAbstract
|
|||
* @param DB_ConLite $oDB Optional db instance
|
||||
* @param bool $bDebug Optional flag to enable debugging
|
||||
*/
|
||||
function SearchResult($search_result, $result_per_page, $oDB = null, $bDebug = false)
|
||||
{
|
||||
function __construct($search_result, $result_per_page, $oDB = null, $bDebug = false) {
|
||||
parent::__construct($oDB, $bDebug);
|
||||
|
||||
$this->index = new Index($oDB);
|
||||
|
@ -1338,8 +1306,7 @@ class SearchResult extends SearchBaseAbstract
|
|||
* @param $result_per_page
|
||||
* @return void
|
||||
*/
|
||||
function setOrderedSearchResult($ranked_search, $result_per_page)
|
||||
{
|
||||
function setOrderedSearchResult($ranked_search, $result_per_page) {
|
||||
asort($ranked_search);
|
||||
|
||||
$sorted_rank = array_reverse($ranked_search, true);
|
||||
|
@ -1358,8 +1325,7 @@ class SearchResult extends SearchBaseAbstract
|
|||
* @param $art_id Id of an article
|
||||
* @return Content of an article, specified by it's content type
|
||||
*/
|
||||
function getContent($art_id, $cms_type, $id = 0)
|
||||
{
|
||||
function getContent($art_id, $cms_type, $id = 0) {
|
||||
$article = new Article($art_id, $this->client, $this->lang);
|
||||
return $article->getContent($cms_type, $id);
|
||||
}
|
||||
|
@ -1369,8 +1335,7 @@ class SearchResult extends SearchBaseAbstract
|
|||
* @param $art_id Id of an article
|
||||
* @return Content of an article in search result, specified by its type
|
||||
*/
|
||||
function getSearchContent($art_id, $cms_type, $cms_nr = NULL)
|
||||
{
|
||||
function getSearchContent($art_id, $cms_type, $cms_nr = NULL) {
|
||||
$cms_type = strtoupper($cms_type);
|
||||
if (strlen($cms_type) > 0) {
|
||||
if (!stristr($cms_type, 'cms_')) {
|
||||
|
@ -1399,14 +1364,14 @@ class SearchResult extends SearchBaseAbstract
|
|||
//build consistent escaped string(Timo Trautmann) 2008-04-17
|
||||
$cms_content = clHtmlEntities(clHtmlEntityDecode(strip_tags($article->getContent($cms_type, $cms_nr))));
|
||||
if (count($this->replacement) == 2) {
|
||||
foreach($search_words as $word) {
|
||||
foreach ($search_words as $word) {
|
||||
//build consistent escaped string, replace ae ue .. with original html entities (Timo Trautmann) 2008-04-17
|
||||
$word = clHtmlEntities(clHtmlEntityDecode($this->index->addSpecialUmlauts($word)));
|
||||
$match = array();
|
||||
preg_match("/$word/i", $cms_content, $match);
|
||||
if (isset($match[0])) {
|
||||
$pattern = $match[0];
|
||||
$replacement = $this->replacement[0].$pattern.$this->replacement[1];
|
||||
$replacement = $this->replacement[0] . $pattern . $this->replacement[1];
|
||||
$cms_content = preg_replace("/$pattern/i", $replacement, $cms_content); // emphasize located searchwords
|
||||
}
|
||||
}
|
||||
|
@ -1418,11 +1383,11 @@ class SearchResult extends SearchBaseAbstract
|
|||
$cms_content = strip_tags($article->getContent($cms_type, $id));
|
||||
|
||||
if (count($this->replacement) == 2) {
|
||||
foreach($search_words as $word) {
|
||||
foreach ($search_words as $word) {
|
||||
preg_match("/$word/i", $cms_content, $match);
|
||||
if (isset($match[0])) {
|
||||
$pattern = $match[0];
|
||||
$replacement = $this->replacement[0].$pattern.$this->replacement[1];
|
||||
$replacement = $this->replacement[0] . $pattern . $this->replacement[1];
|
||||
$cms_content = preg_replace("/$pattern/i", $replacement, $cms_content); // emphasize located searchwords
|
||||
}
|
||||
}
|
||||
|
@ -1430,7 +1395,6 @@ class SearchResult extends SearchBaseAbstract
|
|||
$content[] = $cms_content;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// searchword was not found in cms_type
|
||||
if (isset($cms_nr) && is_numeric($cms_nr)) {
|
||||
|
@ -1453,8 +1417,7 @@ class SearchResult extends SearchBaseAbstract
|
|||
* @param int $page_id
|
||||
* @return array Artices in page $page_id
|
||||
*/
|
||||
function getSearchResultPage($page_id)
|
||||
{
|
||||
function getSearchResultPage($page_id) {
|
||||
$this->result_page = $page_id;
|
||||
$result_page = $this->ordered_search_result[$page_id - 1];
|
||||
return $result_page;
|
||||
|
@ -1464,8 +1427,7 @@ class SearchResult extends SearchBaseAbstract
|
|||
* Returns number of result pages
|
||||
* @return int
|
||||
*/
|
||||
function getNumberOfPages()
|
||||
{
|
||||
function getNumberOfPages() {
|
||||
return $this->pages;
|
||||
}
|
||||
|
||||
|
@ -1473,8 +1435,7 @@ class SearchResult extends SearchBaseAbstract
|
|||
* Returns number of results
|
||||
* @return int
|
||||
*/
|
||||
function getNumberOfResults()
|
||||
{
|
||||
function getNumberOfResults() {
|
||||
return $this->results;
|
||||
}
|
||||
|
||||
|
@ -1482,17 +1443,15 @@ class SearchResult extends SearchBaseAbstract
|
|||
* @param $art_id Id of an article
|
||||
* @return Similarity between searchword and matching word in article
|
||||
*/
|
||||
function getSimilarity($art_id)
|
||||
{
|
||||
return $this->search_result[$art_id]['similarity'];
|
||||
function getSimilarity($art_id) {
|
||||
return $this->search_result[$art_id]['similarity'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $art_id Id of an article
|
||||
* @return Number of matching searchwords found in article
|
||||
*/
|
||||
function getOccurrence($art_id)
|
||||
{
|
||||
function getOccurrence($art_id) {
|
||||
$aOccurence = $this->search_result[$art_id]['occurence'];
|
||||
$iSumOfOccurence = 0;
|
||||
for ($i = 0; $i < count($aOccurence); $i++) {
|
||||
|
@ -1507,8 +1466,7 @@ class SearchResult extends SearchBaseAbstract
|
|||
* @param string $rep2 The closing html-tag e.g. '</b>'
|
||||
* @return void
|
||||
*/
|
||||
function setReplacement($rep1, $rep2)
|
||||
{
|
||||
function setReplacement($rep1, $rep2) {
|
||||
if (strlen(trim($rep1)) > 0 && strlen(trim($rep2)) > 0) {
|
||||
array_push($this->replacement, $rep1);
|
||||
array_push($this->replacement, $rep2);
|
||||
|
@ -1520,10 +1478,9 @@ class SearchResult extends SearchBaseAbstract
|
|||
* @return Category Id
|
||||
* @todo Is not job of search, should be outsourced!
|
||||
*/
|
||||
function getArtCat($artid)
|
||||
{
|
||||
$sql = "SELECT idcat FROM ".$this->cfg['tab']['cat_art']."
|
||||
WHERE idart = ".Contenido_Security::toInteger($artid)." ";
|
||||
function getArtCat($artid) {
|
||||
$sql = "SELECT idcat FROM " . $this->cfg['tab']['cat_art'] . "
|
||||
WHERE idart = " . Contenido_Security::toInteger($artid) . " ";
|
||||
$this->db->query($sql);
|
||||
if ($this->db->next_record()) {
|
||||
return $this->db->f('idcat');
|
||||
|
@ -1531,18 +1488,3 @@ class SearchResult extends SearchBaseAbstract
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @since 2008-07-11
|
||||
*
|
||||
*/
|
||||
class Search_helper {
|
||||
|
||||
var $oDb = NULL;
|
||||
|
||||
function search_helper ($oDb, $lang, $client) {
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -74,7 +74,7 @@ class SMTP
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function SMTP() {
|
||||
function __construct() {
|
||||
$this->smtp_conn = 0;
|
||||
$this->error = null;
|
||||
$this->helo_rply = null;
|
||||
|
|
|
@ -38,7 +38,7 @@ class Structure {
|
|||
* Constructor Function
|
||||
* @param
|
||||
*/
|
||||
function Structure() {
|
||||
function __construct() {
|
||||
// empty
|
||||
} // end function
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -28,9 +29,8 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
class Table {
|
||||
|
@ -39,84 +39,78 @@ class Table {
|
|||
* Table border color
|
||||
* @var string
|
||||
*/
|
||||
var $border_color = '';
|
||||
var $border_color = '';
|
||||
|
||||
/**
|
||||
* Table border style
|
||||
* @var string
|
||||
*/
|
||||
var $border_style = '';
|
||||
var $border_style = '';
|
||||
|
||||
/**
|
||||
* Table cell spacing
|
||||
* @var string
|
||||
*/
|
||||
var $cell_spacing = '';
|
||||
|
||||
var $cell_spacing = '';
|
||||
|
||||
/**
|
||||
* Table cell padding
|
||||
* @var string
|
||||
*/
|
||||
var $cell_padding = '';
|
||||
|
||||
var $cell_padding = '';
|
||||
|
||||
/**
|
||||
* Table header color
|
||||
* @var string
|
||||
*/
|
||||
var $header_color = '';
|
||||
|
||||
var $header_color = '';
|
||||
|
||||
/**
|
||||
* Table light row color
|
||||
* @var string
|
||||
*/
|
||||
var $light_color = '';
|
||||
|
||||
var $light_color = '';
|
||||
|
||||
/**
|
||||
* Table dark row color
|
||||
* @var string
|
||||
*/
|
||||
var $dark_color = '';
|
||||
|
||||
var $dark_color = '';
|
||||
|
||||
/**
|
||||
* Internal dark/light row counter
|
||||
* @var bool
|
||||
*/
|
||||
var $dark_row = 0;
|
||||
var $dark_row = 0;
|
||||
|
||||
/**
|
||||
* Internal table width counter
|
||||
* @var int
|
||||
*/
|
||||
|
||||
var $table_cols = 0;
|
||||
var $table_cols = 0;
|
||||
|
||||
/**
|
||||
* Internal first cell checker
|
||||
* @var bool
|
||||
*/
|
||||
var $first_cell = 0;
|
||||
var $first_cell = 0;
|
||||
|
||||
/**
|
||||
* Internal full border checker
|
||||
* @var bool
|
||||
*/
|
||||
var $fullborder = false;
|
||||
var $fullborder = false;
|
||||
|
||||
/**
|
||||
* Directly output table if true
|
||||
*
|
||||
*/
|
||||
var $directoutput = true;
|
||||
var $directoutput = true;
|
||||
|
||||
/**
|
||||
* 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_style = $m_borderstyle;
|
||||
$this->cellspacing = $m_cellspacing;
|
||||
|
@ -126,8 +120,9 @@ class Table {
|
|||
$this->light_color = $m_light_color;
|
||||
$this->fullborder = $m_fullborder;
|
||||
$this->directoutput = $m_directoutput;
|
||||
}
|
||||
|
||||
} # end function
|
||||
# end function
|
||||
|
||||
/**
|
||||
* Begins the new table
|
||||
|
@ -136,43 +131,38 @@ class Table {
|
|||
*/
|
||||
function start_table() {
|
||||
|
||||
if (!$this->fullborder)
|
||||
{
|
||||
$starttable = '<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 . '">';
|
||||
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 . '">';
|
||||
} 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)
|
||||
{
|
||||
echo $starttable."\n";
|
||||
if ($this->directoutput) {
|
||||
echo $starttable . "\n";
|
||||
} else {
|
||||
return $starttable."\n";
|
||||
return $starttable . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} # end function
|
||||
|
||||
|
||||
# end function
|
||||
|
||||
/**
|
||||
* Outputs a header row
|
||||
* @param none
|
||||
* @return void
|
||||
*/
|
||||
function header_row($additional="") {
|
||||
|
||||
$headerrow = '<tr class="textw_medium" style="background-color: ' . $this->header_color . '" '.$additional.'>';
|
||||
function header_row($additional = "") {
|
||||
|
||||
if ($this->directoutput)
|
||||
{
|
||||
echo $headerrow."\n";
|
||||
} else {
|
||||
return $headerrow."\n";
|
||||
}
|
||||
} # end function
|
||||
$headerrow = '<tr class="textw_medium" style="background-color: ' . $this->header_color . '" ' . $additional . '>';
|
||||
|
||||
if ($this->directoutput) {
|
||||
echo $headerrow . "\n";
|
||||
} else {
|
||||
return $headerrow . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
# end function
|
||||
|
||||
/**
|
||||
* Outputs a regular row
|
||||
|
@ -180,27 +170,24 @@ class Table {
|
|||
* @return void
|
||||
*/
|
||||
function row($id = '') {
|
||||
if ($this->dark_row)
|
||||
{
|
||||
$bgColor = $this->light_color;
|
||||
} else {
|
||||
$bgColor = $this->dark_color;
|
||||
}
|
||||
if ($this->dark_row) {
|
||||
$bgColor = $this->light_color;
|
||||
} else {
|
||||
$bgColor = $this->dark_color;
|
||||
}
|
||||
|
||||
$this->dark_row = !$this->dark_row;
|
||||
|
||||
$row = '<tr class="text_medium" style="background-color: ' . $bgColor . '" '.$id.'>';
|
||||
$this->dark_row = !$this->dark_row;
|
||||
|
||||
if ($this->directoutput)
|
||||
{
|
||||
echo $row."\n";
|
||||
} else {
|
||||
return $row."\n";
|
||||
}
|
||||
|
||||
} # end function
|
||||
$row = '<tr class="text_medium" style="background-color: ' . $bgColor . '" ' . $id . '>';
|
||||
|
||||
if ($this->directoutput) {
|
||||
echo $row . "\n";
|
||||
} else {
|
||||
return $row . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
# end function
|
||||
|
||||
/**
|
||||
* Outputs a header cell
|
||||
|
@ -209,28 +196,25 @@ class Table {
|
|||
* @param $valign The vertical alignment of the cell, default "top"
|
||||
* @return void
|
||||
*/
|
||||
function header_cell($content, $align="center", $valign="top", $additional="", $borderTop = 1){
|
||||
function header_cell($content, $align = "center", $valign = "top", $additional = "", $borderTop = 1) {
|
||||
|
||||
$header_cell = '<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++;
|
||||
$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->directoutput)
|
||||
{
|
||||
echo $header_cell."\n";
|
||||
} else {
|
||||
return $header_cell."\n";
|
||||
}
|
||||
|
||||
} # end function
|
||||
if ($this->first_cell) {
|
||||
$this->table_cols = 0;
|
||||
$this->first_cell = false;
|
||||
}
|
||||
|
||||
$this->table_cols++;
|
||||
|
||||
if ($this->directoutput) {
|
||||
echo $header_cell . "\n";
|
||||
} else {
|
||||
return $header_cell . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
# end function
|
||||
|
||||
/**
|
||||
* Outputs a regular cell
|
||||
|
@ -239,44 +223,42 @@ class Table {
|
|||
* @param $valign The vertical alignment of the cell, default "top"
|
||||
* @param $additional Additional flags for the table
|
||||
*/
|
||||
function cell($content, $align="center", $valign="top", $additional = "", $bSetStyle = true){
|
||||
function cell($content, $align = "center", $valign = "top", $additional = "", $bSetStyle = true) {
|
||||
|
||||
if (strlen($content) == 0)
|
||||
{
|
||||
if (strlen($content) == 0) {
|
||||
$content = " ";
|
||||
}
|
||||
$cell = '<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>';
|
||||
}
|
||||
$cell = '<td ' . $additional;
|
||||
|
||||
if ($this->first_cell)
|
||||
{
|
||||
$this->table_cols = 0;
|
||||
$this->first_cell = false;
|
||||
}
|
||||
|
||||
$this->table_cols++;
|
||||
if ($valign != '') {
|
||||
$cell .= ' valign="' . $valign . '"';
|
||||
}
|
||||
|
||||
if ($this->directoutput)
|
||||
{
|
||||
echo $cell."\n";
|
||||
} else {
|
||||
return $cell."\n";
|
||||
}
|
||||
if ($bSetStyle) {
|
||||
$cell .= ' style="border: 0px; border-bottom:1px; border-top:0px; border-right:1px; border-color: ' . $this->border_color . '; border-style: ' . $this->border_style . '"';
|
||||
}
|
||||
|
||||
} # end function
|
||||
if ($align != '') {
|
||||
$cell .= ' align="' . $align . '"';
|
||||
}
|
||||
|
||||
$cell .= '>' . $content . '</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
|
||||
|
@ -285,94 +267,85 @@ class Table {
|
|||
* @param $valign The vertical alignment of the cell, default "top"
|
||||
* @param $additional Additional flags for the table
|
||||
*/
|
||||
function borderless_cell($content, $align="center", $valign="top", $additional = ""){
|
||||
function borderless_cell($content, $align = "center", $valign = "top", $additional = "") {
|
||||
|
||||
if (strlen($content) == 0)
|
||||
{
|
||||
if (strlen($content) == 0) {
|
||||
$content = " ";
|
||||
}
|
||||
$borderless_cell = '<td '. $additional .' valign="' . $valign . '" align="' . $align . '">' . $content . '</td>';
|
||||
}
|
||||
$borderless_cell = '<td ' . $additional . ' valign="' . $valign . '" align="' . $align . '">' . $content . '</td>';
|
||||
|
||||
if ($this->first_cell)
|
||||
{
|
||||
$this->table_cols = 0;
|
||||
$this->first_cell = false;
|
||||
}
|
||||
|
||||
$this->table_cols++;
|
||||
if ($this->first_cell) {
|
||||
$this->table_cols = 0;
|
||||
$this->first_cell = false;
|
||||
}
|
||||
|
||||
if ($this->directoutput)
|
||||
{
|
||||
echo $borderless_cell."\n";
|
||||
} else {
|
||||
return $borderless_cell."\n";
|
||||
}
|
||||
$this->table_cols++;
|
||||
|
||||
} # end function
|
||||
if ($this->directoutput) {
|
||||
echo $borderless_cell . "\n";
|
||||
} else {
|
||||
return $borderless_cell . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
# end function
|
||||
|
||||
|
||||
/**
|
||||
* Outputs a sum cell
|
||||
* @param $content The content which will fill the cell
|
||||
* @param $align The horizontal alignment of the cell, default "center"
|
||||
* @param $valign The vertical alignment of the cell, default "top"
|
||||
*/
|
||||
function sumcell($content, $align="center", $valign="top"){
|
||||
function sumcell($content, $align = "center", $valign = "top") {
|
||||
|
||||
if (strlen($content) == 0)
|
||||
{
|
||||
if (strlen($content) == 0) {
|
||||
$content = " ";
|
||||
}
|
||||
$sumcell = '<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)
|
||||
{
|
||||
echo $sumcell."\n";
|
||||
} else {
|
||||
return $sumcell."\n";
|
||||
}
|
||||
|
||||
} # end function
|
||||
if ($this->directoutput) {
|
||||
echo $sumcell . "\n";
|
||||
} else {
|
||||
return $sumcell . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
# end function
|
||||
|
||||
/**
|
||||
* Ends a row
|
||||
* @param none
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function end_row()
|
||||
{
|
||||
$end_row = '</tr>';
|
||||
function end_row() {
|
||||
$end_row = '</tr>';
|
||||
|
||||
$this->first_cell = true;
|
||||
$this->first_cell = true;
|
||||
|
||||
if ($this->directoutput)
|
||||
{
|
||||
echo $end_row."\n";
|
||||
if ($this->directoutput) {
|
||||
echo $end_row . "\n";
|
||||
} else {
|
||||
return $end_row."\n";
|
||||
return $end_row . "\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ends a table
|
||||
* @param none
|
||||
* @return void
|
||||
*/
|
||||
function end_table(){
|
||||
function end_table() {
|
||||
$end_table = '</table>';
|
||||
|
||||
if ($this->directoutput)
|
||||
{
|
||||
echo $end_table."\n";
|
||||
if ($this->directoutput) {
|
||||
echo $end_table . "\n";
|
||||
} else {
|
||||
return $end_table."\n";
|
||||
return $end_table . "\n";
|
||||
}
|
||||
} # end function
|
||||
}
|
||||
|
||||
} # end class Table
|
||||
# end function
|
||||
}
|
||||
|
||||
# end class Table
|
||||
?>
|
||||
|
|
|
@ -42,13 +42,6 @@ class TODOCollection extends CommunicationCollection
|
|||
$this->_setItemClass("TODOItem");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function TODOCollection()
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
public function select($where = "", $group_by = "", $order_by = "", $limit = "")
|
||||
{
|
||||
if ($where == "") {
|
||||
|
|
|
@ -129,7 +129,7 @@ class TreeItem
|
|||
* @param string $id The unique ID of that item
|
||||
* @param boolean $collapsed Is this item collapsed by default
|
||||
*/
|
||||
function TreeItem($name ="", $id="", $collapsed = false)
|
||||
function __construct($name ="", $id="", $collapsed = false)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->id = $id;
|
||||
|
|
|
@ -38,7 +38,7 @@ class UI_Left_Top {
|
|||
var $link;
|
||||
var $javascripts;
|
||||
|
||||
function UI_Left_Top() {
|
||||
function __construct() {
|
||||
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ class UI_Left_Top {
|
|||
function render() {
|
||||
global $sess, $cfg;
|
||||
|
||||
$tpl = new Template;
|
||||
$tpl = new Template();
|
||||
|
||||
$tpl->reset();
|
||||
$tpl->set('s', 'SESSID', $sess->id);
|
||||
|
@ -100,7 +100,7 @@ class UI_Menu {
|
|||
var $show;
|
||||
var $bgColor;
|
||||
|
||||
function UI_Menu() {
|
||||
function __construct() {
|
||||
$this->padding = 2;
|
||||
$this->border = 0;
|
||||
$this->rowmark = true;
|
||||
|
@ -147,7 +147,7 @@ class UI_Menu {
|
|||
function render($print = true) {
|
||||
global $sess, $cfg;
|
||||
|
||||
$tpl = new Template;
|
||||
$tpl = new Template();
|
||||
|
||||
$tpl->reset();
|
||||
$tpl->set('s', 'SID', $sess->id);
|
||||
|
@ -284,7 +284,7 @@ class UI_Table_Form {
|
|||
var $accesskey;
|
||||
var $width;
|
||||
|
||||
function UI_Table_Form($name, $action = "", $method = "post") {
|
||||
function __construct($name, $action = "", $method = "post") {
|
||||
global $sess, $cfg;
|
||||
|
||||
$this->formname = $name;
|
||||
|
@ -635,7 +635,7 @@ class UI_Page {
|
|||
var $content;
|
||||
var $margin;
|
||||
|
||||
function UI_Page() {
|
||||
function __construct() {
|
||||
$this->margin = 10;
|
||||
}
|
||||
|
||||
|
@ -674,7 +674,7 @@ class UI_Page {
|
|||
function render($print = true) {
|
||||
global $sess, $cfg;
|
||||
|
||||
$tpl = new Template;
|
||||
$tpl = new Template();
|
||||
|
||||
$scripts = "";
|
||||
|
||||
|
@ -848,7 +848,7 @@ class UI_List {
|
|||
var $solid;
|
||||
var $width;
|
||||
|
||||
function UI_List() {
|
||||
function __construct() {
|
||||
$this->padding = 2;
|
||||
$this->border = 0;
|
||||
}
|
||||
|
@ -897,8 +897,8 @@ class UI_List {
|
|||
function render($print = false) {
|
||||
global $sess, $cfg;
|
||||
|
||||
$tpl = new Template;
|
||||
$tpl2 = new Template;
|
||||
$tpl = new Template();
|
||||
$tpl2 = new Template();
|
||||
|
||||
$tpl->reset();
|
||||
$tpl->set('s', 'SID', $sess->id);
|
||||
|
@ -1075,45 +1075,45 @@ class cScrollList {
|
|||
*
|
||||
* @param $defaultstyle boolean use the default style for object initializing?
|
||||
*/
|
||||
function cScrollList($defaultstyle = true, $action = "") {
|
||||
function __construct($defaultstyle = true, $action = "") {
|
||||
global $cfg, $area, $frame;
|
||||
|
||||
$this->resultsPerPage = 0;
|
||||
$this->listStart = 1;
|
||||
$this->sortable = false;
|
||||
|
||||
$this->objTable = new cHTMLTable;
|
||||
$this->objTable = new cHTMLTable();
|
||||
if ($defaultstyle == true) {
|
||||
$this->objTable->setStyle('border-collapse:collapse;border: 1px; border-style: solid; border-top:0px;border-color: ' . $cfg["color"]["table_border"] . ';');
|
||||
$this->objTable->updateAttributes(array("cellspacing" => 0, "cellpadding" => 2));
|
||||
}
|
||||
|
||||
$this->objHeaderRow = new cHTMLTableRow;
|
||||
$this->objHeaderRow = new cHTMLTableRow();
|
||||
if ($defaultstyle == true) {
|
||||
$this->objHeaderRow->setClass("text_medium");
|
||||
$this->objHeaderRow->setStyle("background-color: #E2E2E2;white-space:nowrap;");
|
||||
}
|
||||
|
||||
|
||||
$this->objHeaderItem = new cHTMLTableHead;
|
||||
$this->objHeaderItem = new cHTMLTableHead();
|
||||
if ($defaultstyle == true) {
|
||||
$this->objHeaderItem->setClass("textg_medium");
|
||||
$this->objHeaderItem->setStyle('white-space:nowrap; border: 1px; border-style: solid;border-bottom: 0px;border-color: ' . $cfg["color"]["table_border"] . ';');
|
||||
$this->objHeaderItem->updateAttributes(array("align" => "left"));
|
||||
}
|
||||
|
||||
$this->objRow = new cHTMLTableRow;
|
||||
$this->objRow = new cHTMLTableRow();
|
||||
if ($defaultstyle == true) {
|
||||
$this->objRow->setClass("text_medium");
|
||||
}
|
||||
|
||||
$this->objItem = new cHTMLTableData;
|
||||
$this->objItem = new cHTMLTableData();
|
||||
if ($defaultstyle == true) {
|
||||
$this->objItem->setStyle('white-space:nowrap; border: 1px; border-style: solid;border-top:0px;border-color: ' . $cfg["color"]["table_border"] . ';');
|
||||
}
|
||||
|
||||
|
||||
$this->sortlink = new cHTMLLink;
|
||||
$this->sortlink = new cHTMLLink();
|
||||
$this->sortlink->setStyle("color: #666666;");
|
||||
$this->sortlink->setCLink($area, $frame, $action);
|
||||
}
|
||||
|
@ -1320,7 +1320,7 @@ class cScrollList {
|
|||
* @param $return If true, returns the list
|
||||
*/
|
||||
function render($return = true) {
|
||||
|
||||
|
||||
$currentpage = $this->getCurrentPage();
|
||||
|
||||
$itemstart = (($currentpage - 1) * $this->resultsPerPage) + 1;
|
||||
|
@ -1402,5 +1402,5 @@ class cScrollList {
|
|||
echo $output;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
|
@ -691,6 +691,7 @@ class Contenido_UpdateNotifier {
|
|||
|
||||
if ($this->sRSSContent != '') {
|
||||
$oRss = simplexml_load_file($this->sCacheDirectory . $this->sRSSFile);
|
||||
//echo $sFeedContent;
|
||||
|
||||
$iCnt = 0;
|
||||
foreach ($oRss->channel->item as $aItem) {
|
||||
|
@ -769,4 +770,4 @@ class Contenido_UpdateNotifier {
|
|||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -32,13 +33,11 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
class Users
|
||||
{
|
||||
class Users {
|
||||
|
||||
/**
|
||||
* Storage of the source table to use for the user informations
|
||||
|
@ -58,8 +57,7 @@ class Users
|
|||
* Constructor Function
|
||||
* @param string $table The table to use as information source
|
||||
*/
|
||||
function Users($table = '')
|
||||
{
|
||||
function __construct($table = '') {
|
||||
if ($table == '') {
|
||||
global $cfg;
|
||||
$this->table = $cfg['tab']['phplib_auth_user_md5'];
|
||||
|
@ -70,62 +68,55 @@ class Users
|
|||
$this->db = new DB_ConLite();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new user by specifying its username.
|
||||
*
|
||||
* @param string $username Specifies the username
|
||||
* @return int Userid of created user
|
||||
*/
|
||||
function create($username)
|
||||
{
|
||||
function create($username) {
|
||||
$newuserid = md5($username);
|
||||
$sql = "SELECT user_id FROM ".$this->table
|
||||
. " WHERE user_id = '".Contenido_Security::escapeDB($newuserid, $this->db)."'";
|
||||
$sql = "SELECT user_id FROM " . $this->table
|
||||
. " WHERE user_id = '" . Contenido_Security::escapeDB($newuserid, $this->db) . "'";
|
||||
$this->db->query($sql);
|
||||
if ($this->db->next_record()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".$this->table
|
||||
. " SET user_id = '".Contenido_Security::escapeDB($newuserid, $this->db)."',"
|
||||
. " username = '".Contenido_Security::escapeDB($username, $this->db)."'";
|
||||
$sql = "INSERT INTO " . $this->table
|
||||
. " SET user_id = '" . Contenido_Security::escapeDB($newuserid, $this->db) . "',"
|
||||
. " username = '" . Contenido_Security::escapeDB($username, $this->db) . "'";
|
||||
$this->db->query($sql);
|
||||
|
||||
return $newuserid;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes the specified user from the database.
|
||||
*
|
||||
* @param string $userid Specifies the user ID
|
||||
* @return bool True if the delete was successful
|
||||
*/
|
||||
function deleteUserByID($userid)
|
||||
{
|
||||
function deleteUserByID($userid) {
|
||||
$sql = "DELETE FROM " . $this->table
|
||||
. " WHERE user_id = '" . Contenido_Security::escapeDB($userid, $this->db) . "'";
|
||||
. " WHERE user_id = '" . Contenido_Security::escapeDB($userid, $this->db) . "'";
|
||||
$this->db->query($sql);
|
||||
return ($this->db->affected_rows() == 0) ? false : true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes the specified user from the database.
|
||||
*
|
||||
* @param string $userid Specifies the username
|
||||
* @return bool True if the delete was successful
|
||||
*/
|
||||
function deleteUserByUsername($username)
|
||||
{
|
||||
function deleteUserByUsername($username) {
|
||||
$sql = "DELETE FROM " . $this->table
|
||||
. " WHERE username = '" . Contenido_Security::escapeDB($username, $this->db) . "'";
|
||||
. " WHERE username = '" . Contenido_Security::escapeDB($username, $this->db) . "'";
|
||||
$this->db->query($sql);
|
||||
return ($this->db->affected_rows() == 0) ? false : true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns all users which are accessible by the current user.
|
||||
*
|
||||
|
@ -133,8 +124,7 @@ class Users
|
|||
* @param bool $includeAdmins Flag to get admins (admin and sysadmin) too
|
||||
* @return array Array of user objects
|
||||
*/
|
||||
function getAccessibleUsers($perms, $includeAdmins = false)
|
||||
{
|
||||
function getAccessibleUsers($perms, $includeAdmins = false) {
|
||||
global $cfg;
|
||||
|
||||
$clientclass = new Client();
|
||||
|
@ -142,15 +132,15 @@ class Users
|
|||
$allClients = $clientclass->getAvailableClients();
|
||||
|
||||
foreach ($allClients as $key => $value) {
|
||||
if (in_array("client[".$key."]", $perms) || in_array("admin[".$key."]", $perms)) {
|
||||
$limit[] = 'perms LIKE "%client['.$key.']%"';
|
||||
if (in_array("client[" . $key . "]", $perms) || in_array("admin[" . $key . "]", $perms)) {
|
||||
$limit[] = 'perms LIKE "%client[' . $key . ']%"';
|
||||
if ($includeAdmins) {
|
||||
$limit[] = 'perms LIKE "%admin['.$key.']%"';
|
||||
$limit[] = 'perms LIKE "%admin[' . $key . ']%"';
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array("admin[".$key."]", $perms)) {
|
||||
$limit[] = 'perms LIKE "%admin['.$key.']%"';
|
||||
if (in_array("admin[" . $key . "]", $perms)) {
|
||||
$limit[] = 'perms LIKE "%admin[' . $key . ']%"';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,7 +161,7 @@ class Users
|
|||
$sql = "SELECT
|
||||
user_id, username, realname
|
||||
FROM
|
||||
". $cfg['tab']['phplib_auth_user_md5']. " WHERE 1 AND ".$limitSQL." ORDER BY realname, username";
|
||||
" . $cfg['tab']['phplib_auth_user_md5'] . " WHERE 1 AND " . $limitSQL . " ORDER BY realname, username";
|
||||
|
||||
$db->query($sql);
|
||||
|
||||
|
@ -186,8 +176,8 @@ class Users
|
|||
|
||||
return ($users);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Class User
|
||||
|
@ -196,8 +186,7 @@ class Users
|
|||
* @version 1.0
|
||||
* @copyright four for business 2003
|
||||
*/
|
||||
class User
|
||||
{
|
||||
class User {
|
||||
|
||||
/**
|
||||
* Storage of the source table to use for the user informations
|
||||
|
@ -232,8 +221,7 @@ class User
|
|||
*
|
||||
* @param string $table The table to use as information source
|
||||
*/
|
||||
function User($table = '')
|
||||
{
|
||||
function __construct($table = '') {
|
||||
if ($table == '') {
|
||||
global $cfg;
|
||||
$this->table = $cfg['tab']['phplib_auth_user_md5'];
|
||||
|
@ -244,18 +232,16 @@ class User
|
|||
$this->db = new DB_ConLite();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads a user from the database by its username.
|
||||
*
|
||||
* @param string $username Specifies the username
|
||||
* @return bool True if the load was successful
|
||||
*/
|
||||
function loadUserByUsername($username)
|
||||
{
|
||||
function loadUserByUsername($username) {
|
||||
// SQL-Statement to select by username
|
||||
$sql = "SELECT * FROM " . $this->table
|
||||
. " WHERE username = '".Contenido_Security::escapeDB($username, $this->db)."'";
|
||||
. " WHERE username = '" . Contenido_Security::escapeDB($username, $this->db) . "'";
|
||||
|
||||
// Query the database
|
||||
$this->db->query($sql);
|
||||
|
@ -270,18 +256,16 @@ class User
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads a user from the database by its userID.
|
||||
*
|
||||
* @param string $userid Specifies the userID
|
||||
* @return bool True if the load was successful
|
||||
*/
|
||||
function loadUserByUserID($userID)
|
||||
{
|
||||
function loadUserByUserID($userID) {
|
||||
// SQL-Statement to select by userID
|
||||
$sql = "SELECT * FROM " . $this->table
|
||||
. " WHERE user_id = '".Contenido_Security::escapeDB($userID, $this->db)."'";
|
||||
. " WHERE user_id = '" . Contenido_Security::escapeDB($userID, $this->db) . "'";
|
||||
|
||||
// Query the database
|
||||
$this->db->query($sql);
|
||||
|
@ -296,15 +280,13 @@ class User
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function returns effective perms for user including group rights as perm string.
|
||||
*
|
||||
* @author Timo Trautmann
|
||||
* @return string Current users permissions
|
||||
*/
|
||||
function getEffectiveUserPerms()
|
||||
{
|
||||
function getEffectiveUserPerms() {
|
||||
global $cfg, $perm;
|
||||
|
||||
//first get users own permissions and filter them into result array $aUserPerms
|
||||
|
@ -336,51 +318,45 @@ class User
|
|||
return implode(',', $aUserPerms);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the value of a specific field.
|
||||
*
|
||||
* @param string $field Specifies the field to retrieve
|
||||
* @return mixed Value of the field
|
||||
*/
|
||||
function getField($field)
|
||||
{
|
||||
function getField($field) {
|
||||
return ($this->values[$field]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the value of a specific field.
|
||||
*
|
||||
* @param string $field Specifies the field to set
|
||||
* @param string $value Specifies the value to set
|
||||
*/
|
||||
function setField($field, $value)
|
||||
{
|
||||
function setField($field, $value) {
|
||||
$this->modifiedValues[$field] = true;
|
||||
$this->values[$field] = $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stores the modified user object to the database
|
||||
* @return bool
|
||||
*/
|
||||
function store()
|
||||
{
|
||||
$sql = "UPDATE " .$this->table ." SET ";
|
||||
function store() {
|
||||
$sql = "UPDATE " . $this->table . " SET ";
|
||||
$first = true;
|
||||
|
||||
foreach ($this->modifiedValues as $key => $value) {
|
||||
if ($first == true) {
|
||||
$sql .= "$key = '" . $this->values[$key] ."'";
|
||||
$sql .= "$key = '" . $this->values[$key] . "'";
|
||||
$first = false;
|
||||
} else {
|
||||
$sql .= ", $key = '" . $this->values[$key] ."'";
|
||||
$sql .= ", $key = '" . $this->values[$key] . "'";
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= " WHERE user_id = '".Contenido_Security::escapeDB($this->values['user_id'], $this->db)."'";
|
||||
$sql .= " WHERE user_id = '" . Contenido_Security::escapeDB($this->values['user_id'], $this->db) . "'";
|
||||
|
||||
$this->db->query($sql);
|
||||
|
||||
|
@ -391,7 +367,6 @@ class User
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stores the modified user object to the database
|
||||
* @param string type Specifies the type (class, category etc) for the property to retrieve
|
||||
|
@ -399,8 +374,7 @@ class User
|
|||
* @param boolean group Specifies if this function should recursively search in groups
|
||||
* @return string The value of the retrieved property
|
||||
*/
|
||||
function getUserProperty($type, $name, $group = false)
|
||||
{
|
||||
function getUserProperty($type, $name, $group = false) {
|
||||
global $cfg, $perm;
|
||||
|
||||
if (!is_object($perm)) {
|
||||
|
@ -414,10 +388,10 @@ class User
|
|||
|
||||
if (is_array($groups)) {
|
||||
foreach ($groups as $value) {
|
||||
$sql = "SELECT value FROM " .$cfg['tab']['group_prop']."
|
||||
WHERE group_id = '".Contenido_Security::escapeDB($value, $this->db)."'
|
||||
AND type = '".Contenido_Security::escapeDB($type, $this->db)."'
|
||||
AND name = '".Contenido_Security::escapeDB($name, $this->db)."'";
|
||||
$sql = "SELECT value FROM " . $cfg['tab']['group_prop'] . "
|
||||
WHERE group_id = '" . Contenido_Security::escapeDB($value, $this->db) . "'
|
||||
AND type = '" . Contenido_Security::escapeDB($type, $this->db) . "'
|
||||
AND name = '" . Contenido_Security::escapeDB($name, $this->db) . "'";
|
||||
$this->db->query($sql);
|
||||
|
||||
if ($this->db->next_record()) {
|
||||
|
@ -427,10 +401,10 @@ class User
|
|||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT value FROM " .$cfg['tab']['user_prop']."
|
||||
WHERE user_id = '".Contenido_Security::escapeDB($this->values['user_id'], $this->db)."'
|
||||
AND type = '".Contenido_Security::escapeDB($type, $this->db)."'
|
||||
AND name = '".Contenido_Security::escapeDB($name, $this->db)."'";
|
||||
$sql = "SELECT value FROM " . $cfg['tab']['user_prop'] . "
|
||||
WHERE user_id = '" . Contenido_Security::escapeDB($this->values['user_id'], $this->db) . "'
|
||||
AND type = '" . Contenido_Security::escapeDB($type, $this->db) . "'
|
||||
AND name = '" . Contenido_Security::escapeDB($name, $this->db) . "'";
|
||||
$this->db->query($sql);
|
||||
|
||||
if ($this->db->next_record()) {
|
||||
|
@ -444,44 +418,42 @@ class User
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stores the modified user object to the database
|
||||
*
|
||||
* @param string sType Specifies the type (class, category etc) for the property to retrieve
|
||||
* @param boolean bGroup Specifies if this function should recursively search in groups
|
||||
* @return array The value of the retrieved property
|
||||
**/
|
||||
function getUserPropertiesByType($sType, $bGroup = false)
|
||||
{
|
||||
global $cfg, $perm;
|
||||
* */
|
||||
function getUserPropertiesByType($sType, $bGroup = false) {
|
||||
global $cfg, $perm;
|
||||
|
||||
if (!is_object($perm)) {
|
||||
$perm = new Contenido_Perm();
|
||||
}
|
||||
if (!is_object($perm)) {
|
||||
$perm = new Contenido_Perm();
|
||||
}
|
||||
|
||||
$aResult = array();
|
||||
$aResult = array();
|
||||
|
||||
if ($bGroup == true) {
|
||||
$aGroups = $perm->getGroupsForUser($this->values['user_id']);
|
||||
if ($bGroup == true) {
|
||||
$aGroups = $perm->getGroupsForUser($this->values['user_id']);
|
||||
|
||||
if (is_array($aGroups)) {
|
||||
foreach ($aGroups as $iID) {
|
||||
$sSQL = "SELECT name, value FROM " .$cfg['tab']['group_prop']."
|
||||
WHERE group_id = '".Contenido_Security::escapeDB($iID, $this->db)."'
|
||||
AND type = '".Contenido_Security::escapeDB($sType, $this->db)."'";
|
||||
if (is_array($aGroups)) {
|
||||
foreach ($aGroups as $iID) {
|
||||
$sSQL = "SELECT name, value FROM " . $cfg['tab']['group_prop'] . "
|
||||
WHERE group_id = '" . Contenido_Security::escapeDB($iID, $this->db) . "'
|
||||
AND type = '" . Contenido_Security::escapeDB($sType, $this->db) . "'";
|
||||
$this->db->query($sSQL);
|
||||
|
||||
while ($this->db->next_record()) {
|
||||
$aResult[$this->db->f('name')] = urldecode($this->db->f('value'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sSQL = "SELECT name, value FROM " .$cfg['tab']['user_prop']."
|
||||
WHERE user_id = '".Contenido_Security::escapeDB($this->values['user_id'], $this->db)."'
|
||||
AND type = '".Contenido_Security::escapeDB($sType, $this->db)."'";
|
||||
$sSQL = "SELECT name, value FROM " . $cfg['tab']['user_prop'] . "
|
||||
WHERE user_id = '" . Contenido_Security::escapeDB($this->values['user_id'], $this->db) . "'
|
||||
AND type = '" . Contenido_Security::escapeDB($sType, $this->db) . "'";
|
||||
$this->db->query($sSQL);
|
||||
|
||||
while ($this->db->next_record()) {
|
||||
|
@ -491,7 +463,6 @@ class User
|
|||
return $aResult;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves all available properties of the user
|
||||
* @return array Assoziative properties list as follows:
|
||||
|
@ -499,14 +470,13 @@ class User
|
|||
* - $arr[iduserprop][type]
|
||||
* - $arr[iduserprop][value]
|
||||
*/
|
||||
function getUserProperties()
|
||||
{
|
||||
function getUserProperties() {
|
||||
global $cfg;
|
||||
|
||||
$aProps = array();
|
||||
|
||||
$sql = "SELECT iduserprop, type, name, value FROM " .$cfg['tab']['user_prop']."
|
||||
WHERE user_id = '".Contenido_Security::escapeDB($this->values['user_id'], $this->db)."'";
|
||||
$sql = "SELECT iduserprop, type, name, value FROM " . $cfg['tab']['user_prop'] . "
|
||||
WHERE user_id = '" . Contenido_Security::escapeDB($this->values['user_id'], $this->db) . "'";
|
||||
$this->db->query($sql);
|
||||
|
||||
if ($this->db->num_rows() == 0) {
|
||||
|
@ -515,8 +485,8 @@ class User
|
|||
|
||||
while ($this->db->next_record()) {
|
||||
$aProps[$this->db->f('iduserprop')] = array(
|
||||
'name' => $this->db->f('name'),
|
||||
'type' => $this->db->f('type'),
|
||||
'name' => $this->db->f('name'),
|
||||
'type' => $this->db->f('type'),
|
||||
'value' => $this->db->f('value'),
|
||||
);
|
||||
}
|
||||
|
@ -524,65 +494,58 @@ class User
|
|||
return $aProps;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stores a property to the database
|
||||
* @param string type Specifies the type (class, category etc) for the property to retrieve
|
||||
* @param string name Specifies the name of the property to retrieve
|
||||
* @param string value Specifies the value to insert
|
||||
*/
|
||||
function setUserProperty($type, $name, $value)
|
||||
{
|
||||
function setUserProperty($type, $name, $value) {
|
||||
global $cfg;
|
||||
|
||||
$value = urlencode($value);
|
||||
|
||||
// Check if such an entry already exists
|
||||
if ($this->getUserProperty($type, $name) !== false)
|
||||
{
|
||||
$sql = "UPDATE ".$cfg['tab']['user_prop']."
|
||||
SET value = '".Contenido_Security::escapeDB($value, $this->db)."'
|
||||
WHERE user_id = '".Contenido_Security::escapeDB($this->values['user_id'], $this->db)."'
|
||||
AND type = '".Contenido_Security::escapeDB($type, $this->db)."'
|
||||
AND name = '".Contenido_Security::escapeDB($name, $this->db)."'";
|
||||
if ($this->getUserProperty($type, $name) !== false) {
|
||||
$sql = "UPDATE " . $cfg['tab']['user_prop'] . "
|
||||
SET value = '" . Contenido_Security::escapeDB($value, $this->db) . "'
|
||||
WHERE user_id = '" . Contenido_Security::escapeDB($this->values['user_id'], $this->db) . "'
|
||||
AND type = '" . Contenido_Security::escapeDB($type, $this->db) . "'
|
||||
AND name = '" . Contenido_Security::escapeDB($name, $this->db) . "'";
|
||||
$this->db->query($sql);
|
||||
} else {
|
||||
$sql = "INSERT INTO ".$cfg['tab']['user_prop']."
|
||||
SET value = '".Contenido_Security::escapeDB($value, $this->db)."',
|
||||
user_id = '".Contenido_Security::escapeDB($this->values['user_id'], $this->db)."',
|
||||
type = '".Contenido_Security::escapeDB($type, $this->db)."',
|
||||
name = '".Contenido_Security::escapeDB($name, $this->db)."',
|
||||
iduserprop = '".Contenido_Security::toInteger($this->db->nextid($cfg['tab']['user_prop']))."'";
|
||||
$sql = "INSERT INTO " . $cfg['tab']['user_prop'] . "
|
||||
SET value = '" . Contenido_Security::escapeDB($value, $this->db) . "',
|
||||
user_id = '" . Contenido_Security::escapeDB($this->values['user_id'], $this->db) . "',
|
||||
type = '" . Contenido_Security::escapeDB($type, $this->db) . "',
|
||||
name = '" . Contenido_Security::escapeDB($name, $this->db) . "',
|
||||
iduserprop = '" . Contenido_Security::toInteger($this->db->nextid($cfg['tab']['user_prop'])) . "'";
|
||||
$this->db->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes a user property from the table
|
||||
* @param string type Specifies the type (class, category etc) for the property to retrieve
|
||||
* @param string name Specifies the name of the property to retrieve
|
||||
*/
|
||||
function deleteUserProperty($type, $name)
|
||||
{
|
||||
function deleteUserProperty($type, $name) {
|
||||
global $cfg;
|
||||
|
||||
// Delete record from table
|
||||
$sql = "DELETE FROM ".$cfg['tab']['user_prop']."
|
||||
WHERE user_id = '".Contenido_Security::escapeDB($this->values['user_id'], $this->db)."' AND
|
||||
type = '".Contenido_Security::escapeDB($type, $this->db)."' AND
|
||||
name = '".Contenido_Security::escapeDB($name, $this->db)."'";
|
||||
$sql = "DELETE FROM " . $cfg['tab']['user_prop'] . "
|
||||
WHERE user_id = '" . Contenido_Security::escapeDB($this->values['user_id'], $this->db) . "' AND
|
||||
type = '" . Contenido_Security::escapeDB($type, $this->db) . "' AND
|
||||
name = '" . Contenido_Security::escapeDB($name, $this->db) . "'";
|
||||
$this->db->query($sql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns all users available in the system
|
||||
* @param string $sort SQL sort part
|
||||
* @return array Array with id and name entries
|
||||
*/
|
||||
function getAvailableUsers($sort = 'ORDER BY realname ASC')
|
||||
{
|
||||
function getAvailableUsers($sort = 'ORDER BY realname ASC') {
|
||||
global $cfg;
|
||||
|
||||
$db = new DB_ConLite();
|
||||
|
@ -590,7 +553,7 @@ class User
|
|||
$sql = "SELECT
|
||||
user_id, username, realname
|
||||
FROM
|
||||
". $cfg['tab']['phplib_auth_user_md5']. " " . $sort;
|
||||
" . $cfg['tab']['phplib_auth_user_md5'] . " " . $sort;
|
||||
|
||||
$db->query($sql);
|
||||
|
||||
|
@ -606,14 +569,12 @@ class User
|
|||
return ($users);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns all system admins available in the system
|
||||
* @param boolean $forceActive Is forceActive true return only activ Sysadmins
|
||||
* @return array Array with id and name entries
|
||||
*/
|
||||
function getSystemAdmins($forceActive = false)
|
||||
{
|
||||
function getSystemAdmins($forceActive = false) {
|
||||
global $cfg;
|
||||
|
||||
$db = new DB_ConLite();
|
||||
|
@ -621,12 +582,12 @@ class User
|
|||
$sql = "SELECT
|
||||
user_id, username, realname, email
|
||||
FROM
|
||||
". $cfg['tab']['phplib_auth_user_md5'] ."
|
||||
" . $cfg['tab']['phplib_auth_user_md5'] . "
|
||||
WHERE
|
||||
perms LIKE \"%sysadmin%\"";
|
||||
|
||||
if ($forceActive === true) {
|
||||
$sql.= " AND (valid_from <= NOW() OR valid_from = '0000-00-00' OR valid_from = '1000-01-01')
|
||||
$sql .= " AND (valid_from <= NOW() OR valid_from = '0000-00-00' OR valid_from = '1000-01-01')
|
||||
AND (valid_to >= NOW() OR valid_to = '0000-00-00' OR valid_to = '1000-01-01') ";
|
||||
}
|
||||
|
||||
|
@ -638,21 +599,19 @@ class User
|
|||
$users[$db->f('user_id')] = array(
|
||||
'username' => $db->f('username'),
|
||||
'realname' => $db->f('realname'),
|
||||
'email' => $db->f('email'),
|
||||
'email' => $db->f('email'),
|
||||
);
|
||||
}
|
||||
|
||||
return ($users);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns all system admins available in the system
|
||||
* @param int $client
|
||||
* @return array Array with id and name entries
|
||||
*/
|
||||
function getClientAdmins($client)
|
||||
{
|
||||
function getClientAdmins($client) {
|
||||
global $cfg;
|
||||
|
||||
$db = new DB_ConLite();
|
||||
|
@ -662,9 +621,9 @@ class User
|
|||
$sql = "SELECT
|
||||
user_id, username, realname, email
|
||||
FROM
|
||||
". $cfg['tab']['phplib_auth_user_md5'] ."
|
||||
" . $cfg['tab']['phplib_auth_user_md5'] . "
|
||||
WHERE
|
||||
perms LIKE \"%admin[".$client."]%\"";
|
||||
perms LIKE \"%admin[" . $client . "]%\"";
|
||||
|
||||
$db->query($sql);
|
||||
|
||||
|
@ -674,21 +633,19 @@ class User
|
|||
$users[$db->f('user_id')] = array(
|
||||
'username' => $db->f('username'),
|
||||
'realname' => $db->f('realname'),
|
||||
'email' => $db->f('email'),
|
||||
'email' => $db->f('email'),
|
||||
);
|
||||
}
|
||||
|
||||
return ($users);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the username of the given userid
|
||||
* @param int $userid
|
||||
* @return string Username if found, or emptry string if not.
|
||||
*/
|
||||
function getUsername($userid)
|
||||
{
|
||||
function getUsername($userid) {
|
||||
global $cfg;
|
||||
|
||||
$db = new DB_ConLite();
|
||||
|
@ -696,24 +653,22 @@ class User
|
|||
$sql = "SELECT
|
||||
username
|
||||
FROM
|
||||
". $cfg['tab']['phplib_auth_user_md5']."
|
||||
" . $cfg['tab']['phplib_auth_user_md5'] . "
|
||||
WHERE
|
||||
user_id = '".Contenido_Security::escapeDB($userid, $db)."'";
|
||||
user_id = '" . Contenido_Security::escapeDB($userid, $db) . "'";
|
||||
|
||||
$db->query($sql);
|
||||
$db->next_record();
|
||||
return ($db->f('username'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the realname of the given userid
|
||||
* @param int $userid
|
||||
* @param bool $bAllowFallbackOnUsername
|
||||
* @return string Realname if found, or emptry string if not.
|
||||
*/
|
||||
function getRealname($userid, $bAllowFallbackOnUsername = false)
|
||||
{
|
||||
function getRealname($userid, $bAllowFallbackOnUsername = false) {
|
||||
global $cfg;
|
||||
|
||||
$db = new DB_ConLite();
|
||||
|
@ -721,9 +676,9 @@ class User
|
|||
$sql = "SELECT
|
||||
realname
|
||||
FROM
|
||||
". $cfg['tab']['phplib_auth_user_md5']."
|
||||
" . $cfg['tab']['phplib_auth_user_md5'] . "
|
||||
WHERE
|
||||
user_id = '".Contenido_Security::escapeDB($userid, $db)."'";
|
||||
user_id = '" . Contenido_Security::escapeDB($userid, $db) . "'";
|
||||
|
||||
$db->query($sql);
|
||||
$db->next_record();
|
||||
|
@ -735,14 +690,12 @@ class User
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the realname of the given username
|
||||
* @param string $username
|
||||
* @return string Realname if found, or emptry string if not.
|
||||
*/
|
||||
function getRealnameByUserName($username)
|
||||
{
|
||||
function getRealnameByUserName($username) {
|
||||
global $cfg;
|
||||
|
||||
$db = new DB_ConLite();
|
||||
|
@ -750,23 +703,21 @@ class User
|
|||
$sql = "SELECT
|
||||
realname
|
||||
FROM
|
||||
". $cfg['tab']['phplib_auth_user_md5']."
|
||||
" . $cfg['tab']['phplib_auth_user_md5'] . "
|
||||
WHERE
|
||||
username = '".Contenido_Security::escapeDB($username, $db)."'";
|
||||
username = '" . Contenido_Security::escapeDB($username, $db) . "'";
|
||||
|
||||
$db->query($sql);
|
||||
$db->next_record();
|
||||
return ($db->f('realname'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the groups a user is in
|
||||
* @param int $userid
|
||||
* @return array Real names of groups
|
||||
*/
|
||||
function getGroupsByUserID($userid)
|
||||
{
|
||||
function getGroupsByUserID($userid) {
|
||||
global $cfg;
|
||||
|
||||
$db = new DB_ConLite();
|
||||
|
@ -774,12 +725,12 @@ class User
|
|||
$sql = "SELECT
|
||||
a.group_id
|
||||
FROM
|
||||
".$cfg['tab']['groups']." AS a,
|
||||
".$cfg['tab']['groupmembers']." AS b
|
||||
" . $cfg['tab']['groups'] . " AS a,
|
||||
" . $cfg['tab']['groupmembers'] . " AS b
|
||||
WHERE
|
||||
(a.group_id = b.group_id)
|
||||
AND
|
||||
(b.user_id = '".Contenido_Security::escapeDB($userid, $db)."')
|
||||
(b.user_id = '" . Contenido_Security::escapeDB($userid, $db) . "')
|
||||
";
|
||||
|
||||
$db->query($sql);
|
||||
|
@ -796,7 +747,7 @@ class User
|
|||
$sDescription = trim($oGroup->getField('description'));
|
||||
|
||||
if ($sDescription != '') {
|
||||
$sTemp.=' ('.$sDescription.')';
|
||||
$sTemp .= ' (' . $sDescription . ')';
|
||||
}
|
||||
|
||||
$arrGroups[] = $sTemp;
|
||||
|
@ -804,14 +755,12 @@ class User
|
|||
return $arrGroups;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the groups a user is in
|
||||
* @param int $userid
|
||||
* @return array Ids of groups
|
||||
*/
|
||||
function getGroupIDsByUserID($userid)
|
||||
{
|
||||
function getGroupIDsByUserID($userid) {
|
||||
global $cfg;
|
||||
|
||||
$db = new DB_ConLite();
|
||||
|
@ -819,12 +768,12 @@ class User
|
|||
$sql = "SELECT
|
||||
a.group_id
|
||||
FROM
|
||||
".$cfg['tab']['groups']." AS a,
|
||||
".$cfg['tab']['groupmembers']." AS b
|
||||
" . $cfg['tab']['groups'] . " AS a,
|
||||
" . $cfg['tab']['groupmembers'] . " AS b
|
||||
WHERE
|
||||
(a.group_id = b.group_id)
|
||||
AND
|
||||
(b.user_id = '".Contenido_Security::escapeDB($userid, $db)."')
|
||||
(b.user_id = '" . Contenido_Security::escapeDB($userid, $db) . "')
|
||||
";
|
||||
|
||||
$db->query($sql);
|
||||
|
@ -838,5 +787,3 @@ class User
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -41,7 +41,7 @@ class cWYSIWYGEditor
|
|||
var $_sEditorContent;
|
||||
var $_aSettings;
|
||||
|
||||
function cWYSIWYGEditor ($sEditorName, $sEditorContent)
|
||||
function __construct ($sEditorName, $sEditorContent)
|
||||
{
|
||||
global $cfg;
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ class XML_doc {
|
|||
/**
|
||||
* Class Construcor
|
||||
*/
|
||||
function XML_doc() {
|
||||
function __construct() {
|
||||
global $encoding, $lang;
|
||||
|
||||
$this->sys_encoding = $encoding[$lang];
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -27,9 +28,8 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -91,526 +91,476 @@ if(!defined('CON_FRAMEWORK')) {
|
|||
* @copyright four for business AG <www.4fb.de>
|
||||
* @version 1.0
|
||||
*/
|
||||
class XmlParser
|
||||
{
|
||||
/**
|
||||
class XmlParser {
|
||||
|
||||
/**
|
||||
* XML Parser autofree
|
||||
*
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
var $autofree = true;
|
||||
|
||||
var $autofree = true;
|
||||
|
||||
/**
|
||||
* XML Parser object
|
||||
*
|
||||
*
|
||||
* @var object
|
||||
* @access private
|
||||
* @access private
|
||||
*/
|
||||
var $parser;
|
||||
var $parser;
|
||||
|
||||
/**
|
||||
* Error message
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
* @access private
|
||||
*/
|
||||
var $error = '';
|
||||
var $error = '';
|
||||
|
||||
/**
|
||||
* Element depth
|
||||
* @var int
|
||||
* @access private
|
||||
* @access private
|
||||
*/
|
||||
var $depth = -1;
|
||||
|
||||
/**
|
||||
* Element counter
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
var $count = 0;
|
||||
|
||||
/**
|
||||
* Path counter
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
var $pcount = 0;
|
||||
|
||||
/**
|
||||
* Array for creating the path
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $paths = array();
|
||||
|
||||
/**
|
||||
* Data storage container for the path data
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $pathdata = array();
|
||||
|
||||
/**
|
||||
* String storing the active path
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $activepath = '';
|
||||
|
||||
/**
|
||||
* The active node
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $activenode = '';
|
||||
|
||||
/**
|
||||
* The defined events
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $events = array();
|
||||
|
||||
/**
|
||||
* Constructor function
|
||||
*
|
||||
* @access private
|
||||
* @param string $sEncoding Encoding used when parsing files (default: UTF-8, as in PHP5)
|
||||
* @return void
|
||||
*/
|
||||
function XmlParser($sEncoding = false)
|
||||
{
|
||||
if (!$sEncoding)
|
||||
{
|
||||
$sEncoding = "UTF-8";
|
||||
}
|
||||
|
||||
$this->_init($sEncoding);
|
||||
}
|
||||
var $depth = -1;
|
||||
|
||||
/**
|
||||
* Element counter
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
var $count = 0;
|
||||
|
||||
/**
|
||||
* Path counter
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
var $pcount = 0;
|
||||
|
||||
/**
|
||||
* Array for creating the path
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $paths = array();
|
||||
|
||||
/**
|
||||
* Data storage container for the path data
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $pathdata = array();
|
||||
|
||||
/**
|
||||
* String storing the active path
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $activepath = '';
|
||||
|
||||
/**
|
||||
* The active node
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $activenode = '';
|
||||
|
||||
/**
|
||||
* The defined events
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $events = array();
|
||||
|
||||
/**
|
||||
* Constructor function
|
||||
*
|
||||
* @access private
|
||||
* @param string $sEncoding Encoding used when parsing files (default: UTF-8, as in PHP5)
|
||||
* @return void
|
||||
*/
|
||||
function __construct($sEncoding = false) {
|
||||
if (!$sEncoding) {
|
||||
$sEncoding = "UTF-8";
|
||||
}
|
||||
|
||||
$this->_init($sEncoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the XML Parser object and sets all options
|
||||
*
|
||||
* @access private
|
||||
* @param string $sEncoding Encoding used when parsing files (default: UTF-8, as in PHP5)
|
||||
* @param string $sEncoding Encoding used when parsing files (default: UTF-8, as in PHP5)
|
||||
* @return void
|
||||
*/
|
||||
function _init($sEncoding = false)
|
||||
{
|
||||
if (!$sEncoding)
|
||||
{
|
||||
$sEncoding = "UTF-8";
|
||||
}
|
||||
// Create parser instance
|
||||
function _init($sEncoding = false) {
|
||||
if (!$sEncoding) {
|
||||
$sEncoding = "UTF-8";
|
||||
}
|
||||
// Create parser instance
|
||||
$this->parser = xml_parser_create($sEncoding);
|
||||
|
||||
|
||||
// Set parser options
|
||||
xml_set_object($this->parser, $this);
|
||||
xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false);
|
||||
xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $sEncoding);
|
||||
|
||||
xml_set_element_handler($this->parser, '_startElement', '_endElement');
|
||||
xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false);
|
||||
xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $sEncoding);
|
||||
|
||||
xml_set_element_handler($this->parser, '_startElement', '_endElement');
|
||||
xml_set_character_data_handler($this->parser, '_characterData');
|
||||
xml_set_processing_instruction_handler($this->parser, '_processingInstruction');
|
||||
|
||||
// Misc stuff
|
||||
$this->events['paths'] = array(NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the XML error message
|
||||
*
|
||||
* @return string XML Error message
|
||||
* @access private
|
||||
*/
|
||||
function _error()
|
||||
{
|
||||
$this->error = "XML error: ".xml_error_string(xml_get_error_code($this->parser))." at line ".xml_get_current_line_number($this->parser);
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define events for the XML parser
|
||||
*
|
||||
* You can define handler functions/objects for start, end, PI and data sections (1.) or
|
||||
* your can define path which will trigger the defined event when encountered (2.)
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* 1.) $parser->setEvents(array("startElement" => "myFunction",
|
||||
* "endElement" => "myFunction",
|
||||
* "characterData" => "myFunction",
|
||||
* "processingInstruction" => "myFunction");
|
||||
*
|
||||
* The value can also be an array with the object reference and the method to call.
|
||||
* i.e. "startElement"=>array(&$myObj, "myMethod") instead of "startelement"=>"myFunction"
|
||||
*
|
||||
* 2.) $parser->setEvents(array("/root/foo/bar"=>"myFunction"));
|
||||
*
|
||||
* Valid array keys are: 'startElement', 'endElement', 'characterData', 'processingInstruction' and paths
|
||||
* folowing the scheme '/root/element'. The path MUST begin from the root element and MUST start with '/'.
|
||||
*
|
||||
* The value can also be an array with the object reference and the method to call.
|
||||
* i.e. "/foo/bar"=>array(&$myObj, "myMethod") instead of "/foo/bar"=>"myFunction"
|
||||
*
|
||||
* @param array Options array, valid keys are 'startElement', 'endElement', 'characterData', 'processingInstruction', or a path
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function setEventHandlers($options = array(NULL))
|
||||
{
|
||||
$options = $this->_changeKeyCase($options);
|
||||
|
||||
if (array_key_exists('startelement', $options))
|
||||
{
|
||||
$this->events['startelement'] = $options['startelement'];
|
||||
}
|
||||
|
||||
if (array_key_exists('endelement', $options))
|
||||
{
|
||||
$this->events['endelement'] = $options['endelement'];
|
||||
}
|
||||
|
||||
if (array_key_exists('characterdata', $options))
|
||||
{
|
||||
$this->events['characterdata'] = $options['characterdata'];
|
||||
}
|
||||
|
||||
if (array_key_exists('processinginstruction', $options))
|
||||
{
|
||||
$this->events['processinginstruction'] = $options['processinginstruction'];
|
||||
}
|
||||
|
||||
$paths = $this->_getDefinedPaths($options);
|
||||
|
||||
$this->events['paths'] = $paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the processing instruction handler
|
||||
*
|
||||
* @param string Processing instruction handler
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function _processingInstruction($parser, $target, $data)
|
||||
{
|
||||
$handler = $this->_getEventHandler('processinginstruction');
|
||||
|
||||
if ($handler)
|
||||
{
|
||||
if (is_array($handler))
|
||||
{
|
||||
$handler[0]->$handler[1]($target, $data);
|
||||
} else
|
||||
{
|
||||
$handler($target, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change all array keys to lowercase
|
||||
* (PHP function change_key_case is available at PHP 4.2 +)
|
||||
*
|
||||
* @param array Source array
|
||||
*
|
||||
* @return array Array with lowercased keys
|
||||
* @access private
|
||||
*/
|
||||
function _changeKeyCase($options = array())
|
||||
{
|
||||
$tmp = array();
|
||||
|
||||
foreach ($options as $key => $value)
|
||||
{
|
||||
$tmp[strtolower($key)] = $value;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns events handlers if set
|
||||
*
|
||||
* @param string Event type
|
||||
*
|
||||
* @return sring Event handler name
|
||||
* @access private
|
||||
*/
|
||||
function _getEventHandler($event)
|
||||
{
|
||||
// Standard events
|
||||
if (array_key_exists($event, $this->events))
|
||||
{
|
||||
return $this->events[$event];
|
||||
}
|
||||
|
||||
// Paths events
|
||||
if (array_key_exists($event, $this->events['paths']))
|
||||
{
|
||||
return $this->events['paths'][$event];
|
||||
}
|
||||
|
||||
// No events found
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all defined paths from the options
|
||||
* array and returns a new array containing
|
||||
* only the paths to function bindings
|
||||
*
|
||||
* @param array Options array
|
||||
*
|
||||
* @return array Paths array
|
||||
* @access private
|
||||
*/
|
||||
function _getDefinedPaths($options)
|
||||
{
|
||||
$tmp = array();
|
||||
|
||||
foreach ($options as $key => $value)
|
||||
{
|
||||
if (strstr($key, '/'))
|
||||
{
|
||||
$tmp[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a path to the stack
|
||||
*
|
||||
* @param string Element node name
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function _addPath($depth, $name)
|
||||
{
|
||||
$this->paths[$depth] = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current active path
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _getActivePath()
|
||||
{
|
||||
$tmp = array();
|
||||
|
||||
for ($i=0; $i<=$this->depth; $i++)
|
||||
{
|
||||
$tmp[] = $this->paths[$i];
|
||||
}
|
||||
|
||||
$path = '/' . join('/', $tmp);
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
// Misc stuff
|
||||
$this->events['paths'] = array(NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the XML error message
|
||||
*
|
||||
* @return string XML Error message
|
||||
* @access private
|
||||
*/
|
||||
function _error() {
|
||||
$this->error = "XML error: " . xml_error_string(xml_get_error_code($this->parser)) . " at line " . xml_get_current_line_number($this->parser);
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define events for the XML parser
|
||||
*
|
||||
* You can define handler functions/objects for start, end, PI and data sections (1.) or
|
||||
* your can define path which will trigger the defined event when encountered (2.)
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* 1.) $parser->setEvents(array("startElement" => "myFunction",
|
||||
* "endElement" => "myFunction",
|
||||
* "characterData" => "myFunction",
|
||||
* "processingInstruction" => "myFunction");
|
||||
*
|
||||
* The value can also be an array with the object reference and the method to call.
|
||||
* i.e. "startElement"=>array(&$myObj, "myMethod") instead of "startelement"=>"myFunction"
|
||||
*
|
||||
* 2.) $parser->setEvents(array("/root/foo/bar"=>"myFunction"));
|
||||
*
|
||||
* Valid array keys are: 'startElement', 'endElement', 'characterData', 'processingInstruction' and paths
|
||||
* folowing the scheme '/root/element'. The path MUST begin from the root element and MUST start with '/'.
|
||||
*
|
||||
* The value can also be an array with the object reference and the method to call.
|
||||
* i.e. "/foo/bar"=>array(&$myObj, "myMethod") instead of "/foo/bar"=>"myFunction"
|
||||
*
|
||||
* @param array Options array, valid keys are 'startElement', 'endElement', 'characterData', 'processingInstruction', or a path
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function setEventHandlers($options = array(NULL)) {
|
||||
$options = $this->_changeKeyCase($options);
|
||||
|
||||
if (array_key_exists('startelement', $options)) {
|
||||
$this->events['startelement'] = $options['startelement'];
|
||||
}
|
||||
|
||||
if (array_key_exists('endelement', $options)) {
|
||||
$this->events['endelement'] = $options['endelement'];
|
||||
}
|
||||
|
||||
if (array_key_exists('characterdata', $options)) {
|
||||
$this->events['characterdata'] = $options['characterdata'];
|
||||
}
|
||||
|
||||
if (array_key_exists('processinginstruction', $options)) {
|
||||
$this->events['processinginstruction'] = $options['processinginstruction'];
|
||||
}
|
||||
|
||||
$paths = $this->_getDefinedPaths($options);
|
||||
|
||||
$this->events['paths'] = $paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the processing instruction handler
|
||||
*
|
||||
* @param string Processing instruction handler
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function _processingInstruction($parser, $target, $data) {
|
||||
$handler = $this->_getEventHandler('processinginstruction');
|
||||
|
||||
if ($handler) {
|
||||
if (is_array($handler)) {
|
||||
$handler[0]->$handler[1]($target, $data);
|
||||
} else {
|
||||
$handler($target, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change all array keys to lowercase
|
||||
* (PHP function change_key_case is available at PHP 4.2 +)
|
||||
*
|
||||
* @param array Source array
|
||||
*
|
||||
* @return array Array with lowercased keys
|
||||
* @access private
|
||||
*/
|
||||
function _changeKeyCase($options = array()) {
|
||||
$tmp = array();
|
||||
|
||||
foreach ($options as $key => $value) {
|
||||
$tmp[strtolower($key)] = $value;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns events handlers if set
|
||||
*
|
||||
* @param string Event type
|
||||
*
|
||||
* @return sring Event handler name
|
||||
* @access private
|
||||
*/
|
||||
function _getEventHandler($event) {
|
||||
// Standard events
|
||||
if (array_key_exists($event, $this->events)) {
|
||||
return $this->events[$event];
|
||||
}
|
||||
|
||||
// Paths events
|
||||
if (array_key_exists($event, $this->events['paths'])) {
|
||||
return $this->events['paths'][$event];
|
||||
}
|
||||
|
||||
// No events found
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all defined paths from the options
|
||||
* array and returns a new array containing
|
||||
* only the paths to function bindings
|
||||
*
|
||||
* @param array Options array
|
||||
*
|
||||
* @return array Paths array
|
||||
* @access private
|
||||
*/
|
||||
function _getDefinedPaths($options) {
|
||||
$tmp = array();
|
||||
|
||||
foreach ($options as $key => $value) {
|
||||
if (strstr($key, '/')) {
|
||||
$tmp[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a path to the stack
|
||||
*
|
||||
* @param string Element node name
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function _addPath($depth, $name) {
|
||||
$this->paths[$depth] = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current active path
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _getActivePath() {
|
||||
$tmp = array();
|
||||
|
||||
for ($i = 0; $i <= $this->depth; $i++) {
|
||||
$tmp[] = $this->paths[$i];
|
||||
}
|
||||
|
||||
$path = '/' . join('/', $tmp);
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* XML start element handler
|
||||
*
|
||||
* @param resource XML Parser resource
|
||||
* @param string XML Element node name
|
||||
* @param array XML Element node attributes
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
* @access private
|
||||
*/
|
||||
function _startElement($parser, $name, $attribs)
|
||||
{
|
||||
// Increase depth
|
||||
$this->depth ++;
|
||||
|
||||
// Set active node
|
||||
$this->activenode = $name;
|
||||
|
||||
// Increase element counter
|
||||
if ($this->activenode == $this->pathdata[$this->activepath][$this->count]['name'])
|
||||
{
|
||||
$this->count ++;
|
||||
} else
|
||||
{
|
||||
$this->count = 0;
|
||||
}
|
||||
|
||||
// Entering element context, add subpath
|
||||
$this->_addPath($this->depth, $name);
|
||||
|
||||
// Get the handler for this event
|
||||
$handler = $this->_getEventHandler('startelement');
|
||||
|
||||
// If a handler is defined call it
|
||||
if ($handler)
|
||||
{
|
||||
if (is_array($handler))
|
||||
{
|
||||
$handler[0]->$handler[1]($name, $attribs);
|
||||
} else
|
||||
{
|
||||
$handler($name, $attribs);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for defined path handlers
|
||||
$this->activepath = $this->_getActivePath();
|
||||
|
||||
// Save path data
|
||||
$this->pathdata[$this->activepath][$this->count] = array('name'=>$name, 'attribs'=>$attribs);
|
||||
}
|
||||
|
||||
/**
|
||||
* XML character data handler
|
||||
*
|
||||
* @param resource XML Parser resource
|
||||
* @param string XML node data
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function _characterData($parser, $data)
|
||||
{
|
||||
// Reset node count
|
||||
if ($this->activenode != $this->pathdata[$this->activepath][$this->count]['name'])
|
||||
{
|
||||
$this->count = 0;
|
||||
}
|
||||
|
||||
// Save path data
|
||||
$this->pathdata[$this->activepath][$this->count]['content'] .= $data;
|
||||
|
||||
// Get the handler for this event
|
||||
$handler = $this->_getEventHandler('characterdata');
|
||||
|
||||
// If a handler is defined call it
|
||||
if ($handler)
|
||||
{
|
||||
if (is_array($handler))
|
||||
{
|
||||
$handler[0]->$handler[1]($data);
|
||||
} else
|
||||
{
|
||||
$handler($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* XML end element handler
|
||||
*
|
||||
* @param resource XML Parser resource
|
||||
* @param string XML Element node name
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function _endElement($parser, $name)
|
||||
{
|
||||
// Get the handler for this event
|
||||
$handler = $this->_getEventHandler('endelement');
|
||||
|
||||
// Call Element handler
|
||||
if ($handler)
|
||||
{
|
||||
if (is_array($handler))
|
||||
{
|
||||
$handler[0]->$handler[1]($name);
|
||||
} else
|
||||
{
|
||||
$handler($name);
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the active path
|
||||
$this->activepath = $this->_getActivePath();
|
||||
|
||||
// Get handler for the active path
|
||||
$handler = $this->_getEventHandler($this->activepath);
|
||||
|
||||
// Call path handler
|
||||
if ($handler)
|
||||
{
|
||||
if (is_array($handler))
|
||||
{ // Handler is an object method
|
||||
$handler[0]->$handler[1]($this->pathdata[$this->activepath][$this->count]['name'],
|
||||
$this->pathdata[$this->activepath][$this->count]['attribs'],
|
||||
$this->pathdata[$this->activepath][$this->count]['content']);
|
||||
} else
|
||||
{ // Handler is a function
|
||||
$handler($this->pathdata[$this->activepath][$this->count]['name'],
|
||||
$this->pathdata[$this->activepath][$this->count]['attribs'],
|
||||
$this->pathdata[$this->activepath][$this->count]['content']);
|
||||
}
|
||||
}
|
||||
|
||||
// Decrease depth
|
||||
$this->depth --;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a XML string
|
||||
*
|
||||
* @param string XML data
|
||||
*
|
||||
* @return bool
|
||||
* @access public
|
||||
*/
|
||||
function parse($data, $final = false)
|
||||
{
|
||||
$success = xml_parse($this->parser, trim($data), $final);
|
||||
|
||||
if ($final && $this->autofree)
|
||||
{
|
||||
xml_parser_free($this->parser);
|
||||
}
|
||||
|
||||
if (!$success)
|
||||
{
|
||||
return $this->_error();
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
function _startElement($parser, $name, $attribs) {
|
||||
// Increase depth
|
||||
$this->depth ++;
|
||||
|
||||
/**
|
||||
* Parse a XML file
|
||||
*
|
||||
* @param string File location
|
||||
*
|
||||
* @return bool
|
||||
* @access public
|
||||
*/
|
||||
function parseFile($file)
|
||||
{
|
||||
if (!($fp = fopen($file, "rb")))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
while ($sData = fread($fp, 4096))
|
||||
{
|
||||
if (!xml_parse($this->parser, $sData, feof($fp)))
|
||||
{
|
||||
$this->_error();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->autofree)
|
||||
{
|
||||
xml_parser_free($this->parser);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
// Set active node
|
||||
$this->activenode = $name;
|
||||
|
||||
} // XML_Parser
|
||||
// Increase element counter
|
||||
if ($this->activenode == $this->pathdata[$this->activepath][$this->count]['name']) {
|
||||
$this->count ++;
|
||||
} else {
|
||||
$this->count = 0;
|
||||
}
|
||||
|
||||
// Entering element context, add subpath
|
||||
$this->_addPath($this->depth, $name);
|
||||
|
||||
// Get the handler for this event
|
||||
$handler = $this->_getEventHandler('startelement');
|
||||
|
||||
// If a handler is defined call it
|
||||
if ($handler) {
|
||||
if (is_array($handler)) {
|
||||
$handler[0]->$handler[1]($name, $attribs);
|
||||
} else {
|
||||
$handler($name, $attribs);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for defined path handlers
|
||||
$this->activepath = $this->_getActivePath();
|
||||
|
||||
// Save path data
|
||||
$this->pathdata[$this->activepath][$this->count] = array('name' => $name, 'attribs' => $attribs);
|
||||
}
|
||||
|
||||
/**
|
||||
* XML character data handler
|
||||
*
|
||||
* @param resource XML Parser resource
|
||||
* @param string XML node data
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function _characterData($parser, $data) {
|
||||
// Reset node count
|
||||
if ($this->activenode != $this->pathdata[$this->activepath][$this->count]['name']) {
|
||||
$this->count = 0;
|
||||
}
|
||||
|
||||
// Save path data
|
||||
$this->pathdata[$this->activepath][$this->count]['content'] .= $data;
|
||||
|
||||
// Get the handler for this event
|
||||
$handler = $this->_getEventHandler('characterdata');
|
||||
|
||||
// If a handler is defined call it
|
||||
if ($handler) {
|
||||
if (is_array($handler)) {
|
||||
$handler[0]->$handler[1]($data);
|
||||
} else {
|
||||
$handler($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* XML end element handler
|
||||
*
|
||||
* @param resource XML Parser resource
|
||||
* @param string XML Element node name
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function _endElement($parser, $name) {
|
||||
// Get the handler for this event
|
||||
$handler = $this->_getEventHandler('endelement');
|
||||
|
||||
// Call Element handler
|
||||
if ($handler) {
|
||||
if (is_array($handler)) {
|
||||
$handler[0]->$handler[1]($name);
|
||||
} else {
|
||||
$handler($name);
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the active path
|
||||
$this->activepath = $this->_getActivePath();
|
||||
|
||||
// Get handler for the active path
|
||||
$handler = $this->_getEventHandler($this->activepath);
|
||||
|
||||
// Call path handler
|
||||
if ($handler) {
|
||||
if (is_array($handler)) { // Handler is an object method
|
||||
$handler[0]->$handler[1]($this->pathdata[$this->activepath][$this->count]['name'],
|
||||
$this->pathdata[$this->activepath][$this->count]['attribs'],
|
||||
$this->pathdata[$this->activepath][$this->count]['content']);
|
||||
} else { // Handler is a function
|
||||
$handler($this->pathdata[$this->activepath][$this->count]['name'],
|
||||
$this->pathdata[$this->activepath][$this->count]['attribs'],
|
||||
$this->pathdata[$this->activepath][$this->count]['content']);
|
||||
}
|
||||
}
|
||||
|
||||
// Decrease depth
|
||||
$this->depth --;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a XML string
|
||||
*
|
||||
* @param string XML data
|
||||
*
|
||||
* @return bool
|
||||
* @access public
|
||||
*/
|
||||
function parse($data, $final = false) {
|
||||
$success = xml_parse($this->parser, trim($data), $final);
|
||||
|
||||
if ($final && $this->autofree) {
|
||||
xml_parser_free($this->parser);
|
||||
}
|
||||
|
||||
if (!$success) {
|
||||
return $this->_error();
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a XML file
|
||||
*
|
||||
* @param string File location
|
||||
*
|
||||
* @return bool
|
||||
* @access public
|
||||
*/
|
||||
function parseFile($file) {
|
||||
if (!($fp = fopen($file, "rb"))) {
|
||||
|
||||
}
|
||||
|
||||
while ($sData = fread($fp, 4096)) {
|
||||
if (!xml_parse($this->parser, $sData, feof($fp))) {
|
||||
$this->_error();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->autofree) {
|
||||
xml_parser_free($this->parser);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// XML_Parser
|
||||
?>
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -28,484 +29,452 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
/**
|
||||
* XmlTree class
|
||||
*
|
||||
* Class to create XML tree structures from
|
||||
* scratch without the need for a XML DOM
|
||||
*
|
||||
* Example:
|
||||
* XmlTree class
|
||||
*
|
||||
* Class to create XML tree structures from
|
||||
* scratch without the need for a XML DOM
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* !! 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
|
||||
*
|
||||
* $tree = new XmlTree('1.0', 'ISO-8859-1');
|
||||
* $root =& $tree->addRoot('rootname', 'some content', array('foo'=>'bar'));
|
||||
*
|
||||
* This genererates following XML:
|
||||
*
|
||||
* <?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
* <rootname foo="bar">some content</rootname>
|
||||
*
|
||||
* $root now references the 'rootname' node object.
|
||||
* To append childNodes use the appendChild method.
|
||||
*
|
||||
* $foo =& $root->appendChild('foo', 'bar');
|
||||
*
|
||||
* Note: From version 1.1 you can use the $obj->add() method
|
||||
* as shortcut to appendchild
|
||||
*
|
||||
* <?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
* <rootname foo="bar">some content<foo>bar</foo></rootname>
|
||||
*
|
||||
* !! ALWAYS use '=&' with the addRoot and appendChild methods. !!
|
||||
*
|
||||
*/
|
||||
class XmlTree
|
||||
{
|
||||
/**
|
||||
* XML Version string
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_strXmlVersion;
|
||||
|
||||
/**
|
||||
* XML Encoding string
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_strXmlEncoding;
|
||||
|
||||
/**
|
||||
* Root element name
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_strRootName;
|
||||
|
||||
/**
|
||||
* Root content
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_strRootContent;
|
||||
|
||||
/**
|
||||
* Root attributes
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_strRootAttribs;
|
||||
|
||||
/**
|
||||
* Root node
|
||||
* @var object
|
||||
* @access private
|
||||
*/
|
||||
var $_objRoot;
|
||||
|
||||
/**
|
||||
* Tree XML string
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_strXml;
|
||||
|
||||
/**
|
||||
* Indent character
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_indentChar = "";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string XML Version i.e. "1.0"
|
||||
* @param string XML Encoding i.e. "UTF-8"
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function XmlTree($strXmlVersion = '1.0', $strXmlEncoding = 'UTF-8')
|
||||
{
|
||||
$this->_strXmlVersion = 'version="'.$strXmlVersion.'"';
|
||||
$this->_strXmlEncoding = 'encoding="'.$strXmlEncoding.'"';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Root element to the XML Tree
|
||||
*
|
||||
* @param string XML Node Name
|
||||
* @param string XML Node Content
|
||||
* @param array Attributes array('name'=>'value')
|
||||
*
|
||||
* @return object Reference to the root node object
|
||||
*/
|
||||
function &addRoot($strNodeName, $strNodeContent = '', $arrNodeAttribs = array())
|
||||
{
|
||||
if (!$strNodeName)
|
||||
{
|
||||
return 'XmlTree::addRoot() -> No node name specified';
|
||||
}
|
||||
|
||||
$this->_objRoot = new XmlNode($strNodeName, $strNodeContent, $arrNodeAttribs);
|
||||
return $this->_objRoot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print or Return Tree XML
|
||||
*
|
||||
* @param boolean Return content
|
||||
*
|
||||
* @return string Tree XML
|
||||
*/
|
||||
function dump($bolReturn = false)
|
||||
{
|
||||
if (!is_object($this->_objRoot))
|
||||
{
|
||||
return 'XmlTree::dump() -> There is no root node';
|
||||
}
|
||||
|
||||
$this->_objRoot->setIndent($this->_indentChar);
|
||||
$this->_strXml = sprintf("<?xml %s %s?>\n", $this->_strXmlVersion, $this->_strXmlEncoding);
|
||||
$this->_strXml .= $this->_objRoot->toXml();
|
||||
|
||||
if ($bolReturn)
|
||||
{
|
||||
return $this->_strXml;
|
||||
}
|
||||
|
||||
echo $this->_strXml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the indent string
|
||||
* @param int level
|
||||
* @return void
|
||||
*/
|
||||
function setIndent($string)
|
||||
{
|
||||
$this->_indentChar = $string;
|
||||
}
|
||||
|
||||
} // XmlTree
|
||||
*
|
||||
* $tree = new XmlTree('1.0', 'ISO-8859-1');
|
||||
* $root =& $tree->addRoot('rootname', 'some content', array('foo'=>'bar'));
|
||||
*
|
||||
* This genererates following XML:
|
||||
*
|
||||
* <?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
* <rootname foo="bar">some content</rootname>
|
||||
*
|
||||
* $root now references the 'rootname' node object.
|
||||
* To append childNodes use the appendChild method.
|
||||
*
|
||||
* $foo =& $root->appendChild('foo', 'bar');
|
||||
*
|
||||
* Note: From version 1.1 you can use the $obj->add() method
|
||||
* as shortcut to appendchild
|
||||
*
|
||||
* <?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
* <rootname foo="bar">some content<foo>bar</foo></rootname>
|
||||
*
|
||||
* !! ALWAYS use '=&' with the addRoot and appendChild methods. !!
|
||||
*
|
||||
*/
|
||||
class XmlTree {
|
||||
|
||||
/**
|
||||
* XML Version string
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_strXmlVersion;
|
||||
|
||||
/**
|
||||
* XML Encoding string
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_strXmlEncoding;
|
||||
|
||||
/**
|
||||
* Root element name
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_strRootName;
|
||||
|
||||
/**
|
||||
* Root content
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_strRootContent;
|
||||
|
||||
/**
|
||||
* Root attributes
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_strRootAttribs;
|
||||
|
||||
/**
|
||||
* Root node
|
||||
* @var object
|
||||
* @access private
|
||||
*/
|
||||
var $_objRoot;
|
||||
|
||||
/**
|
||||
* Tree XML string
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_strXml;
|
||||
|
||||
/**
|
||||
* Indent character
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_indentChar = "";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string XML Version i.e. "1.0"
|
||||
* @param string XML Encoding i.e. "UTF-8"
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct($strXmlVersion = '1.0', $strXmlEncoding = 'UTF-8') {
|
||||
$this->_strXmlVersion = 'version="' . $strXmlVersion . '"';
|
||||
$this->_strXmlEncoding = 'encoding="' . $strXmlEncoding . '"';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Root element to the XML Tree
|
||||
*
|
||||
* @param string XML Node Name
|
||||
* @param string XML Node Content
|
||||
* @param array Attributes array('name'=>'value')
|
||||
*
|
||||
* @return object Reference to the root node object
|
||||
*/
|
||||
function &addRoot($strNodeName, $strNodeContent = '', $arrNodeAttribs = array()) {
|
||||
if (!$strNodeName) {
|
||||
return 'XmlTree::addRoot() -> No node name specified';
|
||||
}
|
||||
|
||||
$this->_objRoot = new XmlNode($strNodeName, $strNodeContent, $arrNodeAttribs);
|
||||
return $this->_objRoot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print or Return Tree XML
|
||||
*
|
||||
* @param boolean Return content
|
||||
*
|
||||
* @return string Tree XML
|
||||
*/
|
||||
function dump($bolReturn = false) {
|
||||
if (!is_object($this->_objRoot)) {
|
||||
return 'XmlTree::dump() -> There is no root node';
|
||||
}
|
||||
|
||||
$this->_objRoot->setIndent($this->_indentChar);
|
||||
$this->_strXml = sprintf("<?xml %s %s?>\n", $this->_strXmlVersion, $this->_strXmlEncoding);
|
||||
$this->_strXml .= $this->_objRoot->toXml();
|
||||
|
||||
if ($bolReturn) {
|
||||
return $this->_strXml;
|
||||
}
|
||||
|
||||
echo $this->_strXml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the indent string
|
||||
* @param int level
|
||||
* @return void
|
||||
*/
|
||||
function setIndent($string) {
|
||||
$this->_indentChar = $string;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// XmlTree
|
||||
|
||||
/**
|
||||
* XmlNode Object
|
||||
*
|
||||
* Object of a XML Tree Node
|
||||
*
|
||||
* @see XmlTree
|
||||
*
|
||||
* !! ALWAYS use '=&' with the addRoot and appendChild methods. !!
|
||||
*
|
||||
*/
|
||||
class XmlNode
|
||||
{
|
||||
/**
|
||||
* Indenting character
|
||||
* @var string
|
||||
*/
|
||||
var $_indentChar;
|
||||
|
||||
/**
|
||||
* Node name
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_strNodeName;
|
||||
|
||||
/**
|
||||
* Node content
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_strNodeContent;
|
||||
|
||||
/**
|
||||
* Added content
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_strNodeContentAdded;
|
||||
|
||||
/**
|
||||
* Node attributes
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_arrNodeAttribs;
|
||||
|
||||
/**
|
||||
* Enclose node content in a cdata section
|
||||
* @var boolean
|
||||
* @access private
|
||||
*/
|
||||
var $_cdata;
|
||||
|
||||
/**
|
||||
* XML for this node
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_strXml;
|
||||
|
||||
/**
|
||||
* Child count
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
var $_intChildCount = 0;
|
||||
|
||||
/**
|
||||
* Parent Node
|
||||
* @var object
|
||||
*/
|
||||
var $parentNode = 0;
|
||||
|
||||
/**
|
||||
* Childnodes
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $childNodes = array();
|
||||
|
||||
/**
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string XML Node Name
|
||||
* @param string XML Node Content
|
||||
* @param array Attributes array('name'=>'value')
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function XmlNode($strNodeName, $strNodeContent = '', $arrNodeAttribs = array(), $cdata = false)
|
||||
{
|
||||
if (!$strNodeName)
|
||||
{
|
||||
return $this->_throwError($this, '%s::Construtctor() : No node name specified.');
|
||||
}
|
||||
|
||||
$this->_cdata = $cdata;
|
||||
|
||||
$this->setNodeName($strNodeName);
|
||||
$this->setNodeContent($strNodeContent);
|
||||
$this->setNodeAttribs($arrNodeAttribs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a node name
|
||||
*
|
||||
* @param string Node name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function setNodeName($strNodeName)
|
||||
{
|
||||
$this->_strNodeName = $strNodeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set node content
|
||||
*
|
||||
* @param string Node content
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function setNodeContent($strNodeContent)
|
||||
{
|
||||
$this->_strNodeContent = $strNodeContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the node attributes
|
||||
*
|
||||
* @param array Node attributes array('name'=>'value')
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function setNodeAttribs($arrNodeAttribs)
|
||||
{
|
||||
$this->_arrNodeAttribs = $arrNodeAttribs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the node parent
|
||||
*
|
||||
* @param object Reference to the parent object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function setNodeParent(&$objParent)
|
||||
{
|
||||
$this->parentNode = $objParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add content to the node
|
||||
*
|
||||
* @param string Content
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function addNodeContent($strNodeContent)
|
||||
{
|
||||
$this->_strNodeContentAdded = $strNodeContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the node has childs
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function hasChilds()
|
||||
{
|
||||
return ($this->_intChildCount > 0) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a child child node
|
||||
*
|
||||
* @param string XML Node Name
|
||||
* @param string XML Node Content
|
||||
* @param array Attributes array('name'=>'value')
|
||||
* @param bool CDATA Section
|
||||
*
|
||||
* @return object Reference to the new node object
|
||||
*/
|
||||
function &appendChild($strNodeName, $strNodeContent = '', $arrNodeAttribs = array(), $cdata = false)
|
||||
{
|
||||
if (!$strNodeName)
|
||||
{
|
||||
return $this->_throwError($this, '%s::appendChild() : No node name specified');
|
||||
}
|
||||
|
||||
$pos = $this->_intChildCount ++;
|
||||
|
||||
$this->childNodes[$pos] = new XmlNode($strNodeName, $strNodeContent, $arrNodeAttribs, $cdata);
|
||||
$this->childNodes[$pos]->setNodeParent($this);
|
||||
|
||||
return $this->childNodes[$pos];
|
||||
}
|
||||
|
||||
/**
|
||||
* Short for appendChild method
|
||||
*
|
||||
* @see appendChild
|
||||
*/
|
||||
function &add($strNodeName, $strNodeContent = '', $arrNodeAttribs = array(), $cdata = false)
|
||||
{
|
||||
return $this->appendChild($strNodeName, $strNodeContent , $arrNodeAttribs , $cdata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the XML string for the node using the
|
||||
* node properties
|
||||
*
|
||||
* @return string XML String
|
||||
* @access private
|
||||
*/
|
||||
function toXml($indent = 0)
|
||||
{
|
||||
// Indent for nodes markub
|
||||
$sp = $this->_getIndent($indent);
|
||||
|
||||
// Indent for content
|
||||
$csp = $this->_getIndent($indent ++);
|
||||
|
||||
// Increment indent
|
||||
//$indent ++;
|
||||
|
||||
$this->_strXml = "$sp<".$this->_strNodeName.$this->_parseAttributes($this->_arrNodeAttribs);
|
||||
|
||||
$maxNodes = count($this->childNodes);
|
||||
|
||||
if ($this->_strNodeContent != '' || $this->_strNodeContentAdded != '' || $maxNodes > 0)
|
||||
{
|
||||
$this->_strXml .= ">";
|
||||
|
||||
if ($this->_cdata)
|
||||
{
|
||||
$this->_strXml .= "$csp<![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
|
||||
* XmlNode Object
|
||||
*
|
||||
* Object of a XML Tree Node
|
||||
*
|
||||
* @see XmlTree
|
||||
*
|
||||
* !! ALWAYS use '=&' with the addRoot and appendChild methods. !!
|
||||
*
|
||||
*/
|
||||
class XmlNode {
|
||||
|
||||
?>
|
||||
/**
|
||||
* Indenting character
|
||||
* @var string
|
||||
*/
|
||||
var $_indentChar;
|
||||
|
||||
/**
|
||||
* Node name
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_strNodeName;
|
||||
|
||||
/**
|
||||
* Node content
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_strNodeContent;
|
||||
|
||||
/**
|
||||
* Added content
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_strNodeContentAdded;
|
||||
|
||||
/**
|
||||
* Node attributes
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_arrNodeAttribs;
|
||||
|
||||
/**
|
||||
* Enclose node content in a cdata section
|
||||
* @var boolean
|
||||
* @access private
|
||||
*/
|
||||
var $_cdata;
|
||||
|
||||
/**
|
||||
* XML for this node
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_strXml;
|
||||
|
||||
/**
|
||||
* Child count
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
var $_intChildCount = 0;
|
||||
|
||||
/**
|
||||
* Parent Node
|
||||
* @var object
|
||||
*/
|
||||
var $parentNode = 0;
|
||||
|
||||
/**
|
||||
* Childnodes
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $childNodes = array();
|
||||
|
||||
/**
|
||||
* Class Constructor
|
||||
*
|
||||
* @param string XML Node Name
|
||||
* @param string XML Node Content
|
||||
* @param array Attributes array('name'=>'value')
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -27,9 +28,8 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,8 +49,8 @@ if(!defined('CON_FRAMEWORK')) {
|
|||
* $html = $xslt->process();
|
||||
*
|
||||
*/
|
||||
class XsltProcessor
|
||||
{
|
||||
class XsltProcessor {
|
||||
|
||||
/**
|
||||
* XSML Processor auto-free
|
||||
* @var bool
|
||||
|
@ -64,7 +64,7 @@ class XsltProcessor
|
|||
* @access private
|
||||
*/
|
||||
var $error = "";
|
||||
|
||||
|
||||
/**
|
||||
* Error number
|
||||
* @var int
|
||||
|
@ -78,14 +78,14 @@ class XsltProcessor
|
|||
* @access private
|
||||
*/
|
||||
var $result = "";
|
||||
|
||||
|
||||
/**
|
||||
* The XML String for the Transformation
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $xml = "";
|
||||
|
||||
|
||||
/**
|
||||
* The XSLT String for the Transformation
|
||||
* @var string
|
||||
|
@ -99,103 +99,95 @@ class XsltProcessor
|
|||
* @access private
|
||||
*/
|
||||
var $processor;
|
||||
|
||||
|
||||
/**
|
||||
* XSLT Process arguments array
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $arguments = array();
|
||||
|
||||
|
||||
/**
|
||||
* XSLT Process parameters array
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $parameters = array();
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @access private
|
||||
*/
|
||||
function XsltProcessor()
|
||||
{
|
||||
function __construct() {
|
||||
$this->_init();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the class
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function _init()
|
||||
{
|
||||
if (!function_exists("xslt_create"))
|
||||
{
|
||||
die ("Cannot instantiate XSLT Class \n XSLT not supported");
|
||||
function _init() {
|
||||
if (!function_exists("xslt_create")) {
|
||||
die("Cannot instantiate XSLT Class \n XSLT not supported");
|
||||
}
|
||||
|
||||
|
||||
$this->processor = xslt_create();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translate literal to numeric entities to avoid
|
||||
* the 'undefined entity error' that a literal
|
||||
* entity would cause.
|
||||
*
|
||||
*
|
||||
* @param string XML String with literal entities
|
||||
* @return string XML string with numeric entites
|
||||
* @access private
|
||||
* @access private
|
||||
*/
|
||||
function literal2NumericEntities($stringXml) {
|
||||
|
||||
$literal2NumericEntity = array();
|
||||
|
||||
if (empty($literal2NumericEntity))
|
||||
{
|
||||
if (empty($literal2NumericEntity)) {
|
||||
$transTbl = clGetHtmlTranslationTable(HTML_ENTITIES);
|
||||
|
||||
foreach ($transTbl as $char => $entity)
|
||||
{
|
||||
if (strpos('&"<>', $char) !== FALSE) continue;
|
||||
$literal2NumericEntity[$entity] = '&#'.ord($char).';';
|
||||
foreach ($transTbl as $char => $entity) {
|
||||
if (strpos('&"<>', $char) !== FALSE)
|
||||
continue;
|
||||
$literal2NumericEntity[$entity] = '&#' . ord($char) . ';';
|
||||
}
|
||||
}
|
||||
|
||||
return strtr($stringXml, $literal2NumericEntity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set the XML to be Transformed
|
||||
* @param string The XML String
|
||||
* @return void
|
||||
* @access public
|
||||
* @access public
|
||||
*/
|
||||
function setXml($xml)
|
||||
{
|
||||
function setXml($xml) {
|
||||
$this->arguments["/_xml"] = $this->literal2NumericEntities($xml);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the XSLT for the Transformation
|
||||
* @param string The XML String
|
||||
* @return void
|
||||
* @access public
|
||||
* @access public
|
||||
*/
|
||||
function setXsl($xsl)
|
||||
{
|
||||
function setXsl($xsl) {
|
||||
$this->arguments["/_xsl"] = $this->literal2NumericEntities($xsl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Set the XML-File to be Transformed
|
||||
* @param string Location of the XML file
|
||||
* @return void
|
||||
* @access public
|
||||
* @access public
|
||||
*/
|
||||
function setXmlFile($file)
|
||||
{
|
||||
function setXmlFile($file) {
|
||||
$xml = $this->readFromFile($file);
|
||||
$this->arguments["/_xml"] = $this->literal2NumericEntities($xml);
|
||||
}
|
||||
|
@ -204,136 +196,123 @@ class XsltProcessor
|
|||
* Set the XSL-File for the Transformation
|
||||
* @param string Location of the XSL file
|
||||
* @return void
|
||||
* @access public
|
||||
* @access public
|
||||
*/
|
||||
function setXslFile($file)
|
||||
{
|
||||
function setXslFile($file) {
|
||||
$xsl = $this->readFromFile($file);
|
||||
$this->arguments["/_xsl"] = $this->literal2NumericEntities($xsl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the contents of a file if
|
||||
* the passed parameter is a file.
|
||||
*
|
||||
*
|
||||
* @param string File location
|
||||
* @return string File contents
|
||||
* @access private
|
||||
* @access private
|
||||
*/
|
||||
function readFromFile($file)
|
||||
{
|
||||
if (file_exists($file))
|
||||
{
|
||||
function readFromFile($file) {
|
||||
if (file_exists($file)) {
|
||||
$data = file($file);
|
||||
$data = join($data, "");
|
||||
return $data;
|
||||
}
|
||||
|
||||
die ("<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.
|
||||
* The parameters can be accessed in XSL
|
||||
* with <xsl:param name="paramname"/>
|
||||
*
|
||||
* The parameters can be accessed in XSL
|
||||
* with <xsl:param name="paramname"/>
|
||||
*
|
||||
* @param string Name
|
||||
* @param string Value
|
||||
* @return void
|
||||
*/
|
||||
function setParam($name, $value)
|
||||
{
|
||||
function setParam($name, $value) {
|
||||
$this->parameters[$name] = utf8_encode($value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Define external scheme handlers for the XSLT Processor.
|
||||
*
|
||||
* Example param array:
|
||||
*
|
||||
* array("get_all", "mySchemeHandler")
|
||||
*
|
||||
* Example scheme handler function:
|
||||
*
|
||||
* function mySchemeHandler($processor, $scheme, $param)
|
||||
* {
|
||||
* // to remove the first slash added by Sablotron
|
||||
* $param = substr($param, 1);
|
||||
*
|
||||
* if ($scheme == 'file_exists')
|
||||
* { // result is returned as valid xml string
|
||||
* return '<?xml version="1.0" encoding="UTF-8"?><root>'.(file_exists($param) ? "true" : "false")."</root>";
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* To use the schema handler use:
|
||||
* <xsl:if test="document('file_exists:somefile.xml<6D>)/root = 'true'">
|
||||
* do something
|
||||
* </xsl:if>
|
||||
*
|
||||
* To call the external function use the 'document()' XSLT-Function.
|
||||
*
|
||||
* <xsl:value-of select="document('schemename:parameter')/root"/>
|
||||
*
|
||||
* Schemename and parameter will be passed to the handler function as second and third parameter.
|
||||
* The return value of the function must be valid XML to access it using XPath.
|
||||
*
|
||||
* @param array array("scheme"=>"schemeHandlerName");
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function setSchemeHandlers($aHandlers)
|
||||
{
|
||||
xslt_set_scheme_handlers($this->processor, $aHandlers);
|
||||
}
|
||||
* Define external scheme handlers for the XSLT Processor.
|
||||
*
|
||||
* Example param array:
|
||||
*
|
||||
* array("get_all", "mySchemeHandler")
|
||||
*
|
||||
* Example scheme handler function:
|
||||
*
|
||||
* function mySchemeHandler($processor, $scheme, $param)
|
||||
* {
|
||||
* // to remove the first slash added by Sablotron
|
||||
* $param = substr($param, 1);
|
||||
*
|
||||
* if ($scheme == 'file_exists')
|
||||
* { // result is returned as valid xml string
|
||||
* return '<?xml version="1.0" encoding="UTF-8"?><root>'.(file_exists($param) ? "true" : "false")."</root>";
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* To use the schema handler use:
|
||||
* <xsl:if test="document('file_exists:somefile.xml<6D>)/root = 'true'">
|
||||
* do something
|
||||
* </xsl:if>
|
||||
*
|
||||
* To call the external function use the 'document()' XSLT-Function.
|
||||
*
|
||||
* <xsl:value-of select="document('schemename:parameter')/root"/>
|
||||
*
|
||||
* Schemename and parameter will be passed to the handler function as second and third parameter.
|
||||
* The return value of the function must be valid XML to access it using XPath.
|
||||
*
|
||||
* @param array array("scheme"=>"schemeHandlerName");
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function setSchemeHandlers($aHandlers) {
|
||||
xslt_set_scheme_handlers($this->processor, $aHandlers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform the XML data using the XSL and
|
||||
* return the results of the transformation
|
||||
*
|
||||
* return the results of the transformation
|
||||
*
|
||||
* @return string Transformed data
|
||||
* @access public
|
||||
* @access public
|
||||
*/
|
||||
function process()
|
||||
{
|
||||
function process() {
|
||||
$this->result = xslt_process($this->processor, "arg:/_xml", "arg:/_xsl", NULL, $this->arguments, $this->parameters);
|
||||
$this->error = xslt_error($this->processor);
|
||||
$this->errno = xslt_errno($this->processor);
|
||||
|
||||
if ($this->autofree)
|
||||
{
|
||||
|
||||
if ($this->autofree) {
|
||||
xslt_free($this->processor);
|
||||
}
|
||||
|
||||
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints the Error message and number
|
||||
* if an error occured
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
* @access public
|
||||
*/
|
||||
function printErrors()
|
||||
{
|
||||
if ($this->errno > 0)
|
||||
{
|
||||
echo "<b>Error Number: </b><span style=\"color:red\">".$this->errno."</span> ";
|
||||
echo "<b>Error Message: </b><span style=\"color:red\">".$this->error."</span>";
|
||||
function printErrors() {
|
||||
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>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Manual free of the parser
|
||||
* @return void
|
||||
*/
|
||||
function free()
|
||||
{
|
||||
function free() {
|
||||
xslt_free($this->processor);
|
||||
}
|
||||
|
||||
|
||||
} // XSLT_Processor
|
||||
|
||||
?>
|
||||
}
|
||||
|
|
|
@ -37,12 +37,6 @@ class cApiModuleCollection extends ItemCollection {
|
|||
$this->_setItemClass("cApiModule");
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function cApiModuleCollection() {
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new communication item
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -23,66 +24,59 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
define("cDatatypeCurrency_Left", 1);
|
||||
define("cDatatypeCurrency_Right", 2);
|
||||
|
||||
class cDatatypeCurrency extends cDatatypeNumber
|
||||
{
|
||||
var $_cCurrencyLocation;
|
||||
var $_sCurrencySymbol;
|
||||
|
||||
function cDatatypeCurrency ()
|
||||
{
|
||||
cDatatypeNumber::cDataTypeNumber();
|
||||
|
||||
$this->setCurrencySymbolLocation(cDatatypeCurrency_Right);
|
||||
$this->setCurrencySymbol("<EFBFBD>");
|
||||
}
|
||||
|
||||
function setCurrencySymbol ($sSymbol)
|
||||
{
|
||||
$this->_sCurrencySymbol = $sSymbol;
|
||||
}
|
||||
|
||||
function getCurrencySymbol ()
|
||||
{
|
||||
return ($this->_sCurrencySymbol);
|
||||
}
|
||||
|
||||
function setCurrencySymbolLocation ($cLocation)
|
||||
{
|
||||
switch ($cLocation)
|
||||
{
|
||||
case cDatatypeCurrency_Left:
|
||||
case cDatatypeCurrency_Right:
|
||||
$this->_cCurrencyLocation = $cLocation;
|
||||
break;
|
||||
default:
|
||||
cWarning(__FILE__, __LINE__, "Warning: No valid cDatatypeCurrency_* Constant given. Available values: cDatatypeCurrency_Left, cDatatypeCurrency_Right");
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function render ()
|
||||
{
|
||||
$value = parent::render();
|
||||
|
||||
switch ($this->_cCurrencyLocation)
|
||||
{
|
||||
case cDatatypeCurrency_Left:
|
||||
return sprintf("%s %s", $this->_sCurrencySymbol, $value);
|
||||
break;
|
||||
case cDatatypeCurrency_Right:
|
||||
return sprintf("%s %s", $value, $this->_sCurrencySymbol);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
class cDatatypeCurrency extends cDatatypeNumber {
|
||||
|
||||
var $_cCurrencyLocation;
|
||||
var $_sCurrencySymbol;
|
||||
|
||||
function __construct() {
|
||||
cDatatypeNumber::__construct();
|
||||
|
||||
$this->setCurrencySymbolLocation(cDatatypeCurrency_Right);
|
||||
$this->setCurrencySymbol("<EFBFBD>");
|
||||
}
|
||||
|
||||
function setCurrencySymbol($sSymbol) {
|
||||
$this->_sCurrencySymbol = $sSymbol;
|
||||
}
|
||||
|
||||
function getCurrencySymbol() {
|
||||
return ($this->_sCurrencySymbol);
|
||||
}
|
||||
|
||||
function setCurrencySymbolLocation($cLocation) {
|
||||
switch ($cLocation) {
|
||||
case cDatatypeCurrency_Left:
|
||||
case cDatatypeCurrency_Right:
|
||||
$this->_cCurrencyLocation = $cLocation;
|
||||
break;
|
||||
default:
|
||||
cWarning(__FILE__, __LINE__, "Warning: No valid cDatatypeCurrency_* Constant given. Available values: cDatatypeCurrency_Left, cDatatypeCurrency_Right");
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function render() {
|
||||
$value = parent::render();
|
||||
|
||||
switch ($this->_cCurrencyLocation) {
|
||||
case cDatatypeCurrency_Left:
|
||||
return sprintf("%s %s", $this->_sCurrencySymbol, $value);
|
||||
break;
|
||||
case cDatatypeCurrency_Right:
|
||||
return sprintf("%s %s", $value, $this->_sCurrencySymbol);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -25,18 +26,17 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
/* The UNIX Timestamp is the amount of seconds
|
||||
passed since Jan 1 1970 00:00:00 GMT */
|
||||
define("cDateTime_UNIX" , 1);
|
||||
passed since Jan 1 1970 00:00:00 GMT */
|
||||
define("cDateTime_UNIX", 1);
|
||||
|
||||
/* 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 */
|
||||
define("cDateTime_Locale", 3);
|
||||
|
@ -48,10 +48,10 @@ define("cDateTime_Locale_TimeOnly", 4);
|
|||
define("cDateTime_Locale_DateOnly", 5);
|
||||
|
||||
/* The MySQL Timestamp is CCYYMMDDHHmmSS */
|
||||
define("cDateTime_MySQL" , 6);
|
||||
define("cDateTime_MySQL", 6);
|
||||
|
||||
/* Custom format */
|
||||
define("cDateTime_Custom" , 99);
|
||||
define("cDateTime_Custom", 99);
|
||||
|
||||
define("cDateTime_Sunday", 0);
|
||||
define("cDateTime_Monday", 1);
|
||||
|
@ -61,516 +61,462 @@ define("cDateTime_Thursday", 4);
|
|||
define("cDateTime_Friday", 5);
|
||||
define("cDateTime_Saturday", 6);
|
||||
|
||||
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);
|
||||
}
|
||||
class cDatatypeDateTime extends cDatatype {
|
||||
|
||||
function setMonth ($iMonth)
|
||||
{
|
||||
$this->_iMonth = $iMonth;
|
||||
}
|
||||
|
||||
function getMonth ()
|
||||
{
|
||||
return ($this->_iMonth);
|
||||
}
|
||||
|
||||
function setDay ($iDay)
|
||||
{
|
||||
$this->_iDay = $iDay;
|
||||
}
|
||||
|
||||
function getDay ()
|
||||
{
|
||||
return ($this->_iDay);
|
||||
}
|
||||
var $_iFirstDayOfWeek;
|
||||
|
||||
function getMonthName ($iMonth)
|
||||
{
|
||||
switch ($iMonth)
|
||||
{
|
||||
case 1: return i18n("January");
|
||||
case 2: return i18n("February");
|
||||
case 3: return i18n("March");
|
||||
case 4: return i18n("April");
|
||||
case 5: return i18n("May");
|
||||
case 6: return i18n("June");
|
||||
case 7: return i18n("July");
|
||||
case 8: return i18n("August");
|
||||
case 9: return i18n("September");
|
||||
case 10: return i18n("October");
|
||||
case 11: return i18n("November");
|
||||
case 12: return i18n("December");
|
||||
}
|
||||
}
|
||||
|
||||
function getDayName ($iDayOfWeek)
|
||||
{
|
||||
switch ($iDayOfWeek)
|
||||
{
|
||||
case 0: return i18n("Sunday");
|
||||
case 1: return i18n("Monday");
|
||||
case 2: return i18n("Tuesday");
|
||||
case 3: return i18n("Wednesday");
|
||||
case 4: return i18n("Thursday");
|
||||
case 5: return i18n("Friday");
|
||||
case 6: return i18n("Saturday");
|
||||
case 7: return i18n("Sunday");
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getDayOrder ()
|
||||
{
|
||||
$aDays = array(0, 1, 2, 3, 4, 5, 6);
|
||||
$aRemainderDays = array_splice($aDays, 0, $this->_iFirstDayOfWeek);
|
||||
|
||||
$aReturnDays = array_merge($aDays, $aRemainderDays);
|
||||
|
||||
return ($aReturnDays);
|
||||
}
|
||||
|
||||
function getNumberOfMonthDays ($iMonth = false, $iYear = false)
|
||||
{
|
||||
if ($iMonth === false)
|
||||
{
|
||||
$iMonth = $this->_iMonth;
|
||||
}
|
||||
|
||||
if ($iYear === false)
|
||||
{
|
||||
$iYear = $this->_iYear;
|
||||
}
|
||||
|
||||
return date("t", mktime(0,0,0,$iMonth, 1, $iYear));
|
||||
}
|
||||
|
||||
function setFirstDayOfWeek ($iDay)
|
||||
{
|
||||
$this->_iFirstDayOfWeek = $iDay;
|
||||
}
|
||||
|
||||
function getFirstDayOfWeek ()
|
||||
{
|
||||
return $this->_iFirstDayOfWeek;
|
||||
}
|
||||
|
||||
function getLeapDay ()
|
||||
{
|
||||
return end($this->getDayOrder());
|
||||
}
|
||||
|
||||
function set ($value, $iOverrideFormat = false)
|
||||
{
|
||||
if ($value == "")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ($iOverrideFormat !== false)
|
||||
{
|
||||
$iFormat = $iOverrideFormat;
|
||||
} else {
|
||||
$iFormat = $this->_cSourceFormat;
|
||||
}
|
||||
|
||||
switch ($iFormat)
|
||||
{
|
||||
case cDateTime_UNIX:
|
||||
$sTemporaryTimestamp = $value;
|
||||
$this->_iYear = date("Y", $sTemporaryTimestamp);
|
||||
$this->_iMonth = date("m", $sTemporaryTimestamp);
|
||||
$this->_iDay = date("d", $sTemporaryTimestamp);
|
||||
$this->_iHour = date("H", $sTemporaryTimestamp);
|
||||
$this->_iMinute = date("i", $sTemporaryTimestamp);
|
||||
$this->_iSecond = date("s", $sTemporaryTimestamp);
|
||||
|
||||
break;
|
||||
case cDateTime_ISO:
|
||||
$sTemporaryTimestamp = strtotime($value);
|
||||
$this->_iYear = date("Y", $sTemporaryTimestamp);
|
||||
$this->_iMonth = date("m", $sTemporaryTimestamp);
|
||||
$this->_iDay = date("d", $sTemporaryTimestamp);
|
||||
$this->_iHour = date("H", $sTemporaryTimestamp);
|
||||
$this->_iMinute = date("i", $sTemporaryTimestamp);
|
||||
$this->_iSecond = date("s", $sTemporaryTimestamp);
|
||||
break;
|
||||
/* This datatype stores its date format in ISO */
|
||||
|
||||
function __construct() {
|
||||
$this->setTargetFormat(cDateTime_Locale);
|
||||
$this->setSourceFormat(cDateTime_UNIX);
|
||||
|
||||
$this->_iYear = 1970;
|
||||
$this->_iMonth = 1;
|
||||
$this->_iDay = 1;
|
||||
$this->_iHour = 0;
|
||||
$this->_iMinute = 0;
|
||||
$this->_iSecond = 0;
|
||||
|
||||
$this->setFirstDayOfWeek(cDateTime_Monday);
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function setCustomTargetFormat($targetFormat) {
|
||||
$this->_sCustomTargetFormat = $targetFormat;
|
||||
}
|
||||
|
||||
function setCustomSourceFormat($sourceFormat) {
|
||||
$this->_sCustomSourceFormat = $sourceFormat;
|
||||
}
|
||||
|
||||
function setSourceFormat($cSourceFormat) {
|
||||
$this->_cSourceFormat = $cSourceFormat;
|
||||
}
|
||||
|
||||
function setTargetFormat($cTargetFormat) {
|
||||
$this->_cTargetFormat = $cTargetFormat;
|
||||
}
|
||||
|
||||
function setYear($iYear) {
|
||||
$this->_iYear = $iYear;
|
||||
}
|
||||
|
||||
function getYear() {
|
||||
return ($this->_iYear);
|
||||
}
|
||||
|
||||
function setMonth($iMonth) {
|
||||
$this->_iMonth = $iMonth;
|
||||
}
|
||||
|
||||
function getMonth() {
|
||||
return ($this->_iMonth);
|
||||
}
|
||||
|
||||
function setDay($iDay) {
|
||||
$this->_iDay = $iDay;
|
||||
}
|
||||
|
||||
function getDay() {
|
||||
return ($this->_iDay);
|
||||
}
|
||||
|
||||
function getMonthName($iMonth) {
|
||||
switch ($iMonth) {
|
||||
case 1: return i18n("January");
|
||||
case 2: return i18n("February");
|
||||
case 3: return i18n("March");
|
||||
case 4: return i18n("April");
|
||||
case 5: return i18n("May");
|
||||
case 6: return i18n("June");
|
||||
case 7: return i18n("July");
|
||||
case 8: return i18n("August");
|
||||
case 9: return i18n("September");
|
||||
case 10: return i18n("October");
|
||||
case 11: return i18n("November");
|
||||
case 12: return i18n("December");
|
||||
}
|
||||
}
|
||||
|
||||
function getDayName($iDayOfWeek) {
|
||||
switch ($iDayOfWeek) {
|
||||
case 0: return i18n("Sunday");
|
||||
case 1: return i18n("Monday");
|
||||
case 2: return i18n("Tuesday");
|
||||
case 3: return i18n("Wednesday");
|
||||
case 4: return i18n("Thursday");
|
||||
case 5: return i18n("Friday");
|
||||
case 6: return i18n("Saturday");
|
||||
case 7: return i18n("Sunday");
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getDayOrder() {
|
||||
$aDays = array(0, 1, 2, 3, 4, 5, 6);
|
||||
$aRemainderDays = array_splice($aDays, 0, $this->_iFirstDayOfWeek);
|
||||
|
||||
$aReturnDays = array_merge($aDays, $aRemainderDays);
|
||||
|
||||
return ($aReturnDays);
|
||||
}
|
||||
|
||||
function getNumberOfMonthDays($iMonth = false, $iYear = false) {
|
||||
if ($iMonth === false) {
|
||||
$iMonth = $this->_iMonth;
|
||||
}
|
||||
|
||||
if ($iYear === false) {
|
||||
$iYear = $this->_iYear;
|
||||
}
|
||||
|
||||
return date("t", mktime(0, 0, 0, $iMonth, 1, $iYear));
|
||||
}
|
||||
|
||||
function setFirstDayOfWeek($iDay) {
|
||||
$this->_iFirstDayOfWeek = $iDay;
|
||||
}
|
||||
|
||||
function getFirstDayOfWeek() {
|
||||
return $this->_iFirstDayOfWeek;
|
||||
}
|
||||
|
||||
function getLeapDay() {
|
||||
return end($this->getDayOrder());
|
||||
}
|
||||
|
||||
function set($value, $iOverrideFormat = false) {
|
||||
if ($value == "") {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($iOverrideFormat !== false) {
|
||||
$iFormat = $iOverrideFormat;
|
||||
} else {
|
||||
$iFormat = $this->_cSourceFormat;
|
||||
}
|
||||
|
||||
switch ($iFormat) {
|
||||
case cDateTime_UNIX:
|
||||
$sTemporaryTimestamp = $value;
|
||||
$this->_iYear = date("Y", $sTemporaryTimestamp);
|
||||
$this->_iMonth = date("m", $sTemporaryTimestamp);
|
||||
$this->_iDay = date("d", $sTemporaryTimestamp);
|
||||
$this->_iHour = date("H", $sTemporaryTimestamp);
|
||||
$this->_iMinute = date("i", $sTemporaryTimestamp);
|
||||
$this->_iSecond = date("s", $sTemporaryTimestamp);
|
||||
|
||||
break;
|
||||
case cDateTime_ISO:
|
||||
$sTemporaryTimestamp = strtotime($value);
|
||||
$this->_iYear = date("Y", $sTemporaryTimestamp);
|
||||
$this->_iMonth = date("m", $sTemporaryTimestamp);
|
||||
$this->_iDay = date("d", $sTemporaryTimestamp);
|
||||
$this->_iHour = date("H", $sTemporaryTimestamp);
|
||||
$this->_iMinute = date("i", $sTemporaryTimestamp);
|
||||
$this->_iSecond = date("s", $sTemporaryTimestamp);
|
||||
break;
|
||||
case cDateTime_MySQL:
|
||||
$sTimeformat = 'YmdHis';
|
||||
|
||||
$targetFormat = str_replace('.', '\.', $sTimeformat);
|
||||
$targetFormat = str_replace('d', '([0-9]{2,2})', $targetFormat);
|
||||
$targetFormat = str_replace('m', '([0-9]{2,2})', $targetFormat);
|
||||
$targetFormat = str_replace('Y', '([0-9]{4,4})', $targetFormat);
|
||||
$targetFormat = str_replace('H', '([0-9]{2,2})', $targetFormat);
|
||||
$targetFormat = str_replace('i', '([0-9]{2,2})', $targetFormat);
|
||||
$targetFormat = str_replace('s', '([0-9]{2,2})', $targetFormat);
|
||||
/* Match the placeholders */
|
||||
preg_match_all('/([a-zA-Z])/', $sTimeformat, $placeholderRegs);
|
||||
|
||||
/* Match the date values */
|
||||
preg_match('/' . $targetFormat . '/', $value, $dateRegs);
|
||||
|
||||
$finalDate = array();
|
||||
|
||||
/* Map date entries to placeholders */
|
||||
foreach ($placeholderRegs[0] as $key => $placeholderReg)
|
||||
{
|
||||
if (isset($dateRegs[$key]))
|
||||
{
|
||||
$finalDate[$placeholderReg] = $dateRegs[$key+1];
|
||||
}
|
||||
}
|
||||
$targetFormat = str_replace('.', '\.', $sTimeformat);
|
||||
$targetFormat = str_replace('d', '([0-9]{2,2})', $targetFormat);
|
||||
$targetFormat = str_replace('m', '([0-9]{2,2})', $targetFormat);
|
||||
$targetFormat = str_replace('Y', '([0-9]{4,4})', $targetFormat);
|
||||
$targetFormat = str_replace('H', '([0-9]{2,2})', $targetFormat);
|
||||
$targetFormat = str_replace('i', '([0-9]{2,2})', $targetFormat);
|
||||
$targetFormat = str_replace('s', '([0-9]{2,2})', $targetFormat);
|
||||
/* Match the placeholders */
|
||||
preg_match_all('/([a-zA-Z])/', $sTimeformat, $placeholderRegs);
|
||||
|
||||
/* Assign placeholders + data to the object's member variables */
|
||||
foreach ($finalDate as $placeHolder => $value)
|
||||
{
|
||||
switch ($placeHolder)
|
||||
{
|
||||
case "d":
|
||||
$this->_iDay = $value;
|
||||
break;
|
||||
case "m":
|
||||
$this->_iMonth = $value;
|
||||
break;
|
||||
case "Y":
|
||||
$this->_iYear = $value;
|
||||
break;
|
||||
case "H":
|
||||
$this->_iHour = $value;
|
||||
break;
|
||||
case "i":
|
||||
$this->_iMinute = $value;
|
||||
break;
|
||||
case "s":
|
||||
$this->_iSecond = $value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case cDateTime_Custom:
|
||||
/* Build a regular expression */
|
||||
|
||||
$sourceFormat = str_replace('.', '\.', $this->_sCustomSourceFormat);
|
||||
$sourceFormat = str_replace('%d', '([0-9]{2,2})', $sourceFormat);
|
||||
$sourceFormat = str_replace('%m', '([0-9]{2,2})', $sourceFormat);
|
||||
$sourceFormat = str_replace('%Y', '([0-9]{4,4})', $sourceFormat);
|
||||
|
||||
/* Match the placeholders */
|
||||
preg_match_all('/(%[a-zA-Z])/', $this->_sCustomSourceFormat, $placeholderRegs);
|
||||
/* Match the date values */
|
||||
preg_match('/' . $targetFormat . '/', $value, $dateRegs);
|
||||
|
||||
|
||||
/* Match the date values */
|
||||
preg_match('/' . $sourceFormat . '/', $value, $dateRegs);
|
||||
|
||||
$finalDate = array();
|
||||
|
||||
/* Map date entries to placeholders */
|
||||
foreach ($placeholderRegs[0] as $key => $placeholderReg)
|
||||
{
|
||||
if (isset($dateRegs[$key]))
|
||||
{
|
||||
$finalDate[$placeholderReg] = $dateRegs[$key+1];
|
||||
}
|
||||
}
|
||||
$finalDate = array();
|
||||
|
||||
/* Assign placeholders + data to the object's member variables */
|
||||
foreach ($finalDate as $placeHolder => $value)
|
||||
{
|
||||
switch ($placeHolder)
|
||||
{
|
||||
case "%d":
|
||||
$this->_iDay = $value;
|
||||
break;
|
||||
case "%m":
|
||||
$this->_iMonth = $value;
|
||||
break;
|
||||
case "%Y":
|
||||
$this->_iYear = $value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function get ($iOverrideFormat = false)
|
||||
{
|
||||
if ($iOverrideFormat !== false)
|
||||
{
|
||||
$iFormat = $iOverrideFormat;
|
||||
} else {
|
||||
$iFormat = $this->_cSourceFormat;
|
||||
}
|
||||
|
||||
|
||||
switch ($iFormat)
|
||||
{
|
||||
case cDateTime_ISO:
|
||||
$sTemporaryTimestamp = mktime($this->_iHour, $this->_iMinute, $this->_iSecond , $this->_iMonth, $this->_iDay, $this->_iYear);
|
||||
return date("Y-m-d H:i:s", $sTemporaryTimestamp);
|
||||
break;
|
||||
case cDateTime_UNIX:
|
||||
$sTemporaryTimestamp = mktime($this->_iHour, $this->_iMinute, $this->_iSecond , $this->_iMonth, $this->_iDay, $this->_iYear);
|
||||
return ($sTemporaryTimestamp);
|
||||
break;
|
||||
case cDateTime_Custom:
|
||||
return strftime($this->_sCustomSourceFormat, mktime($this->_iHour, $this->_iMinute, $this->_iSecond, $this->_iMonth, $this->_iDay, $this->_iYear));
|
||||
break;
|
||||
case cDateTime_MySQL:
|
||||
$sTemporaryTimestamp = mktime($this->_iHour, $this->_iMinute, $this->_iSecond , $this->_iMonth, $this->_iDay, $this->_iYear);
|
||||
return date("YmdHis", $sTemporaryTimestamp);
|
||||
break;
|
||||
default:
|
||||
cError(__FILE__, __LINE__, "Not supported yet");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function render ($iOverrideFormat = false)
|
||||
{
|
||||
if ($iOverrideFormat !== false)
|
||||
{
|
||||
$iFormat = $iOverrideFormat;
|
||||
} else {
|
||||
$iFormat = $this->_cTargetFormat;
|
||||
}
|
||||
|
||||
switch ($iFormat)
|
||||
{
|
||||
case cDateTime_Locale_TimeOnly:
|
||||
$sTimeformat = getEffectiveSetting("backend", "timeformat_time", "H:i:s");
|
||||
|
||||
return date($sTimeformat, mktime($this->_iHour, $this->_iMinute, $this->iSecond, $this->_iMonth, $this->_iDay, $this->_iYear));
|
||||
/* Map date entries to placeholders */
|
||||
foreach ($placeholderRegs[0] as $key => $placeholderReg) {
|
||||
if (isset($dateRegs[$key])) {
|
||||
$finalDate[$placeholderReg] = $dateRegs[$key + 1];
|
||||
}
|
||||
}
|
||||
|
||||
case cDateTime_Locale_DateOnly:
|
||||
$sTimeformat = getEffectiveSetting("backend", "timeformat_date", "Y-m-d");
|
||||
|
||||
return date($sTimeformat, mktime($this->_iHour, $this->_iMinute, $this->iSecond, $this->_iMonth, $this->_iDay, $this->_iYear));
|
||||
case cDateTime_Locale:
|
||||
$sTimeformat = getEffectiveSetting("backend", "timeformat", "Y-m-d H:i:s");
|
||||
|
||||
return date($sTimeformat, mktime($this->_iHour, $this->_iMinute, $this->iSecond, $this->_iMonth, $this->_iDay, $this->_iYear));
|
||||
case cDateTime_Custom:
|
||||
return strftime($this->_sCustomTargetFormat, mktime($this->_iHour, $this->_iMinute, $this->_iSecond, $this->_iMonth, $this->_iDay, $this->_iYear));
|
||||
/* Assign placeholders + data to the object's member variables */
|
||||
foreach ($finalDate as $placeHolder => $value) {
|
||||
switch ($placeHolder) {
|
||||
case "d":
|
||||
$this->_iDay = $value;
|
||||
break;
|
||||
case "m":
|
||||
$this->_iMonth = $value;
|
||||
break;
|
||||
case "Y":
|
||||
$this->_iYear = $value;
|
||||
break;
|
||||
case "H":
|
||||
$this->_iHour = $value;
|
||||
break;
|
||||
case "i":
|
||||
$this->_iMinute = $value;
|
||||
break;
|
||||
case "s":
|
||||
$this->_iSecond = $value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function parse ($value)
|
||||
{
|
||||
if ($value == "")
|
||||
{ return;
|
||||
}
|
||||
switch ($this->_cTargetFormat)
|
||||
{
|
||||
case cDateTime_ISO:
|
||||
$sTemporaryTimestamp = strtotime($value);
|
||||
$this->_iYear = date("Y", $sTemporaryTimestamp);
|
||||
$this->_iMonth = date("m", $sTemporaryTimestamp);
|
||||
$this->_iDay = date("d", $sTemporaryTimestamp);
|
||||
$this->_iHour = date("H", $sTemporaryTimestamp);
|
||||
$this->_iMinute = date("i", $sTemporaryTimestamp);
|
||||
$this->_iSecond = date("s", $sTemporaryTimestamp);
|
||||
break;
|
||||
case cDateTime_Locale_DateOnly:
|
||||
$sTimeformat = getEffectiveSetting('backend', 'timeformat_date', 'Y-m-d');
|
||||
|
||||
$targetFormat = str_replace('.', '\.', $sTimeformat);
|
||||
$targetFormat = str_replace('d', '([0-9]{2,2})', $targetFormat);
|
||||
$targetFormat = str_replace('m', '([0-9]{2,2})', $targetFormat);
|
||||
$targetFormat = str_replace('Y', '([0-9]{4,4})', $targetFormat);
|
||||
|
||||
/* Match the placeholders */
|
||||
preg_match_all('/([a-zA-Z])/', $sTimeformat, $placeholderRegs);
|
||||
break;
|
||||
case cDateTime_Custom:
|
||||
/* Build a regular expression */
|
||||
|
||||
/* Match the date values */
|
||||
preg_match('/' . $targetFormat . '/', $value, $dateRegs);
|
||||
|
||||
$finalDate = array();
|
||||
|
||||
/* Map date entries to placeholders */
|
||||
foreach ($placeholderRegs[0] as $key => $placeholderReg)
|
||||
{
|
||||
if (isset($dateRegs[$key]))
|
||||
{
|
||||
$finalDate[$placeholderReg] = $dateRegs[$key+1];
|
||||
}
|
||||
}
|
||||
$sourceFormat = str_replace('.', '\.', $this->_sCustomSourceFormat);
|
||||
$sourceFormat = str_replace('%d', '([0-9]{2,2})', $sourceFormat);
|
||||
$sourceFormat = str_replace('%m', '([0-9]{2,2})', $sourceFormat);
|
||||
$sourceFormat = str_replace('%Y', '([0-9]{4,4})', $sourceFormat);
|
||||
|
||||
/* Assign placeholders + data to the object's member variables */
|
||||
foreach ($finalDate as $placeHolder => $value)
|
||||
{
|
||||
switch ($placeHolder)
|
||||
{
|
||||
case "d":
|
||||
$this->_iDay = $value;
|
||||
break;
|
||||
case "m":
|
||||
$this->_iMonth = $value;
|
||||
break;
|
||||
case "Y":
|
||||
$this->_iYear = $value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case cDateTime_Locale:
|
||||
$sTimeformat = getEffectiveSetting('backend', 'timeformat', 'Y-m-d H:i:s');
|
||||
|
||||
$targetFormat = str_replace('.', '\.', $sTimeformat);
|
||||
$targetFormat = str_replace('d', '([0-9]{2,2})', $targetFormat);
|
||||
$targetFormat = str_replace('m', '([0-9]{2,2})', $targetFormat);
|
||||
$targetFormat = str_replace('Y', '([0-9]{4,4})', $targetFormat);
|
||||
|
||||
/* Match the placeholders */
|
||||
preg_match_all('/(%[a-zA-Z])/', $this->_sCustomTargetFormat, $placeholderRegs);
|
||||
/* Match the placeholders */
|
||||
preg_match_all('/(%[a-zA-Z])/', $this->_sCustomSourceFormat, $placeholderRegs);
|
||||
|
||||
/* Match the date values */
|
||||
preg_match('/' . $targetFormat . '/', $value, $dateRegs);
|
||||
|
||||
$finalDate = array();
|
||||
|
||||
/* Map date entries to placeholders */
|
||||
foreach ($placeholderRegs[0] as $key => $placeholderReg)
|
||||
{
|
||||
if (isset($dateRegs[$key]))
|
||||
{
|
||||
$finalDate[$placeholderReg] = $dateRegs[$key+1];
|
||||
}
|
||||
}
|
||||
|
||||
/* Assign placeholders + data to the object's member variables */
|
||||
foreach ($finalDate as $placeHolder => $value)
|
||||
{
|
||||
switch ($placeHolder)
|
||||
{
|
||||
case "%d":
|
||||
$this->_iDay = $value;
|
||||
break;
|
||||
case "%m":
|
||||
$this->_iMonth = $value;
|
||||
break;
|
||||
case "%Y":
|
||||
$this->_iYear = $value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case cDateTime_Custom:
|
||||
/* Build a regular expression */
|
||||
|
||||
$targetFormat = str_replace('.', '\.', $this->_sCustomTargetFormat);
|
||||
$targetFormat = str_replace('%d', '([0-9]{2,2})', $targetFormat);
|
||||
$targetFormat = str_replace('%m', '([0-9]{2,2})', $targetFormat);
|
||||
$targetFormat = str_replace('%Y', '([0-9]{4,4})', $targetFormat);
|
||||
|
||||
/* Match the placeholders */
|
||||
preg_match_all('/(%[a-zA-Z])/', $this->_sCustomTargetFormat, $placeholderRegs);
|
||||
/* Match the date values */
|
||||
preg_match('/' . $sourceFormat . '/', $value, $dateRegs);
|
||||
|
||||
/* Match the date values */
|
||||
preg_match('/' . $targetFormat . '/', $value, $dateRegs);
|
||||
|
||||
$finalDate = array();
|
||||
|
||||
/* Map date entries to placeholders */
|
||||
foreach ($placeholderRegs[0] as $key => $placeholderReg)
|
||||
{
|
||||
if (isset($dateRegs[$key]))
|
||||
{
|
||||
$finalDate[$placeholderReg] = $dateRegs[$key+1];
|
||||
}
|
||||
}
|
||||
$finalDate = array();
|
||||
|
||||
/* Map date entries to placeholders */
|
||||
foreach ($placeholderRegs[0] as $key => $placeholderReg) {
|
||||
if (isset($dateRegs[$key])) {
|
||||
$finalDate[$placeholderReg] = $dateRegs[$key + 1];
|
||||
}
|
||||
}
|
||||
|
||||
/* Assign placeholders + data to the object's member variables */
|
||||
foreach ($finalDate as $placeHolder => $value) {
|
||||
switch ($placeHolder) {
|
||||
case "%d":
|
||||
$this->_iDay = $value;
|
||||
break;
|
||||
case "%m":
|
||||
$this->_iMonth = $value;
|
||||
break;
|
||||
case "%Y":
|
||||
$this->_iYear = $value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function get($iOverrideFormat = false) {
|
||||
if ($iOverrideFormat !== false) {
|
||||
$iFormat = $iOverrideFormat;
|
||||
} else {
|
||||
$iFormat = $this->_cSourceFormat;
|
||||
}
|
||||
|
||||
|
||||
switch ($iFormat) {
|
||||
case cDateTime_ISO:
|
||||
$sTemporaryTimestamp = mktime($this->_iHour, $this->_iMinute, $this->_iSecond, $this->_iMonth, $this->_iDay, $this->_iYear);
|
||||
return date("Y-m-d H:i:s", $sTemporaryTimestamp);
|
||||
break;
|
||||
case cDateTime_UNIX:
|
||||
$sTemporaryTimestamp = mktime($this->_iHour, $this->_iMinute, $this->_iSecond, $this->_iMonth, $this->_iDay, $this->_iYear);
|
||||
return ($sTemporaryTimestamp);
|
||||
break;
|
||||
case cDateTime_Custom:
|
||||
return strftime($this->_sCustomSourceFormat, mktime($this->_iHour, $this->_iMinute, $this->_iSecond, $this->_iMonth, $this->_iDay, $this->_iYear));
|
||||
break;
|
||||
case cDateTime_MySQL:
|
||||
$sTemporaryTimestamp = mktime($this->_iHour, $this->_iMinute, $this->_iSecond, $this->_iMonth, $this->_iDay, $this->_iYear);
|
||||
return date("YmdHis", $sTemporaryTimestamp);
|
||||
break;
|
||||
default:
|
||||
cError(__FILE__, __LINE__, "Not supported yet");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function render($iOverrideFormat = false) {
|
||||
if ($iOverrideFormat !== false) {
|
||||
$iFormat = $iOverrideFormat;
|
||||
} else {
|
||||
$iFormat = $this->_cTargetFormat;
|
||||
}
|
||||
|
||||
switch ($iFormat) {
|
||||
case cDateTime_Locale_TimeOnly:
|
||||
$sTimeformat = getEffectiveSetting("backend", "timeformat_time", "H:i:s");
|
||||
|
||||
return date($sTimeformat, mktime($this->_iHour, $this->_iMinute, $this->iSecond, $this->_iMonth, $this->_iDay, $this->_iYear));
|
||||
|
||||
case cDateTime_Locale_DateOnly:
|
||||
$sTimeformat = getEffectiveSetting("backend", "timeformat_date", "Y-m-d");
|
||||
|
||||
return date($sTimeformat, mktime($this->_iHour, $this->_iMinute, $this->iSecond, $this->_iMonth, $this->_iDay, $this->_iYear));
|
||||
case cDateTime_Locale:
|
||||
$sTimeformat = getEffectiveSetting("backend", "timeformat", "Y-m-d H:i:s");
|
||||
|
||||
return date($sTimeformat, mktime($this->_iHour, $this->_iMinute, $this->iSecond, $this->_iMonth, $this->_iDay, $this->_iYear));
|
||||
case cDateTime_Custom:
|
||||
return strftime($this->_sCustomTargetFormat, mktime($this->_iHour, $this->_iMinute, $this->_iSecond, $this->_iMonth, $this->_iDay, $this->_iYear));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function parse($value) {
|
||||
if ($value == "") {
|
||||
return;
|
||||
}
|
||||
switch ($this->_cTargetFormat) {
|
||||
case cDateTime_ISO:
|
||||
$sTemporaryTimestamp = strtotime($value);
|
||||
$this->_iYear = date("Y", $sTemporaryTimestamp);
|
||||
$this->_iMonth = date("m", $sTemporaryTimestamp);
|
||||
$this->_iDay = date("d", $sTemporaryTimestamp);
|
||||
$this->_iHour = date("H", $sTemporaryTimestamp);
|
||||
$this->_iMinute = date("i", $sTemporaryTimestamp);
|
||||
$this->_iSecond = date("s", $sTemporaryTimestamp);
|
||||
break;
|
||||
case cDateTime_Locale_DateOnly:
|
||||
$sTimeformat = getEffectiveSetting('backend', 'timeformat_date', 'Y-m-d');
|
||||
|
||||
$targetFormat = str_replace('.', '\.', $sTimeformat);
|
||||
$targetFormat = str_replace('d', '([0-9]{2,2})', $targetFormat);
|
||||
$targetFormat = str_replace('m', '([0-9]{2,2})', $targetFormat);
|
||||
$targetFormat = str_replace('Y', '([0-9]{4,4})', $targetFormat);
|
||||
|
||||
/* Match the placeholders */
|
||||
preg_match_all('/([a-zA-Z])/', $sTimeformat, $placeholderRegs);
|
||||
|
||||
/* Match the date values */
|
||||
preg_match('/' . $targetFormat . '/', $value, $dateRegs);
|
||||
|
||||
$finalDate = array();
|
||||
|
||||
/* Map date entries to placeholders */
|
||||
foreach ($placeholderRegs[0] as $key => $placeholderReg) {
|
||||
if (isset($dateRegs[$key])) {
|
||||
$finalDate[$placeholderReg] = $dateRegs[$key + 1];
|
||||
}
|
||||
}
|
||||
|
||||
/* Assign placeholders + data to the object's member variables */
|
||||
foreach ($finalDate as $placeHolder => $value) {
|
||||
switch ($placeHolder) {
|
||||
case "d":
|
||||
$this->_iDay = $value;
|
||||
break;
|
||||
case "m":
|
||||
$this->_iMonth = $value;
|
||||
break;
|
||||
case "Y":
|
||||
$this->_iYear = $value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case cDateTime_Locale:
|
||||
$sTimeformat = getEffectiveSetting('backend', 'timeformat', 'Y-m-d H:i:s');
|
||||
|
||||
$targetFormat = str_replace('.', '\.', $sTimeformat);
|
||||
$targetFormat = str_replace('d', '([0-9]{2,2})', $targetFormat);
|
||||
$targetFormat = str_replace('m', '([0-9]{2,2})', $targetFormat);
|
||||
$targetFormat = str_replace('Y', '([0-9]{4,4})', $targetFormat);
|
||||
|
||||
/* Match the placeholders */
|
||||
preg_match_all('/(%[a-zA-Z])/', $this->_sCustomTargetFormat, $placeholderRegs);
|
||||
|
||||
/* Match the date values */
|
||||
preg_match('/' . $targetFormat . '/', $value, $dateRegs);
|
||||
|
||||
$finalDate = array();
|
||||
|
||||
/* Map date entries to placeholders */
|
||||
foreach ($placeholderRegs[0] as $key => $placeholderReg) {
|
||||
if (isset($dateRegs[$key])) {
|
||||
$finalDate[$placeholderReg] = $dateRegs[$key + 1];
|
||||
}
|
||||
}
|
||||
|
||||
/* Assign placeholders + data to the object's member variables */
|
||||
foreach ($finalDate as $placeHolder => $value) {
|
||||
switch ($placeHolder) {
|
||||
case "%d":
|
||||
$this->_iDay = $value;
|
||||
break;
|
||||
case "%m":
|
||||
$this->_iMonth = $value;
|
||||
break;
|
||||
case "%Y":
|
||||
$this->_iYear = $value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case cDateTime_Custom:
|
||||
/* Build a regular expression */
|
||||
|
||||
$targetFormat = str_replace('.', '\.', $this->_sCustomTargetFormat);
|
||||
$targetFormat = str_replace('%d', '([0-9]{2,2})', $targetFormat);
|
||||
$targetFormat = str_replace('%m', '([0-9]{2,2})', $targetFormat);
|
||||
$targetFormat = str_replace('%Y', '([0-9]{4,4})', $targetFormat);
|
||||
|
||||
/* Match the placeholders */
|
||||
preg_match_all('/(%[a-zA-Z])/', $this->_sCustomTargetFormat, $placeholderRegs);
|
||||
|
||||
/* Match the date values */
|
||||
preg_match('/' . $targetFormat . '/', $value, $dateRegs);
|
||||
|
||||
$finalDate = array();
|
||||
|
||||
/* Map date entries to placeholders */
|
||||
foreach ($placeholderRegs[0] as $key => $placeholderReg) {
|
||||
if (isset($dateRegs[$key])) {
|
||||
$finalDate[$placeholderReg] = $dateRegs[$key + 1];
|
||||
}
|
||||
}
|
||||
|
||||
/* Assign placeholders + data to the object's member variables */
|
||||
foreach ($finalDate as $placeHolder => $value) {
|
||||
switch ($placeHolder) {
|
||||
case "%d":
|
||||
$this->_iDay = $value;
|
||||
break;
|
||||
case "%m":
|
||||
$this->_iMonth = $value;
|
||||
break;
|
||||
case "%Y":
|
||||
$this->_iYear = $value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Assign placeholders + data to the object's member variables */
|
||||
foreach ($finalDate as $placeHolder => $value)
|
||||
{
|
||||
switch ($placeHolder)
|
||||
{
|
||||
case "%d":
|
||||
$this->_iDay = $value;
|
||||
break;
|
||||
case "%m":
|
||||
$this->_iMonth = $value;
|
||||
break;
|
||||
case "%Y":
|
||||
$this->_iYear = $value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -25,84 +26,73 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -25,46 +26,46 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
class cDatatype
|
||||
{
|
||||
/* Effective value */
|
||||
var $_mValue;
|
||||
|
||||
/* Displayed value */
|
||||
var $_mDisplayedValue;
|
||||
|
||||
function cDatatype ()
|
||||
{
|
||||
}
|
||||
|
||||
/* Sets this datatype to a specific value */
|
||||
function set ($value)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/* Parses the given value to transfer into the datatype's format */
|
||||
function parse ($value)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/* Returns the effective value */
|
||||
function get ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/* Renders the displayed value */
|
||||
function render ()
|
||||
{
|
||||
|
||||
}
|
||||
class cDatatype {
|
||||
/* Effective value */
|
||||
|
||||
var $_mValue;
|
||||
|
||||
/* Displayed value */
|
||||
var $_mDisplayedValue;
|
||||
|
||||
function __construct() {
|
||||
|
||||
}
|
||||
|
||||
/* Sets this datatype to a specific value */
|
||||
|
||||
function set($value) {
|
||||
|
||||
}
|
||||
|
||||
/* Parses the given value to transfer into the datatype's format */
|
||||
|
||||
function parse($value) {
|
||||
|
||||
}
|
||||
|
||||
/* Returns the effective value */
|
||||
|
||||
function get() {
|
||||
|
||||
}
|
||||
|
||||
/* Renders the displayed value */
|
||||
|
||||
function render() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* class.template.php
|
||||
*
|
||||
|
@ -20,9 +21,8 @@
|
|||
* @link http://www.contenido.org
|
||||
* @since file available since contenido release <= 4.6
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,84 +36,73 @@ if(!defined('CON_FRAMEWORK')) {
|
|||
* @version 1.0
|
||||
*/
|
||||
class Template {
|
||||
|
||||
/**
|
||||
* Needles (static)
|
||||
* @var array
|
||||
*/
|
||||
public $needles = array ();
|
||||
public $needles = array();
|
||||
|
||||
/**
|
||||
* Replacements (static)
|
||||
* @var array
|
||||
*/
|
||||
public $replacements = array ();
|
||||
public $replacements = array();
|
||||
|
||||
/**
|
||||
* Dyn_Needles (dynamic)
|
||||
* @var array
|
||||
*/
|
||||
public $Dyn_needles = array ();
|
||||
public $Dyn_needles = array();
|
||||
|
||||
/**
|
||||
* Dyn_Replacements (dynamic)
|
||||
* @var array
|
||||
*/
|
||||
public $Dyn_replacements = array ();
|
||||
public $Dyn_replacements = array();
|
||||
|
||||
/**
|
||||
* Dynamic counter
|
||||
* @var int
|
||||
*/
|
||||
* Dynamic counter
|
||||
* @var int
|
||||
*/
|
||||
public $dyn_cnt = 0;
|
||||
|
||||
/**
|
||||
* Tags array (for dynamic blocks);
|
||||
* @var array
|
||||
*/
|
||||
public $tags = array ('static' => '{%s}', 'start' => '<!-- BEGIN:BLOCK -->', 'end' => '<!-- END:BLOCK -->');
|
||||
* Tags array (for dynamic blocks);
|
||||
* @var array
|
||||
*/
|
||||
public $tags = array('static' => '{%s}', 'start' => '<!-- BEGIN:BLOCK -->', 'end' => '<!-- END:BLOCK -->');
|
||||
|
||||
/**
|
||||
* gettext domain (default: contenido)
|
||||
* @var string
|
||||
*/
|
||||
protected $_sDomain = "conlite";
|
||||
|
||||
var $array_registeredParsers = array();
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $tags
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($tags = false, $parser = false) {
|
||||
public function __construct($tags = false, $parser = false) {
|
||||
# Needed to block parsers in ConLite's backend and the module-template editor
|
||||
global $contenido, $changeview;
|
||||
|
||||
|
||||
if (is_array($tags)) {
|
||||
$this->tags = $tags;
|
||||
}
|
||||
$this->setEncoding("");
|
||||
if(is_array($parser)) {
|
||||
if (is_array($parser)) {
|
||||
$this->array_registeredParsers = $parser;
|
||||
} elseif ((!isset($contenido)) || ($changeview == 'edit') || ($changeview == 'prev')) {
|
||||
$this->array_registeredParsers = array(
|
||||
new clStrAPIFunctionsParser(),
|
||||
new clCounterFunctionParser(),
|
||||
new clIfFunctionParser()
|
||||
);
|
||||
new clStrAPIFunctionsParser(),
|
||||
new clCounterFunctionParser(),
|
||||
new clIfFunctionParser()
|
||||
);
|
||||
}
|
||||
} // end function
|
||||
|
||||
/**
|
||||
* Old deprecated constructor
|
||||
*
|
||||
* @deprecated since version 2.0 Beta
|
||||
* @param array $tags
|
||||
*/
|
||||
public function Template($tags = false) {
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct($tags);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,11 +112,11 @@ class Template {
|
|||
*
|
||||
* @param string $sDomain Sets the domain to use for template translations
|
||||
* @return void
|
||||
*/
|
||||
*/
|
||||
public function setDomain($sDomain) {
|
||||
$this->_sDomain = $sDomain;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Templates placeholders and values
|
||||
*
|
||||
|
@ -154,11 +143,11 @@ class Template {
|
|||
* Sets an encoding for the template's head block.
|
||||
*
|
||||
* @param string $encoding Encoding to set
|
||||
*/
|
||||
*/
|
||||
public function setEncoding($encoding) {
|
||||
$this->_encoding = $encoding;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Iterate internal counter by one
|
||||
*
|
||||
|
@ -175,10 +164,10 @@ class Template {
|
|||
*/
|
||||
public function reset() {
|
||||
$this->dyn_cnt = 0;
|
||||
$this->needles = array ();
|
||||
$this->replacements = array ();
|
||||
$this->Dyn_needles = array ();
|
||||
$this->Dyn_replacements = array ();
|
||||
$this->needles = array();
|
||||
$this->replacements = array();
|
||||
$this->Dyn_needles = array();
|
||||
$this->Dyn_replacements = array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -193,27 +182,27 @@ class Template {
|
|||
*/
|
||||
public function generate($template, $return = 0, $note = 0) {
|
||||
global $cCurrentModule;
|
||||
|
||||
|
||||
$cfg = cRegistry::getConfig();
|
||||
$aCfgClient = cRegistry::getClientConfig(cRegistry::getClientId());
|
||||
$bModTplUsed = FALSE;
|
||||
|
||||
if(isset($cCurrentModule) && $cfg['dceModEdit']['use']) {
|
||||
|
||||
if (isset($cCurrentModule) && $cfg['dceModEdit']['use']) {
|
||||
cInclude('includes', 'functions.upl.php');
|
||||
$tmpModule = new cApiModule;
|
||||
$tmpModule->loadByPrimaryKey($cCurrentModule);
|
||||
$sModName = strtolower(uplCreateFriendlyName($tmpModule->get('name')));
|
||||
$aModFileEditConf = $tmpModule->getModFileEditConf();
|
||||
unset($tmpModule);
|
||||
$sTmpPath = $aModFileEditConf['modPath'].$sModName."/template/".$template;
|
||||
if(is_readable($sTmpPath)) {
|
||||
$sTmpPath = $aModFileEditConf['modPath'] . $sModName . "/template/" . $template;
|
||||
if (is_readable($sTmpPath)) {
|
||||
$template = $sTmpPath;
|
||||
$bModTplUsed = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if(is_file("templates/".$template) && !$bModTplUsed) {
|
||||
$template = "templates/".$template;
|
||||
|
||||
if (is_file("templates/" . $template) && !$bModTplUsed) {
|
||||
$template = "templates/" . $template;
|
||||
}
|
||||
|
||||
//check if the template is a file or a string
|
||||
|
@ -222,53 +211,52 @@ class Template {
|
|||
} else {
|
||||
$content = implode("", file($template)); //template is a file
|
||||
}
|
||||
|
||||
$content = (($note) ? "<!-- Generated by ConLite ".$cfg['version']."-->\n" : "").$content;
|
||||
|
||||
|
||||
$content = (($note) ? "<!-- Generated by ConLite " . $cfg['version'] . "-->\n" : "") . $content;
|
||||
|
||||
$pieces = array();
|
||||
//replace i18n strings before replacing other placeholders
|
||||
$this->replacei18n($content, "i18n");
|
||||
$this->replacei18n($content, "trans");
|
||||
|
||||
//if content has dynamic blocks
|
||||
if (preg_match("/^.*".preg_quote($this->tags['start'], "/").".*?".preg_quote($this->tags['end'], "/").".*$/s", $content)) {
|
||||
//split everything into an array
|
||||
preg_match_all("/^(.*)".preg_quote($this->tags['start'], "/")."(.*?)".preg_quote($this->tags['end'], "/")."(.*)$/s", $content, $pieces);
|
||||
//safe memory
|
||||
array_shift($pieces);
|
||||
$content = "";
|
||||
//now combine pieces together
|
||||
|
||||
//if content has dynamic blocks
|
||||
if (preg_match("/^.*" . preg_quote($this->tags['start'], "/") . ".*?" . preg_quote($this->tags['end'], "/") . ".*$/s", $content)) {
|
||||
//split everything into an array
|
||||
preg_match_all("/^(.*)" . preg_quote($this->tags['start'], "/") . "(.*?)" . preg_quote($this->tags['end'], "/") . "(.*)$/s", $content, $pieces);
|
||||
//safe memory
|
||||
array_shift($pieces);
|
||||
$content = "";
|
||||
//now combine pieces together
|
||||
//start block
|
||||
$content .= str_replace($this->needles, $this->replacements, $pieces[0][0]);
|
||||
unset ($pieces[0][0]);
|
||||
$content .= str_replace($this->needles, $this->replacements, $pieces[0][0]);
|
||||
unset($pieces[0][0]);
|
||||
|
||||
//generate dynamic blocks
|
||||
for ($a = 0; $a < $this->dyn_cnt; $a ++) {
|
||||
$content .= str_replace($this->Dyn_needles[$a], $this->Dyn_replacements[$a], $pieces[1][0]);
|
||||
for ($a = 0; $a < $this->dyn_cnt; $a ++) {
|
||||
$content .= str_replace($this->Dyn_needles[$a], $this->Dyn_replacements[$a], $pieces[1][0]);
|
||||
}
|
||||
unset ($pieces[1][0]);
|
||||
unset($pieces[1][0]);
|
||||
|
||||
//end block
|
||||
$content .= str_replace($this->needles, $this->replacements, $pieces[2][0]);
|
||||
unset ($pieces[2][0]);
|
||||
unset($pieces[2][0]);
|
||||
} else {
|
||||
$content = str_replace($this->needles, $this->replacements, $content);
|
||||
}
|
||||
|
||||
|
||||
if ($this->_encoding != "") {
|
||||
$content = str_replace("</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
|
||||
if (count($this->array_registeredParsers)) {
|
||||
foreach($this->array_registeredParsers as $class) {
|
||||
foreach ($this->array_registeredParsers as $class) {
|
||||
if (is_string($class)) {
|
||||
$classInstance = new $class;
|
||||
} elseif(is_object($class)) {
|
||||
} elseif (is_object($class)) {
|
||||
$classInstance = $class;
|
||||
}
|
||||
|
||||
|
||||
if (is_object($classInstance)) {
|
||||
if (is_subclass_of($classInstance, "clAbstractTemplateParser")) {
|
||||
$content = $classInstance->parse($content);
|
||||
|
@ -279,15 +267,17 @@ class Template {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($return) {
|
||||
return $content;
|
||||
} else {
|
||||
echo $content;
|
||||
}
|
||||
} # end function
|
||||
}
|
||||
|
||||
/**
|
||||
# end function
|
||||
|
||||
/**
|
||||
* replacei18n()
|
||||
*
|
||||
* Replaces a named function with the translated variant
|
||||
|
@ -295,7 +285,7 @@ class Template {
|
|||
* @param string $template Contents of the template to translate (it is reference to save memory!!!)
|
||||
* @param string $functionName Name of the translation function (e.g. i18n)
|
||||
* @return void
|
||||
*/
|
||||
*/
|
||||
public function replacei18n(& $template, $functionName) {
|
||||
$container = array();
|
||||
// Be sure that php code stays unchanged
|
||||
|
@ -304,37 +294,40 @@ class Template {
|
|||
$x = 0;
|
||||
foreach ($php_matches[0] as $php_match) {
|
||||
$x++;
|
||||
$template = str_replace($php_match , "{PHP#".$x."#PHP}", $template);
|
||||
$template = str_replace($php_match, "{PHP#" . $x . "#PHP}", $template);
|
||||
$container[$x] = $php_match;
|
||||
}
|
||||
}
|
||||
|
||||
// If template contains functionName + parameter store all matches
|
||||
$matches = array();
|
||||
preg_match_all("/".preg_quote($functionName, "/")."\\(([\\\"\\'])(.*?)\\1\\)/s", $template, $matches);
|
||||
|
||||
preg_match_all("/" . preg_quote($functionName, "/") . "\\(([\\\"\\'])(.*?)\\1\\)/s", $template, $matches);
|
||||
|
||||
// Execute the translation code
|
||||
$matches = array_values(array_unique($matches[2]));
|
||||
for ($a = 0; $a < count($matches); $a ++) {
|
||||
$template = preg_replace("/".preg_quote($functionName, "/")."\\([\\\"\\']".preg_quote($matches[$a], "/")."[\\\"\\']\\)/s", i18n($matches[$a], $this->_sDomain), $template);
|
||||
$template = preg_replace("/" . preg_quote($functionName, "/") . "\\([\\\"\\']" . preg_quote($matches[$a], "/") . "[\\\"\\']\\)/s", i18n($matches[$a], $this->_sDomain), $template);
|
||||
}
|
||||
|
||||
|
||||
// Change back php placeholder
|
||||
if (count($container)) {
|
||||
foreach ($container as $x => $php_match) {
|
||||
// If php code contains functionName + parameter store all matches
|
||||
$matches = array();
|
||||
preg_match_all("/".preg_quote($functionName, "/")."\\(([\\\"\\'])(.*?)\\1\\)/s", $php_match, $matches);
|
||||
|
||||
preg_match_all("/" . preg_quote($functionName, "/") . "\\(([\\\"\\'])(.*?)\\1\\)/s", $php_match, $matches);
|
||||
|
||||
// Execute the translation code
|
||||
$matches = array_values(array_unique($matches[2]));
|
||||
for ($a = 0; $a < count($matches); $a ++) {
|
||||
$php_match = preg_replace("/".preg_quote($functionName, "/")."\\([\\\"\\']".preg_quote($matches[$a], "/")."[\\\"\\']\\)/s", '"' . i18n($matches[$a] . '"', $this->_sDomain), $php_match);
|
||||
$php_match = preg_replace("/" . preg_quote($functionName, "/") . "\\([\\\"\\']" . preg_quote($matches[$a], "/") . "[\\\"\\']\\)/s", '"' . i18n($matches[$a] . '"', $this->_sDomain), $php_match);
|
||||
}
|
||||
|
||||
$template = str_replace("{PHP#".$x."#PHP}" , $php_match, $template);
|
||||
|
||||
$template = str_replace("{PHP#" . $x . "#PHP}", $php_match, $template);
|
||||
}
|
||||
}
|
||||
}
|
||||
} # end class
|
||||
|
||||
}
|
||||
|
||||
# end class
|
||||
?>
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -25,45 +26,39 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* class cTree
|
||||
*
|
||||
*/
|
||||
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
|
||||
class cTree extends cTreeItem {
|
||||
|
||||
function setIcon ( $path )
|
||||
{
|
||||
$this->_treeIcon = $path;
|
||||
}
|
||||
var $_treeIcon;
|
||||
|
||||
function __construct($name = "") {
|
||||
/* The root item currently has to be a "0".
|
||||
* This is a bug, feel free to fix it. */
|
||||
cTreeItem::__construct(0, $name);
|
||||
}
|
||||
|
||||
} // end of cTree
|
||||
?>
|
||||
/**
|
||||
* sets a new name for the tree.
|
||||
*
|
||||
* @param string name Name of the tree
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function setTreeName($name) {
|
||||
$this->setName($name);
|
||||
}
|
||||
|
||||
// end of member function setTreeName
|
||||
|
||||
function setIcon($path) {
|
||||
$this->_treeIcon = $path;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -25,28 +26,28 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
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()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -26,14 +27,13 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
define("QUESTIONACTION_PROMPT", "prompt");
|
||||
define("QUESTIONACTION_YESNO" , "yesno");
|
||||
define("QUESTIONACTION_YESNO", "yesno");
|
||||
|
||||
/**
|
||||
* class cApiClickableAction
|
||||
|
@ -42,10 +42,8 @@ define("QUESTIONACTION_YESNO" , "yesno");
|
|||
* their constructors; on-the-fly-implementations should call it directly after
|
||||
* creating an object instance.
|
||||
*/
|
||||
class cApiClickableAction extends cApiAction
|
||||
{
|
||||
|
||||
/*** Attributes: ***/
|
||||
class cApiClickableAction extends cApiAction {
|
||||
/* * * Attributes: ** */
|
||||
|
||||
/**
|
||||
* Help text
|
||||
|
@ -65,19 +63,17 @@ class cApiClickableAction extends cApiAction
|
|||
*/
|
||||
private $_img;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
global $area;
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->_area = $area;
|
||||
$this->_area = $area;
|
||||
$this->_frame = 4;
|
||||
$this->_target = "right_bottom";
|
||||
|
||||
$this->_link = new cHTMLLink;
|
||||
$this->_img = new cHTMLImage;
|
||||
$this->_img = new cHTMLImage;
|
||||
$this->_img->setBorder(0);
|
||||
$this->_img->setStyle("padding-left: 1px; padding-right: 1px;");
|
||||
|
||||
|
@ -86,26 +82,17 @@ class cApiClickableAction extends cApiAction
|
|||
$this->setEnabled();
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function cApiClickableAction()
|
||||
{
|
||||
cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()");
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the action icon for this action.
|
||||
*
|
||||
* @param string icon Path to the icon. Relative to the backend, if not passed as absolute path.
|
||||
* @return void
|
||||
*/
|
||||
public function setIcon($icon)
|
||||
{
|
||||
public function setIcon($icon) {
|
||||
$this->_img->setSrc($icon);
|
||||
}
|
||||
|
||||
public function getIcon()
|
||||
{
|
||||
public function getIcon() {
|
||||
return $this->_img;
|
||||
}
|
||||
|
||||
|
@ -116,10 +103,8 @@ class cApiClickableAction extends cApiAction
|
|||
* using it, otherwise, this method will fail.
|
||||
* @return void
|
||||
*/
|
||||
public function setNamedAction($actionName)
|
||||
{
|
||||
if ($this->loadBy("name", $actionName) !== false)
|
||||
{
|
||||
public function setNamedAction($actionName) {
|
||||
if ($this->loadBy("name", $actionName) !== false) {
|
||||
$a = new cApiArea;
|
||||
$a->loadByPrimaryKey($this->get("idarea"));
|
||||
|
||||
|
@ -131,36 +116,32 @@ class cApiClickableAction extends cApiAction
|
|||
}
|
||||
}
|
||||
|
||||
public function setDisabled()
|
||||
{
|
||||
public function setDisabled() {
|
||||
$this->_enabled = false;
|
||||
$this->_onDisable();
|
||||
}
|
||||
|
||||
public function setEnabled()
|
||||
{
|
||||
public function setEnabled() {
|
||||
$this->_enabled = true;
|
||||
$this->_onEnable();
|
||||
}
|
||||
|
||||
protected function _onDisable()
|
||||
{
|
||||
protected function _onDisable() {
|
||||
|
||||
}
|
||||
|
||||
protected function _onEnable()
|
||||
{
|
||||
protected function _onEnable() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Change linked area
|
||||
*/
|
||||
public function changeArea($sArea)
|
||||
{
|
||||
public function changeArea($sArea) {
|
||||
$this->_area = $sArea;
|
||||
}
|
||||
|
||||
public function wantParameter($parameter)
|
||||
{
|
||||
public function wantParameter($parameter) {
|
||||
$this->_wantParameters[] = $parameter;
|
||||
|
||||
$this->_wantParameters = array_unique($this->_wantParameters);
|
||||
|
@ -172,29 +153,24 @@ class cApiClickableAction extends cApiAction
|
|||
* @param string helptext The helptext to apply
|
||||
* @return void
|
||||
*/
|
||||
public function setHelpText($helptext)
|
||||
{
|
||||
public function setHelpText($helptext) {
|
||||
$this->_helpText = $helptext;
|
||||
}
|
||||
|
||||
public function getHelpText()
|
||||
{
|
||||
public function getHelpText() {
|
||||
return $this->_helpText;
|
||||
}
|
||||
|
||||
public function setParameter($name, $value)
|
||||
{
|
||||
public function setParameter($name, $value) {
|
||||
$this->_parameters[$name] = $value;
|
||||
}
|
||||
|
||||
public function process($parameters)
|
||||
{
|
||||
public function process($parameters) {
|
||||
echo "Process should be overridden";
|
||||
return false;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
public function render() {
|
||||
$this->_img->setAlt($this->_helpText);
|
||||
|
||||
foreach ($this->_parameters as $name => $value) {
|
||||
|
@ -229,52 +205,39 @@ class cApiClickableAction extends cApiAction
|
|||
return ($this->_helpText);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class cApiClickableQuestionAction extends cApiClickableAction {
|
||||
|
||||
class cApiClickableQuestionAction extends cApiClickableAction
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/** @deprecated [2011-03-15] Old constructor function for downwards compatibility */
|
||||
public function cApiClickableQuestionAction()
|
||||
{
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
public function setQuestionMode($mode)
|
||||
{
|
||||
public function setQuestionMode($mode) {
|
||||
$this->_mode = $mode;
|
||||
}
|
||||
|
||||
public function setQuestion($question)
|
||||
{
|
||||
public function setQuestion($question) {
|
||||
$this->_question = $question;
|
||||
}
|
||||
|
||||
public function setResultVar($var)
|
||||
{
|
||||
public function setResultVar($var) {
|
||||
$this->_resultVar = $var;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
switch ($this->_mode)
|
||||
{
|
||||
public function render() {
|
||||
switch ($this->_mode) {
|
||||
case QUESTIONACTION_PROMPT:
|
||||
$this->_link->attachEventDefinition("_".get_class($this).rand(), "onclick", 'var answer = prompt("'.clHtmlSpecialChars($this->_question).'");if (answer == null) {return false;} else { this.href = this.href + "&'.$this->_resultVar.'="+answer; return true;}');
|
||||
$this->_link->attachEventDefinition("_" . get_class($this) . rand(), "onclick", 'var answer = prompt("' . clHtmlSpecialChars($this->_question) . '");if (answer == null) {return false;} else { this.href = this.href + "&' . $this->_resultVar . '="+answer; return true;}');
|
||||
break;
|
||||
case QUESTIONACTION_YESNO:
|
||||
default:
|
||||
$this->_link->attachEventDefinition("_".get_class($this).rand(), "onclick", 'var answer = confirm("'.clHtmlSpecialChars($this->_question).'");if (answer == false) {return false;} else { return true;}');
|
||||
break;
|
||||
$this->_link->attachEventDefinition("_" . get_class($this) . rand(), "onclick", 'var answer = confirm("' . clHtmlSpecialChars($this->_question) . '");if (answer == false) {return false;} else { return true;}');
|
||||
break;
|
||||
}
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -25,100 +26,87 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
?>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -60,9 +60,9 @@ class cWidgetButton extends cHTMLSpan
|
|||
* @param $alt string Alternative text
|
||||
* @param $link string Link
|
||||
*/
|
||||
function cWidgetButton ($img, $alt, $link)
|
||||
function __construct ($img, $alt, $link)
|
||||
{
|
||||
cHTMLSpan::cHTMLSpan();
|
||||
cHTMLSpan::__construct();
|
||||
|
||||
$this->_img = new cHTMLImage($img);
|
||||
$this->_link = new cHTMLLink($link);
|
||||
|
@ -167,9 +167,9 @@ class cWidgetToggleButton extends cWidgetButton
|
|||
* @param $uplink string Link when the button is turned off (=up)
|
||||
* @param $downlink string Link when the button is turned on (=down)
|
||||
*/
|
||||
function cWidgetToggleButton ($img, $alt, $uplink, $downlink)
|
||||
function __construct ($img, $alt, $uplink, $downlink)
|
||||
{
|
||||
cHTMLSpan::cHTMLSpan();
|
||||
cHTMLSpan::__construct();
|
||||
|
||||
$this->_img = new cHTMLImage($img);
|
||||
$this->_link = new cHTMLLink("#");
|
||||
|
@ -243,9 +243,9 @@ class cWidgetMultiToggleButton extends cWidgetButton
|
|||
* @param $alt string Alternative text
|
||||
* @param $lnik string Link to call when the button is clicked
|
||||
*/
|
||||
function cWidgetMultiToggleButton ($img, $alt, $link)
|
||||
function __construct ($img, $alt, $link)
|
||||
{
|
||||
cHTMLSpan::cHTMLSpan();
|
||||
cHTMLSpan::__construct();
|
||||
|
||||
$this->_img = new cHTMLImage($img);
|
||||
$this->_link = new cHTMLLink($link);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -25,105 +26,92 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
class cCalendarControl extends cHTMLTable {
|
||||
|
||||
class cCalendarControl extends cHTMLTable
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
var $_oDate;
|
||||
|
||||
|
||||
function _initFormatting ()
|
||||
{
|
||||
$this->setClass("calendar");
|
||||
$this->setCellSpacing(0);
|
||||
$this->setCellPadding(0);
|
||||
}
|
||||
|
||||
function _renderHead ()
|
||||
{
|
||||
$oHead = new cHTMLTableHeader;
|
||||
|
||||
$aDayOrder = $this->_oDate->getDayOrder();
|
||||
function __construct($initDate = false) {
|
||||
parent::__construct();
|
||||
|
||||
$oRow = new cHTMLTableRow;
|
||||
|
||||
$aData = array();
|
||||
|
||||
foreach ($aDayOrder as $iDay)
|
||||
{
|
||||
$oData = new cHTMLTableData;
|
||||
$oData->setContent(substr($this->_oDate->getDayName($iDay),0,2));
|
||||
|
||||
$aData[] = $oData;
|
||||
}
|
||||
|
||||
$oRow->setContent($aData);
|
||||
$oHead->setContent($oRow);
|
||||
|
||||
return ($oHead);
|
||||
}
|
||||
|
||||
function _renderBody ()
|
||||
{
|
||||
$iRows = 6;
|
||||
$iDaysPerWeek = 7;
|
||||
|
||||
$oHead = new cHTMLTableBody;
|
||||
|
||||
$aRowData = array();
|
||||
|
||||
for ($iRow = 0; $iRow < $iRows; $iRow++)
|
||||
{
|
||||
$oRow = new cHTMLTableRow;
|
||||
$aData = array();
|
||||
$aDayOrder = $this->_oDate->getDayOrder();
|
||||
|
||||
foreach ($aDayOrder as $iDay)
|
||||
{
|
||||
$oData = new cHTMLTableData;
|
||||
$oData->setContent(' ');
|
||||
$oData->setStyle("border: 1px solid white");
|
||||
$oData->setId("cal_".$this->getId()."_".$iRow . "_".$iDay);
|
||||
$aData[] = $oData;
|
||||
}
|
||||
$oRow->setContent($aData);
|
||||
$aRowData[] = $oRow;
|
||||
}
|
||||
|
||||
$oHead->setContent($aRowData);
|
||||
|
||||
return ($oHead);
|
||||
}
|
||||
$this->_initFormatting();
|
||||
$this->_oDate = new cDatatypeDateTime;
|
||||
|
||||
function _renderJS ()
|
||||
{
|
||||
$this->_oDate->setSourceFormat(cDateTime_UNIX);
|
||||
|
||||
$oScript = new cHTMLScript;
|
||||
$sScript = '
|
||||
/* Development: Set today's date */
|
||||
$this->_oDate->setSourceFormat(cDateTime_ISO);
|
||||
|
||||
if ($initDate === false) {
|
||||
$this->_oDate->set(date("Y-m-d H:i:s"));
|
||||
} else {
|
||||
$this->_oDate->set($initDate);
|
||||
}
|
||||
}
|
||||
|
||||
function _initFormatting() {
|
||||
$this->setClass("calendar");
|
||||
$this->setCellSpacing(0);
|
||||
$this->setCellPadding(0);
|
||||
}
|
||||
|
||||
function _renderHead() {
|
||||
$oHead = new cHTMLTableHeader;
|
||||
|
||||
$aDayOrder = $this->_oDate->getDayOrder();
|
||||
|
||||
$oRow = new cHTMLTableRow;
|
||||
|
||||
$aData = array();
|
||||
|
||||
foreach ($aDayOrder as $iDay) {
|
||||
$oData = new cHTMLTableData;
|
||||
$oData->setContent(substr($this->_oDate->getDayName($iDay), 0, 2));
|
||||
|
||||
$aData[] = $oData;
|
||||
}
|
||||
|
||||
$oRow->setContent($aData);
|
||||
$oHead->setContent($oRow);
|
||||
|
||||
return ($oHead);
|
||||
}
|
||||
|
||||
function _renderBody() {
|
||||
$iRows = 6;
|
||||
$iDaysPerWeek = 7;
|
||||
|
||||
$oHead = new cHTMLTableBody;
|
||||
|
||||
$aRowData = array();
|
||||
|
||||
for ($iRow = 0; $iRow < $iRows; $iRow++) {
|
||||
$oRow = new cHTMLTableRow;
|
||||
$aData = array();
|
||||
$aDayOrder = $this->_oDate->getDayOrder();
|
||||
|
||||
foreach ($aDayOrder as $iDay) {
|
||||
$oData = new cHTMLTableData;
|
||||
$oData->setContent(' ');
|
||||
$oData->setStyle("border: 1px solid white");
|
||||
$oData->setId("cal_" . $this->getId() . "_" . $iRow . "_" . $iDay);
|
||||
$aData[] = $oData;
|
||||
}
|
||||
$oRow->setContent($aData);
|
||||
$aRowData[] = $oRow;
|
||||
}
|
||||
|
||||
$oHead->setContent($aRowData);
|
||||
|
||||
return ($oHead);
|
||||
}
|
||||
|
||||
function _renderJS() {
|
||||
$this->_oDate->setSourceFormat(cDateTime_UNIX);
|
||||
|
||||
$oScript = new cHTMLScript;
|
||||
$sScript = '
|
||||
|
||||
var {cid}_markedDay;
|
||||
var {cid}_markedMonth;
|
||||
|
@ -135,7 +123,7 @@ class cCalendarControl extends cHTMLTable
|
|||
|
||||
{cid}_setDefaultDay(2006, 03, 30);
|
||||
|
||||
{cid}_setCalendar('.$this->_oDate->getYear().', '. $this->_oDate->getMonth(). ', '. $this->_oDate->getDay().');
|
||||
{cid}_setCalendar(' . $this->_oDate->getYear() . ', ' . $this->_oDate->getMonth() . ', ' . $this->_oDate->getDay() . ');
|
||||
|
||||
function {cid}_setDefaultDay (year, month, day)
|
||||
{
|
||||
|
@ -150,16 +138,16 @@ class cCalendarControl extends cHTMLTable
|
|||
var sMarkedID = "";
|
||||
|
||||
var iRow = 0;
|
||||
var iFirstDayOfWeek = '.$this->_oDate->getFirstDayOfWeek().';
|
||||
var iFirstDayOfWeek = ' . $this->_oDate->getFirstDayOfWeek() . ';
|
||||
|
||||
for (var i=1; i < 32; i++)
|
||||
{
|
||||
mDate.setDate(i);
|
||||
|
||||
var dayOfWeek = mDate.getDay();
|
||||
var lid = "cal_'.$this->getId().'_" + iRow + "_" + dayOfWeek;
|
||||
var lid = "cal_' . $this->getId() . '_" + iRow + "_" + dayOfWeek;
|
||||
|
||||
if (dayOfWeek == '.$this->_oDate->getLeapDay().')
|
||||
if (dayOfWeek == ' . $this->_oDate->getLeapDay() . ')
|
||||
{
|
||||
iRow++;
|
||||
}
|
||||
|
@ -211,13 +199,13 @@ class cCalendarControl extends cHTMLTable
|
|||
{cid}_currentMonth = month;
|
||||
|
||||
var iRow = 0;
|
||||
var iFirstDayOfWeek = '.$this->_oDate->getFirstDayOfWeek().';
|
||||
var iFirstDayOfWeek = ' . $this->_oDate->getFirstDayOfWeek() . ';
|
||||
|
||||
for (var i=0; i < 7; i++)
|
||||
{
|
||||
for (var j=0; j< 6; j++)
|
||||
{
|
||||
var lid = "cal_'.$this->getId().'_" + j + "_" + i;
|
||||
var lid = "cal_' . $this->getId() . '_" + j + "_" + i;
|
||||
document.getElementById(lid).firstChild.nodeValue = String.fromCharCode(160);
|
||||
document.getElementById(lid).className = "";
|
||||
{cid}_detachHandler(document.getElementById(lid));
|
||||
|
@ -229,9 +217,9 @@ class cCalendarControl extends cHTMLTable
|
|||
mDate.setDate(i);
|
||||
|
||||
var dayOfWeek = mDate.getDay();
|
||||
var lid = "cal_'.$this->getId().'_" + iRow + "_" + dayOfWeek;
|
||||
var lid = "cal_' . $this->getId() . '_" + iRow + "_" + dayOfWeek;
|
||||
|
||||
if (dayOfWeek == '.$this->_oDate->getLeapDay().')
|
||||
if (dayOfWeek == ' . $this->_oDate->getLeapDay() . ')
|
||||
{
|
||||
iRow++;
|
||||
}
|
||||
|
@ -284,16 +272,16 @@ class cCalendarControl extends cHTMLTable
|
|||
var mDate = new Date(year, month - 1, 1);
|
||||
|
||||
var iRow = 0;
|
||||
var iFirstDayOfWeek = '.$this->_oDate->getFirstDayOfWeek().';
|
||||
var iFirstDayOfWeek = ' . $this->_oDate->getFirstDayOfWeek() . ';
|
||||
|
||||
for (var i=1; i < {cid}_GetMonthLength(year, month) + 1; i++)
|
||||
{
|
||||
mDate.setDate(i);
|
||||
|
||||
var dayOfWeek = mDate.getDay();
|
||||
var lid = "cal_'.$this->getId().'_" + iRow + "_" + dayOfWeek;
|
||||
var lid = "cal_' . $this->getId() . '_" + iRow + "_" + dayOfWeek;
|
||||
|
||||
if (dayOfWeek == '.$this->_oDate->getLeapDay().')
|
||||
if (dayOfWeek == ' . $this->_oDate->getLeapDay() . ')
|
||||
{
|
||||
iRow++;
|
||||
}
|
||||
|
@ -376,89 +364,85 @@ class cCalendarControl extends cHTMLTable
|
|||
{
|
||||
switch (iMonth)
|
||||
{
|
||||
case 1: return("'.$this->_oDate->getMonthName(1).'"); break;
|
||||
case 2: return("'.$this->_oDate->getMonthName(2).'"); break;
|
||||
case 3: return("'.$this->_oDate->getMonthName(3).'"); break;
|
||||
case 4: return("'.$this->_oDate->getMonthName(4).'"); break;
|
||||
case 5: return("'.$this->_oDate->getMonthName(5).'"); break;
|
||||
case 6: return("'.$this->_oDate->getMonthName(6).'"); break;
|
||||
case 7: return("'.$this->_oDate->getMonthName(7).'"); break;
|
||||
case 8: return("'.$this->_oDate->getMonthName(8).'"); break;
|
||||
case 9: return("'.$this->_oDate->getMonthName(9).'"); break;
|
||||
case 10: return("'.$this->_oDate->getMonthName(10).'"); break;
|
||||
case 11: return("'.$this->_oDate->getMonthName(11).'"); break;
|
||||
case 12: return("'.$this->_oDate->getMonthName(12).'"); break;
|
||||
case 1: return("' . $this->_oDate->getMonthName(1) . '"); break;
|
||||
case 2: return("' . $this->_oDate->getMonthName(2) . '"); break;
|
||||
case 3: return("' . $this->_oDate->getMonthName(3) . '"); break;
|
||||
case 4: return("' . $this->_oDate->getMonthName(4) . '"); break;
|
||||
case 5: return("' . $this->_oDate->getMonthName(5) . '"); break;
|
||||
case 6: return("' . $this->_oDate->getMonthName(6) . '"); break;
|
||||
case 7: return("' . $this->_oDate->getMonthName(7) . '"); break;
|
||||
case 8: return("' . $this->_oDate->getMonthName(8) . '"); break;
|
||||
case 9: return("' . $this->_oDate->getMonthName(9) . '"); break;
|
||||
case 10: return("' . $this->_oDate->getMonthName(10) . '"); break;
|
||||
case 11: return("' . $this->_oDate->getMonthName(11) . '"); break;
|
||||
case 12: return("' . $this->_oDate->getMonthName(12) . '"); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
';
|
||||
|
||||
$sScript = str_replace("{cid}", $this->getId(), $sScript);
|
||||
$oScript->setContent($sScript);
|
||||
|
||||
|
||||
return $oScript;
|
||||
}
|
||||
|
||||
function _renderMonthDropdown ()
|
||||
{
|
||||
$oMonthSelect = new cHTMLSelectElement($this->getId() . "_monthselect");
|
||||
$oMonthSelect->setId($this->getId() ."_monthselect");
|
||||
|
||||
$aMonths = array();
|
||||
for ($i=1;$i<13;$i++)
|
||||
{
|
||||
$aMonths[$i] = $this->_oDate->getMonthName($i);
|
||||
}
|
||||
|
||||
$oMonthSelect->autoFill($aMonths);
|
||||
$oMonthSelect->setEvent("change", $this->getId() ."_setCalendar(".$this->getId() ."_currentYear, this.value);");
|
||||
$sScript = str_replace("{cid}", $this->getId(), $sScript);
|
||||
$oScript->setContent($sScript);
|
||||
|
||||
|
||||
return $oScript;
|
||||
}
|
||||
|
||||
function _renderMonthDropdown() {
|
||||
$oMonthSelect = new cHTMLSelectElement($this->getId() . "_monthselect");
|
||||
$oMonthSelect->setId($this->getId() . "_monthselect");
|
||||
|
||||
$aMonths = array();
|
||||
for ($i = 1; $i < 13; $i++) {
|
||||
$aMonths[$i] = $this->_oDate->getMonthName($i);
|
||||
}
|
||||
|
||||
$oMonthSelect->autoFill($aMonths);
|
||||
$oMonthSelect->setEvent("change", $this->getId() . "_setCalendar(" . $this->getId() . "_currentYear, this.value);");
|
||||
|
||||
return ($oMonthSelect);
|
||||
}
|
||||
|
||||
function _renderMonthPrev() {
|
||||
$oMonthLeft = new cHTMLImage;
|
||||
$oMonthLeft->setSrc("images/month_prev.gif");
|
||||
$oMonthLeft->setStyle("border: 0px solid black; cursor: pointer;");
|
||||
$oMonthLeft->setEvent("click", $this->getId() . "_monthprev();");
|
||||
return $oMonthLeft;
|
||||
}
|
||||
|
||||
function _renderMonthNext() {
|
||||
$oMonthLeft = new cHTMLImage;
|
||||
$oMonthLeft->setSrc("images/month_next.gif");
|
||||
$oMonthLeft->setStyle("border: 0px solid black; cursor: pointer;");
|
||||
$oMonthLeft->setEvent("click", $this->getId() . "_monthnext();");
|
||||
return $oMonthLeft;
|
||||
}
|
||||
|
||||
function _renderYearControl() {
|
||||
$oYear = new cHTMLTextbox($this->getId() . "_yearbox", "", 4, 4);
|
||||
$oYear->setId($this->getId() . "_yearbox");
|
||||
$oYear->setEvent("change", $this->getId() . "_setCalendar(this.value, " . $this->getId() . "_currentMonth);");
|
||||
|
||||
return $oYear;
|
||||
}
|
||||
|
||||
function render() {
|
||||
$this->setContent(array($this->_renderHead(), $this->_renderBody(), $this->_renderJS()));
|
||||
|
||||
$oSpan = new cHTMLSpan;
|
||||
$oSpan->setContent(array('<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>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -5,29 +5,28 @@
|
|||
* cDataTextWidget generates a textbox widget
|
||||
* for use with the data objects.
|
||||
*/
|
||||
class cDataTextWidget extends cHTMLTextbox
|
||||
{
|
||||
/**
|
||||
* cDataTextWidget: Creates a text box widget
|
||||
*
|
||||
* @param $name Name of the widget
|
||||
* @param $parameters Parameters (see below)
|
||||
*
|
||||
* valid parameters for this control are:
|
||||
* default Default value for this box
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function cDataTextWidget ($name, $parameters)
|
||||
{
|
||||
cHTMLTextbox::cHTMLTextbox($name);
|
||||
|
||||
if (array_key_exists("default", $parameters))
|
||||
{
|
||||
$this->setValue($parameters["default"]);
|
||||
}
|
||||
}
|
||||
class cDataTextWidget extends cHTMLTextbox {
|
||||
|
||||
/**
|
||||
* cDataTextWidget: Creates a text box widget
|
||||
*
|
||||
* @param $name Name of the widget
|
||||
* @param $parameters Parameters (see below)
|
||||
*
|
||||
* valid parameters for this control are:
|
||||
* default Default value for this box
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __construct($name, $parameters) {
|
||||
parent::__construct($name);
|
||||
|
||||
if (array_key_exists("default", $parameters)) {
|
||||
$this->setValue($parameters["default"]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,204 +34,192 @@ class cDataTextWidget extends cHTMLTextbox
|
|||
* cDataTextareaWidget generates a textarea widget for use with the data objects.
|
||||
*
|
||||
*/
|
||||
class cDataTextareaWidget extends cHTMLTextarea
|
||||
{
|
||||
/**
|
||||
* cDataTextareaWidget: Creates a text area widget
|
||||
*
|
||||
* @param $name Name of the widget
|
||||
* @param $parameters Parameters (see below)
|
||||
*
|
||||
* valid parameters for this control are:
|
||||
* default Default value for this area
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function cDataTextareaWidget ($name, $parameters)
|
||||
{
|
||||
cHTMLTextarea::cHTMLTextarea($name);
|
||||
|
||||
if (array_key_exists("default", $parameters))
|
||||
{
|
||||
$this->setValue($parameters["default"]);
|
||||
}
|
||||
class cDataTextareaWidget extends cHTMLTextarea {
|
||||
|
||||
/**
|
||||
* cDataTextareaWidget: Creates a text area widget
|
||||
*
|
||||
* @param $name Name of the widget
|
||||
* @param $parameters Parameters (see below)
|
||||
*
|
||||
* valid parameters for this control are:
|
||||
* default Default value for this area
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __construct($name, $parameters) {
|
||||
parent::__construct($name);
|
||||
|
||||
if (array_key_exists("default", $parameters)) {
|
||||
$this->setValue($parameters["default"]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* class cDataCodeTextareaWidget
|
||||
* cDataCodeTextareaWidget generates a textarea widget for use with the data objects.
|
||||
*/
|
||||
class cDataCodeTextareaWidget extends cHTMLTextarea
|
||||
{
|
||||
/**
|
||||
* cDataTextareaWidget: Creates a text area widget
|
||||
* which can be used for entering code
|
||||
*
|
||||
* @param $name Name of the widget
|
||||
* @param $parameters Parameters (see below)
|
||||
*
|
||||
* valid parameters for this control are:
|
||||
* default Default value for this area
|
||||
* notes Notes for this area
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function cDataCodeTextareaWidget ($name, $parameters)
|
||||
{
|
||||
cHTMLTextarea::cHTMLTextarea($name);
|
||||
|
||||
if (array_key_exists("default", $parameters))
|
||||
{
|
||||
$this->setValue($parameters["default"]);
|
||||
}
|
||||
|
||||
$this->updateAttributes(array("wrap" => "off"));
|
||||
$this->setStyle("width: 100%; font-family: monospace;");
|
||||
$this->setWidth(100);
|
||||
$this->setHeight(20);
|
||||
|
||||
if (array_key_exists("notes", $parameters))
|
||||
{
|
||||
$this->_notes = $parameters["notes"];
|
||||
}
|
||||
}
|
||||
|
||||
function render ()
|
||||
{
|
||||
$out = parent::render();
|
||||
$out .= $this->_notes;
|
||||
|
||||
return ($out);
|
||||
}
|
||||
class cDataCodeTextareaWidget extends cHTMLTextarea {
|
||||
|
||||
/**
|
||||
* cDataTextareaWidget: Creates a text area widget
|
||||
* which can be used for entering code
|
||||
*
|
||||
* @param $name Name of the widget
|
||||
* @param $parameters Parameters (see below)
|
||||
*
|
||||
* valid parameters for this control are:
|
||||
* default Default value for this area
|
||||
* notes Notes for this area
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __construct($name, $parameters) {
|
||||
parent::__construct($name);
|
||||
|
||||
if (array_key_exists("default", $parameters)) {
|
||||
$this->setValue($parameters["default"]);
|
||||
}
|
||||
|
||||
$this->updateAttributes(array("wrap" => "off"));
|
||||
$this->setStyle("width: 100%; font-family: monospace;");
|
||||
$this->setWidth(100);
|
||||
$this->setHeight(20);
|
||||
|
||||
if (array_key_exists("notes", $parameters)) {
|
||||
$this->_notes = $parameters["notes"];
|
||||
}
|
||||
}
|
||||
|
||||
function render() {
|
||||
$out = parent::render();
|
||||
$out .= $this->_notes;
|
||||
|
||||
return ($out);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* class cDataDropdownWidget
|
||||
* cDataDropdownWidget generates a dropdown widget for use with the data objects.
|
||||
*/
|
||||
class cDataDropdownWidget extends cHTMLSelectElement
|
||||
{
|
||||
/**
|
||||
* cDataDropdownWidget: Creates a dropdown widget
|
||||
* with specific entries
|
||||
*
|
||||
* @param $name Name of the widget
|
||||
* @param $parameters Parameters (see below)
|
||||
*
|
||||
* valid parameters for this control are:
|
||||
* default string Default value which will be selected
|
||||
* choices array Values for filling the dropdown
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function cDataDropdownWidget ($name, $parameters)
|
||||
{
|
||||
cHTMLSelectElement::cHTMLSelectElement($name);
|
||||
|
||||
$this->autoFill($parameters["choices"]);
|
||||
|
||||
if (array_key_exists("default", $parameters))
|
||||
{
|
||||
$this->setDefault($parameters["default"]);
|
||||
}
|
||||
}
|
||||
class cDataDropdownWidget extends cHTMLSelectElement {
|
||||
|
||||
/**
|
||||
* cDataDropdownWidget: Creates a dropdown widget
|
||||
* with specific entries
|
||||
*
|
||||
* @param $name Name of the widget
|
||||
* @param $parameters Parameters (see below)
|
||||
*
|
||||
* valid parameters for this control are:
|
||||
* default string Default value which will be selected
|
||||
* choices array Values for filling the dropdown
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __construct($name, $parameters) {
|
||||
parent::__construct($name);
|
||||
|
||||
$this->autoFill($parameters["choices"]);
|
||||
|
||||
if (array_key_exists("default", $parameters)) {
|
||||
$this->setDefault($parameters["default"]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* class cDataForeignTableDropdownWidget
|
||||
* cDataForeignTableDropdownWidget generates a dropdown widget out of a foreign table.
|
||||
*/
|
||||
class cDataForeignTableDropdownWidget extends cHTMLSelectElement
|
||||
{
|
||||
/**
|
||||
* cDataForeignTableDropdownWidget: Creates a dropdown widget
|
||||
* which fetches its entries from a foreign, linked table
|
||||
*
|
||||
* @param $name Name of the widget
|
||||
* @param $parameters Parameters (see below)
|
||||
*
|
||||
* valid parameters for this control are:
|
||||
* foreignClass string Class name of the foreign class
|
||||
* default string Default value which will be selected
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function cDataForeignTableDropdownWidget ($name, $parameters)
|
||||
{
|
||||
cHTMLSelectElement::cHTMLSelectElement($name);
|
||||
|
||||
$c = new $parameters["foreignClass"];
|
||||
$c->query();
|
||||
|
||||
while ($i = $c->next())
|
||||
{
|
||||
$meta = $i->getMetaObject();
|
||||
|
||||
if (is_object($meta))
|
||||
{
|
||||
$data[$i->get($i->primaryKey)] = $meta->getName();
|
||||
}
|
||||
}
|
||||
|
||||
$this->autoFill($data);
|
||||
|
||||
if (array_key_exists("default", $parameters))
|
||||
{
|
||||
$this->setDefault($parameters["default"]);
|
||||
}
|
||||
class cDataForeignTableDropdownWidget extends cHTMLSelectElement {
|
||||
|
||||
/**
|
||||
* cDataForeignTableDropdownWidget: Creates a dropdown widget
|
||||
* which fetches its entries from a foreign, linked table
|
||||
*
|
||||
* @param $name Name of the widget
|
||||
* @param $parameters Parameters (see below)
|
||||
*
|
||||
* valid parameters for this control are:
|
||||
* foreignClass string Class name of the foreign class
|
||||
* default string Default value which will be selected
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __construct($name, $parameters) {
|
||||
parent::__construct($name);
|
||||
|
||||
$c = new $parameters["foreignClass"];
|
||||
$c->query();
|
||||
|
||||
while ($i = $c->next()) {
|
||||
$meta = $i->getMetaObject();
|
||||
|
||||
if (is_object($meta)) {
|
||||
$data[$i->get($i->primaryKey)] = $meta->getName();
|
||||
}
|
||||
}
|
||||
|
||||
$this->autoFill($data);
|
||||
|
||||
if (array_key_exists("default", $parameters)) {
|
||||
$this->setDefault($parameters["default"]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* class cDataCheckboxWidget
|
||||
* cDataCheckboxWidget generates a checkbox for use with the dataobjects
|
||||
*/
|
||||
class cDataCheckboxWidget extends cHTMLCheckbox
|
||||
{
|
||||
/**
|
||||
* cDataCheckboxWidget: Creates a checkbox widget
|
||||
*
|
||||
* @param $name Name of the widget
|
||||
* @param $parameters Parameters (see below)
|
||||
*
|
||||
* valid parameters for this control are:
|
||||
* title string Title of the checkbox label
|
||||
* default string Checked or not checked
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function cDataCheckboxWidget ($name, $parameters)
|
||||
{
|
||||
cHTMLCheckbox::cHTMLCheckbox($name."_stub", "1");
|
||||
|
||||
if ($parameters["title"] != "")
|
||||
{
|
||||
$this->setLabelText($parameters["title"]);
|
||||
} else {
|
||||
$this->setLabelText(" ");
|
||||
}
|
||||
|
||||
$this->setChecked($parameters["default"]);
|
||||
|
||||
$this->_hfield = new cHTMLHiddenField($name, $parameters["default"]);
|
||||
$this->setEvent("click", "if (this.checked == true) { document.getElementById('".$this->_hfield->getId()."').value = '1'; } else { document.getElementById('".$this->_hfield->getId()."').value = '0'; }");
|
||||
}
|
||||
class cDataCheckboxWidget extends cHTMLCheckbox {
|
||||
|
||||
/**
|
||||
* cDataCheckboxWidget: Creates a checkbox widget
|
||||
*
|
||||
* @param $name Name of the widget
|
||||
* @param $parameters Parameters (see below)
|
||||
*
|
||||
* valid parameters for this control are:
|
||||
* title string Title of the checkbox label
|
||||
* default string Checked or not checked
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __construct($name, $parameters) {
|
||||
parent::__construct($name . "_stub", "1");
|
||||
|
||||
if ($parameters["title"] != "") {
|
||||
$this->setLabelText($parameters["title"]);
|
||||
} else {
|
||||
$this->setLabelText(" ");
|
||||
}
|
||||
|
||||
$this->setChecked($parameters["default"]);
|
||||
|
||||
$this->_hfield = new cHTMLHiddenField($name, $parameters["default"]);
|
||||
$this->setEvent("click", "if (this.checked == true) { document.getElementById('" . $this->_hfield->getId() . "').value = '1'; } else { document.getElementById('" . $this->_hfield->getId() . "').value = '0'; }");
|
||||
}
|
||||
|
||||
function render() {
|
||||
$out = $this->_hfield->render();
|
||||
$out .= parent::render();
|
||||
|
||||
return ($out);
|
||||
}
|
||||
|
||||
function render ()
|
||||
{
|
||||
$out = $this->_hfield->render();
|
||||
$out .= parent::render();
|
||||
|
||||
return ($out);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -240,94 +227,85 @@ class cDataCheckboxWidget extends cHTMLCheckbox
|
|||
* cDataMultiTextboxWidget generates a multi-line textbox widget
|
||||
|
||||
*/
|
||||
class cDataMultiTextboxWidget extends cHTMLTable
|
||||
{
|
||||
/**
|
||||
* cDataMultiTextboxWidget: Creates a multi-line textbox widget
|
||||
*
|
||||
* @param $name Name of the widget
|
||||
* @param $parameters Parameters (see below)
|
||||
*
|
||||
* valid parameters for this control are:
|
||||
* title string Title of the multi-line textbox widget
|
||||
* default array Values (=lines) to fill
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function cDataMultiTextboxWidget ($name, $parameters)
|
||||
{
|
||||
cHTMLTable::cHTMLTable();
|
||||
class cDataMultiTextboxWidget extends cHTMLTable {
|
||||
|
||||
$this->name = $name;
|
||||
|
||||
if (array_key_exists("title", $parameters))
|
||||
{
|
||||
$rows[] = $this->addTitle($parameters["title"]);
|
||||
}
|
||||
|
||||
if (is_array($parameters["default"]))
|
||||
{
|
||||
foreach ($parameters["default"] as $i)
|
||||
{
|
||||
$rows[] = $this->addRow($i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* cDataMultiTextboxWidget: Creates a multi-line textbox widget
|
||||
*
|
||||
* @param $name Name of the widget
|
||||
* @param $parameters Parameters (see below)
|
||||
*
|
||||
* valid parameters for this control are:
|
||||
* title string Title of the multi-line textbox widget
|
||||
* default array Values (=lines) to fill
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __construct($name, $parameters) {
|
||||
parent::__construct();
|
||||
|
||||
$this->name = $name;
|
||||
|
||||
if (array_key_exists("title", $parameters)) {
|
||||
$rows[] = $this->addTitle($parameters["title"]);
|
||||
}
|
||||
|
||||
if (is_array($parameters["default"])) {
|
||||
foreach ($parameters["default"] as $i) {
|
||||
$rows[] = $this->addRow($i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$rows[] = $this->addRow("");
|
||||
$this->setPadding(1);
|
||||
|
||||
$this->setContent($rows);
|
||||
}
|
||||
|
||||
function addTitle($title) {
|
||||
$row = new cHTMLTableRow;
|
||||
$data = new cHTMLTableData;
|
||||
$data->setColSpan(2);
|
||||
$data->setContent($title);
|
||||
$row->setContent($data);
|
||||
|
||||
return ($row);
|
||||
}
|
||||
|
||||
function addRow($data) {
|
||||
$row = new cHTMLTableRow;
|
||||
$l = new cHTMLTableData;
|
||||
$r = new cHTMLTableData;
|
||||
|
||||
$l->setVerticalAlignment("middle");
|
||||
$r->setVerticalAlignment("middle");
|
||||
|
||||
$textbox = new cHTMLTextbox($this->name . "[]", $data);
|
||||
$r->setContent($textbox);
|
||||
|
||||
$clearlink = new cHTMLLink;
|
||||
|
||||
$clearimage = new cHTMLImage;
|
||||
$clearimage->setSrc("images/actions/clear_right.gif");
|
||||
|
||||
$clearlink->setAlt(i18n("Clear contents"));
|
||||
$clearimage->setAlt(i18n("Clear contents"));
|
||||
|
||||
$clearlink->setContent($clearimage);
|
||||
|
||||
$i = $textbox->getId();
|
||||
|
||||
$clearlink->setEvent("click", "document.getElementById('$i').value = ''; return false;");
|
||||
$clearlink->setLink("#");
|
||||
|
||||
$l->setContent($clearlink);
|
||||
|
||||
$row->setContent(array($l, $r));
|
||||
|
||||
return ($row);
|
||||
}
|
||||
|
||||
|
||||
$rows[] = $this->addRow("");
|
||||
$this->setPadding(1);
|
||||
|
||||
$this->setContent($rows);
|
||||
|
||||
}
|
||||
|
||||
function addTitle ($title)
|
||||
{
|
||||
$row = new cHTMLTableRow;
|
||||
$data = new cHTMLTableData;
|
||||
$data->setColSpan(2);
|
||||
$data->setContent($title);
|
||||
$row->setContent($data);
|
||||
|
||||
return ($row);
|
||||
}
|
||||
|
||||
function addRow ($data)
|
||||
{
|
||||
$row = new cHTMLTableRow;
|
||||
$l = new cHTMLTableData;
|
||||
$r = new cHTMLTableData;
|
||||
|
||||
$l->setVerticalAlignment("middle");
|
||||
$r->setVerticalAlignment("middle");
|
||||
|
||||
$textbox = new cHTMLTextbox($this->name."[]", $data);
|
||||
$r->setContent($textbox);
|
||||
|
||||
$clearlink = new cHTMLLink;
|
||||
|
||||
$clearimage = new cHTMLImage;
|
||||
$clearimage->setSrc("images/actions/clear_right.gif");
|
||||
|
||||
$clearlink->setAlt(i18n("Clear contents"));
|
||||
$clearimage->setAlt(i18n("Clear contents"));
|
||||
|
||||
$clearlink->setContent($clearimage);
|
||||
|
||||
$i = $textbox->getId();
|
||||
|
||||
$clearlink->setEvent("click", "document.getElementById('$i').value = ''; return false;");
|
||||
$clearlink->setLink("#");
|
||||
|
||||
$l->setContent($clearlink);
|
||||
|
||||
$row->setContent(array($l, $r));
|
||||
|
||||
return ($row);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -25,71 +26,61 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
class cDateChooser extends cDatefield {
|
||||
|
||||
class cDateChooser extends cDatefield
|
||||
{
|
||||
var $_oCalendar;
|
||||
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;");
|
||||
var $_oCalendar;
|
||||
var $_oImage;
|
||||
var $_oButton;
|
||||
|
||||
|
||||
$this->_oCalendar = new cCalendarControl;
|
||||
|
||||
$this->_oDate->setSourceFormat(cDateTime_ISO);
|
||||
$this->_oDate->setTargetFormat(cDateTime_Locale_DateOnly);
|
||||
|
||||
if ($initValue === false)
|
||||
{
|
||||
$this->_oDate->set(date("Y-m-d H:i:s"));
|
||||
} else {
|
||||
$this->_oDate->set($initValue);
|
||||
}
|
||||
|
||||
$this->_aSelectIDs = array();
|
||||
}
|
||||
|
||||
function setSelectsToHide ($aSelectIDs)
|
||||
{
|
||||
if (!is_array($aSelectIDs))
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach ($aSelectIDs as $key => $data)
|
||||
{
|
||||
$aSelectIDs[$key] = '"'.$data.'"';
|
||||
}
|
||||
$this->_aSelectIDs = $aSelectIDs;
|
||||
}
|
||||
function __construct($name, $initValue = false) {
|
||||
parent::__construct($name, "");
|
||||
|
||||
function setReadOnly ($bReadOnly = true)
|
||||
{
|
||||
$this->_bReadOnly = $bReadOnly;
|
||||
}
|
||||
|
||||
function render ()
|
||||
{
|
||||
if ($this->_bReadOnly)
|
||||
{
|
||||
$this->updateAttributes(array ("readonly" => "readonly"));
|
||||
}
|
||||
|
||||
$sDatefield = parent::render();
|
||||
$sTimeformat = getEffectiveSetting("backend", "timeformat_date", "Y-m-d");
|
||||
|
||||
$parseScript = '
|
||||
$this->_oImage = new cHTMLImage;
|
||||
$this->_oImage->setSrc("images/pfeil_runter.gif");
|
||||
$this->_oImage->setStyle("margin-left: 2px; cursor: pointer;");
|
||||
|
||||
|
||||
$this->_oCalendar = new cCalendarControl;
|
||||
|
||||
$this->_oDate->setSourceFormat(cDateTime_ISO);
|
||||
$this->_oDate->setTargetFormat(cDateTime_Locale_DateOnly);
|
||||
|
||||
if ($initValue === false) {
|
||||
$this->_oDate->set(date("Y-m-d H:i:s"));
|
||||
} else {
|
||||
$this->_oDate->set($initValue);
|
||||
}
|
||||
|
||||
$this->_aSelectIDs = array();
|
||||
}
|
||||
|
||||
function setSelectsToHide($aSelectIDs) {
|
||||
if (!is_array($aSelectIDs)) {
|
||||
return;
|
||||
}
|
||||
foreach ($aSelectIDs as $key => $data) {
|
||||
$aSelectIDs[$key] = '"' . $data . '"';
|
||||
}
|
||||
$this->_aSelectIDs = $aSelectIDs;
|
||||
}
|
||||
|
||||
function setReadOnly($bReadOnly = true) {
|
||||
$this->_bReadOnly = $bReadOnly;
|
||||
}
|
||||
|
||||
function render() {
|
||||
if ($this->_bReadOnly) {
|
||||
$this->updateAttributes(array("readonly" => "readonly"));
|
||||
}
|
||||
|
||||
$sDatefield = parent::render();
|
||||
$sTimeformat = getEffectiveSetting("backend", "timeformat_date", "Y-m-d");
|
||||
|
||||
$parseScript = '
|
||||
<script language="JavaScript">
|
||||
|
||||
function {wid}_passToWidget (dateFormat, date)
|
||||
|
@ -105,7 +96,7 @@ class cDateChooser extends cDatefield
|
|||
|
||||
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";
|
||||
{wid}_hideselects (false);
|
||||
|
||||
|
@ -127,7 +118,7 @@ class cDateChooser extends cDatefield
|
|||
|
||||
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++)
|
||||
{
|
||||
|
@ -185,24 +176,22 @@ class cDateChooser extends cDatefield
|
|||
}
|
||||
</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); } }";
|
||||
|
||||
$div = new cHTMLDiv;
|
||||
|
||||
$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 = str_replace("{wid}", $this->getId(), $final);
|
||||
$final = str_replace("{cid}", $this->_oCalendar->getId(), $final);
|
||||
|
||||
$final = str_replace("{did}", $div->getId(), $final);
|
||||
|
||||
return ($final);
|
||||
|
||||
|
||||
}
|
||||
|
||||
$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); } }";
|
||||
|
||||
$div = new cHTMLDiv;
|
||||
|
||||
$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 = str_replace("{wid}", $this->getId(), $final);
|
||||
$final = str_replace("{cid}", $this->_oCalendar->getId(), $final);
|
||||
|
||||
$final = str_replace("{did}", $div->getId(), $final);
|
||||
|
||||
return ($final);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -25,40 +26,32 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -25,202 +26,178 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
class cDropdownDateSelect {
|
||||
|
||||
class cDropdownDateSelect
|
||||
{
|
||||
|
||||
/**
|
||||
* Day, month and year selectors
|
||||
/**
|
||||
* Day, month and year selectors
|
||||
* @var object
|
||||
* @access private
|
||||
*/
|
||||
var $_daySelect;
|
||||
var $_monthSelect;
|
||||
var $_yearSelect;
|
||||
|
||||
/**
|
||||
* Order of the elements
|
||||
*/
|
||||
var $_daySelect;
|
||||
var $_monthSelect;
|
||||
var $_yearSelect;
|
||||
|
||||
/**
|
||||
* Order of the elements
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
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);
|
||||
*/
|
||||
var $_order;
|
||||
|
||||
/* Fill months */
|
||||
for ($month = 1; $month < 13; $month++)
|
||||
{
|
||||
$months[sprintf("%02d", $month)] = getCanonicalMonth($month);
|
||||
}
|
||||
|
||||
$this->_monthSelect->autoFill($months);
|
||||
|
||||
/* Fill years */
|
||||
$currentYear = date("Y");
|
||||
for ($year = $currentYear-20; $year < $currentYear +20; $year++)
|
||||
{
|
||||
$years[$year] = $year;
|
||||
}
|
||||
|
||||
$this->_yearSelect->autoFill($years);
|
||||
|
||||
$this->setTimestamp(time());
|
||||
|
||||
/* Apply old values */
|
||||
if (isset($_POST[$prefix."_day"]))
|
||||
{
|
||||
$this->_daySelect->setDefault($_POST[$prefix."_day"]);
|
||||
}
|
||||
function __construct($prefix) {
|
||||
$this->_daySelect = new cHTMLSelectElement($prefix . "_day");
|
||||
$this->_monthSelect = new cHTMLSelectElement($prefix . "_month");
|
||||
$this->_yearSelect = new cHTMLSelectElement($prefix . "_year");
|
||||
|
||||
if (isset($_POST[$prefix."_month"]))
|
||||
{
|
||||
$this->_monthSelect->setDefault($_POST[$prefix."_month"]);
|
||||
}
|
||||
/* Fill days */
|
||||
for ($day = 1; $day < 32; $day++) {
|
||||
$days[sprintf("%02d", $day)] = $day;
|
||||
}
|
||||
|
||||
if (isset($_POST[$prefix."_year"]))
|
||||
{
|
||||
$this->_yearSelect->setDefault($_POST[$prefix."_year"]);
|
||||
}
|
||||
|
||||
$this->setOrder("dmy");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the day, month and year boxes using a timestamp
|
||||
*
|
||||
* @param $timestamp int Timestamp to set
|
||||
*/
|
||||
function setTimestamp ($timestamp)
|
||||
{
|
||||
$day = date("d", $timestamp);
|
||||
$month = date("m", $timestamp);
|
||||
$year = date("Y", $timestamp);
|
||||
$this->_daySelect->autoFill($days);
|
||||
|
||||
$this->_daySelect->setDefault($day);
|
||||
$this->_monthSelect->setDefault($month);
|
||||
$this->_yearSelect->setDefault($year);
|
||||
|
||||
}
|
||||
/* Fill months */
|
||||
for ($month = 1; $month < 13; $month++) {
|
||||
$months[sprintf("%02d", $month)] = getCanonicalMonth($month);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ID for all three select boxes.
|
||||
*
|
||||
* Note: The parameter id is only the prefix. Your ID is postfixed
|
||||
* by _day, _month and _year for each select box.
|
||||
*
|
||||
* @param $id string Prefix ID to set
|
||||
*/
|
||||
function setId ($id)
|
||||
{
|
||||
$this->_daySelect->setId($id."_day");
|
||||
$this->_monthSelect->setId($id."_month");
|
||||
$this->_yearSelect->setId($id."_year");
|
||||
}
|
||||
$this->_monthSelect->autoFill($months);
|
||||
|
||||
/**
|
||||
* Gets the current timestamp
|
||||
*
|
||||
* @param $timestamp int Timestamp to set
|
||||
*/
|
||||
function getTimestamp ($prefix = false)
|
||||
{
|
||||
if (!is_object($this->_daySelect))
|
||||
{
|
||||
/* Called statically */
|
||||
if (isset($_POST[$prefix."_day"]))
|
||||
{
|
||||
$day = $_POST[$prefix."_day"];
|
||||
}
|
||||
|
||||
if (isset($_POST[$prefix."_month"]))
|
||||
{
|
||||
$month = $_POST[$prefix."_month"];
|
||||
}
|
||||
|
||||
if (isset($_POST[$prefix."_year"]))
|
||||
{
|
||||
$year = $_POST[$prefix."_year"];
|
||||
}
|
||||
} else {
|
||||
$day = $this->_daySelect->getDefault();
|
||||
$month = $this->_monthSelect->getDefault();
|
||||
$year = $this->_yearSelect->getDefault();
|
||||
}
|
||||
|
||||
return mktime(0,0,0, $month, $day, $year);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the order of the day, month and year boxes
|
||||
*
|
||||
* Pass a string with "d", "m" and "y" in the desired order.
|
||||
*
|
||||
* Example:
|
||||
* $test->setOrder("mdy");
|
||||
*
|
||||
* @param $order string Order with the keys "d", "m" and "y"
|
||||
*/
|
||||
function setOrder ($order)
|
||||
{
|
||||
$this->_order = $order;
|
||||
}
|
||||
/* Fill years */
|
||||
$currentYear = date("Y");
|
||||
for ($year = $currentYear - 20; $year < $currentYear + 20; $year++) {
|
||||
$years[$year] = $year;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the element to a disabled state
|
||||
*
|
||||
* @param none
|
||||
*/
|
||||
function setDisabled ($disabled)
|
||||
{
|
||||
$this->_daySelect->setDisabled($disabled);
|
||||
$this->_monthSelect->setDisabled($disabled);
|
||||
$this->_yearSelect->setDisabled($disabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the elements
|
||||
*
|
||||
* @param none
|
||||
*/
|
||||
function render ()
|
||||
{
|
||||
$output = "";
|
||||
|
||||
for ($char = 0; $char < strlen($this->_order); $char++)
|
||||
{
|
||||
$mychar = substr($this->_order, $char, 1);
|
||||
|
||||
switch ($mychar)
|
||||
{
|
||||
case "d": $output .= $this->_daySelect->render(); break;
|
||||
case "m": $output .= $this->_monthSelect->render(); break;
|
||||
case "y": $output .= $this->_yearSelect->render(); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
return ($output);
|
||||
}
|
||||
|
||||
$this->_yearSelect->autoFill($years);
|
||||
|
||||
$this->setTimestamp(time());
|
||||
|
||||
/* Apply old values */
|
||||
if (isset($_POST[$prefix . "_day"])) {
|
||||
$this->_daySelect->setDefault($_POST[$prefix . "_day"]);
|
||||
}
|
||||
|
||||
if (isset($_POST[$prefix . "_month"])) {
|
||||
$this->_monthSelect->setDefault($_POST[$prefix . "_month"]);
|
||||
}
|
||||
|
||||
if (isset($_POST[$prefix . "_year"])) {
|
||||
$this->_yearSelect->setDefault($_POST[$prefix . "_year"]);
|
||||
}
|
||||
|
||||
$this->setOrder("dmy");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the day, month and year boxes using a timestamp
|
||||
*
|
||||
* @param $timestamp int Timestamp to set
|
||||
*/
|
||||
function setTimestamp($timestamp) {
|
||||
$day = date("d", $timestamp);
|
||||
$month = date("m", $timestamp);
|
||||
$year = date("Y", $timestamp);
|
||||
|
||||
$this->_daySelect->setDefault($day);
|
||||
$this->_monthSelect->setDefault($month);
|
||||
$this->_yearSelect->setDefault($year);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ID for all three select boxes.
|
||||
*
|
||||
* Note: The parameter id is only the prefix. Your ID is postfixed
|
||||
* by _day, _month and _year for each select box.
|
||||
*
|
||||
* @param $id string Prefix ID to set
|
||||
*/
|
||||
function setId($id) {
|
||||
$this->_daySelect->setId($id . "_day");
|
||||
$this->_monthSelect->setId($id . "_month");
|
||||
$this->_yearSelect->setId($id . "_year");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current timestamp
|
||||
*
|
||||
* @param $timestamp int Timestamp to set
|
||||
*/
|
||||
function getTimestamp($prefix = false) {
|
||||
if (!is_object($this->_daySelect)) {
|
||||
/* Called statically */
|
||||
if (isset($_POST[$prefix . "_day"])) {
|
||||
$day = $_POST[$prefix . "_day"];
|
||||
}
|
||||
|
||||
if (isset($_POST[$prefix . "_month"])) {
|
||||
$month = $_POST[$prefix . "_month"];
|
||||
}
|
||||
|
||||
if (isset($_POST[$prefix . "_year"])) {
|
||||
$year = $_POST[$prefix . "_year"];
|
||||
}
|
||||
} else {
|
||||
$day = $this->_daySelect->getDefault();
|
||||
$month = $this->_monthSelect->getDefault();
|
||||
$year = $this->_yearSelect->getDefault();
|
||||
}
|
||||
|
||||
return mktime(0, 0, 0, $month, $day, $year);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the order of the day, month and year boxes
|
||||
*
|
||||
* Pass a string with "d", "m" and "y" in the desired order.
|
||||
*
|
||||
* Example:
|
||||
* $test->setOrder("mdy");
|
||||
*
|
||||
* @param $order string Order with the keys "d", "m" and "y"
|
||||
*/
|
||||
function setOrder($order) {
|
||||
$this->_order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the element to a disabled state
|
||||
*
|
||||
* @param none
|
||||
*/
|
||||
function setDisabled($disabled) {
|
||||
$this->_daySelect->setDisabled($disabled);
|
||||
$this->_monthSelect->setDisabled($disabled);
|
||||
$this->_yearSelect->setDisabled($disabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the elements
|
||||
*
|
||||
* @param none
|
||||
*/
|
||||
function render() {
|
||||
$output = "";
|
||||
|
||||
for ($char = 0; $char < strlen($this->_order); $char++) {
|
||||
$mychar = substr($this->_order, $char, 1);
|
||||
|
||||
switch ($mychar) {
|
||||
case "d": $output .= $this->_daySelect->render();
|
||||
break;
|
||||
case "m": $output .= $this->_monthSelect->render();
|
||||
break;
|
||||
case "y": $output .= $this->_yearSelect->render();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
return ($output);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -25,47 +26,45 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
class cFoldingRow extends cHTML {
|
||||
|
||||
class cFoldingRow extends cHTML
|
||||
{
|
||||
/**
|
||||
* Table row with the header
|
||||
/**
|
||||
* Table row with the header
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_headerRow;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var cHTMLTableData
|
||||
*/
|
||||
var $_headerData;
|
||||
|
||||
/**
|
||||
* Table row with the content
|
||||
*/
|
||||
var $_headerRow;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var cHTMLTableData
|
||||
*/
|
||||
var $_headerData;
|
||||
|
||||
/**
|
||||
* Table row with the content
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_contentRow;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var cHTMLTableData
|
||||
*/
|
||||
var $_contentData;
|
||||
|
||||
/**
|
||||
* ID for link that triggers expandCollapse
|
||||
*/
|
||||
var $_contentRow;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var cHTMLTableData
|
||||
*/
|
||||
var $_contentData;
|
||||
|
||||
/**
|
||||
* ID for link that triggers expandCollapse
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_linkId;
|
||||
|
||||
*/
|
||||
var $_linkId;
|
||||
|
||||
/**
|
||||
*
|
||||
* @global type $auth
|
||||
|
@ -74,121 +73,109 @@ class cFoldingRow extends cHTML
|
|||
* @param type $link_id
|
||||
* @param type $bExpanded
|
||||
*/
|
||||
public function cFoldingRow($uuid, $caption = "", $link_id = "", $bExpanded = null) {
|
||||
public function __construct($uuid, $caption = "", $link_id = "", $bExpanded = null) {
|
||||
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->addRequiredScript("cfoldingrow.js");
|
||||
|
||||
$this->setCaption($caption);
|
||||
|
||||
$this->_headerRow = new cHTMLTableRow;
|
||||
|
||||
$this->_headerData = new cHTMLTableData;
|
||||
$this->_contentRow = new cHTMLTableRow;
|
||||
$this->_contentRow->updateAttributes(array("id" => $uuid));
|
||||
$this->_contentData = new cHTMLTableData;
|
||||
$this->_uuid = $uuid;
|
||||
|
||||
$this->_link = new cHTMLLink;
|
||||
$this->_linkId = $link_id;
|
||||
|
||||
$this->_headerData->setClass("foldingrow");
|
||||
|
||||
$this->_hiddenField = new cHTMLHiddenField("expandstate_" . $this->_contentRow->getID());
|
||||
|
||||
$this->_foldingImage = new cHTMLImage;
|
||||
$this->_foldingImage->setStyle("margin-right: 4px;");
|
||||
|
||||
$this->setExpanded(false);
|
||||
|
||||
$this->addRequiredScript("parameterCollector.js");
|
||||
$this->addRequiredScript("cfoldingrow.js");
|
||||
|
||||
$user = new cApiUser($auth->auth["uid"]);
|
||||
|
||||
if ($bExpanded == null) {
|
||||
/* Check for expandstate */
|
||||
|
||||
if (!$user->virgin)
|
||||
{
|
||||
if ($user->getProperty("expandstate", $uuid) == "true")
|
||||
{
|
||||
$this->setExpanded($user->getProperty("expandstate", $uuid));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($bExpanded) {
|
||||
$this->setExpanded(true);
|
||||
} else {
|
||||
$this->setExpanded(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setExpanded ($expanded = false)
|
||||
{
|
||||
if ($expanded == true)
|
||||
{
|
||||
$this->_foldingImage->setSrc("images/widgets/foldingrow/expanded.gif");
|
||||
$this->_foldingImage->updateAttributes(array("data-folding-row" => "expanded", "alt" => ""));
|
||||
$this->_contentRow->setStyle("display: ;");
|
||||
if ($bExpanded == null) {
|
||||
/* Check for expandstate */
|
||||
|
||||
if (!$user->virgin) {
|
||||
if ($user->getProperty("expandstate", $uuid) == "true") {
|
||||
$this->setExpanded($user->getProperty("expandstate", $uuid));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($bExpanded) {
|
||||
$this->setExpanded(true);
|
||||
} else {
|
||||
$this->setExpanded(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setExpanded($expanded = false) {
|
||||
if ($expanded == true) {
|
||||
$this->_foldingImage->setSrc("images/widgets/foldingrow/expanded.gif");
|
||||
$this->_foldingImage->updateAttributes(array("data-folding-row" => "expanded", "alt" => ""));
|
||||
$this->_contentRow->setStyle("display: ;");
|
||||
$this->_hiddenField->setValue('expanded');
|
||||
} else {
|
||||
$this->_foldingImage->setSrc("images/widgets/foldingrow/collapsed.gif");
|
||||
$this->_foldingImage->updateAttributes(array("data-folding-row" => "collapsed", "alt" => ""));
|
||||
$this->_contentRow->setStyle("display: none;");
|
||||
} else {
|
||||
$this->_foldingImage->setSrc("images/widgets/foldingrow/collapsed.gif");
|
||||
$this->_foldingImage->updateAttributes(array("data-folding-row" => "collapsed", "alt" => ""));
|
||||
$this->_contentRow->setStyle("display: none;");
|
||||
$this->_hiddenField->setValue('collapsed');
|
||||
}
|
||||
$this->_expanded = $expanded;
|
||||
}
|
||||
|
||||
function setCaption ($caption)
|
||||
{
|
||||
$this->_caption = $caption;
|
||||
}
|
||||
|
||||
function setHelpContext ($context = false)
|
||||
{
|
||||
$this->_helpContext = $context;
|
||||
}
|
||||
|
||||
function setIndent ($indent = 0)
|
||||
{
|
||||
$this->_indent = $indent;
|
||||
}
|
||||
|
||||
function setContentData ($content)
|
||||
{
|
||||
$this->_contentData->setContent($content);
|
||||
}
|
||||
|
||||
function render ()
|
||||
{
|
||||
/* Build the expand/collapse link */
|
||||
|
||||
$this->_link->setClass("foldingrow");
|
||||
if($this->_linkId != NULL)
|
||||
{
|
||||
$this->_link->setID($this->_linkId);
|
||||
}
|
||||
|
||||
$imgid = $this->_foldingImage->getID();
|
||||
$rowid = $this->_contentRow->getID();
|
||||
$hiddenid = $this->_hiddenField->getID();
|
||||
$uuid = $this->_uuid;
|
||||
|
||||
$this->_link->setLink("javascript:cFoldingRow_expandCollapse('$imgid', '$rowid', '$hiddenid', '$uuid');");
|
||||
$this->_link->setContent($this->_foldingImage->render() . $this->_caption);
|
||||
|
||||
$this->_headerData->setContent(array($this->_hiddenField,$this->_link));
|
||||
$this->_headerRow->setContent($this->_headerData);
|
||||
|
||||
$this->_contentRow->setContent($this->_contentData);
|
||||
|
||||
$output = $this->_headerRow->render();
|
||||
$output .= $this->_contentRow->render();
|
||||
|
||||
return ($output);
|
||||
}
|
||||
|
||||
}
|
||||
$this->_expanded = $expanded;
|
||||
}
|
||||
|
||||
function setCaption($caption) {
|
||||
$this->_caption = $caption;
|
||||
}
|
||||
|
||||
function setHelpContext($context = false) {
|
||||
$this->_helpContext = $context;
|
||||
}
|
||||
|
||||
function setIndent($indent = 0) {
|
||||
$this->_indent = $indent;
|
||||
}
|
||||
|
||||
function setContentData($content) {
|
||||
$this->_contentData->setContent($content);
|
||||
}
|
||||
|
||||
function render() {
|
||||
/* Build the expand/collapse link */
|
||||
|
||||
$this->_link->setClass("foldingrow");
|
||||
if ($this->_linkId != NULL) {
|
||||
$this->_link->setID($this->_linkId);
|
||||
}
|
||||
|
||||
$imgid = $this->_foldingImage->getID();
|
||||
$rowid = $this->_contentRow->getID();
|
||||
$hiddenid = $this->_hiddenField->getID();
|
||||
$uuid = $this->_uuid;
|
||||
|
||||
$this->_link->setLink("javascript:cFoldingRow_expandCollapse('$imgid', '$rowid', '$hiddenid', '$uuid');");
|
||||
$this->_link->setContent($this->_foldingImage->render() . $this->_caption);
|
||||
|
||||
$this->_headerData->setContent(array($this->_hiddenField, $this->_link));
|
||||
$this->_headerRow->setContent($this->_headerData);
|
||||
|
||||
$this->_contentRow->setContent($this->_contentData);
|
||||
|
||||
$output = $this->_headerRow->render();
|
||||
$output .= $this->_contentRow->render();
|
||||
|
||||
return ($output);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -25,103 +26,87 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
cInclude("plugins", "general/classes/class.datatype.number.php");
|
||||
cInclude("plugins", "general/classes/class.datatype.currency.php");
|
||||
|
||||
class cNominalNumberField extends cHTMLTextbox
|
||||
{
|
||||
var $_oNumber;
|
||||
var $_bRealtimeNominalFormat;
|
||||
|
||||
function cNominalNumberField ($name, $initvalue, $width)
|
||||
{
|
||||
global $belang;
|
||||
|
||||
$this->_oNumber = new cDatatypeNumber;
|
||||
$this->_oNumber->set($initvalue);
|
||||
|
||||
$this->disableRealtimeNominalFormat();
|
||||
|
||||
parent::cHTMLTextbox($name, $initvalue, $width);
|
||||
}
|
||||
|
||||
function enableRealtimeNominalFormat ()
|
||||
{
|
||||
$this->_bRealtimeNominalFormat = true;
|
||||
}
|
||||
|
||||
function disableRealtimeNominalFormat ()
|
||||
{
|
||||
$this->_bRealtimeNominalFormat = false;
|
||||
}
|
||||
|
||||
function render ()
|
||||
{
|
||||
parent::setValue($this->_oNumber->render());
|
||||
|
||||
if ($this->_bRealtimeNominalFormat)
|
||||
{
|
||||
|
||||
$decimalChar = $this->_oNumber->getDecimalPointCharacter();
|
||||
$thousandChar = $this->_oNumber->getThousandSeparatorCharacter();
|
||||
|
||||
parent::setEvent("change", "nominal_format_custom(this, '".$decimalChar."', '".$thousandChar."')");
|
||||
}
|
||||
return parent::render();
|
||||
}
|
||||
|
||||
class cNominalNumberField extends cHTMLTextbox {
|
||||
|
||||
var $_oNumber;
|
||||
var $_bRealtimeNominalFormat;
|
||||
|
||||
function __construct($name, $initvalue, $width) {
|
||||
global $belang;
|
||||
|
||||
$this->_oNumber = new cDatatypeNumber;
|
||||
$this->_oNumber->set($initvalue);
|
||||
|
||||
$this->disableRealtimeNominalFormat();
|
||||
|
||||
parent::__construct($name, $initvalue, $width);
|
||||
}
|
||||
|
||||
function enableRealtimeNominalFormat() {
|
||||
$this->_bRealtimeNominalFormat = true;
|
||||
}
|
||||
|
||||
function disableRealtimeNominalFormat() {
|
||||
$this->_bRealtimeNominalFormat = false;
|
||||
}
|
||||
|
||||
function render() {
|
||||
parent::setValue($this->_oNumber->render());
|
||||
|
||||
if ($this->_bRealtimeNominalFormat) {
|
||||
|
||||
$decimalChar = $this->_oNumber->getDecimalPointCharacter();
|
||||
$thousandChar = $this->_oNumber->getThousandSeparatorCharacter();
|
||||
|
||||
parent::setEvent("change", "nominal_format_custom(this, '" . $decimalChar . "', '" . $thousandChar . "')");
|
||||
}
|
||||
return parent::render();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class cNominalCurrencyField extends cNominalNumberField
|
||||
{
|
||||
var $_oNumber;
|
||||
var $_bRealtimeNominalFormat;
|
||||
|
||||
function cNominalCurrencyField ($name, $initvalue, $width)
|
||||
{
|
||||
parent::cNominalNumberField($name, $initvalue, $width);
|
||||
|
||||
$this->_oNumber = new cDatatypeCurrency;
|
||||
$this->_oNumber->set($initvalue);
|
||||
class cNominalCurrencyField extends cNominalNumberField {
|
||||
|
||||
$this->disableRealtimeNominalFormat();
|
||||
|
||||
var $_oNumber;
|
||||
var $_bRealtimeNominalFormat;
|
||||
|
||||
}
|
||||
|
||||
function enableRealtimeNominalFormat ()
|
||||
{
|
||||
$this->_bRealtimeNominalFormat = true;
|
||||
}
|
||||
|
||||
function disableRealtimeNominalFormat ()
|
||||
{
|
||||
$this->_bRealtimeNominalFormat = false;
|
||||
}
|
||||
|
||||
function render ()
|
||||
{
|
||||
parent::setValue($this->_oNumber->render());
|
||||
|
||||
if ($this->_bRealtimeNominalFormat)
|
||||
{
|
||||
$decimalChar = $this->_oNumber->getDecimalPointCharacter();
|
||||
$thousandChar = $this->_oNumber->getThousandSeparatorCharacter();
|
||||
|
||||
$currencySign = $this->_oNumber->getCurrencySymbol();
|
||||
|
||||
parent::setEvent("change", "nominal_format_custom(this, '".$decimalChar."', '".$thousandChar."', '".$currencySign."')");
|
||||
}
|
||||
return parent::render();
|
||||
}
|
||||
|
||||
function __construct($name, $initvalue, $width) {
|
||||
parent::__construct($name, $initvalue, $width);
|
||||
|
||||
$this->_oNumber = new cDatatypeCurrency;
|
||||
$this->_oNumber->set($initvalue);
|
||||
|
||||
$this->disableRealtimeNominalFormat();
|
||||
}
|
||||
|
||||
function enableRealtimeNominalFormat() {
|
||||
$this->_bRealtimeNominalFormat = true;
|
||||
}
|
||||
|
||||
function disableRealtimeNominalFormat() {
|
||||
$this->_bRealtimeNominalFormat = false;
|
||||
}
|
||||
|
||||
function render() {
|
||||
parent::setValue($this->_oNumber->render());
|
||||
|
||||
if ($this->_bRealtimeNominalFormat) {
|
||||
$decimalChar = $this->_oNumber->getDecimalPointCharacter();
|
||||
$thousandChar = $this->_oNumber->getThousandSeparatorCharacter();
|
||||
|
||||
$currencySign = $this->_oNumber->getCurrencySymbol();
|
||||
|
||||
parent::setEvent("change", "nominal_format_custom(this, '" . $decimalChar . "', '" . $thousandChar . "', '" . $currencySign . "')");
|
||||
}
|
||||
return parent::render();
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
|
@ -78,19 +78,19 @@ class cPage extends cHTML {
|
|||
* @access private
|
||||
*/
|
||||
var $extra;
|
||||
|
||||
|
||||
/**
|
||||
* Switch if HTML5
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_isHtml5 = false;
|
||||
|
||||
|
||||
/**
|
||||
* CSS files to add
|
||||
* @var array
|
||||
*/
|
||||
protected $_css;
|
||||
|
||||
|
||||
/**
|
||||
* JS files to add
|
||||
* @var array
|
||||
|
@ -143,20 +143,20 @@ class cPage extends cHTML {
|
|||
function setMargin($margin) {
|
||||
$this->_margin = $margin;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $sFile path to file
|
||||
*/
|
||||
public function addCssFile($sFile) {
|
||||
if(!is_array($this->_css)) {
|
||||
if (!is_array($this->_css)) {
|
||||
$this->_css = array();
|
||||
}
|
||||
$this->_css[] = $sFile;
|
||||
}
|
||||
|
||||
|
||||
public function addJsFile($sFile) {
|
||||
if(!is_array($this->_css)) {
|
||||
if (!is_array($this->_css)) {
|
||||
$this->_js = array();
|
||||
}
|
||||
$this->_js[] = $sFile;
|
||||
|
@ -271,7 +271,7 @@ class cPage extends cHTML {
|
|||
function setEncoding($encoding) {
|
||||
$this->_encoding = $encoding;
|
||||
}
|
||||
|
||||
|
||||
public function sendNoCacheHeaders() {
|
||||
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
|
||||
header("Pragma: no-cache"); // HTTP 1.0.
|
||||
|
@ -296,13 +296,13 @@ class cPage extends cHTML {
|
|||
|
||||
if ($this->_object !== false && method_exists($this->_object, "render") && is_array($this->_requiredScripts)) {
|
||||
foreach ($this->_requiredScripts as $key => $value) {
|
||||
$scripts .= '<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) {
|
||||
foreach($this->_js as $sFilename) {
|
||||
$scripts .= '<script type="text/javascript" src="' . $sFilename . '"></script>'."\n";
|
||||
|
||||
if (is_array($this->_js) && count($this->_js) > 0) {
|
||||
foreach ($this->_js as $sFilename) {
|
||||
$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 .= '</script>';
|
||||
}
|
||||
|
||||
|
||||
$css = "";
|
||||
if(is_array($this->_css)) {
|
||||
foreach($this->_css as $sFilename) {
|
||||
$css .= '<link rel="stylesheet" type="text/css" href="'.$sFilename.'" />'."\n";
|
||||
if (is_array($this->_css)) {
|
||||
foreach ($this->_css as $sFilename) {
|
||||
$css .= '<link rel="stylesheet" type="text/css" href="' . $sFilename . '" />' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$meta = '';
|
||||
if ($this->_encoding != "" && !$this->_isHtml5) {
|
||||
$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-ui.js"></script>';
|
||||
}
|
||||
|
||||
|
||||
$tpl->set('s', 'META', $meta);
|
||||
$tpl->set('s', 'SCRIPTS', $scripts);
|
||||
$tpl->set('s', 'CSS', $css);
|
||||
$tpl->set('s', 'CONTENT', $this->_content);
|
||||
$tpl->set('s', 'MARGIN', $this->_margin);
|
||||
$tpl->set('s', 'EXTRA', $this->extra);
|
||||
$tpl->set('s', 'EXTRA', $this->extra);
|
||||
$tpl->set('s', 'SESSION_ID', $sess->id);
|
||||
|
||||
if ($print == true) {
|
||||
|
@ -374,7 +374,7 @@ class cPageLeftTop extends cPage {
|
|||
*
|
||||
* @param $showCloser boolean True if the closer should be shown (default)
|
||||
*/
|
||||
function cPageLeftTop($showCloser = true) {
|
||||
function __construct($showCloser = true) {
|
||||
$this->showCloser($showCloser);
|
||||
}
|
||||
|
||||
|
@ -390,11 +390,11 @@ class cPageLeftTop extends cPage {
|
|||
function render($print = true) {
|
||||
global $cfg;
|
||||
|
||||
$tpl = new Template;
|
||||
$tpl = new Template();
|
||||
$tpl->set('s', 'CONTENT', $content);
|
||||
$this->setContent($tpl->generate($cfg['path']['contenido'] . $cfg['path']['templates'] . $cfg['templates']['widgets']['left_top'], true));
|
||||
|
||||
cPage::render($print);
|
||||
parent::render($print);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -429,10 +429,10 @@ class cPageLeftTopMultiPane extends cPageLeftTop {
|
|||
*
|
||||
* @param $items array All items passed as multi array (see constructor description)
|
||||
*/
|
||||
function cPageLeftTopMultiPane($items) {
|
||||
function __construct($items) {
|
||||
$this->_items = $items;
|
||||
|
||||
cPageLeftTop::cPageLeftTop();
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -494,21 +494,21 @@ class cPageLeftTopMultiPane extends cPageLeftTop {
|
|||
$tpl->set('s', 'CONTENT', $content);
|
||||
$this->setContent($tpl->generate($cfg['path']['templates'] . $cfg['templates']['widgets']['left_top'], true));
|
||||
|
||||
cPage::render();
|
||||
parent::render();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class cNewPageLeftTopMultiPane extends cPageLeftTopMultiPane {
|
||||
|
||||
function cNewPageLeftTopMultiPane($items) {
|
||||
cPageLeftTopMultiPane::cPageLeftTopMultiPane($items);
|
||||
function __construct($items) {
|
||||
parent::__construct($items);
|
||||
}
|
||||
|
||||
function render($print = true) {
|
||||
global $cfg;
|
||||
|
||||
$infodiv = new cHTMLDiv;
|
||||
$infodiv = new cHTMLDiv();
|
||||
|
||||
if (count($this->_items) > 0) {
|
||||
foreach ($this->_items as $item) {
|
||||
|
@ -549,5 +549,3 @@ class cNewPageLeftTopMultiPane extends cPageLeftTopMultiPane {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -25,137 +26,126 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
class cObjectPager extends cFoldingRow {
|
||||
|
||||
class cObjectPager extends cFoldingRow
|
||||
{
|
||||
var $_pagerLink;
|
||||
var $_parameterToAdd;
|
||||
|
||||
function cObjectPager ($uuid, $items, $itemsperpage, $currentpage, $link, $parameterToAdd, $id='')
|
||||
{
|
||||
if ((int) $currentpage == 0) {
|
||||
$currentpage = 1;
|
||||
}
|
||||
|
||||
if($id == '')
|
||||
{
|
||||
cFoldingRow::cFoldingRow($uuid, i18n("Paging"));
|
||||
}
|
||||
else
|
||||
{
|
||||
cFoldingRow::cFoldingRow($uuid, i18n("Paging"), $id);
|
||||
}
|
||||
|
||||
if (!is_object($link))
|
||||
{
|
||||
cError(__FILE__, __LINE__, "Parameter link is not an object");
|
||||
return false;
|
||||
}
|
||||
$this->_cPager = new cPager($items, $itemsperpage, $currentpage);
|
||||
$this->_pagerLink = $link;
|
||||
$this->_parameterToAdd = $parameterToAdd;
|
||||
|
||||
}
|
||||
|
||||
function render ($bContentOnly = 0)
|
||||
{
|
||||
var $_pagerLink;
|
||||
var $_parameterToAdd;
|
||||
|
||||
function __construct($uuid, $items, $itemsperpage, $currentpage, $link, $parameterToAdd, $id = '') {
|
||||
if ((int) $currentpage == 0) {
|
||||
$currentpage = 1;
|
||||
}
|
||||
|
||||
if ($id == '') {
|
||||
parent::__construct($uuid, i18n("Paging"));
|
||||
} else {
|
||||
parent::__construct($uuid, i18n("Paging"), $id);
|
||||
}
|
||||
|
||||
if (!is_object($link)) {
|
||||
cError(__FILE__, __LINE__, "Parameter link is not an object");
|
||||
return false;
|
||||
}
|
||||
$this->_cPager = new cPager($items, $itemsperpage, $currentpage);
|
||||
$this->_pagerLink = $link;
|
||||
$this->_parameterToAdd = $parameterToAdd;
|
||||
}
|
||||
|
||||
function render($bContentOnly = 0) {
|
||||
#Do not display Page navigation if there is only one Page and we are not in newsletter section
|
||||
if ($this->_cPager->getMaxPages() == 1) {
|
||||
$this->_headerRow->setStyle("display:none");
|
||||
$this->_contentRow->setStyle("display:none");
|
||||
}
|
||||
|
||||
$items = $this->_cPager->getPagesInRange();
|
||||
//echo '<pre>';
|
||||
|
||||
$items = $this->_cPager->getPagesInRange();
|
||||
//echo '<pre>';
|
||||
//print_r($items);
|
||||
//echo '</pre>';
|
||||
$link = $this->_pagerLink;
|
||||
|
||||
$output = '';
|
||||
|
||||
if (!$this->_cPager->isFirstPage())
|
||||
{
|
||||
$img = new cHTMLImage("images/paging/first.gif");
|
||||
|
||||
$link->setAlt(i18n("First page"));
|
||||
$link->setContent($img);
|
||||
$link = $this->_pagerLink;
|
||||
|
||||
$output = '';
|
||||
|
||||
if (!$this->_cPager->isFirstPage()) {
|
||||
$img = new cHTMLImage("images/paging/first.gif");
|
||||
|
||||
$link->setAlt(i18n("First page"));
|
||||
$link->setContent($img);
|
||||
$link->setCustom($this->_parameterToAdd, 1);
|
||||
$output .= $link->render();
|
||||
$output .= " ";
|
||||
|
||||
$img = new cHTMLImage("images/paging/previous.gif");
|
||||
$link->setAlt(i18n("Previous page"));
|
||||
$link->setContent($img);
|
||||
|
||||
$output .= $link->render();
|
||||
$output .= " ";
|
||||
|
||||
$img = new cHTMLImage("images/paging/previous.gif");
|
||||
$link->setAlt(i18n("Previous page"));
|
||||
$link->setContent($img);
|
||||
|
||||
$link->setCustom($this->_parameterToAdd, $this->_cPager->_currentPage - 1);
|
||||
|
||||
$output .= $link->render();
|
||||
$output .= " ";
|
||||
} else {
|
||||
$output .= '<img src="images/spacer.gif" width="8" alt=""> ';
|
||||
$output .= '<img src="images/spacer.gif" width="8" alt="">';
|
||||
}
|
||||
foreach ($items as $key => $item)
|
||||
{
|
||||
$link->setContent($key);
|
||||
$link->setAlt(sprintf(i18n("Page %s"), $key));
|
||||
|
||||
$output .= $link->render();
|
||||
$output .= " ";
|
||||
} else {
|
||||
$output .= '<img src="images/spacer.gif" width="8" alt=""> ';
|
||||
$output .= '<img src="images/spacer.gif" width="8" alt="">';
|
||||
}
|
||||
foreach ($items as $key => $item) {
|
||||
$link->setContent($key);
|
||||
$link->setAlt(sprintf(i18n("Page %s"), $key));
|
||||
$link->setCustom($this->_parameterToAdd, $key);
|
||||
|
||||
switch ($item)
|
||||
{
|
||||
case "|": $output .= "..."; break;
|
||||
case "current": $output .= '<span class="cpager_currentitem">'.$key."</span>"; break;
|
||||
default: $output .= $link->render();
|
||||
}
|
||||
|
||||
$output .= " ";
|
||||
}
|
||||
|
||||
if (!$this->_cPager->isLastPage())
|
||||
{
|
||||
$img = new cHTMLImage("images/paging/next.gif");
|
||||
$link->setAlt(i18n("Next page"));
|
||||
$link->setContent($img);
|
||||
|
||||
switch ($item) {
|
||||
case "|": $output .= "...";
|
||||
break;
|
||||
case "current": $output .= '<span class="cpager_currentitem">' . $key . "</span>";
|
||||
break;
|
||||
default: $output .= $link->render();
|
||||
}
|
||||
|
||||
$output .= " ";
|
||||
}
|
||||
|
||||
if (!$this->_cPager->isLastPage()) {
|
||||
$img = new cHTMLImage("images/paging/next.gif");
|
||||
$link->setAlt(i18n("Next page"));
|
||||
$link->setContent($img);
|
||||
$link->setCustom($this->_parameterToAdd, $this->_cPager->_currentPage + 1);
|
||||
|
||||
$output .= $link->render();
|
||||
$output .= " ";
|
||||
|
||||
$img = new cHTMLImage("images/paging/last.gif");
|
||||
|
||||
|
||||
$output .= $link->render();
|
||||
$output .= " ";
|
||||
|
||||
$img = new cHTMLImage("images/paging/last.gif");
|
||||
|
||||
$link->setCustom($this->_parameterToAdd, $this->_cPager->getMaxPages());
|
||||
$link->setAlt(i18n("Last page"));
|
||||
$link->setContent($img);
|
||||
|
||||
$output .= $link->render();
|
||||
$output .= " ";
|
||||
} else {
|
||||
$output .= '<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->setClass("foldingrow_content");
|
||||
|
||||
$link->setAlt(i18n("Last page"));
|
||||
$link->setContent($img);
|
||||
|
||||
$output .= $link->render();
|
||||
$output .= " ";
|
||||
} else {
|
||||
$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->setClass("foldingrow_content");
|
||||
|
||||
#Do not display Page navigation if there is only one Page and we are not in newsletter section
|
||||
if ($this->_cPager->getMaxPages() == 1) {
|
||||
$output = '';
|
||||
}
|
||||
|
||||
$this->_contentData->setContent($output);
|
||||
|
||||
|
||||
$this->_contentData->setContent($output);
|
||||
|
||||
if ($bContentOnly) {
|
||||
return $output;
|
||||
} else {
|
||||
return cFoldingRow::render();
|
||||
return parent::render();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -164,179 +154,161 @@ class cObjectPager extends cFoldingRow
|
|||
*
|
||||
* @author Timo A. Hummel <timo.hummel@4fb.de>
|
||||
*/
|
||||
class cPager
|
||||
{
|
||||
/**
|
||||
* Amount of items
|
||||
class cPager {
|
||||
|
||||
/**
|
||||
* Amount of items
|
||||
* @var integer
|
||||
* @access private
|
||||
*/
|
||||
var $_items;
|
||||
|
||||
/**
|
||||
* Item padding (before and after the current item)
|
||||
*/
|
||||
var $_items;
|
||||
|
||||
/**
|
||||
* Item padding (before and after the current item)
|
||||
* @var integer
|
||||
* @access private
|
||||
*/
|
||||
var $_itemPadding;
|
||||
|
||||
/**
|
||||
* Items on the left side
|
||||
*/
|
||||
var $_itemPadding;
|
||||
|
||||
/**
|
||||
* Items on the left side
|
||||
* @var integer
|
||||
* @access private
|
||||
*/
|
||||
var $_previousItems;
|
||||
|
||||
/**
|
||||
* Items on the right side
|
||||
*/
|
||||
var $_previousItems;
|
||||
|
||||
/**
|
||||
* Items on the right side
|
||||
* @var integer
|
||||
* @access private
|
||||
*/
|
||||
var $_nextItems;
|
||||
|
||||
/**
|
||||
* Current page
|
||||
*/
|
||||
var $_nextItems;
|
||||
|
||||
/**
|
||||
* Current page
|
||||
* @var integer
|
||||
* @access private
|
||||
*/
|
||||
var $_currentPage;
|
||||
|
||||
/**
|
||||
* Items per page
|
||||
*/
|
||||
var $_currentPage;
|
||||
|
||||
/**
|
||||
* Items per page
|
||||
* @var integer
|
||||
* @access private
|
||||
*/
|
||||
var $_itemsPerPage;
|
||||
|
||||
/**
|
||||
*/
|
||||
var $_itemsPerPage;
|
||||
|
||||
/**
|
||||
* Constructor Function
|
||||
* Initializes the pager
|
||||
*
|
||||
* Initializes the pager
|
||||
*
|
||||
* @param $items int Amount of items
|
||||
* @param $itemsPerPage int Items displayed per page
|
||||
* @param $currentPage int Defines the current page
|
||||
*/
|
||||
function cPager ($items, $itemsPerPage, $currentPage)
|
||||
{
|
||||
|
||||
$this->_items = $items;
|
||||
$this->_itemsPerPage = $itemsPerPage;
|
||||
$this->_currentPage = $currentPage;
|
||||
|
||||
/* Default values. */
|
||||
$this->_itemPadding = 2;
|
||||
$this->_previousItems = 2;
|
||||
$this->_nextItems = 2;
|
||||
}
|
||||
* @param $itemsPerPage int Items displayed per page
|
||||
* @param $currentPage int Defines the current page
|
||||
*/
|
||||
function __construct($items, $itemsPerPage, $currentPage) {
|
||||
|
||||
/**
|
||||
$this->_items = $items;
|
||||
$this->_itemsPerPage = $itemsPerPage;
|
||||
$this->_currentPage = $currentPage;
|
||||
|
||||
/* Default values. */
|
||||
$this->_itemPadding = 2;
|
||||
$this->_previousItems = 2;
|
||||
$this->_nextItems = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the currentPage pointer is the first page.
|
||||
*
|
||||
* @return boolean True if we're on the first page.
|
||||
*/
|
||||
function isFirstPage ()
|
||||
{
|
||||
if ($this->_currentPage == 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
*
|
||||
* @return boolean True if we're on the first page.
|
||||
*/
|
||||
function isFirstPage() {
|
||||
if ($this->_currentPage == 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the currentPage pointer is the last page.
|
||||
*
|
||||
* @return boolean True if we're on the last page.
|
||||
*/
|
||||
function isLastPage ()
|
||||
{
|
||||
if ($this->_currentPage == $this->getMaxPages())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return boolean True if we're on the last page.
|
||||
*/
|
||||
function isLastPage() {
|
||||
if ($this->_currentPage == $this->getMaxPages()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of pages.
|
||||
*
|
||||
* @return int Page count
|
||||
*/
|
||||
function getMaxPages ()
|
||||
{
|
||||
if ($this->_items == 0){
|
||||
return 1;
|
||||
} else if ($this->_itemsPerPage == 0) {
|
||||
*
|
||||
* @return int Page count
|
||||
*/
|
||||
function getMaxPages() {
|
||||
if ($this->_items == 0) {
|
||||
return 1;
|
||||
} else if ($this->_itemsPerPage == 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return (ceil($this->_items / $this->_itemsPerPage));
|
||||
}
|
||||
}
|
||||
return (ceil($this->_items / $this->_itemsPerPage));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns an array with the pager structure.
|
||||
*
|
||||
* Array format:
|
||||
* Key : Page Number
|
||||
* Value: | for "...", "current" for the current item, page number otherwise
|
||||
*
|
||||
* @return array Pager structure
|
||||
*/
|
||||
function getPagesInRange ()
|
||||
{
|
||||
$items = array();
|
||||
*
|
||||
* Array format:
|
||||
* Key : Page Number
|
||||
* Value: | for "...", "current" for the current item, page number otherwise
|
||||
*
|
||||
* @return array Pager structure
|
||||
*/
|
||||
function getPagesInRange() {
|
||||
$items = array();
|
||||
|
||||
$maxPages = $this->getMaxPages();
|
||||
|
||||
if (($this->_itemPadding * 3) + $this->_previousItems + $this->_nextItems > $maxPages) {
|
||||
/* Disable item padding */
|
||||
for ($i = 1; $i < $this->getMaxPages() + 1; $i++) {
|
||||
$items[$i] = $i;
|
||||
}
|
||||
} else {
|
||||
for ($i = 1; $i < $this->_previousItems + 1; $i++) {
|
||||
if ($i <= $maxPages && $i >= 1) {
|
||||
$items[$i] = $i;
|
||||
}
|
||||
|
||||
if ($i + 1 <= $maxPages && $i >= 2) {
|
||||
$items[$i + 1] = "|";
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = $this->_currentPage - $this->_itemPadding; $i < $this->_currentPage + $this->_itemPadding + 1; $i++) {
|
||||
if ($i <= $maxPages && $i >= 1) {
|
||||
$items[$i] = $i;
|
||||
}
|
||||
|
||||
if ($i + 1 <= $maxPages && $i >= 2) {
|
||||
$items[$i + 1] = "|";
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = ($this->getMaxPages() - $this->_nextItems) + 1; $i < $this->getMaxPages() + 1; $i++) {
|
||||
if ($i <= $maxPages && $i >= 2) {
|
||||
$items[$i] = $i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$items[$this->_currentPage] = 'current';
|
||||
|
||||
return ($items);
|
||||
}
|
||||
|
||||
$maxPages = $this->getMaxPages();
|
||||
|
||||
if (($this->_itemPadding * 3) + $this->_previousItems + $this->_nextItems > $maxPages)
|
||||
{
|
||||
/* Disable item padding */
|
||||
for ($i = 1; $i < $this->getMaxPages() + 1; $i++)
|
||||
{
|
||||
$items[$i] = $i;
|
||||
}
|
||||
} else {
|
||||
for ($i=1;$i<$this->_previousItems+1; $i++)
|
||||
{
|
||||
if ($i <= $maxPages && $i >= 1)
|
||||
{
|
||||
$items[$i] = $i;
|
||||
}
|
||||
|
||||
if ($i+1 <= $maxPages && $i >= 2)
|
||||
{
|
||||
$items[$i+1] = "|";
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = $this->_currentPage - $this->_itemPadding; $i< $this->_currentPage + $this->_itemPadding + 1; $i++)
|
||||
{
|
||||
if ($i <= $maxPages && $i >= 1)
|
||||
{
|
||||
$items[$i] = $i;
|
||||
}
|
||||
|
||||
if ($i+1 <= $maxPages && $i >= 2)
|
||||
{
|
||||
$items[$i+1] = "|";
|
||||
}
|
||||
}
|
||||
|
||||
for ($i=($this->getMaxPages()-$this->_nextItems)+1; $i < $this->getMaxPages()+1; $i++)
|
||||
{
|
||||
if ($i <= $maxPages && $i >= 2)
|
||||
{
|
||||
$items[$i] = $i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$items[$this->_currentPage] = 'current';
|
||||
|
||||
return ($items);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -25,57 +26,51 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
class cSwitchableDateChooser extends cDateChooser {
|
||||
|
||||
class cSwitchableDateChooser extends cDateChooser
|
||||
{
|
||||
var $_oCheckBox;
|
||||
var $_bReadOnly;
|
||||
var $_bDisabled;
|
||||
|
||||
function cSwitchableDateChooser ($name, $initValue = false)
|
||||
{
|
||||
parent::cDateChooser($name, $initValue);
|
||||
|
||||
$this->_oCheckBox = new cHTMLCheckbox($this->getID()."_check", "true");
|
||||
$this->_oCheckBox->setLabelText("");
|
||||
|
||||
$this->_oCheckBox->setEvent("click", 'document.getElementById("'.$this->getId().'").disabled = !this.checked; var jstyle = document.getElementById("'.$this->getId().'"); if (this.checked) { jstyle.className = "textbox"; if (x_oldvalue_'.$this->getID().') { jstyle.value = x_oldvalue_'.$this->getID().';} document.getElementById("'.$this->_oImage->getId().'").style.visibility = "";} else { jstyle.className = "textbox_readonly"; x_oldvalue_'.$this->getID().' = jstyle.value; jstyle.value = ""; document.getElementById("'.$this->_oImage->getId().'").style.visibility = "hidden";}');
|
||||
|
||||
$this->enable();
|
||||
}
|
||||
|
||||
function disable ()
|
||||
{
|
||||
$this->_bDisabled = true;
|
||||
$this->setDisabled(true);
|
||||
$this->_oCheckBox->setChecked(false);
|
||||
$this->setClass("textbox_readonly");
|
||||
$this->_oImage->setStyle("margin-left: 2px; cursor: pointer; visibility: hidden;");
|
||||
}
|
||||
|
||||
function enable ()
|
||||
{
|
||||
$this->_bDisabled = false;
|
||||
$this->setDisabled(false);
|
||||
$this->_oCheckBox->setChecked(true);
|
||||
$this->setClass("textbox");
|
||||
}
|
||||
|
||||
function render ()
|
||||
{
|
||||
$sRender = parent::render();
|
||||
|
||||
$oAlignmentTable = new cHTMLAlignmentTable($this->_oCheckBox->toHtml(false), $sRender);
|
||||
|
||||
if ($this->_bDisabled)
|
||||
{
|
||||
$addscript ='document.getElementById("'.$this->getId().'").value = "";';
|
||||
}
|
||||
return $oAlignmentTable->render() . '<script language="JavaScript">'.$addscript.'x_oldvalue_'.$this->getID().' = "'.$this->_oDate->render().'";</script>';
|
||||
}
|
||||
}
|
||||
var $_oCheckBox;
|
||||
var $_bReadOnly;
|
||||
var $_bDisabled;
|
||||
|
||||
function __construct($name, $initValue = false) {
|
||||
parent::__construct($name, $initValue);
|
||||
|
||||
$this->_oCheckBox = new cHTMLCheckbox($this->getID() . "_check", "true");
|
||||
$this->_oCheckBox->setLabelText("");
|
||||
|
||||
$this->_oCheckBox->setEvent("click", 'document.getElementById("' . $this->getId() . '").disabled = !this.checked; var jstyle = document.getElementById("' . $this->getId() . '"); if (this.checked) { jstyle.className = "textbox"; if (x_oldvalue_' . $this->getID() . ') { jstyle.value = x_oldvalue_' . $this->getID() . ';} document.getElementById("' . $this->_oImage->getId() . '").style.visibility = "";} else { jstyle.className = "textbox_readonly"; x_oldvalue_' . $this->getID() . ' = jstyle.value; jstyle.value = ""; document.getElementById("' . $this->_oImage->getId() . '").style.visibility = "hidden";}');
|
||||
|
||||
$this->enable();
|
||||
}
|
||||
|
||||
function disable() {
|
||||
$this->_bDisabled = true;
|
||||
$this->setDisabled(true);
|
||||
$this->_oCheckBox->setChecked(false);
|
||||
$this->setClass("textbox_readonly");
|
||||
$this->_oImage->setStyle("margin-left: 2px; cursor: pointer; visibility: hidden;");
|
||||
}
|
||||
|
||||
function enable() {
|
||||
$this->_bDisabled = false;
|
||||
$this->setDisabled(false);
|
||||
$this->_oCheckBox->setChecked(true);
|
||||
$this->setClass("textbox");
|
||||
}
|
||||
|
||||
function render() {
|
||||
$sRender = parent::render();
|
||||
|
||||
$oAlignmentTable = new cHTMLAlignmentTable($this->_oCheckBox->toHtml(false), $sRender);
|
||||
|
||||
if ($this->_bDisabled) {
|
||||
$addscript = 'document.getElementById("' . $this->getId() . '").value = "";';
|
||||
}
|
||||
return $oAlignmentTable->render() . '<script language="JavaScript">' . $addscript . 'x_oldvalue_' . $this->getID() . ' = "' . $this->_oDate->render() . '";</script>';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -25,174 +26,158 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
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());
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,19 +1,20 @@
|
|||
<?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_DOTTED", "dotted");
|
||||
define("TREEVIEW_GRIDLINE_NONE" , "none");
|
||||
define("TREEVIEW_GRIDLINE_NONE", "none");
|
||||
|
||||
define("TREEVIEW_BACKGROUND_NONE", "none");
|
||||
define("TREEVIEW_BACKGROUND_SHADED", "shaded");
|
||||
|
@ -21,502 +22,467 @@ define("TREEVIEW_BACKGROUND_SHADED", "shaded");
|
|||
define("TREEVIEW_MOUSEOVER_NONE", "none");
|
||||
define("TREEVIEW_MOUSEOVER_MARK", "mark");
|
||||
|
||||
|
||||
/**
|
||||
* class cWidgetTreeView
|
||||
* cWidgetTreeView is a visual representation of a cTree. It supports folding,
|
||||
* optional gridline marks and item icons.
|
||||
*/
|
||||
class cWidgetTreeView extends cTree
|
||||
{
|
||||
class cWidgetTreeView extends cTree {
|
||||
/* * * Attributes: ** */
|
||||
|
||||
/*** Attributes: ***/
|
||||
/**
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
var $_globalActions;
|
||||
|
||||
/**
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
var $_globalActions;
|
||||
|
||||
/**
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
var $_setItemActions;
|
||||
|
||||
/**
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
var $_unsetItemActions;
|
||||
|
||||
/**
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
var $_setAttributeActions;
|
||||
|
||||
/**
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
var $_unsetAttributeActions;
|
||||
|
||||
|
||||
var $_baseLink;
|
||||
/**
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
var $_setItemActions;
|
||||
|
||||
/**
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
var $_unsetItemActions;
|
||||
|
||||
function cWidgetTreeView ($uuid, $treename = false)
|
||||
{
|
||||
global $cfg, $auth;
|
||||
|
||||
cTree::cTree();
|
||||
|
||||
$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
|
||||
/**
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
var $_setAttributeActions;
|
||||
|
||||
/**
|
||||
* removes the action from all treeitems.
|
||||
*
|
||||
* @param cApiClickableAction action Removes the action from the global context.
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function removeGlobalAction( $action )
|
||||
{
|
||||
|
||||
} // end of member function removeGlobalAction
|
||||
/**
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
var $_unsetAttributeActions;
|
||||
var $_baseLink;
|
||||
|
||||
/**
|
||||
* flushes all actions
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function flushGlobalActions( )
|
||||
{
|
||||
|
||||
} // end of member function flushGlobalActions
|
||||
function __construct($uuid, $treename = false) {
|
||||
global $cfg, $auth;
|
||||
|
||||
/**
|
||||
* sets an action to a specific item.
|
||||
*
|
||||
* @param mixed item cTreeItem-Object or an id of a TreeItem-Object
|
||||
* @param cApiClickableAction action
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function applyItemAction( $item, $action )
|
||||
{
|
||||
|
||||
} // end of member function applyItemAction
|
||||
parent::__construct();
|
||||
|
||||
/**
|
||||
* unsets an action from a specific item. Note that you can unset global actions
|
||||
* using this method!
|
||||
*
|
||||
* @param mixed item cTreeItem-Object or an id of a TreeItem-Object
|
||||
* @param cApiClickableAction action Action to unset
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function removeItemAction( $item, $action )
|
||||
{
|
||||
|
||||
} // end of member function removeItemAction
|
||||
$this->_uuid = $uuid;
|
||||
//$this->setGridlineMode(TREEVIEW_GRIDLINE_DOTTED);
|
||||
|
||||
/**
|
||||
* flushes all actions for a specific item
|
||||
*
|
||||
* @param mixed item cTreeItem-Object or an id of a TreeItem-Object
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function flushItemActions( $item )
|
||||
{
|
||||
|
||||
} // end of member function flushItemActions
|
||||
if ($treename != false) {
|
||||
$this->setTreeName($treename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies an action to all items with a certain attribute set.
|
||||
*
|
||||
* @param array attributes Values which need to match. The array key is the attribute name. Multiple array
|
||||
entries are connected with "AND".
|
||||
* @param cApiClickableAction action Action to apply
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function applyActionByItemAttribute( $attributes, $action )
|
||||
{
|
||||
|
||||
} // end of member function applyActionByItemAttribute
|
||||
$this->setBackgroundColors(array($cfg['color']['table_light'], $cfg['color']['table_dark']));
|
||||
|
||||
/**
|
||||
* Removes an action from all items with a certain attribute set.
|
||||
*
|
||||
* @param array attributes Values which need to match. The array key is the attribute name. Multiple array
|
||||
entries are connected with "AND".
|
||||
* @param cApiClickableAction action Action to remove
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function removeActionByItemAttribute( $attributes, $action )
|
||||
{
|
||||
|
||||
} // end of member function removeActionByItemAttribute
|
||||
$this->_user = new cApiUser($auth->auth["uid"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all actions for items with specific attributes
|
||||
*
|
||||
* @param array attributes Values which need to match. The array key is the attribute name. Multiple array
|
||||
entries are connected with "AND".
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function flushActionByItemAttribute( $attributes )
|
||||
{
|
||||
|
||||
} // end of member function flushActionByItemAttribute
|
||||
function processParameters() {
|
||||
if (($items = $this->_user->getUserProperty("expandstate", $this->_uuid)) !== false) {
|
||||
$list = unserialize($items);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param int mode Sets the gridline mode to one of the following values:
|
||||
* TREEVIEW_GRIDLINE_SOLID
|
||||
* TREEVIEW_GRIDLINE_DASHED
|
||||
* TREEVIEW_GRIDLINE_DOTTED
|
||||
* TREEVIEW_GRIDLINE_NONE
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function setGridlineMode( $mode )
|
||||
{
|
||||
$this->_gridlineMode = $mode;
|
||||
} // end of member function setGridlineMode
|
||||
foreach ($list as $litem) {
|
||||
$this->setCollapsed($litem);
|
||||
}
|
||||
}
|
||||
|
||||
function setBackgroundMode ($mode)
|
||||
{
|
||||
$this->_backgroundMode = $mode;
|
||||
}
|
||||
|
||||
function setMouseoverMode ($mode)
|
||||
{
|
||||
$this->_mouseoverMode = $mode;
|
||||
}
|
||||
|
||||
function setBackgroundColors ($colors)
|
||||
{
|
||||
$this->_backgroundColors = $colors;
|
||||
}
|
||||
if (!empty($this->_name)) {
|
||||
$treename = $this->_name . "_";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function render ($with_root = true)
|
||||
{
|
||||
if (array_key_exists($treename . "collapse", $_GET)) {
|
||||
$this->setCollapsed($_GET[$treename . "collapse"]);
|
||||
}
|
||||
|
||||
if (array_key_exists($treename . "expand", $_GET)) {
|
||||
$this->setExpanded($_GET[$treename . "expand"]);
|
||||
}
|
||||
|
||||
$xlist = array(); // Define variable before using it by reference...
|
||||
$this->getCollapsedList($xlist);
|
||||
$slist = serialize($xlist);
|
||||
|
||||
$this->_user->setUserProperty("expandstate", $this->_uuid, $slist);
|
||||
}
|
||||
|
||||
/**
|
||||
* applies an action to all items in the tree.
|
||||
*
|
||||
* @param cApiClickableAction action action object
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function applyGlobalAction($action) {
|
||||
|
||||
}
|
||||
|
||||
// end of member function applyGlobalAction
|
||||
|
||||
/**
|
||||
* removes the action from all treeitems.
|
||||
*
|
||||
* @param cApiClickableAction action Removes the action from the global context.
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function removeGlobalAction($action) {
|
||||
|
||||
}
|
||||
|
||||
// end of member function removeGlobalAction
|
||||
|
||||
/**
|
||||
* flushes all actions
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function flushGlobalActions() {
|
||||
|
||||
}
|
||||
|
||||
// end of member function flushGlobalActions
|
||||
|
||||
/**
|
||||
* sets an action to a specific item.
|
||||
*
|
||||
* @param mixed item cTreeItem-Object or an id of a TreeItem-Object
|
||||
* @param cApiClickableAction action
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function applyItemAction($item, $action) {
|
||||
|
||||
}
|
||||
|
||||
// end of member function applyItemAction
|
||||
|
||||
/**
|
||||
* unsets an action from a specific item. Note that you can unset global actions
|
||||
* using this method!
|
||||
*
|
||||
* @param mixed item cTreeItem-Object or an id of a TreeItem-Object
|
||||
* @param cApiClickableAction action Action to unset
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function removeItemAction($item, $action) {
|
||||
|
||||
}
|
||||
|
||||
// end of member function removeItemAction
|
||||
|
||||
/**
|
||||
* flushes all actions for a specific item
|
||||
*
|
||||
* @param mixed item cTreeItem-Object or an id of a TreeItem-Object
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function flushItemActions($item) {
|
||||
|
||||
}
|
||||
|
||||
// end of member function flushItemActions
|
||||
|
||||
/**
|
||||
* Applies an action to all items with a certain attribute set.
|
||||
*
|
||||
* @param array attributes Values which need to match. The array key is the attribute name. Multiple array
|
||||
entries are connected with "AND".
|
||||
* @param cApiClickableAction action Action to apply
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function applyActionByItemAttribute($attributes, $action) {
|
||||
|
||||
}
|
||||
|
||||
// end of member function applyActionByItemAttribute
|
||||
|
||||
/**
|
||||
* Removes an action from all items with a certain attribute set.
|
||||
*
|
||||
* @param array attributes Values which need to match. The array key is the attribute name. Multiple array
|
||||
entries are connected with "AND".
|
||||
* @param cApiClickableAction action Action to remove
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function removeActionByItemAttribute($attributes, $action) {
|
||||
|
||||
}
|
||||
|
||||
// end of member function removeActionByItemAttribute
|
||||
|
||||
/**
|
||||
* Removes all actions for items with specific attributes
|
||||
*
|
||||
* @param array attributes Values which need to match. The array key is the attribute name. Multiple array
|
||||
entries are connected with "AND".
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function flushActionByItemAttribute($attributes) {
|
||||
|
||||
}
|
||||
|
||||
// end of member function flushActionByItemAttribute
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param int mode Sets the gridline mode to one of the following values:
|
||||
* TREEVIEW_GRIDLINE_SOLID
|
||||
* TREEVIEW_GRIDLINE_DASHED
|
||||
* TREEVIEW_GRIDLINE_DOTTED
|
||||
* TREEVIEW_GRIDLINE_NONE
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function setGridlineMode($mode) {
|
||||
$this->_gridlineMode = $mode;
|
||||
}
|
||||
|
||||
// end of member function setGridlineMode
|
||||
|
||||
function setBackgroundMode($mode) {
|
||||
$this->_backgroundMode = $mode;
|
||||
}
|
||||
|
||||
function setMouseoverMode($mode) {
|
||||
$this->_mouseoverMode = $mode;
|
||||
}
|
||||
|
||||
function setBackgroundColors($colors) {
|
||||
$this->_backgroundColors = $colors;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function render($with_root = true) {
|
||||
$objects = $this->flatTraverse(0);
|
||||
|
||||
if ($with_root == false)
|
||||
{
|
||||
unset($objects[0]);
|
||||
}
|
||||
if ($with_root == false) {
|
||||
unset($objects[0]);
|
||||
}
|
||||
|
||||
$img = new cHTMLImage;
|
||||
$r_table = new cHTMLTable;
|
||||
$r_row = new cHTMLTableRow;
|
||||
$r_leftcell = new cHTMLTableData;
|
||||
$r_rightcell = new cHTMLTableData;
|
||||
$r_actioncell = new cHTMLTableData;
|
||||
|
||||
$img = new cHTMLImage;
|
||||
$r_table = new cHTMLTable;
|
||||
$r_row = new cHTMLTableRow;
|
||||
$r_leftcell = new cHTMLTableData;
|
||||
$r_rightcell = new cHTMLTableData;
|
||||
$r_actioncell = new cHTMLTableData;
|
||||
|
||||
$img_spacer = new cHTMLImage;
|
||||
$img_spacer->updateAttributes(array('width' => '16', 'height' => '20'));
|
||||
$img_spacer->setAlt("");
|
||||
$img_spacer->setSrc("images/spacer.gif");
|
||||
$img_spacer->advanceID();
|
||||
|
||||
$r_table->setCellPadding(0);
|
||||
$r_table->setCellSpacing(0);
|
||||
$r_table->setWidth("100%");
|
||||
$r_rightcell->setStyleDefinition("padding-left", "3px");
|
||||
$r_rightcell->setVerticalAlignment("middle");
|
||||
$r_leftcell->setVerticalAlignment("middle");
|
||||
$r_leftcell->updateAttributes(array("nowrap" => "nowrap"));
|
||||
$r_rightcell->updateAttributes(array("nowrap" => "nowrap"));
|
||||
$r_actioncell->updateAttributes(array("nowrap" => "nowrap"));
|
||||
$r_leftcell->setWidth("1%");
|
||||
$r_rightcell->setWidth("100%");
|
||||
$r_actioncell->setAlignment("right");
|
||||
$r_actioncell->setWidth("1%");
|
||||
|
||||
if (!is_object($this->_baseLink))
|
||||
{
|
||||
$this->_baseLink = new cHTMLLink;
|
||||
}
|
||||
|
||||
$lastitem = array();
|
||||
foreach ($objects as $key => $object)
|
||||
{
|
||||
$img->setAlt("");
|
||||
$r_table->advanceID();
|
||||
$r_rightcell->advanceID();
|
||||
$r_leftcell->advanceID();
|
||||
$r_row->advanceID();
|
||||
$r_actioncell->advanceID();
|
||||
|
||||
for ($level = 1; $level < $object->_level + 1; $level++)
|
||||
{
|
||||
if ($object->_level == $level)
|
||||
{
|
||||
if ($object->_next === false)
|
||||
{
|
||||
if (count($object->_subitems) > 0)
|
||||
{
|
||||
$link = $this->_setExpandCollapseLink($this->_baseLink, $object);
|
||||
$link->advanceID();
|
||||
$img->setSrc($this->_getExpandCollapseIcon($object));
|
||||
$img->advanceID();
|
||||
$link->setContent($img);
|
||||
$out .= $link->render();
|
||||
} else {
|
||||
if ($level == 1 && $with_root == false)
|
||||
{
|
||||
$out .= $img_spacer->render();
|
||||
} else {
|
||||
$img->setSrc($this->_buildImagePath("grid_linedownrightend.gif"));
|
||||
$img->advanceID();
|
||||
$out .= $img->render();
|
||||
}
|
||||
}
|
||||
$lastitem[$level] = true;
|
||||
} else {
|
||||
if (count($object->_subitems) > 0)
|
||||
{
|
||||
$link = $this->_setExpandCollapseLink($this->_baseLink, $object);
|
||||
$link->advanceID();
|
||||
$img->setSrc($this->_getExpandCollapseIcon($object));
|
||||
$img->advanceID();
|
||||
$link->setContent($img);
|
||||
$out .= $link->render();
|
||||
} else {
|
||||
if ($level == 1 && $with_root == false)
|
||||
{
|
||||
$out .= $img_spacer->render();
|
||||
} else {
|
||||
$img->setSrc($this->_buildImagePath("grid_linedownright.gif"));
|
||||
$out .= $img->render();
|
||||
}
|
||||
}
|
||||
|
||||
$lastitem[$level] = false;
|
||||
}
|
||||
} else {
|
||||
if ($lastitem[$level] == true)
|
||||
{
|
||||
$out .= $img_spacer->render();
|
||||
} else {
|
||||
if ($level == 1 && $with_root == false)
|
||||
{
|
||||
$out .= $img_spacer->render();
|
||||
} else {
|
||||
$img->setSrc($this->_buildImagePath("/grid_linedown.gif"));
|
||||
$img->advanceID();
|
||||
$out .= $img->render();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fetch Render icon from the meta object */
|
||||
if (is_object($object->payload))
|
||||
{
|
||||
/* Fetch payload object */
|
||||
$meta = $object->payload->getMetaObject();
|
||||
|
||||
if (is_object($meta))
|
||||
{
|
||||
$icon = $meta->getIcon();
|
||||
$actions = $meta->getActions();
|
||||
|
||||
$r_actioncell->setContent($actions);
|
||||
|
||||
$img->setAlt($meta->getDescription());
|
||||
$img->advanceID();
|
||||
|
||||
/* Check if we've got an edit link */
|
||||
if (count($meta->_editAction) > 0)
|
||||
{
|
||||
$meta->defineActions();
|
||||
|
||||
$edit = $meta->getAction($meta->_editAction);
|
||||
|
||||
$edit->setIcon($icon);
|
||||
|
||||
$renderedIcon = $edit->render();
|
||||
|
||||
$edit->_link->setContent($object->_name);
|
||||
$edit->_link->advanceID();
|
||||
$renderedName = $edit->_link->render();
|
||||
} else {
|
||||
$img->setSrc($icon);
|
||||
$renderedIcon = $img->render();
|
||||
$renderedName = $object->_name;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isset($object->_attributes["icon"]))
|
||||
{
|
||||
$img->setSrc($object->_attributes["icon"]);
|
||||
$renderedIcon = $img->render();
|
||||
$renderedName = $object->_name;
|
||||
} else {
|
||||
/* Fetch tree icon */
|
||||
if ($object->_id == 0)
|
||||
{
|
||||
$icon = $object->_treeIcon;
|
||||
$img->setSrc($icon);
|
||||
$renderedIcon = $img->render();
|
||||
$renderedName = $object->_name;
|
||||
} else {
|
||||
$icon = $object->_treeIcon;
|
||||
$img->setSrc($icon);
|
||||
$renderedIcon = $img->render();
|
||||
$renderedName = $object->_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
$img_spacer->advanceID();
|
||||
|
||||
if ($this->_backgroundMode == TREEVIEW_BACKGROUND_SHADED)
|
||||
{
|
||||
if (current($this->_backgroundColors) === false)
|
||||
{
|
||||
reset($this->_backgroundColors);
|
||||
}
|
||||
|
||||
$color = current($this->_backgroundColors);
|
||||
next($this->_backgroundColors);
|
||||
|
||||
$r_rightcell->setBackgroundColor($color);
|
||||
$r_leftcell->setBackgroundColor($color);
|
||||
$r_actioncell->setBackgroundColor($color);
|
||||
}
|
||||
|
||||
$img->setSrc($icon);
|
||||
$r_leftcell->setContent($out . $renderedIcon);
|
||||
$r_rightcell->setContent($renderedName);
|
||||
|
||||
$r_row->setContent(array($r_leftcell, $r_rightcell, $r_actioncell));
|
||||
|
||||
$r_table->setContent($r_row);
|
||||
$r_table->setCellPadding(0);
|
||||
$r_table->setCellSpacing(0);
|
||||
$r_table->setWidth("100%");
|
||||
$r_rightcell->setStyleDefinition("padding-left", "3px");
|
||||
$r_rightcell->setVerticalAlignment("middle");
|
||||
$r_leftcell->setVerticalAlignment("middle");
|
||||
$r_leftcell->updateAttributes(array("nowrap" => "nowrap"));
|
||||
$r_rightcell->updateAttributes(array("nowrap" => "nowrap"));
|
||||
$r_actioncell->updateAttributes(array("nowrap" => "nowrap"));
|
||||
$r_leftcell->setWidth("1%");
|
||||
$r_rightcell->setWidth("100%");
|
||||
$r_actioncell->setAlignment("right");
|
||||
$r_actioncell->setWidth("1%");
|
||||
|
||||
$result .= $r_table->render();
|
||||
|
||||
unset($out);
|
||||
if (!is_object($this->_baseLink)) {
|
||||
$this->_baseLink = new cHTMLLink;
|
||||
}
|
||||
|
||||
return ('<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;
|
||||
}
|
||||
$lastitem = array();
|
||||
foreach ($objects as $key => $object) {
|
||||
$img->setAlt("");
|
||||
$r_table->advanceID();
|
||||
$r_rightcell->advanceID();
|
||||
$r_leftcell->advanceID();
|
||||
$r_row->advanceID();
|
||||
$r_actioncell->advanceID();
|
||||
|
||||
for ($level = 1; $level < $object->_level + 1; $level++) {
|
||||
if ($object->_level == $level) {
|
||||
if ($object->_next === false) {
|
||||
if (count($object->_subitems) > 0) {
|
||||
$link = $this->_setExpandCollapseLink($this->_baseLink, $object);
|
||||
$link->advanceID();
|
||||
$img->setSrc($this->_getExpandCollapseIcon($object));
|
||||
$img->advanceID();
|
||||
$link->setContent($img);
|
||||
$out .= $link->render();
|
||||
} else {
|
||||
if ($level == 1 && $with_root == false) {
|
||||
$out .= $img_spacer->render();
|
||||
} else {
|
||||
$img->setSrc($this->_buildImagePath("grid_linedownrightend.gif"));
|
||||
$img->advanceID();
|
||||
$out .= $img->render();
|
||||
}
|
||||
}
|
||||
$lastitem[$level] = true;
|
||||
} else {
|
||||
if (count($object->_subitems) > 0) {
|
||||
$link = $this->_setExpandCollapseLink($this->_baseLink, $object);
|
||||
$link->advanceID();
|
||||
$img->setSrc($this->_getExpandCollapseIcon($object));
|
||||
$img->advanceID();
|
||||
$link->setContent($img);
|
||||
$out .= $link->render();
|
||||
} else {
|
||||
if ($level == 1 && $with_root == false) {
|
||||
$out .= $img_spacer->render();
|
||||
} else {
|
||||
$img->setSrc($this->_buildImagePath("grid_linedownright.gif"));
|
||||
$out .= $img->render();
|
||||
}
|
||||
}
|
||||
|
||||
} // end of cWidgetTreeView
|
||||
?>
|
||||
$lastitem[$level] = false;
|
||||
}
|
||||
} else {
|
||||
if ($lastitem[$level] == true) {
|
||||
$out .= $img_spacer->render();
|
||||
} else {
|
||||
if ($level == 1 && $with_root == false) {
|
||||
$out .= $img_spacer->render();
|
||||
} else {
|
||||
$img->setSrc($this->_buildImagePath("/grid_linedown.gif"));
|
||||
$img->advanceID();
|
||||
$out .= $img->render();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fetch Render icon from the meta object */
|
||||
if (is_object($object->payload)) {
|
||||
/* Fetch payload object */
|
||||
$meta = $object->payload->getMetaObject();
|
||||
|
||||
if (is_object($meta)) {
|
||||
$icon = $meta->getIcon();
|
||||
$actions = $meta->getActions();
|
||||
|
||||
$r_actioncell->setContent($actions);
|
||||
|
||||
$img->setAlt($meta->getDescription());
|
||||
$img->advanceID();
|
||||
|
||||
/* Check if we've got an edit link */
|
||||
if (count($meta->_editAction) > 0) {
|
||||
$meta->defineActions();
|
||||
|
||||
$edit = $meta->getAction($meta->_editAction);
|
||||
|
||||
$edit->setIcon($icon);
|
||||
|
||||
$renderedIcon = $edit->render();
|
||||
|
||||
$edit->_link->setContent($object->_name);
|
||||
$edit->_link->advanceID();
|
||||
$renderedName = $edit->_link->render();
|
||||
} else {
|
||||
$img->setSrc($icon);
|
||||
$renderedIcon = $img->render();
|
||||
$renderedName = $object->_name;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isset($object->_attributes["icon"])) {
|
||||
$img->setSrc($object->_attributes["icon"]);
|
||||
$renderedIcon = $img->render();
|
||||
$renderedName = $object->_name;
|
||||
} else {
|
||||
/* Fetch tree icon */
|
||||
if ($object->_id == 0) {
|
||||
$icon = $object->_treeIcon;
|
||||
$img->setSrc($icon);
|
||||
$renderedIcon = $img->render();
|
||||
$renderedName = $object->_name;
|
||||
} else {
|
||||
$icon = $object->_treeIcon;
|
||||
$img->setSrc($icon);
|
||||
$renderedIcon = $img->render();
|
||||
$renderedName = $object->_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_backgroundMode == TREEVIEW_BACKGROUND_SHADED) {
|
||||
if (current($this->_backgroundColors) === false) {
|
||||
reset($this->_backgroundColors);
|
||||
}
|
||||
|
||||
$color = current($this->_backgroundColors);
|
||||
next($this->_backgroundColors);
|
||||
|
||||
$r_rightcell->setBackgroundColor($color);
|
||||
$r_leftcell->setBackgroundColor($color);
|
||||
$r_actioncell->setBackgroundColor($color);
|
||||
}
|
||||
|
||||
$img->setSrc($icon);
|
||||
$r_leftcell->setContent($out . $renderedIcon);
|
||||
$r_rightcell->setContent($renderedName);
|
||||
|
||||
$r_row->setContent(array($r_leftcell, $r_rightcell, $r_actioncell));
|
||||
|
||||
$r_table->setContent($r_row);
|
||||
|
||||
$result .= $r_table->render();
|
||||
|
||||
unset($out);
|
||||
}
|
||||
|
||||
return ('<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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -26,271 +27,230 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Contenido Table view
|
||||
*
|
||||
* @author Timo A. Hummel <timo.hummel@4fb.de>
|
||||
*/
|
||||
class cTableView
|
||||
{
|
||||
var $items;
|
||||
var $captions;
|
||||
var $id;
|
||||
var $rownames;
|
||||
|
||||
var $formname;
|
||||
var $formmethod;
|
||||
var $formaction;
|
||||
var $formvars;
|
||||
|
||||
var $tableid;
|
||||
var $tablebordercolor;
|
||||
|
||||
var $header;
|
||||
var $cancelLink;
|
||||
var $submitjs;
|
||||
|
||||
|
||||
function UI_Table_Form ($name, $action = "", $method = "post")
|
||||
{
|
||||
global $sess, $cfg;
|
||||
|
||||
$this->formname = $name;
|
||||
|
||||
if ($action == "")
|
||||
{
|
||||
$this->formaction = "main.php";
|
||||
} else {
|
||||
$this->formaction = $action;
|
||||
}
|
||||
|
||||
$this->formmethod = $method;
|
||||
class cTableView {
|
||||
|
||||
$this->tableid = "";
|
||||
$this->tablebordercolor = $cfg['color']['table_border'];
|
||||
$this->setAccessKey('s');
|
||||
$this->custom = array();
|
||||
var $items;
|
||||
var $captions;
|
||||
var $id;
|
||||
var $rownames;
|
||||
var $formname;
|
||||
var $formmethod;
|
||||
var $formaction;
|
||||
var $formvars;
|
||||
var $tableid;
|
||||
var $tablebordercolor;
|
||||
var $header;
|
||||
var $cancelLink;
|
||||
var $submitjs;
|
||||
|
||||
$this->setActionButton("submit", "images/but_ok.gif", i18n("Save changes"), "s");
|
||||
|
||||
}
|
||||
|
||||
function setVar ($name, $value)
|
||||
{
|
||||
$this->formvars[$name] = $value;
|
||||
}
|
||||
|
||||
function add ($caption, $field, $rowname = "")
|
||||
{
|
||||
if (is_array($field))
|
||||
{
|
||||
|
||||
foreach ($field as $value)
|
||||
{
|
||||
if (is_object($value) && method_exists($value, "render"))
|
||||
{
|
||||
$n .= $value->render();
|
||||
} else {
|
||||
$n .= $value;
|
||||
}
|
||||
}
|
||||
|
||||
$field = $n;
|
||||
}
|
||||
if (is_object($field) && method_exists($field, "render"))
|
||||
{
|
||||
$n = $field->render();
|
||||
$field = $n;
|
||||
}
|
||||
if ($field == "")
|
||||
{
|
||||
$field = " ";
|
||||
}
|
||||
|
||||
if ($caption == "")
|
||||
{
|
||||
$caption = " ";
|
||||
}
|
||||
|
||||
$this->id++;
|
||||
$this->items[$this->id] = $field;
|
||||
$this->captions[$this->id] = $caption;
|
||||
|
||||
if ($rowname == "")
|
||||
{
|
||||
$rowname = $this->id;
|
||||
}
|
||||
|
||||
$this->rownames[$this->id] = $rowname;
|
||||
}
|
||||
function UI_Table_Form($name, $action = "", $method = "post") {
|
||||
global $sess, $cfg;
|
||||
|
||||
function addCancel ($link)
|
||||
{
|
||||
$this->cancelLink = $link;
|
||||
}
|
||||
|
||||
function addHeader ($header)
|
||||
{
|
||||
$this->header = $header;
|
||||
}
|
||||
|
||||
function setSubmitJS ($js)
|
||||
{
|
||||
$this->submitjs = $js;
|
||||
}
|
||||
|
||||
function setAccessKey ($key)
|
||||
{
|
||||
$this->accessKey = $key;
|
||||
}
|
||||
|
||||
function setActionEvent ($id, $event)
|
||||
{
|
||||
$this->custom[$id]["event"] = $event;
|
||||
}
|
||||
|
||||
function setActionButton ($id, $image, $description = "", $accesskey = false, $action = false)
|
||||
{
|
||||
$this->custom[$id]["image"] = $image;
|
||||
$this->custom[$id]["type"] = "actionsetter";
|
||||
$this->custom[$id]["action"] = $action;
|
||||
$this->custom[$id]["description"] = $description;
|
||||
$this->custom[$id]["accesskey"] = $accesskey;
|
||||
$this->custom[$id]["event"] = "";
|
||||
}
|
||||
|
||||
function unsetActionButton ($id)
|
||||
{
|
||||
unset($this->custom[$id]);
|
||||
}
|
||||
|
||||
|
||||
function render ($return = true)
|
||||
{
|
||||
global $sess, $cfg;
|
||||
|
||||
$tpl = new Template;
|
||||
|
||||
$extra = "";
|
||||
|
||||
|
||||
$form = '<form enctype="multipart/form-data" style="margin:0px" name="'.$this->formname.'" method="'.$this->formmethod.'" action="'.$this->formaction.'">'."\n";
|
||||
$this->formvars["contenido"] = $sess->id;
|
||||
|
||||
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"]);
|
||||
$this->formname = $name;
|
||||
|
||||
if ($action == "") {
|
||||
$this->formaction = "main.php";
|
||||
} else {
|
||||
$this->formaction = $action;
|
||||
}
|
||||
|
||||
$this->formmethod = $method;
|
||||
|
||||
$this->tableid = "";
|
||||
$this->tablebordercolor = $cfg['color']['table_border'];
|
||||
$this->setAccessKey('s');
|
||||
$this->custom = array();
|
||||
|
||||
$this->setActionButton("submit", "images/but_ok.gif", i18n("Save changes"), "s");
|
||||
}
|
||||
|
||||
function setVar($name, $value) {
|
||||
$this->formvars[$name] = $value;
|
||||
}
|
||||
|
||||
function add($caption, $field, $rowname = "") {
|
||||
if (is_array($field)) {
|
||||
|
||||
foreach ($field as $value) {
|
||||
if (is_object($value) && method_exists($value, "render")) {
|
||||
$n .= $value->render();
|
||||
} else {
|
||||
$n .= $value;
|
||||
}
|
||||
}
|
||||
|
||||
$field = $n;
|
||||
}
|
||||
if (is_object($field) && method_exists($field, "render")) {
|
||||
$n = $field->render();
|
||||
$field = $n;
|
||||
}
|
||||
if ($field == "") {
|
||||
$field = " ";
|
||||
}
|
||||
|
||||
if ($caption == "") {
|
||||
$caption = " ";
|
||||
}
|
||||
|
||||
$this->id++;
|
||||
$this->items[$this->id] = $field;
|
||||
$this->captions[$this->id] = $caption;
|
||||
|
||||
if ($rowname == "") {
|
||||
$rowname = $this->id;
|
||||
}
|
||||
|
||||
$this->rownames[$this->id] = $rowname;
|
||||
}
|
||||
|
||||
function addCancel($link) {
|
||||
$this->cancelLink = $link;
|
||||
}
|
||||
|
||||
function addHeader($header) {
|
||||
$this->header = $header;
|
||||
}
|
||||
|
||||
function setSubmitJS($js) {
|
||||
$this->submitjs = $js;
|
||||
}
|
||||
|
||||
function setAccessKey($key) {
|
||||
$this->accessKey = $key;
|
||||
}
|
||||
|
||||
function setActionEvent($id, $event) {
|
||||
$this->custom[$id]["event"] = $event;
|
||||
}
|
||||
|
||||
function setActionButton($id, $image, $description = "", $accesskey = false, $action = false) {
|
||||
$this->custom[$id]["image"] = $image;
|
||||
$this->custom[$id]["type"] = "actionsetter";
|
||||
$this->custom[$id]["action"] = $action;
|
||||
$this->custom[$id]["description"] = $description;
|
||||
$this->custom[$id]["accesskey"] = $accesskey;
|
||||
$this->custom[$id]["event"] = "";
|
||||
}
|
||||
|
||||
function unsetActionButton($id) {
|
||||
unset($this->custom[$id]);
|
||||
}
|
||||
|
||||
function render($return = true) {
|
||||
global $sess, $cfg;
|
||||
|
||||
$tpl = new Template;
|
||||
|
||||
$extra = "";
|
||||
|
||||
|
||||
$form = '<form enctype="multipart/form-data" style="margin:0px" name="' . $this->formname . '" method="' . $this->formmethod . '" action="' . $this->formaction . '">' . "\n";
|
||||
$this->formvars["contenido"] = $sess->id;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Laden…
In neuem Issue referenzieren