Dieser Commit ist enthalten in:
oldperl 2017-03-11 12:58:54 +00:00
Ursprung c92b578d39
Commit 8da8f2a18d
10 geänderte Dateien mit 2165 neuen und 2282 gelöschten Zeilen

Datei anzeigen

@ -1,15 +1,9 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
* *
* Description:
* CSV Handling class
*
* Requirements:
* @con_php_req 5.0
*
*
* @package Contenido Backend classes * @package Contenido Backend classes
* @version 1.0.4 * @version 1.0.4
* @author Timo A. Hummel * @author Timo A. Hummel
@ -19,43 +13,32 @@
* @link http://www.contenido.org * @link http://www.contenido.org
* @since file available since contenido release <= 4.6 * @since file available since contenido release <= 4.6
* *
* {@internal
* created unknown
* modified 2008-06-30, Dominik Ziegler, add security fix
*
* $Id: class.csv.php 214 2013-01-25 15:50:04Z oldperl $: * $Id: class.csv.php 214 2013-01-25 15:50:04Z oldperl $:
* }}
*
*/ */
if (!defined('CON_FRAMEWORK')) { if (!defined('CON_FRAMEWORK')) {
die('Illegal call'); die('Illegal call');
} }
class CSV class CSV {
{
var $_data = array(); var $_data = array();
var $_delimiter; var $_delimiter;
function CSV () public function __construct() {
{
$this->_delimiter = ";"; $this->_delimiter = ";";
} }
function setRow ($row) public function setRow($row) {
{
$args = func_num_args(); $args = func_num_args();
for ($arg=1;$arg<$args;$arg++) for ($arg = 1; $arg < $args; $arg++) {
{
$ma = func_get_arg($arg); $ma = func_get_arg($arg);
$this->setCell($row, $arg, $ma); $this->setCell($row, $arg, $ma);
} }
} }
function setCell($row, $cell, $data) public function setCell($row, $cell, $data) {
{
$row = Contenido_Security::escapeDB($row); $row = Contenido_Security::escapeDB($row);
$cell = Contenido_Security::escapeDB($cell); $cell = Contenido_Security::escapeDB($cell);
$data = Contenido_Security::escapeDB($data); $data = Contenido_Security::escapeDB($data);
@ -64,12 +47,11 @@ class CSV
$this->_data[$row][$cell] = '"' . $data . '"'; $this->_data[$row][$cell] = '"' . $data . '"';
} }
function setDelimiter ($delimiter) public function setDelimiter($delimiter) {
{
$this->_delimiter = $delimiter; $this->_delimiter = $delimiter;
} }
function make() { public function make() {
$out = ''; $out = '';
foreach ($this->_data as $row => $line) { foreach ($this->_data as $row => $line) {
$out .= implode($this->_delimiter, $line); $out .= implode($this->_delimiter, $line);

Datei anzeigen

@ -1,15 +1,9 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
* *
* Description:
* Root Driver for GenericDB
*
* Requirements:
* @con_php_req 5.0
*
*
* @package Contenido Backend classes * @package Contenido Backend classes
* @version 1.3 * @version 1.3
* @author Timo Hummel * @author Timo Hummel
@ -18,15 +12,8 @@
* @link http://www.4fb.de * @link http://www.4fb.de
* @link http://www.contenido.org * @link http://www.contenido.org
* *
* {@internal
* created 2005-08-29
* modified 2008-05-23 Added Debug_DevNull and Debug_VisibleAdv
*
* $Id: class.gdb.driver.php 2 2011-07-20 12:00:48Z oldperl $ * $Id: class.gdb.driver.php 2 2011-07-20 12:00:48Z oldperl $
* }}
*
*/ */
if (!defined('CON_FRAMEWORK')) { if (!defined('CON_FRAMEWORK')) {
die('Illegal call'); die('Illegal call');
} }
@ -36,26 +23,24 @@ class gdbDriver {
var $_sEncoding; var $_sEncoding;
var $_oItemClassInstance; var $_oItemClassInstance;
function gdbDriver() { public function __construct() {
} }
function setEncoding($sEncoding) { public function setEncoding($sEncoding) {
$this->_sEncoding = $sEncoding; $this->_sEncoding = $sEncoding;
} }
function setItemClassInstance($oInstance) { public function setItemClassInstance($oInstance) {
$this->_oItemClassInstance = $oInstance; $this->_oItemClassInstance = $oInstance;
} }
function buildJoinQuery($destinationTable, $destinationClass, $destinationPrimaryKey, $sourceClass, $primaryKey) { public function buildJoinQuery($destinationTable, $destinationClass, $destinationPrimaryKey, $sourceClass, $primaryKey) {
} }
function buildOperator($sField, $sOperator, $sRestriction) { public function buildOperator($sField, $sOperator, $sRestriction) {
} }
} }
?> ?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -27,7 +28,6 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) { if (!defined('CON_FRAMEWORK')) {
die('Illegal call'); die('Illegal call');
} }
@ -37,30 +37,24 @@ $properties = new PropertyCollection;
$db2 = new DB_ConLite; $db2 = new DB_ConLite;
if ($action == "client_new") if ($action == "client_new") {
{
$nextid = $db->nextid($cfg["tab"]["clients"]); $nextid = $db->nextid($cfg["tab"]["clients"]);
$idclient = $nextid; $idclient = $nextid;
$new = true; $new = true;
} }
if(!$perm->have_perm_area_action($area)) if (!$perm->have_perm_area_action($area)) {
{
$notification->displayNotification("error", i18n("Permission denied")); $notification->displayNotification("error", i18n("Permission denied"));
} else { } else {
if ( !isset($idclient) ) if (!isset($idclient)) {
{
$notification->displayNotification("error", i18n("No client ID passed")); $notification->displayNotification("error", i18n("No client ID passed"));
} else { } else {
if (($action == "client_edit") && ($perm->have_perm_area_action($area, $action))) if (($action == "client_edit") && ($perm->have_perm_area_action($area, $action))) {
{
$sNewNotification = ''; $sNewNotification = '';
if ($active != "1") if ($active != "1") {
{
$active = "0"; $active = "0";
} }
if ($new == true) if ($new == true) {
{
$sLangNotification = i18n('Notice: In order to use this client, you must create a new language for it.'); $sLangNotification = i18n('Notice: In order to use this client, you must create a new language for it.');
$sTarget = $sess->url('frameset.php?area=lang'); $sTarget = $sess->url('frameset.php?area=lang');
@ -68,13 +62,11 @@ if(!$perm->have_perm_area_action($area))
top.header.markActive(top.header.document.getElementById('sub_lang'));"; top.header.markActive(top.header.document.getElementById('sub_lang'));";
$sLangNotificationLink = sprintf(i18n('Please click %shere%s to create a new language.'), '<a href="javascript://" onclick="' . $sJsLink . '">', '</a>'); $sLangNotificationLink = sprintf(i18n('Please click %shere%s to create a new language.'), '<a href="javascript://" onclick="' . $sJsLink . '">', '</a>');
$sNewNotification = '<br>' . $sLangNotification . '<br>' . $sLangNotificationLink; $sNewNotification = '<br>' . $sLangNotification . '<br>' . $sLangNotificationLink;
if (substr($frontendpath, strlen($frontendpath)-1) != "/") if (substr($frontendpath, strlen($frontendpath) - 1) != "/") {
{
$frontendpath .= "/"; $frontendpath .= "/";
} }
if (substr($htmlpath, strlen($htmlpath)-1) != "/") if (substr($htmlpath, strlen($htmlpath) - 1) != "/") {
{
$htmlpath .= "/"; $htmlpath .= "/";
} }
@ -132,20 +124,16 @@ if(!$perm->have_perm_area_action($area))
rereadClients(); rereadClients();
} else { } else {
$pathwithoutslash = $frontendpath; $pathwithoutslash = $frontendpath;
if (substr($frontendpath, strlen($frontendpath)-1) != "/") if (substr($frontendpath, strlen($frontendpath) - 1) != "/") {
{
$frontendpath .= "/"; $frontendpath .= "/";
} }
if (substr($htmlpath, strlen($htmlpath)-1) != "/") if (substr($htmlpath, strlen($htmlpath) - 1) != "/") {
{
$htmlpath .= "/"; $htmlpath .= "/";
} }
if (($oldpath != $frontendpath) && ($oldpath != $pathwithoutslash)) if (($oldpath != $frontendpath) && ($oldpath != $pathwithoutslash)) {
{
$notification->displayNotification("warning", i18n("You changed the client path. You might need to copy the frontend to the new location")); $notification->displayNotification("warning", i18n("You changed the client path. You might need to copy the frontend to the new location"));
} }
$sql = "UPDATE $sql = "UPDATE
" . $cfg["tab"]["clients"] . " " . $cfg["tab"]["clients"] . "
@ -228,8 +216,7 @@ if(!$perm->have_perm_area_action($area))
$tpl->set('s', 'CANCELTEXT', i18n("Discard changes")); $tpl->set('s', 'CANCELTEXT', i18n("Discard changes"));
$tpl->set('s', 'CANCELLINK', $sess->url("main.php?area=$area&frame=4&idclient=$idclient")); $tpl->set('s', 'CANCELLINK', $sess->url("main.php?area=$area&frame=4&idclient=$idclient"));
if ($error) if ($error) {
{
echo $error; echo $error;
} }
@ -253,8 +240,7 @@ if(!$perm->have_perm_area_action($area))
$serverpath = $db->f("frontendpath"); $serverpath = $db->f("frontendpath");
if ($serverpath == "") if ($serverpath == "") {
{
$serverpath = $cfg['path']['frontend']; $serverpath = $cfg['path']['frontend'];
} }
@ -269,8 +255,7 @@ if(!$perm->have_perm_area_action($area))
$htmlpath = $db->f("htmlpath"); $htmlpath = $db->f("htmlpath");
if ($htmlpath == "") if ($htmlpath == "") {
{
$htmlpath = "http://"; $htmlpath = "http://";
} }
@ -319,9 +304,10 @@ if(!$perm->have_perm_area_action($area))
$cApiClient = new cApiClient; $cApiClient = new cApiClient;
$cApiClient->loadByPrimaryKey($idclient); $cApiClient->loadByPrimaryKey($idclient);
if ($cApiClient->getProperty("generator", "xhtml") == "true") { var_dump($cApiClient->getProperty("generator", "xhtml"));
if ($cApiClient->getProperty("generator", "xhtml") === TRUE) {
$oXHTMLSelect->setDefault("xhtml"); $oXHTMLSelect->setDefault("xhtml");
} else if ($cApiClient->getProperty("generator", "html5") == "true") { } else if ($cApiClient->getProperty("generator", "html5") === TRUE) {
$oXHTMLSelect->setDefault("html5"); $oXHTMLSelect->setDefault("html5");
} else { } else {
$oXHTMLSelect->setDefault("html"); $oXHTMLSelect->setDefault("html");
@ -336,8 +322,7 @@ if(!$perm->have_perm_area_action($area))
$tpl->set('d', 'FONT', 'text_medium'); $tpl->set('d', 'FONT', 'text_medium');
$tpl->next(); $tpl->next();
if ($new == true) if ($new == true) {
{
$tpl->set('d', 'CATNAME', i18n("Copy frontend template")); $tpl->set('d', 'CATNAME', i18n("Copy frontend template"));
$tpl->set('d', 'BGCOLOR', $cfg["color"]["table_light"]); $tpl->set('d', 'BGCOLOR', $cfg["color"]["table_light"]);
$tpl->set('d', "BORDERCOLOR", $cfg["color"]["table_border"]); $tpl->set('d', "BORDERCOLOR", $cfg["color"]["table_border"]);

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -31,7 +32,6 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) { if (!defined('CON_FRAMEWORK')) {
die('Illegal call'); die('Illegal call');
} }
@ -49,14 +49,13 @@ class pApiContentAllocation {
var $table = null; var $table = null;
var $lang = null; var $lang = null;
var $client = null; var $client = null;
var $treeObj = null; var $treeObj = null;
/** /**
* *
* @modified 27.10.2005 new class variable $this->bDebug (if true print debug information) * @modified 27.10.2005 new class variable $this->bDebug (if true print debug information)
*/ */
function pApiContentAllocation () { public function __construct() {
global $db, $cfg, $lang, $client; global $db, $cfg, $lang, $client;
$this->db = new DB_ConLite; $this->db = new DB_ConLite;
@ -123,7 +122,6 @@ class pApiContentAllocation {
if ($firstonly) { if ($firstonly) {
break; break;
} }
} }
return $tmp; return $tmp;
@ -135,9 +133,10 @@ class pApiContentAllocation {
* @return string SQL * @return string SQL
* @modified 17.11.2005 by Willi Man * @modified 17.11.2005 by Willi Man
*/ */
function findMatchingContent ($restrictions = null, $max = 0) function findMatchingContent($restrictions = null, $max = 0) {
{ if (!is_array($restrictions)) {
if (!is_array($restrictions)) { return false; } return false;
}
global $aCategoriesToExclude; # @see config.local.php! global $aCategoriesToExclude; # @see config.local.php!
$sql = $this->_buildQuery($restrictions, $aCategoriesToExclude, $max); $sql = $this->_buildQuery($restrictions, $aCategoriesToExclude, $max);
@ -173,8 +172,7 @@ class pApiContentAllocation {
} else { } else {
$tables[] = " LEFT JOIN " . $cfg['tab']['pica_alloc_con'] . " AS " . $sql_concat[$i] . " USING (idartlang)"; $tables[] = " LEFT JOIN " . $cfg['tab']['pica_alloc_con'] . " AS " . $sql_concat[$i] . " USING (idartlang)";
} }
if (is_int((int)$restrictions[$i]) AND $restrictions[$i] > 0) if (is_int((int) $restrictions[$i]) AND $restrictions[$i] > 0) {
{
$where[] = $sql_concat[$i] . ".idpica_alloc = " . $restrictions[$i]; $where[] = $sql_concat[$i] . ".idpica_alloc = " . $restrictions[$i];
} }
} }
@ -183,8 +181,7 @@ class pApiContentAllocation {
$where[] = 'cal.online = 1'; $where[] = 'cal.online = 1';
# fetch only articles which are not in following categories # fetch only articles which are not in following categories
if (count($aCategoriesToExclude) > 0) if (count($aCategoriesToExclude) > 0) {
{
$where[] = "cat.idcat NOT IN (" . implode(',', $aCategoriesToExclude) . ")"; $where[] = "cat.idcat NOT IN (" . implode(',', $aCategoriesToExclude) . ")";
} }
@ -205,7 +202,11 @@ class pApiContentAllocation {
$sql .= " LIMIT " . $max; $sql .= " LIMIT " . $max;
} }
if ($this->bDebug) {print "<!-- "; print $sql; print " -->";} # @modified 27.10.2005 if ($this->bDebug) {
print "<!-- ";
print $sql;
print " -->";
} # @modified 27.10.2005
return $sql; return $sql;
} }
@ -217,22 +218,19 @@ class pApiContentAllocation {
* *
* @return array of articles * @return array of articles
*/ */
function findMatchingContentByContentAllocationByCategories ($aContentAllocation, $aCategories = array(), $iOffset = 0, $iNumOfRows = 0) function findMatchingContentByContentAllocationByCategories($aContentAllocation, $aCategories = array(), $iOffset = 0, $iNumOfRows = 0) {
{ if (!is_array($aContentAllocation)) {
if (!is_array($aContentAllocation)) { return array(); } return array();
}
for ($i = 0; $i < count($aContentAllocation); $i++) for ($i = 0; $i < count($aContentAllocation); $i++) {
{ if (!is_int((int) $aContentAllocation[$i]) OR ! $aContentAllocation[$i] > 0) {
if (!is_int((int)$aContentAllocation[$i]) OR !$aContentAllocation[$i] > 0)
{
return array(); return array();
} }
} }
for ($i = 0; $i < count($aCategories); $i++) for ($i = 0; $i < count($aCategories); $i++) {
{ if (!is_int((int) $aCategories[$i]) OR ! $aCategories[$i] > 0) {
if (!is_int((int)$aCategories[$i]) OR !$aCategories[$i] > 0)
{
return array(); return array();
} }
} }
@ -242,12 +240,10 @@ class pApiContentAllocation {
$this->db->query($sql); $this->db->query($sql);
$aResult = array(); $aResult = array();
while($oRow = $this->db->getResultObject()) while ($oRow = $this->db->getResultObject()) {
{
$aResult[] = $oRow; $aResult[] = $oRow;
} }
return $aResult; return $aResult;
} }
/** /**
@ -267,16 +263,13 @@ class pApiContentAllocation {
$tables = array(); $tables = array();
$where = array(); $where = array();
for ($i = 0; $i < $size; $i++) for ($i = 0; $i < $size; $i++) {
{ if ($i == 0) { // first
if ($i == 0)
{ // first
$tables[] = " " . $cfg['tab']['pica_alloc_con'] . " AS " . $sql_concat[$i]; $tables[] = " " . $cfg['tab']['pica_alloc_con'] . " AS " . $sql_concat[$i];
} else { } else {
$tables[] = " LEFT JOIN " . $cfg['tab']['pica_alloc_con'] . " AS " . $sql_concat[$i] . " USING (idartlang)"; $tables[] = " LEFT JOIN " . $cfg['tab']['pica_alloc_con'] . " AS " . $sql_concat[$i] . " USING (idartlang)";
} }
if (is_int((int)$aContentAllocation[$i]) AND $aContentAllocation[$i] > 0) if (is_int((int) $aContentAllocation[$i]) AND $aContentAllocation[$i] > 0) {
{
$where[] = $sql_concat[$i] . ".idpica_alloc = " . $aContentAllocation[$i]; $where[] = $sql_concat[$i] . ".idpica_alloc = " . $aContentAllocation[$i];
} }
} }
@ -285,8 +278,7 @@ class pApiContentAllocation {
$where[] = 'cal.online = 1'; $where[] = 'cal.online = 1';
# fetch only articles in following categories # fetch only articles in following categories
if (count($aCategories) > 0) if (count($aCategories) > 0) {
{
$where[] = "cat.idcat IN (" . implode(',', $aCategories) . ")"; $where[] = "cat.idcat IN (" . implode(',', $aCategories) . ")";
} }
@ -303,12 +295,15 @@ class pApiContentAllocation {
$sql .= " ORDER BY cal.published DESC"; $sql .= " ORDER BY cal.published DESC";
if (is_integer($iNumOfRows) AND $iNumOfRows > 0) if (is_integer($iNumOfRows) AND $iNumOfRows > 0) {
{
$sql .= " LIMIT " . $iOffset . ", " . $iNumOfRows; $sql .= " LIMIT " . $iOffset . ", " . $iNumOfRows;
} }
if ($this->bDebug) {print "<!-- "; print $sql; print " -->";} # @modified 27.10.2005 if ($this->bDebug) {
print "<!-- ";
print $sql;
print " -->";
} # @modified 27.10.2005
return $sql; return $sql;
} }
@ -322,13 +317,10 @@ class pApiContentAllocation {
* *
* @return array of articles * @return array of articles
*/ */
function findMatchingContentByCategories ($aCategories = array(), $iOffset = 0, $iNumOfRows = 0, $sResultType = '') function findMatchingContentByCategories($aCategories = array(), $iOffset = 0, $iNumOfRows = 0, $sResultType = '') {
{
for ($i = 0; $i < count($aCategories); $i++) for ($i = 0; $i < count($aCategories); $i++) {
{ if (!is_int((int) $aCategories[$i]) OR ! $aCategories[$i] > 0) {
if (!is_int((int)$aCategories[$i]) OR !$aCategories[$i] > 0)
{
return array(); return array();
} }
} }
@ -339,39 +331,30 @@ class pApiContentAllocation {
$aResult = array(); $aResult = array();
while($oRow = $this->db->getResultObject()) while ($oRow = $this->db->getResultObject()) {
{ if ($sResultType == 'article_language_id') {
if ($sResultType == 'article_language_id')
{
$aResult[] = $oRow->idartlang; $aResult[] = $oRow->idartlang;
}else } else {
{
$aResult[] = $oRow; $aResult[] = $oRow;
} }
} }
return $aResult; return $aResult;
} }
/** /**
* build SQL query to find articles by catgories * build SQL query to find articles by catgories
* *
*/ */
function _buildQuery_MatchingContentByCategories ($aCategories, $iOffset, $iNumOfRows) function _buildQuery_MatchingContentByCategories($aCategories, $iOffset, $iNumOfRows) {
{
if (count($aCategories) > 0) if (count($aCategories) > 0) {
{
$sWHERE_Category_IN = " c.idcat IN (" . implode(',', $aCategories) . ") AND "; $sWHERE_Category_IN = " c.idcat IN (" . implode(',', $aCategories) . ") AND ";
}else } else {
{
$sWHERE_Category_IN = ''; $sWHERE_Category_IN = '';
} }
if (is_integer($iNumOfRows) AND $iNumOfRows > 0) if (is_integer($iNumOfRows) AND $iNumOfRows > 0) {
{
$sLimit = " LIMIT " . Contenido_Security::toInteger($iOffset) . ", " . Contenido_Security::toInteger($iNumOfRows); $sLimit = " LIMIT " . Contenido_Security::toInteger($iOffset) . ", " . Contenido_Security::toInteger($iNumOfRows);
}else } else {
{
$sLimit = ''; $sLimit = '';
} }
@ -394,7 +377,11 @@ class pApiContentAllocation {
a.idart = b.idart a.idart = b.idart
' . $sLimit . ' '; ' . $sLimit . ' ';
if ($this->bDebug) {print "<!-- "; print $sql; print " -->";} if ($this->bDebug) {
print "<!-- ";
print $sql;
print " -->";
}
return $sql; return $sql;
} }

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -27,7 +28,6 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) { if (!defined('CON_FRAMEWORK')) {
die('Illegal call'); die('Illegal call');
} }
@ -36,10 +36,9 @@ class pApiContentAllocationArticle extends pApiTree {
var $tpl = null; var $tpl = null;
var $template = ''; var $template = '';
var $load = array(); var $load = array();
function pApiContentAllocationArticle ($uuid) { public function __construct($uuid) {
global $cfg; global $cfg;
parent::pApiTree($uuid); parent::pApiTree($uuid);
@ -112,6 +111,7 @@ class pApiContentAllocationArticle extends pApiTree {
$this->tpl->generate($this->template); $this->tpl->generate($this->template);
} }
} }
} }
?> ?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -27,7 +28,6 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) { if (!defined('CON_FRAMEWORK')) {
die('Illegal call'); die('Illegal call');
} }
@ -37,12 +37,12 @@ class pApiContentAllocationComplexList extends pApiTree {
var $idSetter = true; var $idSetter = true;
var $load = array(); var $load = array();
function pApiContentAllocationComplexList ($uuid) { public function __construct($uuid) {
global $cfg; global $cfg;
parent::pApiTree($uuid); parent::pApiTree($uuid);
} }
function _buildRenderTree ($tree) { public function _buildRenderTree($tree) {
global $action, $frame, $area, $sess, $idart; global $action, $frame, $area, $sess, $idart;
$oldIdSetter = $this->idSetter; $oldIdSetter = $this->idSetter;
@ -93,11 +93,11 @@ class pApiContentAllocationComplexList extends pApiTree {
} }
} }
function setChecked($load) { public function setChecked($load) {
$this->load = $load; $this->load = $load;
} }
function renderTree ($return = true) { public function renderTree($return = true) {
$tree = $this->fetchTree(); $tree = $this->fetchTree();
if ($tree === false) { if ($tree === false) {
return false; return false;
@ -109,5 +109,4 @@ class pApiContentAllocationComplexList extends pApiTree {
} }
} }
} }
?> ?>

Datei anzeigen

@ -1,15 +1,9 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
* *
* Description:
* Render selectbox witzh complete content allocation tree
*
* Requirements:
* @con_php_req 5.0
*
*
* @package Contenido Backend plugins * @package Contenido Backend plugins
* @version 0.2.1 * @version 0.2.1
* @author Marco Jahn * @author Marco Jahn
@ -19,15 +13,8 @@
* @link http://www.contenido.org * @link http://www.contenido.org
* @since file available since contenido release <= 4.6 * @since file available since contenido release <= 4.6
* *
* {@internal
* created unknown
* modified 2008-07-02, Frederic Schneider, add security fix
*
* $Id: class.content_allocation_selectbox.php 2 2011-07-20 12:00:48Z oldperl $: * $Id: class.content_allocation_selectbox.php 2 2011-07-20 12:00:48Z oldperl $:
* }}
*
*/ */
if (!defined('CON_FRAMEWORK')) { if (!defined('CON_FRAMEWORK')) {
die('Illegal call'); die('Illegal call');
} }
@ -37,13 +24,13 @@ class pApiContentAllocationSelectBox extends pApiTree {
var $idSetter = true; var $idSetter = true;
var $load = array(); var $load = array();
function pApiContentAllocationComplexList ($uuid) { public function __construct($uuid) {
global $cfg; global $cfg;
parent::pApiTree($uuid); parent::pApiTree($uuid);
} }
function _buildRenderTree ($tree) { public function _buildRenderTree($tree) {
global $action, $frame, $area, $sess, $idart; global $action, $frame, $area, $sess, $idart;
$oldIdSetter = $this->idSetter; $oldIdSetter = $this->idSetter;
@ -70,7 +57,7 @@ class pApiContentAllocationSelectBox extends pApiTree {
return $result; return $result;
} }
function setChecked($load) { public function setChecked($load) {
return false; return false;
} }
@ -78,7 +65,7 @@ class pApiContentAllocationSelectBox extends pApiTree {
* *
* @modified 27.10.2005 $bUseTreeStatus = false (content allocation tree in selectbox is always expanded) * @modified 27.10.2005 $bUseTreeStatus = false (content allocation tree in selectbox is always expanded)
*/ */
function renderTree ($return = true, $parentId = false, $bUseTreeStatus = false) { public function renderTree($return = true, $parentId = false, $bUseTreeStatus = false) {
$tree = $this->fetchTree($parentId, 0, $bUseTreeStatus); $tree = $this->fetchTree($parentId, 0, $bUseTreeStatus);
@ -94,6 +81,7 @@ class pApiContentAllocationSelectBox extends pApiTree {
echo $tree; echo $tree;
} }
} }
} }
?> ?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -27,7 +28,6 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) { if (!defined('CON_FRAMEWORK')) {
die('Illegal call'); die('Illegal call');
} }
@ -94,7 +94,7 @@ class pApiTree {
*/ */
var $_arrOutFilters = array('stripslashes', 'htmldecode', 'urldecode'); var $_arrOutFilters = array('stripslashes', 'htmldecode', 'urldecode');
function pApiTree ($uuid) { public function __construct($uuid) {
global $db, $cfg, $lang, $client, $auth; global $db, $cfg, $lang, $client, $auth;
$this->db = new DB_ConLite; $this->db = new DB_ConLite;
@ -140,10 +140,8 @@ class pApiTree {
$itemStatus = 'expanded'; $itemStatus = 'expanded';
if ($bUseTreeStatus) # modified 27.10.2005 if ($bUseTreeStatus) { # modified 27.10.2005
{ if (is_array($this->treeStatus) && array_key_exists($this->db->f('idpica_alloc'), $this->treeStatus)) {
if (is_array($this->treeStatus) && array_key_exists($this->db->f('idpica_alloc'), $this->treeStatus))
{
$itemStatus = 'collapsed'; $itemStatus = 'collapsed';
} }
} }
@ -172,8 +170,7 @@ class pApiTree {
array_push($result, $rs); array_push($result, $rs);
} }
return $result; return $result;
} else } else {
{
return false; return false;
} }
} }
@ -204,19 +201,25 @@ class pApiTree {
$sql .= " ORDER BY sortorder ASC"; $sql .= " ORDER BY sortorder ASC";
if ($this->bDebug) {print "<!-- "; print $sql; print " -->";} if ($this->bDebug) {
print "<!-- ";
print $sql;
print " -->";
}
$this->db->query($sql); $this->db->query($sql);
$result_tmp = array(); // tmp result array $result_tmp = array(); // tmp result array
while ($this->db->next_record()) { // walk resultset while ($this->db->next_record()) { // walk resultset
$item = $this->_fetchItemNameLang($this->db->f('idpica_alloc')); $item = $this->_fetchItemNameLang($this->db->f('idpica_alloc'));
if ($this->bDebug) {print "<!-- "; print_r($item); print " -->";} if ($this->bDebug) {
print "<!-- ";
print_r($item);
print " -->";
}
if ($showOffline OR $item['online'] == 1) if ($showOffline OR $item['online'] == 1) {
{
$rs = array( $rs = array(
'idpica_alloc' => $this->db->f('idpica_alloc') 'idpica_alloc' => $this->db->f('idpica_alloc')
); );
@ -235,8 +238,7 @@ class pApiTree {
array_push($result, $rs); array_push($result, $rs);
} }
return $result; return $result;
} else } else {
{
return false; return false;
} }
} }
@ -268,7 +270,9 @@ class pApiTree {
} }
} }
function fetchParents () {} function fetchParents() {
}
function fetchLevel($parentId = false, $showOffline = false) { function fetchLevel($parentId = false, $showOffline = false) {
// fetch current lang category // fetch current lang category
@ -341,7 +345,6 @@ class pApiTree {
VALUES VALUES
(" . Contenido_Security::toInteger($treeItem['idpica_alloc']) . ", " . Contenido_Security::toInteger($this->lang) . ", '" . Contenido_Security::escapeDB($treeItem['name'], $this->db) . "')"; (" . Contenido_Security::toInteger($treeItem['idpica_alloc']) . ", " . Contenido_Security::toInteger($this->lang) . ", '" . Contenido_Security::escapeDB($treeItem['name'], $this->db) . "')";
$this->db->query($sql); $this->db->query($sql);
} else { // update } else { // update
$treeItem['name'] = $this->_inFilter($treeItem['name']); $treeItem['name'] = $this->_inFilter($treeItem['name']);
@ -406,7 +409,9 @@ class pApiTree {
$this->db->query($sql); $this->db->query($sql);
} }
function itemMoveDown () {} function itemMoveDown() {
}
function deleteItem($idpica_alloc) { function deleteItem($idpica_alloc) {
$sql = "DELETE FROM " . $this->table['pica_alloc'] . " WHERE idpica_alloc = " . Contenido_Security::toInteger($idpica_alloc); $sql = "DELETE FROM " . $this->table['pica_alloc'] . " WHERE idpica_alloc = " . Contenido_Security::toInteger($idpica_alloc);
@ -448,17 +453,14 @@ class pApiTree {
$aResult = array(); $aResult = array();
if ($oDB->next_record()) { // item found for this language if ($oDB->next_record()) { // item found for this language
$aResult['name'] = $this->_outFilter($oDB->f('name')); $aResult['name'] = $this->_outFilter($oDB->f('name'));
$aResult['idlang'] = $oDB->f('idlang'); $aResult['idlang'] = $oDB->f('idlang');
$aResult['online'] = $oDB->f('online'); $aResult['online'] = $oDB->f('online');
} else { // no item in this language found } else { // no item in this language found
// fetch alternative language name // fetch alternative language name
// HerrB, 2008-04-21: Get all translations, try to use defaultLang translation, use // HerrB, 2008-04-21: Get all translations, try to use defaultLang translation, use
// first available, otherwise. Only using defaultLang results in "ghost" elements, if // first available, otherwise. Only using defaultLang results in "ghost" elements, if
// created in a non-default language. See CON-110 for details. // created in a non-default language. See CON-110 for details.
$sSQL = "SELECT name, idlang, online FROM " . $this->table['pica_lang'] . " WHERE idpica_alloc = " . Contenido_Security::toInteger($idpica_alloc) . " ORDER BY idlang"; $sSQL = "SELECT name, idlang, online FROM " . $this->table['pica_lang'] . " WHERE idpica_alloc = " . Contenido_Security::toInteger($idpica_alloc) . " ORDER BY idlang";
$oDB->query($sSQL); $oDB->query($sSQL);
@ -526,18 +528,14 @@ class pApiTree {
$this->db->query($sql); $this->db->query($sql);
} }
function setFilters($arrInFilters = array(), $arrOutFilters = array()) function setFilters($arrInFilters = array(), $arrOutFilters = array()) {
{
$this->_arrInFilters = $arrInFilters; $this->_arrInFilters = $arrInFilters;
$this->_arrOutFilters = $arrOutFilters; $this->_arrOutFilters = $arrOutFilters;
} }
function _inFilter($data) function _inFilter($data) {
{ foreach ($this->_arrInFilters as $_function) {
foreach ($this->_arrInFilters as $_function) if (function_exists($_function)) {
{
if (function_exists($_function))
{
$data = $_function($data); $data = $_function($data);
} }
} }
@ -545,18 +543,16 @@ class pApiTree {
return $data; return $data;
} }
function _outFilter($data) function _outFilter($data) {
{ foreach ($this->_arrOutFilters as $_function) {
foreach ($this->_arrOutFilters as $_function) if (function_exists($_function)) {
{
if (function_exists($_function))
{
$data = $_function($data); $data = $_function($data);
} }
} }
return $data; return $data;
} }
} }
?> ?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -28,7 +29,6 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) { if (!defined('CON_FRAMEWORK')) {
die('Illegal call'); die('Illegal call');
} }
@ -38,7 +38,6 @@ if(!defined('CON_FRAMEWORK')) {
* - generalize this and papitree !!!! * - generalize this and papitree !!!!
* - Comments! * - Comments!
*/ */
class pApiContentAllocationTreeView extends pApiTree { class pApiContentAllocationTreeView extends pApiTree {
/** /**
@ -54,7 +53,7 @@ class pApiContentAllocationTreeView extends pApiTree {
/** /**
* *
*/ */
function pApiContentAllocationTreeView ($uuid) { public function __construct($uuid) {
global $cfg; global $cfg;
parent::pApiTree($uuid); parent::pApiTree($uuid);
@ -229,6 +228,7 @@ class pApiContentAllocationTreeView extends pApiTree {
$this->tpl->generate($this->template); $this->tpl->generate($this->template);
} }
} }
} }
?> ?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* file FrontendNavigation.php * file FrontendNavigation.php
* *
@ -8,14 +9,12 @@
* @created 25.03.2005 * @created 25.03.2005
* @modified 22.11.2005 * @modified 22.11.2005
*/ */
class FrontendNavigation {
class FrontendNavigation
{
/** /**
* Constructor * Constructor
*/ */
function FrontendNavigation($db, $cfg, $cfgClient, $client, $lang) public function __construct($db, $cfg, $cfgClient, $client, $lang) {
{
$this->_bDebug = false; $this->_bDebug = false;
$this->db = &$db; $this->db = &$db;
$this->cfgClient = &$cfgClient; $this->cfgClient = &$cfgClient;
@ -27,10 +26,8 @@ class FrontendNavigation
/** /**
* Get child categories by given parent category * Get child categories by given parent category
*/ */
function getSubCategories($iParentCategory) public function getSubCategories($iParentCategory) {
{ if (!is_int((int) $iParentCategory) AND $iParentCategory < 0 AND ! is_array($this->cfg) AND ! isset($this->cfg['tab']) AND ! is_int((int) $this->client) AND $this->client < 0 AND ! is_int((int) $this->lang) AND $this->lang < 0) {
if (!is_int((int)$iParentCategory) AND $iParentCategory < 0 AND !is_array($this->cfg) AND !isset($this->cfg['tab']) AND !is_int((int)$this->client) AND $this->client < 0 AND !is_int((int)$this->lang) AND $this->lang < 0)
{
return array(); return array();
} }
@ -51,13 +48,16 @@ class FrontendNavigation
ORDER BY ORDER BY
A.idtree "; A.idtree ";
if ($this->_bDebug) {echo "<pre>"; print_r($sql); echo "</pre>";} if ($this->_bDebug) {
echo "<pre>";
print_r($sql);
echo "</pre>";
}
$this->db->query($sql); $this->db->query($sql);
$navigation = array(); $navigation = array();
while ( $this->db->next_record() ) while ($this->db->next_record()) {
{
$navigation[] = $this->db->f("idcat"); $navigation[] = $this->db->f("idcat");
}# end while }# end while
@ -67,10 +67,8 @@ class FrontendNavigation
/** /**
* Check if child categories of a given parent category exist * Check if child categories of a given parent category exist
*/ */
function hasChildren($iParentCategory) public function hasChildren($iParentCategory) {
{ if (!is_int((int) $iParentCategory) AND $iParentCategory < 0 AND ! is_array($this->cfg) AND ! isset($this->cfg['tab']) AND ! is_int((int) $this->client) AND $this->client < 0 AND ! is_int((int) $this->lang) AND $this->lang < 0) {
if (!is_int((int)$iParentCategory) AND $iParentCategory < 0 AND !is_array($this->cfg) AND !isset($this->cfg['tab']) AND !is_int((int)$this->client) AND $this->client < 0 AND !is_int((int)$this->lang) AND $this->lang < 0)
{
return false; return false;
} }
@ -87,15 +85,17 @@ class FrontendNavigation
C.public = 1 AND C.public = 1 AND
B.parentid = " . $iParentCategory . " "; B.parentid = " . $iParentCategory . " ";
if ($this->_bDebug) {echo "<pre>"; print_r($sql); echo "</pre>";} if ($this->_bDebug) {
echo "<pre>";
print_r($sql);
echo "</pre>";
}
$this->db->query($sql); $this->db->query($sql);
if ( $this->db->next_record() ) if ($this->db->next_record()) {
{
return true; return true;
}else } else {
{
return false; return false;
} }
} }
@ -105,10 +105,8 @@ class FrontendNavigation
* Note: does not work if direct successor (with preid 0) is not visible * Note: does not work if direct successor (with preid 0) is not visible
* or not public * or not public
*/ */
function getSuccessor($iCategory) public function getSuccessor($iCategory) {
{ if (!is_int((int) $iCategory) AND $iCategory < 0 AND ! is_array($this->cfg) AND ! isset($this->cfg['tab']) AND ! is_int((int) $this->client) AND $this->client < 0 AND ! is_int((int) $this->lang) AND $this->lang < 0) {
if (!is_int((int)$iCategory) AND $iCategory < 0 AND !is_array($this->cfg) AND !isset($this->cfg['tab']) AND !is_int((int)$this->client) AND $this->client < 0 AND !is_int((int)$this->lang) AND $this->lang < 0)
{
return -1; return -1;
} }
@ -126,15 +124,17 @@ class FrontendNavigation
B.preid = 0 AND B.preid = 0 AND
B.parentid = " . $iCategory . " "; B.parentid = " . $iCategory . " ";
if ($this->_bDebug) {echo "<pre>"; print_r($sql); echo "</pre>";} if ($this->_bDebug) {
echo "<pre>";
print_r($sql);
echo "</pre>";
}
$this->db->query($sql); $this->db->query($sql);
if ( $this->db->next_record() ) if ($this->db->next_record()) {
{
return $this->db->f("idcat"); return $this->db->f("idcat");
}else } else {
{
return -1; return -1;
} }
} }
@ -142,10 +142,8 @@ class FrontendNavigation
/** /**
* Check if a given category has a direct successor * Check if a given category has a direct successor
*/ */
function hasSuccessor($iCategory) function hasSuccessor($iCategory) {
{ if (!is_int((int) $iCategory) AND $iCategory < 0 AND ! is_array($this->cfg) AND ! isset($this->cfg['tab']) AND ! is_int((int) $this->client) AND $this->client < 0 AND ! is_int((int) $this->lang) AND $this->lang < 0) {
if (!is_int((int)$iCategory) AND $iCategory < 0 AND !is_array($this->cfg) AND !isset($this->cfg['tab']) AND !is_int((int)$this->client) AND $this->client < 0 AND !is_int((int)$this->lang) AND $this->lang < 0)
{
return false; return false;
} }
@ -163,27 +161,26 @@ class FrontendNavigation
B.preid = 0 AND B.preid = 0 AND
B.parentid = " . $iCategory . " "; B.parentid = " . $iCategory . " ";
if ($this->_bDebug) {echo "<pre>"; print_r($sql); echo "</pre>";} if ($this->_bDebug) {
echo "<pre>";
print_r($sql);
echo "</pre>";
}
$this->db->query($sql); $this->db->query($sql);
if ( $this->db->next_record() ) if ($this->db->next_record()) {
{
return true; return true;
}else } else {
{
return false; return false;
} }
} }
/** /**
* Get category name * Get category name
*/ */
function getCategoryName($cat_id) function getCategoryName($cat_id) {
{ if (!is_int((int) $cat_id) AND $cat_id < 0 AND ! is_array($this->cfg) AND ! isset($this->cfg['tab']) AND ! is_int((int) $this->client) AND $this->client < 0 AND ! is_int((int) $this->lang) AND $this->lang < 0) {
if (!is_int((int)$cat_id) AND $cat_id < 0 AND !is_array($this->cfg) AND !isset($this->cfg['tab']) AND !is_int((int)$this->client) AND $this->client < 0 AND !is_int((int)$this->lang) AND $this->lang < 0)
{
return ''; return '';
} }
@ -199,15 +196,17 @@ class FrontendNavigation
B.idlang = " . $this->lang . " B.idlang = " . $this->lang . "
"; ";
if ($this->_bDebug) {echo "<pre>"; print_r($sql); echo "</pre>";} if ($this->_bDebug) {
echo "<pre>";
print_r($sql);
echo "</pre>";
}
$this->db->query($sql); $this->db->query($sql);
if ($this->db->next_record()) if ($this->db->next_record()) {
{
return $this->db->f("name"); return $this->db->f("name");
}else } else {
{
return ''; return '';
} }
} }
@ -215,10 +214,8 @@ class FrontendNavigation
/** /**
* Get category urlname * Get category urlname
*/ */
function getCategoryURLName($cat_id) function getCategoryURLName($cat_id) {
{ if (!is_int((int) $cat_id) AND $cat_id < 0 AND ! is_array($this->cfg) AND ! isset($this->cfg['tab']) AND ! is_int((int) $this->client) AND $this->client < 0 AND ! is_int((int) $this->lang) AND $this->lang < 0) {
if (!is_int((int)$cat_id) AND $cat_id < 0 AND !is_array($this->cfg) AND !isset($this->cfg['tab']) AND !is_int((int)$this->client) AND $this->client < 0 AND !is_int((int)$this->lang) AND $this->lang < 0)
{
return ''; return '';
} }
@ -234,15 +231,17 @@ class FrontendNavigation
B.idlang = " . $this->lang . " B.idlang = " . $this->lang . "
"; ";
if ($this->_bDebug) {echo "<pre>"; print_r($sql); echo "</pre>";} if ($this->_bDebug) {
echo "<pre>";
print_r($sql);
echo "</pre>";
}
$this->db->query($sql); $this->db->query($sql);
if ($this->db->next_record()) if ($this->db->next_record()) {
{
return $this->db->f("urlname"); return $this->db->f("urlname");
}else } else {
{
return ''; return '';
} }
} }
@ -250,10 +249,8 @@ class FrontendNavigation
/** /**
* Check if category is visible * Check if category is visible
*/ */
function isVisible($cat_id) function isVisible($cat_id) {
{ if (!is_int((int) $cat_id) AND $cat_id < 0 AND ! is_array($this->cfg) AND ! isset($this->cfg['tab']) AND ! is_int((int) $this->client) AND $this->client < 0 AND ! is_int((int) $this->lang) AND $this->lang < 0) {
if (!is_int((int)$cat_id) AND $cat_id < 0 AND !is_array($this->cfg) AND !isset($this->cfg['tab']) AND !is_int((int)$this->client) AND $this->client < 0 AND !is_int((int)$this->lang) AND $this->lang < 0)
{
return false; return false;
} }
@ -269,16 +266,18 @@ class FrontendNavigation
B.idlang = " . $this->lang . " B.idlang = " . $this->lang . "
"; ";
if ($this->_bDebug) {echo "<pre>"; print_r($sql); echo "</pre>";} if ($this->_bDebug) {
echo "<pre>";
print_r($sql);
echo "</pre>";
}
$this->db->query($sql); $this->db->query($sql);
$this->db->next_record(); $this->db->next_record();
if ($this->db->f("visible") == 1) if ($this->db->f("visible") == 1) {
{
return true; return true;
}else } else {
{
return false; return false;
} }
} }
@ -286,10 +285,8 @@ class FrontendNavigation
/** /**
* Check if category is public * Check if category is public
*/ */
function isPublic($cat_id) function isPublic($cat_id) {
{ if (!is_int((int) $cat_id) AND $cat_id < 0 AND ! is_array($this->cfg) AND ! isset($this->cfg['tab']) AND ! is_int((int) $this->client) AND $this->client < 0 AND ! is_int((int) $this->lang) AND $this->lang < 0) {
if (!is_int((int)$cat_id) AND $cat_id < 0 AND !is_array($this->cfg) AND !isset($this->cfg['tab']) AND !is_int((int)$this->client) AND $this->client < 0 AND !is_int((int)$this->lang) AND $this->lang < 0)
{
return false; return false;
} }
@ -305,16 +302,18 @@ class FrontendNavigation
B.idlang = " . $this->lang . " B.idlang = " . $this->lang . "
"; ";
if ($this->_bDebug) {echo "<pre>"; print_r($sql); echo "</pre>";} if ($this->_bDebug) {
echo "<pre>";
print_r($sql);
echo "</pre>";
}
$this->db->query($sql); $this->db->query($sql);
$this->db->next_record(); $this->db->next_record();
if ($this->db->f("public") == 1) if ($this->db->f("public") == 1) {
{
return true; return true;
}else } else {
{
return false; return false;
} }
} }
@ -322,10 +321,8 @@ class FrontendNavigation
/** /**
* Return true if $parentid is parent of $catid * Return true if $parentid is parent of $catid
*/ */
function isParent($parentid, $catid) function isParent($parentid, $catid) {
{ if (!is_int((int) $parentid) AND $parentid < 0 AND ! is_int((int) $catid) AND $catid < 0 AND ! is_array($this->cfg) AND ! isset($this->cfg['tab']) AND ! is_int((int) $this->client) AND $this->client < 0 AND ! is_int((int) $this->lang) AND $this->lang < 0) {
if (!is_int((int)$parentid) AND $parentid < 0 AND !is_int((int)$catid) AND $catid < 0 AND !is_array($this->cfg) AND !isset($this->cfg['tab']) AND !is_int((int)$this->client) AND $this->client < 0 AND !is_int((int)$this->lang) AND $this->lang < 0)
{
return false; return false;
} }
@ -343,15 +340,17 @@ class FrontendNavigation
$this->db->query($sql); $this->db->query($sql);
$this->db->next_record(); $this->db->next_record();
if ($this->_bDebug) {echo "<pre>"; print_r($sql); echo "</pre>";} if ($this->_bDebug) {
echo "<pre>";
print_r($sql);
echo "</pre>";
}
$pre = $this->db->f("parentid"); $pre = $this->db->f("parentid");
if($parentid == $pre) if ($parentid == $pre) {
{
return true; return true;
}else } else {
{
return false; return false;
} }
} }
@ -359,10 +358,8 @@ class FrontendNavigation
/** /**
* Get parent id of a category * Get parent id of a category
*/ */
function getParent($preid) function getParent($preid) {
{ if (!is_int((int) $preid) AND $preid < 0 AND ! is_array($this->cfg) AND ! isset($this->cfg['tab']) AND ! is_int((int) $this->client) AND $this->client < 0 AND ! is_int((int) $this->lang) AND $this->lang < 0) {
if (!is_int((int)$preid) AND $preid < 0 AND !is_array($this->cfg) AND !isset($this->cfg['tab']) AND !is_int((int)$this->client) AND $this->client < 0 AND !is_int((int)$this->lang) AND $this->lang < 0)
{
return -1; return -1;
} }
@ -379,13 +376,15 @@ class FrontendNavigation
$this->db->query($sql); $this->db->query($sql);
if ($this->_bDebug) {echo "<pre>"; print_r($sql); echo "</pre>";} if ($this->_bDebug) {
echo "<pre>";
print_r($sql);
echo "</pre>";
}
if ($this->db->next_record()) if ($this->db->next_record()) {
{
return $this->db->f("parentid"); return $this->db->f("parentid");
}else } else {
{
return -1; return -1;
} }
} }
@ -393,10 +392,8 @@ class FrontendNavigation
/** /**
* Check if a category has a parent * Check if a category has a parent
*/ */
function hasParent($preid) function hasParent($preid) {
{ if (!is_int((int) $preid) AND $preid < 0 AND ! is_array($this->cfg) AND ! isset($this->cfg['tab']) AND ! is_int((int) $this->client) AND $this->client < 0 AND ! is_int((int) $this->lang) AND $this->lang < 0) {
if (!is_int((int)$preid) AND $preid < 0 AND !is_array($this->cfg) AND !isset($this->cfg['tab']) AND !is_int((int)$this->client) AND $this->client < 0 AND !is_int((int)$this->lang) AND $this->lang < 0)
{
return false; return false;
} }
@ -413,13 +410,15 @@ class FrontendNavigation
$this->db->query($sql); $this->db->query($sql);
if ($this->_bDebug) {echo "<pre>"; print_r($sql); echo "</pre>";} if ($this->_bDebug) {
echo "<pre>";
print_r($sql);
echo "</pre>";
}
if ($this->db->next_record()) if ($this->db->next_record()) {
{
return true; return true;
}else } else {
{
return false; return false;
} }
} }
@ -427,10 +426,8 @@ class FrontendNavigation
/** /**
* Get level of a category * Get level of a category
*/ */
function getLevel($catid) function getLevel($catid) {
{ if (!is_int((int) $catid) AND $catid < 0 AND ! is_array($this->cfg) AND ! isset($this->cfg['tab']) AND ! is_int((int) $this->client) AND $this->client < 0 AND ! is_int((int) $this->lang) AND $this->lang < 0) {
if (!is_int((int)$catid) AND $catid < 0 AND !is_array($this->cfg) AND !isset($this->cfg['tab']) AND !is_int((int)$this->client) AND $this->client < 0 AND !is_int((int)$this->lang) AND $this->lang < 0)
{
return -1; return -1;
} }
@ -443,13 +440,15 @@ class FrontendNavigation
$this->db->query($sql); $this->db->query($sql);
if ($this->_bDebug) {echo "<pre>"; print_r($sql); echo "</pre>";} if ($this->_bDebug) {
echo "<pre>";
print_r($sql);
echo "</pre>";
}
if ($this->db->next_record()) if ($this->db->next_record()) {
{
return $this->db->f("level"); return $this->db->f("level");
}else } else {
{
return -1; return -1;
} }
} }
@ -465,30 +464,22 @@ class FrontendNavigation
* @author Willi Man * @author Willi Man
* @access public * @access public
*/ */
function getFrontContentUrl($iIdcat, $iIdart, $bAbsolute = true) function getFrontContentUrl($iIdcat, $iIdart, $bAbsolute = true) {
{ if (!is_int((int) $iIdcat) AND $iIdcat < 0) {
if (!is_int((int)$iIdcat) AND $iIdcat < 0)
{
return ''; return '';
} }
if ($bAbsolute === true) if ($bAbsolute === true) {
{
# add absolute web path to urlpath # add absolute web path to urlpath
if (is_int((int)$iIdart) AND $iIdart > 0) if (is_int((int) $iIdart) AND $iIdart > 0) {
{
$sURL = $this->cfgClient[$this->client]['path']['htmlpath'] . 'front_content.php?idcat=' . $iIdcat . '&idart=' . $iIdart; $sURL = $this->cfgClient[$this->client]['path']['htmlpath'] . 'front_content.php?idcat=' . $iIdcat . '&idart=' . $iIdart;
}else } else {
{
$sURL = $this->cfgClient[$this->client]['path']['htmlpath'] . 'front_content.php?idcat=' . $iIdcat; $sURL = $this->cfgClient[$this->client]['path']['htmlpath'] . 'front_content.php?idcat=' . $iIdcat;
} }
}else } else {
{ if (is_int((int) $iIdart) AND $iIdart > 0) {
if (is_int((int)$iIdart) AND $iIdart > 0)
{
$sURL = 'front_content.php?idcat=' . $iIdcat . '&idart=' . $iIdart; $sURL = 'front_content.php?idcat=' . $iIdcat . '&idart=' . $iIdart;
}else } else {
{
$sURL = 'front_content.php?idcat=' . $iIdcat; $sURL = 'front_content.php?idcat=' . $iIdcat;
} }
} }
@ -510,39 +501,30 @@ class FrontendNavigation
* @modified by Willi Man * @modified by Willi Man
* @access public * @access public
*/ */
function getUrlPath($iIdcat, $iIdart, $bAbsolute = true, $iLevel = 0, $sURL_SUFFIX = 'index.html') function getUrlPath($iIdcat, $iIdart, $bAbsolute = true, $iLevel = 0, $sURL_SUFFIX = 'index.html') {
{ if (!is_int((int) $iIdcat) AND $iIdcat < 0) {
if (!is_int((int)$iIdcat) AND $iIdcat < 0)
{
return ''; return '';
} }
$cat_str = ''; $cat_str = '';
prCreateURLNameLocationString($iIdcat, "/", $cat_str, false, "", $iLevel, $this->lang, true, false); prCreateURLNameLocationString($iIdcat, "/", $cat_str, false, "", $iLevel, $this->lang, true, false);
if (strlen($cat_str) <= 1) if (strlen($cat_str) <= 1) {
{
# return empty string if no url location is available # return empty string if no url location is available
return ''; return '';
} }
if ($bAbsolute === true) if ($bAbsolute === true) {
{
# add absolute web path to urlpath # add absolute web path to urlpath
if (is_int((int)$iIdart) AND $iIdart > 0) if (is_int((int) $iIdart) AND $iIdart > 0) {
{
return $this->cfgClient[$this->client]['path']['htmlpath'] . $cat_str . '/index-d-' . $iIdart . '.html'; return $this->cfgClient[$this->client]['path']['htmlpath'] . $cat_str . '/index-d-' . $iIdart . '.html';
}else } else {
{
return $this->cfgClient[$this->client]['path']['htmlpath'] . $cat_str . '/' . $sURL_SUFFIX; return $this->cfgClient[$this->client]['path']['htmlpath'] . $cat_str . '/' . $sURL_SUFFIX;
} }
}else } else {
{ if (is_int((int) $iIdart) AND $iIdart > 0) {
if (is_int((int)$iIdart) AND $iIdart > 0)
{
return $cat_str . '/index-d-' . $iIdart . '.html'; return $cat_str . '/index-d-' . $iIdart . '.html';
}else } else {
{
return $cat_str . '/' . $sURL_SUFFIX; return $cat_str . '/' . $sURL_SUFFIX;
} }
} }
@ -561,33 +543,26 @@ class FrontendNavigation
* *
* @access public * @access public
*/ */
function getUrlPathGenParam($iIdcat, $iSelectedNumber, $bAbsolute = true, $iLevel = 0) function getUrlPathGenParam($iIdcat, $iSelectedNumber, $bAbsolute = true, $iLevel = 0) {
{ if (!is_int((int) $iIdcat) AND $iIdcat < 0) {
if (!is_int((int)$iIdcat) AND $iIdcat < 0)
{
return ''; return '';
} }
$cat_str = ''; $cat_str = '';
prCreateURLNameLocationString($iIdcat, "/", $cat_str, false, "", $iLevel, $this->lang, true, false); prCreateURLNameLocationString($iIdcat, "/", $cat_str, false, "", $iLevel, $this->lang, true, false);
if (strlen($cat_str) <= 1) if (strlen($cat_str) <= 1) {
{
# return empty string if no url location is available # return empty string if no url location is available
return ''; return '';
} }
if ($bAbsolute === true) if ($bAbsolute === true) {
{
# add absolute web path to urlpath # add absolute web path to urlpath
if (is_int((int)$iSelectedNumber)) if (is_int((int) $iSelectedNumber)) {
{
return $this->cfgClient[$this->client]['path']['htmlpath'] . $cat_str . '/index-g-' . $iSelectedNumber . '.html'; return $this->cfgClient[$this->client]['path']['htmlpath'] . $cat_str . '/index-g-' . $iSelectedNumber . '.html';
} }
}else } else {
{ if (is_int((int) $iSelectedNumber)) {
if (is_int((int)$iSelectedNumber))
{
return $cat_str . '/index-g-' . $iSelectedNumber . '.html'; return $cat_str . '/index-g-' . $iSelectedNumber . '.html';
} }
} }
@ -604,17 +579,14 @@ class FrontendNavigation
* @author Willi Man * @author Willi Man
* @access public * @access public
*/ */
function getURL($iIdcat, $iIdart, $sType = '', $bAbsolute = true, $iLevel = 0) function getURL($iIdcat, $iIdart, $sType = '', $bAbsolute = true, $iLevel = 0) {
{ if (!is_int((int) $iIdcat) AND $iIdcat < 0) {
if (!is_int((int)$iIdcat) AND $iIdcat < 0)
{
return ''; return '';
} }
#print "type ".$sType."<br>"; #print "type ".$sType."<br>";
switch ($sType) switch ($sType) {
{
case 'urlpath': case 'urlpath':
$sURL = $this->getUrlPath($iIdcat, $iIdart, $bAbsolute, $iLevel); $sURL = $this->getUrlPath($iIdcat, $iIdart, $bAbsolute, $iLevel);
break; break;
@ -641,11 +613,12 @@ class FrontendNavigation
* @param int $iArticleId * @param int $iArticleId
* @return int category id * @return int category id
*/ */
function getCategoryOfArticle ($iArticleId) function getCategoryOfArticle($iArticleId) {
{
# validate input # validate input
if (!is_int((int)$iArticleId) OR $iArticleId <= 0) { return -1; } if (!is_int((int) $iArticleId) OR $iArticleId <= 0) {
return -1;
}
$sqlString = ' $sqlString = '
SELECT SELECT
@ -661,23 +634,23 @@ class FrontendNavigation
b.idart = c.idart AND b.idart = c.idart AND
a.idart = b.idart '; a.idart = b.idart ';
if ($this->_bDebug) {echo "<pre>".$sqlString."</pre>";} if ($this->_bDebug) {
echo "<pre>" . $sqlString . "</pre>";
}
$this->db->query($sqlString); $this->db->query($sqlString);
# $this->db->Errno returns 0 (zero) if no error occurred. # $this->db->Errno returns 0 (zero) if no error occurred.
if ($this->db->Errno == 0) if ($this->db->Errno == 0) {
{ if ($this->db->next_record()) {
if ($this->db->next_record())
{
return $this->db->f('idcat'); return $this->db->f('idcat');
}else } else {
{
return -1; return -1;
} }
}else } else {
{ if ($this->_bDebug) {
if ($this->_bDebug) {echo "<pre>Mysql Error:".$this->db->Error."(".$this->db->Errno.")</pre>";} echo "<pre>Mysql Error:" . $this->db->Error . "(" . $this->db->Errno . ")</pre>";
}
return -1; # error occurred. return -1; # error occurred.
} }
} }
@ -685,10 +658,8 @@ class FrontendNavigation
/** /**
* Get path of a given category up to a certain level * Get path of a given category up to a certain level
*/ */
function getCategoryPath($cat_id, $level = 0, $reverse = true) function getCategoryPath($cat_id, $level = 0, $reverse = true) {
{ if (!is_int((int) $cat_id) AND $cat_id < 0) {
if (!is_int((int)$cat_id) AND $cat_id < 0)
{
return array(); return array();
} }
@ -696,17 +667,14 @@ class FrontendNavigation
array_push($root_path, $cat_id); array_push($root_path, $cat_id);
$parent_id = $cat_id; $parent_id = $cat_id;
while ($this->getLevel($parent_id) >= 0 AND $this->getLevel($parent_id) > $level) while ($this->getLevel($parent_id) >= 0 AND $this->getLevel($parent_id) > $level) {
{
$parent_id = $this->getParent($parent_id); $parent_id = $this->getParent($parent_id);
if ($parent_id >= 0) if ($parent_id >= 0) {
{
array_push($root_path, $parent_id); array_push($root_path, $parent_id);
} }
} }
if ($reverse == true) if ($reverse == true) {
{
$root_path = array_reverse($root_path); $root_path = array_reverse($root_path);
} }
@ -716,17 +684,14 @@ class FrontendNavigation
/** /**
* Get root category of a given category * Get root category of a given category
*/ */
function getRoot($cat_id) function getRoot($cat_id) {
{ if (!is_int((int) $cat_id) AND $cat_id < 0) {
if (!is_int((int)$cat_id) AND $cat_id < 0)
{
return array(); return array();
} }
$parent_id = $cat_id; $parent_id = $cat_id;
while ($this->getLevel($parent_id) >= 0) while ($this->getLevel($parent_id) >= 0) {
{
$iRootCategory = $parent_id; $iRootCategory = $parent_id;
$parent_id = $this->getParent($parent_id); $parent_id = $this->getParent($parent_id);
} }
@ -742,11 +707,9 @@ class FrontendNavigation
* *
* @copyright four for business AG <www.4fb.de> * @copyright four for business AG <www.4fb.de>
*/ */
function getSubTree($idcat_start) function getSubTree($idcat_start) {
{
if (!is_int((int)$idcat_start) AND $idcat_start < 0 AND !is_array($this->cfg) AND !isset($this->cfg['tab']) AND !is_int((int)$this->client) AND $this->client < 0 AND !is_int((int)$this->lang) AND $this->lang < 0) if (!is_int((int) $idcat_start) AND $idcat_start < 0 AND ! is_array($this->cfg) AND ! isset($this->cfg['tab']) AND ! is_int((int) $this->client) AND $this->client < 0 AND ! is_int((int) $this->lang) AND $this->lang < 0) {
{
return array(); return array();
} }
@ -761,36 +724,34 @@ class FrontendNavigation
ORDER BY ORDER BY
idtree"; idtree";
if ($this->_bDebug) {echo "<pre>"; print_r($sql); echo "</pre>";} if ($this->_bDebug) {
echo "<pre>";
print_r($sql);
echo "</pre>";
}
$this->db->query($sql); $this->db->query($sql);
$i = false; $i = false;
while ( $this->db->next_record() ) while ($this->db->next_record()) {
{ if ($this->db->f("idcat") == $idcat_start) {
if ($this->db->f("idcat") == $idcat_start)
{
$curLevel = $this->db->f("level"); $curLevel = $this->db->f("level");
$i = true; $i = true;
}else } else {
{ if ($curLevel == $this->db->f("level")) {
if ($curLevel == $this->db->f("level"))
{
# ending part of tree # ending part of tree
$i = false; $i = false;
} }
} }
if ($i == true) if ($i == true) {
{
$deeper_cats[] = $this->db->f("idcat"); $deeper_cats[] = $this->db->f("idcat");
} }
} }
return $deeper_cats; return $deeper_cats;
} }
} }
?> ?>