当前位置: 首页>>代码示例>>PHP>>正文


PHP Tools::decodeKeyValueSet方法代码示例

本文整理汇总了PHP中Sintattica\Atk\Core\Tools::decodeKeyValueSet方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::decodeKeyValueSet方法的具体用法?PHP Tools::decodeKeyValueSet怎么用?PHP Tools::decodeKeyValueSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sintattica\Atk\Core\Tools的用法示例。


在下文中一共展示了Tools::decodeKeyValueSet方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getContent

 /**
  * Get the content.
  *
  * @param array $record
  *
  * @return string The content
  */
 public function getContent($record)
 {
     $node = $this->m_node;
     $forceList = [];
     if (isset($node->m_postvars['atkfilter'])) {
         $forceList = Tools::decodeKeyValueSet($node->m_postvars['atkfilter']);
     }
     $suppressList = [];
     if (isset($node->m_postvars['atksuppress'])) {
         $suppressList = $node->m_postvars['atksuppress'];
     }
     $form = $this->editForm('edit', $record, $forceList, $suppressList, $node->getEditFieldPrefix());
     return $node->tabulate('edit', $form);
 }
开发者ID:sintattica,项目名称:atk,代码行数:21,代码来源:EditHandler.php

示例2: addToEditArray

 /**
  * Adds the attribute's edit / hide HTML code to the edit array.
  *
  * This method is called by the node if it wants the data needed to create
  * an edit form. The method is an override of Attribute's method,
  * because in the atkOneToOneRelation, we need to implement the
  * self::AF_ONETOONE_INTEGRATE feature.
  *
  * This is a framework method, it should never be called directly.
  *
  * @param string $mode the edit mode ("add" or "edit")
  * @param array $arr pointer to the edit array
  * @param array $defaults pointer to the default values array
  * @param array $error pointer to the error array
  * @param string $fieldprefix the fieldprefix
  */
 public function addToEditArray($mode, &$arr, &$defaults, &$error, $fieldprefix)
 {
     /* hide */
     if ($mode == 'edit' && $this->hasFlag(self::AF_HIDE_EDIT) || $mode == 'add' && $this->hasFlag(self::AF_HIDE_ADD)) {
         /* when adding, there's nothing to hide... */
         if ($mode == 'edit' || $mode == 'add' && !$this->isEmpty($defaults)) {
             $arr['hide'][] = $this->hide($defaults, $fieldprefix, $mode);
         }
     } else {
         /* we first check if there is no edit override method, if there
          * is this method has the same behaviour as the Attribute's method
          */
         if (method_exists($this->m_ownerInstance, $this->m_name . '_edit') || $this->edit($defaults, $fieldprefix, $mode) !== null) {
             self::addToEditArray($mode, $arr, $defaults, $error, $fieldprefix);
         } else {
             if (!$this->createDestination()) {
                 return;
             }
             $myrecord = null;
             /* readonly */
             if ($this->m_destInstance->hasFlag(Node::NF_READONLY) || $mode == 'edit' && $this->hasFlag(self::AF_READONLY_EDIT) || $mode == 'add' && $this->hasFlag(self::AF_READONLY_ADD)) {
                 $this->createDestination();
                 $attrNames = $this->m_destInstance->getAttributeNames();
                 foreach ($attrNames as $attrName) {
                     $attr = $this->m_destInstance->getAttribute($attrName);
                     $attr->addFlag(self::AF_READONLY);
                 }
             }
             /* we first check if the record doesn't already exist */
             if (isset($defaults[$this->fieldName()]) && !empty($defaults[$this->fieldName()])) {
                 /* record has no primarykey yet, so we must add instead of update */
                 $myrecord = $defaults[$this->fieldName()];
                 if (empty($myrecord[$this->m_destInstance->primaryKeyField()])) {
                     $mode = 'add';
                 } else {
                     $mode = 'edit';
                     $myrecord['atkprimkey'] = $this->m_destInstance->primaryKey($myrecord);
                 }
             } else {
                 $mode = 'add';
             }
             /* mode */
             $arr['hide'][] = '<input type="hidden" name="' . $fieldprefix . $this->fieldName() . '[mode]" value="' . $mode . '">';
             /* add fields */
             $forceList = Tools::decodeKeyValueSet($this->m_destinationFilter);
             if ($this->m_refKey != '') {
                 if ($this->destinationHasRelation()) {
                     $forceList[$this->m_refKey][$this->m_ownerInstance->primaryKeyField()] = $defaults[$this->m_ownerInstance->primaryKeyField()];
                 } else {
                     // its possible that the destination has no relation back. In that case the refKey is just an attribute
                     $forceList[$this->m_refKey] = $defaults[$this->m_ownerInstance->primaryKeyField()];
                 }
             }
             $a = $this->m_destInstance->editArray($mode, $myrecord, $forceList, [], $fieldprefix . $this->fieldName() . '_AE_', false, false);
             /* hidden fields */
             $arr['hide'] = array_merge($arr['hide'], $a['hide']);
             /* editable fields, if self::AF_NOLABEL is specified or if there is just 1 field with the
              * same name as the relation we don't display a label
              * TODO FIXME
              */
             if (!is_array($arr['fields'])) {
                 $arr['fields'] = [];
             }
             if (!$this->hasFlag(self::AF_ONETOONE_INTEGRATE) && !$this->hasFlag(self::AF_NOLABEL) && !(count($a['fields']) == 1 && $a['fields'][0]['name'] == $this->m_name)) {
                 /* separator and name */
                 if ($arr['fields'][count($arr['fields']) - 1]['html'] !== '-') {
                     $arr['fields'][] = array('html' => '-', 'tabs' => $this->m_tabs, 'sections' => $this->getSections());
                 }
                 $arr['fields'][] = array('line' => '<b>' . Tools::atktext($this->m_name, $this->m_ownerInstance->m_module, $this->m_ownerInstance->m_type) . '</b>', 'tabs' => $this->m_tabs, 'sections' => $this->getSections());
             }
             if (is_array($a['fields'])) {
                 // in non-integration mode we move all the fields to the one-to-one relations tabs/sections
                 if (!$this->hasFlag(self::AF_ONETOONE_INTEGRATE) || $this->hasFlag(self::AF_ONETOONE_RESPECT_TABS)) {
                     foreach (array_keys($a['fields']) as $key) {
                         $a['fields'][$key]['tabs'] = $this->m_tabs;
                         $a['fields'][$key]['sections'] = $this->getSections();
                     }
                 }
                 $arr['fields'] = array_merge($arr['fields'], $a['fields']);
             }
             if (!$this->hasFlag(self::AF_ONETOONE_INTEGRATE) && !$this->hasFlag(self::AF_NOLABEL) && !(count($a['fields']) == 1 && $a['fields'][0]['name'] == $this->m_name)) {
                 /* separator */
                 $arr['fields'][] = array('html' => '-', 'tabs' => $this->m_tabs, 'sections' => $this->getSections());
             }
//.........这里部分代码省略.........
开发者ID:sintattica,项目名称:atk,代码行数:101,代码来源:OneToOneRelation.php

示例3: filterToArray

 /**
  * Converts a record filter to a record array.
  *
  * @param string $filter filter string
  *
  * @return array record
  */
 protected function filterToArray($filter)
 {
     $result = [];
     $values = Tools::decodeKeyValueSet($filter);
     foreach ($values as $field => $value) {
         $parts = explode('.', $field);
         $ref =& $result;
         foreach ($parts as $part) {
             $ref =& $ref[$part];
         }
         $ref = $value;
     }
     return $result;
 }
开发者ID:sintattica,项目名称:atk,代码行数:21,代码来源:ManyToOneRelation.php

示例4: getCriteria

 /**
  * Translate the given selector to a criteria array
  * which key/values can be used to filter data.
  *
  * @param string $selector selector string
  *
  * @return array criteria
  */
 protected function getCriteria($selector)
 {
     $criteria = $this->m_filters;
     if (empty($selector)) {
         return $criteria;
     }
     $selectors = explode(') OR (', $selector);
     foreach ($selectors as $selector) {
         $keyValueSet = Tools::decodeKeyValueSet($selector);
         foreach ($keyValueSet as $column => $value) {
             $column = trim($column, ' ()');
             $value = trim($value, ' ()');
             if (strpos($column, '.') !== false) {
                 list($table, $column) = explode('.', $column);
                 if ($table != $this->getTable()) {
                     continue;
                 }
             }
             $value = stripslashes(Tools::stripQuotes($value));
             if (isset($criteria[$column]) && $criteria[$column] != $value) {
                 $criteria[$column] = array_merge((array) $criteria[$column], (array) $value);
             } else {
                 $criteria[$column] = $value;
             }
         }
     }
     return $criteria;
 }
开发者ID:sintattica,项目名称:atk,代码行数:36,代码来源:DataNode.php

示例5: createForceList

 /**
  * Based on information provided in the url (atkfilter), this function creates an array with
  * field values that are used as the initial values of a record in an add page.
  *
  * @return array Values of the newly created record.
  */
 public function createForceList()
 {
     $node = $this->m_node;
     $forceList = [];
     $filterList = isset($node->m_postvars['atkfilter']) ? Tools::decodeKeyValueSet($node->m_postvars['atkfilter']) : [];
     foreach ($filterList as $field => $value) {
         list($table, $column) = explode('.', $field);
         if ($column == null) {
             $forceList[$table] = $value;
         } else {
             if ($table == $this->getNode()->getTable()) {
                 $forceList[$column] = $value;
             } else {
                 $forceList[$table][$column] = $value;
             }
         }
     }
     return $forceList;
 }
开发者ID:sintattica,项目名称:atk,代码行数:25,代码来源:AddHandler.php


注:本文中的Sintattica\Atk\Core\Tools::decodeKeyValueSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。