Beispiel #1
0
 public static function row()
 {
     $args = !self::$cate ? array('status' => '1') : array('status' => '1', 'id' => self::$cate);
     $rsnum = CRUD::dataFetch('ad_cate', $args);
     if (!empty($rsnum)) {
         $dataRow = CRUD::$data;
         $nowDate = date("Y-m-d");
         foreach ($dataRow as $key => $cate) {
             $rsnum = CRUD::dataFetch('ad', array('langtag' => CORE::$langtag, 'parent' => $cate["id"], 'custom' => "status = '1' or (status = '2' and startdate <= '{$nowDate}' and limitdate >= '{$nowDate}')"));
             if (!empty($rsnum)) {
                 VIEW::newBlock("TAG_AD_BLOCK" . $cate["id"]);
                 foreach (CRUD::$data as $key => $row) {
                     VIEW::newBlock("TAG_AD_LIST" . $cate["id"]);
                     foreach ($row as $field => $var) {
                         switch ($field) {
                             case "link":
                                 if (empty($var)) {
                                     $var = '#';
                                 }
                             default:
                                 VIEW::assign("VALUE_" . strtoupper($field), $var);
                                 break;
                         }
                     }
                     IMAGES::load('ad', $row["id"]);
                     list($images) = IMAGES::$data;
                     VIEW::assign(array("VALUE_IMAGE" => $images["path"], "VALUE_ALT" => $images["alt"], "VALUE_TITLE" => $images["title"]));
                 }
             }
         }
     }
 }
Beispiel #2
0
 private static function resize()
 {
     list($width, $height, $path) = self::$args;
     $realPath = base64_decode($path);
     IMAGES::resize($realPath, $width, $height);
     #self::error();
 }
Beispiel #3
0
 private static function row()
 {
     CORE::res_init('fix', 'css');
     if (!empty(self::$cate)) {
         $rsnum = CRUD::dataFetch('news', array('parent' => self::$cate, 'status' => '1', 'langtag' => CORE::$langtag), false, array('sort' => CORE::$cfg["sort"]));
     } else {
         $rsnum = CRUD::dataFetch('news', array('status' => '1', 'langtag' => CORE::$langtag), false, array('sort' => CORE::$cfg["sort"]));
     }
     if (!empty($rsnum)) {
         #VIEW::newBlock("TAG_NEWS_BLOCK");
         $dataRow = CRUD::$data;
         SCHEMA::make('news_list', $dataRow);
         foreach ($dataRow as $key => $row) {
             VIEW::newBlock("TAG_NEWS_LIST");
             foreach ($row as $field => $var) {
                 switch ($field) {
                     case "showdate":
                         VIEW::assign("VALUE_" . strtoupper($field), date("Y.m.d", strtotime($var)));
                         break;
                     default:
                         VIEW::assign("VALUE_" . strtoupper($field), $var);
                         break;
                 }
             }
             IMAGES::load('news', $row["id"]);
             list($images) = IMAGES::$data;
             VIEW::assign(array("VALUE_LINK" => self::dataLink($row["parent"], $row), "VALUE_IMAGE" => $images["path"], "VALUE_ALT" => $images["alt"], "VALUE_TITLE" => $images["title"]));
         }
         # SEO
         $cate_rsnum = CRUD::dataFetch('news_cate', array('id' => self::$cate));
         if (!empty($cate_rsnum)) {
             list($cate_row) = CRUD::$data;
             SEO::load($cate_row["seo_id"]);
             if (empty(SEO::$data["h1"])) {
                 SEO::$data["h1"] = $cate_row["subject"];
             }
         } else {
             SEO::load('news');
             if (empty(SEO::$data["h1"])) {
                 SEO::$data["h1"] = CORE::$lang["news"];
             }
         }
         SEO::output();
         CRUMBS::fetch('news', $cate_row);
     } else {
         VIEW::newBlock("TAG_NONE");
     }
 }
Beispiel #4
0
 public static function related($related = false)
 {
     if (empty($related)) {
         return false;
     }
     $relatedArray = json_decode($related, true);
     $rsnum = CRUD::dataFetch('products', array('id' => $relatedArray, 'status' => '1', 'langtag' => CORE::$langtag));
     if (!empty($rsnum)) {
         VIEW::newBlock("TAG_RELATED_BLOCK");
         $dataRow = CRUD::$data;
         foreach ($dataRow as $key => $row) {
             VIEW::newBlock("TAG_RELATED_LIST");
             IMAGES::load('products', $row["id"]);
             list($image) = IMAGES::$data;
             VIEW::assign(array("VALUE_ID" => $row['id'], "VALUE_SUBJECT" => $row['subject'], "VALUE_IMAGE" => $image['path'], "VALUE_ALT" => $image['alt'], "VALUE_TITLE" => $image['title'], "VALUE_LINK" => PRODUCTS::dataLink($row['parent'], $row), "VALUE_PRICE" => $row['price']));
         }
     }
 }
