Example #1
0
 function renderElement()
 {
     $optionHtml = "";
     $elementValue = $this->getValue();
     if (!$this->defaultValue && $this->blankMessage) {
         $optionHtml .= sfl("<option value='' >%s</option>", $this->blankMessage);
     } elseif ($this->defaultValue) {
         // TODO: put this in a func...
         foreach ($this->defaultValue as $value => $option) {
             if (strval($elementValue) == strval($value)) {
                 $optionHtml .= sfl("<option value='%s' selected='selected'>%s</option>", $value, $option);
             } else {
                 $optionHtml .= sfl("<option value='%s'>%s</option>", $value, $option);
             }
         }
     }
     foreach ($this->options as $value => $option) {
         if (strval($elementValue) == strval($value)) {
             $optionHtml .= sfl("<option value='%s' selected='selected'>%s</option>", $value, $option);
         } else {
             $optionHtml .= sfl("<option value='%s'>%s</option>", $value, $option);
         }
     }
     return sfl("<select name='%s' %s id='form_%s' class='inputSelect'>%s</select>", $this->getName(), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName(), $optionHtml);
 }
 function renderElement()
 {
     $address = $this->getValue();
     if (!is_array($address)) {
         $address = array();
     }
     if (!array_key_exists('address1', $address)) {
         $address['address1'] = null;
     }
     if (!array_key_exists('address2', $address)) {
         $address['address2'] = null;
     }
     if (!array_key_exists('postcode', $address)) {
         $address['postcode'] = null;
     }
     if (!array_key_exists('town', $address)) {
         $address['town'] = null;
     }
     /*
      * The rendering of this element is SO messy due to IE compatibility - needs rewriting
      *
      */
     $out = sf("<div style='float:left;'><input type='text' name='%s[address1]' value='%s' %s id='form_%s' class='inputUkAddress inputUkAddress1' /><br />", $this->getName(), parent::makeInputSafe($address['address1']), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName());
     $out .= sf("<input type='text' name='%s[address2]' value='%s' %s id='form_%s' class='text' class='inputUkAddress inputUkAddress2' /><br />", $this->getName(), parent::makeInputSafe($address['address2']), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName());
     $out .= sf("</div><div style='clear:both;'><label for='form_%s'>%s</label>", $this->getName(), "Post Code");
     $out .= sfl("<table style='border:0px; border-spacing:0px;.' cellpadding=0 cellspacing=0><tr><td style=''><input type='text' name='%s[postcode]' value='%s' %s id='form_%s' class='postCode'  class='inputUkAddress inputUkAddressPostCode'  />", $this->getName(), parent::makeInputSafe($address['postcode']), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName());
     $out .= sfl("</td><td class='tRight'><label class='town'>Town</label></td><td><input type='text' name='%s[town]' value='%s' %s id='form_%s' class='town'  class='inputUkAddress inputUkAddressTown' /></td></tr></table></div>", $this->getName(), parent::makeInputSafe($address['town']), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName());
     return $out;
 }
 public function render()
 {
     $out = $this->preRender();
     $out .= sfl('<div class="row%s%s">%s</div>', $this->style ? " " . $this->style : "", $this->submitted && !$this->validates ? " error" : "", $this->renderElement());
     $out .= $this->postRender();
     return $out;
 }
