/**
  * Pools a component. This is a private method calls by the {@link registerComponent} after
  * validating that the component is poolable
  *
  * @param __IComponent $component The component to pool to
  */
 private function _poolComponent(__IComponent &$component)
 {
     $component_id = $component->getId();
     $this->unregisterComponent($component_id);
     $this->_components[$component_id] =& $component;
     __ClientNotificator::getInstance()->setDirty($component);
 }
    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;
    }
 public function startRender(__IComponent &$component)
 {
     $properties = array();
     $component_properties = $component->getProperties();
     foreach ($component_properties as $property => $value) {
         $properties[] = $property . '="' . $value . '"';
     }
     if ($component->getType() != null) {
         $properties[] = 'type="' . $component->getType() . '"';
     } else {
         if ($component->getOnClickSubmit()) {
             $properties[] = 'type="submit"';
         } else {
             $properties[] = 'type="button"';
         }
     }
     $properties[] = 'id="' . $component->getId() . '"';
     $properties[] = 'name="' . $component->getName() . '"';
     $properties[] = 'value="' . htmlentities($component->getCaption()) . '"';
     $image_src = $component->getSrc();
     if ($image_src != null) {
         $properties[] = 'src="' . $image_src . '"';
     }
     if ($component->getVisible() == false) {
         $properties[] = 'style = "display : none;"';
     }
     $return_value = '<input ' . implode(' ', $properties) . '>';
     return $return_value;
 }
    public function startRender(__IComponent &$component)
    {
        $component_callback_url = APP_URL_PATH . $component->getId() . '.ccp';
        $return_value = <<<CODESET
        <img src="{$component_callback_url}" id="{$component_id}">
CODESET;
        return $return_value;
    }
 public function renderContent($enclosed_content, __IComponent &$component)
 {
     $properties = array();
     if ($component->getVisible() == false) {
         $properties[] = 'style = "display : none;"';
     }
     return '<span id="' . $component->getId() . '_caption" ' . join(" ", $properties) . '>' . $component->getCaption() . '</span>';
 }
 public function startRender(__IComponent &$component)
 {
     $properties = array();
     $properties[] = 'id = "' . $component->getId() . '"';
     if ($component->getVisible() == false) {
         $properties[] = 'style = "display : none;"';
     }
     return '<div ' . join(' ', $properties) . '>';
 }
 public function addComponent(__IComponent &$component)
 {
     //protect to infinite recursion
     if (!key_exists($component->getId(), $this->_components)) {
         $this->_components[$component->getId()] =& $component;
         $component->setContainer($this);
     }
     return $this;
 }
    public function startRender(__IComponent &$component)
    {
        $component_id = $component->getId();
        $data = $component->getData();
        $data_json_string = json_encode($data);
        $javascript_code = <<<CODESET
    {$component_id} = {$data_json_string}; 
CODESET;
        $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript');
        $javascript_rw->addJsCode($javascript_code);
        return '';
    }
 public function startRender(__IComponent &$component)
 {
     $properties = array();
     $properties[] = 'id = "' . $component->getId() . '"';
     if ($component->getVisible() == false) {
         $properties[] = 'style = "display : none;"';
     }
     $return_value = '<fieldset ' . $join(' ', $properties) . '">';
     if ($component->getTitle() != null) {
         $return_value .= '<legend>' . $component->getTitle() . '</legend>';
     }
     return $return_value;
 }
 public function renderContent($enclosed_content, __IComponent &$component)
 {
     $group_id = $component->getGroup();
     if ($group_id == null) {
         $group_id = $component->getId();
     }
     if (__ResponseWriterManager::getInstance()->hasResponseWriter($group_id)) {
         $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter($group_id);
     } else {
         $jod_response_writer = new __JavascriptOnDemandResponseWriter($group_id);
         $js_files = $component->getJsFiles();
         foreach ($js_files as $js_file) {
             $jod_response_writer->addJsFileRef($js_file);
         }
         $checking_variables = $component->getCheckingVariables();
         foreach ($checking_variables as $checking_variable) {
             $jod_response_writer->addLoadCheckingVariable($checking_variable);
         }
         $javascript_rw = null;
         if ($component->hasContainer()) {
             $container = $component->getContainer();
             if ($container instanceof __JavascriptComponent) {
                 $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter($container->getId());
             }
         }
         if ($javascript_rw == null) {
             $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript');
         }
         $javascript_rw->addResponseWriter($jod_response_writer);
     }
     $jod_response_writer->setLoadAfterDomLoaded($component->getAfterDomLoaded());
     $jod_response_writer->addJsCode($enclosed_content);
 }
 protected function _doValidation(__IComponent &$component)
 {
     $this->_validation_result = true;
     if ($component instanceof __IValueHolder && $component->getEnabled() && $component->getVisible()) {
         $value = $component->getValue();
         $captcha_image_component = $this->getCaptcha();
         if (!$captcha_image_component->check($value)) {
             $this->setErrorMessage('The code is invalid');
             $this->_validation_result = false;
         }
     }
     if ($this->_validation_result == true) {
         $this->_error_message = null;
     }
     return $this->_validation_result;
 }
 public function renderContent($enclosed_content, __IComponent &$component)
 {
     $return_value = '';
     $component_items = $component->getItems();
     foreach ($component_items as $component_item) {
         $return_value .= '<option value="' . htmlentities($component_item->getValue()) . '"';
         if ($component_item->getSelected()) {
             $return_value .= ' selected="selected"';
         }
         $properties = array();
         $component_item_properties = $component_item->getProperties();
         foreach ($component_item_properties as $property => $value) {
             $properties[] = $property . '="' . $value . '"';
         }
         $return_value .= ' ' . implode(' ', $properties) . '>' . $component_item->getText() . '</option>';
     }
     return $return_value;
 }
 public function canRenderChildrenComponents(__IComponent &$component)
 {
     $return_value = false;
     $permission_id = $component->getPermission();
     $condition = $component->getCondition();
     if (__PermissionManager::getInstance()->hasPermission($permission_id)) {
         $permission = __PermissionManager::getInstance()->getPermission($permission_id);
         if ($condition == __ProtectedSectionComponent::IF_HAS_PERMISSION && __AuthorizationManager::getInstance()->hasPermission($permission)) {
             $return_value = true;
         } else {
             if ($condition == __ProtectedSectionComponent::IF_NOT_HAS_PERMISSION && !__AuthorizationManager::getInstance()->hasPermission($permission)) {
                 $return_value = true;
             }
         }
     } else {
         throw __ExceptionFactory::getInstance()->createException('Unknow permission id: ' . $permission_id);
     }
     return $return_value;
 }
 public function startRender(__IComponent &$component)
 {
     $component_id = $component->getId();
     $component_properties = $component->getProperties();
     foreach ($component_properties as $property => $value) {
         $property = strtolower($property);
         if ($property != 'runat') {
             $properties[] = $property . '="' . $value . '"';
         }
     }
     $properties[] = 'id="' . $component_id . '"';
     $properties[] = 'name="' . $component->getName() . '"';
     $properties[] = 'action = "' . __UriContainerWriterHelper::resolveUrl($component) . '"';
     $properties[] = 'method="' . strtoupper($component->getMethod()) . '"';
     if ($component->getVisible() == false) {
         $properties[] = 'style = "display : none;"';
     }
     $url = __FrontController::getInstance()->getRequest()->getUrl();
     $encoded_url = base64_encode(serialize($url));
     $form_code = '<form ' . join(' ', $properties) . ' onSubmit="return (__ClientEventHandler.getInstance()).handleSubmit(this);">' . "\n";
     $request_submit_code = __ContextManager::getInstance()->getApplicationContext()->getPropertyContent('REQUEST_SUBMIT_CODE');
     $form_code .= '<input type="HIDDEN" name="' . $request_submit_code . '" value="' . $component_id . '"></input>' . "\n";
     $form_code .= '<input type="HIDDEN" name="viewCode" value="' . $encoded_url . '"></input>' . "\n";
     $flow_executor = __FlowExecutor::getInstance();
     if ($flow_executor->hasActiveFlowExecution()) {
         $active_flow_execution = $flow_executor->getActiveFlowExecution();
         $request_flow_execution_key = __ApplicationContext::getInstance()->getPropertyContent('REQUEST_FLOW_EXECUTION_KEY');
         $form_code .= '<input type="HIDDEN" name="' . $request_flow_execution_key . '" value="' . $active_flow_execution->getId() . '"></input>' . "\n";
         $current_state = $active_flow_execution->getCurrentState();
         if ($current_state != null) {
             $request_flow_state_id = __ApplicationContext::getInstance()->getPropertyContent('REQUEST_FLOW_STATE_ID');
             $form_code .= '<input type="HIDDEN" name="' . $request_flow_state_id . '" value="' . $current_state->getId() . '"></input>' . "\n";
         }
     }
     $hidden_parameters = $component->getHiddenParameters();
     foreach ($hidden_parameters as $hidden_parameter_name => $hidden_parameter_value) {
         if (strtoupper($hidden_parameter_name) != strtoupper($request_submit_code) && strtoupper($hidden_parameter_name) != 'CLIENTENDPOINTVALUES') {
             $form_code .= '<input type="HIDDEN" name="' . $hidden_parameter_name . '" value="' . htmlentities($hidden_parameter_value) . '"></input>' . "\n";
         }
     }
     return $form_code;
 }
 private function _getComponentSetupCommands(__IComponent &$component)
 {
     $return_value = array();
     //update client end-point with current component state:
     $component->updateClient();
     //get all commands from client end-points
     $binding_codes = $component->getBindingCodes();
     foreach ($binding_codes as $binding_code) {
         $ui_binding = __UIBindingManager::getInstance()->getUIBinding($binding_code);
         if ($ui_binding != null) {
             $command = $ui_binding->getClientEndPoint()->getSetupCommand();
             if ($command != null) {
                 $return_value[] = $command;
             }
         }
     }
     $handled_events = __EventHandlerManager::getInstance()->getEventHandler($component->getViewCode())->getComponentHandledEvents($component->getName());
     foreach ($handled_events as $handled_event) {
         if ($handled_event != 'submit') {
             $command = new __AsyncMessageCommand();
             $command->setClass('__RegisterEventListenerCommand');
             $command->setData(array('element' => $component->getId(), 'event' => $handled_event));
             $return_value[] = $command;
         }
     }
     return $return_value;
 }
    public function startRender(__IComponent &$component)
    {
        $properties = array();
        $component_id = $component->getId();
        $date_format = $component->getDateFormat();
        $datebox_button_id = $component_id . '_calbutton';
        if (__ResponseWriterManager::getInstance()->hasResponseWriter('datebox')) {
            $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('datebox');
            $jod_setup_response_writer = $jod_response_writer->getResponseWriter('datebox-setup');
        } else {
            $jod_response_writer = new __JavascriptOnDemandResponseWriter('datebox');
            $jod_response_writer->addCssFileRef('jscalendar/calendar-green.css');
            $jod_response_writer->addJsFileRef('jscalendar/calendar.js');
            $jod_response_writer->addLoadCheckingVariable('Calendar');
            $jod_language_response_writer = new __JavascriptOnDemandResponseWriter('datebox-language');
            $jod_language_response_writer->addJsFileRef('jscalendar/lang/calendar-en.js');
            $jod_language_response_writer->addLoadCheckingVariable('Calendar._DN');
            $jod_response_writer->addResponseWriter($jod_language_response_writer);
            $jod_setup_response_writer = new __JavascriptOnDemandResponseWriter('datebox-setup');
            $jod_setup_response_writer->addJsFileRef('jscalendar/calendar-setup.js');
            $jod_setup_response_writer->addLoadCheckingVariable('Calendar.setup');
            $jod_language_response_writer->addResponseWriter($jod_setup_response_writer);
            $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript');
            $javascript_rw->addResponseWriter($jod_response_writer);
        }
        $js_code = <<<CODESET
Calendar.setup({
\tinputField:"{$component_id}",
\tifFormat:"{$date_format}",
\tbutton:"{$datebox_button_id}",
\tshowsTime:false
});
CODESET;
        $jod_setup_response_writer->addJsCode($js_code);
        $component_properties = $component->getProperties();
        foreach ($component_properties as $property => $value) {
            $properties[] = $property . '="' . $value . '"';
        }
        $properties[] = 'type="text"';
        $properties[] = 'id="' . $component->getId() . '"';
        $properties[] = 'name="' . $component->getName() . '"';
        $properties[] = 'value="' . $component->getValue() . '"';
        if ($component->getVisible() == false) {
            $properties[] = 'style = "display : none;"';
        }
        $local_js_lib = __ApplicationContext::getInstance()->getPropertyContent('JS_LIB_DIR');
        $calendar_image_url = __UrlHelper::resolveUrl('jscalendar/calendar.gif', $local_js_lib);
        $return_value = '<input onchange="this.fire(\'lion:validate\');" ' . implode(' ', $properties) . '>&nbsp;<input type="image" src="' . $calendar_image_url . '"  id="' . $datebox_button_id . '" width="16" height="16" border="0">';
        return $return_value;
    }
    public function startRender(__IComponent &$component)
    {
        $component_id = $component->getId();
        $properties = array();
        $component_properties = $component->getProperties();
        foreach ($component_properties as $property => $value) {
            $property = strtolower($property);
            if ($property != 'runat') {
                $properties[] = $property . '="' . $value . '"';
            }
        }
        if (!key_exists('TYPE', $component_properties)) {
            $properties[] = 'type="text"';
        }
        $properties[] = 'id="' . $component_id . '"';
        $properties[] = 'name="' . $component->getName() . '"';
        $value = $component->getValue();
        $example_value = $component->getExampleValue();
        if (!empty($value)) {
            $properties[] = 'value="' . htmlentities($value) . '"';
        } else {
            if (!empty($example_value)) {
                $properties[] = 'value="' . htmlentities($example_value) . '"';
            }
        }
        if ($component->getVisible() == false) {
            $properties[] = 'style = "display : none;"';
        }
        $return_value = '<input ' . implode(' ', $properties) . '>';
        if (!empty($example_value)) {
            if (__ResponseWriterManager::getInstance()->hasResponseWriter('examplevalues')) {
                $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('examplevalues');
            } else {
                $jod_response_writer = new __JavascriptOnDemandResponseWriter('examplevalues');
                $js_code = <<<CODE
function hideExampleValue(event){
    var formfield = Event.element(event);
    var exampleValue = (\$A(arguments)).last();
    if (formfield.value == exampleValue) {
        formfield.value = "";
    }
}     
CODE;
                $jod_response_writer->addJsCode($js_code);
                $jod_response_writer->setLoadAfterDomLoaded(true);
                $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript');
                $javascript_rw->addResponseWriter($jod_response_writer);
            }
            $js_code = "Event.observe('{$component_id}', 'focus', hideExampleValue.bindAsEventListener(\$({$component_id}), '{$example_value}'));\n";
            $jod_response_writer->addJsCode($js_code);
        }
        return $return_value;
    }
 public function startRender(__IComponent &$component)
 {
     if ($component instanceof __ICompositeComponent) {
         $return_value = null;
         $component_id = $component->getId();
         $view = $this->createView();
         if ($view instanceof __IView) {
             //set the view code as the component identifier:
             $view->setCode($component_id);
             $event_handler = null;
             if (!__EventHandlerManager::getInstance()->hasEventHandler($component_id)) {
                 $event_handler_class = $view->getEventHandlerClass();
                 if ($event_handler_class != null) {
                     $event_handler = new $event_handler_class();
                     if ($event_handler instanceof __ICompositeComponentEventHandler) {
                         //set the view code:
                         $event_handler->setViewCode($component_id);
                         //relate the component with the event handler:
                         $event_handler->setCompositeComponent($component);
                         $component->setEventHandler($event_handler);
                         __EventHandlerManager::getInstance()->addEventHandler($event_handler);
                     } else {
                         throw __ExceptionFactory::getInstance()->createException('Event handler associated to a composite components must implement __ICompositeComponentEventHandler. ' . get_class($event_handler) . ' class does not implement this interface');
                     }
                 }
             }
             //assign the component to the view:
             $this->_assignComponentToView($view, $component);
             //execute the view to render the component:
             $return_value = $view->execute();
         }
         $component->setContent($return_value);
         return '<span id="' . $component_id . '">' . $return_value . '</span>';
     } else {
         throw __ExceptionFactory::getInstance()->createException(get_class($component) . ' class not expected, but an instance of a class implementing __ICompositeComponent.');
     }
 }
    public function startRender(__IComponent &$component)
    {
        $component_id = $component->getId();
        $component_name = $component->getName();
        if (!__ResponseWriterManager::getInstance()->hasResponseWriter('remoteservicedeclarations_' . $component_name)) {
            $send_event_parameters = array();
            $send_event_parameters[] = "'remotecall'";
            $send_event_parameters[] = "arg";
            $send_event_parameters[] = "'{$component_id}'";
            $send_event_parameters = join(', ', $send_event_parameters);
            //generate the remote service function:
            $js_code = <<<CODESET
{$component_name} = function() {
    var arg = \$A({$component_name}.arguments);
    (__ClientEventHandler.getInstance()).sendEvent({$send_event_parameters});   
};
CODESET;
            $jod_response_writer2 = new __JavascriptOnDemandResponseWriter('remoteservicedeclarations_' . $component_name);
            $jod_response_writer2->addJsCode($js_code);
            $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript');
            $javascript_rw->addResponseWriter($jod_response_writer2);
            //generate the callback code (if applicable)
            $callback = $component->getClientResponseCallback();
            if ($callback != null) {
                $js_callback_code = "{$component_id} = new __ResponseCallbackHandler({$callback});";
                if (__ResponseWriterManager::getInstance()->hasResponseWriter('remoteservicecallback')) {
                    $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('remoteservicecallback');
                } else {
                    $jod_response_writer = new __JavascriptOnDemandResponseWriter('remoteservicecallback');
                }
                $jod_response_writer->addJsCode($js_callback_code);
                $jod_response_writer->setLoadAfterDomLoaded(true);
                $javascript_rw->addResponseWriter($jod_response_writer);
            }
        }
    }
 /**
  * Add a child component to current one. 
  * 
  * If a {@link __ItemComponent} instance is received, it will also be added to the item list
  *
  * @param __IComponent &$component The component to add to
  * @return __ItemListComponent A reference to the current component
  */
 public function addComponent(__IComponent &$component)
 {
     if ($component instanceof __ItemComponent && !key_exists($component->getId(), $this->_components)) {
         if (count($this->_items) == 0 && $this->_selection_mode == self::SELECTION_MODE_SINGLE) {
             $component->setSelected(true);
         }
         $this->_items[$component->getId()] =& $component;
         $this->_to_sort = true;
         if ($component->isSelected()) {
             $this->setSelectedItem($component);
         }
         return parent::addComponent($component);
     }
 }
 public function startRender(__IComponent &$component)
 {
     $properties = array();
     $component_properties = $component->getProperties();
     foreach ($component_properties as $property => $value) {
         $properties[] = $property . '="' . $value . '"';
     }
     $properties[] = 'id="' . $component->getId() . '"';
     $properties[] = 'name="' . $component->getName() . '"';
     $properties[] = 'size="' . $component->getRows() . '"';
     if ($component->getSelectionMode() == __ItemListComponent::SELECTION_MODE_MULTIPLE) {
         $properties[] = 'multiple="yes"';
     }
     if ($component->getVisible() == false) {
         $properties[] = 'style = "display : none;"';
     }
     $return_value = '<select ' . implode(' ', $properties) . '>';
     return $return_value;
 }
    public function startRender(__IComponent &$component)
    {
        $component_id = $component->getId();
        if (__ResponseWriterManager::getInstance()->hasResponseWriter('uploadfile')) {
            $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('uploadfile');
        } else {
            $jod_response_writer = new __JavascriptOnDemandResponseWriter('uploadfile');
            $jod_response_writer->setLoadAfterDomLoaded(true);
            $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript');
            $javascript_rw->addResponseWriter($jod_response_writer);
        }
        $jod_response_writer->addJsCode($component_id . ' = new __FileUploader($("' . $component_id . '"));' . "\n");
        if ($component->getStatus() == __IUploaderComponent::UPLOAD_STATUS_DONE) {
            $filename = $component->getFilename();
            $icon = $component->getIcon();
            if ($icon != null) {
                $filename = "<img src='{$icon}' width='32' height='32' valign='absmiddle'>&nbsp;" . $filename;
            }
            $jod_response_writer->addJsCode($component_id . '.renderAsUploaded("' . $filename . '");');
        }
        $properties = array();
        $component_properties = $component->getProperties();
        foreach ($component_properties as $property => $value) {
            $properties[] = $property . '="' . $value . '"';
        }
        $properties[] = 'type = "file"';
        $properties[] = 'id = "' . $component_id . '"';
        $properties[] = 'name = "' . $component_id . '"';
        if ($component->getVisible() == false) {
            $properties[] = 'style = "display : none;"';
        }
        $input_file_properties = implode(' ', $properties);
        $return_value = <<<CODE
    <input type="file" {$input_file_properties}>
CODE;
        return $return_value;
    }
