function class_row(Class_Prog $class, TableCreator $table_creator)
{
    $ret = "";
    $pkg_name = array();
    foreach ($class->requirements as $c) {
        array_push($pkg_name, $c->public_id());
    }
    array_unique($pkg_name);
    sort($pkg_name);
    $cells = array($table_creator->anchor($class->full_name(), $class->name), implode("\n\n", $pkg_name));
    $ret .= $table_creator->row($cells);
    return $ret;
}
 function actionClass($id = null)
 {
     if ($id == null) {
         $this->render('classes', array('classes' => Class_Prog::model()->findAll()));
     } else {
         $c = Class_Prog::model()->findByPk($id);
         if ($c == null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
         $this->render('class', array('class' => $c));
     }
 }
 /**
  * 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));
 }
 function internalFile($name, $ext, $raw)
 {
     $ns = explode('/', $name);
     $name = $ns[count($ns) - 1];
     $camel_name = str_replace(' ', '', ucwords(str_replace('_', ' ', $name)));
     $classes = Class_Prog::model()->findAll('name = :n1 OR name = :n2', array('n1' => $name, 'n2' => $camel_name));
     for ($i = count($ns) - 2, $l = 1; $i >= 0 && count($classes) > 1; $i--, $l++) {
         $new_classes = array();
         foreach ($classes as $c) {
             $t = $c->ancestor_level($l);
             if ($t != null && $t->name == $ns[$i]) {
                 $new_classes[] = $c;
             }
         }
         $classes = $new_classes;
     }
     if (count($classes) == 0) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $class = $classes[0];
     $view = $ext == 'cpp' ? 'impl' : 'decl';
     $this->render_code('cpp_class', $raw, false, array('class' => $class, 'view' => $view));
 }
 function actionParentCompletion($term)
 {
     /*$sql_command = Yii::app()->db->createCommand()
           ->select('name as value, id_class as id' )
           ->from ( 'class' )
           ->where ( 'name like :txt', 
                       array('txt'=>"%$term%") )
           ->order ( 'name' )
           ->limit ( 10 );
       $matches = $sql_command->queryAll();*/
     $classes = Class_Prog::model()->findAll(array('condition' => 'name like :txt', 'order' => 'name', 'limit' => 10, 'params' => array('txt' => "%{$term}%")));
     $matches = array();
     foreach ($classes as $c) {
         $matches[] = array('value' => $c->name . " (" . $c->with('package')->package->full_name() . ")", 'id' => $c->id_class);
     }
     echo json_encode($matches);
 }
Esempio n. 6
0
<?php

