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

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -36,13 +36,13 @@ if(!defined('CON_FRAMEWORK')) {
* *
*/ */
class DebuggerFactory { class DebuggerFactory {
/** /**
*
* @param string $sType * @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; $oDebugger = null;
switch ($sType) { switch ($sType) {
case 'visible': case 'visible':
@ -72,5 +72,4 @@ class DebuggerFactory {
} }
return $oDebugger; return $oDebugger;
} }
} }
?>