From: <gem...@li...> - 2012-01-30 15:04:24
|
Revision: 432 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=432&view=rev Author: mennodekker Date: 2012-01-30 15:04:13 +0000 (Mon, 30 Jan 2012) Log Message: ----------- Final fix to formbridge + removed obsolete statement from staffaction Modified Paths: -------------- branches/1.5.x/library/classes/Gems/Default/StaffAction.php branches/1.5.x/library/classes/MUtil/Model/FormBridge.php Modified: branches/1.5.x/library/classes/Gems/Default/StaffAction.php =================================================================== --- branches/1.5.x/library/classes/Gems/Default/StaffAction.php 2012-01-30 13:36:35 UTC (rev 431) +++ branches/1.5.x/library/classes/Gems/Default/StaffAction.php 2012-01-30 15:04:13 UTC (rev 432) @@ -188,9 +188,6 @@ $this->_instanceId = $data['gsf_login']; } - $sql = "SELECT ggp_id_group,ggp_role FROM gems__groups WHERE ggp_id_group = " . (int) $data['gsf_id_primary_group']; - $groups = $this->db->fetchPairs($sql); - if (!isset($data['gsf_id_organization']) || empty($data['gsf_id_organization'])) { $data['gsf_id_organization'] = $this->menu->getParameterSource()->getMenuParameter('gsf_id_organization', $this->loader->getCurrentUser()->getCurrentOrganizationId()); } Modified: branches/1.5.x/library/classes/MUtil/Model/FormBridge.php =================================================================== --- branches/1.5.x/library/classes/MUtil/Model/FormBridge.php 2012-01-30 13:36:35 UTC (rev 431) +++ branches/1.5.x/library/classes/MUtil/Model/FormBridge.php 2012-01-30 15:04:13 UTC (rev 432) @@ -243,7 +243,11 @@ $options = func_get_args(); $options = MUtil_Ra::pairs($options, 1); - $options = $this->_mergeOptions($name, $options, self::AUTO_OPTIONS); + /** + * As this method redirects to the correct 'add' method, we preserve the original options + * while trying to find the needed ones in the model + */ + $options = $options + $this->_mergeOptions($name, $options, self::AUTO_OPTIONS); if (isset($options['elementClass'])) { $method = 'add' . $options['elementClass']; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-01-31 10:53:57
|
Revision: 437 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=437&view=rev Author: mennodekker Date: 2012-01-31 10:53:47 +0000 (Tue, 31 Jan 2012) Log Message: ----------- ported last browseedit fix to tabformsnippet, although it didn't seem necessary there?! fixed typo Modified Paths: -------------- branches/1.5.x/library/classes/Gems/Snippets/ModelTabFormSnippetGeneric.php branches/1.5.x/library/classes/MUtil/Snippets/ModelFormSnippetAbstract.php Modified: branches/1.5.x/library/classes/Gems/Snippets/ModelTabFormSnippetGeneric.php =================================================================== --- branches/1.5.x/library/classes/Gems/Snippets/ModelTabFormSnippetGeneric.php 2012-01-31 09:59:43 UTC (rev 436) +++ branches/1.5.x/library/classes/Gems/Snippets/ModelTabFormSnippetGeneric.php 2012-01-31 10:53:47 UTC (rev 437) @@ -56,6 +56,19 @@ protected $_form; /** + * Simple default function for making sure there is a $this->_saveButton. + * + * As the save button is not part of the model - but of the interface - it + * does deserve it's own function. + */ + protected function addSaveButton() + { + $this->_form->resetContext(); + parent::addSaveButton(); + } + + + /** * Perform some actions on the form, right before it is displayed but already populated * * Here we add the table display to the form. Modified: branches/1.5.x/library/classes/MUtil/Snippets/ModelFormSnippetAbstract.php =================================================================== --- branches/1.5.x/library/classes/MUtil/Snippets/ModelFormSnippetAbstract.php 2012-01-31 09:59:43 UTC (rev 436) +++ branches/1.5.x/library/classes/MUtil/Snippets/ModelFormSnippetAbstract.php 2012-01-31 10:53:47 UTC (rev 437) @@ -175,7 +175,7 @@ { $args = func_get_args(); if (count($args)<2) { - throw new Gems_Exception_Coding('Use at least 2 arguments, first the bridge and then one or more idividual items'); + throw new Gems_Exception_Coding('Use at least 2 arguments, first the bridge and then one or more individual items'); } $bridge = array_shift($args); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-02-02 17:01:38
|
Revision: 448 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=448&view=rev Author: matijsdejong Date: 2012-02-02 17:01:28 +0000 (Thu, 02 Feb 2012) Log Message: ----------- $html->snippet() adds a snippet to the content of the element Added documentation Modified Paths: -------------- branches/1.5.x/library/classes/Gems/Controller/BrowseEditAction.php branches/1.5.x/library/classes/MUtil/Controller/Action.php branches/1.5.x/library/classes/MUtil/Html/Creator.php branches/1.5.x/library/classes/MUtil/Html.php Modified: branches/1.5.x/library/classes/Gems/Controller/BrowseEditAction.php =================================================================== --- branches/1.5.x/library/classes/Gems/Controller/BrowseEditAction.php 2012-02-02 15:02:24 UTC (rev 447) +++ branches/1.5.x/library/classes/Gems/Controller/BrowseEditAction.php 2012-02-02 17:01:28 UTC (rev 448) @@ -310,7 +310,7 @@ $form->addElement($element); $form->addDisplayGroup(array('formLinks'), 'form_buttons'); } - } else { + } else { $table = new MUtil_Html_TableElement(array('class' => 'formTable')); $table->setAsFormLayout($form, true, true); $table['tbody'][0][0]->class = 'label'; // Is only one row with formLayout, so all in output fields get class. Modified: branches/1.5.x/library/classes/MUtil/Controller/Action.php =================================================================== --- branches/1.5.x/library/classes/MUtil/Controller/Action.php 2012-02-02 15:02:24 UTC (rev 447) +++ branches/1.5.x/library/classes/MUtil/Controller/Action.php 2012-02-02 17:01:28 UTC (rev 448) @@ -397,6 +397,8 @@ public function initHtml($reset = false) { if ($reset || (! $this->html)) { + MUtil_Html::setSnippetLoader($this->getSnippetLoader()); + $this->html = new MUtil_Html_Sequence(); // Add this variable to the view. Modified: branches/1.5.x/library/classes/MUtil/Html/Creator.php =================================================================== --- branches/1.5.x/library/classes/MUtil/Html/Creator.php 2012-02-02 15:02:24 UTC (rev 447) +++ branches/1.5.x/library/classes/MUtil/Html/Creator.php 2012-02-02 17:01:28 UTC (rev 448) @@ -1,6 +1,5 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -26,27 +25,56 @@ * 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 Html + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $id: Creator.php 362 2011-12-15 17:21:17Z matijsdejong $ */ /** - * @author Matijs de Jong - * @since 1.0 - * @version 1.1 - * @package MUtil + * Class for storing references for creating html attributes, elements and other objects. + * + * Basically this class stores list of element and attributes names that should be treated + * in different from just creating the most basic of element types. + * + * @package MUtil * @subpackage Html + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 */ class MUtil_Html_Creator { + /** + * + * @var MUtil_Util_LookupList + */ protected $_attributeFunctionList; + + /** + * + * @var MUtil_Util_LookupList + */ protected $_elementFunctionList; + /** + * + * @var array + */ protected $_initialAttributeFunctions = array( 'href' => 'MUtil_Html_HrefArrayAttribute::hrefAttribute', 'onclick' => 'MUtil_Html_OnClickArrayAttribute::onclickAttribute', 'style' => 'MUtil_Html_StyleArrayAttribute::styleAttribute', ); + /** + * + * @var array + */ protected $_initalElementFunctions = array( 'a' => 'MUtil_Html_AElement::a', 'array' => 'MUtil_Html_Sequence::createSequence', @@ -86,6 +114,7 @@ 'raw' => 'MUtil_Html_Raw::raw', 'seq' => 'MUtil_Html_Sequence::createSequence', 'sequence' => 'MUtil_Html_Sequence::createSequence', // A sequence can contain another sequence, so other function name used + 'snippet' => 'MUtil_Html::snippet', 'spaced' => 'MUtil_Html_Sequence::createSpaced', // A sequence can contain another sequence, so other function name used 'table' => 'MUtil_Html_TableElement::table', 'tbody' => 'MUtil_Html_TBodyElement::tbody', Modified: branches/1.5.x/library/classes/MUtil/Html.php =================================================================== --- branches/1.5.x/library/classes/MUtil/Html.php 2012-02-02 15:02:24 UTC (rev 447) +++ branches/1.5.x/library/classes/MUtil/Html.php 2012-02-02 17:01:28 UTC (rev 448) @@ -1,55 +1,69 @@ <?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. - */ - /** - * - * @author Matijs de Jong - * @since 1.0 - * @version 1.1 - * @package MUtil + * 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. + * + * @package MUtil * @subpackage Html + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $id: Html.php 362 2011-12-15 17:21:17Z matijsdejong $ */ /** * Collections of static function for using the Html subpackage. - * - * @author Matijs de Jong - * @package MUtil + * + * @package MUtil * @subpackage Html + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 */ class MUtil_Html { + /** + * + * @var MUtil_Html_Creator + */ private static $_creator; + + /** + * + * @var MUtil_Html_Renderer + */ private static $_renderer; /** + * + * @var type MUtil_Snippets_SnippetLoader + */ + private static $_snippetLoader; + + /** * Static variable for debuggging purposes. Toggles the echoing of e.g. of sql * select statements, using MUtil_Echo. * @@ -65,9 +79,10 @@ */ public static $verbose = false; - public static function canRender($value) + public static function addUrl2Page(Zend_Navigation_Container $menu, $label, $arg_array = null) { - return self::getRenderer()->canRender($value); + $args = array_slice(func_get_args(), 2); + $menu->addPage(self::url($args)->toPage($label)); } public static function attrib($attributeName, $args_array = null) @@ -77,6 +92,11 @@ return self::getCreator()->createAttribute($attributeName, $args); } + public static function canRender($value) + { + return self::getRenderer()->canRender($value); + } + /** * * @param string $tagName Optional tag to create @@ -101,7 +121,7 @@ /** * Creates a new HtmlElement with the arguments specfied in a single array. - * + * * @param string $tagName (or a Lazy object) * @param array $args * @return MUtil_Html_ElementInterface @@ -118,17 +138,17 @@ /** * Creates a div element - * + * * @param mixed $arg_array Optional MUtil_Ra::args processed settings * @return MUtil_Html_HtmlElement (with div tagName) */ public static function div($arg_array = null) { $args = func_get_args(); - + return self::getCreator()->create('div', $args); } - + public static function element2id(Zend_Form_Element $element) { return self::name2id($element->getName(), $element->getBelongsTo()); @@ -152,6 +172,19 @@ return self::$_renderer; } + /** + * Get the snippet loader for use by self::snippet(). + * + * @return MUtil_Snippets_SnippetLoader + */ + public static function getSnippetLoader() + { + if (! self::$_snippetLoader) { + self::setSnippetLoader(new MUtil_Snippets_SnippetLoader()); + } + return self::$_snippetLoader; + } + public static function name2id($name, $belongsTo = null) { return preg_replace('/\[([^\]]+)\]/', '-$1', $name . '-' . $belongsTo); @@ -183,17 +216,17 @@ /** * Creates a table element - * + * * @param mixed $arg_array Optional MUtil_Ra::args processed settings * @return MUtil_Html_TableElement */ public static function table($arg_array = null) { $args = func_get_args(); - + return self::getCreator()->create('table', $args); } - + public static function setCreator(MUtil_Html_Creator $creator) { self::$_creator = $creator; @@ -206,15 +239,40 @@ return self::$_renderer; } + /** + * Set the snippet loader for use by self::snippet(). + * + * @param MUtil_Snippets_SnippetLoader $snippetLoader + * @return MUtil_Snippets_SnippetLoader + */ + public static function setSnippetLoader(MUtil_Snippets_SnippetLoader $snippetLoader) + { + self::$_snippetLoader = $snippetLoader; + return self::$_snippetLoader; + } + + /** + * + * @param string $name Snippet name + * @param MUtil_Ra::pairs $parameter_value_pairs Optional extra snippets + * @return + */ + public static function snippet($name, $parameter_value_pairs = null) + { + if (func_num_args() > 1) { + $extraSourceParameters = MUtil_Ra::pairs(func_get_args(), 1); + } else { + $extraSourceParameters = array(); + } + + $loader = self::getSnippetLoader(); + + return $loader->getSnippet($name, $extraSourceParameters); + } + public static function url($arg_array = null) { $args = func_get_args(); return new MUtil_Html_HrefArrayAttribute($args); } - - public static function addUrl2Page(Zend_Navigation_Container $menu, $label, $arg_array = null) - { - $args = array_slice(func_get_args(), 2); - $menu->addPage(self::url($args)->toPage($label)); - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-02-06 16:17:19
|
Revision: 452 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=452&view=rev Author: matijsdejong Date: 2012-02-06 16:17:09 +0000 (Mon, 06 Feb 2012) Log Message: ----------- Small display and usability changes Modified Paths: -------------- branches/1.5.x/library/classes/Gems/Default/SurveyMaintenanceAction.php branches/1.5.x/library/classes/Gems/Default/TrackAction.php branches/1.5.x/library/classes/Gems/Default/TrackMaintenanceAction.php branches/1.5.x/library/classes/MUtil/Html/ImgElement.php Modified: branches/1.5.x/library/classes/Gems/Default/SurveyMaintenanceAction.php =================================================================== --- branches/1.5.x/library/classes/Gems/Default/SurveyMaintenanceAction.php 2012-02-06 12:39:20 UTC (rev 451) +++ branches/1.5.x/library/classes/Gems/Default/SurveyMaintenanceAction.php 2012-02-06 16:17:09 UTC (rev 452) @@ -69,7 +69,7 @@ // Add pdf button if allowed if ($menuItem = $this->findAllowedMenuItem('pdf')) { - $bridge->addItemLink(iif($bridge->gsu_has_pdf,$menuItem->toActionLinkLower($this->getRequest(), $bridge))); + $bridge->addItemLink(MUtil_Lazy::iif($bridge->gsu_has_pdf, $menuItem->toActionLinkLower($this->getRequest(), $bridge))); } } Modified: branches/1.5.x/library/classes/Gems/Default/TrackAction.php =================================================================== --- branches/1.5.x/library/classes/Gems/Default/TrackAction.php 2012-02-06 12:39:20 UTC (rev 451) +++ branches/1.5.x/library/classes/Gems/Default/TrackAction.php 2012-02-06 16:17:09 UTC (rev 452) @@ -502,9 +502,9 @@ $fieldValues = $this->db->fetchAll($sql, array('gr2t2f_id_respondent_track' => $data['gr2t_id_respondent_track'])); foreach ($fieldValues as $field) { + $table->tr(); $table->tdh($field['gtf_field_name']); $table->td($field['gr2t2f_value']); - $table->tr(); } $this->html[] = $table; Modified: branches/1.5.x/library/classes/Gems/Default/TrackMaintenanceAction.php =================================================================== --- branches/1.5.x/library/classes/Gems/Default/TrackMaintenanceAction.php 2012-02-06 12:39:20 UTC (rev 451) +++ branches/1.5.x/library/classes/Gems/Default/TrackMaintenanceAction.php 2012-02-06 16:17:09 UTC (rev 452) @@ -1,6 +1,5 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -46,6 +45,13 @@ */ class Gems_Default_TrackMaintenanceAction extends Gems_Controller_BrowseEditAction { + /** + * Mode for the current addBrowse drawing. + * + * @var string + */ + protected $browseMode; + public $sortKey = array('gtr_track_name' => SORT_ASC); public $summarizedActions = array('index', 'autofilter', 'check-all'); @@ -63,16 +69,16 @@ { $request = $this->getRequest(); - if ($request->getActionName() == 'index') { - if ($menuItem = $this->findAllowedMenuItem('show')) { - $bridge->addItemLink($menuItem->toActionLinkLower($this->getRequest(), $bridge)); - } + $actionKey = $request->getActionKey(); + $contrKey = $request->getControllerKey(); + $controller = $this->browseMode ? $this->browseMode : $request->getControllerName(); - $menuItem = $this->findAllowedMenuItem('edit'); - } else { - $menuItem = null; + if ($menuItem = $this->menu->find(array($contrKey => $controller, $actionKey => 'show'))) { + $bridge->addItemLink($menuItem->toActionLinkLower($this->getRequest(), $bridge)); } + $menuItem = $this->menu->find(array($contrKey => $controller, $actionKey => 'edit')); + foreach($model->getItemsOrdered() as $name) { if ($label = $model->get($name, 'label')) { $bridge->addSortable($name, $label); @@ -290,24 +296,13 @@ $model = $this->getModel(); $repeatable = $model->loadRepeatable(); + $this->browseMode = 'track-' . $mode; + $table = $this->getBrowseTable($baseurl); $table->setOnEmpty(sprintf($this->_('No %s found'), $this->_($mode))); $table->getOnEmpty()->class = 'centerAlign'; $table->setRepeater($repeatable); - $url = array( - 'controller' => 'track-' . $mode, - 'action' => 'edit' - ); - - foreach ($keys as $idx => $key) { - $url[$idx] = $repeatable->$key; - } - - $href = new MUtil_Html_HrefArrayAttribute($url); - $body = $table->tbody(); - $body[0]->onclick = array('location.href=\'', $href, '\';'); - $this->html->h3(sprintf($this->_('%s in track'), $this->_(ucfirst($mode)))); $this->html[] = $table; $this->html->actionLink(array('controller' => 'track-' . $mode, 'action' => 'create', 'id' => $this->getRequest()->getParam(MUtil_Model::REQUEST_ID)), $this->_('Add')); Modified: branches/1.5.x/library/classes/MUtil/Html/ImgElement.php =================================================================== --- branches/1.5.x/library/classes/MUtil/Html/ImgElement.php 2012-02-06 12:39:20 UTC (rev 451) +++ branches/1.5.x/library/classes/MUtil/Html/ImgElement.php 2012-02-06 16:17:09 UTC (rev 452) @@ -1,57 +1,59 @@ <?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. - */ - + /** - * @author Matijs de Jong - * @since 1.1 - * @version 1.4 - * @package MUtil + * 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. + * + * + * @package MUtil * @subpackage Html + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ /** - * An image element with added functionality to automatically add with and height + * An image element with added functionality to automatically add with and height * to the attributes. - * - * When the 'src' attribute does not start with a '/' or with http or https a list + * + * When the 'src' attribute does not start with a '/' or with http or https a list * of directories is searched. - * - * The default list of directories is '/' and '/images/' but you can change the + * + * The default list of directories is '/' and '/images/' but you can change the * directories using addImageDir() or setImaageDir(). - * + * * The class assumes the current working directory (getcwd()) is the web root * directory. When this is not the case use the setWebRoot() method. - * - * @author Matijs de Jong - * @package MUtil + * + * @package MUtil * @subpackage Html + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.1 */ class MUtil_Html_ImgElement extends MUtil_Html_HtmlElement { @@ -59,7 +61,7 @@ * @var array List of directory names where img looks for images. */ private static $_imageDirs = array('/', '/images/'); - + /** * * @var string The current web directory. Defaults to getcwd(). @@ -72,8 +74,49 @@ protected $_contentToTag = 'alt'; /** + * Converts an associative array to a string of tag attributes. + * + * @access public + * + * @param array $attribs From this array, each key-value pair is + * converted to an attribute name and value. + * + * @return string The XHTML for the attributes. + */ + protected function _htmlAttribs($attribs) + { + if (isset($attribs['src'])) { + $filename = MUtil_Lazy::rise($attribs['src']); + + if ($dir = self::getImageDir($filename)) { + if (! isset($attribs['width'], $attribs['height'])) { + try { + $info = getimagesize(self::getWebRoot() . $dir . $filename); + + if (! isset($attribs['width'])) { + $attribs['width'] = $info[0]; + } + if (! isset($attribs['height'])) { + $attribs['height'] = $info[1]; + } + } catch (Exception $e) { + if (MUtil_Html::$verbose) { + MUtil_Echo::track($e); + } + } + } + + $attribs['src'] = $this->view->baseUrl() . $dir . $filename; + } + // MUtil_Echo::r($attribs['src']); + } + + return parent::_htmlAttribs($attribs); + } + + /** * Add a directory to the front of the list of search directories. - * + * * @param string $dir Directory name. Slashes added when needed. */ public static function addImageDir($dir) @@ -91,24 +134,24 @@ array_unshift(self::$_imageDirs, $dir); } } - + /** * Searches for a matching image location and returns that location when found. - * + * * $filenames starting with a '/' or with http or https are skipped. - * + * * @param type $filename The src attribute as filename * @return string When a directory matches */ - public static function getImageDir($filename) + public static function getImageDir($filename) { - if ($filename - && ('/' != $filename[0]) - && ('http://' != substr($filename, 0, 7)) + if ($filename + && ('/' != $filename[0]) + && ('http://' != substr($filename, 0, 7)) && ('https://' != substr($filename, 0, 8))) { $webRoot = self::getWebRoot(); - + foreach (self::$_imageDirs as $dir) { if (file_exists($webRoot . $dir . $filename)) { return $dir; @@ -122,7 +165,7 @@ /** * Returns the list of search directories. The first directory in the list is the first directory searched. - * + * * @return array Directory names with slashes added when needed. */ public static function getImageDirs() @@ -132,7 +175,7 @@ /** * Use this function to set the web root directory if your application uses chdir() anywhere. - * + * * @param string $webRoot The current webroot */ public static function getWebRoot() @@ -140,13 +183,13 @@ if (! self::$_webRoot) { self::$_webRoot = getcwd(); } - + return self::$_webRoot; } /** * Static helper function for creation, used by @see MUtil_Html_Creator. - * + * * @param mixed $arg_array Optional MUtil_Ra::args processed settings * @return MUtil_Html_ImgElement */ @@ -157,49 +200,27 @@ } /** - * Function to allow overloading of tag rendering only - * - * Renders the element tag with it's content into a html string - * - * The $view is used to correctly encode and escape the output + * Static helper function for creation, used by @see MUtil_Html_Creator. * - * @param Zend_View_Abstract $view - * @return string Correctly encoded and escaped html output + * @param string $src The source + * @param mixed $arg_array Optional MUtil_Ra::args processed settings + * @return MUtil_Html_ImgElement */ - protected function renderElement(Zend_View_Abstract $view) + public static function imgFile($src, $arg_array = null) { - if (isset($this->_attribs['src'])) { - $filename = $this->_attribs['src']; + $args = MUtil_Ra::args(func_get_args(), 1); - if ($dir = self::getImageDir($filename)) { - if (! isset($this->_attribs['width'], $this->_attribs['height'])) { - try { - $info = getimagesize(self::getWebRoot() . $dir . $filename); - - if (! isset($this->_attribs['width'])) { - $this->_attribs['width'] = $info[0]; - } - if (! isset($this->_attribs['height'])) { - $this->_attribs['height'] = $info[1]; - } - } catch (Exception $e) { - if (MUtil_Html::$verbose) { - MUtil_Echo::track($e); - } - } - } - - $this->_attribs['src'] = $view->baseUrl() . $dir . $filename; - } - // MUtil_Echo::r($this->_attribs['src']); + $args['src'] = $src; + if (! isset($args['alt'])) { + $args['alt'] = ''; } - return parent::renderElement($view); + return new self('img', $args); } /** * Sets the list of search directories. The last directory in the list is the first directory searched for the file. - * + * * @param array $dirs Directory names. Slashes added when needed. */ public static function setImageDirs(array $dirs) @@ -213,7 +234,7 @@ /** * Use this function to set the web root directory if your application uses chdir() anywhere. - * + * * @param string $webRoot The current webroot */ public static function setWebRoot($webRoot) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-02-07 08:33:54
|
Revision: 453 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=453&view=rev Author: mennodekker Date: 2012-02-07 08:33:44 +0000 (Tue, 07 Feb 2012) Log Message: ----------- Doc fixes Modified Paths: -------------- branches/1.5.x/library/classes/Gems/Tracker/Model/TrackModel.php branches/1.5.x/library/classes/MUtil/Model/FormBridge.php Modified: branches/1.5.x/library/classes/Gems/Tracker/Model/TrackModel.php =================================================================== --- branches/1.5.x/library/classes/Gems/Tracker/Model/TrackModel.php 2012-02-06 16:17:09 UTC (rev 452) +++ branches/1.5.x/library/classes/Gems/Tracker/Model/TrackModel.php 2012-02-07 08:33:44 UTC (rev 453) @@ -95,7 +95,7 @@ * Sets the labels, format functions, etc... * * @param boolean $detailed True when shopwing detailed information - * @return Gems_Tracker_Model_StandardTokenModel + * @return Gems_Tracker_Model_TrackModel */ public function applyFormatting($detailed = false) { Modified: branches/1.5.x/library/classes/MUtil/Model/FormBridge.php =================================================================== --- branches/1.5.x/library/classes/MUtil/Model/FormBridge.php 2012-02-06 16:17:09 UTC (rev 452) +++ branches/1.5.x/library/classes/MUtil/Model/FormBridge.php 2012-02-07 08:33:44 UTC (rev 453) @@ -288,7 +288,7 @@ * * @param string $name Name of element * @param mixed $arrayOrKey1 MUtil_Ra::pairs() name => value array - * @return ZendX_JQuery_Form_Element_ColorPicker + * @return ZendX_JQuery_Form_Element_DatePicker */ public function addDate($name, $arrayOrKey1 = null, $value1 = null, $key2 = null, $value2 = null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-02-15 11:30:06
|
Revision: 475 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=475&view=rev Author: matijsdejong Date: 2012-02-15 11:29:55 +0000 (Wed, 15 Feb 2012) Log Message: ----------- Translated function can now be called with specific locale Added todo fields to tokenMailFields(), removed Pulse field physician Modified Paths: -------------- branches/1.5.x/library/classes/Gems/Util/Translated.php branches/1.5.x/library/classes/GemsEscort.php Modified: branches/1.5.x/library/classes/Gems/Util/Translated.php =================================================================== --- branches/1.5.x/library/classes/Gems/Util/Translated.php 2012-02-15 10:54:01 UTC (rev 474) +++ branches/1.5.x/library/classes/Gems/Util/Translated.php 2012-02-15 11:29:55 UTC (rev 475) @@ -193,27 +193,27 @@ return self::$emptyDropdownArray; } - public function getGenders() + public function getGenders($locale = null) { - return array('M' => $this->_('Male'), 'F' => $this->_('Female'), 'U' => $this->_('Unknown')); + return array('M' => $this->_('Male', $locale), 'F' => $this->_('Female', $locale), 'U' => $this->_('Unknown', $locale)); } - public function getGenderGreeting() + public function getGenderGreeting($locale = null) { - return array('M' => $this->_('mr.'), 'F' => $this->_('mrs.'), 'U' => $this->_('mr./mrs.')); + return array('M' => $this->_('mr.', $locale), 'F' => $this->_('mrs.', $locale), 'U' => $this->_('mr./mrs.', $locale)); } - public function getGenderHello() + public function getGenderHello($locale = null) { - return array('M' => $this->_('Mr.'), 'F' => $this->_('Mrs.'), 'U' => $this->_('Mr./Mrs.')); + return array('M' => $this->_('Mr.', $locale), 'F' => $this->_('Mrs.', $locale), 'U' => $this->_('Mr./Mrs.', $locale)); } - public function getYesNo() + public function getYesNo($locale = null) { static $data; if (! $data) { - $data = array(1 => $this->_('Yes'), 0 => $this->_('No')); + $data = array(1 => $this->_('Yes', $locale), 0 => $this->_('No', $locale)); } return $data; Modified: branches/1.5.x/library/classes/GemsEscort.php =================================================================== --- branches/1.5.x/library/classes/GemsEscort.php 2012-02-15 10:54:01 UTC (rev 474) +++ branches/1.5.x/library/classes/GemsEscort.php 2012-02-15 11:29:55 UTC (rev 475) @@ -1650,7 +1650,8 @@ { $locale = isset($tokenData['grs_iso_lang']) ? $tokenData['grs_iso_lang'] : $this->locale; - $genderHello = $this->getUtil()->getTranslated()->getGenderHello(); + // Prepare values + $genderHello = $this->getUtil()->getTranslated()->getGenderHello($locale); $hello[] = $genderHello[$tokenData['grs_gender']]; $hello[] = $tokenData['grs_first_name']; if ($tokenData['grs_surname_prefix']) { @@ -1658,13 +1659,24 @@ } $hello[] = $tokenData['grs_last_name']; - $genderGreeting = $this->getUtil()->getTranslated()->getGenderGreeting(); + $genderGreeting = $this->getUtil()->getTranslated()->getGenderGreeting($locale); $greeting[] = $genderGreeting[$tokenData['grs_gender']]; if ($tokenData['grs_surname_prefix']) { $greeting[] = $tokenData['grs_surname_prefix']; } $greeting[] = $tokenData['grs_last_name']; + // Count todo + $tSelect = $this->getLoader()->getTracker()->getTokenSelect(array( + 'all' => 'COUNT(*)', + 'track' => $this->db->quoteInto('SUM(CASE WHEN gto_id_respondent_track = ? THEN 1 ELSE 0 END)', $tokenData['gto_id_respondent_track']))); + $tSelect->andSurveys(array()) + ->forRespondent($tokenData['gto_id_respondent'], $tokenData['gto_id_organization']) + ->forGroupId($tokenData['gsu_id_primary_group']) + ->onlyValid(); + $todo = $tSelect->fetchRow(); + + // Set the basic fields $result['{email}'] = $tokenData['grs_email']; $result['{first_name}'] = $tokenData['grs_first_name']; $result['{full_name}'] = implode(' ', $hello); @@ -1681,30 +1693,34 @@ $result['{organization_url}'] = $tokenData['gor_url']; $result['{organization_welcome}'] = $tokenData['gor_welcome']; - $result['{physician}'] = ($tokenData['gsf_surname_prefix'] ? $tokenData['grs_surname_prefix'] . ' ' : '') . $tokenData['gsf_last_name']; + $result['{round}'] = $tokenData['gto_round_description']; - $result['{round}'] = $tokenData['gto_round_description']; + $result['{site_ask_url}'] = $this->util->getCurrentURI('ask/'); + // Url's + $url = $this->util->getCurrentURI('ask/forward/' . MUtil_Model::REQUEST_ID . '/' . $tokenData['gto_id_token']); + $url_input = $result['{site_ask_url}'] . 'index/' . MUtil_Model::REQUEST_ID . '/' . $tokenData['gto_id_token']; - $result['{site_ask_url}'] = $this->util->getCurrentURI('ask/'); + $result['{survey}'] = $tokenData['gsu_survey_name']; - $result['{survey}'] = $tokenData['gsu_survey_name']; + $result['{todo_all}'] = sprintf($this->translate->plural('%d survey', '%d surveys', $todo['all'], $locale), $todo['all']); + $result['{todo_all_count}'] = $todo['all']; + $result['{todo_track}'] = sprintf($this->translate->plural('%d survey', '%d surveys', $todo['track'], $locale), $todo['track']); + $result['{todo_track_count}'] = $todo['track']; - $url = $this->util->getCurrentURI('ask/forward/' . MUtil_Model::REQUEST_ID . '/' . $tokenData['gto_id_token']); - $url_input = $result['{site_ask_url}'] . 'index/' . MUtil_Model::REQUEST_ID . '/' . $tokenData['gto_id_token']; + $result['{token}'] = strtoupper($tokenData['gto_id_token']); + $result['{token_from}'] = MUtil_Date::format($tokenData['gto_valid_from'], Zend_Date::DATE_LONG, 'yyyy-MM-dd', $locale); + // $result['{token_input}'] = MUtil_Html::create()->a($url_input, $tokenData['gsu_survey_name']); + // $result['{token_link}'] = MUtil_Html::create()->a($url, $tokenData['gsu_survey_name']); + // $result['{token_link}'] = '<a href="' . $url . '">' . $tokenData['gsu_survey_name'] . '</a>'; + $result['{token_link}'] = '[url=' . $url . ']' . $tokenData['gsu_survey_name'] . '[/url]'; - $result['{token}'] = strtoupper($tokenData['gto_id_token']); - $result['{token_from}'] = MUtil_Date::format($tokenData['gto_valid_from'], Zend_Date::DATE_LONG, 'yyyy-MM-dd', $locale); - // $result['{token_input}'] = MUtil_Html::create()->a($url_input, $tokenData['gsu_survey_name']); - // $result['{token_link}'] = MUtil_Html::create()->a($url, $tokenData['gsu_survey_name']); - // $result['{token_link}'] = '<a href="' . $url . '">' . $tokenData['gsu_survey_name'] . '</a>'; - $result['{token_link}'] = '[url=' . $url . ']' . $tokenData['gsu_survey_name'] . '[/url]'; + $result['{token_until}'] = MUtil_Date::format($tokenData['gto_valid_until'], Zend_Date::DATE_LONG, 'yyyy-MM-dd', $locale); + $result['{token_url}'] = $url; + $result['{token_url_input}'] = $url_input; - $result['{token_until}'] = MUtil_Date::format($tokenData['gto_valid_until'], Zend_Date::DATE_LONG, 'yyyy-MM-dd', $locale); - $result['{token_url}'] = $url; - $result['{token_url_input}'] = $url_input; + $result['{track}'] = $tokenData['gtr_track_name']; - $result['{track}'] = $tokenData['gtr_track_name']; - + // Add the code fields $join = $this->db->quoteInto('gtf_id_field = gr2t2f_id_field AND gr2t2f_id_respondent_track = ?', $tokenData['gto_id_respondent_track']); $select = $this->db->select(); $select->from('gems__track_fields', array(new Zend_Db_Expr("CONCAT('{track.', gtf_field_code, '}')"))) @@ -1721,4 +1737,3 @@ return $result; } } - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |