public function load($param)
 {
     $key = $this->build_key(__CLASS__, $param);
     $GLOBALS['fcache']->set_dir(APP_ROOT_PATH . "public/runtime/data/" . __CLASS__ . "/");
     $cate_list = $GLOBALS['fcache']->get($key);
     if ($cate_list === false) {
         $pid = intval($param['pid']);
         $extwhere = $param['extwhere'];
         require_once APP_ROOT_PATH . "system/utils/child.php";
         require_once APP_ROOT_PATH . "system/utils/tree.php";
         $ids_util = new child("deal_cate");
         $ids = $ids_util->getChildIds($pid);
         $ids[] = $pid;
         $cate_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_cate where is_effect = 1 and is_delete = 0 and id in (" . implode(",", $ids) . ") {$extwhere} order by sort desc");
         foreach ($cate_list as $k => $v) {
             if ($v['uname'] != '') {
                 $curl = url("youhui", "ycate", array("id" => $v['uname']));
             } else {
                 $curl = url("youhui", "ycate", array("id" => $v['id']));
             }
             $cate_list[$k]['url'] = $curl;
             $sub_ids = $ids_util->getChildIds($v['id']);
             $sub_ids[] = $v['id'];
             $cate_list[$k]['count'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where is_delete = 0 and is_effect = 1 and is_shop = 2 and cate_id in (" . implode(",", $sub_ids) . ")");
         }
         $tree_util = new tree();
         $cate_list = $tree_util->toFormatTree($cate_list, 'name');
         $GLOBALS['fcache']->set_dir(APP_ROOT_PATH . "public/runtime/data/" . __CLASS__ . "/");
         $GLOBALS['fcache']->set($key, $cate_list);
     }
     return $cate_list;
 }
Пример #2
0
 public function load($param)
 {
     $param = array("cid" => $param['cid']);
     $key = $this->build_key(__CLASS__, $param);
     $GLOBALS['cache']->set_dir(APP_ROOT_PATH . "public/runtime/data/" . __CLASS__ . "/");
     $key_result = $GLOBALS['cache']->get($key);
     if ($key_result === false) {
         $param['cid'] = intval($GLOBALS['db']->getOne("select id from " . DB_PREFIX . "shop_cate where id = " . intval($param['cid'])));
         $key = $this->build_key(__CLASS__, $param);
         $GLOBALS['cache']->set_dir(APP_ROOT_PATH . "public/runtime/data/" . __CLASS__ . "/");
         $key_result = $GLOBALS['cache']->get($key);
         if ($key_result !== false) {
             return $key_result;
         }
         $cate_id = $param['cid'];
         require_once APP_ROOT_PATH . "system/utils/child.php";
         $ids_util = new child("shop_cate");
         $ids = $ids_util->getChildIds($cate_id);
         $ids[] = $cate_id;
         $deal_cate = $GLOBALS['db']->getAll("select name from " . DB_PREFIX . "shop_cate where id in (" . implode(",", $ids) . ") and is_effect = 1 and is_delete = 0");
         foreach ($deal_cate as $k => $item) {
             $name_words = div_str($item['name']);
             foreach ($name_words as $kk => $vv) {
                 $kw[] = str_to_unicode_string($vv);
             }
         }
         $key_result = implode(" ", $kw);
         $GLOBALS['cache']->set_dir(APP_ROOT_PATH . "public/runtime/data/" . __CLASS__ . "/");
         $GLOBALS['cache']->set($key, $key_result);
     }
     return $key_result;
 }
 public function load($param)
 {
     $key = $this->build_key(__CLASS__, $param);
     $GLOBALS['fcache']->set_dir(APP_ROOT_PATH . "public/runtime/data/" . __CLASS__ . "/");
     $cate_list = $GLOBALS['fcache']->get($key);
     if ($cate_list === false) {
         $pid = intval($param['pid']);
         $is_all = intval($param['is_all']);
         require_once APP_ROOT_PATH . "system/utils/child.php";
         require_once APP_ROOT_PATH . "system/utils/tree.php";
         $ids_util = new child("shop_cate");
         $cate_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "shop_cate where is_effect = 1 and is_delete = 0 order by sort desc,id desc");
         foreach ($cate_list as $k => $v) {
             $sort = array('0' => 'sort', '1' => 'id');
             $ids = $ids_util->getChildIds($v['pid'], "id", "pid", $sort);
             $ids[] = $v['pid'];
             if ($v['pid'] > 0 && !in_array($pid, $ids) && $is_all == 0) {
                 unset($cate_list[$k]);
             } else {
                 if ($v['uname'] != '') {
                     $curl = url("shop", "cate", array("id" => $v['uname']));
                 } else {
                     $curl = url("shop", "cate", array("id" => $v['id']));
                 }
                 $cate_list[$k]['url'] = $curl;
                 $sub_ids = $ids_util->getChildIds($v['pid'], "id", "pid", $sort);
                 $sub_ids[] = $v['id'];
                 $cate_list[$k]['count'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where is_delete = 0 and is_effect = 1 and buy_type <> 1 and shop_cate_id in (" . implode(",", $sub_ids) . ")");
             }
         }
         $tree_util = new tree();
         $cate_list = $tree_util->toFormatTree($cate_list, 'name');
         $GLOBALS['fcache']->set_dir(APP_ROOT_PATH . "public/runtime/data/" . __CLASS__ . "/");
         $GLOBALS['fcache']->set($key, $cate_list);
     }
     return $cate_list;
 }
Пример #4
0
 public function import_mail()
 {
     //开始验证
     if (intval($_REQUEST['mail_type']) == 0) {
         if ($_REQUEST['title'] == '') {
             $this->success(L("MAIL_TITLE_EMPTY_TIP"), 1);
         }
         if ($_REQUEST['content'] == '') {
             $this->success(l("MAIL_CONTENT_EMPTY_TIP"), 1);
         }
     } else {
         if (intval($_REQUEST['deal_id']) == 0 || M("Deal")->where("is_delete=0 and id =" . intval($_REQUEST['deal_id']))->count() == 0) {
             $this->success(l("DEAL_ID_ERROR"), 1);
         }
     }
     if (intval($_REQUEST['send_type']) == 2) {
         if ($_REQUEST['send_define_data'] == '') {
             $this->success(l("SEND_DEFINE_DATE_EMPTY_TIP"), 1);
         }
     }
     $msg_data['type'] = 1;
     $msg_data['title'] = $_REQUEST['title'];
     $msg_data['content'] = $_REQUEST['content'];
     $msg_data['is_html'] = intval($_REQUEST['is_html']);
     if ($_REQUEST['mail_type'] == 1) {
         $msg_data['title'] = M("Deal")->where("is_delete=0 and id =" . intval($_REQUEST['deal_id']))->getField("sub_name") . "团购通知邮件";
         if ($msg_data['content'] == '') {
             $msg_data['content'] = get_deal_mail_content(intval($_REQUEST['deal_id']));
         }
         $msg_data['is_html'] = 1;
     }
     $msg_data['send_time'] = strim($_REQUEST['send_time']) == '' ? NOW_TIME : to_timespan($_REQUEST['send_time']);
     $msg_data['send_status'] = 0;
     $msg_data['deal_id'] = intval($_REQUEST['deal_id']);
     $msg_data['send_type'] = intval($_REQUEST['send_type']);
     switch ($msg_data['send_type']) {
         case 0:
             //会员组
             $msg_data['send_type_id'] = intval($_REQUEST['group_id']);
             break;
         case 1:
             //订阅城市
             $msg_data['send_type_id'] = intval($_REQUEST['city_id']);
             break;
         case 2:
             //自定义号码
             $msg_data['send_type_id'] = 0;
             break;
     }
     $msg_data['send_define_data'] = $_REQUEST['send_define_data'];
     $page = intval($_REQUEST['page']);
     $page = $page == 0 ? 1 : $page;
     $limit = ($page - 1) * 1000 . ",1000";
     $end = false;
     //开始设置
     if (intval(app_conf("EDM_ON")) == 1) {
         set_time_limit(0);
         //edm 发送
         switch ($msg_data['send_type']) {
             case 0:
                 //会员组
                 $condition = "is_effect = 1 and is_delete = 0";
                 if ($msg_data['send_type_id'] > 0) {
                     $condition .= " and group_id = " . $msg_data['send_type_id'];
                 }
                 $mail_list = M("User")->where($condition)->field("email")->limit($limit)->findAll();
                 $email = '';
                 foreach ($mail_list as $k => $v) {
                     $email .= $v['email'] . ",";
                 }
                 if ($email != '') {
                     $email = substr($email, 0, -1);
                 }
                 if ($email == '') {
                     $end = true;
                 }
                 break;
             case 1:
                 //订阅城市
                 $city_id = intval($msg_data['send_type_id']);
                 $condition = "is_effect = 1";
                 if ($city_id > 0) {
                     require_once APP_ROOT_PATH . "system/utils/child.php";
                     $ids_util = new child("deal_city");
                     $ids = $ids_util->getChildIds($city_id);
                     $ids[] = $city_id;
                     $ids_str = implode(",", $ids);
                     $condition .= " and city_id in (" . $ids_str . ")";
                 }
                 $mail_list = M("MailList")->where($conditon)->field("mail_address")->limit($limit)->findAll();
                 $email = '';
                 foreach ($mail_list as $k => $v) {
                     $email .= $v['mail_address'] . ",";
                 }
                 if ($email != '') {
                     $email = substr($email, 0, -1);
                 }
                 if ($email == '') {
                     $end = true;
                 }
                 break;
             case 2:
                 //自定义号码
                 $email = $msg_data['send_define_data'];
                 $end = true;
                 break;
         }
         if ($email == '') {
             $this->success(L("EDM_INSERT_SUCCESS"), 1);
         }
         require 'edm.php';
         $rs = send_mail($email, $msg_data['title'], app_conf("REPLY_ADDRESS"), app_conf("SHOP_TITLE"), $msg_data['content'], strim($_REQUEST['send_time']), $client, $token);
         if ($rs == 'success') {
             //status == 0  error() 时, 继续下页
             if ($end) {
                 $this->success(L("EDM_INSERT_SUCCESS"), 1);
             } else {
                 $this->error(L("EDM_INSERT_SUCCESS"), 1);
             }
         } else {
             $this->success($rs, 1);
         }
     }
 }
 /**
  * Should delete parent and children/sibling recursivelu
  *
  */
 function testDelete_Deep()
 {
     $this->object->AddChild($this->child);
     $this->object->AddSibling($this->sibling);
     $this->parent_->AddObject($this->object);
     $this->parent_->Save();
     $this->parent_->Delete(true);
     $someParent = new parent_();
     $parentList = $someParent->GetList(array(array("parent_Id", ">", 0)));
     $this->assertEquals(0, sizeof($parentList));
     $someObject = new object();
     $objectList = $someObject->GetList(array(array("objectId", ">", 0)));
     $this->assertEquals(0, sizeof($objectList));
     $someChild = new child();
     $childList = $someChild->GetList(array(array("childId", ">", 0)));
     $this->assertEquals(0, sizeof($childList));
     $someSibling = new sibling();
     $siblingList = $someSibling->GetList(array(array("siblingId", ">", 0)));
     $this->assertEquals(0, sizeof($siblingList));
 }
Пример #6
0
<?php

class mom
{
    protected $prot = "protected property\n";
    protected function prot()
    {
        print "protected method\n";
    }
}
class child extends mom
{
    public function callMom()
    {
        $this->prot();
    }
    public function viewMom()
    {
        print $this->prot;
    }
}
$c = new child();
$c->callMom();
$c->viewMom();
Пример #7
0
}
$abase = new base();
$abase->base_method();
$abase->arith_op(1, 2);
class child extends base
{
    function arith_op($a, $b)
    {
        print "child multiplies {$a} and {$b}, to get: " . $a * $b . "\n";
    }
    function child_method()
    {
        print "not a method in {$this->base_var}\n";
    }
}
$achild = new child();
$achild->base_method();
$achild->child_method();
$achild->arith_op(1, 2);
class grandchild extends child
{
    function grandchild($foo)
    {
        $this->base_var = "grandchild";
        print "you just became a grandfather! {$foo}.\n";
    }
}
$agrandchild = new grandchild("bar");
$agrandchild->base_method();
$agrandchild->child_method();
$agrandchild->arith_op(1, 2);
Пример #8
0
 public function index()
 {
     $GLOBALS['tmpl']->caching = true;
     $cache_id = md5(MODULE_NAME . ACTION_NAME . $GLOBALS['deal_city']['id']);
     if (!$GLOBALS['tmpl']->is_cached('mall.html', $cache_id)) {
         //输出商城分类
         $cate_tree = get_cate_tree(0, 1);
         $top_count = 0;
         foreach ($cate_tree as $k => $v) {
             if ($v['level'] == 0) {
                 $top_count++;
             }
             //				if($top_count>6)
             //				{
             //					$cate_tree[$k]['is_hide'] = 1;
             //				}
         }
         $GLOBALS['tmpl']->assign("cate_tree", $cate_tree);
         //获取推荐
         $hot_list = get_goods_list(intval(app_conf("REC_HOT_LIMIT")), 0, " is_hot = 1 and buy_type <> 1", "", false);
         $best_list = get_goods_list(intval(app_conf("REC_BEST_LIMIT")), 0, " is_best = 1 and buy_type <> 1 ", "", false);
         $new_list = get_goods_list(intval(app_conf("REC_NEW_LIMIT")), 0, " is_new = 1 and buy_type <> 1 ", "", false);
         $GLOBALS['tmpl']->assign("inc_var", array('title' => $GLOBALS['lang']['HOT_LIST'], 'list' => $hot_list['list'], 'url' => url("shop", "rec#rhot")));
         $hot_span_goods_html = $GLOBALS['tmpl']->fetch("inc/span_goods.html");
         $GLOBALS['tmpl']->assign("hot_span_goods_html", $hot_span_goods_html);
         $GLOBALS['tmpl']->assign("inc_var", array('title' => $GLOBALS['lang']['BEST_LIST'], 'list' => $best_list['list'], 'url' => url("shop", "rec#rbest")));
         $best_span_goods_html = $GLOBALS['tmpl']->fetch("inc/span_goods.html");
         $GLOBALS['tmpl']->assign("best_span_goods_html", $best_span_goods_html);
         $GLOBALS['tmpl']->assign("inc_var", array('title' => $GLOBALS['lang']['NEW_LIST'], 'list' => $new_list['list'], 'url' => url("shop", "rec#rnew")));
         $new_span_goods_html = $GLOBALS['tmpl']->fetch("inc/span_goods.html");
         $GLOBALS['tmpl']->assign("new_span_goods_html", $new_span_goods_html);
         $recommend_cate = $GLOBALS['db']->getAll("select id,name,uname from " . DB_PREFIX . "shop_cate where grade = 0 order by sort desc");
         //输出分类商品
         $recommend_cate_html = "";
         foreach ($recommend_cate as $cate => $catev) {
             require_once APP_ROOT_PATH . "system/utils/child.php";
             $ids_util = new child("shop_cate");
             $ids = $ids_util->getChildIds($catev['id']);
             $ids[] = $catev['id'];
             $brand_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "brand where shop_cate_id in (" . implode(",", $ids) . ") limit 8");
             foreach ($brand_list as $kk => $brand_item) {
                 $brand_list[$kk]['url'] = url("shop", "brand#index", array("id" => $brand_item['id']));
             }
             //商城推荐分类列表
             $time = get_gmtime();
             $count_sql = "select count(*) from " . DB_PREFIX . "deal where is_effect = 1 and is_delete = 0  and p_shop_cate_id=" . $catev['id'];
             $sql = "select * from " . DB_PREFIX . "deal where is_effect = 1 and is_delete = 0  and p_shop_cate_id=" . $catev['id'];
             $city = get_current_deal_city();
             $city_id = $city['id'];
             if ($city_id > 0) {
                 $ids = load_auto_cache("deal_city_belone_ids", array("city_id" => $city_id));
                 if ($ids) {
                     $sql .= " and city_id in (" . implode(",", $ids) . ")";
                     $count_sql .= " and city_id in (" . implode(",", $ids) . ")";
                 }
             }
             $sql .= " and buy_type <> 1 ";
             $count_sql .= " and buy_type <> 1 ";
             $sql .= " order by sort desc limit 10 ";
             $deals = $GLOBALS['db']->getAll($sql);
             $deals_count = $GLOBALS['db']->getOne($count_sql);
             if ($deals) {
                 foreach ($deals as $k => $deal) {
                     if ($deal['buy_type'] == 1) {
                         $module = "exchange";
                     } else {
                         $module = "goods";
                     }
                     if ($deal['uname'] != '') {
                         $durl = url("shop", $module, array("id" => $deal['uname']));
                     } else {
                         $durl = url("shop", $module, array("id" => $deal['id']));
                     }
                     $deal['url'] = $durl;
                     $deals[$k] = $deal;
                 }
             }
             $cate_list = array('list' => $deals, 'count' => $deals_count);
             //$cate_list=$catev['id'];
             //$cate_list['sd'] = get_goods_list(intval(app_conf("REC_CATE_GOODS_LIMIT")),$catev['id']," buy_type <> 1 ","",false);
             $cate_title = $catev['name'];
             if ($catev['uname'] != "") {
                 $curl = url("shop", "cate#index", array("id" => $catev['uname']));
             } else {
                 $curl = url("shop", "cate#index", array("id" => $catev['id']));
             }
             $GLOBALS['tmpl']->assign("inc_var", array('id' => $catev['id'], 'brand_list' => $brand_list, 'title' => $cate_title, 'list' => $cate_list['list'], 'url' => $curl));
             $recommend_cate_html .= $GLOBALS['tmpl']->fetch("inc/recommend_cate_goods.html");
         }
         $GLOBALS['tmpl']->assign("recommend_cate_html", $recommend_cate_html);
         $GLOBALS['tmpl']->assign("page_title", app_conf("MALL_SHOP_TITLE"));
         $GLOBALS['tmpl']->assign("page_keyword", app_conf("MALL_SHOP_TITLE"));
         $GLOBALS['tmpl']->assign("page_description", app_conf("MALL_SHOP_TITLE"));
         //输出商城公告
         $notice_list = get_notice(0, array(0, 2));
         $GLOBALS['tmpl']->assign("notice_list", $notice_list);
     }
     $GLOBALS['tmpl']->display("mall.html", $cache_id);
 }
