public function run() { $this->configure(); \yapaf\DevServer::handle(); $requestHandler = new RequestHandler($this->configuration); return $requestHandler->handle(); }
/** * @param DomDocument $context * @param \BaseXMS\Mvc\SiteAccess $siteAccess * @return Ambigous <NULL, unknown, \BaseXMS\RequestHandler\RequestHandler> */ public static function factory($context, \BaseXMS\Mvc\SiteAccess $siteAccess) { $return = null; $services = $siteAccess->getServiceLocator(); // Get Request handler class $requestHandlerClass = $context->queryToValue('//contentclass'); //TODO: contentclass is not really the right name if (!$requestHandlerClass) { $requestHandlerClass = '\\BaseXMS\\RequestHandler\\RequestHandler'; $services->get('log')->warn('No RequestHandler class specified - falling back to default class.'); } if (!class_exists($requestHandlerClass)) { $services->get('log')->warn('Could not find RequestHandler class: "' . $requestHandlerClass . '".'); $requestHandlerClass = '\\BaseXMS\\RequestHandler\\RequestHandler'; } $services->get('log')->info('Loading RequestHandler class: "' . $requestHandlerClass . '".'); $return = new $requestHandlerClass(); // couldn't get a valid class if (!$return instanceof RequestHandler) { $services->get('log')->warn('"' . $requestHandlerClass . '" is not a RequestHandler - falling back to default class.'); $return = new RequestHandler(); } $return->setContext($context)->setServiceLocator($services)->setSiteAccess($siteAccess); return $return; }
public function __construct(RequestHandler $request) { $this->request = $request; $this->container = $request->getContainer(); $this->view = $this->container->getTwig(); $this->acquireBaseUrl(); $this->session = ApplicationSession::getInstance(); }
public function __construct(GridField $grid, GridFieldComponent $component, $name) { $this->grid = $grid; $this->component = $component; $this->name = $name; parent::__construct(); }
public static function processRequest() { global $logger; $request = $rawResponse = $response = null; try { /* Authenticate */ $valid = self::authenticateRequest($_SERVER); /* Fetch POST data */ $post = file_get_contents("php://input"); $logger->debug("POST Data Received: " . $post); /* Formulate the request object */ $request = RequestParser::parseInput($_SERVER, $_GET, $post); $logger->debug("REQUEST Object: " . $request->toString()); /* Handle the request */ $rawResponse = RequestHandler::process($request); $logger->debug("RESPONSE Object: " . json_encode($rawResponse)); } catch (ApiException $e) { /* Generate response from Exception details */ $logger->error("ApiException encountered!! " . $e->toString()); $rawResponse = array('httpStatusCode' => $e->getHttpStatusCode(), 'httpStatusCodeMessage' => $e->getHttpStatusCodeMessage(), 'otherHeaders' => $e->getOtherHeaders(), 'code' => $e->getCode(), 'message' => $e->getMessage(), 'debug' => false, 'data' => null); } // Format the $rawResponse variable and output $format = !isset($request) ? 'json' : $request->getFormat(); $debug = !isset($request) ? false : $request->getDebug(); $response = ResponseHandler::respond($rawResponse, $format, $debug); $logger->debug("Output: " . $response); }
public function __construct($grid, $button) { $this->grid = $grid; $this->button = $button; $this->context = singleton($grid->getModelClass())->getDefaultSearchContext(); parent::__construct(); }
public static function getInstance() { if (null === self::$instance) { self::$instance = new self(); } return self::$instance; }
/** * Creates single for whole application RequestHandler object. * Singleton pattern implementation. * * @return RequestHandler Either existing or new. */ public static function getInstance() { if (!self::$instance) { self::$instance = new RequestHandler(); } return self::$instance; }
/** * Create a new page comment interface * @param controller The controller that the interface is used on * @param methodName The method to return this PageCommentInterface object * @param page The page that we're commenting on */ function __construct($controller, $methodName, $page) { $this->controller = $controller; $this->methodName = $methodName; $this->page = $page; parent::__construct(); }
/** * Handler's constructor * * @param GridFIeld $gridField * @param GridField_URLHandler $component * @param Controller $controller */ public function __construct($gridField, $component, $controller) { $this->gridField = $gridField; $this->component = $component; $this->controller = $controller; parent::__construct(); }
/** * Handle request and set message to. */ public function playGame() { $this->model->processShot(RequestHandler::getRequest()); $this->view->setMessage($this->model->getMessage()); $this->view->setData($this->model->getData()['grid']); $this->view->display(); }
/** * @param string $groupField * @param string $groupFieldLabel * @param string $groupUnassignedName * @param array $groupsAvailable */ public function __construct($groupField = 'Group', $groupFieldLabel = 'Group', $groupUnassignedName = '[none/inactive]', $groupsAvailable = array()) { parent::__construct(); $this->groupField = $groupField; $this->groupFieldLabel = $groupFieldLabel; $this->groupUnassignedName = $groupUnassignedName; $this->groupsAvailable = $groupsAvailable; }
/** * Returns user information such as first name, last name, and email address. * * @return SimpleXMLElement Xml of Disconnect response */ public function CurrentUser() { $this->requestXmlDocument = ''; $uriFragment = implode(CoreConstants::SLASH_CHAR, array('v1', 'user', 'current')); $requestParameters = new RequestParameters(NULL, 'GET', NULL, $uriFragment); list($respCode, $respXml, $respError) = $this->restRequestHandler->GetResponse($requestParameters, $this->requestXmlDocument, NULL); return simplexml_load_string($respXml); }
/** * @param string $fragment the fragment to render the button in * @param string $title the text to display on the button * @param \FieldList|Callable|array $fields the fields to display in inline form */ public function __construct($fragment = 'buttons-before-left', $title = '', $fields = null) { parent::__construct(); $this->fragment = $fragment; $this->title = $title ?: _t('GridFieldExtensions.ADD', 'Add'); $this->fields = $fields; $this->cache = \SS_Cache::factory($this->getCacheKey(['holder' => __CLASS__]), 'Output', ['lifetime' => 6 * 60 * 60]); }
/** * @param string $parentController * @param string $urlSegment * @param string $recordClass */ public function __construct($parentController, $urlSegment, $recordClass = null) { $this->parentController = $parentController; $this->urlSegment = $urlSegment; if ($recordClass) { $this->recordClass = $recordClass; } parent::__construct(); }
/** * Create a new field. * @param name The internal field name, passed to forms. * @param title The field label. * @param value The value of the field. * @param form Reference to the container form * @param maxLength The Maximum length of the attribute */ function __construct($name, $title = null, $value = null, $form = null, $rightTitle = null) { $this->name = $name; $this->title = ($title === null) ? $name : $title; if(isset($value)) $this->value = $value; if($form) $this->setForm($form); parent::__construct(); }
function buildRequestForm($method, $button_name) { $reqHandler = new RequestHandler(); $reqHandler->init(); $reqHandler = $this->__inithandler($reqHandler); //待请求参数数组 $reqHandler->createSign(); $params = $reqHandler->getAllParameters(); ksort($params); $sHtml = "<form id='tenpaysubmit' name='tenpaysubmit' action='" . $reqHandler->getGateUrl() . "' method='" . $method . "'>"; while (list($key, $val) = each($params)) { $sHtml .= "<input type='hidden' name='" . $key . "' value='" . $val . "'/>"; } //submit按钮控件请不要含有name属性 $sHtml = $sHtml . "<input type='submit' value='" . $button_name . "'></form>"; $sHtml = $sHtml . "<script>document.forms['tenpaysubmit'].submit();</script>"; return $sHtml; }
public function __construct($gridfield, $component, $record, $controller, $name, $formorfields) { $this->gridfield = $gridfield; $this->component = $component; $this->record = $record; $this->controller = $controller; $this->name = $name; $this->formorfields = $formorfields; parent::__construct(); }
/** * @see \wcf\system\request\IRoute::matches() */ public function matches($requestURL) { if (parent::matches($requestURL)) { $this->routeData['application'] = $this->staticApplication; $this->routeData['controller'] = RequestHandler::getTokenizedController($this->staticController); $this->routeData['isDefaultController'] = false; return true; } return false; }
/** * recursive fill the menu. * * @param string $lbl * @param array $page * @param string $class * @access private * @return DomElement */ private function fillMenu($lbl, $page, $class = null) { if ($class === null) { $rq = new RequestHandler(DEFAULTPAGE, $this->basepath); } if (is_array($page)) { if (isset($page['default'])) { $li = $this->document->createElement('li'); $a = $this->document->createElement('a', $lbl); $a->setAttribute('href', $this->basepath . '/' . $page['default']); if ($class === null && $rq->getPage() == $page['default']) { $li->setAttribute('class', 'selected'); } $li->appendChild($a); unset($page['default']); } else { $li = $this->document->createElement('li', $lbl); } if (count($page) > 0) { $subList = $this->document->createElement('ul'); if (!empty($class)) { $subList->setAttribute('class', 'sub'); } else { $subList->setAttribute('class', 'sub first'); } foreach ($page as $slbl => $spage) { $subList->appendChild($this->fillMenu($slbl, $spage, 'sub')); } $li->appendChild($subList); } return $li; } else { $li = $this->document->createElement('li'); $a = $this->document->createElement('a', $lbl); $a->setAttribute('href', $this->basepath . '/' . $page); if ($class === null && $rq->getPage() == $page) { $li->setAttribute('class', 'selected'); } $li->appendChild($a); return $li; } }
public function _header() { $t = Engine::getType(); if ($t == 'user') { $r = RequestHandler::singleton(); if ($r->getController() != 'styleswitcher') { $template = HBLoader::LoadComponent('Template'); $template->register_outputfilter(array($this, 'pre_filter')); } } }
/** * Create a new field. * @param name The internal field name, passed to forms. * @param title The field label. * @param value The value of the field. * @param form Reference to the container form * @param maxLength The Maximum length of the attribute */ function __construct($name, $title = null, $value = null, $form = null, $rightTitle = null) { $this->name = $name; $this->title = $title === null ? $name : $title; if ($value !== NULL) { $this->setValue($value); } if ($form) { $this->setForm($form); } parent::__construct(); }
/** * build menu before content * * @access public * @return void */ public function beforeContent() { $menu = $this->document->getElementById($this->id); if ($menu) { $this->document->addCss('public/css/simplemenu.css'); $menu->removeAttribute('style'); $menuList = $this->document->createElement('ul'); $rq = new RequestHandler(DEFAULTPAGE, $this->basepath); foreach ($this->menuItems as $lbl => $page) { $li = $this->document->createElement('li'); $a = $this->document->createElement('a', $lbl); $a->setAttribute('href', $this->basepath . '/' . $page); if ($rq->getPage() == $page) { $li->setAttribute('class', 'selected'); } $li->appendChild($a); $menuList->appendChild($li); } $menu->appendChild($menuList); } }
public static function handleRequest() { if (extension_loaded('newrelic')) { newrelic_disable_autorum(); } // retrieve authentication attempt if ($GLOBALS['Session']->hasAccountLevel('Developer')) { $User = $GLOBALS['Session']->Person; } else { $authEngine = new \Sabre\HTTP\BasicAuth(); $authEngine->setRealm('Develop ' . \Site::$title); $authUserPass = $authEngine->getUserPass(); // try to get user $userClass = \User::$defaultClass; $User = $userClass::getByLogin($authUserPass[0], $authUserPass[1]); // send auth request if login is inadiquate if (!$User || !$User->hasAccountLevel('Developer')) { $authEngine->requireLogin(); die("You must login using a " . \Site::getConfig('primary_hostname') . " account with Developer access\n"); } } // store login to session if (isset($GLOBALS['Session'])) { $GLOBALS['Session'] = $GLOBALS['Session']->changeClass('UserSession', array('PersonID' => $User->ID)); } // detect base path $basePath = array_slice(\Site::$requestPath, 0, count(\Site::$resolvedPath)); // switch to JSON response mode if (static::peekPath() == 'json') { $basePath[] = static::$responseMode = static::shiftPath(); } // handle /develop request if ($_SERVER['REQUEST_METHOD'] == 'GET' && static::getResponseMode() == 'html' && !static::peekPath()) { \RequestHandler::respond('app/ext', array('App' => \Sencha_App::getByName('EmergenceEditor'), 'mode' => 'production', 'title' => 'EmergenceEditor')); } // initial and configure SabreDAV $server = new \Sabre\DAV\Server(new RootCollection()); $server->setBaseUri('/' . join('/', $basePath)); // The lock manager is reponsible for making sure users don't overwrite each others changes. Change 'data' to a different // directory, if you're storing your data somewhere else. # $lockBackend = new Sabre_DAV_Locks_Backend_FS('/tmp/dav-lock'); # $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend); # $server->addPlugin($lockPlugin); // filter temporary files $server->addPlugin(new \Sabre\DAV\TemporaryFileFilterPlugin('/tmp/dav-tmp')); // ?mount support $server->addPlugin(new \Sabre\DAV\Mount\Plugin()); // emergence :) $server->addPlugin(new \Emergence\DAV\ServerPlugin()); // All we need to do now, is to fire up the server $server->exec(); }
public function handleRequest($data) { parent::handleRequest($data); if (empty($data['Password'])) { throw new Exception('Enter a new password for your account'); } elseif ($data['Password'] != $data['PasswordConfirm']) { throw new Exception('Enter your new password twice for confirmation'); } $this->Creator->setClearPassword($data['Password']); $this->Creator->save(); // set used $this->Used = time(); $this->save(); return RequestHandler::respond('register/passwordRecovered'); }
/** * Get's the previous URL that lead up to the current request. * * NOTE: Honestly, this should be built into SS_HTTPRequest, but we can't depend on that right now... so instead, * this is being copied verbatim from Controller (in the framework). * * @param SS_HTTPRequest $request * @return string */ protected function getBackURL(SS_HTTPRequest $request) { // Initialize a sane default (basically redirects to root admin URL). $controller = $this->getToplevelController(); $url = method_exists($this->requestHandler, "Link") ? $this->requestHandler->Link() : $controller->Link(); // Try to parse out a back URL using standard framework technique. if ($request->requestVar('BackURL')) { $url = $request->requestVar('BackURL'); } else { if ($request->isAjax() && $request->getHeader('X-Backurl')) { $url = $request->getHeader('X-Backurl'); } else { if ($request->getHeader('Referer')) { $url = $request->getHeader('Referer'); } } } return $url; }
public static function redirectViewRecord(ActiveRecord $Record, $path = array(), $permanent = false) { if (is_array($path)) { $path = implode('/', $path); } if (!($url = $Record->getURL())) { if (!($classPath = static::getClassPath($Record))) { return RequestHandler::throwError('No route to record viewer'); } $url = '/' . $classPath . '/' . $Record->getHandle(); } if ($path) { $url .= '/' . ltrim($path, '/'); } if ($permanent) { Site::redirectPermanent($url); } else { Site::redirect($url); } }
/** * Eintritts-Methode. */ public static function main() { // FestKassa-Konfiguration laden $config = Configuration::instance(); // Presiliste laden self::$priceList_ = new PriceList($config->priceList()); // Wurde auf "Nächste Bestellung" geklickt? if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'confirm' && isset($_REQUEST['erg']) && $_REQUEST['erg'] != 0) { $order = null; // Bestellung aus den Formulardaten generieren try { $order = self::buildOrderFromFormData_(); } catch (Exception $e) { echo "Fehler beim Auswerten der Eingaben: " . $e->getMessage() . "<br/>\n"; return; } if (bccomp('' . $order->sumPrice(), '' . $_REQUEST['erg']) != 0) { echo "Preisliste hat sich geändert. Bitte aktualisieren.<br/>\n"; return; } try { // Abrechnung schreiben self::writeAccountingForOrder_($order); } catch (IOException $ioe) { echo "Fehler beim Schreiben der Abrechnung: " . $ioe->getMessage() . "<br/>\n"; } // Ausdrucken try { self::printOrder_($order); } catch (UnknownPrinterException $ue) { echo "Fehler beim Drucken: Unbekannter Drucker: »" . $config->printerDriver() . "«<br/>\n"; } catch (PrinterException $pe) { echo "Fehler beim Drucken: " . $pe->getMessage() . "<br/>\n"; } } // FestKassa Web GUI an den Browser senden $lastSumPrice = isset($_REQUEST['erg']) ? $_REQUEST['erg'] : 0.0; WebInterface::render(self::$priceList_, $lastSumPrice); }
/** * Import the current file * @param SS_HTTPRequest $request */ public function import(SS_HTTPRequest $request) { $hasheader = (bool) $request->postVar('HasHeader'); $cleardata = $this->component->getCanClearData() ? (bool) $request->postVar('ClearData') : false; if ($request->postVar('action_import')) { $file = File::get()->byID($request->param('FileID')); if (!$file) { return "file not found"; } $colmap = Convert::raw2sql($request->postVar('mappings')); if ($colmap) { //save mapping to cache $this->cacheMapping($colmap); //do import $results = $this->importFile($file->getFullPath(), $colmap, $hasheader, $cleardata); $this->gridField->getForm()->sessionMessage($results->getMessage(), 'good'); } } $controller = $this->getToplevelController(); $url = method_exists($this->requestHandler, "Link") ? $this->requestHandler->Link() : $controller->Link(); $controller->redirect($url); }
/** * Creates a new RequestHandler object. * * @param string $className * @param array $applicationDir * @param string $type */ protected function __construct($className, $applicationDir, $type) { self::$activeRequest = $this; try { // validate class name if (!preg_match('/^[a-z0-9_]+$/i', $className)) { throw new SystemException("Illegal class name '" . $className . "'", 11009); } // find class $className = ucfirst($className) . ucfirst($type); $classPath = $type . '/' . $className . '.class.php'; $found = false; foreach ($applicationDir as $dir) { if (file_exists($dir . $classPath)) { $classPath = $dir . $classPath; $found = true; break; } } if (!$found) { throw new SystemException("unable to find class file '" . $classPath . "'", 11000); } } catch (SystemException $e) { throw new IllegalLinkException(); } // define vars $this->type = $type; $this->{$type} = $className; // include class require_once $classPath; // execute class if (!class_exists($className)) { throw new SystemException("unable to find class '" . $className . "'", 11001); } $this->controllerObj = new $className(); }