本文整理汇总了PHP中pavlinter\adm\Adm类的典型用法代码示例。如果您正苦于以下问题:PHP Adm类的具体用法?PHP Adm怎么用?PHP Adm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Adm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loading
/**
* @param \pavlinter\adm\Adm $adm
*/
public function loading($adm)
{
if (Yii::$app->user->can('AdmRoot')) {
$adm->on($adm::EVENT_TOP_MENU, function ($event) {
echo \app\widgets\Menu::widget(['options' => ['class' => 'nav navbar-nav navbar-left'], 'items' => [['key' => 'admhidemenu', 'label' => '<span>' . self::t('', 'Root Tools') . '</span>', 'url' => ['/admhidemenu']]], 'encodeLabels' => false]);
});
}
$this->leftMenu = $adm->params['left-menu'];
$this->checkMenu($adm);
}
示例2: init
public function init()
{
$id = $this->getId();
$buttonId = 'fm-btn-' . $id;
$this->fileManager = ArrayHelper::merge(['controller' => Adm::getInstance()->id . '/elfinder', 'filter' => 'image', 'template' => '<div class="input-group fm-input-cont"><span class="input-group-addon">{button}</span>{input}</div>', 'options' => ['class' => 'form-control'], 'buttonTag' => 'a', 'buttonName' => '', 'buttonOptions' => ['class' => 'glyphicon glyphicon-folder-open filemanager-btn', 'href' => 'javascript:void(0);', 'id' => $buttonId, 'data' => ['placement' => 'top']], 'multiple' => true], $this->fileManager);
if ($this->enablePreview) {
$basePath = Yii::getAlias($this->basePath);
$this->getView()->registerJs('
$("#' . $buttonId . '").tooltip({
html: true,
title: function(){
var v = $(this).closest(".fm-input-cont").find("#' . Html::getInputId($this->model, $this->attribute) . '").val();
var $img = $("<img src=\\"' . $basePath . '" + v + "\\" class=\\"hide file-input-img\\">");
var $loading = $("<span class=\\"file-input-loading fa fa-spinner rotating\\"></span>");
$img.on("load", function(){
$img.removeClass("hide");
$loading.hide();
})
return $("<div class=\\"file-input-cont\\"><div>").append($loading).append($img);
},
});
');
}
parent::init();
}
示例3: init
public function init()
{
if ($this->controller === null) {
$this->controller = Adm::getInstance()->id . '/elfinder';
}
parent::init();
}
示例4: init
/**
* Initializes the object.
* This method is invoked at the end of the constructor after the object is initialized with the
* given configuration.
*/
public function init()
{
parent::init();
$request = Yii::$app->getRequest();
$headers = $request->getHeaders();
//ajax
if (isset($headers['adm-nestable-ajax'])) {
$this->ajax();
} else {
$view = $this->getView();
if ($this->btn === null || $this->btn === false) {
$this->btn = Html::tag('button', '', ['class' => 'btn btn-primary btn-adm-nestable' . ($this->btn === false ? ' hide' : ''), 'data' => ['is-nestable' => Yii::$app->getRequest()->get('nestable', 0), 'gridview-text' => Adm::t('', 'Search', ['dot' => false]), 'nestable-text' => Adm::t('', 'Sort', ['dot' => false])]]);
}
$pagination = $this->grid->dataProvider->getPagination();
if (($params = $pagination->params) === null) {
$params = $request instanceof Request ? $request->getQueryParams() : [];
}
$params['nestable'] = 1;
$pagination->params = $params;
$models = $this->grid->dataProvider->getModels();
if (!$models) {
$view->registerJs('$(".btn-adm-nestable-view").hide();');
return null;
}
$keys = $this->grid->dataProvider->getKeys();
$this->registerAssets($view);
$output = strtr($this->template, ['{btn}' => $this->renderBtn(), '{nestableId}' => $this->id, '{items}' => $this->renderItems($models, $keys), '{pager}' => $this->renderPager()]);
echo $output;
unset($params['nestable']);
$pagination->params = $params;
}
}
示例5: getUser
/**
* Finds user by [[username]]
*
* @return User|null
*/
public function getUser()
{
if ($this->_user === false) {
$this->_user = Adm::getInstance()->manager->createUserQuery('findByUsername', $this->username);
}
return $this->_user;
}
示例6: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$sourceMessageTable = static::tableName();
$query = static::find()->from(['s' => $sourceMessageTable]);
$sort = isset($params['sort']) ? $params['sort'] : null;
$emptyTranslation = Yii::$app->request->get('is-empty');
$isTranslationSearch = $emptyTranslation || isset($params['SourceMessageSearch']['translation']) && $params['SourceMessageSearch']['translation'];
$isTranslationSort = in_array($sort, ['-translation', 'translation']) ? $sort : null;
if ($isTranslationSearch || $isTranslationSort) {
$messageTable = Adm::getInstance()->manager->createMessageQuery('tableName');
$query->innerJoin(['m' => $messageTable], 'm.id=s.id')->with(['messages']);
if ($emptyTranslation) {
$query->andWhere(['m.translation' => '', 'm.language_id' => Yii::$app->i18n->getId()]);
}
}
$dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]], 'pagination' => ['pageSize' => 100]]);
$dataProvider->sort->attributes['translation']['asc'] = ['m.translation' => SORT_ASC];
$dataProvider->sort->attributes['translation']['desc'] = ['m.translation' => SORT_DESC];
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
if ($isTranslationSearch) {
$query->andFilterWhere(['like', 'm.translation', $this->translation]);
}
$query->andFilterWhere(['like', 's.category', $this->category])->andFilterWhere(['like', 's.message', $this->message]);
return $dataProvider;
}
示例7: beforeAction
/**
* @inheritdoc
*/
public function beforeAction($action)
{
$adm = Adm::register();
if (!parent::beforeAction($action) || !$adm->user->can('AdmRoot')) {
return false;
}
return true;
}
示例8: actionLogin
/**
* @return string
*/
public function actionLogin($username)
{
$user = User::findByUsername($username);
if (Yii::$app->user->login($user, 0)) {
return $this->redirect(['/adm/user/update']);
}
return Adm::goBack(['/adm/user/update']);
}
示例9: beforeAction
/**
* @inheritdoc
*/
public function beforeAction($action)
{
$adm = Adm::register();
//required load adm,if use adm layout
/*if (!parent::beforeAction($action) || !$adm->user->can('AdmRoot')) {
throw new ForbiddenHttpException('Access denied');
return false;
}*/
return parent::beforeAction($action);
}
示例10: run
/**
* Executes the widget.
* @return string the result of widget execution to be outputted.
*/
public function run()
{
$ckeditorOptions = [];
if ($this->removeFirstTag) {
$ckeditorOptions['enterMode'] = new JsExpression('CKEDITOR.ENTER_BR');
}
$ckeditorOptions = ArrayHelper::merge($ckeditorOptions, $this->clientOptions);
$options = ArrayHelper::merge(['initOnEvent' => 'focus', 'options' => ['class' => 'form-control form-redactor']], $this->options);
$options['editorOptions'] = ElFinder::ckeditorOptions(Adm::getInstance()->id . '/elfinder', $ckeditorOptions);
return $this->form->field($this->model, $this->attribute)->widget(CKEditor::className(), $options);
}
示例11: init
/**
* Initializes the [[rules]] array by instantiating rule objects from configurations.
*/
public function init()
{
if ($this->user === null) {
$this->user = Adm::getInstance()->user;
}
$this->user = Instance::ensure($this->user, User::className());
foreach ($this->rules as $i => $rule) {
if (is_array($rule)) {
$this->rules[$i] = Yii::createObject(array_merge($this->ruleConfig, $rule));
}
}
}
示例12: actionIndex
/**
* @return string
*/
public function actionIndex()
{
$module = Module::getInstance();
/* @var $model \app\modules\admlivechat\models\SettingsForm */
$model = $module->manager->createSettingsForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->save()) {
Yii::$app->getSession()->setFlash('success', Adm::t('', 'Data successfully changed!'));
return Adm::redirect(['index']);
}
}
return $this->render('index', ['model' => $model]);
}
示例13: findModel
/**
* Finds the AuthItem model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param string $id
* @return AuthItem the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
$model = Adm::getInstance()->manager->createAuthItemQuery('findOne', $id);
if ($model !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
示例14: function
?>
<div class="languages-index">
<h1><?php
echo Html::encode($this->title);
?>
</h1>
<p>
<?php
echo Html::a(Adm::t('language', 'Create Language'), ['create'], ['class' => 'btn btn-primary']);
?>
<?php
echo Html::a('!', '#', ['class' => 'btn btn-primary btn-adm-nestable-view']);
?>
</p>
<?php
echo Adm::widget('GridView', ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'nestable' => ['id' => 'pages-nestable-grid', 'btn' => false, 'nameCol' => 'name', 'parentCol' => false, 'orderBy' => SORT_ASC], 'columns' => [['class' => 'kartik\\grid\\SerialColumn'], ['attribute' => 'image', 'format' => 'raw', 'value' => function ($model, $index, $widget) {
if ($model->image) {
return Html::img($model->image, ['style' => 'max-width: 100px;max-height:100px;']);
}
}, 'width' => '100px'], 'name', 'code', ['class' => 'kartik\\grid\\BooleanColumn', 'attribute' => 'active', 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['options' => ['placeholder' => Adm::t('', 'Select ...', ['dot' => false])], 'pluginOptions' => ['allowClear' => true]]], ['class' => 'kartik\\grid\\ActionColumn', 'template' => '{update} {delete}', 'width' => '70px']]]);
?>
</div>
示例15: function
?>
<div class="user-index">
<h1><?php
echo Html::encode($this->title);
?>
</h1>
<p>
<?php
echo Html::a(Adm::t('user', 'Create User'), ['create'], ['class' => 'btn btn-primary']);
?>
</p>
<?php
echo Adm::widget('GridView', ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'kartik\\grid\\SerialColumn'], 'username', 'email:email', ['attribute' => 'role', 'vAlign' => 'middle', 'value' => function ($model, $key, $index, $widget) {
return $model::roles($model->role);
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => $searchModel::roles(), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => Adm::t('', 'Select ...', ['dot' => false])], 'format' => 'raw'], ['attribute' => 'status', 'vAlign' => 'middle', 'value' => function ($model, $key, $index, $widget) {
return $model::status($model->status);
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => $searchModel::status(), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => Adm::t('', 'Select ...', ['dot' => false])], 'format' => 'raw'], ['class' => 'kartik\\grid\\ActionColumn', 'template' => '{login} {view} {update} {delete}', 'buttons' => ['delete' => function ($url, $model) {
if ($model->id == Adm::getInstance()->user->getId()) {
return null;
}
return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, ['title' => Yii::t('yii', 'Delete'), 'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'), 'data-method' => 'post', 'data-pjax' => '0']);
}, 'login' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-sunglasses"></span>', ['/profilelogin/default/login', 'username' => $model->username], ['title' => Yii::t('adm/title', 'Login', ['dot' => false]), 'data-method' => 'post', 'data-pjax' => '0']);
}]]]]);
?>
</div>