public function execute($filterChain) { $this->fixSfGuard(); $request = $this->context->getRequest(); $response = $this->context->getResponse(); $user = $this->context->getUser(); $is_first_call = $this->isFirstCall(); if ($is_first_call) { if ($request->hasParameter('_sw_func_reset')) { $user->setAttribute('sw_func_code', '', 'swToolbox'); $filterChain->execute(); return; } if ($request->hasParameter('_sw_func_enabled')) { if ((int) $request->getParameter('_sw_func_enabled') == 1) { $user->setAttribute('sw_func_enabled', true, 'swToolbox'); $user->setAttribute('sw_func_code', '', 'swToolbox'); unset($_GET['_sw_func_enabled']); } if ((int) $request->getParameter('_sw_func_enabled') == 0) { $user->setAttribute('sw_func_enabled', false, 'swToolbox'); $user->setAttribute('sw_func_code', null, 'swToolbox'); unset($_GET['_sw_func_enabled']); } } if ($user->getAttribute('sw_func_enabled', false, 'swToolbox')) { self::$code = $user->getAttribute('sw_func_code', '', 'swToolbox'); } } if (!$user->getAttribute('sw_func_enabled', false, 'swToolbox')) { $filterChain->execute(); return; } $action = $this->context->getActionStack()->getLastEntry(); $route = $this->context->getRouting()->getCurrentInternalUri(); $url = $request->getPathInfo(); if ($is_first_call) { if ($from_link = $request->getParameter('_sw_func_link')) { unset($_GET['_sw_func_link']); $this->raw("\$browser"); $this->with('response'); $this->create('contains', $from_link); $this->create('click', $from_link, $_GET); $this->end(); $this->raw(" /* " . $this->createPHP('call', $url, 'get', $_GET) . " */ "); $this->raw(";\n\n"); $this->raw("\$browser"); } else { if ($user->getAttribute('sw_func_executing', false, 'swToolbox')) { // behing redirected or an error occur during execution $this->raw(";"); $this->raw("\$browser"); $this->with('response'); $this->create('isRedirected', true); $this->create('isStatusCode', 302); $this->end(); $this->create('followRedirect'); $this->raw(";\n\n"); $this->raw("\$browser"); $user->setAttribute('sw_func_executing', false, 'swToolbox'); } else { if ($request->isMethod('post') || $request->isMethod('put')) { $this->raw("\$browser"); $this->create('call', $url, $request->getMethod(), $this->getVarsFromRequest($request)); $this->raw(" /* " . $this->createPHP('get', $url) . "\n" . $this->createPHP('click', 'alt or value of submit here', $this->getVarsFromRequest($request)) . " */ "); } else { if ($request->isMethod('delete')) { $this->raw("\$browser"); $this->create('call', $url, $request->getMethod(), $this->getVarsFromRequest($request)); } else { $this->raw("\$browser"); $this->create('call', $url, $request->getMethod(), $_GET); } } } } } if (!$is_first_call) { $this->raw(";\n\n"); $this->raw("\$browser"); } $this->with('request'); if (!$is_first_call || $this->context->getActionStack()->getSize() > 1) { $this->create('isForwardedTo', $action->getModuleName(), $action->getActionName()); } else { $this->create('isParameter', 'module', $action->getModuleName()); $this->create('isParameter', 'action', $action->getActionName()); } $this->end(); $user->setAttribute('sw_func_code', self::getRawPhp(), 'swToolbox'); $user->setAttribute('sw_func_executing', true, 'swToolbox'); $filterChain->execute(); $user->setAttribute('sw_func_executing', false, 'swToolbox'); $this->with('response'); $this->create('isStatusCode', $response->getStatusCode()); $this->end(); $this->raw(";\n\n"); $content = $response->getContent(); // add link name $content = preg_replace_callback(self::LINK_EREG, array($this, 'linkCallback'), $content); $response->setContent($content); $user->setAttribute('sw_func_code', self::getRawPhp(), 'swToolbox'); }