|
@@ -855,51 +855,61 @@ class ProjectUpdate extends Command |
|
@@ -855,51 +855,61 @@ class ProjectUpdate extends Command |
|
855
|
foreach ($items as $item) {
|
855
|
foreach ($items as $item) {
|
|
856
|
$route = $this->get_url_route($item['url'] ?? '');
|
856
|
$route = $this->get_url_route($item['url'] ?? '');
|
|
857
|
if ($route) {
|
857
|
if ($route) {
|
|
858
|
- $parent = $model->read(['pid' => $pid, 'route' => $route], 'id');
|
|
|
|
859
|
- if (!$parent) {
|
|
|
|
860
|
- try {
|
|
|
|
861
|
- $item['name'] = $this->special2str($item['name'] ?? '');
|
|
|
|
862
|
- //图片
|
|
|
|
863
|
- if (is_array($item['images'] ?? '')) {
|
|
|
|
864
|
- $image = $item['images'][0] ?? '';
|
|
|
|
865
|
- } else {
|
|
|
|
866
|
- $image = $item['images'] ?? '';
|
|
|
|
867
|
- }
|
|
|
|
868
|
- $new_img = $this->source_download($image, $project_id, $domain, $web_url_domain, $home_url);
|
|
|
|
869
|
- //描述
|
|
|
|
870
|
- if (isset($item['description']) && $item['description']) {
|
|
|
|
871
|
- //匹配描述资源
|
|
|
|
872
|
- $source_list = $this->html_preg($item['description'], $project_id, $domain, $web_url_domain, $home_url);
|
|
|
|
873
|
- if ($source_list) {
|
|
|
|
874
|
- foreach ($source_list as $vs) {
|
|
|
|
875
|
- if ($vs['download']) {
|
|
|
|
876
|
- //需要下载资源
|
|
|
|
877
|
- $down_url = $this->source_download($vs['url_complete'], $project_id, $domain, $web_url_domain, $home_url);
|
|
|
|
878
|
- } else {
|
|
|
|
879
|
- //已经下载过资源
|
|
|
|
880
|
- $down_url = getImageUrl($vs['url_complete']);
|
|
|
|
881
|
- }
|
|
|
|
882
|
- $item['description'] = str_replace($vs['url'], $down_url, $item['description']);
|
|
|
|
883
|
- }
|
858
|
+ $item['name'] = $this->special2str($item['name'] ?? '');
|
|
|
|
859
|
+ //图片
|
|
|
|
860
|
+ if (is_array($item['images'] ?? '')) {
|
|
|
|
861
|
+ $image = $item['images'][0] ?? '';
|
|
|
|
862
|
+ } else {
|
|
|
|
863
|
+ $image = $item['images'] ?? '';
|
|
|
|
864
|
+ }
|
|
|
|
865
|
+ $new_img = $this->source_download($image, $project_id, $domain, $web_url_domain, $home_url);
|
|
|
|
866
|
+ //描述
|
|
|
|
867
|
+ $describe = '';
|
|
|
|
868
|
+ if (isset($item['description']) && $item['description']) {
|
|
|
|
869
|
+ $describe = $item['description'];
|
|
|
|
870
|
+ //匹配描述资源
|
|
|
|
871
|
+ $source_list = $this->html_preg($describe, $project_id, $domain, $web_url_domain, $home_url);
|
|
|
|
872
|
+ if ($source_list) {
|
|
|
|
873
|
+ foreach ($source_list as $vs) {
|
|
|
|
874
|
+ if ($vs['download']) {
|
|
|
|
875
|
+ //需要下载资源
|
|
|
|
876
|
+ $down_url = $this->source_download($vs['url_complete'], $project_id, $domain, $web_url_domain, $home_url);
|
|
|
|
877
|
+ } else {
|
|
|
|
878
|
+ //已经下载过资源
|
|
|
|
879
|
+ $down_url = getImageUrl($vs['url_complete']);
|
|
884
|
}
|
880
|
}
|
|
|
|
881
|
+ $describe = str_replace($vs['url'], $down_url, $describe);
|
|
885
|
}
|
882
|
}
|
|
|
|
883
|
+ }
|
|
|
|
884
|
+ }
|
|
|
|
885
|
+ try {
|
|
|
|
886
|
+ $parent = $model->read(['route' => $route], 'id');
|
|
|
|
887
|
+ if (!$parent) {
|
|
886
|
$parent_id = $model->addReturnId([
|
888
|
$parent_id = $model->addReturnId([
|
|
887
|
'project_id' => $project_id,
|
889
|
'project_id' => $project_id,
|
|
888
|
'title' => $item['name'],
|
890
|
'title' => $item['name'],
|
|
889
|
'image' => $new_img,
|
891
|
'image' => $new_img,
|
|
890
|
'pid' => $pid,
|
892
|
'pid' => $pid,
|
|
891
|
'keywords' => $item['keywords'] ?? '',
|
893
|
'keywords' => $item['keywords'] ?? '',
|
|
892
|
- 'describe' => (isset($item['description']) && $item['description']) ? $item['description'] : '',
|
894
|
+ 'describe' => $describe,
|
|
893
|
'original_id' => $item['id'],
|
895
|
'original_id' => $item['id'],
|
|
894
|
'route' => $route
|
896
|
'route' => $route
|
|
895
|
]);
|
897
|
]);
|
|
896
|
$this->set_map($route, RouteMap::SOURCE_PRODUCT_CATE, $parent_id, $project_id);
|
898
|
$this->set_map($route, RouteMap::SOURCE_PRODUCT_CATE, $parent_id, $project_id);
|
|
897
|
- } catch (\Exception $e) {
|
|
|
|
898
|
- echo 'date:' . date('Y-m-d H:i:s') . ', category_insert error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
899
|
- continue;
|
899
|
+ } else {
|
|
|
|
900
|
+ $parent_id = $parent['id'];
|
|
|
|
901
|
+ $model->edit([
|
|
|
|
902
|
+ 'title' => $item['name'],
|
|
|
|
903
|
+ 'image' => $new_img,
|
|
|
|
904
|
+ 'pid' => $pid,
|
|
|
|
905
|
+ 'keywords' => $item['keywords'] ?? '',
|
|
|
|
906
|
+ 'describe' => $describe,
|
|
|
|
907
|
+ 'original_id' => $item['id']
|
|
|
|
908
|
+ ], ['id' => $parent_id]);
|
|
900
|
}
|
909
|
}
|
|
901
|
- } else {
|
|
|
|
902
|
- $parent_id = $parent['id'];
|
910
|
+ } catch (\Exception $e) {
|
|
|
|
911
|
+ echo 'date:' . date('Y-m-d H:i:s') . ', category_insert error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
912
|
+ continue;
|
|
903
|
}
|
913
|
}
|
|
904
|
|
914
|
|
|
905
|
if (!empty($item['children'] ?? [])) {
|
915
|
if (!empty($item['children'] ?? [])) {
|
|
@@ -916,10 +926,10 @@ class ProjectUpdate extends Command |
|
@@ -916,10 +926,10 @@ class ProjectUpdate extends Command |
|
916
|
foreach ($items as $item) {
|
926
|
foreach ($items as $item) {
|
|
917
|
$route = $this->get_url_route($item['url'] ?? '');
|
927
|
$route = $this->get_url_route($item['url'] ?? '');
|
|
918
|
if ($route) {
|
928
|
if ($route) {
|
|
919
|
- $parent = $model->read(['pid' => $pid, 'alias' => $route], 'id');
|
|
|
|
920
|
- if (!$parent) {
|
|
|
|
921
|
- try {
|
|
|
|
922
|
- $item['name'] = $this->special2str($item['name'] ?? '');
|
929
|
+ $item['name'] = $this->special2str($item['name'] ?? '');
|
|
|
|
930
|
+ try {
|
|
|
|
931
|
+ $parent = $model->read(['alias' => $route], 'id');
|
|
|
|
932
|
+ if (!$parent) {
|
|
923
|
$parent_id = $model->addReturnId([
|
933
|
$parent_id = $model->addReturnId([
|
|
924
|
'project_id' => $project_id,
|
934
|
'project_id' => $project_id,
|
|
925
|
'name' => $item['name'],
|
935
|
'name' => $item['name'],
|
|
@@ -928,12 +938,18 @@ class ProjectUpdate extends Command |
|
@@ -928,12 +938,18 @@ class ProjectUpdate extends Command |
|
928
|
'alias' => $route
|
938
|
'alias' => $route
|
|
929
|
]);
|
939
|
]);
|
|
930
|
$this->set_map($route, RouteMap::SOURCE_NEWS_CATE, $parent_id, $project_id);
|
940
|
$this->set_map($route, RouteMap::SOURCE_NEWS_CATE, $parent_id, $project_id);
|
|
931
|
- } catch (\Exception $e) {
|
|
|
|
932
|
- echo 'date:' . date('Y-m-d H:i:s') . ', category_news_insert error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
933
|
- continue;
|
941
|
+
|
|
|
|
942
|
+ } else {
|
|
|
|
943
|
+ $parent_id = $parent['id'];
|
|
|
|
944
|
+ $model->edit([
|
|
|
|
945
|
+ 'name' => $item['name'],
|
|
|
|
946
|
+ 'pid' => $pid,
|
|
|
|
947
|
+ 'original_id' => $item['id'],
|
|
|
|
948
|
+ ], ['id' => $parent_id]);
|
|
934
|
}
|
949
|
}
|
|
935
|
- } else {
|
|
|
|
936
|
- $parent_id = $parent['id'];
|
950
|
+ } catch (\Exception $e) {
|
|
|
|
951
|
+ echo 'date:' . date('Y-m-d H:i:s') . ', category_news_insert error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
952
|
+ continue;
|
|
937
|
}
|
953
|
}
|
|
938
|
|
954
|
|
|
939
|
if (!empty($item['children'] ?? [])) {
|
955
|
if (!empty($item['children'] ?? [])) {
|