Build fake page with error based on fake controller initiation
488435
protected function buildFakePage()
    {
        try {
            $rawResponse = App::$View->render('_core/exceptions/' . $this->tpl, ['msg' => $this->text]);
            if (Str::likeEmpty($rawResponse)) {
                $rawResponse = $this->text;
            }
        } catch (\Exception $e) {
            $rawResponse = $this->text;
        }
        // set status code for header
        App::$Response->setStatusCode((int)$this->status);
        // return compiled html output
        return $rawResponse;
    }
701840
function (input, controller, controller_property) {
	return {
		input      : input,
		value      : controller[controller_property] = input.invoke(),
		is_changed : function () {
			var value = controller[controller_property] = this.input.invoke();
			if (this.value !== value) {
				this.value = value;
				return true;
			}
		}
	};
}
864756
function performAction($controller,$action,$queryString = null,$render = 0) {
		$controllerFile = ROOT . '/application/controllers/' . $controller . "controller.php";
		//print "Trying to load $controllerFile<br>";
		if (file_exists($controllerFile)){
			//print "File exists<br>";
			include_once($controllerFile);
		} else {
			throw new Exception("Controller file: $controllerFile does not exists");
		}
		$controllerName = ucfirst($controller).'Controller';
		$actionName= $action . 'Action'; // This is done to avoid clash with reserved function names like list();
		if (class_exists($controllerName)){
			
		} else {
			throw new Exception("ControllerClass: $controllerName does not exists");
		}

		//print "Trying to load $controllerName<br>"; 
		$dispatch = new $controllerName($controller, $action);
		$dispatch->render = $render;
		$dispatch->$actionName($queryString);

		if ($dispatch->render >0) {
				$dispatch->display();
		}

	}
1328562
def _handle_unknown_method(self, method, remainder, request=None):
        '''
        
        '''
        if request is None:
            self._raise_method_deprecation_warning(self._handle_unknown_method)

        # try finding a post_{custom} or {custom} method first
        controller = self._find_controller('post_%s' % method, method)
        if controller:
            return controller, remainder

        # if no controller exists, try routing to a sub-controller; note that
        # since this isn't a safe GET verb, any local exposes are 405'd
        if remainder:
            if self._find_controller(remainder[0]):
                abort(405)
            sub_controller = self._lookup_child(remainder[0])
            if sub_controller:
                return lookup_controller(sub_controller, remainder[1:],
                                         request)

        abort(405)
479365
def open_fake_page(self, page_text, url=None, soup_config=None):
        
        soup_config = soup_config or self.soup_config
        self.__state = _BrowserState(
            page=bs4.BeautifulSoup(page_text, **soup_config),
            url=url)
407863
public function errorAction()
    {
        $errors       = $this->_getParam('error_handler');
        $exception    = $errors->exception;
        $info         = null;
        $message      = 'Application error';
        $responseCode = 200;

        switch ($errors->type) {
            case \Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
            case \Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
                // 404 error -- controller or action not found
                $responseCode = 404;
                $message      = 'Page not found';
                break;

            case \Zend_Controller_Plugin_ErrorHandler::EXCEPTION_OTHER:

                if ($exception instanceof \Gems_Exception) {
                    $responseCode = $exception->getCode();
                    $message      = $exception->getMessage();
                    $info         = $exception->getInfo();
                    break;
                }
                // Intentional fall through

            default:
                $message = $exception->getMessage();
                break;
        }

        \Gems_Log::getLogger()->logError($errors->exception, $errors->request);

        if (\MUtil_Console::isConsole()) {
            $this->_helper->viewRenderer->setNoRender(true);

            echo $message . "\n\n";
            if ($info) {
                echo $info . "\n\n";
            }

            $next = $exception->getPrevious();
            while ($next) {
                echo '  ' . $next->getMessage() . "\n";
                $next = $next->getPrevious();
            }

            echo $exception->getTraceAsString();

        } else {
            if ($responseCode) {
                $this->getResponse()->setHttpResponseCode($responseCode);
            }

            $this->view->exception = $exception;
            $this->view->message   = $message;
            $this->view->request   = $errors->request;
            if ($info) {
                $this->view->info = $info;
            }

        }
    }
