Hi I write a hack for phTheme.class.php, can you review it?
1. In the file, pnTheme.class.php, function _load_config(), After lines:
Code
// identify and load the correct module configuration
$this->cachepage = true;
$this->cachepage = true;
Add the follow:
Code
// BEGIN - UM Hack
$customargs2=$this->_check_if_exists($customargs, &$pageconfigurations);
// END - UM Hack
$customargs2=$this->_check_if_exists($customargs, &$pageconfigurations);
// END - UM Hack
2. In the file, pnTheme.class.php, function _load_config(), replace line:
Code
} else if (isset($pageconfigurations[$this->module.'-'.$this->type.'-'.$this->func.$customargs])) {
$file = $pageconfigurations[$this->module.'-'.$this->type.'-'.$this->func.$customargs]['file'];
$file = $pageconfigurations[$this->module.'-'.$this->type.'-'.$this->func.$customargs]['file'];
By:
Code
/* BEGIN UM Hack
} else if (isset($pageconfigurations[$this->module.'-'.$this->type.'-'.$this->func.$customargs])) {
$file = $pageconfigurations[$this->module.'-'.$this->type.'-'.$this->func.$customargs]['file'];
*/
} else if (!empty($customargs2)) {
$file = $pageconfigurations[$this->module.'-'.$this->type.'-'.$this->func.$customargs2]['file'];
// END UM Hack
} else if (isset($pageconfigurations[$this->module.'-'.$this->type.'-'.$this->func.$customargs])) {
$file = $pageconfigurations[$this->module.'-'.$this->type.'-'.$this->func.$customargs]['file'];
*/
} else if (!empty($customargs2)) {
$file = $pageconfigurations[$this->module.'-'.$this->type.'-'.$this->func.$customargs2]['file'];
// END UM Hack
3. In the file pnTheme.class.php add the follow method to Theme class
Code
/**
* Check if exists some configuration for a specific url
*
* @author UNDERMEDIA S.A. <info@undermedia.com.ec>
* @param string $pCustomArgs query parsed
* @param array $pPageConfig the page configurations
* @return string
*/
function _check_if_exists($pCustomArgs, $pPageConfig)
{
if(trim($pCustomArgs)=="")
return "";
elseif(isset($pPageConfig[$this->module.'-'.$this->type.'-'.$this->func.$pCustomArgs]))
return $pCustomArgs;
else
return $this->_check_if_exists($this->_delete_last_arg($pCustomArgs),$pPageConfig);
}
/**
* delete last argument from parse query
*
* @author UNDERMEDIA S.A. <info@undermedia.com.ec>
* @param string $tempargs query parsed
* @return string
*/
function _delete_last_arg($tempargs)
{
$tempargs=split("-",$tempargs);
$i=count($tempargs);
if ($i>0)
unset($tempargs[$i-1]);
$i=count($tempargs);
for($j=0;$j<$i;$j++)
{
if(trim($tempargs[$j])!="")
$res .= '-'.$tempargs[$j];
}
return $res;
}
* Check if exists some configuration for a specific url
*
* @author UNDERMEDIA S.A. <info@undermedia.com.ec>
* @param string $pCustomArgs query parsed
* @param array $pPageConfig the page configurations
* @return string
*/
function _check_if_exists($pCustomArgs, $pPageConfig)
{
if(trim($pCustomArgs)=="")
return "";
elseif(isset($pPageConfig[$this->module.'-'.$this->type.'-'.$this->func.$pCustomArgs]))
return $pCustomArgs;
else
return $this->_check_if_exists($this->_delete_last_arg($pCustomArgs),$pPageConfig);
}
/**
* delete last argument from parse query
*
* @author UNDERMEDIA S.A. <info@undermedia.com.ec>
* @param string $tempargs query parsed
* @return string
*/
function _delete_last_arg($tempargs)
{
$tempargs=split("-",$tempargs);
$i=count($tempargs);
if ($i>0)
unset($tempargs[$i-1]);
$i=count($tempargs);
for($j=0;$j<$i;$j++)
{
if(trim($tempargs[$j])!="")
$res .= '-'.$tempargs[$j];
}
return $res;
}
Thanks
edited by: netoec84, Feb 24, 2007 - 06:04 PM
