CodeIgniter wrapper for YUI - CIwY 0.0.03 Beta


Calendar Widget

The Calendar widget provides functions that enable you to embed the YUI calendar widget in your page.

Initializing the Class

Like in CodeIgniter, the Calendar Widget is initialized in your controller using the $this->ciwy->loadComponent() function:

$this->ciwy->loadComponent('calendar');

Once loaded, the Calendar Widget is ready to be used in your wiev
echo $this->ciwy->yuiTags();
echo $this->ciwy->container('calendar');
echo $this->ciwy->generate();
If necessary you can change widget property using

Examples

Here is an example showing how you can create a calendar widget setting some properties.

$this->ciwy->load_widget('calendar');
$this->ciwy->calendar->setProperty(array('title', '<center>My calendar title</center>'));
$this->ciwy->calendar->set_config('title', 'My calendar title');
$this->ciwy->calendar->setProperty(array( // Set mindate, maxdate and selected date
'mindate' => date('m/d/Y', date('m').'/04/2010'),
'maxdate' => date('m/d/Y', date('m').'/29/2010'),
'selected' => date('m/d/Y', date('m').'/17/2010,'.date('m').'/20/2010,'.date('m').'/24/2010-'.date('m').'/27/2010')
)); echo $this->ciwy->yuiTags();
echo $this->ciwy->container('calendar');
echo $this->ciwy->generate();

$this->ciwy->calendar->container();

Returns HTML code for the calendar container.

echo $this->ciwy->calendar->container();
// Produces: <div id="calendar"></div>

$this->ciwy->calendar->create_istance();

Create a new calendar widget istance and return its name.
The function accept as optional parameter the name of the new istance, if exists an istance with the same name, the function will first generate a new istance name for you and then the new istance itself.

$this->ciwy->calendar->create_istance('cal1');

$this->ciwy->calendar->generate();

Return HTML code with JavaScript inside to render a calendar

<script type="text/javascript">
  YAHOO.namespace("example.calendar");
  YAHOO.example.calendar.init = function() {
    YAHOO.example.calendar.calendar_t = new YAHOO.widget.Calendar("calendar_t","calendar", {
      MD_DAY_POSITION:1,
      MD_MONTH_POSITION:2,
      MDY_DAY_POSITION:1,
      MDY_MONTH_POSITION:2,
      MDY_YEAR_POSITION:3,
      MY_MONTH_POSITION:1,
      MY_YEAR_POSITION:2,
      MY_LABEL_MONTH_POSITION:1,
      MY_LABEL_YEAR_POSITION:2,
      MONTHS_LONG:["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"],
      MONTHS_SHORT:["Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic"],
      WEEKDAYS_SHORT:["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa"],
      WEEKDAYS_MEDIUM:["Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"],
      WEEKDAYS_LONG:["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato"],
      WEEKDAYS_1CHAR:["D", "L", "M", "M", "G", "V", "S"],
      title:"<center>My calendar title</center>",
      mindate:"17/04/2010",
      maxdate:"25/04/2010",
      selected:"18/04/2010,22/04/2010-24/04/2010",
    });
    YAHOO.example.calendar.calendar_t.render();
  }
  YAHOO.util.Event.onDOMReady(YAHOO.example.calendar.init);
</script>

$this->ciwy->calendar->set_property();

Used to manually set YUI calendar widget property. The function will prevent to set invalid property name.

$property = array('title' => 'My Calendar title');
$this->ciwy->calendar->set_property($property);

$this->ciwy->calendar->set_navigatorProperty();

Used to manually set navigator property of YUI calendar widget. The function will prevent to set invalid property name.

$property = array('initialFocus' => 'year');
$this->ciwy->calendar->set_navigatorProperty($property);