/** * Get the form field for this field. * * We put this method at the field level as it allows us to easily * create a new DB field and a new Form field and use them without * the need to modify another place where the mapping would be * performed. * * @param array Definition of the field. * @param string Form field class. */ function formField($def, $form_field = 'Pluf_Form_Field_Varchar') { Pluf::loadClass('Pluf_Form_BoundField'); // To get mb_ucfirst $defaults = array('required' => !$def['blank'], 'label' => mb_ucfirst($def['verbose']), 'help_text' => $def['help_text']); unset($def['blank'], $def['verbose'], $def['help_text']); if (isset($def['default'])) { $defaults['initial'] = $def['default']; unset($def['default']); } if (isset($def['choices'])) { $defaults['widget'] = 'Pluf_Form_Widget_SelectInput'; if (isset($def['widget_attrs'])) { $def['widget_attrs']['choices'] = $def['choices']; } else { $def['widget_attrs'] = array('choices' => $def['choices']); } } foreach (array_keys($def) as $key) { if (!in_array($key, array('widget', 'label', 'required', 'multiple', 'initial', 'choices', 'widget_attrs'))) { unset($def[$key]); } } $params = array_merge($defaults, $def); return new $form_field($params); }
public function testLoadClass() { Pluf::loadClass('Pluf_Model'); $this->assertEquals(true, class_exists('Pluf_Model')); }
/** * Autoload function. * * @param string Class name. */ function __autoload($class_name) { try { Pluf::loadClass($class_name); } catch (Exception $e) { if (Pluf::f('debug')) { print $e->getMessage(); die; } eval("class {$class_name} { \n function __construct() { \n throw new Exception('Class {$class_name} not found');\n }\n \n static function __callstatic(\$m, \$args) {\n throw new Exception('Class {$class_name} not found');\n }\n }"); } }
# Plume CMS is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Plume CMS is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # ***** END LICENSE BLOCK ***** */ Pluf::loadClass('Pluf_Model'); class TestModel extends Pluf_Model { function init() { $this->_a['table'] = 'testmodel'; $this->_a['model'] = 'TestModel'; $this->_a['cols'] = array('id' => array('type' => 'Pluf_DB_Field_Sequence', 'blank' => true), 'title' => array('type' => 'Pluf_DB_Field_Varchar', 'blank' => false, 'size' => 100), 'description' => array('type' => 'Pluf_DB_Field_Text', 'blank' => true)); $this->_a['idx'] = array('title' => array('type' => 'normal')); $this->_a['views'] = array('simple' => array('select' => 'testmodel_id, title, description'), '__unique__' => array('select' => 'testmodel_id')); parent::init(); } } class TestModelRecurse extends Pluf_Model { function init()
/** * Get the remote access url to the repository. * * This will always return the anonymous access url. */ public function getRemoteAccessUrl() { $conf = $this->getConf(); $scm = $conf->getVal('scm', 'git'); $scms = Pluf::f('allowed_scm'); Pluf::loadClass($scms[$scm]); return call_user_func(array($scms[$scm], 'getAnonymousAccessUrl'), $this); }