public function startRender(__IComponent &$component)
 {
     $properties = array();
     $component_properties = $component->getProperties();
     $style = array();
     foreach ($component_properties as $property => $value) {
         if ($property != 'STYLE') {
             $properties[] = $property . '="' . $value . '"';
         } else {
             $style[] = $value;
         }
     }
     $properties[] = 'id="' . $component->getId() . '"';
     $properties[] = 'name="' . $component->getName() . '"';
     if ($component->getVisible() == false) {
         $style[] = 'display : none;';
     }
     if (count($style > 0)) {
         $style_attribute = 'style = "' . implode('', $style) . '"';
     } else {
         $style_attribute = null;
     }
     $return_value = '<select ' . implode(' ', $properties) . ' ' . $style_attribute . '>';
     return $return_value;
 }
 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() . '"';
     $jod_response_writer = $this->_getJavascriptResponseWriter();
     if ($component->getVisible() == false) {
         $properties[] = 'style = "display : none;"';
     }
     $value = $component->getValue();
     if ($value) {
         $properties[] = 'class="depressed"';
     } else {
         $properties[] = 'class="raised"';
     }
     $width = $component->getWidth();
     $height = $component->getHeight();
     $style = array();
     if ($width != null) {
         $style[] = 'width:' . $width;
     }
     if ($height != null) {
         $style[] = 'height:' . $height;
     }
     $return_value = '<span style="display: inline-block; ' . implode('; ', $style) . '" onclick="toggleButton(this);" ' . implode(' ', $properties) . '>';
     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;
 }
 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();
     $properties[] = 'id = "' . $component->getId() . '"';
     $properties[] = 'name = "' . $component->getName() . '"';
     if ($component->getVisible() == false) {
         $properties[] = 'style = "display : none;"';
     }
     return '<span ' . join(' ', $properties) . '>';
 }
    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)
    {
        $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)
 {
     $properties = array();
     $component_properties = $component->getProperties();
     foreach ($component_properties as $property => $value) {
         $properties[] = $property . '="' . $value . '"';
     }
     $properties[] = 'id="' . $component->getId() . '"';
     $properties[] = 'name="' . $component->getName() . '"';
     if ($component->getVisible() == false) {
         $properties[] = 'style = "display : none;"';
     }
     $return_value = '<textarea ' . implode(' ', $properties) . '>';
     return $return_value;
 }
 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();
     $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;
 }
    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);
            }
        }
    }
 public function startRender(__IComponent &$component)
 {
     $component_id = $component->getId();
     $event_handler = __EventHandlerManager::getInstance()->getEventHandler($component->getViewCode());
     $component_to_validate = $component->getComponentToValidate();
     $component_to_validate_id = $component_to_validate->getId();
     if (__ResponseWriterManager::getInstance()->hasResponseWriter('livevalidation')) {
         $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('livevalidation');
     } else {
         $jod_response_writer = new __JavascriptOnDemandResponseWriter('livevalidation');
         $jod_response_writer->addJsFileRef('livevalidation/livevalidation_1.3.1.js');
         $jod_response_writer->addLoadCheckingVariable('Validate');
         $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript');
         $javascript_rw->addResponseWriter($jod_response_writer);
     }
     $configuration = array('validMessage : ""');
     if ($component->getValidateOnlyOnBlur()) {
         $configuration[] = 'onlyOnBlur: true';
     } else {
         if ($component->getValidateOnlyOnSubmit()) {
             $configuration[] = 'onlyOnSubmit: true';
         } else {
             $configuration[] = 'wait: ' . $component->getWait();
         }
     }
     $report_after_component = $component->getComponentForErrorReporting();
     $report_after_element = $component->getReportAfterElement();
     if ($report_after_component != null) {
         $configuration[] = 'insertAfterWhatNode: "' . $report_after_component->getId() . '"';
     } else {
         if ($report_after_element != null) {
             $configuration[] = 'insertAfterWhatNode: "' . $report_after_element . '"';
         }
     }
     if ($event_handler->isEventHandled('validate', $component_to_validate->getName())) {
         $configuration[] = 'onValid: function() { (__ClientEventHandler.getInstance()).sendEvent("validate", { validationRule : "' . $component_id . '"}, "' . $component_to_validate_id . '", true); }';
     } else {
         if ($event_handler->isEventHandled('validate', $component->getName())) {
             $configuration[] = 'onValid: function() { (__ClientEventHandler.getInstance()).sendEvent("validate", { validationRule : "' . $component_id . '"}, "' . $component_id . '", true); }';
         }
     }
     $on_invalid = $component->getOnInvalid();
     if (!empty($on_invalid)) {
         $configuration[] = 'onInvalid: ' . $on_invalid;
     }
     $js_code = "if(\$(\"{$component_to_validate_id}\")) {\n";
     $js_code .= "if(!window['{$component_id}']) {\n";
     $js_code .= '    window[\'' . $component_id . '\'] = new LiveValidation("' . $component_to_validate_id . '", {' . join(', ', $configuration) . '});' . "\n";
     $js_code .= "} else {\n";
     $js_code .= '    ' . $component_id . '.initialize("' . $component_to_validate_id . '", {' . join(', ', $configuration) . '});' . "\n";
     $js_code .= "}\n";
     $js_code .= $this->_getValidLengthJsPart($component);
     $js_code .= $this->_getValidFormatJsPart($component);
     $js_code .= $this->_getComponentMatchJsPart($component);
     $js_code .= $this->_getMandatoryJsPart($component);
     $js_code .= $this->_getAcceptanceJsPart($component);
     $js_code .= $this->_getShowMessageJsPart($component);
     $js_code .= $this->_getAllowedExtensionsJsPart($component);
     $js_code .= $this->_getNumericalityJsPart($component);
     $js_code .= $this->_getListenValidateEvent($component);
     $js_code .= "}\n";
     $jod_response_writer->addJsCode($js_code);
 }
 /**
  * Register a component as part of the current page
  *
  * @param __IComponent $component The component to register to
  */
 public function registerComponent(__IComponent &$component)
 {
     if ($component instanceof __IPoolable && $component->getPersist()) {
         $names_array =& $this->_component_names;
     } else {
         $names_array =& $this->_non_poolable_component_names;
     }
     if ($component->getIndex() !== null) {
         if (!key_exists($component->getName(), $names_array)) {
             $names_array[$component->getName()] = array();
         } else {
             if (!is_array($names_array[$component->getName()])) {
                 throw __ExceptionFactory::getInstance()->createException('ERR_INDEX_NOT_EXPECTED_FOR_COMPONENT', array($component->getIndex(), $component->getName()));
             }
         }
         $names_array[$component->getName()][$component->getIndex()] = $component->getId();
     } else {
         $names_array[$component->getName()] = $component->getId();
     }
     //set the view code:
     $component->setViewCode($this->_view_code);
     //pool the component:
     __ComponentPool::getInstance()->registerComponent($component);
 }