Exemple #1
0
 function getInput()
 {
     $years = [];
     for ($i = date('Y') - $this->maxAge; $i <= date('Y') - $this->minAge; $i++) {
         $years[$i] = $i;
     }
     $value = $this->getValue();
     $year = substr($value, 0, 4);
     $monthV = substr($value, 5, 2);
     $day = substr($value, 8, 2);
     $this->htmlOptions['class'] = isset($this->htmlOptions['class']) ? $this->htmlOptions['class'] . ' ' : '';
     $this->htmlOptions['class'] .= $this->inputClass . ' birthday';
     $htmlOptions = $this->htmlOptions;
     $htmlOptions['class'] .= ' bday-year';
     $r = Form::get()->select('', $years, $year, $htmlOptions);
     $mths = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
     $months = [];
     foreach ($mths as $k => $month) {
         $months[$k < 10 ? "0" . ($k + 1) : $k + 1] = $this->translate($month);
     }
     $htmlOptions = $this->htmlOptions;
     $htmlOptions['class'] .= ' bday-month';
     $r .= Form::get()->select('', $months, $monthV, $htmlOptions);
     $days = [];
     for ($i = 1; $i <= 31; $i++) {
         $days[$i < 10 ? "0" . $i : $i] = $i < 10 ? "0" . $i : $i;
     }
     $htmlOptions = $this->htmlOptions;
     $htmlOptions['class'] .= ' bday-day';
     $r .= Form::get()->select('', $days, $day, $htmlOptions);
     return $r . Form::get()->hiddenInput($this->getName(), $this->getValue(), ['class' => 'birthday_value']);
 }
Exemple #2
0
 function getInput()
 {
     if ($this->getValue()) {
         $value = is_numeric($this->getValue()) ? $this->getValue() : strtotime($this->getValue());
     } else {
         $value = time();
     }
     $this->inputClass .= ' datetimeinput';
     $format = str_replace(['Y', 'm', 'd'], ['yy', 'mm', 'dd'], $this->format);
     $this->htmlOptions['class'] = (isset($this->htmlOptions['class']) ? $this->htmlOptions['class'] . ' ' : '') . $this->inputClass . ' datetime-date';
     $r = Form::get()->date('', date($this->format, $value), $format, $this->htmlOptions);
     $hours = range(0, 23);
     $seconds = $minutes = range(0, 59);
     if ($this->hour) {
         $r .= Form::get()->select('', $hours, date('H', $value), ['class' => $this->inputClass . ' datetime-hour']);
     } else {
         $r .= Form::get()->hiddenInput('', (int) date('H', $value), ['class' => 'datetime-hour']);
     }
     if ($this->minute) {
         $r .= Form::get()->select('', $minutes, date('i', $value), ['class' => $this->inputClass . ' datetime-minute']);
     } else {
         $r .= Form::get()->hiddenInput('', (int) date('i', $value), ['class' => 'datetime-minute']);
     }
     if ($this->second) {
         $r .= Form::get()->select('', $seconds, date('s', $value), ['class' => $this->inputClass . ' datetime-second']);
     } else {
         $r .= Form::get()->hiddenInput('', (int) date('s', $value), ['class' => 'datetime-second']);
     }
     return $r . Form::get()->hiddenInput($this->getName(), date($this->format . ' H:i:s', $value), ['class' => 'datetime-value']);
 }
Exemple #3
0
 /**
  * Get HTML Code for Input
  * @return string
  */
 public function getInput()
 {
     $this->htmlOptions['class'] = (isset($this->htmlOptions['class']) ? $this->htmlOptions['class'] . ' ' : '') . 'input markdown-input';
     $this->htmlOptions['ajax-url'] = $this->previewURL ?: WebApp::get()->request()->getCurrentURL();
     $this->htmlOptions['csrf-key'] = WebApp::get()->request()->getCsrfKey();
     $this->htmlOptions['csrf-value'] = WebApp::get()->request()->getCsrfValue();
     return Form::get()->textarea($this->getName(), $this->getValue(), $this->htmlOptions);
 }
