Skip to content

Commit

Permalink
New feature : more class on question and answer item for easiest mani…
Browse files Browse the repository at this point in the history
…pulation

New feature : more explicit label for accessibility, hidden by default with .hide class
Dev : TODO same table.question
Dev : Add answers-list , answer-item , questions-list, type_of_answer-item, type_of_answer-list
Dev : Add some question attribute specific class on answer wrapper ( noanswer-item, numberonly, maxchars ..) : TODO : documentation

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@12403 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
shnoulle committed Feb 8, 2012
1 parent e1362c3 commit 9d3da4e
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 111 deletions.
38 changes: 18 additions & 20 deletions application/helpers/common_helper.php
Expand Up @@ -950,6 +950,8 @@ function getQuestionClass($input)
*
* @param integer $columns - the number of columns, usually supplied by $dcols
* @param integer $answer_count - the number of answers to a question, usually supplied by $anscount
* @param string $wrapperclass - a global class for the wrapper
* @param string $itemclass - a class for the item
* @return array with all the various opening and closing tags to generate a set of columns.
*
* It returns an array with the following items:
Expand All @@ -963,6 +965,8 @@ function getQuestionClass($input)
* option
* $wrapper['item-start-other'] = opening wrapper tag for other
* option
* $wrapper['item-start-noanswer'] = opening wrapper tag for no answer
* option
* $wrapper['item-end'] = closing wrapper tag for individual
* option
* $wrapper['maxrows'] = maximum number of rows in each
Expand Down Expand Up @@ -1010,18 +1014,11 @@ function getQuestionClass($input)
* 'ul' is the default because it's the best possible compromise
* between semantic markup and visual layout.
*/
function setupColumns($columns, $answer_count)
function setupColumns($columns, $answer_count,$wrapperclass="",$itemclass="")
{


$colstyle = COLSTYLE;

/*
if(defined('PRINT_TEMPLATE')) // This forces tables based columns for printablesurvey
{
$colstyle = 'table';
};
*/
if($columns < 2)
{
$colstyle = null;
Expand All @@ -1038,7 +1035,7 @@ function setupColumns($columns, $answer_count)
$columns = ceil($answer_count/ceil($answer_count/$columns)); // # of columns is # of answers divided by # of rows (all rounded up)
}

$class_first = '';
$class_first = ' class="'.$wrapperclass.'"';
if($columns > 1 && $colstyle != null)
{
if($colstyle == 'ul')
Expand All @@ -1049,25 +1046,26 @@ function setupColumns($columns, $answer_count)
{
$ul = '';
}
$class_first = ' class="cols-'.$columns . $ul.' first"';
$class = ' class="cols-'.$columns . $ul.'"';
$class_last_ul = ' class="cols-'.$columns . $ul.' last"';
$class_last_table = ' class="cols-'.$columns.' last"';
$class_first = ' class="'.$wrapperclass.' cols-'.$columns . $ul.' first"';
$class = ' class="'.$wrapperclass.' cols-'.$columns . $ul.'"';
$class_last_ul = ' class="'.$wrapperclass.' cols-'.$columns . $ul.' last"';
$class_last_table = ' class="'.$wrapperclass.' cols-'.$columns.' last"';
}
else
{
$class = '';
$class_last_ul = '';
$class_last_table = '';
$class = ' class="'.$wrapperclass.'"';
$class_last_ul = ' class="'.$wrapperclass.'"';
$class_last_table = ' class="'.$wrapperclass.'"';
};

$wrapper = array(
'whole-start' => "\n<ul$class_first>\n"
,'whole-end' => "</ul>\n"
,'col-devide' => ''
,'col-devide-last' => ''
,'item-start' => "\t<li>\n"
,'item-start-other' => "\t<li class=\"other\">\n"
,'item-start' => "\t<li class=\"{$itemclass}\">\n"
,'item-start-other' => "\t<li class=\"{$itemclass} other other-item\">\n"
,'item-start-noanswer' => "\t<li class=\"{$itemclass} noanswer-item\">\n"
,'item-end' => "\t</li>\n"
,'maxrows' => ceil($answer_count/$columns) //Always rounds up to nearest whole number
,'cols' => $columns
Expand Down Expand Up @@ -1102,8 +1100,8 @@ function setupColumns($columns, $answer_count)
};
$wrapper['whole-start'] = "\n<table$class>\n$table_cols\n\t<tbody>\n<tr>\n<td>\n\t<ul>\n";
$wrapper['whole-end'] = "\t</ul>\n</td>\n</tr>\n\t</tbody>\n</table>\n";
$wrapper['item-start'] = "<li>\n";
$wrapper['item-end'] = "</li>\n";
$wrapper['item-start'] = "<li class=\"{$itemclass}\">\n";
$wrapper['item-end'] = "</li class=\"{$itemclass}\">\n";
};

return $wrapper;
Expand Down

0 comments on commit 9d3da4e

Please sign in to comment.