/** * Construct the widget * * @access private */ function buildXHTML() { $colorpicker = PIWI_URL . 'piwidata/js/colorpicker/ColorPicker2.js'; $popup = PIWI_URL . 'piwidata/js/colorpicker/PopupWindow.js'; $anchor = PIWI_URL . 'piwidata/js/colorpicker/AnchorPosition.js'; $this->addFile($colorpicker); $this->addFile($popup); $this->addFile($anchor); $pickerName = $this->_id . '_colorpicker'; $this->_XHTML = "<script type=\"text/javascript\">\n"; $this->_XHTML .= "var " . $pickerName . "_properties = [];\n"; $this->_XHTML .= $pickerName . "_properties['windowname'] = '" . $this->_popupName . "';\n"; $this->_XHTML .= $pickerName . "_properties['fontStyle'] = '" . $this->_colorFontStyle . "';\n"; $this->_XHTML .= $pickerName . "_properties['fieldID'] = '" . $this->_entry->getID() . "';\n"; if (!empty($this->_onSelectEvent)) { $this->_onSelectEvent = " " . $this->_onSelectEvent . " "; } $this->_XHTML .= $pickerName . "_properties['onselect'] = '" . $this->_onSelectEvent . "';\n"; if ($this->_usePopup) { $this->_XHTML .= "var " . $pickerName . " = new ColorPicker('window'," . $pickerName . "_properties);\n"; } else { $this->_XHTML .= "var " . $pickerName . " = new ColorPicker(''," . $pickerName . "_properties);\n"; } $this->_XHTML .= "</script>\n"; $this->_button->addEvent(ON_CLICK, $pickerName . ".select(document.getElementById('" . $this->_entry->getID() . "'), " . "'" . $pickerName . "_ahref'); return false;"); if (!empty($this->_onSelectEvent)) { $this->_entry->addEvent(ON_CHANGE, $this->_onSelectEvent); } if ($this->_hideInput) { $this->_entry->setType("hidden"); } $this->_XHTML .= "<table border=\"0\" style=\"border-spacing: 0px; padding: 0px; border: 0px;\">\n"; $this->_XHTML .= " <tr>\n"; $this->_XHTML .= " <td>\n"; $this->_XHTML .= "<script type=\"text/javascript\">\n"; $this->_XHTML .= "function ExecutePingBackOf" . $this->_entry->getID() . "() {\n"; $this->_XHTML .= " " . $this->_onSelectEvent . "\n"; $this->_XHTML .= "}\n"; $this->_XHTML .= "</script>\n"; $this->_XHTML .= $this->_entry->get(); $this->_XHTML .= " </td>\n"; $this->_XHTML .= " <td>\n"; $this->_XHTML .= "<a id=\"" . $pickerName . "_ahref\"></a>\n"; $this->_XHTML .= $this->_button->get(); $this->_XHTML .= "<script type=\"text/javascript\">\n"; $this->_XHTML .= $pickerName . ".writeDiv();\n"; $this->_XHTML .= "</script>\n"; $this->_XHTML .= " </td>\n"; $this->_XHTML .= " </tr>\n"; $this->_XHTML .= "</table>"; }
function DataGridCapture($numrows, $numcolumns, $titles, $gadget, $action, $entry_type, $caption = '', $id = '') { $this->_name = 'datagridcapture'; $this->_class = 'datagrid'; $this->_columns = array(); $this->_caption = $caption; $this->_actionColumns = array(); $this->_data = array(); if (empty($id)) { $this->_id = 'datagridcapture_' . rand(1, 100); } else { $this->_id = $id; } /*if (is_array($data)) { $this->_data = $data; } else { die("beh!"); } */ $this->setOddColor('#eee'); $this->setEvenColor('#fff'); for ($id = 0; $id < $numrows; $id++) { $idtext = $this->_id . '_' . $id; $keyField1 = new Entry('name_' . $idtext, str_replace('"', '"', '')); #$keyField->setStyle('background: transparent;border-style: solid; border: 10px;'); $keyField1->setStyle('border-style: solid; border: 10px;'); $keyField1->setEnabled(true); $keyField1->setSize(30); $data[$id]['key'] = $keyField1->get(); $keyField2 = new Entry('value_' . $idtext, str_replace('"', '"', '')); $keyField2->setStyle('background: transparent; border: 1px;'); $keyField2->setEnabled(true); $keyField2->setSize(30); $data[$id]['value'] = $keyField2->get(); $data[$id]['action'] = '<a OnClick="javascript: if(confirm(\'Are this values correct?\')) { window.location=\'?gadget=' . $gadget . '&action=' . $action . '&id=' . $id . '&key=\'+document.getElementById(\'' . $keyField1->getID() . '\').value+\'&value=\'+document.getElementById(\'' . $keyField2->getID() . '\').value+\'&entry_type=' . $entry_type . '\';}"><img id="imgcat' . $id . '" src="images/stock/save.png" border="0" alt="" /></a>'; } parent::init(); foreach ($titles as $t) { $this->addColumn(new Column(_("{$t}"), "{$t}", true)); } $this->addData($data); }
/** * Construct the widget * * @access public */ function buildXHTML() { $this->_buildXHTML(); if ($this->_includeCSS) { $theme = PIWI_URL . 'piwidata/js/jscalendar/calendar-' . $this->_theme . '.css'; $this->addFile($theme); } if ($this->_includeJS) { //add the js file! if ($this->_calType != 'gregorian') { $this->addFile(PIWI_URL . 'piwidata/js/jscalendar/' . $this->_calType . '.js'); } $this->addFile(PIWI_URL . 'piwidata/js/jscalendar/calendar.js'); $this->addFile(PIWI_URL . 'piwidata/js/jscalendar/calendar-setup.js'); $this->addFile($this->_langFile); } $this->_XHTML .= "<script type=\"text/javascript\">\n"; if ($this->_selectMultipleDates) { $dateVar = "dateOf" . $this->_tableID . '_' . rand(); $this->_XHTML .= " var multipleDates_" . $this->_tableID . " = [];\n"; if (count($this->_selectedDates) > 0) { $this->_XHTML .= " var selectedDates_" . $this->_tableID . " = new Array(" . count($this->_selectedDates) . ");\n"; $this->_XHTML .= "var datehandler = new Date();\n"; $i = 0; foreach ($this->_selectedDates as $date) { list($year, $month, $day) = preg_split('/-/', $date); if (isset($month)) { //Damn javascript, it thinks that 04 is May and not april.. $month = (int) $month; $month = $month - 1; $this->_XHTML .= " selectedDates_" . $this->_tableID . "[" . $i . "] = new Date(" . $year . "," . $month . "," . $day . ");\n"; $i++; } } $this->_XHTML .= "\n"; $this->_XHTML .= " multipleDates_" . $this->_tableID . " = selectedDates_" . $this->_tableID . ";\n"; } $this->_XHTML .= " function updateMultipleDatesIn" . $this->_tableID . "(calendar) {\n"; $this->_XHTML .= " multipleDates_" . $this->_tableID . ".length = 0;\n"; $this->_XHTML .= " for (var i in calendar.multiple) {\n"; $this->_XHTML .= " var " . $dateVar . " = calendar.multiple[i];\n"; $this->_XHTML .= " if (" . $dateVar . ") {\n"; $this->_XHTML .= " multipleDates_" . $this->_tableID . "[multipleDates_" . $this->_tableID . ".length] = " . $dateVar . ";\n"; $this->_XHTML .= " }\n"; $this->_XHTML .= " }\n"; $this->_XHTML .= " calendar.hide();\n"; $this->_XHTML .= " return true;\n"; $this->_XHTML .= " }\n"; } $this->_XHTML .= " Calendar.setup({\n"; $this->_XHTML .= " inputField: \"" . $this->_entry->getID() . "\",\n"; $this->_XHTML .= " ifFormat: \"" . $this->_dateFormat . "\",\n"; $this->_XHTML .= " dateType: \"" . $this->_calType . "\",\n"; $this->_XHTML .= " button: \"" . $this->_button->getID() . "\",\n"; $this->_XHTML .= " singleClick: true,\n"; if ($this->_showWeekNumbers) { $this->_XHTML .= " weekNumbers: true,\n"; } else { $this->_XHTML .= " weekNumbers: false,\n"; } if (!is_null($this->_firstDay)) { $this->_XHTML .= " firstDay: " . $this->_firstDay . ",\n"; } if (!empty($this->_initDate) || !empty($this->_value)) { if (empty($this->_initDate)) { $this->_XHTML .= " date: \"" . $this->_value . "\",\n"; } else { $this->_XHTML .= " date: \"" . $this->_initDate . "\",\n"; } } if ($this->_showTimePicker) { $this->_XHTML .= " showsTime: true,\n"; } else { $this->_XHTML .= " showsTime: false,\n"; } if ($this->_selectMultipleDates) { $this->_XHTML .= " onClose: updateMultipleDatesIn" . $this->_tableID; if (!empty($this->_onCloseEvent)) { $this->_XHTML .= ", " . $this->onCloseEvent . ",\n"; } else { $this->_XHTML .= ",\n"; } $this->_XHTML .= " multiple: multipleDates_" . $this->_tableID . ",\n"; } else { $this->_XHTML .= " multiple: false,\n"; } if (!empty($this->_onUpdateEvent)) { $this->_XHTML .= " onUpdate: " . $this->_onUpdateEvent . ",\n"; } if (!empty($this->_onSelectEvent)) { $this->_XHTML .= " onSelect: " . $this->_onSelectEvent . ",\n"; } if (!empty($this->_onCloseEvent) && !$this->_selectMultipleDates) { $this->_XHTML .= " onClose: " . $this->_onCloseEvent . "\n"; } if (substr($this->_XHTML, -2) == ",\n") { $this->_XHTML = substr($this->_XHTML, 0, -2); } $this->_XHTML .= "});\n"; $this->_XHTML .= "</script>\n"; }