Permalink
Browse files

Fixed bug in installer and worked on attachment

  • Loading branch information...
1 parent cf8554d commit 7ffc05332b353a22a33dedc6daa44641aa2ea92c @ericbarnes ericbarnes committed Aug 10, 2010
View
2 upload/setup/migrations/001_Create_settings.php
@@ -398,8 +398,6 @@ function table_settings()
{
$CI =& get_instance();
- $CI->dbforge->drop_table('settings');
-
if ( ! $CI->db->table_exists('settings'))
{
$fields = array(
View
100 upload/setup/migrations/005_Alter_settings.php
@@ -1,100 +0,0 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * 68kb
- *
- * An open source knowledge base script
- *
- * @package 68kb
- * @author 68kb Dev Team
- * @copyright Copyright (c) 2010, 68kb
- * @license http://68kb.com/user_guide/license.html
- * @link http://68kb.com
- * @since Version 2.0
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Database Migrations
- *
- * @subpackage Models
- * @link http://68kb.com/user_guide/
- */
-class Alter_settings
-{
- var $msg = '';
-
- // ------------------------------------------------------------------------
-
- function up()
- {
- $CI =& get_instance();
-
- $CI->load->dbforge();
-
- $CI->dbforge->drop_table('settings');
-
- if ( ! $CI->db->table_exists('settings'))
- {
- $fields = array(
- 'option_id' => array('type' => 'INT','constraint' => 11,'unsigned' => TRUE,'auto_increment' => TRUE),
- );
- $CI->dbforge->add_field($fields);
- $CI->dbforge->add_field("option_name varchar(64) NOT NULL DEFAULT ''");
- $CI->dbforge->add_field("option_value mediumtext NOT NULL");
- $CI->dbforge->add_field("option_group varchar(55) NOT NULL DEFAULT 'site'");
- $CI->dbforge->add_field("auto_load ENUM('no','yes') NOT NULL DEFAULT 'yes'");
-
- $CI->dbforge->add_key('option_id', TRUE);
- $CI->dbforge->add_key('option_name', TRUE);
- $CI->dbforge->add_key('option_name');
- $CI->dbforge->add_key('auto_load');
-
- $CI->dbforge->create_table('settings');
-
- $data = array('option_name' => 'site_name','option_value' => 'Your Site', 'option_group' => 'site', 'auto_load' => 'yes');
- $CI->db->insert('settings', $data);
- $data = array('option_name' => 'site_email','option_value' => 'demo@demo.com', 'option_group' => 'site', 'auto_load' => 'yes');
- $CI->db->insert('settings', $data);
- $data = array('option_name' => 'site_keywords','option_value' => 'keywords, go, here', 'option_group' => 'site', 'auto_load' => 'yes');
- $CI->db->insert('settings', $data);
- $data = array('option_name' => 'site_description','option_value' => 'Site Description', 'option_group' => 'site', 'auto_load' => 'yes');
- $CI->db->insert('settings', $data);
- $data = array('option_name' => 'site_max_search','option_value' => '20', 'option_group' => 'site', 'auto_load' => 'yes');
- $CI->db->insert('settings', $data);
- $data = array('option_name' => 'site_cache_time','option_value' => '0', 'option_group' => 'site', 'auto_load' => 'yes');
- $CI->db->insert('settings', $data);
- $data = array('option_name' => 'site_theme','option_value' => 'default', 'option_group' => 'site', 'auto_load' => 'yes');
- $CI->db->insert('settings', $data);
- $data = array('option_name' => 'site_admin_template','option_value' => 'default', 'option_group' => 'site', 'auto_load' => 'yes');
- $CI->db->insert('settings', $data);
- $data = array('option_name' => 'site_bad_words','option_value' => "", 'option_group' => 'site', 'auto_load' => 'no');
- $CI->db->insert('settings', $data);
- $data = array('option_name' => 'script_version','option_value' => '', 'option_group' => 'script', 'auto_load' => 'yes');
- $CI->db->insert('settings', $data);
- $data = array('option_name' => 'script_build','option_value' => '', 'option_group' => 'script', 'auto_load' => 'yes');
- $CI->db->insert('settings', $data);
- $data = array('option_name' => 'script_db_version','option_value' => "", 'option_group' => 'script', 'auto_load' => 'yes');
- $CI->db->insert('settings', $data);
- $data = array('option_name' => 'script_latest','option_value' => '0', 'option_group' => 'script', 'auto_load' => 'yes');
- $CI->db->insert('settings', $data);
- $data = array('option_name' => 'script_last_cron','option_value' => "", 'option_group' => 'script', 'auto_load' => 'yes');
- $CI->db->insert('settings', $data);
-
- return 'settings table installed...<br />';
- }
-
- $this->msg = 'Altered Settings Table.';
- return $this->msg;
- }
-
- // ------------------------------------------------------------------------
-
- function down()
- {
-
- }
-}
-
-/* End of file 005_Alter_settings.php */
-/* Location: ./upload/setup/migrations/005_Alter_settings.php */
View
0 upload/setup/migrations/006_Alter_users.php → upload/setup/migrations/005_Alter_users.php
File renamed without changes.
View
0 ...setup/migrations/007_Alter_categories.php → ...setup/migrations/006_Alter_categories.php
File renamed without changes.
View
0 upload/setup/migrations/008_User_notes.php → upload/setup/migrations/007_User_notes.php
File renamed without changes.
View
0 ...d/setup/migrations/009_Article_fields.php → ...d/setup/migrations/008_Article_fields.php
File renamed without changes.
View
67 upload/setup/migrations/009_Edit_attachements.php
@@ -0,0 +1,67 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * 68kb
+ *
+ * An open source knowledge base script
+ *
+ * @package 68kb
+ * @author 68kb Dev Team
+ * @copyright Copyright (c) 2010, 68kb
+ * @license http://68kb.com/user_guide/license.html
+ * @link http://68kb.com
+ * @since Version 2.0
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Database Migrations
+ *
+ * @subpackage Models
+ * @link http://68kb.com/user_guide/
+ */
+class Edit_attachements
+{
+ var $msg = '';
+
+ // ------------------------------------------------------------------------
+
+ function up()
+ {
+ $CI =& get_instance();
+
+ $CI->load->dbforge();
+
+ if ( ! $CI->db->field_exists('attach_title', 'attachments'))
+ {
+ $fields = array(
+ 'attach_name' => array(
+ 'name' => 'attach_file',
+ 'type' => 'varchar',
+ 'constraint' => '55'
+ ),
+ );
+ $CI->dbforge->modify_column('attachments', $fields);
+
+ $fields = array(
+ 'attach_title' => array(
+ 'type' => 'VARCHAR',
+ 'constraint' => '55',
+ ),
+ );
+ $CI->dbforge->add_column('attachments', $fields);
+ }
+
+ $this->msg = 'Altered Attachments Table.';
+ return $this->msg;
+ }
+
+ // ------------------------------------------------------------------------
+
+ function down()
+ {
+
+ }
+}
+/* End of file 010_Edit_attachements.php */
+/* Location: ./upload/setup/migrations/010_Edit_attachements.php */
View
1 upload/system/68kb/cache/categories_model/41bad94dfc291624ffcca4447ca80be57eef9f9d.cache
@@ -1 +0,0 @@
-a:4:{s:16:"__cache_contents";a:2:{i:0;a:2:{s:8:"cat_name";s:4:"Test";s:7:"cat_uri";s:4:"test";}i:1;a:2:{s:8:"cat_name";s:12:"Sub Category";s:7:"cat_uri";s:17:"test/sub_category";}}s:15:"__cache_created";i:1281445977;s:20:"__cache_dependencies";a:0:{}s:15:"__cache_expires";i:1281449577;}
View
2 upload/system/68kb/cache/categories_model/7d04b033b9f522af841712167293feba43063c86.cache
@@ -1 +1 @@
-a:4:{s:16:"__cache_contents";a:1:{i:0;a:2:{s:8:"cat_name";s:4:"Test";s:7:"cat_uri";s:4:"test";}}s:15:"__cache_created";i:1281446112;s:20:"__cache_dependencies";a:0:{}s:15:"__cache_expires";i:1281449712;}
+a:4:{s:16:"__cache_contents";a:1:{i:0;a:2:{s:8:"cat_name";s:6:"Parent";s:7:"cat_uri";s:6:"parent";}}s:15:"__cache_created";i:1281453477;s:20:"__cache_dependencies";a:0:{}s:15:"__cache_expires";i:1281457077;}
View
10 upload/system/68kb/cache/index.html
@@ -1,10 +0,0 @@
-<html>
-<head>
- <title>403 Forbidden</title>
-</head>
-<body>
-
-<p>Directory access is forbidden.</p>
-
-</body>
-</html>
View
2 upload/system/68kb/cache/load_addons.cache
@@ -1 +1 @@
-a:4:{s:16:"__cache_contents";a:1:{i:0;O:8:"stdClass":2:{s:16:"module_directory";s:5:"debug";s:11:"module_name";s:5:"debug";}}s:15:"__cache_created";i:1281449160;s:20:"__cache_dependencies";a:0:{}s:15:"__cache_expires";i:1281449220;}
+a:4:{s:16:"__cache_contents";a:0:{}s:15:"__cache_created";i:1281455959;s:20:"__cache_dependencies";a:0:{}s:15:"__cache_expires";i:1281456019;}
View
12 upload/system/68kb/config/config.php
@@ -40,6 +40,18 @@
/*
|--------------------------------------------------------------------------
+| Allowed upload types
+|--------------------------------------------------------------------------
+|
+| The mime types corresponding to the types of files you allow to be uploaded.
+| Usually the file extension can be used as the mime type. Separate multiple
+| types with a pipe.
+|
+*/
+$config['allowed_types'] = 'pdf|txt|zip|gif|jpg|png';
+
+/*
+|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
View
1 upload/system/68kb/language/english/kb_lang.php
@@ -79,6 +79,7 @@
$lang['lang_attachment'] = 'Add Attachment';
$lang['lang_attachments'] = 'Attachments';
+$lang['lang_attachment_title'] = 'Attachment Title';
$lang['lang_attachment_add'] = 'After you save this article you can add attachments';
$lang['lang_upload'] = 'Upload';
$lang['lang_show'] = 'Show';
View
171 upload/system/68kb/modules/kb/controllers/admin_articles.php
@@ -62,7 +62,7 @@ public function index()
public function add()
{
$data['nav'] = 'articles';
-
+
$this->template->title(lang('lang_add_article'));
// Get the categories
@@ -123,7 +123,7 @@ public function add()
$target = ROOTPATH .'uploads/'.$id;
$this->_mkdir($target);
$config['upload_path'] = $target;
- $config['allowed_types'] = $this->config->item('attachment_types');
+ $config['allowed_types'] = $this->config->item('allowed_types');
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
@@ -135,12 +135,13 @@ public function add()
$upload = array('upload_data' => $this->upload->data());
$insert = array(
'article_id' => $id,
- 'attach_name' => $upload['upload_data']['file_name'],
+ 'attach_title' => $this->input->post('attach_title', TRUE),
+ 'attach_file' => $upload['upload_data']['file_name'],
'attach_type' => $upload['upload_data']['file_type'],
'attach_size' => $upload['upload_data']['file_size']
);
$this->db->insert('attachments', $insert);
- $data['attach'] = $this->article_model->get_attachments($id);
+ $data['attach'] = $this->articles_model->get_attachments($id);
}
}
if (isset($_POST['save']) && $_POST['save']<>"")
@@ -164,11 +165,13 @@ public function add()
*/
public function edit($id = '')
{
- if ($id == '')
+ if ($id == '' OR ! is_numeric($id))
{
redirect('admin/kb/articles');
}
+ $id = (int) $id;
+
$data['nav'] = 'articles';
$this->template->title(lang('lang_edit_article'));
@@ -209,9 +212,15 @@ public function edit($id = '')
}
else
{
+ $owner = 1;
+ if ($user = $this->users_model->get_user($this->input->post('article_author', TRUE)))
+ {
+ $owner = $user['user_id'];
+ }
+
$data = array(
- 'article_uri' => $article_uri,
- 'article_author' => $this->session->userdata('userid'),
+ 'article_uri' => $this->input->post('article_uri', TRUE),
+ 'article_author' => $owner,
'article_title' => $this->input->post('article_title', TRUE),
'article_keywords' => $this->input->post('article_keywords', TRUE),
'article_short_desc' => $this->input->post('article_short_desc', TRUE),
@@ -220,59 +229,133 @@ public function edit($id = '')
'article_order' => $this->input->post('article_order', TRUE)
);
- $id = $this->articles_model->add_article($data);
+ $this->articles_model->edit_article($id, $data);
$this->session->set_flashdata('msg', lang('lang_settings_saved'));
- if (is_int($id))
+ // now add cat to product relationship
+ if (isset($_POST['cats']))
{
- // now add cat to product relationship
- if (isset($_POST['cats']))
+ $this->articles_model->insert_cats($_POST['cats'], $id);
+ }
+
+ if ($_FILES['userfile']['name'] != "")
+ {
+ $target = ROOTPATH .'uploads/'.$id;
+ $this->_mkdir($target);
+ $config['upload_path'] = $target;
+ $config['allowed_types'] = $this->config->item('allowed_types');
+ $this->load->library('upload', $config);
+ if ( ! $this->upload->do_upload())
{
- $this->articles_model->insert_cats($_POST['cats'], $id);
+ $this->session->set_flashdata('error', $this->upload->display_errors());
+ redirect('admin/kb/articles/edit/'.$id);
}
-
- if ($_FILES['userfile']['name'] != "")
+ else
{
- $target = ROOTPATH .'uploads/'.$id;
- $this->_mkdir($target);
- $config['upload_path'] = $target;
- $config['allowed_types'] = $this->config->item('attachment_types');
- $this->load->library('upload', $config);
- if ( ! $this->upload->do_upload())
- {
- $this->session->set_flashdata('error', $this->upload->display_errors());
- redirect('admin/kb/articles/edit/'.$id);
- }
- else
- {
- $upload = array('upload_data' => $this->upload->data());
- $insert = array(
- 'article_id' => $id,
- 'attach_name' => $upload['upload_data']['file_name'],
- 'attach_type' => $upload['upload_data']['file_type'],
- 'attach_size' => $upload['upload_data']['file_size']
- );
- $this->db->insert('attachments', $insert);
- $data['attach'] = $this->article_model->get_attachments($id);
- }
+ $upload = array('upload_data' => $this->upload->data());
+ $insert = array(
+ 'article_id' => $id,
+ 'attach_title' => $this->input->post('attach_title', TRUE),
+ 'attach_file' => $upload['upload_data']['file_name'],
+ 'attach_type' => $upload['upload_data']['file_type'],
+ 'attach_size' => $upload['upload_data']['file_size']
+ );
+ $this->db->insert('attachments', $insert);
+ $data['attach'] = $this->articles_model->get_attachments($id);
}
- if (isset($_POST['save']) && $_POST['save']<>"")
- {
- redirect('admin/kb/articles/edit/'.$id);
- }
- else
- {
- redirect('admin/kb/articles/');
- }
}
+
+ if (isset($_POST['save']) && $_POST['save']<>"")
+ {
+ redirect('admin/kb/articles/edit/'.$id);
+ }
+
redirect('admin/kb/articles/');
}
}
// ------------------------------------------------------------------------
/**
+ * Delete an Uploaded file.
+ *
+ */
+ public function upload_delete($id = '')
+ {
+ $this->load->helper('file');
+ if ( ! is_numeric($id))
+ {
+ redirect('admin/kb/articles/');
+ }
+ $id = (int) $id;
+
+ $this->db->select('attach_id, article_id, attach_file')->from('attachments')->where('attach_id', $id);
+ $query = $this->db->get();
+ if ($query->num_rows() > 0)
+ {
+ $row = $query->row();
+ $article_id = $row->article_id;
+ unlink(ROOTPATH .'uploads/'.$row->article_id.'/'.$row->attach_file);
+ $this->db->delete('attachments', array('attach_id' => $id));
+ redirect('admin/kb/articles/edit/'.$article_id.'/#attachments');
+ }
+ else
+ {
+ redirect('admin/kb/articles/');
+ }
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Attempt to make a directory to house uploaded files.
+ *
+ * @access private
+ */
+ private function _mkdir($target)
+ {
+ // from php.net/mkdir user contributed notes
+ if (file_exists($target))
+ {
+ if ( ! @is_dir($target))
+ {
+ return FALSE;
+ }
+ else
+ {
+ return TRUE;
+ }
+ }
+
+ // Attempting to create the directory may clutter up our display.
+ if (@mkdir($target))
+ {
+ $stat = @stat(dirname($target));
+ $dir_perms = $stat['mode'] & 0007777; // Get the permission bits.
+ @chmod($target, $dir_perms);
+ return TRUE;
+ }
+ else
+ {
+ if (is_dir(dirname($target)))
+ {
+ return FALSE;
+ }
+ }
+
+ // If the above failed, attempt to create the parent node, then try again.
+ if ($this->_mkdir(dirname($target)))
+ {
+ return $this->_mkdir($target);
+ }
+
+ return FALSE;
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
* Grid
*
* This is used by the data table js.
View
24 upload/system/68kb/modules/kb/models/articles_model.php
@@ -208,11 +208,11 @@ function edit_article($article_id, $data)
$article_id = (int)$article_id;
if (isset($data['article_uri']) && $data['article_uri'] != '')
{
- $data['article_uri'] = $this->format_uri($data['article_uri'], 0, $article_id);
+ $data['article_uri'] = create_slug($data['article_uri']);
}
else
{
- $data['article_uri'] = $this->format_uri($data['article_title'], 0, $article_id);
+ $data['article_uri'] = create_slug($data['article_title']);
}
if ( ! isset($data['article_modified']) )
{
@@ -450,9 +450,27 @@ private function _get_article_by_id($id)
function get_attachments($id)
{
$id = (int)$id;
+
$this->db->from('attachments')->where('article_id', $id);
+
$query = $this->db->get();
- return $query;
+
+ if ($query->num_rows() == 0)
+ {
+ return FALSE;
+ }
+
+ $data = $query->result_array();
+
+ $i = 0;
+ foreach ($data as $item)
+ {
+ $data[$i]['download_path'] = 'uploads/'.$id.'/'.$item['attach_file'];
+ $i++;
+ }
+ $query->free_result();
+
+ return $data;
}
// ------------------------------------------------------------------------
View
37 upload/system/68kb/modules/kb/views/admin/articles/form.php
@@ -83,16 +83,37 @@
</div>
</fieldset>
- <?php if(isset($cat['cat_image']) && $cat['cat_image'] <> '') { ?>
- <div class="row1">
- <?php
- echo img($this->config->item('cat_image_path') . $cat['cat_image']) .'<br />';
- echo '<a href="'.site_url('admin/categories/delete_image/'.$cat['cat_id']).'">'.lang('lang_delete').'</a>';
- ?>
- </div>
- <?php } ?>
+ <a name="attachments"></a>
+ <?php if(isset($attach) && is_array($attach)): ?>
+ <fieldset>
+ <legend><?php echo lang('lang_attachments'); ?></legend>
+ <table width="100%" class="main" id="attach">
+ <tr>
+ <th><?php echo lang('lang_title'); ?></th>
+ <th>File</th>
+ <th>Type</th>
+ <th>Size</th>
+ <th>Delete</th>
+ </tr>
+ <?php foreach($attach as $item): ?>
+ <tr>
+ <td><?php echo $item['attach_title']; ?></td>
+ <td><?php echo $item['attach_file']; ?></td>
+ <td><?php echo $item['attach_type']; ?></td>
+ <td><?php echo $item['attach_size']; ?></td>
+
+ <td><?php echo '<a href="'.site_url('admin/kb/articles/upload_delete/'.$item['attach_id']).'">'.lang('lang_delete').'</a>'; ?></td>
+ </tr>
+ <?php endforeach; ?>
+ </table>
+ </fieldset>
+ <?php endif; ?>
<div class="row2">
+ <p>
+ <?php echo form_label(lang('lang_attachment_title'). ':', 'attach_title'); ?>
+ <?php echo form_input('attach_title', set_value('attach_title'), 'size="25"'); ?>
+ </p>
<?php echo form_label(lang('lang_attachment'). ':', 'userfile'); ?>
<?php echo form_upload('userfile', '', 'id="userfile"'); ?>
</div>
View
270 upload/system/68kb/modules/search/libraries/Search_parser.php
@@ -0,0 +1,270 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * 68kb
+ *
+ * An open source knowledge base script
+ *
+ * @package 68kb
+ * @author 68kb Dev Team
+ * @copyright Copyright (c) 2010, 68kb
+ * @license http://68kb.com/user_guide/license.html
+ * @link http://68kb.com
+ * @since Version 2.0
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Search Model
+ *
+ * @subpackage Models
+ * @link http://68kb.com/user_guide/
+ *
+ */
+class Search_parser
+{
+ private $_ci;
+
+ private $_data = array();
+
+ function __construct($data = array())
+ {
+ $this->_ci =& get_instance();
+ $this->_data = $data;
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Get search form
+ *
+ * @subpackage Helpers
+ * @param int
+ * @return string
+ */
+ function form($data = '')
+ {
+ // Set the default options
+ $defaults = array(
+ 'show_categories' => 'no',
+ 'class' => 'search_form',
+ 'id' => '',
+ 'style' => ''
+ );
+
+ $options = $this->_ci->settings->get_params($data['attributes'], $defaults);
+
+ $this->_ci->load->helper('form');
+
+ // Should we load up the categories
+ $cats = '';
+ if ($options['show_categories'] == 'yes')
+ {
+ $this->_ci->load->library('categories/categories_library');
+ $cats = $this->_ci->categories_model->get_categories();
+ $this->_ci->categories_library->category_tree($cats);
+ $cats = $this->_ci->categories_library->get_categories();
+
+ $cat_options['0'] = lang('lang_search_all');
+ foreach($cats as $row)
+ {
+ $indent = ($row['cat_parent'] != 0) ? repeater('&nbsp;&raquo;&nbsp;', $row['depth']) : '';
+ $cat_options[$row['cat_id']] = $indent.$row['cat_name'];
+ }
+ $cats = form_dropdown('category', $cat_options, 'class="category"');
+ }
+
+ $attributes = array('class' => $options['class'], 'id' => $options['id'], 'style' => $options['style']);
+
+ $output = form_open('search/do_search', $attributes);
+
+ $output .= str_replace('{kb:cats}', $cats, $data['content']);
+
+ $output .= form_close();
+
+ return $output;
+
+
+
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Listings Helper
+ *
+ * @param array
+ * @return mixed
+ */
+ function get()
+ {
+ $this->_ci->benchmark->mark('get_listings_start');
+
+ // Set the default options
+ $defaults = array('limit' => 10, 'owner' => '', 'category' => '', 'class' => '', 'extra_field' => '', 'sort_order' => 'random', 'sort_column' => 'listing_title', 'cache' => 0, 'exclude' => '');
+
+ $options = $this->_ci->settings->get_params($this->_data['attributes'], $defaults);
+
+ // Do the listings query
+ $this->_ci->db->from('listings')
+ ->join('listing_status', 'listing_status = status_id', 'inner')
+ ->join('listing_fields', 'listing_id = listing_field_id', 'inner')
+ ->join('users', 'user_id = listing_owner_id', 'left');
+
+ $where = 'status_show_listing = "y" AND listing_expiration > '. time();
+
+ // Call any hooks and add them to the where clause.
+ if ($this->_ci->events->active_hook('get_listings_where'))
+ {
+ $where .= $this->_ci->events->trigger('get_listings_where');
+ }
+
+ $this->_ci->db->where($where);
+
+ // Searching for a single users listings
+ if ($options['owner'] != '' && is_numeric($options['owner']))
+ {
+ $this->_ci->db->where('listing_owner_id', (int) $options['owner']);
+ }
+
+ // Searching off a listings class
+ if ($options['class'] != '')
+ {
+ $this->_ci->db->like('listing_class', $options['class']);
+ }
+
+ // Searching in a specific category
+ if ($options['category'] !== '' && is_numeric($options['category'])) // Single category
+ {
+ $this->_ci->db->where('listing_category', (int) $options['category']);
+ }
+ elseif ($options['category'] !== '' && strpos($options['category'], ',') !== FALSE) // Passing multiple categories (1,2,3) Must have a comma as seperator
+ {
+ $this->_ci->db->where_in('listing_category', $options['category']);
+ }
+
+ // Check for excluded listings
+ if ($options['exclude'] != '')
+ {
+ $exclude = explode(',', $options['exclude']);
+ $this->_ci->db->where_not_in('listing_id', $exclude);
+ }
+
+ // Extra Field Searching
+ if ($options['extra_field'] !== '' && strpos($options['extra_field'], '|') !== FALSE) // Must have a pipe as a seperator
+ {
+ $extra_field = explode('|', $options['extra_field']);
+
+ // See if they used the field name or the table name
+ if (strpos($extra_field[0], 'extra_field_') === FALSE)
+ {
+ $extra_field[0] = 'extra_field_'.$extra_field[0];
+ }
+
+ $this->_ci->db->where($extra_field[0], $extra_field[1]);
+ }
+
+ // Allowed order by. This prevents some one from using something to produce an invalid query.
+ $allowed_order_by = array('asc', 'desc', 'random');
+
+ $sort_order = 'asc';
+ if ( ! in_array(strtolower($options['sort_order']), $allowed_order_by))
+ {
+ $sort_order = 'desc';
+ }
+
+ // This sets the allowed order by clauses. Prevents invalid query.
+ $listing_cols = $this->_ci->db->list_fields('listings');
+ $fields_cols = $this->_ci->db->list_fields('listing_fields');
+ $allowed_sort = array_merge($listing_cols, $fields_cols);
+
+ // Order By
+ if (in_array($options['sort_column'], $allowed_sort))
+ {
+ $this->_ci->db->order_by($options['sort_column'], $sort_order);
+ $this->_ci->db->limit($options['limit']);
+ }
+ else
+ {
+ $this->_ci->db->order_by('listing_title', $sort_order);
+ $this->_ci->db->limit($options['limit']);
+ }
+
+ $query = $this->_ci->db->get();
+
+ // Log the query in case some one wants to see it.
+ log_message('debug', 'Listing Plugin Query: '. $this->_ci->db->last_query());
+
+ // no records so we can't continue
+ if ($query->num_rows() == 0)
+ {
+ return array();
+ }
+
+ $data = $query->result_array();
+
+ // load img helper
+ $this->_ci->load->helper('html');
+
+ // Get any other thing they may want.
+ $i = 0;
+ foreach ($data AS $row)
+ {
+ $this->_ci->db->select('image_thumb')->from('listings_images')->where('image_listing_id', $row['listing_id'])->limit(1);
+ $img_query = $this->_ci->db->get();
+
+ if ($img_query->num_rows() > 0)
+ {
+ $img_data = $img_query->row_array();
+
+ $image_properties = array(
+ 'src' => $this->_ci->config->item('listing_image_path') . $img_data['image_thumb'],
+ 'alt' => $row['listing_title'],
+ 'class' => 'listing_image',
+ );
+ }
+ else
+ {
+ $image_properties = array(
+ 'src' => 'themes/'.$this->_ci->settings->get_setting('site_theme') . '/images/nophoto.gif',
+ 'alt' => $row['listing_title'],
+ 'class' => 'listing_image',
+ );
+ }
+
+ $data[$i]['listing_images'] = $img_query->num_rows();
+ $data[$i]['listing_upload_image'] = img($image_properties);
+ $img_query->free_result();
+
+ // Generate the URL
+ $data[$i]['listing_url'] = site_url('listings/'.$row['listing_id'].'/'.$row['listing_uri']);
+ $i++;
+ }
+
+ $query->free_result();
+
+ $this->_ci->benchmark->mark('get_listings_end');
+
+ return $data;
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Get a single param
+ *
+ * @param string - The array key
+ * @return mixed - The value
+ */
+ private function _get_param($key)
+ {
+ if (isset($this->_data['attributes'][$key]))
+ {
+ return $this->_data['attributes'][$key];
+ }
+ return FALSE;
+ }
+}
+
+/* End of file Search_parser.php */
+/* Location: ./upload/system/68kb/modules/search/libraries/Search_parser.php */
View
7 upload/themes/cp/css/style.css
@@ -769,6 +769,13 @@ table,.none td {
border: 0
}
+#attach td {
+ border:1px solid #DBDBDB;
+ line-height:26px;
+ padding:0 12px;
+ text-align:left;
+ vertical-align:top;
+}
.status {
padding: 5px 0
}
View
4 upload/themes/default/css/style.css
@@ -37,6 +37,7 @@ a:hover {
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
+ margin: 0 10px 10px;
}
#sidebar h3 {
font-size: 13px;
@@ -272,6 +273,9 @@ td.formleft, td.formright {
color:#888888;
padding:5px;
}
+.search_form input {
+ margin: 0 0 10px 0;
+}
/* @end */
/* @group Pagination */
View
14 upload/themes/default/home.php
@@ -1,6 +1,10 @@
-<h2>Featured Articles</h2>
+<div class="grid_4 alpha">
+ <h2>Featured Articles</h2>
-<h2>Recent Articles</h2>
-{kb:articles:get}
- <p><strong>{kb:article_title}</strong></p>
-{/kb:articles:get}
+</div>
+<div class="grid_4 omega">
+ <h2>Recent Articles</h2>
+ {kb:articles:get}
+ <p><strong>{kb:article_title}</strong></p>
+ {/kb:articles:get}
+</div>
View
1 upload/themes/default/inc/top_nav.php
@@ -3,5 +3,4 @@
<li><a href="<?php echo site_url('categories'); ?>" <?php if ($this->uri->segment(1) == 'categories') echo 'class="current"'; ?>>Categories</a></li>
<li><a href="<?php echo site_url('glossary'); ?>" <?php if ($this->uri->segment(1) == 'glossary') echo 'class="current"'; ?>>Glossary</a></li>
<li><a href="<?php echo site_url('search'); ?>" <?php if ($module == 'search') echo 'class="current"'; ?>>Advanced Search</a></li>
- <li><a href="<?php echo site_url('contact'); ?>" title="css menus">Contact Us</a></li>
</ul>
View
16 upload/themes/default/kb/details.php
@@ -1,8 +1,20 @@
<h1>{kb:article:article_title}</h1>
-
+{kb:article:article_id}
{kb:article:article_description}
<div class="info">
<p>{lang:lang_category}: {kb:article_cats}</p>
<p>{lang:lang_last_updated}: {kb:article:article_modified} with {kb:article:article_hits} views</p>
-</div>
+</div>
+
+<?php if ($attach): ?>
+ <fieldset>
+ <legend>{lang:lang_attachments}</legend>
+
+ <ul>
+ {kb:attach}
+ <li><a href="{kb:download_path}" target="_blank">{kb:attach_title}</a></li>
+ {/kb:attach}
+ </ul>
+ </fieldset>
+<?php endif; ?>
View
14 upload/themes/default/layout.php
@@ -28,10 +28,20 @@
</div>
<div class="clear"></div>
- <div class="grid_9 body">
+ <div class="grid_8 body">
<?php echo $body; ?>
</div>
- <div class="grid_3" id="sidebar">
+ <div class="grid_4" id="sidebar">
+ <div class="item">
+ <h3>Search</h3>
+ {kb:search:form class="search_form" show_categories="no"}
+ <input type="text" name="keywords" value="Search" onfocus="if (this.value==this.defaultValue) this.value='';" />
+ {kb:cats}
+ <input type="submit" name="submit" value="Seach!" />
+ {/kb:search:form}
+ <?php echo anchor('search', 'Advanced Search'); ?>
+ </div>
+
<div class="item">
<h3>Categories</h3>
{kb:categories:cat_list}

0 comments on commit 7ffc053

Please sign in to comment.