<?php
// +----------------------------------------------------------------------
// | mobanbox [ Beautiful Digital Content Trading System ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015 http://mobanbox.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Email author@mobanbox.net
// +----------------------------------------------------------------------

_setView(__FILE__);

	$collectionID = get_id(2);

	$collectionsClass = new collections();
	
	$collection = $collectionsClass->get($collectionID);
	if(!is_array($collection) || ($collection['public'] == 'false' && check_login_bool() && $collection['user_id'] != $_SESSION['user']['user_id'])) {
		refresh('/'.$languageURL.'collections/', $langArray['wrong_collection'], 'error');
	}
	
	if(isset($_POST['rating'])) {
		$_GET['rating'] = $_POST['rating'];
	}
	
	if(!isset($_GET['rating']) || !is_numeric($_GET['rating']) || $_GET['rating'] > 5) {
		$_GET['rating'] = 5;
	}
	elseif($_GET['rating'] < 1) {
		$_GET['rating'] = 1;
	}
	
	$collection = $collectionsClass->rate($collectionID, $_GET['rating']);

	$stars = '';
	for($i=1;$i<6;$i++) {
		if($collection['rating'] >= $i) {
			$stars .= '<i class="icon-star-full text-warn"></i>';
		}
		else {
			$stars .= '<i class="icon-star-empty"></i>';
		}
	}
	
	die('<div class="row-col h-v">
    <div class="row-cell v-m">
      <div class="modal-dialog modal-sm">
        <div class="modal-content">
          <div class="modal-header">
          	<h5 class="modal-title">您的评分为</h5>
          </div>
          <div class="modal-body text-center p-lg">
            <p class="text-lg">'.$stars.'</p>
          </div>
          <div class="modal-footer">
            <a href="/'.$languageURL.'collections/view/.$colletionsID." type="button" class="btn skin p-x-md">确定</a>
          </div>
        </div>
      </div>
    </div>
  </div>');

?>