* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <*****@*****.**>
*  @copyright  2007-2011 PrestaShop SA
*  @version  Release: $Revision: 1.4 $
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
require_once dirname(__FILE__) . '/../../classes/Validate.php';
require_once dirname(__FILE__) . '/../../classes/Db.php';
require_once dirname(__FILE__) . '/../../classes/Tools.php';
require_once dirname(__FILE__) . '/ProductCommentCriterion.php';
if (empty($_GET['id_lang']) === false && isset($_GET['id_product']) === true) {
    $criterions = ProductCommentCriterion::get($_GET['id_lang']);
    if ((int) $_GET['id_product']) {
        $selects = ProductCommentCriterion::getByProduct($_GET['id_product'], $_GET['id_lang']);
    }
    echo '<select name="id_product_comment_criterion[]" id="id_product_comment_criterion" multiple="true" style="height:100px;width:360px;">';
    foreach ($criterions as $criterion) {
        echo '<option value="' . (int) $criterion['id_product_comment_criterion'] . '"';
        if (isset($selects) === true && sizeof($selects)) {
            foreach ($selects as $select) {
                if ($select['id_product_comment_criterion'] == $criterion['id_product_comment_criterion']) {
                    echo ' selected="selected"';
                }
            }
        }
        echo '>' . htmlspecialchars($criterion['name'], ENT_COMPAT, 'UTF-8') . '</option>';
    }
Пример #2
0
    private function _displayFormCriterion()
    {
        global $cookie;
        $this->_html .= '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post" name="criterion_form">
			<fieldset><legend><img src="' . $this->_path . 'img/note.png" alt="" title="" />' . $this->l('Comment\'s criterions') . '</legend>
				<label for="criterion">' . $this->l('Comment\'s criterion') . '</label>
				<div class="margin-form">
					<input type="text" name="criterion" id="criterion" /> <input type="submit" name="submitCriterion" value="' . $this->l('Add') . '" class="button" />
					<p>' . $this->l('Create a new grading criterion for your products.') . '</p>
				</div>
		<p>' . $this->l('Once created, you must activate it for the desired products with the form below.') . '<br />' . $this->l('Be aware that the criterions are independent in each language.') . '</p>';
        require_once dirname(__FILE__) . '/ProductCommentCriterion.php';
        $criterions = ProductCommentCriterion::get($cookie->id_lang);
        if (sizeof($criterions)) {
            $this->_html .= '
				 <input type="hidden" name="id_product_comment_criterion" id="id_product_comment_criterion" />
				 <input type="hidden" name="criterion_name" id="criterion_name" />
				 <input type="hidden" name="criterion_id_lang" id="criterion_id_lang" value="' . intval($cookie->id_lang) . '" />
				 <input type="hidden" name="criterion_action" id="criterion_action" />
				 <br /><table class="table">
				 <thead>
				  <tr>
				   <th style="width:30px;">' . $this->l('Actions') . '</th>
				   <th style="width:260px;">' . $this->l('Criterion') . '</th>
				   <th style="width:30px;">' . $this->l('Actions') . '</th>
				   <th style="width:260px;">' . $this->l('Criterion') . '</th>
				   <th style="width:30px;">' . $this->l('Actions') . '</th>
				   <th style="width:260px;">' . $this->l('Criterion') . '</th>
				  </tr>
				 </thead>
				 <tbody><tr>';
            $len = sizeof($criterions);
            for ($i = 0; $i < $len; ++$i) {
                $this->_html .= '
					 <td><a href="javascript:;" onclick="editCriterion(\'' . intval($criterions[$i]['id_product_comment_criterion']) . '\');"><img src="' . $this->_path . 'img/accept.png" alt="' . $this->l('Accept') . '" /></a>
					     <a href="javascript:;" onclick="deleteCriterion(\'' . intval($criterions[$i]['id_product_comment_criterion']) . '\');"><img src="' . $this->_path . 'img/delete.png" alt="' . $this->l('Delete') . '" /></a></td>
					 <td><input type="text" id="criterion_name_' . intval($criterions[$i]['id_product_comment_criterion']) . '" value="' . htmlspecialchars($criterions[$i]['name'], ENT_COMPAT, 'UTF-8') . '" /></td>';
                if (!(($i + 1) % 3) || $i + 1 >= $len) {
                    $this->_html .= '</tr><tr>';
                }
            }
            if (!$len) {
                $this->_html = '</tr>';
            }
            $this->_html .= '</tbody>
				</table>';
        }
        $this->_html .= '</fieldset></form><br />';
    }