Introduce getFile to the plugin api
Useful to get files (like smiley graphics) from the fallback chain
This commit is contained in:
parent
d97cdf7378
commit
b73dd8bb1e
@ -1635,7 +1635,6 @@ class serendipity_plugin
|
|||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param string template filename (no directory!)
|
* @param string template filename (no directory!)
|
||||||
* @param bool Called by a plugin (defaults true), since we do not have a theme using it yet
|
|
||||||
* @return string Parsed Smarty return
|
* @return string Parsed Smarty return
|
||||||
*/
|
*/
|
||||||
function &parseTemplate($filename)
|
function &parseTemplate($filename)
|
||||||
@ -1651,6 +1650,26 @@ class serendipity_plugin
|
|||||||
return $serendipity['smarty']->fetch('file:'. $tfile);
|
return $serendipity['smarty']->fetch('file:'. $tfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get full path for a filename. Will first look into themes and then in the plugins directory
|
||||||
|
* @param string relative path to file
|
||||||
|
* @param string The path selector that tells whether to return a HTTP or realpath
|
||||||
|
* @return string The full path+filename to the requested file
|
||||||
|
* */
|
||||||
|
function &getFile($filename, $key = 'serendipityPath')
|
||||||
|
{
|
||||||
|
global $serendipity;
|
||||||
|
|
||||||
|
$path = serendipity_getTemplateFile($filename, $key, true);
|
||||||
|
if (!$path) {
|
||||||
|
if (file_exists(dirname($this->pluginFile) . '/' . $filename)) {
|
||||||
|
return $serendipity[$key] . 'plugins/' . basename(dirname($this->pluginFile)) . '/' . $filename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,12 +80,8 @@ class serendipity_event_emoticate extends serendipity_event
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Hijack global variable $serendipity['custom_emoticons'] if it exists */
|
/* Hijack global variable $serendipity['custom_emoticons'] if it exists */
|
||||||
if ($serendipity['version'][0] > 1) {
|
|
||||||
// called in backend too, but uses frontend fallback. Advise to use the Plugin simple approach 4th parameter!
|
|
||||||
$hijack_file = serendipity_getTemplateFile('emoticons.inc.php', 'serendipityPath', true, true);
|
|
||||||
} else {
|
|
||||||
$hijack_file = serendipity_getTemplateFile('emoticons.inc.php', 'serendipityPath', true);
|
$hijack_file = serendipity_getTemplateFile('emoticons.inc.php', 'serendipityPath', true);
|
||||||
}
|
|
||||||
if (@file_exists($hijack_file)) {
|
if (@file_exists($hijack_file)) {
|
||||||
@include $hijack_file; // This file contains $serendipity['custom_emoticons'] and maybe $serendipity['custom_emoticons_regexp']
|
@include $hijack_file; // This file contains $serendipity['custom_emoticons'] and maybe $serendipity['custom_emoticons_regexp']
|
||||||
if (isset($serendipity['custom_emoticons']) && is_array($serendipity['custom_emoticons'])) {
|
if (isset($serendipity['custom_emoticons']) && is_array($serendipity['custom_emoticons'])) {
|
||||||
@ -102,23 +98,23 @@ class serendipity_event_emoticate extends serendipity_event
|
|||||||
if (!isset($this->smilies)) {
|
if (!isset($this->smilies)) {
|
||||||
$ext = $this->get_config('extension', 'png');
|
$ext = $this->get_config('extension', 'png');
|
||||||
$this->smilies = array(
|
$this->smilies = array(
|
||||||
"\:'\(" => serendipity_getTemplateFile('img/emoticons/cry.'.$ext, 'serendipityHTTPPath', true),
|
"\:'\(" => $this->getFile('img/emoticons/cry.'.$ext, 'serendipityHTTPPath'),
|
||||||
|
|
||||||
'\:\-?\)' => serendipity_getTemplateFile('img/emoticons/smile.'.$ext, 'serendipityHTTPPath', true),
|
'\:\-?\)' => $this->getFile('img/emoticons/smile.'.$ext, 'serendipityHTTPPath'),
|
||||||
|
|
||||||
'\:\-?\|' => serendipity_getTemplateFile('img/emoticons/normal.'.$ext, 'serendipityHTTPPath', true),
|
'\:\-?\|' => $this->getFile('img/emoticons/normal.'.$ext, 'serendipityHTTPPath'),
|
||||||
|
|
||||||
'\:\-?O' => serendipity_getTemplateFile('img/emoticons/eek.'.$ext, 'serendipityHTTPPath', true),
|
'\:\-?O' => $this->getFile('img/emoticons/eek.'.$ext, 'serendipityHTTPPath'),
|
||||||
|
|
||||||
'\:\-?\(' => serendipity_getTemplateFile('img/emoticons/sad.'.$ext, 'serendipityHTTPPath', true),
|
'\:\-?\(' => $this->getFile('img/emoticons/sad.'.$ext, 'serendipityHTTPPath'),
|
||||||
|
|
||||||
'8\-?\)' => serendipity_getTemplateFile('img/emoticons/cool.'.$ext, 'serendipityHTTPPath', true),
|
'8\-?\)' => $this->getFile('img/emoticons/cool.'.$ext, 'serendipityHTTPPath'),
|
||||||
|
|
||||||
'\:\-?D' => serendipity_getTemplateFile('img/emoticons/laugh.'.$ext, 'serendipityHTTPPath', true),
|
'\:\-?D' => $this->getFile('img/emoticons/laugh.'.$ext, 'serendipityHTTPPath'),
|
||||||
|
|
||||||
'\:\-?P' => serendipity_getTemplateFile('img/emoticons/tongue.'.$ext, 'serendipityHTTPPath', true),
|
'\:\-?P' => $this->getFile('img/emoticons/tongue.'.$ext, 'serendipityHTTPPath'),
|
||||||
|
|
||||||
';\-?\)' => serendipity_getTemplateFile('img/emoticons/wink.'.$ext, 'serendipityHTTPPath', true),
|
';\-?\)' => $this->getFile('img/emoticons/wink.'.$ext, 'serendipityHTTPPath'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user