|
...
|
...
|
@@ -855,51 +855,61 @@ class ProjectUpdate extends Command |
|
|
|
foreach ($items as $item) {
|
|
|
|
$route = $this->get_url_route($item['url'] ?? '');
|
|
|
|
if ($route) {
|
|
|
|
$parent = $model->read(['pid' => $pid, 'route' => $route], 'id');
|
|
|
|
if (!$parent) {
|
|
|
|
try {
|
|
|
|
$item['name'] = $this->special2str($item['name'] ?? '');
|
|
|
|
//图片
|
|
|
|
if (is_array($item['images'] ?? '')) {
|
|
|
|
$image = $item['images'][0] ?? '';
|
|
|
|
} else {
|
|
|
|
$image = $item['images'] ?? '';
|
|
|
|
}
|
|
|
|
$new_img = $this->source_download($image, $project_id, $domain, $web_url_domain, $home_url);
|
|
|
|
//描述
|
|
|
|
if (isset($item['description']) && $item['description']) {
|
|
|
|
//匹配描述资源
|
|
|
|
$source_list = $this->html_preg($item['description'], $project_id, $domain, $web_url_domain, $home_url);
|
|
|
|
if ($source_list) {
|
|
|
|
foreach ($source_list as $vs) {
|
|
|
|
if ($vs['download']) {
|
|
|
|
//需要下载资源
|
|
|
|
$down_url = $this->source_download($vs['url_complete'], $project_id, $domain, $web_url_domain, $home_url);
|
|
|
|
} else {
|
|
|
|
//已经下载过资源
|
|
|
|
$down_url = getImageUrl($vs['url_complete']);
|
|
|
|
}
|
|
|
|
$item['description'] = str_replace($vs['url'], $down_url, $item['description']);
|
|
|
|
}
|
|
|
|
$item['name'] = $this->special2str($item['name'] ?? '');
|
|
|
|
//图片
|
|
|
|
if (is_array($item['images'] ?? '')) {
|
|
|
|
$image = $item['images'][0] ?? '';
|
|
|
|
} else {
|
|
|
|
$image = $item['images'] ?? '';
|
|
|
|
}
|
|
|
|
$new_img = $this->source_download($image, $project_id, $domain, $web_url_domain, $home_url);
|
|
|
|
//描述
|
|
|
|
$describe = '';
|
|
|
|
if (isset($item['description']) && $item['description']) {
|
|
|
|
$describe = $item['description'];
|
|
|
|
//匹配描述资源
|
|
|
|
$source_list = $this->html_preg($describe, $project_id, $domain, $web_url_domain, $home_url);
|
|
|
|
if ($source_list) {
|
|
|
|
foreach ($source_list as $vs) {
|
|
|
|
if ($vs['download']) {
|
|
|
|
//需要下载资源
|
|
|
|
$down_url = $this->source_download($vs['url_complete'], $project_id, $domain, $web_url_domain, $home_url);
|
|
|
|
} else {
|
|
|
|
//已经下载过资源
|
|
|
|
$down_url = getImageUrl($vs['url_complete']);
|
|
|
|
}
|
|
|
|
$describe = str_replace($vs['url'], $down_url, $describe);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
$parent = $model->read(['route' => $route], 'id');
|
|
|
|
if (!$parent) {
|
|
|
|
$parent_id = $model->addReturnId([
|
|
|
|
'project_id' => $project_id,
|
|
|
|
'title' => $item['name'],
|
|
|
|
'image' => $new_img,
|
|
|
|
'pid' => $pid,
|
|
|
|
'keywords' => $item['keywords'] ?? '',
|
|
|
|
'describe' => (isset($item['description']) && $item['description']) ? $item['description'] : '',
|
|
|
|
'describe' => $describe,
|
|
|
|
'original_id' => $item['id'],
|
|
|
|
'route' => $route
|
|
|
|
]);
|
|
|
|
$this->set_map($route, RouteMap::SOURCE_PRODUCT_CATE, $parent_id, $project_id);
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
echo 'date:' . date('Y-m-d H:i:s') . ', category_insert error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
$parent_id = $parent['id'];
|
|
|
|
$model->edit([
|
|
|
|
'title' => $item['name'],
|
|
|
|
'image' => $new_img,
|
|
|
|
'pid' => $pid,
|
|
|
|
'keywords' => $item['keywords'] ?? '',
|
|
|
|
'describe' => $describe,
|
|
|
|
'original_id' => $item['id']
|
|
|
|
], ['id' => $parent_id]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$parent_id = $parent['id'];
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
echo 'date:' . date('Y-m-d H:i:s') . ', category_insert error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($item['children'] ?? [])) {
|
|
...
|
...
|
@@ -916,10 +926,10 @@ class ProjectUpdate extends Command |
|
|
|
foreach ($items as $item) {
|
|
|
|
$route = $this->get_url_route($item['url'] ?? '');
|
|
|
|
if ($route) {
|
|
|
|
$parent = $model->read(['pid' => $pid, 'alias' => $route], 'id');
|
|
|
|
if (!$parent) {
|
|
|
|
try {
|
|
|
|
$item['name'] = $this->special2str($item['name'] ?? '');
|
|
|
|
$item['name'] = $this->special2str($item['name'] ?? '');
|
|
|
|
try {
|
|
|
|
$parent = $model->read(['alias' => $route], 'id');
|
|
|
|
if (!$parent) {
|
|
|
|
$parent_id = $model->addReturnId([
|
|
|
|
'project_id' => $project_id,
|
|
|
|
'name' => $item['name'],
|
|
...
|
...
|
@@ -928,12 +938,18 @@ class ProjectUpdate extends Command |
|
|
|
'alias' => $route
|
|
|
|
]);
|
|
|
|
$this->set_map($route, RouteMap::SOURCE_NEWS_CATE, $parent_id, $project_id);
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
echo 'date:' . date('Y-m-d H:i:s') . ', category_news_insert error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$parent_id = $parent['id'];
|
|
|
|
$model->edit([
|
|
|
|
'name' => $item['name'],
|
|
|
|
'pid' => $pid,
|
|
|
|
'original_id' => $item['id'],
|
|
|
|
], ['id' => $parent_id]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$parent_id = $parent['id'];
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
echo 'date:' . date('Y-m-d H:i:s') . ', category_news_insert error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($item['children'] ?? [])) {
|
...
|
...
|
|