示例#1
0
 /**
  * @param org_glizy_components_Component $targetComponent
  *
  * @return array
  */
 private function processAjaxCallController($targetComponent)
 {
     if (__Request::exists('controllerName')) {
         $targetComponent->setAttribute('controllerName', __Request::get('controllerName'));
     }
     $result = array('status' => false);
     $r = $targetComponent->callController();
     if ($r !== null && $r !== false) {
         if ($targetComponent->controllerDirectOutput()) {
             return $r;
         }
         $result['status'] = true;
         if (is_array($r) && isset($r['error'])) {
             $result['status'] = false;
             $result['error'] = $r['error'];
             return $result;
         }
         $outputFormatInHtml = false;
         $html = '';
         if (is_array($r) && isset($r['sendOutput'])) {
             // controlla se c'è renderizzare dei componenti da mandare all'output
             __Request::set('action', isset($r['sendOutputState']) ? $r['sendOutputState'] : '');
             $outputFormatInHtml = isset($r['sendOutputFormat']) && $r['sendOutputFormat'] == 'html';
             $this->_rootComponent->process();
             $componentsId = $r['sendOutput'];
             unset($r['sendOutput']);
             unset($r['sendOutputState']);
             if (!is_array($componentsId)) {
                 $componentsId = array($componentsId);
             }
             foreach ($componentsId as $id) {
                 $c = $this->_rootComponent->getComponentById($id);
                 if (is_object($c)) {
                     $this->_rootComponent->_output = array();
                     $c->render();
                     //$r[ 'sendOutput' ][ $id ] = $this->_output[ 0 ][ 'code' ];
                     $r[$id] = '';
                     foreach ($this->_rootComponent->_output as $o) {
                         if (strpos($o['editableRegion'], '__') !== false) {
                             continue;
                         }
                         $r[$id] .= $o['code'];
                         $html .= $o['code'];
                     }
                 }
             }
         }
         if ($outputFormatInHtml) {
             $result['html'] = $html;
         } else {
             $result['result'] = $r;
         }
     }
     return $result;
 }