14 * to license@zend.com so we can send you a copy immediately. |
14 * to license@zend.com so we can send you a copy immediately. |
15 * |
15 * |
16 * @category Zend |
16 * @category Zend |
17 * @package Zend_Gdata |
17 * @package Zend_Gdata |
18 * @subpackage App |
18 * @subpackage App |
19 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
19 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
20 * @license http://framework.zend.com/license/new-bsd New BSD License |
20 * @license http://framework.zend.com/license/new-bsd New BSD License |
21 * @version $Id: App.php 22972 2010-09-18 20:33:53Z ramon $ |
21 * @version $Id: App.php 25259 2013-02-13 17:38:12Z frosch $ |
22 */ |
22 */ |
23 |
23 |
24 /** |
24 /** |
25 * Zend_Gdata_Feed |
25 * Zend_Gdata_Feed |
26 */ |
26 */ |
38 |
38 |
39 /** |
39 /** |
40 * Zend_Gdata_App_MediaSource |
40 * Zend_Gdata_App_MediaSource |
41 */ |
41 */ |
42 require_once 'Zend/Gdata/App/MediaSource.php'; |
42 require_once 'Zend/Gdata/App/MediaSource.php'; |
|
43 |
|
44 /** |
|
45 * Zend_Uri/Http |
|
46 */ |
|
47 require_once 'Zend/Uri/Http.php'; |
43 |
48 |
44 /** |
49 /** |
45 * Provides Atom Publishing Protocol (APP) functionality. This class and all |
50 * Provides Atom Publishing Protocol (APP) functionality. This class and all |
46 * other components of Zend_Gdata_App are designed to work independently from |
51 * other components of Zend_Gdata_App are designed to work independently from |
47 * other Zend_Gdata components in order to interact with generic APP services. |
52 * other Zend_Gdata components in order to interact with generic APP services. |
48 * |
53 * |
49 * @category Zend |
54 * @category Zend |
50 * @package Zend_Gdata |
55 * @package Zend_Gdata |
51 * @subpackage App |
56 * @subpackage App |
52 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
57 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
53 * @license http://framework.zend.com/license/new-bsd New BSD License |
58 * @license http://framework.zend.com/license/new-bsd New BSD License |
54 */ |
59 */ |
55 class Zend_Gdata_App |
60 class Zend_Gdata_App |
56 { |
61 { |
57 |
62 |
717 * Imports a feed located at $uri. |
722 * Imports a feed located at $uri. |
718 * |
723 * |
719 * @param string $uri |
724 * @param string $uri |
720 * @param Zend_Http_Client $client The client used for communication |
725 * @param Zend_Http_Client $client The client used for communication |
721 * @param string $className The class which is used as the return type |
726 * @param string $className The class which is used as the return type |
|
727 * @param bool $useObjectMapping Enable/disable the use of XML to object mapping. |
722 * @throws Zend_Gdata_App_Exception |
728 * @throws Zend_Gdata_App_Exception |
723 * @return string|Zend_Gdata_App_Feed Returns string only if the object |
729 * @return string|Zend_Gdata_App_Feed Returns string only if the fourth |
724 * mapping has been disabled explicitly |
730 * parameter ($useObjectMapping) is set |
725 * by passing false to the |
731 * to false. |
726 * useObjectMapping() function. |
|
727 */ |
732 */ |
728 public static function import($uri, $client = null, |
733 public static function import($uri, $client = null, |
729 $className='Zend_Gdata_App_Feed') |
734 $className='Zend_Gdata_App_Feed', $useObjectMapping = true) |
730 { |
735 { |
731 $app = new Zend_Gdata_App($client); |
736 $app = new Zend_Gdata_App($client); |
732 $requestData = $app->prepareRequest('GET', $uri); |
737 $requestData = $app->prepareRequest('GET', $uri); |
733 $response = $app->performHttpRequest( |
738 $response = $app->performHttpRequest( |
734 $requestData['method'], $requestData['url']); |
739 $requestData['method'], $requestData['url']); |
735 |
740 |
736 $feedContent = $response->getBody(); |
741 $feedContent = $response->getBody(); |
737 if (!$this->_useObjectMapping) { |
742 if (false === $useObjectMapping) { |
738 return $feedContent; |
743 return $feedContent; |
739 } |
744 } |
740 $feed = self::importString($feedContent, $className); |
745 $feed = self::importString($feedContent, $className); |
741 if ($client != null) { |
746 if ($client != null) { |
742 $feed->setHttpClient($client); |
747 $feed->setHttpClient($client); |
1053 } |
1058 } |
1054 $foundClassName = $name . '_' . $class; |
1059 $foundClassName = $name . '_' . $class; |
1055 break; |
1060 break; |
1056 } catch (Zend_Exception $e) { |
1061 } catch (Zend_Exception $e) { |
1057 // package wasn't here- continue searching |
1062 // package wasn't here- continue searching |
|
1063 } catch (ErrorException $e) { |
|
1064 // package wasn't here- continue searching |
|
1065 // @see ZF-7013 and ZF-11959 |
1058 } |
1066 } |
1059 } |
1067 } |
1060 if ($foundClassName != null) { |
1068 if ($foundClassName != null) { |
1061 $reflectionObj = new ReflectionClass($foundClassName); |
1069 $reflectionObj = new ReflectionClass($foundClassName); |
1062 $instance = $reflectionObj->newInstanceArgs($args); |
1070 $instance = $reflectionObj->newInstanceArgs($args); |
1085 * Retrieve all entries for a feed, iterating through pages as necessary. |
1093 * Retrieve all entries for a feed, iterating through pages as necessary. |
1086 * Be aware that calling this function on a large dataset will take a |
1094 * Be aware that calling this function on a large dataset will take a |
1087 * significant amount of time to complete. In some cases this may cause |
1095 * significant amount of time to complete. In some cases this may cause |
1088 * execution to timeout without proper precautions in place. |
1096 * execution to timeout without proper precautions in place. |
1089 * |
1097 * |
1090 * @param $feed The feed to iterate through. |
1098 * @param object $feed The feed to iterate through. |
1091 * @return mixed A new feed of the same type as the one originally |
1099 * @return mixed A new feed of the same type as the one originally |
1092 * passed in, containing all relevent entries. |
1100 * passed in, containing all relevent entries. |
1093 */ |
1101 */ |
1094 public function retrieveAllEntriesForFeed($feed) { |
1102 public function retrieveAllEntriesForFeed($feed) { |
1095 $feedClass = get_class($feed); |
1103 $feedClass = get_class($feed); |
1115 * This method enables logging of requests by changing the |
1123 * This method enables logging of requests by changing the |
1116 * Zend_Http_Client_Adapter used for performing the requests. |
1124 * Zend_Http_Client_Adapter used for performing the requests. |
1117 * NOTE: This will not work if you have customized the adapter |
1125 * NOTE: This will not work if you have customized the adapter |
1118 * already to use a proxy server or other interface. |
1126 * already to use a proxy server or other interface. |
1119 * |
1127 * |
1120 * @param $logfile The logfile to use when logging the requests |
1128 * @param string $logfile The logfile to use when logging the requests |
1121 */ |
1129 */ |
1122 public function enableRequestDebugLogging($logfile) |
1130 public function enableRequestDebugLogging($logfile) |
1123 { |
1131 { |
1124 $this->_httpClient->setConfig(array( |
1132 $this->_httpClient->setConfig(array( |
1125 'adapter' => 'Zend_Gdata_App_LoggingHttpClientAdapterSocket', |
1133 'adapter' => 'Zend_Gdata_App_LoggingHttpClientAdapterSocket', |