-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallme.php
More file actions
65 lines (57 loc) · 1.83 KB
/
callme.php
File metadata and controls
65 lines (57 loc) · 1.83 KB
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
<?php
/**
* @package Joomla.Plugin
* @subpackage Content.callme
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Mariella {@link www.ladyj.eu}
* @author Created on 04-Dec-2014
* @license GNU/GPL
*/
defined('_JEXEC') || die;
jimport('joomla.plugin.plugin');
/**
* Content Plugin.
*
* Replace telephone numbers with a clic-to-call reference:
* <a href="tel:...">...</a>
*
* @package callme
* @subpackage Plugin
*/
class plgContentcallme extends JPlugin {
/**
* @param string $text text to be scanned and modified
* @return boolean always returns true
*/
protected function callme (&$text)
{
//pattern matches 4 digits
//followed by a space, '-' or '/' followed by 4 digits more
$pattern = '/([0-9]{4})-? ?\/?([0-9]{4})/';
$replacement = '<a href="tel:$1$2">$1/$2</a>';
$text = preg_replace($pattern, $replacement, $text);
return true;
}
/**
* Example prepare content method
*
* Method is called by the view
*
* @param string $context The context of the content being passed to the plugin.
* @param object &$article The content object. Note $article->text is also available
* @param object &$params The content params
* @param int $limitstart The 'page' number
* @return boolean always returs true
*/
public function onContentPrepare($context, &$article, &$params, $limitstart)
{
if ($context == 'com_finder.indexer') {
return true;
}
if (is_object($article)) {
return $this->callme($article->text);
}
return $this->callme($article);
}//function
}//class