http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88744

Revision: 88744
Author:   jeroendedauw
Date:     2011-05-24 20:17:26 +0000 (Tue, 24 May 2011)
Log Message:
-----------
changes to hold into account a single edit can have multiple sets of changes 
when there are more then one matching watchlist groups

Modified Paths:
--------------
    trunk/extensions/SemanticWatchlist/SemanticWatchlist.hooks.php
    trunk/extensions/SemanticWatchlist/SemanticWatchlist.php
    trunk/extensions/SemanticWatchlist/SemanticWatchlist.sql
    trunk/extensions/SemanticWatchlist/api/ApiQuerySemanticWatchlist.php
    trunk/extensions/SemanticWatchlist/includes/SWL_ChangeSet.php
    trunk/extensions/SemanticWatchlist/includes/SWL_Group.php
    trunk/extensions/SemanticWatchlist/specials/SpecialSemanticWatchlist.php

Added Paths:
-----------
    trunk/extensions/SemanticWatchlist/includes/SWL_Edit.php

Modified: trunk/extensions/SemanticWatchlist/SemanticWatchlist.hooks.php
===================================================================
--- trunk/extensions/SemanticWatchlist/SemanticWatchlist.hooks.php      
2011-05-24 20:16:55 UTC (rev 88743)
+++ trunk/extensions/SemanticWatchlist/SemanticWatchlist.hooks.php      
2011-05-24 20:17:26 UTC (rev 88744)
@@ -25,17 +25,36 @@
      * @return true
      */
        public static function onDataUpdate( SMWStore $store, SMWSemanticData 
$newData ) {
-               $changeSet = SWLChangeSet::newFromSemanticData( 
$store->getSemanticData( $newData->getSubject() ), $newData );
-               $groups = SWLGroups::getMatchingWatchGroups( 
$changeSet->getTitle() );
+               $subject = $newData->getSubject();
+               $oldData = $store->getSemanticData( $subject );
+               $title = Title::makeTitle( $subject->getNamespace(), 
$subject->getDBkey() );
                
-               $wasInserted = $changes->writeToStore( $groups ) != 0;
+               $groups = SWLGroups::getMatchingWatchGroups( $title );
                
-               if ( $wasInserted ) {
-               foreach ( $groups as /* SWLGroup */ $group ) {
-                       $group->notifyWatchingUsers( $changes );
-               }                       
+               $edit = false;
+               
+               foreach ( $groups as /* SWLGroup */ $group ) {
+                       $changeSet = SWLChangeSet::newFromSemanticData( 
$oldData, $newData, $group->getProperties() );
+                       
+                       if ( $changeSet->hasUserDefinedProperties() ) {
+                               if ( $edit === false ) {
+                                       $edit = new SWLEdit(
+                                               $title->getArticleID(), 
+                                               $GLOBALS['wgUser'],
+                                               wfTimestampNow()
+                                       );
+                                       
+                                       $edit->writeToDB();
+                               }
+                               
+                               $setId = $changeSet->writeToStore( $groups, 
$edit->getId() );
+                               
+                               if ( $setId != 0 ) {
+                                       $group->notifyWatchingUsers( $changeSet 
);
+                               }       
+                       }
                }
-
+               
                return true;
        }
 

Modified: trunk/extensions/SemanticWatchlist/SemanticWatchlist.php
===================================================================
--- trunk/extensions/SemanticWatchlist/SemanticWatchlist.php    2011-05-24 
20:16:55 UTC (rev 88743)
+++ trunk/extensions/SemanticWatchlist/SemanticWatchlist.php    2011-05-24 
20:17:26 UTC (rev 88744)
@@ -63,6 +63,7 @@
 $wgAutoloadClasses['ApiQuerySemanticWatchlist']                = dirname( 
__FILE__ ) . '/api/ApiQuerySemanticWatchlist.php';
 
 $wgAutoloadClasses['SWLChangeSet']                                     = 
dirname( __FILE__ ) . '/includes/SWL_ChangeSet.php';
+$wgAutoloadClasses['SWLEdit']                                          = 
dirname( __FILE__ ) . '/includes/SWL_Edit.php';
 $wgAutoloadClasses['SWLEmailer']                                       = 
dirname( __FILE__ ) . '/includes/SWL_Emailer.php';
 $wgAutoloadClasses['SWLGroup']                                         = 
dirname( __FILE__ ) . '/includes/SWL_Group.php';
 $wgAutoloadClasses['SWLGroups']                                                
= dirname( __FILE__ ) . '/includes/SWL_Groups.php';

Modified: trunk/extensions/SemanticWatchlist/SemanticWatchlist.sql
===================================================================
--- trunk/extensions/SemanticWatchlist/SemanticWatchlist.sql    2011-05-24 
20:16:55 UTC (rev 88743)
+++ trunk/extensions/SemanticWatchlist/SemanticWatchlist.sql    2011-05-24 
20:17:26 UTC (rev 88744)
@@ -14,7 +14,7 @@
   group_concepts           BLOB                NOT NULL -- Concept names
 ) /*$wgDBTableOptions*/;
 
