예제 #1
0
 protected function setToolbar()
 {
     // Check permissions for the current rows to determine if we should show the states togglers and the delete button
     $rows = K2Response::getRows();
     $canEditState = false;
     $canEditFeaturedState = false;
     $canDelete = false;
     foreach ($rows as $row) {
         if ($row->canEditState) {
             $canEditState = true;
         }
         if ($row->canEditFeaturedState) {
             $canEditFeaturedState = true;
         }
         if ($row->canDelete) {
             $canDelete = true;
         }
     }
     if ($canEditFeaturedState) {
         K2Response::addToolbarAction('feature', 'K2_FEATURE', array('data-state' => 'featured', 'data-value' => '1', 'data-action' => 'set-state'));
         K2Response::addToolbarAction('unfeature', 'K2_UNFEATURE', array('data-state' => 'featured', 'data-value' => '0', 'data-action' => 'set-state'));
     }
     if ($canEditState) {
         K2Response::addToolbarAction('publish', 'K2_PUBLISH', array('data-state' => 'state', 'data-value' => '1', 'data-action' => 'set-state'));
         K2Response::addToolbarAction('unpublish', 'K2_UNPUBLISH', array('data-state' => 'state', 'data-value' => '0', 'data-action' => 'set-state'));
         K2Response::addToolbarAction('trash', 'K2_TRASH', array('data-state' => 'state', 'data-value' => '-1', 'data-action' => 'set-state'));
     }
     K2Response::addToolbarAction('batch', 'K2_BATCH', array('data-action' => 'batch'));
     if ($canDelete) {
         K2Response::addToolbarAction('remove', 'K2_DELETE', array('data-action' => 'remove'));
     }
 }