Skip to content

Commit

Permalink
Add: scope note in controlled vocabulary
Browse files Browse the repository at this point in the history
  • Loading branch information
idoalit committed Jun 24, 2016
1 parent 1138e80 commit 8a1be9a
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ config/sysconfig.local.inc.php
sysconfig.inc.php
slims8_akasia.sublime-project
slims8_akasia.sublime-workspace
Thumbs.db
18 changes: 13 additions & 5 deletions admin/AJAX_vocabolary_control.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,23 @@

$output = '<li>';
$output .= '<span class="voc" style="font-style:italic;padding: 0 5px; border-radius:2px;">'.$row[1].(isset($row[2])?'</span> - '.$row[2]:'').(isset($row[3])?' - '.$row[3]:'');
$output .= '<ul style="padding-left:20px;">';
$output .= '<ul style="padding-left:20px; list-style:none;">';
$li = '';
$scope = '';

$voc_q = $dbs->query('SELECT rt_id, related_topic_id FROM mst_voc_ctrl WHERE topic_id='.$row[0]);
$voc_q = $dbs->query('SELECT rt_id, related_topic_id, scope FROM mst_voc_ctrl WHERE topic_id='.$row[0]);
while ($voc_d = $voc_q->fetch_row()) {
$topic_q = $dbs->query('SELECT topic FROM mst_topic WHERE topic_id='.$voc_d[1]);
$topic_d = $topic_q->fetch_row();
$output .= '<li><strong style="margin-right:10px;">'.$voc_d[0].'</strong><span style="padding: 0 5px; border-radius:2px;" class="voc">'.$topic_d[0].'</span></li>';
if (is_null($voc_d[2])) {
$topic_q = $dbs->query('SELECT topic, topic_type FROM mst_topic WHERE topic_id='.$voc_d[1]);
$topic_d = $topic_q->fetch_row();
$li .= '<li><strong style="margin-right:10px;">'.__($voc_d[0]).'</strong><span style="padding: 0 5px; border-radius:2px;" class="voc">'.$topic_d[0].' - '.$topic_d[1].'</span></li>';
} else {
$scope = $voc_d[2];
}
}

$output .= $scope.$li;

$output .= '</ul>';
$output .= '</li>';

Expand Down
38 changes: 22 additions & 16 deletions admin/modules/master_file/iframe_vocabolary_control.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,32 @@ function confirmProcess(topic_id, vocabolary_id)

$row = 1;
while ($voc_d = $voc_q->fetch_assoc()) {

// fallback related topic id
$topic_q = $dbs->query('SELECT topic FROM mst_topic WHERE topic_id='.$voc_d['related_topic_id']);
$topic_d = $topic_q->fetch_row();

// alternate the row color
$row_class = ($row%2 == 0)?'alterCell':'alterCell2';
if (!is_null($voc_d['scope'])) {
echo '<b>Scope note: </b>'.$voc_d['scope'].'<hr>';
}

if (is_null($voc_d['scope'])) {
// fallback related topic id
$topic_q = $dbs->query('SELECT topic FROM mst_topic WHERE topic_id='.$voc_d['related_topic_id']);
$topic_d = $topic_q->fetch_row();

// links
$edit_link = '<a class="notAJAX btn btn-primary button openPopUp" href="'.MWB.'master_file/pop_vocabolary_control.php?editTopic=true&itemID='.$itemID.'&vocID='.$voc_d['vocabolary_id'].'" height="450" title="'.__('Vocabolary Control').'" style="text-decoration: underline;"><i class="glyphicon glyphicon-pencil"></i></a>';
$remove_link = '<a href="#" class="notAJAX btn button btn-danger btn-delete" onclick="javascript: confirmProcess('.$itemID.', '.$voc_d['vocabolary_id'].')"><i class="glyphicon glyphicon-trash"></i></a>';
$related_term = $voc_d['rt_id'];
// alternate the row color
$row_class = ($row%2 == 0)?'alterCell':'alterCell2';

$table->appendTableRow(array($remove_link, $edit_link, $related_term, $topic_d[0]));
$table->setCellAttr($row, null, 'valign="top" class="'.$row_class.'" style="font-weight: bold; width: auto;"');
$table->setCellAttr($row, 0, 'valign="top" class="'.$row_class.'" style="font-weight: bold; width: 5%;"');
$table->setCellAttr($row, 1, 'valign="top" class="'.$row_class.'" style="font-weight: bold; width: 5%;"');
$table->setCellAttr($row, 2, 'valign="top" class="'.$row_class.'" style="font-weight: bold; width: 8%;"');
// links
$edit_link = '<a class="notAJAX btn btn-primary button openPopUp" href="'.MWB.'master_file/pop_vocabolary_control.php?editTopic=true&itemID='.$itemID.'&vocID='.$voc_d['vocabolary_id'].'" height="450" title="'.__('Vocabolary Control').'" style="text-decoration: underline;"><i class="glyphicon glyphicon-pencil"></i></a>';
$remove_link = '<a href="#" class="notAJAX btn button btn-danger btn-delete" onclick="javascript: confirmProcess('.$itemID.', '.$voc_d['vocabolary_id'].')"><i class="glyphicon glyphicon-trash"></i></a>';
$related_term = $voc_d['rt_id'];

$row++;
$table->appendTableRow(array($remove_link, $edit_link, $related_term, $topic_d[0]));
$table->setCellAttr($row, null, 'valign="top" class="'.$row_class.'" style="font-weight: bold; width: auto;"');
$table->setCellAttr($row, 0, 'valign="top" class="'.$row_class.'" style="font-weight: bold; width: 5%;"');
$table->setCellAttr($row, 1, 'valign="top" class="'.$row_class.'" style="font-weight: bold; width: 5%;"');
$table->setCellAttr($row, 2, 'valign="top" class="'.$row_class.'" style="font-weight: bold; width: 8%;"');

$row++;
}
}
echo $table->printTable();
// hidden form
Expand Down
111 changes: 111 additions & 0 deletions admin/modules/master_file/pop_scope_vocabolary.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php

