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