[1] | 1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
---|
| 2 | /**
|
---|
[10] | 3 | * PrivateContent Class
|
---|
[1] | 4 | *
|
---|
| 5 | * @author dzungnv02
|
---|
| 6 | *
|
---|
| 7 | */
|
---|
| 8 |
|
---|
[42] | 9 | /* private $_aryDir = array(
|
---|
| 10 | 0 => array ('id' => 1, 'name' => 'Dir 1', 'parentID' => 0),
|
---|
| 11 | 1 => array ('id' => 2, 'name' => 'Dir 2', 'parentID' => 0),
|
---|
| 12 | 2 => array ('id' => 3, 'name' => 'Dir 1.1', 'parentID' => 1),
|
---|
| 13 | 3 => array ('id' => 4, 'name' => 'Dir 1.1.1', 'parentID' => 3),
|
---|
| 14 | 4 => array ('id' => 5, 'name' => 'Dir 1.1.1.1', 'parentID' => 4),
|
---|
| 15 | 5 => array ('id' => 6, 'name' => 'Dir 1.1.2', 'parentID' => 3),
|
---|
| 16 | 6 => array ('id' => 7, 'name' => 'Dir 3', 'parentID' => 0),
|
---|
| 17 | 7 => array ('id' => 8, 'name' => 'Dir 3.1', 'parentID' => 7)
|
---|
| 18 | );
|
---|
| 19 |
|
---|
| 20 | private $_aryFile = array(
|
---|
| 21 | 0 => array('id' => 1, 'name' => 'File 1', 'minetype' => 'text', 'size' => '1.5MB', 'parentID' => 1),
|
---|
| 22 | 1 => array('id' => 2, 'name' => 'File 2', 'minetype' => 'text', 'size' => '1.6MB', 'parentID' => 1),
|
---|
| 23 | 2 => array('id' => 3, 'name' => 'File 3', 'minetype' => 'text', 'size' => '1.7MB', 'parentID' => 2),
|
---|
| 24 | 3 => array('id' => 4, 'name' => 'File 4', 'minetype' => 'text', 'size' => '1.8MB', 'parentID' => 2),
|
---|
| 25 | 4 => array('id' => 5, 'name' => 'File 5', 'minetype' => 'text', 'size' => '1.8MB', 'parentID' => 0),
|
---|
| 26 | 5 => array('id' => 6, 'name' => 'File 6', 'minetype' => 'text', 'size' => '1.8MB', 'parentID' => 3),
|
---|
| 27 | 5 => array('id' => 7, 'name' => 'File 7', 'minetype' => 'text', 'size' => '1.8MB', 'parentID' => 5)
|
---|
| 28 | ); */
|
---|
| 29 |
|
---|
[10] | 30 | class PrivateContent extends MX_Controller
|
---|
[1] | 31 | {
|
---|
[42] | 32 |
|
---|
[11] | 33 | public function __construct() {
|
---|
| 34 | parent::__construct();
|
---|
| 35 | $this->load->model('Directory_model', 'objDirectory', TRUE);
|
---|
[42] | 36 | $this->vservices->setApiUrl($this->config->item('api_url'));
|
---|
| 37 | $this->vservices->setConnection($this->curl);
|
---|
| 38 | $this->vservices->setUserId(33);
|
---|
[11] | 39 | }
|
---|
| 40 |
|
---|
| 41 | public function getContent () {
|
---|
[42] | 42 | $xmlData = $this->vservices->getPrivateTree();
|
---|
| 43 | $this->xml->parse($xmlData);
|
---|
| 44 | $aryDirs = array();
|
---|
| 45 | $aryFiles = array();
|
---|
[66] | 46 | write_file('log.txt', var_export($xmlData, true));
|
---|
[42] | 47 |
|
---|
[66] | 48 | if (!isset($this->xml->tree)) {
|
---|
| 49 | $aryError = array('err' => 'KhÃŽng thá» kết ná»i Äến máy chá»§!', 'errCode' => '-1');
|
---|
| 50 | $aryData = array('DIRECTORIES' => array() , 'FILES' => array(), 'ERROR' => $aryError);
|
---|
| 51 | echo json_encode($aryData);
|
---|
| 52 | return;
|
---|
| 53 | }
|
---|
[42] | 54 |
|
---|
[66] | 55 | $aryError = array('err' => $this->xml->tree->_param['err'], 'errCode' => (int)$this->xml->tree->_param['errCode']);
|
---|
| 56 |
|
---|
| 57 | if (isset($this->xml->tree->folderlist->folder)) {
|
---|
| 58 | if (is_array($this->xml->tree->folderlist->folder)) {
|
---|
| 59 | foreach($this->xml->tree->folderlist->folder as $key=>$value){
|
---|
| 60 | $aryDirs[] = array('id' => $value->_param['id'], 'name' => $value->_value, 'parentID' => $value->_param['parentid'] == -1 ? 0:$value->_param['parentid']);
|
---|
| 61 | }
|
---|
[42] | 62 | }
|
---|
[66] | 63 | else {
|
---|
| 64 | $folder = $this->xml->tree->folderlist->folder;
|
---|
| 65 | $aryDirs[] = array('id' => $folder->_param['id'], 'name' => $folder->_value,'parentID' => $folder->_param['parentid'] == -1 ? 0:$folder->_param['parentid']);
|
---|
| 66 | }
|
---|
[42] | 67 | }
|
---|
| 68 |
|
---|
[66] | 69 | if (isset($this->xml->tree->filelist->file)) {
|
---|
| 70 | if (is_array($this->xml->tree->filelist->file)) {
|
---|
| 71 | foreach($this->xml->tree->filelist->file as $key=>$value){
|
---|
| 72 | $aryFiles[] = array('id' => $value->_param['id'], 'name' => $value->_value, 'parentID' => $value->_param['parentid'] == -1 ? 0:$value->_param['parentid'], 'minetype' => $value->_param['filetype']);
|
---|
| 73 | }
|
---|
| 74 | }else {
|
---|
| 75 | $file = $this->xml->tree->filelist->file;
|
---|
| 76 | $aryFiles[] = array('id' => $file->_param['id'], 'name' => $file->_value,'parentID' => $file->_param['parentid'] == -1 ? 0:$file->_param['parentid'], 'minetype' => $file->_param['filetype']);
|
---|
[42] | 77 | }
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | $aryData = array('DIRECTORIES' => $aryDirs , 'FILES' => $aryFiles, 'ERROR' => $aryError);
|
---|
[10] | 81 | echo json_encode($aryData);
|
---|
| 82 | }
|
---|
[1] | 83 |
|
---|
[10] | 84 | public function createDir () {
|
---|
[42] | 85 | $parentDir = $this->input->post('fparentid',TRUE);
|
---|
| 86 | $name = $this->input->post('fname',TRUE);
|
---|
[70] | 87 |
|
---|
[66] | 88 | $xmlData = $this->vservices->actionExecute('mkdir',array('name' => $name, 'parent_id' => $parentDir == 0 ? -1:$parentDir));
|
---|
[43] | 89 |
|
---|
[42] | 90 | $this->xml->parse($xmlData);
|
---|
[66] | 91 | $aryError = array('err' => $this->xml->status->_param['err'], 'errCode' => (int)$this->xml->status->_param['errCode']);
|
---|
[42] | 92 | $aryData = array('id' => $this->xml->status->_param['id'], 'name' => $name, 'parentID' => $parentDir, 'ERROR' => $aryError);
|
---|
[70] | 93 |
|
---|
| 94 | /* $aryError = array('err' => '', 'errCode' => 0);
|
---|
| 95 | $aryData = array('id' => rand(100, 1000), 'name' => $name, 'parentID' => $parentDir, 'ERROR' => $aryError); */
|
---|
[42] | 96 | echo json_encode($aryData);
|
---|
[10] | 97 | }
|
---|
| 98 |
|
---|
| 99 | public function deleteDir () {
|
---|
[66] | 100 | $delobj = $this->input->post('delobj',TRUE);
|
---|
| 101 | $xmlData = $this->vservices->actionExecute('deletemulti',array('delobj' => $delobj));
|
---|
| 102 | $this->xml->parse($xmlData);
|
---|
[70] | 103 | $aryFolders = array();
|
---|
| 104 |
|
---|
| 105 | if (isset($this->xml->tree->folder)) {
|
---|
| 106 | if (is_array($this->xml->tree->folder)) {
|
---|
| 107 | foreach ($this->xml->tree->folder as $key => $folder) {
|
---|
| 108 | $aryFolders['DIRECTORIES'][] = $folder->_param['id'];
|
---|
| 109 | }
|
---|
| 110 | }
|
---|
| 111 | else {
|
---|
| 112 | $aryFolders['DIRECTORIES'][] = $this->xml->tree->folder->_param['id'];
|
---|
| 113 | }
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | if (isset($this->xml->tree->file)) {
|
---|
| 117 | if (is_array($this->xml->tree->file)) {
|
---|
| 118 | foreach ($this->xml->tree->file as $key => $file) {
|
---|
| 119 | $aryFolders['FILES'][] = $file->_param['id'];
|
---|
| 120 | }
|
---|
| 121 | }
|
---|
| 122 | else {
|
---|
| 123 | $aryFolders['FILES'][] = $this->xml->tree->folder->_param['id'];
|
---|
| 124 | }
|
---|
| 125 | }
|
---|
| 126 |
|
---|
[66] | 127 | $aryError = array('err' => $this->xml->tree->_param['err'], 'errCode' => (int)$this->xml->tree->_param['errCode']);
|
---|
[70] | 128 | $aryData = array('DIRECTORIES' => isset($aryFolders['DIRECTORIES']) ? $aryFolders['DIRECTORIES'] : array(), 'FILES' => isset($aryFolders['FILES'])? $aryFolders['FILES'] : array() ,'ERROR' => $aryError);
|
---|
[66] | 129 | echo json_encode($aryData);
|
---|
[10] | 130 | }
|
---|
[16] | 131 |
|
---|
| 132 | public function rename() {
|
---|
| 133 | $id = $this->input->post('id',TRUE);
|
---|
[70] | 134 | $data = $this->input->post('data',TRUE);
|
---|
| 135 |
|
---|
[16] | 136 | $aryData = array();
|
---|
| 137 | $aryData['RESULT'] = $this->objDirectory->rename($id, $newName, $objectType);;
|
---|
| 138 | $aryData['UPDATED'] = array('id' => $id, 'name' => $newName, 'type' => $objectType);
|
---|
| 139 | echo json_encode($aryData);
|
---|
| 140 | }
|
---|
[70] | 141 |
|
---|
| 142 | public function copy () {
|
---|
| 143 | $destination = $this->input->post('destination',TRUE);
|
---|
| 144 | $data = $this->input->post('data',TRUE);
|
---|
| 145 |
|
---|
| 146 | $aryData = array();
|
---|
| 147 | $aryData['RESULT'] = json_decode($data);
|
---|
| 148 | $aryError = array('err' => '', 'errCode' => 0);
|
---|
| 149 | $aryData['ERROR'] = $aryError;
|
---|
| 150 | echo json_encode($aryData);
|
---|
| 151 |
|
---|
| 152 | }
|
---|
[42] | 153 |
|
---|
| 154 | public function upload() {
|
---|
| 155 |
|
---|
| 156 | }
|
---|
[1] | 157 | }
|
---|
| 158 |
|
---|
| 159 | /* End of file directory.php */
|
---|
| 160 | /* Location: ./application/modules/ajax/controllers/directory.php */ |
---|