This is the API documentation for concrete5 version 5.6 and earlier. View Current API Documentation
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 
<?php
    defined('C5_EXECUTE') or die("Access Denied.");
/**
 * Controller for a block that displays a file link on a page. 
 *
 * @package Blocks
 * @subpackage File
 * @author Andrew Embler <[email protected]>
 * @copyright  Copyright (c) 2003-2012 Concrete5. (http://www.concrete5.org)
 * @license    http://www.concrete5.org/license/     MIT License
 *
 */ 
    class Concrete5_Controller_Block_File extends BlockController {

        protected $btInterfaceWidth = 300;
        protected $btCacheBlockRecord = true;
        protected $btCacheBlockOutput = true;
        protected $btCacheBlockOutputOnPost = true;
        protected $btCacheBlockOutputForRegisteredUsers = true;
        protected $btInterfaceHeight = 250;
        protected $btTable = 'btContentFile';
        
        protected $btExportFileColumns = array('fID');
        
        /** 
         * Used for localization. If we want to localize the name/description we have to include this
         */
        public function getBlockTypeDescription() {
            return t("Link to files stored in the asset library.");
        }
        
        public function getBlockTypeName() {
            return t("File");
        }

        public function getJavaScriptStrings() {
            return array('file-required' => t('You must select a file.'));  
        }
        
        public function getSearchableContent(){
            return $this->fileLinkText;
        }
        
        public function validate($args) {
            $e = Loader::helper('validation/error');
            if ($args['fID'] < 1) {
                $e->add(t('You must select a file.'));
            }
            if (trim($args['fileLinkText']) == '') {
                $e->add(t('You must give your file a link.'));
            }
            return $e;
        }
        
        function getFileID() {return $this->fID;}
        
        function getFileObject() {
            return File::getByID($this->fID);
        }
        
        function getLinkText() {
            if ($this->fileLinkText) {
                return $this->fileLinkText;
            } else {
                $f = $this->getFileObject();
                return $f->getTitle();
            }
        }
        
        
        
    }
?>