Example #1
0
 /**
  * Hook to <ul>
  * <li>correct the action menu that displays "delete" a bit too much.
  * A direct correction would be to change the logic directly in SkinTemplate::buildContentNavigationUrls.
  * The menu builder now uses if( $wgUser->isAllowed( 'delete' ) ) ...
  * A better builder would use if( $$title->quickUserCan( 'delete' ) ) ...</li>
  * <li>add a "Set as background" action for files</li>
  * </ul>
  * @param SkinTemplate $skinTemplate
  * @param Array $content_navigation
  * @return Boolean True (=continue hook)
  * 
  */
 public static function SkinTemplateNavigation(&$skinTemplate, &$content_navigation)
 {
     $title = $skinTemplate->getRelevantTitle();
     // removes "delete" action if necessary
     if (isset($content_navigation['actions']['delete']) && !$title->quickUserCan('delete')) {
         unset($content_navigation['actions']['delete']);
     }
     // adds a "Set as background" action for files
     global $wgUser;
     if (in_array(WP_SUBSCRIBERS_USER_GROUP, $wgUser->getGroups()) && WpWikiplace::isTitleValidForBackground($title) && count(WpWikiplace::factoryAllOwnedByUserId($wgUser->getId())) != 0) {
         $content_navigation['actions']['background'] = array('class' => false, 'text' => wfMessage('wp-background-action')->text(), 'href' => SpecialWikiplaces::getLocalUrlForSetAsBackground($title->getPrefixedDBkey()));
     }
     return true;
 }
 public function validateBackgroundFilePageName($page_name, $allData)
 {
     if ($page_name == null) {
         return false;
     }
     $file_title = Title::newFromText($page_name);
     if (!$file_title->isKnown()) {
         return wfMessage('filepage-nofile');
     }
     if (!WpWikiplace::isTitleValidForBackground($file_title)) {
         return wfMessage('wp-invalid-background')->text();
     }
     return true;
     // all ok
 }