Пример #1
0
 public static function addChildToParent($child_id, $parent_id)
 {
     $t_catalogue = TABLE_CATALOGUE;
     $query_str = "UPDATE {$t_catalogue} " . "SET children_id = " . "IF(children_id='','{$child_id}',CONCAT_WS(',', children_id, '{$child_id}')) " . "WHERE id = '{$parent_id}' LIMIT 1";
     $query = G::$db->exec($query_str);
     G::logMessage(" Add {$child_id} to {$parent_id} = {$query} " . print_r(G::$db->errorInfo(), true));
 }
Пример #2
0
 /** Checks if user with $login exists
  * @param $login
  * @return bool
  */
 private function user_exists($login)
 {
     G::logMessage(" login = {$login}");
     if (strlen($login) <= 0) {
         return false;
     }
     $query = G::$db->query("SELECT * FROM " . TABLE_USERS . " WHERE login='******' LIMIT 1");
     $users = $query->fetchAll();
     if (count($users) > 0) {
         return true;
     }
     return false;
 }
Пример #3
0
 private function unserializeProps($data)
 {
     $properties = array();
     if ($data == "") {
         return $properties;
     }
     parse_str($data, $data);
     foreach ($data as $key => $value) {
         $properties[] = G::$pageData->propsManager->createProperty($key, $value);
         G::logMessage("props: {$key} = {$value}");
     }
     return $properties;
 }
 /**
  * @param $value (float)
  * @param $from - (int) id || (string) mark
  * @param $to - (int) id || (string) mark
  * @return float
  */
 public function convert($value, $from, $to)
 {
     if ($from === $to) {
         return $value;
     }
     $currency_from = $this->identifyCurrency($from);
     $currency_to = $this->identifyCurrency($to);
     G::logMessage("CC::convert() -> " . $to . " " . $currency_to);
     if ($currency_from["id"] == $currency_to["id"]) {
         $result = $value;
     } else {
         $result = $value * $currency_from["rate"] / $currency_to["rate"];
     }
     return $result;
 }
Пример #5
0
 public function createProperty($name, $value)
 {
     $base_prop_data = $this->getPropDataByName($name);
     if ($base_prop_data) {
         switch ($base_prop_data["type"]) {
             case PROP_TYPE_SWITCH:
             case PROP_TYPE_SWITCH_STRICT:
                 return new ProductProperty($value, $base_prop_data);
             case PROP_TYPE_COLOR:
                 return new ColorProperty($value, $base_prop_data);
             case PROP_TYPE_EXIST:
                 return new ExistProperty($value, $base_prop_data);
             case PROP_TYPE_RANGE:
                 G::logMessage("CATCH RANGE TYPE");
                 return new RangeProperty($value, $base_prop_data);
             default:
                 return BaseProductProperty($value, $base_prop_data);
         }
     }
 }
Пример #6
0
         }
         // TODO preg_match img_filename
         if (!isset($filename) || !strlen($filename)) {
             $errors[] = RenderUtils::renderError("Invalid image data!");
         }
         if (!isset($new_filename) || !strlen($new_filename) || !preg_match(LABEL_REG_EXP, $new_filename)) {
             $errors[] = RenderUtils::renderError("Invalid filename!");
         }
         if (!count($errors)) {
             if (copy(ROOT . "/images/catalogue/_tmp/" . $filename, ROOT . $path . $new_filename . ".jpg")) {
                 G::logMessage("[" . ROOT . "/images/catalogue/_tmp/" . $filename . "] successfully copied to [" . ROOT . $path . $new_filename . ".jpg]");
                 $result = true;
                 $tr = RenderUtils::renderImageDataTableRow("#", $path, $new_filename . ".jpg");
                 unlink(ROOT . "/images/catalogue/_tmp/" . $filename);
             } else {
                 G::logMessage("Failed coping [" . ROOT . "/images/catalogue/_tmp/" . $filename . "] to [" . ROOT . $path . $new_filename . ".jpg]");
             }
         }
     } else {
         $errors[] = RenderUtils::renderError("Access denied!");
     }
     if (count($errors)) {
         $result = false;
     }
     $data = array("result" => $result, "errors" => $errors, "tr" => $tr);
     break;
 case DELETE_IMAGE:
     init("admin/images");
     $errors = array();
     $result = false;
     if (G::$user->isOrHigher(U_MODERATOR)) {
Пример #7
0
 private function getBrandItem($brand_label = "")
 {
     if ($brand_label == "") {
         $brand_label = $this->address["page"];
     }
     $brand = $this->getBrandByLabel($brand_label);
     if ($brand) {
         $url = strlen($brand->url) ? "<a href='{$brand->url}'>{$brand->name} на сайте</a>" : "";
         $data = array("id" => $brand->id, "label" => $brand->label, "brand_name" => $brand->name, "brand_full_name" => $brand->full_name, "logo_small_url" => $brand->getLogoUrl("small"), "logo_medium_url" => $brand->getLogoUrl("medium"), "logo_large_url" => $brand->getLogoUrl("large"), "country_name" => $brand->getCountry(), "robots" => "index,nofollow", "content" => $brand->description . (strlen($url) ? "<p>{$url}</p>" : ""));
     } else {
         G::logMessage("Brand '{$brand_label}' not found");
     }
     return $data;
 }
Пример #8
0
 public static function cropProductImage($filename, $width, $height, $x = 0, $y = 0, $new_width = 0, $new_height = 0)
 {
     $data = array();
     $file_path = ROOT . PATH_CAT_IMAGES . "_tmp/";
     $data["img_filename"] = $new_filename = "new" . date("U") . rand(100, 10000000) . ".jpg";
     if (file_exists($file_path . $filename)) {
         $img = @imagecreatefromjpeg($file_path . $filename);
         // get image
         G::logMessage(">> img = {$img}");
         if ($new_width == 0 || $new_height == 0) {
             $new_width = $width;
             $new_height = $height;
         }
         G::logMessage(">> size = {$width} x {$height}");
         $img = self::cropImage($img, $width, $height, $x, $y, $new_width, $new_height);
         // crop and resize
         G::logMessage(">> {$img} cropped = {$img}");
         $data["result"] = imagejpeg($img, $file_path . $new_filename);
         // save image
         G::logMessage(">> result = " . $data["result"]);
         imagedestroy($img);
         // unload reference
         unlink($file_path . $filename);
         // delete tmp file
     } else {
         G::logMessage("NO file");
     }
     return $data;
 }
                <th>label</th>
                <th width="250px">&nbsp;</th>
            </tr>
        </thead>
        <tbody>
    <?php 
for ($i = 0; $i < count($files); $i++) {
    $file = $files[$i];
    $file_name = substr($file, 0, stripos($file, "."));
    $labels = array();
    foreach ($products as $pr) {
        if (preg_match("/[\\=?\\&?]/", $pr["image"])) {
            parse_str($pr["image"], $image_data);
            $image = $image_data[$image_type];
            //DEBUG
            G::logMessage("image >>> " . $image . " " . print_r($image_data, true));
            //
        } else {
            // DEBUG
            $image = $pr["image"];
            //
        }
        if ($image == $file_name) {
            $labels[] = "(<a href='" . $view_path . $pr["label"] . "' target='_blank'>{$pr['label']}</a>) {$pr['title']}";
        }
    }
    $text = implode("<br />", $labels);
    echo RenderUtils::renderImageDataTableRow($i, $path, $file, $text);
}
?>
        </tbody>