Beispiel #5
0
 private static function add()
 {
     #$stock_id = array_shift(CORE::$args);
     #$stock_row = STOCK::fetch($stock_id);
     $p_row = self::p_data($_POST["id"]);
     #$unship_num = self::stock_unship($stock_row["id"]); # 未出貨庫存
     #$real_num = $stock_row["amount"] - $unship_num; # 可用庫存
     $num = empty($_POST["amount"]) || $_POST["amount"] == "null" ? 1 : $_POST["amount"];
     # 訂購數量
     IMAGES::load('products', $_POST["id"]);
     list($images) = IMAGES::$data;
     $cart = array('id' => $p_row["id"], 'name' => $p_row["subject"], 'image' => $images["path"], 'price' => !empty($p_row["discount"]) ? $p_row["discount"] : $p_row["price"], 'amount' => $num, 'subtotal' => $num * $p_row["price"]);
     SESS::write('cart', $cart["id"], $cart);
     /*
     if($real_num >= $num){
     	SESS::write('cart',$cart["id"],$cart);
     }else{
     	$cart["amount"] = $real_num;
     	$cart["subtotal"] = $real_num * $stock_row["price"];
     	SESS::write('cart',$stock_row["id"],$cart);
     }
     */
     header('location: ' . CORE::$root . 'cart/');
 }
Beispiel #6
0
 private static function products_detail($args)
 {
     $output = array('name' => $args['subject'], 'description' => preg_replace('/\\s(?=)/', '', strip_tags($args['content'])));
     if (!empty($args['serial'])) {
         $output['serialNumber'] = $args['serial'];
     }
     IMAGES::load('products', $args['id']);
     if (is_array(IMAGES::$data)) {
         list($image) = IMAGES::$data;
         $output['image'] = self::image($image['path'], $image['width'], $image['height']);
     }
     self::$schema[] = self::basic('IndividualProduct', $output);
 }
Beispiel #7
0
 private static function detail($id)
 {
     $rsnum = CRUD::dataFetch('ad', array('id' => $id));
     if (!empty($rsnum)) {
         list($row) = CRUD::$data;
         foreach ($row as $field => $var) {
             switch ($field) {
                 case "cateID":
                     VIEW::assignGlobal("VALUE_" . strtoupper($field) . "_OPTION", AD::cateSelect($var));
                     break;
                 case "status":
                     VIEW::assignGlobal("VALUE_" . strtoupper($field) . "_CK" . $var, 'selected');
                     break;
                 default:
                     VIEW::assignGlobal("VALUE_" . strtoupper($field), $var);
                     break;
             }
         }
         IMAGES::output('ad', $row["id"]);
         SEO::load($row["seo_id"]);
         SEO::output();
         $last_page = SESS::get("PAGE");
         if (!empty($last_page)) {
             VIEW::assignGlobal("VALUE_BACK_LINK", CORE::$manage . "ad/page-{$last_page}/");
         } else {
             VIEW::assignGlobal("VALUE_BACK_LINK", CORE::$manage . "ad/");
         }
     } else {
         self::$temp["MAIN"] = self::$temp_option["MSG"];
         CORE::msg(self::$lang["no_args"], CORE::$manage . 'ad/');
     }
 }
 function __construct($fileName)
 {
     if (!$this->testGDInstalled()) {
         if ($this->debug) {
             throw new Exception('The GD Library is not installed.');
         } else {
             throw new Exception();
         }
     }
     $this->initialise();
     // *** Save the image file name. Only store this incase you want to display it
     $this->fileName = $fileName;
     $this->fileExtension = fix_strtolower(strrchr($fileName, '.'));
     // *** Open up the file
     $this->image = $this->openImage($fileName);
     // *** Assign here so we don't modify the original
     $this->imageResized = $this->image;
     // *** If file is an image
     if ($this->testIsImage($this->image)) {
         // *** Get width and height
         $this->width = imagesx($this->image);
         $this->widthOriginal = imagesx($this->image);
         $this->height = imagesy($this->image);
         $this->heightOriginal = imagesy($this->image);
         /*  Added 15-09-08
          *  Get the filesize using this build in method.
          *  Stores an array of size
          *
          *  $this->imageSize[1] = width
          *  $this->imageSize[2] = height
          *  $this->imageSize[3] = width x height
          *
          */
         if (class_exists('IMAGES')) {
             $this->imageSize = IMAGES::size($this->fileName);
         } else {
             $this->imageSize = getimagesize($this->fileName);
         }
     } else {
         $this->errorArray[] = 'File is not an image';
     }
 }
