Ejemplo n.º 1
0
 public static function details($_model = null)
 {
     $module = static::$module;
     $modeler = $module::model()->modeler;
     $_model = $_model == null ? forward_static_call_array(array($modeler, 'model'), array()) : forward_static_call_array(array($modeler, 'model'), array($_model));
     $_o = (object) null;
     $_o->size = 'large';
     $_o->icon_type = 'menu-icon';
     $_o->icon_background = 'atom-icon-background';
     $_o->menu = (object) null;
     $_o->menu->items = self::modelOperationsMenuItems();
     $_o->head = 'Package Details';
     $_o->body = array('');
     $_o->body[] = (object) array('js' => 'registry.setContext({card:\'cards/package/details\',collection:\'packages\',node:\'' . $_model->id . '\'});');
     $_o->body[] = CardKitHTML::sublineBlock('Name');
     $_o->body[] = DOMElementKitJS::loadComponentHere(DOMElementKitJS::xhrCallObject('forms/package/name', array($_model->id)), $_model->name, 'settings');
     $_o->body[] = CardKitHTML::sublineBlock('Package Sequode');
     $_o->body[] = $_model->sequode_id != 0 && \Sequode\Application\Modules\Sequode\Modeler::exists($_model->sequode_id, 'id') ? DOMElementKitJS::loadComponentHere(DOMElementKitJS::xhrCallObject('forms/package/packageSequode', array($_model->id)), \Sequode\Application\Modules\Sequode\Modeler::model()->name, 'settings') : ModuleForm::render(static::$registry_key, 'packageSequode')[0];
     $_o->body[] = CardKitHTML::sublineBlock('Package Token');
     $_o->body[] = $_model->token;
     $_o->body[] = CardKitHTML::sublineBlock('<a target="_blank" href="/source/' . $_model->token . '">Download</a>');
     $_o->body[] = CardKit::nextInCollection((object) array('model_id' => $_model->id, 'details_route' => 'cards/package/details'));
     if (\Sequode\Application\Modules\Account\Authority::isSystemOwner()) {
         $_o->body[] = CardKitHTML::modelId($_model);
     }
     return $_o;
 }
