Changeset 345


Ignore:
Timestamp:
03/13/10 11:14:02 (23 months ago)
Author:
aarkerio
Message:

Update Shares

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/controllers/shares_controller.php

    r329 r345  
    3333  endif; 
    3434       
    35   $fields     = array('id', 'title', 'description', 'created', 'lenght', 'user_id', 'filename'); 
    36   $order      = 'id DESC'; 
    37   $limit      = 12; 
     35  $params = array( 
     36                  'conditions' => $conditions, 
     37                  'fields'     => array('id', 'title', 'description', 'created', 'lenght', 'user_id', 'filename'), 
     38                  'order'      => 'id DESC', 
     39                  'limit'      => 12 
     40                  ); 
    3841       
    3942  $this->set('data', $this->Share->find('all', $params));  
    4043 } 
    4144  
    42  public function show($user_id, $id) 
     45/** 
     46 * @param mixed Null or string $username 
     47 * @param mixed Null or integer $entry_id 
     48 * @access public 
     49 * @return void 
     50 */ 
     51 public function show($user_id, $share_id) 
    4352 {    
    4453   $this->layout    = $this->Edublog->layout($user_id); 
    4554   $this->set('blog', $this->Edublog->blog($user_id)); 
    4655   $this->pageTitle = 'Share'; 
    47    $params = array('conditions' => array('Share.id'=>$id, 'Share.status'=>1), 
     56   $params = array('conditions' => array('Share.id'=>$share_id, 'Share.status'=>1), 
    4857                   'fields'     => array('id', 'title', 'description', 'created', 'filename', 'length', 'size', 'duration')); 
    49    $this->set('data', $this->Share->find('all',$params)); 
     58   $this->set('data', $this->Share->find('first',$params)); 
    5059  } 
    5160   
    5261/** 
    53  * 
    54  * 
     62 * @param mixed Null or string $username 
     63 * @param mixed Null or integer $entry_id 
     64 * @access public 
     65 * @return void 
    5566 */ 
    56  public function all($username=null, $entry_id=null)  
     67 public function all($username=Null, $entry_id=Null)  
    5768 { 
    5869   $this->pageTitle = $username . '\'s Share'; 
     
    8192  } 
    8293   
    83   /****==== ADMIN METHODS ====**/ 
    84   public function admin_listing() 
    85   {      
    86     $this->layout = 'admin';      
    87     $this->pageTitle = $this->Auth->user('username') . '\'s Shares'; 
    88      
    89     $params = array('conditions'   => array('Share.user_id'=>$this->Auth->user('id')), 
    90                     'fields'       => array('id', 'file', 'created', 'public', 'description'), 
    91                     'order'        => 'Share.id DESC', 
    92                     'limit'        => 20); 
    93          
    94    $this->set('data', $this->Share->find('all', $params));  
     94 /****==== ADMIN METHODS ====**/ 
     95 public function admin_listing() 
     96 {      
     97  $this->layout = 'admin';  
     98  $this->pageTitle = $this->Auth->user('username') . '\'s Shares'; 
     99  $this->paginate['limit']   = 20; 
     100  $this->paginate['fields'] = array('Share.id', 'Share.file', 'Share.description', 'Share.public', 'Share.created'); 
     101  $this->paginate['conditions'] = array('Share.user_id'=>$this->Auth->user('id')); 
     102  $this->paginate['order']      = 'Share.id DESC'; 
     103  $data = $this->paginate('Share'); 
     104  $this->set(compact('data')); 
    95105  } 
    96106     
  • trunk/views/shares/admin_listing.ctp

    r273 r345  
    11<?php  
    22echo $html->div('title_section',  $session->read('Auth.User.username').' shared files'); 
    3 echo $html->link($html->image('admin/new.gif', array('alt'=>'Add new share', 'title'=>'Add new share')), '#', array("onclick"=>"hU()"), false, false);  
     3echo $html->link($html->image('admin/new.gif', array('alt'=>'Add new share', 'title'=>'Add new share')), '#', array("onclick"=>"hU()"), False, False);  
    44$session->flash();  
    55?> 
    6  
    76<div id="addshare" style="display:none"> 
    87<?php echo $form->create('Share', array("enctype"=>"multipart/form-data") ); ?> 
     
    2120 
    2221<?php 
    23 //die(print_r($data)); 
    24  
    25 $th = array ('Download', 'File', 'Size Kb', 'Description', 'Public', 'Delete'); 
     22 $th = array ('Download', 'File', 'Size Kb', 'Description', 'Uploaded', 'Public', 'Delete'); 
    2623echo $html->tableHeaders($th); 
    2724foreach ($data as $val): 
    28        $st = ($val['Share']['public'] == 1) ? 'Public': 'No public'; 
    29        $size = filesize('../webroot/files/userfiles/'.$val['Share']['file']); 
    30        $sizemb = round(($size/1024),2); 
    31        $tr = array ( 
     25    $st = ($val['Share']['public'] == 1) ? 'Public': 'No public'; 
     26    $size = filesize('../webroot/files/userfiles/'.$val['Share']['file']); 
     27    $sizemb = round(($size/1024),2); 
     28    $tr = array ( 
    3229               $html->link( 
    3330                           $html->image('static/button_download.gif', array('alt'=>"Download file", 'alt'=>"Download file")), 
     
    3633                           False,  
    3734                           False), 
    38         $val['Share']['file'], 
    39             $sizemb, 
    40         $val['Share']['description'], 
    41         $html->link($st, '/admin/shares/change/'.$val['Share']['id'].'/'.$val['Share']['public']), 
    42         $gags->confirmDel($val['Share']['id'], 'shares') 
    43         ); 
     35    $val['Share']['file'], 
     36        $sizemb, 
     37    $val['Share']['description'], 
     38    '<span style="font-size:7pt;">'.$val['Share']['created'].'</span>', 
     39    $html->link($st, '/admin/shares/change/'.$val['Share']['id'].'/'.$val['Share']['public']), 
     40    $gags->confirmDel($val['Share']['id'], 'shares') 
     41    ); 
    4442        
    4543    echo $html->tableCells($tr, array('class'=>"altRow", "onmouseover"=>"this.className='highlight'", "onmouseout"=>"this.className='altRow'"),  
     
    4846?> 
    4947</table> 
    50  
     48<?php 
     49echo  $html->div(null,null, array('style'=>'font-size:9pt;width:400px;margin:15px auto;')); 
     50    echo $html->div(null,$paginator->prev('« '.__('Previous', true),null,null,array('class'=>'disabled')), 
     51                                         array('style'=>'width:100px;float:left')); 
     52    echo $html->div(null,$paginator->next(__('Next', true).' »', null, null, array('class' => 'disabled')), 
     53                                         array('style'=>'width:100px;float:right')); 
     54    echo $html->div(null,$paginator->counter(), array('style'=>'width:200px;float:center')); 
     55echo '</div>'; 
     56?> 
    5157<script type="text/javascript">  
    5258<!--  
     
    6470--> 
    6571</script> 
    66  
    67  
Note: See TracChangeset for help on using the changeset viewer.