Пример #1
0
 /**
  * Creates the inline editor
  */
 protected function inline_editor()
 {
     // silently fail when editing not possible
     if (!$this->initFromInput()) {
         return;
     }
     if (auth_quickaclcheck($this->pid) < AUTH_EDIT) {
         return;
     }
     if (!$this->schemadata->getSchema()->isEditable()) {
         return;
     }
     if (checklock($this->pid)) {
         return;
     }
     // lock page
     lock($this->pid);
     // output the editor
     $value = $this->schemadata->getDataColumn($this->column);
     echo '<label data-column="' . hsc($this->column->getFullQualifiedLabel()) . '">';
     echo $value->getValueEditor('entry');
     echo '</label>';
     $hint = $this->column->getType()->getTranslatedHint();
     if ($hint) {
         echo '<div class="hint">';
         echo hsc($hint);
         echo '</div>';
     }
     // csrf protection
     formSecurityToken();
 }
Пример #2
0
 /**
  * Sort by lookup table
  *
  * @param QueryBuilder $QB
  * @param string $tablealias
  * @param string $colname
  * @param string $order
  */
 public function sort(QueryBuilder $QB, $tablealias, $colname, $order)
 {
     if (!$this->usesLookup()) {
         parent::sort($QB, $tablealias, $colname, $order);
         return;
     }
     $schema = 'data_' . $this->schema->getTable();
     $field = $this->column->getColName();
     $rightalias = $QB->generateTableAlias();
     $QB->addLeftJoin($tablealias, $schema, $rightalias, "{$tablealias}.{$colname} = {$rightalias}.pid");
     $this->column->getType()->sort($QB, $rightalias, $field, $order);
 }
 /**
  * Validate a single value
  *
  * @param Column $col the column of that value
  * @param mixed &$rawvalue the value, will be fixed according to the type
  * @return bool
  */
 public function validateValue(Column $col, &$rawvalue)
 {
     // fix multi value types
     $type = $col->getType();
     $trans = $type->getTranslatedLabel();
     if ($type->isMulti() && !is_array($rawvalue)) {
         $rawvalue = $type->splitValues($rawvalue);
     }
     // strip empty fields from multi vals
     if (is_array($rawvalue)) {
         $rawvalue = array_filter($rawvalue, array($this, 'filter'));
         $rawvalue = array_values($rawvalue);
         // reset the array keys
     }
     // validate data
     return $this->validateField($type, $trans, $rawvalue);
 }
 /**
  * Returns the HTML to edit a single column definition of the schema
  *
  * @param string $column_id
  * @param Column $col
  * @param string $key The key to use in the form
  * @return string
  * @todo this should probably be reused for adding new columns via AJAX later?
  */
 protected function adminColumn($column_id, Column $col, $key = 'cols')
 {
     $base = 'schema[' . $key . '][' . $column_id . ']';
     // base name for all fields
     $class = $col->isEnabled() ? '' : 'disabled';
     $html = "<tr class=\"{$class}\">";
     $html .= '<td class="sort">';
     $html .= '<input type="text" name="' . $base . '[sort]" value="' . hsc($col->getSort()) . '" size="3">';
     $html .= '</td>';
     $html .= '<td class="label">';
     $html .= '<input type="text" name="' . $base . '[label]" value="' . hsc($col->getType()->getLabel()) . '">';
     $html .= '</td>';
     $html .= '<td class="ismulti">';
     $checked = $col->getType()->isMulti() ? 'checked="checked"' : '';
     $html .= '<input type="checkbox" name="' . $base . '[ismulti]" value="1" ' . $checked . '>';
     $html .= '</td>';
     $html .= '<td class="config">';
     $config = json_encode($col->getType()->getConfig(), JSON_PRETTY_PRINT);
     $html .= '<textarea name="' . $base . '[config]" cols="45" rows="10" class="config">' . hsc($config) . '</textarea>';
     $html .= '</td>';
     $types = Column::allTypes();
     $html .= '<td class="class">';
     $html .= '<select name="' . $base . '[class]">';
     foreach ($types as $type) {
         $selected = $col->getType()->getClass() == $type ? 'selected="selected"' : '';
         $html .= '<option value="' . hsc($type) . '" ' . $selected . '>' . hsc($type) . '</option>';
     }
     $html .= '</select>';
     $html .= '</td>';
     $html .= '<td class="isenabled">';
     $checked = $col->isEnabled() ? 'checked="checked"' : '';
     $html .= '<input type="checkbox" name="' . $base . '[isenabled]" value="1" ' . $checked . '>';
     $html .= '</td>';
     $html .= '</tr>';
     return $html;
 }