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


PHP FabrikWorker::isReserved方法代码示例

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


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

示例1: save

 /**
  * Save a connection
  */
 function save()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('Invalid Token');
     jimport('joomla.utilities.date');
     $session =& JFactory::getSession();
     $user =& JFactory::getUser();
     $db =& JFactory::getDBO();
     $pluginManager =& JModel::getInstance('Pluginmanager', 'FabrikModel');
     $task = JRequest::getCmd('task');
     $id = JRequest::getInt('id', 0, 'post');
     $details = JRequest::getVar('details', array(), 'post', 'array');
     $className = $details['plugin'];
     $elementModel = $pluginManager->getPlugIn($className, 'element');
     $elementModel->setId($id);
     $row =& $elementModel->getElement();
     $origRow = clone $row;
     $this->_setSaveRedirect($task, $row->id);
     $name = JRequest::getVar('name', '', 'post', 'CMD');
     $name = str_replace('-', '_', $name);
     if (FabrikWorker::isReserved($name)) {
         return JError::raiseWarning(500, JText::_('SORRY THIS NAME IS RESERVED FOR FABRIK'));
     }
     if (JRequest::getInt('id') === 0) {
         //have to forcefully set group id otherwise tablemodel id is blank
         $elementModel->getElement()->group_id = $details['group_id'];
     }
     $tableModel =& $elementModel->getTableModel();
     //are we updating the name of the primary key element?
     if ($row->name === str_replace('`', '', $tableModel->_shortKey())) {
         if ($name !== $row->name) {
             //yes we are so update the table
             $table =& $tableModel->getTable();
             $table->db_primary_key = str_replace($row->name, $name, $table->db_primary_key);
             $table->store();
         }
     }
     //test for duplicate names
     //unlinking produces this error
     if (!JRequest::getVar('unlink', false)) {
         $row->group_id = (int) $details['group_id'];
         $db->setQuery("SELECT t.id, group_id FROM `#__fabrik_joins` AS j " . "\n LEFT JOIN #__fabrik_tables AS t " . "\n ON j.table_join = t.db_table_name " . "\n WHERE group_id = " . (int) $row->group_id . " AND element_id = 0");
         $res = $db->loadObject();
         if (is_null($res)) {
             // no join found
             if ($tableModel->fieldExists(JRequest::getVar('name'), array($id))) {
                 return JError::raiseWarning(500, JText::_('SORRY THIS NAME IS ALREADY IN USE'));
             }
         } else {
             $jointableModel =& JModel::getInstance('table', 'fabrikModel');
             $jointableModel->setId((int) $res->id);
             $joinEls = $jointableModel->getElements();
             $ignore = array($id);
             foreach ($joinEls as $joinEl) {
                 if ($joinEl->getElement()->name == JRequest::getVar('name')) {
                     $ignore[] = $joinEl->getElement()->id;
                 }
             }
             if ($jointableModel->fieldExists(JRequest::getVar('name'), $ignore)) {
                 JError::raiseNotice(500, JText::_('SORRY THIS NAME IS ALREADY IN USE'));
             }
         }
     }
     //end  duplicate name test
     $post = JRequest::get('post', 4);
     // $$$ hugh allows "safe" HTML.
     //$$$ rob default etc may require you to have \" or < recored - safe html filter removes these
     $raws = array('default', 'sub_values');
     foreach ($raws as $raw) {
         $post[$raw] = JRequest::getVar($raw, null, 'default', 'none', 2);
     }
     $tableParams =& $tableModel->getParams();
     //only update the element name if we can alter existing columns, otherwise the name and
     //field name become out of sync
     //if ($tableParams->get('alter_existing_db_cols') == 1 || $id == 0) {
     // $$$ hugh - check to see if there's actually a table
     if (empty($tableModel->_id) || ($tableModel->_canAlterFields() || $id == 0)) {
         $post['name'] = $name;
     } else {
         $post['name'] = JRequest::getVar('name_orig', '', 'post', 'cmd');
     }
     $ar = array('state', 'use_in_page_title', 'show_in_table_summary', 'link_to_detail', 'can_order', 'filter_exact_match');
     foreach ($ar as $a) {
         if (!array_key_exists($a, $post)) {
             $post[$a] = 0;
         }
     }
     // $$$ rob - test for change in element type
     //(eg if changing from db join to field we need to remove the join
     //entry from the #__fabrik_joins table
     $origElementModel =& JModel::getInstance('Element', 'FabrikModel');
     $origElementModel->setId($id);
     $origEl =& $origElementModel->getElement();
     $origElementPluginModel =& $pluginManager->getPlugIn($origEl->plugin, 'element');
     $origElementPluginModel->beforeSave($row);
     if (!$row->bind($post)) {
         return JError::raiseWarning(500, $row->getError());
//.........这里部分代码省略.........
开发者ID:nikshade,项目名称:fabrik21,代码行数:101,代码来源:element.php

示例2: validate

 /**
  * Method to validate the form data.
  *
  * @param	object		$form		The form to validate against.
  * @param	array		$data		The data to validate.
  * @return	mixed		Array of filtered data if valid, false otherwise.
  * @since	1.1
  */
 function validate($form, $data)
 {
     $ok = parent::validate($form, $data);
     //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);
     // validate name
     //$data['name'] = str_replace('-', '_', $data['name']);
     if (FabrikWorker::isReserved($data['name'])) {
         $this->setError(JText::_('COM_FABRIK_RESEVED_NAME_USED'));
     }
     $elementModel = $this->getElementPluginModel($data);
     $elementModel->getElement()->bind($data);
     if ($data['id'] === 0) {
         //have to forcefully set group id otherwise listmodel id is blank
         $elementModel->getElement()->group_id = $data['group_id'];
     }
     $listModel =& $elementModel->getListModel();
     //test for duplicate names
     //unlinking produces this error
     if (!JRequest::getVar('unlink', false) && (int) $data['id'] === 0) {
         $row->group_id = (int) $data['group_id'];
         $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 = {$row->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(JText::_('COM_FABRIK_ELEMENT_NAME_IN_USE'));
             }
         } else {
             $joinListModel = JModel::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(JText::_('COM_FABRIK_ELEMENT_NAME_IN_USE'));
             }
         }
     }
     //end  duplicate name test
     // $$$ rob commented out as on new elemetns db join was creating
     // join records pointing to an el id of 0
     // should consider makeing an $element->onValidate() or similar
     /*if (!$elementModel->onSave()) {
     		 $this->setError(JText::_('COM_FABRIK_ERROR_SAVING_ELEMENT_PLUGIN_OPTIONS'));
     	 }*/
     return count($this->getErrors()) == 0 ? $data : false;
 }
