本文整理汇总了PHP中Backend::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Backend::model方法的具体用法?PHP Backend::model怎么用?PHP Backend::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Backend
的用法示例。
在下文中一共展示了Backend::model方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Initializes the component. The backend to use is chosen here. If a
* current backend is stored in the session we use that, otherwise we fall
* back on whatever backend is set as default.
*/
public function init()
{
$currentBackendId = Yii::app()->session->get(self::SESSION_KEY);
if ($currentBackendId !== null) {
$this->_backend = Backend::model()->findByPk($currentBackendId);
} else {
$this->_backend = Backend::model()->default()->find();
}
parent::init();
}
示例2: array
<?php
$leftItems = array(array('label' => Yii::t('Menu', 'Movies'), 'items' => array(array('label' => Yii::t('Menu', 'Browse'), 'url' => array('movie/index'), 'active' => in_array($this->route, array('movie/index', 'movie/details'))), array('label' => Yii::t('Menu', 'Recently added'), 'url' => array('movie/recentlyAdded'))), 'linkOptions' => array('class' => 'fa fa-video-camera')), array('label' => Yii::t('Menu', 'TV Shows'), 'items' => array(array('label' => Yii::t('Menu', 'Browse'), 'url' => array('tvShow/index'), 'active' => in_array($this->route, array('tvShow/index', 'tvShow/details', 'tvShow/season'))), array('label' => Yii::t('Menu', 'Recently added'), 'url' => array('tvShow/recentlyAdded'))), 'linkOptions' => array('class' => 'fa fa-desktop')));
$rightItems = array();
// Add a "Change backend" menu when there's more than one configured backend
$backends = Backend::model()->findAll();
if (count($backends) > 1) {
$backendItems = array();
$currentBackend = Yii::app()->backendManager->getCurrent();
foreach ($backends as $backend) {
$label = $backend->name;
if ($currentBackend !== null && $currentBackend->id == $backend->id) {
$label = TbHtml::icon(TbHtml::ICON_OK) . ' ' . $label;
}
$backendItems[] = array('label' => $label, 'url' => array('backend/change', 'id' => $backend->id));
}
$rightItems[] = array('label' => Yii::t('Menu', 'Change backend'), 'items' => $backendItems, 'linkOptions' => array('class' => 'fa fa-cloud'));
}
// Add the "Settings" menu for administrators
if (Yii::app()->user->role == User::ROLE_ADMIN) {
$rightItems[] = array('label' => Yii::t('Menu', 'Settings'), 'items' => array(array('label' => Yii::t('Menu', 'Settings')), array('label' => Yii::t('Menu', 'Manage'), 'url' => array('setting/admin')), array('label' => Yii::t('Menu', 'Backends')), array('label' => Yii::t('Menu', 'Manage'), 'url' => array('backend/admin')), array('label' => Yii::t('Menu', 'Create new'), 'url' => array('backend/create')), array('label' => Yii::t('Menu', 'Users')), array('label' => Yii::t('Menu', 'Manage'), 'url' => array('user/admin')), array('label' => Yii::t('Menu', 'Create new'), 'url' => array('user/create')), array('label' => Yii::t('Menu', 'System log')), array('label' => Yii::t('Menu', 'Browse'), 'url' => array('log/'))), 'linkOptions' => array('class' => 'fa fa-cogs'));
}
// Add the "Actions" menu
$changeLanguageItem = array('label' => Yii::t('Menu', 'Change language'), 'url' => '#', 'linkOptions' => array('data-toggle' => 'modal', 'data-target' => '#change-language-modal'));
$actions = array(array('label' => Yii::t('Menu', 'Interface')), $changeLanguageItem, array('label' => Yii::t('Menu', 'System')));
// Only show "Flush cache" if cacheApiCalls is enabled
if (Setting::getBoolean('cacheApiCalls')) {
$actions[] = array('label' => Yii::t('Menu', 'Flush cache'), 'url' => array('site/flushCache'), 'linkOptions' => array('confirm' => Yii::t('Misc', 'Are you sure you want to flush the cache?')));
}
$actions[] = array('label' => Yii::t('Menu', 'Update library'), 'url' => array('backend/updateLibrary'), 'linkOptions' => array('confirm' => Yii::t('Misc', "Are you sure you want to update the backend's library?")));
if (Yii::app()->powerOffManager->getAllowedActions()) {
示例3: requireDefaultBackend
/**
* Checks that there is another backend set as default if the default
* checkbox is unchecked for this one
* @param string $attribute the attribute being validated
*/
public function requireDefaultBackend($attribute)
{
if (!$this->{$attribute}) {
$error = Yii::t('Backend', 'There must be a default backend');
// If this backend is currently the default one it must remain so
if (!$this->isNewRecord) {
$model = $this->findByPk($this->id);
if ($model->default) {
$this->addError($attribute, $error);
}
}
// If there are no other backends then this must be the default one
if (count(Backend::model()->findAll()) === 0) {
$this->addError($attribute, $error);
}
}
}
示例4: array
<?php
/* @var $this BackendController */
/* @var $model Backend */
$this->pageTitle = $title = Yii::t('Backend', 'Manage backends');
?>
<h2><?php
echo $title;
?>
</h2>
<?php
echo FormHelper::helpBlock(Yii::t('Backend', 'This is where you configure your backends. A
backend is an instance of XBMC that the application connects to and serves
library contents from. If you specify more than one backend, a new item
will appear in the main menu, allowing you to easily switch backends.'));
?>
<?php
echo TbHtml::linkButton(Yii::t('Backend', 'Create new backend'), array('color' => TbHtml::BUTTON_COLOR_PRIMARY, 'url' => array('create')));
?>
<hr />
<?php
$this->widget('bootstrap.widgets.TbGridView', array('type' => TbHtml::GRID_TYPE_STRIPED, 'dataProvider' => Backend::model()->dataProvider, 'enableSorting' => false, 'template' => '{items}', 'columns' => array('name', 'hostname', 'port', 'tcp_port', array('name' => 'default', 'header' => Yii::t('Backend', 'Default'), 'type' => 'raw', 'value' => function ($data) {
return $data->default ? TbHtml::icon(TbHtml::ICON_OK) : '';
}), 'macAddress', 'subnetMask', array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{update} {delete}'))));
示例5: actionCreate
/**
* Creates a new backend, then return to the admin action
*/
public function actionCreate()
{
$model = new Backend();
if (isset($_POST['Backend'])) {
$model->attributes = $_POST['Backend'];
// Check whether this is the first backend ever created, if so we
// redirect to the settings page
$firstRun = $this->getCurrent() === null;
if ($model->save()) {
$this->log('"%s" created backend "%s"', Yii::app()->user->name, $model->name);
Yii::app()->user->setFlash('success', Yii::t('Backend', 'Backend created successfully'));
$this->checkWebSocketConnectivity($model);
if ($firstRun) {
Yii::app()->user->setFlash('info', Yii::t('Settings', 'Before you get started, please have a look at the application settings'));
$this->redirect(array('setting/admin'));
} else {
$this->redirect(array('admin'));
}
}
} else {
$model->hostname = 'localhost';
$model->port = 8080;
$model->tcp_port = 9090;
$model->username = 'xbmc';
$model->password = 'xbmc';
// Check "default" if there are no other backends
$backends = Backend::model()->findAll();
if (count($backends) === 0) {
$model->default = true;
}
}
$this->render('create', array('model' => $model));
}
示例6: CFileCacheDependency
<?php
// Only use a cached version if there is just one backend configured, otherwise
// the cache invalidation gets too complicated
if (count(Backend::model()->findAll()) === 1) {
$cacheDependency = new CFileCacheDependency(realpath(__DIR__ . '/_navbar.php'));
$cacheDuration = 60 * 60 * 24 * 365;
if ($this->beginCache('MainMenu', array('dependency' => $cacheDependency, 'duration' => $cacheDuration, 'varyByExpression' => function () {
return implode('_', array(Yii::app()->user->role, intval(Setting::getBoolean('cacheApiCalls')), intval(Yii::app()->powerOffManager->getAllowedActions()), intval(Yii::app()->backendManager->getCurrent() === null), Yii::app()->language, Yii::app()->baseUrl));
}))) {
$this->renderPartial('//layouts/_navbar');
$this->endCache();
}
} else {
$this->renderPartial('//layouts/_navbar');
}