Example #4
0
 function renderElement()
 {
     $name = $this->getValue();
     if (!is_array($name)) {
         $name = array();
     }
     if (!array_key_exists('title', $name)) {
         $name['title'] = null;
     }
     if (!array_key_exists('firstName', $name)) {
         $name['firstName'] = null;
     }
     if (!array_key_exists('lastName', $name)) {
         $name['lastName'] = null;
     }
     $titleOptions = sfl("<option value='' >Title</option>");
     foreach ($this->titles as $title => $data) {
         if ($name['title'] == $title) {
             $titleOptions .= sfl("<option value='%s' selected='selected'>%s</option>", parent::makeInputSafe($title), $data['text']);
         } else {
             $titleOptions .= sfl("<option value='%s'>%s</option>", parent::makeInputSafe($title), $data['text']);
         }
     }
     $out = sfl("<select name='%s[title]' %s id='form_%s' class='inputName inputNameTitle' >%s</select>", $this->getName(), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName(), $titleOptions);
     $out .= sfl("<input type='text' name='%s[firstName]' value='%s' %s id='form_%s' class='inputName inputNameFirst' class='text' />", $this->getName(), parent::makeInputSafe($name['firstName']), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName());
     $out .= sfl("<input type='text' name='%s[lastName]' value='%s' %s id='form_%s' class='inputName inputNameLast' class='text' />", $this->getName(), parent::makeInputSafe($name['lastName']), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName());
     return $out;
 }
 function renderElement()
 {
     $date = $this->getValue();
     $minValue = is_array($date) && array_key_exists('min', $date) ? $date['min'] : null;
     $maxValue = is_array($date) && array_key_exists('max', $date) ? $date['max'] : null;
     $minOptions = sfl("<option value='' >Any</option>");
     for ($i = $this->ageMin; $i <= $this->ageMax; $i++) {
         // TODO: Bug here days don't always return the correct number of days...
         if ($minValue == $i) {
             $minOptions .= sfl("<option value='%s' selected='selected'>%s</option>", $i, $i);
         } else {
             $minOptions .= sfl("<option value='%s'>%s</option>", $i, $i);
         }
     }
     $maxOptions = sfl("<option value='' >Any</option>");
     for ($i = $this->ageMin; $i <= $this->ageMax; $i++) {
         // TODO: Bug here days don't always return the correct number of days...
         if ($maxValue == $i) {
             $maxOptions .= sfl("<option value='%s' selected='selected'>%s</option>", $i, $i);
         } else {
             $maxOptions .= sfl("<option value='%s'>%s</option>", $i, $i);
         }
     }
     $out = sfl("<select name='%s[min]' id='form_%s' %s class='inputAgeRange inputAgeRangeMin' >%s</select>", $this->getName(), $this->getName(), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $minOptions);
     $out .= sfl("<span class='inputAgeRangeSeparator'>%s</span> <select name='%s[max]' id='form_%s' %s class='inputAgeRange inputAgeRangeMax' >%s</select>", $this->separator, $this->getName(), $this->getName(), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $maxOptions);
     return $out;
 }
Example #6
0
 function renderElement()
 {
     $html = "";
     $elementValue = $this->getValue();
     foreach ($this->options as $value => $option) {
         $html .= sfl('<div class="radioOption">' . '	<input type="radio" name="%s" value="%s" %s %s %s id="form_%s[%s]"  class="inputRadio">' . '	<label for="form_%s[%s]">%s</label>' . '</div>', $this->getName(), $value, $this->onChange ? sf(' onchange="%s"', $this->onChange) : '', strval($elementValue) == strval($value) ? sf('checked="checked"') : '', $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName(), $value, $this->getName(), $value, $option);
     }
     return sf("<div class='radioGroup'>%s</div>", $html);
 }
 function renderElement()
 {
     $htmlOut = "";
     $elementValue = $this->getValue();
     foreach ($this->options as $value => $imageUrl) {
         $htmlOut .= $this->renderThumbnail($value, $imageUrl, strval($elementValue) == strval($value));
     }
     return sfl("<div name='%s' %s id='form_%s' class='inputImagePicker'>%s</div>", $this->getName(), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName(), $htmlOut);
 }
 function renderElement()
 {
     $html = "";
     $elementValue = $this->getValue();
     $usedSuggested = false;
     foreach ($this->options as $value => $option) {
         if (strval($elementValue) == strval($value)) {
             $usedSuggested = true;
             $html .= sfl('<div class="inputSuggestionOption"><input type="radio" name="%s" value="%s" %s checked="checked"  /> %s</div>', $this->getName(), parent::makeInputSafe($value), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $option);
         } else {
             $html .= sfl('<div class="inputSuggestionOption"><input type="radio" name="%s" value="%s" %s /> %s</div>', $this->getName(), parent::makeInputSafe($value), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $option);
         }
     }
     return sf("<div class='inputSuggestionContainer'>%s\n\t\t\t\t\t\t<div class='inputSuggestionOption'>%s %s<input type='text' name='%s' value='%s' class='inputSuggestionText' />%s</div></div>", $html, sfl('<input type="radio" name="%s" value="custom" %s %s />', $this->getName(), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $usedSuggested ? "" : 'checked="checked"'), $this->beforeText, $this->getName() . "_custom", $usedSuggested ? "" : parent::makeInputSafe($this->getValue()), $this->afterText);
 }