840848
function () {

            // Note: Controllers are responsible of setting needRedraw.
            if (this.needRedraw) {

                // Create root element for the page
                var page = document.createElement('div');
                page.style.display = 'block';
                page.setAttribute('data-role', 'page');

                // Create, render and add the header
                if (this.header) {
                    var header = document.createElement('div');
                    header.setAttribute('data-role', 'header');
                    this.header.setElement(header);
                    this.header.render();
                    page.appendChild(header);
                }

                // Create the content element
                var content = document.createElement('div');
                content.setAttribute('data-role', 'content');
                content.className = 'content';

                // Render the content
                this.content.setElement(content);
                this.content.render();

                // Make sure content fills the screen to the top/bottom
                // when no header/footer are provided.
                if (!this.header) {
                    content.style.top = '0';
                }
                if (!this.footer) {
                    content.style.bottom = '0';
                }

                page.appendChild(content);

                // Create, render and add the footer
                if (this.footer) {
                    var footer = document.createElement('div');
                    footer.setAttribute('data-role', 'footer');
                    this.footer.setElement(footer);
                    this.footer.render();
                    page.appendChild(footer);
                }

                // Add the page into the DOM.
                if (this.el.firstChild) {
                    this.el.replaceChild(page, this.el.firstChild);
                }
                else {
                    this.el.appendChild(page);
                }
 
                this.needRedraw = false;
            }
        }
980911
public function init()
    {
        $request =& $this->request;
        $route = '/:controller/:action';
        $opts = array('controller' => 'Home', 'action' => 'index');

        // Inlined as a closure to fix "using $this when not in object context" on 5.3
        $validateSession = function () {
            if (!empty($_SESSION['phpci_user_id'])) {
                $user = b8\Store\Factory::getStore('User')->getByPrimaryKey($_SESSION['phpci_user_id']);

                if ($user) {
                    $_SESSION['phpci_user'] = $user;
                    return true;
                }

                unset($_SESSION['phpci_user_id']);
            }

            return false;
        };

        $skipAuth = array($this, 'shouldSkipAuth');

        // Handler for the route we're about to register, checks for a valid session where necessary:
        $routeHandler = function (&$route, Response &$response) use (&$request, $validateSession, $skipAuth) {
            $skipValidation = in_array($route['controller'], array('session', 'webhook', 'build-status'));

            if (!$skipValidation && !$validateSession() && (!is_callable($skipAuth) || !$skipAuth())) {
                if ($request->isAjax()) {
                    $response->setResponseCode(401);
                    $response->setContent('');
                } else {
                    $_SESSION['phpci_login_redirect'] = substr($request->getPath(), 1);
                    $response = new RedirectResponse($response);
                    $response->setHeader('Location', PHPCI_URL.'session/login');
                }

                return false;
            }

            return true;
        };

        $this->router->clearRoutes();
        $this->router->register($route, $opts, $routeHandler);
    }
578935
def invoke_controller(self, controller, args, kwargs, state):
        '''
        
        '''
        cfg = _cfg(controller)
        content_types = cfg.get('content_types', {})
        req = state.request
        resp = state.response
        pecan_state = req.pecan

        # If a keyword is supplied via HTTP GET or POST arguments, but the
        # function signature does not allow it, just drop it (rather than
        # generating a TypeError).
        argspec = getargspec(controller)
        keys = kwargs.keys()
        for key in keys:
            if key not in argspec.args and not argspec.keywords:
                kwargs.pop(key)

        # get the result from the controller
        result = controller(*args, **kwargs)

        # a controller can return the response object which means they've taken
        # care of filling it out
        if result is response:
            return
        elif isinstance(result, WebObResponse):
            state.response = result
            return

        raw_namespace = result

        # pull the template out based upon content type and handle overrides
        template = content_types.get(pecan_state['content_type'])

        # check if for controller override of template
        template = pecan_state.get('override_template', template)
        if template is None and cfg['explicit_content_type'] is False:
            if self.default_renderer == 'json':
                template = 'json'

        pecan_state['content_type'] = pecan_state.get(
            'override_content_type',
            pecan_state['content_type']
        )

        # if there is a template, render it
        if template:
            if template == 'json':
                pecan_state['content_type'] = 'application/json'
            result = self.render(template, result)

        # If we are in a test request put the namespace where it can be
        # accessed directly
        if req.environ.get('paste.testing'):
            testing_variables = req.environ['paste.testing_variables']
            testing_variables['namespace'] = raw_namespace
            testing_variables['template_name'] = template
            testing_variables['controller_output'] = result

        # set the body content
        if result and isinstance(result, six.text_type):
            resp.text = result
        elif result:
            resp.body = result

        if pecan_state['content_type']:
            # set the content type
            resp.content_type = pecan_state['content_type']
95351
function (err, req, res, next) {
    err = this.coerceError(err);

    if (err instanceof errors.NotFound && req.accepts('html')) {
      if (err instanceof errors.BinNotFound) {
        if (req.editor) {
          return (new BinHandler(this.sandbox)).notFound(req, res, next);
        }
      }

      return this.renderErrorPage('error', err, req, res);
    } else if (err instanceof errors.HTTPError) {
      // return this.renderError(err, req, res);
      return this.renderErrorPage(err.status, err, req, res);
    }

    if (err) {
      // console.error(err.stack);
    }

    next(err);
  }
