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) { $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) . '> <input type="image" src="' . $calendar_image_url . '" id="' . $datebox_button_id . '" width="16" height="16" border="0">'; 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->getGroup() . '"'; if ($component->getValue() === true) { $properties[] = 'checked = "checked"'; } if ($component->getVisible() == false) { $properties[] = 'style = "display : none;"'; } $return_value = '<input type="RADIO" ' . implode(' ', $properties) . '>'; return $return_value; }
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; }
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; }
public function renderContent($enclosed_content, __IComponent &$component) { return $component->getValue(); }