/** * Display, this wil output the template to the browser * If no template is specified we build the path form the current module and action * * @return void * @param string[optional] $template The template to use, if not provided it will be based on the action. */ public function display($template = null) { // parse header $this->header->parse(); // if no template is specified, we have to build the path ourself // the default template is based on the name of the current action if ($template === null) { $template = BACKEND_MODULE_PATH . '/layout/templates/' . $this->URL->getAction() . '.tpl'; } // display $this->tpl->display($template); }
public function __construct() { $URL = new BackendURL(); new BackendTemplate(); new BackendNavigation(); new BackendHeader(); $action = new BackendAction($URL->getAction(), $URL->getModule()); $action->execute(); }
/** * @param string[optional] $name Name of the form. * @param string[optional] $action The action (URL) whereto the form will be submitted, if not provided it will be autogenerated. * @param string[optional] $method The method to use when submiting the form, default is POST. * @param bool[optional] $useToken Should we automagically add a formtoken? * @param bool[optional] $useGlobalError Should we automagically show a global error? */ public function __construct($name = null, $action = null, $method = 'post', $useToken = true, $useGlobalError = true) { if (Spoon::exists('url')) { $this->URL = Spoon::get('url'); } if (Spoon::exists('header')) { $this->header = Spoon::get('header'); } $this->useGlobalError = (bool) $useGlobalError; // build a name if there wasn't one provided $name = $name === null ? SpoonFilter::toCamelCase($this->URL->getModule() . '_' . $this->URL->getAction(), '_', true) : (string) $name; // build the action if it wasn't provided $action = $action === null ? '/' . $this->URL->getQueryString() : (string) $action; // call the real form-class parent::__construct($name, $action, $method, $useToken); // add default classes $this->setParameter('id', $name); $this->setParameter('class', 'forkForms submitWithLink'); }
/** * Default constructor * * @return void */ public function __construct() { // create URL-object to handle the URL $URL = new BackendURL(); // create new template so we have a reference that will be available on every module/action new BackendTemplate(); // create a navigation object new BackendNavigation(); // create a header-object new BackendHeader(); // create a new action $action = new BackendAction($URL->getAction(), $URL->getModule()); // execute the action $action->execute(); }
/** * Parse some vars */ private function parseVars() { // assign a placeholder var $this->assign('var', ''); // assign current timestamp $this->assign('timestamp', time()); // assign body ID if ($this->URL instanceof BackendURL) { $this->assign('bodyID', SpoonFilter::toCamelCase($this->URL->getModule(), '_', true)); // build classes $bodyClass = SpoonFilter::toCamelCase($this->URL->getModule() . '_' . $this->URL->getAction(), '_', true); // special occasions if ($this->URL->getAction() == 'add' || $this->URL->getAction() == 'edit') { $bodyClass = $this->URL->getModule() . 'AddEdit'; } // assign $this->assign('bodyClass', $bodyClass); } }
/** * Try to determine the selected state * * @return mixed * @param array $value The value. * @param int $key The key. * @param array[optional] $keys The previous marked keys. */ private function compareURL(array $value, $key, $keys = array()) { // create active url $activeURL = $this->URL->getModule() . '/' . $this->URL->getAction(); // add current key $keys[] = $key; // sub action? if (isset($value['selected_for']) && in_array($activeURL, (array) $value['selected_for'])) { return $keys; } // if the URL is available and same as the active one we have what we need. if (isset($value['url']) && $value['url'] == $activeURL) { if (isset($value['children'])) { // loop the childs foreach ($value['children'] as $key => $value) { // recursive here... $subKeys = $this->compareURL($value, $key, $keys); // wrap it up if (!empty($subKeys)) { return $subKeys; } } } // fallback return $keys; } // any children if (isset($value['children'])) { // loop the childs foreach ($value['children'] as $key => $value) { // recursive here... $subKeys = $this->compareURL($value, $key, $keys); // wrap it up if (!empty($subKeys)) { return $subKeys; } } } }