57592
public function onBeforeInit()
    {
        $disallowed_controllers = [
            DevelopmentAdmin::class,
            DevBuildController::class,
            DatabaseAdmin::class
        ];

        // Don't run this during dev/build or dev/tasks
        if (!in_array(get_class($this->owner), $disallowed_controllers)) {
            // Set global local based on Site Config
            $config = SiteConfig::current_site_config();
            i18n::set_locale($config->SiteLocale);

            // Now find and set the desired currency symbol
            $number_format = new NumberFormatter($config->SiteLocale, NumberFormatter::CURRENCY);
            $symbol = $number_format->getSymbol(NumberFormatter::CURRENCY_SYMBOL);
            DBCurrency::config()->currency_symbol = $symbol;
        }
    }
837256
def generate(*args)
      init_vars(options)

      controller = args.shift
      actions = args

      if controller
        sanitize(controller, actions, options)
      else
        puts "Please provide a controller name."
        exit
      end
    end
486725
public function onInvalidControl() {
		$auth=$this->_getAuthController();
		if(URequest::isAjax()){
			$this->jquery->get($auth->_getBaseRoute()."/noAccess/".implode(".", Startup::$urlParts),$auth->_getBodySelector(),["historize"=>false]);	
			echo $this->jquery->compile($this->view);
		}else{
			parent::initialize();
			$auth->noAccess(Startup::$urlParts);
			parent::finalize();
		}
		exit();
	}
475697
function PageDirectiveController ($scope) {
  var ctrl = this;

  ctrl.isActive = function isActive () {
    return !!$scope.isActive;
  };

  ctrl.activate = function activate () {
    $scope.pagesCtrl.activate($scope);
  };

  $scope.internalControl = {
    activate: ctrl.activate,
    isActive: ctrl.isActive
  };
}
1188936
public static function build() {
        try {
            self::init();
            self::dependencies();
    
            $route = self::canRoute();
    
            if ($route !== false) {
                $actionContext = self::actionContext($route);
    
                if ($actionContext !== null && !self::cached($actionContext)) {
                    self::filters($actionContext);
                    self::headers();
                    self::validation();
                    self::render($actionContext);
                }
            }
        }
        catch (\Exception $ex) {
            $errorHandlerEventArgs = new ErrorHandlerEventArgs($ex);
            self::invokeAll(self::$appContext->getErrorHandler(), array($errorHandlerEventArgs));

            if ($errorHandlerEventArgs->getHandled() !== true) {
                throw $ex;
            }
        }
    }
1030826
function routesCode (pages) {
  function genRoute ({
    path: pagePath,
    key: componentName,
    frontmatter: {
      layout
    },
    regularPath,
    _meta
  }) {
    let code = `
  {
    name: ${JSON.stringify(componentName)},
    path: ${JSON.stringify(pagePath)},
    component: GlobalLayout,
    beforeEnter: (to, from, next) => {
      ensureAsyncComponentsLoaded(${JSON.stringify(layout || 'Layout')}, ${JSON.stringify(componentName)}).then(next)
    },${_meta ? `\n    meta: ${JSON.stringify(_meta)}` : ''}
  }`

    const dncodedPath = decodeURIComponent(pagePath)
    if (dncodedPath !== pagePath) {
      code += `,
  {
    path: ${JSON.stringify(dncodedPath)},
    redirect: ${JSON.stringify(pagePath)}
  }`
    }

    if (/\/$/.test(pagePath)) {
      code += `,
  {
    path: ${JSON.stringify(pagePath + 'index.html')},
    redirect: ${JSON.stringify(pagePath)}
  }`
    }

    if (regularPath !== pagePath) {
      code += `,
  {
    path: ${JSON.stringify(regularPath)},
    redirect: ${JSON.stringify(pagePath)}
  }`
    }

    return code
  }

  const notFoundRoute = `,
  {
    path: '*',
    component: GlobalLayout
  }`

  return (
    `export const routes = [${pages.map(genRoute).join(',')}${notFoundRoute}\n]`
  )
}
1199915
def make_controller(cls, config, session, left_menu_items=None):
        """"""
        m = config.model
        Controller = config.defaultCrudRestController

        class ModelController(Controller):
            model        = m
            table        = config.table_type(session)
            table_filler = config.table_filler_type(session)
            new_form     = config.new_form_type(session)
            new_filler   = config.new_filler_type(session)
            edit_form    = config.edit_form_type(session)
            edit_filler  = config.edit_filler_type(session)
            allow_only   = config.allow_only

            if hasattr(config.layout, 'crud_resources'):
                resources = config.layout.crud_resources

            def _before(self, *args, **kw):
                super(self.__class__, self)._before(*args, **kw)

                tmpl_context.make_pager_args = make_pager_args

                if request.response_type not in ('application/json',):
                    default_renderer = AdminController._get_default_renderer()
                    for action in ('get_all', 'new', 'edit'):
                        for template in config.layout.crud_templates.get(action, []):
                            if template.startswith(default_renderer):
                                override_template(getattr(self, action), template)

        return ModelController(session, left_menu_items)