Example #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));
     }
 }
Example #2
0
 /**
  * Constructor
  *
  * @param Form    $form            the form calling the editor selection
  * @param string  $name            editor name
  * @param string  $value           Pre-selected text value
  * @param boolean $nohtml          dohtml disabled
  * @param array   $allowed_editors allowed editors
  */
 public function __construct(Form $form, $name = 'editor', $value = null, $nohtml = false, $allowed_editors = array())
 {
     parent::__construct(\XoopsLocale::A_SELECT);
     $this->allowed_editors = $allowed_editors;
     $this->form = $form;
     $this->name = $name;
     $this->value = $value;
     $this->nohtml = $nohtml;
 }
Example #3
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);
     }
 }
Example #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);
 }