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  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108 109 
<?php
    defined('C5_EXECUTE') or die("Access Denied.");
/**
 * External Form block controller. 
 *
 * @package Blocks
 * @subpackage External Form
 * @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_ExternalForm extends BlockController {
        
        protected $btTable = 'btExternalForm';
        protected $btInterfaceWidth = "370";
        protected $btInterfaceHeight = "100";
        public $helpers = array('file');
        protected $btCacheBlockRecord = true;
        protected $btWrapperClass = 'ccm-ui';       
        /** 
         * Used for localization. If we want to localize the name/description we have to include this
         */
        public function getBlockTypeDescription() {
            return t("Include external forms in the filesystem and place them on pages.");
        }
        
        public function getBlockTypeName() {
            return t("External Form");
        }

        public function getJavaScriptStrings() {
            return array('form-required' => t('You must select a form.'));  
        }
        
        
        function getFilename() {return $this->filename;}
        
        function getExternalFormFilenamePath() {
            if (file_exists(DIR_FILES_BLOCK_TYPES_FORMS_EXTERNAL . '/' . $this->filename)) {
                $filename = DIR_FILES_BLOCK_TYPES_FORMS_EXTERNAL . '/' . $this->filename;
            } else if (file_exists(DIR_FILES_BLOCK_TYPES_FORMS_EXTERNAL_CORE . '/' . $this->filename)) {
                $filename = DIR_FILES_BLOCK_TYPES_FORMS_EXTERNAL_CORE . '/' . $this->filename;
            }
            return $filename;
        }

        // we use call so that any methods passed to the custom form block controller,
        // if they're not implemented here, we attempt to find them in the
        // controller for that specific custom form block
        
        protected function getControllerFile() {
            if (file_exists(DIR_FILES_BLOCK_TYPES_FORMS_EXTERNAL_PROCESS . '/' . $this->filename)) {
                $filename = DIR_FILES_BLOCK_TYPES_FORMS_EXTERNAL_PROCESS . '/' . $this->filename;
                $class = Object::camelcase(substr($this->filename, 0, strrpos($this->filename, '.php')));
                
            } else if (file_exists(DIR_FILES_BLOCK_TYPES_FORMS_EXTERNAL_PROCESS_CORE . '/' . $this->filename)) {
                $filename = DIR_FILES_BLOCK_TYPES_FORMS_EXTERNAL_PROCESS_CORE . '/' . $this->filename;
                $class = Object::camelcase(substr($this->filename, 0, strrpos($this->filename, '.php')));
            }
            
            
            if (isset($filename)) {
                require_once($filename);
                $class .= 'ExternalFormBlockController';
                $fp = new $class($this->getBlockObject());
            }
            
            if(is_object($fp)) {
                $fp->on_start();
                return $fp;
            } else {
                throw new Exception(t('Unable load external form block controller file: %s',$this->filename)); 
            }
        }
        
        public function view() {
            $this->set('controller', $this);        
        }
        
        public function __call($nm, $a) {
            $cnt = $this->getControllerFile();
            return $cnt->runTask($nm, $a);
        }

        public function add() {
            $this->set('filenames', $this->getFormList());  
        }
        public function edit() {
            $this->set('filenames', $this->getFormList());  
        }
        

        public function getFormList() {
                
            $forms = array();
            $fh = Loader::helper('file');
            
            if (file_exists(DIR_FILES_BLOCK_TYPES_FORMS_EXTERNAL)) {
                $forms = array_merge($forms, $fh->getDirectoryContents(DIR_FILES_BLOCK_TYPES_FORMS_EXTERNAL, array('controllers')));
            }
            if (file_exists(DIR_FILES_BLOCK_TYPES_FORMS_EXTERNAL_CORE)) {
                $forms = array_merge($forms, $fh->getDirectoryContents(DIR_FILES_BLOCK_TYPES_FORMS_EXTERNAL_CORE, array('controllers')));
            }
            
            return $forms;
        }
            
    }