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 https://nette.org
- 12: *
- 19: */
- 29: /**
- 30: * Presenter object represents a webpage instance. It executes all the logic for the request.
- 31: *
- 35: */
- 37: {
- 38: /**#@+ life cycle phases {@link Presenter::getPhase()} */
- 44: /**#@-*/
- 46: /**#@+ bad link handling {@link Presenter::$invalidLinkMode} */
- 50: /**#@-*/
- 52: /**#@+ special parameter key */
- 56: /**#@-*/
- 64: /** @var array of event handlers; Occurs when the presenter is shutting down; function(Presenter $sender, Exception $exception = NULL) */
- 120: /**
- 122: */
- 124: {
- 127: }
- 131: /**
- 134: */
- 136: {
- 138: }
- 142: /**
- 143: * Returns self.
- 145: */
- 147: {
- 149: }
- 153: /**
- 154: * Returns a name that uniquely identifies component.
- 156: */
- 158: {
- 160: }
- 164: /********************* interface IPresenter ****************d*g**/
- 168: /**
- 171: */
- 173: {
- 175: // PHASE 1: STARTUP
- 179: }
- 182: // calls $this->action{action}();
- 185: trigger_error('Method name present' . $this->getAction() . '() is deprecated; use ' . $this->formatActionMethod($this->getAction()) . '() instead.', E_USER_WARNING);
- 186: }
- 190: }
- 193: }
- 195: // PHASE 2: PREPARING VIEW
- 198: // calls $this->prepare{view}();
- 201: // PHASE 3: SIGNAL HANDLING
- 205: // PHASE 4: RENDERING VIEW
- 209: // calls $this->render{view}();
- 213: // save component tree persistent state
- 217: }
- 219: // finish template rendering
- 225: // continue with shutting down
- 228: // PHASE 5: SHUTDOWN
- 233: }
- 237: }
- 243: }
- 244: }
- 248: /**
- 249: * Returns current presenter life cycle phase.
- 251: */
- 253: {
- 255: }
- 259: /**
- 261: */
- 263: {
- 264: }
- 268: /**
- 269: * Common prepare method.
- 271: */
- 273: {
- 274: }
- 278: /**
- 279: * Common render method.
- 281: */
- 283: {
- 284: }
- 288: /**
- 289: * Common render method.
- 291: */
- 293: {
- 294: }
- 298: /**
- 301: */
- 303: {
- 304: }
- 308: /********************* signal handling ****************d*g**/
- 312: /**
- 315: */
- 317: {
- 320: $component = $this->signalReceiver === '' ? $this : $this->getComponent($this->signalReceiver, FALSE);
- 322: throw new BadSignalException("The signal receiver component '$this->signalReceiver' is not found.");
- 325: throw new BadSignalException("The signal receiver component '$this->signalReceiver' is not ISignalReceiver implementor.");
- 326: }
- 328: // auto invalidate
- 331: }
- 335: }
- 339: /**
- 340: * Returns pair signal receiver and name.
- 342: */
- 344: {
- 346: }
- 350: /**
- 351: * Checks if the signal receiver is the given one.
- 355: */
- 357: {
- 360: }
- 374: }
- 375: }
- 379: /********************* rendering ****************d*g**/
- 383: /**
- 384: * Returns current action name.
- 386: */
- 388: {
- 390: }
- 394: /**
- 395: * Changes current action. Only alphanumeric characters are allowed.
- 398: */
- 400: {
- 407: }
- 408: }
- 412: /**
- 413: * Returns current view.
- 415: */
- 417: {
- 419: }
- 423: /**
- 424: * Changes current view. Any name is allowed.
- 427: */
- 429: {
- 431: }
- 435: /**
- 436: * Returns current layout name.
- 438: */
- 440: {
- 442: }
- 446: /**
- 447: * Changes or disables layout.
- 450: */
- 452: {
- 454: }
- 458: /**
- 460: */
- 462: {
- 463: trigger_error('Presenter::changeView() is deprecated; use Presenter::setView(...) instead.', E_USER_WARNING);
- 465: }
- 469: /**
- 471: */
- 473: {
- 474: trigger_error('Presenter::getScene() is deprecated; use Presenter::getView() instead.', E_USER_WARNING);
- 476: }
- 480: /**
- 482: */
- 484: {
- 485: trigger_error('Presenter::changeScene() is deprecated; use Presenter::setView(...) instead.', E_USER_WARNING);
- 487: }
- 491: /**
- 493: */
- 495: {
- 496: trigger_error('Presenter::changeLayout() is deprecated; use Presenter::setLayout(...) instead.', E_USER_WARNING);
- 498: }
- 502: /**
- 505: */
- 507: {
- 513: }
- 519: }
- 523: // content template
- 529: }
- 530: }
- 535: }
- 537: // layout template
- 546: }
- 548: }
- 549: }
- 550: }
- 551: }
- 554: }
- 558: /**
- 559: * Formats layout template file names.
- 563: */
- 565: {
- 576: }
- 577: }
- 585: }
- 589: /**
- 590: * Formats view template file names.
- 594: */
- 596: {
- 602: $presenter = $pos === FALSE ? 'templates/' . $presenter : substr_replace($presenter, '/templates', $pos, 0);
- 604: }
- 610: }
- 614: /**
- 615: * Formats action method name.
- 618: */
- 620: {
- 622: }
- 626: /**
- 627: * Formats prepare view method name.
- 630: */
- 632: {
- 634: }
- 638: /**
- 639: * Formats render view method name.
- 642: */
- 644: {
- 646: }
- 650: /********************* partial AJAX rendering ****************d*g**/
- 654: /**
- 656: */
- 658: {
- 660: }
- 664: /**
- 665: * Is AJAX request?
- 667: */
- 669: {
- 672: }
- 674: }
- 678: /**
- 680: */
- 682: {
- 687: throw new UnexpectedValueException("Object returned by $this->class::getAjaxDriver() must be instance of Nette\\Application\\IAjaxDriver, '$class' given.");
- 688: }
- 690: }
- 692: }
- 696: /**
- 698: */
- 700: {
- 702: }
- 706: /********************* navigation & flow ****************d*g**/
- 710: /**
- 711: * Forward to another presenter or action.
- 716: */
- 718: {
- 725: }
- 729: }
- 733: /**
- 734: * Redirect to another URL and ends presenter execution.
- 739: */
- 741: {
- 748: }
- 749: }
- 753: /**
- 754: * Link to myself.
- 756: */
- 758: {
- 760: }
- 764: /**
- 765: * Returns the last created PresenterRequest.
- 767: */
- 769: {
- 771: }
- 775: /**
- 776: * Returns the last created PresenterRequest flag.
- 779: */
- 781: {
- 783: }
- 787: /**
- 788: * Correctly terminates presenter.
- 791: */
- 793: {
- 795: }
- 799: /**
- 800: * Conditional redirect to canonicalized URI.
- 803: */
- 805: {
- 807: $uri = $this->createRequest($this, $this->action, $this->getGlobalState() + $this->request->params, 'redirectX');
- 810: }
- 811: }
- 812: }
- 816: /**
- 817: * Attempts to cache the sent entity by its last modification date
- 823: */
- 825: {
- 828: }
- 835: }
- 840: }
- 844: }
- 850: }
- 861: }
- 862: }
- 870: }
- 871: }
- 880: }
- 883: }
- 887: /**
- 888: * PresenterRequest/URL factory.
- 896: */
- 898: {
- 899: // note: createRequest supposes that saveState(), run() & tryCall() behaviour is final
- 901: // cached services for better performance
- 907: }
- 911: // PARSE DESTINATION
- 912: // 1) fragment
- 919: }
- 921: // 2) ?query syntax
- 926: }
- 928: // 3) URL scheme
- 935: }
- 937: // 4) signal or empty
- 942: }
- 944: }
- 948: }
- 950: // 5) presenter: action
- 963: }
- 973: }
- 974: }
- 976: }
- 978: // PROCESS SIGNAL ARGUMENTS
- 985: }
- 988: // counterpart of signalReceived() & tryCall()
- 992: }
- 995: }
- 996: }
- 998: // counterpart of IStatePersistent
- 1001: }
- 1008: }
- 1009: }
- 1010: }
- 1012: // PROCESS ARGUMENTS
- 1015: /*$action = $presenterClass::$defaultAction;*/ // in PHP 5.3
- 1017: }
- 1022: // counterpart of run() & tryCall()
- 1023: // in PHP 5.3
- 1028: // in PHP 5.3
- 1032: }
- 1033: }
- 1034: }
- 1036: // convert indexed parameters to named
- 1040: }
- 1047: }
- 1048: }
- 1050: // counterpart of IStatePersistent
- 1051: if ($args && array_intersect_key($args, PresenterHelpers::getPersistentParams($presenterClass))) {
- 1053: }
- 1062: }
- 1063: }
- 1064: }
- 1066: }
- 1068: // ADD ACTION & SIGNAL & FLASH
- 1073: }
- 1076: }
- 1089: // CONSTRUCT URL
- 1095: }
- 1097: // make URL relative if possible
- 1102: }
- 1103: }
- 1106: }
- 1110: /**
- 1111: * Invalid link handler. Descendant can override this method to change default behaviour.
- 1115: */
- 1117: {
- 1121: }
- 1131: }
- 1132: }
- 1136: /********************* interface IStatePersistent ****************d*g**/
- 1140: /**
- 1141: * Returns array of persistent components.
- 1142: * This default implementation detects components by class-level annotation @persistent(cmp1, cmp2).
- 1144: */
- 1146: {
- 1148: }
- 1152: /**
- 1153: * Saves state information for all subcomponents to $this->globalState.
- 1155: */
- 1157: {
- 1163: }
- 1170: }
- 1171: }
- 1178: }
- 1179: }
- 1184: {
- 1186: // counts with RecursiveIteratorIterator::SELF_FIRST
- 1187: $since = isset($components[$name]['since']) ? $components[$name]['since'] : FALSE; // FALSE = nonpersistent
- 1188: }
- 1195: }
- 1196: }
- 1200: }
- 1209: }
- 1213: }
- 1216: }
- 1217: }
- 1218: }
- 1221: }
- 1225: /**
- 1226: * Permanently saves state information for all subcomponents to $this->globalState.
- 1228: */
- 1230: {
- 1233: }
- 1237: /**
- 1238: * Initializes $this->globalParams, $this->signal & $this->signalReceiver, $this->action, $this->view. Called by run().
- 1241: */
- 1243: {
- 1244: // init $this->globalParams
- 1251: }
- 1259: }
- 1260: }
- 1262: // init & validate $this->action & $this->view
- 1263: $this->changeAction(isset($selfParams[self::ACTION_KEY]) ? $selfParams[self::ACTION_KEY] : self::$defaultAction);
- 1265: // init $this->signalReceiver and key 'signal' in appropriate params array
- 1276: }
- 1279: }
- 1280: }
- 1283: }
- 1287: /**
- 1288: * Pops parameters for specified component.
- 1291: */
- 1293: {
- 1301: }
- 1302: }
- 1306: /********************* flash session ****************d*g**/
- 1310: /**
- 1311: * Checks if a flash session namespace exists.
- 1313: */
- 1315: {
- 1318: }
- 1322: /**
- 1323: * Returns session namespace provided to pass temporary data between redirects.
- 1325: */
- 1327: {
- 1330: }
- 1332: }
- 1336: /********************* backend ****************d*g**/
- 1340: /**
- 1342: */
- 1344: {
- 1346: }
- 1350: /**
- 1352: */
- 1354: {
- 1356: }
- 1360: /**
- 1362: */
- 1364: {
- 1366: }
- 1370: /**
- 1372: */
- 1374: {
- 1376: }
- 1378: }