From 60cb3284d23d651a201cfa9fdbc21c16d47e3de6 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sun, 23 Jun 2019 14:18:43 +0200 Subject: [PATCH] Mage_Log - DOC block update - doc blocks added/fixed - PSR2 fixes (whitespaces, linebreaks, ...) --- app/code/core/Mage/Log/Helper/Data.php | 8 +- .../System/Config/Source/Loglevel.php | 7 ++ app/code/core/Mage/Log/Model/Aggregation.php | 42 +++++++-- app/code/core/Mage/Log/Model/Cron.php | 7 +- app/code/core/Mage/Log/Model/Customer.php | 2 +- app/code/core/Mage/Log/Model/Log.php | 3 + .../Mage/Log/Model/Resource/Aggregation.php | 10 ++- .../core/Mage/Log/Model/Resource/Customer.php | 11 ++- app/code/core/Mage/Log/Model/Resource/Log.php | 21 +++-- .../core/Mage/Log/Model/Resource/Visitor.php | 36 ++++---- .../Log/Model/Resource/Visitor/Collection.php | 10 +-- .../Log/Model/Resource/Visitor/Online.php | 16 ++-- .../Resource/Visitor/Online/Collection.php | 11 ++- app/code/core/Mage/Log/Model/Visitor.php | 90 +++++++++++++++---- .../core/Mage/Log/Model/Visitor/Online.php | 17 ++-- .../data/log_setup/data-install-1.6.0.0.php | 2 +- .../Log/sql/log_setup/install-1.6.0.0.php | 32 ++++--- .../sql/log_setup/mysql4-install-0.7.0.php | 2 +- .../log_setup/mysql4-upgrade-0.7.3-0.7.4.php | 2 +- .../log_setup/mysql4-upgrade-0.7.4-0.7.5.php | 2 +- .../log_setup/mysql4-upgrade-0.7.5-0.7.6.php | 2 +- .../log_setup/mysql4-upgrade-0.7.6-0.7.7.php | 2 +- .../mysql4-upgrade-1.5.9.9-1.6.0.0.php | 2 +- .../mysql4-upgrade-1.6.0.0-1.6.1.0.php | 3 +- .../mysql4-upgrade-1.6.1.0-1.6.1.1.php | 2 +- 25 files changed, 233 insertions(+), 109 deletions(-) diff --git a/app/code/core/Mage/Log/Helper/Data.php b/app/code/core/Mage/Log/Helper/Data.php index 560a046f456..785e1d182de 100644 --- a/app/code/core/Mage/Log/Helper/Data.php +++ b/app/code/core/Mage/Log/Helper/Data.php @@ -32,7 +32,7 @@ class Mage_Log_Helper_Data extends Mage_Core_Helper_Abstract const XML_PATH_LOG_ENABLED = 'system/log/enable_log'; /** - * @var Mage_Log_Helper_Data + * @var int */ protected $_logLevel; @@ -41,6 +41,10 @@ class Mage_Log_Helper_Data extends Mage_Core_Helper_Abstract */ private $_allowedFileExtensions = array('log', 'txt', 'html', 'csv'); + /** + * Mage_Log_Helper_Data constructor. + * @param array $data + */ public function __construct(array $data = array()) { $this->_logLevel = isset($data['log_level']) ? $data['log_level'] @@ -81,7 +85,7 @@ public function isLogDisabled() /** * Checking if file extensions is allowed. If passed then return true. * - * @param $file + * @param string $file * @return bool */ public function isLogFileExtensionValid($file) diff --git a/app/code/core/Mage/Log/Model/Adminhtml/System/Config/Source/Loglevel.php b/app/code/core/Mage/Log/Model/Adminhtml/System/Config/Source/Loglevel.php index 428d61050a9..4531c3bab9b 100644 --- a/app/code/core/Mage/Log/Model/Adminhtml/System/Config/Source/Loglevel.php +++ b/app/code/core/Mage/Log/Model/Adminhtml/System/Config/Source/Loglevel.php @@ -54,11 +54,18 @@ class Mage_Log_Model_Adminhtml_System_Config_Source_Loglevel */ protected $_helper; + /** + * Mage_Log_Model_Adminhtml_System_Config_Source_Loglevel constructor. + * @param array $data + */ public function __construct(array $data = array()) { $this->_helper = !empty($data['helper']) ? $data['helper'] : Mage::helper('log'); } + /** + * @return array + */ public function toOptionArray() { $options = array( diff --git a/app/code/core/Mage/Log/Model/Aggregation.php b/app/code/core/Mage/Log/Model/Aggregation.php index 5ed4b958f98..5ee3c2c03a6 100644 --- a/app/code/core/Mage/Log/Model/Aggregation.php +++ b/app/code/core/Mage/Log/Model/Aggregation.php @@ -36,7 +36,6 @@ */ class Mage_Log_Model_Aggregation extends Mage_Core_Model_Abstract { - /** * Last record data * @@ -67,7 +66,7 @@ public function run() * Remove empty records before $lastDate * * @param string $lastDate - * @return void + * @return Mage_Log_Model_Resource_Aggregation */ private function _removeEmpty($lastDate) { @@ -102,7 +101,7 @@ private function _process($store) } $lastDateRecord = $date; - $date = $to; + $date = $to; } return $lastDateRecord; } @@ -123,48 +122,77 @@ private function _save($data, $from, $to) } } + /** + * @param int $id + * @param array $data + */ private function _update($id, $data) { return $this->_getResource()->saveLog($data, $id); } + /** + * @param array $data + */ private function _insert($data) { return $this->_getResource()->saveLog($data); } + /** + * @param string $from + * @param string $to + * @param int $store + * @return array + */ private function _getCounts($from, $to, $store) { return $this->_getResource()->getCounts($from, $to, $store); } + /** + * @return false|string + */ public function getLastRecordDate() { $result = $this->_getResource()->getLastRecordDate(); - if (!$result) + if (!$result) { $result = $this->_date(strtotime('now - 2 months')); + } return $result; } + /** + * @param string|int $in + * @param null $offset + * @return false|string + */ private function _date($in, $offset = null) { $out = $in; - if (is_numeric($in)) + if (is_numeric($in)) { $out = date("Y-m-d H:i:s", $in); + } return $out; } + /** + * @param string|int $in + * @param null $offset + * @return false|int + */ private function _timestamp($in, $offset = null) { $out = $in; - if (!is_numeric($in)) + if (!is_numeric($in)) { $out = strtotime($in); + } return $out; } /** - * @param $in + * @param string|int $in * @return string */ private function _round($in) diff --git a/app/code/core/Mage/Log/Model/Cron.php b/app/code/core/Mage/Log/Model/Cron.php index 441ade34179..a9c6c9c2d32 100644 --- a/app/code/core/Mage/Log/Model/Cron.php +++ b/app/code/core/Mage/Log/Model/Cron.php @@ -61,11 +61,11 @@ protected function _sendLogCleanEmail() } $translate = Mage::getSingleton('core/translate'); - /* @var $translate Mage_Core_Model_Translate */ + /* @var Mage_Core_Model_Translate $translate */ $translate->setTranslateInline(false); $emailTemplate = Mage::getModel('core/email_template'); - /* @var $emailTemplate Mage_Core_Model_Email_Template */ + /* @var Mage_Core_Model_Email_Template $emailTemplate */ $emailTemplate->setDesignConfig(array('area' => 'backend')) ->sendTransactional( Mage::getStoreConfig(self::XML_PATH_EMAIL_LOG_CLEAN_TEMPLATE), @@ -95,8 +95,7 @@ public function logClean() try { Mage::getModel('log/log')->clean(); - } - catch (Exception $e) { + } catch (Exception $e) { $this->_errors[] = $e->getMessage(); $this->_errors[] = $e->getTrace(); } diff --git a/app/code/core/Mage/Log/Model/Customer.php b/app/code/core/Mage/Log/Model/Customer.php index 668d2f82ba0..bdf7371bdfa 100644 --- a/app/code/core/Mage/Log/Model/Customer.php +++ b/app/code/core/Mage/Log/Model/Customer.php @@ -59,7 +59,7 @@ protected function _construct() /** * Load last log by customer id * - * @param Mage_Customer_Model_Customer|int $customer + * @param Mage_Log_Model_Customer|int $customer * @return $this */ public function loadByCustomer($customer) diff --git a/app/code/core/Mage/Log/Model/Log.php b/app/code/core/Mage/Log/Model/Log.php index 3bc67f7ad66..bcc52fdae7b 100644 --- a/app/code/core/Mage/Log/Model/Log.php +++ b/app/code/core/Mage/Log/Model/Log.php @@ -58,6 +58,9 @@ protected function _construct() $this->_init('log/log'); } + /** + * @return float|int + */ public function getLogCleanTime() { return Mage::getStoreConfig(self::XML_LOG_CLEAN_DAYS) * 60 * 60 * 24; diff --git a/app/code/core/Mage/Log/Model/Resource/Aggregation.php b/app/code/core/Mage/Log/Model/Resource/Aggregation.php index 6812c349994..627fa8f8506 100644 --- a/app/code/core/Mage/Log/Model/Resource/Aggregation.php +++ b/app/code/core/Mage/Log/Model/Resource/Aggregation.php @@ -26,7 +26,7 @@ /** - * Log aggregation resource model + * Log aggregation resource model * * @category Mage * @package Mage_Log @@ -52,8 +52,10 @@ public function getLastRecordDate() { $adapter = $this->_getReadAdapter(); $select = $adapter->select() - ->from($this->getTable('log/summary_table'), - array($adapter->quoteIdentifier('date')=>'MAX(add_date)')); + ->from( + $this->getTable('log/summary_table'), + array($adapter->quoteIdentifier('date')=>'MAX(add_date)') + ); return $adapter->fetchOne($select); } @@ -129,7 +131,7 @@ public function removeEmpty($date) 'add_date < ?' => $date, 'customer_count = 0', 'visitor_count = 0' - ); + ); $adapter->delete($this->getTable('log/summary_table'), $condition); } diff --git a/app/code/core/Mage/Log/Model/Resource/Customer.php b/app/code/core/Mage/Log/Model/Resource/Customer.php index 9c8bf262b3b..85b7905acf7 100644 --- a/app/code/core/Mage/Log/Model/Resource/Customer.php +++ b/app/code/core/Mage/Log/Model/Resource/Customer.php @@ -94,7 +94,7 @@ protected function _construct() /** * Retrieve select object for load object data - * + * * @param string $field * @param mixed $value * @param Mage_Log_Model_Customer $object @@ -110,15 +110,18 @@ protected function _getLoadSelect($field, $value, $object) ->joinInner( array('lvt' => $this->_visitorTable), "lvt.visitor_id = {$table}.visitor_id", - array('last_visit_at')) + array('last_visit_at') + ) ->joinInner( array('lvit' => $this->_visitorInfoTable), 'lvt.visitor_id = lvit.visitor_id', - array('http_referer', 'remote_addr')) + array('http_referer', 'remote_addr') + ) ->joinInner( array('luit' => $this->_urlInfoTable), 'luit.url_id = lvt.last_url_id', - array('url')) + array('url') + ) ->order("{$table}.login_at DESC") ->limit(1); } diff --git a/app/code/core/Mage/Log/Model/Resource/Log.php b/app/code/core/Mage/Log/Model/Resource/Log.php index 95f27735768..c587af2f74c 100644 --- a/app/code/core/Mage/Log/Model/Resource/Log.php +++ b/app/code/core/Mage/Log/Model/Resource/Log.php @@ -85,11 +85,13 @@ protected function _cleanVisitors($time) $select = $readAdapter->select() ->from( array('visitor_table' => $this->getTable('log/visitor')), - array('visitor_id' => 'visitor_table.visitor_id')) + array('visitor_id' => 'visitor_table.visitor_id') + ) ->joinLeft( array('customer_table' => $this->getTable('log/customer')), 'visitor_table.visitor_id = customer_table.visitor_id AND customer_table.log_id IS NULL', - array()) + array() + ) ->where('visitor_table.last_visit_at < ?', $timeLimit) ->limit(100); @@ -147,12 +149,14 @@ protected function _cleanCustomers($time) $select = $readAdapter->select() ->from( array('log_customer_main' => $this->getTable('log/customer')), - array('log_id')) + array('log_id') + ) ->joinLeft( array('log_customer' => $this->getTable('log/customer')), 'log_customer_main.customer_id = log_customer.customer_id ' . 'AND log_customer_main.log_id < log_customer.log_id', - array()) + array() + ) ->where('log_customer.customer_id IS NULL') ->where('log_customer_main.log_id < ?', $lastLogId + 1); @@ -168,7 +172,8 @@ protected function _cleanCustomers($time) $select = $readAdapter->select() ->from( $this->getTable('log/customer'), - array('log_id', 'visitor_id')) + array('log_id', 'visitor_id') + ) ->where('log_id > ?', $customerLogId) ->where('log_id < ?', $lastLogId + 1) ->order('log_id') @@ -229,11 +234,13 @@ protected function _cleanUrls() $select = $readAdapter->select() ->from( array('url_info_table' => $this->getTable('log/url_info_table')), - array('url_id')) + array('url_id') + ) ->joinLeft( array('url_table' => $this->getTable('log/url_table')), 'url_info_table.url_id = url_table.url_id', - array()) + array() + ) ->where('url_table.url_id IS NULL') ->limit(100); diff --git a/app/code/core/Mage/Log/Model/Resource/Visitor.php b/app/code/core/Mage/Log/Model/Resource/Visitor.php index f9481a800b5..cc190d19553 100644 --- a/app/code/core/Mage/Log/Model/Resource/Visitor.php +++ b/app/code/core/Mage/Log/Model/Resource/Visitor.php @@ -41,6 +41,10 @@ class Mage_Log_Model_Resource_Visitor extends Mage_Core_Model_Resource_Db_Abstra */ protected $_urlLoggingCondition; + /** + * Mage_Log_Model_Resource_Visitor constructor. + * @param array $data + */ public function __construct(array $data = array()) { parent::__construct(); @@ -60,7 +64,7 @@ protected function _construct() /** * Prepare data for save * - * @param Mage_Core_Model_Abstract $visitor + * @param Mage_Core_Model_Abstract|Mage_Log_Model_Visitor $visitor * @return array */ protected function _prepareDataForSave(Mage_Core_Model_Abstract $visitor) @@ -77,8 +81,8 @@ protected function _prepareDataForSave(Mage_Core_Model_Abstract $visitor) /** * Saving information about url * - * @param Mage_Log_Model_Visitor $visitor - * @return Mage_Log_Model_Resource_Visitor + * @param Mage_Core_Model_Abstract|Mage_Log_Model_Visitor $visitor + * @return $this */ protected function _saveUrlInfo($visitor) { @@ -99,7 +103,7 @@ protected function _saveUrlInfo($visitor) /** * Save url info before save * - * @param Mage_Core_Model_Abstract $visitor + * @param Mage_Core_Model_Abstract|Mage_Log_Model_Visitor $visitor * @return $this */ protected function _beforeSave(Mage_Core_Model_Abstract $visitor) @@ -116,7 +120,7 @@ protected function _beforeSave(Mage_Core_Model_Abstract $visitor) /** * Actions after save * - * @param Mage_Core_Model_Abstract $visitor + * @param Mage_Core_Model_Abstract|Mage_Log_Model_Visitor $visitor * @return $this */ protected function _afterSave(Mage_Core_Model_Abstract $visitor) @@ -148,8 +152,8 @@ protected function _afterSave(Mage_Core_Model_Abstract $visitor) /** * Perform actions after object load * - * @param Mage_Core_Model_Abstract $object - * @return Mage_Core_Model_Resource_Db_Abstract + * @param Mage_Core_Model_Abstract|Mage_Log_Model_Visitor $object + * @return $this */ protected function _afterLoad(Mage_Core_Model_Abstract $object) { @@ -171,12 +175,12 @@ protected function _afterLoad(Mage_Core_Model_Abstract $object) /** * Saving visitor information * - * @param Mage_Log_Model_Visitor $visitor - * @return Mage_Log_Model_Resource_Visitor + * @param Mage_Core_Model_Abstract|Mage_Log_Model_Visitor $visitor + * @return $this */ protected function _saveVisitorInfo($visitor) { - /* @var $stringHelper Mage_Core_Helper_String */ + /* @var Mage_Core_Helper_String $stringHelper */ $stringHelper = Mage::helper('core/string'); $referer = $stringHelper->cleanString($visitor->getHttpReferer()); @@ -207,8 +211,8 @@ protected function _saveVisitorInfo($visitor) /** * Saving visitor and url relation * - * @param Mage_Log_Model_Visitor $visitor - * @return Mage_Log_Model_Resource_Visitor + * @param Mage_Core_Model_Abstract|Mage_Log_Model_Visitor $visitor + * @return $this */ protected function _saveVisitorUrl($visitor) { @@ -226,8 +230,8 @@ protected function _saveVisitorUrl($visitor) /** * Saving information about customer * - * @param Mage_Log_Model_Visitor $visitor - * @return Mage_Log_Model_Resource_Visitor + * @param Mage_Core_Model_Abstract|Mage_Log_Model_Visitor $visitor + * @return $this */ protected function _saveCustomerInfo($visitor) { @@ -272,8 +276,8 @@ protected function _saveCustomerInfo($visitor) /** * Saving information about quote * - * @param Mage_Log_Model_Visitor $visitor - * @return Mage_Log_Model_Resource_Visitor + * @param Mage_Core_Model_Abstract|Mage_Log_Model_Visitor $visitor + * @return $this */ protected function _saveQuoteInfo($visitor) { diff --git a/app/code/core/Mage/Log/Model/Resource/Visitor/Collection.php b/app/code/core/Mage/Log/Model/Resource/Visitor/Collection.php index ebbafb8eaab..f4ea25b9bf5 100644 --- a/app/code/core/Mage/Log/Model/Resource/Visitor/Collection.php +++ b/app/code/core/Mage/Log/Model/Resource/Visitor/Collection.php @@ -173,8 +173,7 @@ protected function _getGroupByDateFormat($type) */ protected function _getRangeByType($typeCode) { - switch ($typeCode) - { + switch ($typeCode) { case 'day': $range = 'DAY'; break; @@ -185,7 +184,6 @@ protected function _getRangeByType($typeCode) default: $range = 'MINUTE'; break; - } return $range; @@ -194,9 +192,7 @@ protected function _getRangeByType($typeCode) /** * Filter by customer ID, as 'type' field does not exist * - * @param string $fieldName - * @param array $condition - * @return $this + * @inheritDoc */ public function addFieldToFilter($fieldName, $condition = null) { @@ -219,7 +215,7 @@ public function addFieldToFilter($fieldName, $condition = null) */ protected function _getFieldMap($fieldName) { - if(isset($this->_fieldMap[$fieldName])) { + if (isset($this->_fieldMap[$fieldName])) { return $this->_fieldMap[$fieldName]; } else { return 'main_table.' . $fieldName; diff --git a/app/code/core/Mage/Log/Model/Resource/Visitor/Online.php b/app/code/core/Mage/Log/Model/Resource/Visitor/Online.php index be7f7a8735f..e8f54c83306 100644 --- a/app/code/core/Mage/Log/Model/Resource/Visitor/Online.php +++ b/app/code/core/Mage/Log/Model/Resource/Visitor/Online.php @@ -26,7 +26,7 @@ /** - * Log Prepare Online visitors resource + * Log Prepare Online visitors resource * * @category Mage * @package Mage_Log @@ -60,7 +60,7 @@ public function prepare(Mage_Log_Model_Visitor_Online $object) $writeAdapter->beginTransaction(); - try{ + try { $writeAdapter->delete($this->getMainTable()); $visitors = array(); @@ -73,7 +73,8 @@ public function prepare(Mage_Log_Model_Visitor_Online $object) $select = $readAdapter->select() ->from( $this->getTable('log/visitor'), - array('visitor_id', 'first_visit_at', 'last_visit_at', 'last_url_id')) + array('visitor_id', 'first_visit_at', 'last_visit_at', 'last_url_id') + ) ->where('last_visit_at >= ?', $readAdapter->formatDate($lastDate)); $query = $readAdapter->query($select); @@ -93,7 +94,8 @@ public function prepare(Mage_Log_Model_Visitor_Online $object) $select = $readAdapter->select() ->from( $this->getTable('log/visitor_info'), - array('visitor_id', 'remote_addr')) + array('visitor_id', 'remote_addr') + ) ->where('visitor_id IN(?)', array_keys($visitors)); $query = $readAdapter->query($select); @@ -105,7 +107,8 @@ public function prepare(Mage_Log_Model_Visitor_Online $object) $select = $readAdapter->select() ->from( $this->getTable('log/url_info_table'), - array('url_id', 'url')) + array('url_id', 'url') + ) ->where('url_id IN(?)', array_keys($lastUrls)); $query = $readAdapter->query($select); @@ -118,7 +121,8 @@ public function prepare(Mage_Log_Model_Visitor_Online $object) $select = $readAdapter->select() ->from( $this->getTable('log/customer'), - array('visitor_id', 'customer_id')) + array('visitor_id', 'customer_id') + ) ->where('visitor_id IN(?)', array_keys($visitors)); $query = $readAdapter->query($select); diff --git a/app/code/core/Mage/Log/Model/Resource/Visitor/Online/Collection.php b/app/code/core/Mage/Log/Model/Resource/Visitor/Online/Collection.php index 80ca3032a5e..eba7c0fe37a 100644 --- a/app/code/core/Mage/Log/Model/Resource/Visitor/Online/Collection.php +++ b/app/code/core/Mage/Log/Model/Resource/Visitor/Online/Collection.php @@ -68,7 +68,7 @@ public function addCustomerData() foreach ($attributes as $alias => $attributeCode) { $attribute = $customer->getAttribute($attributeCode); - /* @var $attribute Mage_Eav_Model_Entity_Attribute_Abstract */ + /* @var Mage_Eav_Model_Entity_Attribute_Abstract $attribute */ if ($attribute->getBackendType() == 'static') { $tableAlias = 'customer_' . $attribute->getAttributeCode(); @@ -80,8 +80,7 @@ public function addCustomerData() ); $this->_fields[$alias] = sprintf('%s.%s', $tableAlias, $attribute->getAttributeCode()); - } - else { + } else { $tableAlias = 'customer_' . $attribute->getAttributeCode(); $joinConds = array( @@ -126,11 +125,11 @@ public function addWebsiteFilter($websiteIds) * array('attribute'=>'lastname', 'like'=>'test%'), * ) * - * @see self::_getConditionSql for $condition - * * @param string $field * @param null|string|array $condition - * @return Mage_Eav_Model_Entity_Collection_Abstract + * @return Mage_Core_Model_Resource_Db_Collection_Abstract + * @see self::_getConditionSql for $condition + * */ public function addFieldToFilter($field, $condition = null) { diff --git a/app/code/core/Mage/Log/Model/Visitor.php b/app/code/core/Mage/Log/Model/Visitor.php index c3be27894d8..a46e60b6cc2 100644 --- a/app/code/core/Mage/Log/Model/Visitor.php +++ b/app/code/core/Mage/Log/Model/Visitor.php @@ -24,19 +24,44 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - /** * Enter description here ... * * @method Mage_Log_Model_Resource_Visitor getResource() - * @method string getSessionId() - * @method Mage_Log_Model_Visitor setSessionId(string $value) - * @method Mage_Log_Model_Visitor setFirstVisitAt(string $value) - * @method Mage_Log_Model_Visitor setLastVisitAt(string $value) + * @method int getCustomerId() + * @method $this setCustomerId(int $value) + * @method int getCustomerLogId() + * @method $this setCustomerLogId(int $value) + * @method bool getDoCustomerLogin() + * @method $this setDoCustomerLogin(bool $value) + * @method bool getDoCustomerLogout() + * @method $this setDoCustomerLogout(bool $value) + * @method bool getDoQuoteCreate() + * @method $this setDoQuoteCreate(bool $value) + * @method bool getDoQuoteDestroy() + * @method $this setDoQuoteDestroy(bool $value) + * @method $this setFirstVisitAt(string $value) + * @method string getHttpAcceptCharset() + * @method string getHttpAcceptLanguage() + * @method string getHttpHost() + * @method string getHttpReferer() + * @method string getHttpSecure() + * @method string getHttpUserAgent() + * @method bool getIsNewVisitor() + * @method $this setIsNewVisitor(bool $value) + * @method $this setLastVisitAt(string $value) * @method int getLastUrlId() - * @method Mage_Log_Model_Visitor setLastUrlId(int $value) + * @method $this setLastUrlId(int $value) + * @method int getQuoteId() + * @method $this setQuoteId(int $value) + * @method string getRemoteAddr() + * @method string getRequestUri() + * @method string getServerAddr() + * @method string getSessionId() + * @method $this setSessionId(string $value) * @method int getStoreId() - * @method Mage_Log_Model_Visitor setStoreId(int $value) + * @method $this setStoreId(int $value) + * @method int getVisitorId() * * @category Mage * @package Mage_Log @@ -70,6 +95,10 @@ class Mage_Log_Model_Visitor extends Mage_Core_Model_Abstract */ protected $_session; + /** + * Mage_Log_Model_Visitor constructor. + * @param array $data + */ public function __construct(array $data = array()) { $this->_httpHelper = !empty($data['http_helper']) ? $data['http_helper'] : Mage::helper('core/http'); @@ -158,6 +187,9 @@ public function getUrl() return $url; } + /** + * @return mixed + */ public function getFirstVisitAt() { if (!$this->hasData('first_visit_at')) { @@ -166,6 +198,9 @@ public function getFirstVisitAt() return $this->getData('first_visit_at'); } + /** + * @return mixed + */ public function getLastVisitAt() { if (!$this->hasData('last_visit_at')) { @@ -180,7 +215,7 @@ public function getLastVisitAt() * Used in event "controller_action_predispatch" * * @param Varien_Event_Observer $observer - * @return Mage_Log_Model_Visitor + * @return $this */ public function initByRequest($observer) { @@ -224,7 +259,7 @@ protected function _isVisitorSessionNew() * Used in event "controller_action_postdispatch" * * @param Varien_Event_Observer $observer - * @return Mage_Log_Model_Visitor + * @return $this */ public function saveByRequest($observer) { @@ -248,10 +283,11 @@ public function saveByRequest($observer) * Used in event "customer_login" * * @param Varien_Event_Observer $observer - * @return Mage_Log_Model_Visitor + * @return $this */ public function bindCustomerLogin($observer) { + /** @var Mage_Customer_Model_Customer $customer */ if ($customer = $observer->getEvent()->getCustomer()) { $this->setDoCustomerLogin(true); $this->setCustomerId($customer->getId()); @@ -265,7 +301,7 @@ public function bindCustomerLogin($observer) * Used in event "customer_logout" * * @param Varien_Event_Observer $observer - * @return Mage_Log_Model_Visitor + * @return $this */ public function bindCustomerLogout($observer) { @@ -275,8 +311,13 @@ public function bindCustomerLogout($observer) return $this; } + /** + * @param Varien_Event_Observer $observer + * @return $this + */ public function bindQuoteCreate($observer) { + /** @var Mage_Sales_Model_Quote $quote */ if ($quote = $observer->getEvent()->getQuote()) { if ($quote->getIsCheckoutCart()) { $this->setQuoteId($quote->getId()); @@ -286,8 +327,13 @@ public function bindQuoteCreate($observer) return $this; } + /** + * @param Varien_Event_Observer $observer + * @return $this + */ public function bindQuoteDestroy($observer) { + /** @var Mage_Sales_Model_Quote $quote */ if ($quote = $observer->getEvent()->getQuote()) { $this->setDoQuoteDestroy(true); } @@ -296,6 +342,8 @@ public function bindQuoteDestroy($observer) /** * Methods for research (depends from customer online admin section) + * @param Varien_Object $data + * @return $this */ public function addIpData($data) { @@ -304,15 +352,19 @@ public function addIpData($data) return $this; } + /** + * @param Varien_Object $data + * @return $this + */ public function addCustomerData($data) { $customerId = $data->getCustomerId(); - if( intval($customerId) <= 0 ) { + if (intval($customerId) <= 0) { return $this; } $customerData = Mage::getModel('customer/customer')->load($customerId); $newCustomerData = array(); - foreach( $customerData->getData() as $propName => $propValue ) { + foreach ($customerData->getData() as $propName => $propValue) { $newCustomerData['customer_' . $propName] = $propValue; } @@ -320,21 +372,29 @@ public function addCustomerData($data) return $this; } + /** + * @param Varien_Object $data + * @return $this + */ public function addQuoteData($data) { $quoteId = $data->getQuoteId(); - if( intval($quoteId) <= 0 ) { + if (intval($quoteId) <= 0) { return $this; } $data->setQuoteData(Mage::getModel('sales/quote')->load($quoteId)); return $this; } + /** + * @param Varien_Event_Observer $observer + * @return bool + */ public function isModuleIgnored($observer) { $ignores = $this->_config->getNode('global/ignoredModules/entities')->asArray(); - if( is_array($ignores) && $observer) { + if (is_array($ignores) && $observer) { $curModule = $observer->getEvent()->getControllerAction()->getRequest()->getRouteName(); if (isset($ignores[$curModule])) { return true; diff --git a/app/code/core/Mage/Log/Model/Visitor/Online.php b/app/code/core/Mage/Log/Model/Visitor/Online.php index 691edda39fc..3a80b33afd0 100644 --- a/app/code/core/Mage/Log/Model/Visitor/Online.php +++ b/app/code/core/Mage/Log/Model/Visitor/Online.php @@ -28,20 +28,19 @@ /** * Prepare Log Online Visitors Model * - * @method Mage_Log_Model_Resource_Visitor_Online _getResource() * @method Mage_Log_Model_Resource_Visitor_Online getResource() * @method string getVisitorType() - * @method Mage_Log_Model_Visitor_Online setVisitorType(string $value) + * @method $this setVisitorType(string $value) * @method int getRemoteAddr() - * @method Mage_Log_Model_Visitor_Online setRemoteAddr(int $value) + * @method $this setRemoteAddr(int $value) * @method string getFirstVisitAt() - * @method Mage_Log_Model_Visitor_Online setFirstVisitAt(string $value) + * @method $this setFirstVisitAt(string $value) * @method string getLastVisitAt() - * @method Mage_Log_Model_Visitor_Online setLastVisitAt(string $value) + * @method $this setLastVisitAt(string $value) * @method int getCustomerId() - * @method Mage_Log_Model_Visitor_Online setCustomerId(int $value) + * @method $this setCustomerId(int $value) * @method string getLastUrl() - * @method Mage_Log_Model_Visitor_Online setLastUrl(string $value) + * @method $this setLastUrl(string $value) * * @category Mage * @package Mage_Log @@ -64,7 +63,7 @@ protected function _construct() /** * Retrieve resource instance wrapper * - * @return Mage_Log_Model_Mysql4_Visitor_Online + * @inheritDoc */ protected function _getResource() { @@ -96,7 +95,7 @@ public function getPrepareAt() * Set Prepare at timestamp (if time is null, set current timestamp) * * @param int $time - * @return Mage_Log_Model_Mysql4_Visitor_Online + * @return $this */ public function setPrepareAt($time = null) { diff --git a/app/code/core/Mage/Log/data/log_setup/data-install-1.6.0.0.php b/app/code/core/Mage/Log/data/log_setup/data-install-1.6.0.0.php index 0c6055a0f74..344d692c230 100644 --- a/app/code/core/Mage/Log/data/log_setup/data-install-1.6.0.0.php +++ b/app/code/core/Mage/Log/data/log_setup/data-install-1.6.0.0.php @@ -25,7 +25,7 @@ */ $installer = $this; -/* @var $installer Mage_Core_Model_Resource_Setup */ +/* @var Mage_Core_Model_Resource_Setup $installer */ $data = array( array( diff --git a/app/code/core/Mage/Log/sql/log_setup/install-1.6.0.0.php b/app/code/core/Mage/Log/sql/log_setup/install-1.6.0.0.php index ad4956a933c..0f2840bc71d 100644 --- a/app/code/core/Mage/Log/sql/log_setup/install-1.6.0.0.php +++ b/app/code/core/Mage/Log/sql/log_setup/install-1.6.0.0.php @@ -25,7 +25,7 @@ */ $installer = $this; -/* @var $installer Mage_Core_Model_Resource_Setup */ +/* @var Mage_Core_Model_Resource_Setup $installer */ $installer->startSetup(); @@ -56,8 +56,10 @@ 'unsigned' => true, 'nullable' => false, ), 'Store ID') - ->addIndex($installer->getIdxName('log/customer', array('visitor_id')), - array('visitor_id')) + ->addIndex( + $installer->getIdxName('log/customer', array('visitor_id')), + array('visitor_id') + ) ->setComment('Log Customers Table'); $installer->getConnection()->createTable($table); @@ -159,8 +161,10 @@ ->addColumn('visit_time', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array( 'nullable' => false, ), 'Visit Time') - ->addIndex($installer->getIdxName('log/url_table', array('visitor_id')), - array('visitor_id')) + ->addIndex( + $installer->getIdxName('log/url_table', array('visitor_id')), + array('visitor_id') + ) ->setComment('Log URL Table'); $installer->getConnection()->createTable($table); @@ -268,12 +272,18 @@ ), 'Customer ID') ->addColumn('last_url', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array( ), 'Last URL') - ->addIndex($installer->getIdxName('log/visitor_online', array('visitor_type')), - array('visitor_type')) - ->addIndex($installer->getIdxName('log/visitor_online', array('first_visit_at', 'last_visit_at')), - array('first_visit_at', 'last_visit_at')) - ->addIndex($installer->getIdxName('log/visitor_online', array('customer_id')), - array('customer_id')) + ->addIndex( + $installer->getIdxName('log/visitor_online', array('visitor_type')), + array('visitor_type') + ) + ->addIndex( + $installer->getIdxName('log/visitor_online', array('first_visit_at', 'last_visit_at')), + array('first_visit_at', 'last_visit_at') + ) + ->addIndex( + $installer->getIdxName('log/visitor_online', array('customer_id')), + array('customer_id') + ) ->setComment('Log Visitor Online Table'); $installer->getConnection()->createTable($table); diff --git a/app/code/core/Mage/Log/sql/log_setup/mysql4-install-0.7.0.php b/app/code/core/Mage/Log/sql/log_setup/mysql4-install-0.7.0.php index 999638e0ab6..7ddfdf0907b 100644 --- a/app/code/core/Mage/Log/sql/log_setup/mysql4-install-0.7.0.php +++ b/app/code/core/Mage/Log/sql/log_setup/mysql4-install-0.7.0.php @@ -25,7 +25,7 @@ */ $installer = $this; -/* @var $installer Mage_Core_Model_Resource_Setup */ +/* @var Mage_Core_Model_Resource_Setup $installer */ $installer->startSetup(); diff --git a/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-0.7.3-0.7.4.php b/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-0.7.3-0.7.4.php index 56035bf69d0..d6abd3490bc 100644 --- a/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-0.7.3-0.7.4.php +++ b/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-0.7.3-0.7.4.php @@ -26,7 +26,7 @@ $installer = $this; -/* @var $installer Mage_Core_Model_Resource_Setup */ +/* @var Mage_Core_Model_Resource_Setup $installer */ $installer->startSetup(); $installer->getConnection()->addKey($installer->getTable('log/customer'), 'IDX_VISITOR', 'visitor_id'); diff --git a/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-0.7.4-0.7.5.php b/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-0.7.4-0.7.5.php index 732f0909a80..f2fc58b515e 100644 --- a/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-0.7.4-0.7.5.php +++ b/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-0.7.4-0.7.5.php @@ -26,7 +26,7 @@ $installer = $this; -/* @var $installer Mage_Core_Model_Resource_Setup */ +/* @var Mage_Core_Model_Resource_Setup $installer */ $installer->startSetup(); $installer->run(" diff --git a/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-0.7.5-0.7.6.php b/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-0.7.5-0.7.6.php index 1193a170058..a049ebcf978 100644 --- a/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-0.7.5-0.7.6.php +++ b/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-0.7.5-0.7.6.php @@ -26,7 +26,7 @@ $installer = $this; -/* @var $installer Mage_Core_Model_Resource_Setup */ +/* @var Mage_Core_Model_Resource_Setup $installer */ $installer->startSetup(); $installer->getConnection()->modifyColumn($installer->getTable('log/visitor_online'), 'remote_addr', 'bigint(20) NOT NULL'); diff --git a/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-0.7.6-0.7.7.php b/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-0.7.6-0.7.7.php index 67dfbc65af3..0ecd0f563d8 100644 --- a/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-0.7.6-0.7.7.php +++ b/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-0.7.6-0.7.7.php @@ -24,7 +24,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/* @var $installer Mage_Core_Model_Resource_Setup */ +/* @var Mage_Core_Model_Resource_Setup $installer */ $installer = $this; $installer->startSetup(); diff --git a/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php b/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php index b1621d0dd02..7514daae2d0 100644 --- a/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php +++ b/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php @@ -24,7 +24,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/* @var $installer Mage_Core_Model_Resource_Setup */ +/* @var Mage_Core_Model_Resource_Setup $installer */ $installer = $this; $installer->startSetup(); diff --git a/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-1.6.0.0-1.6.1.0.php b/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-1.6.0.0-1.6.1.0.php index a4bf456c857..5c24c728df2 100644 --- a/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-1.6.0.0-1.6.1.0.php +++ b/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-1.6.0.0-1.6.1.0.php @@ -24,7 +24,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/* @var $installer Mage_Core_Model_Resource_Setup */ +/* @var Mage_Core_Model_Resource_Setup $installer */ $installer = $this; $installer->startSetup(); @@ -32,4 +32,3 @@ $installer->getConnection()->addIndex($installer->getTable('log/url_table'), 'url_id', array('url_id')); $installer->endSetup(); - diff --git a/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-1.6.1.0-1.6.1.1.php b/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-1.6.1.0-1.6.1.1.php index 3eb3e849479..d87df3a6ea4 100644 --- a/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-1.6.1.0-1.6.1.1.php +++ b/app/code/core/Mage/Log/sql/log_setup/mysql4-upgrade-1.6.1.0-1.6.1.1.php @@ -24,7 +24,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/* @var $installer Mage_Core_Model_Resource_Setup */ +/* @var Mage_Core_Model_Resource_Setup $installer */ $installer = $this; $installer->startSetup();