public function endRender(__IComponent &$component)
    {
        $component_id = $component->getId();
        $return_value = $this->_component_writer->endRender($component);
        $place_after_element = $component->placeAfterElement;
        if (!empty($place_after_element)) {
            $jod_response_writer = new __JavascriptOnDemandResponseWriter('place-after-element' . $component_id);
            $jod_response_writer->addJsCode("var {$component_id} = \$('{$component_id}').remove();\n\n            {$component_id}.insert({$place_after_element});\n");
            $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript');
            $javascript_rw->addResponseWriter($jod_response_writer);
        }
        $waiting_components = $component->waitingComponents;
        if (!empty($waiting_components)) {
            if (__ResponseWriterManager::getInstance()->hasResponseWriter('waiting-components')) {
                $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('waiting-components');
            } else {
                $jod_response_writer = new __JavascriptOnDemandResponseWriter('waiting-components');
                $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript');
                $javascript_rw->addResponseWriter($jod_response_writer);
            }
            $waiting_components_array = preg_split('/,/', $waiting_components);
            foreach ($waiting_components_array as $waiting_component_name) {
                $component_handler = __ComponentHandlerManager::getInstance()->getComponentHandler($component->getViewCode());
                $waiting_component = $component_handler->getComponent($waiting_component_name);
                $waiting_component_id = $waiting_component->getId();
                $js_code = <<<CODE
(__ProgressBroadcaster.getInstance()).setWaitingDependence("{$waiting_component_id}", "{$component_id}");                
CODE;
                $jod_response_writer->addJsCode($js_code);
            }
        }
        return $return_value;
    }
 /**
  * Gets the startup notification, which contains initial component states
  *
  * @param string $view_code
  * @return __AsyncMessage
  */
 public function getStartupNotification($view_code)
 {
     $return_value = null;
     if (__ComponentHandlerManager::getInstance()->hasComponentHandler($view_code)) {
         $components = __ComponentHandlerManager::getInstance()->getComponentHandler($view_code)->getComponents();
         $return_value = __AsyncMessageFactory::getInstance()->createComponentsAsyncMessage($components, true);
     }
     return $return_value;
 }
