summaryrefslogtreecommitdiff
path: root/Ribbon_body.php
diff options
context:
space:
mode:
Diffstat (limited to 'Ribbon_body.php')
-rw-r--r--Ribbon_body.php79
1 files changed, 79 insertions, 0 deletions
diff --git a/Ribbon_body.php b/Ribbon_body.php
new file mode 100644
index 0000000..e687495
--- /dev/null
+++ b/Ribbon_body.php
@@ -0,0 +1,79 @@
+<?php
+
+class Ribbon {
+
+ static $content;
+
+ function onParserInit( Parser $parser ) {
+
+ $parser->setHook( 'ribbon', array( __CLASS__, 'renderRibbon' ) );
+ return true;
+
+ }
+
+ static function onBeforePageDisplay( OutputPage &$out, Skin &$skin ) {
+
+ $out->addModuleStyles( array (
+ 'ext.ribbon'
+ ) );
+
+ }
+
+ static function renderRibbon( $input, array $args, Parser $parser, PPFrame $frame ) {
+
+ $text = str_replace( "\n", '<br>', htmlspecialchars( $input ));
+
+ if (array_key_exists( 'square', $args ))
+ $square = intval($args['']);
+ else
+ $square = 369;
+
+ if (array_key_exists( 'height', $args ))
+ $height = intval($args['height']);
+ else
+ $height = 35;
+
+ if (array_key_exists( 'fsize', $args ))
+ $fsize = intval($args['fsize']);
+ else
+ $fsize = 15;
+
+ $sign = '';
+
+ $middle = $square / 2;
+ $top = $middle - intval($middle * sin(deg2rad(45)));
+ $right = intval($middle * cos(deg2rad(45))) - $middle - $height;
+
+ $html = ''
+ . '<div class="corner-ribbon-wrapper right" style="'
+ . 'width: ' . $square . 'px; '
+ . 'height: ' . $square . 'px;">'
+ . '<div class="corner-ribbon" style="'
+ . 'top: ' . $top . 'px; '
+ . 'right: ' . $right . 'px; '
+ . '-webkit-transform: rotate(' . $sign . '45deg);'
+ . '-moz-transform: rotate(' . $sign . '45deg);'
+ . '-ms-transform: rotate(' . $sign . '45deg);'
+ . '-o-transform: rotate(' . $sign . '45deg);'
+ . 'transform: rotate(' . $sign . '45deg);'
+ . 'font-size: ' . $fsize . 'px;">'
+ . '<a class="ribbon-link" style="'
+ . 'width: ' . $square . 'px; '
+ . 'line-height: ' . $height . 'px;"'
+ . 'href="#">' . $text
+ . '</a></div></div>';
+
+ $javascript = ''
+ . '<script type="text/javascript">'
+ . '(function () {'
+ . 'document.body.insertAdjacentHTML( "afterbegin", \'' . $html . '\' );'
+ . '}());'
+ . '</script>';
+
+ return array( $javascript, "markerType" => 'nowiki' );
+
+ }
+
+}
+
+?>