Deprecated Title::userIsWatching(); use User::isWatched() instead.
[lhc/web/wiklou.git] / includes / EditPage.php
index c84ae75..1f526cc 100644 (file)
@@ -1,6 +1,22 @@
 <?php
 /**
- * Contains the EditPage class
+ * Page edition user interface.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
  * @file
  */
 
@@ -740,7 +756,7 @@ class EditPage {
                } elseif ( $wgUser->getOption( 'watchcreations' ) && !$this->mTitle->exists() ) {
                        # Watch creations
                        $this->watchthis = true;
-               } elseif ( $this->mTitle->userIsWatching() ) {
+               } elseif ( $wgUser->isWatched( $this->mTitle ) ) {
                        # Already watched
                        $this->watchthis = true;
                }
@@ -1047,7 +1063,6 @@ class EditPage {
                                        '</div>';
                                return true;
                }
-               return false;
        }
 
        /**
@@ -1455,7 +1470,7 @@ class EditPage {
         */
        protected function commitWatch() {
                global $wgUser;
-               if ( $this->watchthis xor $this->mTitle->userIsWatching() ) {
+               if ( $wgUser->isLoggedIn() && $this->watchthis != $wgUser->isWatched( $this->mTitle ) ) {
                        $dbw = wfGetDB( DB_MASTER );
                        $dbw->begin( __METHOD__ );
                        if ( $this->watchthis ) {
@@ -2399,7 +2414,16 @@ HTML
                        '</div>' );
        }
 
+       /**
+        * Get the copyright warning
+        *
+        * Renamed to getCopyrightWarning(), old name kept around for backwards compatibility
+        */
        protected function getCopywarn() {
+               return self::getCopyrightWarning( $this->mTitle );
+       }
+
+       public static function getCopyrightWarning( $title ) {
                global $wgRightsText;
                if ( $wgRightsText ) {
                        $copywarnMsg = array( 'copyrightwarning',
@@ -2410,7 +2434,7 @@ HTML
                                '[[' . wfMsgForContent( 'copyrightpage' ) . ']]' );
                }
                // Allow for site and per-namespace customization of contribution/copyright notice.
-               wfRunHooks( 'EditPageCopyrightWarning', array( $this->mTitle, &$copywarnMsg ) );
+               wfRunHooks( 'EditPageCopyrightWarning', array( $title, &$copywarnMsg ) );
 
                return "<div id=\"editpage-copywarn\">\n" .
                        call_user_func_array( "wfMsgNoTrans", $copywarnMsg ) . "\n</div>";