From: <gem...@li...> - 2012-02-08 12:24:44
|
Revision: 462 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=462&view=rev Author: matijsdejong Date: 2012-02-08 12:24:32 +0000 (Wed, 08 Feb 2012) Log Message: ----------- Standard button use for BrowseEditAction.php Added Icons for track rounds Modified Paths: -------------- branches/1.5.x/library/classes/Gems/Controller/BrowseEditAction.php branches/1.5.x/library/classes/Gems/Html.php branches/1.5.x/library/classes/Gems/Snippets/TokenModelSnippetAbstract.php branches/1.5.x/library/classes/Gems/Tracker/Engine/StepEngineAbstract.php branches/1.5.x/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php branches/1.5.x/library/classes/Gems/Tracker/Model/StandardTokenModel.php branches/1.5.x/library/classes/MUtil/Model/FormBridge.php branches/1.5.x/library/configs/db/patches.sql branches/1.5.x/library/configs/db/tables/gems__rounds.40.sql branches/1.5.x/library/snippets/RespondentTokenSnippet.php branches/1.5.x/library/snippets/ShowRoundStepSnippet.php branches/1.5.x/library/snippets/TrackSurveyOverviewSnippet.php branches/1.5.x/library/snippets/TrackTokenOverviewSnippet.php Added Paths: ----------- branches/1.5.x/library/classes/MUtil/Form/Element/Multiselect.php branches/1.5.x/library/classes/MUtil/Form/Element/Select.php branches/1.5.x/library/classes/MUtil/View/Helper/FormSelectHtml.php Modified: branches/1.5.x/library/classes/Gems/Controller/BrowseEditAction.php =================================================================== --- branches/1.5.x/library/classes/Gems/Controller/BrowseEditAction.php 2012-02-08 12:15:39 UTC (rev 461) +++ branches/1.5.x/library/classes/Gems/Controller/BrowseEditAction.php 2012-02-08 12:24:32 UTC (rev 462) @@ -186,11 +186,16 @@ protected function addBrowseTableColumns(MUtil_Model_TableBridge $bridge, MUtil_Model_ModelAbstract $model) { // Add edit button if allowed, otherwise show, again if allowed - if ($menuItem = $this->findAllowedMenuItem('edit', 'show')) { + if ($menuItem = $this->findAllowedMenuItem('show')) { $bridge->addItemLink($menuItem->toActionLinkLower($this->getRequest(), $bridge)); } parent::addBrowseTableColumns($bridge, $model); + + // Add edit button if allowed, otherwise show, again if allowed + if ($menuItem = $this->findAllowedMenuItem('edit')) { + $bridge->addItemLink($menuItem->toActionLinkLower($this->getRequest(), $bridge)); + } } /** @@ -959,7 +964,12 @@ $table->setOnEmpty(sprintf($this->_('Unknown %s.'), $this->getTopic(1))); $table->setRepeater($repeater); $table->tfrow($this->createMenuLinks($this->menuShowIncludeLevel), array('class' => 'centerAlign')); + + if ($menuItem = $this->findAllowedMenuItem('edit')) { + $table->tbody()->onclick = array('location.href=\'', $menuItem->toHRefAttribute($this->getRequest()), '\';'); + } + $this->html[] = $table; } } Modified: branches/1.5.x/library/classes/Gems/Html.php =================================================================== --- branches/1.5.x/library/classes/Gems/Html.php 2012-02-08 12:15:39 UTC (rev 461) +++ branches/1.5.x/library/classes/Gems/Html.php 2012-02-08 12:24:32 UTC (rev 462) @@ -1,49 +1,49 @@ <?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - + /** - * File description of Gems_Html + * Copyright (c) 2011, Erasmus MC + * All rights reserved. * - * @author Matijs de Jong <mj...@ma...> - * @since 1.0 - * @version 1.4 - * @package Gems + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package Gems * @subpackage Html + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ /** - * Class description of Gems_Html + * Gems specific Html elements and settings * - * @author Matijs de Jong <mj...@ma...> - * @package Gems + * @package Gems * @subpackage Html + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 */ class Gems_Html { @@ -87,6 +87,7 @@ // Set the image directories MUtil_Html_ImgElement::addImageDir('gems/images'); + MUtil_Html_ImgElement::addImageDir('gems/icons'); $escort = GemsEscort::getInstance(); if (isset($escort->project->imagedir)) { MUtil_Html_ImgElement::addImageDir($escort->project->imagedir); @@ -146,7 +147,7 @@ } else { $args['class'] = new MUtil_Html_ClassArrayAttribute('browselink'); } - + // MUtil_Echo::r($args); $pager = new MUtil_Html_PagePanel($panel_args); Modified: branches/1.5.x/library/classes/Gems/Snippets/TokenModelSnippetAbstract.php =================================================================== --- branches/1.5.x/library/classes/Gems/Snippets/TokenModelSnippetAbstract.php 2012-02-08 12:15:39 UTC (rev 461) +++ branches/1.5.x/library/classes/Gems/Snippets/TokenModelSnippetAbstract.php 2012-02-08 12:24:32 UTC (rev 462) @@ -54,6 +54,26 @@ */ public $loader; + protected function addTokenLinks(MUtil_Model_TableBridge $bridge) + { + $title = MUtil_Html::create()->strong($this->_('+')); + + $showLinks[] = $this->createMenuLink($bridge, 'track', 'show', $title); + $showLinks[] = $this->createMenuLink($bridge, 'survey', 'show', $title); + + // Remove nulls + $showLinks = array_filter($showLinks); + + if ($showLinks) { + foreach ($showLinks as $showLink) { + if ($showLink) { + $showLink->title = array($this->_('Token'), $bridge->gto_id_token->strtoupper()); + } + } + } + $bridge->addItemLink($showLinks); + } + /** * Creates the model * @@ -71,10 +91,12 @@ 'calc_valid_from', 'gto_valid_from'); $model->addColumn( - 'CASE WHEN gto_completion_time IS NULL THEN gto_id_token ELSE NULL END', + 'CASE WHEN gto_completion_time IS NULL AND grc_success = 1 AND gto_valid_from <= CURRENT_TIMESTAMP AND gto_completion_time IS NULL AND (gto_valid_until IS NULL OR gto_valid_until >= CURRENT_TIMESTAMP) THEN gto_id_token ELSE NULL END', 'calc_id_token', 'gto_id_token'); - + $model->addColumn( + 'CASE WHEN gto_completion_time IS NULL AND grc_success = 1 AND gto_valid_from <= CURRENT_TIMESTAMP AND gto_completion_time IS NULL AND gto_valid_until < CURRENT_TIMESTAMP THEN 1 ELSE 0 END', + 'was_missed'); return $model; } Modified: branches/1.5.x/library/classes/Gems/Tracker/Engine/StepEngineAbstract.php =================================================================== --- branches/1.5.x/library/classes/Gems/Tracker/Engine/StepEngineAbstract.php 2012-02-08 12:15:39 UTC (rev 461) +++ branches/1.5.x/library/classes/Gems/Tracker/Engine/StepEngineAbstract.php 2012-02-08 12:24:32 UTC (rev 462) @@ -438,6 +438,7 @@ $model->set('gro_id_survey'); $model->set('gro_round_description'); $model->set('gro_id_order'); + $model->set('gro_icon_file'); // Calculate valid from $model->set('valid_after', 'elementClass', 'html', 'label', ' ', 'value', MUTil_Html::create()->h4($this->_('Valid from calculation'))); Modified: branches/1.5.x/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php =================================================================== --- branches/1.5.x/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2012-02-08 12:15:39 UTC (rev 461) +++ branches/1.5.x/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2012-02-08 12:24:32 UTC (rev 462) @@ -112,6 +112,12 @@ protected $util; /** + * + * @var Zend_View + */ + protected $view; + + /** * Copy from Zend_Translate_Adapter * * Translates the given string @@ -191,6 +197,27 @@ } /** + * Returns a list of available icons under 'htdocs/pulse/icons' + * @return string[] + */ + protected function _getAvailableIcons() + { + $icons = array(); + $iterator = new DirectoryIterator(realpath(GEMS_WEB_DIR . '/gems/icons')); + + foreach ($iterator as $fileinfo) { + if ($fileinfo->isFile()) { + // $icons[$fileinfo->getFilename()] = $fileinfo->getFilename(); + $filename = $fileinfo->getFilename(); + $url = $this->view->baseUrl() . MUtil_Html_ImgElement::getImageDir($filename); + $icons[$fileinfo->getFilename()] = MUtil_Html::create('span', $filename, array('style' => 'background: transparent url(' . $url . $filename . ') center right no-repeat; padding-right: 20px;')); + } + } + + return $icons; + } + + /** * Update the track, both in the database and in memory. * * @param array $values The values that this token should be set to @@ -707,17 +734,29 @@ } $model->set('gro_id_survey', 'label', $this->_('Survey'), 'multiOptions', $this->util->getTrackData()->getAllSurveysAndDescriptions()); + $model->set('gro_icon_file', 'label', $this->_('Icon')); $model->set('gro_id_order', 'label', $this->_('Order'), 'default', 10, 'validators[]', $model->createUniqueValidator(array('gro_id_order', 'gro_id_track'))); $model->set('gro_round_description', 'label', $this->_('Description'), 'size', '30'); //, 'minlength', 4, 'required', true); $model->set('gro_changed_event', 'label', $this->_('After change'), 'multiOptions', $this->events->listRoundChangedEvents()); $model->set('gro_active', 'label', $this->_('Active'), 'multiOptions', $this->util->getTranslated()->getYesNo(), 'elementClass', 'checkbox'); - if ($action == 'create') { - $this->_ensureRounds(); + switch ($action) { + case 'create': + $this->_ensureRounds(); - if ($this->_rounds && ($round = end($this->_rounds))) { - $model->set('gro_id_order', 'default', $round['gro_id_order'] + 10); - } + if ($this->_rounds && ($round = end($this->_rounds))) { + $model->set('gro_id_order', 'default', $round['gro_id_order'] + 10); + } + // Intentional fall through + // break; + case 'edit': + $model->set('gro_icon_file', 'multiOptions', $this->util->getTranslated()->getEmptyDropdownArray() + $this->_getAvailableIcons()); + break; + + default: + $model->set('gro_icon_file', 'formatFunction', array('MUtil_Html_ImgElement', 'imgFile')); + break; + } return $model; Modified: branches/1.5.x/library/classes/Gems/Tracker/Model/StandardTokenModel.php =================================================================== --- branches/1.5.x/library/classes/Gems/Tracker/Model/StandardTokenModel.php 2012-02-08 12:15:39 UTC (rev 461) +++ branches/1.5.x/library/classes/Gems/Tracker/Model/StandardTokenModel.php 2012-02-08 12:24:32 UTC (rev 462) @@ -167,10 +167,16 @@ } //If we are allowed to see who filled out a survey, modify the model accordingly - if (GemsEscort::getInstance()->hasPrivilege('pr.respondent.who')) { + $escort = GemsEscort::getInstance(); + if ($escort->hasPrivilege('pr.respondent.who')) { $this->addLeftTable('gems__staff', array('gto_by' => 'gems__staff_2.gsf_id_user')); $this->addColumn('CASE WHEN gems__staff_2.gsf_id_user IS NULL THEN ggp_name ELSE COALESCE(CONCAT_WS(" ", CONCAT(COALESCE(gems__staff_2.gsf_last_name,"-"),","), gems__staff_2.gsf_first_name, gems__staff_2.gsf_surname_prefix)) END', 'ggp_name'); } + if ($escort->hasPrivilege('pr.respondent.result')) { + $this->addColumn('gto_result', 'calc_result', 'gto_result'); + } else { + $this->addColumn('NULL', 'calc_result', 'gto_result'); + } $this->useTokenAsKey(); } Added: branches/1.5.x/library/classes/MUtil/Form/Element/Multiselect.php =================================================================== --- branches/1.5.x/library/classes/MUtil/Form/Element/Multiselect.php (rev 0) +++ branches/1.5.x/library/classes/MUtil/Form/Element/Multiselect.php 2012-02-08 12:24:32 UTC (rev 462) @@ -0,0 +1,54 @@ +<?php + +/** + * Copyright (c) 2012, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package MUtil + * @subpackage Form + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: MultiselectRaw.php 203 2012-01-01t 12:51:32Z matijs $ + */ + +/** + * Add Html labels to standard parent + * + * @package MUtil + * @subpackage Form + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5 + */ +class MUtil_Form_Element_Multiselect extends Zend_Form_Element_Multiselect +{ + /** + * Use formSelect view helper by default + * @var string + */ + public $helper = 'formSelectHtml'; +} Added: branches/1.5.x/library/classes/MUtil/Form/Element/Select.php =================================================================== --- branches/1.5.x/library/classes/MUtil/Form/Element/Select.php (rev 0) +++ branches/1.5.x/library/classes/MUtil/Form/Element/Select.php 2012-02-08 12:24:32 UTC (rev 462) @@ -0,0 +1,54 @@ +<?php + +/** + * Copyright (c) 2012, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package MUtil + * @subpackage Form + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: Select.php 203 2012-01-01t 12:51:32Z matijs $ + */ + +/** + * Add Html labels to standard parent + * + * @package MUtil + * @subpackage Form + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5 + */ +class MUtil_Form_Element_Select extends Zend_Form_Element_Select +{ + /** + * Use formSelect view helper by default + * @var string + */ + public $helper = 'formSelectHtml'; +} Modified: branches/1.5.x/library/classes/MUtil/Model/FormBridge.php =================================================================== --- branches/1.5.x/library/classes/MUtil/Model/FormBridge.php 2012-02-08 12:15:39 UTC (rev 461) +++ branches/1.5.x/library/classes/MUtil/Model/FormBridge.php 2012-02-08 12:24:32 UTC (rev 462) @@ -553,7 +553,7 @@ $options = $this->_mergeOptions($name, $options, self::DISPLAY_OPTIONS, self::MULTI_OPTIONS); - $element = new Zend_Form_Element_Select($name, $options); + $element = new MUtil_Form_Element_Select($name, $options); return $this->_addToForm($name, $element); } @@ -603,7 +603,7 @@ $options = $this->_mergeOptions($name, $options, self::DISPLAY_OPTIONS, self::MULTI_OPTIONS); - $element = new Zend_Form_Element_Multiselect($name, $options); + $element = new MUtil_Form_Element_Multiselect($name, $options); return $this->_addToForm($name, $element); } Added: branches/1.5.x/library/classes/MUtil/View/Helper/FormSelectHtml.php =================================================================== --- branches/1.5.x/library/classes/MUtil/View/Helper/FormSelectHtml.php (rev 0) +++ branches/1.5.x/library/classes/MUtil/View/Helper/FormSelectHtml.php 2012-02-08 12:24:32 UTC (rev 462) @@ -0,0 +1,132 @@ +<?php + +/** + * Copyright (c) 2012, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package MUtil + * @subpackage View + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: FormSelectHtml.php 203 2012-01-01t 12:51:32Z matijs $ + */ + +/** + * + * + * @package MUtil + * @subpackage View + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5 + */ +class MUtil_View_Helper_FormSelectHtml extends Zend_View_Helper_FormSelect +{ + /** + * Builds the actual <option> tag + * + * @param string $value Options Value + * @param string $label Options Label + * @param array $selected The option value(s) to mark as 'selected' + * @param array|bool $disable Whether the select is disabled, or individual options are + * @return string Option Tag XHTML + */ + protected function _build($value, $label, $selected, $disable) + { + if (is_bool($disable)) { + $disable = array(); + } + + $opt = '<option' + . ' value="' . $this->view->escape($value) . '"'; + + if ($label instanceof MUtil_Html_HtmlElement) { + // Element not allowed, get parts that are allowed + foreach (array('class', 'dir', 'id', 'label', 'lang', 'style', 'title') as $attr) { + if (isset($label->$attr)) { + $opt .= ' ' . $attr . '="' . $this->view->escape($label->$attr) . '"'; + } + } + + // Now get the content + $renderer = MUtil_Html::getRenderer(); + $content = ''; + foreach ($label->getIterator() as $part) { + $content .= $renderer->renderAny($this->view, $part); + } + + } elseif ($label instanceof MUtil_Html_HtmlInterface) { + $content = $label->render($this->view); + } else { + $content = $this->view->escape($label); + $opt .= ' label="' . $this->view->escape($label) . '"'; + + } + + // selected? + if (in_array((string) $value, $selected)) { + $opt .= ' selected="selected"'; + } + + // disabled? + if (in_array($value, $disable)) { + $opt .= ' disabled="disabled"'; + } + + $opt .= '>' . $content . "</option>"; + + return $opt; + } + /** + * Generates 'select' list of options. + * + * @access public + * + * @param string|array $name If a string, the element name. If an + * array, all other parameters are ignored, and the array elements + * are extracted in place of added parameters. + * + * @param mixed $value The option value to mark as 'selected'; if an + * array, will mark all values in the array as 'selected' (used for + * multiple-select elements). + * + * @param array|string $attribs Attributes added to the 'select' tag. + * + * @param array $options An array of key-value pairs where the array + * key is the radio value, and the array value is the radio text. + * + * @param string $listsep When disabled, use this list separator string + * between list values. + * + * @return string The select tag and options XHTML. + */ + public function formSelectHtml($name, $value = null, $attribs = null, + $options = null, $listsep = "<br />\n") + { + return parent::formSelect($name, $value, $attribs, $options, $listsep); + } +} Modified: branches/1.5.x/library/configs/db/patches.sql =================================================================== --- branches/1.5.x/library/configs/db/patches.sql 2012-02-08 12:15:39 UTC (rev 461) +++ branches/1.5.x/library/configs/db/patches.sql 2012-02-08 12:24:32 UTC (rev 462) @@ -364,4 +364,7 @@ -- PATCH: Default userdefinition per organization ALTER TABLE gems__organizations ADD `gor_user_class` VARCHAR( 30 ) NOT NULL DEFAULT 'StaffUser' AFTER `gor_code`; -ALTER TABLE `gems__radius_config` CHANGE `grcfg_ip` `grcfg_ip` VARCHAR( 39 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL \ No newline at end of file +ALTER TABLE `gems__radius_config` CHANGE `grcfg_ip` `grcfg_ip` VARCHAR( 39 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL + +-- PATCH: Add icon field to rounds +ALTER TABLE `gems__rounds` ADD gro_icon_file VARCHAR(100) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null AFTER `gro_round_description`; Modified: branches/1.5.x/library/configs/db/tables/gems__rounds.40.sql =================================================================== --- branches/1.5.x/library/configs/db/tables/gems__rounds.40.sql 2012-02-08 12:15:39 UTC (rev 461) +++ branches/1.5.x/library/configs/db/tables/gems__rounds.40.sql 2012-02-08 12:24:32 UTC (rev 462) @@ -12,6 +12,7 @@ gro_survey_name varchar(100) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null, gro_round_description varchar(100) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null, + gro_icon_file VARCHAR(100) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null, gro_changed_event varchar(64) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null, -- depreciated Modified: branches/1.5.x/library/snippets/RespondentTokenSnippet.php =================================================================== --- branches/1.5.x/library/snippets/RespondentTokenSnippet.php 2012-02-08 12:15:39 UTC (rev 461) +++ branches/1.5.x/library/snippets/RespondentTokenSnippet.php 2012-02-08 12:24:32 UTC (rev 462) @@ -104,6 +104,8 @@ $roundDescription[] = $HTML->if($bridge->calc_round_description, $HTML->small(' [', $bridge->calc_round_description, ']')); $roundDescription[] = $HTML->small(' [', $bridge->createSortLink('calc_round_description'), ']'); + $roundIcon[] = MUtil_Lazy::iif($bridge->gro_icon_file, MUtil_Html::create('img', array('src' => $bridge->gro_icon_file, 'class' => 'icon'))); + if ($menuItem = $this->findMenuItem('track', 'show-track')) { $href = $menuItem->toHRefAttribute($this->request, $bridge); $track1 = $HTML->if($bridge->calc_track_name, $HTML->a($href, $bridge->calc_track_name)); @@ -120,7 +122,7 @@ // $bridge->colgroup(array('span' => 3, 'width' => '9em')); $bridge->addMultiSort($track); - $bridge->addMultiSort('gsu_survey_name', $roundDescription); + $bridge->addMultiSort('gsu_survey_name', $roundDescription, $roundIcon); $bridge->addSortable('ggp_name'); $bridge->addSortable('calc_used_date', null, $HTML->if($bridge->is_completed, 'disabled date', 'enabled date')); $bridge->addSortable('gto_changed'); @@ -135,10 +137,6 @@ $bridge->useRowHref = false; - $title = $HTML->strong($this->_('+')); - - $showLinks[] = $this->createMenuLink($bridge, 'track', 'show', $title); - $showLinks[] = $this->createMenuLink($bridge, 'survey', 'show', $title); $actionLinks[] = $this->createMenuLink($bridge, 'track', 'answer'); $actionLinks[] = $this->createMenuLink($bridge, 'survey', 'answer'); $actionLinks[] = array( @@ -149,18 +147,13 @@ // MUtil_Lazy::comp($bridge->val1, '==', $bridge->val2)->if($bridge->val3, 'broehaha'); // Remove nulls - $showLinks = array_filter($showLinks); $actionLinks = array_filter($actionLinks); - if ($showLinks || $actionLinks) { - foreach ($showLinks as $showLink) { - if ($showLink) { - $showLink->title = array($this->_('Token'), $bridge->gto_id_token->strtoupper()); - } - } + if ($actionLinks) { $bridge->addItemLink($actionLinks); - $bridge->addItemLink($showLinks); } + + $this->addTokenLinks($bridge); } /** Modified: branches/1.5.x/library/snippets/ShowRoundStepSnippet.php =================================================================== --- branches/1.5.x/library/snippets/ShowRoundStepSnippet.php 2012-02-08 12:15:39 UTC (rev 461) +++ branches/1.5.x/library/snippets/ShowRoundStepSnippet.php 2012-02-08 12:24:32 UTC (rev 462) @@ -94,6 +94,7 @@ $bridge->addItem('gro_id_survey'); $bridge->addItem('gro_round_description'); $bridge->addItem('gro_id_order'); + $bridge->addItem('gro_icon_file'); $bridge->addItem($model->get('valid_after', 'value')); $this->_addIf(array('grp_valid_after_source', 'grp_valid_after_id', 'grp_valid_after_field'), $bridge, $model); @@ -109,6 +110,13 @@ $bridge->addItem('gro_active'); $bridge->addItem('gro_changed_event'); + + $menuItem = $this->menu->find(array( + $this->request->getControllerKey() => $this->request->getControllerName(), + $this->request->getActionKey() => 'edit')); + if ($menuItem) { + $bridge->tbody()->onclick = array('location.href=\'', $menuItem->toHRefAttribute($this->request), '\';'); + } } /** Modified: branches/1.5.x/library/snippets/TrackSurveyOverviewSnippet.php =================================================================== --- branches/1.5.x/library/snippets/TrackSurveyOverviewSnippet.php 2012-02-08 12:15:39 UTC (rev 461) +++ branches/1.5.x/library/snippets/TrackSurveyOverviewSnippet.php 2012-02-08 12:24:32 UTC (rev 462) @@ -105,7 +105,10 @@ $table->addColumn($link->toActionLinkLower($trackRepeater)); } - $table->addColumn($trackRepeater->gsu_survey_name, $this->_('Survey')); + $surveyName[] = $trackRepeater->gsu_survey_name; + $surveyName[] = MUtil_Lazy::iif($trackRepeater->gro_icon_file, MUtil_Html::create('img', array('src' => $trackRepeater->gro_icon_file, 'class' => 'icon'))); + + $table->addColumn($surveyName, $this->_('Survey')); $table->addColumn($trackRepeater->gro_round_description, $this->_('Details')); $table->addColumn($trackRepeater->ggp_name, $this->_('By')); $table->addColumn($trackRepeater->gsu_survey_description->call(array(__CLASS__, 'oneLine')), @@ -116,7 +119,7 @@ private function getRepeater($trackId) { $sql = " - SELECT gro_id_round, gro_id_track, gro_round_description, gro_valid_after, gro_valid_for, gro_used_date, gro_active, + SELECT gro_id_round, gro_id_track, gro_round_description, gro_icon_file, gro_valid_after, gro_valid_for, gro_used_date, gro_active, gsu_id_survey, gsu_survey_name, gsu_survey_description, gsu_survey_pdf, gsu_active, ggp_name FROM gems__rounds LEFT JOIN gems__surveys ON gro_id_survey = gsu_id_survey Modified: branches/1.5.x/library/snippets/TrackTokenOverviewSnippet.php =================================================================== --- branches/1.5.x/library/snippets/TrackTokenOverviewSnippet.php 2012-02-08 12:15:39 UTC (rev 461) +++ branches/1.5.x/library/snippets/TrackTokenOverviewSnippet.php 2012-02-08 12:24:32 UTC (rev 462) @@ -103,7 +103,8 @@ $showLinks = array_filter($showLinks); // Columns - $bridge->addSortable('gsu_survey_name'); + $bridge->addSortable('gsu_survey_name') + ->append(MUtil_Lazy::iif($bridge->gro_icon_file, MUtil_Html::create('img', array('src' => $bridge->gro_icon_file, 'class' => 'icon')))); $bridge->addSortable('gto_round_description'); $bridge->addSortable('ggp_name'); $bridge->addSortable('gto_valid_from', null, 'date'); @@ -133,7 +134,6 @@ } $bridge->addItemLink($showLinks); } - } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |