/trunk/bibliotheque/AppUrls.php |
---|
1,15 → 1,17 |
<?php |
class AppUrls { |
private $urlBase = null; |
private $urlMobile = null; |
private $urlBaseDossier = null; |
private $urlCourante = null; |
private $urlRedirection = null; |
private $urlPopUp = null; |
public function __construct(Url $urlBase = null, Url $urlBaseDossier = null, Url $urlPopUp = null) { |
public function __construct(Url $urlBase = null, Url $urlBaseDossier = null, Url $urlPopUp = null, Url $urlMobile = null) { |
$this->urlBase = (is_null($urlBase)) ? Registre::get('eFlore.urlBase') : $urlBase; |
$this->urlBaseDossier = (is_null($urlBaseDossier)) ? Registre::get('eFlore.urlBaseDossier') : $urlBaseDossier; |
$this->urlPopUp = (is_null($urlPopUp)) ? Registre::get('eFlore.urlPopUp') : $urlPopUp; |
$this->urlMobile = (is_null($urlMobile)) ? Registre::get('eFlore.urlMobile') : $urlMobile; |
} |
public function obtenirUrlBase() { |
168,6 → 170,26 |
return $url; |
} |
public function getParametresUrlMobile() { |
$parametres = array( |
'referentiel' => Registre::get('parametres.referentiel'), |
'niveau' => 1, |
'module' => 'mobile', |
'action' => 'fiche' |
); |
return $parametres; |
} |
public function obtenirUrlMobile($numNom, $type_nom = 'nom_vernaculaire', $nom = '') { |
$parametres = $this->getParametresUrlMobile(); |
$parametres['num_nom'] = $numNom; |
$parametres['type_nom'] = $type_nom; |
$parametres['nom'] = $nom; |
$this->urlMobile->setRequete($parametres); |
$url = $this->urlMobile->getURL(); |
return $url; |
} |
public function getParametresUrlMetaDonnees() { |
$parametres = array( |
'module' => 'fiche-metadonnees', |
/trunk/bibliotheque/QrCode.php |
---|
New file |
0,0 → 1,74 |
<?php |
/** |
* BarcodeQR - Code QR Barcode Image Generator (PNG) |
* |
* @package BarcodeQR |
* @category BarcodeQR |
* @name BarcodeQR |
* @version 1.0 |
* @author Shay Anderson 05.11 |
* @link http://www.shayanderson.com/php/php-qr-code-generator-class.htm |
* @license http://www.gnu.org/licenses/gpl.html GPL License |
* This is free software and is distributed WITHOUT ANY WARRANTY |
*/ |
final class QrCode { |
private $API_CHART_URL = ''; |
private $taille = '150'; |
private $contenu; |
private $urlQrCodeTpl; |
private $dossierQrCode; |
public function __construct($conteneur) { |
$this->API_CHART_URL = $conteneur->getParametre('urlApiChart'); |
$this->dossierQrCode = $conteneur->getParametre('dossierQrCode'); |
$this->urlQrCodeTpl = $conteneur->getParametre('urlQrCodeTpl'); |
} |
/** |
* URL code |
* |
* @param string $url |
*/ |
public function setUrl($url = '') { |
$this->contenu = $url; |
} |
/** |
* Taille du QRcode en pixel. Cela sera forcément un carré. |
* |
* @param string $taille |
*/ |
public function setTaille($taille) { |
$this->taille = $taille; |
} |
/** |
* Generate QR code image |
* |
* @param string $filename |
* @return bool |
*/ |
public function dessiner($idQrCode = null) { |
if (!preg_match('/\.png$/i', $idQrCode)) { |
$idQrCode .= '.png'; |
} |
$cheminImg = $this->dossierQrCode.$idQrCode; |
if (file_exists($cheminImg) == false) { |
$ch = curl_init(); |
curl_setopt($ch, CURLOPT_URL, $this->API_CHART_URL); |
curl_setopt($ch, CURLOPT_POST, true); |
curl_setopt($ch, CURLOPT_POSTFIELDS, "chs={$this->taille}x{$this->taille}&cht=qr&chl=".urlencode($this->contenu)); |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
curl_setopt($ch, CURLOPT_HEADER, false); |
curl_setopt($ch, CURLOPT_TIMEOUT, 30); |
$img = curl_exec($ch); |
curl_close($ch); |
file_put_contents($cheminImg, $img); |
} |
$urlQrCode = sprintf($this->urlQrCodeTpl, $idQrCode); |
return $urlQrCode; |
} |
} |
?> |
/trunk/bibliotheque/Conteneur.php |
---|
130,6 → 130,18 |
return $this->partages['Bdd']; |
} |
public function getCache($dossierStockage = null) { |
if (!isset($this->partages['Cache'])){ |
$params = array( |
'mise_en_cache' => $this->getParametre('cache'), |
'stockage_chemin' => is_null($dossierStockage) ? $this->getParametre('chemincache') : $dossierStockage, |
'duree_de_vie' => $this->getParametre('dureecache') |
); |
$this->partages['Cache'] = new CacheSimple($params); |
} |
return $this->partages['Cache']; |
} |
public function getRestClient() { |
if (!isset($this->partages['RestClient'])){ |
$this->partages['RestClient'] = new RestClient(); |
136,5 → 148,12 |
} |
return $this->partages['RestClient']; |
} |
public function getQrCode() { |
if (!isset($this->partages['QrCode'])){ |
$this->partages['QrCode'] = new QrCode($this); |
} |
return $this->partages['QrCode']; |
} |
} |
?> |