开发者ID:rhotog,项目名称:fabrik,代码行数:67,代码来源:element.php

示例3: 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::isReserved($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::isReserved($data['name'], false)) {
             $this->setError(FText::_('COM_FABRIK_RESERVED_NAME_USED'));
         }
     }
     $listModel = $elementModel->getListModel();
     /**
      * Test for duplicate names
      * unlinking produces this error
      */
     if (!$input->get('unlink', false) && (int) $data['id'] === 0) {
         $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 {
             $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:LGBGit,项目名称:tierno,代码行数:77,代码来源:element.php

示例4: getBottomContent

 /**
  * Sets up HTML to be injected into the form's bottom
  *
  * @param   object  $params     params
  * @param   object  $formModel  form model
  *
  * @return void
  */
 public function getBottomContent($params, $formModel)
 {
     // If we have already processed the form
     $this->html = '';
     if (JRequest::getVar('fabrik_confirmation') == 1) {
         $session = JFactory::getSession();
         // Unset this flag
         JRequest::setVar('fabrik_confirmation', 2);
         $post = JRequest::get('post', 4);
         /**
          * load in the posted values as hidden fields so that if we
          * return to the form to edit it it will populate with our data
          */
         // $$$ 24/10/2011 testing removing this as data is retrieved via the session not thorugh posted data
         foreach ($post as $key => $val) {
             $noneraw = JString::substr($key, 0, JString::strlen($key) - 4);
             if ($key == 'join' || $key == 'fabrik_vars') {
                 continue;
             }
             if ($formModel->hasElement($key) || $formModel->hasElement($noneraw)) {
                 // Return;
             }
             if ($formModel->hasElement($noneraw)) {
                 $key = $formModel->getElement($noneraw)->getHTMLName(0);
                 // $$$ rob include both raw and non-raw keys (non raw for radios etc, _raw for db joins)
                 if (is_array($val)) {
                     foreach ($val as $val2) {
                         if (!FabrikWorker::isReserved($key)) {
                             if (!strstr($key, '[]')) {
                                 $key .= '[]';
                             }
                             // $fields[] = '<input type="hidden" name="'.str_replace('_raw','',$key).'[]" value="'.urlencode($val2).'" />';
                             // $fields[] = '<input type="hidden" name="'.$key.'" value="'.urlencode($val2).'" />';
                             $fields[] = '<input type="hidden" name="' . $key . '" value="' . $val2 . '" />';
                         }
                     }
                 } else {
                     if (!FabrikWorker::isReserved($key)) {
                         // $fields[] = '<input type="hidden" name="'.str_replace('_raw','',$key).'" value="'.urlencode($val).'" />';
                         // $fields[] = '<input type="hidden" name="'.$key.'" value="'.urlencode($val).'" />';
                         $fields[] = '<input type="hidden" name="' . $key . '" value="' . $val . '" />';
                     }
                 }
             }
         }
         // Add in a view field as the form doesn't normally contain one
         $fields[] = '<input type="hidden" name="view" value="form" />';
         $fields[] = '<input type="hidden" name="fabrik_confirmation" value="2" />';
         // Add in a button to allow you to go back to the form and edit your data
         $fields[] = "<input type=\"button\" id=\"fabrik_redoconfirmation\" class=\"button\" value=\"" . JText::_('PLG_FORM_CONFIRMATION_RE_EDIT') . "\" />";
         // Unset the task otherwise we will submit the form to be processed.
         FabrikHelperHTML::addScriptDeclaration("head.ready(function() {" . "\$('fabrik_redoconfirmation').addEvent('click', function(e) {;\n" . "  this.form.task.value = '';\n" . "  this.form.submit.click();\n" . "\t});\n" . "});");
         $this->html = implode("\n", $fields);
     }
 }
开发者ID:rogeriocc,项目名称:fabrik,代码行数:63,代码来源:confirmation.php

示例5: getBottomContent

 /**
  * set up the html to be injected into the bottom of the form
  *
  * @param object $params (no repeat counter stuff needed here as the plugin manager
  * which calls this function has already done the work for you
  * @param object form model
  */
 function getBottomContent(&$params, $formModel)
 {
     //if we have already processed the form
     $this->html = '';
     if (JRequest::getVar('fabrik_confirmation') == 1) {
         //unset this flag
         JRequest::setVar('fabrik_confirmation', 2);
         $post = JRequest::get('post', 4);
         //load in the posted values as hidden fields so that if we
         //return to the form to edit it it will populate with our data
         foreach ($post as $key => $val) {
             // form data is stored in session
             $noneraw = substr($key, 0, strlen($key) - 4);
             if ($key == 'join' || $key == 'fabrik_vars' || $formModel->hasElement($key) || $formModel->hasElement($noneraw)) {
                 continue;
             }
             // $$$ rob include both raw and non-raw keys (non raw for radios etc, _raw for db joins)
             if (is_array($val)) {
                 foreach ($val as $val2) {
                     if (!FabrikWorker::isReserved($key)) {
                         $fields[] = '<input type="hidden" name="' . str_replace('_raw', '', $key) . '[]" value="' . urlencode($val2) . '" />';
                         $fields[] = '<input type="hidden" name="' . $key . '[]" value="' . urlencode($val2) . '" />';
                     }
                 }
             } else {
                 if (!FabrikWorker::isReserved($key)) {
                     $fields[] = '<input type="hidden" name="' . str_replace('_raw', '', $key) . '" value="' . urlencode($val) . '" />';
                     $fields[] = '<input type="hidden" name="' . $key . '" value="' . urlencode($val) . '" />';
                 }
             }
         }
         //add in a view field as the form doesn't normally contain one
         $fields[] = '<input type="hidden" name="view" value="form" />';
         //add in a button to allow you to go back to the form and edit your data
         $fields[] = "<input type=\"button\" id=\"fabrik_redoconfirmation\" class=\"button\" value=\"" . JText::_('PLG_FORM_CONFIRMATION_RE_EDIT') . "\" />";
         FabrikHelperHTML::addScriptDeclaration("head.ready(function() {" . "\$('fabrik_redoconfirmation').addEvent('click', function(e) {" . "  this.form.task.value = '';" . "  this.form.submit();" . "\t});" . "});");
         $this->html = implode("\n", $fields);
     }
 }
开发者ID:juliano-hallac,项目名称:fabrik,代码行数:46,代码来源:confirmation.php

示例6: getBottomContent

 /**
  * Sets up HTML to be injected into the form's bottom
  *
  * @return void
  */
 public function getBottomContent()
 {
     $formModel = $this->getModel();
     $input = $this->app->input;
     // If we have already processed the form
     $this->html = '';
     if ($input->getInt('fabrik_confirmation') === 1) {
         // Unset this flag
         $input->set('fabrik_confirmation', 2);
         $safeHtmlFilter = JFilterInput::getInstance(null, null, 1, 1);
         $post = $safeHtmlFilter->clean($_POST, 'array');
         /**
          * load in the posted values as hidden fields so that if we
          * return to the form to edit it it will populate with our data
          */
         // $$$ 24/10/2011 testing removing this as data is retrieved via the session not through posted data
         foreach ($post as $key => $val) {
             $noneRaw = JString::substr($key, 0, JString::strlen($key) - 4);
             if ($key == 'fabrik_vars') {
                 continue;
             }
             if ($formModel->hasElement($key) || $formModel->hasElement($noneRaw)) {
                 // Return;
             }
             if ($formModel->hasElement($noneRaw)) {
                 $key = $formModel->getElement($noneRaw)->getHTMLName(0);
                 // $$$ rob include both raw and non-raw keys (non raw for radios etc., _raw for db joins)
                 if (is_array($val)) {
                     foreach ($val as $val2) {
                         if (!FabrikWorker::isReserved($key)) {
                             if (!strstr($key, '[]')) {
                                 $key .= '[]';
                             }
                             // $fields[] = '<input type="hidden" name="'.str_replace('_raw','',$key).'[]" value="'.urlencode($val2).'" />';
                             // $fields[] = '<input type="hidden" name="'.$key.'" value="'.urlencode($val2).'" />';
                             $fields[] = '<input type="hidden" name="' . $key . '" value="' . $val2 . '" />';
                         }
                     }
                 } else {
                     if (!FabrikWorker::isReserved($key)) {
                         // $fields[] = '<input type="hidden" name="'.str_replace('_raw','',$key).'" value="'.urlencode($val).'" />';
                         // $fields[] = '<input type="hidden" name="'.$key.'" value="'.urlencode($val).'" />';
                         $fields[] = '<input type="hidden" name="' . $key . '" value="' . $val . '" />';
                     }
                 }
             }
         }
         // Add in a view field as the form doesn't normally contain one
         $fields[] = '<input type="hidden" name="view" value="form" />';
         $fields[] = '<input type="hidden" name="fabrik_confirmation" value="2" />';
         // Add in a button to allow you to go back to the form and edit your data
         $fields[] = "<input type=\"button\" id=\"fabrik_redoconfirmation\" class=\"button btn\" value=\"" . FText::_('PLG_FORM_CONFIRMATION_RE_EDIT') . "\" />";
         // Unset the task otherwise we will submit the form to be processed.
         FabrikHelperHTML::addScriptDeclaration("\n\t\t\t\twindow.addEvent('fabrik.loaded', function() {\n\t\t\t\t\t\$('fabrik_redoconfirmation').addEvent('click', function(e) {;\n\t\t\t\t\t\tthis.form.task.value = '';\n\t\t\t\t\t\t// this.form.submit();\n\t\t\t\t\t\tvar thisform = Fabrik.getBlock(this.form.id);\n\t\t\t\t\t\tthisform.doSubmit(new Event.Mock(thisform._getButton('Submit')), thisform._getButton('Submit'));\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t");
         $this->html = implode("\n", $fields);
     }
 }
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:62,代码来源:confirmation.php


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