Пример #9
0
<?php

abstract class base
{
    public abstract function __construct();
    protected function test()
    {
        echo 'base::test', PHP_EOL;
    }
}
class child extends base
{
    /*
        public function __construct()
        {
       //parent::__construct();
       echo $this->test();
       echo 'child::__construct', PHP_EOL;
        }
    */
    public function test2()
    {
        $this->test();
    }
}
$c = new child();
$c->test2();
Пример #10
0
<?php

/* Property cannot be declared abstract in abstract class and for abstract method-> class should be abstract */
abstract class test
{
    public $vara = 'abstract_class_variable';
    protected abstract function abc();
}
class child extends test
{
    public function abc()
    {
        echo $this->vara . '<br>';
        echo 'Inside the child class';
    }
}
$test = new child();
$test->abc();
Пример #11
0
                                </div>


                                <div class="tab-pane fade" role="tabpanel" id="class10B">
                                    <div class="table-responsive">
                                        <?php 
$table = new child();
$table->show("ten", "arts");
?>

                                    </div>
                                </div>
                                <div class="tab-pane fade" role="tabpanel" id="class10C">
                                    <div class="table-responsive">
                                        <?php 
$table = new child();
$table->show("ten", "commerce");
?>

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- end class ten -->




                </div>
Пример #12
0
<?php

