Source of file CMSNonSecuredFileAddController.php
Size: 3,070 Bytes - Last Modified: 2021-12-24T06:44:15+00:00
/var/www/docs.ssmods.com/process/src/code/controllers/CMSNonSecuredFileAddController.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 | <?php /** * * Specific controller used to add files to the advanced-assets CMS UI, but that aren't (yet) secured. * * @author Deviate Ltd 2014-2015 http://www.deviate.net.nz * @package silverstripe-advancedassets * @todo Modify addFolder() and initValidate() to show messages within the CMS. */ class CMSNonSecuredFileAddController extends CMSFileAddController { private static $url_segment = 'assets/add'; private static $url_priority = 65; public function init() { parent::init(); if($this->request->requestVar('ID') && is_numeric($this->request->requestVar('ID'))) { $this->setCurrentPageID($this->request->requestVar('ID')); } $this->initValidate(); } /** * * Intial validation of incoming CMS requests before we do anything useful. * * @return SS_HTTPResponse * @todo Refactor into single static. There are v.close dupes of this in the other controllers. */ public function initValidate() { $folderId = SecuredFilesystem::get_numeric_identifier($this, 'ID'); if ($folderId) { $folder = DataObject::get_by_id("Folder", $folderId); if ($folder && $folder->exists()) { if ($folder->Secured) { $message = _t('SecuredFilesystem.messages.ERROR_ACCESS_ONLY_IN_SECURED_FILES'); return SecuredFilesystem::show_access_message($this, $message); } } else { $message = _t('SecuredFilesystem.messages.ERROR_FOLDER_NOT_EXISTS'); return SecuredFilesystem::show_access_message($this, $message); } } } /** * * @param boolean $unlinked * @return SS_List */ public function Breadcrumbs($unlinked = false) { $items = parent::Breadcrumbs($unlinked); $originalLink = singleton('AssetAdmin')->Link('show'); $changedLink = singleton('NonSecuredAssetAdmin')->Link('show'); foreach ($items as $item) { $item->Link = str_replace($originalLink, $changedLink, $item->Link); } return $items; } /** * * @param number $id Not used. * @param FieldList $fields Not used. * @return Form * @todo what template is used here? AssetAdmin_UploadContent.ss doesn't seem to be used anymore */ public function getEditForm($id = null, $fields = null) { $form = parent::getEditForm($id, $fields); $folder = $this->currentPage(); $backLink = LiteralField::create( 'BackLink', sprintf( '<a href="%s" class="backlink ss-ui-button cms-panel-link" data-icon="back">%s</a>', Controller::join_links(singleton('NonSecuredAssetAdmin')->Link('show'), $folder->ID), _t('AssetAdmin.BackToFolder', 'Back to folder') ) ); $fields = $form->Fields(); $fields->removeByName("BackLink"); $fields->push($backLink); return $form; } } |