/**
  * @param $label
  * @return array
  */
 public static function getCatalogueNode($label)
 {
     $t_catalogue = TABLE_CATALOGUE;
     $t_meta = TABLE_META;
     $query_str = "SELECT *," . "{$t_catalogue}.id as id " . "FROM {$t_catalogue} " . "LEFT JOIN {$t_meta} ON {$t_catalogue}.meta_id = {$t_meta}.id " . "WHERE label='{$label}' " . "LIMIT 1";
     $query = G::$db->query($query_str) or G::fatalError("CatalogueUtils::getCatalogueNode() : " . DATABASE_ERROR_MESSAGE);
     $node = $query->fetch(PDO::FETCH_ASSOC);
     $query->closeCursor();
     $node["user_edited_data"] = PageUtils::parseItemUserData($node["created_data"], $node["last_edited_data"]);
     unset($node["created_data"], $node["last_edited_data"]);
     return $node;
 }
<?php

$products = PageUtils::getItemsList("catalogue", true);
?>


<!--div class="cropper-container">
    <img class="cropper" src="/images/catalogue/large/durr-trio.jpg">
    <div class="extra-preview">
    </div>
</div -->


<button class="button-css-blue" id="table_clean_filters">Clear filters</button>
<span id="table_rowcount"></span>
<button class="button-css-blue" id="button_minimize_table" style="float: right;">_</button>
<button class="button-css-blue" id="button_create_new" style="float: right; margin-right:5px;">Create NEW</button>
<div class="semi-spoiler" height="200">
    <table id="table_products_list" class="nodes_list_table">
        <thead>
            <tr>
                <th width="30px">id</th>
                <th width="60px" filter-type='ddl'>type</th>
                <th filter-type='ddl'>brand_id</th>
                <th>marking</th>
                <th>image</th>
                <th>label</th>
                <th width="30%">title</th>
                <th width="60px">price</th>
                <th width="60px">amount</th>
            </tr>
Esempio n. 3
0
                 //$data["itemList"] = $pages;
             } else {
                 $data["result"] = false;
                 $data["errors"] = array("access denied");
             }
             break;
     }
     break;
 case PAGE_DELETE:
     init($_POST["label"]);
     if (G::$user->isOrHigher(U_MODERATOR)) {
         $result = G::$pageData->delete();
         $data["result"] = $result;
         $data["errors"] = G::$pageData->getErrors();
         $fields = array(TABLE_PAGES . ".id", "title", "label");
         $pages = PageUtils::getItemsList($fields);
         $data["pageList"] = $pages;
     } else {
         $data["result"] = false;
         $data["errors"] = array("access denied");
     }
     break;
 case GET_CATEGORIES_TREE:
     init("admin/catalogue");
     // PageData load
     G::$pageData->load();
     if (G::$user->isOrHigher(U_MODERATOR)) {
         include $_SERVER["DOCUMENT_ROOT"] . PATH_INCLUDES . "admin/admin_categories_tree.php";
     } else {
         echo "ACCESS DENIED";
     }
Esempio n. 4
0
 /**
  * @param $type - pages|articles|catalogue
  * @return mixed
  */
 public function getItemsList($type)
 {
     if (!isset($this->lists)) {
         $this->lists = array();
     }
     if (!isset($lists[$type])) {
         $lists[$type] = PageUtils::getItemsList($type);
     }
     return $lists[$type];
 }
Esempio n. 5
0
 /** FORMATS data to string for MYSQL INSERT
  * @param $data = all key=>values
  * @param $tables - array( "table_name", ... )
  * @return array( table_name => serialized_data )
  */
 public static function serializeInsert($data, $table_name)
 {
     $table_keys = PageUtils::getTableKeys($table_name);
     $keys = array();
     $values = array();
     foreach ($data as $key => $value) {
         // ATTENTION! bullshit happens when $value=1 -> $value == "null" return true!
         //if(in_array($key, $table_keys) && $value != null &&  $value."" != "null") Just live it here. Don't delete. ELIJAH
         if (in_array($key, $table_keys)) {
             $keys[] = $key;
             $values[] = $value;
         }
     }
     return "(" . implode(",", $keys) . ") VALUES ('" . implode("','", $values) . "')";
 }
