![]() |
Xataface Datepicker Module 0.1
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_datepicker { 00035 00047 function &buildWidget($record, &$field, $form, $formFieldName, $new=false){ 00048 $mt = Dataface_ModuleTool::getInstance(); 00049 $mod = $mt->loadModule('modules_datepicker'); 00050 00051 $widget =& $field['widget']; 00052 if ( !@$widget['format'] ){ 00053 $widget['format'] = 'yy-mm-dd'; 00054 } 00055 $factory =& Dataface_FormTool::factory(); 00056 $atts = array( 00057 'class' => 'xf-datepicker', 00058 'data-xf-date-format' => $widget['format'], 00059 'df:cloneable'=>1 00060 ); 00061 00062 00063 00064 00065 $jt = Dataface_JavascriptTool::getInstance(); 00066 $jt->addPath(dirname(__FILE__).'/js', $mod->getBaseURL().'/js'); 00067 00068 $ct = Dataface_CSSTool::getInstance(); 00069 $ct->addPath(dirname(__FILE__).'/css', $mod->getBaseURL().'/css'); 00070 00071 // Add our javascript 00072 $jt->import('xataface/widgets/datepicker.js'); 00073 00074 $el =& $factory->addElement('text', $formFieldName, $widget['label'], $atts); 00075 if ( PEAR::isError($el) ) return $el; 00076 $el->setProperties($widget); 00077 00078 00079 00080 00081 return $el; 00082 } 00083 00084 00085 }