Beispiel #9
0
 private static function seek($id = false)
 {
     if (empty($_POST['call'])) {
         echo 'NONE';
     }
     $seekStr = $_POST['call'];
     if (!empty($id)) {
         $rsnum = CRUD::dataFetch('gallery', array('id' => $id), array('related'));
         if (!empty($rsnum)) {
             list($nowRow) = CRUD::$data;
             if (!empty($nowRow['related'])) {
                 $relatedArray = json_decode($nowRow['related'], true);
                 $seekFilter = "id NOT IN('" . implode("','", $relatedArray) . "','" . $id . "')";
                 $sk = array('status' => '1', 'langtag' => CORE::$langtag, 'subject' => '%' . $seekStr . '%', 'custom' => $seekFilter);
             } else {
                 $sk = array('status' => '1', 'langtag' => CORE::$langtag, 'subject' => '%' . $seekStr . '%', 'id' => "!{$id}");
             }
         }
     }
     if (empty($sk) || !is_array($sk)) {
         $sk = array('status' => '1', 'langtag' => CORE::$langtag, 'subject' => '%' . $seekStr . '%');
     }
     $rsnum = CRUD::dataFetch('gallery', $sk);
     if (!empty($rsnum)) {
         $dataRow = CRUD::$data;
         foreach ($dataRow as $key => $row) {
             foreach ($row as $field => $var) {
                 $output[$key][$field] = rawurlencode($var);
             }
             IMAGES::load('gallery', $row["id"]);
             list($image) = IMAGES::$data;
             $output[$key]['image'] = '<img src="' . $image['path'] . '" style="width: 100px;">';
             $output[$key]['link'] = GALLERY::dataLink($row['parent'], $row);
         }
         if (is_array($output)) {
             echo json_encode($output);
         }
     } else {
         echo 'NONE';
     }
 }
Beispiel #10
0
 public static function del($tb_name, $id)
 {
     $rsnum = IMAGES::load($tb_name, $id);
     if (!empty($rsnum)) {
         foreach (IMAGES::$data as $key => $row) {
             DB::delete(CORE::$prefix . '_images', array('id' => $row["id"]));
             self::delCrop($row['crop'], $row['crop_m']);
         }
     }
 }
Beispiel #11
0
 public static function dataDel($tb_name, array $args)
 {
     $rsnum = CRUD::dataFetch($tb_name, $args);
     if (!empty($rsnum)) {
         list($row) = CRUD::$data;
         DB::delete(CORE::$prefix . "_" . $tb_name, $args);
         # 去除語系連結
         if (isset($row["lang_id"]) && !empty($row["lang_id"])) {
             $lang_rsnum = CRUD::dataFetch("lang", array("id" => $row["lang_id"]));
             if (!empty($lang_rsnum)) {
                 list($lang_row) = CRUD::$data;
                 $lang_related = json_decode($lang_row["related"], true);
                 if (is_array($lang_related)) {
                     unset($lang_related[CORE::$langtag]);
                     if (count($lang_related) >= 1) {
                         $new_related = array('id' => $lang_row["id"], 'related' => json_encode($lang_related));
                         CRUD::dataUpdate("lang", $new_related);
                     } else {
                         $related_none = true;
                     }
                 } else {
                     $related_none = true;
                 }
                 # 沒有可連結資料,刪除整筆記錄
                 if ($related_none) {
                     DB::delete(CORE::$prefix . "_lang", array('id' => $row["lang_id"]));
                 }
             }
         }
         # 刪除 seo 紀錄
         if (isset($row["seo_id"]) && !empty($row["seo_id"])) {
             DB::delete(CORE::$prefix . "_seo", array('id' => $row["seo_id"]));
         }
         # 刪除圖片記錄
         IMAGES::del($tb_name, $row["id"]);
         return true;
     } else {
         return false;
     }
 }
