Source for file Presenter.php
Documentation is available at Presenter.php
- 1: <?php
- 3: /**
- 4: * Nette Framework
- 5: *
- 11: */
- 15: /**
- 16: * Presenter object represents a webpage instance. It executes all the logic for the request.
- 17: *
- 20: *
- 29: */
- 31: {
- 32: /**#@+ @deprecated */
- 37: /**#@-*/
- 39: /**#@+ bad link handling {@link Presenter::$invalidLinkMode} */
- 43: /**#@-*/
- 45: /**#@+ @ignore internal special parameter key */
- 49: /**#@-*/
- 57: /** @var array of function(Presenter $sender, IPresenterResponse $response = NULL); Occurs when the presenter is shutting down */
- 122: /**
- 124: */
- 126: {
- 128: }
- 132: /**
- 133: * Returns self.
- 135: */
- 137: {
- 139: }
- 143: /**
- 144: * Returns a name that uniquely identifies component.
- 146: */
- 148: {
- 150: }
- 154: /********************* interface IPresenter ****************d*g**/
- 158: /**
- 161: */
- 163: {
- 165: // PHASE 1: STARTUP
- 175: trigger_error("Method $class::startup() or its descendant doesn't call parent::startup().", E_USER_WARNING);
- 176: }
- 177: // calls $this->action<Action>()
- 182: }
- 185: }
- 187: // back compatibility
- 190: trigger_error('beforePrepare() is deprecated; use createComponent{Name}() instead.', E_USER_WARNING);
- 191: }
- 193: trigger_error('prepare' . ucfirst($this->getView()) . '() is deprecated; use createComponent{Name}() instead.', E_USER_WARNING);
- 194: }
- 196: // PHASE 2: SIGNAL HANDLING
- 198: // calls $this->handle<Signal>()
- 201: // PHASE 3: RENDERING VIEW
- 205: // calls $this->render<View>()
- 209: // save component tree persistent state
- 213: }
- 215: // finish template rendering
- 219: // continue with shutting down
- 222: // PHASE 4: SHUTDOWN
- 227: if ($this->response instanceof RenderResponse && ($this->isControlInvalid() || $hasPayload)) { // snippets - TODO
- 232: } elseif (!$this->response && $hasPayload) { // back compatibility for use terminate() instead of sendPayload()
- 234: }
- 238: $this->getFlashSession()->setExpiration($this->response instanceof RedirectingResponse ? '+ 30 seconds': '+ 3 seconds');
- 239: }
- 245: }
- 246: }
- 250: /**
- 252: */
- 254: {
- 257: }
- 261: /**
- 263: */
- 265: {
- 267: }
- 271: /**
- 272: * Common render method.
- 274: */
- 276: {
- 277: }
- 281: /**
- 282: * Common render method.
- 284: */
- 286: {
- 287: }
- 291: /**
- 294: */
- 296: {
- 297: }
- 301: /********************* signal handling ****************d*g**/
- 305: /**
- 308: */
- 310: {
- 313: $component = $this->signalReceiver === '' ? $this : $this->getComponent($this->signalReceiver, FALSE);
- 315: throw new BadSignalException("The signal receiver component '$this->signalReceiver' is not found.");
- 318: throw new BadSignalException("The signal receiver component '$this->signalReceiver' is not ISignalReceiver implementor.");
- 319: }
- 321: // auto invalidate
- 324: }
- 328: }
- 332: /**
- 333: * Returns pair signal receiver and name.
- 335: */
- 337: {
- 339: }
- 343: /**
- 344: * Checks if the signal receiver is the given one.
- 348: */
- 350: {
- 353: }
- 367: }
- 368: }
- 372: /********************* rendering ****************d*g**/
- 376: /**
- 377: * Returns current action name.
- 379: */
- 381: {
- 383: }
- 387: /**
- 388: * Changes current action. Only alphanumeric characters are allowed.
- 391: */
- 393: {
- 400: }
- 401: }
- 405: /**
- 406: * Returns current view.
- 408: */
- 410: {
- 412: }
- 416: /**
- 417: * Changes current view. Any name is allowed.
- 420: */
- 422: {
- 425: }
- 429: /**
- 430: * Returns current layout name.
- 432: */
- 434: {
- 436: }
- 440: /**
- 441: * Changes or disables layout.
- 444: */
- 446: {
- 449: }
- 453: /**
- 457: */
- 459: {
- 465: // content template
- 471: }
- 472: }
- 477: }
- 479: // layout template
- 481: $files = $this->formatLayoutTemplateFiles($this->getName(), $this->layout ? $this->layout : 'layout');
- 490: }
- 492: }
- 493: }
- 498: }
- 499: }
- 500: }
- 503: }
- 507: /**
- 508: * Formats layout template file names.
- 512: */
- 514: {
- 516: $root = Environment::getVariable('templatesDir', Environment::getVariable('appDir') . '/templates'); // back compatibility
- 526: }
- 527: }
- 534: }
- 545: }
- 547: }
- 551: /**
- 552: * Formats view template file names.
- 556: */
- 558: {
- 560: $root = Environment::getVariable('templatesDir', Environment::getVariable('appDir') . '/templates'); // back compatibility
- 565: $presenter = $pos === FALSE ? 'templates/' . $presenter : substr_replace($presenter, '/templates', $pos, 0);
- 567: }
- 573: }
- 584: }
- 588: /**
- 589: * Formats action method name.
- 592: */
- 594: {
- 596: }
- 600: /**
- 601: * Formats render view method name.
- 604: */
- 606: {
- 608: }
- 612: /**
- 614: */
- 616: {
- 617: throw new DeprecatedException(__METHOD__ . '() is deprecated; use $presenter->sendTemplate() instead.');
- 618: }
- 622: /********************* partial AJAX rendering ****************d*g**/
- 626: /**
- 628: */
- 630: {
- 632: }
- 636: /**
- 637: * Is AJAX request?
- 639: */
- 641: {
- 644: }
- 646: }
- 650: /**
- 651: * Sends AJAX payload to the output.
- 654: */
- 656: {
- 658: }
- 662: /**
- 664: */
- 666: {
- 667: throw new DeprecatedException(__METHOD__ . '() is deprecated; use $presenter->payload instead.');
- 668: }
- 672: /********************* navigation & flow ****************d*g**/
- 676: /**
- 677: * Forward to another presenter or action.
- 682: */
- 684: {
- 691: }
- 695: }
- 699: /**
- 700: * Redirect to another URL and ends presenter execution.
- 705: */
- 707: {
- 713: $code = $this->getHttpRequest()->isMethod('post') ? IHttpResponse::S303_POST_GET : IHttpResponse::S302_FOUND;
- 714: }
- 716: }
- 720: /**
- 721: * Link to myself.
- 723: */
- 725: {
- 727: }
- 731: /**
- 732: * Returns the last created PresenterRequest.
- 734: */
- 736: {
- 738: }
- 742: /**
- 743: * Returns the last created PresenterRequest flag.
- 746: */
- 748: {
- 750: }
- 754: /**
- 755: * Correctly terminates presenter.
- 759: */
- 761: {
- 764: }
- 768: /**
- 769: * Conditional redirect to canonicalized URI.
- 772: */
- 774: {
- 776: $uri = $this->createRequest($this, $this->action, $this->getGlobalState() + $this->request->params, 'redirectX');
- 779: }
- 780: }
- 781: }
- 785: /**
- 786: * Attempts to cache the sent entity by its last modification date
- 793: */
- 795: {
- 798: }
- 802: }
- 806: }
- 807: }
- 811: /**
- 812: * PresenterRequest/URL factory.
- 820: */
- 822: {
- 823: // note: createRequest supposes that saveState(), run() & tryCall() behaviour is final
- 825: // cached services for better performance
- 831: }
- 835: // PARSE DESTINATION
- 836: // 1) fragment
- 843: }
- 845: // 2) ?query syntax
- 850: }
- 852: // 3) URL scheme
- 859: }
- 861: // 4) signal or empty
- 868: }
- 871: }
- 873: }
- 877: }
- 879: // 5) presenter: action
- 892: }
- 902: }
- 903: }
- 905: }
- 907: // PROCESS SIGNAL ARGUMENTS
- 914: }
- 917: // counterpart of signalReceived() & tryCall()
- 921: }
- 924: }
- 925: }
- 927: // counterpart of IStatePersistent
- 930: }
- 937: }
- 938: }
- 939: }
- 941: // PROCESS ARGUMENTS
- 944: /*$action = $presenterClass::$defaultAction;*/ // in PHP 5.3
- 946: }
- 952: // counterpart of run() & tryCall()
- 953: // in PHP 5.3
- 956: // in PHP 5.3
- 960: }
- 961: }
- 963: // convert indexed parameters to named
- 967: }
- 974: }
- 975: }
- 977: // counterpart of IStatePersistent
- 980: }
- 989: }
- 990: }
- 991: }
- 993: }
- 995: // ADD ACTION & SIGNAL & FLASH
- 1000: }
- 1003: }
- 1016: // CONSTRUCT URL
- 1022: }
- 1024: // make URL relative if possible
- 1029: }
- 1030: }
- 1033: }
- 1037: /**
- 1038: * Converts list of arguments to named parameters.
- 1045: */
- 1047: {
- 1052: }
- 1061: // continue with process
- 1068: }
- 1075: }
- 1076: }
- 1080: }
- 1081: }
- 1085: /**
- 1086: * Invalid link handler. Descendant can override this method to change default behaviour.
- 1090: */
- 1092: {
- 1096: }
- 1106: }
- 1107: }
- 1111: /********************* interface IStatePersistent ****************d*g**/
- 1115: /**
- 1116: * Returns array of persistent components.
- 1117: * This default implementation detects components by class-level annotation @persistent(cmp1, cmp2).
- 1119: */
- 1121: {
- 1123: }
- 1127: /**
- 1128: * Saves state information for all subcomponents to $this->globalState.
- 1130: */
- 1132: {
- 1141: }
- 1142: }
- 1149: }
- 1150: }
- 1155: {
- 1157: // counts with RecursiveIteratorIterator::SELF_FIRST
- 1158: $since = isset($components[$name]['since']) ? $components[$name]['since'] : FALSE; // FALSE = nonpersistent
- 1159: }
- 1166: }
- 1167: }
- 1171: }
- 1180: }
- 1184: }
- 1187: }
- 1188: }
- 1189: }
- 1192: }
- 1196: /**
- 1197: * Permanently saves state information for all subcomponents to $this->globalState.
- 1199: */
- 1201: {
- 1202: // load lazy components
- 1205: }
- 1209: }
- 1213: /**
- 1214: * Initializes $this->globalParams, $this->signal & $this->signalReceiver, $this->action, $this->view. Called by run().
- 1217: */
- 1219: {
- 1220: // init $this->globalParams
- 1227: }
- 1235: }
- 1236: }
- 1238: // init & validate $this->action & $this->view
- 1239: $this->changeAction(isset($selfParams[self::ACTION_KEY]) ? $selfParams[self::ACTION_KEY] : self::$defaultAction);
- 1241: // init $this->signalReceiver and key 'signal' in appropriate params array
- 1252: }
- 1255: }
- 1256: }
- 1259: }
- 1263: /**
- 1264: * Pops parameters for specified component.
- 1267: */
- 1269: {
- 1277: }
- 1278: }
- 1282: /********************* flash session ****************d*g**/
- 1286: /**
- 1287: * Checks if a flash session namespace exists.
- 1289: */
- 1291: {
- 1293: && $this->getSession()->hasNamespace('Nette.Application.Flash/' . $this->params[self::FLASH_KEY]);
- 1294: }
- 1298: /**
- 1299: * Returns session namespace provided to pass temporary data between redirects.
- 1301: */
- 1303: {
- 1306: }
- 1308: }
- 1312: /********************* backend ****************d*g**/
- 1316: /**
- 1318: */
- 1320: {
- 1322: }
- 1326: /**
- 1328: */
- 1330: {
- 1332: }
- 1336: /**
- 1338: */
- 1340: {
- 1342: }
- 1346: /**
- 1348: */
- 1350: {
- 1352: }
- 1356: /**
- 1358: */
- 1360: {
- 1362: }
- 1366: /**
- 1368: */
- 1370: {
- 1372: }
- 1374: }