|
@@ -51,16 +51,16 @@ class car_helper
|
|
|
return self::$stInstance;
|
|
|
}
|
|
|
|
|
|
- public function detail_url($car_id)
|
|
|
+ public function index_url($car_id)
|
|
|
{
|
|
|
$car_id = intval($car_id);
|
|
|
if($car_id <= 0) return '';
|
|
|
|
|
|
- $file_name = "{$car_id}.html";
|
|
|
+ $file_name = "{$car_id}_index.html";
|
|
|
$file_path = BASE_UPLOAD_PATH. DS. "car". DS. $file_name;
|
|
|
if(!file_exists($file_path))
|
|
|
{
|
|
|
- if($this->generate_html_file($car_id,$file_path) == false) {
|
|
|
+ if($this->write_file($file_path, $this->index_file_content($car_id)) == false){
|
|
|
return '';
|
|
|
}
|
|
|
}
|
|
@@ -71,21 +71,58 @@ class car_helper
|
|
|
return $url;
|
|
|
}
|
|
|
|
|
|
- private function generate_html_file($car_id,$file_path)
|
|
|
+ public function detail_url($car_id)
|
|
|
{
|
|
|
- ob_start();
|
|
|
- Tpl::output('tpl', new tpl_display($car_id));
|
|
|
- Tpl::showpage("car/car_info");
|
|
|
- $html_content = ob_get_contents();
|
|
|
- ob_clean();
|
|
|
+ $car_id = intval($car_id);
|
|
|
+ if($car_id <= 0) return '';
|
|
|
+
|
|
|
+ $file_name = "{$car_id}_detail.html";
|
|
|
+ $file_path = BASE_UPLOAD_PATH. DS. "car". DS. $file_name;
|
|
|
+ if(!file_exists($file_path))
|
|
|
+ {
|
|
|
+ if($this->write_file($file_path, $this->detail_file_content($car_id)) == false) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $version = $this->mCarsVersion[$car_id];
|
|
|
+ $url = UPLOAD_SITE_URL. DS. "car". DS. "{$file_name}?{$version}";
|
|
|
|
|
|
+ return $url;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function write_file($file_path, $content)
|
|
|
+ {
|
|
|
$write_success = false;
|
|
|
+
|
|
|
$file = fopen($file_path,'w');
|
|
|
if($file) {
|
|
|
- $write_success = fwrite($file, $html_content);
|
|
|
+ $write_success = fwrite($file, $content);
|
|
|
fclose($file);
|
|
|
}
|
|
|
-
|
|
|
return $write_success;
|
|
|
}
|
|
|
+
|
|
|
+ private function index_file_content($car_id)
|
|
|
+ {
|
|
|
+ $mod_car = Model('car');
|
|
|
+ $car_info = $mod_car->base_info([ 'car_id'=>$car_id ]);
|
|
|
+ ob_start();
|
|
|
+ Tpl::output('car_info', $car_info);
|
|
|
+ Tpl::output('detail_url', $this->detail_url($car_id));
|
|
|
+ Tpl::showpage("car/car_details");
|
|
|
+ $content = ob_get_contents();
|
|
|
+ ob_clean();
|
|
|
+ return $content;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function detail_file_content($car_id)
|
|
|
+ {
|
|
|
+ ob_start();
|
|
|
+ Tpl::output('tpl', new tpl_display($car_id));
|
|
|
+ Tpl::showpage("car/car_info");
|
|
|
+ $content = ob_get_contents();
|
|
|
+ ob_clean();
|
|
|
+ return $content;
|
|
|
+ }
|
|
|
}
|