[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 |
|
---|
| 45 | $aryDirs = array();
|
---|
| 46 | $aryFiles = array();
|
---|
| 47 |
|
---|
| 48 | $aryError = array('err' => $this->xml->tree->_param['err'], 'errCode' => $this->xml->tree->_param['errCode']);
|
---|
| 49 |
|
---|
| 50 | if (is_array($this->xml->tree->folderlist->folder)) {
|
---|
| 51 | foreach($this->xml->tree->folderlist->folder as $key=>$value){
|
---|
| 52 | $aryDirs[] = array('id' => $value->_param['id'], 'name' => $value->_value, 'parentID' => $value->_param['parentid'] == -1 ? 0:$value->_param['parentid']);
|
---|
| 53 | }
|
---|
| 54 | }
|
---|
| 55 | else if (isset($this->xml->tree->folderlist->folder)) {
|
---|
| 56 | $folder = $this->xml->tree->folderlist->folder;
|
---|
| 57 | $aryDirs[] = array('id' => $folder->_param['id'], 'name' => $folder->_value,'parentID' => $folder->_param['parentid'] == -1 ? 0:$folder->_param['parentid']);
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | if (is_array($this->xml->tree->filelist->file)) {
|
---|
| 61 | foreach($this->xml->tree->filelist->file as $key=>$value){
|
---|
| 62 | $aryFiles[] = array('id' => $value->_param['id'], 'name' => $value->_value, 'parentID' => $value->_param['parentid'] == -1 ? 0:$value->_param['parentid'], 'minetype' => $value->_param['filetype']);
|
---|
| 63 | }
|
---|
| 64 | }else if (isset($this->xml->tree->filelist->file)) {
|
---|
| 65 | $file = $this->xml->tree->filelist->file;
|
---|
| 66 | $aryFiles[] = array('id' => $file->_param['id'], 'name' => $file->_value,'parentID' => $file->_param['parentid'] == -1 ? 0:$file->_param['parentid'], 'minetype' => $file->_param['filetype']);
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | $aryData = array('DIRECTORIES' => $aryDirs , 'FILES' => $aryFiles, 'ERROR' => $aryError);
|
---|
[10] | 70 | echo json_encode($aryData);
|
---|
| 71 | }
|
---|
[1] | 72 |
|
---|
[10] | 73 | public function createDir () {
|
---|
[42] | 74 | $parentDir = $this->input->post('fparentid',TRUE);
|
---|
| 75 | $name = $this->input->post('fname',TRUE);
|
---|
| 76 | $xmlData = $this->vservices->createDir($name, $parentDir);
|
---|
| 77 | $this->xml->parse($xmlData);
|
---|
| 78 | $aryError = array('err' => $this->xml->status->_param['err'], 'errCode' => $this->xml->status->_param['errCode']);
|
---|
| 79 | $aryData = array('id' => $this->xml->status->_param['id'], 'name' => $name, 'parentID' => $parentDir, 'ERROR' => $aryError);
|
---|
| 80 | echo json_encode($aryData);
|
---|
[10] | 81 | }
|
---|
| 82 |
|
---|
| 83 | public function deleteDir () {
|
---|
[11] | 84 | $dirID = $this->input->post('id',TRUE);
|
---|
| 85 | $delAllChild = $this->input->post('delallchild',TRUE);
|
---|
[10] | 86 |
|
---|
[12] | 87 | $aryChild = $this->objDirectory->getAllDirChild($dirID);
|
---|
| 88 | $aryResult = array('isSuccess' => TRUE);
|
---|
| 89 |
|
---|
[11] | 90 | echo json_encode($aryChild);
|
---|
[10] | 91 | }
|
---|
[16] | 92 |
|
---|
| 93 | public function rename() {
|
---|
| 94 | $id = $this->input->post('id',TRUE);
|
---|
| 95 | $newName = $this->input->post('newname',TRUE);
|
---|
| 96 | $objectType = $this->input->post('objtype',TRUE);
|
---|
[1] | 97 |
|
---|
[16] | 98 | $aryData = array();
|
---|
| 99 | $aryData['RESULT'] = $this->objDirectory->rename($id, $newName, $objectType);;
|
---|
| 100 | $aryData['UPDATED'] = array('id' => $id, 'name' => $newName, 'type' => $objectType);
|
---|
| 101 | echo json_encode($aryData);
|
---|
| 102 | }
|
---|
[42] | 103 |
|
---|
| 104 | public function upload() {
|
---|
| 105 |
|
---|
| 106 | }
|
---|
[1] | 107 | }
|
---|
| 108 |
|
---|
| 109 | /* End of file directory.php */
|
---|
| 110 | /* Location: ./application/modules/ajax/controllers/directory.php */ |
---|