1: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2:
3:
4: /**
5: * The Ajax class is the controller used for ajax calls made by javascript.
6: *
7: * @package controller
8: * @version 0.01
9: * @since 2014-04-03
10: * @author Rizwan Ali <riz@bitspro.com>
11: */
12:
13: class Ajax extends CI_Controller {
14:
15: /**
16: * Returns data_id for the article which was selected in the popup for inserting link in to document
17: *
18: * @param int $data_id
19: *
20: * @return string
21: *
22: * @since 2014-04-03
23: * @author Rizwan Ali <riz@bitspro.com>
24: */
25: public function get_article($data_id = 0)
26: {
27: $this->load->model('Model_article');
28: $data = $this->session->flashdata('current_article');
29: if ($data != '') {
30: $res = $this->Model_article->article_article_add(base64_decode(urldecode($data_id)), $data);
31: echo $res[0] . '::' . $res[1];
32: } else {
33: echo "false";
34: }
35: }
36:
37: /**
38: * Returns refe_id for the reference which was selected in the popup for inserting link in to document
39: *
40: * @param int $data_id
41: * @param int $row
42: *
43: * @return string
44: *
45: * @since 2014-04-03
46: * @author Rizwan Ali <riz@bitspro.com>
47: */
48: public function get_reference($data_id = 0,$row = 1){
49:
50: $this->load->model('Model_reference');
51: $data = $this->session->flashdata('current_reference_title');
52: if($data!=''){
53: $res = $this->Model_reference->article_reference_add(base64_decode(urldecode($data_id)),$data['refe_id'],$row);
54: echo $res[0].'::'.$res[1];
55: }else{
56: echo "false";
57: }
58:
59: }
60:
61: /**
62: * Mark article as delete in the database
63: *
64: * @param string $id
65: *
66: * @return void
67: *
68: * @since 2014-04-03
69: * @author Rizwan Ali <riz@bitspro.com>
70: */
71: public function delete_article($id =''){
72: $this->load->model('Model_article');
73: $this->Model_article->remove($id);
74: }
75:
76: /**
77: * Delete index from database
78: *
79: * @param string $id
80: *
81: * @return void
82: *
83: * @since 2014-04-03
84: * @author Rizwan Ali <riz@bitspro.com>
85: */
86: public function delete_index($id = ''){
87: $this->load->model('Model_article');
88: $this->Model_article->remove_index($id);
89: }
90:
91: /**
92: * Insert a new index in to database for particular article
93: *
94: * @param string $name
95: * @param string $parent
96: *
97: * @return index_id
98: *
99: * @since 2014-04-03
100: * @author Rizwan Ali <riz@bitspro.com>
101: */
102: public function insert_index($name ='',$parent = ''){
103: $this->load->model('Model_article');
104: echo $this->Model_article->add_index($name,base64_decode(urldecode($parent)));
105: }
106:
107: /**
108: * Add link in the link table to connect reference with article
109: *
110: *
111: * @return link_id
112: *
113: * @since 2014-04-03
114: * @author Rizwan Ali <riz@bitspro.com>
115: */
116: public function insert_reference(){
117: $this->load->model('Model_reference');
118: echo $this->Model_reference->article_reference_add_with_term(base64_decode(urldecode($this->input->get('datad'))),urldecode($this->input->get('term')));
119: }
120:
121: /**
122: * Updates orignal data field of article in database
123: *
124: *
125: * @return void
126: *
127: * @since 2014-04-03
128: * @author Rizwan Ali <riz@bitspro.com>
129: */
130: public function update_article_data()
131: {
132: $this->load->model('Model_article');
133: $this->Model_article->update_data_only();
134: }
135: }
136: ?>