AAAAhome/academiac/www/templates/puntopc/classes/ArtxPage.php 0000604 00000023604 15137144503 0017562 0 ustar 00 page = $page;
}
/**
* Checks whether Joomla! has system messages to display.
*/
public function hasMessages()
{
$app = JFactory::getApplication();
$messages = $app->getMessageQueue();
if (is_array($messages) && count($messages))
foreach ($messages as $msg)
if (isset($msg['type']) && isset($msg['message']))
return true;
return false;
}
/**
* Returns true when one of the given positions contains at least one module.
* Example:
* if ($obj->containsModules('top1', 'top2', 'top3')) {
* // the following code will be executed when one of the positions contains modules:
* ...
* }
*/
public function containsModules()
{
foreach (func_get_args() as $position)
if (0 != $this->page->countModules($position))
return true;
return false;
}
/**
* Builds list of positions, collapsing the empty ones.
*
* Samples:
* Four positions:
* No empty positions: 25%:25%:25%:25%
* With one empty position: -:50%:25%:25%, 50%:-:25%:25%, 25%:50%:-:25%, 25%:25%:50%:-
* With two empty positions: -:-:75%:25%, -:50%:-:50%, -:50%:50%:-, -:50%:50%:-, 75%:-:-:25%, 50%:-:50%:-, 25%:75%:-:-
* One non-empty position: 100%
* Three positions:
* No empty positions: 33%:33%:34%
* With one empty position: -:66%:34%, 50%:-:50%, 33%:67%:-
* One non-empty position: 100%
*/
public function positions($positions, $style)
{
// Build $cells by collapsing empty positions:
$cells = array();
$buffer = 0;
$cell = null;
foreach ($positions as $name => $width) {
if ($this->containsModules($name)) {
$cells[$name] = $buffer + $width;
$buffer = 0;
$cell = $name;
} else if (null == $cell)
$buffer += $width;
else
$cells[$cell] += $width;
}
// Backward compatibility:
// For three equal width columns with empty center position width should be 50/50:
if (3 == count($positions) && 2 == count($cells)) {
$columns1 = array_keys($positions);
$columns2 = array_keys($cells);
if (33 == $positions[$columns1[0]] && 33 == $positions[$columns1[1]] && 34 == $positions[$columns1[2]]
&& $columns2[0] == $columns1[0] && $columns2[1] == $columns1[2])
{
$cells[$columns2[0]] = 50;
$cells[$columns2[1]] = 50;
}
}
// Render $cells:
if (count($cells) == 0)
return '';
$result = '
';
$result .= '
';
foreach ($cells as $name => $width)
$result .='
' . $this->position($name, $style) . '
';
$result .= '
';
$result .= '
';
return $result;
}
public function position($position, $style = null)
{
return '';
}
/**
* Wraps component content into article style unless it is not wrapped already.
*
* The componentWrapper method gets the content of the 'component' buffer and searches for the '
' string in it.
* Then it wraps content of the buffer with art-post.
*/
public function componentWrapper()
{
if ($this->page->getType() != 'html')
return;
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$layout = JRequest::getCmd('layout');
$content = $this->page->getBuffer('component');
// Workarounds for Joomla bugs and inconsistencies:
switch ($option) {
case "com_content":
switch ($view) {
case "form":
if ("edit" == $layout)
$content = str_replace('