Example #9
0
 function renderElement()
 {
     $time = $this->getValue();
     $hourValue = $time['hour'];
     $minValue = $time['min'];
     //	if($elementValue == "" || is_null($elementValue))
     $hourOptions = sfl('<option value="">Hour</option>');
     for ($i = 0; $i <= 23; $i += $this->hourInterval) {
         $text = $i <= 9 ? "0{$i}" : $i;
         $hourOptions .= sfl("<option value='%s'%s>%s</option>", $i, intval($hourValue) == intval($i) ? ' selected="selected"' : '', $text);
     }
     $minOptions = sfl("<option value=''>Minutes</option>");
     for ($i = 0; $i <= 59; $i += $this->miniteInterval) {
         $text = $i <= 9 ? "0{$i}" : $i;
         $minOptions .= sfl("<option value='%s'%s>%s</option>", $i, intval($minValue) == intval($i) ? ' selected="selected"' : '', $text);
     }
     $out = sfl("<select name='%s[hour]' id='form_%s' class='inputTime inputTimeHour' >%s</select>", $this->getName(), $this->getName(), $hourOptions);
     $out .= sfl(": <select name='%s[min]' id='form_%s' style='inputTime inputTimeMinute' >%s</select>", $this->getName(), $this->getName(), $minOptions);
     return $out;
 }
Example #10
0
 function renderElement()
 {
     $date = $this->getValue();
     $dayValue = isset($date['day']) ? $date['day'] : date("d");
     $monthValue = isset($date['month']) ? $date['month'] : date("m");
     $yearValue = isset($date['year']) ? $date['year'] : date("Y");
     $dayOptions = sfl("<option value='' >Day</option>");
     for ($i = 1; $i <= 31; $i++) {
         // TODO: Bug here days don't always return the correct number of days...
         $dayNumber = date("j", mktime(0, 0, 0, 1, $i, date("Y")));
         $dayValueLeading = date("d", mktime(0, 0, 0, 1, $i, date("Y")));
         if ($dayValue == $i) {
             $dayOptions .= sfl("<option value='%s' selected='selected'>%s</option>", $dayValueLeading, $dayNumber);
         } else {
             $dayOptions .= sfl("<option value='%s'>%s</option>", $dayValueLeading, $dayNumber);
         }
     }
     $monthOptions = sfl("<option value='' >Month</option>");
     for ($i = 1; $i <= 12; $i++) {
         if (strval($monthValue) == strval($i)) {
             $monthOptions .= sfl("<option value='%s' selected='selected'>%s</option>", date("m", mktime(0, 0, 0, $i, 1, date("Y"))), date("F", mktime(0, 0, 0, $i, 1, date("Y"))));
         } else {
             $monthOptions .= sfl("<option value='%s'>%s</option>", date("m", mktime(0, 0, 0, $i, 1, date("Y"))), date("F", mktime(0, 0, 0, $i, 1, date("Y"))));
         }
     }
     $yearOptions = sfl("<option value='' >Year</option>");
     for ($i = $this->yearRange[1]; $i >= $this->yearRange[0]; $i--) {
         if (strval($yearValue) == strval($i)) {
             $yearOptions .= sfl("<option value='%s' selected='selected'>%s</option>", $i, $i);
         } else {
             $yearOptions .= sfl("<option value='%s'>%s</option>", $i, $i);
         }
     }
     $out = sfl("<select name='%s[day]' %s id='form_%s_day' class='inputDate inputDateDay'>%s</select>", $this->getName(), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName(), $dayOptions);
     $out .= sfl("<select name='%s[month]' %s id='form_%s_month' class='inputDate inputDateMonth'>%s</select>", $this->getName(), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName(), $monthOptions);
     $out .= sfl("<select name='%s[year]' %s id='form_%s_year' class='inputDate inputDateYear'>%s</select>", $this->getName(), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName(), $yearOptions);
     return $out;
 }
 public function render($options = array())
 {
     // If elementOnly is specified, only the form element itself is returned
     if (isset($options['elementOnly']) && $options['elementOnly']) {
         $out = $this->renderElement();
     } else {
         $out = $this->preRender();
         $out .= sfl('<div class="row%s%s%s row_%s"%s>', $this->style ? " " . $this->style : "", $this->cssClass ? " " . $this->cssClass : "", $this->submitted && !$this->validates ? " error" : "", $this->name, $this->cssStyle ? " style='" . $this->cssStyle . "'" : "");
         try {
             $out .= sf('%s%s<div class="element">%s</div>', $this->renderErrors(), ($this->label != '' || $this->getRequired()) && (!array_key_exists('label', $options) || $options['label'] !== false) ? $this->renderLabel() : '', $this->renderElement());
         } catch (Exception $e) {
             // if in debug mode display exception details
             if (atsumi_Debug::getActive()) {
                 $out .= sfl('Element Exception "%s": %s #%s', $e->getMessage(), $e->getFile(), $e->getLine());
             }
             // fire error listeners
             Atsumi::error__listen($e);
         }
         $out .= '</div>';
         $out .= $this->postRender();
     }
     return $out;
 }
