Bladeren bron

add to testsrv

stanley-king 7 jaren geleden
bovenliggende
commit
95544b9f8b

+ 15 - 56
helper/ugc/ugc_content.php

@@ -19,15 +19,8 @@ class content_config
 
 abstract class UGContent
 {
-    protected $mItemId;
     public function __construct($content)
     {
-        $item_id = intval($content['item_id']);
-        if($item_id > 0) {
-            $this->mItemId = $item_id;
-        } else {
-            $this->mItemId = 0;
-        }
     }
     public function base_info()
     {
@@ -39,18 +32,14 @@ abstract class UGContent
 
         return $param;
     }
-    public function item_id() {
-        return $this->mItemId;
-    }
 
     public abstract function format_block();
     public abstract function is_vote();
-    public abstract function vote_result();
 
     protected function item_data($show_type, $show_data, $title='', $type='', $data='', $reserved='')
     {
         $result['home1_title'] = $title;
-        $result['image'] = $show_data;
+        $result['image']       = $show_data;
         $result['show_type'] = $show_type;
         $result['show_data'] = $show_data;
         $result['type'] = $type;
@@ -99,9 +88,6 @@ class pics_item extends UGContent
     public function is_vote() {
         return false;
     }
-    public function vote_result() {
-        return [];
-    }
 }
 
 class text_item extends UGContent
@@ -124,9 +110,6 @@ class text_item extends UGContent
     public function is_vote() {
         return false;
     }
-    public function vote_result() {
-        return [];
-    }
 }
 
 class goods_item extends UGContent
@@ -142,9 +125,6 @@ class goods_item extends UGContent
     public function is_vote() {
         return false;
     }
-    public function vote_result() {
-        return [];
-    }
 }
 
 class voice_item extends UGContent
@@ -160,21 +140,20 @@ class voice_item extends UGContent
     public function is_vote() {
         return false;
     }
-    public function vote_result() {
-        return [];
-    }
 }
 
 class video_item extends UGContent
 {
     private $mTitle;
     private $mVideo;
+    private $mImage;
 
     public function __construct($content)
     {
         parent::__construct($content);
         $this->mTitle = empty($content['title']) ? "" : $content['title'];
         $this->mVideo = $content['video'];
+        $this->mImage = $content['cover'];
     }
     public function set_images($images)
     {
@@ -186,11 +165,11 @@ class video_item extends UGContent
 
     public function format_block()
     {
-        $image = $this->video();
-        if($image == false) return false;
+        $url = $this->video();
+        if($url == false) return false;
 
         $params = $this->base_info();
-        $params['item_data'] = $this->item_data('video',$image,$this->mTitle);
+        $params['item_data'] = $this->item_data('image',$this->mImage,$this->mTitle,'video',$this->mVideo);
         return $params;
     }
 
@@ -202,9 +181,6 @@ class video_item extends UGContent
     public function is_vote() {
         return false;
     }
-    public function vote_result() {
-        return [];
-    }
 }
 
 class vote_item extends UGContent
@@ -238,7 +214,8 @@ class vote_item extends UGContent
         if($data == false) return false;
 
         $params = $this->base_info();
-        $params['item_data'] = $this->item_data('vote','',$this->mTitle,'vote',$data);
+        $reserved = "vote_type={$this->mType}";
+        $params['item_data'] = $this->item_data('vote','',$this->mTitle,'vote',$data,$reserved);
         return $params;
     }
 
@@ -264,6 +241,9 @@ class vote_item extends UGContent
         }
         return serialize($result);
     }
+    public function vote_type() {
+        return $this->mType;
+    }
 }
 
 class href_item extends  UGContent
@@ -290,9 +270,6 @@ class href_item extends  UGContent
     public function is_vote() {
         return false;
     }
-    public function vote_result() {
-        return [];
-    }
 }
 
 class question_item extends UGContent
@@ -309,9 +286,6 @@ class question_item extends UGContent
     public function is_vote() {
         return false;
     }
-    public function vote_result() {
-        return [];
-    }
 }
 
 class special_object
@@ -349,36 +323,21 @@ class special_object
         $this->del_items($sp_id);
 
         $item_sort = 0;
