Skip to content

Controller v2 system

Nyo edited this page Apr 8, 2016 · 1 revision

As of 10/02/2016, ripple is migrating to a new controller system (and also view system, but that's another question). This is how a class must be structured in order to appropriately be used in ripple.

General

  • const URL: The request URL for the handler. For instance, if I have set URL to login, then all requests to /login will be forwarded to that.
  • const LoggedIn: bool. Set to true if the user must be logged in for doing anything on that page. Set to false if the user must NOT be logged in. Do not set if whatever is fine. (optional)
  • const CheckAdmin: bool. Set to true to check if the user is an admin before doing anything. If not admin, redirects user to /forbidden_admin. (optional)

If the page was on ripple before the new system

  • const PageID: an int containing the page ID before ripple switched to the new system, to allow backwards compatibility.

If the page supports GET requests

  • const Title: the title of the page
  • public function P(): Prints the data for the end user if it's accessing the page directly. The data for making out the page is usually retrieved via PrintGetData(), so this function is most of the time just a wrapper.
  • public function PrintGetData(): Retrieves the data necessary to make the page, usually it's an array of elements. Please note that whatever is returned by this function is likely to be used in the future for the API.
  • public $mh_GET: An array of elements that MUST be in $_GET at all times. This value is optional.
  • public $mh_GET_missing: Custom error response when an element from $mh_GET is missing. You can use {mh_GET_missing} in the string if you need to get the name of the missing parameter

If the page has success/error messages

  • public $error_messages: an array of error messages, which index may be passed in $_GET["e"].
  • public $success_messages: same as above, but for success messages.

If the page supports POST requests

  • public function D(): Prints the data for the end user if it's accessing the page directly. The data for making out the page is usually retrieved via DoGetData(), so this function is most of the time just a wrapper.
  • public function DoGetData(): Retrieves the data necessary to make the page, usually it's an array of elements. Please note that whatever is returned by this function is likely to be used in the future for the API.
  • public $mh_POST: An array of elements that MUST be in $_POST at all times. This value is optional.
  • public $mh_POST_missing: Custom error response when an element from $mh_POST is missing. You can use {mh_POST_missing} in the string if you need to get the name of the missing parameter