Example #12
0
 /**
  * Formats a backtrace into a content type
  * @access protected
  * @param array $trace The trace to format
  * @param string $contentType The type of content to return
  */
 protected static function formatTrace($trace, $contentType = 'text/plain')
 {
     $out = '';
     $row = 0;
     foreach ($trace as $i => $l) {
         if (array_key_exists('class', $l) && $l['class'] == 'atsumi_ErrorHandler') {
             continue;
         }
         $args = array_key_exists('args', $l) ? self::argsToString($l['args']) : '';
         switch ($contentType) {
             default:
             case 'text/plain':
                 $location = array_key_exists('file', $l) ? sf("%s(%s): ", str_replace(atsumi_Loader::getWorkspace(), 'WORKSPACE', $l['file']), $l['line']) : "[internal function]: ";
                 $out .= sfl('#%s %s%s%s', $row, $location, array_key_exists('class', $l) ? array_key_exists('object', $l) ? sf('%s->%s', $l['class'], $l['function']) : sf('%s::%s', $l['class'], $l['function']) : $l['function'], sf('(%s)', $args));
                 break;
             case 'text/html':
                 $location = array_key_exists('file', $l) ? sf("%s(<strong>%s</strong>): ", preg_replace('|\\/([a-zA-Z0-9\\-\\_\\.]+\\.php)|', '/<strong class="atsumiFile">\\1</strong>', htmlentities(str_replace(atsumi_Loader::getWorkspace(), 'WORKSPACE', $l['file']))), $l['line']) : "[internal function]: ";
                 $out .= sfl("#<strong>%s</strong> %s%s%s", $row, $location, array_key_exists('class', $l) ? array_key_exists('object', $l) ? sf("<strong class='atsumiObject'>%s</strong>-><strong class='atsumiMethod'>%s</strong>", $l['class'], $l['function']) : sf("<strong class='atsumiClass'>%s</strong>::<strong class='atsumiMethod'>%s</strong>", $l['class'], $l['function']) : sf("%s", $l['function']), sf("(%s)", $args));
                 break;
         }
         $row++;
     }
     return $out;
 }
Example #13
0
 public function getFormBottom($options = array())
 {
     // add the submit to the bottom of the form for now(will convert to element in next version)
     $html = '';
     if (!isset($options['buttonOnly']) || $options['buttonOnly'] == false) {
         $html = sfl('	<div class="submit rowSubmit%s">', array_key_exists('rowClasses', $options) ? ' ' . $options['rowClasses'] : '');
     }
     $html .= sfl('	%s<button type="submit" class="%s" id="submit_%s">%s</button>%s', array_key_exists('preButtonHtml', $options) ? $options['preButtonHtml'] : '', array_key_exists('buttonClasses', $options) ? ' ' . $options['buttonClasses'] : 'button button-submit', $this->name, array_key_exists('innerButtonHtml', $options) ? $options['innerButtonHtml'] : $this->getSubmit(), array_key_exists('postButtonHtml', $options) ? $options['postButtonHtml'] : '');
     if (!isset($options['buttonOnly']) || $options['buttonOnly'] == false) {
         $html .= sfl('	</div>');
     }
     $html .= sfl('</form>');
     return $html;
 }
Example #14
0
 protected function renderCell($date)
 {
     return sfl("<td class='date'>%s</td>", date("d", strtotime($date['date'])));
 }