示例#23
0
 public function setComponent(__IComponent &$component)
 {
     $this->_component_id = $component->getId();
 }
 /**
  * Will render error message (if any) instead of delegating on async message commands 
  * to avoid race conditions
  *
  * @param __IComponent $component
  * @return string
  */
 public function _getShowMessageJsPart(__IComponent &$component)
 {
     $return_value = '';
     $error_message = $component->getErrorMessage();
     if (!empty($error_message)) {
         $return_value .= 'new __ShowValidationErrorCommand("' . $error_message . '", "' . $component->getId() . '").execute();' . "\n";
     }
     return $return_value;
 }
 public function renderContent($enclosed_content, __IComponent &$component)
 {
     return $component->getCaption();
 }
 protected function _doValidation(__IComponent &$component)
 {
     $this->_validation_result = true;
     if ($component instanceof __IValueHolder && $component->getEnabled() && $component->getVisible()) {
         $value = $component->getValue();
         $trimmed_value = trim($value);
         $component_to_match = $this->getComponentToMatch();
         //check file size (if applicable):
         $error_file_size = false;
         $max_file_size = $this->getMaxFileSize();
         if ($max_file_size !== null) {
             if ($component instanceof __IUploaderComponent) {
                 $size = $component->getSize();
                 if ($size !== null && $max_file_size < $size) {
                     $error_file_size = true;
                 }
             } else {
                 throw __ExceptionFactory::getInstance()->createException('Can not validate file size on a non uploader component (not implementing the __IUploaderComponent): ' . get_class($component));
             }
         }
         if ($error_file_size) {
             $component->setStatus(__IUploaderComponent::UPLOAD_STATUS_ERROR);
             $exceded_size = $size - $max_file_size;
             $this->setErrorMessage('Maximum file size (' . $this->_getPrintableSize($max_file_size) . ') exceded by ' . $this->_getPrintableSize($exceded_size));
             $this->_validation_result = false;
         } else {
             if ($component_to_match instanceof __IValueHolder && trim($component_to_match->getValue()) !== $trimmed_value) {
                 print "[" . trim($component_to_match->getValue()) . "] - [" . $trimmed_value . ']';
                 $this->setErrorMessage(__ResourceManager::getInstance()->getResource('ERR_FIELD_MUST_MATCH')->setParameters(array($component->getAlias(), $component_to_match->getAlias()))->getValue());
                 $this->_validation_result = false;
             } else {
                 if (strlen($trimmed_value) == 0 && $this->getMandatory()) {
                     $this->setErrorMessage(__ResourceManager::getInstance()->getResource('ERR_REQUIRED_FIELD')->setParameters(array($component->getAlias()))->getValue());
                     $this->_validation_result = false;
                 } else {
                     if ($this->getValidLength() != null && strlen($value) != $this->getValidLength()) {
                         $this->setErrorMessage(__ResourceManager::getInstance()->getResource('ERR_INVALID_LENGTH')->setParameters(array($component->getAlias(), $this->getValidLength()))->getValue());
                         $this->_validation_result = false;
                     } else {
                         if ($this->getMinLength() != null && strlen($value) < $this->getMinLength()) {
                             $this->setErrorMessage(__ResourceManager::getInstance()->getResource('ERR_TOO_SHORT_VALUE')->setParameters(array($component->getAlias(), $this->getMinLength()))->getValue());
                             $this->_validation_result = false;
                         } else {
                             if ($this->getMaxLength() != null && strlen($value) > $this->getMaxLength()) {
                                 $this->setErrorMessage(__ResourceManager::getInstance()->getResource('ERR_TOO_LONG_VALUE')->setParameters(array($component->getAlias(), $this->getMaxLength()))->getValue());
                                 $this->_validation_result = false;
                             } else {
                                 if (!empty($value) && $this->getPattern() != null && !preg_match("/" . $this->getPattern() . "/i", $value)) {
                                     $this->setErrorMessage(__ResourceManager::getInstance()->getResource('ERR_INVALID_VALUE')->setParameters(array($component->getAlias()))->getValue());
                                     $this->_validation_result = false;
                                 } else {
                                     if ($this->getAcceptance() && !$value) {
                                         $this->setErrorMessage(__ResourceManager::getInstance()->getResource('ERR_MUST_BE_ACCEPTED'));
                                         $this->_validation_result = false;
                                     } else {
                                         if (!empty($value) && $this->getOnlyInteger() && !is_numeric($value)) {
                                             $this->setErrorMessage('Must be integer');
                                             $this->_validation_result = false;
                                         } else {
                                             if (!empty($value) && $this->getSpecificNumber() !== null && $value != $this->getSpecificNumber()) {
                                                 $this->setErrorMessage('Must be ' . $this->getSpecificNumber());
                                                 $this->_validation_result = false;
                                             } else {
                                                 if (!empty($value) && $this->getMinimumNumber() !== null && $value < $this->getMinimumNumber()) {
                                                     $this->setErrorMessage('Must not be less than ' . $this->getMinimumNumber());
                                                     $this->_validation_result = false;
                                                 } else {
                                                     if (!empty($value) && $this->getMaximumNumber() !== null && $value > $this->getMaximumNumber()) {
                                                         $this->setErrorMessage('Must not be more than ' . $this->getMaximumNumber());
                                                         $this->_validation_result = false;
                                                     } else {
                                                         if (!empty($value) && $this->getAllowedExtensions() != null && !preg_match('/\\.(' . join('|', $this->getAllowedExtensions()) . ')$/i', $value)) {
                                                             $component->setStatus(__IUploaderComponent::UPLOAD_STATUS_ERROR);
                                                             $this->setErrorMessage('Invalid file type. Expected extensions: ' . join(', ', $this->getAllowedExtensions()));
                                                             $this->_validation_result = false;
                                                         } else {
                                                             $event_handler = __EventHandlerManager::getInstance()->getEventHandler($this->_view_code);
                                                             if ($event_handler->isEventHandled('validate', $this->_component)) {
                                                                 $ui_event = new __UIEvent('validate', array('validationRule' => $this->getId()), $component);
                                                                 if ($event_handler->handleEvent($ui_event) === false) {
                                                                     $this->_validation_result = false;
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($this->_validation_result == true) {
         $this->_error_message = null;
     }
     return $this->_validation_result;
 }
 protected function _isComponentBeingCreated(__IComponent &$component)
 {
     return key_exists($component->getId(), $this->_created_components);
 }
 /**
  * Sets as dirty a given component, which will be checked for client notifications
  *
  * @param __IComponent $component
  */
 public function setDirty(__IComponent &$component)
 {
     $this->_dirty_components[$component->getId()] =& $component;
 }
    public function startRender(__IComponent &$component)
    {
        if (__ResponseWriterManager::getInstance()->hasResponseWriter('sliderjscode')) {
            $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('sliderjscode');
        } else {
            $jod_response_writer = new __JavascriptOnDemandResponseWriter('sliderjscode');
            $jod_response_writer->addJsFileRef('scriptaculous/src/slider.js');
            $jod_response_writer->addLoadCheckingVariable('Control');
            $jod_response_writer->addLoadCheckingVariable('Control.Slider');
            $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript');
            $javascript_rw->addResponseWriter($jod_response_writer);
        }
        $component_id = $component->getId();
        $handle = $component_id . '_handle';
        $track = $component_id . '_track';
        $initial_value = $component->getValue();
        $input_receiver = $component->getInputReceiver();
        $decimals = $component->getDecimals();
        if ($decimals > 0) {
            $v = 'Math.round(v*1' . str_pad('', $decimals, '0') . ')/1' . str_pad('', $decimals, '0');
        } else {
            $v = 'Math.round(v)';
        }
        $onreceiver_keyup_js = '';
        $onslide_js = '';
        if ($input_receiver != null) {
            $input_receiver_id = $input_receiver->getId();
            $onslide_js = '';
            if ($input_receiver instanceof __InputBoxComponent) {
                $onslide_js = 'onSlide: function(v) { $(\'' . $input_receiver_id . '\').value = ' . $v . '; },';
                $onreceiver_keyup_js = <<<CODE

            \$("{$input_receiver_id}").onKeyUp = function() {
                var value = \$("{$input_receiver_id}").value;
                if (value == '') return;
                if (isNaN(value))
                    \$('{$component_id}').setValue(0);
                else
                    \$('{$component_id}').setValue(value);
            }                
                
CODE;
            } else {
                if ($input_receiver instanceof __LabelComponent) {
                    $onslide_js = 'onSlide: function(v) { $(\'' . $input_receiver_id . '\').update(' . $v . '); },';
                }
            }
        }
        $lower_limit = $component->getLowerLimit();
        $upper_limit = $component->getUpperLimit();
        $axis = $component->getAxis();
        $js_code = <<<CODE

        window['{$component_id}'] = new Control.Slider("{$handle}", "{$track}", {
                {$onslide_js}
                onChange: function(v) { (__ClientEventHandler.getInstance()).sendEvent("change", {}, "{$component_id}"); },
                range: \$R({$lower_limit},{$upper_limit}),
                sliderValue: {$initial_value},
                axis: "{$axis}"
        });
        {$onreceiver_keyup_js}  
        
CODE;
        $jod_response_writer->addJsCode($js_code);
        $width = $component->getWidth();
        $height = $component->getHeight();
        $handle_width = $component->getHandleWidth();
        $handle_height = $component->getHandleHeight();
        $track_css_class = $component->getTrackCssClass();
        $left_track_css_class = $component->getLeftTrackCssClass();
        $handle_img = $component->getHandleImg();
        if (empty($track_css_class)) {
            $track_style = 'style="width:' . $width . '; background-color:#ccc; height: ' . $height . ';"';
        } else {
            $track_style = 'class="' . $track_css_class . '"';
        }
        if (empty($handle_img)) {
            $handle_style = 'style="width:' . $handle_width . '; height:' . $handle_height . ';background-color:#f00; cursor:move;"';
        } else {
            $handle_style = 'style="width:' . $handle_width . '; height:' . $handle_height . ';"';
        }
        $return_value = <<<CODE
        <div id="{$component_id}" style="width:{$width}; height: {$handle_height};">
        <div {$track_style} id="{$track}" style="width:{$width}; height:{$height};">
            <div class="{$left_track_css_class}"></div><div id="{$handle}" {$handle_style}><img src="{$handle_img}" alt="" style="float: left;" /></div>
        </div>            
        </div>
CODE;
        return $return_value;
    }
    public function endRender(__IComponent &$component)
    {
        $component_id = $component->getId();
        $return_value = $this->_component_writer->endRender($component);
        $context_help = $component->getContextHelp();
        if (!empty($context_help)) {
            if (__ResponseWriterManager::getInstance()->hasResponseWriter('formcontexthelp')) {
                $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('formcontexthelp');
            } else {
                $jod_response_writer = new __JavascriptOnDemandResponseWriter('formcontexthelp');
                $jod_response_writer->addCssFileRef('formcontexthelp/formcontexthelp.css');
                $jod_response_writer->addJsFileRef('formcontexthelp/formcontexthelp.js');
                $jod_response_writer->addLoadCheckingVariable('prepareInputsForHints');
                $jod_response_writer->addJsCode("\nprepareInputsForHints();\n");
                $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript');
                $javascript_rw->addResponseWriter($jod_response_writer);
            }
            $return_value .= '<span id="' . $component_id . '_contextHelp" class="hint" style="display: none;">' . $context_help . '<span id="' . $component_id . '_contextHelpPointer" class="hint-pointer" style="display: none;">&nbsp;</span></span>';
        }
        $example = str_replace("'", "\\'", $component->getExample());
        if (!empty($example)) {
            if (__ResponseWriterManager::getInstance()->hasResponseWriter('inputexamples')) {
                $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('inputexamples');
            } else {
                $jod_response_writer = new __JavascriptOnDemandResponseWriter('inputexamples');
                $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript');
                $javascript_rw->addResponseWriter($jod_response_writer);
                $code = <<<CODESET
                
window['showAllExamples'] = function() {
    \$\$('input').each(function(inputElement) {
        showExampleValueOnInput(inputElement);
    });
};
           
var showExampleValueOnInput = function(input) {
  if(input['exampleValue']) {
      input.onfocus = function () {
          if(input.exampleValue == input.value) {
              if(input.originalType == 'password') {
                  input.type = 'password';
              }
              input.value = '';
              input.style.color = '';
          }
      }
      input.onblur = function () {
          if(input.value == '') {
              if(input.type == 'password') {
                  input.originalType = 'password';
                  input.type = 'text';
              }
              input.value = input.exampleValue;
              input.style.color = '#858585';
          }
      }
      
      if(input.value == '') {
          if(input.type == 'password') {
              input.originalType = 'password';
              input.type = 'text';
          }
          input.value = input.exampleValue;
      }
      if(input.value == input.exampleValue) {
          if(input.type == 'password') {
              input.originalType = 'password';
              input.type = 'text';
          }
          input.style.color = '#858585';
      }
  }  
};
CODESET;
                $jod_response_writer->addJsCode($code);
            }
            $code = <<<CODESET
var {$component_id} = \$('{$component_id}'); 
{$component_id}.exampleValue = '{$example}';
showExampleValueOnInput({$component_id});
CODESET;
            $jod_response_writer->addJsCode($code);
        }
        $mask = $component->getMask();
        if (!empty($mask)) {
            if (__ResponseWriterManager::getInstance()->hasResponseWriter('inputmask')) {
                $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('inputmask');
            } else {
                $jod_response_writer = new __JavascriptOnDemandResponseWriter('inputmask');
                $jod_response_writer->addJsFileRef('inputmask/inputmask.js');
                $jod_response_writer->addLoadCheckingVariable('__InputMask');
                $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript');
                $javascript_rw->addResponseWriter($jod_response_writer);
            }
            $jod_response_writer->addJsCode("(__InputMask.getInstance()).addMask(\"{$component_id}\", \"{$mask}\");\n");
        }
        return $return_value;
    }