File indexing completed on 2024-12-22 05:36:43
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Gdata 0017 * @subpackage Analytics 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** 0024 * @see Zend_Gdata_Query 0025 */ 0026 // require_once 'Zend/Gdata/Query.php'; 0027 0028 /** 0029 * @category Zend 0030 * @package Zend_Gdata 0031 * @subpackage Analytics 0032 */ 0033 class Zend_Gdata_Analytics_AccountQuery extends Zend_Gdata_Query 0034 { 0035 const ANALYTICS_FEED_URI = 'https://www.googleapis.com/analytics/v2.4/management/accounts'; 0036 0037 /** 0038 * The default URI used for feeds. 0039 */ 0040 protected $_defaultFeedUri = self::ANALYTICS_FEED_URI; 0041 0042 /** 0043 * @var string 0044 */ 0045 protected $_accountId = '~all'; 0046 /** 0047 * @var string 0048 */ 0049 protected $_webpropertyId = '~all'; 0050 /** 0051 * @var string 0052 */ 0053 protected $_profileId = '~all'; 0054 0055 /** 0056 * @var bool 0057 */ 0058 protected $_webproperties = false; 0059 /** 0060 * @var bool 0061 */ 0062 protected $_profiles = false; 0063 /** 0064 * @var bool 0065 */ 0066 protected $_goals = false; 0067 0068 /** 0069 * @param string $accountId 0070 * @return Zend_Gdata_Analytics_AccountQuery 0071 */ 0072 public function setAccountId($accountId) 0073 { 0074 $this->_accountId = $accountId; 0075 return $this; 0076 } 0077 0078 /** 0079 * @return string 0080 */ 0081 public function getAccountId() 0082 { 0083 return $this->_accountId; 0084 } 0085 0086 /** 0087 * @param string $webpropertyId 0088 * @return Zend_Gdata_Analytics_AccountQuery 0089 */ 0090 public function setWebpropertyId($webpropertyId) 0091 { 0092 $this->_webpropertyId = $webpropertyId; 0093 return $this; 0094 } 0095 0096 /** 0097 * @return string 0098 */ 0099 public function getWebpropertyId() 0100 { 0101 return $this->_webpropertyId; 0102 } 0103 0104 /** 0105 * @param string $profileId 0106 * @return Zend_Gdata_Analytics_AccountQuery 0107 */ 0108 public function setProfileId($profileId) 0109 { 0110 $this->_profileId = $profileId; 0111 return $this; 0112 } 0113 0114 /** 0115 * @return string 0116 */ 0117 public function getProfileId() 0118 { 0119 return $this->_profileId; 0120 } 0121 0122 /** 0123 * @param string $accountId 0124 * @return Zend_Gdata_Analytics_AccountQuery 0125 */ 0126 public function webproperties($accountId = '~all') 0127 { 0128 $this->_webproperties = true; 0129 $this->setAccountId($accountId); 0130 return $this; 0131 } 0132 0133 /** 0134 * @param string $webpropertyId 0135 * @param string $accountId 0136 * @return Zend_Gdata_Analytics_AccountQuery 0137 */ 0138 public function profiles($webpropertyId = '~all', $accountId = '~all') 0139 { 0140 $this->_profiles = true; 0141 if (null !== $accountId) { 0142 $this->setAccountId($accountId); 0143 } 0144 $this->setWebpropertyId($webpropertyId); 0145 return $this; 0146 } 0147 0148 /** 0149 * @param string $webpropertyId 0150 * @param string $accountId 0151 * @param string $accountId 0152 * @return Zend_Gdata_Analytics_AccountQuery 0153 */ 0154 public function goals($profileId = '~all', $webpropertyId = '~all', $accountId = '~all') 0155 { 0156 $this->_goals = true; 0157 if (null !== $accountId) { 0158 $this->setAccountId($accountId); 0159 } 0160 if (null !== $webpropertyId) { 0161 $this->setWebpropertyId($webpropertyId); 0162 } 0163 $this->setProfileId($profileId); 0164 return $this; 0165 } 0166 0167 /** 0168 * @return string url 0169 */ 0170 public function getQueryUrl() 0171 { 0172 $url = $this->_defaultFeedUri; 0173 0174 // add account id 0175 if ($this->_webproperties or $this->_profiles or $this->_goals) { 0176 $url .= '/' . $this->_accountId . '/webproperties'; 0177 } 0178 0179 if ($this->_profiles or $this->_goals) { 0180 $url .= '/' . $this->_webpropertyId . '/profiles'; 0181 } 0182 0183 if ($this->_goals) { 0184 $url .= '/' . $this->_profileId . '/goals'; 0185 } 0186 0187 $url .= $this->getQueryString(); 0188 return $url; 0189 } 0190 }