Exemple #4
0
 /**
  * @return mixed|string
  */
 public function getInput()
 {
     $this->htmlOptions['class'] = (isset($this->htmlOptions['class']) ? $this->htmlOptions['class'] . ' ' : '') . 'checkbox-input';
     if ($this->options) {
         return \mpf\web\helpers\Form::get()->checkboxGroup($this->getName(), $this->options, $this->getValue(), $this->htmlOptions, $this->template, $this->separator);
     } else {
         return \mpf\web\helpers\Form::get()->checkbox($this->getName(), $this->getLabel(), $this->val, $this->getValue(), $this->htmlOptions, $this->template);
     }
 }
 /**
  * Get the input;
  * @return string
  */
 public function getInput()
 {
     $options = $this->htmlOptions;
     $options['class'] = (isset($options['class']) ? $options['class'] . ' ' : '') . 'input autocomplete';
     $options['autc_ajax'] = $this->ajaxUpdate ? '1' : '0';
     $options['autc_url'] = $this->ajaxURL;
     $options['autc_for'] = str_replace(['[', ']'], '__', $this->getName());
     $options['autc_minletters'] = $this->minLettersToSearch;
     $options['autc_insert'] = $this->allowNewValues ? '1' : '0';
     $opts = [];
     foreach ($this->options as $word) {
         $opts[] = "<li>{$word}</li>";
     }
     $opts = implode("", $opts);
     return Form::get()->hiddenInput($this->getName(), $this->getValue(), ['id' => str_replace(['[', ']'], '__', $this->getName())]) . Form::get()->input("", "text", $this->getValue(), $options) . Html::get()->tag("div", "<ul>{$opts}</ul>", ['id' => 'options-for-' . $options['autc_for'], 'class' => 'form-autocomplete-list']) . Html::get()->scriptFile($this->form->getAssetsURL() . 'autocomplete.js');
 }
 public function getInput()
 {
     if (!in_array($this->valueAs, ['string', 'array'])) {
         trigger_error("Invalid option for `valueAs`! Can only be string or array!");
         return "";
     }
     if ('string' == $this->valueAs) {
         $r = Form::get()->hiddenInput($this->getName(), $this->getValue(), ['class' => 'keywords-hidden-input']);
     } else {
         $r = Form::get()->select($this->getName(), $this->getValue(), $this->getValue(), ['class' => 'keywords-hidden-input', 'multiple' => 'multiple']);
     }
     $r .= Html::get()->tag('div', '', ['class' => 'keywords-list-input']);
     $this->htmlOptions['class'] = (isset($this->htmlOptions['class']) ? $this->htmlOptions['class'] . ' ' : '') . $this->inputClass . ' keywords-visible-input';
     $this->htmlOptions['placeholder'] = $this->translate($this->placeHolder);
     $r .= Form::get()->input('', 'text', '', $this->htmlOptions);
     if (!self::$published) {
         $r .= $this->getScripts() . $this->getStyles();
         self::$published = true;
     }
     return $r;
 }
 protected function getForm($row, Table $table)
 {
     $this->formHTMLOptions['style'] = (isset($this->formHTMLOptions['style']) ? $this->formHTMLOptions['style'] : '') . 'display:none;';
     $this->formHTMLOptions['method'] = 'post';
     $this->formHTMLOptions['is-ajax'] = $this->ajax ? '1' : '0';
     $this->formHTMLOptions['action'] = $this->url ? is_array($this->url) ? WebApp::get()->request()->createURL($this->url[0], $this->url[1], isset($this->url[2]) ? $this->url[2] : [], isset($this->url[3]) ? $this->url[3] : null) : $this->url : '';
     $form = Form::get()->openForm($this->formHTMLOptions);
     switch ($this->type) {
         case 'input':
         case 'password':
         case 'email':
             $form .= Form::get()->input($this->name, str_replace('input', 'text', $this->type), $row->{$this->name}, $this->inputHTMLOptions);
             break;
         case 'date':
             $form .= Form::get()->input($this->name, str_replace('input', 'date', $this->type), $row->{$this->name}, $this->inputHTMLOptions);
             break;
         case 'select':
             $form .= Form::get()->select($this->name, $this->options, $row->{$this->name}, $this->inputHTMLOptions);
             break;
         case 'default':
             trigger_error("Invalid type {$this->type}!");
             break;
     }
     $form .= Form::get()->hiddenInput($this->key, $row->{$this->key});
     $this->saveButtonIcon = str_replace(array('%DATATABLE_ASSETS%', '%SIZE%'), array($table->getAssetsURL(), $this->iconSize . 'x' . $this->iconSize), $this->saveButtonIcon);
     $this->cancelButtonIcon = str_replace(array('%DATATABLE_ASSETS%', '%SIZE%'), array($table->getAssetsURL(), $this->iconSize . 'x' . $this->iconSize), $this->cancelButtonIcon);
     if ('%MPF_ASSETS%' == substr($this->saveButtonIcon, 0, 12)) {
         $this->saveButtonIcon = AssetsPublisher::get()->mpfAssetFile(substr($this->saveButtonIcon, 12));
     }
     if ('%MPF_ASSETS%' == substr($this->cancelButtonIcon, 0, 12)) {
         $this->cancelButtonIcon = AssetsPublisher::get()->mpfAssetFile(substr($this->cancelButtonIcon, 12));
     }
     if ($this->showSaveButton) {
         $form .= Form::get()->imageButton($this->saveButtonIcon, $this->saveButtonLabel, '', '', ['class' => 'inline-save-button']);
     }
     if ($this->showCancelButton) {
         $form .= Form::get()->imageButton($this->cancelButtonIcon, $this->cancelButtonLabel, '', '', ['class' => 'inline-cancel-button']);
     }
     return $form . Form::get()->closeForm();
 }
