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


PHP FabrikWorker::validElementName方法代码示例

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


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

示例1: validate

 /**
  * Method to validate the form data.
  *
  * @param   JForm  $form  The form to validate against.
  * @param   array  $data  The data to validate.
  * @param   string $group The name of the field group to validate.
  *
  * @see     JFormRule
  * @see     JFilterInput
  *
  * @return  mixed  Array of filtered data if valid, false otherwise.
  */
 public function validate($form, $data, $group = null)
 {
     $ok = parent::validate($form, $data);
     $input = $this->app->input;
     // Standard jForm validation failed so we shouldn't test further as we can't be sure of the data
     if (!$ok) {
         return false;
     }
     $db = FabrikWorker::getDbo(true);
     $elementModel = $this->getElementPluginModel($data);
     $nameChanged = $data['name'] !== $elementModel->getElement()->name;
     $elementModel->getElement()->bind($data);
     $listModel = $elementModel->getListModel();
     if ($data['id'] == '') {
         // Have to forcefully set group id otherwise listmodel id is blank
         $elementModel->getElement()->group_id = $data['group_id'];
         if ($listModel->canAddFields() === false && $listModel->noTable() === false) {
             $this->setError(FText::_('COM_FABRIK_ERR_CANT_ADD_FIELDS'));
         }
         if (!FabrikWorker::validElementName($data['name'])) {
             $this->setError(FText::_('COM_FABRIK_RESERVED_NAME_USED'));
         }
     } else {
         if ($listModel->canAlterFields() === false && $nameChanged && $listModel->noTable() === false) {
             $this->setError(FText::_('COM_FABRIK_ERR_CANT_ALTER_EXISTING_FIELDS'));
         }
         if ($nameChanged && !FabrikWorker::validElementName($data['name'], false)) {
             $this->setError(FText::_('COM_FABRIK_RESERVED_NAME_USED'));
         }
     }
     $listModel = $elementModel->getListModel();
     /**
      * Test for duplicate names
      * un-linking produces this error
      */
     if (!$input->get('unlink', false) && (int) $data['id'] === 0) {
         /**
          * @FIXME - if a repeat group is  created through the Group settings, we don't add the auto-created
          * table to the #_fabrik_lists table, so the following query obviously doesn't find it ... so we
          * barf when creating element in the repeat group with a "duplicate name", even though it's going
          * to be on a separate table.
          */
         $query = $db->getQuery(true);
         $query->select('t.id')->from('#__{package}_joins AS j');
         $query->join('INNER', '#__{package}_lists AS t ON j.table_join = t.db_table_name');
         $query->where('group_id = ' . (int) $data['group_id'] . ' AND element_id = 0');
         $db->setQuery($query);
         $joinTblId = (int) $db->loadResult();
         $ignore = array($data['id']);
         if ($joinTblId === 0) {
             if ($listModel->fieldExists($data['name'], $ignore)) {
                 $this->setError(FText::_('COM_FABRIK_ELEMENT_NAME_IN_USE'));
             }
         } else {
             /** @var FabrikFEModelList $joinListModel */
             $joinListModel = JModelLegacy::getInstance('list', 'FabrikFEModel');
             $joinListModel->setId($joinTblId);
             $joinEls = $joinListModel->getElements();
             foreach ($joinEls as $joinEl) {
                 if ($joinEl->getElement()->name == $data['name']) {
                     $ignore[] = $joinEl->getElement()->id;
                 }
             }
             if ($joinListModel->fieldExists($data['name'], $ignore)) {
                 $this->setError(FText::_('COM_FABRIK_ELEMENT_NAME_IN_USE'));
             }
         }
     }
     // Strip <p> tag from label
     $data['label'] = JString::str_ireplace(array('<p>', '</p>'), '', $data['label']);
     return count($this->getErrors()) == 0 ? $data : false;
 }
开发者ID:glauberm,项目名称:cinevi,代码行数:84,代码来源:element.php


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