Author: radek.qo
Date: 2010-05-04 23:32:17 +0200 (Tue, 04 May 2010)
New Revision: 29349

Modified:
   
plugins/sfWhoIsOnlinePlugin/branches/1.0/lib/model/doctrine/PluginsfWhoIsOnlineUser.class.php
   
plugins/sfWhoIsOnlinePlugin/branches/1.0/lib/sfWhoIsOnlineUserFacade.class.php
Log:
[1.0] added some basic comments to code

Modified: 
plugins/sfWhoIsOnlinePlugin/branches/1.0/lib/model/doctrine/PluginsfWhoIsOnlineUser.class.php
===================================================================
--- 
plugins/sfWhoIsOnlinePlugin/branches/1.0/lib/model/doctrine/PluginsfWhoIsOnlineUser.class.php
       2010-05-04 18:45:16 UTC (rev 29348)
+++ 
plugins/sfWhoIsOnlinePlugin/branches/1.0/lib/model/doctrine/PluginsfWhoIsOnlineUser.class.php
       2010-05-04 21:32:17 UTC (rev 29349)
@@ -3,21 +3,24 @@
 /**
  * PluginsfWhoIsOnlineUser
  *
- * This class has been auto-generated by the Doctrine ORM Framework
- *
- * @package    ##PACKAGE##
- * @subpackage ##SUBPACKAGE##
- * @author     ##NAME## <##EMAIL##>
- * @version    SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
+ * @author     [email protected]
  */
 abstract class PluginsfWhoIsOnlineUser extends BasesfWhoIsOnlineUser
 {
+       /**
+        * Populates location variables from array got Geobyte IPLocator service
+        * @param unknown_type $tags
+        */
        public function fromTags($tags)
        {
                $this->city = $tags["city"];
                $this->country = $tags["country"];
                $this->countrycode = $tags["iso2"];
        }
+       /**
+        * Populates location variables from XML got by HostIP
+        * @param SimpleXmlElement $xml
+        */
        public function fromXml(SimpleXmlElement $xml)
        {
                $city = $xml->xpath('//gml:name');
@@ -34,6 +37,9 @@
                $this->country = $countryName;
                $this->countrycode = $countryAbbrev;
        }
+       /**
+        * Overrides parents save method. It saves current timestamp.
+        */
        public function save(Doctrine_Connection $conn = null)
        {
                $b = @get_browser(null,true);

Modified: 
plugins/sfWhoIsOnlinePlugin/branches/1.0/lib/sfWhoIsOnlineUserFacade.class.php
===================================================================
--- 
plugins/sfWhoIsOnlinePlugin/branches/1.0/lib/sfWhoIsOnlineUserFacade.class.php  
    2010-05-04 18:45:16 UTC (rev 29348)
+++ 
plugins/sfWhoIsOnlinePlugin/branches/1.0/lib/sfWhoIsOnlineUserFacade.class.php  
    2010-05-04 21:32:17 UTC (rev 29349)
@@ -1,5 +1,20 @@
 <?php
+/**
+ * Facade which represents whole "who is online" API
+ * @author [email protected]
+ * @version 0.9
+ */
 class sfWhoIsOnlineUserFacade {
+       /**
+        * Register user's IP address to database and locates his position.
+        * You may implement your own getIp() method in myUser class
+        * if you wish to use another algorithm for getting IP.
+        * 
+        * Parameter name is get by getName() method (called on sfUser),
+        * if not implemented it takes IP as name.
+        * 
+        * @param sfUser $sfUser
+        */
        public static function registerUser(sfUser $sfUser)
        {
                if(method_exists($sfUser,"getIp")) {
@@ -13,27 +28,32 @@
                if($instance == null) {
                        $instance = new sfWhoIsOnlineUser();
                        $instance->ip = $ip;
+               
+                       $tags = 
get_meta_tags('http://www.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress='.$ip);
+                       if(@$tags["known"] == "true") {
+                               $instance->fromTags($tags);
+                       } else {
+                               // Making an API call to Hostip:
+                       $xmlString = 
file_get_contents('http://api.hostip.info/?ip='.$ip);
+                       $xml = new SimpleXMLElement($xmlString);
+                       $instance->fromXml($xml);
+                       }
                }
-
-               $tags = 
get_meta_tags('http://www.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress='.$ip);
-               if($tags["known"] == "true") {
-                       $instance->fromTags($tags);
-               } else {
-                       // Making an API call to Hostip:
-               $xmlString = 
file_get_contents('http://api.hostip.info/?ip='.$ip);
-               $xml = new SimpleXMLElement($xmlString);
-               $instance->fromXml($xml);
-               }
-        
+               
                if(method_exists($sfUser,"getName")) {
                        $ip = $sfUser->getName();
                } else {
                        $name = $ip;
                }
+               
         $instance->name = $name;
         
         $instance->save();
        }
+       /**
+        * Get IP address of current user. You may implement your own getIp() 
method in myUser class
+        * @return string IPAddress
+        */
        private static function getIp()
        {
                if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to