<?php echo "<?php\n"; $nameColumn = GHelper::guessNameColumn($this->tableSchema->columns); $label = $this->pluralize($this->class2name($this->modelClass)); echo "if(!isset(\$this->breadcrumbs))\n\r\n\$this->breadcrumbs=array(\r\n\t'{$label}'=>array('index'),\r\n\t\$model->{$nameColumn}=>array('view','id'=>\$model->{$this->tableSchema->primaryKey}),\r\n\tYii::t('app', 'Update'),\r\n);\n"; ?> if(!isset($this->menu)) $this->menu=array( array('label'=>Yii::t('app', 'List') . ' <?php echo $this->modelClass; ?> ', 'url'=>array('index')), array('label'=>Yii::t('app', 'Create') . ' <?php echo $this->modelClass; ?> ', 'url'=>array('create')), array('label'=>Yii::t('app', 'View') . ' <?php echo $this->modelClass; ?> ', 'url'=>array('view', 'id'=>$model-><?php echo $this->tableSchema->primaryKey; ?> )), array('label'=>Yii::t('app', 'Manage') . ' <?php echo $this->modelClass; ?> ', 'url'=>array('admin')), ); ?>
protected function renderAddButton() { $model = strtolower(get_class($this->_model)); $relatedModel = strtolower(get_class($this->_relatedModel)); $relations = $this->_model->relations(); $controller = GHelper::resolveController($relations[$this->relation]); if ($this->addButtonUrl != '') { $link = $this->addButtonUrl; } else { $link = $this->controller->createUrl($controller . '/create', array('relation' => $this->relation)); } if ($this->addButtonRefreshUrl == '') { $this->addButtonRefreshUrl = $this->controller->createUrl($model . '/getOptions', array('relation' => $this->relation, 'style' => $this->style, 'fields' => $this->fields)); } $string = Yii::t('app', 'Add new {model}', array('{model}' => $relatedModel)); $dialog = 'zii.widgets.jui.CJuiDialog'; $this->beginWidget($dialog, array('id' => $this->relation . '_dialog', 'options' => array('autoOpen' => false, 'modal' => true, 'title' => $string, 'width' => 800, 'height' => 600))); $this->endWidget($dialog); echo CHtml::AjaxButton(is_string($this->showAddButton) ? $this->showAddButton : $string, $link, array('success' => "function(html) {\n\t\t\t\t\t\t\t\tjQuery('#" . $this->relation . "_dialog').html(html);\n\t\t\t\t\t\t\t\t\$('#" . $this->relation . "_dialog').dialog('open');\n\t\t\t\t\t\t\t}"), array('id' => $this->relation . '_create')); // prepare the Submit button that is not loaded into the DOM yet Yii::app()->clientScript->registerScript($this->relation . '_submit', "jQuery('body').delegate('#submit_" . $this->relation . "','click',function(){\n\t\t\t\tjQuery.ajax({'url':'" . $link . "',\n\t\t\t\t\t\t'cache':false,\n\t\t\t\t\t\t'type':'POST',\n\t\t\t\t\t\t'data':jQuery(this).parents('form').serialize(),\n\t\t\t\t\t\t'success':function(html){\n\t\t\t\t\t\tjQuery('#" . $this->relation . "_dialog').html(html)}});\n\t\t\treturn false;});"); Yii::app()->clientScript->registerScript($this->relation . '_done', "jQuery('body').delegate('#" . $this->relation . "_done','click',function(){\n\t\t\t\t\tjQuery.ajax({'url':'" . $this->addButtonRefreshUrl . "',\n\t\t\t\t\t\t\t'cache':false,\n\t\t\t\t\t\t\t'success':function(html){\n\t\t\t\t\t\t\tjQuery('#" . $this->relation . "_options').html(html)}});\n\t\t\t\t\t\t\$('#" . $this->relation . "_dialog').dialog('close');\n\t\t\t\treturn false;});"); }
<?php echo "<?php\r\n\$locale = CLocale::getInstance(Yii::app()->language);\n\r\n"; ?> $this->widget('zii.widgets.CDetailView', array( 'data'=>$model, 'attributes'=>array( <?php foreach ($this->tableSchema->columns as $column) { if ($column->isForeignKey) { echo "\t\tarray(\n"; echo "\t\t\t'name'=>'{$column->name}',\n"; foreach ($this->relations as $key => $relation) { if (($relation[0] == "CHasOneRelation" || $relation[0] == "CBelongsToRelation") && $relation[2] == $column->name) { $columns = CActiveRecord::model($relation[1])->tableSchema->columns; $suggestedfield = $this->suggestName($columns); $controller = GHelper::resolveController($relation); echo "\t\t\t'value'=>(\$model->{$key} !== null)?CHtml::link(\$model->{$key}->{$suggestedfield->name}, array('{$controller}/view','id'=>\$model->{$key}->id)):'n/a',\n"; echo "\t\t\t'type'=>'html',\n"; } } echo "\t\t),\n"; } else { if (stristr($column->name, 'url')) { // TODO - experimental - move to provider class echo "array("; echo "\t\t\t'name'=>'{$column->name}',\n"; echo "\t\t\t'type'=>'link',\n"; echo "),\n"; } else { if ($column->name == 'createtime' or $column->name == 'updatetime' or $column->name == 'timestamp') { echo "array(\r\n\t\t\t\t\t'name'=>'{$column->name}',\r\n\t\t\t\t\t'value' =>\$locale->getDateFormatter()->formatDateTime(\$model->{$column->name}, 'medium', 'medium')),\n";
public function getRecordTitle() { $nameColumn = GHelper::guessNameColumn($this->tableSchema->columns); return $this->{$nameColumn}; }