-        $i = 0;
-        $count = count($this->contents);
-
         foreach ($this->contents as $item)
         {
             $data  = $item->format_block();
-            ++$i;
-            if($count == $i) {
-                $fLast = true;
-            } else {
-                $fLast = false;
-            }
             if($data == false) {
                 continue;
             }
 
             $data['special_id'] = $sp_id;
             $data['item_sort'] = $item_sort;
-
             $item_id = $this->save_item($item->item_id(),$data);
-
-            if($item->is_vote()) {
+            if($item_id != false && $item->is_vote())
+            {
                 $vote_result = $item->vote_result();
-                $this->mb_special->editUserSpecial($this->special_id,['member_id' => $user_id,'special_id' => $sp_id],['has_vote' => 1,'vote_result' => $vote_result]);
-            }
-
-            if($item_id > 0 && $fLast == false) {
-                $item_sort++;
-                $this->insert_divider($sp_id,$item_sort);
-                $item_sort++;
+                $vote_type = $item->vote_type();
+                $this->mb_special->editUserSpecial($this->special_id,['member_id' => $user_id,'special_id' => $sp_id],['has_vote' => 1,'vote_type' => $vote_type,'vote_result' => $vote_result]);
             }
         }
 

+ 0 - 4
mobile/control/member_ugc.php

@@ -14,15 +14,11 @@ class member_ugcControl extends mbMemberControl
     {
         parent::__construct();
     }
-
     public function pub_listOp()
     {
-
     }
-
     public function pri_listOp()
     {
-
     }
 
     public function addOp()

+ 18 - 1
mobile/control/special.php

@@ -111,8 +111,12 @@ class tpl_ugc
             elseif($show_type == 'text') {
                 $this->show_text($item);
             }
+            else {
+
+            }
         }
     }
+
     private function show_text($item)
     {
         $data  = $item['data'];
@@ -125,7 +129,8 @@ class tpl_ugc
         $type  = $item['type'];
         $title = $item['title'];
 
-        if($type == 'url') {
+        if($type == 'url')
+        {
             $url  = $item['data'];
             $str = "<div class=\"thumbnail\">
                         <a href=\"{$url}\">
@@ -136,6 +141,18 @@ class tpl_ugc
                         <div class=\"thumbnail_pro\">{$title}</div>
                     </div>";
         }
+        elseif($type == 'video')
+        {
+            $video  = $item['data'];
+            $str = "<div class=\"thumbnail\">
+                        <video poster=\"$image\" src=\"{$video}\">
+                            您的设备不支持视频播放
+                        </video>
+                        <div class=\"thumbnail_pro\">
+                            《化妆小教程》
+                        </div>
+                    </div>";
+        }
         else
         {
             $str = "<div class=\"thumbnail\">

+ 1 - 1
mobile/templates/default/ugc/content.php

@@ -9,7 +9,7 @@
     <meta name="format-detection" content="telephone=no">
     <meta name="screen-orientation" content="portrait">
     <meta name="x5-fullscreen" content="true"/>
-    <link rel="stylesheet" href="<?php echo RESOURCE_SITE_URL; ?>/mobile/ugc/css/main.css">
+    <link rel="stylesheet" href="<?php echo RESOURCE_SITE_URL; ?>/mobile/ugc/css/main.css?<?php echo bonus_version(); ?>">
 </head>
 <body>
 <div class="title">

+ 38 - 0
test/TestPush.php

@@ -0,0 +1,38 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 2017/4/11
+ * Time: 下午5:52
+ */
+
+define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
+require_once(BASE_ROOT_PATH . '/fooder.php');
+require_once(BASE_ROOT_PATH . '/helper/memsg/message_sender.php');
+
+class TestPush extends PHPUnit_Framework_TestCase
+{
+    public static function setUpBeforeClass()
+    {
+        Base::run_util();
+    }
+
+    public function testPusher()
+    {
+        $sender = new memsg\message_sender();
+        $sender->send();
+    }
+
+    public function testSubstring()
+    {
+        $str = "123456789ABCDEFG";
+        $len = strlen($str);
+        $start = 1;
+        $x = substr($str,$start,$len - $start);
+
+        $src = "BBB中国人AAA";
+        $x = strlen($src);
+        $y = substr($src,7,3);
+    }
+}

+ 38 - 0
test/TestTime.php

@@ -0,0 +1,38 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 2017/5/25
+ * Time: 上午10:21
+ */
+class TestTime extends PHPUnit_Framework_TestCase
+{
+    public function testDay()
+    {
+        $date = date('Y-m-d',time());
+        $this->mStartm = strtotime(date('Y-m-d',time()));
+        $this->mEndtm  = $this->mStartm + 86400 - 1;
+    }
+
+    public function testWeek()
+    {
+        $date = date('Y-m-d',time());
+        $cur_time = strtotime(date('Y-m-d',time())) + 86400;
+        $start = $cur_time - 86400 * 7;
+        $end = $cur_time -1;
+
+        $v = ($end - $start + 1) / 86400;
+    }
+    public function testMonth()
+    {
+        $cur = time();
+        $cur_date = new DateTime();
+        $cur_date->setTimestamp($cur);
+        $inter = new DateInterval('P1M');
+        $cur_date->sub($inter);
+        $time = $cur_date->getTimestamp();
+    }
+
+
+}