contributions/binaries/controller/base/binaries.basecontroller.php
Go to the documentation of this file.00001 <?php 00002 /** 00003 * Defines a view route for binaries 00004 * 00005 * @author Gerd Riesselmann 00006 * @ingroup Binaries 00007 */ 00008 class BinariesBaseController extends ControllerBase { 00009 00010 /** 00011 * Return array of IDispatchToken this controller takes responsability 00012 */ 00013 public function get_routes() { 00014 $ret = array( 00015 'view' => new ParameterizedRoute('binaries/{id:ui>}', $this, 'binaries_view', $this->get_route_decorators()), 00016 ); 00017 return $ret; 00018 } 00019 00020 /** 00021 * Return Decorators for binaries routes 00022 * 00023 * @return mixed 00024 */ 00025 protected function get_route_decorators() { 00026 return array(new BinariesCacheManager()); 00027 } 00028 00029 /** 00030 * Activates includes before action to reduce cache memory 00031 */ 00032 public function before_action() { 00033 Load::models('binaries'); 00034 } 00035 00036 /** 00037 * Show binary 00038 * 00039 * @param $page_data PageData 00040 * @param $id ID of binary 00041 */ 00042 public function action_binaries_view($page_data, $id) { 00043 $binary = Binaries::get($id); 00044 if (empty($binary)) { 00045 return CONTROLLER_NOT_FOUND; 00046 } 00047 00048 $view = ViewFactory::create_view(ViewFactoryMime::MIME, 'binaries/view', $page_data); 00049 $view->assign(MimeView::MIMETYPE, $binary->mimetype); 00050 $view->assign('binary', $binary); 00051 $view->render(); 00052 } 00053 }