public function handleDatasource($name, $method, array $preloadedData, array &$templateVariables)
 {
     $this->name = $name;
     $datasource = ActionUtils::createActionDatasource($name, $method);
     // set the variables for use
     $this->templateVars =& $templateVariables;
     $this->currentDatasource = $datasource;
     // set the current datasource
     $this->currentActionOrDatasource = $datasource;
     $methodResolved = ActionUtils::parseMethod($method);
     $this->currentMethod = $methodResolved;
     //if(LOG_ENABLE) System::log(self::$logType, 'Datasource: ['.$datasource.']');
     // if we did an action and the datasource is already set, use it
     if (self::$actionBoundDatasource == $datasource) {
         return $this;
     }
     if (!method_exists($this, $methodResolved)) {
         throw new Exception('Method [' . $methodResolved . '] does not exist on class [' . get_class($this) . ']');
     }
     // clear the data first
     $this->setData(null);
     // set preloaded data (from Renderer)
     if (!empty($preloadedData)) {
         $this->setData($preloadedData);
     }
     $this->preDatasource();
     //if(LOG_ENABLE) System::log(self::$logType, 'Executing method ['.$methodResolved.']');
     $result = null;
     $result = $this->{$methodResolved}();
     if ($result == null) {
         $result = array();
     }
     // bind to datasource
     $this->setData($result);
     $this->postDatasource();
     return $this;
     // for chaining
 }
Esempio n. 2
0
 public function setControls($params)
 {
     $cvars = array('view', 'view_page', 'view_handler', 'view_paging', 'view_nodebug', 'view_nocache', 'view_pushcache', 'view_rss_link', 'action', 'action_nonce', 'action_success_view', 'action_form_view', 'action_continue_view', 'action_new_view', 'action_cancel_view', 'action_confirm_delete_view', 'action_datasource', 'action_buffer');
     foreach ($params as $name => $value) {
         //			if(in_array($name, $cvars)) {
         $this->controls[$name] = $value;
         //			}
         if (substr($name, 0, 2) == 'b_') {
             if (substr($name, -2) == '_x' || substr($name, -2) == '_y') {
                 $name = substr($name, 0, -2);
             }
             $this->controls['action_button'] = substr($name, 2);
         }
         if (substr($name, 0, 2) == 'a_') {
             if (substr($name, -2) == '_x' || substr($name, -2) == '_y') {
                 $name = substr($name, 0, -2);
             }
             $this->controls['action_button'] = 'save';
             $this->controls['action_override_method'] = substr($name, 2);
         }
     }
     if (isset($this->controls['view_pushcache'])) {
         $_SERVER['REQUEST_URI'] = preg_replace('/\\?view_pushcache=([^\\&]+)\\&/', '?', $_SERVER['REQUEST_URI']);
         $_SERVER['REQUEST_URI'] = preg_replace('/\\?view_pushcache=([^\\&]+)/', '', $_SERVER['REQUEST_URI']);
         unset($_GET['view_pushcache']);
     }
     if (isset($this->controls['action_button'])) {
         $this->controls['action_executing'] = true;
         $this->controls['view_nocache'] = true;
     }
     if (isset($this->controls['action'])) {
         try {
             list($elem, $method) = ActionUtils::parseActionDatasource($this->controls['action']);
             $this->controls['action'] = ActionUtils::createActionDatasource($elem, $method);
             $this->controls['action_element'] = $elem;
             $this->controls['action_method'] = $method;
         } catch (ActionDatasourceException $ae) {
             unset($this->controls['action']);
             unset($this->controls['action_element']);
             unset($this->controls['action_method']);
         }
     }
     return $this;
 }