Ejemplo n.º 2
0
 public static function source($_model_token)
 {
     if (!(\Sequode\Application\Modules\Package\Modeler::exists($_model_token, 'token') && \Sequode\Application\Modules\Sequode\Modeler::exists(\Sequode\Application\Modules\Package\Modeler::model()->sequode_id, 'id') && (\Sequode\Application\Modules\Account\Authority::isOwner(\Sequode\Application\Modules\Package\Modeler::model()) || \Sequode\Application\Modules\Account\Authority::isSystemOwner()) && (\Sequode\Application\Modules\Account\Authority::isOwner(\Sequode\Application\Modules\Sequode\Modeler::model()) || \Sequode\Application\Modules\Account\Authority::isSystemOwner()))) {
         return;
     }
     header('Content-Type: text/plain', true);
     header('Content-Disposition: attachment; filename="' . \Sequode\Application\Modules\Package\Modeler::model()->name . '.class.php"');
     echo \Sequode\Application\Modules\Package\Operations::download();
 }
 public static function removeFromSequodeFavorites($sequode_model = null, $_model = null)
 {
     $modeler = static::$modeler;
     if ($sequode_model != null) {
         \Sequode\Application\Modules\Sequode\Modeler::model($sequode_model);
     }
     $_model == null ? forward_static_call_array(array($modeler, 'model'), array()) : forward_static_call_array(array($modeler, 'model'), array($_model));
     $palette = json_decode($modeler::model()->sequode_favorites);
     $array = array();
     foreach ($palette as $value) {
         if (intval($value) != \Sequode\Application\Modules\Sequode\Modeler::model()->id) {
             $array[] = $value;
         }
     }
     $modeler::model()->updateField(json_encode($array), 'sequode_favorites');
     return $modeler::model();
 }
    public static function download()
    {
        $used_ids = array();
        $sequence_set_model_ids = array_unique(json_decode(\Sequode\Application\Modules\Sequode\Modeler::model()->sequence));
        $sequode_model = new \Sequode\Application\Modules\Sequode\Modeler::$model();
        foreach ($sequence_set_model_ids as $id) {
            $used_ids[] = $id;
            $sequode_model->exists($id, 'id');
            $used_ids = array_merge($used_ids, json_decode(\Sequode\Application\Modules\Sequode\Modeler::model()->sequence));
        }
        $sequode_model = new \Sequode\Application\Modules\Sequode\Modeler::$model();
        $models = array();
        $where = array();
        $where[] = array('field' => 'owner_id', 'operator' => '!=', 'value' => \Sequode\Application\Modules\Account\Modeler::model()->id);
        $where[] = array('field' => 'shared', 'operator' => '=', 'value' => '1');
        $where[] = array('field' => 'palette', 'operator' => '=', 'value' => '0');
        $sequode_model->getAll($where, 'id,name,detail,usage_type,coding_type,sequence,input_object,property_object,output_object,input_object_detail,property_object_detail,output_object_detail,input_object_map,property_object_map,output_object_map,input_form_object,property_form_object');
        $models = $sequode_model->all;
        $where = array();
        $where[] = array('field' => 'owner_id', 'operator' => '=', 'value' => \Sequode\Application\Modules\Account\Modeler::model()->id);
        $sequode_model->getAll($where, 'id,name,detail,usage_type,coding_type,sequence,input_object,property_object,output_object,input_object_detail,property_object_detail,output_object_detail,input_object_map,property_object_map,output_object_map,input_form_object,property_form_object');
        $name_to_id = array();
        foreach ($sequode_model->all as $key => $object) {
            if (in_array($object->id, $sequence_set_model_ids)) {
                $name_to_id[$object->name] = $object->id;
            }
        }
        $models = array_merge($models, $sequode_model->all);
        $model_id_to_key = array();
        foreach ($models as $key => $object) {
            $model_id_to_key[$object->id] = $key;
        }
        $used_ids = array();
        foreach ($models as $key => $model) {
            $node = (object) null;
            $node->id = intval($model->id);
            $node->n = str_replace(' ', '_', $model->name);
            $node->d = json_decode($model->detail);
            $node->if = json_decode($model->input_form_object);
            $node->pf = json_decode($model->property_form_object);
            $node->i = json_decode($model->input_object);
            $node->p = json_decode($model->property_object);
            $node->o = json_decode($model->output_object);
            $node->ii = json_decode($model->input_object_detail);
            $node->pi = json_decode($model->property_object_detail);
            $node->oi = json_decode($model->output_object_detail);
            if ($model->usage_type == 1) {
                $node->im = json_decode($model->input_object_map);
                $node->pm = json_decode($model->property_object_map);
                $node->om = json_decode($model->output_object_map);
            }
            if ($model->usage_type == 1) {
                $node->st = json_decode($model->usage_type);
                $node->s = json_decode($model->sequence);
                $used_ids = array_merge($used_ids, $node->s);
            } elseif ($model->usage_type == 0) {
                $node->ct = intval($model->coding_type);
                $node->c = '%START_CLOSURE_REPLACEMENT_HOOK%' . \Sequode\Application\Modules\Sequode\Kits\Operations::makeCodeFromNode($node) . '%END_CLOSURE_REPLACEMENT_HOOK%';
            }
            $models[$key] = $node;
        }
        $used_ids = array_unique($used_ids);
        $filtered_models = array();
        foreach ($models as $key => $model) {
            if (in_array($model->id, $used_ids)) {
                $filtered_models[] = $model;
                $models[$key] = null;
            }
        }
        unset($models);
        $id_to_key = array();
        foreach ($filtered_models as $key => $object) {
            $id_to_key[$object->id] = $key;
        }
        $_o = '<?php
class ' . \Sequode\Application\Modules\Package\Modeler::model()->name . ' {
    
    use \\Sequode\\Application\\Modules\\Package\\Traits\\Operations\\SequenceSetExpressTrait;
    
    public static $name_to_id = ' . PHPClosure::export($name_to_id, true) . ';
    public static $id_to_key = ' . PHPClosure::export($id_to_key, true) . ';
    public static $index = ' . $sequence_set_model_ids[0] . ';
    public static function models(){
        return ' . str_replace('Inp_Obj', 'i', str_replace('Prop_Obj', 'p', str_replace('Out_Obj', 'o', str_replace('\'%START_CLOSURE_REPLACEMENT_HOOK%', 'function($_s){ ', str_replace('%END_CLOSURE_REPLACEMENT_HOOK%\'', ' return; }', PHPClosure::export($filtered_models, true)))))) . ';
    }
}
';
        return $_o;
    }
