Ignore:
Timestamp:
Aug 4, 2014 6:09:41 PM (11 years ago)
Author:
dungnv
Message:
 
Location:
pro-bachkim-filespace/sourcecode
Files:
7 added
11 edited

Legend:

Unmodified
Added
Removed
  • pro-bachkim-filespace/sourcecode/application/config/autoload.php

    r1 r42  
    5353*/
    5454
    55 $autoload['libraries'] = array('database');
     55$autoload['libraries'] = array('database','curl', 'xml', 'vservices');
    5656
    5757
  • pro-bachkim-filespace/sourcecode/application/modules/ajax/controllers/privatecontent.php

    r16 r42  
    77 */
    88
     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
     20private $_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
    930class PrivateContent extends MX_Controller
    1031{
    11         /* private $_aryDir = array(
    12                                 0 => array ('id' => 1, 'name' => 'Dir 1', 'parentID' => 0),
    13                                 1 => array ('id' => 2, 'name' => 'Dir 2', 'parentID' => 0),
    14                                 2 => array ('id' => 3, 'name' => 'Dir 1.1', 'parentID' => 1),
    15                                 3 => array ('id' => 4, 'name' => 'Dir 1.1.1', 'parentID' => 3),
    16                                 4 => array ('id' => 5, 'name' => 'Dir 1.1.1.1', 'parentID' => 4),
    17                                 5 => array ('id' => 6, 'name' => 'Dir 1.1.2', 'parentID' => 3),
    18                                 6 => array ('id' => 7, 'name' => 'Dir 3', 'parentID' => 0),
    19                                 7 => array ('id' => 8, 'name' => 'Dir 3.1', 'parentID' => 7)
    20                 );
    21        
    22         private $_aryFile = array(
    23                                 0 => array('id' => 1, 'name' => 'File 1', 'minetype' => 'text', 'size' => '1.5MB', 'parentID' => 1),
    24                                 1 => array('id' => 2, 'name' => 'File 2', 'minetype' => 'text', 'size' => '1.6MB', 'parentID' => 1),
    25                                 2 => array('id' => 3, 'name' => 'File 3', 'minetype' => 'text', 'size' => '1.7MB', 'parentID' => 2),
    26                                 3 => array('id' => 4, 'name' => 'File 4', 'minetype' => 'text', 'size' => '1.8MB', 'parentID' => 2),
    27                                 4 => array('id' => 5, 'name' => 'File 5', 'minetype' => 'text', 'size' => '1.8MB', 'parentID' => 0),
    28                                 5 => array('id' => 6, 'name' => 'File 6', 'minetype' => 'text', 'size' => '1.8MB', 'parentID' => 3),
    29                                 5 => array('id' => 7, 'name' => 'File 7', 'minetype' => 'text', 'size' => '1.8MB', 'parentID' => 5)
    30                 ); */
    31        
     32
    3233        public function __construct() {
    3334                parent::__construct();
    3435                $this->load->model('Directory_model', 'objDirectory', TRUE);
     36                $this->vservices->setApiUrl($this->config->item('api_url'));
     37                $this->vservices->setConnection($this->curl);
     38                $this->vservices->setUserId(33);
    3539        }
    3640       
    3741        public function getContent () {
    38                 $aryData = array('DIRECTORIES' =>  $this->objDirectory->getAllDirectory() , 'FILES' => $this->objDirectory->getAllFile(), 'ENCRYPT' => md5('abcdef'));
     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);
    3970                echo json_encode($aryData);
    4071        }
    4172
    4273        public function createDir () {
    43                 $parentDir =  $this->input->post('parentID',TRUE);
    44                 $name =  $this->input->post('name',TRUE);
    45                
    46                 if (!is_null($parentDir) && !is_null($name)) {
    47                        
    48                         $maxID = $this->objDirectory->getMaxID (true);
    49                         $aryDir = array('id' => (int)$maxID + 1, 'name' => $name, 'parentID' => $parentDir, 'maxID' => $maxID);
    50                        
    51                         $result = $this->objDirectory->createDir($aryDir);
    52                         echo json_encode($aryDir);
    53                 }
     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);
    5481        }
    5582       
     
    74101                echo json_encode($aryData);
    75102        }
    76 
     103       
     104        public function upload() {
     105               
     106        }
    77107}
    78108
  • pro-bachkim-filespace/sourcecode/application/modules/filemanager/views/main.php

    r16 r42  
    3434                        <div class="btn-group">
    3535                                <button class="btn btn-warning" title="Tải xuống"><i class="icon-cloud-download"></i></button>
    36                                 <button class="btn btn-info" title="Tải lên"><i class="icon-cloud-upload"></i></button>
     36                                <button id="btnUpload" class="btn btn-info" title="Tải lên"><i class="icon-cloud-upload"></i></button>
    3737                        </div>
    3838                </div>
  • pro-bachkim-filespace/sourcecode/application/views/layout/contextmenu.php

    r16 r42  
    11<ul id="treeMenu" class="contextMenu">
    2         <li class="share"><a href="#share">Chia sẻ</a></li>
     2        <li class="newfolder"><a href="#newfolder">Tạo thư mục mới</a></li>
     3        <li class="share separator"><a href="#share">Chia sẻ</a></li>
    34        <li class="copy separator"><a href="#copy">Sao chép đến ...</a></li>
    45        <li class="cut"><a href="#cut">Di chuyển đến...</a></li>
     
    1011        <li class="open"><a href="#open">Mở</a></li>
    1112        <li class="preview"><a href="#preview">Xem trước</a></li>
     13        <li class="newfolder separator"><a href="#newfolder">Tạo thư mục mới</a></li>
    1214        <li class="share separator"><a href="#share">Chia sẻ</a></li>
    1315        <li class="copy separator"><a href="#copy">Sao chép đến ...</a></li>
  • pro-bachkim-filespace/sourcecode/application/views/layout/footer.php

    r18 r42  
    1313<script src="assets/js/bootstrap/bootstrap.min.js"></script>
    1414<script src="assets/js/jquery/jquery.confirm.min.js"></script>
    15 <!-- <script src="assets/js/bootstrap/bootbox.min.js"></script> -->
     15<script src="assets/js/bootstrap/ace-elements.min.js"></script>
     16
     17<script src="assets/js/jquery/jquery.uploadfile.min.js"></script>
     18
    1619<script src="assets/js/jquery/jquery-ui-1.10.4.min.js"></script>
    1720<script src="assets/js/jquery/jquery.contextMenu.js"></script>
  • pro-bachkim-filespace/sourcecode/application/views/layout/modalform.php

    r18 r42  
    109109<!-- END:Copy modal box -->
    110110
    111 <!-- BEGIN:Delete confirm modal box -->
    112 <!-- END:Delete confirm modal box -->
     111<!-- BEGIN:UPLOAD modal box -->
     112<div id="box-upload" class="modal" tabindex="-1">
     113        <div class="modal-dialog">
     114                <div class="modal-content">
     115                        <div class="modal-header">
     116                                <button type="button" class="close" data-dismiss="modal">&times;</button>
     117                                <h4 class="blue bigger">Tải file lên Violet Space</h4>
     118                        </div>
     119
     120                        <div class="modal-body overflow-visible">
     121                                <div class="row">
     122                                        <div class="col-xs-12 col-sm-12">
     123                                                <div id="fileuploader">Chọn file:</div>
     124                                        </div>
     125                                </div>
     126                        </div>
     127
     128                        <div class="modal-footer">
     129                                <button class="btn btn-sm" data-dismiss="modal">
     130                                        <i class="icon-remove"></i>
     131                                        Đóng
     132                                </button>
     133
     134                                <!-- <button class="btn btn-sm btn-primary">
     135                                        <i class="icon-cloud-upload"></i>
     136                                        Tải lên
     137                                </button> -->
     138                        </div>
     139                </div>
     140        </div>
     141</div>
     142<!-- END:UPLOAD modal box -->
     143
     144<!-- BEGIN:New folder box -->
     145<div id="box-newfolder" class="modal" tabindex="-1">
     146        <div class="modal-dialog">
     147                <div class="modal-content">
     148                        <div class="modal-header">
     149                                <button type="button" class="close" data-dismiss="modal">&times;</button>
     150                                <h4 class="blue bigger">Tạo thư mục mới</h4>
     151                        </div>
     152                        <div class="modal-body overflow-visible">
     153                                <form id="frm-newfolder">
     154                                        <div class="row">
     155                                                <div class="col-xs-12">
     156                                                        <div class="input-group">
     157                                                                <div class="radio">
     158                                                                        <label for="f-newfoldername">Tên thư mục</label>
     159                                                                        <div>
     160                                                                                <input type="text" id="f-newfoldername" name="fname" class="form-control" style="width:525px">
     161                                                                                <input type="hidden" id="f-parentid" name="fparentid">
     162                                                                        </div>
     163                                                                </div>
     164                                                        </div>
     165                                                </div>
     166                                        </div>
     167                                </form>
     168                        </div>
     169                        <div class="modal-footer">
     170                                <button id="btn-submit-newfolder" class="btn btn-sm btn-primary">
     171                                        <i class="icon-folder-close"></i>
     172                                        OK
     173                                </button>
     174                                <button class="btn btn-sm" data-dismiss="modal">
     175                                        <i class="icon-remove"></i>
     176                                        Đóng
     177                                </button>
     178                        </div>
     179                </div>
     180        </div>
     181</div>
     182<!-- END:New folder box -->
  • pro-bachkim-filespace/sourcecode/assets/css/jquery/jquery.contextmenu_new.css

    r15 r42  
    6161
    6262.contextMenu LI.preview A { background-image: url(images/preview.png); }
    63 .contextMenu LI.open A { background-image: url(images/folder_open.png); }
     63.contextMenu LI.open A { /* background-image: url(images/folder_open.png); */ }
    6464.contextMenu LI.share A { background-image: url(images/share.png); }
    6565.contextMenu LI.rename A { background-image: url(images/rename.png); }
     66
     67.contextMenu LI.newfolder A { background-image: url(images/folder_open.png); }
    6668
    6769.contextMenu LI.edit A { background-image: url(images/page_white_edit.png); }
  • pro-bachkim-filespace/sourcecode/assets/css/space/style.css

    r17 r42  
    88@import "vsgrid.css";
    99@import "contextmenu.css";
     10@import "../uploadfile.min.css";
    1011
    1112body {
     
    150151        border-radius: 0 !important;
    151152}
     153
     154#fileuploader {
     155        text-align: center;
     156}
  • pro-bachkim-filespace/sourcecode/assets/js/filemanager/filemanager.js

    r23 r42  
    8585                        privateTree.deleteDir(curDir);
    8686                });
     87               
     88                $('#btnUpload').click (function() {
     89                        var curDir = privateTree.getCurrentDir();
     90                        privateTree.upload();
     91                });
     92               
    8793
    8894
  • pro-bachkim-filespace/sourcecode/assets/js/vsgrid.js

    r23 r42  
    99                        if( o.dirIDprefix == undefined ) o.dirIDprefix = null;
    1010                        if( o.host == undefined ) o.host = 'http://localhost/';
     11                        if( o.tree == undefined ) o.tree = null;
    1112                       
    1213                        if( o.sharemodal == undefined ) o.sharemodal = $("#box-shareto");
     
    4849                                        itemClick(el);
    4950                                        switch(action) {
     51                                                case 'newfolder':
     52                                                        openNewFolderModal(currentObj);
     53                                                        break;
    5054                                                case 'rename':
    5155                                                        rename(el);
     
    6266                                        }
    6367                                       
     68                                });
     69                        }
     70                       
     71                        var openNewFolderModal = function (c) {
     72                                $('#box-newfolder').modal('show');
     73                                $('#frm-newfolder').find('#f-parentid').val(c.id);
     74                        }
     75                       
     76                        var bindCreateFolder = function () {
     77                                $('#box-newfolder').find('#frm-newfolder').unbind('submit');
     78                                $('#box-newfolder').find('#btn-submit-newfolder').unbind('click');
     79                               
     80                                $('#box-newfolder').find('#frm-newfolder').bind('submit',
     81                                        function(e){
     82                                                if ($('#frm-newfolder').find('#f-newfoldername').val() == '') {
     83                                                        alert('Chưa nhập tên thư mục mới!');
     84                                                }else {
     85                                                        var postData = $('#box-newfolder').find('#frm-newfolder').serializeArray();
     86                                                        var script = 'ajax/privatecontent/createdir';
     87                                                        sendCommand({
     88                                                                script: script,
     89                                                                postdata:postData,
     90                                                                callbackSuccess: function (parsedData) {
     91                                                                                                        createNode({
     92                                                                                                                id: parsedData.id,
     93                                                                                                                name: parsedData.name,
     94                                                                                                                curentNode: currentObj,
     95                                                                                                                hidden: false,
     96                                                                                                                addToJSONData:true});
     97                                                                                                        o.tree.createDir(parsedData);
     98                                                                                                }
     99                                                        });
     100                                                       
     101                                                        $('#box-newfolder').modal('hide');
     102                                                }
     103                                               
     104                                                e.preventDefault();
     105                                });
     106                               
     107                                $('#box-newfolder').on('show.bs.modal', function () {
     108                                        $('#box-newfolder').find('#frm-newfolder').get(0).reset();
     109                                });
     110                               
     111                                $('#box-newfolder').find('#btn-submit-newfolder').bind('click',
     112                                        function (){
     113                                                $('#box-newfolder').find('#frm-newfolder').submit();
    64114                                });
    65115                        }
     
    153203                                currentObj.id = $(i).attr('rel').substring(3);
    154204                                currentObj.type = $(i).find('>div>div').hasClass('icon-directory') ? 'directory':'file';
     205                                var item = searchItemByID(currentObj.id, currentObj.type);
     206                                currentObj.parentID = item.parentID;
     207                        }
     208                       
     209                        var searchItemByID = function (itemID, type) {
     210                                var source = (type == 'directory') ? o.directoryTreeData.DIRECTORIES : (type == 'file') ? o.directoryTreeData.FILES : null;
     211                                var item = null;
     212                                for (var i = 0 ; i < source.length; i++) {
     213                                        if (source[i].id == itemID) {
     214                                                item = source[i];
     215                                                break;
     216                                        }
     217                                }
     218                                return item;
    155219                        }
    156220
     
    182246                               
    183247                                keyboardRename();
     248                                bindCreateFolder();
    184249                        }
    185250                       
     
    252317                                                        p.callbackSuccess(parseData);
    253318                                                }
    254 
    255319                                        }).done(function() {if (p.callbackDone != null)p.callbackDone(this);}).fail(function() {if (p.callbackFail != null)p.callbackFail(this);}).always(function() {if (p.callbackAlways != null)p.callbackAlways(this);});
    256320                                }
    257321                        }
    258322
    259                         this.getData = function (data) {
     323                        this.setData = function (data) {
    260324                                o.directoryTreeData = data.directoryTreeData;
    261325                                o.curentParent = data.curentParent;
    262                                 o.dirIDprefix = data.dirIDprefix
     326                                o.dirIDprefix = data.dirIDprefix;
    263327                                renderGrid(o);
     328                        }
     329                       
     330                        this.setTree = function (treeObj) {
     331                                o.tree = treeObj;
    264332                        }
    265333                       
    266334                        this.showModal = function (obj, act) {
    267335                                switch( act ) {
     336                                        case 'newfolder':
     337                                                openNewFolderModal(obj);
     338                                                break;
    268339                                        case 'copy':
    269340                                        case 'cut':
  • pro-bachkim-filespace/sourcecode/assets/js/vstree.js

    r18 r42  
    1515                        if( o.expandEasing == undefined ) o.expandEasing = null;
    1616                        if( o.collapseEasing == undefined ) o.collapseEasing = null;
     17                        if( o.me == undefined ) o.me = this;
    1718
    1819                        if( o.directoryTreeData == undefined ) o.directoryTreeData = null;
     
    107108                                        newdir.id = d.id;
    108109                                        newdir.name = d.name;
     110                                       
     111                                        console.log(d.currentNode);
     112                                       
    109113                                        newdir.parentID = $(o.container).find(d.currentNode).parent().attr('id').substring(o.dirIDprefix.length, $(d.currentNode).parent().attr('id').length);
    110114                                        o.directoryTreeData.DIRECTORIES.push(newdir);
     
    125129                                                                rename(el);
    126130                                                                break;
     131                                                        case 'newfolder':
    127132                                                        case 'share':
    128133                                                        case 'copy':
     
    144149                        }
    145150                        //END - Create a node of Tree
    146 
     151                       
    147152                        var deleteNode = function (parsedData) {
    148153                                if (parsedData.isSuccess == false) return false;
     
    190195                                if (o.grid == null) return false;
    191196                               
    192                                 o.grid.getData({
     197                                o.grid.setTree(o.me);
     198                                o.grid.setData({
    193199                                                                directoryTreeData: o.directoryTreeData,
    194200                                                                curentParent:$(o.container).find('.currentDir').parent().attr('id'),
     
    281287                        };
    282288
    283                         this.createDir = function(c) {
    284                                 var cid = $(c).parent().attr('id');
    285                                 var pid = cid.substring(o.dirIDprefix.length, cid.length);
    286 
    287                                 var dirName = prompt("Please enter new directory name", "");
    288                                 var script = 'ajax/privatecontent/createdir';
    289 
    290                                 if (dirName != null && dirName.length != 0) {
    291                                         sendCommand({
    292                                                 script: script,
    293                                                 postdata:{parentID:pid,name:dirName},
    294                                                 callbackSuccess: function (parsedData) {createNode({
    295                                                                                         id: parsedData.id,
    296                                                                                         name: parsedData.name,
    297                                                                                         curentNode: c,
    298                                                                                         hidden: false,
    299                                                                                         addToJSONData:true});
    300                                                                                 }
    301                                         });
    302                                 }
     289                        this.createDir = function(data) {
     290                                var cNode = $('#' + o.dirIDprefix + data.parentID).find('> A');
     291                               
     292                                createNode({
     293                                        id: data.id,
     294                                        name: data.name,
     295                                        currentNode: cNode,
     296                                        hidden: false,
     297                                        addToJSONData:true});
     298                               
     299                                //console.log($(o.container).find(cNode).parent().attr('id').substring(o.dirIDprefix.length, $(cNode).parent().attr('id').length));
    303300                        }
    304301
     
    328325                                });
    329326                        }
     327                       
     328                        this.upload = function () {
     329                                $('#box-upload').modal('show');
     330                               
     331                                $("#fileuploader").uploadFile({
     332                                        url: o.host + 'ajax/privatecontent/upload',
     333                                        fileName:"myfile",
     334                                        multiple:true,
     335                                        maxFileCount: 5,
     336                                        dragDropStr: "<span><b>Kéo thả các file vào đây!</b></span>",
     337                                        uploadErrorStr:"Tải lên có lỗi!"
     338                                });
     339                               
     340                                $('#box-upload').on('hide.bs.modal', function () {
     341                                        $('#box-upload').find('.modal-body>.row>.col-xs-12>').remove();
     342                                        $('#box-upload').find('.modal-body>.row>.col-xs-12').append('<div id="fileuploader">Chọn file:</div>');
     343                                });
     344                        }
    330345
    331346                        this.copy = function () {
    332                                 alert ('copy');
     347                               
    333348                        }
    334349
    335350                        this.paste = function () {
    336                                 alert ('paste');
     351                               
    337352                        }
    338353
Note: See TracChangeset for help on using the changeset viewer.