/**
  * Get the form(s) used to edit this page - either:
  * - the default form(s) for the page itself, if there are any; or
  * - the default form(s) for a category that this article belongs to,
  * if there are any; or
  * - the default form(s) for the article's namespace, if there are any.
  */
 static function getDefaultFormsForPage($title)
 {
     // See if the page itself has a default form (or forms), and
     // return it/them if so.
     // (Disregard category pages for this check.)
     if ($title->getNamespace() != NS_CATEGORY) {
         $default_form = self::getDefaultForm($title);
         if ($default_form != '') {
             return array($default_form);
         }
     }
     $default_forms = self::getFormsThatPagePointsTo($title->getText(), $title->getNamespace(), self::PAGE_DEFAULT_FORM);
     if (count($default_forms) > 0) {
         return $default_forms;
     }
     // If this is not a category page, look for a default form
     // for its parent category or categories.
     $namespace = $title->getNamespace();
     if (NS_CATEGORY !== $namespace) {
         $default_forms = array();
         $categories = SFUtils::getCategoriesForPage($title);
         foreach ($categories as $category) {
             if (class_exists('PSSchema')) {
                 // Check the Page Schema, if one exists.
                 $psSchema = new PSSchema($category);
                 if ($psSchema->isPSDefined()) {
                     $formName = SFPageSchemas::getFormName($psSchema);
                     if (!is_null($formName)) {
                         $default_forms[] = $formName;
                     }
                 }
             }
             $categoryPage = Title::makeTitleSafe(NS_CATEGORY, $category);
             $defaultFormForCategory = self::getDefaultForm($categoryPage);
             if ($defaultFormForCategory != '') {
                 $default_forms[] = $defaultFormForCategory;
             }
             $default_forms = array_merge($default_forms, self::getFormsThatPagePointsTo($category, NS_CATEGORY, self::DEFAULT_FORM));
         }
         if (count($default_forms) > 0) {
             // It is possible for two categories to have the same default form, so purge any
             // duplicates from the array to avoid a "more than one default form" warning.
             return array_unique($default_forms);
         }
     }
     // All that's left is checking for the namespace. If this is
     // a subpage, exit out - default forms for namespaces don't
     // apply to subpages.
     if ($title->isSubpage()) {
         return array();
     }
     // If we're still here, just return the default form for the
     // namespace, which may well be null.
     if (NS_MAIN === $namespace) {
         // If it's in the main (blank) namespace, check for the
         // file named with the word for "Main" in this language.
         $namespace_label = wfMessage('sf_blank_namespace')->inContentLanguage()->text();
     } else {
         global $wgContLang;
         $namespace_labels = $wgContLang->getNamespaces();
         $namespace_label = $namespace_labels[$namespace];
     }
     $namespacePage = Title::makeTitleSafe(NS_PROJECT, $namespace_label);
     $default_form = self::getDefaultForm($namespacePage);
     if ($default_form != '') {
         return array($default_form);
     }
     $default_forms = self::getFormsThatPagePointsTo($namespace_label, NS_PROJECT, self::DEFAULT_FORM);
     return $default_forms;
 }
	/**
	 * Get the form(s) used to edit this page - either:
	 * - the default form(s) for the page itself, if there are any; or
	 * - the default form(s) for a category that this article belongs to,
	 * if there are any; or
	 * - the default form(s) for the article's namespace, if there are any.
	 */
	static function getDefaultFormsForPage( $title ) {
		// See if the page itself has a default form (or forms), and
		// return it/them if so.
		$default_forms = self::getFormsThatPagePointsTo( $title->getText(), $title->getNamespace(), self::PAGE_DEFAULT_FORM );
		if ( count( $default_forms ) > 0 ) {
			return $default_forms;
		}
		// If this is not a category page, look for a default form
		// for its parent category or categories.
		$namespace = $title->getNamespace();
		if ( NS_CATEGORY !== $namespace ) {
			$default_forms = array();
			$categories = SFUtils::getCategoriesForPage( $title );
			foreach ( $categories as $category ) {
				if ( class_exists( 'PSSchema' ) ) {
					// Check the Page Schema, if one exists.
					$psSchema = new PSSchema( $category );
					if ( $psSchema->isPSDefined() ) {
						$formName = SFPageSchemas::getFormName( $psSchema );
						if ( !is_null( $formName ) ) {
							$default_forms[] = $formName;
						}
					}
				}
				$default_forms = array_merge( $default_forms, self::getFormsThatPagePointsTo( $category, NS_CATEGORY, self::DEFAULT_FORM ) );
			}
			if ( count( $default_forms ) > 0 ) {
				return $default_forms;
			}
		}

		// All that's left is checking for the namespace. If this is
		// a subpage, exit out - default forms for namespaces don't
		// apply to subpages.
		if ( $title->isSubpage() ) {
			return array();
		}

		// If we're still here, just return the default form for the
		// namespace, which may well be null.
		if ( NS_MAIN === $namespace ) {
			// If it's in the main (blank) namespace, check for the
			// file named with the word for "Main" in this language.
			$namespace_label = wfMsgForContent( 'sf_blank_namespace' );
		} else {
			global $wgContLang;
			$namespace_labels = $wgContLang->getNamespaces();
			$namespace_label = $namespace_labels[$namespace];
		}
		$default_forms = self::getFormsThatPagePointsTo( $namespace_label, NS_PROJECT, self::DEFAULT_FORM );
		return $default_forms;
	}