Merge branch 'master' of disposed.de:scattport
This commit is contained in:
@@ -52,7 +52,7 @@ $autoload['packages'] = array(APPPATH.'third_party');
|
||||
| $autoload['libraries'] = array('database', 'session', 'xmlrpc');
|
||||
*/
|
||||
|
||||
$autoload['libraries'] = array('session', 'lang_detect', 'database', 'access', 'datamapper', 'messages');
|
||||
$autoload['libraries'] = array('session', 'lang_detect', 'database', 'access', 'messages');
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -114,7 +114,7 @@ class Projects extends CI_Controller {
|
||||
|
||||
if (isset($data['project_id'])) {
|
||||
$this->load->helper('directory');
|
||||
$projectPath = FCPATH.'uploads/'.$this->session->userdata('user_id').'/'.$data['project_id'].'/';
|
||||
$projectPath = FCPATH . 'uploads/' . $data['project_id'] . '/';
|
||||
mkdirs($projectPath);
|
||||
|
||||
if ($modelUploaded) {
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
* Trials are used to store different variations of the same project.
|
||||
*
|
||||
* @author Karsten Heiken <karsten@disposed.de>
|
||||
* @author Eike Foken <kontakt@eikefoken.de>
|
||||
* @author Eike Foken <kontakts@eikefoken.de>
|
||||
*/
|
||||
class Trials extends CI_Controller {
|
||||
|
||||
@@ -84,10 +84,13 @@ class Trials extends CI_Controller {
|
||||
}
|
||||
|
||||
$this->load->helper('directory');
|
||||
$trialPath = FCPATH.'uploads/'.$this->session->userdata('user_id').'/'.$projectId.'/'. $trialId.'/';
|
||||
$trialPath = FCPATH . 'uploads/' . $projectId . '/' . $trialId . '/';
|
||||
mkdirs($trialPath);
|
||||
|
||||
redirect('trials/detail/' . $trialId, 'refresh');
|
||||
$this->load->library('job');
|
||||
$this->job->createConfigs($trialId);
|
||||
|
||||
//redirect('trials/detail/' . $trialId, 'refresh');
|
||||
} else {
|
||||
$this->messages->add(_('The trial could not be created.'), 'error');
|
||||
}
|
||||
|
||||
48
application/libraries/Job.php
Normal file
48
application/libraries/Job.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php defined('BASEPATH') || exit("No direct script access allowed");
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Eike Foken <kontakt@eikefoken.de>
|
||||
*/
|
||||
class Job {
|
||||
|
||||
private $CI;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->CI =& get_instance();
|
||||
|
||||
// load models
|
||||
$this->CI->load->model('program');
|
||||
$this->CI->load->model('trial');
|
||||
|
||||
log_message('debug', "Trial Class Initialized");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $trialId
|
||||
* @return boolean Returns TRUE on success.
|
||||
*/
|
||||
public function createConfigs($trialId) {
|
||||
$trial = $this->CI->trial->getById($trialId);
|
||||
$path = FCPATH . 'uploads/' . $trial['project_id'] . '/' . $trial['id'] . '/';
|
||||
|
||||
$program = $this->CI->program->getById($trial['program_id']);
|
||||
|
||||
$handler = fopen($path . 'trial.conf', "w");
|
||||
|
||||
$parameters = $this->CI->trial->getParameters($trialId);
|
||||
foreach ($parameters as $param) {
|
||||
$line = str_replace("{type}", $param['type'], $program['input_line']);
|
||||
$line = str_replace("{param}", $param['name'], $line);
|
||||
$line = str_replace("{value}", $param['value'], $line);
|
||||
fwrite($handler, $line);
|
||||
}
|
||||
fclose($handler);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -82,10 +82,26 @@ class Trial extends CI_Model {
|
||||
return $this->db->affected_rows() == 1 ? $trialId : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all parameters for the specified trial.
|
||||
*
|
||||
* @param string $trialId
|
||||
* @return array
|
||||
*/
|
||||
public function getParameters($trialId) {
|
||||
$this->db->select('trials_parameters.*, parameters.name AS `name`, parameters.type AS `type`');
|
||||
$this->db->join('parameters', 'trials_parameters.parameter_id = parameters.id', 'left');
|
||||
$this->db->where('trial_id', $trialId);
|
||||
|
||||
$query = $this->db->get('trials_parameters');
|
||||
|
||||
return $query->num_rows() > 0 ? $query->result_array() : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a trial by id.
|
||||
*
|
||||
* @param type $trial_id The trial to get.
|
||||
* @param string $trial_id The trial to get.
|
||||
* @return array The trial
|
||||
*/
|
||||
public function get($trial_id) {
|
||||
@@ -94,6 +110,16 @@ class Trial extends CI_Model {
|
||||
return $query->row_array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a trial by ID.
|
||||
*
|
||||
* @param string $trialId The trial to get
|
||||
* @return array The trial
|
||||
*/
|
||||
public function getById($trialId) {
|
||||
return $this->db->get_where('trials', array('id' => $trialId))->row_array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a trial by its project id.
|
||||
*
|
||||
|
||||
@@ -31,6 +31,20 @@ $(document).ready(function() {
|
||||
<?=form_error('name')?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Config file line'), 'input_line');?>
|
||||
<span class="req">*</span>
|
||||
<div>
|
||||
<textarea name="input_line" id="input_line" rows="6" cols="60" class="textarea"><?=set_value('input_line', $program['input_line']);?></textarea>
|
||||
<?=form_error('input_line')?>
|
||||
</div>
|
||||
<label class="note">
|
||||
<?=_('Here you can specify how a single line of a configuration file looks. You can use the following placeholders:');?><br />
|
||||
<strong>{type}</strong> <?=_('Parameter type');?><br />
|
||||
<strong>{param}</strong> <?=_('Parameter name');?><br />
|
||||
<strong>{value}</strong> <?=_('Value');?><br />
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
<a class="button save" href="javascript:void(0);" onclick="$('form[name=editProgram]').submit();"><?=_('Save');?></a>
|
||||
|
||||
Reference in New Issue
Block a user