X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fplugin.php;h=65ccdafbb02af1b82277b42f77aa7cd1734f446e;hb=25864aea9dd81ebcdb8c7386af3662eda800ccc3;hp=4f53eee6b1fbc6118ab8a5a4c4445c029fa18546;hpb=be5d113fc684fcbe41b8374c62bfeb0f267216b7;p=quix0rs-gnu-social.git diff --git a/lib/plugin.php b/lib/plugin.php index 4f53eee6b1..65ccdafbb0 100644 --- a/lib/plugin.php +++ b/lib/plugin.php @@ -27,7 +27,7 @@ * @link http://status.net/ */ -if (!defined('STATUSNET')) { +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } @@ -65,6 +65,8 @@ class Plugin Event::addHandler(mb_substr($method, 2), array($this, $method)); } } + + $this->setupGettext(); } function initialize() @@ -76,4 +78,42 @@ class Plugin { return true; } + + /** + * Checks if this plugin has localization that needs to be set up. + * Gettext localizations can be called via the _m() helper function. + */ + protected function setupGettext() + { + $class = get_class($this); + if (substr($class, -6) == 'Plugin') { + $name = substr($class, 0, -6); + $path = INSTALLDIR . "/plugins/$name/locale"; + if (file_exists($path) && is_dir($path)) { + bindtextdomain($name, $path); + } + } + } + + protected function log($level, $msg) + { + common_log($level, get_class($this) . ': '.$msg); + } + + protected function debug($msg) + { + $this->log(LOG_DEBUG, $msg); + } + + function onPluginVersion(&$versions) + { + $cls = get_class($this); + $name = mb_substr($cls, 0, -6); + + $versions[] = array('name' => $name, + 'version' => _('Unknown')); + + return true; + } } +