Ejemplo n.º 5
0
 public static function updateIsPackage($sequode_model = null)
 {
     if ($sequode_model == null) {
         $sequode_model = \Sequode\Application\Modules\Sequode\Modeler::model();
     }
     $components_object = (object) null;
     FormInputModeler::exists('checkboxSwitch', 'name');
     $components_object->package = json_decode(FormInputModeler::model()->component_object);
     $components_object->package->Label = '';
     $components_object->package->On_Text = 'Useable As Package';
     $components_object->package->On_Value = 1;
     $components_object->package->Off_Text = 'Not Used As Package';
     $components_object->package->Off_Value = 0;
     $components_object->package->Value = \Sequode\Application\Modules\Sequode\Authority::isPackage($sequode_model) ? 1 : 0;
     return $components_object;
 }
Ejemplo n.º 6
0
 public static function isInSequodeFavorites($test_model = null, $_model = null)
 {
     $modeler = static::$modeler;
     if ($_model == null) {
         $_model = $modeler::model();
     }
     if ($test_model == null) {
         $test_model = \Sequode\Application\Modules\Sequode\Modeler::model();
     }
     return in_array($test_model->id, json_decode($_model->sequode_favorites)) ? true : false;
 }
Ejemplo n.º 7
0
 public static function sequode($dom_id, $_model = null)
 {
     $module = static::$module;
     $modeler = $module::model()->modeler;
     $context = $module::model()->context;
     $form_inputs = $module::model()->components->form_inputs;
     $_model == null ? forward_static_call_array(array($modeler, 'model'), array()) : forward_static_call_array(array($modeler, 'model'), array($_model));
     $_o = FormComponent::formObject();
     $_o->form_inputs = FormComponent::formInputs($form_inputs, __FUNCTION__, func_get_args());
     $_o->submit_xhr_call_route = FormComponent::xhrCallRoute($context, 'operations', 'run');
     $_o->submit_xhr_call_parameters = array();
     $_o->submit_xhr_call_parameters[] = $modeler::model()->id;
     $_o->submit_xhr_call_parameters[] = FormComponent::$collection_replacement_hook;
     $_o->submit_button = \Sequode\Application\Modules\Sequode\Modeler::model()->name;
     return $_o;
 }
Ejemplo n.º 8
0
 public static function updateName($sequode_model_id = 0, $name = '')
 {
     if (!(\Sequode\Application\Modules\Sequode\Modeler::exists($sequode_model_id, 'id') && \Sequode\Application\Modules\Account\Authority::canEdit())) {
         return;
     }
     $object = (object) null;
     $object->Success = false;
     $name = trim(str_replace('-', '_', str_replace(' ', '_', urldecode($name))));
     if (strlen($name) == 0) {
         $object->Error = 'Name cannot be empty';
     } elseif (!eregi("^([A-Za-z0-9_])*\$", $name)) {
         $object->Error = 'Name can be alphanumeric and contain spaces only';
     } elseif (!\Sequode\Application\Modules\Account\Authority::canRename($name)) {
         $object->Error = 'Name already used';
     }
     if (!isset($object->Error)) {
         \Sequode\Application\Modules\Sequode\Modeler::exists($sequode_model_id, 'id');
         \Sequode\Application\Modules\Sequode\Operations::updateName($name);
         $object->Success = true;
     }
     echo json_encode($object);
     return;
 }
Ejemplo n.º 9
0
 public static function removeFromGridArea($position, $grid_areas, $sequode_model = null)
 {
     if ($sequode_model == null) {
         $sequode_model = \Sequode\Application\Modules\Sequode\Modeler::model();
     }
     $grid_area_key = self::getGridAreasKeyFromPosition($position, $sequode_model);
     $grid_areas = self::reduceGridAreaCount($grid_areas, $grid_area_key);
     $grid_areas = self::removeZeroCountGridAreas($grid_areas);
     if (count($grid_areas) == 0) {
         $grid_areas = self::defaultGridAreas();
     }
     return $grid_areas;
 }
Ejemplo n.º 10
0
 public static function isPackage($sequode_model = null)
 {
     if ($sequode_model == null) {
         $sequode_model = \Sequode\Application\Modules\Sequode\Modeler::model();
     }
     return $sequode_model->package == 1 ? true : false;
 }