Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Worked on glossary
  • Loading branch information
ericlbarnes committed Jul 27, 2010
1 parent 26affb7 commit 0b23c58
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 1 deletion.
2 changes: 1 addition & 1 deletion upload/includes/68kb/cache/load_addons.cache
@@ -1 +1 @@
a:4:{s:16:"__cache_contents";a:0:{}s:15:"__cache_created";i:1280259736;s:20:"__cache_dependencies";a:0:{}s:15:"__cache_expires";i:1280259796;}
a:4:{s:16:"__cache_contents";a:0:{}s:15:"__cache_created";i:1280260845;s:20:"__cache_dependencies";a:0:{}s:15:"__cache_expires";i:1280260905;}
1 change: 1 addition & 0 deletions upload/includes/68kb/language/english/kb_lang.php
Expand Up @@ -349,6 +349,7 @@
$lang['lang_glossary'] = 'Glossary';
$lang['lang_term'] = 'Term';
$lang['lang_add_term'] = 'Add Term';
$lang['lang_edit_term'] = 'Edit Term';
$lang['lang_definition'] = 'Definition';
$lang['kb_save'] = 'Save';
$lang['kb_save_and_continue'] = 'Save and Continue Editing';
Expand Down
88 changes: 88 additions & 0 deletions upload/includes/68kb/modules/kb/controllers/admin_glossary.php
Expand Up @@ -55,6 +55,94 @@ public function index()

// ------------------------------------------------------------------------

/**
* add term
*
*/
public function add()
{
$data['nav'] = 'glossary';

$this->template->title(lang('lang_add_term'));
$data['action'] = 'add';

$this->load->helper(array('form', 'url', 'html'));
$this->load->library('form_validation');
$this->form_validation->set_rules('g_term', 'lang:lang_title', 'required');
$this->form_validation->set_rules('g_definition', 'lang:lang_definition', 'required');
$this->events->trigger('glossary/validation');

if ($this->form_validation->run() == FALSE)
{
$this->template->build('admin/glossary/form', $data);
}
else
{
$data = array(
'g_term' => $this->input->post('g_term', TRUE),
'g_definition' => $this->input->post('g_definition', TRUE)
);

if ($this->db->insert('glossary', $data))
{
$this->session->set_flashdata('msg', lang('lang_settings_saved'));
redirect('admin/kb/glossary/');
}
}
}

// ------------------------------------------------------------------------

/**
* edit term
*
*/
public function edit($id = '')
{
if ( ! is_numeric($id))
{
redirect('admin/kb/glossary');
}
$id = (int) $id;

$data['nav'] = 'glossary';

$this->db->from('glossary')->where('g_id', $id);
$query = $this->db->get();
$data['row'] = $query->row_array();
$query->free_result();

$this->template->title(lang('lang_edit_term'));

$data['action'] = 'add';

$this->load->helper(array('form', 'url', 'html'));
$this->load->library('form_validation');
$this->form_validation->set_rules('g_term', 'lang:lang_title', 'required');
$this->form_validation->set_rules('g_definition', 'lang:lang_definition', 'required');
$this->events->trigger('glossary/validation');

if ($this->form_validation->run() == FALSE)
{
$this->template->build('admin/glossary/form', $data);
}
else
{
$data = array(
'g_term' => $this->input->post('g_term', TRUE),
'g_definition' => $this->input->post('g_definition', TRUE)
);
$this->db->where('g_id', $id);
if ($this->db->update('glossary', $data))
{
$this->session->set_flashdata('msg', lang('lang_settings_saved'));
redirect('admin/kb/glossary/');
}
}
}

// ------------------------------------------------------------------------

/**
* Grid
*
Expand Down
38 changes: 38 additions & 0 deletions upload/includes/68kb/modules/kb/views/admin/glossary/form.php
@@ -0,0 +1,38 @@
<?php
if ($this->events->active_hook('articles/form'))
{
$this->events->trigger('articles/form');
}
else
{
echo '<script src="js/js-quicktags/js_quicktags.js" type="text/javascript"></script>';
}
?>
<div class="grid_16">
<h2><?php echo lang('lang_manage_glossary'); ?></h2>

<?php if(validation_errors()) {
echo '<div class="error"><h3>'.lang('lang_errors_occured').'</h3> '.validation_errors().'</div>';
}
?>

<?php echo form_open($this->uri->uri_string(), 'class="crud"'); ?>
<div id="form">
<div class="inline">

<p class="row1">
<?php echo form_label(lang('lang_title'). ': <em>('.lang('lang_required').')</em>', 'g_term'); ?>
<?php echo form_input('g_term', set_value('g_term', @$row['g_term']), 'id="g_term"'); ?>
</p>

<div class="row2">
<?php echo form_label(lang('lang_definition'). ':', 'g_definition'); ?>
<div class="toolbar"><script type="text/javascript">if(typeof edToolbar=='function') edToolbar('g_definition');</script></div>
<?php echo form_textarea('g_definition', set_value('g_definition', @$row['g_definition']), 'id="g_definition" class="inputtext"'); ?>
</div>

<p class="submit"><?php echo form_submit('submit', lang('lang_save'), 'class="save"'); ?></p>
</div>
</div>
</form>
</div>

0 comments on commit 0b23c58

Please sign in to comment.