I'm woking on a MediaWiki skin for my site. For the page content I'm using <?= $this->html( 'bodycontent' ); ?> to output it all. Part of this, on longer pages, is the Table of Contents (TOC).
I would like to move the location of the TOC out of the body an into the sidebar but I'm not sure how to prevent the TOC from showing in the bodycontent or where to get the raw data to display it in the sidebar.
I'm hoping there is a data time similar to $this->data['sidebar']['navigation'] that I can use to format it how I want.
How can I turn off the TOC in the bodycontent?
Is there a $this->data location that has the TOC data?
The MediaWiki skinning system is not really designed for this, but someone created an extension to make your work easier: https://www.mediawiki.org/wiki/Extension:DeToc
Using that extension you would do something like this (inside function execute()):
$body = $this->data['bodycontent'];
$new_body = DeToc::RemoveToc($body, $extracted_toc);
/* Print body */
echo $new_body;
/* Print TOC somewhere else */
echo $extracted_toc;
Alternatively you could just turn off the TOC, using $parser->mShowToc = false;, and then create the TOC yourself. MediaWiki internally uses a regex like this to find all sections: '/^\={2,5}(.*?)\={2,5}$/m'
Related
We have to recreate a Government form from our website. The form is full of vertical and horizontal lines and different width and height cells. Some cells contain pre-printed text and have two or three lines of data.
We have created the Web page to capture and validate the dynamic data and now need a method of rendering the form (A4) to the printer. The client does not want a classic PDF print preview so our normal reporting tool will not work. Can anyone guide me on how to create a print output using css, html with vertical and horizontal lines and positioned data.
Sorry if I affended this board, I was actually trying to get some guidance from the experts
Our current code is below. We use Jaspersoft Ireports to design the form layout and the PHPJasperXML library to render a PDF and write a copy on the server.
I have to rewrite this using CSS & HTML and render in an Iframe with an immediate (kiosk) print. I'm just looking for the right approach before I go down the wrong route.
include "config.php";
$version="0.9d";$pgport=5432;
$pchartfolder="./class/pchart2";
$ecsd_id = $_REQUEST['ecsd_id'];
include_once('class/tcpdf/tcpdf.php');
include_once("class/PHPJasperXML.inc.php");
ob_clean();
$PHPJasperXML = new PHPJasperXML();
//$PHPJasperXML->debugsql=true;
$PHPJasperXML->arrayParameter=array('ecsd_id'=>$ecsd_id);
$PHPJasperXML->load_xml_file("ecsd_pdp.jrxml");
//$PHPJasperXML->transferDBtoArray($server,$user,$pass,$db);
$PHPJasperXML->transferDBtoArray($dbhost,$dbuser,$dbpass,$dbname);
//$PHPJasperXML->load_xml_file("ecsd_pdp_copy.jrxml");
$PHPJasperXML->outpage("I");
$PHPJasperXML->outpage("F", "ecsd_prints/" . $ecsd_id . ".pdf");
//page output method I:standard output F =save as filename and submit and parameter as destinate file name D:Download file
I am trying to remove the footer in my MediaWiki installation
"This page was last modified..."
Number of views
Privacy policy link
MediaWiki image
I am using the Vector theme.
The instructions on the MediaWiki site don't seem to match the Vector theme, which appears to be the default one.
I can't find any of the $wg elements mentioned on the MediaWiki site (such as $wgHooks and $wgMaxCredits) in the Vector theme itself. So how can I modify the theme to remove the footer elements?
Any help or advice would be much appreciated. I am sure I am missing some part of the MediaWiki site, but can't seem to find it.
I'm not sure why you want to do that, but here are some thoughts:
The "This page was last modified..." message is constructed with the Lastmodifiedat interface message. So, if you edit MediaWiki:Lastmodifiedat in your wiki and remove any contents, the footer element will be empty (even if the li-element is still there!).
The number of views was removed in MediaWiki 1.25, so i suggest you upgrade your wiki and the count will be away automatically ;) If you don't want to upgrade or can't (for whatever reason) you can set $wgDisableCounters = false; in your LocalSettings.php.
The privacy, about and disclaimer link can be removed by replacing the appropriate interface messages with a dash "-". Just edit these pages on your wiki:
MediaWiki:Privacy
MediaWiki:Aboutsite
MediaWiki:Disclaimers
To remove the MediaWiki image, you just need to set this line in your LocalSettings.php:
$wgFooterIcons['poweredby'] = array();
Btw.: You don't see most of the variables and interface messages in the Vector skin, because the footer is mostly generated in MediaWiki itself and the Skin simply handels how it is displayed, not what is displayed.
You can use CSS to remove the footer for any theme or skin: there is a common CSS file built into the MediaWiki database behind each wiki:
http://<your-site>/wiki/index.php/MediaWiki:Common.css
Enter that link in your browser to go that page. Then click the "Edit" link to edit that page and add this line to the page:
#footer { display: none; }
NOTE: You may not want to remove the entire footer. You can remove individual components by entering them in the WikiMedia:Common.css instead:
/* last modification stuff */
#footer-info { display: none; }
/* footer links */
#footer-places { display: none; }
/* powered by icon */
#footer-icon { display: none; }
Personally, I would keep the footer-icon which contains the Powered by MediaWiki icon, and give credit where it is due.
If you are working with the MobileFrontend extension then you will also need to add the same lines to:
http://<your-site>/wiki/index.php/MediaWiki:Mobile.css
Do you want to remove the WikiMedia footer or just change it?
I can see wanting to remove parts of the default footer like the last modification string. You can use CSS to hide it as I mentioned above or you can enter this URL into your browser:
http://<your-site>/wiki/index.php/MediaWiki:Lastmodifiedat
Edit that page and remove the line that's there, then save the page. The last modification stuff will disappear from your wiki pages.
But the footer links section can be very useful. If you want to CHANGE the footer links, there is a hook (SkinTemplateOutputPageBeforeExec) provided in the MediaWiki docs:
https://www.mediawiki.org/wiki/Manual%3AFooter#Add_links_to_the_footer
If you want to REMOVE the existing footer links and ADD YOUR OWN new footer links, follow the instructions in the embedded comments and then add this PHP code to your LocalSettings.php file:
# Remove all existing footer links and add my own
$wgHooks['SkinTemplateOutputPageBeforeExec'][] = function( $sk, &$tpl ) {
# IMPORTANT: this is the secret sauce - remove all existing footer links
$tpl->data['footerlinks']['places'] = array();
# To add new footer links to local wiki pages:
#
# 1) You MUST create your new pages in your (Main) namespace first, for example:
#
# http://<your-site>/wiki/index.php/About_Us
# http://<your-site>/wiki/index.php/Contact_Us
# http://<your-site>/wiki/index.php/Disclaimer
# http://<your-site>/wiki/index.php/Download
# http://<your-site>/wiki/index.php/Privacy_Policy
#
# 2) You MUST then create each of these pages in your MediaWiki namespace:
#
# http://<your-site>/wiki/index.php/MediaWiki:Aboutpage
# - Insert 1 line, with "About Us" (no quotes)
# http://<your-site>/wiki/index.php/MediaWiki:Contactpage
# - Insert 1 line, with "Contact Us" (no quotes)
# http://<your-site>/wiki/index.php/MediaWiki:Disclaimerpage
# - Insert 1 line, with "Disclaimer" (no quotes)
# http://<your-site>/wiki/index.php/MediaWiki:Downloadpage
# - Insert 1 line, with "Download" (no quotes)
# http://<your-site>/wiki/index.php/MediaWiki:Privacypage
# - Insert 1 line, with "Privacy Policy" (no quotes)
#
# 3) Add new footer links like this:
$tpl->set( 'aboutpage', $sk->footerLink( 'aboutpage', 'aboutpage' ) );
$tpl->data['footerlinks']['places'][] = 'aboutpage';
$tpl->set( 'contactpage', $sk->footerLink( 'contactpage', 'contactpage' ) );
$tpl->data['footerlinks']['places'][] = 'contactpage';
$tpl->set( 'disclaimerpage', $sk->footerLink( 'disclaimerpage', 'disclaimerpage' ) );
$tpl->data['footerlinks']['places'][] = 'disclaimerpage';
$tpl->set( 'downloadpage', $sk->footerLink( 'downloadpage', 'downloadpage' ) );
$tpl->data['footerlinks']['places'][] = 'downloadpage';
$tpl->set( 'privacypage', $sk->footerLink( 'privacypage', 'privacypage' ) );
$tpl->data['footerlinks']['places'][] = 'privacypage';
return true;
};
IMPORTANT: Don't forget to follow the instructions and create your own pages and the corresponding MediaWiki redirects, or your links may not show or they may be broken.
We have our site running on Drupal. Now I have 2 landingpages: pages without menu's and a bit different in layout as the others. I want to edit the complete HTML of the pages in the Drupal-interface, so marketeers can easily add HTML-snippets (for testing etc), without using a developer.
How could I create an empty header and footer, and let the complete HTML be the content?
You could create a specific node type, and then use this function in your template.php :
<?php
function theme_preprocess_page(&$variables)
{
if (isset($variables['node']->type))
{
$nodetype = $variables['node']->type;
$variables['theme_hook_suggestions'][] = 'page__' . $nodetype;
}
}
It will allows you to create templates for pages (Drupal is only offering this possibility for the page content) based on node types using page--node-type.tpl.php, so that you'll be able to customize the entire page html instead of just the content.
I created my event pages with a different website. That website generated an html page for me(with Javascript, CSS hosted at their end) each time I created an event. I would like to embed the event pages into my website. In order to achieve, I tried to create a blank page template like below:
<?php
/**
* Template Name: Blank
*
*/
if (have_posts()) {
while (have_posts()) { the_post();
the_content();
}
}
?>
Then pasted the content (including head and body) into WYSIWYG editor. However, WordPress pushes everything into body. How can I create a pure blank page template and have the ability to edit everything with WYSIWYG?
Not quite sure if this is the best way to solve your problem. If I understand correctly you want to include events from website X in a page on website Y?
Assuming you set up events as a custom post type, you could use an 'event' RSS feed on website X: http://www.website-x/feed/?post_type=event
Then, on website Y reed the feed using:
$content = file_get_contents('http://www.wesite-x/feed/?post_type=event');
$x = new SimpleXmlElement($content);
foreach($x->channel->item as $entry)
{
$title = $entry->title;
//ETC...
}
It's not wysiwyg but it well get you all the content you need, and you can do whatever you want with it.
Hope this helps.
I have a textarea wherein the user can enter any kind of HTML (and that includes javascript). After that, I allow the user to preview it in his browser. The way that works is by POSTing the content to a page that displays the said content in a "template" kind of thing. The backend's in PHP.
Page 1
an HTML form that simply has a textarea
Page 2 (where the form gets submitted)
PHP code to echo the HTML entered in the textarea unmodified,
with an intention of keeping all HTML formatting as-is
Now, I'm aware of XSS. But my intention here is to only allow that particular user to preview whatever he's written. The content he enters won't be stored or shown to other people.
Since I'll be allowing anonymous users, my idea was to use a simple CSRF-like protection to ensure that only the user who generated the preview can view it.
That's the basic idea. I want the user to be able to preview arbitrary HTML of his choosing, while not opening up potential security holes. Is there any security aspect I'm overlooking?
I assume that in your code, there is an AJAX call submitting the content and it gets converted and comes out. So, in your PHP file, while outputting the code, give this.
Method #1: HTML Safe
<?php
...
$output = /* The final output */;
$output = htmlspecialchars($output);
die ($output);
?>
Method #2: Stripping certain tags
<?php
...
$output = /* The final output */;
$aDisabledAttributes = array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavaible', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragdrop', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterupdate', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmoveout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload')
$output = strip_tags($output, "<p><a><b><i><em><strong><table><ul><ol><li>");
die ($output);
?>