--- List of all changes made to properties.
+-- Single value changes to a property.
 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/swl_changes (
   change_id                INT(10) unsigned    NOT NULL auto_increment PRIMARY 
KEY,
   change_set_id            INT(10) unsigned    NOT NULL, -- Foreign key: 
swl_sets.set_id
@@ -31,6 +31,11 @@
   edit_time                CHAR(14) binary     NOT NULL default '' -- The time 
the chages where made  
 ) /*$wgDBTableOptions*/;
 
+-- Sets of changes. There can be many such sets for one edit, with overlapping 
changes.
+CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/swl_sets (
+  set_id                   INT(10) unsigned    NOT NULL auto_increment PRIMARY 
KEY
+) /*$wgDBTableOptions*/;
+
 -- Links change sets their edits.
 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/swl_sets_per_edit (
   spe_set_id               SMALLINT unsigned   NOT NULL, -- Foreign key: 
swl_sets.set_id

Modified: trunk/extensions/SemanticWatchlist/api/ApiQuerySemanticWatchlist.php
===================================================================
--- trunk/extensions/SemanticWatchlist/api/ApiQuerySemanticWatchlist.php        
2011-05-24 20:16:55 UTC (rev 88743)
+++ trunk/extensions/SemanticWatchlist/api/ApiQuerySemanticWatchlist.php        
2011-05-24 20:17:26 UTC (rev 88744)
@@ -65,18 +65,20 @@
         * @param string $continue
         */
        protected function setupChangeSetQuery( $userId, $limit, $continue ) {
-               $this->addTables( array( 'swl_sets', 'swl_sets_per_group', 
'swl_users_per_group' ) );
+               $this->addTables( array( 'swl_edits', 'swl_sets_per_edit', 
'swl_sets_per_group', 'swl_users_per_group' ) );
 
                $this->addJoinConds( array(
-                       'swl_sets_per_group' => array( 'INNER JOIN', array( 
'set_id=spg_set_id' ) ),
+                       'swl_sets_per_edit' => array( 'INNER JOIN', array( 
'edit_id=spe_edit_id' ) ),
+                       'swl_sets_per_group' => array( 'INNER JOIN', array( 
'spe_set_id=spg_set_id' ) ),
                        'swl_users_per_group' => array( 'INNER JOIN', array( 
'spg_group_id=upg_group_id' ) ),
-               ) );            
+               ) );
                
                $this->addFields( array(
-               'set_id',
-               'set_user_name',
-               'set_page_id',
-               'set_time',
+               'spe_set_id',
+               'edit_user_name',
+               'edit_page_id',
+               'edit_time',
+                       'edit_id'
                ) );
                
                $this->addWhere( array(
@@ -85,15 +87,15 @@
                
                $this->addOption( 'DISTINCT' );
                $this->addOption( 'LIMIT', $limit + 1 );
-               $this->addOption( 'ORDER BY', 'set_time DESC, set_id DESC' );
+               $this->addOption( 'ORDER BY', 'edit_time DESC, spe_set_id DESC' 
);
                
                if ( !is_null( $continue ) ) {
                        $continueParams = explode( '-', $continue );
                        
                        if ( count( $continueParams ) == 2 ) {
                                $dbr = wfGetDB( DB_SLAVE );
-                               $this->addWhere( 'set_time <= ' . 
$dbr->addQuotes( $continueParams[0] ) );
-                               $this->addWhere( 'set_id <= ' . 
$dbr->addQuotes( $continueParams[1] ) );                                        
+                               $this->addWhere( 'edit_time <= ' . 
$dbr->addQuotes( $continueParams[0] ) );
+                               $this->addWhere( 'spe_set_id <= ' . 
$dbr->addQuotes( $continueParams[1] ) );                                    
                        }
                        else {
                                // TODO: error

Modified: trunk/extensions/SemanticWatchlist/includes/SWL_ChangeSet.php
===================================================================
--- trunk/extensions/SemanticWatchlist/includes/SWL_ChangeSet.php       
2011-05-24 20:16:55 UTC (rev 88743)
+++ trunk/extensions/SemanticWatchlist/includes/SWL_ChangeSet.php       
2011-05-24 20:17:26 UTC (rev 88744)
@@ -1,9 +1,8 @@
 <?php
 
 /**
- * Wrapper around SMWChangeSet that holds extra info such as user and time,
- * and has methods for (un)serialization and database interaction. 
  * 
+ * 
  * @since 0.1
  * 
  * @file SWL_ChangeSet.php
@@ -43,20 +42,6 @@
        protected $changes;
        
        /**
-        * The user that made the changes.
-        * 
-        * @var User
-        */
-       protected $user;
-       
-       /**
-        * The time on which the changes where made.
-        * 
-        * @var integer
-        */
-       protected $time;
-       
-       /**
         * DB ID of the change set (swl_sets.set_id).
         * 
         * @var integer
@@ -74,6 +59,13 @@
        protected $title = false;
        
        /**
+        * The edit this set of changes belongs to.
+        * 
+        * @var SWLEdit
+        */
+       protected $edit;
+       
+       /**
         * Creates and returns a new SWLChangeSet instance from a database 
result
         * obtained by doing a select on swl_sets. 
         * 
@@ -83,9 +75,19 @@
         * 
         * @return SWLChangeSet
         */
-       public static function newFromDBResult( $set ) {                
-               $changeSet = new SMWChangeSet(
-                       SMWDIWikiPage::newFromTitle( Title::newFromID( 
$set->set_page_id ) )
+       public static function newFromDBResult( $set ) {
+               $changeSet = new SWLChangeSet(
+                       SMWDIWikiPage::newFromTitle( Title::newFromID( 
$set->edit_page_id ) ),
+                       null,
+                       null,
+                       null,
+                       $set->spe_set_id,
+                       new SWLEdit(
+                               $set->edit_page_id,
+                               $set->edit_user_name,
+                               $set->edit_time,
+                               $set->edit_id
+                       )
                );
                
                $dbr = wfGetDb( DB_SLAVE );
@@ -99,7 +101,7 @@
                                'change_new_value'
                        ),
                        array(
-                               'change_set_id' => $set->set_id
+                               'change_set_id' => $set->spe_set_id
                        )
                );
                
@@ -112,13 +114,6 @@
                        );
                }       
                
-               $changeSet = new SWLChangeSet(
-                       $changeSet,
-                       User::newFromName( $set->set_user_name, false ),
-                       $set->set_time,
-                       $set->set_id
-               );
-               
                return $changeSet;
        }
        
@@ -133,10 +128,20 @@
         * @return SWLChangeSet
         */
        public static function newFromArray( array $changeSetArray ) {
-               $changeSet = new SMWChangeSet(
-                       SMWDIWikiPage::newFromTitle( Title::newFromID( 
$changeSetArray['page_id'] ) )
+               $changeSet = new SWLChangeSet(
+                       SMWDIWikiPage::newFromTitle( Title::newFromID( 
$changeSetArray['page_id'] ) ),
+                       null,
+                       null,
+                       null,
+                       $changeSetArray['id'],
+                       new SWLEdit(
+                               $changeSetArray['page_id'],
+                               $changeSetArray['user_name'],
+                               $changeSetArray['time'],
+                               $changeSetArray['editid']
+                       )
                );
-               
+
                foreach ( $changeSetArray['changes'] as $propName => $changes ) 
{
                        $property = SMWDIProperty::doUnserialize( $propName, 
'__pro' );
 
@@ -150,14 +155,7 @@
                                        )
                                );                                      
                        }
-               }
-               
-               $changeSet = new SWLChangeSet(
-                       $changeSet,
-                       User::newFromName( $changeSetArray['user_name'], false 
),
-                       $changeSetArray['time'],
-                       $changeSetArray['id']
-               );              
+               }               
 
                return $changeSet;
        }
