/** * Loads skin and user CSS files. * @param OutputPage $out */ function setupSkinUserCss(OutputPage $out) { parent::setupSkinUserCss($out); $title = $out->getTitle(); $isCard = false; if ($title && $title->exists()) { $categoris = SFUtils::getCategoriesForPage($title); if (in_array('Card', $categoris)) { if (!$out->getRequest()->getVal('action') || $out->getRequest()->getVal('action') == 'view') { $isCard = true; } } } if ($title && $title->exists() && $title->getNamespace() == NS_MAIN) { if ($title->getArticleID() === Title::newMainPage()->getArticleID()) { $styles = array('skins.settlein.styles'); } else { if ($isCard) { $styles = array('skins.settlein.page.styles'); } else { $styles = array('skins.settlein.styles'); } } } else { if ($isCard) { $styles = array('skins.settlein.page.styles'); } else { $styles = array('skins.settlein.styles'); } } if ($out->getRequest()->getVal('color')) { global $wgServer, $wgScriptPath; $color = htmlspecialchars($out->getRequest()->getVal('color')); $out->addStyle($wgServer . $wgScriptPath . '/skins/SettleIn/assets/colors/' . $color . '.css'); } if ($out->getRequest()->getVal('beta_font')) { global $wgServer, $wgScriptPath; $font = htmlspecialchars($out->getRequest()->getVal('beta_font')); $out->addStyle($wgServer . $wgScriptPath . '/skins/SettleIn/assets/fonts/' . $font . '.css'); } if ($this->getUser() && $this->getUser()->isLoggedIn()) { $out->addModuleStyles('ext.settlegeoforminput.foo'); } $out->addModuleStyles($styles); }
/** * 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; }
function execute($query) { global $wgOut, $wgRequest, $wgUser, $sfgScriptPath; $this->setHeaders(); // Cycle through the query values, setting the appropriate // local variables. $category_name = $wgRequest->getVal('category_name'); $default_form = $wgRequest->getVal('default_form'); $parent_category = $wgRequest->getVal('parent_category'); $category_name_error_str = null; $save_page = $wgRequest->getCheck('wpSave'); $preview_page = $wgRequest->getCheck('wpPreview'); if ($save_page || $preview_page) { // Validate category name if ($category_name === '') { $category_name_error_str = wfMsg('sf_blank_error'); } else { // Redirect to wiki interface $wgOut->setArticleBodyOnly(true); $title = Title::makeTitleSafe(NS_CATEGORY, $category_name); $full_text = SFCreateCategory::createCategoryText($default_form, $category_name, $parent_category); $text = SFUtils::printRedirectForm($title, $full_text, "", $save_page, $preview_page, false, false, false, null, null); $wgOut->addHTML($text); return; } } $all_forms = SFUtils::getAllForms(); // Set 'title' as hidden field, in case there's no URL niceness global $wgContLang; $mw_namespace_labels = $wgContLang->getNamespaces(); $special_namespace = $mw_namespace_labels[NS_SPECIAL]; $text = <<<END \t<form action="" method="get"> END; $text .= "\t" . Html::hidden('title', "{$special_namespace}:CreateCategory") . "\n"; $firstRow = wfMsg('sf_createcategory_name') . ' ' . Html::input('category_name', null, 'text', array('size' => 25)) . "\n"; if (!is_null($category_name_error_str)) { $firstRow .= Html::element('span', array('style' => 'color: red;'), $category_name_error_str) . "\n"; } $firstRow .= "\t" . wfMsg('sf_createcategory_defaultform') . "\n"; $formSelector = "\t" . Html::element('option', null, null) . "\n"; foreach ($all_forms as $form) { $formSelector .= "\t" . Html::element('option', null, $form) . "\n"; } $firstRow .= Html::rawElement('select', array('id' => 'form_dropdown', 'name' => 'default_form'), $formSelector); $text .= Html::rawElement('p', null, $firstRow); $subcategory_label = wfMsg('sf_createcategory_makesubcategory'); $text .= <<<END \t<p>{$subcategory_label} \t<select id="category_dropdown" name="parent_category"> \t<option></option> END; $categories = SFUtils::getCategoriesForPage(); foreach ($categories as $category) { $category = str_replace('_', ' ', $category); $text .= "\t" . Html::element('option', null, $category) . "\n"; } $text .= "\t</select>\n"; $editButtonsText = "\t" . Html::input('wpSave', wfMsg('savearticle'), 'submit', array('id' => 'wpSave')) . "\n"; $editButtonsText .= "\t" . Html::input('wpPreview', wfMsg('preview'), 'submit', array('id' => 'wpPreview')) . "\n"; $text .= "\t" . Html::rawElement('div', array('class' => 'editButtons'), $editButtonsText) . "\n"; $text .= <<<END \t<br /><hr /<br /> END; $sk = $wgUser->getSkin(); $create_form_link = SFUtils::linkForSpecialPage($sk, 'CreateForm'); $text .= "\t" . Html::rawElement('p', null, $create_form_link . '.') . "\n"; $text .= "\t</form>\n"; $wgOut->addExtensionStyle($sfgScriptPath . "/skins/SemanticForms.css"); $wgOut->addHTML($text); }
function execute($query) { global $wgOut, $wgRequest, $sfgScriptPath; $this->setHeaders(); // Cycle through the query values, setting the appropriate // local variables. if (!is_null($query)) { $presetCategoryName = str_replace('_', ' ', $query); $wgOut->setPageTitle(wfMessage('sf-createcategory-with-name', $presetCategoryName)->text()); $category_name = $presetCategoryName; } else { $presetCategoryName = null; $category_name = $wgRequest->getVal('category_name'); } $default_form = $wgRequest->getVal('default_form'); $parent_category = $wgRequest->getVal('parent_category'); $category_name_error_str = null; $save_page = $wgRequest->getCheck('wpSave'); $preview_page = $wgRequest->getCheck('wpPreview'); if ($save_page || $preview_page) { // Guard against cross-site request forgeries (CSRF). $validToken = $this->getUser()->matchEditToken($wgRequest->getVal('csrf'), 'CreateCategory'); if (!$validToken) { $text = "This appears to be a cross-site request forgery; canceling save."; $wgOut->addHTML($text); return; } // Validate category name if ($category_name === '') { $category_name_error_str = wfMessage('sf_blank_error')->text(); } else { // Redirect to wiki interface $wgOut->setArticleBodyOnly(true); $title = Title::makeTitleSafe(NS_CATEGORY, $category_name); $full_text = SFCreateCategory::createCategoryText($default_form, $category_name, $parent_category); $text = SFUtils::printRedirectForm($title, $full_text, "", $save_page, $preview_page, false, false, false, null, null); $wgOut->addHTML($text); return; } } $all_forms = SFUtils::getAllForms(); // Set 'title' as hidden field, in case there's no URL niceness global $wgContLang; $mw_namespace_labels = $wgContLang->getNamespaces(); $text = "\t" . '<form action="" method="post">' . "\n"; $firstRow = ''; if (is_null($presetCategoryName)) { $text .= "\t" . Html::hidden('title', $this->getTitle()->getPrefixedText()) . "\n"; $firstRow .= wfMessage('sf_createcategory_name')->text() . ' ' . Html::input('category_name', null, 'text', array('size' => 25)) . "\n"; if (!is_null($category_name_error_str)) { $firstRow .= Html::element('span', array('style' => 'color: red;'), $category_name_error_str) . "\n"; } } $firstRow .= "\t" . wfMessage('sf_createcategory_defaultform')->text() . "\n"; $formSelector = "\t" . Html::element('option', null, null) . "\n"; foreach ($all_forms as $form) { $formSelector .= "\t" . Html::element('option', null, $form) . "\n"; } $firstRow .= Html::rawElement('select', array('id' => 'form_dropdown', 'name' => 'default_form'), $formSelector); $text .= Html::rawElement('p', null, $firstRow) . "\n"; $secondRow = wfMessage('sf_createcategory_makesubcategory')->text() . ' '; $selectBody = "\t" . Html::element('option', null, null) . "\n"; $categories = SFUtils::getCategoriesForPage(); foreach ($categories as $category) { $category = str_replace('_', ' ', $category); $selectBody .= "\t" . Html::element('option', null, $category) . "\n"; } $secondRow .= Html::rawElement('select', array('id' => 'category_dropdown', 'name' => 'parent_category'), $selectBody); $text .= Html::rawElement('p', null, $secondRow) . "\n"; $text .= "\t" . Html::hidden('csrf', $this->getUser()->getEditToken('CreateCategory')) . "\n"; $editButtonsText = "\t" . Html::input('wpSave', wfMessage('savearticle')->text(), 'submit', array('id' => 'wpSave')) . "\n"; $editButtonsText .= "\t" . Html::input('wpPreview', wfMessage('preview')->text(), 'submit', array('id' => 'wpPreview')) . "\n"; $text .= "\t" . Html::rawElement('div', array('class' => 'editButtons'), $editButtonsText) . "\n"; $text .= "\t</form>\n"; $wgOut->addExtensionStyle($sfgScriptPath . "/skins/SemanticForms.css"); $wgOut->addHTML($text); }
/** * 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; }
/** * Outputs the entire contents of the (X)HTML page */ public function execute() { global $wgSettleTranslateDomains, $wgLanguageCode; $this->isCardPage = false; if ($this->getSkin()->getTitle()) { if ($this->getSkin()->getTitle()->exists()) { $categories = SFUtils::getCategoriesForPage($this->getSkin()->getTitle()); if (in_array('Card', $categories)) { if (!$this->getSkin()->getRequest()->getVal('action') || $this->getSkin()->getRequest()->getVal('action') == 'view') { $this->isCardPage = true; } } } } $this->cleanPage = false; if ($this->getSkin()->getTitle()) { if ($this->getSkin()->getTitle()->getNamespace() == NS_SPECIAL) { if (in_array($this->getSkin()->getTitle()->getBaseText(), array('SettleIn/about', 'SettleIn/contact', 'SettleIn/tos'))) { $this->cleanPage = true; } } } // Init $this->isLoggedIn = false; if ($this->getSkin()->getUser() && !$this->getSkin()->getUser()->isAnon()) { $this->user = $this->getSkin()->getUser(); $this->isLoggedIn = true; } $nav = $this->data['content_navigation']; $this->data['namespace_urls'] = $nav['namespaces']; $this->data['view_urls'] = $nav['views']; $this->data['action_urls'] = $nav['actions']; $this->data['variant_urls'] = $nav['variants']; // Prepare some data $this->countriesList = SettleGeoTaxonomy::getInstance()->getEntities(SettleGeoTaxonomy::TYPE_COUNTRY, null, $wgLanguageCode); $this->connectedLanguagesList = array($wgLanguageCode => Language::fetchLanguageName($wgLanguageCode)); if ($wgSettleTranslateDomains && count($wgSettleTranslateDomains)) { foreach ($wgSettleTranslateDomains as $langKey => $domain) { $this->connectedLanguagesList[$langKey] = Language::fetchLanguageName($langKey); } } $this->categoriesList = array(); //TODO: this should be reworked once fixed list of categories will be introduced $this->categoriesList = stools::getPropertyAllowedValues('Tags'); // Output HTML Page $this->html('headelement'); $this->getSkin()->getOutput()->addHeadItem('fonts', '<link href=\'http://fonts.googleapis.com/css?family=Oswald:400,300\' rel=\'stylesheet\' type=\'text/css\'>' . '<link href=\'http://fonts.googleapis.com/css?family=Oxygen:400,300,700\' rel=\'stylesheet\' type=\'text/css\'>' . '<link href=\'http://fonts.googleapis.com/css?family=PT+Sans\' rel=\'stylesheet\' type=\'text/css\'>' . '<link rel="apple-touch-icon-precomposed" sizes="144x144" href="' . $this->getSkin()->getSkinStylePath("img/favicon_precomposed.jpg") . '">' . '<link rel="icon" type="image/png" href="' . $this->getSkin()->getSkinStylePath("img/favicon.jpg") . '">'); $this->printSlideMenu(); ?> <main> <?php $title = $this->getSkin()->getTitle(); if ($title && $title->exists() && $title->getNamespace() == NS_MAIN) { if ($title->getArticleID() === Title::newMainPage()->getArticleID()) { $this->printMainPage(); // main page layout } else { $this->printNormalPage(); // normal page layout } } else { $this->printNormalPage(); // normal page layout } $this->printFooterThings(); // footer on all pages $this->printTrail(); // system trail ?> </main> </body> </html> <?php }