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;
 }
 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();
     if ($component->getVisible() == false) {
         $properties[] = 'style = "display : none;"';
     }
     return '<span id="' . $component->getId() . '" ' . 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();
     $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 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;
 }
 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 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;
    }
 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;
 }