GSGreenText/GSGreenTextPlugin.php

47 lines
1.1 KiB
PHP

<?php
if (!defined('GNUSOCIAL')) {
exit(1);
}
class GreenTextPlugin extends Plugin
{
const VERSION = '0.0.1';
public function onEndShowStyles(Action $action)
{
$action->style(".greentext { color: green; }");
}
public function onQvitterEndShowHeadElements(Action $action)
{
$this->onEndShowStyles($action);
}
function onStartNoticeSave(&$notice)
{
$sepnotice = preg_split("/<br\s*?\/?>\r?\n*/", $notice->rendered, -1);
foreach($sepnotice as &$sep)
{
if(0 === strpos($sep, '&gt;'))
{
$sep = "<span class='greentext'>" . $sep . "</span>";
}
}
$notice->rendered = implode("<br />" . PHP_EOL, $sepnotice);
}
function onPluginVersion(array &$versions)
{
$versions[] = array('name' => 'GreenText',
'version' => self::VERSION,
'author' => 'MoonMan',
'homepage' => '',
'description' =>
_m('Starting line with ">" makes line green.'));
return true;
}
}