2010 October, 9 (Guerric)

    Table of contents
    No headers
    http://bugs.developer.mindtouch.com/view.php?id=9003
    // Paste PHP Code
    
    Index: deki/core/objects/deki_page_alert.php
    ===================================================================
    --- deki/core/objects/deki_page_alert.php    (revision 22643)
    +++ deki/core/objects/deki_page_alert.php    (working copy)
    @@ -155,12 +155,7 @@
            
             $Plug = $this->getPlug();
             // setup the plug
    -        $Plug = $Plug->At('subscriptions');
    -        // add the pages to check
    -        $checkPages = $this->parentIds;
    -        $checkPages[] = $this->pageId;
    -        
    -        $Plug = $Plug->With('pages', implode(',', $checkPages));
    +        $Plug = $Plug->At('subscriptions')->At($this->pageId);    
             $Result = $Plug->Get();
            
             // TODO: should this fail silently or show an error message?
    Index: deki/plugins/page_alerts/page_alerts.php
    ===================================================================
    --- deki/plugins/page_alerts/page_alerts.php    (revision 0)
    +++ deki/plugins/page_alerts/page_alerts.php    (revision 0)
    @@ -0,0 +1,154 @@
    +<?php
    +/*
    + * MindTouch Core - open source enterprise collaborative networking
    + * Copyright (c) 2006-2010 MindTouch Inc.
    + * www.mindtouch.com oss@mindtouch.com
    + *
    + * For community documentation and downloads visit www.opengarden.org;
    + * please review the licensing section.
    + *
    + * 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.,
    + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    + * http://www.gnu.org/copyleft/gpl.html
    + */
    +
    +class DekiPageAlertsPlugin extends DekiPlugin
    +{
    +    public static function init()
    +    {
    +        // add the button to the skin
    +        DekiPlugin::registerHook(Hooks::SKIN_OVERRIDE_VARIABLES, array(__CLASS__, 'skinHook'));        
    +    }
    +    
    +    public static function skinHook(&$Template)
    +    {
    +        global $wgArticle, $wgTitle, $wgUser;
    +        
    +        // page alerts: views pages, talk pages, and logged in users with subscribe
    +        // doesn't make sense for the anon user to subscribe to alerts
    +        if (($wgArticle->isViewPage() || $wgTitle->isTalkPage()) && !$wgTitle->isTemplateHomepage())
    +        {
    +            $enablePageAlerts = !$wgUser->isAnonymous() && $wgUser->canSubscribe() && ($wgArticle->getId() > 0);
    +            $Template->set('page.alerts', self::getPageAlertsButton($wgArticle, $enablePageAlerts));
    +        }
    +    }
    +    
    +    /**
    +     * Generates the markup for page alerts
    +     * @author guerrics
    +     *
    +     * @param Article $Article - if null, disabled state
    +     * @return string html
    +     */
    +    protected static function getPageAlertsButton($Article, $enabled = true)
    +    {
    +        $Title = Title::newFromText('PageAlerts', NS_SPECIAL);
    +        $id = $Article->getId();
    +        if ($id > 0)
    +        {
    +            $specialUrl = $Title->getLocalURL('id=' . $Article->getId());
    +        }
    +        else
    +        {
    +            // page alerts should be disabled
    +            $specialUrl = '#';
    +        }
    +        
    +        if (!$enabled)
    +        {
    +            // disabled markup
    +            $html =
    +            '<div id="deki-page-alerts" class="disabled">
    +                <div class="toggle">
    +                    <a href="javascript:void(0);" class="off">
    +                        <span>'. wfMsg('Page.PageAlerts.page-title') .'</span>
    +                        <span class="status">' .
    +                            wfMsg('Page.PageAlerts.status.off') .
    +                        '</span>
    +                    </a>
    +                </div>'.
    +            '</div>';
    +        }
    +        else
    +        {    
    +            // build the markup for the alerts area
    +            $status = $Article->getAlertStatus();
    +            $isSubscribed = ($status != DekiPageAlert::STATUS_OFF);
    +    
    +            $toggleHtml = '
    +            <div class="toggle">
    +                <a href="'. $specialUrl .'" class="'. ($isSubscribed ? '' : 'off') .'">
    +                    <span>'. wfMsg('Page.PageAlerts.page-title') .'</span>
    +                    <span class="status">' .
    +                        ($isSubscribed ? wfMsg('Page.PageAlerts.status.on') : wfMsg('Page.PageAlerts.status.off')) .
    +                    '</span>
    +                </a>
    +            </div>';
    +            
    +            if ($status == DekiPageAlert::STATUS_PARENT)
    +            {
    +                $parentId = $Article->getAlertParentId();
    +                $Parent = Title::newFromId($parentId);
    +                // fail gracefully if the paretnt title cannot be found
    +                if (!is_null($Parent))
    +                {
    +                    // special case, show link to parent
    +                    $optionsHtml =
    +                    '<li class="parent">' .
    +                        wfMsg(
    +                            'Page.PageAlerts.notice.parent',
    +                            '<a href="'. $Parent->getLocalUrl() .'">'. htmlspecialchars($Parent->getDisplayText()) .'</a>'
    +                        ) .
    +                    '</li>';
    +                }
    +            }
    +            else
    +            {        
    +                $optionsHtml = '
    +                <li class="self">
    +                    <input type="radio" name="alert" id="deki-page-alerts-self" '.
    +                    ($status == DekiPageAlert::STATUS_SELF ? 'checked="checked"' : '') .
    +                    'value="'. DekiPageAlert::STATUS_SELF .'" />
    +                    <label for="deki-page-alerts-self">'. wfMsg('Page.PageAlerts.form.self') .'</label>
    +                </li>
    +                <li class="tree">
    +                    <input type="radio" name="alert" id="deki-page-alerts-tree" '.
    +                    ($status == DekiPageAlert::STATUS_TREE ? 'checked="checked"' : '') .
    +                    'value="'. DekiPageAlert::STATUS_TREE .'" />
    +                    <label for="deki-page-alerts-tree">'. wfMsg('Page.PageAlerts.form.tree') .'</label>
    +                </li>
    +                <li class="off">
    +                    <input type="radio" name="alert" id="deki-page-alerts-off" '.
    +                    ($status == DekiPageAlert::STATUS_OFF ? 'checked="checked"' : '') .
    +                    'value="'. DekiPageAlert::STATUS_OFF .'" />
    +                    <label for="deki-page-alerts-off">'. wfMsg('Page.PageAlerts.form.off.verbose') .'</label>
    +                </li>';
    +            }
    +            
    +            // wrap the options elements in a list and form
    +            $html =
    +            '<div id="deki-page-alerts">' .
    +                $toggleHtml .
    +                '<form class="options">' .
    +                    '<div class="legend">' . wfMsg('Page.PageAlerts.form.legend') . '</div>' .
    +                    '<ul>' . $optionsHtml . '</ul>' .
    +                '</form>' .
    +            '</div>';
    +        }
    +        
    +        return $html;
    +    }
    +    
    +}
    +DekiPageAlertsPlugin::init();
    Index: deki/plugins/page_alerts/plugin_resources.php
    ===================================================================
    --- deki/plugins/page_alerts/plugin_resources.php    (revision 0)
    +++ deki/plugins/page_alerts/plugin_resources.php    (revision 0)
    @@ -0,0 +1,30 @@
    +<?php
    +/*
    + * MindTouch Core - open source enterprise collaborative networking
    + * Copyright (c) 2006-2010 MindTouch Inc.
    + * www.mindtouch.com oss@mindtouch.com
    + *
    + * For community documentation and downloads visit www.opengarden.org;
    + * please review the licensing section.
    + *
    + * 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.,
    + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    + * http://www.gnu.org/copyleft/gpl.html
    + */
    +
    +/**
    + * Plugin resources
    + */
    +DekiPluginResource::loadJavascript('page_alerts', 'page_alerts.js');
    +DekiPluginResource::loadCss('page_alerts', 'page_alerts.css');
    Index: includes/DefaultSettings.php
    ===================================================================
    --- includes/DefaultSettings.php    (revision 22643)
    +++ includes/DefaultSettings.php    (working copy)
    @@ -405,6 +405,7 @@
         'image_gallery_lite',
         'nav_pane',
         'page_tags',
    +    'page_alerts',
         'page_template_selector',
         'param_switches',
         'sitemap',
    Index: includes/Skin.php
    ===================================================================
    --- includes/Skin.php    (revision 22643)
    +++ includes/Skin.php    (working copy)
    @@ -1545,112 +1545,6 @@
         function formSelect($name, $data, $setValue = false, $params = array()) {
             return wfSelectForm($name, $data, $setValue, $params);
         }
    -    
    -    /**
    -     * Generates the markup for page alerts
    -     * @author guerrics
    -     *
    -     * @param Article $Article - if null, disabled state
    -     * @return string html
    -     */
    -    public static function getPageAlertsButton($Article, $enabled = true)
    -    {
    -        $Title = Title::newFromText('PageAlerts', NS_SPECIAL);
    -        $id = $Article->getId();
    -        if ($id > 0)
    -        {
    -            $specialUrl = $Title->getLocalURL('id=' . $Article->getId());
    -        }
    -        else
    -        {
    -            // page alerts should be disabled
    -            $specialUrl = '#';
    -        }
    -        
    -        if (!$enabled)
    -        {
    -            // disabled markup
    -            $html =
    -            '<div id="deki-page-alerts" class="disabled">
    -                <div class="toggle">
    -                    <a href="'. $specialUrl .'" class="off">
    -                        <span>'. wfMsg('Page.PageAlerts.page-title') .'</span>
    -                        <span class="status">' .
    -                            wfMsg('Page.PageAlerts.status.off') .
    -                        '</span>
    -                    </a>
    -                </div>'.
    -            '</div>';
    -        }
    -        else
    -        {    
    -            // build the markup for the alerts area
    -            $status = $Article->getAlertStatus();
    -            $isSubscribed = ($status != DekiPageAlert::STATUS_OFF);
    -    
    -            $toggleHtml = '
    -            <div class="toggle">
    -                <a href="'. $specialUrl .'" class="'. ($isSubscribed ? '' : 'off') .'">
    -                    <span>'. wfMsg('Page.PageAlerts.page-title') .'</span>
    -                    <span class="status">' .
    -                        ($isSubscribed ? wfMsg('Page.PageAlerts.status.on') : wfMsg('Page.PageAlerts.status.off')) .
    -                    '</span>
    -                </a>
    -            </div>';
    -            
    -            if ($status == DekiPageAlert::STATUS_PARENT)
    -            {
    -                $parentId = $Article->getAlertParentId();
    -                $Parent = Title::newFromId($parentId);
    -                // fail gracefully if the paretnt title cannot be found
    -                if (!is_null($Parent))
    -                {
    -                    // special case, show link to parent
    -                    $optionsHtml =
    -                    '<li class="parent">' .
    -                        wfMsg(
    -                            'Page.PageAlerts.notice.parent',
    -                            '<a href="'. $Parent->getLocalUrl() .'">'. htmlspecialchars($Parent->getDisplayText()) .'</a>'
    -                        ) .
    -                    '</li>';
    -                }
    -            }
    -            else
    -            {        
    -                $optionsHtml = '
    -                <li class="self">
    -                    <input type="radio" name="alert" id="deki-page-alerts-self" '.
    -                    ($status == DekiPageAlert::STATUS_SELF ? 'checked="checked"' : '') .
    -                    'value="'. DekiPageAlert::STATUS_SELF .'" />
    -                    <label for="deki-page-alerts-self">'. wfMsg('Page.PageAlerts.form.self') .'</label>
    -                </li>
    -                <li class="tree">
    -                    <input type="radio" name="alert" id="deki-page-alerts-tree" '.
    -                    ($status == DekiPageAlert::STATUS_TREE ? 'checked="checked"' : '') .
    -                    'value="'. DekiPageAlert::STATUS_TREE .'" />
    -                    <label for="deki-page-alerts-tree">'. wfMsg('Page.PageAlerts.form.tree') .'</label>
    -                </li>
    -                <li class="off">
    -                    <input type="radio" name="alert" id="deki-page-alerts-off" '.
    -                    ($status == DekiPageAlert::STATUS_OFF ? 'checked="checked"' : '') .
    -                    'value="'. DekiPageAlert::STATUS_OFF .'" />
    -                    <label for="deki-page-alerts-off">'. wfMsg('Page.PageAlerts.form.off.verbose') .'</label>
    -                </li>';
    -            }
    -            
    -            // wrap the options elements in a list and form
    -            $html =
    -            '<div id="deki-page-alerts">' .
    -                $toggleHtml .
    -                '<form class="options">' .
    -                    '<div class="legend">' . wfMsg('Page.PageAlerts.form.legend') . '</div>' .
    -                    '<ul>' . $optionsHtml . '</ul>' .
    -                '</form>' .
    -            '</div>';
    -        }
    -        
    -        return $html;
    -    }
     }
     
     endif;
    Index: includes/SkinTemplate.php
    ===================================================================
    --- includes/SkinTemplate.php    (revision 22643)
    +++ includes/SkinTemplate.php    (working copy)
    @@ -547,15 +547,6 @@
                 $wgArticle->userCanTalk() ?  array('class' => 'selected'): array())
             );
            
    -        // page alerts: views pages, talk pages, and logged in users with subscribe
    -        // doesn't make sense for the anon user to subscribe to alerts
    -        if (($wgArticle->isViewPage() || $wgTitle->isTalkPage()) && !$wgTitle->isTemplateHomepage())
    -        {
    -            $enablePageAlerts = !$wgUser->isAnonymous() && $wgUser->canSubscribe() && ($wgArticle->getId() > 0);
    -            $tpl->set('page.alerts', Skin::getPageAlertsButton($wgArticle, $enablePageAlerts));
    -        }
    -        
    -        
             $this->onclick->pagetalk = '';
             $this->onclick->pageemail = '';
             $this->onclick->pageadd = '';
    Index: includes/SkinTemplate_.php
    ===================================================================
    --- includes/SkinTemplate_.php    (revision 22643)
    +++ includes/SkinTemplate_.php    (working copy)
    @@ -613,14 +613,6 @@
                 $this->cssclass->pagetalk = DekiNamespace::isTalk($wgTitle->getNamespace()) ? 'active': 'inactive';
             }
     
    -        // page alerts: views pages, talk pages, and logged in users with subscribe
    -        // doesn't make sense for the anon user to subscribe to alerts
    -        if (($wgArticle->isViewPage() || $wgTitle->isTalkPage()) && !$wgTitle->isTemplateHomepage())
    -        {
    -            $enablePageAlerts = !$wgUser->isAnonymous() && $wgUser->canSubscribe() && ($wgArticle->getId() > 0);
    -            $tpl->set('page.alerts', Skin::getPageAlertsButton($wgArticle, $enablePageAlerts));
    -        }
    -
             $this->onclick->pageemail = '';
             $this->onclick->pagetalk = '';
             $this->onclick->pageadd = '';
    Index: skins/common/css.php
    ===================================================================
    --- skins/common/css.php    (revision 22643)
    +++ skins/common/css.php    (working copy)
    @@ -50,7 +50,6 @@
     $CSS->addSkin('jquery/thickbox/thickbox.css');
     $CSS->addSkin('jquery/autocomplete/jquery.autocomplete.css');
     $CSS->addSkin('messaging.css');
    -$CSS->addSkin('page_alerts.css');
     $CSS->addSkin('ckb/controls.css');
     $CSS->addSkin('ckb/reports.css');
     $CSS->addSkin('pagination.css');
    Index: skins/common/js.php
    ===================================================================
    --- skins/common/js.php    (revision 22643)
    +++ skins/common/js.php    (working copy)
    @@ -56,11 +56,6 @@
         $Js->addCommon('popups/plugins/wysiwyg.js');    //dialogs plugin
     }
     
    -if ($Js->canSubscribe())
    -{
    -    $Js->addCommon('page_alerts.js');
    -}
    -
     // add any javascript that plugins need to cache
     $files = DekiPluginResource::getLoadedJavascript();
     foreach ($files as $file)
    Tag page
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by