/**
* Copyright (C) 2007,2008 Arie Nugraha ([email protected])
* Create by Waris Agung Widodo ([email protected])
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/

// key to authenticate
define('INDEX_AUTH', '1');
// key to get full database access
define('DB_ACCESS', 'fa');

// main system configuration
require '../../../sysconfig.inc.php';
// IP based access limitation
require LIB.'ip_based_access.inc.php';
do_checkIP('smc');
do_checkIP('smc-masterfile');
// start the session
require SB.'admin/default/session.inc.php';
require SB.'admin/default/session_check.inc.php';
require SIMBIO.'simbio_GUI/table/simbio_table.inc.php';
require SIMBIO.'simbio_GUI/form_maker/simbio_form_table_AJAX.inc.php';
require SIMBIO.'simbio_GUI/paging/simbio_paging.inc.php';
require SIMBIO.'simbio_DB/datagrid/simbio_dbgrid.inc.php';
require SIMBIO.'simbio_DB/simbio_dbop.inc.php';

// privileges checking
$can_read = utility::havePrivilege('master_file', 'r');
$can_write = utility::havePrivilege('master_file', 'w');

// GET ID FROM URL
$itemID = (integer)isset($_GET['itemID'])?$_GET['itemID']:0;
if (isset($_POST['save'])) {
$data['topic_id'] = (integer)$_POST['topic_id'];
$data['scope'] = trim($dbs->escape_string(strip_tags($_POST['scope'])));

# create new sql op object
$sql_op = new simbio_dbop($dbs);

if (!empty($_POST['vocabolary_id'])) {
// do update
$save = $sql_op->update('mst_voc_ctrl', $data, 'vocabolary_id='.$_POST['vocabolary_id']);
} else {
// insert
$save = $sql_op->insert('mst_voc_ctrl', $data);
}

if (isset($_POST['delete'])) {
# create new sql op object
$save = $sql_op->delete('mst_voc_ctrl', 'vocabolary_id='.$_POST['vocabolary_id']);
}

if ($save) {
$alert_save = '<script type="text/javascript">';
$alert_save .= 'alert(\''.__('Data saved!').'\');';
$alert_save .= 'parent.setIframeContent(\'itemIframe\', \''.MWB.'master_file/iframe_vocabolary_control.php?itemID='.$data['topic_id'].'\');';
$alert_save .= 'top.jQuery.colorbox.close();';
$alert_save .= '</script>';
echo $alert_save;
} else {
utility::jsAlert('Failed save data!');
}
}

// start buffer
ob_start();

// query scope
$scope_q = $dbs->query('SELECT scope, vocabolary_id FROM mst_voc_ctrl WHERE topic_id='.$itemID.' AND scope IS NOT NULL');
$scope_d = $scope_q->fetch_row();

$page_title = 'Scope Note Vocabulary';
?>
<h1><?php echo $page_title; ?></h1>
<form name="scopeForm" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<div class="form-group">
<label for="exampleInputEmail1">Scope</label>
<textarea style="height:auto;" class="form-control" name="scope" rows="5"><?php echo $scope_d[0]; ?></textarea>
</div>
<input type="hidden" name="topic_id" value="<?php echo $itemID; ?>">
<input type="hidden" name="vocabolary_id" value="<?php echo $scope_d[1]; ?>">
<div class="checkbox">
<label>
<input type="checkbox" name="delete"> Delete this scope
</label>
</div>
<input type="submit" name="save" class="btn btn-primary" value="<?php echo __('Save');?>">
</form>


<?php
/* main content end */
$content = ob_get_clean();
// include the page template
require SB.'/admin/'.$sysconf['admin_template']['dir'].'/notemplate_page_tpl.php';
5 changes: 4 additions & 1 deletion admin/modules/master_file/topic.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@
$form->addTextField('text', 'authList', __('Authority Files'), $rec_d['auth_list'], 'style="width: 30%;"');
// vocabolary control
if (!$in_pop_up AND $form->edit_mode) {
$str_input = '<div class="makeHidden"><a class="notAJAX button btn btn-info openPopUp" href="'.MWB.'master_file/pop_vocabolary_control.php?itemID='.$itemID.'" title="'.__('Vocabulary Control').'" height="400">'.__('Add New Vocabulary').'</a></div>';
$str_input = '<div class="makeHidden">';
$str_input .= '<a class="notAJAX button btn btn-info openPopUp" href="'.MWB.'master_file/pop_vocabolary_control.php?itemID='.$itemID.'" height="550px" title="'.__('Vocabulary Control').'">'.__('Add New Vocabulary').'</a>';
$str_input .= '<a class="notAJAX button btn btn-info openPopUp" href="'.MWB.'master_file/pop_scope_vocabolary.php?itemID='.$itemID.'" title="'.__('Scope Note Vocabulary').'" height="400">'.__('Scope Note').'</a>';
$str_input .= '</div>';
$str_input .= '<iframe name="itemIframe" id="itemIframe" class="borderAll" style="width: 98%; height: 200px;" src="'.MWB.'master_file/iframe_vocabolary_control.php?itemID='.$itemID.'"></iframe>'."\n";
$form->addAnything(__('Vocabulary Control'), $str_input);
}
Expand Down
Binary file added js/ckeditor/skins/moono/images/Thumbs.db
Binary file not shown.

0 comments on commit 8a1be9a

Please sign in to comment.