From: <min...@us...> - 2006-07-21 19:40:22
|
Revision: 14019 Author: mindless Date: 2006-07-21 12:40:20 -0700 (Fri, 21 Jul 2006) ViewCVS: http://svn.sourceforge.net/gallery/?rev=14019&view=rev Log Message: ----------- allow g->url params=$array arg1="more=here" argN params are added to the given array Modified Paths: -------------- trunk/gallery2/modules/core/classes/GalleryTemplateAdapter.class trunk/gallery2/modules/core/test/phpunit/TemplateAdapterTest.class Modified: trunk/gallery2/modules/core/classes/GalleryTemplateAdapter.class =================================================================== --- trunk/gallery2/modules/core/classes/GalleryTemplateAdapter.class 2006-07-21 19:33:19 UTC (rev 14018) +++ trunk/gallery2/modules/core/classes/GalleryTemplateAdapter.class 2006-07-21 19:40:20 UTC (rev 14019) @@ -105,17 +105,15 @@ function url($params, &$smarty) { global $gallery; - if (isset($params['params'])) { - /* Allow the user to pass in bulk params */ - $hrefParams = $params['params']; - } else { - /* Search for args and add them to the params */ - $hrefParams = array(); - for ($i = 1; ($arg = "arg$i") && isset($params[$arg]); $i++) { - list ($key, $value) = explode('=', $params[$arg], 2); - $hrefParams[$key] = $value; - unset($params[$arg]); - } + /* Allow the user to pass in bulk params */ + $hrefParams = isset($params['params']) ? $params['params'] : array(); + unset($params['params']); + + /* Search for args and add them to the params */ + for ($i = 1; ($arg = "arg$i") && isset($params[$arg]); $i++) { + list ($key, $value) = explode('=', $params[$arg], 2); + $hrefParams[$key] = $value; + unset($params[$arg]); } if (isset($params['href'])) { $hrefParams['href'] = $params['href']; Modified: trunk/gallery2/modules/core/test/phpunit/TemplateAdapterTest.class =================================================================== --- trunk/gallery2/modules/core/test/phpunit/TemplateAdapterTest.class 2006-07-21 19:33:19 UTC (rev 14018) +++ trunk/gallery2/modules/core/test/phpunit/TemplateAdapterTest.class 2006-07-21 19:40:20 UTC (rev 14019) @@ -127,6 +127,15 @@ $this->_mockUrlGenerator->_calls[0]); } + function testUrlParamsAndArgs() { + $this->_setupAdapterWithMocks(); + $this->_templateAdapter->url(array('params' => array('view' => 'fun.View'), + 'arg1' => 'foo=bar'), $this->_mockSmarty); + + $this->assertEquals(array(array('view' => 'fun.View', 'foo' => 'bar'), array()), + $this->_mockUrlGenerator->_calls[0]); + } + function testChangeInDescendents() { $test = array('module' => 'pirate', 'text' => 'ninja', 'l10Domain' => 'en_US'); $this->_setupAdapterWithMocks(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |