示例#1
0
文件: Utils.php 项目: neoff/mywork
function StripTags($string)
{
    $patterns = array("/<br\\s*?\\/?>/", "/&nbsp;/", "/(&laquo;|&raquo;)/", "/&/", "/(<|>)/");
    $replacements = array("\n", " ", '"', " and ", "");
    $string = preg_replace($patterns, $replacements, $string);
    $string = stripslashes($string);
    $string = html_entity_decode($string);
    $string = strip_tags($string);
    return ToUTF($string);
}
示例#2
0
文件: Actions.php 项目: neoff/mywork
 public function index($array)
 {
     list($region_id, $category_id) = $array;
     $options = array('parent_id' => $category_id);
     $parents = Models\Category::find('first', array('conditions' => "category_id = {$category_id}"));
     //print_r($parents->attributes());
     if (!$category_id) {
         $options = array('conditions' => "parent_id is null");
         $c_parrent_name = $c_name = "Список категорий";
         $c_parrent_id = $c_id = 0;
     } else {
         if (!$parents->parent_id) {
             $c_parrent_id = 0;
             $c_parrent_name = "Список категорий";
         } else {
             $c_parrent_id = $parents->parent_id;
             $p = Models\Category::first(array('category_id' => $c_parrent_id));
             $c_parrent_name = ToUTF($p->name);
         }
         $options = array('parent_id' => $category_id);
         $c_name = ToUTF($parents->name);
         $c_id = $parents->category_id;
     }
     $categorys = Models\Category::find('all', $options);
     $parrent = $this->Set("parent_category");
     $parrent->addChild("category_id", $c_parrent_id);
     $parrent->addChild("category_name", $c_parrent_name);
     if ($categorys) {
         $categories = $this->Set("categories");
         $categories->addAttribute("category_id", $category_id);
         $categories->addAttribute("category_name", $c_name);
         foreach ($categorys as $key => $val) {
             $amount = Models\Category::count(array('conditions' => "parent_id = {$val->category_id}"));
             if (!$amount) {
                 $ids = new SetId($val->dirid, $val->classid, $val->grid);
                 $amount = count(Models\Category::warez($region_id, $ids));
             }
             $category = $categories->addChild("category");
             $category->addChild("category_id", $val->category_id);
             $category->addChild("category_name", ToUTF($val->name));
             $category->addChild("amount", $amount);
             $icon = $category->addChild("category_icon");
             $icon->addAttribute("width", "");
             $icon->addAttribute("height", "");
         }
     }
 }
示例#3
0
文件: Shops.php 项目: neoff/mywork
 public function index($shop_id = array(0, false, false))
 {
     list($shop_id, $width, $height) = $shop_id;
     $options = array('region_id' => $shop_id, "publication" => 1);
     $shop_m = Models\Shops::all($options);
     //print_r($shops);
     $this->shops = "";
     $this->shops->addAttribute("region_id", $shop_id);
     list($longitude, $latitude) = array("", "");
     foreach ($shop_m as $key => $val) {
         $shop = $this->shops->addChild("shop");
         $shop->addChild("shop_id", $val->shop_id);
         $shop->addChild("shop_name", ToUTF($val->name));
         $metro = $shop->addChild("metro");
         if ($val->metro) {
             $c = explode(",", $val->metro);
             if (count($c) > 1) {
                 foreach ($c as $v) {
                     $metro->addChild("station", preg_replace("/^\\s+?/i", "", ToUTF($v)));
                 }
             } else {
                 $metro->addChild("station", ToUTF($val->metro));
             }
         }
         $adresss = ToUTF($val->address);
         $pattern = array("/^МО,\\s*?г.\\s*?/", "/^МО,\\s*?/", "/^ул.\\s*/", "/^г.\\s*?Москва,\\s*?ул.\\s*/", "/^г.\\s*?Москва,\\s*/", "/^Москва,\\s*ул.\\s*/", "/^Москва,\\s*/", "/^г.\\s*/", "/^Коммунальная зона\\s*/", "/^\\s+?/");
         $shop->addChild("address", preg_replace($pattern, '', $adresss));
         $shop->addChild("day_hours", ToUTF($val->day_hours));
         $shop->addChild("holiday_hours", ToUTF($val->holyday_hours));
         $shop->addChild("phone", ToUTF($val->phone));
         $coordinates = $shop->addChild("coordinates");
         $val->coordinates();
         //if($val->longitude && $val->latitude)
         //{
         $coordinates->addChild("longitude", $val->longitude);
         $coordinates->addChild("latitude", $val->latitude);
         //}
         $shop->addChild("wayTo", StripTags($val->howto));
         $shop->addChild("zoom", $val->map_zoom);
         $images = $shop->addChild("images");
         $image = $images->addChild("image", "http://www.mvideo.ru/imgs/shop/face/big_{$val->p}.gif");
         $image->addAttribute("width", "500");
         $image->addAttribute("height", "375");
     }
 }
示例#4
0
文件: Region.php 项目: neoff/mywork
 public function index($region_id = 0)
 {
     $region_m = Models\Regions::all(array("virtual" => 0));
     $this->regions = "";
     //print_r($region_m);
     foreach ($region_m as $key => $val) {
         if ($val->id != 8) {
             $region = $this->regions->addChild("region");
             $region->addChild("region_id", $val->id);
             $region->addChild("region_name", ToUTF($val->name));
             $region->addChild("region_domain", $val->domain);
             $coordinates = $region->addChild("coordinates");
             $val->coordinates();
             $coordinates->addChild("longitude", $val->longitude);
             $coordinates->addChild("latitude", $val->latitude);
         }
     }
 }