class test
{
    public $name = 'localhost';
    public final function abc()
    {
        return 'Inside the class test into abc';
    }
}
class child extends test
{
    public function xyz()
    {
        echo 'child class->' . test::abc();
    }
}
$child = new child();
echo $child->abc() . '<br>';
$child->xyz();
Пример #13
0
 public function update()
 {
     B('FilterString');
     $data = M(MODULE_NAME)->create();
     $log_info = M(MODULE_NAME)->where("id=" . intval($data['id']))->getField("name");
     //开始验证有效性
     $this->assign("jumpUrl", u(MODULE_NAME . "/edit", array("id" => $data['id'])));
     if (!check_empty($data['name'])) {
         $this->error(L("DELIVERY_NAME_EMPTY_TIP"));
     }
     require_once APP_ROOT_PATH . "system/utils/child.php";
     $child = new child("delivery_region");
     // 更新数据
     $list = M(MODULE_NAME)->save($data);
     if (false !== $list) {
         M("DeliveryFee")->where("delivery_id=" . $data['id'])->delete();
         //开始处理配送地区
         $delivery_regions = $_REQUEST['region_support_region'];
         foreach ($delivery_regions as $k => $v) {
             if ($v != '') {
                 $id_arr = explode(",", $v);
                 $sub_ids = array();
                 foreach ($id_arr as $vv) {
                     if (!in_array($vv, $sub_ids)) {
                         $tmp_ids = $child->getChildIds($vv);
                         $tmp_ids[] = $vv;
                         $sub_ids = array_merge($sub_ids, $tmp_ids);
                     }
                 }
                 //添加相应的支持地区
                 $delivery_fee_item = array();
                 $delivery_fee_item['delivery_id'] = $data['id'];
                 $delivery_fee_item['region_ids'] = implode(",", $sub_ids);
                 $delivery_fee_item['first_weight'] = $_REQUEST['region_first_weight'][$k];
                 $delivery_fee_item['first_fee'] = $_REQUEST['region_first_fee'][$k];
                 $delivery_fee_item['continue_weight'] = $_REQUEST['region_continue_weight'][$k];
                 $delivery_fee_item['continue_fee'] = $_REQUEST['region_continue_fee'][$k];
                 M("DeliveryFee")->add($delivery_fee_item);
             }
         }
         //成功提示
         save_log($log_info . L("UPDATE_SUCCESS"), 1);
         $this->success(L("UPDATE_SUCCESS"));
     } else {
         //错误提示
         save_log($log_info . L("UPDATE_FAILED"), 0);
         $this->error(L("UPDATE_FAILED"), 0, $log_info . L("UPDATE_FAILED"));
     }
 }
