本文整理汇总了PHP中Module::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Module::getInstance方法的具体用法?PHP Module::getInstance怎么用?PHP Module::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Module
的用法示例。
在下文中一共展示了Module::getInstance方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
public static function getInstance($args = null)
{
if (!isset($args['class'])) {
$args['class'] = 'WeaverModule';
}
if (!isset($args['db'])) {
$args['db'] = WEAVER_IRI;
}
return parent::getInstance($args);
}
示例2: getInstance
public static function getInstance($args = null)
{
if (!isset($args['class'])) {
$args['class'] = 'MediaModule';
}
if (!isset($args['db'])) {
$args['db'] = MEDIA_IRI;
}
return parent::getInstance($args);
}
示例3: run
function run($args, $options) {
if ($options['help'] && !$args['action'])
$this->showHelp();
else {
$action = $args['action'];
global $argv;
foreach ($argv as $idx=>$val)
if ($val == $action)
unset($argv[$idx]);
require_once dirname(__file__)."/modules/{$args['action']}.php";
if (($module = Module::getInstance($action)))
return $module->_run($args['action']);
$this->stderr->write("Unknown action given\n");
$this->showHelp();
}
}
示例4: run
function run($args, $options)
{
if ($options['help'] && !$args['action']) {
$this->showHelp();
} else {
$action = $args['action'];
global $argv;
foreach ($argv as $idx => $val) {
if ($val == $action) {
unset($argv[$idx]);
}
}
foreach (glob(dirname(__FILE__) . '/modules/*.php') as $script) {
include_once $script;
}
if ($module = Module::getInstance($action)) {
return $module->_run($args['action']);
}
$this->stderr->write("Unknown action given\n");
$this->showHelp();
}
}
示例5: function
*/
use yii\helpers\Html;
use kartik\grid\GridView;
use yii\widgets\Pjax;
/** @var IdentityInterface|ActiveRecord $identity */
$identity = Yii::$app->getUser()->identityClass;
$this->title = Module::t('Requests');
echo Breadcrumbs::widget(['links' => [$this->title]]);
?>
<div class="request-log-default-index">
<h3><?php
echo Html::encode($this->title);
?>
</h3>
<?php
Pjax::begin();
echo GridView::widget(['filterModel' => $searchModel, 'dataProvider' => $dataProvider, 'columns' => [['attribute' => 'id', 'value' => function ($model, $index, $dataColumn) {
/** @var RequestLog $model */
return $model->id;
}, 'filter' => false], 'app_id', 'route', 'params', ['attribute' => 'user_id', 'value' => function ($model, $index, $dataColumn) {
return $model->user ? $model->user->{Module::getInstance()->usernameAttribute} : Module::t('Guest');
}, 'filter' => ArrayHelper::map($identity::find()->all(), 'id', Module::getInstance()->usernameAttribute)], 'ip', ['attribute' => 'datetime', 'value' => function ($model, $index, $dataColumn) {
return $model->datetime;
}, 'filter' => false], ['attribute' => 'user_agent', 'value' => function ($model, $index, $dataColumn) {
return $model->user_agent;
}, 'filter' => false]]]);
Pjax::end();
?>
</div>
示例6: sleep
public static function sleep()
{
$module = Module::getInstance();
sleep(mt_rand($module->delay_min, $module->delay_max));
}
示例7: actionRemove
public function actionRemove($id = false)
{
global $mainframe, $user;
if (!$user->isSuperAdmin()) {
YiiMessage::raseNotice("Your account not have permission to modify module");
$this->redirect(Router::buildLink("cpanel"));
}
$cids = Request::getVar("cid", 0);
$model = Module::getInstance();
$model->removeItem($cids);
YiiMessage::raseSuccess("Successfully remove Module(s)");
$this->redirect(Router::buildLink("modules"));
}
示例8: Module
/**
* @return \WPPM\Module
*/
public function Module()
{
return Module::getInstance();
}
示例9: listModules
/**
* List all availiable Modules
*/
private function listModules()
{
// get all modules listed in the database
$db = DB::getInstance();
$sql = "SELECT name\n FROM modules";
$result = $db->query($sql);
do {
$mod_db[$result->name] = '';
} while ($result->next());
// get all available modules from the file system
$dir = opendir('modules/');
// run through module directory
while (false !== ($name = readdir($dir))) {
// only real folders
if ($name != "." && $name != ".." && is_dir('modules/' . $name)) {
// is there any MODULENAME.info file?
$file = 'modules/' . $name . '/' . $name . '.info';
if (is_readable($file)) {
// read module information
$info = array();
$raw = file($file);
foreach ($raw as $line) {
$parts = explode(':', $line);
if (strtolower($parts[0]) == 'requires') {
$req = explode(',', trim($parts[1]));
if (count($req) > 0 && $req[0] != '') {
$info[strtolower($parts[0])] = $req;
}
} else {
$info[strtolower($parts[0])] = trim($parts[1]);
}
}
// is all given info correct?
if ($info['id'] == $name && !empty($info['name']) && !empty($info['version']) && !empty($info['group']) && !empty($info['description'])) {
$module = Module::getInstance($name);
unset($mod_db[$name]);
$module->version = $info['version'];
$module->requires = $info['requires'];
$module->name = $info['name'];
$module->description = $info['description'];
$module->save();
$groups[$info['group']][] = $module;
$modules[$module->id] = $module;
}
}
}
}
closedir($dir);
// are there any module entries in the db for which no module folder exist?
if (count($mod_db) > 0) {
Error::addError('Achtung: Zu einigen Einträgen in der Datenbank konnte kein Modul gefunden werden!');
}
// resolve dependancies
foreach ($modules as $m) {
$activable = $deact = true;
// all required modules active?
if (is_array($m->requires)) {
foreach ($m->requires as $r) {
if ($r->active === false) {
$activable = false;
break;
}
}
}
$m->can_act = $activable;
// any active modules which rely on the current one?
foreach ($modules as $d) {
if ($d->active === true && is_array($d->requires)) {
foreach ($d->requires as $r) {
if ($r === $m->id) {
$deact = false;
break;
}
}
}
}
$m->can_deact = $deact;
}
$tpl = new Template('module');
$tpl->assign('modules', $modules);
$tpl->assign('groups', $groups);
$tpl->assign('permission', $this->s->user->hasRights('module:activate'));
return $tpl->fetch("modules_table.html");
}