<?php
  /**
   * Comments
   *
   * @package Wojo Framework
   * @author wojoscripts.com
   * @copyright 2017
   * @version $Id: comments.tpl.php, v1.00 2017-02-05 10:12:05 gewa Exp $
   */
  if (!defined("_WOJO"))
      die('Direct access to this location is not allowed.');
	  
  if (!Auth::checkAcl("owner")) : print Message::msgError(Lang::$word->NOACCESS); return; endif;
?>
<?php switch(Url::segment($this->segments)): case "edit": ?>
<!-- Start configuration -->
<div class="row horizontal-gutters align-middle">
  <div class="columns">
    <h2><?php echo Lang::$word->META_M_COMMENTS;?></h2>
    <p class="wojo small text"><?php echo Lang::$word->CMT_INFO;?></p>
  </div>
  <div class="columns shrink"><a data-action="toggle" data-page="comment" class="wojo small primary icon label sAction"><i class="icon question sign"></i></a>
  </div>
</div>
<form method="post" id="wojo_form" name="wojo_form">
  <div class="wojo segment form">
    <div class="wojo fields align-middle">
      <div class="field four wide labeled">
        <label class="content-right mobile-content-left"><?php echo Lang::$word->CMT_NAMEREQ;?></label>
      </div>
      <div class="field">
        <div class="wojo inline fields">
          <div class="wojo checkbox radio field">
            <input name="name_req" type="radio" value="1" <?php Validator::getChecked($this->row->name_req, 1); ?>>
            <label><?php echo Lang::$word->YES;?></label>
          </div>
          <div class="wojo checkbox radio field">
            <input name="name_req" type="radio" value="0" <?php Validator::getChecked($this->row->name_req, 0); ?>>
            <label><?php echo Lang::$word->NO;?></label>
          </div>
        </div>
      </div>
    </div>
    <div class="wojo fields align-middle">
      <div class="field four wide labeled">
        <label class="content-right mobile-content-left"><?php echo Lang::$word->CMT_RATING;?></label>
      </div>
      <div class="field">
        <div class="wojo inline fields">
          <div class="wojo checkbox radio field">
            <input name="rating" type="radio" value="1" <?php Validator::getChecked($this->row->rating, 1); ?>>
            <label><?php echo Lang::$word->YES;?></label>
          </div>
          <div class="wojo checkbox radio field">
            <input name="rating" type="radio" value="0" <?php Validator::getChecked($this->row->rating, 0); ?>>
            <label><?php echo Lang::$word->NO;?></label>
          </div>
        </div>
      </div>
    </div>
    <div class="wojo fields align-middle">
      <div class="field four wide labeled">
        <label class="content-right mobile-content-left"><?php echo Lang::$word->CMT_SHOWCAP;?></label>
      </div>
      <div class="field">
        <div class="wojo inline fields">
          <div class="wojo checkbox radio field">
            <input name="show_captcha" type="radio" value="1" <?php Validator::getChecked($this->row->show_captcha, 1); ?>>
            <label><?php echo Lang::$word->YES;?></label>
          </div>
          <div class="wojo checkbox radio field">
            <input name="show_captcha" type="radio" value="0" <?php Validator::getChecked($this->row->show_captcha, 0); ?>>
            <label><?php echo Lang::$word->NO;?></label>
          </div>
        </div>
      </div>
    </div>
    <div class="wojo fields align-middle">
      <div class="field four wide labeled">
        <label class="content-right mobile-content-left"><?php echo Lang::$word->CMT_AUTOA;?></label>
      </div>
      <div class="field">
        <div class="wojo inline fields">
          <div class="wojo checkbox radio field">
            <input name="auto_approve" type="radio" value="1" <?php Validator::getChecked($this->row->auto_approve, 1); ?>>
            <label><?php echo Lang::$word->YES;?></label>
          </div>
          <div class="wojo checkbox radio field">
            <input name="auto_approve" type="radio" value="0" <?php Validator::getChecked($this->row->auto_approve, 0); ?>>
            <label><?php echo Lang::$word->NO;?></label>
          </div>
        </div>
      </div>
    </div>
    <div class="wojo fields align-middle">
      <div class="field four wide labeled">
        <label class="content-right mobile-content-left"><?php echo Lang::$word->CMT_PUBLIC;?></label>
      </div>
      <div class="field">
        <div class="wojo inline fields">
          <div class="wojo checkbox radio field">
            <input name="public_access" type="radio" value="1" <?php Validator::getChecked($this->row->public_access, 1); ?>>
            <label><?php echo Lang::$word->YES;?></label>
          </div>
          <div class="wojo checkbox radio field">
            <input name="public_access" type="radio" value="0" <?php Validator::getChecked($this->row->public_access, 0); ?>>
            <label><?php echo Lang::$word->NO;?></label>
          </div>
        </div>
      </div>
    </div>
    <div class="wojo fields align-middle">
      <div class="field four wide labeled">
        <label class="content-right mobile-content-left"><?php echo Lang::$word->CMT_NOTIFY;?></label>
      </div>
      <div class="field">
        <div class="wojo inline fields">
          <div class="wojo checkbox radio field">
            <input name="notify_new" type="radio" value="1" <?php Validator::getChecked($this->row->notify_new, 1); ?>>
            <label><?php echo Lang::$word->YES;?></label>
          </div>
          <div class="wojo checkbox radio field">
            <input name="notify_new" type="radio" value="0" <?php Validator::getChecked($this->row->notify_new, 0); ?>>
            <label><?php echo Lang::$word->NO;?></label>
          </div>
        </div>
      </div>
    </div>
    <div class="wojo fields align-middle">
      <div class="field four wide labeled">
        <label class="content-right mobile-content-left"><?php echo Lang::$word->CMT_DATEFORMAT;?></label>
      </div>
      <div class="field">
        <select name="dateformat" class="wojo fluid dropdown">
          <?php echo Date::getShortDate($this->row->dateformat);?>
          <?php echo Date::getLongDate($this->row->dateformat);?>
        </select>
      </div>
    </div>
    <div class="wojo fields align-middle">
      <div class="field four wide labeled">
        <label class="content-right mobile-content-left"><?php echo Lang::$word->CMT_SINCE;?></label>
      </div>
      <div class="field">
        <div class="wojo inline fields">
          <div class="wojo checkbox radio field">
            <input name="timesince" type="radio" value="1" <?php Validator::getChecked($this->row->timesince, 1); ?>>
            <label><?php echo Lang::$word->YES;?></label>
          </div>
          <div class="wojo checkbox radio field">
            <input name="timesince" type="radio" value="0" <?php Validator::getChecked($this->row->timesince, 0); ?>>
            <label><?php echo Lang::$word->NO;?></label>
          </div>
        </div>
      </div>
    </div>
    <div class="wojo fields align-middle">
      <div class="field four wide labeled">
        <label class="content-right mobile-content-left"><?php echo Lang::$word->CMT_SORTING;?></label>
      </div>
      <div class="field">
        <select name="sorting" class="wojo fluid dropdown">
          <option value="DESC" <?php echo Validator::getSelected($this->row->sorting, "DESC");?>><?php echo Lang::$word->CMT_SORTING_T;?></option>
          <option value="ASC" <?php echo Validator::getSelected($this->row->sorting, "ASC");?>><?php echo Lang::$word->CMT_SORTING_B;?></option>
        </select>
      </div>
    </div>
    <div class="wojo fields align-bottom">
      <div class="field four wide labeled">
        <label class="content-right mobile-content-left"><?php echo Lang::$word->CMT_CHARS;?></label>
      </div>
      <div class="field">
        <input data-range='{"step":10,"from":20, "to":400, "scale":[20,50,100,200,400]}' type="hidden" name="char_limit" value="<?php echo $this->row->char_limit;?>" class="rangeslider">
      </div>
    </div>
    <div class="wojo fields align-bottom">
      <div class="field four wide labeled">
        <label class="content-right mobile-content-left"><?php echo Lang::$word->CMT_CPP;?></label>
      </div>
      <div class="field">
        <input data-range='{"step":5,"from":5, "to":50, "scale":[5,20,35,50]}' type="hidden" name="perpage" value="<?php echo $this->row->perpage;?>" class="rangeslider">
      </div>
    </div>
    <div class="wojo space divider"></div>
    <div class="wojo fields align-middle">
      <div class="field four wide labeled">
        <label class="content-right mobile-content-left"><?php echo Lang::$word->CMT_BLACK;?></label>
      </div>
      <div class="field">
        <textarea placeholder="<?php echo Lang::$word->CMT_BLACK;?>" name="blacklist_words"><?php echo $this->row->blacklist_words;?></textarea>
      </div>
    </div>
  </div>
  <div class="content-center">
    <button type="button" data-action="commentConfig" name="dosubmit" class="wojo primary button"><?php echo Lang::$word->CMT_UPDATE;?></button>
  </div>
