Dieser Commit ist enthalten in:
o.pinke 2025-07-18 15:15:42 +02:00
Ursprung 3611f1dec4
Commit 316a8e26e0
5 geänderte Dateien mit 517 neuen und 439 gelöschten Zeilen

Datei anzeigen

@ -35,7 +35,6 @@ if(!defined('CON_FRAMEWORK')) {
}
/**
* Base class for Contenido_Category, Contenido_Categories, Contenido_Category_Language.
* @version 0.9.0
@ -45,32 +44,33 @@ if(!defined('CON_FRAMEWORK')) {
* created 2008-02-15
* }}
*/
class Contenido_Category_Base {
class Contenido_Category_Base
{
/**
* @var obj
* @var DB_ConLite
* @access protected
*/
protected $oDb;
protected DB_ConLite $oDb;
/**
* @var array
* @access protected
*/
protected $aCfg;
protected array $aCfg;
/**
* @var boolean
* @access protected
*/
protected $bDbg;
protected bool $bDbg;
/**
* @var string
* @access protected
*/
protected $sDbgMode;
protected string $sDbgMode;
/**
* @var obj
* @var Debug_File|Debug_Visible|Debug_Hidden|Debug_VisibleAdv|Debug_DevNull|null
* @access protected
*/
protected $oDbg;
protected Debug_File|Debug_Visible|Debug_Hidden|Debug_VisibleAdv|Debug_DevNull|null $oDbg;
/**
* Constructor.
@ -80,7 +80,8 @@ class Contenido_Category_Base {
* @return void
* @author Rudi Bieller
*/
public function __construct(DB_ConLite $oDb, array $aCfg) {
public function __construct(DB_ConLite $oDb, array $aCfg)
{
$this->oDb = $oDb;
$this->aCfg = $aCfg;
$this->bDbg = false;
@ -95,7 +96,8 @@ class Contenido_Category_Base {
* @return void
* @author Rudi Bieller
*/
public function setDebug($bDebug = true, $sDebugMode = 'visible') {
public function setDebug(bool $bDebug = true, string $sDebugMode = 'visible'): void
{
if ($bDebug === false) {
$this->bDbg = false;
$this->oDbg = null;
@ -104,13 +106,9 @@ class Contenido_Category_Base {
if (!in_array($sDebugMode, array('visible', 'visible_adv', 'file', 'devnull', 'hidden'))) {
$sDebugMode = 'devnull';
}
try {
$this->sDbgMode = $sDebugMode;
$this->bDbg = true;
$this->oDbg = DebuggerFactory::getDebugger($sDebugMode);
} catch (InvalidArgumentException $e) {
throw $e;
}
}
}
}
@ -125,74 +123,65 @@ class Contenido_Category_Base {
* created 2008-02-15
* }}
*/
class Contenido_Category extends Contenido_Category_Base {
/**#@+
* @var int
* @access protected
*/
protected $iIdCat;
protected $iIdClient;
protected $iIdParent;
protected $iIdPre;
protected $iIdPost;
protected $iStatus;
/**#@-*/
class Contenido_Category extends Contenido_Category_Base
{
protected int $iIdCat;
protected int $iIdClient;
protected int $iIdParent;
protected int $iIdPre;
protected int $iIdPost;
protected int $iStatus;
/**#@+
* @var string
* @access protected
*/
protected $sAuthor;
protected $sCreated;
protected $sModified;
/**#@-*/
protected string $sAuthor;
protected string $sCreated;
protected string $sModified;
/**
* @var obj
* @var Contenido_Category_Language
* @access protected
*/
protected $oCategoryLanguage;
protected Contenido_Category_Language $oCategoryLanguage;
/**
* @var int
* @access protected
*/
protected $iIdLang;
protected int $iIdLang;
/**
* @var boolean
* @access protected
*/
protected $bLoadSubCategories;
protected bool $bLoadSubCategories;
/**
* @var obj
* @var Contenido_Categories|null
* @access protected
*/
protected $oSubCategories; // if required, this holds the SubCategories of current Category
protected Contenido_Categories|null $oSubCategories; // if required, this holds the SubCategories of current Category
/**
* @var boolean
* @access protected
*/
protected $bHasSubCategories;
protected bool $bHasSubCategories;
/**
* @var int
* @access protected
*/
protected $iCurrentSubCategoriesLoadDepth; // current level of SubCategories
protected int $iCurrentSubCategoriesLoadDepth; // current level of SubCategories
/**
* @var int
* @access protected
*/
protected $iSubCategoriesLoadDepth; // up to which level should SubCategories be loaded
protected int $iSubCategoriesLoadDepth; // up to which level should SubCategories be loaded
/**
* @var obj DB_ConLite
* @var DB_ConLite
* @access private
*/
private $_oDb;
private DB_ConLite $_oDb;
/**
@ -203,7 +192,8 @@ class Contenido_Category extends Contenido_Category_Base {
* @return void
* @author Rudi Bieller
*/
public function __construct(DB_ConLite $oDb, array $aCfg) {
public function __construct(DB_ConLite $oDb, array $aCfg)
{
parent::__construct($oDb, $aCfg);
$this->oSubCategories = null;
$this->bHasSubCategories = false;
@ -223,7 +213,8 @@ class Contenido_Category extends Contenido_Category_Base {
* @throws Exception TODO
* @author Rudi Bieller
*/
public function load($iIdCat, $bIncludeLanguage = false, $iIdlang = -1) {
public function load(int $iIdCat, bool $bIncludeLanguage = false, int $iIdlang = -1)
{
if (intval($iIdCat) <= 0) {
throw new InvalidArgumentException('Idcat to load must be greater than 0!');
}
@ -241,10 +232,10 @@ class Contenido_Category extends Contenido_Category_Base {
$this->oDbg->show($sSql, 'Contenido_Category::load($iIdCat, $bIncludeLanguage = false, $iIdlang = -1): $sSql');
}
$this->oDb->query($sSql);
if ($this->oDb->Errno != 0) {
if ($this->oDb->getErrno() != 0) {
return false;
}
$this->oDb->next_record();
$this->oDb->nextRecord();
$this->setIdCat($iIdCat);
$this->setIdClient($this->oDb->f('idclient'));
$this->setIdParent($this->oDb->f('parentid'));
@ -255,16 +246,12 @@ class Contenido_Category extends Contenido_Category_Base {
$this->setDateCreated($this->oDb->f('created'));
$this->setDateModified($this->oDb->f('lastmodified'));
if ($bIncludeLanguage === true) {
try {
$oCategoryLanguage = new Contenido_Category_Language($this->oDb, $this->aCfg);
$oCategoryLanguage->setDebug($this->bDbg, $this->sDbgMode);
$oCategoryLanguage->setIdCat($this->getIdCat());
$oCategoryLanguage->setIdLang($this->getIdLang());
$oCategoryLanguage->load();
$this->setCategoryLanguage($oCategoryLanguage);
} catch (Exception $e) {
throw $e;
}
}
if ($this->bLoadSubCategories === true) {
$this->_getSubCategories($iIdCat, $bIncludeLanguage, $iIdlang);
@ -279,10 +266,12 @@ class Contenido_Category extends Contenido_Category_Base {
* @param boolean $bIncludeLanguage If set to true, also creates Contenido_Category_Language object
* @param int $iIdlang If $bIncludeLanguage is set to true, you must set this value, too or use setIdLang() before!
* @return Contenido_Categories
* @throws Exception
* @author Rudi Bieller
*/
private function _getSubCategories($iIdcat, $bIncludeLanguage = false, $iIdlang = -1) {
if (intval($iIdcat) <= 0) {
private function _getSubCategories(int $iIdcat, bool $bIncludeLanguage = false, int $iIdlang = -1): Contenido_Categories
{
if ($iIdcat <= 0) {
throw new InvalidArgumentException('Idcat to load must be greater than 0!');
}
if ($bIncludeLanguage === true && $this->getIdLang() == -1) {
@ -297,7 +286,6 @@ class Contenido_Category extends Contenido_Category_Base {
// current load depth: $this->iCurrentSubCategoriesLoadDepth
// load depth to go to: $this->iSubCategoriesLoadDepth
foreach ($aSubCategories as $iIdcatCurrent) {
try {
$oCategory = new Contenido_Category($this->_oDb, $this->aCfg);
$oCategory->setDebug($this->bDbg, $this->sDbgMode);
if ($this->iSubCategoriesLoadDepth > 0) {
@ -305,9 +293,6 @@ class Contenido_Category extends Contenido_Category_Base {
}
$oCategory->load($iIdcatCurrent, $bIncludeLanguage, $iIdlang);
$this->oSubCategories->add($oCategory);
} catch (InvalidArgumentException $e) {
throw $e;
}
}
}
@ -318,7 +303,8 @@ class Contenido_Category extends Contenido_Category_Base {
* @return array
* @author Rudi Bieller
*/
private function _getSubCategoriesAsArray($iIdcat) {
private function _getSubCategoriesAsArray(int $iIdcat): bool|array
{
if (intval($iIdcat) <= 0) {
throw new InvalidArgumentException('Idcat to load must be greater than 0!');
}
@ -342,10 +328,10 @@ class Contenido_Category extends Contenido_Category_Base {
$this->oDbg->show($sSql, 'Contenido_Category::_getSubCategoriesAsArray($iIdcat): $sSql');
}
$this->oDb->query($sSql);
if ($this->oDb->Errno != 0) {
if ($this->oDb->getErrno() != 0) {
return false;
}
while ($this->oDb->next_record()) {
while ($this->oDb->nextRecord()) {
$aSubCats[] = $this->oDb->f('idcat');
}
return $aSubCats;
@ -361,9 +347,10 @@ class Contenido_Category extends Contenido_Category_Base {
* @return void
* @author Rudi Bieller
*/
public function setloadSubCategories($bLoad = false, $iLoadDepth = 0) {
$this->bLoadSubCategories = (boolean) $bLoad;
$this->iSubCategoriesLoadDepth = (int) $iLoadDepth;
public function setloadSubCategories(bool $bLoad = false, int $iLoadDepth = 0): void
{
$this->bLoadSubCategories = $bLoad;
$this->iSubCategoriesLoadDepth = $iLoadDepth;
}
/**
@ -373,92 +360,133 @@ class Contenido_Category extends Contenido_Category_Base {
* @return void
* @author Rudi Bieller
*/
public function setSubCategories(Contenido_Categories $oCategories) {
public function setSubCategories(Contenido_Categories $oCategories): void
{
$this->oSubCategories = $oCategories;
}
public function setCategoryLanguage(Contenido_Category_Language $oCatLang) {
public function setCategoryLanguage(Contenido_Category_Language $oCatLang): void
{
$this->oCategoryLanguage = $oCatLang;
}
public function setIdCat($iIdcat) {
$this->iIdCat = (int) $iIdcat;
public function setIdCat(int $iIdcat): void
{
$this->iIdCat = $iIdcat;
}
public function setIdClient($iIdcient) {
$this->iIdClient = (int) $iIdcient;
public function setIdClient(int $iIdcient): void
{
$this->iIdClient = $iIdcient;
}
public function setIdParent($iIdcatParent) {
$this->iIdParent = (int) $iIdcatParent;
public function setIdParent(int $iIdcatParent): void
{
$this->iIdParent = $iIdcatParent;
}
public function setIdPre($iIdcatPre) {
$this->iIdPre = (int) $iIdcatPre;
public function setIdPre(int $iIdcatPre): void
{
$this->iIdPre = $iIdcatPre;
}
public function setIdPost($iIdcatPost) {
$this->iIdPost = (int) $iIdcatPost;
public function setIdPost(int $iIdcatPost): void
{
$this->iIdPost = $iIdcatPost;
}
public function setStatus($iStatus) {
$iStatus = (int) $iStatus;
public function setStatus(int $iStatus): void
{
$aValid = array(0, 1);
if (!in_array($iStatus, $aValid)) {
throw new InvalidArgumentException('Status must be either 0 or 1');
}
$this->iStatus = $iStatus;
}
public function setAuthor($sAuthor) {
public function setAuthor(string $sAuthor): void
{
// TODO: input validation, strlen 32
$this->sAuthor = (string) $sAuthor;
$this->sAuthor = $sAuthor;
}
public function setDateCreated($sDateCreated) {
public function setDateCreated(string $sDateCreated): void
{
// TODO: input validation, correct date/datetime format
$this->sCreated = (string) $sDateCreated;
$this->sCreated = $sDateCreated;
}
public function setDateModified($sDateModified) {
public function setDateModified(string $sDateModified): void
{
// TODO: input validation, correct date/datetime format
$this->sModified = (string) $sDateModified;
$this->sModified = $sDateModified;
}
public function setIdLang($iIdlang) {
$this->iIdLang = (int) $iIdlang;
public function setIdLang(int $iIdlang): void
{
$this->iIdLang = $iIdlang;
}
// GETTER
public function getSubCategories() {
public function getSubCategories(): ?Contenido_Categories
{
return is_null($this->oSubCategories) ? new Contenido_Categories($this->oDb, $this->aCfg) : $this->oSubCategories;
}
public function getCategoryLanguage() {
public function getCategoryLanguage(): Contenido_Category_Language
{
return !is_null($this->oCategoryLanguage) ? $this->oCategoryLanguage : new Contenido_Category_Language($this->oDb, $this->aCfg);
}
public function getIdCat() {
return !is_null($this->iIdCat) ? (int) $this->iIdCat : -1;
public function getIdCat(): int
{
return !is_null($this->iIdCat) ? $this->iIdCat : -1;
}
public function getIdClient() {
return !is_null($this->iIdClient) ? (int) $this->iIdClient : -1;
public function getIdClient(): int
{
return !is_null($this->iIdClient) ? $this->iIdClient : -1;
}
public function getIdParent() {
return !is_null($this->iIdParent) ? (int) $this->iIdParent : -1;
public function getIdParent(): int
{
return !is_null($this->iIdParent) ? $this->iIdParent : -1;
}
public function getIdPre() {
return !is_null($this->iIdPre) ? (int) $this->iIdPre : -1;
public function getIdPre(): int
{
return !is_null($this->iIdPre) ? $this->iIdPre : -1;
}
public function getIdPost() {
return !is_null($this->iIdPost) ? (int) $this->iIdPost : -1;
public function getIdPost(): int
{
return !is_null($this->iIdPost) ? $this->iIdPost : -1;
}
public function getStatus() {
return !is_null($this->iStatus) ? (int) $this->iStatus : -1;
public function getStatus(): int
{
return !is_null($this->iStatus) ? $this->iStatus : -1;
}
public function getAuthor() {
return !is_null($this->sAuthor) ? (string) $this->sAuthor : '';
public function getAuthor(): string
{
return !is_null($this->sAuthor) ? $this->sAuthor : '';
}
public function getDateCreated() {
return !is_null($this->sCreated) ? (string) $this->sCreated : '';
public function getDateCreated(): string
{
return !is_null($this->sCreated) ? $this->sCreated : '';
}
public function getDateModified() {
return !is_null($this->sModified) ? (string) $this->sModified : '';
public function getDateModified(): string
{
return !is_null($this->sModified) ? $this->sModified : '';
}
public function getIdLang() {
return (!is_null($this->iIdLang) && $this->iIdLang > 0) ? (int) $this->iIdLang : -1;
public function getIdLang(): int
{
return (!is_null($this->iIdLang) && $this->iIdLang > 0) ? $this->iIdLang : -1;
}
}
@ -472,28 +500,29 @@ class Contenido_Category extends Contenido_Category_Base {
* modified 2008-02-25 Implemented ArrayAccess; added methods reverse(), ksort() and krsort().
* }}
*/
class Contenido_Categories extends Contenido_Category_Base implements IteratorAggregate, ArrayAccess, Countable {
class Contenido_Categories extends Contenido_Category_Base implements IteratorAggregate, ArrayAccess, Countable
{
/**
* @var array
* @access protected
*/
protected $aContenidoCategories;
protected array $aContenidoCategories;
/**
* @var int
* @access protected
*/
protected $iIdLang;
protected int $iIdLang;
/**
* @var boolean
* @access protected
*/
protected $bLoadSubCategories;
protected bool $bLoadSubCategories;
/**
* @var int
* @access protected
*/
protected $iSubCategoriesLoadDepth; // up to which level should SubCategories be loaded
protected int $iSubCategoriesLoadDepth; // up to which level should SubCategories be loaded
/**
* Constructor.
@ -503,9 +532,10 @@ class Contenido_Categories extends Contenido_Category_Base implements IteratorAg
* @return void
* @author Rudi Bieller
*/
public function __construct(DB_ConLite $oDb, array $aCfg) {
public function __construct(DB_ConLite $oDb, array $aCfg)
{
parent::__construct($oDb, $aCfg);
$this->aContenidoCategories = array();
$this->aContenidoCategories = [];
$this->bLoadSubCategories = false;
$this->iSubCategoriesLoadDepth = 0;
}
@ -517,9 +547,11 @@ class Contenido_Categories extends Contenido_Category_Base implements IteratorAg
* @param boolean $bIncludeLanguage
* @param int $iIdlang If $bIncludeLanguage is set to true, you must set this value, too or use setIdLang() before!
* @return void
* @throws Exception
* @author Rudi Bieller
*/
public function load(array $aCategoryIds, $bIncludeLanguage = false, $iIdlang = -1) {
public function load(array $aCategoryIds, bool $bIncludeLanguage = false, int $iIdlang = -1)
{
$this->setIdLang($iIdlang);
if (sizeof($aCategoryIds) > 0) {
// loop over passed category ids and create single Category object on each run
@ -540,11 +572,12 @@ class Contenido_Categories extends Contenido_Category_Base implements IteratorAg
* Add a Contenido_Category object into internal array ("Collection")
* @access public
* @param Contenido_Category $oContenidoCategory
* @param int $iOffset
* @param int|null $iOffset
* @return void
* @author Rudi Bieller
*/
public function add(Contenido_Category $oContenidoCategory, $iOffset = null) {
public function add(Contenido_Category $oContenidoCategory, int $iOffset = null): void
{
$this->offsetSet($iOffset, $oContenidoCategory);
}
@ -556,9 +589,10 @@ class Contenido_Categories extends Contenido_Category_Base implements IteratorAg
* @return void
* @author Rudi Bieller
*/
public function setloadSubCategories($bLoad = false, $iLoadDepth = 0) {
$this->bLoadSubCategories = (boolean) $bLoad;
$this->iSubCategoriesLoadDepth = (int) $iLoadDepth;
public function setloadSubCategories(bool $bLoad = false, int $iLoadDepth = 0): void
{
$this->bLoadSubCategories = $bLoad;
$this->iSubCategoriesLoadDepth = $iLoadDepth;
}
/**
@ -568,8 +602,9 @@ class Contenido_Categories extends Contenido_Category_Base implements IteratorAg
* @return void
* @author Rudi Bieller
*/
public function setIdLang($iIdlang) {
$this->iIdLang = (int) $iIdlang;
public function setIdLang(int $iIdlang): void
{
$this->iIdLang = $iIdlang;
}
/**
@ -578,8 +613,9 @@ class Contenido_Categories extends Contenido_Category_Base implements IteratorAg
* @return int
* @author Rudi Bieller
*/
public function getIdLang() {
return (!is_null($this->iIdLang) && $this->iIdLang > 0) ? (int) $this->iIdLang : -1;
public function getIdLang(): int
{
return (!is_null($this->iIdLang) && $this->iIdLang > 0) ? $this->iIdLang : -1;
}
/**
@ -588,7 +624,8 @@ class Contenido_Categories extends Contenido_Category_Base implements IteratorAg
* @return ArrayObject
* @author Rudi Bieller
*/
public function getIterator () {
public function getIterator(): ArrayObject
{
return new ArrayObject($this->aContenidoCategories);
}
@ -598,7 +635,8 @@ class Contenido_Categories extends Contenido_Category_Base implements IteratorAg
* @return int
* @author Rudi Bieller
*/
public function count () {
public function count(): int
{
return sizeof($this->aContenidoCategories);
}
@ -608,7 +646,8 @@ class Contenido_Categories extends Contenido_Category_Base implements IteratorAg
* @return void
* @author Rudi Bieller
*/
public function ksort() {
public function ksort(): void
{
ksort($this->aContenidoCategories);
}
@ -618,7 +657,8 @@ class Contenido_Categories extends Contenido_Category_Base implements IteratorAg
* @return void
* @author Rudi Bieller
*/
public function krsort() {
public function krsort(): void
{
krsort($this->aContenidoCategories);
}
@ -628,7 +668,8 @@ class Contenido_Categories extends Contenido_Category_Base implements IteratorAg
* @return void
* @author Rudi Bieller
*/
public function reverse() {
public function reverse(): void
{
$this->aContenidoCategories = array_reverse($this->aContenidoCategories);
}
@ -641,9 +682,11 @@ class Contenido_Categories extends Contenido_Category_Base implements IteratorAg
* @return boolean
* @author Rudi Bieller
*/
public function offsetExists($mOffset) {
public function offsetExists($mOffset)
{
return array_key_exists($this->aContenidoCategories, $mOffset);
}
/**
* Interface method for ArrayAccess.
* @access public
@ -651,9 +694,11 @@ class Contenido_Categories extends Contenido_Category_Base implements IteratorAg
* @return obj
* @author Rudi Bieller
*/
public function offsetGet($mOffset) {
public function offsetGet($mOffset)
{
return $this->aContenidoCategories[$mOffset];
}
/**
* Interface method for ArrayAccess.
* @access public
@ -662,13 +707,15 @@ class Contenido_Categories extends Contenido_Category_Base implements IteratorAg
* @return void
* @author Rudi Bieller
*/
public function offsetSet($mOffset, $mValue) {
public function offsetSet($mOffset, $mValue): void
{
if (is_null($mOffset)) {
$this->aContenidoCategories[] = $mValue;
} else {
$this->aContenidoCategories[$mOffset] = $mValue;
}
}
/**
* Interface method for ArrayAccess.
* @access public
@ -676,7 +723,8 @@ class Contenido_Categories extends Contenido_Category_Base implements IteratorAg
* @return void
* @author Rudi Bieller
*/
public function offsetUnset($mOffset) {
public function offsetUnset($mOffset): void
{
unset($this->aContenidoCategories[$mOffset]);
}
}
@ -690,51 +738,21 @@ class Contenido_Categories extends Contenido_Category_Base implements IteratorAg
* created 2008-02-15
* }}
*/
class Contenido_Category_Language extends Contenido_Category_Base {
/**#@+
* @var int
* @access protected
*/
protected $iIdCatlang;
class Contenido_Category_Language extends Contenido_Category_Base
{
protected int $iIdCatlang;
protected $iIdCat;
protected $iIdLang;
protected $iIdTplcfg;
/**#@-*/
protected int $iIdTplcfg;
/**
* @var string
* @access protected
*/
protected $sName;
protected $sAlias;
/**#@+
* @var int
* @access protected
*/
protected $iVisible;
protected $iPublic;
protected $iStatus;
/**#@-*/
/**#@+
* @var string
* @access protected
*/
protected $sAuthor;
protected $sDateCreated;
protected $sDateModified;
/**#@-*/
/**
* @var int
* @access protected
*/
protected $iStartIdartlang;
/**
* @var string
* @access protected
*/
protected $sUrlname;
/**
@ -745,18 +763,21 @@ class Contenido_Category_Language extends Contenido_Category_Base {
* @return void
* @author Rudi Bieller
*/
public function __construct(DB_ConLite $oDb, array $aCfg) {
public function __construct(DB_ConLite $oDb, array $aCfg)
{
parent::__construct($oDb, $aCfg);
}
/**
* Load cat_lang for a given idcat.
* @access public
* @param int $iIdCatLang
* @param int|null $iIdCatLang
* @return boolean
* @throws Exception
* @author Rudi Bieller
*/
public function load($iIdCatLang = null) {
public function load(int $iIdCatLang = null): bool
{
if ($this->getIdCat() == -1 || $this->getIdLang() == -1) {
throw new Exception('idcat and idlang must be set in order to load from con_cat_lang!');
}
@ -777,10 +798,10 @@ class Contenido_Category_Language extends Contenido_Category_Base {
idcatlang = ' . Contenido_Security::toInteger($iIdCatLang);
}
$this->oDb->query($sSql);
if ($this->oDb->Errno != 0) {
if ($this->oDb->getErrno() != 0) {
return false;
}
$this->oDb->next_record();
$this->oDb->nextRecord();
$this->setIdCatLang($this->oDb->f('idcatlang'));
$this->setIdCat($this->getIdCat());
$this->setIdLang($this->getIdLang());
@ -800,107 +821,157 @@ class Contenido_Category_Language extends Contenido_Category_Base {
// SETTER
public function setIdCatLang($iIdcatlang) {
$this->iIdCatlang = (int) $iIdcatlang;
public function setIdCatLang(int $iIdcatlang): void
{
$this->iIdCatlang = $iIdcatlang;
}
public function setIdCat($iIdcat) {
$this->iIdCat = (int) $iIdcat;
public function setIdCat(int $iIdcat): void
{
$this->iIdCat = $iIdcat;
}
public function setIdLang($iIdlang) {
$this->iIdlang = (int) $iIdlang;
public function setIdLang(int $iIdlang): void
{
$this->iIdlang = $iIdlang;
}
public function setIdTemplateConfig($iIdTplcfg) {
$this->iIdTplcfg = (int) $iIdTplcfg;
public function setIdTemplateConfig(int $iIdTplcfg): void
{
$this->iIdTplcfg = $iIdTplcfg;
}
public function setName($sName) {
$this->sName = (string) $sName;
public function setName(string$sName): void
{
$this->sName = $sName;
}
public function setAlias($sAlias) {
$this->sAlias = (string) $sAlias;
public function setAlias(string $sAlias): void
{
$this->sAlias = $sAlias;
}
public function setVisible($iVisible) {
$iVisible = (int) $iVisible;
public function setVisible(int $iVisible): void
{
$aValid = array(0, 1);
if (!in_array($iVisible, $aValid)) {
throw new InvalidArgumentException('Visible must be either 0 or 1');
}
$this->iVisible = $iVisible;
}
public function setPublic($iPublic) {
$iPublic = (int) $iPublic;
public function setPublic(int $iPublic): void
{
$aValid = array(0, 1);
if (!in_array($iPublic, $aValid)) {
throw new InvalidArgumentException('Public must be either 0 or 1');
}
$this->iPublic = $iPublic;
}
public function setStatus($iStatus) {
$iStatus = (int) $iStatus;
public function setStatus(int $iStatus): void
{
$aValid = array(0, 1);
if (!in_array($iStatus, $aValid)) {
throw new InvalidArgumentException('Status must be either 0 or 1');
}
$this->iStatus = $iStatus;
}
public function setAuthor($sAuthor) {
$this->sAuthor = (string) $sAuthor;
public function setAuthor(string $sAuthor): void
{
$this->sAuthor = $sAuthor;
}
public function setDateCreated($sDateCreated) {
$this->sDateCreated = (string) $sDateCreated;
public function setDateCreated(string $sDateCreated): void
{
$this->sDateCreated = $sDateCreated;
}
public function setDateLastModified($sDateLastModified) {
$this->sDateModified = (string) $sDateLastModified;
public function setDateLastModified(string $sDateLastModified): void
{
$this->sDateModified = $sDateLastModified;
}
public function setStartIdLang($iStartIdlang) {
$this->iStartIdartlang = (int) $iStartIdlang;
public function setStartIdLang(int $iStartIdlang): void
{
$this->iStartIdartlang = $iStartIdlang;
}
public function setUrlName($sUrlName) {
$this->sUrlname = (string) $sUrlName;
public function setUrlName(string$sUrlName): void
{
$this->sUrlname = $sUrlName;
}
// GETTER
public function getIdCatLang() {
return !is_null($this->iIdCatlang) ? (int) $this->iIdCatlang : -1;
public function getIdCatLang()
{
return !is_null($this->iIdCatlang) ? $this->iIdCatlang : -1;
}
public function getIdCat() {
public function getIdCat(): int
{
return !is_null($this->iIdCat) ? (int)$this->iIdCat : -1;
}
public function getIdLang() {
return !is_null($this->iIdlang) ? (int) $this->iIdlang : -1;
public function getIdLang(): int
{
return !is_null($this->iIdlang) ? $this->iIdlang : -1;
}
public function getIdTemplateConfig() {
return !is_null($this->iIdTplcfg) ? (int) $this->iIdTplcfg : -1;
public function getIdTemplateConfig(): int
{
return !is_null($this->iIdTplcfg) ? $this->iIdTplcfg : -1;
}
public function getName() {
public function getName(): string
{
return !is_null($this->sName) ? (string)$this->sName : '';
}
public function getAlias() {
public function getAlias(): string
{
return !is_null($this->sAlias) ? (string)$this->sAlias : '';
}
public function getVisible() {
public function getVisible(): int
{
return !is_null($this->iVisible) ? (int)$this->iVisible : -1;
}
public function getPublic() {
public function getPublic(): int
{
return !is_null($this->iPublic) ? (int)$this->iPublic : -1;
}
public function getStatus() {
public function getStatus(): int
{
return !is_null($this->iStatus) ? (int)$this->iStatus : -1;
}
public function getAuthor() {
public function getAuthor(): string
{
return !is_null($this->sAuthor) ? (string)$this->sAuthor : '';
}
public function getDateCreated() {
public function getDateCreated(): string
{
return !is_null($this->sDateCreated) ? (string)$this->sDateCreated : '';
}
public function getDateLastModified() {
public function getDateLastModified(): string
{
return !is_null($this->sDateModified) ? (string)$this->sDateModified : '';
}
public function getStartIdLang() {
public function getStartIdLang(): int
{
return !is_null($this->iStartIdartlang) ? (int)$this->iStartIdartlang : -1;
}
public function getUrlName() {
public function getUrlName(): string
{
return !is_null($this->sUrlname) ? (string)$this->sUrlname : '';
}
}
?>

Datei anzeigen

@ -41,7 +41,7 @@ if(!defined('CON_FRAMEWORK')) {
class Contenido_FrontendNavigation extends Contenido_FrontendNavigation_Base {
/**
* @var obj
* @var
* @access protected
*/
protected $oAuth; // for validating against fe-authentication
@ -50,13 +50,13 @@ class Contenido_FrontendNavigation extends Contenido_FrontendNavigation_Base {
* @var array
* @access protected
*/
protected $aLevel;
protected array $aLevel;
/**
* @var int
* @access protected
*/
protected $iRootCat;
protected int $iRootCat;
/**
* Constructor.
@ -68,7 +68,7 @@ class Contenido_FrontendNavigation extends Contenido_FrontendNavigation_Base {
* @return void
* @author Rudi Bieller
*/
public function __construct(DB_ConLite $oDb, array $aCfg, $iClient, $iLang, array $aCfgClient) {
public function __construct(DB_ConLite $oDb, array $aCfg, int $iClient, int $iLang, array $aCfgClient) {
parent::__construct($oDb, $aCfg, $iClient, $iLang, $aCfgClient);
$this->iRootCat = -1;
}
@ -85,7 +85,8 @@ class Contenido_FrontendNavigation extends Contenido_FrontendNavigation_Base {
* @return boolean
* @author Rudi Bieller
*/
protected function loadSubCategories($iIdcat, $bAsObjects = true, $bWithSubCategories = false, $iSubCategoriesLoadDepth = 3) {
protected function loadSubCategories(int $iIdcat, bool $bAsObjects = true, bool $bWithSubCategories = false, int $iSubCategoriesLoadDepth = 3): bool
{
$iIdcat = (int) $iIdcat;
$bUseAuth = (is_null($this->oAuth)
|| (get_class($this->oAuth) != 'Auth'
@ -129,11 +130,11 @@ class Contenido_FrontendNavigation extends Contenido_FrontendNavigation_Base {
$this->oDbg->show($sSql, 'Contenido_FrontendNavigation::loadSubCategories($iIdcat, $bAsObjects = true): $sSql');
}
$this->oDb->query($sSql);
if ($this->oDb->Errno != 0) {
if ($this->oDb->getErrno() != 0) {
return false;
}
$this->aCategories = array();
while ($this->oDb->next_record()) {
while ($this->oDb->nextRecord()) {
// check against fe-auth and against be-access
if ($bUseAuth === true && intval($this->oDb->f('public')) == 0) {
$sPerms = strval($this->oAuth->auth['perm']);
@ -159,12 +160,17 @@ class Contenido_FrontendNavigation extends Contenido_FrontendNavigation_Base {
}
if($bAsObjects === true) {
$oCategories = new Contenido_Categories(new DB_ConLite(), $this->aCfg);
if(!empty($this->sDbgMode)) {
$oCategories->setDebug($this->bDbg, $this->sDbgMode);
} else {
$oCategories->setDebug($this->bDbg, 'hidden');
}
$oCategories->setIdLang($this->iLang);
$oCategories->setloadSubCategories($bWithSubCategories, $iSubCategoriesLoadDepth);
$oCategories->load($this->aCategories, true, $this->iLang);
$this->oCategories = $oCategories;
}
return true;
}
/**
@ -179,7 +185,8 @@ class Contenido_FrontendNavigation extends Contenido_FrontendNavigation_Base {
* @return mixed Contenido_Categories or Array, depending on value for $bAsObjects
* @author Rudi Bieller
*/
public function getSubCategories($iIdcat, $bAsObjects = true, $bWithSubCategories = false, $iSubCategoriesLoadDepth = 3) {
public function getSubCategories(int $iIdcat, bool $bAsObjects = true, bool $bWithSubCategories = false, int $iSubCategoriesLoadDepth = 3): mixed
{
$this->loadSubCategories($iIdcat, $bAsObjects, $bWithSubCategories, $iSubCategoriesLoadDepth);
return $bAsObjects === true ? $this->oCategories : $this->aCategories;
}
@ -196,11 +203,11 @@ class Contenido_FrontendNavigation extends Contenido_FrontendNavigation_Base {
}
$sSql = 'SELECT level FROM ' . $this->aCfg["tab"]["cat_tree"] . ' WHERE idcat = ' . Contenido_Security::escapeDB(intval($iIdcat), $this->oDb);
$this->oDb->query($sSql);
if ($this->oDb->Errno != 0) {
if ($this->oDb->getErrno() != 0) {
return -1;
}
if ($this->oDb->num_rows() > 0) {
$this->oDb->next_record();
$this->oDb->nextRecord();
return intval($this->oDb->f('level'));
}
return -1;
@ -214,7 +221,8 @@ class Contenido_FrontendNavigation extends Contenido_FrontendNavigation_Base {
* @return boolean
* @author Rudi Bieller
*/
public function isActiveParent(Contenido_Category $oCategory, $iCurrentIdcat) {
public function isActiveParent(Contenido_Category $oCategory, int $iCurrentIdcat): bool
{
if ($oCategory->getIdParent() > 0) {
$iCurrentIdcat = (int) $iCurrentIdcat;
if ($oCategory->getIdParent() == $iCurrentIdcat) {
@ -234,7 +242,8 @@ class Contenido_FrontendNavigation extends Contenido_FrontendNavigation_Base {
* @return boolean
* @author Rudi Bieller
*/
public function isActiveChild(Contenido_Category $oCategory, $iCurrentIdcat) {
public function isActiveChild(Contenido_Category $oCategory, int $iCurrentIdcat): bool
{
if ($oCategory->getSubCategories()->count() > 0) {
$iCurrentIdcat = (int) $iCurrentIdcat;
$oChildCategories = $oCategory->getSubCategories();
@ -255,7 +264,8 @@ class Contenido_FrontendNavigation extends Contenido_FrontendNavigation_Base {
* @param int $iTreeHaystackCat
* @return boolean
*/
public function isInPathToRoot($iNeedleCat, $iTreeHaystackCat) {
public function isInPathToRoot(int $iNeedleCat, int $iTreeHaystackCat): bool
{
$oBreadcrumb = new Contenido_FrontendNavigation_Breadcrumb($this->oDb, $this->aCfg, $this->iClient, $this->iLang, $this->aCfgClient);
$aBreadCats = $oBreadcrumb->getAsArray($iTreeHaystackCat, ($this->getLevel($this->getRootCat())+1));
return in_array($iNeedleCat, $aBreadCats);
@ -269,16 +279,18 @@ class Contenido_FrontendNavigation extends Contenido_FrontendNavigation_Base {
* @return void
* @author Rudi Bieller
*/
public function setAuth(Auth $oAuth) {
public function setAuth(Auth $oAuth): void
{
$this->oAuth = $oAuth;
}
public function setRootCat($iIdcat) {
public function setRootCat($iIdcat): void
{
$this->iRootCat = (int) $iIdcat;
}
public function getRootCat() {
public function getRootCat(): int
{
return (int) $this->iRootCat;
}
}
?>

Datei anzeigen

@ -36,53 +36,51 @@ class Contenido_FrontendNavigation_Base {
* @var int
* @access protected
*/
protected $iLang;
protected $iClient;
protected int $iLang;
protected int $iClient;
/**#@-*/
/**
* @var array
* @access protected
*/
protected $aCategories;
protected array $aCategories;
/**
* @var obj
* @var null|Contenido_Categories
* @access protected
*/
protected $oCategories;
protected null|Contenido_Categories $oCategories;
// needed properties for db queries
/**
* @var obj
* @access protected
*/
protected $oDb;
protected DB_ConLite $oDb;
/**
* @var array
* @access protected
*/
protected $aCfg;
protected array $aCfg;
/**
* @var array
* @access protected
*/
protected $aCfgClient;
protected array $aCfgClient;
/**
* @var boolean
* @access protected
*/
protected $bDbg;
protected bool $bDbg;
/**
* @var string
* @access protected
*/
protected $sDbgMode;
protected string $sDbgMode;
/**
* @var obj
* @access protected
*/
protected $oDbg;
protected Debug_File|Debug_Visible|Debug_Hidden|Debug_VisibleAdv|Debug_DevNull|null $oDbg;
/**
* Constructor.
@ -94,14 +92,14 @@ class Contenido_FrontendNavigation_Base {
* @return void
* @author Rudi Bieller
*/
public function __construct(DB_ConLite $oDb, array $aCfg, $iClient, $iLang, array $aCfgClient) {
public function __construct(DB_ConLite $oDb, array $aCfg, int $iClient, int $iLang, array $aCfgClient) {
$this->oDb = $oDb;
$this->aCfg = $aCfg;
$this->iClient = (int) $iClient;
$this->iLang = (int) $iLang;
$this->aCfgClient = $aCfgClient;
$this->_iCurrentLoadDepth = 1;
$this->_aSubCategories = array();
$this->_aSubCategories = [];
$this->bDbg = false;
$this->oDbg = null;
}
@ -114,22 +112,18 @@ class Contenido_FrontendNavigation_Base {
* @param string $sStyle Available styles are: front_content, custom, custom_path
* @param array $aConfig As default this is Contenido_UrlBuilderConfig::getConfig(), can be overridden by setting this value
* @param boolean $bUseAbsolutePath If true, will use absolute http://www.xy.com/ as "prefix"
* @return void
* @throws InvalidArgumentException
* @return string
* @see appropriate Contenido_UrlBuilder for details on needed params
* @todo Apply other styles as soon as they are available
*/
public function getUrl(array $aParams, $sStyle = 'custom_path', array $aConfig = array(), $bUseAbsolutePath = false) {
try {
public function getUrl(array $aParams, string $sStyle = 'custom_path', array $aConfig = array(), bool $bUseAbsolutePath = false): string
{
$oUrlBuilder = Contenido_UrlBuilderFactory::getUrlBuilder($sStyle);
if ($bUseAbsolutePath === true) {
$oUrlBuilder->setHttpBasePath($this->aCfgClient[$this->iClient]['path']['htmlpath']);
}
$oUrlBuilder->buildUrl($aParams, $bUseAbsolutePath, $aConfig);
return $oUrlBuilder->getUrl();
} catch (InvalidArgumentException $e) {
throw $e;
}
}
/**
@ -140,7 +134,8 @@ class Contenido_FrontendNavigation_Base {
* @return void
* @author Rudi Bieller
*/
public function setDebug($bDebug = true, $sDebugMode = 'visible') {
public function setDebug($bDebug = true, $sDebugMode = 'visible'): void
{
if (!in_array($sDebugMode, array('visible', 'hidden'))) {
$sDebugMode = 'hidden';
}
@ -154,4 +149,3 @@ class Contenido_FrontendNavigation_Base {
}
}
}
?>

Datei anzeigen

@ -38,19 +38,19 @@ class Contenido_FrontendNavigation_Breadcrumb extends Contenido_FrontendNavigati
* @access private
* @desc Used for breadcrumb loop over tree
*/
private $_iCurrentLevel;
private int $_iCurrentLevel;
/**
* @var boolean
* @access private
*/
private $_bAsArray;
private bool $_bAsArray;
/**
* @var array
* @access private
*/
private $_aCategories;
private array $_aCategories;
/**
* Constructor.
@ -62,7 +62,7 @@ class Contenido_FrontendNavigation_Breadcrumb extends Contenido_FrontendNavigati
* @return void
* @author Rudi Bieller
*/
public function __construct(DB_ConLite $oDb, array $aCfg, $iClient, $iLang, array $aCfgClient) {
public function __construct(DB_ConLite $oDb, array $aCfg, int $iClient, $iLang, array $aCfgClient) {
parent::__construct($oDb, $aCfg, $iClient, $iLang, $aCfgClient);
$this->oCategories = null;
$this->_bAsArray = false;
@ -79,7 +79,8 @@ class Contenido_FrontendNavigation_Breadcrumb extends Contenido_FrontendNavigati
* @author Rudi Bieller
* @todo Add possibility to return an array
*/
public function get($iBaseCategoryId, $iRootLevel = 0, $bReset = false) {
public function get(int $iBaseCategoryId, int $iRootLevel = 0, bool $bReset = false): ?array
{
$this->getBreadcrumb($iBaseCategoryId, $iRootLevel, $bReset);
$this->oCategories->reverse(); // For a breadcrumb, we start at the main category, not the current one.
return $this->oCategories;
@ -96,7 +97,8 @@ class Contenido_FrontendNavigation_Breadcrumb extends Contenido_FrontendNavigati
* @author Rudi Bieller
* @todo Add possibility to return an array
*/
public function getAsArray($iBaseCategoryId, $iRootLevel = 0, $bReset = false) {
public function getAsArray(int $iBaseCategoryId, int $iRootLevel = 0, bool $bReset = false): array
{
$this->_bAsArray = true;
$this->getBreadcrumb($iBaseCategoryId, $iRootLevel, $bReset);
$this->_aCategories = array_reverse($this->_aCategories); // For a breadcrumb, we start at the main category, not the current one.
@ -113,7 +115,8 @@ class Contenido_FrontendNavigation_Breadcrumb extends Contenido_FrontendNavigati
* @return array
* @author Rudi Bieller
*/
protected function getBreadcrumb($iBaseCategoryId, $iRootLevel = 0, $bReset = false) {
protected function getBreadcrumb(int $iBaseCategoryId, int $iRootLevel = 0, bool $bReset = false): Contenido_Categories|bool|array|null
{
// this method calls itself, so check if this happened already
if ($bReset === true || is_null($this->oCategories) || $this->oCategories->count() == 0) {
$this->oCategories = new Contenido_Categories($this->oDb, $this->aCfg);
@ -138,10 +141,10 @@ class Contenido_FrontendNavigation_Breadcrumb extends Contenido_FrontendNavigati
$this->oDbg->show($sSql, 'Contenido_FrontendNavigation_Breadcrumb::getBreadcrumb($iBaseCategoryId, $iRootLevel = 0, $bReset = false): $sSql');
}
$this->oDb->query($sSql);
if ($this->oDb->Errno != 0) {
if ($this->oDb->getErrno() != 0) {
return false;
}
$this->oDb->next_record();
$this->oDb->nextRecord();
if ($this->_bAsArray === false) {
$oContenidoCategory = new Contenido_Category(new DB_ConLite(), $this->aCfg);
$oContenidoCategory->load(intval($this->oDb->f('idcat')), true, $this->iLang);
@ -163,4 +166,3 @@ class Contenido_FrontendNavigation_Breadcrumb extends Contenido_FrontendNavigati
}
}
}
?>

Datei anzeigen

@ -38,11 +38,11 @@ if(!defined('CON_FRAMEWORK')) {
class DebuggerFactory {
/**
*
* @param string $sType
* @return Debug_VisibleAdv
* @return Debug_File|Debug_Visible|Debug_Hidden|Debug_VisibleAdv|Debug_DevNull
*/
public static function getDebugger($sType) {
public static function getDebugger(string $sType): Debug_File|Debug_Visible|Debug_Hidden|Debug_VisibleAdv|Debug_DevNull
{
$oDebugger = null;
switch ($sType) {
case 'visible':
@ -73,4 +73,3 @@ class DebuggerFactory {
return $oDebugger;
}
}
?>