示例#1
0
 public function __construct($name)
 {
     parent::__construct($name);
     $this->fields->build('P4A_Data_Field', 'filename');
     $this->fields->build('P4A_Data_Field', 'size')->setType("filesize");
     $this->fields->build('P4A_Data_Field', 'last_modified')->setType("date");
     $this->setPk('filename');
 }
示例#2
0
文件: field.php 项目: eliudiaz/p4a
 /**
  * Returns the HTML rendered field as radio buttons group
  * @return string
  */
 public function getAsRadio()
 {
     $id = $this->getId();
     $properties = $this->composeStringProperties();
     $external_data = $this->data->getAll();
     $value_field = $this->getSourceValueField();
     $description_field = $this->getSourceDescriptionField();
     $new_value = $this->getNewValue();
     $sContent = "";
     $enabled = '';
     if (!$this->isEnabled()) {
         $enabled = 'disabled="disabled" ';
     }
     if ($this->isNullAllowed()) {
         if ($this->null_message === null) {
             $message = 'none_selected';
         } else {
             $message = $this->null_message;
         }
         array_unshift($external_data, array($value_field => '', $description_field => __($message)));
     }
     foreach ($external_data as $key => $current) {
         if ($current[$value_field] == $new_value) {
             $checked = "checked='checked'";
         } else {
             $checked = "";
         }
         $input = "<input {$enabled} name='{$id}' id='{$id}_{$key}input' type='radio' " . $this->composeStringActions() . " {$checked} value='" . htmlspecialchars($current[$value_field]) . "'/>";
         if ($this->isFormatted()) {
             $label = $this->format($current[$description_field], $this->data->fields->{$description_field}->getType(), $this->data->fields->{$description_field}->getNumOfDecimals());
         } else {
             $label = $current[$description_field];
         }
         $sContent .= P4A_Generate_Widget_Layout_Table($input, "<label for='{$id}_{$key}input'>{$label}</label>");
     }
     $this->label->unsetProperty('for');
     $return = $this->composeLabel() . "<div class='p4a_field_radio_values' {$properties}>{$sContent}</div>";
     $this->label->setProperty('for', "{$id}input");
     return $return;
 }
示例#3
0
 public function deleteRow()
 {
     $pointer = $this->getRowNumber();
     unset($this->_array[$pointer - 1]);
     parent::deleteRow();
 }
示例#4
0
 /**
  * Removes the row from the database
  */
 public function deleteRow()
 {
     if (!$this->isNew() and !$this->isReadOnly()) {
         $db = P4A_DB::singleton($this->getDSN());
         $table = $this->getTable();
         $schema = $this->getSchema();
         $pks = $this->getPK();
         foreach ($this->_multivalue_fields as $fieldname => $aField) {
             $pk_value = $this->fields->{$pks}->getNewValue();
             $fk_table = ($schema ? "{$schema}." : "") . $aField["table"];
             $fk = $aField["fk"];
             $db->adapter->query("DELETE FROM {$fk_table} WHERE {$fk}=?", array($pk_value));
         }
         $table = new P4A_Db_Table(array('name' => $this->getTable(), 'schema' => $this->getSchema(), 'db' => $db->adapter));
         $table->delete($this->_composePkString());
         $this->resetNumRows();
     }
     parent::deleteRow();
 }
示例#5
0
文件: mask.php 项目: eliudiaz/p4a
 /**
  * Moves to the first row
  * @return P4A_Mask
  */
 public function firstRow()
 {
     $this->data->firstRow();
     return $this;
 }
示例#6
0
文件: table.php 项目: eliudiaz/p4a
 /**
  * Translate the value with the description
  * @param string $value The value to translate
  * @return string
  */
 public function getDescription($value)
 {
     if (!$this->data) {
         return $value;
     } else {
         $row = $this->data->getPkRow($value);
         if (is_array($row)) {
             if (isset($row[$this->data_description_field])) {
                 return $row[$this->data_description_field];
             } else {
                 return null;
             }
         } else {
             return $value;
         }
     }
 }