/* @var $this ClassController */
/* @var $classes array[Class]*/
/* @var $name string*/
$this->breadcrumbs = array('Class' => array('index'), "Disambiguate {$name}");
$this->menu = array(array('label' => 'List Class', 'url' => array('index')), array('label' => 'Create Class', 'url' => array('create')));
$this->widget('zii.widgets.grid.CGridView', array('id' => 'class-par-grid', 'dataProvider' => new CArrayDataProvider($classes, array('keyField' => 'id_class')), 'columns' => Class_Prog::grid_columns(array())));
Esempio n. 7
0
 static function grid_columns($append = array())
 {
     $arr = array(array('class' => 'CDataColumn', 'type' => 'html', 'name' => 'name', 'value' => 'CHtml::link($data->name,
                         array("class/view","id"=>$data->id_class) )'), array('class' => 'CDataColumn', 'header' => 'Package', 'type' => 'html', 'value' => 'isset($data->package) ?
                         CHtml::link($data->package->full_name(" :: "),
                                     array("package/view","id"=>$data->package->id_package) ) :
                         null'), array('type' => 'html', 'name' => 'type', 'filter' => Class_Prog::type_drop(), 'value' => '$data->type'), 'description', 'usage', 'qobject:raw:Q', 'library:raw:lib');
     return array_merge($arr, $append);
 }
Esempio n. 8
0
function display_class(Class_Prog $class, TableCreator $table_creator)
{
    $txt = "";
    if (!$class->library) {
        $id = $class->full_name();
        $name = $class->full_name(" :: ");
        $txt .= $table_creator->anchor($id, '') . "\n";
        $txt .= $table_creator->title(4, $name, $class->name);
        $txt .= $table_creator->begin_desc_list();
        $txt .= $table_creator->desc_list_item('Descrizione', $class->description);
        if (strlen(trim($class->usage)) > 0) {
            $txt .= $table_creator->desc_list_item('Utilizzo', $class->usage);
        }
        $class->with('children', 'parents');
        if (count($class->parents)) {
            $inh_txt = '';
            $inh_txt .= "\\vspace{-7mm}\n";
            $inh_txt .= $table_creator->begin_list();
            foreach ($class->parents as $par) {
                if (!$par->library) {
                    $inh_txt .= $table_creator->list_item($table_creator->link($par->full_name(), $par->full_name(" :: ")));
                } else {
                    $inh_txt .= $table_creator->list_item($par->full_name());
                }
            }
            $inh_txt .= $table_creator->end_list();
            $txt .= $table_creator->desc_list_item('Classi ereditate', $inh_txt);
        }
        if (count($class->children)) {
            $inh_txt = '';
            $inh_txt .= "\\vspace{-7mm}\n";
            $inh_txt .= $table_creator->begin_list();
            foreach ($class->children as $par) {
                $inh_txt .= $table_creator->list_item($table_creator->link($par->full_name(), $par->full_name(" :: ")));
            }
            $inh_txt .= $table_creator->end_list();
            $txt .= $table_creator->desc_list_item('Classi figlie', $inh_txt);
        }
        $ass = Association::model()->findAll('class_from = :idc or class_to = :idc', array(':idc' => $class->id_class));
        if (count($ass)) {
            $rel = '';
            $rel .= "\\vspace{-7mm}\n";
            $rel .= $table_creator->begin_desc_list();
            foreach ($ass as $ss) {
                if ($ss->class_to != $class->id_class) {
                    $par = $ss->with('classTo')->classTo;
                    $ass_dir = "uscente";
                } else {
                    if ($ss->class_from != $class->id_class) {
                        $par = $ss->with('classFrom')->classFrom;
                        $ass_dir = "entrante";
                    } else {
                        continue;
                    }
                }
                $ss->with('attribute');
                if (!$par->library) {
                    $acn = $par->full_name();
                    if (strlen($acn) > 60) {
                        $acn = substr($acn, strlen($acn) - 60);
                        $acn = "..." . substr($acn, strpos($acn, "::") + 2);
                    }
                    $ass_name = $table_creator->link($par->full_name(), $acn);
                } else {
                    $ass_name = $par->full_name();
                }
                $ass_txt = "Relazione {$ass_dir}, " . lcfirst($ss->attribute->description);
                $rel .= $table_creator->desc_list_item($ass_name, $ass_txt);
            }
            $rel .= $table_creator->end_desc_list();
            $txt .= $table_creator->desc_list_item('Relazioni con altre classi', $rel);
        }
    }
    $txt .= $table_creator->end_desc_list();
    $txt .= "\n\\vspace{0.5cm}\n";
    return $txt;
}
Esempio n. 9
0
 function append_parent($name)
 {
     $this->parents[] = $p = Class_Prog::find_by_qualified_name($name, $this->namespace[count($this->namespace) - 1]);
 }
Esempio n. 10
0
function test_row(Method $meth, TableCreator $table_creator)
{
    $text = $meth->ttest != null ? $meth->ttest->unitTest->public_id() : '';
    return $table_creator->row(array(Class_Prog::model()->findByPK($meth->id_class)->name . "::" . $meth->name . "()", $text));
}
Esempio n. 11
0
function display_class(Class_Prog $class, TableCreator $table_creator)
{
    $string = "";
    $id = $class->full_name();
    $string .= $table_creator->anchor($id, '') . "\n";
    $string .= $table_creator->title(3, $class->name . " ({$class->type})");
    $string .= "\n    \\begin{figure}[H]\n        \\centering\n        \\scalegraphics{img/classi/{$class->name}}\n        \\caption{Classe {$class->name}}\\label{fig:{$id}} \n    \\end{figure}\n    ";
    $string .= "\\begin{description}\n    \\item[Descrizione]  \\hfill \\\\\n      ";
    $string .= $class->description;
    $string .= "\n    \\item[Utilizzo]  \\hfill \\\\\n      ";
    $string .= $class->usage;
    $class->with('children', 'parents');
    if (count($class->parents)) {
        $string .= "\n\t  \\item[Classi ereditate]  \\hfill\n      ";
        $string .= $table_creator->begin_list();
        foreach ($class->parents as $par) {
            if (!$par->library) {
                $string .= $table_creator->list_item($table_creator->link($par->full_name(), $par->full_name(" :: ")));
            } else {
                $string .= $table_creator->list_item($par->full_name());
            }
        }
        $string .= $table_creator->end_list();
    }
    if (count($class->children)) {
        $string .= "\n\t  \\item[Ereditata da]  \\hfill\n      ";
        $string .= $table_creator->begin_list();
        foreach ($class->children as $par) {
            $string .= $table_creator->list_item($table_creator->link($par->full_name(), $par->full_name(" :: ")));
        }
        $string .= $table_creator->end_list();
    }
    if (!empty($class->attributes0)) {
        $string .= "\n\t  \\item[Attributi]  \\hfill\n\t  \\begin{description}\n\t  ";
        //$string .= $table_creator->begin_desc_list();
        foreach ($class->attributes0 as $attribute) {
            $string .= display_attribute($attribute, $table_creator);
        }
        //$string .= $table_creator->end_desc_list();
        $string .= "\n\t  \\end{description}\n      ";
    }
    if (!empty($class->methods)) {
        $string .= "\n\t  \\item[Metodi]  \\hfill\n\t  \\begin{description}\n      ";
        //$string .= $table_creator->begin_desc_list();
        foreach ($class->methods as $meth) {
            $string .= display_method($meth, $table_creator);
        }
        //$string .= $table_creator->end_desc_list();
        $string .= "\n\t  \\end{description}\n      ";
    }
    $string .= "\n    \\end{description}\n    ";
    return $string;
}
Esempio n. 12
0
<?php

$classes = Class_Prog::model()->findAll();
foreach ($classes as $class) {
    $errors = SpellCheck::check($class->description);
    if (!empty($errors)) {
        echo CHtml::link($class->name, array('class/view', 'id' => $class->id_class));
        echo " - Description";
        echo '<ul>';
        foreach ($errors as $err) {
            echo "<li>{$err}</li>";
        }
        echo '</ul>';
    }
    $errors = SpellCheck::check($class->usage);
    if (!empty($errors)) {
        echo CHtml::link($class->name, array('class/view', 'id' => $class->id_class));
        echo " - Usage";
        echo '<ul>';
        foreach ($errors as $err) {
            echo "<li>{$err}</li>";
        }
        echo '</ul>';
    }
}
Esempio n. 13
0
                                    "parent"=>$data->id_class,
                                    "child"=>' . $model->id_class . ',
                                    "to"=>' . $model->id_class . ')')))));