</form>
<?php break;?>
<?php default: ?>
<div class="row half-gutters align-middle">
  <div class="column mobile-100 phone-100">
    <h2><?php echo Lang::$word->META_M_COMMENTS;?></h2>
    <p class="wojo small text">
      <?php echo Lang::$word->CMT_INFO1;?>
    </p>
  </div>
  <div class="column shrink mobile-100 phone-100">
    <a href="<?php echo Url::url(Router::$path, "edit/");?>" class="wojo small primary basic icon button"><i class="icon cog"></i></a>
  </div>
</div>
<?php if(!$this->data):?>
<div class="content-center"><img src="<?php echo ADMINVIEW;?>/images/notfound.png" alt="">
  <p class="wojo small thick caps text"><?php echo Lang::$word->CMT_EMPTY;?></p>
</div>
<?php else:?>
<?php foreach($this->data as $row):?>
<div class="wojo shadow card" id="item_<?php echo $row->id;?>">
  <div class="header">
    <div class="row horizontal-gutters">
      <div class="column">
        <h4>
          <?php echo ($row->uname)? $row->uname : $row->username;?>
        </h4>
      </div>
      <div class="column shrink">
        <a data-set='{"option":[{"qAction": "1","page":"commentApprove", "id":<?php echo $row->id;?>}], "url":"/helper.php", "complete":"remove", "parent":"#item_<?php echo $row->id;?>"}' data-content="<?php echo Lang::$word->APPROVE;?>" class="wojo tiny positive circular basic icon button qAction"><i class="icon check"></i></a>
        <a data-set='{"option":[{"delete": "deleteComment","title": "<?php echo $row->id;?>","id":<?php echo $row->id;?>}],"action":"delete","parent":"#item_<?php echo $row->id;?>"}' class="wojo tiny negative circular basic icon button action"><i class="icon trash"></i></a>
      </div>
    </div>
    <div class="wojo space divider"></div>
    <p class="wojo small text">
      <?php echo $row->body;?>
    </p>
  </div>
  <div class="small content">
    <span class="wojo small caps text"><?php echo Date::doDate("long_date", $row->created);?>
  </div>
</div>
<?php endforeach;?>
<div class="row half-gutters-mobile half-gutters-phone align-middle">
  <div class="columns shrink mobile-100 phone-100">
    <div class="wojo small thick text"><?php echo Lang::$word->TOTAL . ': ' . $this->pager->items_total;?> / <?php echo Lang::$word->CURPAGE . ': ' . $this->pager->current_page . ' '. Lang::$word->OF . ' ' . $this->pager->num_pages;?></div>
  </div>
  <div class="columns mobile-100 phone-100 content-right mobile-content-left"><?php echo $this->pager->display_pages('small');?></div>
</div>
<?php endif;?>
<?php break;?>
<?php endswitch;?>