Skip to content

Commit

Permalink
added possibility to add individual CSS class to page data tab
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.code.sf.net/p/cmsimplexh/code/trunk@1532 4f8f9682-67af-44ce-aacd-401fd16d96b5
  • Loading branch information
cmb69 committed Apr 21, 2015
1 parent bfd8e35 commit ee7f728
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
5 changes: 3 additions & 2 deletions cmsimple/classes/PageDataModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,13 @@ public function removeParam($field)
*
* @param string $title The title of the tab.
* @param string $view_file The filename of the view.
* @param string $cssClass A CSS class name.
*
* @return void
*/
public function addTab($title, $view_file)
public function addTab($title, $view_file, $cssClass = null)
{
$this->tabs[$title] = $view_file;
$this->tabs[$title] = array($view_file, $cssClass);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions cmsimple/classes/PageDataRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,15 @@ public function removeInterest($field)
*
* @param string $tab_name The title of the tab.
* @param string $tab_view The filename of the view.
* @param string $cssClass A CSS class name.
*
* @return void
*/
// @codingStandardsIgnoreStart
public function add_tab($tab_name, $tab_view)
public function add_tab($tab_name, $tab_view, $cssClass = null)
{
// @codingStandardsIgnoreEnd
$this->model->addTab($tab_name, $tab_view);
$this->model->addTab($tab_name, $tab_view, $cssClass);
}

/**
Expand Down
15 changes: 9 additions & 6 deletions cmsimple/classes/PageDataView.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,21 @@ public function __construct($page, $tabs = null)
*
* @param string $title Label of the tab.
* @param string $filename Name of the view file.
* @param string $cssClass A CSS class.
*
* @return string HTML
*
* @access protected
*
* @todo Declare visibility.
*/
function tab($title, $filename)
function tab($title, $filename, $cssClass)
{
list($function, $dummy) = explode('.', basename($filename), 2);
// TODO: use something more appropriate than an anchor
return "\n\t" . '<a class="xh_inactive_tab" id="xh_tab_' . $function
. '" onclick="XH.toggleTab(\'' . $function . '\');"><span>'
. $title . '</span></a>';
. '" onclick="XH.toggleTab(\'' . $function . '\');"><span class="'
. $cssClass . '">' . $title . '</span></a>';
}

/**
Expand All @@ -86,8 +87,9 @@ function tab($title, $filename)
function tabs()
{
$o = "\n" . '<div id="xh_pdtabs">';
foreach ($this->tabs as $title => $file) {
$o .= $this->tab($title, $file);
foreach ($this->tabs as $title => $array) {
list($file, $cssClass) = $array;
$o .= $this->tab($title, $file, $cssClass);
}
$o .= "\n</div>";
return $o;
Expand Down Expand Up @@ -145,7 +147,8 @@ function view($filename)
public function views()
{
$o = "\n" . '<div id="xh_pdviews">';
foreach ($this->tabs as $title => $file) {
foreach ($this->tabs as $title => $array) {
$file = $array[0];
$o .= $this->view($file);
}
$o .= "\n" . '</div>';
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/PageDataViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class PageDataViewTest extends PHPUnit_Framework_TestCase
public function setUp()
{
$tabs = array(
'Meta' => 'Metatags_view.php',
'Page' => 'Pageparams_view.php'
'Meta' => array('Metatags_view.php', null),
'Page' => array('Pageparams_view.php', null)
);
$this->pageDataView = new XH_PageDataView(array(), $tabs);
}
Expand All @@ -54,7 +54,7 @@ public function testTab()
'content' => $title
)
);
$actual = $this->pageDataView->tab($title, $filename);
$actual = $this->pageDataView->tab($title, $filename, null);
@$this->assertTag($matcher, $actual);
}

Expand Down

0 comments on commit ee7f728

Please sign in to comment.