コード例 #1
0
 public function search($record, $extended = false, $fieldprefix = '', DataGrid $grid = null)
 {
     $this->createDestination();
     if ($this->m_destinationFilter != '') {
         $sp = new StringParser($this->m_destinationFilter);
         $this->m_destInstance->addFilter($sp->parse($record));
     }
     $recordset = $this->m_destInstance->select()->includes(Tools::atk_array_merge($this->m_destInstance->descriptorFields(), $this->m_destInstance->m_primaryKey))->getAllRows();
     $result = '<select class="form-control" name="atksearch[' . $this->fieldName() . ']">';
     $result .= '<option value="">' . Tools::atktext('search_all', 'atk');
     $result .= $this->createdd($recordset);
     $result .= '</select>';
     return $result;
 }
コード例 #2
0
ファイル: ManyToOneRelation.php プロジェクト: sintattica/atk
 public function getSelectableRecordsSelector($record = [], $mode = '')
 {
     $this->createDestination();
     $selector = $this->createFilter($record, $mode);
     $result = $this->m_destInstance->select($selector)->orderBy($this->getDestination()->getOrder())->includes(Tools::atk_array_merge($this->m_destInstance->descriptorFields(), $this->m_destInstance->m_primaryKey));
     return $result;
 }
コード例 #3
0
ファイル: Node.php プロジェクト: sintattica/atk
 /**
  * Disable privilege checking for an action.
  *
  * This method disables privilege checks for the specified action, for the
  * duration of the current http request.
  *
  * @param string $action The name of the action for which security is
  *                       disabled.
  */
 public function addAllowedAction($action)
 {
     if (is_array($action)) {
         $this->m_unsecuredActions = Tools::atk_array_merge($this->m_unsecuredActions, $action);
     } else {
         $this->m_unsecuredActions[] = $action;
     }
 }
コード例 #4
0
ファイル: ManyToManyRelation.php プロジェクト: sintattica/atk
 /**
  * Returns a piece of html code that can be used in a form to search.
  *
  * @param array $record Array with values
  * @param bool $extended if set to false, a simple search input is
  *                            returned for use in the searchbar of the
  *                            recordlist. If set to true, a more extended
  *                            search may be returned for the 'extended'
  *                            search page. The Attribute does not
  *                            make a difference for $extended is true, but
  *                            derived attributes may reimplement this.
  * @param string $fieldprefix The fieldprefix of this attribute's HTML element.
  * @param DataGrid $grid
  *
  * @return string Piece of html code
  */
 public function search($record, $extended = false, $fieldprefix = '', DataGrid $grid = null)
 {
     $this->createDestination();
     $id = $this->getHtmlId($fieldprefix);
     $name = $this->getSearchFieldName($fieldprefix);
     $selectOptions = [];
     $selectOptions['enable-select2'] = true;
     $selectOptions['dropdown-auto-width'] = true;
     $selectOptions['minimum-results-for-search'] = 10;
     if ($extended) {
         $selectOptions['placeholder'] = Tools::atktext('search_all');
     }
     //width always auto
     $selectOptions['width'] = 'auto';
     $selectOptions = array_merge($selectOptions, $this->m_select2Options['search']);
     $data = '';
     foreach ($selectOptions as $k => $v) {
         $data .= ' data-' . $k . '="' . htmlspecialchars($v) . '"';
     }
     // now select all records
     $recordset = $this->m_destInstance->select()->includes(Tools::atk_array_merge($this->m_destInstance->descriptorFields(), $this->m_destInstance->m_primaryKey))->getAllRows();
     $result = '<select class="form-control"' . $data;
     if ($extended) {
         $result .= 'multiple="multiple" size="' . min(5, count($recordset) + 1) . '"';
     }
     $result .= 'id="' . $id . '" name="' . $name . '[]">';
     $pkfield = $this->m_destInstance->primaryKeyField();
     if (!$extended) {
         $result .= '<option value="">' . Tools::atktext('search_all', 'atk') . '</option>';
     }
     for ($i = 0; $i < count($recordset); ++$i) {
         $pk = $recordset[$i][$pkfield];
         if (!empty($record[$this->fieldName()]) && Tools::atk_in_array($pk, $record[$this->fieldName()])) {
             $sel = ' selected="selected"';
         } else {
             $sel = '';
         }
         $result .= '<option value="' . $pk . '"' . $sel . '>' . $this->m_destInstance->descriptor($recordset[$i]) . '</option>';
     }
     $result .= '</select>';
     $result .= "<script>ATK.enableSelect2ForSelect('#{$id}');</script>";
     return $result;
 }
コード例 #5
0
ファイル: AggregatedColumn.php プロジェクト: sintattica/atk
 public function addToQuery($query, $tablename = '', $fieldaliasprefix = '', &$record, $level = 0, $mode = '')
 {
     if ($mode !== 'add' && $mode != 'edit') {
         $allfields = Tools::atk_array_merge($this->m_displayfields, $this->m_searchfields);
         $alias = $fieldaliasprefix . $this->fieldName() . '_AE_';
         foreach ($allfields as $field) {
             /** @var Attribute $p_attrib */
             $p_attrib = $this->m_ownerInstance->m_attribList[$field];
             $p_attrib->addToQuery($query, $tablename, $alias, $record, $level, $mode);
         }
     }
 }