本文整理汇总了PHP中Command::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Command::model方法的具体用法?PHP Command::model怎么用?PHP Command::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Command
的用法示例。
在下文中一共展示了Command::model方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadModel
public function loadModel($id)
{
$model = Command::model()->findByPk((int) $id);
if ($model === null) {
throw new CHttpException(404, Yii::t('mc', 'The requested page does not exist.'));
}
return $model;
}
示例2: array
?>
<?php
if (!$edit) {
$attribs = array('name', 'level', 'prereq', 'chat', 'response', 'run');
} else {
$form = $this->beginWidget('CActiveForm', array('id' => 'command-form', 'enableAjaxValidation' => false));
$userRoles = array_combine(User::$roleLevels, User::getRoleLabels());
$userRoles[0] = Yii::t('mc', 'None');
if (Yii::app()->user->isSuperuser()) {
$attribs[] = array('label' => $form->labelEx($model, 'server_id'), 'type' => 'raw', 'value' => $form->textField($model, 'server_id') . ' ' . $form->error($model, 'server_id'), 'hint' => Yii::t('mc', 'The server ID, use 0 for "Global"'));
$attribs[] = array('label' => $form->labelEx($model, 'hidden'), 'type' => 'raw', 'value' => $form->checkBox($model, 'hidden') . ' ' . $form->error($model, 'hidden'), 'hint' => Yii::t('mc', 'Only show this command to other superusers'));
}
$attribs[] = array('label' => $form->labelEx($model, 'name'), 'type' => 'raw', 'value' => $form->textField($model, 'name') . ' ' . $form->error($model, 'name'));
$attribs[] = array('label' => $form->labelEx($model, 'level'), 'type' => 'raw', 'value' => $form->dropDownList($model, 'level', $userRoles) . ' ' . $form->error($model, 'level'));
$attribs[] = array('label' => $form->labelEx($model, 'prereq'), 'type' => 'raw', 'value' => $form->dropDownList($model, 'prereq', array('0' => 'None') + CHtml::listData(Command::model()->findAllByAttributes(array('server_id' => $sv)), 'id', 'name')) . ' ' . $form->error($model, 'prereq'), 'hint' => Yii::t('mc', 'This command has to be run before'));
$attribs[] = array('label' => $form->labelEx($model, 'chat'), 'type' => 'raw', 'value' => $form->textField($model, 'chat') . ' ' . $form->error($model, 'chat'), 'hint' => Yii::t('mc', 'The users message has to begin with this'));
$attribs[] = array('label' => $form->labelEx($model, 'response'), 'type' => 'raw', 'value' => $form->textField($model, 'response') . ' ' . $form->error($model, 'response'), 'hint' => Yii::t('mc', 'Whispered to the player'));
$attribs[] = array('label' => $form->labelEx($model, 'run'), 'type' => 'raw', 'value' => $form->textField($model, 'run') . ' ' . $form->error($model, 'run'), 'hint' => Yii::t('mc', 'Run this Minecraft command (<a href="http://www.multicraft.org/site/page?view=usage#commands" target="_blank">see usage</a> for arguments and multiple commands)'));
$attribs[] = array('label' => '', 'type' => 'raw', 'value' => CHtml::submitButton($model->isNewRecord ? Yii::t('mc', 'Create') : Yii::t('mc', 'Save')));
}
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => $attribs));
if ($edit) {
$this->endWidget();
}
if (Yii::app()->user->hasFlash('command')) {
?>
<div class="flash-success">
<?php
echo Yii::app()->user->getFlash('command');
?>
示例3: array
<li id="command-tab" class="selected"><?php
echo Yii::t('Job', 'Command Mode');
?>
</li><li id="test-case-tab"><?php
echo Yii::t('Job', 'Test Case Mode');
?>
</li>
</ul>
<div id="run-fields">
<!-- command fields start -->
<div id="command-fields">
<div class="row-fluid">
<?php
echo CHtml::activeLabel($command, 'name', array('class' => 'span2'));
$listData = array('' => '', -1 => '[' . Yii::t('Command', 'New Command') . ']');
$listData += Command::model()->getCommandOptions();
$this->widget('application.extensions.combobox.InputComboBox', array('model' => $job, 'attribute' => 'command_id', 'data' => $listData, 'options' => array('onSelect' => '
if(-1 == $("#Job_command_id").val()) {
item.value = ""
}
jobForm.setCommand(item.value, $("#Job_command_id").val())
', 'allowText' => true, 'showStyle' => false, 'disableAutocomplete' => true), 'htmlOptions' => array('class' => 'focus span10', 'placeholder' => Yii::t('Job', 'Name Tip'))));
// set hidden data.
echo CHtml::activeHiddenField($job, 'id');
echo CHtml::activeHiddenField($job, 'stage_num');
echo CHtml::activeHiddenField($command, 'name');
echo CHtml::activeHiddenField($command, 'mode');
echo CHtml::hiddenField('Job[type]', $job->type, array("id" => "Job_type"));
?>
</div>
<div class="row-fluid" style="margin-bottom: 0">
示例4: actionListCommands
/**
** Command Functions
**/
public function actionListCommands($server_id)
{
$this->check($server_id);
$cmds = Command::model()->findAllByAttributes(array('server_id' => (int) $server_id));
$this->ls('Command', $cmds);
}
示例5: createDefaultCommands
public function createDefaultCommands()
{
$cmds = array(array(Yii::t('mc', 'Message of the Day'), 10, 'motd', ''), array(Yii::t('mc', 'Give Item'), 30, 'give', 'builtin:give'), array(Yii::t('mc', 'Teleport To'), 30, 'tp', 'builtin:tp'), array(Yii::t('mc', 'Summon Player'), 30, 'summon', 'builtin:summon'), array(Yii::t('mc', 'Admin Say'), 30, 'asay', 'builtin:asay'), array(Yii::t('mc', 'Save World'), 30, 'save', 'builtin:save'), array(Yii::t('mc', 'Time'), 10, 'time', 'builtin:time'), array(Yii::t('mc', 'Date'), 10, 'date', 'builtin:date'), array(Yii::t('mc', 'Player List'), 10, 'list', 'builtin:list'), array(Yii::t('mc', 'Say Player List'), 30, 'saylist', 'builtin:saylist'), array(Yii::t('mc', 'Create Backup'), 40, '', 'builtin:backup'), array(Yii::t('mc', 'Restart'), 40, '', 'builtin:restart'), array(Yii::t('mc', 'Restart if Empty'), 40, '', 'builtin:restart_empty'), array(Yii::t('mc', 'Stop'), 40, '', 'builtin:stop'), array(Yii::t('mc', 'Stop if Empty'), 40, '', 'builtin:stop_empty'), array(Yii::t('mc', 'Start'), 40, '', 'builtin:start'), array(Yii::t('mc', 'Teleport Other'), 40, '', 'builtin:tp_other'));
foreach ($cmds as $c) {
$cmd = Command::model()->findByAttributes(array('server_id' => $this->id, 'name' => $c[0]));
if ($cmd) {
continue;
}
$cmd = new Command();
$cmd->server_id = $this->id;
$cmd->name = $c[0];
$cmd->level = $c[1];
$cmd->chat = $c[2];
$cmd->run = $c[3];
$cmd->save();
}
}
示例6:
case 'project_id':
$oldProject = Project::model()->findByPk($diffAttr->old);
if ($oldProject) {
$diffAttr->old = $oldProject->path;
}
$newProject = Project::model()->findByPk($diffAttr->new);
if ($newProject) {
$diffAttr->new = $newProject->path;
}
break;
case 'command_id':
$oldCommand = Command::model()->findByPk($diffAttr->old);
if ($oldCommand) {
$diffAttr->old = $oldCommand->name;
}
$newCommand = Command::model()->findByPk($diffAttr->new);
if ($newCommand) {
$diffAttr->new = $newCommand->name;
}
break;
case 'machine_id':
$oldMachine = Machine::model()->findByPk($diffAttr->old);
if ($oldMachine) {
$diffAttr->old = $oldMachine->name;
}
$newMachine = Machine::model()->findByPk($diffAttr->new);
if ($newMachine) {
$diffAttr->new = $newMachine->name;
}
break;
case 'crucial':