/** * @param array $array * @return P4A_Array_Source */ public function load(array $array) { $this->_array = array(); $this->_array[-1] = array(); if (empty($array)) { return; } $first_row = $array[0]; if (!is_array($first_row)) { foreach ($array as $value) { $this->_array[] = array('f0' => $value); } $this->setPK('f0'); $first_row = array('f0' => $first_row); } else { foreach ($array as $value) { $this->_array[] = $value; } } foreach ($first_row as $field_name => $value) { if (!isset($this->fields->{$field_name})) { $this->fields->build('P4A_Data_Field', $field_name); } $this->_array[-1][$field_name] = ''; } return $this; }
/** * Builds a new page inside the pane * @return P4A_Frame */ public function addPage($page_name, $label = null) { $this->pages->build('p4a_frame', $page_name); if ($label !== null) { $this->pages->{$page_name}->setLabel($label); } return $this->pages->{$page_name}; }
/** * Associates a data source with the mask. * Also set the data structure to allow correct widget rendering. * Also moves to the first row of the data source. * @param P4A_Data_Source $data_source * @return P4A_Collection the fields collection */ public function setSource($data_source) { $this->data = $data_source; while ($field = $this->data->fields->nextItem()) { $field_name = $field->getName(); $this->fields->build(P4A_FIELD_CLASS, $field_name, false); $this->fields->{$field_name}->setDataField($field); } return $this->fields; }
/** * @return P4A_Field */ protected function buildDeletePreviewDownloadButtons() { if (!isset($this->buttons->button_file_delete)) { $this->buttons->build("p4a_button", "button_file_delete")->setLabel('Delete')->addAjaxAction('onclick')->implement('onclick', $this, 'fileDeleteOnClick'); } if (!isset($this->buttons->button_file_preview)) { $this->buttons->build("p4a_button", "button_file_preview")->setLabel('Preview')->implement('onclick', $this, 'filePreviewOnClick'); } if (!isset($this->buttons->button_file_download)) { $this->buttons->build("p4a_button", "button_file_download")->setLabel('Download')->implement('onclick', $this, 'fileDownloadOnClick'); } return $this; }
/** * Adds an element to the element * @param string $name Mnemonic identifier for the element * @param string $label * @return P4A_Menu_Item */ public function addItem($name, $label = null) { $item = $this->items->build("P4A_Menu_Item", $name); if ($label !== null) { $item->setLabel($label); } return $item; }
/** * @param string $button_name * @param string $icon * @param string $float * @return P4A_Button */ public function addButton($button_name, $icon = null, $float = "left") { $button = $this->buttons->build("p4a_button", $button_name); $button->addAjaxAction('onclick'); if (strlen($icon) > 0) { $button->setIcon($icon); $button->setSize(self::height); } $anchor = "anchor" . $float; $this->{$anchor}($button, "2px"); return $button; }