Beispiel #12
0
 private static function detail()
 {
     $rsnum = CRUD::dataFetch('products', array('id' => self::$id));
     if (!empty($rsnum)) {
         list($row) = CRUD::$data;
         foreach ($row as $field => $var) {
             VIEW::assignGlobal("VALUE_" . strtoupper($field), $var);
         }
         SCHEMA::make('products_detail', $row);
         VIEW::assignGlobal("VALUE_BACK_LINK", self::dataLink(self::$cate));
         IMAGES::load('products', $row["id"]);
         foreach (IMAGES::$data as $key => $images) {
             switch ($key) {
                 case 0:
                     break;
                 case 1:
                     foreach ($images as $field => $var) {
                         VIEW::assignGlobal("IMAGE_" . strtoupper($field), $var);
                     }
                 default:
                     VIEW::newBlock("TAG_IMAGES");
                     foreach ($images as $field => $var) {
                         VIEW::assign("IMAGES_" . strtoupper($field), $var);
                     }
                     break;
             }
         }
         if (empty($row["discount"])) {
             VIEW::assignGlobal("DISCOUNT_NONE", 'style="display: none;"');
         }
         SEO::load($row["seo_id"]);
         if (empty(SEO::$data["h1"])) {
             SEO::$data["h1"] = $row["subject"];
         }
         SEO::output();
         CRUMBS::fetch('products', $row);
         while (++$i <= 99) {
             VIEW::newBlock("TAG_AMOUNT_LIST");
             VIEW::assign("VALUE_AMOUNT", $i);
         }
         PRODUCTS::related($row['related']);
     }
 }
Beispiel #13
0
 private static function hot($nowID)
 {
     $rsnum = CRUD::dataFetch('blog', array('status' => '1', 'hot' => '1', 'id' => '!' . $nowID), false, array('rand()' => ''), '0,5');
     if (!empty($rsnum)) {
         VIEW::newBlock("TAG_HOT_BLOCK");
         $dataRow = CRUD::$data;
         foreach ($dataRow as $row) {
             VIEW::newBlock("TAG_HOT_LIST");
             foreach ($row as $field => $var) {
                 switch ($field) {
                     case "content":
                         $maxLength = 15;
                         $var = mb_strlen($var, 'UTF-8') > $maxLength ? mb_substr(strip_tags($var), 0, $maxLength, 'UTF-8') . '...' : $var;
                         break;
                 }
                 VIEW::assign("VALUE_" . strtoupper($field), $var);
             }
             IMAGES::load('blog', $row["id"]);
             list($images) = IMAGES::$data;
             VIEW::assign(array("VALUE_IMAGE" => $images["path"], "VALUE_ALT" => $images["alt"], "VALUE_TITLE" => $images["title"], 'VALUE_LINK' => self::dataLink($row["parent"], $row)));
         }
     }
 }
Beispiel #14
0
 private static function detail()
 {
     $rsnum = CRUD::dataFetch('gallery', array('id' => self::$id));
     if (!empty($rsnum)) {
         list($row) = CRUD::$data;
         foreach ($row as $field => $var) {
             switch ($field) {
                 case "dirpath":
                     #$images = self::dirLoad($var);
                     #continue;
                     break;
             }
             $output["VALUE_" . strtoupper($field)] = $var;
         }
         IMAGES::load('gallery', $row['id']);
         if (is_array(IMAGES::$data)) {
             foreach (IMAGES::$data as $images) {
                 VIEW::newBlock('TAG_GALLERY_LIST');
                 foreach ($images as $field => $var) {
                     $imgOutput['IMAGE_' . strtoupper($field)] = $var;
                 }
                 VIEW::assign($imgOutput);
             }
         }
         $output['VALUE_BACK_LINK'] = self::dataLink(self::$cate);
         VIEW::assignGlobal($output);
         SEO::load($row["seo_id"]);
         if (empty(SEO::$data["h1"])) {
             SEO::$data["h1"] = $row["subject"];
         }
         SEO::output();
         CRUMBS::fetch('gallery', $row);
         self::other($row['id']);
         MESSAGE::$func = 'gallery';
         MESSAGE::$dataID = $row['id'];
         new MESSAGE();
         VIEW::assignGlobal("TAG_MESSAGE_BLOCK", MESSAGE::$output);
         GALLERY::related($row['related']);
     } else {
         header('location: ' . CORE::$root . 'gallery/');
     }
 }