Esempio n. 6
0
 public static function renderNodeTableRow($node)
 {
     if (is_object($node)) {
         $node = (array) $node;
     }
     $str = "";
     $type_bkg = "";
     $row_bkg = "";
     $brand_bkg = "";
     $image_bkg = "";
     $label_bkg = "";
     $price_bkg = "";
     $amount_bkg = "";
     switch ($node["type"]) {
         default:
             $type = "unknown";
             $row_bkg = "#fcc";
             break;
         case TYPE_CATEGORY:
             $type = "category";
             $row_bkg = "#efe";
             break;
         case TYPE_PRODUCT_BIG:
             $type = "big";
             $row_bkg = "#def";
             break;
         case TYPE_PRODUCT_SMALL:
             $type = "small";
             break;
     }
     if ($node["hidden"] == "1") {
         $type = $type . " (hidden)";
         $row_bkg = "#999";
     }
     $brand = G::$pageData->getBrand($node["brand_id"]);
     if ($brand) {
         $brand_name = $brand->name;
     } else {
         if ($node["type"] == TYPE_CATEGORY) {
             $brand_name = "";
         } else {
             $brand_name = "unknown (id={$node['brand_id']})";
             $brand_bkg = "#fcc";
         }
     }
     if ($node["image"] == "") {
         $image_bkg = "#fcc";
     }
     $valid = PageUtils::validatePageParam($node["label"], "label");
     if (!$valid["result"]) {
         $label_bkg = "#fcc";
     }
     $price = $node["price"];
     $amount = $node["amount"];
     if ($node["type"] == TYPE_CATEGORY) {
         $price = "";
         $amount = "";
     } else {
         if ($node["price"] <= 0) {
             $price_bkg = "#fe3";
         }
         if ($node["amount"] <= 0) {
             $amount_bkg = "#fe3";
         }
     }
     $str .= "<tr " . ($row_bkg ? "bgcolor='{$row_bkg}'" : "") . " name={$node['id']}>" . "<td>{$node['id']}</td>" . "<td " . ($type_bkg ? "bgcolor='{$type_bkg}'" : "") . ">{$type}</td>" . "<td " . ($brand_bkg ? "bgcolor='{$brand_bkg}'" : "") . ">{$brand_name}</td>" . "<td>{$node['original_marking']}</td>" . "<td " . ($image_bkg ? "bgcolor='{$image_bkg}'" : "") . ">{$node['image']}</td>" . "<td " . ($label_bkg ? "bgcolor='{$label_bkg}'" : "") . ">{$node['label']}</td>" . "<td>{$node['title']}</td>" . "<td " . ($price_bkg ? "bgcolor='{$price_bkg}'" : "") . ">{$price}</td>" . "<td " . ($amount_bkg ? "bgcolor='{$amount_bkg}'" : "") . ">{$amount}</td>" . "</tr>\n";
     /*
     $str .= "<tr " . ($row_bkg ? "bgcolor=$row_bkg" : "") . " name=$node[id]>" .
         "<td>$node[id]</td>" .
         "<td " . ($type_bkg ? "bgcolor=$type_bkg" : "") . ">$type</td>" .
         "<td " . ($brand_bkg ? "bgcolor=$brand_bkg" : "") . ">$brand_name</td>" .
         "<td>$node[original_marking]</td>" .
         "<td " . ($image_bkg ? "bgcolor=$image_bkg" : "") . ">$node[image]</td>" .
         "<td " . ($label_bkg ? "bgcolor=$label_bkg" : "") . ">$node[label]</td>" .
         "<td>$node[title]</td>" .
         "<td " . ($price_bkg ? "bgcolor=$price_bkg" : "") . ">$price</td>" .
         "<td " . ($amount_bkg ? "bgcolor=$amount_bkg" : "") . ">$amount</td>" .
         "</tr>\n";    }
     */
     return self::encodingChecked($str);
 }