コード例 #1
0
 public static function onNewUserRedirect(&$redirectURL)
 {
     if (Hydra::isEnabled(self::EXPERIMENT_NAME)) {
         $redirectURL = '/wikiHow:tour';
     }
     return true;
 }
コード例 #2
0
 static function beforeHeaderDisplay($isMobile)
 {
     global $whEditRedirectSave, $wgOut, $wgRequest, $wgUser, $wgTitle;
     /*
      * We only want to display the edit redirect page on desktop after the first edit on a main namespace page. We check a bunch of criteria to ensure this is he case.
      * criteria to ensure this is indeed the first edit
      */
     if (!$isMobile && isset($_SESSION[self::OUR_SESSION_NAME]) && $_SESSION[self::OUR_SESSION_NAME] && Hydra::isEnabled(self::EXPERIMENT_NAME) || $wgRequest->getVal("abtest_test2") == "1") {
         // Turn off cache because this is a onetime thing
         $wgOut->enableClientCache(false);
         unset($_SESSION[self::OUR_SESSION_NAME]);
         $cats = $wgTitle->getParentCategories();
         if (sizeof($cats) == 0) {
             return true;
         }
         $catkeys = array_keys($cats);
         $cat = false;
         foreach ($catkeys as $k) {
             if (preg_match('@Category:(.+)@i', $k, $matches) && $matches[1] != 'Featured-Articles') {
                 $cat = $matches[1];
                 break;
             }
         }
         // We only display the edit redirect dialog for main namespace edits
         if ($wgTitle->getNamespace() == NS_MAIN && $wgRequest->getText('action', 'view') == 'view' && $cat) {
             EasyTemplate::set_path(dirname(__FILE__));
             $catText = str_replace('-', ' ', $cat);
             $vars = array('cat' => $cat, 'catText' => $catText);
             $tmpl = EasyTemplate::html("CatRedirect.tmpl.php", $vars);
             $wgOut->addScript($tmpl);
         }
     }
     return true;
 }
コード例 #3
0
 public static function onArticleFromTitle(&$title, &$article)
 {
     global $wgOut;
     if ($title && strtolower($title->getText()) == 'tour' && $title->getNamespace() == NS_PROJECT && Hydra::isEnabled(self::EXPERIMENT_NAME)) {
         $title = Title::newFromText('tour2', NS_PROJECT);
         $wgOut->redirect($title->getFullURL());
     }
     return true;
 }
コード例 #4
0
 public static function onNewUserRedirect(&$redirectURL)
 {
     if (Hydra::isEnabled(self::EXPERIMENT_NAME)) {
         $t = Title::makeTitle(NS_SPECIAL, self::PAGE_NAME);
         // Remove leading slash because redirect functionality is messed up to add slash
         $redirectURL = preg_replace("@^/@", "", $t->getLocalURL());
     }
     return true;
 }
コード例 #5
0
    static function beforeHeaderDisplay($isMobile)
    {
        global $whEditRedirectSave, $wgOut, $wgRequest, $wgUser, $wgTitle;
        /*
         * We only want to display the edit redirect page on desktop after the first edit on a main namespace page. We check a bunch of criteria to ensure this is he case.
         * criteria to ensure this is indeed the first edit
         */
        if (!$isMobile && isset($_SESSION[self::OUR_SESSION_NAME]) && $_SESSION[self::OUR_SESSION_NAME] && Hydra::isEnabled(self::EXPERIMENT_NAME) || $wgRequest->getVal("abtest_test") == "1") {
            // Turn off cache because this is a onetime thing
            $wgOut->enableClientCache(false);
            unset($_SESSION[self::OUR_SESSION_NAME]);
            // We only display the edit redirect dialog for main namespace edits
            if ($wgTitle->getNamespace() == NS_MAIN && $wgRequest->getText('action', 'view') == 'view') {
                $wgOut->addScript(<<<EOD
\t<style type="text/css">
\t.no-close .ui-dialog-titlebar-close {
\t\tdisplay:none;\t
\t}
\t</style>
\t\t<script type="text/javascript">
(function(\$) {
\t\$(document).ready(function() {
\t\tvar txt = "<span>There are tons of other ways to contribute around here! What do you want to try next?</span><br/><br/>";
\t\ttxt += '<ul style="list-style:none;"><li style="padding-bottom:10px;"><a href="/Special:TipsPatrol?utm_source=post+edit+link&utm_medium=link&utm_campaign=abtest_choice_tips" style="font-size:12pt;" id="edit_redirect_tips_link" style="display:inline;border:none;" ><span style="font-weight:bold;"> Take me to Tips Patrol</span>: Review, edit, and add tips </a></li>'; 
\t\ttxt += '<li><a tabindex="3" href="/Special:RCPatrol?utm_source=post+edit+link&utm_medium=link&utm_campaign=abtest_choice_rc_patrol" style="font-size:12pt;" id="edit_redirect_rc_patrol_link" style="display:inline;border:none;font-weight:bold;"><span style="font-weight:bold;">Take me to RC Patrol</span>: Check and approve recent edits</a></li></ul>'; 
\t\ttxt += '<div style="float:right;"><a href="#" style="text-decoration:underline;" class="cancel_button" tabindex="1">No, Thanks</a>';
\t\t\$("#dialog-box").html(txt);
\t\t\$("#dialog-box").dialog({
\t\t\twidth: 600,
\t\t\tmodal: true,
\t\t\ttitle: 'Thanks for your help!',
\t\t\tcloseText: 'Close',
\t\t\topen: function() {
\t\t\t\t\$(".cancel_button").click(function() {
\t\t\t\t\t\$("#dialog-box").dialog("close");
\t\t\t\t\treturn false;
\t\t\t\t});
\t\t\t\t\$(".cancel_button").focus();
\t\t\t}
\t\t});
\t});
})(jQuery);
</script>
EOD
);
            }
        }
        return true;
    }
コード例 #6
0
 public static function beforeHeaderDisplay()
 {
     global $wgUser;
     if (Hydra::isEnabled(self::EXPERIMENT_NAME)) {
         if ($wgUser->getId() > 0) {
             $sk = $wgUser->getSkin();
             $r = mt_rand(1, 4);
             if ($r == 1) {
                 $sk->addWidget("<a href=\"/Special:CreatePage?utm_source=hydra_creative&utm_campaign=hydra_creative_1\"><img src=\"" . self::getImgUrl('render1.jpg') . "\"></a>", 'hydra_ad');
             } elseif ($r == 2) {
                 $sk->addWidget("<a href=\"/Special:RCPatrol?utm_source=hydra_creative&utm_campaign=hydra_creative_2\"><img src=\"" . self::getImgUrl('render2.jpg') . "\"></a>", 'hydra_ad');
             } elseif ($r == 3) {
                 $sk->addWidget("<a href=\"/Special:ListRequestedTopics?utm_source=hydra_creative&utm_campaign=hydra_creative_3\"><img src=\"" . self::getImgUrl('render3.jpg') . "\"></a>", 'hydra_ad');
             } elseif ($r == 4) {
                 $sk->addWidget("<a href=\"/Special:EditFinder/Copyedit?utm_source=hydra_creative&utm_campaign=hydra_creative_4\"><img src=\"" . self::getImgUrl('render4.jpg') . "\"></a>", 'hydra_ad');
             }
         }
     }
     return true;
 }