/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id, $modelClass = __CLASS__) { $model = Smartphone::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php require_once 'cellphone_v2.php'; require_once 'smartphone_v1.php'; $applist = array("Angry Birds", "Tetris", "Pandora"); $myPhone = new Smartphone('555-555-1111', 'iPhone', 'Black', $applist); $applist = array("CNN", "Angry Birds"); $yourPhone = new Smartphone('555-555-2222', 'Droid', 'Purple', $applist); echo 'Phone number: ' . $myPhone->getPhoneNumber() . '<br />'; echo 'List Apps: ' . $myPhone->displayApps() . '<br />'; echo 'Phone number: ' . $yourPhone->getPhoneNumber() . '<br />'; echo 'List Apps: ' . $yourPhone->displayApps() . '<br />';
<?php /** @var SmartphoneController $this */ /** @var Smartphone $model */ $this->breadcrumbs = array($model->label(2) => array('index'), Yii::t('app', $model->id) => array('view', 'id' => $model->id), Yii::t('AweCrud.app', 'Update')); $this->menu = array(array('label' => Yii::t('AweCrud.app', 'Delete'), 'icon' => 'trash', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => Yii::t('AweCrud.app', 'Are you sure you want to delete this item?'))), array('label' => Yii::t('AweCrud.app', 'Manage'), 'icon' => 'list-alt', 'url' => array('admin'))); ?> <fieldset> <legend><?php echo Yii::t('AweCrud.app', 'Update') . ' ' . Smartphone::label(); ?> <?php echo CHtml::encode($model); ?> </legend> <?php echo $this->renderPartial('_form', array('model' => $model)); ?> </fieldset>
<?php /** @var SmartphoneController $this */ /** @var Smartphone $model */ $this->breadcrumbs = array('Smartphones' => array('index'), $model->id); $this->menu = array(array('label' => Yii::t('AweCrud.app', 'Create') . ' ' . Smartphone::label(), 'icon' => 'plus', 'url' => array('create')), array('label' => Yii::t('AweCrud.app', 'Update'), 'icon' => 'pencil', 'url' => array('update', 'id' => $model->id)), array('label' => Yii::t('AweCrud.app', 'Delete'), 'icon' => 'trash', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => Yii::t('AweCrud.app', 'Are you sure you want to delete this item?'))), array('label' => Yii::t('AweCrud.app', 'Manage'), 'icon' => 'list-alt', 'url' => array('admin'))); ?> <fieldset> <legend><?php echo Yii::t('AweCrud.app', 'View') . ' ' . Smartphone::label(); ?> <?php echo CHtml::encode($model); ?> </legend> <?php $this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array('id', 'nombre', array('name' => 'imagen', 'type' => 'image'), 'alt_imagen', array('name' => 'visible', 'type' => 'boolean')))); ?> </fieldset>
<?php /** @var SmartphoneController $this */ /** @var Smartphone $model */ $this->breadcrumbs = array('Smartphones' => array('index'), Yii::t('AweCrud.app', 'Manage')); $this->menu = array(array('label' => Yii::t('AweCrud.app', 'List') . ' ' . Smartphone::label(2), 'icon' => 'list', 'url' => array('index')), array('label' => Yii::t('AweCrud.app', 'Create') . ' ' . Smartphone::label(), 'icon' => 'plus', 'url' => array('create'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('smartphone-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <fieldset> <legend> <?php echo Yii::t('AweCrud.app', 'Manage'); ?> <?php echo Smartphone::label(2); ?> </legend> <?php $this->widget('bootstrap.widgets.TbGridView', array('id' => 'smartphone-grid', 'type' => 'striped condensed', 'dataProvider' => $model->search(), 'filter' => $model, 'afterAjaxUpdate' => 'reInstallDatepicker', 'columns' => array('nombre', array('name' => 'imagen', 'type' => 'image', 'value' => 'isset($data->imagen) ? $data->imagen : null', 'htmlOptions' => array('width' => '50'), 'filter' => false), 'alt_imagen', array('name' => 'visible', 'value' => '($data->visible == 0) ? Yii::t(\'AweCrud.app\', \'No\') : Yii::t(\'AweCrud.app\', \'Yes\')', 'filter' => array('0' => Yii::t('AweCrud.app', 'No'), '1' => Yii::t('AweCrud.app', 'Yes'))), array('class' => 'bootstrap.widgets.TbButtonColumn')))); Yii::app()->clientScript->registerScript('for-date-picker', "\n function reInstallDatepicker(id, data){\n \n }\n\n "); ?> </fieldset>