예제 #3
0
 public function restoreView()
 {
     if ($this->_component_handler != null) {
         __ComponentHandlerManager::getInstance()->addComponentHandler($this->_component_handler);
         __EventHandlerManager::getInstance()->addEventHandler($this->_event_handler);
         $component_pool = __ComponentPool::getInstance();
         foreach ($this->_components as $component) {
             $component_pool->registerComponent($component);
             unset($component);
         }
     }
 }
 /**
  * Get the component to be validated by the current validator
  *
  * @return __IComponent
  */
 public function getCaptcha()
 {
     $return_value = null;
     $component_handler = __ComponentHandlerManager::getInstance()->getComponentHandler($this->_view_code);
     if ($component_handler != null) {
         if ($component_handler->hasComponent($this->_captcha_image_component)) {
             $return_value = $component_handler->getComponent($this->_captcha_image_component, $this->_captcha_component_index);
         } else {
             throw __ExceptionFactory::getInstance()->createException('Component to validate not found: ' . $this->_component);
         }
     }
     return $return_value;
 }
    public function endRender(__IComponent &$component)
    {
        $return_value = $this->_component_writer->endRender($component);
        $spinner = $component->spinner;
        if (empty($spinner)) {
            $spinner = true;
            //by default
        } else {
            $spinner = $this->_toBool($spinner);
        }
        if ($spinner) {
            $component_id = $component->getId();
            $spinner_id = $component_id . '_spinner';
            $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript');
            //setup spinner
            if ($component->hasProperty('spinnerTargetComponent')) {
                $target_component_name = $component->getProperty('spinnerTargetComponent');
                $view_code = $component->getViewCode();
                $component_handler = __ComponentHandlerManager::getInstance()->getComponentHandler($view_code);
                if ($component_handler != null && $component_handler->hasComponent($target_component_name)) {
                    $spinner_target = $component_handler->getComponent($target_component_name)->getId();
                } else {
                    throw __ExceptionFactory::getInstance()->createException('Target spinner component not found: ' . $target_component_name);
                }
            } else {
                if ($component->hasProperty('spinnerTargetElement')) {
                    $spinner_target = $component->getProperty('spinnerTargetElement');
                } else {
                    $spinner_target = $component_id;
                }
            }
            $spinner_target = $javascript_rw->addJsCode($spinner_id . ' = new __Spinner("' . $spinner_target . '");');
            //setup waiting message:
            $waiting_message = $component->waitingMessage;
            if (!empty($waiting_message)) {
                $javascript_rw->addJsCode($spinner_id . '.setWaitingMessage("' . nl2br(stripslashes($waiting_message)) . '");');
            }
            //setup progress bar:
            $show_progress = $this->_toBool($component->showProgress);
            if ($show_progress) {
                $js_code = <<<CODE
var progressHandler = (__ProgressBroadcaster.getInstance()).getProgressHandler("{$component_id}");
if(typeof(progressHandler) != "undefined") {
    progressHandler.registerUiProgressIndicator({$spinner_id});
}
CODE;
                $javascript_rw->addJsCode($js_code);
            }
        }
        return $return_value;
    }
 /**
  * Get the component to be validated by the current validator (if applicable)
  *
  * @return __IValueHolder
  */
 public function getComponentToValidate()
 {
     $return_value = null;
     $component_handler = __ComponentHandlerManager::getInstance()->getComponentHandler($this->_view_code);
     if ($component_handler != null) {
         if ($component_handler->hasComponent($this->_control_to_validate)) {
             $return_value = $component_handler->getComponent($this->_control_to_validate);
             if (!$return_value instanceof __IValueHolder) {
                 throw __ExceptionFactory::getInstance()->createException('Validations are allowed for components implementing __IValueHolder');
             }
         }
     }
     return $return_value;
 }
 /**
  * Set a value for current optionbox. Value is boolean, representing checked optionbox as true.
  *
  * @param bool $value
  */
 public function setValue($value)
 {
     $value = $this->_toBool($value);
     if ($this->_value !== $value) {
         $this->_value = $value;
         if ($value == true && $this->_view_code != null) {
             //will set as false all the option boxes within the same group:
             $component_handler = __ComponentHandlerManager::getInstance()->getComponentHandler($this->_view_code);
             $view_components = $component_handler->getComponents();
             foreach ($view_components as &$view_component) {
                 if ($view_component instanceof __OptionBoxComponent && $view_component->getId() != $this->getId() && $view_component->getGroup() == $this->getGroup()) {
                     $view_component->setValue(false);
                 }
             }
         }
     }
 }
 public function areViewsRestorable()
 {
     $return_value = true;
     //by default we're going to read the view from the cache:
     if (!__AuthenticationManager::getInstance()->isAnonymous()) {
         $return_value = false;
     } else {
         $component_handler_manager = __ComponentHandlerManager::getInstance();
         foreach ($this->_view_codes as $view_code => $dummy) {
             if ($component_handler_manager->hasComponentHandler($view_code) && $component_handler_manager->getComponentHandler($view_code)->isDirty()) {
                 //do not read from the cache if the component handler is dirty
                 $return_value = false;
             }
         }
     }
     return $return_value;
 }
 public function getComponentForErrorReporting()
 {
     $return_value = null;
     if ($this->_report_after_component != null) {
         $component_handler = __ComponentHandlerManager::getInstance()->getComponentHandler($this->_view_code);
         if ($component_handler != null) {
             if ($component_handler->hasComponent($this->_report_after_component, $this->_report_after_component_index)) {
                 $return_value = $component_handler->getComponent($this->_report_after_component, $this->_report_after_component_index);
             } else {
                 throw __ExceptionFactory::getInstance()->createException('Component to use for error reporting not found: ' . $this->_report_after_component);
             }
         }
     }
     return $return_value;
 }
 protected function _generateRemoteServiceCode($method_name, $arguments = array())
 {
     $component_name = $method_name;
     $component_handler = __ComponentHandlerManager::getInstance()->getComponentHandler($this->_event_handler->getViewCode());
     //get the remote_service_writer:
     $remote_service_spec = __ComponentSpecFactory::getInstance()->createComponentSpec('remoteservice');
     $remote_service_spec->setId(substr(md5($this->_view_code . ':' . $method_name), 0, 8));
     $remote_service_writer = $remote_service_spec->getWriter();
     if ($component_handler->hasComponent($component_name)) {
         $remote_service = $component_handler->getComponent($component_name);
     } else {
         $remote_service = __ComponentFactory::getInstance()->createComponent($remote_service_spec);
         $remote_service->setName($component_name);
         foreach ($arguments as $argument_name => $argument_value) {
             $remote_service->{$argument_name} = $argument_value;
         }
         $component_handler->registerComponent($remote_service);
     }
     $remote_service_writer->bindComponentToClient($remote_service);
     $remote_service_writer->startRender($remote_service);
 }
예제 #11
0
 public function free()
 {
     __ComponentHandlerManager::getInstance()->freeComponentHandler($this->getViewCode());
 }
 /**
  * Get the component used to show the slider value
  *
  * @return __LabelComponent|__InputBoxComponent
  */
 public function &getInputReceiver()
 {
     $return_value = null;
     if (__ComponentHandlerManager::getInstance()->hasComponentHandler($this->_view_code)) {
         $component_handler = __ComponentHandlerManager::getInstance()->getComponentHandler($this->_view_code);
         if ($component_handler != null) {
             if ($this->_input_receiver != null) {
                 if ($component_handler->hasComponent($this->_input_receiver)) {
                     $return_value = $component_handler->getComponent($this->_input_receiver);
                     if (!$return_value instanceof __InputBoxComponent && !$return_value instanceof __LabelComponent) {
                         throw __ExceptionFactory::getInstance()->createException('Wrong receiver component class. Only inputbox and labels are allowed, not ' . get_class($return_value));
                     }
                 } else {
                     throw __ExceptionFactory::getInstance()->createException('Input receiver not found: ' . $this->_input_receiver);
                 }
             }
         }
     }
     return $return_value;
 }