Пример #14
0
	重载可以重写父类中指定方法所实现的功能
代码示例:
<?php 
class father
{
    //定义father 类
    public function printNUM()
    {
        echo 10;
    }
}
class child extends father
{
    //子类child 继承 father 类
    public function printNUM()
    {
        //重写 father 类中的方法,实现重载
        echo 10 * 10;
    }
}
$test1 = new father();
$test1->printNUM();
//输出10
echo "<br>";
$test2 = new child();
$test2->printNUM();
// 输出100
?>
运行结果:
10
100
Пример #15
0
final
基本概念:
	利用final关键字修饰的方法不能被重载
	同样使用该关键字修饰的类也不能被继承
<?php 
class father
{
    final function fun()
    {
        echo "father";
    }
}
class child extends father
{
    function fun()
    {
        echo "child";
    }
}
$obj = new child();
$obj->fun();
?>
运行结果:(报错)
PHP Fatal error: Cannot override final method father::fun() in /course/test.php on line 12
 /**
  * Gets a list of child objects associated to this one
  * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...} 
  * @param string $sortBy 
  * @param boolean $ascending 
  * @param int limit 
  * @return array of child objects
  */
 function GetChildList($fcv_array = array(), $sortBy = '', $ascending = true, $limit = '')
 {
     $child = new child();
     $fcv_array[] = array("objectId", "=", $this->objectId);
     $dbObjects = $child->GetList($fcv_array, $sortBy, $ascending, $limit);
     return $dbObjects;
 }