Skip to content

Commit

Permalink
T3Layout: Fix show/hide function
Browse files Browse the repository at this point in the history
Remove hidden class on layout in backend
  • Loading branch information
joomlart committed May 3, 2013
1 parent a8039d3 commit e39795b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
16 changes: 10 additions & 6 deletions source/plg_system_t3/includes/core/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ public function __construct($template = null)

$layout = JFactory::getApplication()->input->getCmd('t3layout', '');
if(empty($layout)){
$layout = $template->params->get('mainlayout', 'default-joomla-3.x');
$layout = $template->params->get('mainlayout', 'default');
}

$fconfig = JPATH_ROOT . '/templates/' . $template->template . '/etc/layout/' . $layout . '.ini';
if(is_file($fconfig)){
jimport('joomla.filesystem.file');
Expand Down Expand Up @@ -98,7 +99,7 @@ public function setParam ($name, $value) {
* @return string Layout name
*/
public function getLayout () {
return JFactory::getApplication()->input->getCmd ('tmpl') ? JFactory::getApplication()->input->getCmd ('tmpl') : $this->getParam('mainlayout');
return JFactory::getApplication()->input->getCmd ('tmpl') ? JFactory::getApplication()->input->getCmd ('tmpl') : $this->getParam('mainlayout', 'default');
}

/**
Expand Down Expand Up @@ -456,12 +457,15 @@ function _c ($name, $cls = array()){
$data = '';
$param = $this->getLayoutSetting($name, '');

if(empty($param) && is_string($cls)){
$data = ' ' . $cls;
} else if (is_array($cls)){
if(empty($param)){
if(empty($param)){
if(is_string($cls)){
$data = ' ' . $cls;
} else if (is_array($cls)){
$param = (object)$cls;
}
}

if(!empty($param)){

$data = '"';
$data .= isset($param->default) ? ' data-default="' . $param->default . '"' : '';
Expand Down
32 changes: 30 additions & 2 deletions source/plg_system_t3/includes/core/templatelayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,46 @@ function _c($name, $cls = array()) {

$posparams = $this->getLayoutSetting($name, '');

$cinfo = $oinfo = $this->parseVisibility($cls);
$cinfo = $oinfo = $this->parseVisibility(is_string($cls) ? array('default' => $cls) : (is_array($cls) ? $cls : array()));
if(!empty($posparams)){
$cinfo = $this->parseVisibility($posparams);
}

$data = '';
$visible = array(
'name' => $name,
'vals' => $this->extractKey(array($cinfo), 'hidden'),
'deft' => $this->extractKey(array($oinfo), 'hidden')
);

echo parent::_c($name, $cls) . '" data-vis="' . $this->htmlattr($visible) . '" data-others="' . $this->htmlattr($this->extractKey(array($oinfo), 'others'));
if(empty($posparams)){
if(is_string($cls)){
$data = ' ' . $cls;
} else if (is_array($cls)){
$posparams = (object)$cls;
}
}

if(!empty($posparams)){

$data = '"';
$data .= isset($posparams->default) ? ' data-default="' . $posparams->default . '"' : '';
$data .= isset($posparams->normal) ? ' data-normal="' . $posparams->normal . '"' : '';
$data .= isset($posparams->wide) ? ' data-wide="' . $posparams->wide . '"' : '';
$data .= isset($posparams->xtablet) ? ' data-xtablet="' . $posparams->xtablet . '"' : '';
$data .= isset($posparams->tablet) ? ' data-tablet="' . $posparams->tablet . '"' : '';
$data .= isset($posparams->mobile) ? ' data-mobile="' . $posparams->mobile . '"' : '';

if($data == '"'){
$data = '';
} else {
$data = (isset($posparams->default) ? ' ' . $posparams->default : '') . ' t3respon' . substr($data, 0, strrpos($data, '"'));
}
}

$data = preg_replace('@("|\s)?hidden(\s|")?@iU', '$1$2', $data);

echo $data . '" data-vis="' . $this->htmlattr($visible) . '" data-others="' . $this->htmlattr($this->extractKey(array($oinfo), 'others'));
}

protected function _parse($html) {
Expand Down

0 comments on commit e39795b

Please sign in to comment.