/** * This overrides the parent implementation by rendering TForm-specific content. * @return the rendering result. */ public function render() { $body = $this->renderBody(); // render body first in case the contained control generates more JS $name = $this->getUniqueID(); $action = pradoEncodeData($_SERVER['REQUEST_URI']); //is this right? $content = "<form action=\"{$action}\" method=\"post\" enctype=\"multipart/form-data\""; $onsubmit = $this->renderOnSubmitStatements(); if (strlen($onsubmit)) { $content .= " onsubmit=\"{$onsubmit}\""; } $content .= ' ' . $this->renderAttributes() . '>'; $content .= $this->renderHiddenFields(); $content .= $this->renderBeginScripts(); $content .= $this->renderStyleFiles(); $content .= $this->renderScriptFiles(); $content .= $body; $content .= $this->renderArrayScripts(); $content .= $this->renderEndScripts(); $content .= "</form>"; return $content; }
protected function renderBody() { $src = $this->getImageUrl(); $text = $this->isEncodeText() ? pradoEncodeData($this->getText()) : $this->getText(); if (strlen($src)) { return "<img src=\"{$src}\" border=\"0\" title=\"{$text}\"/>"; } else { if (strlen($text)) { return $text; } else { return parent::renderBody(); } } }
/** * This overrides the parent implementation by rendering either <b>Text</b> or the body contents. * @return string the rendering result */ protected function renderBody() { $text = $this->isEncodeText() ? pradoEncodeData($this->getText()) : $this->getText(); return strlen($text) ? $text : parent::renderBody(); }
/** * Get the validation error message. * @return string error message */ protected function getMessage() { $text = $this->getText(); $text = $this->isEncodeText() ? pradoEncodeData($text) : $text; $msg = $this->getErrorMessage(); $msg = $this->getAnchoredMessage($this->isEncodeText() ? pradoEncodeData($msg) : $msg); if (strlen($text)) { return $text; } else { if (strlen($msg)) { return $msg; } else { return $this->renderBody(); } } }
/** * Renders the list as an HTML select element. * @return string the rendering result */ protected function renderBody() { $content = "\n"; $formatString = $this->getDataTextFormatString(); foreach ($this->getItems() as $item) { $text = $item->getText(); if (strlen($formatString)) { $text = sprintf($formatString, $text); } if ($this->isEncodeText()) { $text = pradoEncodeData($text); } $value = $item->getValue(); if ($item->isSelected()) { $content .= '<option value="' . $value . '" selected="selected">' . $text . "</option>\n"; } else { $content .= '<option value="' . $value . '">' . $text . "</option>\n"; } } return $content; }
/** * Get the form action (i.e. where the form is submitted to). * Default is the current request URI. * @return string form action attribute value. */ public function getAction() { return isset($this->action) ? $this->action : pradoEncodeData($_SERVER['REQUEST_URI']); //is this right? }
/** * Renders the text box * @return string the rendering result */ public function render() { if ($this->getTextMode() === 'MultiLine') { $content = '<textarea ' . $this->renderAttributes() . '>'; $content .= $this->isEncodeText() ? pradoEncodeData($this->getText()) : $this->getText(); $content .= '</textarea>'; } else { $content = '<input '; $content .= $this->renderAttributes(); $content .= ' />'; } return $content; }
/** * Renders the body content of the control. * This method overrides the parent's implementation. * @return string the rendering result. */ public function render() { $rendered = parent::render(); $text = $this->isEncodeText() ? pradoEncodeData($this->getText()) : $this->getText(); if (strlen($text)) { $name = $this->getUniqueID(); $label = "<label for=\"{$name}\">{$text}</label>"; if ($this->getTextAlign() == 'Left') { $rendered = $label . $rendered; } else { $rendered = $rendered . $label; } } return $rendered; }
/** * This overrides the parent implementation by rendering more TImage-specific attributes. * @return ArrayObject the attributes to be rendered */ protected function getAttributesToRender() { $attributes = parent::getAttributesToRender(); $attributes['src'] = $this->getImageUrl(); $attributes['border'] = $this->getBorder(); $attributes['alt'] = $this->isEncodeText() ? pradoEncodeData($this->getAlternateText()) : $this->getAlternateText(); $align = $this->getImageAlign(); if (strlen($align)) { $attributes['align'] = $align; } return $attributes; }
/** * Renders the HTMLArea * @return string the rendering result */ public function render() { $text = $this->isEncodeText() ? pradoEncodeData($this->getText()) : $this->getText(); if ($this->isVisualEditEnabled()) { $this->renderJsEditor(); } if ($this->isReadOnly()) { // to disable the server-side text updating $this->setEnabled(false); } $width = $this->getWidth(); if (!strpos($width, '%')) { if ($width < 450) { $width = 450; } // to ensure proper display of visual toolbar $this->setWidth($width . "px"); } $height = $this->getHeight(); if (!strpos($height, '%')) { if ($height < 200) { $height = 200; } $this->setHeight($height . "px"); } return '<textarea ' . $this->renderAttributes() . '>' . $text . '</textarea>'; }
/** * Sets the text of the button using the callback client. * @param string new text value */ public function setText($text) { parent::setText($text); if ($this->Page && $this->Page->IsActiveAction) { $text = $this->isEncodeText() ? pradoEncodeData($text) : $text; $this->Page->CallbackClient->Element->update($this, $text); } }
/** * Renders <b>Text</b> as content. * This method overrides parent's implementation. */ protected function renderBody() { return $this->isEncodeText() ? pradoEncodeData($this->getText()) : $this->getText(); }
/** * This overrides the parent implementation by rendering more TButton-specific attributes. * @return ArrayObject the attributes to be rendered */ protected function getAttributesToRender() { $attributes = parent::getAttributesToRender(); $attributes['type'] = "submit"; $attributes['name'] = $this->getUniqueID(); $attributes['value'] = $this->isEncodeText() ? pradoEncodeData($this->getText()) : $this->getText(); if ($this->causesValidation() && $this->Page->isEndScriptRegistered('TValidator')) { $script = "Prado.Validation.AddTarget('{$this->ClientID}');"; $this->Page->registerEndScript($this->ClientID . 'target', $script); } return $attributes; }
/** * Renders the checkbox list * @return string the rendering result */ public function render() { $attr = $this->renderAttributes(); $id = $this->getUniqueID(); $items = $this->getItems(); $count = $items->length(); $cols = $this->getRepeatColumns(); $rows = $count % $cols == 0 ? $count / $cols : intval($count / $cols) + 1; $postback = $this->isAutoPostBack() ? 'onclick="javascript:' . $this->getPage()->getPostBackClientEvent($this, '') . '"' : ''; $lines = array(); $type = $this->getInputType(); $formatString = $this->getDataTextFormatString(); foreach ($items as $index => $item) { $text = $item->getText(); $value = $item->getValue(); if (strlen($formatString)) { $text = sprintf($formatString, $text); } if ($this->isEncodeText()) { $text = pradoEncodeData($text); } if ($item->isSelected()) { if ($this->isEnabled()) { $input = "<input id=\"{$id}:{$index}\" name=\"{$id}[]\" value=\"{$value}\" type=\"{$type}\" checked=\"checked\" {$postback}/>"; } else { $input = "<input id=\"{$id}:{$index}\" name=\"{$id}[]\" value=\"{$value}\" type=\"{$type}\" disabled=\"disabled\" checked=\"checked\" {$postback}/>"; } } else { if ($this->isEnabled()) { $input = "<input id=\"{$id}:{$index}\" name=\"{$id}[]\" value=\"{$value}\" type=\"{$type}\" {$postback}/>"; } else { $input = "<input id=\"{$id}:{$index}\" name=\"{$id}[]\" value=\"{$value}\" type=\"{$type}\" disabled=\"disabled\" {$postback}/>"; } } $label = !empty($text) ? "<label for=\"{$id}:{$index}\">{$text}</label>" : ""; $lines[] = $this->getTextAlign() === 'Left' ? $label . $input : $input . $label; } $output = array(); if ($this->getRepeatDirection() === 'Vertical') { $n = 0; for ($j = 0; $j < $cols; ++$j) { $r = ($count - $n) % ($cols - $j) == 0 ? ($count - $n) / ($cols - $j) : intval(($count - $n) / ($cols - $j)) + 1; for ($i = 0; $i < $rows; ++$i) { if ($i < $r) { $output[$i][$j] = $lines[$n]; $n++; } else { $output[$i][$j] = ''; } } } } else { for ($i = 0; $i < $rows; ++$i) { for ($j = 0; $j < $cols; ++$j) { $n = $i * $cols + $j; if ($n < $count) { $output[$i][$j] = $lines[$n]; } else { $output[$i][$j] = ''; } } } } if ($this->getRepeatLayout() === 'Table') { $content = "<table {$attr}>\n"; for ($i = 0; $i < $rows; ++$i) { $content .= "<tr>\n"; for ($j = 0; $j < $cols; ++$j) { $content .= "<td>" . $output[$i][$j] . "</td>\n"; } $content .= "</tr>\n"; } $content .= "</table>\n"; } else { $content = "<span {$attr}>"; for ($i = 0; $i < $rows; ++$i) { for ($j = 0; $j < $cols; ++$j) { $content .= $output[$i][$j]; } $content .= "<br/>"; } $content .= "</span>\n"; } return $content; }