![]() |
Xataface Datepicker Module 0.2
jQuery Datepicker Widget for Xataface
|
00001 <?php 00002 /* 00003 * Xataface Datepicker 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_datetimepicker { 00035 00049 function &buildWidget($record, &$field, $form, $formFieldName, $new=false){ 00050 $mt = Dataface_ModuleTool::getInstance(); 00051 $mod = $mt->loadModule('modules_datepicker'); 00052 00053 $widget =& $field['widget']; 00054 if ( !@$widget['format'] ){ 00055 $widget['format'] = "yyyy-mm-dd HH:MM:ss"; 00056 } 00057 $factory =& Dataface_FormTool::factory(); 00058 $atts = array( 00059 'class' => 'xf-datetimepicker', 00060 'data-xf-date-format' => $widget['format'], 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/datetimepicker.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 }
1.7.4