'select',
'#title' => t('Title of the circuit_simulation'),
'#options' => _list_of_circuit_simulation(),
'#default_value' => $selected,
'#ajax' => array(
'callback' => 'circuit_simulation_project_details_callback'
)
);
if (!$url_circuit_simulation_id) {
$form['circuit_simulation_details'] = array(
'#type' => 'item',
'#markup' => '
'
);
$form['selected_circuit_simulation'] = array(
'#type' => 'item',
'#markup' => ''
);
} //!$url_circuit_simulation_id
else {
$circuit_simulation_default_value = $url_circuit_simulation_id;
$form['circuit_simulation_details'] = array(
'#type' => 'item',
'#markup' => '' . _circuit_simulation_details($circuit_simulation_default_value) . '
'
);
$form['selected_circuit_simulation'] = array(
'#type' => 'item',
'#markup' => '' . l('Download Circuit Simulation', 'circuit_simulationing-project/full-download/project/' . $circuit_simulation_default_value,array('attributes' => array('title' => 'This is a zip file containing a pdf (abstract) and a dwxml/dwxmz file which is the eSim circuit simulation which is to be viewed by right clicking on the file and opening with eSim.'))) . '
'
);
}
return $form;
}
function circuit_simulation_project_details_callback($form, $form_state)
{
$commands = array();
$circuit_simulation_default_value = $form_state['values']['circuit_simulation'];
if ($circuit_simulation_default_value != 0) {
$form['circuit_simulation_details']['#markup'] = _circuit_simulation_details($circuit_simulation_default_value);
$circuit_simulation_details = _circuit_simulation_information($circuit_simulation_default_value);
$provider = user_load($circuit_simulation_details->uid);
if ($circuit_simulation_details->uid > 0) {
$commands[] = ajax_command_html('#ajax_selected_circuit_simulation', l('Download Circuit Simulation', 'circuit-simulation-project/full-download/project/' . $circuit_simulation_default_valuei,array('attributes' => array('title' => 'This is a zip file containing a pdf (abstract) and a dwxml/dwxmz file which is the eSim circuit simulation which is to be viewed by right clicking on the file and opening with eSim.'))));
} //$circuit_simulation_details->uid > 0
else {
$commands[] = ajax_command_html('#ajax_selected_circuit_simulation', '');
$commands[] = ajax_command_html('#ajax_selected_circuit_simulation_esim', '');
}
$commands[] = ajax_command_html('#ajax_circuit_simulation_details', _circuit_simulation_details($circuit_simulation_default_value));
} //$circuit_simulation_default_value != 0
else {
// $form['lab_experiment_list']['#options'] = _ajax_get_experiment_list();
// $commands[] = ajax_command_replace('#ajax_selected_experiment', drupal_render($form['lab_experiment_list']));
$commands[] = ajax_command_html('#ajax_circuit_simulation_details', '');
$commands[] = ajax_command_html('#ajax_selected_circuit_simulation', '');
$commands[] = ajax_command_html('#ajax_selected_circuit_simulation_esim', '');
$commands[] = ajax_command_data('#ajax_selected_circuit_simulation', 'form_state_value_select', $form_state['values']['circuit_simulation']);
}
return array(
'#type' => 'ajax',
'#commands' => $commands
);
}
function bootstrap_table_format($headers, $rows)
{
$thead = "";
$tbody = "";
foreach ($headers as $header) {
$thead .= "{$header} | ";
} //$headers as $header
foreach ($rows as $row) {
$tbody .= "";
foreach ($row as $data) {
$tbody .= "{$data} | ";
} //$row as $data
$tbody .= "
";
} //$rows as $row
$table = "
";
return $table;
}
/*****************************************************/
function _list_of_circuit_simulation()
{
$circuit_simulation_titles = array(
'0' => 'Please select...'
);
//$lab_titles_q = db_query("SELECT * FROM {circuit_simulation_proposal} WHERE solution_display = 1 ORDER BY lab_title ASC");
$query = db_select('circuit_simulation_proposal');
$query->fields('circuit_simulation_proposal');
$query->condition('approval_status', 3);
$query->orderBy('project_title', 'ASC');
$circuit_simulation_titles_q = $query->execute();
while ($circuit_simulation_titles_data = $circuit_simulation_titles_q->fetchObject()) {
$circuit_simulation_titles[$circuit_simulation_titles_data->id] = $circuit_simulation_titles_data->project_title . ' (Proposed by ' . $circuit_simulation_titles_data->name_title . ' ' . $circuit_simulation_titles_data->contributor_name . ')';
} //$circuit_simulation_titles_data = $circuit_simulation_titles_q->fetchObject()
return $circuit_simulation_titles;
}
function _circuit_simulation_information($proposal_id)
{
$query = db_select('circuit_simulation_proposal');
$query->fields('circuit_simulation_proposal');
$query->condition('id', $proposal_id);
$query->condition('approval_status', 3);
$circuit_simulation_q = $query->execute();
$circuit_simulation_data = $circuit_simulation_q->fetchObject();
if ($circuit_simulation_data) {
return $circuit_simulation_data;
} //$circuit_simulation_data
else {
return 'Not found';
}
}
function _circuit_simulation_details($circuit_simulation_default_value)
{
$circuit_simulation_details = _circuit_simulation_information($circuit_simulation_default_value);
if ($circuit_simulation_default_value != 0) {
if($circuit_simulation_details->reference != NULL){
$url = '~(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?$0', $circuit_simulation_details->reference);
}else{
$reference = 'Not provided';
}
$form['circuit_simulation_details']['#markup'] = 'About the Circuit Simulation ' . '' . '- Proposer Name: ' . $circuit_simulation_details->name_title . ' ' . $circuit_simulation_details->contributor_name . '
' . '- Title of the Flowhseet: ' . l($circuit_simulation_details->project_title,'circuit-simulation-project/full-download/project/' . $circuit_simulation_default_value,array('attributes' => array('title' => 'This is a zip file containing a pdf (abstract) and a dwxml/dwxmz file which is the eSim circuit simulation which is to be viewed by right clicking on the file and opening with eSim.'))) . '
' . '- University: ' . $circuit_simulation_details->university . '
' . '- '.'Reference: ' . $reference .'
'.' ';
$details = $form['circuit_simulation_details']['#markup'];
return $details;
} //$circuit_simulation_default_value != 0
}
|