Exemple #8
0
 /**
  * Returns the HTML code for the element.
  * @return string
  */
 public function display()
 {
     $source = str_replace(['{VENDOR}', '{APP_ROOT}'], [LIBS_FOLDER, APP_ROOT], $this->jsSource);
     $url = AssetsPublisher::get()->publishFolder($source);
     $events = $this->getJSEvents();
     $r = Form::get()->input($this->name . '[]', 'file', null, ['id' => $this->id, 'data-url' => $this->dataUrl, 'multiple' => 'multiple']) . Html::get()->scriptFile($url . "js/vendor/jquery.ui.widget.js") . Html::get()->scriptFile($url . "js/jquery.iframe-transport.js") . Html::get()->scriptFile($url . "js/jquery.fileupload.js") . Html::get()->script("\$(function () {\n    \$('#{$this->id}').fileupload({\n        dataType: 'json' " . (isset($this->jsEventsHandlers['fileuploaddone']) ? '' : ",\n        done: function (e, data) {\n            \$.each(data.result.files, function (index, file) {\n                \$('<p/>').text(file.name).appendTo(\$(\"#{$this->resultsId}\"));\n            });\n        }") . "\n    }){$events};\n});");
     if ($this->generateResultsDiv) {
         $r .= Html::get()->tag("div", "", ["id" => $this->resultsId]);
     }
     return $r;
 }
Exemple #9
0
 public function getInput()
 {
     $this->htmlOptions['class'] = (isset($this->htmlOptions['class']) ? $this->htmlOptions['class'] . ' ' : '') . 'input';
     return Form::get()->textarea($this->getName(), $this->getValue(), $this->htmlOptions);
 }
Exemple #10
0
 public function getInput()
 {
     $this->htmlOptions['class'] = (isset($this->htmlOptions['class']) ? $this->htmlOptions['class'] . ' ' : '') . 'radio-input';
     return Form::get()->radioGroup($this->getName(), $this->options, $this->getValue(), $this->htmlOptions, $this->template, $this->separator);
 }
Exemple #11
0
 /**
  * @return string
  */
 public function getFilter()
 {
     return Form::get()->date($this->dataProvider->filtersKey . '[' . $this->name . ']');
 }
Exemple #12
0
 /**
  * Get HTML table filter for selected column;
  * @return string
  */
 public function getFilter()
 {
     if (false === $this->filter) {
         return '';
     }
     if (is_array($this->filter)) {
         return Form::get()->select($this->dataProvider->filtersKey . '[' . $this->name . ']', $this->filter, null, array(), '');
     }
     return Form::get()->input($this->dataProvider->filtersKey . '[' . $this->name . ']');
 }
