Esempio n. 1
0
 /**
  * __construct
  *
  * @param string  $caption  caption
  * @param string  $name     name
  * @param integer $size     size
  * @param integer $value    value unix timestamp
  * @param boolean $showtime true to show time, false for date only
  */
 public function __construct($caption, $name, $size = 2, $value = 0, $showtime = true)
 {
     parent::__construct($caption, '');
     $value = (int) $value;
     $value = $value > 0 ? $value : time();
     $datetime = getdate($value);
     $date = new DateSelect('', $name . '[date]', $size, $value);
     $date->setAttribute('id', $name . '-date');
     $this->addElement($date);
     if ($showtime) {
         $timearray = array();
         for ($i = 0; $i < 24; ++$i) {
             for ($j = 0; $j < 60; $j = $j + 10) {
                 $key = $i * 3600 + $j * 60;
                 $timearray[$key] = $j != 0 ? $i . ':' . $j : $i . ':0' . $j;
             }
         }
         ksort($timearray);
         $timeselect = new Select('', $name . '[time]', $datetime['hours'] * 3600 + 600 * ceil($datetime['minutes'] / 10));
         $timeselect->setAttribute('id', $name . '-time');
         $timeselect->addOptionArray($timearray);
         $timeselect->setClass('span2');
         $this->addElement($timeselect);
     } else {
         $this->addElement(new Hidden($name . '[time]', 0));
     }
 }
Esempio n. 2
0
 /**
  * __construct
  *
  * @param string|array $caption Caption or array of all attributes
  * @param string       $name    unique identifier for this tab
  */
 public function __construct($caption, $name = null)
 {
     if (is_array($caption)) {
         parent::__construct($caption);
     } else {
         parent::__construct([]);
         $this->setName($name);
         $this->setCaption($caption);
     }
 }
Esempio n. 3
0
 /**
  * render
  *
  * @return string
  */
 public function render()
 {
     $editor_handler = \XoopsEditorHandler::getInstance();
     $editor_handler->allowed_editors = $this->allowed_editors;
     $option_select = new Select("", $this->name, $this->value);
     $onchangeCode = '"if(this.options[this.selectedIndex].value.length > 0 ){window.document.forms.' . $this->form->getName() . '.submit();}"';
     $option_select->set('onchange', $onchangeCode);
     $option_select->addOptionArray($editor_handler->getList($this->nohtml));
     $this->addElement($option_select);
     return parent::render();
 }
Esempio n. 4
0
 /**
  * __construct
  *
  * @param string|array      $caption Caption or array of all attributes
  * @param string            $name    name
  * @param integer|\DateTime $value   unix timestamp or DateTime object
  */
 public function __construct($caption, $name = null, $value = 0)
 {
     // stash everything in the tray and sort out later
     if (is_array($caption)) {
         parent::__construct($caption);
         $this->set(':joiner', '');
     } else {
         parent::__construct($caption, '', $name);
         $this->set('value', $value);
     }
     $workingTime = \Xoops\Core\Locale\Time::cleanTime($this->get('value', 0));
     $dateDefinition = ['caption' => '', 'name' => $this->get('name') . '[date]', 'id' => $this->get('name') . '-date', 'size' => 15, 'value' => $workingTime, ElementFactory::FORM_KEY => $this];
     new DateSelect($dateDefinition);
     $minuteInterval = $this->get(':minuteinterval', 15);
     $hours = (int) ltrim($workingTime->format('H'), '0');
     $minutes = (int) ltrim($workingTime->format('i'), '0');
     $timeDefinition = ['caption' => '', 'name' => $this->get('name') . '[time]', 'id' => $this->get('name') . '-time', 'size' => 1, 'value' => \Xoops\Core\Locale\Time::formatTime($hours * 3600 + 60 * $minuteInterval * ceil($minutes / $minuteInterval), 'short', new \DateTimeZone('UTC')), ElementFactory::FORM_KEY => $this, 'option' => \Xoops\Core\Lists\Time::getList($minuteInterval)];
     new Select($timeDefinition);
 }
Esempio n. 5
0
 /**
  * create HTML to output the form as a table
  *
  * @return string
  */
 public function render()
 {
     $xoops = \Xoops::getInstance();
     $xoops->theme()->addBaseScriptAssets('@jquery');
     $xoops->theme()->addBaseScriptAssets('@jqueryui');
     $xoops->theme()->addBaseStylesheetAssets('@jqueryuicss');
     $xoops->theme()->addScript('', '', '$(function() { $("#tabs_' . $this->getName() . '").tabs(); });');
     $ret = '<div id="tabs_' . $this->getName() . '">' . NWLINE;
     $ret .= '<ul>' . NWLINE;
     foreach ($this->getElements() as $ele) {
         if ($ele instanceof Tab) {
             $ret .= '<li><a href="#tab_' . $ele->getName() . '"><span>' . $ele->getCaption() . '</span></a></li>' . NWLINE;
         }
     }
     $ret .= '</ul>' . NWLINE;
     $hidden = '';
     $extras = array();
     foreach ($this->getElements() as $ele) {
         /* @var $ele Element */
         if (!$ele->isHidden()) {
             if (!$ele instanceof Raw) {
                 if ($ele instanceof Tab) {
                     $ret .= '<div id="tab_' . $ele->getName() . '">' . NWLINE;
                     $ret .= '<table class="outer" cellspacing="1">' . NWLINE;
                     $ret .= $ele->render();
                     $ret .= '</table>' . NWLINE;
                     $ret .= '</div>' . NWLINE;
                 } else {
                     $extras[] = $ele;
                 }
             } else {
                 $ret .= $ele->render();
             }
         } else {
             $hidden .= $ele->render();
         }
     }
     if (!empty($extras)) {
         $tray = new ElementTray('', $this->getDelimiter());
         foreach ($extras as $extra) {
             $tray->addElement($extra);
         }
         $ret .= $tray->render();
         $ret .= NWLINE;
     }
     $ret .= $hidden . NWLINE;
     $ret .= '</div>' . NWLINE;
     return $ret;
 }
Esempio n. 6
0
 /**
  * @covers Xoops\Form\ElementTray::render
  * @todo   Implement testRender().
  */
 public function testRender()
 {
     $value = $this->object->render();
     $this->assertTrue(is_string($value));
 }