<?php echo $header; ?>
<?php echo $column_left; ?>

<div id="content" class="isl-module-content">
  <script>var islConfig = <?php echo json_encode($islConfig); ?>;</script>
  <div class="page-header">
    <div class="container-fluid">
      <h1><?php echo $heading_title; ?></h1>

      <ul class="breadcrumb">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
          <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
        <?php } ?>
      </ul>

      <div class="pull-right">
        <button onclick="$('#form-isl-<?php echo $islConfig['name']; ?>-widget').submit();" type="submit" class="save-changes btn btn-primary" data-toggle="tooltip" title="<?php echo $button_save; ?>"><i class="fa fa-save"></i></button>
        <a href="<?php echo $url_extension; ?>" class="btn btn-default" data-toggle="tooltip" title="<?php echo $text_cancel; ?>"><i class="fa fa-reply"></i></a>
      </div>
    </div>
  </div>

  <div class="container-fluid">
    <?php echo $unlincensedHtml; ?>

    <?php if ($error_warning) { ?>
      <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert">&times;</button>
        <i class="fa fa-exclamation-circle" style="margin-right:10px"></i><?php echo $error_warning; ?>
      </div>
    <?php } ?>
    <?php if ($success) { ?>
      <div class="alert alert-success autoSlideUp">
        <button type="button" class="close" data-dismiss="alert">&times;</button>
        <i class="fa fa-check-circle" style="margin-right:10px"></i><?php echo $success; ?>
      </div>
      <script>$('.autoSlideUp').delay(5000).fadeOut(600, function(){ $(this).show().css({'visibility':'hidden'}); }).slideUp(600);</script>
    <?php } ?>

    <div class="page-content">
      <div class="panel panel-default">
        <form action="<?php echo $url_form; ?>" method="post" enctype="multipart/form-data" id="form-isl-<?php echo $islConfig['name']; ?>-widget" class="form-horizontal">

          <div class="panel-heading">
            <h3 id="_top" class="panel-title"><i class="fa fa-pencil"></i> <?php echo $sub_title; ?></h3>
          </div>

          <div class="panel-body">

            <div class="row">
              <div class="<?php echo !empty($info_form_widget) ? 'col-md-9' : 'col-xs-12' ?>">

                <div class="form-group required">
                  <label class="col-sm-3 control-label"><?php echo $entry_name; ?></label>
                  <div class="col-sm-9">
                    <?php if ($module_id) { ?>
                      <div class="input-group">
                        <div class="input-group-addon" data-toggle="tooltip" title="Type value: <?php echo $setting['widget']['type']; ?>"><?php echo $setting['widget']['name_type']; ?></div>
                        <input type="text" name="<?php echo $module_setting; ?>[name]" value="<?php echo $setting['widget']['name']; ?>" placeholder="Widget name" class="form-control">
                      </div>
                    <?php } else { ?>
                      <input type="text" name="<?php echo $module_setting; ?>[name]" value="<?php echo $setting['widget']['name']; ?>" placeholder="Widget name" class="form-control">
                    <?php } ?>
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label"><?php echo $entry_title; ?></label>
                  <div class="col-sm-9">
                    <?php foreach ($languages as $lang) { ?>
                      <div class="input-group" style="margin-bottom:5px;">
                        <div class="input-group-addon"><img src="<?php echo $lang['flag_url']; ?>" title="<?php echo $lang['name']; ?>"></div>
                        <input type="text" name="<?php echo $module_setting; ?>[title][<?php echo $lang['language_id']; ?>]" value="<?php echo !empty($setting['widget']['title'][$lang['language_id']]) ? $setting['widget']['title'][$lang['language_id']] : $setting['widget']['title'][0]; ?>" class="form-control">
                      </div>
                    <?php } ?>
                  </div>
                </div>

                <?php if (!$module_id) { ?>
                  <div class="form-group">
                    <label class="col-sm-3 control-label">Type</label>
                    <div class="col-sm-6 col-md-3">
                      <select name="<?php echo $module_setting; ?>[type]" class="form-control" data-isl-toggle='{"target":"widget_type"}'>
                        <option value="search" <?php echo $setting['widget']['type'] == 'search' ? 'selected="selected"' : ''; ?>>Search</option>
                        <option value="category" <?php echo $setting['widget']['type'] == 'category' ? 'selected="selected"' : ''; ?>>Category</option>
                        <option value="post_tabs" <?php echo $setting['widget']['type'] == 'post_tabs' ? 'selected="selected"' : ''; ?>>Post Tabs</option>
                        <option value="post_recent" <?php echo $setting['widget']['type'] == 'post_recent' ? 'selected="selected"' : ''; ?>>Post Recent</option>
                        <option value="post_popular" <?php echo $setting['widget']['type'] == 'post_popular' ? 'selected="selected"' : ''; ?>>Post Popular</option>
                        <option value="post_tags" <?php echo $setting['widget']['type'] == 'post_tags' ? 'selected="selected"' : ''; ?>>Post Tags</option>
                      </select>
                    </div>
                  </div>
                <?php } else { ?>
                  <input type="hidden" name="<?php echo $module_setting; ?>[type]" value="<?php echo $setting['widget']['type']; ?>" class="form-control">
                <?php } ?>

              </div>

              <?php if (!empty($info_form_widget)) { ?>
              <div class="col-md-3">
                <div class="panel panel-default panel-info">
                  <div class="panel-heading"><?php echo $text_information; ?></div>
                  <div class="panel-body">
                    <ul class="isl-list">
                      <?php foreach ($info_form_widget as $info) { ?>
                        <li><?php echo $info ?></li>
                      <?php } ?>
                    </ul>
                  </div>
                </div>
              </div>
              <?php } ?>
            </div>

            <h3 id="_settings" class="isl-legend isl-mt-10"><?php echo $text_settings; ?></h3>
            <hr class="isl-hr">

            <div class="row">
              <div class="<?php echo !empty($info_form_widget_setting) ? 'col-md-9' : 'col-xs-12' ?>">

                <div class="form-group-container">
                  <div class="widget_type widget_type_v_search" <?php echo $setting['widget']['type'] != 'search' ? 'style="display:none"' : ''; ?>>
                    <div class="form-group">
                      <label class="col-sm-3 control-label"><?php echo $entry_placeholder; ?></label>
                      <div class="col-sm-9">
                        <?php foreach ($languages as $lang) { ?>
                          <div class="input-group" style="margin-bottom:5px;">
                            <div class="input-group-addon"><img src="<?php echo $lang['flag_url']; ?>" title="<?php echo $lang['name']; ?>"></div>
                            <input type="text" name="<?php echo $module_setting; ?>[search_placeholder][<?php echo $lang['language_id']; ?>]" value="<?php echo !empty($setting['widget']['search_placeholder'][$lang['language_id']]) ? $setting['widget']['search_placeholder'][$lang['language_id']] : $setting['widget']['search_placeholder'][0]; ?>" class="form-control">
                          </div>
                        <?php } ?>
                      </div>
                    </div>
                  </div>
                  <div class="widget_type widget_type_v_post_tabs widget_type_v_post_recent widget_type_v_post_popular" <?php echo !in_array($setting['widget']['type'], array('post_tabs', 'post_recent', 'post_popular')) ? 'style="display:none"' : ''; ?>>
                    <div class="form-group">
                      <label class="col-sm-3 control-label"><?php echo $entry_limit; ?></label>
                      <div class="col-sm-6 col-md-3">
                        <input type="number" name="<?php echo $module_setting; ?>[post_limit]" value="<?php echo $setting['widget']['post_limit']; ?>" min="1" class="form-control isl-w-s isl-inline-block">
                      </div>
                    </div>
                  </div>
                </div>

                <div class="form-group">
                  <label class="col-sm-3 control-label"><?php echo $entry_status; ?></label>
                  <div class="col-sm-6 col-md-3">
                    <select name="<?php echo $module_setting; ?>[status]" class="form-control">
                      <option value="1" <?php echo $setting['widget']['status'] == '1' ? 'selected="selected"' : ''; ?>><?php echo $text_enabled; ?></option>
                      <option value="0" <?php echo $setting['widget']['status'] != '1' ? 'selected="selected"' : ''; ?>><?php echo $text_disabled; ?></option>
                    </select>
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label"><?php echo $entry_custom_css; ?></label>
                  <div class="col-sm-9">
                    <textarea class="form-control" name="<?php echo $module_setting; ?>[custom_css]" rows="10"><?php echo $setting['widget']['custom_css']; ?></textarea>
                  </div>
                </div>

              </div>
              <?php if (!empty($info_form_widget_setting)) { ?>
              <div class="col-md-3">
                <div class="panel panel-default panel-info">
                  <div class="panel-heading"><?php echo $text_information; ?></div>
                  <div class="panel-body">
                    <ul class="isl-list">
                      <?php foreach ($info_form_widget_setting as $info) { ?>
                        <li><?php echo $info ?></li>
                      <?php } ?>
                    </ul>
                  </div>
                </div>
              </div>
              <?php } ?>
            </div>


          </div> <!-- /.panel-body -->
        </form>
      </div>
    </div> <!-- /.page-content -->

  </div>
</div> <!-- /.isl-module-content -->

<?php echo $footer; ?>