Exemple #13
0
 public function getInput()
 {
     $options = $this->htmlOptions;
     $options['class'] = (isset($options['class']) ? $options['class'] . ' ' : '') . $this->inputClass;
     return Form::get()->input($this->name, 'file', $this->getValue(), $options);
 }
Exemple #14
0
 function getInput()
 {
     $format = str_replace(['Y', 'm', 'd'], ['yy', 'mm', 'dd'], $this->format);
     $this->htmlOptions['class'] = (isset($this->htmlOptions['class']) ? $this->htmlOptions['class'] . ' ' : '') . $this->inputClass;
     return Form::get()->date($this->getName(), $this->getValue(), $format, $this->htmlOptions);
 }
Exemple #15
0
 public function getInput()
 {
     $options = $this->htmlOptions;
     $options['class'] = (isset($options['class']) ? $options['class'] . ' ' : '') . $this->inputClass;
     return Form::get()->select($this->getName(), $this->options, $this->getValue(), $options, $this->emptyValue);
 }
Exemple #16
0
 public function getInput()
 {
     $options = $this->htmlOptions;
     $options['class'] = (isset($options['class']) ? $options['class'] . ' ' : '') . $this->inputClass;
     return FormHelper::get()->input($this->getName(), $this->inputType, $this->getValue(), $options);
 }
Exemple #17
0
 /**
  * It creates a link and a hidden form. That form will be submitted where the link is setup as URL.
  *
  * @param string|array $url Url where form will be submitted
  * @param string $text Visible text for the link
  * @param array $postData List of hidden inputs that will be sent in form and the value for each.
  * @param array $htmlOptions An associative list of htmloptions. Name and value.
  * @param bool $checkAccess If $url is array then it will check if it has access to that page and if not it will not display the link
  * @param bool|string $confirm Use confirmation message. Can be false or string with the message for confirmation
  * @return string
  */
 public function postLink($url, $text, $postData = [], $htmlOptions = [], $checkAccess = true, $confirm = false)
 {
     if ($checkAccess && is_array($url)) {
         $module = isset($url[3]) ? $url[3] : (isset($url[2]) && is_string($url[2]) ? $url[2] : null);
         if (!WebApp::get()->hasAccessTo($url[0], isset($url[1]) ? $url[1] : null, $module)) {
             return "";
             // is not visible;
         }
     }
     if (is_array($url)) {
         $module = isset($url[3]) ? $url[3] : (isset($url[2]) && is_string($url[2]) ? $url[2] : null);
         $url = WebApp::get()->request()->createURL($url[0], isset($url[1]) ? $url[1] : null, isset($url[2]) && is_array($url[2]) ? $url[2] : [], $module);
     }
     $uniqueID = uniqid("post-link-form");
     $htmlOptions['onclick'] = (isset($htmlOptions['onclick']) ? $htmlOptions['onclick'] . ' ' : '') . 'document.getElementById(\'' . $uniqueID . '\').submit(); return false;';
     if ($confirm) {
         $htmlOptions['onclick'] = "if (confirm('{$confirm}')) { {$htmlOptions['onclick']} }; return false;";
     }
     $r = $this->link($url, $text, $htmlOptions, false);
     $r .= Form::get()->openForm(['style' => 'display:none;', 'method' => 'post', 'id' => $uniqueID, 'action' => $url]);
     foreach ($postData as $name => $value) {
         $r .= Form::get()->hiddenInput($name, $value);
     }
     $r .= Form::get()->closeForm();
     return $r;
 }
Exemple #18
0
</div>
<div class="forum-default-group-line">
    <span>Default Members Group:</span>
    <a href="#"><?php 
echo \mpf\modules\forum\models\ForumSection::findByPk($this->sectionId)->defaultMembersGroup->full_name;
?>
</a>
    <?php 
echo \mpf\web\helpers\Form::get()->openForm(['method' => 'post', 'style' => 'display:none;']);
?>
    <?php 
echo \mpf\web\helpers\Form::get()->select('group', \mpf\helpers\ArrayHelper::get()->transform(\mpf\modules\forum\models\ForumUserGroup::findAllByAttributes(['section_id' => $this->sectionId]), ['id' => 'full_name']));
?>
    <input type="submit" name="changedefaultmembersgroup" value="Update"/>
    <?php 
