Streetview : Try to reduce the number of hits
This commit is contained in:
parent
83d80a5045
commit
9170fe86d7
@ -1184,8 +1184,11 @@ class IdentiteController extends Zend_Controller_Action
|
||||
$heading = $deg[$num];
|
||||
$streetview->setHeading($heading);
|
||||
//$streetview->setLocationTxt($adresse);
|
||||
$url = '/fichier/streetview/'.$streetview->display();
|
||||
$this->view->assign('url', $url);
|
||||
$img = $streetview->display();
|
||||
if ( $img!==false ) {
|
||||
$url = '/fichier/streetview/'.$streetview->display();
|
||||
$this->view->assign('url', $url);
|
||||
}
|
||||
}
|
||||
$this->view->assign('lat', $lat);
|
||||
$this->view->assign('lon', $lon);
|
||||
|
@ -156,7 +156,6 @@ class Scores_Google_Streetview
|
||||
*/
|
||||
public function getImg()
|
||||
{
|
||||
Zend_Registry::get('firebug')->info('URL = '.$this->url);
|
||||
try {
|
||||
$client = new Zend_Http_Client($this->url);
|
||||
$client->setStream();
|
||||
@ -164,10 +163,12 @@ class Scores_Google_Streetview
|
||||
if ( $response->isSuccessful() ) {
|
||||
if (!copy($response->getStreamName(), $this->pathImg())) {
|
||||
Zend_Registry::get('firebug')->info('Erreur copie image !');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (Zend_Http_Client_Exception $e) {
|
||||
Zend_Registry::get('firebug')->info('HTTP Exception : '.$e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,13 +189,21 @@ class Scores_Google_Streetview
|
||||
public function display()
|
||||
{
|
||||
$this->url = $this->urlImg();
|
||||
Zend_Registry::get('firebug')->info('URL = '.$file);
|
||||
$file = $this->pathImg();
|
||||
Zend_Registry::get('firebug')->info('Filename = '.$file);
|
||||
if ( !file_exists($file) ) {
|
||||
$this->getImg();
|
||||
$imgExist = false;
|
||||
if ( !file_exists($file) && APPLICATION_ENV == 'production' ) {
|
||||
$imgExist = $this->getImg();
|
||||
} elseif (file_exists($file)) {
|
||||
$imgExist = true;
|
||||
}
|
||||
|
||||
return basename($file);
|
||||
if ($imgExist) {
|
||||
return basename($file);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user