@@ -167,10 +165,11 @@
         * 
         * @param SMWSemanticData $old
         * @param SMWSemanticData $new
+        * @param array $filterProperties Optional list of properties (string 
serializations) to filter on. Null for no filtering.
         * 
         * @return SMWChangeSet
         */
-       public static function newFromSemanticData( SMWSemanticData $old, 
SMWSemanticData $new ) {
+       public static function newFromSemanticData( SMWSemanticData $old, 
SMWSemanticData $new, array $filterProperties = null ) {
                $subject = $old->getSubject();
                
                if ( $subject != $new->getSubject() ) {
@@ -181,14 +180,26 @@
                $insertions = new SMWSemanticData( $subject );
                $deletions = new SMWSemanticData( $subject );
                
-               $oldProperties = $old->getProperties();
-               $newProperties = $new->getProperties();
+               $oldProperties = array();
+               $newProperties = array();
                
+               foreach ( $old->getProperties() as $property ) {
+                       if ( is_null( $filterProperties ) || in_array( 
$property->getLabel(), $filterProperties ) ) {
+                               $oldProperties[] = $property;
+                       }
+               }
+               
+               foreach ( $new->getProperties() as $property ) {
+                       if ( is_null( $filterProperties ) || in_array( 
$property->getLabel(), $filterProperties ) ) {
+                               $newProperties[] = $property;
+                       }
+               }
+               
                // Find the deletions.
-               self::findSingleDirectionChanges( $deletions, $oldProperties, 
$old, $newProperties );
+               self::findSingleDirectionChanges( $deletions, $oldProperties, 
$old, $newProperties, $filterProperties );
                
                // Find the insertions.
-               self::findSingleDirectionChanges( $insertions, $newProperties, 
$new, $oldProperties );
+               self::findSingleDirectionChanges( $insertions, $newProperties, 
$new, $oldProperties, $filterProperties );
                
                foreach ( $oldProperties as $propertyKey => /* SMWDIProperty */ 
$diProperty ) {
                        $oldDataItems = array();
@@ -254,7 +265,7 @@
         */
        protected static function findSingleDirectionChanges( SMWSemanticData 
&$changeSet,
                array &$oldProperties, SMWSemanticData $oldData, array 
$newProperties ) {
-                       
+               
                $deletionKeys = array();
                
                foreach ( $oldProperties as $propertyKey => /* SMWDIProperty */ 
$diProperty ) {
@@ -278,32 +289,52 @@
         * @param SWLPropertyChanges $changes Can be null
         * @param SMWSemanticData $insertions Can be null
         * @param SMWSemanticData $deletions Can be null
+        * @param integer $id Can be null
+        * @param SWLEdit $edit Can be null
         */
        public function __construct( SMWDIWikiPage $subject, /* 
SWLPropertyChanges */ $changes = null,
                /* SMWSemanticData */ $insertions = null, /* SMWSemanticData */ 
$deletions = null,
-               /* User */ $user = null, $time = null, $id = null ) {
+               $id = null, /* SWLEdit */ $edit = null ) {
        
                $this->subject = $subject;
                $this->changes = is_null( $changes ) ? new SWLPropertyChanges() 
: $changes;
                $this->insertions = is_null( $insertions ) ? new 
SMWSemanticData( $subject ): $insertions;
                $this->deletions = is_null( $deletions ) ? new SMWSemanticData( 
$subject ): $deletions;
                
-               $this->time = is_null( $time ) ? wfTimestampNow() : $time;
-               $this->user = is_null( $user ) ? $GLOBALS['wgUser'] : $user;
                $this->id = $id;
+               $this->edit = $edit;
        }
        
        /**
+        * Rteurns if the change set contains (changes for) user defined 
properties.
+        * 
+        * @since 0.1
+        * 
+        * @return boolean
+        */
+       public function hasUserDefinedProperties() {
+               $properties = array();
+               
+               foreach ( $this->getAllProperties() as /* SMWDIProperty */ 
$property ) {
+                       if ( $property->isUserDefined() ) {
+                               $properties[] = $property;
+                       }
+               }
+               
+               return count( $properties ) != 0;
+       }
+       
+       /**
         * Returns whether the set contains any changes.
         * 
-        * @param boolean $refresh
+        * @since 0.1
         * 
         * @return boolean
         */
-       public function hasChanges( $refresh = false ) {
+       public function hasChanges() {
                return $this->changes->hasChanges()
-                       || $this->insertions->hasVisibleProperties( $refresh )
-                       || $this->deletions->hasVisibleProperties( $refresh );
+                       || $this->insertions->hasVisibleProperties()
+                       || $this->deletions->hasVisibleProperties();
        }
        
        /**
@@ -422,9 +453,10 @@
        public function toArray() {
                $changeSet = array(
                        'id' => $this->id,
-                       'user_name' => $this->user->getName(),
-                       'page_id' => $this->getTitle()->getArticleID(),
-                       'time' => $this->time,
+                       'user_name' => $this->edit->getUserName(),
+                       'page_id' => $this->edit->getPageID(),
+                       'time' => $this->edit->getTime(),
+                       'editid' => $this->edit->getId(),
                        'changes' => array()
                );
                
@@ -457,20 +489,12 @@
         * @since 0.1
         * 
         * @param array of SWLGroup
+        * @param integer $editId
         * 
         * @return integer ID of the inserted row (0 if nothing was inserted).
         */
-       public function writeToStore( array $groupsToAssociate ) {
-               $properties = array();
-               
-               foreach ( $this->getAllProperties() as /* SMWDIProperty */ 
$property ) {
-                       if ( $property->isUserDefined() ) {
-                               $properties[] = $property;
-                       }
-               }
-               
-               // If there are no changed user properties, don't insert a new 
entry. 
-               if ( count( $properties ) == 0 ) {
+       public function writeToStore( array $groupsToAssociate, $editId ) {
+               if ( !$this->hasUserDefinedProperties() ) {
                        return 0;
                }
                
@@ -478,18 +502,22 @@
                
                $dbw->insert(
                        'swl_sets',
-                       array(
-                               'set_user_name' => $this->getUser()->getName(),
-                               'set_page_id' => 
$this->getTitle()->getArticleID(),
-                               'set_time' => is_null( $this->getTime() ) ? 
$dbw->timestamp() : $this->getTime() 
-                       )
+                       array()
                );
                
                $id = $dbw->insertId();
                
+               $dbw->insert(
+                       'swl_sets_per_edit',
+                       array(
+                               'spe_set_id' => $id,
+                               'spe_edit_id' => $editId
+                       )
+               );
+               
                $changes = array();
                
-               foreach ( $properties as /* SMWDIProperty */ $property ) {
+               foreach ( $this->getAllProperties() as /* SMWDIProperty */ 
$property ) {
                        if ( $property->isUserDefined() ) {
                                $propSerialization = 
$property->getSerialization();
                        
@@ -554,6 +582,8 @@
        /**
         * Gets the title of the page these changes belong to.
         * 
+        * @since 0.1
+        * 
         * @return Title
         */
        public function getTitle() {
@@ -565,55 +595,14 @@
        }
        
        /**
-        * Sets the user that made the changes.
+        * Gets the edit this set of changes belong to.
         * 
-        * @param User $user
-        */
-       public function setUser( User $user ) {
-               $this->user = $user;
-       }
-       
-       /**
-        * Gets the user that made the changes.
-        * 
-        * @return User
-        */
-       public function getUser() {
-               return $this->user;
-       }
-       
-       /**
-        * Sets the time on which the changes where made.
-        * 
-        * @param integer $time
-        */
-       public function setTime( $time ) {
-               $this->time = $time;
-       }
-       
-       /**
-        * Gets the time on which the changes where made.
-        * 
-        * @return integer
-        */
-       public function getTime() {
-               return $this->time;
-       }
-       
-       /**
-        * Remove changes to properties not in the porvided list.
-        * 
         * @since 0.1
         * 
-        * @param array $properties List of property names
+        * @return SWLEdit
         */
-       public function filterOnProperties( array $properties ) {
-               // TODO
-               foreach ( $this->getAllProperties() as /* SMWDIProperty */ 
$property ) {
-                       if ( !in_array( $property->getSerialization(), 
$properties ) ) {
-                               //$this->changeSet->removeChangesForProperty( 
$property );
-                       }
-               }
+       public function getEdit() {
+               return $this->edit;
        }
        
 }
\ No newline at end of file

Added: trunk/extensions/SemanticWatchlist/includes/SWL_Edit.php
===================================================================
--- trunk/extensions/SemanticWatchlist/includes/SWL_Edit.php                    
        (rev 0)
+++ trunk/extensions/SemanticWatchlist/includes/SWL_Edit.php    2011-05-24 
20:17:26 UTC (rev 88744)
@@ -0,0 +1,237 @@
+<?php
+
+/**
+ * 
+ * 
+ * @since 0.1
+ * 
+ * @file SWL_Edit.php
+ * @ingroup SemanticWatchlist
+ * 
+ * @licence GNU GPL v3 or later
+ * @author Jeroen De Dauw < [email protected] >
+ */
+class SWLEdit {
+       
+       /**
+        * The ID of the page the edit was made to.
+        * 
+        * @var integer
+        */
+       protected $pageId;
+       
+       /**
+        * The name of the user that made the edit.
+        * 
+        * @var string
+        */
+       protected $userName;
+       
+       /**
+        * The user that made the changes.
+        * 
+        * @var User or false
+        */
+       protected $user = false;
+       
+       /**
+        * The time on which the edit was made.
+        * 
+        * @var integer
+        */
+       protected $time;
+       
+       /**
+        * DB ID of the edit (swl_edits.edit_id).
+        * 
+        * @var integer
+        */
+       protected $id;
+       
+       /**
+        * Creates and returns a new instance of SWLEdit by getting it's info 
from the database.
+        * 
+        * @since 0.1 
+        * 
+        * @param integer $id
+        * 
+        * @return SWLEdit
+        */
+       public static function newFromId( $id ) {
+               $dbr = wfGetDB( DB_SLAVE );
+               
+               return self::newFromDBResult( $dbr->select(
+                       'swl_edits',
+                       array(
+                               'edit_id',
+                               'edit_user_name',
+                               'edit_page_id',
+                               'edit_time'
+                       ),
+                       array( 'edit_id' => $id )
+               ) );
+       }
+       
+       /**
+        * Creates and returns a new instance of SWLEdit from a database result.
+        * 
+        * @since 0.1 
+        * 
+        * @param ResultWrapper $edit
+        * 
+        * @return SWLEdit
+        */
+       public static function newFromDBResult( $edit ) {
+               return new self(
+                       $edit->edit_page_id,
+                       $edit->edit_user_name,
+                       $edit->edit_time,
+                       $edit->edit_id
+               );
+       }
+       
+       /**
+        * Constructor.
+        * 
+        * @since 0.1
+        */
+       public function __construct( $pageId, $userName, $time, $id = null ) {
+               $this->pageId = $pageId;
+               $this->userName = $userName;
+               $this->time = $time;
+               $this->id = $id;
+       }
+       
+       /**
+        * Writes the edit to the database, either updating it
+        * when it already exists, or inserting it when it doesn't.
+        * 
+        * @since 0.1
+        * 
+        * @return boolean Success indicator
+        */
+       public function writeToDB() {
+               if ( is_null( $this->id ) ) {
+                       return $this->insertIntoDB();
+               }
+               else {
+                       return  $this->updateInDB();
+               }
+       }
+       
+       /**
+        * Updates the group in the database.
+        * 
+        * @since 0.1
+        * 
+        * @return boolean Success indicator
+        */
+       protected function updateInDB() {
+               $dbr = wfGetDB( DB_MASTER );
+               
+               return  $dbr->update(
+                       'swl_edits',
+                       array(
+                               'edit_user_name' => $this->userName,
+                               'edit_page_id' => $this->pageId,
+                               'edit_time' => $this->time
+                       ),
+                       array( 'edit_id' => $this->id )
+               );
+       }
+       
+       /**
+        * Inserts the group into the database.
+        * 
+        * @since 0.1
+        * 
+        * @return boolean Success indicator
+        */
+       protected function insertIntoDB() {
+               $dbr = wfGetDB( DB_MASTER );
+               
+               $result = $dbr->insert(
+                       'swl_edits',
+                       array(
+                               'edit_user_name' => $this->userName,
+                               'edit_page_id' => $this->pageId,
+                               'edit_time' => $this->time
+                       )
+               );
+               
+               $this->id = $dbr->insertId();
+               
+               return $result;
+       }
+       
+       /**
+        * Returns the edit database id (swl_edits.edit_id).
+        * 
+        * @since 0.1
+        * 
+        * @return integer
+        */
+       public function getId() {
+               return $this->id;
+       }
+       
+       /**
+        * Returns the ID of the page the edit was made to.
+        * 
+        * @since 0.1
+        * 
+        * @return integer
+        */
+       public function getPageId() {
+               return $this->pageId;
+       }
+       
+       /**
+        * Gets the title of the page these changes belong to.
+        * 
+        * @since 0.1
+        * 
+        * @return Title
+        */
+       public function getTitle() {
+               return Title::newFromID( $this->pageId );
+       }
+       
+       /**
+        * Gets the name of the user that made the changes.
+        * 
+        * @since 0.1
+        * 
+        * @return string
+        */
+       public function getUserName() {
+               return $this->userName;
+       }
+       
+       /**
+        * Gets the user that made the changes.
+        * 
+        * @since 0.1
+        * 
+        * @return User
+        */
+       public function getUser() {
+               if ( $this->user === false ) {
+                       $this->user = User::newFromName( $this->userName );
+               }
+               
+               return $this->user;
+       }
+       
+       /**
+        * Gets the time on which the changes where made.
+        * 
+        * @since 0.1
+        * 
+        * @return integer
+        */
+       public function getTime() {
+               return $this->time;
+       }
+       
+}
\ No newline at end of file


Property changes on: trunk/extensions/SemanticWatchlist/includes/SWL_Edit.php
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/extensions/SemanticWatchlist/includes/SWL_Group.php
===================================================================
--- trunk/extensions/SemanticWatchlist/includes/SWL_Group.php   2011-05-24 
20:16:55 UTC (rev 88743)
+++ trunk/extensions/SemanticWatchlist/includes/SWL_Group.php   2011-05-24 
20:17:26 UTC (rev 88744)
@@ -224,7 +224,7 @@
        }
 
        /**
-        * Returns the properties specified by the group.
+        * Returns the properties specified by the group as strings 
(serializations of SMWDIProperty).
         * 
         * @since 0.1
         * 
@@ -235,6 +235,23 @@
        }
        
        /**
+        * Returns the properties specified by the group as SMWDIProperty 
objects.
+        * 
+        * @since 0.1
+        * 
+        * @return array[SMWDIProperty]
+        */
+       public function getPropertyObjects() {
+               $properties = array();
+               
+               foreach ( $this->properties as $property ) {
+                       $properties[] = SMWDIProperty::newFromSerialization( 
$property );
+               }
+               
+               return $properties;
+       }
+       
+       /**
         * Returns the concepts specified by the group.
         * 
         * @since 0.1
@@ -421,19 +438,6 @@
        }
        
        /**
-        * Removethe non covered properties.
-        * 
-        * @since 0.1
-        * 
-        * @param SWLChangeSet $changes
-        * 
-        * @return SWLChangeSet
-        */
-       public function removeNonCoveredChanges( SWLChangeSet &$changes ) {
-               $changes->filterOnProperties( $this->getProperties() );
-       }
-       
-       /**
         * Gets all the watching users and passes them, together with the 
specified
         * changes and the group object itself, to the SWLGroupNotify hook.
         * 
@@ -444,8 +448,6 @@
        public function notifyWatchingUsers( SWLChangeSet $changes ) {
                $users = $this->getWatchingUsers();
                
-               $this->removeNonCoveredChanges( $changes );
-               
                if ( $changes->hasChanges( true ) ) {
                        wfRunHooks( 'SWLGroupNotify', array( $this, $users, 
$changes ) );
                }

Modified: 
trunk/extensions/SemanticWatchlist/specials/SpecialSemanticWatchlist.php
===================================================================
--- trunk/extensions/SemanticWatchlist/specials/SpecialSemanticWatchlist.php    
2011-05-24 20:16:55 UTC (rev 88743)
+++ trunk/extensions/SemanticWatchlist/specials/SpecialSemanticWatchlist.php    
2011-05-24 20:17:26 UTC (rev 88744)
@@ -209,7 +209,7 @@
                $changeSetsHTML = array();
                
                foreach ( $sets as $set ) {
-                       $dayKey = substr( $set->getTime(), 0, 8 ); // Get the 
YYYYMMDD part.
+                       $dayKey = substr( $set->getEdit()->getTime(), 0, 8 ); 
// Get the YYYYMMDD part.
                        
                        if ( !array_key_exists( $dayKey, $changeSetsHTML ) ) {
                                $changeSetsHTML[$dayKey] = array();
@@ -278,46 +278,48 @@
        protected function getChangeSetHTML( SWLChangeSet $changeSet ) {
                global $wgLang;
                
+               $edit = $changeSet->getEdit();
+               
                $html = '';
                
                $html .= '<li>';
                
                $html .= 
                        '<p>' .
-                               $wgLang->time( $changeSet->getTime(), true ) . 
' ' .
+                               $wgLang->time( $edit->getTime(), true ) . ' ' .
                                Html::element(
                                        'a',
-                                       array( 'href' => 
$changeSet->getTitle()->getLocalURL() ),
-                                       $changeSet->getTitle()->getText()
+                                       array( 'href' => 
$edit->getTitle()->getLocalURL() ),
+                                       $edit->getTitle()->getText()
                                ) . ' (' .
                                Html::element(
                                        'a',
-                                       array( 'href' => 
$changeSet->getTitle()->getLocalURL( 'action=history' ) ),
+                                       array( 'href' => 
$edit->getTitle()->getLocalURL( 'action=history' ) ),
                                        wfMsg( 'hist' )
                                ) . ') . . ' .
                                Html::element(
                                        'a',
-                                       array( 'href' => 
$changeSet->getUser()->getUserPage()->getLocalURL() ),
-                                       $changeSet->getUser()->getName()
+                                       array( 'href' => 
$edit->getUser()->getUserPage()->getLocalURL() ),
+                                       $edit->getUser()->getName()
                                ) . ' (' .
                                Html::element(
                                        'a',
-                                       array( 'href' => 
$changeSet->getUser()->getTalkPage()->getLocalURL() ),
+                                       array( 'href' => 
$edit->getUser()->getTalkPage()->getLocalURL() ),
                                        wfMsg( 'talkpagelinktext' )
                                ) . ' | ' .
-                               ( $changeSet->getUser()->isAnon() ? '' :
+                               ( $edit->getUser()->isAnon() ? '' :
                                        Html::element(
                                                'a',
-                                               array( 'href' => 
SpecialPage::getTitleFor( 'Contributions', $changeSet->getUser()->getName() 
)->getLocalURL() ),
+                                               array( 'href' => 
SpecialPage::getTitleFor( 'Contributions', $edit->getUser()->getName() 
)->getLocalURL() ),
                                                wfMsg( 'contribslink' )         
                                
                                        ) . ' | '
                                ) .
                                Html::element(
                                        'a',
-                                       array( 'href' => 
SpecialPage::getTitleFor( 'Block', $changeSet->getUser()->getName() 
)->getLocalURL() ),
+                                       array( 'href' => 
SpecialPage::getTitleFor( 'Block', $edit->getUser()->getName() )->getLocalURL() 
),
                                        wfMsg( 'blocklink' )
                                ) . ')' .
-                               ( $changeSet->getTime() > $this->lastViewed ? ' 
[NEW]' : '' )   .
+                               ( $edit->getTime() > $this->lastViewed ? ' 
[NEW]' : '' )        .
                        '</p>'
                ;
                


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to