echo \mpf\web\helpers\Form::get()->closeForm();
?>
</div>


<?php 
\mpf\widgets\datatable\Table::get(['dataProvider' => $model->getDataProvider($this->sectionId), 'columns' => ['full_name', 'html_class', 'admin' => ['class' => 'YesNo'], 'moderator' => ['class' => 'YesNo'], 'newthread' => ['class' => 'YesNo'], 'threadreply' => ['class' => 'YesNo'], 'canread' => ['class' => 'YesNo'], ['class' => 'Actions', 'buttons' => ['delete' => ['class' => 'Delete', 'iconSize' => 22, 'url' => $this->getUrlForDatatableAction('delete')], 'edit' => ['class' => 'Edit', 'iconSize' => 22, 'url' => $this->getUrlForDatatableAction('editGroup')]]]]])->display();
?>
<script>
    $(document).ready(function () {
        $('.forum-default-group-line a').click(function () {
            $(this).hide();
            $('form', this.parentNode).show();
            return false;
        })
    })
Exemple #19
0
<?php

/* @var $this \app\controllers\Admin */
echo \app\components\htmltools\Page::title('Config Edit');
\mpf\widgets\form\Form::get(array())->publishAssets();
?>

<div class="mform mform-default-wide">
    <form method="post">
        <?php 
if ($this->getRequest()->secure) {
    ?>
            <?php 
    echo \mpf\web\helpers\Form::get()->hiddenInput($this->getRequest()->getCsrfKey(), $this->getRequest()->getCsrfValue());
    ?>
        <?php 
}
?>
        <?php 
foreach ($models as $model) {
    ?>
            <?php 
    /* @var $model \app\models\GlobalConfig */
    ?>
            <div class="row">
                <label class="label"><?php 
    echo $model->name;
    ?>
</label>
                <input class="input" type="text" name="GlobalConfig[<?php 
    echo $model->id;
Exemple #20
0
 /**
  * @return string
  */
 protected function getContent()
 {
     $hiddenInputs = [];
     foreach ($this->hiddenInputs as $name => $value) {
         $hiddenInputs[] = \mpf\web\helpers\Form::get()->hiddenInput($name, $value);
     }
     $hiddenInputs = implode("\n", $hiddenInputs);
     $fields = array();
     foreach ($this->fields as $field) {
         if (is_string($field)) {
             $field = new fields\Text(array('name' => $field));
             $fields[] = $field->display($this);
         } elseif (is_array($field)) {
             $class = isset($field['type']) ? ucfirst($field['type']) : 'Text';
             $class = false === strpos($class, '\\') ? '\\mpf\\widgets\\form\\fields\\' . $class : $class;
             unset($field['type']);
             $field = new $class($field);
             /* @var $field \mpf\widgets\form\Field */
             $fields[] = $field->display($this);
         }
     }
     $buttons = [];
     if ($this->submitButton) {
         $buttons[] = $this->getButton(is_array($this->submitButton) ? $this->submitButton : ['name' => $this->name, 'label' => $this->submitButton]);
     } else {
         $buttons[] = $this->getButton($this->name);
     }
     foreach ($this->buttons as $button) {
         $buttons[] = $this->getButton($button);
     }
     if (!isset($this->buttonsRowHtmlOptions['class'])) {
         $this->buttonsRowHtmlOptions['class'] = 'row-buttons';
     }
     $links = [];
     foreach ($this->links as $label => $link) {
         if (is_array($link)) {
             $links[] = Html::get()->link($link['href'], $label, $link);
         } else {
             $links[] = Html::get()->link($link, $this->translate($label));
         }
     }
     $links = implode(' ', $links);
     return $hiddenInputs . implode("\n", $fields) . HtmlHelper::get()->tag('div', $links . implode("\n", $buttons), $this->buttonsRowHtmlOptions);
 }
Exemple #21
0
 public function getInput()
 {
     return Form::get()->htmlTextarea($this->getName(), $this->getValue(), $this->htmlOptions, $this->tinyMCETemplate);
 }