$pid = '';
$pdesc = '';
echo '<div class="append">';
echo CHtml::beginForm(array('addParent', 'id' => $model->id_class));
echo CHtml::label('Add as parent', 'parent');
echo CHtml::hiddenField('parent', $pid, array('id' => 'actual_parent'));
$this->widget('zii.widgets.jui.CJuiAutoComplete', array('name' => 'id_parent_autocomplete', 'sourceUrl' => array('class/parentcompletion'), 'options' => array('select' => "js:function(event, ui) {\n                        \$('#actual_parent').val(ui.item.id);\n                    }"), 'value' => $pdesc));
echo CHtml::submitButton('Add');
echo CHtml::endForm();
echo '</div>';
echo "<h2>Children</h2>";
$this->widget('zii.widgets.grid.CGridView', array('id' => 'class-child-grid', 'dataProvider' => new CArrayDataProvider($model->with('children')->children, array('keyField' => 'id_class')), 'columns' => Class_Prog::grid_columns(array(array('class' => 'CButtonColumn', 'deleteButtonUrl' => 'array("removeInheritance",
                                    "parent"=>' . $model->id_class . ',
                                    "child"=>$data->id_class,
                                    "to"=>' . $model->id_class . ' )')))));
$cid = '';
$cdesc = '';
echo '<div class="append">';
echo CHtml::beginForm(array('addChild', 'id' => $model->id_class));
echo CHtml::label('Add as child', 'child');
echo CHtml::hiddenField('child', $cid, array('id' => 'actual_child'));
$this->widget('zii.widgets.jui.CJuiAutoComplete', array('name' => 'id_child_autocomplete', 'sourceUrl' => array('class/parentcompletion'), 'options' => array('select' => "js:function(event, ui) {\n                        \$('#actual_child').val(ui.item.id);\n                    }"), 'value' => $cdesc));
echo CHtml::submitButton('Add');
echo CHtml::endForm();
echo '</div>';
echo "<h2>Attributes</h2>";
$this->widget('zii.widgets.grid.CGridView', array('dataProvider' => new CActiveDataProvider('Attribute', array('criteria' => array('condition' => 'id_class = :id', 'params' => array(':id' => $model->id_class), 'order' => 'static, access, name'), 'pagination' => false)), 'columns' => array(array('class' => 'CDataColumn', 'header' => 'Name', 'type' => 'html', 'value' => 'CHtml::link($data->name,array("attributeView","id"=>$data->id_attribute))'), 'type', 'access', 'const', 'static', 'description', array('class' => 'CButtonColumn', 'updateButtonUrl' => 'array("attributeupdate", "id"=>$data->id_attribute )', 'viewButtonUrl' => 'array("attributeview", "id"=>$data->id_attribute )', 'deleteButtonUrl' => 'array("attributedelete", "id"=>$data->id_attribute )'))));
echo '<div class="append">';
echo CHtml::link("Add attribute", array("attributeCreate", "class" => $model->id_class));
Esempio n. 14
0
?>
<div class="search-form" style="display:none">
<?php 
$this->renderPartial('_search', array('model' => $model));
?>
</div><!-- search-form -->


<?php 
$page_size = isset($_GET['num']) ? $_GET['num'] : 'lol';
$dp = $model->with('package')->search();
if ($page_size == 0 || !is_numeric($page_size)) {
    $page_size = 'infinity';
    $dp->pagination = false;
} else {
    $dp->pagination->pageSize = $page_size;
}
$page_sizes = array_unique(array(20, 50, 100, 'infinity', $page_size));
natsort($page_sizes);
echo '<p>View: ';
foreach ($page_sizes as $ps) {
    if ($ps == $page_size) {
        echo "<strong>{$ps}</strong>";
    } else {
        echo CHtml::link($ps, array('index', 'num' => $ps));
    }
    echo " ";
}
echo ' classes per page</p>';
$this->widget('zii.widgets.grid.CGridView', array('id' => 'class-prog-grid', 'dataProvider' => $dp, 'filter' => $model, 'columns' => Class_Prog::grid_columns(array(array('class' => 'CButtonColumn')))));
Esempio n. 15
0
 function print_class(Class_Prog $class, $assoc)
 {
     $class->with('children,parents,members,methods,package');
     $id = $this->class_id($class->id_class);
     $ns = $this->package_id($class->id_package);
     $pecialization = "";
     foreach ($class->children as $child) {
         $pecialization .= " " . $this->generalization_id($class->id_class, $child->id_class);
     }
     $generalization = "";
     foreach ($class->parents as $parent) {
         $generalization .= " " . $this->generalization_id($parent->id_class, $class->id_class);
     }
     $this->open_uml_element($class->type == 'interface' ? 'Interface' : 'Class', $id, $class->name, $ns, array('specialization' => $pecialization, 'generalization' => $generalization, 'isActive' => "false", 'isAbstract' => $class->type == 'class' ? 'false' : 'true'));
     $this->open_uml_simple_element('Classifier.feature');
     foreach ($class->members as $attribute) {
         $this->attribute($attribute, $assoc);
     }
     foreach ($class->methods as $method) {
         $this->method($method);
     }
     $this->close_element();
     $this->close_element();
     foreach ($class->parents as $parent) {
         $idg = $this->generalization_id($parent->id_class, $class->id_class);
         $this->uml_empty_element('Generalization', $idg, "", $ns, array('child' => $id, 'parent' => $this->class_id($parent->id_class)));
     }
 }
Esempio n. 16
0
<?php

$classes = Class_Prog::model()->with('package')->findAll('library = 0');
foreach ($classes as $class) {
    echo $class->package->full_name("/") . "/" . $class->cpp_header_file() . "\n";
    if ($sources) {
        echo $class->package->full_name("/") . "/" . $class->cpp_source_file() . "\n";
    }
}
Esempio n. 17
0
$this->breadcrumbs = array('Packages' => array('index'), $model->name);
$this->menu = array(array('label' => 'Create Package', 'url' => array('create')), array('label' => 'Update Package', 'url' => array('update', 'id' => $model->id_package)), array('label' => 'Delete Package', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id_package), 'confirm' => 'Are you sure you want to delete this item?')), array('label' => 'Manage Package', 'url' => array('index')), array('label' => 'Check spelling', 'url' => array('spellceck/package', 'id' => $model->id_package)));
echo "<h1>View Package ";
//print_r($model->parent_array());
foreach ($model->parent_array() as $n) {
    echo CHtml::link($n->name, array('view', 'id' => $n->id_package)) . "::";
}
echo $model->name . " </h1>";
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id_package', 'name', 'parent', 'description', 'virtual', array('label' => 'Accoppiamento Afferente', 'type' => 'raw', 'value' => $model->afferente()), array('label' => 'Accoppiamento Efferente', 'type' => 'raw', 'value' => $model->efferente()))));
echo "<h2>Children</h2>";
$model->with('packages');
$this->widget('zii.widgets.grid.CGridView', array('dataProvider' => new CActiveDataProvider('Package', array('criteria' => array('condition' => 'parent = :id', 'params' => array(':id' => $model->id_package)), 'pagination' => false)), 'columns' => array(array('class' => 'CDataColumn', 'header' => 'Name', 'type' => 'html', 'value' => 'CHtml::link($data->name,array("package/view","id"=>$data->id_package))'), 'description')));
echo '<div class="append">';
echo CHtml::link("Add child", array("package/create", "parent" => $model->id_package));
echo '</div>';
echo "<h2>Classes</h2>";
$model->with('classes');
$this->widget('zii.widgets.grid.CGridView', array('dataProvider' => new CActiveDataProvider('Class_Prog', array('criteria' => array('condition' => 'id_package = :id', 'params' => array(':id' => $model->id_package)), 'pagination' => false)), 'columns' => Class_Prog::grid_columns()));
echo '<div class="append">';
echo CHtml::link("Add class", array("class/create", "package" => $model->id_package));
echo '</div>';
echo '<h2>Relations with other packages</h2><ul>';
$adp = new CArrayDataProvider($model->get_dependencies());
$adp->keyField = false;
$this->widget('zii.widgets.grid.CGridView', array('dataProvider' => $adp, 'columns' => array(array('class' => 'CDataColumn', 'header' => 'From', 'type' => 'html', 'value' => '$data["id_from"] == ' . $model->id_package . '?
                     $data["name_from"] :
                     CHtml::link($data["name_from"],array("package/view",
                                    "id"=>$data["id_from"]))'), array('class' => 'CDataColumn', 'header' => 'To', 'type' => 'html', 'value' => '$data["id_to"] == ' . $model->id_package . '?
                     $data["name_to"] :
                     CHtml::link($data["name_to"],array("package/view",
                                    "id"=>$data["id_to"]))'), 'type')));
Esempio n. 18
0
<?php

/// @warning HARD CODED DB PK!!!!!!!!!!!
$methods = Method::model()->findAll();
$table = $table_creator->begin_table("|m{3cm}|m{6cm}|m{2cm}|m{2cm}|") . $table_creator->heading_row(array("Classe", "Metodo", "Righe", "Test"));
foreach ($methods as $m) {
    $class = Class_Prog::model()->findByPK($m->id_class)->name;
    $table .= $table_creator->row(array($class, $m->name, '', ''));
}
$table .= $table_creator->caption("Tabella metodi") . $table_creator->end_table();
if ($table_creator->id() != 'html' && !$raw) {
    echo CodeGen::generic_render_code($table, 'latex', true);
} else {
    echo $table;
}
 function actionUpdate_bind()
 {
     if (!isset(Yii::app()->session['class'])) {
         $this->redirect(array('index'));
     }
     $class = Yii::app()->session['class'];
     if (isset($_REQUEST['bind_class'])) {
         $oldclass = Class_Prog::findByPk($_REQUEST['bind_class']);
         if ($oldclass != null) {
             $class->id_class = $oldclass->id_class;
             $class->isNewRecord = false;
             Yii::app()->session['class'] = $class;
         }
     }
     if ($class->isNewRecord) {
         $this->render('upate/bind');
     } else {
         $this->redirect(array('update_class'));
     }
 }