Dummy - The framework for Dummies - Framework Reference

While in your controller, you can access any function of variable from the framework simply using $this (though there is always an active alias to $Dummy). Outside (like in global functions or the code inside your DefaultDummyController), you can still access there variables using the $Dummy alias (in functions, you will need to make it global or pass as parameter).

Before we get into the $Dummy object, here is a list of constants set at startup:

  • CONS_STARTTIME - Unix time when the script started
  • MEMORY_LIMIT - Numerical value of php's memory_limit
  • CONS_ONSERVER - boolean - if running on server or local (IP's considered locals are 10.0.*, 192.168.*, 127.0.* and ::1) - this is processed in Startup.php if you need to change.
  • CONS_IP - client IP
  • CONS_ISMOBILE - boolean if the client is accessing from a mobile device
  • CONS_GZIP_OK - boolean if the client browser accepts gzipped pages

Here is a full list of variables for the $Dummy object. Some are configuration related (first batch) and others function related.

  • $Dummy->debugMode - boolean
    Either if running on debug mode, if true, will display the debug bar and allow ELI5, as well ignoring minor errors. 
     
  • $Dummy->debugbarPlace - string: top, right, bottom, left
    Where to place the debugbar on debug mode
     
  • $Dummy->autoTags - boolean
    Either to automatically apply default tags on the View(), this will remove context-sensitive tags like {_ajaxonly} or {_mobonly} depending on layout, as well fill constants like {PATH_FILES} (see source code for all tags)
  • $Dummy->dbConnector - string or boolean
    Either to use one database (string with a valid class inside /sys/dbo or true for mysqli) or not (false)
     
  • $Dummy->cms - boolean
    Either to run the CMS check or not. If true, the table for the CMS must be created in the database (see cms.xml)
     
  • $Dummy->jsminify - boolean
    Either if the View::compactjs will run or not. You can enclose javascript with tags (like {_javascript}) and call this function on that tag to minify it, but if jsminify is false that won't happen (good for debugging javascript)
     
  • $Dummy->validExtesions - array of strings
    Which file extensions are considered valid pages. If a call does not use one of these, the layout will be set to ajax mode. Default extensions are: 'html','htm','jsp','php','asp' and 'php3'
     
  • $Dummy->keepStatistics - boolean
    Either to run or not statistics keeping. If true, the statistics database must be set (see stats.xml)
     
  • $Dummy->keepLog - boolean
    If true, will keep a dummy.log file on root registering all $Dummy->errorLog entries
     
  • $Dummy->site_path - string
    The path to your site, as set on the $Dummy->start
     
  • $Dummy->config_path - string
    The path to your dinConfig file
     
  • $Dummy->installedDomains - array
    A list of valid domains the site is installed (include all variations, such as with and without www.) for the VAULT check system
     
  • $Dummy->vaultRedirect - string
    A file (located in the default view) that will be displayed if trying to access a file in the VAULT and the protection fails (like a no hot-link warning)
     
  • $Dummy->cacheEnabled - boolean
    Defines if the cache system is enabled
     
  • $Dummy->cacheRaw - boolean
    If raw files (set as layout raw, usually ajax files) are cached or not (default false)
     
  • $Dummy->cacheDuration - integer
    Time in minutes for cache duration, set 0 for forever
     
  • $Dummy->cacheConditions - array
    A list of $_SESSION variables that are used as flair for the cache system. You can also define specific conditions in those:
    only variable name (example: "flair") - will just use as a flair for the cache seed
    variable name = value (example: "flair=3") - cache will only be available if the variable is set accordingly
    !variable (example: "!logged") - cache will only be available if the defined variable does not exist (is not set)

 

These are function/activity related:

  • $Dummy->original_path - string
    The raw original URI path for the page. Unaltered by routes and alias.
     
  • $Dummy->boottime - float
    Time (microseconds) it took to reach your controller code
     
  • $Dummy->db - cdbo object
    The database connector, an instance from /sys/dbo/
     
  • $Dummy->dc - DefaultDummyController object
    Your controller, which is set in /site/master.php
     
  • $Dummy->returnCode - string or int
    The HTTP return code for this call, defaults to 200 or 404 depending if page found. This regards only the HTTP code, but will force a 403, 404 or 500 default page to be displayed if $Dummy->viewServed is false (see below)
     
  • $Dummy->viewServed - boolean
    If a valid view (from a file or CMS) was served. This is about the page that will be show, not the HTTP return code. For instance, to have a custom 403 error depending on the situation, you can serve different views (which will trigger this flag to be true) but all with the returnCode set to 403
     
  • $Dummy->layout - int
    Which layout to be served, can be a number from 0 to 3 or one of the layout constants (in order): CONS_LAYOUT_NORMAL, CONS_LAYOUT_SIMPLE, CONS_LAYOUT_RAW, CONS_LAYOUT_MOBILE
     
  • $Dummy->workKey - string
    Your script key, set at $Dummy->start
     
  • $Dummy->warningLog - array
    Array or warning messages (non error messages that will not be displayed to the user)
     
  • $Dummy->errorLog - array
    Array of error messages (non fatal PHP errors will be redirected here). This is the array stored in /dummy.log if $Dummy->keepLog is true
     
  • $Dummy->uri - URI object
    Data about a URI path, including ->path (array of folders), ->action (filename) and ->ext  
     
  • $Dummy->domain - string
    Which domain is being served
     
  • $Dummy->routes - array
    Array of your registered routes using $Dummy->route or $Dummy->domainRoute. You don't need to handle this
     
  • $Dummy->view - View object
    Template object where your HTML is loaded into
     
  • $Dummy->explainMe - boolean
    If on debugmode and the query ELI5={workkey} is send, this will be true and explanation messages on step-by-step framework workflow will be set in warningLog
     
  • $Dummy->cmscache - array or false
    A cache of data for the current CMS served page. Created when the script checks if there is a CMS data to be served, and used later after the template is ready to receive it.
     
  • $Dummy->dinConfig - array or false
    Array from your /site/dinConfig.dat .
     
  • $Dummy->templateParams - array
    Array of parameters sent to View functions when required (mostly used by the admin module)
     
  • $Dummy->modules - array
    Array of meta data about your tables, used by the admin
     
  • $Dummy->cacheSeed - string
    Auto-generated seed for the cache system, contains at least the domain and layout, plus $Dummy->cacheConditions
     
  • $Dummy->cacheServed - boolean
    Set if the cache has already been served (the framework does not stop because it might need to record statistics and other php commands, so this is used to chech that)


 

And now, all the functions in $Dummy (not including constructor). Functions with a × are automatic and you don't need to worry (some are private):

  • $Dummy->start($site,$key,$externalConfig="")
    Handles all the workflow of the framework, this is the function you call at the index.php, explained in the Framework page
     
  • $Dummy->terminate($reason="")
    Ends the script. You can call this at any time if you want to end the script with any HTTP error like 403 or 404.
    This function will:
    1. Disconnect the database
    2. Load error page into the framework (if $viewServed is false or $reason is a numeric HTTP code)
    3. Fill canonical information into {canonical} and add the meta for canonical in the <head>, only if return code 200
    4. Add a link rel tag in the <head> for your favicon (any file named favicon in your /files/ folder)
    5. Add debug or dummybar (ELI5) in the template
    6. Store $Dummy->errorLog messages if $Dummy->keepLog 
    7. Store the cache for the page, if it is not an error page and cache is selected.
    8. Output the template
    9. Stop the script (die) if $reason was not empty
       
  • × $Dummy->redirect($page,$folder=false)
    Performs an internal redirect to a new $page (optional new folder)
    For instance, if your current controller decides to serve another page, like a success or error page, you can use this function and the new page will be served as if the current. Runs automatically based on routes, moveout and domain routes.
     
  • × $Dummy->headerRedirect($location,$redirmode="200")
    Basically the same as the above but will halt the script by requesting an outside redirection using header(Location)
    $Dummy->redirect will not change the page url being served, if you need the url to change on the browser, this is better.
    Note you can store warning and queries from the current page to be loaded in the next using the $_SESSION[CONS_SESSION_LOG] (array of messages) and $_SESSION[CONS_SESSION_LOG_REQ] (array in the format $name=>$value that will be filled in $_REQUEST on the next page). Runs automatically on domain routes or redirect routes.
     
  • $Dummy->moveOut($localDomain,$localPagePattern,$destinationDomain,$destinationPage)
    Works like an immediate hard-coded routing to a new domain. If $localDomain is the current domain, and the page requested PREG_MATCH with $localPagePattern, will redirect (using $Dummy->headerRedirect) to $destinationDomain/$destinaionPage. A good place to use this is on your onStart() function
     
  • $Dummy->loadConfig($force=false, $file = "dinConfig")
    Loads the data of /site/dinConfig.dat in $Dummy->dinConfig. If already loaded or from cache (session), the $force parameter forces a reload. The cached data is stored only for 1 minute. Note it also uses a backup file (that is attempted if the main file fails) and a daily-backup file on worst case scenario (at which point, generates an error 500 if unable to load any). The main dinConfig is automatically loaded, but if you want to use another file, you will need to load it manually.
     
  • $Dummy->saveConfig($file = "dinConfig")
    Saves the data of $Dummy->dinConfig into /site/dinConfig.dat
    This function is never called automatically. Call it if you change data in $Dummy->dinConfig and wants it saved.
     
  • $Dummy->route($routeReg,$destinationRoute,$variablesArray=array(),$useHeader=false)
    Sets a route in the framework to be processed after everything is loaded. If the route matches ($routeReg = $Dummy->uri->toString()) will re-route to $destinationRoute and can set new variables in $_REQUEST if sent in $vadiablesArray. A good place to use this is on your onStart() function.
  • $Dummy->domainRoute($source,$new,$variablesArray=array(),$path='',$newTitle='')
    Same as above, but with domain names
     
  • × $Dummy->runRoutes()
    Called by the framework when it is time to check all routes
     
  • × $Dummy->getViewContent($file='',$asString=false)
    Loads data from a template file (or the current $Dummy->uri->toString()) and returns as a View object or string
     
  • × $Dummy->loadView($file='',$replaceCurrent=false)
    Simplified interface for $getViewContent used by the framework
     
  • × $Dummy->echoView($data,$replaceCurrent=false)
    Echos (or rather add to the template) a string (or View), depending if working on output buffered mode or not.
    If $replaceCurrent is set, will totally replace whatever is on the template, otherwise will append
     
  • × $Dummy->serveFixedFiles()
    Checks if the requested file is a fixed file and immediately serves it. The complete list of what are considered a fixed files are in /sys/fixedfiles.php (example of these files: robots.txt, favicon, apple-touch files)
     
  • $Dummy->prepareMail($ignoreVariables=array()
    Returns a View() object pre-constructed with the current $_REQUEST, useful to fill out automated mails.
     
  • × $Dummy->getCMS($fill=false)
    Checks if the current page have CMS data to be shown. If $fill is set, will assign {CONTENTMAN} with the page contents and set all meta data from the CMS file. This is all automatic by the framework so you don't need to use this. 
     
  • × $Dummy->showHeaders()
    Send headers with proper text translation (like 200 OK or 404 NOT FOUND)
     
  • × $Dummy->showDebugBar()
    Builds the debug bar for the terminate() function
     
  • × $Dummy->routeCompare($routeType,$route,$uri=false)
    Compares the given route with the optional $uri or current $Dummy->uri
     
  • × $Dummy->autoTags()
    Performs the autoTags pass, setting context-sensitive tags and adding constants.
     
  • × $Dummy->resetCMS()
    Recreates the CMS cache that handles pages from the content manager (stores in dinConfig which pages are CMS so it can detect them without consulting the database). This is called every time the CMS is changed on the administrative pane, or if you run debugmode.
     
  • $Dummy->currentPageIsCMS()
    Cheks if the page being called ($uri) is a page served by the CMS system.
     
  • × $Dummy->getCMS($fill = false)
    Fetches all the data for the current CMS page and will either load directly into the current view (if $fill is true) or will store in $Dummy->cmscache. Note all the CMS data is always stored in $Dummy->cmscache so you can also check this data in your code.
     
  • × $Dummy->checkCache($terminate = true)
    Cheks for a cached version of the current page ($uri), taking into consideration $_SESSION and $_REQUEST (will also respect $Dummy->cacheConditions). If found, will output the cached page and terminate. If $terminate is not set, will return true or false if a cache was served.
     
  • × $Dummy->purgeCache()
    Deletes all cached pages. Automatically called every time something is changed on the administrative pane or noCache is set in the $_REQUEST.
     
  • × $Dummy->saveCache(&$data)
    Stores the view ($data) as a cached version (serialized the object). Automatically called if a page is served and can be cached.