本文整理汇总了PHP中get_addon_class函数的典型用法代码示例。如果您正苦于以下问题:PHP get_addon_class函数的具体用法?PHP get_addon_class怎么用?PHP get_addon_class使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_addon_class函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAllAddon
/**
* 获取插件列表
* @param string $addon_dir
* @author jry <598821125@qq.com>
*/
public function getAllAddon($addon_dir = THINK_ADDON_PATH)
{
$dirs = array_map('basename', glob($addon_dir . '*', GLOB_ONLYDIR));
if ($dirs === FALSE || !file_exists($addon_dir)) {
$this->error = '插件目录不可读或者不存在';
return FALSE;
}
$addons = array();
$map['name'] = array('in', $dirs);
$list = $this->where($map)->field(true)->order('sort asc,id desc')->select();
foreach ($list as $addon) {
$addons[$addon['name']] = $addon;
}
foreach ($dirs as $value) {
if (!isset($addons[$value])) {
$class = get_addon_class($value);
if (!class_exists($class)) {
// 实例化插件失败忽略执行
\Think\Log::record('插件' . $value . '的入口文件不存在!');
continue;
}
$obj = new $class();
$addons[$value] = $obj->info;
if ($addons[$value]) {
$addons[$value]['status'] = -1;
//未安装
}
}
}
foreach ($addons as &$val) {
switch ($val['status']) {
case '-1':
//未安装
$val['status'] = '<i class="glyphicon glyphicon-trash" style="color:red"></i>';
$val['right_button'] = '<a class="ajax-get" href="' . U('install?addon_name=' . $val['name']) . '">安装</a>';
break;
case '0':
//禁用
$val['status'] = '<i class="glyphicon glyphicon-ban-circle" style="color:red"></i>';
$val['right_button'] = '<a href="' . U('config', array('id' => $val['id'])) . '">设置</a> ';
$val['right_button'] .= '<a class="ajax-get" href="' . U('setStatus', array('status' => 'resume', 'ids' => $val['id'])) . '">启用</a> ';
$val['right_button'] .= '<a class="ajax-get" href="' . U('uninstall?id=' . $val['id']) . '">卸载</a> ';
if ($val['adminlist']) {
$val['right_button'] .= '<a href="' . U('adminlist', array('name' => $val['name'])) . '">管理</a>';
}
break;
case '1':
//正常
$val['status'] = '<i class="glyphicon glyphicon-ok" style="color:green"></i>';
$val['right_button'] = '<a href="' . U('config', array('id' => $val['id'])) . '">设置</a> ';
$val['right_button'] .= '<a class="ajax-get" href="' . U('setStatus', array('status' => 'forbid', 'ids' => $val['id'])) . '">禁用</a> ';
$val['right_button'] .= '<a class="ajax-get" href="' . U('uninstall?id=' . $val['id']) . '">卸载</a> ';
if ($val['adminlist']) {
$val['right_button'] .= '<a href="' . U('adminlist', array('name' => $val['name'])) . '">管理</a>';
}
break;
}
}
return $addons;
}
示例2: getRank
public function getRank()
{
$aType = I('post.type', 'today', 'op_t');
$name = get_addon_class('CheckIn');
$class = new $name();
$html = $class->rank($aType);
$this->ajaxReturn(array('status' => 1, 'html' => $html));
}
示例3: _initialize
public function _initialize()
{
$class = get_addon_class('BaiduRankTool');
if (!class_exists($class)) {
$this->error('插件不存在');
}
$this->addon = new $class();
$this->_config = $this->addon->getConfig();
}
示例4: get_addon_config
/**
* 获取插件类的配置文件数组
* @param string $name 插件名
*/
function get_addon_config($name)
{
$class = get_addon_class($name);
if (class_exists($class)) {
$addon = new $class();
return $addon->getConfig();
} else {
return array();
}
}
示例5: getList
/**
* 获取插件列表
* @param string $addon_dir
*/
public function getList($addon_dir = '')
{
if (!$addon_dir) {
$addon_dir = ONETHINK_ADDON_PATH;
}
$dirs = array_map('basename', glob($addon_dir . '*', GLOB_ONLYDIR));
//TODO 新增模块插件的支持
/* $modules=D('Module')->getAll();
foreach($modules as $m){
if($m['is_setup']){
$module_dir=APP_PATH.$m['name'].'/Addons/';
if(!file_exists($module_dir)){
continue;
}
$tmp_dirs = array_map('basename',glob($module_dir.'*', GLOB_ONLYDIR));
$dirs=array_merge($dirs,$tmp_dirs);
}
}*/
if ($dirs === FALSE || !file_exists($addon_dir)) {
$this->error = '插件目录不可读或者不存在';
return FALSE;
}
$addons = array();
$where['name'] = array('in', $dirs);
$list = $this->where($where)->field(true)->select();
foreach ($list as $addon) {
$addon['uninstall'] = 0;
$addons[$addon['name']] = $addon;
}
foreach ($dirs as $value) {
if (!isset($addons[$value])) {
$class = get_addon_class($value);
if (!class_exists($class)) {
// 实例化插件失败忽略执行
\Think\Log::record('插件' . $value . '的入口文件不存在!');
continue;
}
$obj = new $class();
$addons[$value] = $obj->info;
if ($addons[$value]) {
$addons[$value]['uninstall'] = 1;
unset($addons[$value]['status']);
}
}
}
//dump($list);exit;
int_to_string($addons, array('status' => array(-1 => '损坏', 0 => '禁用', 1 => '启用', null => '未安装')));
$addons = list_sort_by($addons, 'uninstall', 'desc');
return $addons;
}
示例6: getList
/**
* 获取插件列表
*
* @param string $addon_dir
*/
public function getList($addon_dir = '')
{
if (!$addon_dir) {
$addon_dir = ONETHINK_ADDON_PATH;
}
$dirs = array_map('basename', glob($addon_dir . '*', GLOB_ONLYDIR));
if ($dirs === FALSE || !file_exists($addon_dir) || count($dirs) == 0) {
$this->error = '插件目录不可读或者不存在';
return FALSE;
}
$addons = array();
$where['name'] = array('in', $dirs);
$list = $this->where($where)->field(true)->order('id desc')->select();
foreach ($list as $addon) {
$addon['is_weixin'] = file_exists($addon_dir . $addon['name'] . '/Model/WeixinAddonModel.class.php');
$addon['uninstall'] = 0;
$addon['is_show_text'] = $addon['is_show'] == 1 ? '是' : '否';
$addons[$addon['name']] = $addon;
}
foreach ($dirs as $value) {
if (!isset($addons[$value])) {
$class = get_addon_class($value);
if (!class_exists($class)) {
// 实例化插件失败忽略执行
\Think\Log::record('插件' . $value . '的入口文件不存在!');
continue;
}
$obj = new $class();
$addons[$value] = $obj->info;
if ($addons[$value]) {
$addons[$value]['uninstall'] = 1;
unset($addons[$value]['status']);
}
$addons[$value]['is_weixin'] = file_exists($addon_dir . $value . '/Model/WeixinAddonModel.class.php');
}
}
foreach ($addons as $key => $val) {
if (!$val['is_weixin']) {
unset($addons[$key]);
}
}
int_to_string($addons, array('status' => array(-1 => '损坏', 0 => '禁用', 1 => '启用', null => '未安装')));
$addons = list_sort_by($addons, 'uninstall', 'desc');
return $addons;
}
示例7: config
public function config()
{
$this->getModel();
if (IS_POST) {
$flag = D('Common/AddonConfig')->set(_ADDONS, I('config'));
if ($flag !== false) {
$this->success('保存成功', Cookie('__forward__'));
} else {
$this->error('保存失败');
}
}
$map['name'] = _ADDONS;
$addon = M('addons')->where($map)->find();
if (!$addon) {
$this->error('插件未安装');
}
$addon_class = get_addon_class($addon['name']);
if (!class_exists($addon_class)) {
trace("插件{$addon['name']}无法实例化,", 'ADDONS', 'ERR');
}
$data = new $addon_class();
$addon['addon_path'] = $data->addon_path;
$addon['custom_config'] = $data->custom_config;
$this->meta_title = '设置插件-' . $data->info['title'];
$db_config = D('Common/AddonConfig')->get(_ADDONS);
// dump ( $db_config );
$addon['config'] = (include $data->config_file);
if ($db_config) {
foreach ($addon['config'] as $key => $value) {
if ($value['type'] != 'group') {
!isset($db_config[$key]) || ($addon['config'][$key]['value'] = $db_config[$key]);
} else {
foreach ($value['options'] as $gourp => $options) {
foreach ($options['options'] as $gkey => $value) {
!isset($db_config[$key]) || ($addon['config'][$key]['options'][$gourp]['options'][$gkey]['value'] = $db_config[$gkey]);
}
}
}
}
}
$this->assign('data', $addon);
$this->display();
}
示例8: removeHooks
/**
* 去除插件所有钩子里对应的插件数据
*/
public function removeHooks($name)
{
$addons_class = get_addon_class($name);
if (!class_exists($addons_class)) {
return false;
}
$methods = get_class_methods($addons_class);
$hooks = $this->getField('name', true);
$common = array_intersect($hooks, $methods);
if ($common) {
foreach ($common as $hook) {
$flag = $this->removeAddons($hook, array($name));
if (false === $flag) {
return false;
}
}
}
return true;
}
示例9: config
function config()
{
$normal_tips = '配置完保存后,在微信里回复: 会员卡,即可看到效果。';
$this->assign('normal_tips', $normal_tips);
$this->getModel();
if (IS_POST) {
if ($_POST['config']['background'] == 11) {
$_POST['config']['background_custom'] = get_cover_url($_POST['config']['bg']);
}
$flag = D('Common/AddonConfig')->set(_ADDONS, I('config'));
if ($flag !== false) {
$this->success('保存成功', Cookie('__forward__'));
} else {
$this->error('保存失败');
}
}
$map['name'] = _ADDONS;
$addon = M('Addons')->where($map)->find();
if (!$addon) {
$this->error('插件未安装');
}
$addon_class = get_addon_class($addon['name']);
$data = new $addon_class();
$addon['addon_path'] = $data->addon_path;
$addon['custom_config'] = $data->custom_config;
$db_config = D('Common/AddonConfig')->get(_ADDONS);
$addon['config'] = (include $data->config_file);
if ($db_config) {
foreach ($addon['config'] as $key => $value) {
if ($value['type'] != 'group') {
!isset($db_config[$key]) || ($addon['config'][$key]['value'] = $db_config[$key]);
} else {
foreach ($value['options'] as $gourp => $options) {
foreach ($options['options'] as $gkey => $value) {
!isset($db_config[$key]) || ($addon['config'][$key]['options'][$gourp]['options'][$gkey]['value'] = $db_config[$gkey]);
}
}
}
}
}
$this->assign('data', $addon);
$this->display();
}
示例10: getList
/**
* 获取插件列表
* @param string $addon_dir
*/
public function getList($addon_dir = '')
{
if (!$addon_dir) {
$addon_dir = ZS_ADDON_PATH;
}
$dirs = array_map('basename', glob($addon_dir . '*', GLOB_ONLYDIR));
if ($dirs === FALSE || !file_exists($addon_dir)) {
$this->error = '插件目录不可读或者不存在';
return FALSE;
}
$addons = array();
$where['name'] = array('in', $dirs);
$list = $this->where($where)->field(true)->select();
foreach ($list as $addon) {
$addon['uninstall'] = 0;
$addons[$addon['name']] = $addon;
}
foreach ($dirs as $value) {
if (!isset($addons[$value])) {
$class = get_addon_class($value);
if (!class_exists($class)) {
// 实例化插件失败忽略执行
\Think\Log::record('插件' . $value . '的入口文件不存在!');
continue;
}
$obj = new $class();
$addons[$value] = $obj->info;
$admin_list = $obj->admin_list;
if ($addons[$value]) {
$addons[$value]['uninstall'] = 1;
unset($addons[$value]['status']);
}
if ($admin_list) {
$addons[$value]['has_adminlist'] = 1;
} else {
$addons[$value]['has_adminlist'] = 0;
}
}
}
int_to_string($addons, array('status' => array(-1 => '损坏', 0 => '禁用', 1 => '启用', null => '未安装')));
$addons = list_sort_by($addons, 'uninstall', 'desc');
return $addons;
}
示例11: getList
public function getList()
{
$dirs = array_map('basename', glob(ADDON_PATH . '*', GLOB_ONLYDIR));
if ($dirs === false || !file_exists(ADDON_PATH)) {
$this->error = '插件目录不可读或者不存在';
return array();
}
$addons = array();
$list = $this->select();
foreach ($list as &$info) {
$info['uninstall'] = 0;
$addons[$info['name']] = $info;
}
foreach ($dirs as $value) {
if (!isset($addons[$value])) {
$class = get_addon_class($value);
if (!class_exists($class)) {
// 实例化插件失败忽略执行
\Think\Log::record('插件' . $value . '的入口文件不存在!');
continue;
}
$obj = new $class();
$addons[$value] = $obj->info;
if ($addons[$value]) {
$addons[$value]['uninstall'] = 1;
$addons[$value]['status'] = null;
}
}
}
$result = array();
$map = array('status' => array(-1 => '损坏', 0 => '禁用', 1 => '启用', null => '未安装'));
foreach ($addons as $key => &$row) {
if (!in_array($key, $dirs)) {
$row['status'] = -1;
}
$row['status_text'] = $map['status'][$row['status']] ?: '-';
array_push($result, $row);
}
return $result;
}
示例12: getList
/**
* 获取插件列表
* @param string $addon_dir
* @param int $limit
* @return array|bool
*/
public function getList($addon_dir = '', $limit = 0)
{
if (!$addon_dir) {
$addon_dir = Addon_PATH;
}
$dirs = array_map('basename', glob($addon_dir . '*', GLOB_ONLYDIR));
if ($dirs === false || !File::file_exists($addon_dir)) {
$this->error = '插件目录不可读或者不存在';
return false;
}
$addons = array();
$where['name'] = array('in', $dirs);
$list = $this->where($where)->field(true)->limit($limit)->select();
foreach ($list as $addon) {
$addon['uninstall'] = 0;
$addons[$addon['name']] = $addon;
}
foreach ($dirs as $value) {
if (!isset($addons[$value])) {
$class = get_addon_class($value);
if (!class_exists($class)) {
// 实例化插件失败忽略执行
\Think\Log::record('插件' . $value . '的入口文件不存在!');
continue;
}
$obj = new $class();
$addons[$value] = $obj->info;
if ($addons[$value]) {
$addons[$value]['uninstall'] = 1;
$addons[$value]['status'] = 99;
}
} else {
//todo 已安装的
}
}
int_to_string($addons, array('status' => array(-1 => '损坏', 0 => '禁用', 1 => '启用', 99 => '未安装')));
$addons = list_sort_by($addons, 'uninstall', 'desc');
return $addons;
}
示例13: del
public function del($id = '', $name)
{
$ids = array_unique((array) I('ids', 0));
if (empty($ids)) {
$this->error('请选择要操作的数据!');
}
$class = get_addon_class($name);
if (!class_exists($class)) {
$this->error('插件不存在');
}
$addon = new $class();
$param = $addon->admin_list;
if (!$param) {
$this->error('插件列表信息不正确');
}
extract($param);
if (isset($model)) {
$addonModel = D("Addons://{$name}/{$model}");
if (!$addonModel) {
$this->error('模型无法实列化');
}
}
$map = array('id' => array('in', $ids));
if ($addonModel->where($map)->delete()) {
$this->success('删除成功');
} else {
$this->error('删除失败!');
}
}
示例14: ajax_apiparam
/**
* 根据Api获取参数
*/
public function ajax_apiparam()
{
if (IS_AJAX) {
$addonstype = I('cate', 0);
$addonsid = I('cateid', 0);
if (!in_array($addonstype, array('local', 'cloud'))) {
$data['status'] = 0;
$data['errmsg'] = '插件不存在';
$this->ajaxReturn($data, 'JSON');
} else {
if ($addonstype == 'local') {
$addon_name = M('Addons')->where(array('id' => $addonsid))->getField('name');
$class = get_addon_class($addon_name);
if (!class_exists($class)) {
$data['status'] = 0;
$data['errmsg'] = '插件不存在';
$this->ajaxReturn($data, 'JSON');
}
$addons = new $class();
$paramlist = $addons->info['weixinkeyword']['option'];
$newlist = array();
foreach ($paramlist as $key => $value) {
$newlist[] = array('0' => $key, '2' => $key . '【' . $value . '】');
}
$data['status'] = 1;
$data['msg'] = $newlist;
$this->ajaxReturn($data, 'JSON');
}
}
}
}
示例15: sendSMS
function sendSMS($mobile, $content)
{
$sms_hook = modC('SMS_HOOK', 'none', 'USERCONFIG');
$sms_hook = check_sms_hook_is_exist($sms_hook);
if ($sms_hook == 'none') {
return L('_THE_ADMINISTRATOR_HAS_NOT_CONFIGURED_THE_SMS_SERVICE_PROVIDER_INFORMATION_PLEASE_CONTACT_THE_ADMINISTRATOR_');
}
$name = get_addon_class($sms_hook);
$class = new $name();
return $class->sendSms($mobile, $content);
}