|
@@ -14,8 +14,8 @@ class body_filder
|
|
|
static $save_path = BASE_DATA_PATH . '/upload/detail';
|
|
|
static $down_path = BASE_DATA_PATH . '/Download/detail';
|
|
|
|
|
|
- static $req_path = 'http://p.lrlz.com/data/upload/detail/';
|
|
|
- //static $req_path = 'http://localhost/data/upload/detail/';
|
|
|
+ //static $req_path = 'http://p.lrlz.com/data/upload/detail/';
|
|
|
+ static $req_path = 'http://localhost/data/upload/detail/';
|
|
|
|
|
|
public function __construct()
|
|
|
{
|
|
@@ -122,7 +122,7 @@ class body_filder
|
|
|
copy($path,$newpath);
|
|
|
|
|
|
++$num;
|
|
|
- array_push($name);
|
|
|
+ array_push($imgs,$name);
|
|
|
}
|
|
|
}
|
|
|
if(isset($imgs)) {
|
|
@@ -149,6 +149,76 @@ class body_filder
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private function img_width($img)
|
|
|
+ {
|
|
|
+ $path = self::$save_path . '/' . $img;
|
|
|
+ $img_info = getimagesize($path);
|
|
|
+ if (empty($img_info) || count($img_info) == 0) return 0;
|
|
|
+
|
|
|
+ return $img_info[0];
|
|
|
+
|
|
|
+ }
|
|
|
+ private function group($pics,$max_width)
|
|
|
+ {
|
|
|
+ $ret = array();
|
|
|
+
|
|
|
+ $row = array();
|
|
|
+ $width_count = 0;
|
|
|
+ foreach($pics as $img)
|
|
|
+ {
|
|
|
+ $width = $this->img_width($img);
|
|
|
+ $width_count += $width;
|
|
|
+ if($width_count > $max_width) {
|
|
|
+ array_push($ret,$row);
|
|
|
+ $row = array();
|
|
|
+ array_push($row,$img);
|
|
|
+ $width_count = 0;
|
|
|
+ }
|
|
|
+ else if($width_count == $max_width){
|
|
|
+ array_push($row,$img);
|
|
|
+ array_push($ret,$row);
|
|
|
+ $row = array();
|
|
|
+ $width_count = 0;
|
|
|
+ } else {
|
|
|
+ array_push($row,$img);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function layout($pics)
|
|
|
+ {
|
|
|
+ $table_start = "<table style=\"width:100%%;\" cellpadding=\"0\" cellspacing=\"0\">";
|
|
|
+ $table_end = "</table>";
|
|
|
+
|
|
|
+ //1. 枚举图片
|
|
|
+ $max_width = $this->max_width($pics);
|
|
|
+ $table = $this->group($pics,$max_width);
|
|
|
+
|
|
|
+ $html = $table_start;;
|
|
|
+ foreach($table as $row)
|
|
|
+ {
|
|
|
+// if(count($row) == 1) {
|
|
|
+// $name = $row[0];
|
|
|
+// $html .= "<img src=\"" . self::$req_path . "{$name}\">";
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+
|
|
|
+ $html .= "<tr>";
|
|
|
+ foreach($row as $col) {
|
|
|
+ $tmp = "<img src=\"" . self::$req_path . "{$col}\">";
|
|
|
+ $html .= "<td> {$tmp} </td>";
|
|
|
+ }
|
|
|
+ $html .= "</tr>";
|
|
|
+// }
|
|
|
+ }
|
|
|
+ $html .= $table_end;
|
|
|
+
|
|
|
+ return $html;
|
|
|
+ }
|
|
|
+
|
|
|
public function proc()
|
|
|
{
|
|
|
$goods = $this->goods_common->field('goods_commonid,goods_body')->limit(false)->select();
|
|
@@ -157,6 +227,9 @@ class body_filder
|
|
|
$body = $val['goods_body'];
|
|
|
$comm_id = $val['goods_commonid'];
|
|
|
$body = $this->filter_gif($body);
|
|
|
+
|
|
|
+ $this->filterex($body,$comm_id);
|
|
|
+
|
|
|
$imgs = $this->filter_table($body,$comm_id);
|
|
|
|
|
|
if($imgs == false) continue;
|
|
@@ -167,6 +240,27 @@ class body_filder
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param $pics
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ private function max_width(&$pics)
|
|
|
+ {
|
|
|
+ $max_width = 0;
|
|
|
+ foreach ($pics as &$img)
|
|
|
+ {
|
|
|
+ $path = self::$save_path . '/' . $img;
|
|
|
+ $img_info = getimagesize($path);
|
|
|
+ if (empty($img_info) || count($img_info) == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ $max_width = $img_info[0] > $max_width ? $img_info[0] : $max_width;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $max_width;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|