コード例 #1
0
ファイル: Command.php プロジェクト: rk4an/centreon
 /**
  * 
  * @param array $element
  * @return array
  */
 public static function renderHtmlInput(array $element)
 {
     // Select for Commands
     $commandSelect = Select::renderHtmlInput($element);
     $myHtml = '<div class="row"><div class="col-sm-12">' . $commandSelect['html'] . '</div></div>';
     $myJs = $commandSelect['js'];
     $myHtml .= '<div id="' . $element['name'] . '_command_args" class="row"></div>';
     $commandArgumentsUrl = Di::getDefault()->get('router')->getPathFor('/centreon-configuration/command/[i:id]/arguments');
     $myJs .= ' ' . '$("#' . $element['name'] . '").on("change", function() { ' . '$("#' . $element['name'] . '_command_args").empty(); ' . 'var commandId = $("#' . $element['name'] . '").val(); ' . 'var realCommandArgumentsUrl = "' . $commandArgumentsUrl . '"; ' . 'var computedCommandArgumentsUrl = realCommandArgumentsUrl.replace("[i:id]", commandId);' . '$.ajax({ ' . 'url: computedCommandArgumentsUrl,' . 'type: "GET", ' . 'dataType: "json" ' . '})' . '.success(function(data, status, jqxhr) { ' . 'var argumentsHtml = ""; ' . '$.each(data, function(key, value){ ' . 'argumentsHtml += "<div class=\\"row\\"><div class=\\"col-sm-3\\">"+value.name+"</div>' . '<div class=\\"col-sm-4\\">' . '<input class=\\"form-control\\" type=\\"text\\" value=\\""+value.value+"\\">' . '</div>' . '<div class=\\"col-sm-3\\">"+value.example+"</div></div>" ' . '}); ' . '$("#' . $element['name'] . '_command_args").append(argumentsHtml); ' . '});' . '});';
     return array('html' => $myHtml, 'js' => $myJs);
 }
コード例 #2
0
    /**
     * 
     * @param array $element
     * @return array
     */
    public static function renderHtmlInput(array $element)
    {
        $extraData = 'data-callback="' . $element['label_initCallback'] . '"';
        if (isset($element['label_additionalRoute']) && trim($element['label_additionalRoute'])) {
            $element['label_additionalRoute'] = Di::getDefault()->get('router')->getPathFor($element['label_additionalRoute'], $element['label_extra']);
            $extraData .= ' data-extra-url="' . $element['label_additionalRoute'] . '"';
        }
        $render = parent::renderHtmlInput($element);
        $render['html'] = preg_replace('/<input(.*)/', '<input ' . $extraData . '$1', $render['html']);
        $render['js'] .= '$("#' . $element['name'] . '").on("change", function () {
              var callback = $(this).data("callback");
              var url = $(this).data("extra-url");
              url = (url === undefined ? "" : url);

              var callbackFunction = window[callback];
              if ( typeof callbackFunction === "function" ) {
                  callbackFunction($(this).select2("data"), $(this), url);
              }
            });';
        return array('html' => $render['html'], 'js' => $render['js']);
    }
コード例 #3
0
ファイル: Selectimage.php プロジェクト: rk4an/centreon
 /**
  * 
  * @param array $element
  * @return array
  */
 public static function renderHtmlInput(array $element)
 {
     $selectImageParameters = array('label_label' => $element['label_label'], 'label_multiple' => false, 'name' => $element['name'], 'label_object_type' => $element['label_object_type'], 'label_defaultValuesRoute' => $element['label_defaultValuesRoute'], 'label_listValuesRoute' => $element['label_listValuesRoute'], 'label_extra' => $element['label_extra'], 'label_object_type' => $element['label_object_type']);
     $addImageUrl = Di::getDefault()->get('router')->getPathFor($element['label_wizardRoute']);
     $selectForImage = Select::renderHtmlInput($selectImageParameters);
     $fileUploadForImage = File::renderHtmlInput($element);
     $finalHtml = '<div class="inlineGroup">' . '<div class="Elem1">' . $selectForImage['html'] . '</div>' . '<div class="Elem2">' . '<button ' . 'class="btnC btnDefault " ' . 'id="modalAdd_' . $element['name'] . '" ' . 'type="button">' . '<i class="icon-upload"></i>' . '</button>' . '</div>' . '</div>';
     $finalJs = $selectForImage['js'] . ' ' . $fileUploadForImage['js'] . ' ';
     $finalJs .= '$("#modalAdd_' . $element['name'] . '").on("click", function(e) {
         $("#modal").removeData("bs.modal");
         $("#modal").removeData("centreonWizard");
         $("#modal .modal-content").text("");
         $("#modal").one("loaded.bs.modal", function(e) {
             $(this).centreonWizard();
         });
         $("#modal").modal({
             "remote": "' . $addImageUrl . '"
         });
     });';
     return array('html' => $finalHtml, 'js' => $finalJs);
 }