public function testGenerateShowLinkTo() { $pfw_routes = $this->getPfwRoutes(); Pfw_Loader::loadClass('Pfw_Controller_Front'); $front = Pfw_Controller_Front::getInstance(); $front->getRouter()->setRoutes($pfw_routes); $smarty = new Pfw_Smarty_Standard(); $params = array('route' => 'default_show', 'controller' => 'foo', 'id' => '123', 'action' => 'bar'); $link = $smarty->_generateLinkTo($params, 'hello world'); $this->assertEquals(rtrim('<a href="/foo/123">hello world</a>'), rtrim($link)); }
Pfw_Loader::loadClass('Pfw_PluginManager'); Pfw_Loader::loadClass('Pfw_Session'); Pfw_Loader::loadClass('Pfw_Alert'); // initialize the session Pfw_Session::start(); // initialize the plugin manager Pfw_PluginManager::init(); // initialize alerts Pfw_Alert::init(); // turn off error display for production if ($_ENVIRONMENT == "production") { ini_set('display_errors', 0); ini_set('log_errors', 1); } // setup front controller and routing $front = Pfw_Controller_Front::getInstance(); $front->getRouter()->setRoutes($_pfw_routes)->setModules($_pfw_modules); $four_oh_four = false; try { $front->dispatch(); } catch (Pfw_Exception_System $e) { $e->emitLog(); if ($_ENVIRONMENT == "development") { objp($e); exit; } $four_oh_four = true; } catch (Pfw_Exception_User $e) { $e->emitLog(); if ($_ENVIRONMENT == "development") { objp($e);
public function _generateLinkTo($params, $content) { Pfw_Loader::loadClass('Pfw_Controller_Front'); $front = Pfw_Controller_Front::getInstance(); list($args, $attrs) = $this->_filterAttrs($params); if (!isset($attrs['href'])) { if (!isset($args['route'])) { $args['route'] = 'default_action'; } $router = $front->getRouter(); $route = $args['route']; unset($args['route']); $attrs['href'] = $router->urlFor($route, $args); } return $this->_generateElement('a', $attrs, $content); }