This repository has been archived by the owner on Jun 12, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.php
66 lines (55 loc) · 1.84 KB
/
helper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* @package com_ostoolbar
* @contact www.ostraining.com, support@ostraining.com
* @copyright 2014 Open Source Training, LLC. All rights reserved
* @license http://www.gnu.org/licenses/gpl.html GNU/GPL
*/
defined('_JEXEC') or die();
abstract class OstoolbarHelper
{
public static function splitList($string, $delimiter = ",")
{
$list = preg_split("/\s*" . $delimiter . "\s*/", $string);
return $list;
}
public static function parseParams($string)
{
$params = array();
$lines = preg_split("/\s*\\n\s*/", $string);
for ($i = 0; $i < count($lines); $i++) :
$line = $lines[$i];
$split = preg_split("/\s*=\s*/", $line);
$key = isset($split[0]) ? $split[0] : null;
$value = isset($split[1]) ? $split[1] : null;
if ($key !== null && $value !== null) :
$params[$key] = $value;
endif;
endfor;
return $params;
}
public static function renderErrors($errors)
{
$app = JFactory::getApplication();
for ($i = 0; $i < count($errors); $i++) :
$app->enqueueMessage($errors[$i], 'error');
endfor;
}
public static function setPageTitle($text, $class = 'ost-logo')
{
$html = "<div class='header " . $class . "'>\n";
$html .= "<span class='header_text'>" . $text . "</span>\n";
$html .= "</div>\n";
JToolbarHelper::title($html);
}
public static function customButton($text, $class, $id, $link)
{
$bar = JToolbar::getInstance('toolbar');
$html = "<a href=\"$link\" class=\"toolbar\">\n";
$html .= "<span class=\"$class\" title=\"$text\">\n";
$html .= "</span>\n";
$html .= "$text\n";
$html .= "</a>\n";
$bar->appendButton('Custom', $html, $id);
}
}