Source for file Presenter.php
Documentation is available at Presenter.php
- 1: <?php
- 3: /**
- 4: * Nette Framework
- 5: *
- 6: * Copyright (c) 2004, 2009 David Grudl (http://davidgrudl.com)
- 7: *
- 8: * This source file is subject to the "Nette license" that is bundled
- 9: * with this package in the file license.txt.
- 10: *
- 11: * For more information please see http://nettephp.com
- 12: *
- 18: */
- 28: /**
- 29: * Presenter object represents a webpage instance. It executes all the logic for the request.
- 30: *
- 34: *
- 43: */
- 45: {
- 46: /**#@+ life cycle phases {@link Presenter::getPhase()} */
- 51: /**#@-*/
- 53: /**#@+ bad link handling {@link Presenter::$invalidLinkMode} */
- 57: /**#@-*/
- 59: /**#@+ special parameter key */
- 63: /**#@-*/
- 71: /** @var array of function(Presenter $sender, \Exception $exception = NULL); Occurs when the presenter is shutting down */
- 130: /**
- 132: */
- 134: {
- 138: }
- 142: /**
- 144: */
- 146: {
- 148: }
- 152: /**
- 153: * Returns self.
- 155: */
- 157: {
- 159: }
- 163: /**
- 164: * Returns a name that uniquely identifies component.
- 166: */
- 168: {
- 170: }
- 174: /********************* interface IPresenter ****************d*g**/
- 178: /**
- 181: */
- 183: {
- 185: // PHASE 1: STARTUP
- 191: trigger_error("Method $class::startup() or its descendant doesn't call parent::startup().", E_USER_WARNING);
- 192: }
- 193: // calls $this->action<Action>()
- 198: }
- 201: }
- 203: // back compatibility
- 206: trigger_error('beforePrepare() is deprecated; use createComponent{Name}() instead.', E_USER_WARNING);
- 207: }
- 209: trigger_error('prepare' . ucfirst($this->getView()) . '() is deprecated; use createComponent{Name}() instead.', E_USER_WARNING);
- 210: }
- 212: // PHASE 2: SIGNAL HANDLING
- 214: // calls $this->handle<Signal>()
- 217: // PHASE 3: RENDERING VIEW
- 221: // calls $this->render<View>()
- 225: // save component tree persistent state
- 229: }
- 231: // finish template rendering
- 237: // continue with shutting down
- 240: // PHASE 4: SHUTDOWN
- 245: }
- 248: $this->getFlashSession()->setExpiration($e instanceof RedirectingException ? '+ 30 seconds': '+ 3 seconds');
- 249: }
- 255: }
- 256: }
- 260: /**
- 261: * Returns current presenter life cycle phase.
- 263: */
- 265: {
- 267: }
- 271: /**
- 273: */
- 275: {
- 277: }
- 281: /**
- 282: * Common render method.
- 284: */
- 286: {
- 287: }
- 291: /**
- 292: * Common render method.
- 294: */
- 296: {
- 297: }
- 301: /**
- 304: */
- 306: {
- 307: }
- 311: /********************* signal handling ****************d*g**/
- 315: /**
- 318: */
- 320: {
- 323: $component = $this->signalReceiver === '' ? $this : $this->getComponent($this->signalReceiver, FALSE);
- 325: throw new BadSignalException("The signal receiver component '$this->signalReceiver' is not found.");
- 328: throw new BadSignalException("The signal receiver component '$this->signalReceiver' is not ISignalReceiver implementor.");
- 329: }
- 331: // auto invalidate
- 334: }
- 338: }
- 342: /**
- 343: * Returns pair signal receiver and name.
- 345: */
- 347: {
- 349: }
- 353: /**
- 354: * Checks if the signal receiver is the given one.
- 358: */
- 360: {
- 363: }
- 377: }
- 378: }
- 382: /********************* rendering ****************d*g**/
- 386: /**
- 387: * Returns current action name.
- 389: */
- 391: {
- 393: }
- 397: /**
- 398: * Changes current action. Only alphanumeric characters are allowed.
- 401: */
- 403: {
- 410: }
- 411: }
- 415: /**
- 416: * Returns current view.
- 418: */
- 420: {
- 422: }
- 426: /**
- 427: * Changes current view. Any name is allowed.
- 430: */
- 432: {
- 434: }
- 438: /**
- 439: * Returns current layout name.
- 441: */
- 443: {
- 445: }
- 449: /**
- 450: * Changes or disables layout.
- 453: */
- 455: {
- 457: }
- 461: /**
- 464: */
- 466: {
- 472: }
- 476: // content template
- 482: }
- 483: }
- 488: }
- 490: // layout template
- 499: }
- 501: }
- 502: }
- 503: }
- 504: }
- 507: }
- 511: /**
- 512: * Formats layout template file names.
- 516: */
- 518: {
- 529: }
- 530: }
- 538: }
- 542: /**
- 543: * Formats view template file names.
- 547: */
- 549: {
- 555: $presenter = $pos === FALSE ? 'templates/' . $presenter : substr_replace($presenter, '/templates', $pos, 0);
- 557: }
- 563: }
- 567: /**
- 568: * Formats action method name.
- 571: */
- 573: {
- 575: }
- 579: /**
- 580: * Formats render view method name.
- 583: */
- 585: {
- 587: }
- 591: /********************* partial AJAX rendering ****************d*g**/
- 595: /**
- 597: */
- 599: {
- 601: }
- 605: /**
- 606: * Is AJAX request?
- 608: */
- 610: {
- 613: }
- 615: }
- 619: /**
- 620: * Sends AJAX payload to the output.
- 622: */
- 624: {
- 629: }
- 632: }
- 633: }
- 637: /**
- 639: */
- 641: {
- 642: throw new DeprecatedException(__METHOD__ . '() is deprecated; use $presenter->payload instead.');
- 643: }
- 647: /********************* navigation & flow ****************d*g**/
- 651: /**
- 652: * Forward to another presenter or action.
- 657: */
- 659: {
- 666: }
- 670: }
- 674: /**
- 675: * Redirect to another URL and ends presenter execution.
- 680: */
- 682: {
- 689: $code = $this->getHttpRequest()->isMethod('post') ? IHttpResponse::S303_POST_GET : IHttpResponse::S302_FOUND;
- 690: }
- 692: }
- 693: }
- 697: /**
- 698: * Link to myself.
- 700: */
- 702: {
- 704: }
- 708: /**
- 709: * Returns the last created PresenterRequest.
- 711: */
- 713: {
- 715: }
- 719: /**
- 720: * Returns the last created PresenterRequest flag.
- 723: */
- 725: {
- 727: }
- 731: /**
- 732: * Correctly terminates presenter.
- 735: */
- 737: {
- 739: }
- 743: /**
- 744: * Conditional redirect to canonicalized URI.
- 747: */
- 749: {
- 751: $uri = $this->createRequest($this, $this->action, $this->getGlobalState() + $this->request->params, 'redirectX');
- 754: }
- 755: }
- 756: }
- 760: /**
- 761: * Attempts to cache the sent entity by its last modification date
- 767: */
- 769: {
- 772: }
- 779: }
- 784: }
- 788: }
- 794: }
- 805: }
- 806: }
- 814: }
- 815: }
- 824: }
- 827: }
- 831: /**
- 832: * PresenterRequest/URL factory.
- 840: */
- 842: {
- 843: // note: createRequest supposes that saveState(), run() & tryCall() behaviour is final
- 845: // cached services for better performance
- 851: }
- 855: // PARSE DESTINATION
- 856: // 1) fragment
- 863: }
- 865: // 2) ?query syntax
- 870: }
- 872: // 3) URL scheme
- 879: }
- 881: // 4) signal or empty
- 888: }
- 891: }
- 893: }
- 897: }
- 899: // 5) presenter: action
- 912: }
- 922: }
- 923: }
- 925: }
- 927: // PROCESS SIGNAL ARGUMENTS
- 934: }
- 937: // counterpart of signalReceived() & tryCall()
- 941: }
- 944: }
- 945: }
- 947: // counterpart of IStatePersistent
- 950: }
- 957: }
- 958: }
- 959: }
- 961: // PROCESS ARGUMENTS
- 964: /*$action = $presenterClass::$defaultAction;*/ // in PHP 5.3
- 966: }
- 971: // counterpart of run() & tryCall()
- 972: // in PHP 5.3
- 975: // in PHP 5.3
- 979: }
- 980: }
- 982: // convert indexed parameters to named
- 986: }
- 993: }
- 994: }
- 996: // counterpart of IStatePersistent
- 997: if ($args && array_intersect_key($args, PresenterHelpers::getPersistentParams($presenterClass))) {
- 999: }
- 1008: }
- 1009: }
- 1010: }
- 1012: }
- 1014: // ADD ACTION & SIGNAL & FLASH
- 1019: }
- 1022: }
- 1035: // CONSTRUCT URL
- 1041: }
- 1043: // make URL relative if possible
- 1048: }
- 1049: }
- 1052: }
- 1056: /**
- 1057: * Invalid link handler. Descendant can override this method to change default behaviour.
- 1061: */
- 1063: {
- 1067: }
- 1077: }
- 1078: }
- 1082: /********************* interface IStatePersistent ****************d*g**/
- 1086: /**
- 1087: * Returns array of persistent components.
- 1088: * This default implementation detects components by class-level annotation @persistent(cmp1, cmp2).
- 1090: */
- 1092: {
- 1094: }
- 1098: /**
- 1099: * Saves state information for all subcomponents to $this->globalState.
- 1101: */
- 1103: {
- 1109: }
- 1116: }
- 1117: }
- 1124: }
- 1125: }
- 1130: {
- 1132: // counts with RecursiveIteratorIterator::SELF_FIRST
- 1133: $since = isset($components[$name]['since']) ? $components[$name]['since'] : FALSE; // FALSE = nonpersistent
- 1134: }
- 1141: }
- 1142: }
- 1146: }
- 1155: }
- 1159: }
- 1162: }
- 1163: }
- 1164: }
- 1167: }
- 1171: /**
- 1172: * Permanently saves state information for all subcomponents to $this->globalState.
- 1174: */
- 1176: {
- 1177: // load lazy components
- 1180: }
- 1184: }
- 1188: /**
- 1189: * Initializes $this->globalParams, $this->signal & $this->signalReceiver, $this->action, $this->view. Called by run().
- 1192: */
- 1194: {
- 1195: // init $this->globalParams
- 1202: }
- 1210: }
- 1211: }
- 1213: // init & validate $this->action & $this->view
- 1214: $this->changeAction(isset($selfParams[self::ACTION_KEY]) ? $selfParams[self::ACTION_KEY] : self::$defaultAction);
- 1216: // init $this->signalReceiver and key 'signal' in appropriate params array
- 1227: }
- 1230: }
- 1231: }
- 1234: }
- 1238: /**
- 1239: * Pops parameters for specified component.
- 1242: */
- 1244: {
- 1252: }
- 1253: }
- 1257: /********************* flash session ****************d*g**/
- 1261: /**
- 1262: * Checks if a flash session namespace exists.
- 1264: */
- 1266: {
- 1269: }
- 1273: /**
- 1274: * Returns session namespace provided to pass temporary data between redirects.
- 1276: */
- 1278: {
- 1281: }
- 1283: }
- 1287: /********************* backend ****************d*g**/
- 1291: /**
- 1293: */
- 1295: {
- 1297: }
- 1301: /**
- 1303: */
- 1305: {
- 1307: }
- 1311: /**
- 1313: */
- 1315: {
- 1317: }
- 1321: /**
- 1323: */
- 1325: {
- 1327: }
- 1329: }