From: <gem...@li...> - 2012-06-14 13:56:40
|
Revision: 762 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=762&view=rev Author: mennodekker Date: 2012-06-14 13:56:33 +0000 (Thu, 14 Jun 2012) Log Message: ----------- Allow different SnippetLoaders to be used, that only implement the interface instead of extending the base class Modified Paths: -------------- trunk/library/classes/MUtil/Html.php trunk/library/classes/MUtil/Snippets/SnippetLoader.php Added Paths: ----------- trunk/library/classes/MUtil/Snippets/SnippetLoaderInterface.php Modified: trunk/library/classes/MUtil/Html.php =================================================================== --- trunk/library/classes/MUtil/Html.php 2012-06-14 13:06:26 UTC (rev 761) +++ trunk/library/classes/MUtil/Html.php 2012-06-14 13:56:33 UTC (rev 762) @@ -282,10 +282,10 @@ /** * Set the snippet loader for use by self::snippet(). * - * @param MUtil_Snippets_SnippetLoader $snippetLoader + * @param MUtil_Snippets_SnippetLoaderInterface $snippetLoader * @return MUtil_Snippets_SnippetLoader */ - public static function setSnippetLoader(MUtil_Snippets_SnippetLoader $snippetLoader) + public static function setSnippetLoader(MUtil_Snippets_SnippetLoaderInterface $snippetLoader) { self::$_snippetLoader = $snippetLoader; return self::$_snippetLoader; Modified: trunk/library/classes/MUtil/Snippets/SnippetLoader.php =================================================================== --- trunk/library/classes/MUtil/Snippets/SnippetLoader.php 2012-06-14 13:06:26 UTC (rev 761) +++ trunk/library/classes/MUtil/Snippets/SnippetLoader.php 2012-06-14 13:56:33 UTC (rev 762) @@ -45,7 +45,7 @@ * @license New BSD License * @since Class available since version 1.4 */ -class MUtil_Snippets_SnippetLoader +class MUtil_Snippets_SnippetLoader implements MUtil_Snippets_SnippetLoaderInterface { /** * The file locations where to look for snippets. @@ -83,7 +83,7 @@ * @param string $dir * @return MUtil_Snippets_SnippetLoader */ - public function addDirectory($dir, $loadDefaults = true) + public function addDirectory($dir) { if (! in_array($dir, $this->snippetsDirectories)) { if (file_exists($dir)) { Added: trunk/library/classes/MUtil/Snippets/SnippetLoaderInterface.php =================================================================== --- trunk/library/classes/MUtil/Snippets/SnippetLoaderInterface.php (rev 0) +++ trunk/library/classes/MUtil/Snippets/SnippetLoaderInterface.php 2012-06-14 13:56:33 UTC (rev 762) @@ -0,0 +1,108 @@ +<?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. + * + * @package MUtil + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + */ + +/** + * Handles loading of snippets + * + * @package MUtil + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5.5 + */ +interface MUtil_Snippets_SnippetLoaderInterface +{ + /** + * Sets the source of variables and the first directory for snippets + * + * @param mixed $source Something that is or can be made into MUtil_Registry_SourceInterface, otheriwse Zend_Registry is used. + */ + public function __construct($source = null); + + /** + * Add a directory to the front of the list of places where snippets are loaded from. + * + * @param string $dir + * @return MUtil_Snippets_SnippetLoaderInterface + */ + public function addDirectory($dir); + + /** + * Add parameter values to the source for snippets. + * + * @param mixed $container_or_pairs This function can be called with either a single container or a list of name/value pairs. + * @return MUtil_Snippets_SnippetLoaderInterface + */ + public function addSource($container_or_pairs); + + /** + * Returns the directories where snippets are loaded from. + * + * @param array $dirs + * @return array + */ + public function getDirectories(); + + /** + * Searches and loads a .php snippet file. + * + * @param string $filename The name of the snippet + * @param array $extraSourceParameters name/value pairs to add to the source for this snippet + * @return MUtil_Snippets_SnippetInterface The snippet + */ + public function getSnippet($filename, array $extraSourceParameters = null); + + /** + * Returns a source of values for snippets. + * + * @return MUtil_Registry_SourceInterface + */ + public function getSource(); + + /** + * Set the directories where snippets are loaded from. + * + * @param array $dirs + * @return MUtil_Snippets_SnippetLoaderInterface (continuation pattern) + */ + public function setDirectories(array $dirs); + + /** + * Sets the source of variables for snippets + * + * @param MUtil_Registry_SourceInterface $source + * @return MUtil_Snippets_SnippetLoaderInterface (continuation pattern) + */ + public function setSource(MUtil_Registry_SourceInterface $source); +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-10-24 15:30:30
|
Revision: 993 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=993&view=rev Author: matijsdejong Date: 2012-10-24 15:30:17 +0000 (Wed, 24 Oct 2012) Log Message: ----------- Small fix for echo Started on string utility class Modified Paths: -------------- trunk/library/classes/MUtil/Echo.php Added Paths: ----------- trunk/library/classes/MUtil/String.php Modified: trunk/library/classes/MUtil/Echo.php =================================================================== --- trunk/library/classes/MUtil/Echo.php 2012-10-19 14:43:01 UTC (rev 992) +++ trunk/library/classes/MUtil/Echo.php 2012-10-24 15:30:17 UTC (rev 993) @@ -208,7 +208,9 @@ if (isset($trace[1]['type'])) { $header .= $trace[1]['class'] . $trace[1]['type']; } - $header .= $trace[1]['function'] . '() '; + if (isset($trace[1]['function'])) { + $header .= $trace[1]['function'] . '() '; + } if (isset($trace[0]['line'])) { $header .= ': ' . $trace[0]['line']; } Added: trunk/library/classes/MUtil/String.php =================================================================== --- trunk/library/classes/MUtil/String.php (rev 0) +++ trunk/library/classes/MUtil/String.php 2012-10-24 15:30:17 UTC (rev 993) @@ -0,0 +1,94 @@ +<?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 String + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: String.php 203 2012-01-01t 12:51:32Z matijs $ + */ + +/** + * A collection of static string utility functions + * + * @package MUtil + * @subpackage String + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5 + */ +class MUtil_String +{ + /** + * Return the part of $input before any of the $charFilter characters + * + * beforeChars('abcdef', 'dgi') => 'abc' + * + * beforeChars('abcdef', 'xyz') => 'abcdef' + * + * @param string $input The text to return part of + * @param string $charFilter The characters to filter on + * @return string + */ + public static function beforeChars($input, $charFilter) + { + $rest = strpbrk($input, $charFilter); + + if ($rest === false) { + return $input; + } + + return substr($input, 0, -strlen($rest)); + } + + /** + * Return the part after $input and $filter stopped being the same + * + * stripStringLeft('abcdef', 'abcx') => 'def' + * + * stripStringLeft('abcdef', 'def') => 'abcdef' + * + * @param string $input The text to return part of + * @param string $filter The text to filter on + * @return string + */ + public static function stripStringLeft($input, $filter) + { + $count = min(array(strlen($input), strlen($filter))); + + for ($i = 0; $i < $count; $i++) { + if ($input[$i] != $filter[$i]) { + break; + } + } + + return substr($input, $i); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-12-29 19:35:32
|
Revision: 1079 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1079&view=rev Author: matijsdejong Date: 2012-12-29 19:35:24 +0000 (Sat, 29 Dec 2012) Log Message: ----------- Started on 'model needs to have a function to format values' Modified Paths: -------------- trunk/library/classes/MUtil/Version.php Added Paths: ----------- trunk/library/classes/MUtil/Model/Assembler/ trunk/library/classes/MUtil/Model/Assembler/FormAssembler.php trunk/library/classes/MUtil/Model/AssemblerAbstract.php trunk/library/classes/MUtil/Model/AssemblerInterface.php trunk/library/classes/MUtil/Model/Input.php trunk/library/classes/MUtil/Model/Processor/ trunk/library/classes/MUtil/Model/Processor/ChainedProcessor.php trunk/library/classes/MUtil/Model/Processor/Display/ trunk/library/classes/MUtil/Model/Processor/Display/FormatsProcessor.php trunk/library/classes/MUtil/Model/Processor/Display/MultiOptionProcessor.php trunk/library/classes/MUtil/Model/Processor/Element/ trunk/library/classes/MUtil/Model/Processor/Element/TextElementProcessor.php trunk/library/classes/MUtil/Model/Processor/ElementProcessorAbstract.php trunk/library/classes/MUtil/Model/ProcessorInterface.php Added: trunk/library/classes/MUtil/Model/Assembler/FormAssembler.php =================================================================== --- trunk/library/classes/MUtil/Model/Assembler/FormAssembler.php (rev 0) +++ trunk/library/classes/MUtil/Model/Assembler/FormAssembler.php 2012-12-29 19:35:24 UTC (rev 1079) @@ -0,0 +1,60 @@ +<?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 Model + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: FormAssembler.php 203 2012-01-01t 12:51:32Z matijs $ + */ + +/** + * + * + * @package MUtil + * @subpackage Model + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since MUtil version 1.2 + */ +class MUtil_Model_Assembler_FormAssembler extends MUtil_Model_AssemblerAbstract +{ + /** + * Create the processor for this name + * + * @param string $name + * @return MUtil_Model_ProcessorInterface or null when it does not exist + */ + protected function _assemble($name) + { + return new MUtil_Model_Processor_Element_TextElementProcessor(); + } + +} Added: trunk/library/classes/MUtil/Model/AssemblerAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/AssemblerAbstract.php (rev 0) +++ trunk/library/classes/MUtil/Model/AssemblerAbstract.php 2012-12-29 19:35:24 UTC (rev 1079) @@ -0,0 +1,252 @@ +<?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 Model + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: AssemblerAbstract.php 203 2012-01-01t 12:51:32Z matijs $ + */ + +/** + * + * + * @package MUtil + * @subpackage Model + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since MUtil version 1.2 + */ +abstract class MUtil_Model_AssemblerAbstract implements MUtil_Model_AssemblerInterface +{ + /** + * + * @var mixed + */ + protected $_data = array(); + + /** + * + * @var MUtil_Model_ModelAbstract + */ + protected $_model; + + /** + * + * @var array Of name => MUtil_Model_ProcessorInterface + */ + protected $_processors = array(); + + /** + * + * @var MUtil_Lazy_RepeatableInterface + */ + protected $_repeater; + + /** + * + * @var array + */ + protected $_row = array(); + + /** + * Create the processor for this name + * + * @param string $name + * @return MUtil_Model_ProcessorInterface or null when it does not exist + */ + abstract protected function _assemble($name); + + /** + * Get the processed output of the input or a lazy object if the data is repeated + * or not yet set using setRepeater() or setRow(). + * + * @param string $name + * @return mixed MUtil_Lazy_Call when not using setRow(), actual output otherwise + */ + public function getOutput($name) + { + if (! $this->hasProcessor($name)) { + if ($this->_row) { + if (isset($this->_row[$name])) { + return $this->_row[$name]; + } + + return null; + } + // Fall through and return lazy call + + } else { + // Assembler should be created with current values + $processor = $this->getProcessor($name); + + if ($this->_row) { + $input = new MUtil_Model_Input($this->_model, $name, $this->_row); + + $processor->process($input); + + return $input->getOutput(); + } + } + + return new MUtil_Lazy_Call(array($this, 'output'), array($name)); + } + + /** + * Returns the processor for the name + * + * @param string $name + * @return MUtil_Model_ProcessorInterface or null when it does not exist + */ + public function getProcessor($name) + { + if ($this->hasProcessor($name)) { + return $this->_processors[$name]; + } + } + + /** + * Returns true if a processor exist for $name + * + * @param string $name + * @return boolean + */ + public function hasProcessor($name) + { + if (! array_key_exists($name, $this->_processors)) { + // Default if nothing there + $this->_processors[$name] = false; + + // Try to create one + if ($this->_model->has($name)) { + if ($processor = $this->_assemble($name)) { + $this->setProcessor($name, $processor); + } + } + } + + return false !== $this->_processors[$name]; + } + + /** + * Helper function for when using lazy output or late use of setRow() + * + * @param string $name + * @return mixed + */ + public function output($name) + { + if ($this->_row) { + $data = $this->_row; + } else { + $data = $this->_repeater->__current(); + } + + if ($this->hasProcessor($name)) { + $processor = $this->getProcessor($name); + + $input = new MUtil_Model_Input($this->_model, $name, $data); + + $processor->process($input); + + return $input->getOutput(); + + } elseif (isset($data[$name])) { + + return $data[$name]; + } + } + + /** + * Set the processor for a name + * + * @param string $name + * $param MUtil_Model_ProcessorInterface $processor + * @return MUtil_Model_AssemblerInterface (continuation pattern) + */ + public function setProcessor($name, MUtil_Model_ProcessorInterface $processor) + { + $this->_processors[$name] = $processor; + + return $this; + } + + /** + * Set the model of this assembler + * + * @param MUtil_Model_ModelAbstract $model + * @return MUtil_Model_AssemblerInterface (continuation pattern) + */ + public function setModel(MUtil_Model_ModelAbstract $model) + { + $this->_model = $model; + + return $this; + } + + /** + * Use this method when you want to repeat the output for each row when rendering. + * + * The assembler does not itself loop through the multiple rows, for that to happen + * you need to place the outputs of the gets on something that has the same repeater + * and does repeat it, e.g. an MUtil_Html object. + * + * Either setRepeater() or setRow() should be set. setRow() is dominant. + * + * @param mixed $repeater MUtil_Lazy_RepeatableInterface or something that can be made into one. + * @return MUtil_Model_AssemblerInterface (continuation pattern) + */ + public function setRepeater($repeater) + { + if ($repeater instanceof MUtil_Lazy_RepeatableInterface) { + $this->_repeater = $repeater; + } else { + $this->_repeater = new MUtil_Lazy_Repeatable($repeater); + } + + return $this; + } + + /** + * Use this method when using a single row of input, i.e. do nothing lazy + * and just draw the current row. + * + * Either setRepeater() or setRow() should be set. setRow() is dominant. + * + * @param array $data An array with data. + * @return MUtil_Model_AssemblerInterface (continuation pattern) + */ + public function setRow(array $data) + { + $this->_row = $data; + + return $this; + } +} Added: trunk/library/classes/MUtil/Model/AssemblerInterface.php =================================================================== --- trunk/library/classes/MUtil/Model/AssemblerInterface.php (rev 0) +++ trunk/library/classes/MUtil/Model/AssemblerInterface.php 2012-12-29 19:35:24 UTC (rev 1079) @@ -0,0 +1,115 @@ +<?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 Model + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: AssemblerInterface.php 203 2012-01-01t 12:51:32Z matijs $ + */ + +/** + * + * + * @package MUtil + * @subpackage Model + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since MUtil version 1.2 + */ +interface MUtil_Model_AssemblerInterface +{ + /** + * Get the processed output of the input or a lazy object if the data is repeated + * or not yet set using setRepeater() or setRow(). + * + * @param string $name + * @return mixed MUtil_Lazy_Call when not using setRow(), actual output otherwise + */ + public function getOutput($name); + + /** + * Returns the processor for the name + * + * @param string $name + * @return MUtil_Model_ProcessorInterface or null when it does not exist + */ + public function getProcessor($name); + + /** + * Returns true if a processor exist for $name + * + * @param string $name + * @return boolean + */ + public function hasProcessor($name); + + /** + * Set the model of this assembler + * + * @param MUtil_Model_ModelAbstract $model + * @return MUtil_Model_AssemblerInterface + */ + public function setModel(MUtil_Model_ModelAbstract $model); + + /** + * Set the processor for a name + * + * @param string $name + * $param MUtil_Model_ProcessorInterface $processor + * @return MUtil_Model_AssemblerInterface (continuation pattern) + */ + public function setProcessor($name, MUtil_Model_ProcessorInterface $processor); + + /** + * Use this method when you want to repeat the output for each row when rendering. + * + * The assembler does not itself loop through the multiple rows, for that to happen + * you need to place the outputs of the gets on something that has the same repeater + * and does repeat it, e.g. an MUtil_Html object. + * + * Either setRepeater() or setRow() should be set. setRow() is dominant. + * + * @param mixed $repeater MUtil_Lazy_RepeatableInterface or something that can be made into one. + * @return MUtil_Model_AssemblerInterface (continuation pattern) + */ + public function setRepeater($repeater); + + /** + * Use this method when using a single row of input, i.e. do nothing lazy + * and just draw the current row. + * + * Either setRepeater() or setRow() should be set. setRow() is dominant. + * + * @param array $data An array with data. + * @return MUtil_Model_AssemblerInterface (continuation pattern) + */ + public function setRow(array $data); +} Added: trunk/library/classes/MUtil/Model/Input.php =================================================================== --- trunk/library/classes/MUtil/Model/Input.php (rev 0) +++ trunk/library/classes/MUtil/Model/Input.php 2012-12-29 19:35:24 UTC (rev 1079) @@ -0,0 +1,253 @@ +<?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 Model + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: Crop.php 203 2012-01-01t 12:51:32Z matijs $ + */ + +/** + * + * + * @package MUtil + * @subpackage Model + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since MUtil version 1.2 + */ +class MUtil_Model_Input +{ + /** + * The data incuding $this->_context[$this->_name] + * + * @var array + */ + protected $_context; + + /** + * + * @var MUtil_Model_ModelAbstract + */ + protected $_model; + + /** + * The name of the item being garvested + * + * @var string + */ + protected $_name; + + /** + * + * @var array + */ + protected $_options; + + /** + * The original begin value + * + * @var mixed + */ + protected $_origValue; + + /** + * The current output result + * + * @var mixed + */ + protected $_output; + + /** + * + * @param MUtil_Model_ModelAbstract $model The model used + * @param string $name The item being cropped + * @param array $context The current data + */ + public function __construct(MUtil_Model_ModelAbstract $model, $name, array $context = array()) + { + // Should always exist + if (! array_key_exists($name, $context)) { + $content[$name] = null; + } + + $this->_context = $context; + $this->_model = $model; + $this->_name = $name; + $this->_options = $model->get($name); + $this->_origValue = $context[$name]; + $this->_output = $this->_origValue; + } + + /** + * Returns a context item or the whole context array when no name + * is given. + * + * @param string $name Optional name of context item + * @return mixed + */ + public function getContext($name = null) + { + if (null === $name) { + return $this->_context; + } + + if (array_key_exists($name, $this->_context)) { + return $this->_context[$name]; + } + } + + /** + * + * @return string The name of the current item + */ + public function getName() + { + return $this->_name; + } + + /** + * Return a single option value + * + * @param string $name The name of an option item + * @return mixed + */ + public function getOption($name) + { + if (array_key_exists($name, $this->_options)) { + return $this->_options[$name]; + } + } + + /** + * Return all options + * + * @return array + */ + public function getOptions() + { + return $this->_options; + } + + /** + * Return the original value + * + * @return mixed + */ + public function getOriginalValue() + { + return $this->_origValue; + } + + /** + * Return the current output + * + * @return mixed + */ + public function getOutput() + { + return $this->_output; + } + + /** + * Set a context item or replace the whole context array when an array is passed. + * + * @param mixed $nameOrArray The name of context item to set or an array containing a new context + * @param mixed $value The value to set + * @return MUtil_Model_Crop (continuation pattern) + */ + public function setContext($nameOrArray, $value = null) + { + if (is_array($nameOrArray)) { + $this->_context = $nameOrArray; + } else { + $this->_context[$nameOrArray] = $value; + } + + return $this; + } + + /** + * Set an option item. + * + * @param mixed $name The name of option item to set + * @param mixed $value The value to set + * @return MUtil_Model_Crop (continuation pattern) + */ + public function setOption($name, $value = null) + { + // If $key end with ] it is array value + if (substr($name, -1) == ']') { + if (substr($name, -2) == '[]') { + // If $name ends with [], append it to array + $name = substr($name, 0, -2); + $this->_options[$name][] = $value; + } else { + // Otherwise extract subkey + $pos = strpos($name, '['); + $subkey = substr($name, $pos + 1, -1); + $name = substr($name, 0, $pos); + + $this->_options[$name][$subkey] = $value; + } + } else { + $this->_options[$name] = $value; + } + + return $this; + } + + /** + * Set a context item or replace the whole context array when an array is passed. + * + * @param array $options An array containing a new options + * @return MUtil_Model_Crop (continuation pattern) + */ + public function setOptions(array $options) + { + $this->_options = $options; + + return $this; + } + + /** + * The output result value of this crop item + * + * @param mixed $output The new output result + * @return MUtil_Model_Crop (continuation pattern) + */ + public function setOutput($output) + { + $this->_output = $output; + + return $this; + } +} Added: trunk/library/classes/MUtil/Model/Processor/ChainedProcessor.php =================================================================== --- trunk/library/classes/MUtil/Model/Processor/ChainedProcessor.php (rev 0) +++ trunk/library/classes/MUtil/Model/Processor/ChainedProcessor.php 2012-12-29 19:35:24 UTC (rev 1079) @@ -0,0 +1,83 @@ +<?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 Model + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: ChainedProcessor.php 203 2012-01-01t 12:51:32Z matijs $ + */ + +/** + * + * + * @package MUtil + * @subpackage Model + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since MUtil version 1.2 + */ +class MUtil_Model_Processor_ChainedProcessor implements MUtil_Model_ProcessorInterface +{ + /** + * + * @var array Of MUtil_Model_ProcessorInterface + */ + protected $_processors; + + /** + * + * @param array $processors Of MUtil_Model_ProcessorInterface + */ + public function __construct(array $processors) + { + foreach ($processors as $processor) { + if ($processor instanceof MUtil_Model_ProcessorInterface) { + throw new MUtil_Model_ModelException( + 'Each processor must be an instance of MUtil_Model_ProcessorInterface' + ); + } + } + + $this->_processors = $processors; + } + + /** + * Processes the input, changing e.g. the result, context or options + * + * @param MUtil_Model_Input $input + */ + public function process(MUtil_Model_Input $input) + { + foreach ($this->_processors as $processor) { + $processor->process($input); + } + } +} Added: trunk/library/classes/MUtil/Model/Processor/Display/FormatsProcessor.php =================================================================== --- trunk/library/classes/MUtil/Model/Processor/Display/FormatsProcessor.php (rev 0) +++ trunk/library/classes/MUtil/Model/Processor/Display/FormatsProcessor.php 2012-12-29 19:35:24 UTC (rev 1079) @@ -0,0 +1,75 @@ +<?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 Model + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: MultiOptionValueProcessor.php 203 2012-01-01t 12:51:32Z matijs $ + */ + +/** + * Apply the formatFunction or dateFormat formats instead of the original value + * + * @package MUtil + * @subpackage Model + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since MUtil version 1.2 + */ +class MUtil_Model_Processor_Display_FormatsProcessor implements MUtil_Model_ProcessorInterface +{ + /** + * Processes the input, changing e.g. the result, context or options + * + * @param MUtil_Model_Input $input + * @return void + */ + public function process(MUtil_Model_Input $input) + { + $value = $input->getResult(); + $result = false; + + if ($function = $input->getOption('formatFunction')) { + $result = $function($value); + + } elseif ($format = $input->getOption('dateFormat')) { + if (is_callable($format)) { + $result = $format($value); + } else { + $result = MUtil_Date::format($value, $format, $input->getOption('storageFormat')); + } + } + + if ($result) { + $input->setOutput($result); + } + } +} Added: trunk/library/classes/MUtil/Model/Processor/Display/MultiOptionProcessor.php =================================================================== --- trunk/library/classes/MUtil/Model/Processor/Display/MultiOptionProcessor.php (rev 0) +++ trunk/library/classes/MUtil/Model/Processor/Display/MultiOptionProcessor.php 2012-12-29 19:35:24 UTC (rev 1079) @@ -0,0 +1,65 @@ +<?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 Model + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: MultiOptionValueProcessor.php 203 2012-01-01t 12:51:32Z matijs $ + */ + +/** + * Display the multi option text instead of the original value + * + * @package MUtil + * @subpackage Model + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since MUtil version 1.2 + */ +class MUtil_Model_Processor_Display_MultiOptionProcessor implements MUtil_Model_ProcessorInterface +{ + /** + * Processes the input, changing e.g. the result, context or options + * + * @param MUtil_Model_Input $input + * @return void + */ + public function process(MUtil_Model_Input $input) + { + if ($multi = $input->getOption('multiOptions')) { + + $value = $input->getResult(); + if (isset($multi[$value])) { + $input->setOutput($multi[$value]); + } + } + } +} Added: trunk/library/classes/MUtil/Model/Processor/Element/TextElementProcessor.php =================================================================== --- trunk/library/classes/MUtil/Model/Processor/Element/TextElementProcessor.php (rev 0) +++ trunk/library/classes/MUtil/Model/Processor/Element/TextElementProcessor.php 2012-12-29 19:35:24 UTC (rev 1079) @@ -0,0 +1,77 @@ +<?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 Model + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: DateProcessor.php 203 2012-01-01t 12:51:32Z matijs $ + */ + +/** + * + * + * @package MUtil + * @subpackage Model + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since MUtil version 1.2 + */ +class MUtil_Model_Processor_Element_TextElementProcessor extends MUtil_Model_Processor_ElementProcessorAbstract +{ + /** + * Allow use textbox specific options + * + * @var boolean + */ + protected $useTextOptions = true; + + /** + * Processes the input, changing e.g. the result, context or options + * + * @param MUtil_Model_Input $input + * @return void + */ + public function process(MUtil_Model_Input $input) + { + $options = $this->getFilteredOptions($input); + + $stringLengthValidator = $this->getStringLengthValidator($options); + + if ($stringLengthValidator) { + $input->setOption('validators[]', $stringLengthValidator); + } + + $this->applyElement( + $input, + new Zend_Form_Element_Text($input->getName(), $options) + ); + } +} Added: trunk/library/classes/MUtil/Model/Processor/ElementProcessorAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/Processor/ElementProcessorAbstract.php (rev 0) +++ trunk/library/classes/MUtil/Model/Processor/ElementProcessorAbstract.php 2012-12-29 19:35:24 UTC (rev 1079) @@ -0,0 +1,181 @@ +<?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 Model + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: ElementProcessorAbstract.php 203 2012-01-01t 12:51:32Z matijs $ + */ + +/** + * + * + * @package MUtil + * @subpackage Model + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since MUtil version 1.2 + */ +abstract class MUtil_Model_Processor_ElementProcessorAbstract implements MUtil_Model_ProcessorInterface +{ + /** + * When no size is set for a text-element, the size will be set to the minimum of the + * maxsize and this value. + * + * @var int + */ + protected $defaultTextLength = 40; + + /** + * Allow use of general display options + * + * @var boolean + */ + protected $useDisplayOptions = true; + + /** + * Allow use textbox specific options + * + * @var boolean + */ + protected $useTextOptions = false; + + /** + * Apply the standard processing needed and set the element as the output + * + * @param MUtil_Model_Input $input + * @param Zend_Form_Element $element + */ + protected function applyElement(MUtil_Model_Input $input, Zend_Form_Element $element) + { + if ($value = $input->getOutput()) { + $element->setValue($value); + } + + $input->setOutput($element); + } + + /** + * Nested array of allowed option names + * + * @return array + */ + protected function getAllowedOptionsNames() + { + $options = array(); + + if ($this->useDisplayOptions) { + $options[] = array( + 'accesskey', + 'autoInsertNotEmptyValidator', + 'class', + 'disabled', + 'description', + 'escape', + 'label', + 'onclick', + 'readonly', + 'required', + 'tabindex', + 'value', + 'showLabels', + 'labelplacement', + ); + } + + if ($this->useTextOptions) { + $options[] = array( + 'maxlength', + 'minlength', + 'onchange', + 'onfocus', + 'onselect', + 'size'); + } + /* + self::CHECK_OPTIONS => array('checkedValue', 'uncheckedValue'), + self::DATE_OPTIONS => array('dateFormat', 'storageFormat'), + self::EXHIBIT_OPTIONS => array('formatFunction'), + self::FILE_OPTIONS => array('accept', 'count', 'destination', 'valueDisabled'), + self::GROUP_OPTIONS => array('elements', 'legend', 'separator'), + self::JQUERY_OPTIONS => array('jQueryParams'), + self::MULTI_OPTIONS => array('disable', 'multiOptions', 'onchange', 'separator', 'size', 'disableTranslator'), + self::PASSWORD_OPTIONS => array('repeatLabel'), + self::TAB_OPTIONS => array('value'), + self::TEXTAREA_OPTIONS => array('cols', 'rows', 'wrap'), + //*/ + + return $options; + } + + /** + * Get those options that are actually allowed to be used by this element + * + * @param MUtil_Model_Input $input + * @return array + */ + protected function getFilteredOptions(MUtil_Model_Input $input) + { + $allowedOptions = MUtil_Ra::flatten($this->getAllowedOptionsNames()); + + $options = $input->getOptions(); + + return array_intersect_key($options, array_flip($allowedOptions)); + } + + /** + * Create a StringLength validator (array) and remove those + * options that should not appear in the output. + * + * @param array $options + * @return array For validator creation + */ + protected function getStringLengthValidator(array &$options) + { + if (isset($options['minlength'])) { + $stringlength['min'] = $options['minlength']; + unset($options['minlength']); + } + if (isset($options['size']) && (! isset($options['maxlength']))) { + $options['maxlength'] = $options['size']; + } + if (isset($options['maxlength'])) { + if (! isset($options['size'])) { + $options['size'] = min($options['maxlength'], $this->defaultTextLength); + } + $stringlength['max'] = $options['maxlength']; + } + + if (isset($stringlength)) { + return array('StringLength', true, $stringlength); + } + } +} Added: trunk/library/classes/MUtil/Model/ProcessorInterface.php =================================================================== --- trunk/library/classes/MUtil/Model/ProcessorInterface.php (rev 0) +++ trunk/library/classes/MUtil/Model/ProcessorInterface.php 2012-12-29 19:35:24 UTC (rev 1079) @@ -0,0 +1,55 @@ +<?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 Model + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: ProcessorInterface.php 203 2012-01-01t 12:51:32Z matijs $ + */ + +/** + * + * + * @package MUtil + * @subpackage Model + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since MUtil version 1.2 + */ +interface MUtil_Model_ProcessorInterface +{ + /** + * Processes the input, changing e.g. the result, context or options + * + * @param MUtil_Model_Input $input + */ + public function process(MUtil_Model_Input $input); +} Modified: trunk/library/classes/MUtil/Version.php =================================================================== --- trunk/library/classes/MUtil/Version.php 2012-12-29 19:32:02 UTC (rev 1078) +++ trunk/library/classes/MUtil/Version.php 2012-12-29 19:35:24 UTC (rev 1079) @@ -47,8 +47,8 @@ class MUtil_Version { const MAJOR = 1; - const MINOR = 1; - const BUILD = 36; + const MINOR = 2; + const BUILD = 40; public static function get() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2013-01-11 18:29:09
|
Revision: 1097 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1097&view=rev Author: matijsdejong Date: 2013-01-11 18:28:58 +0000 (Fri, 11 Jan 2013) Log Message: ----------- Check for absolute paths in PluginLoader Modified Paths: -------------- trunk/library/classes/MUtil/Form.php trunk/library/classes/MUtil/Loader/PluginLoader.php Modified: trunk/library/classes/MUtil/Form.php =================================================================== --- trunk/library/classes/MUtil/Form.php 2013-01-11 18:14:20 UTC (rev 1096) +++ trunk/library/classes/MUtil/Form.php 2013-01-11 18:28:58 UTC (rev 1097) @@ -80,9 +80,6 @@ */ public function __construct($options = null) { - $this->addPrefixPath('MUtil_Form_Decorator', 'MUtil/Form/Decorator/', Zend_Form::DECORATOR); - $this->addPrefixPath('MUtil_Form_Element', 'MUtil/Form/Element/', Zend_Form::ELEMENT); - $this->addElementPrefixPath('MUtil_Form_Decorator', 'MUtil/Form/Decorator', Zend_Form_Element::DECORATOR); $this->addElementPrefixPath('MUtil_Validate', 'MUtil/Validate/', Zend_Form_Element::VALIDATE); @@ -238,6 +235,46 @@ } /** + * Retrieve plugin loader for given type + * + * $type may be one of: + * - decorator + * - element + * + * If a plugin loader does not exist for the given type, defaults are + * created. + * + * @param string $type + * @return Zend_Loader_PluginLoader_Interface + */ + public function getPluginLoader($type = null) + { + $type = strtoupper($type); + if (!isset($this->_loaders[$type])) { + switch ($type) { + case self::DECORATOR: + $prefixSegment = 'Form_Decorator'; + $pathSegment = 'Form/Decorator'; + break; + case self::ELEMENT: + $prefixSegment = 'Form_Element'; + $pathSegment = 'Form/Element'; + break; + default: + require_once 'Zend/Form/Exception.php'; + throw new Zend_Form_Exception(sprintf('Invalid type "%s" provided to getPluginLoader()', $type)); + } + + $this->_loaders[$type] = new MUtil_Loader_PluginLoader(array( + 'Zend_' . $prefixSegment . '_' => 'Zend/' . $pathSegment . '/', + 'MUtil_' . $prefixSegment . '_' => 'MUtil/' . $pathSegment . '/', + )); + } + + return $this->_loaders[$type]; + } + + /** * Return true when the form is lazy * * @return boolean Modified: trunk/library/classes/MUtil/Loader/PluginLoader.php =================================================================== --- trunk/library/classes/MUtil/Loader/PluginLoader.php 2013-01-11 18:14:20 UTC (rev 1096) +++ trunk/library/classes/MUtil/Loader/PluginLoader.php 2013-01-11 18:28:58 UTC (rev 1097) @@ -71,10 +71,15 @@ throw new Zend_Loader_PluginLoader_Exception('Zend_Loader_PluginLoader::addPrefixPath() method only takes strings for prefix and path.'); } - // Only add existing directories - if (file_exists(rtrim($path, '/\\'))) { - parent::addPrefixPath($prefix, $path); + if ($path) { + if (('/' == $path[0]) || ('.' == $path[0]) || ((strlen($path) > 1) && (':' == $path[1]))) { + // Only add existing directories + if (! file_exists(rtrim($path, '/\\'))) { + return $this; + } + } } + parent::addPrefixPath($prefix, $path); return $this; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-11-01 11:08:45
|
Revision: 1004 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1004&view=rev Author: matijsdejong Date: 2012-11-01 11:08:38 +0000 (Thu, 01 Nov 2012) Log Message: ----------- removed renderAny added documentation Modified Paths: -------------- trunk/library/classes/MUtil/Html/HtmlElement.php trunk/library/classes/MUtil/Html/Renderer.php trunk/library/classes/MUtil/Html.php Modified: trunk/library/classes/MUtil/Html/HtmlElement.php =================================================================== --- trunk/library/classes/MUtil/Html/HtmlElement.php 2012-11-01 09:38:21 UTC (rev 1003) +++ trunk/library/classes/MUtil/Html/HtmlElement.php 2012-11-01 11:08:38 UTC (rev 1004) @@ -1062,14 +1062,14 @@ if ($this->_repeater->__start()) { $html = null; while ($this->_repeater->__next()) { - $html .= implode('', $renderer->renderAny($view, $this->_content)); + $html .= $renderer->renderAny($view, $this->_content); } return $html; } } elseif ($content = $renderer->renderAny($view, $this->_content)) { - return implode('', $content); + return $content; } } Modified: trunk/library/classes/MUtil/Html/Renderer.php =================================================================== --- trunk/library/classes/MUtil/Html/Renderer.php 2012-11-01 09:38:21 UTC (rev 1003) +++ trunk/library/classes/MUtil/Html/Renderer.php 2012-11-01 11:08:38 UTC (rev 1004) @@ -1,10 +1,9 @@ <?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 @@ -15,7 +14,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,25 +25,50 @@ * 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: Renderer.php 362 2011-12-15 17:21:17Z matijsdejong $ */ /** - * @author Matijs de Jong - * @since 1.0 - * @version 1.1 - * @package MUtil + * Render output for a view. + * + * This object handles MUtil_Html_HtmlInterface and MUtil_Lazy_LazyInterface + * objects natively, as well as array, scalar values and objects with a + * __toString function. + * + * All other object types passed to the renderer should have a render function + * defined for them in the ClassRenderList. + * + * @package MUtil * @subpackage Html + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 */ - class MUtil_Html_Renderer { + /** + * + * @var MUtil_Util_ClassList + */ protected $_classRenderFunctions; - // The MUtil_Html_Renderer::doNotRender items allow you to pass these - // items to a content without triggering error messages. - // - // This is usefull if you want to pass an item but are not sure that - // it will be used in very case. + /** + * Default array of objects rendering functions. + * + * The MUtil_Html_Renderer::doNotRender function allows items to be passed + * as content without triggering error messages. + * + * This is usefull if you want to pass an item to sub objects, but are not + * sure that it will be used in every case. + * + * @var array classname => static output function + */ protected $_initialClassRenderFunctions = array( 'Zend_Db_Adapter_Abstract' => 'MUtil_Html_Renderer::doNotRender', 'Zend_Controller_Request_Abstract' => 'MUtil_Html_Renderer::doNotRender', @@ -54,11 +78,23 @@ 'Zend_Translate' => 'MUtil_Html_Renderer::doNotRender', ); + /** + * Create the renderer + * + * @param mixed $classRenderFunctions Array of classname => renderFunction or MUtil_Util_ClassList + * @param boolean $append Replace when false, append to default definitions otherwise + */ public function __construct($classRenderFunctions = null, $append = true) { $this->setClassRenderList($classRenderFunctions, $append); } + /** + * Check if the value can be rendered by this object + * + * @param mixed $value + * @return boolean True when the object can be rendered + */ public function canRender($value) { if (is_object($value)) { @@ -83,6 +119,16 @@ } } + /** + * Static helper function used for object types that should + * not produce output when (accidently) rendered. + * + * Eg Zend_Translate or Zend_Db_Adapter_Abstract + * + * @param Zend_View_Abstract $view + * @param mixed $content + * @return null + */ public static function doNotRender(Zend_View_Abstract $view, $content) { if (MUtil_Html::$verbose) { @@ -91,11 +137,33 @@ return null; } + /** + * Get the classlist containing render functions for non-builtin objects + * + * @return MUtil_Util_ClassList + */ public function getClassRenderList() { return $this->_classRenderFunctions; } + /** + * Renders the $content so that it can be used as output for the $view, + * including output escaping and encoding correction. + * + * This functions handles MUtil_Html_HtmlInterface and MUtil_Lazy_LazyInterface + * objects natively, as well as array, scalar values and objects with a + * __toString function. + * + * Other objects a definition should have a render function in getClassRenderList(). + * + * All Lazy variabables are raised. + * + * @param Zend_View_Abstract $view + * @param mixed $content Anything HtmlInterface, number, string, array, object with __toString + * or an object that has a defined render function in getClassRenderList(). + * @return string Output to echo to the user + */ public function renderAny(Zend_View_Abstract $view, $content) { // Resolve first as this function as recursion heavy enough as it is. @@ -111,14 +179,10 @@ // Again, skip on the recursion count foreach ($content as $key => $item) { - $new_content[$key] = $this->renderAny($view, $item); - // MUtil_Echo::r($key . '=>' . $new_content[$key]); - if (null === $new_content[$key]) { - unset($new_content[$key]); - } + $new_content[] = $this->renderAny($view, $item); } - return $new_content; + return implode('', $new_content); } else { if (is_object($content)) { @@ -141,25 +205,20 @@ return $new_content; - } elseif (! is_array($content)) { - return $content; // Returns 0 (zero) and '' when that is the value of $content } - } - public function renderArray(Zend_View_Abstract $view, array $content) - { - if ($content) { - foreach ($content as $key => $item) { - $content[$key] = $this->renderAny($view, $item); - if (null === $content[$key]) { - unset($content[$key]); - } - } - - return $content; + if (! is_array($content)) { // Skip empty array + return $content; // Returns 0 (zero) and '' when that is the value of $content } } + /** + * Change the list of non-builtin objects that can be rendered by this renderer. + * + * @param mixed $classRenderFunctions Array of classname => renderFunction or MUtil_Util_ClassList + * @param boolean $append Replace when false, append otherwise + * @return MUtil_Html_Renderer (continuation pattern) + */ public function setClassRenderList($classRenderFunctions = null, $append = false) { if ($classRenderFunctions instanceof MUtil_Util_ClassList) { Modified: trunk/library/classes/MUtil/Html.php =================================================================== --- trunk/library/classes/MUtil/Html.php 2012-11-01 09:38:21 UTC (rev 1003) +++ trunk/library/classes/MUtil/Html.php 2012-11-01 11:08:38 UTC (rev 1004) @@ -98,6 +98,12 @@ return self::getCreator()->createAttribute($attributeName, $args); } + /** + * Check if the value can be rendered by the default renderer + * + * @param mixed $value + * @return boolean True when the object can be rendered + */ public static function canRender($value) { return self::getRenderer()->canRender($value); @@ -235,16 +241,19 @@ return self::getCreator()->create('raw', array($content)); } + /** + * Renders the $content so that it can be used as output for the $view, + * including output escaping and encoding correction. + * + * @param Zend_View_Abstract $view + * @param mixed $content Anything number, string, array, Lazy, HtmlInterface, object with __toString + * @return string Output to echo to the user + */ public static function renderAny(Zend_View_Abstract $view, $content) { return self::getRenderer()->renderAny($view, $content); } - public static function renderArray(Zend_View_Abstract $view, array $content) - { - return self::getRenderer()->renderArray($view, $content); - } - public static function renderNew(Zend_View_Abstract $view, $tagName, $arg_array = null) { $args = array_slice(func_get_args(), 2); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-12-28 16:16:19
|
Revision: 1076 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1076&view=rev Author: matijsdejong Date: 2012-12-28 16:16:11 +0000 (Fri, 28 Dec 2012) Log Message: ----------- Added/fixed documentation and small bugs Modified Paths: -------------- trunk/library/classes/MUtil/Html/Renderer.php trunk/library/classes/MUtil/Model/TableModel.php trunk/library/classes/MUtil/Util/ClassList.php trunk/library/classes/MUtil/Util/FunctionList.php trunk/library/classes/MUtil/Util/LookupList.php Modified: trunk/library/classes/MUtil/Html/Renderer.php =================================================================== --- trunk/library/classes/MUtil/Html/Renderer.php 2012-12-28 13:55:22 UTC (rev 1075) +++ trunk/library/classes/MUtil/Html/Renderer.php 2012-12-28 16:16:11 UTC (rev 1076) @@ -98,13 +98,13 @@ public function canRender($value) { if (is_object($value)) { - if (method_exists($value, '__toString') || - ($value instanceof MUtil_Lazy_LazyInterface) || - ($value instanceof MUtil_Html_HtmlInterface)) { + if (($value instanceof MUtil_Lazy_LazyInterface) || + ($value instanceof MUtil_Html_HtmlInterface) || + method_exists($value, '__toString')) { return true; } - return $this->_classRenderFunctions->get($content); + return $this->_classRenderFunctions->get($value); } else { if (is_array($value)) { Modified: trunk/library/classes/MUtil/Model/TableModel.php =================================================================== --- trunk/library/classes/MUtil/Model/TableModel.php 2012-12-28 13:55:22 UTC (rev 1075) +++ trunk/library/classes/MUtil/Model/TableModel.php 2012-12-28 16:16:11 UTC (rev 1076) @@ -52,6 +52,11 @@ */ private $_table; + /** + * + * @param Zend_Db_Table_Abstract $table An Zend abstract table or the table name + * @param string $altName An alternative name to use, default is the name of the table itself + */ public function __construct($table, $altName = null) { if ($table instanceof Zend_Db_Table_Abstract) { Modified: trunk/library/classes/MUtil/Util/ClassList.php =================================================================== --- trunk/library/classes/MUtil/Util/ClassList.php 2012-12-28 13:55:22 UTC (rev 1075) +++ trunk/library/classes/MUtil/Util/ClassList.php 2012-12-28 16:16:11 UTC (rev 1076) @@ -1,51 +1,68 @@ <?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 Util + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $id: ClassList.php 362 2011-12-15 17:21:17Z matijsdejong $ */ /** - * - * @author Matijs de Jong - * @package MUtil + * Return a value (the kind is up to the user), using either an object + * or a class name as lookup key. + * + * When not finding a direct match, this object checks (first) the parent classes + * and then the interfaces for a match. Search results are then stored in a cache. + * + * @package MUtil * @subpackage Util + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 */ class MUtil_Util_ClassList extends MUtil_Util_LookupList { + /** + * Sub classes known to have a mapping + * + * @var array + */ protected $_subClasses; + + /** + * Classes not found in this lookup list + * + * @var array + */ protected $_notSubClasses; /** @@ -75,56 +92,58 @@ { if (is_object($key)) { $class = get_class($key); + } else { + $class = $key; + } - // Check for existence - if ($result = parent::_getItem($class, $default)) { - return $result; - } - // Check was already found - if (array_key_exists($class, $this->_subClasses)) { - return $this->_subClasses[$class]; - } - // Check was already searched and not found - if (array_key_exists($class, $this->_notSubClasses)) { - return $default; - } + // Check for simple existence + if ($result = parent::_getItem($class, $default)) { + return $result; + } - // Check the parent classes of the object - $parents = class_parents($key); - $result = null; - foreach ($parents as $parentClass) { - if ($result = parent::_getItem($parentClass, null)) { - // Add the current class to the cache - $this->_subClasses[$class] = $result; + // Check was already found + if (array_key_exists($class, $this->_subClasses)) { + return $this->_subClasses[$class]; + } - // Add all parents up to the one matching to the cache - foreach ($parents as $priorParent) { - $this->_subClasses[$priorParent] = $result; - if ($parentClass === $priorParent) { - // Further parents are not automatically in the list - break; - } + // Check was already searched and not found + if (array_key_exists($class, $this->_notSubClasses)) { + return $default; + } + + // Check the parent classes of the object + $parents = class_parents($key); + $result = null; + foreach ($parents as $parentClass) { + if ($result = parent::_getItem($parentClass, null)) { + // Add the current class to the cache + $this->_subClasses[$class] = $result; + + // Add all parents up to the one matching to the cache + foreach ($parents as $priorParent) { + $this->_subClasses[$priorParent] = $result; + if ($parentClass === $priorParent) { + // Further parents are not automatically in the list + break; } - return $result; } + return $result; } + } - // Check the interfaces implemented by the object - $implemented = class_implements($key); - foreach ($implemented as $interface) { - if ($result = parent::_getItem($interface, null)) { - // Add the current class to the cache - $this->_subClasses[$class] = $result; - return $result; - } + // Check the interfaces implemented by the object + $implemented = class_implements($key); + foreach ($implemented as $interface) { + if ($result = parent::_getItem($interface, null)) { + // Add the current class to the cache + $this->_subClasses[$class] = $result; + return $result; } + } - // Add to the not found cache - $this->_notSubClasses[$class] = true; + // Add to the not found cache + $this->_notSubClasses[$class] = true; - return $default; - } else { - return parent::_getItem($key, $default); - } + return $default; } } \ No newline at end of file Modified: trunk/library/classes/MUtil/Util/FunctionList.php =================================================================== --- trunk/library/classes/MUtil/Util/FunctionList.php 2012-12-28 13:55:22 UTC (rev 1075) +++ trunk/library/classes/MUtil/Util/FunctionList.php 2012-12-28 16:16:11 UTC (rev 1076) @@ -1,47 +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. - */ - + /** - * - * @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 Util + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $id: FunctionList.php 362 2011-12-15 17:21:17Z matijsdejong $ */ /** - * - * @author Matijs de Jong - * @package MUtil + * Return a function value using a scalar key. + * + * @package MUtil * @subpackage Util + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 */ class MUtil_Util_FunctionList extends MUtil_Util_LookupList { @@ -59,9 +61,11 @@ if (isset($this->_elements[$key])) { $function = $this->_elements[$key]; - // TODO: Check for object loading here - - return $function; + if (is_callable($function)) { + return $function; + } else { + return $default; + } } else { return $default; } Modified: trunk/library/classes/MUtil/Util/LookupList.php =================================================================== --- trunk/library/classes/MUtil/Util/LookupList.php 2012-12-28 13:55:22 UTC (rev 1075) +++ trunk/library/classes/MUtil/Util/LookupList.php 2012-12-28 16:16:11 UTC (rev 1076) @@ -1,47 +1,52 @@ <?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 Util + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $id: LookupList.php 362 2011-12-15 17:21:17Z matijsdejong $ */ /** - * - * @author Matijs de Jong - * @package MUtil + * Return a value (the kind is up to the user) using a scalar key. + * + * The advantages to using e.g. a standard array object is that both the + * key type and the search algorithm can be customized in each child class. + * + * @package MUtil * @subpackage Util + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 */ class MUtil_Util_LookupList { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2013-01-11 18:14:28
|
Revision: 1096 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1096&view=rev Author: matijsdejong Date: 2013-01-11 18:14:20 +0000 (Fri, 11 Jan 2013) Log Message: ----------- Continuing on the method to format values Modified Paths: -------------- trunk/library/classes/MUtil/Loader/PluginLoader.php trunk/library/classes/MUtil/Model/ModelAbstract.php trunk/library/classes/MUtil/Model.php Modified: trunk/library/classes/MUtil/Loader/PluginLoader.php =================================================================== --- trunk/library/classes/MUtil/Loader/PluginLoader.php 2013-01-11 15:24:03 UTC (rev 1095) +++ trunk/library/classes/MUtil/Loader/PluginLoader.php 2013-01-11 18:14:20 UTC (rev 1096) @@ -47,11 +47,23 @@ class MUtil_Loader_PluginLoader extends Zend_Loader_PluginLoader { /** + * Add the default autoloader to this plugin loader. + * + * @return Zend_Loader_PluginLoader (continuation pattern) + */ + public function addFallBackPath() + { + parent::addPrefixPath('', ''); + + return $this; + } + + /** * Add prefixed paths to the registry of paths * * @param string $prefix * @param string $path - * @return Zend_Loader_PluginLoader + * @return Zend_Loader_PluginLoader (continuation pattern) */ public function addPrefixPath($prefix, $path) { @@ -66,6 +78,7 @@ return $this; } + /** * Instantiate a new class using the arguments array for initiation * @@ -75,7 +88,7 @@ */ public function createClass($className, array $arguments = array()) { - if (!class_exists($className)) { + if (!class_exists($className, false)) { $className = $this->load($className); } Modified: trunk/library/classes/MUtil/Model/ModelAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/ModelAbstract.php 2013-01-11 15:24:03 UTC (rev 1095) +++ trunk/library/classes/MUtil/Model/ModelAbstract.php 2013-01-11 18:14:20 UTC (rev 1096) @@ -67,10 +67,46 @@ private $_changedCount = 0; private $_keys; + + /** + * Contains the per field settings of the model + * + * @var array field_name => array(settings) + */ private $_model = array(); - private $_model_meta; + + /** + * Contains the settings for the model as a whole + * + * @var array + */ + private $_model_meta = array( + MUtil_Model::META_ASSEMBLERS => array( + MUtil_Model::FORM => 'FormAssembler', + ), + ); + + /** + * An identifying name for the model + * + * @var string + */ private $_model_name; + + /** + * The order in which field names where ->set() since + * the last ->resetOrder() - minus those not set. + * + * @var array + */ private $_model_order; + + /** + * Contains the (order in which) fields where accessed using + * ->get(), containing only those fields that where accesed. + * + * @var type + */ private $_model_used = false; /** @@ -509,6 +545,12 @@ } } + /** + * Returns the field that name is an Alias of + * + * @param string $name + * @return string + */ public function getAlias($name) { if (isset($this->_model[$name][self::ALIAS_OF])) { @@ -516,6 +558,42 @@ } } + /** + * Get/load the assembler for the specific idenitifier + * + * @param string $identifier + * @param array $data Optional array with data. + * @return MUtil_Model_AssemblerInterface + */ + public function getAssemblerFor($identifier, array $data = null) + { + $assemblers = $this->getMeta(MUtil_Model::META_ASSEMBLERS); + + if (isset($assemblers[$identifier])) { + if ($assemblers[$identifier] instanceof MUtil_Model_AssemblerInterface) { + return $assemblers[$identifier]; + } + + $loader = MUtil_Model::getAssemblerLoader(); + $assembler = $loader->createClass($assemblers[$identifier]); + $assembler->setModel($this); + + if (null !== $data) { + $assembler->setRow($data); + } + + $assemblers[$identifier] = $assembler; + $this->setMeta(MUtil_Model::META_ASSEMBLERS, $assemblers); + + return $assembler; + } + } + + /** + * The number of item rows changed since the last save or delete + * + * @return int + */ public function getChanged() { return $this->_changedCount; @@ -546,11 +624,30 @@ return $results; } + /** + * Get the current default filter for save/loade + * @return array + */ public function getFilter() { return $this->getMeta('filter', array()); } + /** + * Get/load the assembler for forms + * + * @param array $data Optional array with data. + * @return MUtil_Model_AssemblerInterface + */ + public function getFormAssembler(array $data = null) + { + return $this->getAssemblerFor(MUtil_Model::FORM, $data); + } + + /** + * Returns all the field names in this model + * @return array + */ public function getItemNames() { return array_keys($this->_model); Modified: trunk/library/classes/MUtil/Model.php =================================================================== --- trunk/library/classes/MUtil/Model.php 2013-01-11 15:24:03 UTC (rev 1095) +++ trunk/library/classes/MUtil/Model.php 2013-01-11 18:14:20 UTC (rev 1096) @@ -37,6 +37,16 @@ class MUtil_Model { /** + * Indentifier for form (meta) assemblers and (field) processors + */ + const FORM = 'form'; + + /** + * Indentifier for assemblers meta key + */ + const META_ASSEMBLERS = 'assemblers'; + + /** * In order to keep the url's short and to hide any field names from * the user, model identifies key values by using 'id' for a single * key value and id1, id2, etc... for multiple keys. @@ -86,6 +96,12 @@ const TYPE_TIME = 5; /** + * + * @var MUtil_Loader_PluginLoader + */ + private static $_assemblerLoader; + + /** * Static variable for debuggging purposes. Toggles the echoing of e.g. of sql * select statements, using MUtil_Echo. * @@ -100,4 +116,34 @@ * @var boolean $verbose If true echo retrieval statements. */ public static $verbose = false; + + /** + * Returns the plugin loader for assemblers + * + * @return MUtil_Loader_PluginLoader + */ + public static function getAssemblerLoader() + { + if (! self::$_assemblerLoader) { + $loader = new MUtil_Loader_PluginLoader(); + + $loader->addPrefixPath('MUtil_Model_Assembler', __DIR__ . '/Model/Assembler') + ->addFallBackPath(); + // maybe add interface def to plugin loader: MUtil_Model_AssemblerInterface + + self::$_assemblerLoader = $loader; + } + + return self::$_assemblerLoader; + } + + /** + * Sets the plugin loader for assemblers + * + * @param MUtil_Loader_PluginLoader $loader + */ + public static function setAssemblerLoader(MUtil_Loader_PluginLoader $loader) + { + self::$_assemblerLoader = $loader; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2013-01-13 20:03:25
|
Revision: 1098 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1098&view=rev Author: matijsdejong Date: 2013-01-13 20:03:13 +0000 (Sun, 13 Jan 2013) Log Message: ----------- Loader/PluginLoader.php now checks the include path for possible loading directories Assemblers and Processors can be loaded through (centrally defined) plugin Loader/PluginLoader.php Model/Input loads options lazily Model/AssemblerInterface allows options to be set during processor construction Modified Paths: -------------- trunk/library/classes/MUtil/Loader/PluginLoader.php trunk/library/classes/MUtil/Model/Assembler/FormAssembler.php trunk/library/classes/MUtil/Model/AssemblerAbstract.php trunk/library/classes/MUtil/Model/AssemblerInterface.php trunk/library/classes/MUtil/Model/Input.php trunk/library/classes/MUtil/Model/ModelAbstract.php trunk/library/classes/MUtil/Model/Processor/ElementProcessorAbstract.php trunk/library/classes/MUtil/Model.php Added Paths: ----------- trunk/library/classes/MUtil/Model/Processor/Element/SelectElementProcessor.php Modified: trunk/library/classes/MUtil/Loader/PluginLoader.php =================================================================== --- trunk/library/classes/MUtil/Loader/PluginLoader.php 2013-01-11 18:28:58 UTC (rev 1097) +++ trunk/library/classes/MUtil/Loader/PluginLoader.php 2013-01-13 20:03:13 UTC (rev 1098) @@ -71,15 +71,10 @@ throw new Zend_Loader_PluginLoader_Exception('Zend_Loader_PluginLoader::addPrefixPath() method only takes strings for prefix and path.'); } - if ($path) { - if (('/' == $path[0]) || ('.' == $path[0]) || ((strlen($path) > 1) && (':' == $path[1]))) { - // Only add existing directories - if (! file_exists(rtrim($path, '/\\'))) { - return $this; - } - } + // MUtil_Echo::track(self::getAbsolutePaths($path)); + foreach (self::getAbsolutePaths($path) as $sub) { + parent::addPrefixPath($prefix, $sub); } - parent::addPrefixPath($prefix, $path); return $this; } @@ -163,4 +158,81 @@ ); } } + + /** + * Add existing include path directories to subdirectory (if not absolute) + * + * @staticvar string $includePaths Array containing exploded and checked include path + * @param string $path + * @return array Can be empty if none of the options exist + */ + public static function getAbsolutePaths($path) + { + static $includePaths; + + if ($path) { + // Try to see if the path is an absolute path. Some exotic absolute paths can fail this test, + // but it is more error prone to test for them here than to loop through them afterwards. + if (self::isAbsolutePath($path)) { + if ($real = realpath($path)) { + return array($real); + } else { + return array(); + } + } + } + + if (! is_array($includePaths)) { + // Make sure the include path are loaded + foreach (Zend_Loader::explodeIncludePath() as $include) { + // Current path will be checked, for each file + // but check the other paths for exiistence + if (('.' != $include) && ($real = realpath($include))) { + $includePaths[] = $real . DIRECTORY_SEPARATOR; + } + } + } + + // Check path name + $results = array(); + if ($real = realpath($path)) { + $results[] = $real; + } + + // Check simple concatenation + foreach ($includePaths as $include) { + if ($real = realpath($include . $path)) { + $results[] = $real;; + } + } + + // Reverse the result as that is the order this loader handles the directories + return array_reverse($results); + } + + /** + * Do a quick check for a path being absolute (may not work for some exotic absolute paths though) + * + * @param string $path + * @return boolean + */ + public static function isAbsolutePath($path) + { + if ($path) { + // Try to see if the path is an absolute path. Some exotic absolute paths can fail this test, + // but it is more error prone to test for them here than to loop through them afterwards. + if (substr(PHP_OS, 0, 1) === 'WIN') { + // Match for A:\ and \\ network paths + if (preg_match('/([A-Za-z]:\\|\\\\)./', $path)) { + return true; + } + } else { + if (strlen($path) && (DIRECTORY_SEPARATOR === $path[0])) { + return true; + } + } + } + + return false; + } } Modified: trunk/library/classes/MUtil/Model/Assembler/FormAssembler.php =================================================================== --- trunk/library/classes/MUtil/Model/Assembler/FormAssembler.php 2013-01-11 18:28:58 UTC (rev 1097) +++ trunk/library/classes/MUtil/Model/Assembler/FormAssembler.php 2013-01-13 20:03:13 UTC (rev 1098) @@ -49,12 +49,18 @@ /** * Create the processor for this name * + * @param MUtil_Model_ModelAbstract $model * @param string $name - * @return MUtil_Model_ProcessorInterface or null when it does not exist + * @return MUtil_Model_ProcessorInterface or string or array for creation null when it does not exist */ - protected function _assemble($name) + protected function _assemble(MUtil_Model_ModelAbstract $model, $name) { - return new MUtil_Model_Processor_Element_TextElementProcessor(); + + if ($model->has($name, 'multiOptions')) { + return 'Element_SelectElementProcessor'; + } + + return 'Element_TextElementProcessor'; } } Modified: trunk/library/classes/MUtil/Model/AssemblerAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/AssemblerAbstract.php 2013-01-11 18:28:58 UTC (rev 1097) +++ trunk/library/classes/MUtil/Model/AssemblerAbstract.php 2013-01-13 20:03:13 UTC (rev 1098) @@ -36,8 +36,14 @@ */ /** + * Abstract implementation of AssemblerInterface, only _assmble() needs to be + * implemented. * + * This abstract class contains helper functions to facilitate working + * with processors. * + * @see MUtil_Model_AssemblerInterface + * * @package MUtil * @subpackage Model * @copyright Copyright (c) 2012 Erasmus MC @@ -54,12 +60,24 @@ /** * + * @var array name => extra options for name + */ + protected $_extraArgs = array(); + + /** + * * @var MUtil_Model_ModelAbstract */ protected $_model; /** * + * @var MUtil_Loader_PluginLoader + */ + private $_processorLoader = array(); + + /** + * * @var array Of name => MUtil_Model_ProcessorInterface */ protected $_processors = array(); @@ -79,21 +97,37 @@ /** * Create the processor for this name * + * @param MUtil_Model_ModelAbstract $model * @param string $name - * @return MUtil_Model_ProcessorInterface or null when it does not exist + * @return MUtil_Model_ProcessorInterface or string or array for creation null when it does not exist */ - abstract protected function _assemble($name); + abstract protected function _assemble(MUtil_Model_ModelAbstract $model, $name); /** * Get the processed output of the input or a lazy object if the data is repeated * or not yet set using setRepeater() or setRow(). * * @param string $name + * @param mixed $arrayOrKey1 A key => value array or the name of the first key, see MUtil_Args::pairs() + * These setting are applied to the model. + * @param mixed $value1 The value for $arrayOrKey1 or null when $arrayOrKey1 is an array + * @param string $key2 Optional second key when $arrayOrKey1 is a string + * @param mixed $value2 Optional second value when $arrayOrKey1 is a string, + * an unlimited number of $key values pairs can be given. * @return mixed MUtil_Lazy_Call when not using setRow(), actual output otherwise */ - public function getOutput($name) + public function getOutput($name, $arrayOrKey1 = null, $value1 = null, $key2 = null, $value2 = null) { - if (! $this->hasProcessor($name)) { + // Process new settings + if ($args = MUtil_Ra::pairs(func_get_args(), 1)) { + if (! $this->_model) { + throw new MUtil_Model_ModelException("Cannot use processor without a model."); + } + + $this->_model->set($name, $args); + } + + if (! $this->hasProcessor($name, $args)) { if ($this->_row) { if (isset($this->_row[$name])) { return $this->_row[$name]; @@ -119,14 +153,44 @@ return new MUtil_Lazy_Call(array($this, 'output'), array($name)); } + /** + * Returns the plugin loader for processors. + * + * @return MUtil_Loader_PluginLoader + */ + public function getProcessorLoader() + { + if (! $this->_processorLoader) { + $this->setProcessorLoader(MUtil_Model::getProcessorLoader()); + } + + return $this->_processorLoader; + } + + /** * Returns the processor for the name * * @param string $name + * @param mixed $arrayOrKey1 A key => value array or the name of the first key, see MUtil_Args::pairs() + * These setting are applied to the model. + * @param mixed $value1 The value for $arrayOrKey1 or null when $arrayOrKey1 is an array + * @param string $key2 Optional second key when $arrayOrKey1 is a string + * @param mixed $value2 Optional second value when $arrayOrKey1 is a string, + * an unlimited number of $key values pairs can be given. * @return MUtil_Model_ProcessorInterface or null when it does not exist */ - public function getProcessor($name) + public function getProcessor($name, $arrayOrKey1 = null, $value1 = null, $key2 = null, $value2 = null) { + // Process new settings + if ($args = MUtil_Ra::pairs(func_get_args(), 1)) { + if (! $this->_model) { + throw new MUtil_Model_ModelException("Cannot use processor without a model."); + } + + $this->_model->set($name, $args); + } + if ($this->hasProcessor($name)) { return $this->_processors[$name]; } @@ -140,13 +204,17 @@ */ public function hasProcessor($name) { + if (! $this->_model) { + throw new MUtil_Model_ModelException("Cannot use processor without a model."); + } + if (! array_key_exists($name, $this->_processors)) { // Default if nothing there $this->_processors[$name] = false; // Try to create one if ($this->_model->has($name)) { - if ($processor = $this->_assemble($name)) { + if ($processor = $this->_assemble($this->_model, $name)) { $this->setProcessor($name, $processor); } } @@ -185,30 +253,57 @@ } /** - * Set the processor for a name + * Set the model of this assembler * - * @param string $name - * $param MUtil_Model_ProcessorInterface $processor + * @param MUtil_Model_ModelAbstract $model * @return MUtil_Model_AssemblerInterface (continuation pattern) */ - public function setProcessor($name, MUtil_Model_ProcessorInterface $processor) + public function setModel(MUtil_Model_ModelAbstract $model) { - $this->_processors[$name] = $processor; + $this->_model = $model; return $this; } /** - * Set the model of this assembler + * Sets the plugin loader for processors. * - * @param MUtil_Model_ModelAbstract $model + * @param MUtil_Loader_PluginLoader $loader + */ + public function setProcessorLoader(MUtil_Loader_PluginLoader $loader) + { + $this->_processorLoader = $loader; + } + + /** + * Set the processor for a name + * + * @param string $name + * $param mixed $processor MUtil_Model_ProcessorInterface or string or array that can be used to create processor * @return MUtil_Model_AssemblerInterface (continuation pattern) */ - public function setModel(MUtil_Model_ModelAbstract $model) + public function setProcessor($name, $processor) { - $this->_model = $model; + if (is_string($processor)) { + $loader = $this->getProcessorLoader(); + $processor = $loader->createClass($processor); - return $this; + } elseif (is_array($processor)) { + $loader = $this->getProcessorLoader(); + $arguments = $processor; + $processor = array_shift($arguments); + + $processor = $loader->createClass($processor, $arguments); + + } + + if ($processor instanceof MUtil_Model_ProcessorInterface) { + $this->_processors[$name] = $processor; + + return $this; + } + + throw new MUtil_Model_ModelException("No valid processor set for '$name'."); } /** Modified: trunk/library/classes/MUtil/Model/AssemblerInterface.php =================================================================== --- trunk/library/classes/MUtil/Model/AssemblerInterface.php 2013-01-11 18:28:58 UTC (rev 1097) +++ trunk/library/classes/MUtil/Model/AssemblerInterface.php 2013-01-13 20:03:13 UTC (rev 1098) @@ -36,7 +36,12 @@ */ /** + * An assembler creates Processors that generate output for fieldnames. * + * The processer for a field (accessed through getProcessor()) does not depend + * on the specific current row data, but the output of that processor + * (accesible through getOutput()) can change depending on the content + * of the row data. * * @package MUtil * @subpackage Model @@ -51,17 +56,29 @@ * or not yet set using setRepeater() or setRow(). * * @param string $name + * @param mixed $arrayOrKey1 A key => value array or the name of the first key, see MUtil_Args::pairs() + * These setting are applied to the model. + * @param mixed $value1 The value for $arrayOrKey1 or null when $arrayOrKey1 is an array + * @param string $key2 Optional second key when $arrayOrKey1 is a string + * @param mixed $value2 Optional second value when $arrayOrKey1 is a string, + * an unlimited number of $key values pairs can be given. * @return mixed MUtil_Lazy_Call when not using setRow(), actual output otherwise */ - public function getOutput($name); + public function getOutput($name, $arrayOrKey1 = null, $value1 = null, $key2 = null, $value2 = null); /** * Returns the processor for the name * * @param string $name + * @param mixed $arrayOrKey1 A key => value array or the name of the first key, see MUtil_Args::pairs() + * These setting are applied to the model. + * @param mixed $value1 The value for $arrayOrKey1 or null when $arrayOrKey1 is an array + * @param string $key2 Optional second key when $arrayOrKey1 is a string + * @param mixed $value2 Optional second value when $arrayOrKey1 is a string, + * an unlimited number of $key values pairs can be given. * @return MUtil_Model_ProcessorInterface or null when it does not exist */ - public function getProcessor($name); + public function getProcessor($name, $arrayOrKey1 = null, $value1 = null, $key2 = null, $value2 = null); /** * Returns true if a processor exist for $name @@ -83,10 +100,10 @@ * Set the processor for a name * * @param string $name - * $param MUtil_Model_ProcessorInterface $processor + * $param mixed $processor MUtil_Model_ProcessorInterface or string or array that can be used to create processor * @return MUtil_Model_AssemblerInterface (continuation pattern) */ - public function setProcessor($name, MUtil_Model_ProcessorInterface $processor); + public function setProcessor($name, $processor); /** * Use this method when you want to repeat the output for each row when rendering. Modified: trunk/library/classes/MUtil/Model/Input.php =================================================================== --- trunk/library/classes/MUtil/Model/Input.php 2013-01-11 18:28:58 UTC (rev 1097) +++ trunk/library/classes/MUtil/Model/Input.php 2013-01-13 20:03:13 UTC (rev 1098) @@ -70,7 +70,7 @@ * * @var array */ - protected $_options; + protected $_options = array(); /** * The original begin value @@ -102,7 +102,6 @@ $this->_context = $context; $this->_model = $model; $this->_name = $name; - $this->_options = $model->get($name); $this->_origValue = $context[$name]; $this->_output = $this->_origValue; } @@ -144,17 +143,29 @@ { if (array_key_exists($name, $this->_options)) { return $this->_options[$name]; + } else { + return $this->_model->get($this->_name, $name); } } /** - * Return all options + * Return all or a named subset of options * + * @param array $names Optional: an array of names to get the options from * @return array */ - public function getOptions() + public function getOptions(array $names = null) { - return $this->_options; + if (null === $names) { + // Return all + return $this->_options + $this->_model->get($this->_name); + } + + $result = array(); + foreach ($names as $name) { + $result[$name] = $this->getOption($name); + } + return $result; } /** @@ -206,6 +217,11 @@ { // If $key end with ] it is array value if (substr($name, -1) == ']') { + // Load from original model + if (! isset($this->_options[$name])) { + $this->_options[$name] = $this->_model->get($this->_name, $name); + } + if (substr($name, -2) == '[]') { // If $name ends with [], append it to array $name = substr($name, 0, -2); Modified: trunk/library/classes/MUtil/Model/ModelAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/ModelAbstract.php 2013-01-11 18:28:58 UTC (rev 1097) +++ trunk/library/classes/MUtil/Model/ModelAbstract.php 2013-01-13 20:03:13 UTC (rev 1098) @@ -569,24 +569,27 @@ { $assemblers = $this->getMeta(MUtil_Model::META_ASSEMBLERS); - if (isset($assemblers[$identifier])) { - if ($assemblers[$identifier] instanceof MUtil_Model_AssemblerInterface) { - return $assemblers[$identifier]; - } + if (! isset($assemblers[$identifier])) { + // We cannot create when noting is specified + return null; + } - $loader = MUtil_Model::getAssemblerLoader(); - $assembler = $loader->createClass($assemblers[$identifier]); - $assembler->setModel($this); + if ($assemblers[$identifier] instanceof MUtil_Model_AssemblerInterface) { + return $assemblers[$identifier]; + } - if (null !== $data) { - $assembler->setRow($data); - } + $loader = MUtil_Model::getAssemblerLoader(); + $assembler = $loader->createClass($assemblers[$identifier]); + $assembler->setModel($this); - $assemblers[$identifier] = $assembler; - $this->setMeta(MUtil_Model::META_ASSEMBLERS, $assemblers); + if (null !== $data) { + $assembler->setRow($data); + } - return $assembler; - } + $assemblers[$identifier] = $assembler; + $this->setMeta(MUtil_Model::META_ASSEMBLERS, $assemblers); + + return $assembler; } /** @@ -1165,10 +1168,11 @@ * Both set the attribute 'save' to true for 'field_x'. * * @param string $name The fieldname - * @param string|array $arrayOrKey1 A key => value array or the name of the first key - * @param mixed $value1 The value for $arrayOrKey1 or null when $arrayOrKey1 is an array - * @param string $key2 Optional second key when $arrayOrKey1 is a string - * @param mixed $value2 Optional second value when $arrayOrKey1 is a string, an unlimited number of $key values pairs can be given. + * @param mixed $arrayOrKey1 A key => value array or the name of the first key, see MUtil_Args::pairs() + * @param mixed $value1 The value for $arrayOrKey1 or null when $arrayOrKey1 is an array + * @param string $key2 Optional second key when $arrayOrKey1 is a string + * @param mixed $value2 Optional second value when $arrayOrKey1 is a string, + * an unlimited number of $key values pairs can be given. * @return $this */ public function set($name, $arrayOrKey1 = null, $value1 = null, $key2 = null, $value2 = null) Added: trunk/library/classes/MUtil/Model/Processor/Element/SelectElementProcessor.php =================================================================== --- trunk/library/classes/MUtil/Model/Processor/Element/SelectElementProcessor.php (rev 0) +++ trunk/library/classes/MUtil/Model/Processor/Element/SelectElementProcessor.php 2013-01-13 20:03:13 UTC (rev 1098) @@ -0,0 +1,74 @@ +<?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 Model + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: DateProcessor.php 203 2012-01-01t 12:51:32Z matijs $ + */ + +/** + * + * + * @package MUtil + * @subpackage Model + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since MUtil version 1.2 + */ +class MUtil_Model_Processor_Element_SelectElementProcessor extends MUtil_Model_Processor_ElementProcessorAbstract +{ + /** + * Allow use of answers select specific options + * + * @var boolean + */ + protected $useMultiOptions = true; + + /** + * Processes the input, changing e.g. the result, context or options + * + * @param MUtil_Model_Input $input + * @return void + */ + public function process(MUtil_Model_Input $input) + { + $options = $this->getFilteredOptions($input); + + // Is sometimes added automatically, but should not be used here + unset($options['maxlength']); + + $this->applyElement( + $input, + new Zend_Form_Element_Select($input->getName(), $options) + ); + } +} Modified: trunk/library/classes/MUtil/Model/Processor/ElementProcessorAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/Processor/ElementProcessorAbstract.php 2013-01-11 18:28:58 UTC (rev 1097) +++ trunk/library/classes/MUtil/Model/Processor/ElementProcessorAbstract.php 2013-01-13 20:03:13 UTC (rev 1098) @@ -62,10 +62,17 @@ protected $useDisplayOptions = true; /** - * Allow use textbox specific options + * Allow use of answers select specific options * * @var boolean */ + protected $useMultiOptions = false; + + /** + * Allow use of textbox specific options + * + * @var boolean + */ protected $useTextOptions = false; /** @@ -111,6 +118,18 @@ ); } + if ($this->useMultiOptions) { + $options[] = array( + 'disable', + 'multiOptions', + 'onchange', + 'separator', + 'size', + 'disableTranslator' + ); + + } + if ($this->useTextOptions) { $options[] = array( 'maxlength', @@ -120,6 +139,7 @@ 'onselect', 'size'); } + /* self::CHECK_OPTIONS => array('checkedValue', 'uncheckedValue'), self::DATE_OPTIONS => array('dateFormat', 'storageFormat'), @@ -127,7 +147,6 @@ self::FILE_OPTIONS => array('accept', 'count', 'destination', 'valueDisabled'), self::GROUP_OPTIONS => array('elements', 'legend', 'separator'), self::JQUERY_OPTIONS => array('jQueryParams'), - self::MULTI_OPTIONS => array('disable', 'multiOptions', 'onchange', 'separator', 'size', 'disableTranslator'), self::PASSWORD_OPTIONS => array('repeatLabel'), self::TAB_OPTIONS => array('value'), self::TEXTAREA_OPTIONS => array('cols', 'rows', 'wrap'), @@ -146,7 +165,7 @@ { $allowedOptions = MUtil_Ra::flatten($this->getAllowedOptionsNames()); - $options = $input->getOptions(); + $options = $input->getOptions($allowedOptions); return array_intersect_key($options, array_flip($allowedOptions)); } Modified: trunk/library/classes/MUtil/Model.php =================================================================== --- trunk/library/classes/MUtil/Model.php 2013-01-11 18:28:58 UTC (rev 1097) +++ trunk/library/classes/MUtil/Model.php 2013-01-13 20:03:13 UTC (rev 1098) @@ -97,11 +97,17 @@ /** * - * @var MUtil_Loader_PluginLoader + * @var array of MUtil_Loader_PluginLoader */ - private static $_assemblerLoader; + private static $_loaders = array(); /** + * + * @var array of global for directory paths + */ + private static $_nameSpaces = array('MUtil'); + + /** * Static variable for debuggging purposes. Toggles the echoing of e.g. of sql * select statements, using MUtil_Echo. * @@ -124,26 +130,72 @@ */ public static function getAssemblerLoader() { - if (! self::$_assemblerLoader) { + return self::getLoader('Assembler'); + // maybe add interface def to plugin loader: MUtil_Model_AssemblerInterface + } + + /** + * Returns a subClass plugin loader + * + * @param string $prefix The prefix to load the loader for. CamelCase and should not contain an '_', '/' or '\'. + * @return MUtil_Loader_PluginLoader + */ + public static function getLoader($subClass) + { + if (! isset(self::$_loaders[$subClass])) { $loader = new MUtil_Loader_PluginLoader(); - $loader->addPrefixPath('MUtil_Model_Assembler', __DIR__ . '/Model/Assembler') - ->addFallBackPath(); - // maybe add interface def to plugin loader: MUtil_Model_AssemblerInterface + foreach (self::$_nameSpaces as $nameSpace) { + $loader->addPrefixPath( + $nameSpace . '_Model_' . $subClass, + $nameSpace . DIRECTORY_SEPARATOR . 'Model' . DIRECTORY_SEPARATOR . $subClass); + } + $loader->addFallBackPath(); - self::$_assemblerLoader = $loader; + self::$_loaders[$subClass] = $loader; } - return self::$_assemblerLoader; + return self::$_loaders[$subClass]; } /** + * Returns the plugin loader for processors. + * + * @return MUtil_Loader_PluginLoader + */ + public static function getProcessorLoader() + { + return self::getLoader('Processor'); + // maybe add interface def to plugin loader: MUtil_Model_AssemblerInterface + } + + /** * Sets the plugin loader for assemblers * * @param MUtil_Loader_PluginLoader $loader */ public static function setAssemblerLoader(MUtil_Loader_PluginLoader $loader) { - self::$_assemblerLoader = $loader; + self::setLoader($loader, 'Assembler'); } + + /** + * Sets the plugin loader for assemblers + * + * @param MUtil_Loader_PluginLoader $loader + */ + public static function setLoader(MUtil_Loader_PluginLoader $loader, $subClass) + { + self::$_loaders[$subClass] = $loader; + } + + /** + * Sets the plugin loader for processors. + * + * @param MUtil_Loader_PluginLoader $loader + */ + public static function setProcessorLoader(MUtil_Loader_PluginLoader $loader) + { + self::setLoader($loader, 'Processor'); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2013-03-21 15:09:40
|
Revision: 1200 http://sourceforge.net/p/gemstracker/code/1200 Author: matijsdejong Date: 2013-03-21 15:09:37 +0000 (Thu, 21 Mar 2013) Log Message: ----------- Extra comments and changed echo output to always Modified Paths: -------------- trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php trunk/library/classes/MUtil/Model/JoinModel.php trunk/library/classes/MUtil/Model/SelectModel.php Modified: trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php =================================================================== --- trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php 2013-03-21 10:59:41 UTC (rev 1199) +++ trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php 2013-03-21 15:09:37 UTC (rev 1200) @@ -323,7 +323,7 @@ $this->addSnippets($this->autofilterSnippets, $params); } - if ($resetMvc && MUtil_Echo::hasOutput()) { + if ($resetMvc) { // Lazy call here, because any echo calls in the snippets have not yet been // performed. so they will appear only in the next call when not lazy. $this->html->raw(MUtil_Lazy::call(array('MUtil_Echo', 'out'))); Modified: trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php 2013-03-21 10:59:41 UTC (rev 1199) +++ trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php 2013-03-21 15:09:37 UTC (rev 1200) @@ -843,7 +843,7 @@ /** * The select object where we get the query from. * - * @return Zend_Db_Table_Select + * @return Zend_Db_Select */ abstract public function getSelect(); Modified: trunk/library/classes/MUtil/Model/JoinModel.php =================================================================== --- trunk/library/classes/MUtil/Model/JoinModel.php 2013-03-21 10:59:41 UTC (rev 1199) +++ trunk/library/classes/MUtil/Model/JoinModel.php 2013-03-21 15:09:37 UTC (rev 1200) @@ -292,6 +292,11 @@ return $this->_select->getAdapter(); } + /** + * The select object where we get the query from. + * + * @return Zend_Db_Select + */ public function getSelect() { $select = clone $this->_select; Modified: trunk/library/classes/MUtil/Model/SelectModel.php =================================================================== --- trunk/library/classes/MUtil/Model/SelectModel.php 2013-03-21 10:59:41 UTC (rev 1199) +++ trunk/library/classes/MUtil/Model/SelectModel.php 2013-03-21 15:09:37 UTC (rev 1200) @@ -109,7 +109,7 @@ /** * The select object where we get the query from. * - * @return Zend_Db_Table_Select + * @return Zend_Db_Select */ public function getSelect() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |