<?php $comps = IntegrationTest::model()->findAll(); $table = $table_creator->begin_table("|l|p{6cm}|l|l|") . $table_creator->heading_row(array("Test", "Descrizione", "Componente", "Stato")); foreach ($comps as $test) { $test->with('test', 'package'); $table .= $table_creator->row(array($test->public_id(), $test->test->description, $test->package->name, 'success')); } $table .= $table_creator->caption("Tabella test di integrazione") . $table_creator->end_table(); if ($table_creator->id() != 'html' && !$raw) { echo CodeGen::generic_render_code($table, 'latex', true); } else { echo $table; }
<?php require_once 'JCrud.php'; require_once 'util.php'; $data = json_decode(file_get_contents("php://input")); $cg = new CodeGen(); $cg->action = $data->action; $cg->tableName = $data->tableName; $cg->tableId = $data->tableId; $cg->execute(); class CodeGen { public function __construct() { } public $pkColName, $tableName, $tableId, $action, $mysql; private static $newLine = "\r\n"; private static $tab1 = "\t"; private static $tab2 = "\t\t"; private static $tab3 = "\t\t\t"; private static $tab4 = "\t\t\t\t"; private static $tab5 = "\t\t\t\t\t"; private function loadData() { $db = new JCrud(); $sql = "select * from columns where tableId=? order by orderNo"; $params[] = $this->tableId; $this->allColumns = $db->query2($sql, $params); } public function execute() {
$data["class_from"] : CHtml::link($data["class_from"], array("class/view","id"=>$data["id_from"]))'), 'aggregation_from', array('class' => 'CDataColumn', 'header' => 'Attribute', 'type' => 'html', 'value' => 'CHtml::link($data["attribute"], array("class/attributeView","id"=>$data["id_att"]))'), 'aggregation_to', array('class' => 'CDataColumn', 'header' => 'To', 'type' => 'html', 'value' => '$data["class_to"] == ' . $model->id_class . ' ? $data["class_to"] : CHtml::link($data["class_to"], array("class/view","id"=>$data["id_to"]))'), array('class' => 'CButtonColumn', 'template' => '{update} {delete}', 'deleteButtonUrl' => 'array("assocDelete", "id"=>$data["id"] )', 'updateButtonUrl' => 'array("assocUpdate", "id"=>$data["id"] )')))); echo "<h2>Methods</h2>"; $this->widget('zii.widgets.grid.CGridView', array('dataProvider' => new CActiveDataProvider('Method', array('criteria' => array('condition' => 'id_class = :id', 'params' => array(':id' => $model->id_class), 'order' => 'static, access, name, const, id_method'), 'pagination' => false)), 'columns' => array(array('class' => 'CDataColumn', 'header' => 'Name', 'type' => 'html', 'value' => 'CHtml::link($data->name,array("methodView","id"=>$data->id_method))'), 'description', 'access', 'return', 'virtual', 'override', 'final', 'const', 'nothrow', 'static', array('class' => 'CButtonColumn', 'updateButtonUrl' => 'array("methodupdate", "id"=>$data->id_method )', 'viewButtonUrl' => 'array("methodview", "id"=>$data->id_method )', 'deleteButtonUrl' => 'array("methoddelete", "id"=>$data->id_method )')))); echo '<div class="append">'; echo CHtml::link("Add method", array("methodCreate", "class" => $model->id_class)); echo '</div>'; $slots = array(); $signals = array(); foreach ($model->methods as $meth) { $slots = array_merge($slots, $meth->slots); $signals = array_merge($signals, $meth->signals); } echo '<h2>Slots</h2>'; $this->widget('zii.widgets.grid.CGridView', array('dataProvider' => new CArrayDataProvider($slots, array('keyField' => 'id_method')), 'columns' => array(array('class' => 'CDataColumn', 'header' => 'Class', 'type' => 'html', 'value' => 'CHtml::link($data->with("class")->class->name, array("view","id"=>$data->class->id_class))'), array('class' => 'CDataColumn', 'header' => 'Name', 'type' => 'html', 'value' => 'CHtml::link($data->name,array("methodView","id"=>$data->id_method))'), 'description', 'access', 'return', 'virtual', 'override', 'final', 'const', 'nothrow', 'static'))); echo '<h2>Signals</h2>'; $this->widget('zii.widgets.grid.CGridView', array('dataProvider' => new CArrayDataProvider($signals, array('keyField' => 'id_method')), 'columns' => array(array('class' => 'CDataColumn', 'header' => 'Class', 'type' => 'html', 'value' => 'CHtml::link($data->with("class")->class->name, array("view","id"=>$data->class->id_class))'), array('class' => 'CDataColumn', 'header' => 'Name', 'type' => 'html', 'value' => 'CHtml::link($data->name,array("methodView","id"=>$data->id_method))'), 'description', 'access', 'return', 'virtual', 'override', 'final', 'const', 'nothrow', 'static'))); echo '<h2>Inherited Methods</h2>'; $this->widget('zii.widgets.grid.CGridView', array('dataProvider' => new CArrayDataProvider($model->inh_methods(), array('keyField' => 'id_method')), 'columns' => array(array('class' => 'CDataColumn', 'header' => 'Class', 'type' => 'html', 'value' => 'CHtml::link($data->with("class")->class->name, array("view","id"=>$data->class->id_class))'), array('class' => 'CDataColumn', 'header' => 'Name', 'type' => 'html', 'value' => 'CHtml::link($data->name,array("methodView","id"=>$data->id_method))'), 'description', 'access', 'return', 'virtual', 'override', 'final', 'const', 'nothrow', 'static', array('class' => 'CDataColumn', 'header' => 'Override', 'type' => 'html', 'value' => '!$data->virtual && !$data->override?"":CHtml::link("Override", array("class/override", "id_class"=>' . $model->id_class . ', "id_method"=>$data->id_method) )')))); echo CodeGen::render_code($model->include . "\n\n" . $model->cpp_namespace_open() . "\n" . $model->cpp_doc() . "\n" . $model->cpp_decl() . "\n\n" . $model->cpp_namespace_close(), true);
function cpp_doc($indent = 0) { $indent += 1; // make room for * $ind = "\n" . str_repeat(' ', $indent); return "/*!{$ind}" . "* @class {$this->name}{$ind}" . "* @details " . CodeGen::indent_code($this->description, 80, $indent, 10) . $ind . (strlen(trim($this->usage)) == 0 ? '' : "* @par Usage {$ind}" . "* " . CodeGen::indent_code($this->usage, 80, $indent, 1) . $ind) . "*/"; }
<?php $this->breadcrumbs = array('Upload source' => array('index'), 'Preview'); $this->menu = array(array('label' => 'Edit', 'url' => array('index', 'edit' => 1)), array('label' => 'Scan', 'url' => array('scan'))); echo CHtml::beginForm(array('diff'), 'get'); echo CHtml::label('Compare with generated header for ', 'class'); echo CHtml::hiddenField('id', '', array('id' => 'actual_class')); $this->widget('zii.widgets.jui.CJuiAutoComplete', array('name' => 'class_autocomplete', 'sourceUrl' => array('class/parentcompletion'), 'options' => array('select' => "js:function(event, ui) {\n \$('#actual_class').val(ui.item.id);\n }"), 'value' => '')); echo CHtml::dropDownList('mode', 'diff', array('diff' => 'diff', 'inline' => 'inline')); echo CHtml::submitButton('Compare'); echo CHtml::endForm(); echo CodeGen::render_code($code, true, 'cpp-qt');
function cpp_doc($indent = 8) { $indent += 1; // make room for * $ind = "\n" . str_repeat(' ', $indent); $longest_name = 0; foreach ($this->arguments as $arg) { if (strlen($arg->name) > $longest_name) { $longest_name = strlen($arg->name); } } $params = ""; $this->with('arguments'); foreach ($this->arguments as $arg) { $params .= "* @param[{$arg->direction}]" . ($arg->direction == 'in' ? ' ' : ' ') . "{$arg->name} " . str_repeat(' ', $longest_name - strlen($arg->name)) . CodeGen::indent_code($arg->description, 80, $indent, $longest_name + 15) . $ind; } return "/*!{$ind}" . "* @details " . CodeGen::indent_code($this->description, 80, $indent, 10) . $ind . (strlen($this->pre) > 0 ? "* @pre " . CodeGen::indent_code($this->pre, 80, $indent, 10) . $ind : '') . (strlen($this->post) > 0 ? "* @post " . CodeGen::indent_code($this->post, 80, $indent, 10) . $ind : '') . "{$params}*/"; }
<?php $cnt = $this->renderPartial("xmi", array(), true); if ($raw) { echo $cnt; } else { echo CodeGen::render_code($cnt, true, 'xml'); }
<?php /* @var $this AttributeController */ /* @var $model Attribute */ $this->breadcrumbs = array('Classes' => array('class/index'), $class->name => array('class/view', 'id' => $class->id_class), $model->name); $this->menu = array(array('label' => 'View Class', 'url' => array('view', 'id' => $class->id_class)), array('label' => 'Associations', 'url' => array('associations')), array('label' => 'Create Attribute', 'url' => array('attributeCreate', 'class' => $class->id_class)), array('label' => 'Update Attribute', 'url' => array('attributeUpdate', 'id' => $model->id_attribute)), array('label' => 'Delete Attribute', 'url' => '#', 'linkOptions' => array('submit' => array('attributeDelete', 'id' => $model->id_attribute), 'confirm' => 'Are you sure you want to delete this item?')), array('label' => 'Create Method', 'url' => array('methodCreate', 'class' => $class->id_class)), array('label' => 'Check spelling', 'url' => array('spellceck/attribute', 'id' => $model->id_attribute))); echo '<h1>View Attribute '; $class->with('package'); foreach ($class->package->parent_array(true) as $n) { echo CHtml::link($n->name, array('package/view', 'id' => $n->id_package)) . " :: "; } echo CHtml::link($class->name, array('class/view', 'id' => $class->id_class)); echo " :: " . $model->name . "</h1>"; $this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('name', 'type', 'const', 'static', 'access', 'description', 'getter', 'setter'))); echo '<h2>Association</h2>'; $model->with('association'); if (isset($model->association)) { $ass = $model->association->with('classFrom', 'classTo'); $this->widget('zii.widgets.CDetailView', array('data' => $ass, 'attributes' => array(array('label' => 'Class From', 'type' => 'html', 'value' => CHtml::link(CHtml::encode($ass->classFrom->name), array('class/view', 'id' => $ass->classFrom->id_class))), 'aggregation_from', array('label' => 'Class To', 'type' => 'html', 'value' => CHtml::link(CHtml::encode($ass->classTo->name), array('class/view', 'id' => $ass->classTo->id_class))), 'aggregation_to', 'multiplicity'))); echo CHtml::link('Remove association', array('assocdelete', 'id' => $ass->id_association)); echo ' - '; echo CHtml::link('Edit association', array('assocupdate', 'id' => $ass->id_association)); } else { echo '<p>This attribute is not an association</p>'; echo CHtml::link('Create association', array('assoccreate', 'attribute' => $model->id_attribute), array('style' => 'font-size:10em; background-color:yellow; color:red; text-decoration:blink;')); } echo CodeGen::render_code("class {$class->name} {\n {$model->access}:\n " . $model->cpp_doc() . "\n " . $model->cpp_decl() . "\n};\n");
public function execute() { $codeGen = new CodeGen($this); $codeGen->execute(); }
<?php $this->breadcrumbs = array('Upload source' => array('index'), 'Preview' => array('view'), 'Diff from ' . $class->cpp_header_file()); $this->menu = array(array('label' => 'Edit', 'url' => array('index', 'edit' => 1)), array('label' => 'View Uploaded File', 'url' => array('view')), array('label' => 'View Generated File', 'url' => array('generator/decl', 'id' => $class->id_class)), array('label' => 'Scan', 'url' => array('scan'))); if (empty($diff)) { echo '<div class="error">No changes.</div>'; } else { echo "<p>Changes from the " . CHtml::link('generated file', array('generator/decl', 'id' => $class->id_class)) . "</p>"; if ($mode == 'inline') { $this->menu[] = array('label' => 'Full Diff', 'url' => array('diff', 'id' => $class->id_class, 'mode' => 'diff')); Yii::app()->clientscript->registerCss('diff', 'del {color:red;} ins{color:green;}'); echo "<pre class='diff'>{$diff}</pre>"; } else { $this->menu[] = array('label' => 'Inline Diff', 'url' => array('diff', 'id' => $class->id_class, 'mode' => 'inline')); echo CodeGen::generic_render_code($diff, 'diff', true); } }
public function CreateItem($name, $mode) { $codeGen = new CodeGen(); $codeGen->has_template_authorization = $this->has_template_authorization; $codeGen->app = $this->jwtApp; $codeGen->root = $this->rootPath; $codeGen->defaultNavigation = $this->defaultNavigation; return $codeGen->CreateItem($name, $mode); }
<td style="vertical-align: middle"><?php echo $code->getPurpose(); ?> </td> <td style="vertical-align: middle"><?php echo $code->getDate(); ?> </td> </tr> <?php } ?> </table> <?php } else { if ($action == 'generate') { /*$rand = rand(100, 999); $date = date('mdy'); $name = strtoupper($_SESSION['user']->getName()[0] . $_SESSION['user']->getName()[1]); $abbrev = ''; foreach (explode(' ', $_SESSION['user']->getAdmin()->getAdminRank()) as $word) { $abbrev .= strtoupper($word[0]); }*/ $code = CodeGen::generateCode($_SESSION['user']); CodeGen::add($code, $_SESSION['user'], $_POST['purpose']); Event::addEvent($_SESSION['user']->getName() . ' has generated an approval code.', $_SESSION['user'], 1); echo $code; } }