本文整理汇总了PHP中Plugin::call方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugin::call方法的具体用法?PHP Plugin::call怎么用?PHP Plugin::call使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plugin
的用法示例。
在下文中一共展示了Plugin::call方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _retreat
function _retreat($params)
{
$user = $params['user'];
$channel = $params['channel'];
$inchannels = DB::get()->col('SELECT name FROM channels WHERE user_id = :user_id', array('user_id' => $user->id));
$join = 'office:' . $user->username;
$joinalias = $this->_room_alias($join);
foreach ($inchannels as $partchan) {
DB::get()->query('DELETE FROM channels WHERE name = :name AND user_id = :user_id;', array('name' => $partchan, 'user_id' => $user->id));
if (preg_match('%^search:(?P<criteria>.+)$%i', $partchan, $searchmatches)) {
DB::get()->query("DELETE FROM options WHERE name = :name AND grouping = 'searches' AND user_id = :user_id;", array('name' => $searchmatches['criteria'], 'user_id' => $user->id));
} else {
if ($partchan != $join) {
Status::create()->data("{$user->username} has retreated to <a href=\"#\" onclick=\"joinRoom('" . addslashes($join) . "');return false;\">{$joinalias}</a> from {$partchan}")->type('part')->channel($partchan)->insert();
}
}
}
DB::get()->query('INSERT INTO channels (name, user_id, last) VALUES (:name, :user_id, NOW());', array('name' => $join, 'user_id' => $user->id));
if (!($herald = DB::get()->val("SELECT value FROM options WHERE user_id = :user_id AND name = :name AND grouping = :grouping", array('user_id' => $user->id, 'name' => 'Herald', 'grouping' => 'Identity')))) {
$herald = '{$nickname} has joined {$room}';
}
$js = '';
$cssclass = '';
$packed = Plugin::call('herald', array('herald' => $herald, 'js' => $js, 'cssclass' => $cssclass));
extract($packed);
$herald = str_replace('{$nickname}', $user->nickname, $herald);
$herald = str_replace('{$room}', $joinalias, $herald);
$msg = htmlspecialchars($herald);
Status::create()->data($msg)->type('join')->cssclass($cssclass)->channel($join)->js($js)->insert();
Immediate::create()->laststatus()->js('setRoom("' . addslashes($join) . '");');
return true;
}
示例2: index
function index($path)
{
$cmd = $_POST['cmd'];
$auto = array($_POST['cmd']);
$auto = $this->_autocomplete($auto, $cmd);
$users = DB::get()->col('SELECT username FROM users;');
$nicks = DB::get()->col("SELECT value FROM options WHERE grouping = 'Identity' AND name = 'Nickname';");
$users = $users + $nicks;
$userregex = implode('|', array_map('preg_quote', $users));
$cmd = preg_replace('%(' . $userregex . ')%i', '{$nickname}', $cmd);
$autos = Plugin::call('autocomplete', $auto, $cmd);
$auto = array();
foreach ($autos as $op) {
if (strpos($op, '{$nickname}') === false) {
$auto[] = $op;
} else {
foreach ($users as $user) {
$auto[] = str_replace('{$nickname}', $user, $op);
}
}
}
foreach ($auto as $k => $v) {
if ($v[0] == '*') {
$auto[$k] = substr($v, 1);
continue;
}
if (strncasecmp($cmd, $v, strlen($cmd)) != 0) {
unset($auto[$k]);
}
}
sort($auto);
echo json_encode($auto);
}
示例3: render
public function render($viewname = '')
{
$glob = glob(MICROSITE_PATH . '/microsite/views/*.php');
$views = array();
foreach ($glob as $view) {
$views[basename($view, '.php')] = $view;
}
$views = Plugin::call('viewlist', $views);
if ($viewname == '') {
if ($this->vars['_view'] != '') {
$viewname = $this->vars['_view'];
} else {
$viewname = '404';
}
}
if (isset($views[$viewname])) {
foreach ($this->vars as $k => $v) {
if ($k[0] != '_') {
${$k} = $v;
}
}
$view = $this;
ob_start();
include $views[$viewname];
$out = ob_get_clean();
$out = new Dom($out);
return $out;
} else {
throw new Exception('View does not exist: ' . $viewname);
}
}
示例4: __construct
function __construct($path)
{
$chanbar = ' <ul>
<li id="settings" class="option"><a href="#" class="button">settings</a></li>
<li id="files" class="option"><a href="#" class="button">files</a></li>
<li id="people" class="option"><a href="#" class="button">people</a></li>
</ul>
';
$user = Auth::user();
$curchan = DB::get()->val('SELECT name from channels where user_id = :user_id AND active = 1', array('user_id' => $user->id));
if ($curchan == '') {
$curchan = 'bar';
}
$widgets = Widgets::get_widgets();
$components = array('title' => 'Barchat Home', 'path' => $path, 'chanbar' => $chanbar, 'user_id' => Auth::user_id(), 'username' => $user->username, 'nickname' => $user->nickname, 'session_key' => $user->session_key, 'cur_chan' => addslashes($curchan), 'widgets' => $widgets);
$v = new View($components);
Plugin::call('reload', $user);
//check for user agent
$useragent = $_SERVER['HTTP_USER_AGENT'];
//
if (preg_match('/ip(hone|od|ad)/i', $useragent)) {
$v->render('template-ios');
} else {
$v->render('template');
}
}
示例5: render
public function render($viewname = '')
{
$glob = glob(MICROSITE_PATH . '/microsite/views/*.php');
$views = array();
foreach ($glob as $view) {
$views[basename($view, '.php')] = $view;
}
$views = Plugin::call('viewlist', $views);
if ($viewname == '') {
if ($this->vars['_view'] != '') {
$viewname = $this->vars['_view'];
} else {
$viewname = 'table';
}
}
if (isset($views[$viewname])) {
foreach ($this->vars as $k => $v) {
if ($k[0] != '_') {
${$k} = $v;
}
}
$view = $this;
include $views[$viewname];
} else {
echo 'View does not exist: ' . $viewname;
}
}
示例6: get_widgets
function get_widgets()
{
$user = Auth::user();
$active_widgets = DB::get()->results("SELECT * FROM options WHERE user_id = :user_id AND grouping = 'widgets' ORDER BY name ASC", array('user_id' => $user->id));
$widgets = array();
foreach ($active_widgets as $widgetdata) {
$data = (object) unserialize($widgetdata->value);
$data->id = $widgetdata->id;
$contents = Plugin::call('widget_' . $data->name, "{$data->name}", $data);
$title = isset($data->title) ? $data->title : $data->name;
$widgets[$data->id] = '<div class="widget ' . $data->name . '" id="widget_' . $data->id . '">
<div class="widgettitle" ondblclick="$(this).parents(\'.widget\').children(\'.widgetbody\').slideToggle();return false;">' . $title . '
<a class="removewidget" href="#" onclick="removeWidget(' . $data->id . ');return false;">[-]</a>
<a class="collapsewidget" href="#" onclick="$(this).parents(\'.widget\').children(\'.widgetbody\').slideToggle();return false;">[v]</a>
</div><div class="widgetbody"><div class="widgetcontent">' . $contents . '</div></div></div>';
}
$widgets = implode('', array_filter($widgets));
return $widgets;
}
示例7: dispatch
/**
* @brief dispatch 路由分发方法
*
* @return void
*/
public static function dispatch()
{
// 注册最后的通用路由
$route = array('widget' => 'Page', 'method' => 'showPage', 'format' => '/%s/', 'patter' => '|^/([^/]+)[/]?$|', 'params' => array('alias'));
self::setRoute('Page', $route);
// 获取地址信息
if (OptionLibrary::get('rewrite') == 'open') {
$pathInfo = str_replace(substr(LOGX_PATH, 0, strlen(LOGX_PATH) - 1), '', Request::S('REQUEST_URI', 'string'));
$pathInfo = str_replace('?' . Request::S('QUERY_STRING', 'string'), '', $pathInfo);
} else {
$pathInfo = self::getPathInfo();
}
$pathInfo = Plugin::call('pathInfo', $pathInfo);
// 遍历路由表进行匹配
foreach (self::$_routeTable as $key => $route) {
if (preg_match($route['patter'], $pathInfo, $matches)) {
self::$_currentRoute = $key;
$params = NULL;
if (!empty($route['params'])) {
unset($matches[0]);
$params = array_combine($route['params'], $matches);
}
self::$_currentParams = $params;
if (isset($route['widget'])) {
Widget::getWidget($route['widget'])->{$route}['method']($params);
} elseif (isset($route['plugin'])) {
Plugin::getPlugin($route['plugin'])->{$route}['method']($params);
}
return;
}
}
//echo '**'.$_SERVER['QUERY_STRING'];
//$path = explode( '/', $pathInfo );
// 永久重定向为规范的 URL 地址
//Response::redirect( $pathInfo.'/', true );
// 没有匹配的路由则显示 404 页面
Response::error(404);
}
示例8: _get_options
function _get_options()
{
// Core options:
$optionlist = array(array('Amazon Web Services', 'AWS Secret Access Key'), array('Amazon Web Services', 'AWS Access Key ID'), array('Amazon Web Services', 'S3 Bucket Name'), array('Time', 'Zone Offset'));
// Plugin options
$optionlist = Plugin::call('get_options', $optionlist);
$options = array('system' => array(), 'user' => array());
foreach ($optionlist as $option) {
$opobj = Option::get($option[0], $option[1]);
if (!is_object($opobj)) {
$opobj = new Option();
$opobj->grouping = $option[0];
$opobj->name = $option[1];
$opobj->id = $option[0] . ':' . $option[1];
}
if ($opobj->user_id == 0) {
$options['system'][] = $opobj;
} else {
$options['user'][] = $opobj;
}
}
return $options;
}
示例9: widgetContent
/**
* @brief widgetContent 输出小工具内容
*
* @param $widget 小工具对象
* @param $format 输出格式
*
* @return void
*/
public function widgetContent($widget, $format = '')
{
echo Plugin::call($widget['call'], $format);
}
示例10: postComment
/**
* @brief postComment 发表评论
*
* @return void
*/
public function postComment()
{
$c = array();
// 如果用户已登录,则可以不填写基本信息
if (Widget::getWidget('User')->isLogin()) {
$user = Widget::getWidget('User')->getUser();
$c['uid'] = $user['uid'];
$c['author'] = $user['username'];
$c['email'] = $user['email'];
$c['website'] = $user['website'];
} else {
$c['uid'] = 0;
$c['author'] = Request::P('author', 'string');
$c['email'] = Request::P('email', 'string');
$c['website'] = Request::P('website', 'string');
}
$c['pid'] = Request::P('postId');
$c['content'] = Request::P('content', 'string');
$error = '';
if (!$c['pid'] || !$c['author'] || !$c['email'] || !$c['content']) {
// 检查信息完整性
$error = _t('Author, Email and Content can not be null.');
} else {
// 检查文章是否存在、是否允许评论
Widget::initWidget('Post');
$post = new PostLibrary();
$p = $post->getPost($c['pid']);
if ($p) {
Widget::getWidget('Post')->setPID($c['pid']);
} else {
$p = $post->getPage($c['pid'], FALSE);
Widget::getWidget('Post')->setAlias($p['alias']);
}
if (!Widget::getWidget('Post')->query() || !Widget::getWidget('Post')->postAllowReply()) {
$error = _t('Comment closed.');
} else {
// TODO 敏感词过滤
// TODO 内容处理
$c['content'] = str_replace(array("\r\n", "\n", "\r"), '<br />', htmlspecialchars($c['content']));
$c = Plugin::call('postComment', $c);
// 写入评论
$comment = new CommentLibrary();
$comment->postComment($c);
// 评论计数加一
$post->incReply($c['pid']);
// 保存用户信息
Response::setCookie('author', $c['author'], time() + 24 * 3600 * 365);
Response::setCookie('email', $c['email'], time() + 24 * 3600 * 365);
Response::setCookie('website', $c['website'], time() + 24 * 3600 * 365);
}
}
if ($error) {
$r = array('success' => FALSE, 'message' => $error);
} else {
$r = array('success' => TRUE, 'message' => _t('Post comment success.'));
}
if (Request::isAjax()) {
Response::ajaxReturn($r);
} else {
if ($error) {
Response::error(_t('Post failed'), $error);
} else {
Response::back();
}
}
}
示例11: __call
/**
* @brief __call 魔术方法,用于处理钩子
*
* @param $name 钩子名
* @param $arguments 钩子参数
*
* @return mix
*/
public function __call($name, $arguments)
{
return Plugin::call($name, $arguments);
}
示例12: postPage
/**
* @brief postPage 发布页面
*
* @return void
*/
public function postPage()
{
$p = array();
$p['title'] = Request::P('title', 'string');
$p['alias'] = Request::P('alias', 'string');
$p['content'] = Request::P('content', 'string');
if (!$p['title'] || !$p['content'] || !$p['alias']) {
$r = array('success' => FALSE, 'message' => _t('Title, Content and Alias can not be null.'));
Response::ajaxReturn($r);
return;
}
$p['allow_reply'] = Request::P('allowComment') ? 1 : 0;
$user = Widget::getWidget('User')->getUser();
$p['uid'] = $user['uid'];
$p['top'] = 0;
$p['type'] = 2;
$p['status'] = 1;
$post = new PostLibrary();
// 检查别名是否重复
if ($post->getPage($p['alias'])) {
$r = array('success' => FALSE, 'message' => _t('Alias already exists.'));
Response::ajaxReturn($r);
return;
}
// 写入页面
$pid = $post->postPost($p);
// 处理新附件
$meta = new MetaLibrary();
$meta->setType(3);
$meta->setPID(1000000000);
$attachments = $meta->getMeta();
foreach ($attachments as $a) {
$meta->movRelation($a['mid'], 1000000000, $pid);
}
// 插件接口
$p['pid'] = $pid;
Plugin::call('postPage', $p);
$r = array('success' => TRUE, 'message' => _t('Add page success.'));
Response::ajaxReturn($r);
}
示例13: PHP_JS
<script type="text/javascript" src="/js/jquery.cssrule.js"></script>
<link type="text/css" rel="stylesheet" href="/js/syntax/styles/shCore.css"/>
<link type="text/css" rel="stylesheet" href="/js/syntax/styles/shThemeDefault.css"/>
<script type="text/javascript">
SyntaxHighlighter.config.clipboardSwf = '/js/syntax/scripts/clipboard.swf';
var cur_chan = '<?php
echo $cur_chan;
?>
';
</script>
<script type="text/javascript">$P = new PHP_JS();</script>
<?php
Plugin::call('header');
?>
</head>
<body>
<div id="drawer"><table></table></div>
<div id="mainscroller">
<table id="notices" class="notices"></table>
<div id="portal" class="portal"></div>
<script type="text/javascript">
var user_id = <?php
echo $user_id;
?>
;
var username = '<?php
示例14: _instant_time
function _instant_time($params)
{
$user = $params['user'];
$channel = $params['channel'];
$task = $params['task'];
$pcode = $this->_project_alias($params['pcode']);
$time = $params['time'];
$approx = $params['approx'];
$notes = $params['notes'];
$return = true;
if (strpos($time, ':') === 0) {
$hours = floatval(substr($time, 1)) / 60;
} elseif (strpos($time, ':') > 0) {
list($hours, $minutes) = split(':', $time);
$hours = intval($hours) + $minutes / 60;
} else {
$hours = floatval($time);
}
if (strpos($approx, ':') === 0) {
$est = floatval(substr($approx, 1)) / 60;
} elseif (strpos($approx, ':') > 0) {
$est = (strtotime($approx) - strtotime($time)) / 3600;
} elseif (trim($approx) == '') {
$est = null;
} else {
$est = floatval($approx);
}
extract(Plugin::call('task_filter', array('task' => $task, 'notes' => $notes)));
$timerec = array('time' => $hours, 'ondate' => date('Y-m-d'), 'pcode' => $pcode, 'task' => $task, 'notes' => $notes, 'billable' => !(preg_match('%-\\$%', $task) || preg_match('%-\\$%', $notes)));
$projects = $this->_get_projects();
if (in_array($timerec['pcode'], $projects)) {
$this->_add_time($timerec);
$msg = "<span class=\"time\">Added {$hours} hours</span> <span class=\"project\">{$pcode}</span> <span class=\"task\">{$task}</span>";
Immediate::ok($msg, 'ok time time_instant');
} else {
Immediate::error('Specified project "' . $timerec['pcode'] . '" does not exist.');
}
return $return;
}
示例15: Plugin
<?php
namespace Garradin;
require_once __DIR__ . '/_inc.php';
$page = Utils::get('_u') ?: 'index.php';
$plugin = new Plugin(Utils::get('_p'));
define('Garradin\\PLUGIN_ROOT', $plugin->path());
define('Garradin\\PLUGIN_URL', WWW_URL . 'admin/plugin/' . $plugin->id() . '/');
define('Garradin\\PLUGIN_QSP', '?');
$tpl->assign('plugin', $plugin->getInfos());
$tpl->assign('plugin_root', PLUGIN_ROOT);
$plugin->call('admin/' . $page);