本文整理汇总了PHP中Package::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Package::model方法的具体用法?PHP Package::model怎么用?PHP Package::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadModel
public function loadModel($id)
{
if (($model = Package::model()->findByPk($id)) === null) {
throw new CHttpException(404, 'Страница не найдена');
}
return $model;
}
示例2: actionPackage
function actionPackage($id = null)
{
if ($id == null) {
$this->render('packages', array('packages' => Package::model()->findAll()));
} else {
$c = Package::model()->findByPk($id);
if ($c == null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
$this->render('package', array('package' => $c));
}
}
示例3: beforeAction
protected function beforeAction($action)
{
$actions = array('index');
if (in_array($action->id, $actions)) {
$this->package_id = (int) Yii::app()->getRequest()->getParam('package_id');
if (!$this->package_id) {
throw new CHttpException(400, 'Не установлен ID пакета');
}
if (($this->package = Package::model()->findByPk($this->package_id)) === null) {
throw new CHttpException(404, 'Пакет не найден');
}
}
return parent::beforeAction($action);
}
示例4: actionShow
public function actionShow($alias)
{
if (Yii::app()->user->isAuthenticated() === false) {
$this->controller->redirect(Yii::app()->user->loginUrl);
}
if (($user = Yii::app()->user->getProfile()) === null) {
Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::ERROR_MESSAGE, Yii::t('UserModule.user', 'User not found.'));
Yii::app()->user->logout();
$this->controller->redirect((array) '/user/account/login');
}
$course = Course::model()->published()->find('t.alias = :alias', array(':alias' => $alias));
if (!$course) {
throw new CHttpException(404);
}
// ToDO
// Пакет
$package = Package::model()->findByPK(1);
// День
$dayId = Yii::app()->getRequest()->getParam('day', null);
if ($dayId) {
$day = Day::model()->published()->package($package->id)->findByPK((int) $dayId);
} else {
$day = Day::model()->published()->package($package->id)->find(array('order' => 't.number ASC'));
}
if (!$day) {
throw new CHttpException(404);
}
// Страница
$pageId = Yii::app()->getRequest()->getParam('page', null);
if ($pageId) {
$page = Page::model()->published()->day($day->id)->findByPK((int) $pageId);
} else {
$page = Page::model()->published()->day($day->id)->find(array('order' => 't.number ASC'));
}
if (!$page) {
throw new CHttpException(404);
}
// Вывод в шаблон
$this->render('show', array('course' => $course, 'package' => $package, 'day' => $day, 'page' => $page));
}
示例5: actionView
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
$model = $this->loadModel($id);
if (isset($_REQUEST['add_package'])) {
$class = Package::model()->findByPk($_REQUEST['add_package']);
if ($class != null) {
$nm = new ClassRequirement();
$nm->id_requirement = $model->id_requirement;
$nm->id_package = $class->id_package;
$nm->save(false);
}
}
if (isset($_REQUEST['add_class'])) {
$class = Class_Prog::model()->findByPk($_REQUEST['add_class']);
if ($class != null) {
$nm = new ClassRequirementReal();
$nm->id_requirement = $model->id_requirement;
$nm->id_class = $class->id_class;
$nm->save(false);
}
}
$this->render('view', array('model' => $model));
}
示例6: component_row
<?php
function component_row(Package $package, $indentation, TableCreator $table_creator)
{
$package->with('integration');
$ret = $table_creator->row(array($package->full_name(), $package->integration == null ? 'Architettura del sistema' : $package->integration->public_id()));
$nested = $package->with('packages')->packages;
foreach ($nested as $nuc) {
$ret .= component_row($nuc, $indentation + 1, $table_creator);
}
return $ret;
}
$comps = Package::model()->findAll("parent is null and name != 'Qt'");
$table = $table_creator->begin_table("|l|l|") . $table_creator->heading_row(array("Componente", "Test"));
foreach ($comps as $package) {
$package->with('integration');
$table .= component_row($package, 0, $table_creator);
}
$table .= $table_creator->caption("Tabella componente / test di integrazione") . $table_creator->end_table();
if ($table_creator->id() != 'html' && !$raw) {
echo CodeGen::generic_render_code($table, 'latex', true);
} else {
echo $table;
}
示例7: find_by_qualified_name
static function find_by_qualified_name($name, Package $namespace = null)
{
$name = trim($name);
if (strlen($name) == 0) {
return null;
}
$model = self::model();
$name_parts = explode('::', $name);
if (count($name_parts) == 1) {
if ($namespace != null && !$namespace->isNewRecord) {
return $model->find('name = :name and id_package = :idp', array('name' => $name, 'idp' => $namespace->id_package));
}
return $model->find('name = :name', array('name' => $name));
}
$namespace = Package::model()->find('parent is null and name = :name', array('name' => $name_parts[0]));
for ($i = 1; $i < count($name_parts) - 1; $i++) {
$namespace = Package::model()->find('parent = :idp and name = :name', array('name' => $name_parts[$i], 'idp' => $namespace->id_package));
}
if ($namespace == null) {
return null;
}
return $model->find('name = :name and id_package = :idp', array('name' => $name_parts[count($name_parts) - 1], 'idp' => $namespace->id_package));
}
示例8: actionDelete
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'admin' page.
* @param integer $id the ID of the model to be deleted
*/
public function actionDelete($id)
{
if (Yii::app()->request->isPostRequest) {
// we only allow deletion via POST request
$model = $this->loadModel($id);
$currentUp = UpDetail::model()->findAllByAttributes(array('up_number_of_letter' => $model->number_of_letter));
$latestUP = Up::model()->find(array('order' => 'id DESC'));
if ($model->number_of_letter != $latestUP->number_of_letter) {
Yii::app()->user->setFlash('error', 'Sudah ada UP baru. Tidak dapat menghapus UP lama.');
$this->redirect(array('view', 'id' => $model->id));
}
$realization = $model->getTotal($model->number_of_letter)["realization"];
if ($realization != 0) {
Yii::app()->user->setFlash('error', 'Tidak dapat menghapus UP yang sudah terrealisasi.');
$this->redirect(array('view', 'id' => $model->id));
}
//Delete Detail
$details = UpDetail::model()->findAllByAttributes(array('up_number_of_letter' => $model->number_of_letter));
foreach ($details as $detail) {
//update package UP status to LS
$package = Package::model()->findByAttributes(array('code' => $detail->package_code));
$package->up = 'LS';
$package->update();
//update package UP status to LS
$detail->delete();
}
//Delete Detail
$model->delete();
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if (!isset($_GET['ajax'])) {
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
}
} else {
throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
}
}
示例9: actionClear
/**
* Clear data on database
*/
public function actionClear()
{
//Check record data on database
$exist = Package::model()->exists();
if ($exist) {
//Clear Data
Yii::app()->db->createCommand()->truncateTable(Package::model()->tableName());
Yii::app()->db->createCommand()->truncateTable(PackageAccount::model()->tableName());
Yii::app()->user->setFlash('success', 'Data berhasil dibersihkan.');
$this->redirect(array('index'));
} else {
Yii::app()->user->setFlash('error', 'Data tidak ditemukan.');
$this->redirect(array('index'));
}
}
示例10: actionPpkPackageAccountChart
public function actionPpkPackageAccountChart($id, $ppkId)
{
$package = Package::model()->findByPk($id);
$ppk = Ppk::model()->findByPk($ppkId);
$packageAccounts = PackageAccount::model()->findAllByAttributes(array('package_code' => "{$package->code}", 'ppk_code' => "{$ppk->code}"));
$this->render('ppkPackageAccountChart', array('ppk' => $ppk, 'package' => $package, 'packageAccounts' => $packageAccounts));
}
示例11: actionClear
/**
* Clear all DIPA, Budget, Package, Account Package, and Realization data from database record
*/
public function actionClear()
{
//Check record data on database
$realization = Realization::model()->exists();
$packageAccount = PackageAccount::model()->exists();
$package = Package::model()->exists();
$budget = Budget::model()->exists();
$dipa = Dipa::model()->exists();
//Clear data
if ($realization) {
//Truncate realization table on anggaran database
Yii::app()->db->createCommand()->truncateTable(Realization::model()->tableName());
}
if ($packageAccount) {
//Truncate package_account table on anggaran database
Yii::app()->db->createCommand()->truncateTable(PackageAccount::model()->tableName());
}
if ($package) {
//Truncate package table on anggaran database
Yii::app()->db->createCommand()->truncateTable(Package::model()->tableName());
}
if ($budget) {
//Truncate budget table on anggaran database
Yii::app()->db->createCommand()->truncateTable(Budget::model()->tableName());
}
if ($dipa) {
//Truncate dipa table on anggaran database
Yii::app()->db->createCommand()->truncateTable(Dipa::model()->tableName());
}
//Redirect to DIPA index page
Yii::app()->user->setFlash('success', 'Data berhasil dibersihkan. </br> Anda dapat memasukkan anggaran baru.');
$this->redirect(array('index'));
}
示例12: foreach
$namespace_array[] = $namespace . $package->name;
$package->with('packages,classes');
$sub_scope = $namespace . $package->name . '::';
if (isset($package->packages)) {
foreach ($package->packages as $c) {
ns_build_package($c, $sub_scope, $namespace_array);
}
}
if (isset($package->classes)) {
foreach ($package->classes as $class) {
$namespace_array[] = $sub_scope . $class->name;
}
}
}
$namespace_array = array();
$packages = Package::model()->findAll('parent is null');
foreach ($packages as $p) {
ns_build_package($p, "", $namespace_array);
}
?>
<script>
//highlight
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
matchBrackets: true,
mode: "text/x-c++hdr",
extraKeys: {"Ctrl-Space": "autocomplete"},
indentUnit: 4,
indentWithTabs: true,
theme: 'default',
示例13: actionIndex
/**
* Lists all models.
*/
public function actionIndex()
{
$this->title = 'Daftar Realisasi';
//Check existed dipa (used to show & hide submit button)
$showContent = FALSE;
$parent = Package::model()->exists();
$errors = ErrorRealization::model()->findAll();
$limit = array();
$realization = array();
$rest = array();
if ($errors) {
foreach ($errors as $data) {
$limit[$data->packageAccount_code] = 0;
$realization[$data->packageAccount_code] = 0;
$rest[$data->packageAccount_code] = 0;
$pAccount = PackageAccount::model()->findByAttributes(array('code' => "{$data->packageAccount_code}"));
if ($pAccount) {
$limit[$data->packageAccount_code] = $pAccount->limit;
$realization[$data->packageAccount_code] = PackageAccount::model()->getTotal($pAccount->code)['realization'];
$rest[$data->packageAccount_code] = PackageAccount::model()->getTotal($pAccount->code)['restMoney'];
}
}
}
if ($parent) {
$showContent = TRUE;
}
$model = new Realization('search');
$model->unsetAttributes();
// clear any default values
if (isset($_GET['Realization'])) {
$model->attributes = $_GET['Realization'];
}
$this->render('index', array('model' => $model, 'showContent' => $showContent, 'errors' => $errors, 'limit' => $limit, 'realization' => $realization, 'rest' => $rest));
}
示例14: isset
<?php
$ass = isset($_GET['ass']) && $_GET['ass'];
$xmi = new XmiRenderer();
$xmi->begin();
$toplevel = Package::model()->findAll('parent is null');
foreach ($toplevel as $pack) {
$xmi->package($pack, $ass);
}
$xmi->end();
示例15: actionParentCompletion
function actionParentCompletion($term)
{
$limit = 10;
$sql_command = Yii::app()->db->createCommand()->select('name as value, id_package as id')->from('package')->where('name like :txt', array('txt' => "%{$term}%"))->order('name')->limit($limit);
$matches = $sql_command->queryAll();
if (count($matches) == 1) {
$p = Package::model()->findByPk($matches[0]['id']);
$p->with('packages');
if (isset($p->packages) && is_array($p->packages)) {
foreach ($p->packages as $c) {
if (count($matches) >= $limit) {
break;
}
array_push($matches, array('value' => $p->name . "::" . $c->name, 'id' => $c->id_package));
}
}
}
echo json_encode($matches);
}