From: <gem...@li...> - 2012-04-19 10:57:52
|
Revision: 623 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=623&view=rev Author: matijsdejong Date: 2012-04-19 10:57:42 +0000 (Thu, 19 Apr 2012) Log Message: ----------- User gets clearer message from program after changing an item (if specified at action level) Modified Paths: -------------- trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php trunk/library/classes/Gems/Snippets/ModelFormSnippetAbstract.php Modified: trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php =================================================================== --- trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php 2012-04-18 12:53:21 UTC (rev 622) +++ trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php 2012-04-19 10:57:42 UTC (rev 623) @@ -139,7 +139,8 @@ */ public function createAction() { - $this->createEditParameters['formTitle'] = $this->getCreateTitle(); + $this->createEditParameters['formTitle'] = $this->getCreateTitle(); + $this->createEditParameters['topicCallable'] = array($this, 'getTopic'); parent::createAction(); } @@ -160,7 +161,8 @@ */ public function editAction() { - $this->createEditParameters['formTitle'] = $this->getEditTitle(); + $this->createEditParameters['formTitle'] = $this->getEditTitle(); + $this->createEditParameters['topicCallable'] = array($this, 'getTopic'); parent::editAction(); } Modified: trunk/library/classes/Gems/Snippets/ModelFormSnippetAbstract.php =================================================================== --- trunk/library/classes/Gems/Snippets/ModelFormSnippetAbstract.php 2012-04-18 12:53:21 UTC (rev 622) +++ trunk/library/classes/Gems/Snippets/ModelFormSnippetAbstract.php 2012-04-19 10:57:42 UTC (rev 623) @@ -71,6 +71,13 @@ protected $formTitle; /** + * When set getTopic uses this function instead of parent class. + * + * @var callable + */ + protected $topicCallable; + + /** * Required * * @var Gems_Menu @@ -181,4 +188,19 @@ return sprintf($this->_('Edit %s'), $this->getTopic()); } } + + /** + * Helper function to allow generalized statements about the items in the model to used specific item names. + * + * @param int $count + * @return $string + */ + public function getTopic($count = 1) + { + if (is_callable($this->topicCallable)) { + return call_user_func($this->topicCallable, $count); + } else { + return parent::getTopic($count); + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |