Merge from branch 2.4
This commit is contained in:
commit
4e9e5aea9e
6
application/models/JoScoresCutoffMvt.php
Normal file
6
application/models/JoScoresCutoffMvt.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
class Application_Model_JoScoresCutoffMvt extends Zend_Db_Table_Abstract
|
||||
{
|
||||
protected $_name = 'scores_cutoff_mvt';
|
||||
protected $_schema = 'jo';
|
||||
}
|
@ -35,14 +35,13 @@ class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
|
||||
if ($checkAuth) {
|
||||
$login = $request->getParam('login');
|
||||
$pass = $request->getParam('pass', '');
|
||||
$hach = $request->getParam('hach');
|
||||
|
||||
$auth = Zend_Auth::getInstance();
|
||||
|
||||
//On vérifie le tout lors d'une connexion par url
|
||||
if ( !empty($login) && !empty($hach) ) {
|
||||
if ( !empty($login) && !empty($pass) ) {
|
||||
|
||||
$authAdapter = new Scores_AuthAdapter($login, $hach, $checkWs);
|
||||
$authAdapter = new Scores_AuthAdapter($login, $pass, $checkWs);
|
||||
$result = $auth->authenticate($authAdapter);
|
||||
if (!$result->isValid()) {
|
||||
$layout = Zend_Layout::getMVCInstance();
|
||||
|
@ -14809,8 +14809,14 @@ $tabFormules[392]['borneMin']='';
|
||||
$tabFormules[392]['borneMax']='';
|
||||
$tabFormules[392]['formule']='(R[233]*12)/nm';
|
||||
|
||||
|
||||
function calculRatios($tabBilans, $tabIdentite, $accesPartenaire) {
|
||||
global $tva, $tabFormules, $mBil, $tabBilan, $efftr;
|
||||
global $tva;
|
||||
global $tabFormules; //Never use in fonctions
|
||||
global $mBil; //Partage de la classe déjà déclaré dans calculIndiscore
|
||||
global $tabBilan;
|
||||
global $efftr;
|
||||
|
||||
$numBil=0;
|
||||
$numBilType=array();
|
||||
foreach ($tabBilans as $millesime=>$bil) {
|
||||
|
@ -26,4 +26,12 @@ return array(
|
||||
'idClient' => 32,
|
||||
'user' => array('mricois', 'yleanour'),
|
||||
),
|
||||
'sfr' => array(
|
||||
'actif' => true,
|
||||
'versions' => array(
|
||||
'0.1' => array( 'actif' => true, 'defaut' => true ),
|
||||
),
|
||||
'idClient' => 157,
|
||||
'user' => array('mricois', 'yleanour'),
|
||||
),
|
||||
);
|
@ -13,18 +13,37 @@ class Entreprise extends WsScore
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Evaluation
|
||||
* @param string $siren
|
||||
* Identifiant de l'entreprise (9 chiffres)
|
||||
* @return Evaluation
|
||||
*/
|
||||
public function getEvaluate($siren)
|
||||
{
|
||||
//Vérifier le siren
|
||||
$this->authenticate();
|
||||
|
||||
if ( strlen($siren) != 9 ) {
|
||||
$this->sendError('1010');
|
||||
}
|
||||
|
||||
$classInsee = new MInsee();
|
||||
|
||||
//Vérifier SIREN valide
|
||||
if( !$classInsee->valideSiren($siren) ) {
|
||||
$this->sendError('1010');
|
||||
}
|
||||
|
||||
//Vérifier SIREN existe
|
||||
if ( !$classInsee->sirenExiste($siren) ) {
|
||||
$this->sendError('1020');
|
||||
}
|
||||
|
||||
//Calculate
|
||||
$eval = new Evaluation();
|
||||
|
||||
$eval->indicateur = '';
|
||||
$eval->po = 0;
|
||||
$eval->comment = '';
|
||||
$eval->dateScore = '0000-00-00';
|
||||
return $eval;
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,8 @@ class Evaluation
|
||||
public $comment;
|
||||
|
||||
/**
|
||||
* Date ???? format AAAA-MM-JJ
|
||||
* Date calcul indiScore (AAAA-MM-JJ)
|
||||
* @var string
|
||||
*/
|
||||
public $date;
|
||||
public $dateScore;
|
||||
}
|
@ -2224,13 +2224,18 @@ class Saisie extends WsScore
|
||||
* scoreDir
|
||||
* scoreConf
|
||||
* remarque
|
||||
* @param boolean $delete
|
||||
* @throws SoapFault
|
||||
* @return int
|
||||
*/
|
||||
public function setScoreCutoff($infos)
|
||||
public function setScoreCutoff($infos, $delete = false)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
if (null === $delete) {
|
||||
$delete = false;
|
||||
}
|
||||
|
||||
$data = json_decode($infos, true);
|
||||
|
||||
//if profil = score (20), use this table to convert
|
||||
@ -2266,8 +2271,36 @@ class Saisie extends WsScore
|
||||
$cutoffM = new Application_Model_JoScoresCutoff();
|
||||
$sql = $cutoffM->select()->where('siren=?', $data['siren']);
|
||||
$row = $cutoffM->fetchRow($sql);
|
||||
if ( null === $row ) {
|
||||
$data = array_merge($data, array('dateInsert'=>date('YmdHis')));
|
||||
|
||||
//Historisation
|
||||
if ( null !== $row ) {
|
||||
$mvtM = new Application_Model_JoScoresCutoffMvt();
|
||||
$backupData = $row->toArray();
|
||||
unset($backupData['dateUpdate']);
|
||||
$backupData = array_merge($backupData, array(
|
||||
'idMvt' => $this->tabInfoUser['id'],
|
||||
'dateMvt'=>date('YmdHis')
|
||||
));
|
||||
|
||||
try {
|
||||
$mvtM->insert($backupData);
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->tabInfoUser['idClient']!=1) {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
} else {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$cutoffM->delete('siren='.$data['siren']);
|
||||
}
|
||||
|
||||
if ( !$delete ) {
|
||||
//Insertion
|
||||
$data = array_merge($data, array(
|
||||
'idInsert' => $this->tabInfoUser['id'],
|
||||
'dateInsert'=>date('YmdHis')
|
||||
));
|
||||
try {
|
||||
$result = $cutoffM->insert($data);
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
@ -2276,39 +2309,29 @@ class Saisie extends WsScore
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$result = $cutoffM->update($data, 'siren='.$data['siren']);
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->tabInfoUser['idClient']==1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Mise en surveillance
|
||||
if ($result>0 && !empty($this->tabInfoUser['email'])) {
|
||||
$iInsee = new MInsee();
|
||||
$tabIdentite = $iInsee->getIdentiteLight($data['siren']);
|
||||
$data = array(
|
||||
'source' => 'score',
|
||||
'login' => $this->tabInfoUser['login'],
|
||||
'email' => $this->tabInfoUser['email'],
|
||||
'siren' => $data['siren'],
|
||||
'nic' => 0,
|
||||
'ref' => 'CUTOFF',
|
||||
'encoursClient' => 0,
|
||||
'rs' => $tabIdentite['Nom'],
|
||||
'cp' => $tabIdentite['CP'],
|
||||
'ville' => $tabIdentite['Ville'],
|
||||
'dateAjout'=>date('Y-m-d'),
|
||||
'dateSuppr'=>0,
|
||||
);
|
||||
$iDb = new WDB('jo');
|
||||
$iDb->insert('surveillances_site', $data);
|
||||
}
|
||||
|
||||
//Mise en surveillance
|
||||
if ($result>0 && !empty($this->tabInfoUser['email'])) {
|
||||
$iInsee = new MInsee();
|
||||
$tabIdentite = $iInsee->getIdentiteLight($data['siren']);
|
||||
$data = array(
|
||||
'source' => 'score',
|
||||
'login' => $this->tabInfoUser['login'],
|
||||
'email' => $this->tabInfoUser['email'],
|
||||
'siren' => $data['siren'],
|
||||
'nic' => 0,
|
||||
'ref' => 'CUTOFF',
|
||||
'encoursClient' => 0,
|
||||
'rs' => $tabIdentite['Nom'],
|
||||
'cp' => $tabIdentite['CP'],
|
||||
'ville' => $tabIdentite['Ville'],
|
||||
'dateAjout'=>date('Y-m-d'),
|
||||
'dateSuppr'=>0,
|
||||
);
|
||||
$iDb = new WDB('jo');
|
||||
$iDb->insert('surveillances_site', $data);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
@ -2374,5 +2397,5 @@ class Saisie extends WsScore
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -16,7 +16,7 @@
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Reader.php 25103 2012-11-07 20:29:29Z rob $
|
||||
* @version $Id: Reader.php 25275 2013-03-06 09:55:33Z frosch $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -443,7 +443,9 @@ class Zend_Feed_Reader
|
||||
* Detect the feed type of the provided feed
|
||||
*
|
||||
* @param Zend_Feed_Abstract|DOMDocument|string $feed
|
||||
* @param bool $specOnly
|
||||
* @return string
|
||||
* @throws Zend_Feed_Exception
|
||||
*/
|
||||
public static function detectType($feed, $specOnly = false)
|
||||
{
|
||||
|
@ -16,7 +16,7 @@
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: EntryAbstract.php 25024 2012-07-30 15:08:15Z rob $
|
||||
* @version $Id: EntryAbstract.php 25275 2013-03-06 09:55:33Z frosch $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -72,9 +72,9 @@ abstract class Zend_Feed_Reader_EntryAbstract
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DOMElement $entry
|
||||
* @param int $entryKey
|
||||
* @param string $type
|
||||
* @param DOMElement $entry
|
||||
* @param int $entryKey
|
||||
* @param string|null $type
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DOMElement $entry, $entryKey, $type = null)
|
||||
@ -85,7 +85,9 @@ abstract class Zend_Feed_Reader_EntryAbstract
|
||||
if ($type !== null) {
|
||||
$this->_data['type'] = $type;
|
||||
} else {
|
||||
$this->_data['type'] = Zend_Feed_Reader::detectType($feed);
|
||||
$this->_data['type'] = Zend_Feed_Reader::detectType(
|
||||
$this->_domDocument
|
||||
);
|
||||
}
|
||||
$this->_loadExtensions();
|
||||
}
|
||||
@ -212,8 +214,10 @@ abstract class Zend_Feed_Reader_EntryAbstract
|
||||
}
|
||||
}
|
||||
require_once 'Zend/Feed/Exception.php';
|
||||
throw new Zend_Feed_Exception('Method: ' . $method
|
||||
. 'does not exist and could not be located on a registered Extension');
|
||||
throw new Zend_Feed_Exception(
|
||||
'Method: ' . $method
|
||||
. 'does not exist and could not be located on a registered Extension'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@
|
||||
* @category Zend
|
||||
* @package Zend_Http
|
||||
* @subpackage Client_Adapter
|
||||
* @version $Id: Proxy.php 25261 2013-02-14 12:31:01Z frosch $
|
||||
* @version $Id: Proxy.php 25273 2013-03-06 08:02:21Z frosch $
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
@ -66,7 +66,7 @@ class Zend_Http_Client_Adapter_Proxy extends Zend_Http_Client_Adapter_Socket
|
||||
'proxy_user' => '',
|
||||
'proxy_pass' => '',
|
||||
'proxy_auth' => Zend_Http_Client::AUTH_BASIC,
|
||||
'persistent' => false
|
||||
'persistent' => false,
|
||||
);
|
||||
|
||||
/**
|
||||
@ -96,7 +96,7 @@ class Zend_Http_Client_Adapter_Proxy extends Zend_Http_Client_Adapter_Socket
|
||||
public function connect($host, $port = 80, $secure = false)
|
||||
{
|
||||
// If no proxy is set, fall back to Socket adapter
|
||||
if (! $this->config['proxy_host']) {
|
||||
if (!$this->config['proxy_host']) {
|
||||
return parent::connect($host, $port, $secure);
|
||||
}
|
||||
|
||||
@ -124,7 +124,9 @@ class Zend_Http_Client_Adapter_Proxy extends Zend_Http_Client_Adapter_Socket
|
||||
* @return string Request as string
|
||||
* @throws Zend_Http_Client_Adapter_Exception
|
||||
*/
|
||||
public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '')
|
||||
public function write(
|
||||
$method, $uri, $http_ver = '1.1', $headers = array(), $body = ''
|
||||
)
|
||||
{
|
||||
// If no proxy is set, fall back to default Socket adapter
|
||||
if (!$this->config['proxy_host']) {
|
||||
@ -142,7 +144,9 @@ class Zend_Http_Client_Adapter_Proxy extends Zend_Http_Client_Adapter_Socket
|
||||
$host = $this->config['proxy_host'];
|
||||
$port = $this->config['proxy_port'];
|
||||
|
||||
if ($this->connected_to[0] != "tcp://$host" || $this->connected_to[1] != $port) {
|
||||
if ($this->connected_to[0] != "tcp://$host"
|
||||
|| $this->connected_to[1] != $port
|
||||
) {
|
||||
require_once 'Zend/Http/Client/Adapter/Exception.php';
|
||||
throw new Zend_Http_Client_Adapter_Exception(
|
||||
'Trying to write but we are connected to the wrong proxy server'
|
||||
@ -307,7 +311,7 @@ class Zend_Http_Client_Adapter_Proxy extends Zend_Http_Client_Adapter_Socket
|
||||
}
|
||||
}
|
||||
|
||||
if (false !== $success) {
|
||||
if (!$success) {
|
||||
require_once 'Zend/Http/Client/Adapter/Exception.php';
|
||||
throw new Zend_Http_Client_Adapter_Exception(
|
||||
'Unable to connect to HTTPS server through proxy: could not '
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage SlideShare
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: SlideShare.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
* @version $Id: SlideShare.php 25283 2013-03-09 10:07:13Z frosch $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -49,7 +49,6 @@ require_once 'Zend/Service/SlideShare/SlideShow.php';
|
||||
*/
|
||||
class Zend_Service_SlideShare
|
||||
{
|
||||
|
||||
/**
|
||||
* Web service result code mapping
|
||||
*/
|
||||
@ -71,17 +70,17 @@ class Zend_Service_SlideShare
|
||||
/**
|
||||
* Slide share Web service communication URIs
|
||||
*/
|
||||
const SERVICE_UPLOAD_URI = 'http://www.slideshare.net/api/1/upload_slideshow';
|
||||
const SERVICE_GET_SHOW_URI = 'http://www.slideshare.net/api/1/get_slideshow';
|
||||
const SERVICE_GET_SHOW_BY_USER_URI = 'http://www.slideshare.net/api/1/get_slideshow_by_user';
|
||||
const SERVICE_GET_SHOW_BY_TAG_URI = 'http://www.slideshare.net/api/1/get_slideshow_by_tag';
|
||||
const SERVICE_GET_SHOW_BY_GROUP_URI = 'http://www.slideshare.net/api/1/get_slideshows_from_group';
|
||||
const SERVICE_UPLOAD_URI = 'https://www.slideshare.net/api/2/upload_slideshow';
|
||||
const SERVICE_GET_SHOW_URI = 'https://www.slideshare.net/api/2/get_slideshow';
|
||||
const SERVICE_GET_SHOW_BY_USER_URI = 'https://www.slideshare.net/api/2/get_slideshows_by_user';
|
||||
const SERVICE_GET_SHOW_BY_TAG_URI = 'https://www.slideshare.net/api/2/get_slideshows_by_tag';
|
||||
const SERVICE_GET_SHOW_BY_GROUP_URI = 'https://www.slideshare.net/api/2/get_slideshows_by_group';
|
||||
|
||||
/**
|
||||
* The MIME type of Slideshow files
|
||||
*
|
||||
*/
|
||||
const POWERPOINT_MIME_TYPE = "application/vnd.ms-powerpoint";
|
||||
const POWERPOINT_MIME_TYPE = "application/vnd.ms-powerpoint";
|
||||
|
||||
/**
|
||||
* The API key to use in requests
|
||||
@ -147,15 +146,20 @@ class Zend_Service_SlideShare
|
||||
public function getHttpClient()
|
||||
{
|
||||
|
||||
if(!($this->_httpclient instanceof Zend_Http_Client)) {
|
||||
if (!($this->_httpclient instanceof Zend_Http_Client)) {
|
||||
$client = new Zend_Http_Client();
|
||||
$client->setConfig(array('maxredirects' => 2,
|
||||
'timeout' => 5));
|
||||
$client->setConfig(
|
||||
array(
|
||||
'maxredirects' => 2,
|
||||
'timeout' => 5
|
||||
)
|
||||
);
|
||||
|
||||
$this->setHttpClient($client);
|
||||
}
|
||||
|
||||
$this->_httpclient->resetParameters();
|
||||
|
||||
return $this->_httpclient;
|
||||
}
|
||||
|
||||
@ -181,10 +185,16 @@ class Zend_Service_SlideShare
|
||||
public function getCacheObject()
|
||||
{
|
||||
|
||||
if(!($this->_cacheobject instanceof Zend_Cache_Core)) {
|
||||
$cache = Zend_Cache::factory('Core', 'File', array('lifetime' => 43200,
|
||||
'automatic_serialization' => true),
|
||||
array('cache_dir' => '/tmp'));
|
||||
if (!($this->_cacheobject instanceof Zend_Cache_Core)) {
|
||||
$cache = Zend_Cache::factory(
|
||||
'Core',
|
||||
'File',
|
||||
array(
|
||||
'lifetime' => 43200,
|
||||
'automatic_serialization' => true
|
||||
),
|
||||
array('cache_dir' => '/tmp')
|
||||
);
|
||||
|
||||
$this->setCacheObject($cache);
|
||||
}
|
||||
@ -283,17 +293,19 @@ class Zend_Service_SlideShare
|
||||
/**
|
||||
* The Constructor
|
||||
*
|
||||
* @param string $apikey The API key
|
||||
* @param string $apikey The API key
|
||||
* @param string $sharedSecret The shared secret
|
||||
* @param string $username The username
|
||||
* @param string $password The password
|
||||
* @param string $username The username
|
||||
* @param string $password The password
|
||||
*/
|
||||
public function __construct($apikey, $sharedSecret, $username = null, $password = null)
|
||||
public function __construct(
|
||||
$apikey, $sharedSecret, $username = null, $password = null
|
||||
)
|
||||
{
|
||||
$this->setApiKey($apikey)
|
||||
->setSharedSecret($sharedSecret)
|
||||
->setUserName($username)
|
||||
->setPassword($password);
|
||||
->setSharedSecret($sharedSecret)
|
||||
->setUserName($username)
|
||||
->setPassword($password);
|
||||
|
||||
$this->_httpclient = new Zend_Http_Client();
|
||||
}
|
||||
@ -301,41 +313,47 @@ class Zend_Service_SlideShare
|
||||
/**
|
||||
* Uploads the specified Slide show the the server
|
||||
*
|
||||
* @param Zend_Service_SlideShare_SlideShow $ss The slide show object representing the slide show to upload
|
||||
* @param boolean $make_src_public Determines if the the slide show's source file is public or not upon upload
|
||||
* @param Zend_Service_SlideShare_SlideShow $ss The slide show object representing the slide show to upload
|
||||
* @param boolean $makeSrcPublic Determines if the the slide show's source file is public or not upon upload
|
||||
* @return Zend_Service_SlideShare_SlideShow The passed Slide show object, with the new assigned ID provided
|
||||
* @throws Zend_Service_SlideShare_Exception
|
||||
*/
|
||||
public function uploadSlideShow(Zend_Service_SlideShare_SlideShow $ss, $make_src_public = true)
|
||||
public function uploadSlideShow(
|
||||
Zend_Service_SlideShare_SlideShow $ss, $makeSrcPublic = true
|
||||
)
|
||||
{
|
||||
|
||||
$timestamp = time();
|
||||
|
||||
$params = array('api_key' => $this->getApiKey(),
|
||||
'ts' => $timestamp,
|
||||
'hash' => sha1($this->getSharedSecret().$timestamp),
|
||||
'username' => $this->getUserName(),
|
||||
'password' => $this->getPassword(),
|
||||
'slideshow_title' => $ss->getTitle());
|
||||
$params = array(
|
||||
'api_key' => $this->getApiKey(),
|
||||
'ts' => $timestamp,
|
||||
'hash' => sha1($this->getSharedSecret() . $timestamp),
|
||||
'username' => $this->getUserName(),
|
||||
'password' => $this->getPassword(),
|
||||
'slideshow_title' => $ss->getTitle()
|
||||
);
|
||||
|
||||
$description = $ss->getDescription();
|
||||
$tags = $ss->getTags();
|
||||
$tags = $ss->getTags();
|
||||
|
||||
$filename = $ss->getFilename();
|
||||
|
||||
if(!file_exists($filename) || !is_readable($filename)) {
|
||||
if (!file_exists($filename) || !is_readable($filename)) {
|
||||
require_once 'Zend/Service/SlideShare/Exception.php';
|
||||
throw new Zend_Service_SlideShare_Exception("Specified Slideshow for upload not found or unreadable");
|
||||
throw new Zend_Service_SlideShare_Exception(
|
||||
'Specified Slideshow for upload not found or unreadable'
|
||||
);
|
||||
}
|
||||
|
||||
if(!empty($description)) {
|
||||
if (!empty($description)) {
|
||||
$params['slideshow_description'] = $description;
|
||||
} else {
|
||||
$params['slideshow_description'] = "";
|
||||
}
|
||||
|
||||
if(!empty($tags)) {
|
||||
if (!empty($tags)) {
|
||||
$tmp = array();
|
||||
foreach($tags as $tag) {
|
||||
foreach ($tags as $tag) {
|
||||
$tmp[] = "\"$tag\"";
|
||||
}
|
||||
$params['slideshow_tags'] = implode(' ', $tmp);
|
||||
@ -343,7 +361,6 @@ class Zend_Service_SlideShare
|
||||
$params['slideshow_tags'] = "";
|
||||
}
|
||||
|
||||
|
||||
$client = $this->getHttpClient();
|
||||
$client->setUri(self::SERVICE_UPLOAD_URI);
|
||||
$client->setParameterPost($params);
|
||||
@ -352,23 +369,29 @@ class Zend_Service_SlideShare
|
||||
require_once 'Zend/Http/Client/Exception.php';
|
||||
try {
|
||||
$response = $client->request('POST');
|
||||
} catch(Zend_Http_Client_Exception $e) {
|
||||
} catch (Zend_Http_Client_Exception $e) {
|
||||
require_once 'Zend/Service/SlideShare/Exception.php';
|
||||
throw new Zend_Service_SlideShare_Exception("Service Request Failed: {$e->getMessage()}", 0, $e);
|
||||
throw new Zend_Service_SlideShare_Exception(
|
||||
"Service Request Failed: {$e->getMessage()}", 0, $e
|
||||
);
|
||||
}
|
||||
|
||||
$sxe = simplexml_load_string($response->getBody());
|
||||
|
||||
if($sxe->getName() == "SlideShareServiceError") {
|
||||
if ($sxe->getName() == "SlideShareServiceError") {
|
||||
$message = (string)$sxe->Message[0];
|
||||
list($code, $error_str) = explode(':', $message);
|
||||
require_once 'Zend/Service/SlideShare/Exception.php';
|
||||
throw new Zend_Service_SlideShare_Exception(trim($error_str), $code);
|
||||
throw new Zend_Service_SlideShare_Exception(trim(
|
||||
$error_str
|
||||
), $code);
|
||||
}
|
||||
|
||||
if(!$sxe->getName() == "SlideShowUploaded") {
|
||||
if (!$sxe->getName() == "SlideShowUploaded") {
|
||||
require_once 'Zend/Service/SlideShare/Exception.php';
|
||||
throw new Zend_Service_SlideShare_Exception("Unknown XML Respons Received");
|
||||
throw new Zend_Service_SlideShare_Exception(
|
||||
'Unknown XML Respons Received'
|
||||
);
|
||||
}
|
||||
|
||||
$ss->setId((int)(string)$sxe->SlideShowID);
|
||||
@ -381,21 +404,24 @@ class Zend_Service_SlideShare
|
||||
*
|
||||
* @param int $ss_id The slide show ID
|
||||
* @return Zend_Service_SlideShare_SlideShow the Slideshow object
|
||||
* @throws Zend_Service_SlideShare_Exception
|
||||
*/
|
||||
public function getSlideShow($ss_id)
|
||||
{
|
||||
$timestamp = time();
|
||||
|
||||
$params = array('api_key' => $this->getApiKey(),
|
||||
'ts' => $timestamp,
|
||||
'hash' => sha1($this->getSharedSecret().$timestamp),
|
||||
'slideshow_id' => $ss_id);
|
||||
$params = array(
|
||||
'api_key' => $this->getApiKey(),
|
||||
'ts' => $timestamp,
|
||||
'hash' => sha1($this->getSharedSecret() . $timestamp),
|
||||
'slideshow_id' => $ss_id
|
||||
);
|
||||
|
||||
$cache = $this->getCacheObject();
|
||||
|
||||
$cache_key = md5("__zendslideshare_cache_$ss_id");
|
||||
|
||||
if(!$retval = $cache->load($cache_key)) {
|
||||
if (!$retval = $cache->load($cache_key)) {
|
||||
$client = $this->getHttpClient();
|
||||
|
||||
$client->setUri(self::SERVICE_GET_SHOW_URI);
|
||||
@ -404,26 +430,31 @@ class Zend_Service_SlideShare
|
||||
require_once 'Zend/Http/Client/Exception.php';
|
||||
try {
|
||||
$response = $client->request('POST');
|
||||
} catch(Zend_Http_Client_Exception $e) {
|
||||
} catch (Zend_Http_Client_Exception $e) {
|
||||
require_once 'Zend/Service/SlideShare/Exception.php';
|
||||
throw new Zend_Service_SlideShare_Exception("Service Request Failed: {$e->getMessage()}", 0, $e);
|
||||
throw new Zend_Service_SlideShare_Exception(
|
||||
"Service Request Failed: {$e->getMessage()}", 0, $e
|
||||
);
|
||||
}
|
||||
|
||||
$sxe = simplexml_load_string($response->getBody());
|
||||
|
||||
if($sxe->getName() == "SlideShareServiceError") {
|
||||
if ($sxe->getName() == "SlideShareServiceError") {
|
||||
$message = (string)$sxe->Message[0];
|
||||
list($code, $error_str) = explode(':', $message);
|
||||
require_once 'Zend/Service/SlideShare/Exception.php';
|
||||
throw new Zend_Service_SlideShare_Exception(trim($error_str), $code);
|
||||
throw new Zend_Service_SlideShare_Exception(trim(
|
||||
$error_str
|
||||
), $code);
|
||||
}
|
||||
|
||||
if(!$sxe->getName() == 'Slideshows') {
|
||||
if (!($sxe->getName() == 'Slideshow')) {
|
||||
require_once 'Zend/Service/SlideShare/Exception.php';
|
||||
throw new Zend_Service_SlideShare_Exception('Unknown XML Repsonse Received');
|
||||
throw new Zend_Service_SlideShare_Exception(
|
||||
'Unknown XML Repsonse Received'
|
||||
);
|
||||
}
|
||||
|
||||
$retval = $this->_slideShowNodeToObject(clone $sxe->Slideshow[0]);
|
||||
$retval = $this->_slideShowNodeToObject(clone $sxe);
|
||||
|
||||
$cache->save($retval, $cache_key);
|
||||
}
|
||||
@ -439,9 +470,13 @@ class Zend_Service_SlideShare
|
||||
* @param int $limit The maximum number of slide shows to retrieve
|
||||
* @return array An array of Zend_Service_SlideShare_SlideShow objects
|
||||
*/
|
||||
public function getSlideShowsByUsername($username, $offset = null, $limit = null)
|
||||
public function getSlideShowsByUsername(
|
||||
$username, $offset = null, $limit = null
|
||||
)
|
||||
{
|
||||
return $this->_getSlideShowsByType('username_for', $username, $offset, $limit);
|
||||
return $this->_getSlideShowsByType(
|
||||
'username_for', $username, $offset, $limit
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -455,9 +490,9 @@ class Zend_Service_SlideShare
|
||||
public function getSlideShowsByTag($tag, $offset = null, $limit = null)
|
||||
{
|
||||
|
||||
if(is_array($tag)) {
|
||||
if (is_array($tag)) {
|
||||
$tmp = array();
|
||||
foreach($tag as $t) {
|
||||
foreach ($tag as $t) {
|
||||
$tmp[] = "\"$t\"";
|
||||
}
|
||||
|
||||
@ -484,33 +519,35 @@ class Zend_Service_SlideShare
|
||||
* Retrieves Zend_Service_SlideShare_SlideShow object arrays based on the type of
|
||||
* list desired
|
||||
*
|
||||
* @param string $key The type of slide show object to retrieve
|
||||
* @param string $value The specific search query for the slide show type to look up
|
||||
* @param int $offset The offset of the list to start retrieving from
|
||||
* @param int $limit The maximum number of slide shows to retrieve
|
||||
* @param string $key The type of slide show object to retrieve
|
||||
* @param string $value The specific search query for the slide show type to look up
|
||||
* @param int $offset The offset of the list to start retrieving from
|
||||
* @param int $limit The maximum number of slide shows to retrieve
|
||||
* @return array An array of Zend_Service_SlideShare_SlideShow objects
|
||||
* @throws Zend_Service_SlideShare_Exception
|
||||
*/
|
||||
protected function _getSlideShowsByType($key, $value, $offset = null, $limit = null)
|
||||
{
|
||||
|
||||
$key = strtolower($key);
|
||||
|
||||
switch($key) {
|
||||
switch ($key) {
|
||||
case 'username_for':
|
||||
$responseTag = 'User';
|
||||
$queryUri = self::SERVICE_GET_SHOW_BY_USER_URI;
|
||||
$queryUri = self::SERVICE_GET_SHOW_BY_USER_URI;
|
||||
break;
|
||||
case 'group_name':
|
||||
$responseTag = 'Group';
|
||||
$queryUri = self::SERVICE_GET_SHOW_BY_GROUP_URI;
|
||||
$queryUri = self::SERVICE_GET_SHOW_BY_GROUP_URI;
|
||||
break;
|
||||
case 'tag':
|
||||
$responseTag = 'Tag';
|
||||
$queryUri = self::SERVICE_GET_SHOW_BY_TAG_URI;
|
||||
$queryUri = self::SERVICE_GET_SHOW_BY_TAG_URI;
|
||||
break;
|
||||
default:
|
||||
require_once 'Zend/Service/SlideShare/Exception.php';
|
||||
throw new Zend_Service_SlideShare_Exception("Invalid SlideShare Query");
|
||||
throw new Zend_Service_SlideShare_Exception(
|
||||
'Invalid SlideShare Query'
|
||||
);
|
||||
}
|
||||
|
||||
$timestamp = time();
|
||||
@ -520,11 +557,11 @@ class Zend_Service_SlideShare
|
||||
'hash' => sha1($this->getSharedSecret().$timestamp),
|
||||
$key => $value);
|
||||
|
||||
if($offset !== null) {
|
||||
if ($offset !== null) {
|
||||
$params['offset'] = (int)$offset;
|
||||
}
|
||||
|
||||
if($limit !== null) {
|
||||
if ($limit !== null) {
|
||||
$params['limit'] = (int)$limit;
|
||||
}
|
||||
|
||||
@ -532,8 +569,7 @@ class Zend_Service_SlideShare
|
||||
|
||||
$cache_key = md5($key.$value.$offset.$limit);
|
||||
|
||||
if(!$retval = $cache->load($cache_key)) {
|
||||
|
||||
if (!$retval = $cache->load($cache_key)) {
|
||||
$client = $this->getHttpClient();
|
||||
|
||||
$client->setUri($queryUri);
|
||||
@ -542,29 +578,35 @@ class Zend_Service_SlideShare
|
||||
require_once 'Zend/Http/Client/Exception.php';
|
||||
try {
|
||||
$response = $client->request('POST');
|
||||
} catch(Zend_Http_Client_Exception $e) {
|
||||
} catch (Zend_Http_Client_Exception $e) {
|
||||
require_once 'Zend/Service/SlideShare/Exception.php';
|
||||
throw new Zend_Service_SlideShare_Exception("Service Request Failed: {$e->getMessage()}", 0, $e);
|
||||
throw new Zend_Service_SlideShare_Exception(
|
||||
"Service Request Failed: {$e->getMessage()}", 0, $e
|
||||
);
|
||||
}
|
||||
|
||||
$sxe = simplexml_load_string($response->getBody());
|
||||
|
||||
if($sxe->getName() == "SlideShareServiceError") {
|
||||
if ($sxe->getName() == "SlideShareServiceError") {
|
||||
$message = (string)$sxe->Message[0];
|
||||
list($code, $error_str) = explode(':', $message);
|
||||
require_once 'Zend/Service/SlideShare/Exception.php';
|
||||
throw new Zend_Service_SlideShare_Exception(trim($error_str), $code);
|
||||
throw new Zend_Service_SlideShare_Exception(
|
||||
trim($error_str), $code
|
||||
);
|
||||
}
|
||||
|
||||
if(!$sxe->getName() == $responseTag) {
|
||||
if (!$sxe->getName() == $responseTag) {
|
||||
require_once 'Zend/Service/SlideShare/Exception.php';
|
||||
throw new Zend_Service_SlideShare_Exception('Unknown or Invalid XML Repsonse Received');
|
||||
throw new Zend_Service_SlideShare_Exception(
|
||||
'Unknown or Invalid XML Repsonse Received'
|
||||
);
|
||||
}
|
||||
|
||||
$retval = array();
|
||||
|
||||
foreach($sxe->children() as $node) {
|
||||
if($node->getName() == 'Slideshow') {
|
||||
foreach ($sxe->children() as $node) {
|
||||
if ($node->getName() == 'Slideshow') {
|
||||
$retval[] = $this->_slideShowNodeToObject($node);
|
||||
}
|
||||
}
|
||||
@ -581,12 +623,12 @@ class Zend_Service_SlideShare
|
||||
*
|
||||
* @param SimpleXMLElement $node The input XML from the slideshare.net service
|
||||
* @return Zend_Service_SlideShare_SlideShow The resulting object
|
||||
* @throws Zend_Service_SlideShare_Exception
|
||||
*/
|
||||
protected function _slideShowNodeToObject(SimpleXMLElement $node)
|
||||
{
|
||||
|
||||
if($node->getName() == 'Slideshow') {
|
||||
|
||||
$ss = new Zend_Service_SlideShare_SlideShow();
|
||||
|
||||
$ss->setId((string)$node->ID);
|
||||
@ -597,9 +639,8 @@ class Zend_Service_SlideShare
|
||||
$ss->setStatus((string)$node->Status);
|
||||
$ss->setStatusDescription((string)$node->StatusDescription);
|
||||
|
||||
foreach(explode(",", (string)$node->Tags) as $tag) {
|
||||
|
||||
if(!in_array($tag, $ss->getTags())) {
|
||||
foreach (explode(",", (string)$node->Tags) as $tag) {
|
||||
if (!in_array($tag, $ss->getTags())) {
|
||||
$ss->addTag($tag);
|
||||
}
|
||||
}
|
||||
@ -610,10 +651,11 @@ class Zend_Service_SlideShare
|
||||
$ss->setTranscript((string)$node->Transcript);
|
||||
|
||||
return $ss;
|
||||
|
||||
}
|
||||
|
||||
require_once 'Zend/Service/SlideShare/Exception.php';
|
||||
throw new Zend_Service_SlideShare_Exception("Was not provided the expected XML Node for processing");
|
||||
throw new Zend_Service_SlideShare_Exception(
|
||||
'Was not provided the expected XML Node for processing'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage SlideShare
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: SlideShow.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
* @version $Id: SlideShow.php 25283 2013-03-09 10:07:13Z frosch $
|
||||
*/
|
||||
|
||||
|
||||
@ -33,7 +33,6 @@
|
||||
*/
|
||||
class Zend_Service_SlideShare_SlideShow
|
||||
{
|
||||
|
||||
/**
|
||||
* Status constant mapping for web service
|
||||
*
|
||||
@ -328,7 +327,7 @@ class Zend_Service_SlideShare_SlideShow
|
||||
/**
|
||||
* Sets the description for the Slide show
|
||||
*
|
||||
* @param strign $desc The description of the slide show
|
||||
* @param string $desc The description of the slide show
|
||||
* @return Zend_Service_SlideShare_SlideShow
|
||||
*/
|
||||
public function setDescription($desc)
|
||||
|
File diff suppressed because it is too large
Load Diff
179
library/Zend/Service/Twitter/Response.php
Normal file
179
library/Zend/Service/Twitter/Response.php
Normal file
@ -0,0 +1,179 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Twitter
|
||||
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Http_Response
|
||||
*/
|
||||
require_once 'Zend/Http/Response.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Json
|
||||
*/
|
||||
require_once 'Zend/Json.php';
|
||||
|
||||
/**
|
||||
* Representation of a response from Twitter.
|
||||
*
|
||||
* Provides:
|
||||
*
|
||||
* - method for testing if we have a successful call
|
||||
* - method for retrieving errors, if any
|
||||
* - method for retrieving the raw JSON
|
||||
* - method for retrieving the decoded response
|
||||
* - proxying to elements of the decoded response via property overloading
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Twitter
|
||||
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Service_Twitter_Response
|
||||
{
|
||||
/**
|
||||
* @var Zend_Http_Response
|
||||
*/
|
||||
protected $httpResponse;
|
||||
|
||||
/**
|
||||
* @var array|stdClass
|
||||
*/
|
||||
protected $jsonBody;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $rawBody;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Assigns the HTTP response to a property, as well as the body
|
||||
* representation. It then attempts to decode the body as JSON.
|
||||
*
|
||||
* @param Zend_Http_Response $httpResponse
|
||||
* @throws Zend_Service_Twitter_Exception if unable to decode JSON response
|
||||
*/
|
||||
public function __construct(Zend_Http_Response $httpResponse)
|
||||
{
|
||||
$this->httpResponse = $httpResponse;
|
||||
$this->rawBody = $httpResponse->getBody();
|
||||
try {
|
||||
$jsonBody = Zend_Json::decode($this->rawBody, Zend_Json::TYPE_OBJECT);
|
||||
$this->jsonBody = $jsonBody;
|
||||
} catch (Zend_Json_Exception $e) {
|
||||
require_once 'Zend/Service/Twitter/Exception.php';
|
||||
throw new Zend_Service_Twitter_Exception(sprintf(
|
||||
'Unable to decode response from twitter: %s',
|
||||
$e->getMessage()
|
||||
), 0, $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Property overloading to JSON elements
|
||||
*
|
||||
* If a named property exists within the JSON response returned,
|
||||
* proxies to it. Otherwise, returns null.
|
||||
*
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
if (null === $this->jsonBody) {
|
||||
return null;
|
||||
}
|
||||
if (!isset($this->jsonBody->{$name})) {
|
||||
return null;
|
||||
}
|
||||
return $this->jsonBody->{$name};
|
||||
}
|
||||
|
||||
/**
|
||||
* Was the request successful?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSuccess()
|
||||
{
|
||||
return $this->httpResponse->isSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* Did an error occur in the request?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isError()
|
||||
{
|
||||
return !$this->httpResponse->isSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the errors.
|
||||
*
|
||||
* Twitter _should_ return a standard error object, which contains an
|
||||
* "errors" property pointing to an array of errors. This method will
|
||||
* return that array if present, and raise an exception if not detected.
|
||||
*
|
||||
* If the response was successful, an empty array is returned.
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception\DomainException if unable to detect structure of error response
|
||||
*/
|
||||
public function getErrors()
|
||||
{
|
||||
if (!$this->isError()) {
|
||||
return array();
|
||||
}
|
||||
if (null === $this->jsonBody
|
||||
|| !isset($this->jsonBody->errors)
|
||||
) {
|
||||
require_once 'Zend/Service/Twitter/Exception.php';
|
||||
throw new Zend_Service_Twitter_Exception(
|
||||
'Either no JSON response received, or JSON error response is malformed; cannot return errors'
|
||||
);
|
||||
}
|
||||
return $this->jsonBody->errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the raw response body
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRawResponse()
|
||||
{
|
||||
return $this->rawBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retun the decoded response body
|
||||
*
|
||||
* @return array|stdClass
|
||||
*/
|
||||
public function toValue()
|
||||
{
|
||||
return $this->jsonBody;
|
||||
}
|
||||
}
|
@ -1,167 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Twitter
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Search.php 24593 2012-01-05 20:35:02Z matthew $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Http_Client
|
||||
*/
|
||||
require_once 'Zend/Rest/Client.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Json
|
||||
*/
|
||||
require_once 'Zend/Json.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed
|
||||
*/
|
||||
require_once 'Zend/Feed.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Service
|
||||
* @subpackage Twitter
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
class Zend_Service_Twitter_Search extends Zend_Rest_Client
|
||||
{
|
||||
/**
|
||||
* Return Type
|
||||
* @var String
|
||||
*/
|
||||
protected $_responseType = 'json';
|
||||
|
||||
/**
|
||||
* Response Format Types
|
||||
* @var array
|
||||
*/
|
||||
protected $_responseTypes = array(
|
||||
'atom',
|
||||
'json'
|
||||
);
|
||||
|
||||
/**
|
||||
* Uri Compoent
|
||||
*
|
||||
* @var Zend_Uri_Http
|
||||
*/
|
||||
protected $_uri;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $returnType
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($responseType = 'json')
|
||||
{
|
||||
$this->setResponseType($responseType);
|
||||
$this->setUri("http://search.twitter.com");
|
||||
|
||||
$this->setHeaders('Accept-Charset', 'ISO-8859-1,utf-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* set responseType
|
||||
*
|
||||
* @param string $responseType
|
||||
* @throws Zend_Service_Twitter_Exception
|
||||
* @return Zend_Service_Twitter_Search
|
||||
*/
|
||||
public function setResponseType($responseType = 'json')
|
||||
{
|
||||
if(!in_array($responseType, $this->_responseTypes, TRUE)) {
|
||||
require_once 'Zend/Service/Twitter/Exception.php';
|
||||
throw new Zend_Service_Twitter_Exception('Invalid Response Type');
|
||||
}
|
||||
$this->_responseType = $responseType;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve responseType
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResponseType()
|
||||
{
|
||||
return $this->_responseType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current twitter trends. Currnetly only supports json as the return.
|
||||
*
|
||||
* @throws Zend_Http_Client_Exception
|
||||
* @return array
|
||||
*/
|
||||
public function trends()
|
||||
{
|
||||
$response = $this->restGet('/trends.json');
|
||||
|
||||
return Zend_Json::decode($response->getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a Twitter search query.
|
||||
*
|
||||
* @throws Zend_Http_Client_Exception
|
||||
*/
|
||||
public function search($query, array $params = array())
|
||||
{
|
||||
|
||||
$_query = array();
|
||||
|
||||
$_query['q'] = $query;
|
||||
|
||||
foreach($params as $key=>$param) {
|
||||
switch($key) {
|
||||
case 'geocode':
|
||||
case 'lang':
|
||||
case 'since_id':
|
||||
$_query[$key] = $param;
|
||||
break;
|
||||
case 'rpp':
|
||||
$_query[$key] = (intval($param) > 100) ? 100 : intval($param);
|
||||
break;
|
||||
case 'page':
|
||||
$_query[$key] = intval($param);
|
||||
break;
|
||||
case 'show_user':
|
||||
$_query[$key] = 'true';
|
||||
}
|
||||
}
|
||||
|
||||
$response = $this->restGet('/search.' . $this->_responseType, $_query);
|
||||
|
||||
switch($this->_responseType) {
|
||||
case 'json':
|
||||
return Zend_Json::decode($response->getBody());
|
||||
break;
|
||||
case 'atom':
|
||||
return Zend_Feed::importString($response->getBody());
|
||||
break;
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Sample command.
|
||||
*
|
||||
* @command-handler sample
|
||||
* @command-handler-description Sample command.
|
||||
* @command-handler-header Windows Azure SDK for PHP
|
||||
* @command-handler-header (C) RealDolmen 2011 - www.realdolmen.com
|
||||
*/
|
||||
class Sample
|
||||
extends Zend_Service_Console_Command
|
||||
{
|
||||
/**
|
||||
* Hello command
|
||||
*
|
||||
* @command-name hello
|
||||
* @command-description Prints Hello, World!
|
||||
* @command-parameter-for $name Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_Env --name|-n Required. Name to say hello to.
|
||||
* @command-parameter-for $bePolite Zend_Service_Console_Command_ParameterSource_Argv -p Optional. Switch to enable polite mode or not.
|
||||
* @command-example Print "Hello, Maarten! How are you?" (using polite mode):
|
||||
* @command-example hello -n:"Maarten" -p
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function helloCommand($name, $bePolite = false)
|
||||
{
|
||||
echo 'Hello, ' . $name . '.';
|
||||
if ($bePolite) {
|
||||
echo ' How are you?';
|
||||
}
|
||||
echo "\r\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* What time is it command
|
||||
*
|
||||
* @command-name timestamp
|
||||
* @command-description Prints the current timestamp.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function timestampCommand()
|
||||
{
|
||||
echo date();
|
||||
echo "\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
Zend_Service_Console_Command::bootstrap($_SERVER['argv']);
|
38
library/Zend/Service/WindowsAzure/Log/Exception.php
Normal file
38
library/Zend/Service/WindowsAzure/Log/Exception.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Service_WindowsAzure
|
||||
* @subpackage Exception
|
||||
* @version $Id: Exception.php 25285 2013-03-09 10:30:20Z frosch $
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Service_WindowsAzure_Exception
|
||||
*/
|
||||
require_once 'Zend/Service/WindowsAzure/Exception.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Service_WindowsAzure
|
||||
* @subpackage Log
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Service_WindowsAzure_Log_Exception
|
||||
extends Zend_Service_WindowsAzure_Exception
|
||||
{
|
||||
}
|
@ -21,9 +21,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Service_Log_Formatter_Interface
|
||||
* @see Zend_Log_Formatter_Interface
|
||||
*/
|
||||
require_once 'Zend/Service/Log/Formatter/Interface.php';
|
||||
require_once 'Zend/Log/Formatter/Interface.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Service_WindowsAzure_Storage_DynamicTableEntity
|
||||
@ -37,36 +37,37 @@ require_once 'Zend/Service/WindowsAzure/Storage/DynamicTableEntity.php';
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Service_WindowsAzure_Log_Formatter_WindowsAzure implements Zend_Service_Log_Formatter_Interface
|
||||
class Zend_Service_WindowsAzure_Log_Formatter_WindowsAzure
|
||||
implements Zend_Log_Formatter_Interface
|
||||
{
|
||||
/**
|
||||
* Write a message to the table storage
|
||||
*
|
||||
* @param array $event
|
||||
* @return Zend_Service_WindowsAzure_Storage_DynamicTableEntity
|
||||
*/
|
||||
public function format($event)
|
||||
{
|
||||
|
||||
// partition key is the current date, represented as YYYYMMDD
|
||||
// row key will always be the current timestamp. These values MUST be hardcoded.
|
||||
$logEntity = new Zend_Service_WindowsAzure_Storage_DynamicTableEntity(
|
||||
date('Ymd'), microtime(true));
|
||||
// Windows Azure automatically adds the timestamp, but the timezone is most of the time
|
||||
// different compared to the origin server's timezone, so add this timestamp aswell.
|
||||
$event['server_timestamp'] = $event['timestamp'];
|
||||
unset($event['timestamp']);
|
||||
|
||||
foreach ($event as $key => $value) {
|
||||
if ((is_object($value) && !method_exists($value,'__toString'))
|
||||
|| is_array($value)) {
|
||||
/**
|
||||
* Write a message to the table storage
|
||||
*
|
||||
* @param array $event
|
||||
*
|
||||
* @return Zend_Service_WindowsAzure_Storage_DynamicTableEntity
|
||||
*/
|
||||
public function format($event)
|
||||
{
|
||||
// partition key is the current date, represented as YYYYMMDD
|
||||
// row key will always be the current timestamp. These values MUST be hardcoded.
|
||||
$logEntity = new Zend_Service_WindowsAzure_Storage_DynamicTableEntity(
|
||||
date('Ymd'), microtime(true)
|
||||
);
|
||||
// Windows Azure automatically adds the timestamp, but the timezone is most of the time
|
||||
// different compared to the origin server's timezone, so add this timestamp aswell.
|
||||
$event['server_timestamp'] = $event['timestamp'];
|
||||
unset($event['timestamp']);
|
||||
|
||||
foreach ($event as $key => $value) {
|
||||
if ((is_object($value) && !method_exists($value, '__toString'))
|
||||
|| is_array($value)
|
||||
) {
|
||||
$value = gettype($value);
|
||||
}
|
||||
$logEntity->{$key} = $value;
|
||||
}
|
||||
|
||||
$logEntity->{$key} = $value;
|
||||
}
|
||||
|
||||
return $logEntity;
|
||||
}
|
||||
return $logEntity;
|
||||
}
|
||||
}
|
@ -21,9 +21,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Service_Log_Writer_Abstract
|
||||
* @see Zend_Log_Writer_Abstract
|
||||
*/
|
||||
require_once 'Zend/Service/Log/Writer/Abstract.php';
|
||||
require_once 'Zend/Log/Writer/Abstract.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
@ -32,94 +32,109 @@ require_once 'Zend/Service/Log/Writer/Abstract.php';
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Service_WindowsAzure_Log_Writer_WindowsAzure extends Zend_Service_Log_Writer_Abstract
|
||||
class Zend_Service_WindowsAzure_Log_Writer_WindowsAzure
|
||||
extends Zend_Log_Writer_Abstract
|
||||
{
|
||||
/**
|
||||
* @var Zend_Service_Log_Formatter_Interface
|
||||
*/
|
||||
protected $_formatter;
|
||||
/**
|
||||
* @var Zend_Service_Log_Formatter_Interface
|
||||
*/
|
||||
protected $_formatter;
|
||||
|
||||
/**
|
||||
* Connection to a windows Azure
|
||||
*
|
||||
* @var Zend_Service_Service_WindowsAzure_Storage_Table
|
||||
*/
|
||||
protected $_tableStorageConnection = null;
|
||||
/**
|
||||
* Connection to a windows Azure
|
||||
*
|
||||
* @var Zend_Service_Service_WindowsAzure_Storage_Table
|
||||
*/
|
||||
protected $_tableStorageConnection = null;
|
||||
|
||||
/**
|
||||
* Name of the table to use for logging purposes
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_tableName = null;
|
||||
/**
|
||||
* Name of the table to use for logging purposes
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_tableName = null;
|
||||
|
||||
/**
|
||||
* Whether to keep all messages to be logged in an external buffer until the script ends and
|
||||
* only then to send the messages in batch to the logging component.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_bufferMessages = false;
|
||||
/**
|
||||
* Whether to keep all messages to be logged in an external buffer until the script ends and
|
||||
* only then to send the messages in batch to the logging component.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_bufferMessages = false;
|
||||
|
||||
/**
|
||||
* If message buffering is activated, it will store all the messages in this buffer and only
|
||||
* write them to table storage (in a batch transaction) when the script ends.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_messageBuffer = array();
|
||||
/**
|
||||
* If message buffering is activated, it will store all the messages in this buffer and only
|
||||
* write them to table storage (in a batch transaction) when the script ends.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_messageBuffer = array();
|
||||
|
||||
/**
|
||||
* @param Zend_Service_Service_WindowsAzure_Storage_Table $tableStorageConnection
|
||||
* @param string $tableName
|
||||
* @param bool $createTable create the Windows Azure table for logging if it does not exist
|
||||
*/
|
||||
public function __construct(Zend_Service_WindowsAzure_Storage_Table $tableStorageConnection,
|
||||
$tableName, $createTable = true, $bufferMessages = true)
|
||||
{
|
||||
if ($tableStorageConnection == null) {
|
||||
require_once 'Zend/Service/Log/Exception.php';
|
||||
throw new Zend_Service_Log_Exception('No connection to the Windows Azure tables provided.');
|
||||
}
|
||||
/**
|
||||
* @param Zend_Service_Service_WindowsAzure_Storage_Table|Zend_Service_WindowsAzure_Storage_Table $tableStorageConnection
|
||||
* @param string $tableName
|
||||
* @param bool $createTable create the Windows Azure table for logging if it does not exist
|
||||
* @param bool $bufferMessages
|
||||
* @throws Zend_Service_Log_Exception
|
||||
*/
|
||||
public function __construct(
|
||||
Zend_Service_WindowsAzure_Storage_Table $tableStorageConnection,
|
||||
$tableName, $createTable = true, $bufferMessages = true
|
||||
)
|
||||
{
|
||||
if ($tableStorageConnection == null) {
|
||||
require_once 'Zend/Service/Log/Exception.php';
|
||||
throw new Zend_Service_Log_Exception(
|
||||
'No connection to the Windows Azure tables provided.'
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_string($tableName)) {
|
||||
require_once 'Zend/Service/Log/Exception.php';
|
||||
throw new Zend_Service_Log_Exception('Provided Windows Azure table name must be a string.');
|
||||
}
|
||||
if (!is_string($tableName)) {
|
||||
require_once 'Zend/Service/Log/Exception.php';
|
||||
throw new Zend_Service_Log_Exception(
|
||||
'Provided Windows Azure table name must be a string.'
|
||||
);
|
||||
}
|
||||
|
||||
$this->_tableStorageConnection = $tableStorageConnection;
|
||||
$this->_tableName = $tableName;
|
||||
$this->_tableStorageConnection = $tableStorageConnection;
|
||||
$this->_tableName = $tableName;
|
||||
|
||||
// create the logging table if it does not exist. It will add some overhead, so it's optional
|
||||
if ($createTable) {
|
||||
$this->_tableStorageConnection->createTableIfNotExists($this->_tableName);
|
||||
}
|
||||
// create the logging table if it does not exist. It will add some overhead, so it's optional
|
||||
if ($createTable) {
|
||||
$this->_tableStorageConnection->createTableIfNotExists(
|
||||
$this->_tableName
|
||||
);
|
||||
}
|
||||
|
||||
// keep messages to be logged in an internal buffer and only send them over the wire when
|
||||
// the script execution ends
|
||||
if ($bufferMessages) {
|
||||
$this->_bufferMessages = $bufferMessages;
|
||||
}
|
||||
// keep messages to be logged in an internal buffer and only send them over the wire when
|
||||
// the script execution ends
|
||||
if ($bufferMessages) {
|
||||
$this->_bufferMessages = $bufferMessages;
|
||||
}
|
||||
|
||||
$this->_formatter = new Zend_Service_WindowsAzure_Log_Formatter_WindowsAzure();
|
||||
}
|
||||
$this->_formatter =
|
||||
new Zend_Service_WindowsAzure_Log_Formatter_WindowsAzure();
|
||||
}
|
||||
|
||||
/**
|
||||
* If the log messages have been stored in the internal buffer, just send them
|
||||
* to table storage.
|
||||
*/
|
||||
public function shutdown() {
|
||||
parent::shutdown();
|
||||
if ($this->_bufferMessages) {
|
||||
$this->_tableStorageConnection->startBatch();
|
||||
foreach ($this->_messageBuffer as $logEntity) {
|
||||
$this->_tableStorageConnection->insertEntity($this->_tableName, $logEntity);
|
||||
}
|
||||
$this->_tableStorageConnection->commit();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* If the log messages have been stored in the internal buffer, just send them
|
||||
* to table storage.
|
||||
*/
|
||||
public function shutdown()
|
||||
{
|
||||
parent::shutdown();
|
||||
if ($this->_bufferMessages) {
|
||||
$this->_tableStorageConnection->startBatch();
|
||||
foreach ($this->_messageBuffer as $logEntity) {
|
||||
$this->_tableStorageConnection->insertEntity(
|
||||
$this->_tableName, $logEntity
|
||||
);
|
||||
}
|
||||
$this->_tableStorageConnection->commit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Create a new instance of Zend_Service_Log_Writer_WindowsAzure
|
||||
*
|
||||
* @param array $config
|
||||
@ -129,11 +144,13 @@ class Zend_Service_WindowsAzure_Log_Writer_WindowsAzure extends Zend_Service_Log
|
||||
static public function factory($config)
|
||||
{
|
||||
$config = self::_parseConfig($config);
|
||||
$config = array_merge(array(
|
||||
'connection' => null,
|
||||
'tableName' => null,
|
||||
'createTable' => true,
|
||||
), $config);
|
||||
$config = array_merge(
|
||||
array(
|
||||
'connection' => null,
|
||||
'tableName' => null,
|
||||
'createTable' => true,
|
||||
), $config
|
||||
);
|
||||
|
||||
return new self(
|
||||
$config['connection'],
|
||||
@ -142,33 +159,38 @@ class Zend_Service_WindowsAzure_Log_Writer_WindowsAzure extends Zend_Service_Log
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* The only formatter accepted is already loaded in the constructor
|
||||
*
|
||||
* @todo enable custom formatters using the WindowsAzure_Storage_DynamicTableEntity class
|
||||
*
|
||||
* @todo enable custom formatters using the WindowsAzure_Storage_DynamicTableEntity class
|
||||
*/
|
||||
public function setFormatter(Zend_Service_Log_Formatter_Interface $formatter)
|
||||
public function setFormatter(
|
||||
Zend_Service_Log_Formatter_Interface $formatter
|
||||
)
|
||||
{
|
||||
require_once 'Zend/Service/Log/Exception.php';
|
||||
throw new Zend_Service_Log_Exception(get_class($this) . ' does not support formatting');
|
||||
throw new Zend_Service_Log_Exception(
|
||||
get_class($this) . ' does not support formatting');
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a message to the table storage. If buffering is activated, then messages will just be
|
||||
* added to an internal buffer.
|
||||
*
|
||||
* @param array $event
|
||||
* @return void
|
||||
* @todo format the event using a formatted, not in this method
|
||||
*/
|
||||
protected function _write($event)
|
||||
{
|
||||
$logEntity = $this->_formatter->format($event);
|
||||
/**
|
||||
* Write a message to the table storage. If buffering is activated, then messages will just be
|
||||
* added to an internal buffer.
|
||||
*
|
||||
* @param array $event
|
||||
* @return void
|
||||
* @todo format the event using a formatted, not in this method
|
||||
*/
|
||||
protected function _write($event)
|
||||
{
|
||||
$logEntity = $this->_formatter->format($event);
|
||||
|
||||
if ($this->_bufferMessages) {
|
||||
$this->_messageBuffer[] = $logEntity;
|
||||
} else {
|
||||
$this->_tableStorageConnection->insertEntity($this->_tableName, $logEntity);
|
||||
}
|
||||
}
|
||||
if ($this->_bufferMessages) {
|
||||
$this->_messageBuffer[] = $logEntity;
|
||||
} else {
|
||||
$this->_tableStorageConnection->insertEntity(
|
||||
$this->_tableName, $logEntity
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -33,6 +33,6 @@ require_once 'Zend/Service/WindowsAzure/Exception.php';
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Service_WindowsAzure_Management_Exception
|
||||
extends Zend_Service_WindowsAzure_Exception
|
||||
extends Zend_Service_WindowsAzure_Exception
|
||||
{
|
||||
}
|
@ -16,7 +16,7 @@
|
||||
* @package Zend_Version
|
||||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Version.php 25268 2013-02-25 18:06:28Z matthew $
|
||||
* @version $Id: Version.php 25289 2013-03-13 16:51:14Z matthew $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -32,7 +32,7 @@ final class Zend_Version
|
||||
/**
|
||||
* Zend Framework version identification - see compareVersion()
|
||||
*/
|
||||
const VERSION = '1.12.2';
|
||||
const VERSION = '1.12.3';
|
||||
|
||||
/**
|
||||
* The latest stable version Zend Framework available
|
||||
|
14
scripts/build/config/_sql/jo.scores_cutoff_mvt.sql
Normal file
14
scripts/build/config/_sql/jo.scores_cutoff_mvt.sql
Normal file
@ -0,0 +1,14 @@
|
||||
CREATE TABLE IF NOT EXISTS `scores_cutoff_mvt` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`siren` int(9) NOT NULL COMMENT 'Siren de l''''entité pour laquelle il faut appliquer un contour du score et/ou de l''''encours',
|
||||
`encours` int(10) DEFAULT NULL COMMENT 'Encours en euros',
|
||||
`scoreSolv` tinyint(3) DEFAULT NULL COMMENT 'Indiscore 100',
|
||||
`scoreDir` tinyint(3) DEFAULT NULL COMMENT 'Note de dirigeance sur 100',
|
||||
`scoreConf` tinyint(3) DEFAULT NULL COMMENT 'Note de conformité sur 100',
|
||||
`remarque` longtext NOT NULL COMMENT 'Remarque afin de savoir pourquoi il y a ce contour',
|
||||
`idInsert` int(11) NOT NULL COMMENT 'user id',
|
||||
`dateInsert` datetime NOT NULL COMMENT 'Date de création du contour',
|
||||
`idMvt` int(11) NOT NULL COMMENT 'user id',
|
||||
`dateMvt` datetime NOT NULL COMMENT 'Date historisation',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Historique des contours pour les Indiscore' AUTO_INCREMENT=1 ;
|
Loading…
x
Reference in New Issue
Block a user