Exemplo n.º 1
0
 /**
  * Execute the action
  * We will build the classname, require the class and call the execute method.
  */
 public function execute()
 {
     $this->loadConfig();
     // is the requested action possible? If not we throw an exception. We don't redirect because that could trigger a redirect loop
     if (!in_array($this->getAction(), $this->config->getPossibleActions())) {
         throw new BackendException('This is an invalid action (' . $this->getAction() . ').');
     }
     // build action-class-name
     $actionClassName = SpoonFilter::toCamelCase('backend_' . $this->getModule() . '_' . $this->getAction());
     // require the config file, we know it is there because we validated it before (possible actions are defined by existance off the file).
     require_once BACKEND_MODULE_PATH . '/actions/' . $this->getAction() . '.php';
     // validate if class exists (aka has correct name)
     if (!class_exists($actionClassName)) {
         throw new BackendException('The actionfile is present, but the classname should be: ' . $actionClassName . '.');
     }
     // get working languages
     $languages = BackendLanguage::getWorkingLanguages();
     $workingLanguages = array();
     // loop languages and build an array that we can assign
     foreach ($languages as $abbreviation => $label) {
         $workingLanguages[] = array('abbr' => $abbreviation, 'label' => $label, 'selected' => $abbreviation == BackendLanguage::getWorkingLanguage());
     }
     // assign the languages
     $this->tpl->assign('workingLanguages', $workingLanguages);
     // create action-object
     $object = new $actionClassName();
     $object->execute();
 }
Exemplo n.º 2
0
 /**
  * You have to specify the action and module so we know what to do with this instance
  *
  * @param string $action The action to load.
  * @param string $module The module to load.
  */
 public function __construct($action, $module)
 {
     // grab stuff from the reference and store them in this object (for later/easy use)
     $this->tpl = Spoon::get('template');
     $this->setModule($module);
     $this->setAction($action);
     $this->loadConfig();
     // is the requested action possible? If not we throw an exception. We don't redirect because that could trigger a redirect loop
     if (!in_array($this->getAction(), $this->config->getPossibleActions())) {
         throw new BackendException('This is an invalid action (' . $this->getAction() . ').');
     }
 }