This commit is contained in:
Romain Neutron
2012-04-26 00:55:53 +02:00
parent edbfff226e
commit ade22295ad
631 changed files with 92375 additions and 101763 deletions

View File

@@ -17,371 +17,360 @@
*/
class Bridge_Account
{
/**
*
* @var int
*/
protected $id;
/**
*
* @var int
*/
protected $id;
/**
*
* @var appbox
*/
protected $appbox;
/**
*
* @var appbox
*/
protected $appbox;
/**
*
* @var Bridge_Api
*/
protected $api;
/**
*
* @var Bridge_Api
*/
protected $api;
/**
*
* @var string
*/
protected $dist_id;
/**
*
* @var string
*/
protected $dist_id;
/**
*
* @var User_Adapter
*/
protected $user;
/**
*
* @var User_Adapter
*/
protected $user;
/**
*
* @var string
*/
protected $name;
/**
*
* @var string
*/
protected $name;
/**
*
* @var Bridge_AccountSettings
*/
protected $settings;
/**
*
* @var Bridge_AccountSettings
*/
protected $settings;
/**
*
* @var DateTime
*/
protected $created_on;
/**
*
* @var DateTime
*/
protected $created_on;
/**
*
* @var DateTime
*/
protected $updated_on;
/**
*
* @var DateTime
*/
protected $updated_on;
/**
*
* @param appbox $appbox
* @param Bridge_Api $api
* @param int $id
* @return Bridge_Account
*/
public function __construct(appbox &$appbox, Bridge_Api &$api, $id)
{
$this->id = (int) $id;
$this->appbox = $appbox;
$this->api = $api;
/**
*
* @param appbox $appbox
* @param Bridge_Api $api
* @param int $id
* @return Bridge_Account
*/
public function __construct(appbox &$appbox, Bridge_Api &$api, $id)
{
$this->id = (int) $id;
$this->appbox = $appbox;
$this->api = $api;
$this->api->get_connector()->set_auth_settings($this->get_settings());
$this->api->get_connector()->set_auth_settings($this->get_settings());
$sql = 'SELECT id, dist_id, usr_id, name, created_on, updated_on
$sql = 'SELECT id, dist_id, usr_id, name, created_on, updated_on
FROM bridge_accounts WHERE id = :id';
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':id' => $this->id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':id' => $this->id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if (!$row)
throw new Bridge_Exception_AccountNotFound('Account Not Found');
if ( ! $row)
throw new Bridge_Exception_AccountNotFound('Account Not Found');
$this->dist_id = $row['dist_id'];
$this->user = User_Adapter::getInstance($row['usr_id'], $this->appbox);
$this->name = $row['name'];
$this->updated_on = new DateTime($row['updated_on']);
$this->created_on = new DateTime($row['created_on']);
$this->dist_id = $row['dist_id'];
$this->user = User_Adapter::getInstance($row['usr_id'], $this->appbox);
$this->name = $row['name'];
$this->updated_on = new DateTime($row['updated_on']);
$this->created_on = new DateTime($row['created_on']);
return $this;
}
return $this;
}
/**
*
* @return Bridge_AccountSettings
*/
public function get_settings()
{
if (!$this->settings)
$this->settings = new Bridge_AccountSettings($this->appbox, $this);
/**
*
* @return Bridge_AccountSettings
*/
public function get_settings()
{
if ( ! $this->settings)
$this->settings = new Bridge_AccountSettings($this->appbox, $this);
return $this->settings;
}
return $this->settings;
}
/**
*
* @return int
*/
public function get_id()
{
return $this->id;
}
/**
*
* @return int
*/
public function get_id()
{
return $this->id;
}
/**
*
* @return Bridge_Api
*/
public function get_api()
{
return $this->api;
}
/**
*
* @return Bridge_Api
*/
public function get_api()
{
return $this->api;
}
/**
*
* @return string
*/
public function get_dist_id()
{
return $this->dist_id;
}
/**
*
* @return string
*/
public function get_dist_id()
{
return $this->dist_id;
}
/**
*
* @return User_Adapter
*/
public function get_user()
{
return $this->user;
}
/**
*
* @return User_Adapter
*/
public function get_user()
{
return $this->user;
}
/**
*
* @return string
*/
public function get_name()
{
return $this->name;
}
/**
*
* @return string
*/
public function get_name()
{
return $this->name;
}
/**
*
* @return DateTime
*/
public function get_created_on()
{
return $this->created_on;
}
/**
*
* @return DateTime
*/
public function get_created_on()
{
return $this->created_on;
}
/**
*
* @return DateTime
*/
public function get_updated_on()
{
return $this->updated_on;
}
/**
*
* @return DateTime
*/
public function get_updated_on()
{
return $this->updated_on;
}
/**
*
* @param string $name
* @return Bridge_Account
*/
public function set_name($name)
{
$this->name = $name;
$this->updated_on = new DateTime();
/**
*
* @param string $name
* @return Bridge_Account
*/
public function set_name($name)
{
$this->name = $name;
$this->updated_on = new DateTime();
$sql = 'UPDATE bridge_accounts
$sql = 'UPDATE bridge_accounts
SET name = :name, updated_on = :update WHERE id = :id';
$params = array(
':name' => $this->name
, ':id' => $this->id
, ':update' => $this->updated_on->format(DATE_ISO8601)
);
$params = array(
':name' => $this->name
, ':id' => $this->id
, ':update' => $this->updated_on->format(DATE_ISO8601)
);
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
return $this;
}
/**
*
* @return Void
*/
public function delete()
{
do
{
$elements = Bridge_Element::get_elements_by_account($this->appbox, $this);
foreach ($elements as $element)
{
$element->delete();
}
return $this;
}
while (count($elements) > 0);
$sql = 'DELETE FROM bridge_accounts WHERE id = :id';
/**
*
* @return Void
*/
public function delete()
{
do {
$elements = Bridge_Element::get_elements_by_account($this->appbox, $this);
foreach ($elements as $element) {
$element->delete();
}
} while (count($elements) > 0);
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':id' => $this->id));
$stmt->closeCursor();
$sql = 'DELETE FROM bridge_accounts WHERE id = :id';
return;
}
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':id' => $this->id));
$stmt->closeCursor();
/**
*
* @param appbox $appbox
* @param int $account_id
* @return Bridge_Account
*/
public static function load_account(appbox &$appbox, $account_id)
{
$sql = 'SELECT id, api_id FROM bridge_accounts WHERE id = :account_id';
return;
}
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':account_id' => $account_id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
/**
*
* @param appbox $appbox
* @param int $account_id
* @return Bridge_Account
*/
public static function load_account(appbox &$appbox, $account_id)
{
$sql = 'SELECT id, api_id FROM bridge_accounts WHERE id = :account_id';
if (!$row)
throw new Bridge_Exception_AccountNotFound('Account Not Found');
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':account_id' => $account_id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$api = new Bridge_Api($appbox, $row['api_id']);
$api->get_connector()->set_locale($appbox->get_session()->get_locale());
if ( ! $row)
throw new Bridge_Exception_AccountNotFound('Account Not Found');
return new self($appbox, $api, $row['id']);
}
$api = new Bridge_Api($appbox, $row['api_id']);
$api->get_connector()->set_locale($appbox->get_session()->get_locale());
/**
*
* @param appbox $appbox
* @param Bridge_Api $api
* @param User_Adapter $user
* @param string $distant_id
* @return Bridge_Account
*/
public static function load_account_from_distant_id(appbox $appbox, Bridge_Api $api, User_Adapter $user, $distant_id)
{
$sql = 'SELECT id FROM bridge_accounts
return new self($appbox, $api, $row['id']);
}
/**
*
* @param appbox $appbox
* @param Bridge_Api $api
* @param User_Adapter $user
* @param string $distant_id
* @return Bridge_Account
*/
public static function load_account_from_distant_id(appbox $appbox, Bridge_Api $api, User_Adapter $user, $distant_id)
{
$sql = 'SELECT id FROM bridge_accounts
WHERE api_id = :api_id AND usr_id = :usr_id AND dist_id = :dist_id';
$params = array(
':api_id' => $api->get_id()
, ':usr_id' => $user->get_id()
, ':dist_id' => $distant_id
);
$params = array(
':api_id' => $api->get_id()
, ':usr_id' => $user->get_id()
, ':dist_id' => $distant_id
);
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if (!$row)
throw new Bridge_Exception_AccountNotFound();
if ( ! $row)
throw new Bridge_Exception_AccountNotFound();
return new Bridge_Account($appbox, $api, $row['id']);
}
return new Bridge_Account($appbox, $api, $row['id']);
}
/**
*
* @param appbox $appbox
* @param Bridge_Api $api
* @param int $quantity
* @return Bridge_Account
*/
public static function get_accounts_by_api(appbox &$appbox, Bridge_Api &$api, $quantity = 50)
{
$sql = 'SELECT id FROM bridge_accounts WHERE api_id = :api_id
/**
*
* @param appbox $appbox
* @param Bridge_Api $api
* @param int $quantity
* @return Bridge_Account
*/
public static function get_accounts_by_api(appbox &$appbox, Bridge_Api &$api, $quantity = 50)
{
$sql = 'SELECT id FROM bridge_accounts WHERE api_id = :api_id
LIMIT 0,' . (int) $quantity;
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':api_id' => $api->get_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':api_id' => $api->get_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$results = array();
$results = array();
foreach ($rs as $row)
{
$results[] = new Bridge_Account($appbox, $api, $row['id']);
foreach ($rs as $row) {
$results[] = new Bridge_Account($appbox, $api, $row['id']);
}
return $results;
}
return $results;
}
/**
*
* @param appbox $appbox
* @param user_adapter $user
* @return Bridge_Account
*/
public static function get_accounts_by_user(appbox &$appbox, user_adapter &$user)
{
$sql = 'SELECT id, api_id FROM bridge_accounts WHERE usr_id = :usr_id';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':usr_id' => $user->get_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$results = array();
$apis = array();
foreach ($rs as $row)
/**
*
* @param appbox $appbox
* @param user_adapter $user
* @return Bridge_Account
*/
public static function get_accounts_by_user(appbox &$appbox, user_adapter &$user)
{
$api_id = $row['api_id'];
if (!isset($apis[$api_id]))
{
try
{
$apis[$api_id] = new Bridge_Api($appbox, $api_id);
$sql = 'SELECT id, api_id FROM bridge_accounts WHERE usr_id = :usr_id';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':usr_id' => $user->get_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$results = array();
$apis = array();
foreach ($rs as $row) {
$api_id = $row['api_id'];
if ( ! isset($apis[$api_id])) {
try {
$apis[$api_id] = new Bridge_Api($appbox, $api_id);
} catch (Exception $e) {
continue;
}
}
$results[] = new Bridge_Account($appbox, $apis[$api_id], $row['id']);
}
catch (Exception $e)
{
continue;
}
}
$results[] = new Bridge_Account($appbox, $apis[$api_id], $row['id']);
return $results;
}
return $results;
}
/**
*
* @param appbox $appbox
* @param Bridge_Api $api
* @param User_Adapter $user
* @param string $dist_id
* @param string $name
* @return Bridge_Account
*/
public static function create(appbox &$appbox, Bridge_Api &$api, User_Adapter &$user, $dist_id, $name)
{
$sql = 'INSERT INTO bridge_accounts
/**
*
* @param appbox $appbox
* @param Bridge_Api $api
* @param User_Adapter $user
* @param string $dist_id
* @param string $name
* @return Bridge_Account
*/
public static function create(appbox &$appbox, Bridge_Api &$api, User_Adapter &$user, $dist_id, $name)
{
$sql = 'INSERT INTO bridge_accounts
(id, api_id, dist_id, usr_id, name, created_on, updated_on)
VALUES (null, :api_id, :dist_id, :usr_id, :name, NOW(), NOW())';
$params = array(
':api_id' => $api->get_id()
, ':dist_id' => $dist_id
, ':usr_id' => $user->get_id()
, ':name' => $name
);
$params = array(
':api_id' => $api->get_id()
, ':dist_id' => $dist_id
, ':usr_id' => $user->get_id()
, ':name' => $name
);
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$account_id = $appbox->get_connection()->lastInsertId();
return new self($appbox, $api, $account_id);
}
$account_id = $appbox->get_connection()->lastInsertId();
return new self($appbox, $api, $account_id);
}
}

View File

@@ -17,97 +17,95 @@
*/
class Bridge_AccountSettings
{
/**
*
* @var appbox
*/
protected $appbox;
/**
*
* @var appbox
*/
protected $appbox;
/**
*
* @var Bridge_Account
*/
protected $account;
/**
*
* @var Bridge_Account
*/
protected $account;
/**
*
* @param appbox $appbox
* @param Bridge_Account $account
* @return Bridge_AccountSettings
*/
public function __construct(appbox &$appbox, Bridge_Account &$account)
{
$this->appbox = $appbox;
$this->account = $account;
/**
*
* @param appbox $appbox
* @param Bridge_Account $account
* @return Bridge_AccountSettings
*/
public function __construct(appbox &$appbox, Bridge_Account &$account)
{
$this->appbox = $appbox;
$this->account = $account;
return $this;
}
return $this;
}
/**
*
* @param string $key
* @param mixed $default_value
* @return mixed
*/
public function get($key, $default_value = null)
{
$sql = 'SELECT value FROM bridge_account_settings
/**
*
* @param string $key
* @param mixed $default_value
* @return mixed
*/
public function get($key, $default_value = null)
{
$sql = 'SELECT value FROM bridge_account_settings
WHERE account_id = :account_id AND `key` = :key';
$params = array(':account_id' => $this->account->get_id(), ':key' => $key);
$params = array(':account_id' => $this->account->get_id(), ':key' => $key);
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
return isset($row['value']) ? $row['value'] : $default_value;
}
return isset($row['value']) ? $row['value'] : $default_value;
}
/**
*
* @param string $key
* @param string $value
* @return string
*/
public function set($key, $value)
{
$sql = 'REPLACE INTO bridge_account_settings
/**
*
* @param string $key
* @param string $value
* @return string
*/
public function set($key, $value)
{
$sql = 'REPLACE INTO bridge_account_settings
(account_id, `key`, value) VALUES (:account_id, :key, :value)';
$params = array(
':value' => $value
, ':account_id' => $this->account->get_id()
, ':key' => $key
);
$params = array(
':value' => $value
, ':account_id' => $this->account->get_id()
, ':key' => $key
);
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
return $value;
}
return $value;
}
/**
*
* @param string $key
* @return string
*/
public function delete($key)
{
$return_value = $this->get($key);
/**
*
* @param string $key
* @return string
*/
public function delete($key)
{
$return_value = $this->get($key);
$sql = 'DELETE FROM bridge_account_settings
$sql = 'DELETE FROM bridge_account_settings
WHERE account_id = :account_id AND `key` = :key';
$params = array(':account_id' => $this->account->get_id(), ':key' => $key);
$params = array(':account_id' => $this->account->get_id(), ':key' => $key);
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
return $return_value;
}
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
return $return_value;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -17,165 +17,163 @@
*/
abstract class Bridge_Api_Abstract
{
/**
*
* @var Bridge_Api_Auth_Interface
*/
protected $_auth;
/**
*
* @var Bridge_Api_Auth_Interface
*/
protected $_auth;
/**
*
* @var string
*/
protected $locale = 'en_US';
/**
*
* @var string
*/
protected $locale = 'en_US';
/**
*
* @param registryInterface $registry
* @param Bridge_Api_Auth_Interface $auth
* @return Bridge_Api_Abstract
*/
public function __construct(registryInterface $registry, Bridge_Api_Auth_Interface $auth)
{
$this->registry = $registry;
$this->_auth = $auth;
$this->initialize_transport();
$this->set_auth_params();
/**
*
* @param registryInterface $registry
* @param Bridge_Api_Auth_Interface $auth
* @return Bridge_Api_Abstract
*/
public function __construct(registryInterface $registry, Bridge_Api_Auth_Interface $auth)
{
$this->registry = $registry;
$this->_auth = $auth;
$this->initialize_transport();
$this->set_auth_params();
return $this;
}
return $this;
}
/**
*
* @param Bridge_AccountSettings $settings
* @return Bridge_Api_Abstract
*/
public function set_auth_settings(Bridge_AccountSettings &$settings)
{
$this->_auth->set_settings($settings);
$this->set_transport_authentication_params();
/**
*
* @param Bridge_AccountSettings $settings
* @return Bridge_Api_Abstract
*/
public function set_auth_settings(Bridge_AccountSettings &$settings)
{
$this->_auth->set_settings($settings);
$this->set_transport_authentication_params();
return $this;
}
return $this;
}
/**
*
* @return Array The result of the primary handshake, Including tokens and others
*/
public function connect()
{
if ( ! $this->is_configured())
throw new Bridge_Exception_ApiConnectorNotConfigured('Connector not configured');
$request_token = $this->_auth->parse_request_token();
/**
*
* @return Array The result of the primary handshake, Including tokens and others
*/
public function connect()
{
if (!$this->is_configured())
throw new Bridge_Exception_ApiConnectorNotConfigured('Connector not configured');
$request_token = $this->_auth->parse_request_token();
return $this->_auth->connect($request_token);
}
return $this->_auth->connect($request_token);
}
/**
*
* @return Bridge_Api_Abstract
*/
public function reconnect()
{
if ( ! $this->is_configured())
throw new Bridge_Exception_ApiConnectorNotConfigured();
$this->_auth->reconnect();
/**
*
* @return Bridge_Api_Abstract
*/
public function reconnect()
{
if (!$this->is_configured())
throw new Bridge_Exception_ApiConnectorNotConfigured();
$this->_auth->reconnect();
return $this;
}
return $this;
}
/**
*
* @return Bridge_Api_Abstract
*/
public function disconnect()
{
if ( ! $this->is_configured())
throw new Bridge_Exception_ApiConnectorNotConfigured();
$this->_auth->disconnect();
/**
*
* @return Bridge_Api_Abstract
*/
public function disconnect()
{
if (!$this->is_configured())
throw new Bridge_Exception_ApiConnectorNotConfigured();
$this->_auth->disconnect();
return $this;
}
return $this;
}
/**
*
* @return boolean
*/
public function is_connected()
{
return $this->_auth->is_connected();
}
/**
*
* @return boolean
*/
public function is_connected()
{
return $this->_auth->is_connected();
}
/**
*
* @return string
*/
public function get_auth_url($supp_params = array())
{
return $this->_auth->get_auth_url($supp_params);
}
/**
*
* @return string
*/
public function get_auth_url($supp_params = array())
{
return $this->_auth->get_auth_url($supp_params);
}
/**
*
* @param string $locale
* @return Bridge_Api_Abstract
*/
public function set_locale($locale)
{
$this->locale = $locale;
/**
*
* @param string $locale
* @return Bridge_Api_Abstract
*/
public function set_locale($locale)
{
$this->locale = $locale;
return $this;
}
return $this;
}
/**
*
* @return string
*/
public function get_locale()
{
return $this->locale;
}
/**
*
* @return string
*/
public function get_locale()
{
return $this->locale;
}
/**
*
* @param type $object_id
* @return boolean
*/
public function is_valid_object_id($object_id)
{
return is_scalar($object_id) && ! is_bool($object_id);
}
/**
* This method is called when calling any API method
* This allows use to change the exception object.
* For instance, you can set it to a Bridge_Exception_ActionAuthNeedReconnect
*
* @param Exception $e
* @return Void
*/
public function handle_exception(Exception &$e)
{
return;
}
/**
*
* @param type $object_id
* @return boolean
*/
public function is_valid_object_id($object_id)
{
return is_scalar($object_id) && !is_bool($object_id);
}
/**
* The method to initialize Authentication transport
* It's called on constructor
*/
abstract protected function initialize_transport();
/**
* This method is called when calling any API method
* This allows use to change the exception object.
* For instance, you can set it to a Bridge_Exception_ActionAuthNeedReconnect
*
* @param Exception $e
* @return Void
*/
public function handle_exception(Exception &$e)
{
return;
}
/**
* The method used to set the connection params to the auth object
* It's called after transport initialization
*/
abstract protected function set_auth_params();
/**
* The method to initialize Authentication transport
* It's called on constructor
*/
abstract protected function initialize_transport();
/**
* The method used to set the connection params to the auth object
* It's called after transport initialization
*/
abstract protected function set_auth_params();
/**
* Set the transport authentication params to the auth object
* It's called, every time the settings are set
*/
abstract protected function set_transport_authentication_params();
/**
* Set the transport authentication params to the auth object
* It's called, every time the settings are set
*/
abstract protected function set_transport_authentication_params();
}

View File

@@ -17,152 +17,150 @@
*/
abstract class Bridge_Api_AbstractCollection
{
/**
*
* @var int
*/
protected $total_page = 1;
/**
*
* @var int
*/
protected $total_page = 1;
/**
*
* @var int
*/
protected $current_page = 1;
/**
*
* @var int
*/
protected $current_page = 1;
/**
*
* @var int
*/
protected $total_items;
/**
*
* @var int
*/
protected $total_items;
/**
*
* @var int
*/
protected $items_per_page;
/**
*
* @var int
*/
protected $items_per_page;
/**
*
* @var Array
*/
protected $elements = array();
/**
*
* @var Array
*/
protected $elements = array();
/**
*
* @return int
*/
public function get_total_items()
{
return $this->total_items;
}
/**
*
* @return int
*/
public function get_total_items()
{
return $this->total_items;
}
public function set_total_items($total_items)
{
$this->total_items = (int) $total_items;
public function set_total_items($total_items)
{
$this->total_items = (int) $total_items;
return $this;
}
return $this;
}
/**
*
* @return int
*/
public function get_items_per_page()
{
return $this->items_per_page;
}
/**
*
* @return int
*/
public function get_items_per_page()
{
return $this->items_per_page;
}
/**
*
* @param int $items_per_page
* @return Bridge_Api_AbstractCollection
*/
public function set_items_per_page($items_per_page)
{
$this->items_per_page = (int) $items_per_page;
/**
*
* @param int $items_per_page
* @return Bridge_Api_AbstractCollection
*/
public function set_items_per_page($items_per_page)
{
$this->items_per_page = (int) $items_per_page;
return $this;
}
return $this;
}
/**
*
* @return int
*/
public function get_current_page()
{
return $this->current_page;
}
/**
*
* @return int
*/
public function get_current_page()
{
return $this->current_page;
}
/**
*
* @param int $current_page
* @return Bridge_Api_AbstractCollection
*/
public function set_current_page($current_page)
{
if ($current_page > 0)
$this->current_page = (int) $current_page;
/**
*
* @param int $current_page
* @return Bridge_Api_AbstractCollection
*/
public function set_current_page($current_page)
{
if ($current_page > 0)
$this->current_page = (int) $current_page;
return $this;
}
return $this;
}
/**
*
* @return int
*/
public function get_total_page()
{
return $this->total_page;
}
/**
*
* @return int
*/
public function get_total_page()
{
return $this->total_page;
}
/**
*
* @param int $total_page
* @return Bridge_Api_AbstractCollection
*/
public function set_total_page($total_page)
{
if ($total_page > 0)
$this->total_page = (int) $total_page;
/**
*
* @param int $total_page
* @return Bridge_Api_AbstractCollection
*/
public function set_total_page($total_page)
{
if ($total_page > 0)
$this->total_page = (int) $total_page;
return $this;
}
return $this;
}
/**
*
* @return boolean
*/
public function has_next_page()
{
return $this->current_page < $this->total_page;
}
/**
*
* @return boolean
*/
public function has_next_page()
{
return $this->current_page < $this->total_page;
}
/**
*
* @return boolean
*/
public function has_previous_page()
{
return $this->current_page > 1;
}
/**
*
* @return boolean
*/
public function has_previous_page()
{
return $this->current_page > 1;
}
/**
*
* @return boolean
*/
public function has_more_than_one_page()
{
return $this->total_page > 1;
}
/**
*
* @return Array
*/
public function get_elements()
{
return $this->elements;
}
/**
*
* @return boolean
*/
public function has_more_than_one_page()
{
return $this->total_page > 1;
}
/**
*
* @return Array
*/
public function get_elements()
{
return $this->elements;
}
}

View File

@@ -17,23 +17,21 @@
*/
class Bridge_Api_Auth_Abstract
{
/**
*
* @var Bridge_AccountSettings
*/
protected $settings;
/**
*
* @var Bridge_AccountSettings
*/
protected $settings;
/**
*
* @param Bridge_AccountSettings $settings
* @return Bridge_Api_Auth_Abstract
*/
public function set_settings(Bridge_AccountSettings $settings)
{
$this->settings = $settings;
return $this;
}
/**
*
* @param Bridge_AccountSettings $settings
* @return Bridge_Api_Auth_Abstract
*/
public function set_settings(Bridge_AccountSettings $settings)
{
$this->settings = $settings;
return $this;
}
}

View File

@@ -17,139 +17,137 @@
*/
class Bridge_Api_Auth_Flickr extends Bridge_Api_Auth_Abstract implements Bridge_Api_Auth_Interface
{
/**
*
* @var string
*/
protected $flickr_client_id;
/**
*
* @var string
*/
protected $flickr_client_id;
/**
*
* @var string
*/
protected $flickr_client_secret;
/**
*
* @var string
*/
protected $permissions;
/**
*
* @var string
*/
protected $flickr_client_secret;
/**
*
* @var Phlickr_Api
*/
protected $_api;
/**
*
* @var string
*/
protected $permissions;
/**
*
* @return Phlickr_Api
*/
protected function get_api()
{
if (!$this->_api)
/**
*
* @var Phlickr_Api
*/
protected $_api;
/**
*
* @return Phlickr_Api
*/
protected function get_api()
{
$this->_api = new Phlickr_Api(
$this->flickr_client_id,
$this->flickr_client_secret
);
if ( ! $this->_api) {
$this->_api = new Phlickr_Api(
$this->flickr_client_id,
$this->flickr_client_secret
);
}
return $this->_api;
}
return $this->_api;
}
/**
*
* @return string
*/
public function parse_request_token()
{
return isset($_GET["frob"]) ? $_GET["frob"] : null;
}
/**
*
* @param string $param
* @return Array
*/
public function connect($param)
{
$auth_token = $this->get_api()->setAuthTokenFromFrob($param);
if (!$this->get_api()->isAuthValid())
throw new Bridge_Exception_ApiConnectorAccessTokenFailed();
$this->get_api()->setAuthToken($auth_token);
return array('auth_token'=>$auth_token);
}
/**
*
* @return Bridge_Api_Auth_Flickr
*/
public function reconnect()
{
return $this;
}
/**
*
* @return Bridge_Api_Auth_Flickr
*/
public function disconnect()
{
$this->settings->set('auth_token', null);
return $this;
}
/**
*
* @return boolean
*/
public function is_connected()
{
return $this->settings->get('auth_token') !== null;// && $this->get_api()->isAuthValid();
}
/**
*
* @return Array
*/
public function get_auth_signatures()
{
return array(
'auth_token' => $this->settings->get('auth_token')
);
}
/**
*
* @param array $parameters
* @return Bridge_Api_Auth_Flickr
*/
public function set_parameters(Array $parameters)
{
$avail_parameters = array('flickr_client_id', 'flickr_client_secret', 'permissions');
foreach ($parameters as $parameter => $value)
/**
*
* @return string
*/
public function parse_request_token()
{
if (!in_array($parameter, $avail_parameters))
continue;
$this->$parameter = $value;
return isset($_GET["frob"]) ? $_GET["frob"] : null;
}
return $this;
}
/**
*
* @param string $param
* @return Array
*/
public function connect($param)
{
$auth_token = $this->get_api()->setAuthTokenFromFrob($param);
if ( ! $this->get_api()->isAuthValid())
throw new Bridge_Exception_ApiConnectorAccessTokenFailed();
/**
*
* @return string
*/
public function get_auth_url(Array $supp_params = array())
{
$request_token = $this->get_api()->requestFrob();
$this->get_api()->setAuthToken($auth_token);
return $this->get_api()->buildAuthUrl($this->permissions, $request_token);
}
return array('auth_token' => $auth_token);
}
/**
*
* @return Bridge_Api_Auth_Flickr
*/
public function reconnect()
{
return $this;
}
/**
*
* @return Bridge_Api_Auth_Flickr
*/
public function disconnect()
{
$this->settings->set('auth_token', null);
return $this;
}
/**
*
* @return boolean
*/
public function is_connected()
{
return $this->settings->get('auth_token') !== null; // && $this->get_api()->isAuthValid();
}
/**
*
* @return Array
*/
public function get_auth_signatures()
{
return array(
'auth_token' => $this->settings->get('auth_token')
);
}
/**
*
* @param array $parameters
* @return Bridge_Api_Auth_Flickr
*/
public function set_parameters(Array $parameters)
{
$avail_parameters = array('flickr_client_id', 'flickr_client_secret', 'permissions');
foreach ($parameters as $parameter => $value) {
if ( ! in_array($parameter, $avail_parameters))
continue;
$this->$parameter = $value;
}
return $this;
}
/**
*
* @return string
*/
public function get_auth_url(Array $supp_params = array())
{
$request_token = $this->get_api()->requestFrob();
return $this->get_api()->buildAuthUrl($this->permissions, $request_token);
}
}

View File

@@ -17,25 +17,25 @@
*/
interface Bridge_Api_Auth_Interface
{
const STATE_NEED_RECO = 'need_reconnect';
const STATE_BAD = 'not_connected';
const STATE_OK = 'connection OK';
const STATE_NEED_RECO = 'need_reconnect';
const STATE_BAD = 'not_connected';
const STATE_OK = 'connection OK';
public function connect($param);
public function connect($param);
public function reconnect();
public function reconnect();
public function disconnect();
public function disconnect();
public function is_connected();
public function is_connected();
public function parse_request_token();
public function parse_request_token();
public function get_auth_url(Array $supp_parameters = array());
public function get_auth_url(Array $supp_parameters = array());
public function get_auth_signatures();
public function get_auth_signatures();
public function set_settings(Bridge_AccountSettings $settings);
public function set_settings(Bridge_AccountSettings $settings);
public function set_parameters(Array $parameters);
public function set_parameters(Array $parameters);
}

View File

@@ -17,178 +17,175 @@
*/
class Bridge_Api_Auth_OAuth2 extends Bridge_Api_Auth_Abstract implements Bridge_Api_Auth_Interface
{
/**
*
* @var string
*/
protected $client_id;
/**
*
* @var string
*/
protected $client_id;
/**
*
* @var string
*/
protected $client_secret;
/**
*
* @var string
*/
protected $client_secret;
/**
*
* @var string
*/
protected $redirect_uri;
/**
*
* @var string
*/
protected $redirect_uri;
/**
*
* @var string
*/
protected $scope;
/**
*
* @var string
*/
protected $scope;
/**
*
* @var string
*/
protected $response_type;
/**
*
* @var string
*/
protected $response_type;
/**
*
* @var string
*/
protected $token_endpoint;
/**
*
* @var string
*/
protected $token_endpoint;
/**
*
* @var string
*/
protected $auth_endpoint;
/**
*
* @var string
*/
protected $auth_endpoint;
/**
*
* @var string
*/
public function parse_request_token()
{
return isset($_GET[$this->response_type]) ? $_GET[$this->response_type] : null;
}
/**
*
* @param string $request_token
* @return Array
*/
public function connect($request_token)
{
$post_params = array(
'code' => $request_token,
'client_id' => $this->client_id,
'client_secret' => $this->client_secret,
'redirect_uri' => $this->redirect_uri,
'grant_type' => 'authorization_code'
);
$response_json = http_query::getUrl($this->token_endpoint, $post_params);
$response = json_decode($response_json, JSON_HEX_TAG | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_HEX_APOS);
if (!is_array($response) || !isset($response['refresh_token']) || !isset($response['access_token']))
throw new Bridge_Exception_ApiConnectorAccessTokenFailed('Unable to retrieve tokens');
return array('refresh_token' => $response['refresh_token'], 'auth_token' => $response['access_token']);
}
/**
*
* @return Bridge_Api_Auth_OAuth2
*/
public function reconnect()
{
$post_params = array(
'client_id' => $this->client_id,
'client_secret' => $this->client_secret,
'refresh_token' => $this->settings->get('refresh_token'),
'grant_type' => 'refresh_token'
);
$response = http_query::getUrl($this->token_endpoint, $post_params);
$response = json_decode($response, JSON_HEX_TAG | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_HEX_APOS);
if (!is_array($response) || !isset($response['access_token']))
throw new Bridge_Exception_ApiConnectorAccessTokenFailed();
$this->settings->set('auth_token', $response['access_token']);
return $this;
}
/**
*
* @return Bridge_Api_Auth_OAuth2
*/
public function disconnect()
{
$this->settings->set('auth_token', null);
return $this;
}
/**
*
* @return boolean
*/
public function is_connected()
{
return $this->settings->get('auth_token') !== null;
}
/**
*
* @return Array
*/
public function get_auth_signatures()
{
return array(
'auth_token' => $this->settings->get('auth_token')
);
}
/**
*
* @param array $parameters
* @return Bridge_Api_Auth_OAuth2
*/
public function set_parameters(Array $parameters)
{
$avail_parameters = array(
'client_id'
, 'client_secret'
, 'redirect_uri'
, 'scope'
, 'response_type'
, 'token_endpoint'
, 'auth_endpoint'
);
foreach ($parameters as $parameter => $value)
/**
*
* @var string
*/
public function parse_request_token()
{
if (!in_array($parameter, $avail_parameters))
continue;
$this->$parameter = $value;
return isset($_GET[$this->response_type]) ? $_GET[$this->response_type] : null;
}
return $this;
}
/**
*
* @param string $request_token
* @return Array
*/
public function connect($request_token)
{
$post_params = array(
'code' => $request_token,
'client_id' => $this->client_id,
'client_secret' => $this->client_secret,
'redirect_uri' => $this->redirect_uri,
'grant_type' => 'authorization_code'
);
/**
*
* @return string
*/
public function get_auth_url(Array $supp_parameters = array())
{
$params = array_merge(array(
'response_type' => 'code',
'client_id' => $this->client_id,
'redirect_uri' => $this->redirect_uri,
'scope' => $this->scope
$response_json = http_query::getUrl($this->token_endpoint, $post_params);
$response = json_decode($response_json, JSON_HEX_TAG | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_HEX_APOS);
if ( ! is_array($response) || ! isset($response['refresh_token']) || ! isset($response['access_token']))
throw new Bridge_Exception_ApiConnectorAccessTokenFailed('Unable to retrieve tokens');
return array('refresh_token' => $response['refresh_token'], 'auth_token' => $response['access_token']);
}
/**
*
* @return Bridge_Api_Auth_OAuth2
*/
public function reconnect()
{
$post_params = array(
'client_id' => $this->client_id,
'client_secret' => $this->client_secret,
'refresh_token' => $this->settings->get('refresh_token'),
'grant_type' => 'refresh_token'
);
$response = http_query::getUrl($this->token_endpoint, $post_params);
$response = json_decode($response, JSON_HEX_TAG | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_HEX_APOS);
if ( ! is_array($response) || ! isset($response['access_token']))
throw new Bridge_Exception_ApiConnectorAccessTokenFailed();
$this->settings->set('auth_token', $response['access_token']);
return $this;
}
/**
*
* @return Bridge_Api_Auth_OAuth2
*/
public function disconnect()
{
$this->settings->set('auth_token', null);
return $this;
}
/**
*
* @return boolean
*/
public function is_connected()
{
return $this->settings->get('auth_token') !== null;
}
/**
*
* @return Array
*/
public function get_auth_signatures()
{
return array(
'auth_token' => $this->settings->get('auth_token')
);
}
/**
*
* @param array $parameters
* @return Bridge_Api_Auth_OAuth2
*/
public function set_parameters(Array $parameters)
{
$avail_parameters = array(
'client_id'
, 'client_secret'
, 'redirect_uri'
, 'scope'
, 'response_type'
, 'token_endpoint'
, 'auth_endpoint'
);
foreach ($parameters as $parameter => $value) {
if ( ! in_array($parameter, $avail_parameters))
continue;
$this->$parameter = $value;
}
return $this;
}
/**
*
* @return string
*/
public function get_auth_url(Array $supp_parameters = array())
{
$params = array_merge(array(
'response_type' => 'code',
'client_id' => $this->client_id,
'redirect_uri' => $this->redirect_uri,
'scope' => $this->scope
), $supp_parameters);
return sprintf('%s?%s', $this->auth_endpoint, http_build_query($params, null, '&'));
}
return sprintf('%s?%s', $this->auth_endpoint, http_build_query($params, null, '&'));
}
}

View File

@@ -18,16 +18,15 @@
class Bridge_Api_ContainerCollection extends Bridge_Api_AbstractCollection
{
/**
*
* @param Bridge_Api_ContainerInterface $container
* @return Bridge_Api_ContainerCollection
*/
public function add_element(Bridge_Api_ContainerInterface $container)
{
$this->elements[] = $container;
return $this;
}
/**
*
* @param Bridge_Api_ContainerInterface $container
* @return Bridge_Api_ContainerCollection
*/
public function add_element(Bridge_Api_ContainerInterface $container)
{
$this->elements[] = $container;
return $this;
}
}

View File

@@ -18,19 +18,19 @@
interface Bridge_Api_ContainerInterface
{
public function get_id();
public function get_id();
public function get_thumbnail($width = 120, $height = 90);
public function get_thumbnail($width = 120, $height = 90);
public function get_url();
public function get_url();
public function get_title();
public function get_title();
public function get_description();
public function get_description();
public function get_updated_on();
public function get_updated_on();
public function get_created_on();
public function get_created_on();
public function get_type();
public function get_type();
}

File diff suppressed because it is too large Load Diff

View File

@@ -12,137 +12,136 @@
*/
class Bridge_Api_Dailymotion_Container implements Bridge_Api_ContainerInterface
{
/**
*
* @var Array
*/
protected $entry;
/**
*
* @var Array
*/
protected $entry;
/**
*
* @var string
*/
protected $type;
/**
*
* @var string
*/
protected $type;
/**
*
* @var string
*/
protected $thumbnail;
/**
*
* @var string
*/
protected $thumbnail;
/**
*
* @param array $entry
* @param type $type
* @param type $thumbnail
* @return Bridge_Api_Dailymotion_Container
*/
public function __construct(Array $entry, $type, $thumbnail = '', $url = '')
{
$this->entry = $entry;
$this->type = $type;
$this->thumbnail = $thumbnail;
$this->url = $url;
/**
*
* @param array $entry
* @param type $type
* @param type $thumbnail
* @return Bridge_Api_Dailymotion_Container
*/
public function __construct(Array $entry, $type, $thumbnail = '', $url = '')
{
$this->entry = $entry;
$this->type = $type;
$this->thumbnail = $thumbnail;
$this->url = $url;
return $this;
}
return $this;
}
/**
*
* @return mixed
*/
private function get($key, $default = null)
{
return isset($this->entry[$key]) ? $this->entry[$key] : $default;
}
/**
*
* @return mixed
*/
private function get($key, $default = null)
{
return isset($this->entry[$key]) ? $this->entry[$key] : $default;
}
/**
*
* @return void
*/
public function get_created_on()
{
return;
}
/**
*
* @return void
*/
public function get_created_on()
{
return;
}
/**
*
* @return string
*/
public function get_description()
{
return $this->get("description", '');
}
/**
*
* @return string
*/
public function get_description()
{
return $this->get("description", '');
}
/**
*
* @return string
*/
public function get_id()
{
return $this->get("id", '');
}
/**
*
* @return string
*/
public function get_id()
{
return $this->get("id", '');
}
/**
*
* @param type $width
* @param type $height
* @return string
*/
public function get_thumbnail($width = 120, $height = 90)
{
return $this->thumbnail;
}
/**
*
* @param type $width
* @param type $height
* @return string
*/
public function get_thumbnail($width = 120, $height = 90)
{
return $this->thumbnail;
}
/**
*
* @return string
*/
public function get_title()
{
return $this->get("name", '');
}
/**
*
* @return string
*/
public function get_title()
{
return $this->get("name", '');
}
/**
*
* @return string
*/
public function get_type()
{
return $this->type;
}
/**
*
* @return string
*/
public function get_type()
{
return $this->type;
}
/**
*
* @return void
*/
public function get_updated_on()
{
return;
}
/**
*
* @return void
*/
public function get_updated_on()
{
return;
}
/**
*
* @return void
*/
public function get_url()
{
return $this->url;
}
/**
*
* @return void
*/
public function get_url()
{
return $this->url;
}
public function get_duration()
{
return '';
}
public function get_duration()
{
return '';
}
public function get_category()
{
return '';
}
public function get_category()
{
return '';
}
public function is_private()
{
return null;
}
public function is_private()
{
return null;
}
}

View File

@@ -12,165 +12,164 @@
*/
class Bridge_Api_Dailymotion_Element implements Bridge_Api_ElementInterface
{
/**
*
* @var array
*/
protected $entry;
/**
*
* @var array
*/
protected $entry;
/**
*
* @var string
*/
protected $type;
/**
*
* @var string
*/
protected $type;
/**
*
* @param array $entry
* @param type $type
* @return Bridge_Api_Dailymotion_Element
*/
public function __construct(Array $entry, $type)
{
$this->entry = $entry;
$this->type = $type;
/**
*
* @param array $entry
* @param type $type
* @return Bridge_Api_Dailymotion_Element
*/
public function __construct(Array $entry, $type)
{
$this->entry = $entry;
$this->type = $type;
return $this;
}
return $this;
}
/**
*
* @return mixed
*/
private function get($key, $default = null)
{
return isset($this->entry[$key]) ? $this->entry[$key] : $default;
}
/**
*
* @return mixed
*/
private function get($key, $default = null)
{
return isset($this->entry[$key]) ? $this->entry[$key] : $default;
}
/**
*
* @return DateTime
*/
public function get_created_on()
{
return DateTime::createFromFormat('U', $this->get("created_time"));
}
/**
*
* @return DateTime
*/
public function get_created_on()
{
return DateTime::createFromFormat('U', $this->get("created_time"));
}
/**
*
* @return string
*/
public function get_description()
{
return $this->get("description", '');
}
/**
*
* @return string
*/
public function get_description()
{
return $this->get("description", '');
}
/**
*
* @return string
*/
public function get_id()
{
return $this->get("id", '');
}
/**
*
* @return string
*/
public function get_id()
{
return $this->get("id", '');
}
/**
*
* @return string
*/
public function get_thumbnail($width = 120, $height = 90)
{
return $this->get("thumbnail_medium_url", '');
}
/**
*
* @return string
*/
public function get_thumbnail($width = 120, $height = 90)
{
return $this->get("thumbnail_medium_url", '');
}
/**
*
* @return string
*/
public function get_title()
{
return $this->get("title", '');
}
/**
*
* @return string
*/
public function get_title()
{
return $this->get("title", '');
}
/**
*
* @return string
*/
public function get_type()
{
return $this->type;
}
/**
*
* @return string
*/
public function get_type()
{
return $this->type;
}
/**
*
* @return DateTime
*/
public function get_updated_on()
{
return DateTime::createFromFormat('U', $this->get("modified_time"));
}
/**
*
* @return DateTime
*/
public function get_updated_on()
{
return DateTime::createFromFormat('U', $this->get("modified_time"));
}
/**
*
* @return string
*/
public function get_url()
{
return $this->get("url", '');
}
/**
*
* @return string
*/
public function get_url()
{
return $this->get("url", '');
}
/**
*
* @return boolean
*/
public function is_private()
{
return ! ! $this->get("private", 0);
}
/**
*
* @return boolean
*/
public function is_private()
{
return !!$this->get("private", 0);
}
/**
*
* @return string
*/
public function get_duration()
{
return p4string::format_seconds((int) $this->get('duration', '0'));
}
/**
*
* @return string
*/
public function get_duration()
{
return p4string::format_seconds((int) $this->get('duration', '0'));
}
/**
*
* @return int
*/
public function get_view_count()
{
return (int) $this->get('views_total', 0);
}
/**
*
* @return int
*/
public function get_view_count()
{
return (int) $this->get('views_total', 0);
}
/**
*
* @return int
*/
public function get_rating()
{
return (int) $this->get('ratings_total', 0);
}
/**
*
* @return int
*/
public function get_rating()
{
return (int) $this->get('ratings_total', 0);
}
/**
*
* @return string
*/
public function get_category()
{
return $this->get('channel', '');
}
/**
*
* @return string
*/
public function get_category()
{
return $this->get('channel','');
}
/**
*
* @return string
*/
public function get_tags()
{
return implode(",",$this->get('tags',array()));
}
/**
*
* @return string
*/
public function get_tags()
{
return implode(",", $this->get('tags', array()));
}
}

View File

@@ -18,16 +18,15 @@
class Bridge_Api_ElementCollection extends Bridge_Api_AbstractCollection
{
/**
*
* @param Bridge_Api_ElementInterface $element
* @return Bridge_Api_ElementCollection
*/
public function add_element(Bridge_Api_ElementInterface $element)
{
$this->elements[] = $element;
return $this;
}
/**
*
* @param Bridge_Api_ElementInterface $element
* @return Bridge_Api_ElementCollection
*/
public function add_element(Bridge_Api_ElementInterface $element)
{
$this->elements[] = $element;
return $this;
}
}

View File

@@ -18,43 +18,41 @@
interface Bridge_Api_ElementInterface
{
/**
* @return int
*/
/**
* @return int
*/
public function get_duration();
public function get_duration();
public function get_view_count();
public function get_view_count();
public function get_rating();
public function get_rating();
/**
* @return string
*/
public function get_id();
/**
* @return string
*/
public function get_url();
public function get_id();
public function get_thumbnail();
public function get_url();
public function get_title();
public function get_thumbnail();
public function get_description();
public function get_title();
public function get_category();
public function get_description();
public function get_type();
public function get_category();
/**
* @return Datetime
*/
public function get_updated_on();
public function get_type();
public function get_created_on();
/**
* @return Datetime
*/
public function get_updated_on();
public function get_created_on();
/**
* @return boolean
*/
public function is_private();
/**
* @return boolean
*/
public function is_private();
}

File diff suppressed because it is too large Load Diff

View File

@@ -17,140 +17,138 @@
*/
class Bridge_Api_Flickr_Container implements Bridge_Api_ContainerInterface
{
/**
*
* @var SimpleXMLElement
*/
protected $entry;
/**
*
* @var SimpleXMLElement
*/
protected $entry;
/**
*
* @var string
*/
protected $type;
/**
*
* @var string
*/
protected $type;
/**
*
* @var string
*/
protected $thumbnail;
/**
*
* @var string
*/
protected $thumbnail;
/**
*
* @var string
*/
protected $user_id;
/**
*
* @var string
*/
protected $user_id;
/**
*
* @param SimpleXMLElement $entry
* @param string $user_id
* @param string $type
* @param string $thumbnail
* @return Bridge_Api_Flickr_Container
*/
public function __construct(SimpleXMLElement $entry, $user_id, $type, $thumbnail)
{
$this->entry = $entry;
$this->type = $type;
$this->thumbnail = $thumbnail;
/**
*
* @param SimpleXMLElement $entry
* @param string $user_id
* @param string $type
* @param string $thumbnail
* @return Bridge_Api_Flickr_Container
*/
public function __construct(SimpleXMLElement $entry, $user_id, $type, $thumbnail)
{
$this->entry = $entry;
$this->type = $type;
$this->thumbnail = $thumbnail;
$this->user_id = (string) $user_id;
$this->user_id = (string) $user_id;
return $this;
}
return $this;
}
/**
*
* @return string
*/
public function get_id()
{
return (string) $this->entry['id'];
}
/**
*
* @return string
*/
public function get_id()
{
return (string) $this->entry['id'];
}
/**
*
* @return string
*/
public function get_thumbnail($width = 120, $height = 90)
{
/**
*
* @return string
*/
public function get_thumbnail($width = 120, $height = 90)
{
return $this->thumbnail;
}
return $this->thumbnail;
}
/**
*
* @return string
*/
public function get_url()
{
return sprintf(
'https://secure.flickr.com/photos/%s/sets/%s'
, $this->user_id
, $this->entry['id']
);
}
/**
*
* @return string
*/
public function get_url()
{
return sprintf(
'https://secure.flickr.com/photos/%s/sets/%s'
, $this->user_id
, $this->entry['id']
);
}
/**
*
* @return string
*/
public function get_title()
{
return (string) $this->entry->title;
}
/**
*
* @return string
*/
public function get_title()
{
return (string) $this->entry->title;
}
/**
*
* @return string
*/
public function get_description()
{
return (string) $this->entry->description;
}
/**
*
* @return string
*/
public function get_description()
{
return (string) $this->entry->description;
}
/**
*
* @return DateTime
*/
public function get_updated_on()
{
return DateTime::createFromFormat('U', (string) $this->entry['date_update']);
}
/**
*
* @return DateTime
*/
public function get_updated_on()
{
return DateTime::createFromFormat('U', (string) $this->entry['date_update']);
}
/**
*
* @return DateTime
*/
public function get_created_on()
{
return DateTime::createFromFormat('U', (string) $this->entry['date_create']);
}
/**
*
* @return DateTime
*/
public function get_created_on()
{
return DateTime::createFromFormat('U', (string) $this->entry['date_create']);
}
/**
*
* @return string
*/
public function get_type()
{
return $this->type;
}
/**
*
* @return string
*/
public function get_type()
{
return $this->type;
}
public function get_duration()
{
return '';
}
public function get_category()
{
return '';
}
public function get_duration()
{
return '';
}
public function get_category()
{
return '';
}
public function is_private()
{
return null;
}
public function is_private()
{
return null;
}
}

View File

@@ -17,266 +17,255 @@
*/
class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface
{
protected $entry;
protected $entry;
/**
*
* @var string
*/
protected $type;
/**
*
* @var string
*/
protected $type;
/**
*
* @var string
*/
protected $user_id;
/**
*
* @var string
*/
protected $user_id;
/**
*
* @param SimpleXMLElement $entry
* @param string $user_id
* @param string $type
* @return Bridge_Api_Flickr_Element
*/
public function __construct(SimpleXMLElement $entry, $user_id, $type, $entry_from_list = true)
{
$this->entry = array();
$this->type = $type;
if ($entry_from_list)
$this->init_from_list_entry($entry);
else
$this->init_from_single_entry($entry);
$this->user_id = (string) $user_id;
return $this;
}
private function init_from_list_entry($entry)
{
$this->entry["id"] = isset($entry["id"]) ? (string) $entry["id"] : "";
$this->entry["url"] = $this->generate_page_url($entry);
$this->entry["thumbnail"] = $this->generate_thumb_url($entry, 's');
$this->entry["title"] = isset($entry["title"]) ? (string) $entry["title"] : "";
$this->entry["updated_on"] = isset($entry["lastupdate"]) ? (string) $entry["lastupdate"] : null;
$this->entry["created_on"] = isset($entry["dateupload"]) ? (string) $entry["dateupload"] : null;
$this->entry["views"] = isset($entry["views"]) ? (string) $entry["views"] : 0;
$this->entry["ispublic"] = isset($entry["ispublic"]) ? !!(string)$entry["ispublic"] : false;
$this->entry["description"] = isset($entry->description) ? (string) $entry->description : "";
$this->entry["tags"] = isset($entry["tags"]) ? (string) $entry["tags"] : "";
}
private function init_from_single_entry($entry)
{
$photo = $entry->photo;
$url = '';
foreach ($photo->urls->url as $one_url)
/**
*
* @param SimpleXMLElement $entry
* @param string $user_id
* @param string $type
* @return Bridge_Api_Flickr_Element
*/
public function __construct(SimpleXMLElement $entry, $user_id, $type, $entry_from_list = true)
{
if ($one_url["type"] == "photopage")
$url = (string) $one_url;
}
$dates = $photo->dates;
$visibility = $photo->visibility;
$tags = array();
foreach ($photo->tags->tag as $one_tag)
{
$tags[] = $one_tag;
$this->entry = array();
$this->type = $type;
if ($entry_from_list)
$this->init_from_list_entry($entry);
else
$this->init_from_single_entry($entry);
$this->user_id = (string) $user_id;
return $this;
}
$this->entry["id"] = isset($photo["id"]) ? (string) $photo["id"] : '';
$this->entry["url"] = $url;
$this->entry["thumbnail"] = $this->generate_thumb_url($photo, 's');
$this->entry["title"] = isset($photo->title) ? (string) $photo->title : '';
$this->entry["updated_on"] = isset($dates["lastupdate"]) ? (string) $dates["lastupdate"] : null;
$this->entry["created_on"] = isset($dates["posted"]) ? (string) $dates["posted"] : null;
$this->entry["views"] = isset($photo["views"]) ? (string) $photo["views"] : 0;
$this->entry["ispublic"] = isset($visibility["ispublic"]) ? !!(string) $visibility["ispublic"] : false;
$this->entry["description"] = isset($photo->description) ? (string) $photo->description : "";
$this->entry["tags"] = implode(" ", $tags);
}
private function init_from_list_entry($entry)
{
$this->entry["id"] = isset($entry["id"]) ? (string) $entry["id"] : "";
$this->entry["url"] = $this->generate_page_url($entry);
$this->entry["thumbnail"] = $this->generate_thumb_url($entry, 's');
$this->entry["title"] = isset($entry["title"]) ? (string) $entry["title"] : "";
$this->entry["updated_on"] = isset($entry["lastupdate"]) ? (string) $entry["lastupdate"] : null;
$this->entry["created_on"] = isset($entry["dateupload"]) ? (string) $entry["dateupload"] : null;
$this->entry["views"] = isset($entry["views"]) ? (string) $entry["views"] : 0;
$this->entry["ispublic"] = isset($entry["ispublic"]) ? ! ! (string) $entry["ispublic"] : false;
$this->entry["description"] = isset($entry->description) ? (string) $entry->description : "";
$this->entry["tags"] = isset($entry["tags"]) ? (string) $entry["tags"] : "";
}
private function generate_page_url($entry)
{
if (isset($entry["owner"]) && isset($entry["id"]))
private function init_from_single_entry($entry)
{
$photo = $entry->photo;
$url = '';
return sprintf("http://www.flickr.com/%ss/%s/%s/", $this->type, (string) $entry["owner"], (string) $entry["id"]);
return "";
}
foreach ($photo->urls->url as $one_url) {
if ($one_url["type"] == "photopage")
$url = (string) $one_url;
}
$dates = $photo->dates;
$visibility = $photo->visibility;
$tags = array();
foreach ($photo->tags->tag as $one_tag) {
$tags[] = $one_tag;
}
/**
*
* @param type $entry
* @param type $size
* @param type $extension
* @return string
*/
private function generate_thumb_url($entry, $size = '', $extension = '')
{
if (isset($entry["url_t"]))
$this->entry["id"] = isset($photo["id"]) ? (string) $photo["id"] : '';
$this->entry["url"] = $url;
$this->entry["thumbnail"] = $this->generate_thumb_url($photo, 's');
$this->entry["title"] = isset($photo->title) ? (string) $photo->title : '';
$this->entry["updated_on"] = isset($dates["lastupdate"]) ? (string) $dates["lastupdate"] : null;
$this->entry["created_on"] = isset($dates["posted"]) ? (string) $dates["posted"] : null;
$this->entry["views"] = isset($photo["views"]) ? (string) $photo["views"] : 0;
$this->entry["ispublic"] = isset($visibility["ispublic"]) ? ! ! (string) $visibility["ispublic"] : false;
$this->entry["description"] = isset($photo->description) ? (string) $photo->description : "";
$this->entry["tags"] = implode(" ", $tags);
}
return (string) $entry["url_t"];
private function generate_page_url($entry)
{
if (isset($entry["owner"]) && isset($entry["id"]))
return sprintf("http://www.flickr.com/%ss/%s/%s/", $this->type, (string) $entry["owner"], (string) $entry["id"]);
return "";
}
if (!isset($entry["farm"]) || !isset($entry["farm"]) || !isset($entry["farm"]) || !isset($entry["farm"]) || !isset($entry["farm"]))
/**
*
* @param type $entry
* @param type $size
* @param type $extension
* @return string
*/
private function generate_thumb_url($entry, $size = '', $extension = '')
{
if (isset($entry["url_t"]))
return (string) $entry["url_t"];
return '';
if ( ! isset($entry["farm"]) || ! isset($entry["farm"]) || ! isset($entry["farm"]) || ! isset($entry["farm"]) || ! isset($entry["farm"]))
return '';
$farm = (string) $entry["farm"];
$server_id = (string) $entry["server"];
$id_photo = (string) $entry["id"];
$secret = (string) $entry["secret"];
$farm = (string) $entry["farm"];
$server_id = (string) $entry["server"];
$id_photo = (string) $entry["id"];
$secret = (string) $entry["secret"];
if (empty($size) && empty($extension))
if (empty($size) && empty($extension))
return sprintf('https://farm%s.static.flickr.com/%s/%s_%s.jpg', $farm, $server_id, $id_photo, $secret);
elseif ( ! empty($size) && ! empty($extension))
return sprintf('https://farm%s.static.flickr.com/%s/%s_%s_%s.jpg', $farm, $server_id, $id_photo, $secret, $size);
elseif ( ! empty($size))
return sprintf('https://farm%s.static.flickr.com/%s/%s_%s_%s.jpg', $farm, $server_id, $id_photo, $secret, $size, '.jpg');
elseif ( ! empty($extension))
return sprintf('https://farm%s.static.flickr.com/%s/%s_%s_o.%s', $farm, $server_id, $id_photo, $secret, $extension);
else
return "";
}
return sprintf('https://farm%s.static.flickr.com/%s/%s_%s.jpg', $farm, $server_id, $id_photo, $secret);
elseif (!empty($size) && !empty($extension))
/**
*
* @return string
*/
public function get_id()
{
return $this->entry["id"];
}
return sprintf('https://farm%s.static.flickr.com/%s/%s_%s_%s.jpg', $farm, $server_id, $id_photo, $secret, $size);
elseif (!empty($size))
/**
*
* @return string
*/
public function get_url()
{
return $this->entry["url"];
}
return sprintf('https://farm%s.static.flickr.com/%s/%s_%s_%s.jpg', $farm, $server_id, $id_photo, $secret, $size, '.jpg');
elseif (!empty($extension))
/**
*
* @return string
*/
public function get_thumbnail()
{
return $this->entry["thumbnail"];
}
return sprintf('https://farm%s.static.flickr.com/%s/%s_%s_o.%s', $farm, $server_id, $id_photo, $secret, $extension);
else
/**
*
* @return string
*/
public function get_title()
{
return $this->entry["title"];
}
return "";
}
/**
*
* @return null
*/
public function get_description()
{
return $this->entry["description"];
}
/**
*
* @return string
*/
public function get_id()
{
return $this->entry["id"];
}
/**
*
* @return null
*/
public function get_updated_on()
{
$date = $this->entry["updated_on"];
if ($date)
$date = DateTime::createFromFormat('U', $date);
/**
*
* @return string
*/
public function get_url()
{
return $this->entry["url"];
}
return $date;
}
/**
*
* @return string
*/
public function get_thumbnail()
{
return $this->entry["thumbnail"];
}
/**
*
* @return null
*/
public function get_category()
{
return '';
}
/**
*
* @return string
*/
public function get_title()
{
return $this->entry["title"];
}
/**
*
* @return null
*/
public function get_duration()
{
return '';
}
/**
*
* @return null
*/
public function get_description()
{
return $this->entry["description"];
}
/**
*
* @return int
*/
public function get_view_count()
{
return (int) $this->entry["views"];
}
/**
*
* @return null
*/
public function get_updated_on()
{
$date = $this->entry["updated_on"];
if ($date)
$date = DateTime::createFromFormat('U', $date);
/**
*
* @return null
*/
public function get_rating()
{
return null;
}
return $date;
}
/**
*
* @return DateTime
*/
public function get_created_on()
{
$date = $this->entry["created_on"];
if ($date)
$date = DateTime::createFromFormat('U', $date);
/**
*
* @return null
*/
public function get_category()
{
return '';
}
return $date;
}
/**
*
* @return null
*/
public function get_duration()
{
return '';
}
/**
*
* @return null
*/
public function is_private()
{
return ! $this->entry["ispublic"];
}
/**
*
* @return int
*/
public function get_view_count()
{
return (int) $this->entry["views"];
}
/**
*
* @return string
*/
public function get_type()
{
return $this->type;
}
/**
*
* @return null
*/
public function get_rating()
{
return null;
}
/**
*
* @return DateTime
*/
public function get_created_on()
{
$date = $this->entry["created_on"];
if ($date)
$date = DateTime::createFromFormat('U', $date);
return $date;
}
/**
*
* @return null
*/
public function is_private()
{
return !$this->entry["ispublic"];
}
/**
*
* @return string
*/
public function get_type()
{
return $this->type;
}
/**
*
* @return string
*/
public function get_tags()
{
return $this->entry["tags"];
}
/**
*
* @return string
*/
public function get_tags()
{
return $this->entry["tags"];
}
}

View File

@@ -19,158 +19,158 @@ use \Symfony\Component\HttpFoundation;
*/
interface Bridge_Api_Interface
{
const OBJECT_CLASS_ELEMENT = 'element';
const OBJECT_CLASS_CONTAINER = 'container';
const OBJECT_CLASS_ELEMENT = 'element';
const OBJECT_CLASS_CONTAINER = 'container';
public function __construct(registryInterface $registry, Bridge_Api_Auth_Interface $auth);
public function __construct(registryInterface $registry, Bridge_Api_Auth_Interface $auth);
/**
*
* @return Array
*/
public function connect();
/**
*
* @return Array
*/
public function connect();
/**
*
* @return Bridge_Api_Interface
*/
public function reconnect();
/**
*
* @return Bridge_Api_Interface
*/
public function reconnect();
/**
*
* @return Bridge_Api_Interface
*/
public function disconnect();
/**
*
* @return Bridge_Api_Interface
*/
public function disconnect();
/**
*
* @return boolean
*/
public function is_configured();
/**
*
* @return boolean
*/
public function is_configured();
/**
*
* @return boolean
*/
public function is_connected();
/**
*
* @return boolean
*/
public function is_connected();
/**
*
* @return Bridge_Api_Interface
*/
public function set_locale($locale);
/**
*
* @return Bridge_Api_Interface
*/
public function set_locale($locale);
/**
*
* @return Bridge_Api_Interface
*/
public function set_auth_settings(Bridge_AccountSettings &$settings);
/**
*
* @return Bridge_Api_Interface
*/
public function set_auth_settings(Bridge_AccountSettings &$settings);
/**
*
* @return string
*/
public function get_name();
/**
*
* @return string
*/
public function get_name();
/**
*
* @return string
*/
public function get_icon_url();
/**
*
* @return string
*/
public function get_icon_url();
/**
*
* @return string
*/
public function get_auth_url();
/**
*
* @return string
*/
public function get_auth_url();
/**
*
* @return string
*/
public function get_image_url();
/**
*
* @return string
*/
public function get_image_url();
/**
*
* @return string
*/
public function get_terms_url();
/**
*
* @return string
*/
public function get_terms_url();
/**
*
* @return string
*/
public function get_url();
/**
*
* @return string
*/
public function get_url();
/**
*
* @return string
*/
public function get_infos();
/**
*
* @return string
*/
public function get_infos();
public function get_object_class_from_type($type);
public function get_object_class_from_type($type);
public function get_default_element_type();
public function get_default_element_type();
public function get_default_container_type();
public function get_default_container_type();
public function get_element_types();
public function get_element_types();
public function get_container_types();
public function get_container_types();
public function get_element_from_id($element_id, $object);
public function get_element_from_id($element_id, $object);
public function get_container_from_id($element_id, $object);
public function get_container_from_id($element_id, $object);
public function get_category_list();
public function get_category_list();
public function get_user_name();
public function get_user_name();
public function get_user_id();
public function get_user_id();
public function list_elements($type, $offset_start = 0, $quantity = 10);
public function list_elements($type, $offset_start = 0, $quantity = 10);
public function list_containers($type, $offset_start = 0, $quantity = 10);
public function list_containers($type, $offset_start = 0, $quantity = 10);
public function update_element($object, $object_id, Array $datas);
public function update_element($object, $object_id, Array $datas);
public function create_container($container_type, Request $request);
public function create_container($container_type, Request $request);
public function add_element_to_container($element_type, $element_id, $destination, $container_id);
public function add_element_to_container($element_type, $element_id, $destination, $container_id);
public function delete_object($object, $object_id);
public function delete_object($object, $object_id);
/**
*
* @return Closure
*/
public function acceptable_records();
/**
*
* @return Closure
*/
public function acceptable_records();
public function get_element_status(Bridge_Element $element);
public function get_element_status(Bridge_Element $element);
public function map_connector_to_element_status($status);
public function map_connector_to_element_status($status);
public function get_error_message_from_status($connector_status);
public function get_error_message_from_status($connector_status);
public function upload(record_adapter &$record, array $options = array());
public function upload(record_adapter &$record, array $options = array());
public function is_valid_object_id($object_id);
public function is_valid_object_id($object_id);
/**
*
* @return boolean
*/
public function is_multiple_upload();
/**
*
* @return boolean
*/
public function is_multiple_upload();
/**
*
* @return array
*/
public function check_upload_constraints(Array $datas, record_adapter $record);
/**
*
* @return array
*/
public function check_upload_constraints(Array $datas, record_adapter $record);
public function get_upload_datas(Request $request, record_adapter $record);
public function get_upload_datas(Request $request, record_adapter $record);
public function get_update_datas(Request $request);
public function get_update_datas(Request $request);
public function check_update_constraints(Array $datas);
public function check_update_constraints(Array $datas);
}

File diff suppressed because it is too large Load Diff

View File

@@ -17,120 +17,117 @@
*/
class Bridge_Api_Youtube_Container implements Bridge_Api_ContainerInterface
{
/**
*
* @var Zend_Gdata_App_Entry
*/
protected $entry;
/**
*
* @var Zend_Gdata_App_Entry
*/
protected $entry;
/**
*
* @var string
*/
protected $type;
/**
*
* @var string
*/
protected $type;
/**
*
* @var string
*/
protected $thumbnail;
/**
*
* @var string
*/
protected $thumbnail;
public function __construct(Zend_Gdata_App_Entry $entry, $type, $thumbnail)
{
$this->entry = $entry;
$this->type = $type;
$this->thumbnail = $thumbnail;
public function __construct(Zend_Gdata_App_Entry $entry, $type, $thumbnail)
{
$this->entry = $entry;
$this->type = $type;
$this->thumbnail = $thumbnail;
return $this;
}
return $this;
}
/**
*
* @var string
*/
public function get_id()
{
return $this->entry->getPlaylistId()->getText();
}
/**
*
* @var string
*/
public function get_id()
{
return $this->entry->getPlaylistId()->getText();
}
/**
*
* @var string
*/
public function get_thumbnail($width = 120, $height = 90)
{
return $this->thumbnail;
}
/**
*
* @var string
*/
public function get_thumbnail($width = 120, $height = 90)
{
return $this->thumbnail;
}
/**
*
* @var string
*/
public function get_url()
{
return $this->entry->getAlternateLink()->getHref();
}
/**
*
* @var string
*/
public function get_url()
{
return $this->entry->getAlternateLink()->getHref();
}
/**
*
* @var string
*/
public function get_title()
{
return $this->entry->getTitle()->getText();
}
/**
*
* @var string
*/
public function get_title()
{
return $this->entry->getTitle()->getText();
}
/**
*
* @var string
*/
public function get_description()
{
return $this->entry->getDescription()->getText();
}
/**
*
* @var string
*/
public function get_description()
{
return $this->entry->getDescription()->getText();
}
/**
*
* @var DateTime
*/
public function get_updated_on()
{
return new DateTime($this->entry->getUpdated()->getText());
}
/**
*
* @var DateTime
*/
public function get_updated_on()
{
return new DateTime($this->entry->getUpdated()->getText());
}
/**
*
* @var DateTime
*/
public function get_created_on()
{
return new DateTime($this->entry->getPublished()->getText());
}
/**
*
* @var DateTime
*/
public function get_created_on()
{
return new DateTime($this->entry->getPublished()->getText());
}
/**
*
* @var string
*/
public function get_type()
{
return $this->type;
}
/**
*
* @var string
*/
public function get_type()
{
return $this->type;
}
public function get_duration()
{
return '';
}
public function get_duration()
{
return '';
}
public function get_category()
{
return '';
}
public function get_category()
{
return '';
}
public function is_private()
{
return null;
}
public function is_private()
{
return null;
}
}

View File

@@ -17,164 +17,160 @@
*/
class Bridge_Api_Youtube_Element implements Bridge_Api_ElementInterface
{
/**
*
* @var Zend_Gdata_App_Entry
*/
protected $entry;
/**
*
* @var Zend_Gdata_App_Entry
*/
protected $entry;
/**
*
* @var string
*/
protected $type;
/**
*
* @var string
*/
protected $type;
/**
*
* @param Zend_Gdata_App_Entry $entry
* @param string $type
* @return Bridge_Api_Youtube_Element
*/
public function __construct(Zend_Gdata_App_Entry $entry, $type)
{
$this->entry = $entry;
$this->type = $type;
return $this;
}
/**
*
* @return string
*/
public function get_id()
{
return $this->entry->getVideoId();
}
/**
* Return the thumbnail of the element
* Available size : 120*90;480*360;
*
* @return string
*/
public function get_thumbnail()
{
$video_thumbnails = $this->entry->getVideoThumbnails();
foreach ($video_thumbnails as $thumb)
/**
*
* @param Zend_Gdata_App_Entry $entry
* @param string $type
* @return Bridge_Api_Youtube_Element
*/
public function __construct(Zend_Gdata_App_Entry $entry, $type)
{
if (120 == $thumb['width'] && 90 == $thumb['height'])
$this->entry = $entry;
$this->type = $type;
return $thumb['url'];
return $this;
}
}
/**
*
* @return string
*/
public function get_url()
{
return $this->entry->getVideoWatchPageUrl();
}
/**
*
* @return string
*/
public function get_id()
{
return $this->entry->getVideoId();
}
/**
*
* @return string
*/
public function get_title()
{
return $this->entry->getVideoTitle();
}
/**
* Return the thumbnail of the element
* Available size : 120*90;480*360;
*
* @return string
*/
public function get_thumbnail()
{
$video_thumbnails = $this->entry->getVideoThumbnails();
/**
*
* @return string
*/
public function get_description()
{
return $this->entry->getVideoDescription();
}
foreach ($video_thumbnails as $thumb) {
if (120 == $thumb['width'] && 90 == $thumb['height'])
return $thumb['url'];
}
}
/**
*
* @return DateTime
*/
public function get_updated_on()
{
return new DateTime($this->entry->getUpdated()->getText());
}
/**
*
* @return string
*/
public function get_url()
{
return $this->entry->getVideoWatchPageUrl();
}
/**
*
* @return string
*/
public function get_category()
{
return $this->entry->getVideoCategory();
}
/**
*
* @return string
*/
public function get_title()
{
return $this->entry->getVideoTitle();
}
/**
*
* @return string
*/
public function get_duration()
{
return p4string::format_seconds($this->entry->getVideoDuration());
}
/**
*
* @return string
*/
public function get_description()
{
return $this->entry->getVideoDescription();
}
/**
*
* @return int
*/
public function get_view_count()
{
return (int) $this->entry->getVideoViewCount();
}
/**
*
* @return DateTime
*/
public function get_updated_on()
{
return new DateTime($this->entry->getUpdated()->getText());
}
/**
*
* @return int
*/
public function get_rating()
{
$rating_info = $this->entry->getVideoRatingInfo();
/**
*
* @return string
*/
public function get_category()
{
return $this->entry->getVideoCategory();
}
return (int) $rating_info["numRaters"];
}
/**
*
* @return string
*/
public function get_duration()
{
return p4string::format_seconds($this->entry->getVideoDuration());
}
/**
*
* @return DateTime
*/
public function get_created_on()
{
return new DateTime($this->entry->getPublished()->getText());
}
/**
*
* @return int
*/
public function get_view_count()
{
return (int) $this->entry->getVideoViewCount();
}
/**
*
* @return boolean
*/
public function is_private()
{
return !!$this->entry->isVideoPrivate();
}
/**
*
* @return int
*/
public function get_rating()
{
$rating_info = $this->entry->getVideoRatingInfo();
/**
*
* @return string
*/
public function get_type()
{
return $this->type;
}
return (int) $rating_info["numRaters"];
}
public function get_tags()
{
return implode(",", $this->entry->getVideoTags());
}
/**
*
* @return DateTime
*/
public function get_created_on()
{
return new DateTime($this->entry->getPublished()->getText());
}
/**
*
* @return boolean
*/
public function is_private()
{
return ! ! $this->entry->isVideoPrivate();
}
/**
*
* @return string
*/
public function get_type()
{
return $this->type;
}
public function get_tags()
{
return implode(",", $this->entry->getVideoTags());
}
}

View File

@@ -17,504 +17,498 @@
*/
class Bridge_Element
{
/**
*
* @var appbox
*/
protected $appbox;
/**
*
* @var appbox
*/
protected $appbox;
/**
*
* @var account
*/
protected $account;
/**
*
* @var account
*/
protected $account;
/**
*
* @var int
*/
protected $id;
/**
*
* @var int
*/
protected $id;
/**
*
* @var record_adapter
*/
protected $record;
/**
*
* @var record_adapter
*/
protected $record;
/**
*
* @var string
*/
protected $dist_id;
/**
*
* @var string
*/
protected $dist_id;
/**
*
* @var string
*/
protected $status;
/**
*
* @var string
*/
protected $status;
/**
*
* @var string
*/
protected $connector_status;
/**
*
* @var string
*/
protected $connector_status;
/**
*
* @var string
*/
protected $title;
/**
*
* @var string
*/
protected $title;
/**
*
* @var string
*/
protected $type;
/**
*
* @var string
*/
protected $type;
/**
*
* @var array
*/
protected $datas;
/**
*
* @var array
*/
protected $datas;
/**
*
* @var DateTime
*/
protected $created_on;
/**
*
* @var DateTime
*/
protected $created_on;
/**
*
* @var DateTime
*/
protected $uploaded_on;
/**
*
* @var DateTime
*/
protected $uploaded_on;
/**
*
* @var DateTime
*/
protected $updated_on;
/**
*
* @var Bridge_Api_ElementInterface
*/
protected $connector_element;
/**
*
* @var DateTime
*/
protected $updated_on;
const STATUS_DONE = 'done';
const STATUS_PROCESSING_SERVER = 'processing_server';
const STATUS_PROCESSING = 'processing';
const STATUS_PENDING = 'pending';
const STATUS_ERROR = 'error';
/**
*
* @var Bridge_Api_ElementInterface
*/
protected $connector_element;
/**
*
* @param appbox $appbox
* @param Bridge_Account $account
* @param int $id
* @return Bridge_Element
*/
public function __construct(appbox &$appbox, Bridge_Account &$account, $id)
{
$this->appbox = $appbox;
$this->account = $account;
$this->id = (int) $id;
const STATUS_DONE = 'done';
const STATUS_PROCESSING_SERVER = 'processing_server';
const STATUS_PROCESSING = 'processing';
const STATUS_PENDING = 'pending';
const STATUS_ERROR = 'error';
$sql = 'SELECT sbas_id, record_id, dist_id, status, connector_status, type
/**
*
* @param appbox $appbox
* @param Bridge_Account $account
* @param int $id
* @return Bridge_Element
*/
public function __construct(appbox &$appbox, Bridge_Account &$account, $id)
{
$this->appbox = $appbox;
$this->account = $account;
$this->id = (int) $id;
$sql = 'SELECT sbas_id, record_id, dist_id, status, connector_status, type
, title, serialized_datas, created_on, updated_on, uploaded_on
FROM bridge_elements WHERE id = :id';
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':id' => $this->id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':id' => $this->id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if (!$row)
throw new Bridge_Exception_ElementNotFound('Element Not Found');
if ( ! $row)
throw new Bridge_Exception_ElementNotFound('Element Not Found');
$this->record = new record_adapter($row['sbas_id'], $row['record_id']);
$this->dist_id = $row['dist_id'];
$this->status = $row['status'];
$this->connector_status = $row['connector_status'];
$this->record = new record_adapter($row['sbas_id'], $row['record_id']);
$this->dist_id = $row['dist_id'];
$this->status = $row['status'];
$this->connector_status = $row['connector_status'];
$this->title = $row['title'];
$this->type = $row['type'];
$this->datas = unserialize($row['serialized_datas']);
$this->updated_on = new DateTime($row['updated_on']);
$this->created_on = new DateTime($row['created_on']);
$this->uploaded_on = $row['uploaded_on'] ? new DateTime($row['uploaded_on']) : null;
$this->title = $row['title'];
$this->type = $row['type'];
$this->datas = unserialize($row['serialized_datas']);
$this->updated_on = new DateTime($row['updated_on']);
$this->created_on = new DateTime($row['created_on']);
$this->uploaded_on = $row['uploaded_on'] ? new DateTime($row['uploaded_on']) : null;
return $this;
}
return $this;
}
/**
*
* @return Bridge_Account
*/
public function get_account()
{
return $this->account;
}
/**
*
* @return Bridge_Account
*/
public function get_account()
{
return $this->account;
}
/**
*
* @return int
*/
public function get_id()
{
return $this->id;
}
/**
*
* @return int
*/
public function get_id()
{
return $this->id;
}
/**
*
* @return record_adapter
*/
public function get_record()
{
return $this->record;
}
/**
*
* @return record_adapter
*/
public function get_record()
{
return $this->record;
}
/**
*
* @return string
*/
public function get_dist_id()
{
return $this->dist_id;
}
/**
*
* @return string
*/
public function get_dist_id()
{
return $this->dist_id;
}
/**
*
* @param string $dist_id
* @return Bridge_Element
*/
public function set_dist_id($dist_id)
{
$this->dist_id = $dist_id;
$this->updated_on = new DateTime();
/**
*
* @param string $dist_id
* @return Bridge_Element
*/
public function set_dist_id($dist_id)
{
$this->dist_id = $dist_id;
$this->updated_on = new DateTime();
$sql = 'UPDATE bridge_elements
$sql = 'UPDATE bridge_elements
SET dist_id = :dist_id, updated_on = :update WHERE id = :id';
$params = array(
':dist_id' => $this->dist_id
, ':id' => $this->id
, ':update' => $this->updated_on->format(DATE_ISO8601)
);
$params = array(
':dist_id' => $this->dist_id
, ':id' => $this->id
, ':update' => $this->updated_on->format(DATE_ISO8601)
);
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
return $this;
}
return $this;
}
/**
*
* @return string
*/
public function get_status()
{
return $this->status;
}
/**
*
* @return string
*/
public function get_status()
{
return $this->status;
}
/**
*
* @param string $status
* @return Bridge_Element
*/
public function set_status($status)
{
$this->status = $status;
$this->updated_on = new DateTime();
/**
*
* @param string $status
* @return Bridge_Element
*/
public function set_status($status)
{
$this->status = $status;
$this->updated_on = new DateTime();
$sql = 'UPDATE bridge_elements
$sql = 'UPDATE bridge_elements
SET status = :status, updated_on = :update WHERE id = :id';
$params = array(
':status' => $this->status
, ':id' => $this->id
, ':update' => $this->updated_on->format(DATE_ISO8601)
);
$params = array(
':status' => $this->status
, ':id' => $this->id
, ':update' => $this->updated_on->format(DATE_ISO8601)
);
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
return $this;
}
return $this;
}
/**
*
* @return string
*/
public function get_connector_status()
{
return $this->connector_status;
}
/**
*
* @return string
*/
public function get_connector_status()
{
return $this->connector_status;
}
/**
*
* @param string $status
* @return Bridge_Element
*/
public function set_connector_status($status)
{
$this->connector_status = $status;
$this->updated_on = new DateTime();
/**
*
* @param string $status
* @return Bridge_Element
*/
public function set_connector_status($status)
{
$this->connector_status = $status;
$this->updated_on = new DateTime();
$sql = 'UPDATE bridge_elements
$sql = 'UPDATE bridge_elements
SET connector_status = :connector_status, updated_on = :update
WHERE id = :id';
$params = array(
':connector_status' => $this->connector_status
, ':id' => $this->id
, ':update' => $this->updated_on->format(DATE_ISO8601)
);
$params = array(
':connector_status' => $this->connector_status
, ':id' => $this->id
, ':update' => $this->updated_on->format(DATE_ISO8601)
);
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
return $this;
}
/**
*
* @return string
*/
public function get_title()
{
return $this->title;
}
/**
*
* @return string
*/
public function get_type()
{
return $this->type;
}
/**
*
* @return Bridge_Api_ElementInterface
*/
public function build_connector_element()
{
if (!$this->connector_element)
{
try
{
$this->connector_element = $this->account->get_api()->get_element_from_id($this->dist_id, $this->type);
}
catch (Exception $e)
{
return null;
}
return $this;
}
return $this->connector_element;
}
/**
*
* @return string
*/
public function get_title()
{
return $this->title;
}
/**
*
* @param string $title
* @return Bridge_Element
*/
public function set_title($title)
{
$this->title = $title;
$this->updated_on = new DateTime();
/**
*
* @return string
*/
public function get_type()
{
return $this->type;
}
$sql = 'UPDATE bridge_elements
/**
*
* @return Bridge_Api_ElementInterface
*/
public function build_connector_element()
{
if ( ! $this->connector_element) {
try {
$this->connector_element = $this->account->get_api()->get_element_from_id($this->dist_id, $this->type);
} catch (Exception $e) {
return null;
}
}
return $this->connector_element;
}
/**
*
* @param string $title
* @return Bridge_Element
*/
public function set_title($title)
{
$this->title = $title;
$this->updated_on = new DateTime();
$sql = 'UPDATE bridge_elements
SET title = :title, updated_on = :update WHERE id = :id';
$params = array(
':title' => $this->title
, ':id' => $this->id
, ':update' => $this->updated_on->format(DATE_ISO8601)
);
$params = array(
':title' => $this->title
, ':id' => $this->id
, ':update' => $this->updated_on->format(DATE_ISO8601)
);
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
return $this;
}
return $this;
}
/**
*
* @return array
*/
public function get_datas()
{
return $this->datas;
}
/**
*
* @return array
*/
public function get_datas()
{
return $this->datas;
}
/**
*
* @param array $datas
* @return Bridge_Element
*/
public function set_datas(Array $datas)
{
$this->datas = $datas;
$this->updated_on = new DateTime();
/**
*
* @param array $datas
* @return Bridge_Element
*/
public function set_datas(Array $datas)
{
$this->datas = $datas;
$this->updated_on = new DateTime();
$sql = 'UPDATE bridge_elements
$sql = 'UPDATE bridge_elements
SET serialized_datas = :datas, updated_on = :update WHERE id = :id';
$params = array(
':datas' => serialize($this->datas)
, ':id' => $this->id
, ':update' => $this->updated_on->format(DATE_ISO8601)
);
$params = array(
':datas' => serialize($this->datas)
, ':id' => $this->id
, ':update' => $this->updated_on->format(DATE_ISO8601)
);
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
return $this;
}
return $this;
}
/**
*
* @return DateTime
*/
public function get_created_on()
{
return $this->created_on;
}
/**
*
* @return DateTime
*/
public function get_created_on()
{
return $this->created_on;
}
/**
* @todo write tests
*
* @return DateTime
*/
public function get_uploaded_on()
{
return $this->uploaded_on;
}
/**
* @todo write tests
*
* @return DateTime
*/
public function get_uploaded_on()
{
return $this->uploaded_on;
}
/**
* @todo write tests
*
* @return DateTime
*/
public function set_uploaded_on(DateTime $date = null)
{
$this->uploaded_on = $date;
$this->updated_on = new DateTime();
/**
* @todo write tests
*
* @return DateTime
*/
public function set_uploaded_on(DateTime $date = null)
{
$this->uploaded_on = $date;
$this->updated_on = new DateTime();
$sql = 'UPDATE bridge_elements
$sql = 'UPDATE bridge_elements
SET uploaded_on = :uploaded_on, updated_on = :update WHERE id = :id';
$params = array(
':uploaded_on' => $this->uploaded_on ? $this->uploaded_on->format(DATE_ISO8601) : null
, ':id' => $this->id
, ':update' => $this->updated_on->format(DATE_ISO8601)
);
$params = array(
':uploaded_on' => $this->uploaded_on ? $this->uploaded_on->format(DATE_ISO8601) : null
, ':id' => $this->id
, ':update' => $this->updated_on->format(DATE_ISO8601)
);
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
return $this;
}
return $this;
}
/**
*
* @return DateTime
*/
public function get_updated_on()
{
return $this->updated_on;
}
/**
*
* @return DateTime
*/
public function get_updated_on()
{
return $this->updated_on;
}
/**
*
* @return Void
*/
public function delete()
{
$sql = 'DELETE FROM bridge_elements WHERE id = :id';
/**
*
* @return Void
*/
public function delete()
{
$sql = 'DELETE FROM bridge_elements WHERE id = :id';
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':id' => $this->id));
$stmt->closeCursor();
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':id' => $this->id));
$stmt->closeCursor();
return;
}
return;
}
/**
*
* @param appbox $appbox
* @param Bridge_Account $account
* @param int $quantity
* @return Bridge_Element
*/
public static function get_elements_by_account(appbox $appbox, Bridge_Account $account, $offset_start = 0, $quantity = 50)
{
$sql = 'SELECT id FROM bridge_elements WHERE account_id = :account_id
/**
*
* @param appbox $appbox
* @param Bridge_Account $account
* @param int $quantity
* @return Bridge_Element
*/
public static function get_elements_by_account(appbox $appbox, Bridge_Account $account, $offset_start = 0, $quantity = 50)
{
$sql = 'SELECT id FROM bridge_elements WHERE account_id = :account_id
ORDER BY id DESC
LIMIT ' . (int) $offset_start . ',' . (int) $quantity;
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':account_id' => $account->get_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':account_id' => $account->get_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$results = array();
$results = array();
foreach ($rs as $row)
{
$results[] = new Bridge_Element($appbox, $account, $row['id']);
foreach ($rs as $row) {
$results[] = new Bridge_Element($appbox, $account, $row['id']);
}
return $results;
}
return $results;
}
/**
*
* @param appbox $appbox
* @param Bridge_Account $account
* @param record_adapter $record
* @param string $title
* @param string $status
* @param string $type
* @param array $datas
* @return Bridge_Element
*/
public static function create(appbox &$appbox, Bridge_Account &$account, record_adapter &$record, $title, $status, $type, Array $datas = array())
{
$sql = 'INSERT INTO bridge_elements
/**
*
* @param appbox $appbox
* @param Bridge_Account $account
* @param record_adapter $record
* @param string $title
* @param string $status
* @param string $type
* @param array $datas
* @return Bridge_Element
*/
public static function create(appbox &$appbox, Bridge_Account &$account, record_adapter &$record, $title, $status, $type, Array $datas = array())
{
$sql = 'INSERT INTO bridge_elements
(id, account_id, sbas_id, record_id, dist_id, title, `type`
, serialized_datas, status, created_on, updated_on)
VALUES
(null, :account_id, :sbas_id, :record_id, null, :title, :type
,:datas , :status, NOW(), NOW())';
$params = array(
':account_id' => $account->get_id()
, ':sbas_id' => $record->get_sbas_id()
, ':record_id' => $record->get_record_id()
, ':status' => $status
, ':title' => $title
, ':type' => $type
, ':datas' => serialize($datas)
);
$params = array(
':account_id' => $account->get_id()
, ':sbas_id' => $record->get_sbas_id()
, ':record_id' => $record->get_record_id()
, ':status' => $status
, ':title' => $title
, ':type' => $type
, ':datas' => serialize($datas)
);
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$element_id = $appbox->get_connection()->lastInsertId();
return new self($appbox, $account, $element_id);
}
$element_id = $appbox->get_connection()->lastInsertId();
return new self($appbox, $account, $element_id);
}
}

View File

@@ -17,27 +17,25 @@
*/
class Bridge_Exception_ApiDisabled extends Bridge_Exception
{
protected $api;
protected $api;
/**
*
* @param Bridge_Api $api
*/
public function __construct(Bridge_Api $api)
{
$this->api = $api;
/**
*
* @param Bridge_Api $api
*/
public function __construct(Bridge_Api $api)
{
$this->api = $api;
parent::__construct();
}
/**
*
* @return Bridge_Api
*/
public function get_api()
{
return $this->api;
}
parent::__construct();
}
/**
*
* @return Bridge_Api
*/
public function get_api()
{
return $this->api;
}
}