Xataface Duration Selector Module 0.1
Duration Selector Widget for Xataface Forms
|
00001 <?php 00002 /* 00003 * Xataface Duration Selector Module 00004 * Copyright (C) 2011 Steve Hannah <steve@weblite.ca> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Library General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Library General Public 00017 * License along with this library; if not, write to the 00018 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 * 00021 */ 00034 class Dataface_FormTool_durationselector{ 00035 00047 function &buildWidget($record, &$field, $form, $formFieldName, $new=false){ 00048 $mt = Dataface_ModuleTool::getInstance(); 00049 $mod = $mt->loadModule('modules_durationselector'); 00050 00051 $widget =& $field['widget']; 00052 00053 $factory =& Dataface_FormTool::factory(); 00054 if ( !@$widget['interval'] ){ 00055 $widget['interval'] = 30; 00056 } 00057 $atts = array( 00058 'class' => 'xf-durationselector', 00059 'data-xf-durationselector-interval' => $widget['interval'], 00060 'data-xf-durationselector-start' => $widget['start'], 00061 'df:cloneable'=>1 00062 ); 00063 00064 00065 00066 00067 $jt = Dataface_JavascriptTool::getInstance(); 00068 $jt->addPath(dirname(__FILE__).'/js', $mod->getBaseURL().'/js'); 00069 00070 $ct = Dataface_CSSTool::getInstance(); 00071 $ct->addPath(dirname(__FILE__).'/css', $mod->getBaseURL().'/css'); 00072 00073 // Add our javascript 00074 $jt->import('xataface/widgets/durationselector.js'); 00075 00076 $el =& $factory->addElement('text', $formFieldName, $widget['label'], $atts); 00077 if ( PEAR::isError($el) ) return $el; 00078 $el->setProperties($widget); 00079 00080 00081 00082 00083 return $el; 00084 } 00085 00086 00087 }