Changeset 923 for pro-violet-viettel


Ignore:
Timestamp:
May 14, 2015 5:30:46 PM (10 years ago)
Author:
dungnv
Message:
 
Location:
pro-violet-viettel/www/deploy/20150304
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pro-violet-viettel/www/deploy/20150304/application/modules/ajax/controllers/privatecontent.php

    r893 r923  
    1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     1<?php
     2
     3if (! defined ( 'BASEPATH' ))
     4        exit ( 'No direct script access allowed' );
    25/**
    36 * PrivateContent Class
     
    710 */
    811
    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 
     12
     13class PrivateContent extends MX_Controller {
    3314        public function __construct() {
    34                 parent::__construct();
    35                 $user = $this->session->userdata ( 'userInfo' );
    36                 $this->vservices->setApiUrl($this->config->item('api_url'));
    37                 $this->vservices->setConnection($this->curl);
    38                 $this->vservices->setUserId($user['us_id']);
    39         }
    40 
    41         public function getContent () {
    42                 $xmlData = $this->vservices->getPrivateTree();
    43 
    44                 $this->xml->parse($xmlData);
    45 
    46                 $aryDirs = array();
    47                 $aryFiles = array();
    48                 write_file('log.txt', var_export($xmlData, true));
    49 
    50                 if (!isset($this->xml->tree)) {
    51                         $aryError = array('err' => 'KhÃŽng thể kết nối đến máy chá»§!', 'errCode' => '-1');
    52                         $aryData = array('DIRECTORIES' =>  array() , 'FILES' => array(), 'ERROR' => $aryError);
    53                         echo json_encode($aryData);
     15                parent::__construct ();
     16                $user = $this->session->userdata ( 'userInfo' );
     17                $this->vservices->setApiUrl ( $this->config->item ( 'api_url' ) );
     18                $this->vservices->setConnection ( $this->curl );
     19                $this->vservices->setUserId ( $user ['us_id'] );
     20        }
     21
     22        public function getContent() {
     23                $xmlData = $this->vservices->getPrivateTree ();
     24
     25                $this->xml->parse ( $xmlData );
     26
     27                $aryDirs = array ();
     28                $aryFiles = array ();
     29                write_file ( 'log.txt', var_export ( $xmlData, true ) );
     30
     31                if (! isset ( $this->xml->tree )) {
     32                        $aryError = array (
     33                                        'err' => 'KhÃŽng thể kết nối đến máy chá»§!',
     34                                        'errCode' => '-1'
     35                        );
     36                        $aryData = array (
     37                                        'DIRECTORIES' => array (),
     38                                        'FILES' => array (),
     39                                        'ERROR' => $aryError
     40                        );
     41                        echo json_encode ( $aryData );
    5442                        return;
    5543                }
    5644
    57                 $aryError = array('err' => $this->xml->tree->_param['err'], 'errCode' => (int)$this->xml->tree->_param['errCode']);
    58 
    59                 if (isset($this->xml->tree->folderlist->folder)) {
    60                         if (is_array($this->xml->tree->folderlist->folder)) {
    61                                 foreach($this->xml->tree->folderlist->folder as $key=>$value){
    62                                         $aryDirs[] = array('id' => $value->_param['id'], 'name' => $value->_value, 'parentID' => $value->_param['parentid'] == -1 ? 0:$value->_param['parentid']);
    63                                 }
    64                         }
    65                         else {
     45                $aryError = array (
     46                                'err' => $this->xml->tree->_param ['err'],
     47                                'errCode' => ( int ) $this->xml->tree->_param ['errCode']
     48                );
     49
     50                if (isset ( $this->xml->tree->folderlist->folder )) {
     51                        if (is_array ( $this->xml->tree->folderlist->folder )) {
     52                                foreach ( $this->xml->tree->folderlist->folder as $key => $value ) {
     53                                        $aryDirs [] = array (
     54                                                        'id' => $value->_param ['id'],
     55                                                        'name' => $value->_value,
     56                                                        'parentID' => $value->_param ['parentid'] == - 1 ? 0 : $value->_param ['parentid']
     57                                        );
     58                                }
     59                        } else {
    6660                                $folder = $this->xml->tree->folderlist->folder;
    67                                 $aryDirs[] = array('id' => $folder->_param['id'], 'name' => $folder->_value,'parentID' => $folder->_param['parentid'] == -1 ? 0:$folder->_param['parentid']);
    68                         }
    69                 }
    70 
    71                 if (isset($this->xml->tree->filelist->file)) {
    72                         if (is_array($this->xml->tree->filelist->file)) {
    73                                 foreach($this->xml->tree->filelist->file as $key=>$value){
    74                                         //$fileUrl = dirname(dirname(dirname($value->_param['fileurl'])));
    75                                         $fileUrl="";
    76                                         if ($value->_param['fileurl']!=""){
    77                                         $fileUrl = $this->config->item('api_url').$value->_param['fileurl'];
    78                                         }
    79                                         $thumbnail="";
    80                                         if ($value->_param['thumbnail']!=""){
    81                                         $thumbnail = $this->config->item('api_url').$value->_param['thumbnail'];
    82                                         }
    83                                         $aryFiles[] = array('id' => $value->_param['id'], 'name' => $value->_value, 'parentID' => $value->_param['parentid'] == -1 ? 0:$value->_param['parentid'], 'minetype' => $value->_param['filetype'], 'size' => $value->_param['size'],'thumbnail' => $thumbnail,'fileurl' => $fileUrl);
    84                                 }
    85                         }else {
     61                                $aryDirs [] = array (
     62                                                'id' => $folder->_param ['id'],
     63                                                'name' => $folder->_value,
     64                                                'parentID' => $folder->_param ['parentid'] == - 1 ? 0 : $folder->_param ['parentid']
     65                                );
     66                        }
     67                }
     68
     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                                        // $fileUrl = dirname(dirname(dirname($value->_param['fileurl'])));
     73                                        $fileUrl = "";
     74                                        if ($value->_param ['fileurl'] != "") {
     75                                                $fileUrl = $this->config->item ( 'api_url' ) . $value->_param ['fileurl'];
     76                                        }
     77
     78                                        $thumbnail = "";
     79                                        if ($value->_param ['thumbnail'] != "") {
     80                                                $thumbnail = $this->config->item ( 'api_url' ) . $value->_param ['thumbnail'];
     81                                        }
     82
     83                                        $aryFiles [] = array (
     84                                                        'id' => $value->_param ['id'],
     85                                                        'name' => $value->_value,
     86                                                        'parentID' => $value->_param ['parentid'] == - 1 ? 0 : $value->_param ['parentid'],
     87                                                        'minetype' => $value->_param ['filetype'],
     88                                                        'size' => $value->_param ['size'],
     89                                                        'thumbnail' => $thumbnail,
     90                                                        'fileurl' => $fileUrl
     91                                        );
     92                                }
     93                        } else {
    8694                                $file = $this->xml->tree->filelist->file;
    87                                 $aryFiles[] = array('id' => $file->_param['id'], 'name' => $file->_value,'parentID' => $file->_param['parentid'] == -1 ? 0:$file->_param['parentid'], 'minetype' => $file->_param['filetype'], 'size' => $file->_param['size'], 'thumbnail' => $value->_param['thumbnail'],'fileurl' => $value->_param['fileurl']);
    88                         }
    89                 }
     95                                $aryFiles [] = array (
     96                                                'id' => $file->_param ['id'],
     97                                                'name' => $file->_value,
     98                                                'parentID' => $file->_param ['parentid'] == - 1 ? 0 : $file->_param ['parentid'],
     99                                                'minetype' => $file->_param ['filetype'],
     100                                                'size' => $file->_param ['size'],
     101                                                'thumbnail' => $value->_param ['thumbnail'],
     102                                                'fileurl' => $value->_param ['fileurl']
     103                                );
     104                        }
     105                }
     106
    90107                $user = $this->session->userdata ( 'userInfo' );
    91                 $aryData = array('DIRECTORIES' =>  $aryDirs , 'FILES' => $aryFiles, 'ERROR' => $aryError, 'userinfo'=>$user);
    92                 echo json_encode($aryData);
    93         }
    94 
    95         public function createDir () {
    96                 $parentDir =  $this->input->post('fparentid',TRUE);
    97                 $name =  $this->input->post('fname',TRUE);
    98 
    99                 $xmlData = $this->vservices->actionExecute('mkdir',array('name' => $name, 'parent_id' => $parentDir == 0 ? -1:$parentDir));
    100 
    101                 $this->xml->parse($xmlData);
    102 
    103                 $aryError = array('err' => $this->xml->status->_param['err'], 'errCode' => (int)$this->xml->status->_param['errCode']);
    104                 $aryData = array('id' => $this->xml->status->_param['id'], 'name' => $this->xml->status->_param['name'], 'parentID' => $parentDir, 'ERROR' => $aryError);
    105                 echo json_encode($aryData);
    106         }
    107 
    108         public function delete () {
    109                 $delobj =  $this->input->post('delobj',TRUE);
    110                 $xmlData = $this->vservices->actionExecute('deletemulti',array('delobj' => $delobj));
    111                 $this->xml->parse($xmlData);
    112                 $aryFolders = array();
    113 
    114                 if (isset($this->xml->tree->folder)) {
    115                         if (is_array($this->xml->tree->folder)) {
    116                                 foreach ($this->xml->tree->folder as $key => $folder) {
    117                                         $aryFolders['DIRECTORIES'][] = $folder->_param['id'];
    118                                 }
    119                         }
    120                         else {
    121                                 $aryFolders['DIRECTORIES'][] = $this->xml->tree->folder->_param['id'];
    122                         }
    123                 }
    124 
    125                 if (isset($this->xml->tree->file)) {
    126                         if (is_array($this->xml->tree->file)) {
    127                                 foreach ($this->xml->tree->file as $key => $file) {
    128                                         $aryFolders['FILES'][] = $file->_param['id'];
    129                                 }
    130                         }
    131                         else {
    132                                 $aryFolders['FILES'][] = $this->xml->tree->file->_param['id'];
    133                         }
    134                 }
    135 
    136                 $aryError = array('err' => $this->xml->tree->_param['err'], 'errCode' => (int)$this->xml->tree->_param['errCode']);
    137                 $aryData = array('DIRECTORIES' => isset($aryFolders['DIRECTORIES']) ? $aryFolders['DIRECTORIES'] : array(), 'FILES' => isset($aryFolders['FILES'])? $aryFolders['FILES'] : array() ,'ERROR' => $aryError);
    138                 echo json_encode($aryData);
     108                $aryData = array (
     109                                'DIRECTORIES' => $aryDirs,
     110                                'FILES' => $aryFiles,
     111                                'ERROR' => $aryError,
     112                                'userinfo' => $user
     113                );
     114                echo json_encode ( $aryData );
     115        }
     116
     117        public function createDir() {
     118                $parentDir = $this->input->post ( 'fparentid', TRUE );
     119                $name = $this->input->post ( 'fname', TRUE );
     120
     121                $xmlData = $this->vservices->actionExecute ( 'mkdir', array (
     122                                'name' => $name,
     123                                'parent_id' => $parentDir == 0 ? - 1 : $parentDir
     124                ) );
     125
     126                $this->xml->parse ( $xmlData );
     127
     128                $aryError = array (
     129                                'err' => $this->xml->status->_param ['err'],
     130                                'errCode' => ( int ) $this->xml->status->_param ['errCode']
     131                );
     132                $aryData = array (
     133                                'id' => $this->xml->status->_param ['id'],
     134                                'name' => $this->xml->status->_param ['name'],
     135                                'parentID' => $parentDir,
     136                                'ERROR' => $aryError
     137                );
     138                echo json_encode ( $aryData );
     139        }
     140
     141        public function delete() {
     142                $delobj = $this->input->post ( 'delobj', TRUE );
     143                $xmlData = $this->vservices->actionExecute ( 'deletemulti', array (
     144                                'delobj' => $delobj
     145                ) );
     146                $this->xml->parse ( $xmlData );
     147                $aryFolders = array ();
     148
     149                if (isset ( $this->xml->tree->folder )) {
     150                        if (is_array ( $this->xml->tree->folder )) {
     151                                foreach ( $this->xml->tree->folder as $key => $folder ) {
     152                                        $aryFolders ['DIRECTORIES'] [] = $folder->_param ['id'];
     153                                }
     154                        } else {
     155                                $aryFolders ['DIRECTORIES'] [] = $this->xml->tree->folder->_param ['id'];
     156                        }
     157                }
     158
     159                if (isset ( $this->xml->tree->file )) {
     160                        if (is_array ( $this->xml->tree->file )) {
     161                                foreach ( $this->xml->tree->file as $key => $file ) {
     162                                        $aryFolders ['FILES'] [] = $file->_param ['id'];
     163                                }
     164                        } else {
     165                                $aryFolders ['FILES'] [] = $this->xml->tree->file->_param ['id'];
     166                        }
     167                }
     168
     169                $aryError = array (
     170                                'err' => $this->xml->tree->_param ['err'],
     171                                'errCode' => ( int ) $this->xml->tree->_param ['errCode']
     172                );
     173                $aryData = array (
     174                                'DIRECTORIES' => isset ( $aryFolders ['DIRECTORIES'] ) ? $aryFolders ['DIRECTORIES'] : array (),
     175                                'FILES' => isset ( $aryFolders ['FILES'] ) ? $aryFolders ['FILES'] : array (),
     176                                'ERROR' => $aryError
     177                );
     178                echo json_encode ( $aryData );
    139179        }
    140180
    141181        public function rename() {
    142                 $id =  $this->input->post('id',TRUE);
    143                 $data =  $this->input->post('data',TRUE);
    144 
    145                 /* $aryData = array();
    146                 $aryData['RESULT'] = $this->objDirectory->rename($id, $newName, $objectType);;
    147                 $aryData['UPDATED'] = array('id' => $id, 'name' => $newName, 'type' => $objectType);
    148                 echo json_encode($aryData); */
    149         }
    150 
    151         public function copy () {
    152                 $destination =  $this->input->post('destination',TRUE);
    153                 $data =  $this->input->post('data',TRUE);
    154                 $act =  $this->input->post('act',TRUE);
    155 
    156                 $xmlData = $this->vservices->actionExecute('copy' ,array('act' => $act,'data' => $data, 'destination' => $destination == 0 ? -1:$destination));
    157 
    158                 error_log(date('YmdHis').' - $xmlData: '.var_export($xmlData, TRUE), 3, '/srv/www/sbg/log/file.log');
    159 
    160                 $this->xml->parse($xmlData);
    161 
    162                 $aryNewDirs =   isset($this->xml->data->folderdata) ? json_decode($this->xml->data->folderdata->_value) : array();
    163                 $aryNewFiles =  isset($this->xml->data->filedata) ? json_decode($this->xml->data->filedata->_value) : array();
    164 
    165                 $aryData = array('DIRECTORIES' => $aryNewDirs, 'FILES' => $aryNewFiles);
    166                 $aryData['ERROR'] = array('err' => $this->xml->data->_param['err'], 'errCode' => (int)$this->xml->data->_param['errCode']);;
    167                 echo json_encode($aryData);
    168         }
    169 
    170        
     182                $item = $this->input->post ( 'data', TRUE );
     183                $objItem = json_decode($item);
     184                error_log(var_export($objItem->id, TRUE)."\n", 3, '/srv/www/sbg/log/rename.log');
     185                $xmlData = $this->vservices->actionExecute ('rename', array ('id' => $objItem->id, 'name' => $objItem->name, 'type' => $objItem->type, 'parentid' => $objItem->parentID == 0 ? -1:$objItem->parentID, 'newName' => $objItem->newName));
     186
     187                //error_log(var_export($item, TRUE), 3, '/srv/www/sbg/log/rename.log');
     188/*              $aryData ['DATA'] = json_decode($data);
     189                $aryData ['ERROR'] = array (
     190                                'err' => '',
     191                                'errCode' => 0
     192                );
     193
     194                echo json_encode ( $aryData ); */
     195        }
     196
     197        public function copy() {
     198                $destination = $this->input->post ( 'destination', TRUE );
     199                $data = $this->input->post ( 'data', TRUE );
     200                $act = $this->input->post ( 'act', TRUE );
     201
     202                $xmlData = $this->vservices->actionExecute ( 'copy', array (
     203                                'act' => $act,
     204                                'data' => $data,
     205                                'destination' => $destination == 0 ? - 1 : $destination
     206                ) );
     207
     208                error_log ( date ( 'YmdHis' ) . ' - $xmlData: ' . var_export ( $xmlData, TRUE ), 3, '/srv/www/sbg/log/file.log' );
     209
     210                $this->xml->parse ( $xmlData );
     211
     212                $aryNewDirs = isset ( $this->xml->data->folderdata ) ? json_decode ( $this->xml->data->folderdata->_value ) : array ();
     213                $aryNewFiles = isset ( $this->xml->data->filedata ) ? json_decode ( $this->xml->data->filedata->_value ) : array ();
     214
     215                $aryData = array (
     216                                'DIRECTORIES' => $aryNewDirs,
     217                                'FILES' => $aryNewFiles
     218                );
     219                $aryData ['ERROR'] = array (
     220                                'err' => $this->xml->data->_param ['err'],
     221                                'errCode' => ( int ) $this->xml->data->_param ['errCode']
     222                );
     223                echo json_encode ( $aryData );
     224        }
    171225}
    172226
  • pro-violet-viettel/www/deploy/20150304/assets/js/grid.js

    r915 r923  
    198198                        var renameComplete = function (node) {
    199199                                var editor = $(node).find('>INPUT');
    200                                 var dirID = $(node).attr('id');
     200                                var id = $(node).attr('id');
    201201                                var newName = $(editor).val();
     202                                var item = {
     203                                                id:id,
     204                                                name:$(node).parent().find('> INPUT[type="hidden"][class^="name"]').val(),
     205                                                type:$(node).parent().find('> INPUT[type="hidden"][class^="type"]').val(),
     206                                                parentID:$(node).parent().find('> INPUT[type="hidden"][class^="parentID"]').val(),
     207                                                newName:newName
     208                                                };
     209
     210                                o.manager.rename(item);
     211
    202212                                $(node).attr('rel', newName);
    203213                                $(node).text(newName);
    204214                                $(node).find('>INPUT').remove();
     215
    205216                        }
    206217
  • pro-violet-viettel/www/deploy/20150304/assets/js/manager.js

    r917 r923  
    870870                                 **********************************************/
    871871                                /***********************************************
     872                                 * RENAME - START *
     873                                 **********************************************/
     874                                        var rename = function (item) {
     875                                                /*
     876                                                 * item = {id,name,type,parentID,newName}
     877                                                 */
     878                                        var postdata = {
     879                                                data: JSON.stringify(item)
     880                                            };
     881                                                 sendCommand({
     882                                             postdata: postdata,
     883                                             script: 'rename',
     884                                             callbackSuccess: function (parseData) {
     885                                                 console.log(parseData);
     886                                             }
     887                                         });
     888                                        }
     889                                /***********************************************
     890                                 * RENAME - END *
     891                                 **********************************************/
     892                                /***********************************************
    872893                                 * COPY & PASTE & MOVE - START * =***********
    873894                                 **********************************************/
     
    10301051                                 * COPY & PASTE & MOVE - END *
    10311052                                 **********************************************/
     1053                                this.rename = function (item) {
     1054                                        rename(item);
     1055                                }
     1056
    10321057                                this.buildDirectoriesTree = function (objDir) {
    10331058                                        var parentID = objDir.id;
Note: See TracChangeset for help on using the changeset viewer.