示例#5
0
文件: Product.php 项目: neoff/mywork
 public function index($array)
 {
     //print_r($array);
     list($region_id, $product_id, $ask, $reviews, $page) = $array;
     $options = array("_warecode" => $product_id);
     list($where, $array) = Models\Warez::SetParam($region_id, $options);
     $productes = Models\Warez::sql($region_id, $where, $array);
     if ($productes) {
         $productes = $productes[0];
         $rfile = dirname(dirname(dirname($_SERVER["SCRIPT_FILENAME"])));
         require_once $rfile . '/www/classifier_' . $region_id . '.inc.php';
         $d = $productes->dirid * self::$Mult;
         $c = $productes->classid * self::$MultC;
         $g = $productes->grid * self::$MultG;
         $category->category_id = $d + $c + $g;
         $category->name = $Groups[$productes->dirid][$productes->classid][$productes->grid];
         $this->categories = "";
         $this->categories->addChild("category_id", $category ? $category->category_id : 0);
         $this->categories->addChild("category_name", $category ? ToUTF($category->name) : "Список категорий");
         $this->product = "";
         if ($productes->inetqty > 0) {
             $this->product->addAttribute("inetSale", 1);
         }
         $dic = $productes->getInetDiscountStatus($productes->warecode, $region_id);
         $this->product->addAttribute("card_discount", $dic);
         $this->product->addChild("product_id", $product_id);
         $this->product->addChild("region_id", $region_id);
         $this->product->addChild("title", StripTags($productes->ware));
         $imgs = $this->product->addChild("images");
         $img = $imgs->addChild("img", "http://www.mvideo.ru/Pdb/{$product_id}.jpg");
         $img->addAttribute("width", "180");
         $img->addAttribute("height", "180");
         $img->addAttribute("main", "1");
         $mov = $this->product->addChild("movies");
         //$mov->addChild("video", "http://www.mvideo.ru/Pdb/$product_id.jpg");
         $this->product->addChild("inet_price", $productes->inetprice);
         if ($productes->oldprice) {
             $old_price = $productes->oldprice;
         } else {
             $old_price = $productes->price;
         }
         $this->product->addChild("old_price", $old_price);
         $this->product->addChild("price", $productes->price);
         $productes->getRatingRev();
         $this->product->addChild("rating", $productes->rating);
         $this->product->addChild("reviews_num", $productes->reviews);
         $productes->getDesctiptions();
         $this->product->addChild("description", StripTags($productes->description));
         //if(!$ask && !$reviews)
         //{
         $options = $this->product->addChild("options");
         $options_m = Models\Optionlist::all(array('warecode' => $product_id));
         foreach ($options_m as $key => $val) {
             $option = $options->addChild("option");
             $option->addChild("name", StripTags($val->prname));
             $option->addChild("value", StripTags($val->prval));
         }
         //}
         if ($ask) {
             $limit = true;
             if ($ask == 2) {
                 $limit = false;
             }
             $ask = $this->product->addChild("aks");
             //$ask_m=array();
             $ask_m = Models\Link::getAccess($region_id, $product_id, $limit);
             //print_r($ask_m);
             $group = "";
             foreach ($ask_m as $key => $val) {
                 if ($group != $val->grid) {
                     $group = $val->grid;
                     $groups_m = Models\Groups::find('fist', array("grid" => $val->grid));
                     $gr = $ask->addChild("group");
                     $gr->addAttribute("id", $val->grid);
                     $gr->addAttribute("title", StripTags($groups_m->grname));
                 }
                 $prod = $gr->addChild("product");
                 $prod->addChild("product_id", $val->warecode);
                 $prod->addChild("title", StripTags($val->ware));
                 $prod->addChild("inet_price", $val->inetprice);
                 if ($val->oldprice) {
                     $old_price = $val->oldprice;
                 } else {
                     $old_price = $val->price;
                 }
                 $prod->addChild("old_price", $old_price);
                 $prod->addChild("price", $val->price);
                 $val->getRatingRev();
                 $prod->addChild("rating", $val->rating);
                 $prod->addChild("reviews_num", $val->reviews);
                 $val->getDesctiptions();
                 $prod->addChild("description", StripTags($val->description));
                 $image = $prod->addChild("image", "http://www.mvideo.ru/Pdb/{$val->warecode}.jpg");
                 $image->addAttribute("width", "180");
                 $image->addAttribute("height", "180");
             }
         }
         if ($reviews) {
             $reviews = $this->product->addChild("reviews");
             $reviews_m = Models\Reviews::all(array('warecode' => $product_id, "approved" => 1));
             foreach ($reviews_m as $key => $val) {
                 $review = $reviews->addChild("review");
                 $date = "";
                 if ($val->add_date) {
                     $date = $val->add_date->format("d.m.Y");
                 }
                 $review->addChild("date", $date);
                 $review->addChild("author", ToUTF($val->name));
                 $review->addChild("city", ToUTF($val->city));
                 $review->addChild("rating", $val->rating);
                 $review->addChild("title", StripTags($val->title));
                 $review->addChild("text", StripTags($val->text));
             }
         }
     }
 }
示例#6
0
文件: Category.php 项目: neoff/mywork
 private function displayProductNode()
 {
     $name = $this->parent_name;
     if (property_exists($this->parents, 'name')) {
         $name = ToUTF($this->parents->name);
     }
     $this->products = "";
     $this->products->addAttribute("category_id", $this->category_id);
     $this->products->addAttribute("category_name", $name);
 }