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->outputBuffered - boolean
    Either if run outbut buffered (ob) or not. If running on output buffered, will use template, otherwise simple echo
  • $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->dinConfigParse - boolean
    Either if the dinConfig parsing will happen (load dinConfig.dat in your /site/ and store in $Dummy->dinConfig)
  • $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)


These are function/activity related:

  • $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 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 if $Dummy->dinConfigParse is set.
  • $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

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. Output the template
    8. 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
  • $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)
  • $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
  • $Dummy->loadConfig($force=false)
    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
  • $Dummy->saveConfig()
    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
  • $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.