From: <gem...@li...> - 2011-09-27 17:28:54
|
Revision: 82 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=82&view=rev Author: matijsdejong Date: 2011-09-27 17:28:46 +0000 (Tue, 27 Sep 2011) Log Message: ----------- - added constructor with arguments to RequestCache.php - extra documentation for BrowseEditAction.php, TargetAbstract.php, TargetInterface.php - continued on #10 new BrowseEditAction.php todo: make possible to add filters to excel, look Excel export, maybe export using snippet Modified Paths: -------------- trunk/library/classes/Gems/Controller/BrowseEditAction.php trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php trunk/library/classes/Gems/Default/MailLogAction.php trunk/library/classes/Gems/Registry/TargetAbstract.php trunk/library/classes/Gems/Snippets/ModelTableSnippetAbstract.php trunk/library/classes/Gems/Util/RequestCache.php trunk/library/classes/Gems/Util.php trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php trunk/library/classes/MUtil/Registry/TargetAbstract.php trunk/library/classes/MUtil/Registry/TargetInterface.php trunk/library/snippets/Generic/AutosearchForm.php trunk/library/snippets/Generic/ModelItemTableSnippet.php trunk/library/snippets/Generic/ModelTableSnippet.php Added Paths: ----------- trunk/library/snippets/Generic/CurrentButtonRow.php Modified: trunk/library/classes/Gems/Controller/BrowseEditAction.php =================================================================== --- trunk/library/classes/Gems/Controller/BrowseEditAction.php 2011-09-27 14:43:57 UTC (rev 81) +++ trunk/library/classes/Gems/Controller/BrowseEditAction.php 2011-09-27 17:28:46 UTC (rev 82) @@ -583,16 +583,13 @@ * * @param boolean $includeDefaults Include the default values (yes for filtering, no for urls * @param string $sourceAction The action to get the cache from if not the current one. + * @param boolean $readonly Optional, tell the cache not to store any new values * @return array */ public function getCachedRequestData($includeDefaults = true, $sourceAction = null, $readonly = false) { if (! $this->requestCache) { - $this->requestCache = $this->util->getRequestCache(); - if ($sourceAction) { - $this->requestCache->setSourceAction($sourceAction); - } - $this->requestCache->setReadonly($readonly); + $this->requestCache = $this->util->getRequestCache($sourceAction, $readonly); $this->requestCache->setMenu($this->menu); $this->requestCache->setRequest($this->request); Modified: trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php =================================================================== --- trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php 2011-09-27 14:43:57 UTC (rev 81) +++ trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php 2011-09-27 17:28:46 UTC (rev 82) @@ -74,13 +74,20 @@ protected $autofilterSnippets = 'Generic_ModelTableSnippet'; /** - * The snippets used for the index action, minus those in autofilter + * The snippets used for the index action, before those in autofilter * * @var mixed String or array of snippets name */ - protected $indexSnippets = 'Generic_AutosearchForm'; + protected $indexStartSnippets = 'Generic_AutosearchForm'; /** + * The snippets used for the index action, after those in autofilter + * + * @var mixed String or array of snippets name + */ + protected $indexStopSnippets = 'Generic_CurrentButtonRow'; + + /** * The snippets used for the show action * * @var mixed String or array of snippets name @@ -88,6 +95,42 @@ protected $showSnippets = 'Generic_ModelItemTableSnippet'; /** + * + * @var Gems_Util + */ + public $util; + + /** + * Outputs the model to excel, applying all filters and searches needed + * + * When you want to change the output, there are two places to check: + * + * 1. $this->addExcelColumns($model), where the model can be changed to have labels for columns you + * need exported + * + * 2. $this->getExcelData($data, $model) where the supplied data and model are merged to get output + * (by default all fields from the model that have a label) + */ + public function excelAction() + { + // Set the request cache to use the search params from the index action + $requestCache = $this->util->getRequestCache('index', true); + $filter = $requestCache->getProgramParams(); + + $model = $this->getModel(); + + $model->applyParameters($filter); + + // $this->addExcelColumns($model); // Hook to modify the model + + $this->view->result = $this->getExcelData($model->load(), $model); + $this->view->filename = $this->getRequest()->getControllerName() . '.xls'; + $this->view->setScriptPath(GEMS_LIBRARY_DIR . '/views/scripts' ); + + $this->render('excel', null, true); + } + + /** * Finds the first item with one of the actions specified as parameter and using the current controller * * @param string $action @@ -109,6 +152,45 @@ } /** + * Returns an array with all columns from the model that have a label + * + * @param array $data + * @param MUtil_Model_ModelAbstract $model + * @return array + */ + protected function getExcelData($data, MUtil_Model_ModelAbstract $model) + { + $headings = array(); + $emptyMsg = $this->_('No data found.'); + foreach ($model->getItemsOrdered() as $name) { + if ($label = $model->get($name, 'label')) { + $headings[$name] = (string) $label; + } + } + $results = array(); + $results[] = $headings; + if ($headings) { + if ($data) { + foreach ($data as $row) { + foreach ($headings as $key => $value) { + $result[$key] = isset($row[$key]) ? $row[$key] : null; + } + $results[] = $result; + } + return $results; + } else { + foreach ($headings as $key => $value) { + $result[$key] = $emptyMsg; + } + $results[] = $result; + return $results; + } + } else { + return array($emptyMsg); + } + } + + /** * Intializes the html component. * * @param boolean $reset Throws away any existing html output when true Modified: trunk/library/classes/Gems/Default/MailLogAction.php =================================================================== --- trunk/library/classes/Gems/Default/MailLogAction.php 2011-09-27 14:43:57 UTC (rev 81) +++ trunk/library/classes/Gems/Default/MailLogAction.php 2011-09-27 17:28:46 UTC (rev 82) @@ -140,6 +140,9 @@ return $model; } + /** + * Action for showing a browse page + */ public function indexAction() { $this->html->h3($this->_('Mail Activity Log')); @@ -147,4 +150,16 @@ // MUtil_Echo::track($this->indexParameters); parent::indexAction(); } + + + /** + * Action for showing an item page + */ + public function showAction() + { + $this->html->h3($this->_('Show Mail Activity Log item')); + + // MUtil_Echo::track($this->indexParameters); + parent::showAction(); + } } Modified: trunk/library/classes/Gems/Registry/TargetAbstract.php =================================================================== --- trunk/library/classes/Gems/Registry/TargetAbstract.php 2011-09-27 14:43:57 UTC (rev 81) +++ trunk/library/classes/Gems/Registry/TargetAbstract.php 2011-09-27 17:28:46 UTC (rev 82) @@ -4,7 +4,7 @@ /** * 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 @@ -15,7 +15,7 @@ * * 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 @@ -26,23 +26,25 @@ * 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 Gems + * + * + * @package Gems * @subpackage Registry + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ /** - * Extends MUtil_Registry_TargetAbstract with the ability to create + * Extends MUtil_Registry_TargetAbstract with the ability to create PHP * callables by request an existing method using $this->methodName. - * - * @author Matijs de Jong - * @package Gems + * + * @package Gems * @subpackage Registry + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.1 */ class Gems_Registry_TargetAbstract extends MUtil_Registry_TargetAbstract { Modified: trunk/library/classes/Gems/Snippets/ModelTableSnippetAbstract.php =================================================================== --- trunk/library/classes/Gems/Snippets/ModelTableSnippetAbstract.php 2011-09-27 14:43:57 UTC (rev 81) +++ trunk/library/classes/Gems/Snippets/ModelTableSnippetAbstract.php 2011-09-27 17:28:46 UTC (rev 82) @@ -82,6 +82,7 @@ public $menu; /** + * Optional, used for base url * * @var Gems_Util_RequestCache */ @@ -122,11 +123,16 @@ */ public function checkRegistryRequestsAnswers() { - if ($this->requestCache && (! $this->baseUrl)) { - $this->baseUrl = $this->requestCache->getProgramParams(); + if ($this->requestCache) { + // Items that should not be stored. + $this->requestCache->removeParams('page', 'items', 'action'); - if (MUtil_Registry_Source::$verbose) { - MUtil_Echo::track($this->baseUrl); + if ((! $this->baseUrl)) { + $this->baseUrl = $this->requestCache->getProgramParams(); + + if (MUtil_Registry_Source::$verbose) { + MUtil_Echo::track($this->baseUrl); + } } } @@ -186,4 +192,21 @@ return $table; } } + + /** + * Overrule to implement snippet specific filtering and sorting. + * + * @param MUtil_Model_ModelAbstract $model + */ + protected function processFilterAndSort(MUtil_Model_ModelAbstract $model) + { + if ($this->requestCache) { + $data = $this->requestCache->getProgramParams(); + + $model->applyParameters($data); + + } else { + parent::processFilterAndSort($model); + } + } } Modified: trunk/library/classes/Gems/Util/RequestCache.php =================================================================== --- trunk/library/classes/Gems/Util/RequestCache.php 2011-09-27 14:43:57 UTC (rev 81) +++ trunk/library/classes/Gems/Util/RequestCache.php 2011-09-27 17:28:46 UTC (rev 82) @@ -109,6 +109,19 @@ protected $sourceAction; /** + * + * @param string $sourceAction The action to get the cache from if not the current one. + * @param boolean $readonly Optional, tell the cache not to store any new values + */ + public function __construct($sourceAction = null, $readonly = false) + { + if ($sourceAction) { + $this->setSourceAction($sourceAction); + } + $this->setReadonly($readonly); + } + + /** * Should be called after answering the request to allow the Target * to check if all required registry values have been set correctly. * Modified: trunk/library/classes/Gems/Util.php =================================================================== --- trunk/library/classes/Gems/Util.php 2011-09-27 14:43:57 UTC (rev 81) +++ trunk/library/classes/Gems/Util.php 2011-09-27 17:28:46 UTC (rev 82) @@ -170,11 +170,13 @@ /** * + * @param string $sourceAction The action to get the cache from if not the current one. + * @param boolean $readonly Optional, tell the cache not to store any new values * @return Gems_Util_RequestCache */ - public function getRequestCache() + public function getRequestCache($sourceAction = null, $readonly = false) { - return $this->_getClass('requestCache'); + return $this->_getClass('requestCache', null, array($sourceAction, $readonly)); } /** Modified: trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php =================================================================== --- trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php 2011-09-27 14:43:57 UTC (rev 81) +++ trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php 2011-09-27 17:28:46 UTC (rev 82) @@ -70,13 +70,20 @@ protected $indexParameters = array(); /** - * The snippets used for the index action, minus those in autofilter + * The snippets used for the index action, before those in autofilter * * @var mixed String or array of snippets name */ - protected $indexSnippets = null; + protected $indexStartSnippets = null; /** + * The snippets used for the index action, after those in autofilter + * + * @var mixed String or array of snippets name + */ + protected $indexStopSnippets = null; + + /** * The parameters used for the show action * * @var array Mixed key => value array for snippet initialization @@ -139,16 +146,22 @@ */ public function indexAction() { - if ($this->indexSnippets) { + if ($this->indexStartSnippets || $this->indexStopSnippets) { $this->indexParameters = $this->indexParameters + $this->autofilterParameters; $this->indexParameters['model'] = $this->getModel(); $this->indexParameters['request'] = $this->getRequest(); - $this->addSnippets($this->indexSnippets, $this->indexParameters); + if ($this->indexStartSnippets) { + $this->addSnippets($this->indexStartSnippets, $this->indexParameters); + } } $this->autofilterAction(false); + + if ($this->indexStopSnippets) { + $this->addSnippets($this->indexStopSnippets, $this->indexParameters); + } } @@ -158,8 +171,6 @@ public function showAction() { if ($this->showSnippets) { - $this->showParameters = $this->indexParameters + $this->autofilterParameters; - $this->showParameters['model'] = $this->getModel(); $this->showParameters['request'] = $this->getRequest(); Modified: trunk/library/classes/MUtil/Registry/TargetAbstract.php =================================================================== --- trunk/library/classes/MUtil/Registry/TargetAbstract.php 2011-09-27 14:43:57 UTC (rev 81) +++ trunk/library/classes/MUtil/Registry/TargetAbstract.php 2011-09-27 17:28:46 UTC (rev 82) @@ -1,48 +1,54 @@ <?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.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 Registry + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ /** - * MUtil_Registry_TargetAbstract is a default target object. - * - * Also usable to copy the code to implement your own version of this class. + * MUtil_Registry_TargetAbstract is a default target object, that requests values + * for all defined instance variables with names not starting with '_'. * - * @author Matijs de Jong - * @package MUtil + * I.e. variables in a class inheriting from MUtil_Registry_TargetAbstract can be + * initialized by a source even when they are protected or private. + * + * Also usafull to copy the code to implement your own version of this class. + * + * @package MUtil * @subpackage Registry + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.1 */ abstract class MUtil_Registry_TargetAbstract implements MUtil_Registry_TargetInterface { @@ -90,12 +96,12 @@ } /** - * Allows the loader to know the resources to set. - * - * Returns those object variables defined by the subclass but not at the level of this definition. - * - * Can be overruled. - * + * Allows the loader to know the resources to set. + * + * Returns those object variables defined by the subclass but not at the level of this definition. + * + * Can be overruled. + * * @return array of string names */ public function getRegistryRequests() Modified: trunk/library/classes/MUtil/Registry/TargetInterface.php =================================================================== --- trunk/library/classes/MUtil/Registry/TargetInterface.php 2011-09-27 14:43:57 UTC (rev 81) +++ trunk/library/classes/MUtil/Registry/TargetInterface.php 2011-09-27 17:28:46 UTC (rev 82) @@ -4,7 +4,7 @@ /** * 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 @@ -15,7 +15,7 @@ * * 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 @@ -26,14 +26,14 @@ * 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.1 - * @package MUtil + * + * + * @package MUtil * @subpackage Registry + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ /** @@ -44,11 +44,13 @@ * * @see MUtil_Registry_Source * - * @author Matijs de Jong - * @package MUtil + * @package MUtil * @subpackage Registry + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.1 */ -interface MUtil_Registry_TargetInterface +interface MUtil_Registry_TargetInterface { /** * Allows the source to set request. @@ -69,7 +71,7 @@ /** * Allows the loader to know the resources to set. - * + * * @return array of string names */ public function getRegistryRequests(); Modified: trunk/library/snippets/Generic/AutosearchForm.php =================================================================== --- trunk/library/snippets/Generic/AutosearchForm.php 2011-09-27 14:43:57 UTC (rev 81) +++ trunk/library/snippets/Generic/AutosearchForm.php 2011-09-27 17:28:46 UTC (rev 82) @@ -68,13 +68,45 @@ protected $request; /** + * Optional, otherwise created from $util * + * @var Gems_Util_RequestCache + */ + public $requestCache; + + /** + * + * @var Gems_Util + */ + protected $util; + + /** + * * @var string Id for auto search button */ protected $searchButtonId = 'AUTO_SEARCH_TEXT_BUTTON'; /** + * Should be called after answering the request to allow the Target + * to check if all required registry values have been set correctly. + * + * @return boolean False if required are missing. + */ + public function checkRegistryRequestsAnswers() + { + if ($this->util && (! $this->requestCache)) { + $this->requestCache = $this->util->getRequestCache(); + } + if ($this->requestCache) { + // Do not store searchButtonId + $this->requestCache->removeParams($this->searchButtonId); + } + + return parent::checkRegistryRequestsAnswers(); + } + + /** * Creates the form itself * * @param array $options @@ -196,6 +228,10 @@ */ protected function getSearchData() { - return $this->request->getParams(); + if ($this->requestCache) { + return $this->requestCache->getProgramParams(); + } else { + return $this->request->getParams(); + } } } Added: trunk/library/snippets/Generic/CurrentButtonRow.php =================================================================== --- trunk/library/snippets/Generic/CurrentButtonRow.php (rev 0) +++ trunk/library/snippets/Generic/CurrentButtonRow.php 2011-09-27 17:28:46 UTC (rev 82) @@ -0,0 +1,85 @@ +<?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. + * + * Short description of file + * + * @package Gems + * @subpackage Snippets + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + */ + +/** + * Short description for class + * + * Long description for class (if any)... + * + * @package Gems + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.2 + */ +class Generic_CurrentButtonRow extends MUtil_Snippets_SnippetAbstract +{ + /** + * Required + * + * @var Gems_Menu + */ + protected $menu; + + /** + * Required + * + * @var Zend_Controller_Request_Abstract + */ + protected $request; + + /** + * Create the snippets content + * + * This is a stub function either override getHtmlOutput() or override render() + * + * @param Zend_View_Abstract $view Just in case it is needed here + * @return MUtil_Html_HtmlInterface Something that can be rendered + */ + public function getHtmlOutput(Zend_View_Abstract $view) + { + $menuList = $this->menu->getMenuList(); + + $menuList->addParameterSources($this->request) + ->addCurrentParent($this->_('Cancel')) + ->addCurrentChildren(); + + return $menuList; + } + +} Modified: trunk/library/snippets/Generic/ModelItemTableSnippet.php =================================================================== --- trunk/library/snippets/Generic/ModelItemTableSnippet.php 2011-09-27 14:43:57 UTC (rev 81) +++ trunk/library/snippets/Generic/ModelItemTableSnippet.php 2011-09-27 17:28:46 UTC (rev 82) @@ -1,6 +1,5 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -92,6 +91,31 @@ protected $request; /** + * Adds rows from the model to the bridge that creates the browse table. + * + * Overrule this function to add different columns to the browse table, without + * having to recode the core table building code. + * + * @param MUtil_Model_TableBridge $bridge + * @param MUtil_Model_ModelAbstract $model + * @return void + */ + protected function addShowTableRows(MUtil_Model_VerticalTableBridge $bridge, MUtil_Model_ModelAbstract $model) + { + parent::addShowTableRows($bridge, $model); + + $controller = $this->request->getControllerName(); + + $menuList = $this->menu->getMenuList(); + $menuList->addParameterSources($bridge) + ->addByController($controller) + ->addByController($controller, 'edit') + ->addByController($controller, 'delete'); + + $bridge->tfrow($menuList, array('class' => 'centerAlign')); + } + + /** * Creates the model * * @return MUtil_Model_ModelAbstract Modified: trunk/library/snippets/Generic/ModelTableSnippet.php =================================================================== --- trunk/library/snippets/Generic/ModelTableSnippet.php 2011-09-27 14:43:57 UTC (rev 81) +++ trunk/library/snippets/Generic/ModelTableSnippet.php 2011-09-27 17:28:46 UTC (rev 82) @@ -54,6 +54,29 @@ protected $model; /** + * + * @var Gems_Util + */ + protected $util; + + /** + * Automatically add request cacge + * + * Should be called after answering the request to allow the Target + * to check if all required registry values have been set correctly. + * + * @return boolean False if required are missing. + */ + public function checkRegistryRequestsAnswers() + { + if ($this->util && (! $this->requestCache)) { + $this->requestCache = $this->util->getRequestCache(); + } + + return parent::checkRegistryRequestsAnswers(); + } + + /** * Creates the model * * @return MUtil_Model_ModelAbstract This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |