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


PHP FieldManager::delete方法代码示例

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


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

示例1: delete

 public function delete($section_id)
 {
     $query = "SELECT `id`, `sortorder` FROM tbl_sections WHERE `id` = '{$section_id}'";
     $details = Symphony::Database()->fetchRow(0, $query);
     ## Delete all the entries
     include_once TOOLKIT . '/class.entrymanager.php';
     $entryManager = new EntryManager($this->_Parent);
     $entries = Symphony::Database()->fetchCol('id', "SELECT `id` FROM `tbl_entries` WHERE `section_id` = '{$section_id}'");
     $entryManager->delete($entries);
     ## Delete all the fields
     $fieldManager = new FieldManager($this->_Parent);
     $fields = Symphony::Database()->fetchCol('id', "SELECT `id` FROM `tbl_fields` WHERE `parent_section` = '{$section_id}'");
     if (is_array($fields) && !empty($fields)) {
         foreach ($fields as $field_id) {
             $fieldManager->delete($field_id);
         }
     }
     ## Delete the section
     Symphony::Database()->delete('tbl_sections', " `id` = '{$section_id}'");
     ## Update the sort orders
     Symphony::Database()->query("UPDATE tbl_sections SET `sortorder` = (`sortorder` - 1) WHERE `sortorder` > '" . $details['sortorder'] . "'");
     ## Delete the section associations
     Symphony::Database()->delete('tbl_sections_association', " `parent_section_id` = '{$section_id}'");
     return true;
 }
开发者ID:aaronsalmon,项目名称:symphony-2,代码行数:25,代码来源:class.sectionmanager.php

示例2: delete

 /**
  * Deletes a Section by Section ID, removing all entries, fields, the
  * Section and any Section Associations in that order
  *
  * @param integer $section_id
  *    The ID of the Section to delete
  * @throws DatabaseException
  * @throws Exception
  * @return boolean
  *    Returns true when completed
  */
 public static function delete($section_id)
 {
     $details = Symphony::Database()->fetchRow(0, sprintf("\n            SELECT `sortorder` FROM tbl_sections WHERE `id` = %d", $section_id));
     // Delete all the entries
     include_once TOOLKIT . '/class.entrymanager.php';
     $entries = Symphony::Database()->fetchCol('id', "SELECT `id` FROM `tbl_entries` WHERE `section_id` = '{$section_id}'");
     EntryManager::delete($entries);
     // Delete all the fields
     $fields = FieldManager::fetch(null, $section_id);
     if (is_array($fields) && !empty($fields)) {
         foreach ($fields as $field) {
             FieldManager::delete($field->get('id'));
         }
     }
     // Delete the section
     Symphony::Database()->delete('tbl_sections', sprintf("\n            `id` = %d", $section_id));
     // Update the sort orders
     Symphony::Database()->query(sprintf("\n            UPDATE tbl_sections\n            SET `sortorder` = (`sortorder` - 1)\n            WHERE `sortorder` > %d", $details['sortorder']));
     // Delete the section associations
     Symphony::Database()->delete('tbl_sections_association', sprintf("\n            `parent_section_id` = %d", $section_id));
     return true;
 }
开发者ID:jurajkapsz,项目名称:symphony-2,代码行数:33,代码来源:class.sectionmanager.php

示例3: __actionEdit

 public function __actionEdit()
 {
     if (@array_key_exists('save', $_POST['action']) || @array_key_exists('done', $_POST['action'])) {
         $canProceed = true;
         $fields = $_POST['fields'];
         $meta = $_POST['meta'];
         $section_id = $this->_context[1];
         $sectionManager = new SectionManager($this->_Parent);
         $existing_section = $sectionManager->fetch($section_id);
         $fieldManager = new FieldManager($this->_Parent);
         $this->_errors = array();
         ## Check to ensure all the required section fields are filled
         if (!isset($meta['name']) || trim($meta['name']) == '') {
             $required = array('Name');
             $this->_errors['name'] = __('This is a required field.');
             $canProceed = false;
         } elseif ($meta['name'] != $existing_section->get('name') && Symphony::Database()->fetchRow(0, "SELECT * FROM `tbl_sections` WHERE `name` = '" . $meta['name'] . "' AND `id` != {$section_id} LIMIT 1")) {
             $this->_errors['name'] = __('A Section with the name <code>%s</code> name already exists', array($meta['name']));
             $canProceed = false;
         }
         ## Check to ensure all the required section fields are filled
         if (!isset($meta['navigation_group']) || strlen(trim($meta['navigation_group'])) == 0) {
             $required = array('Navigation Group');
             $this->_errors['navigation_group'] = __('This is a required field.');
             $canProceed = false;
         } elseif (is_array($fields) && !empty($fields)) {
             ## Check for duplicate CF names
             if ($canProceed) {
                 $name_list = array();
                 foreach ($fields as $position => $data) {
                     if (trim($data['element_name']) == '') {
                         $data['element_name'] = $fields[$position]['element_name'] = Lang::createHandle($data['label'], NULL, '-', false, true, array('@^[\\d-]+@i' => ''));
                     }
                     if (trim($data['element_name']) != '' && in_array($data['element_name'], $name_list)) {
                         $this->_errors[$position] = array('label' => __('Two custom fields have the same element name. All element names must be unique.'));
                         $canProceed = false;
                         break;
                     }
                     $name_list[] = $data['element_name'];
                 }
             }
             if ($canProceed) {
                 $fieldManager = new FieldManager($this->_Parent);
                 $unique = array();
                 foreach ($fields as $position => $data) {
                     $required = NULL;
                     $field = $fieldManager->create($data['type']);
                     $field->setFromPOST($data);
                     if ($field->mustBeUnique() && !in_array($field->get('type'), $unique)) {
                         $unique[] = $field->get('type');
                     } elseif ($field->mustBeUnique() && in_array($field->get('type'), $unique)) {
                         ## Warning. cannot have 2 of this field!
                         $canProceed = false;
                         $this->_errors[$position] = array('label' => __('There is already a field of type <code>%s</code>. There can only be one per section.', array($field->name())));
                     }
                     $errors = array();
                     if (Field::__OK__ != $field->checkFields($errors, false, false) && !empty($errors)) {
                         $this->_errors[$position] = $errors;
                         $canProceed = false;
                         break;
                     }
                 }
             }
         }
         if ($canProceed) {
             $meta['handle'] = Lang::createHandle($meta['name']);
             $meta['hidden'] = isset($meta['hidden']) ? 'yes' : 'no';
             if (!$sectionManager->edit($section_id, $meta)) {
                 $this->pageAlert(__('An unknown database occurred while attempting to create the section.'), Alert::ERROR);
             } else {
                 ## Delete missing CF's
                 $id_list = array();
                 if (is_array($fields) && !empty($fields)) {
                     foreach ($fields as $position => $data) {
                         if (isset($data['id'])) {
                             $id_list[] = $data['id'];
                         }
                     }
                 }
                 $missing_cfs = Symphony::Database()->fetchCol('id', "SELECT `id` FROM `tbl_fields` WHERE `parent_section` = '{$section_id}' AND `id` NOT IN ('" . @implode("', '", $id_list) . "')");
                 if (is_array($missing_cfs) && !empty($missing_cfs)) {
                     foreach ($missing_cfs as $id) {
                         $fieldManager->delete($id);
                     }
                 }
                 ## Save each custom field
                 if (is_array($fields) && !empty($fields)) {
                     foreach ($fields as $position => $data) {
                         $field = $fieldManager->create($data['type']);
                         $field->setFromPOST($data);
                         $field->set('sortorder', (string) $position);
                         $field->set('parent_section', $section_id);
                         $bEdit = true;
                         if (!$field->get('id')) {
                             $bEdit = false;
                         }
                         ## Creation
                         if ($field->commit()) {
                             $field_id = $field->get('id');
                             ###
//.........这里部分代码省略.........
开发者ID:klaftertief,项目名称:sym-forum,代码行数:101,代码来源:content.blueprintssections.php

示例4: __actionNew


//.........这里部分代码省略.........
                  * @delegate SectionPreEdit
                  * @since Symphony 2.2
                  * @param string $context
                  * '/blueprints/sections/'
                  * @param integer $section_id
                  *  The Section ID that is about to be edited.
                  * @param array $meta
                  *  The section's settings, passed by reference
                  * @param array $fields
                  *  An associative array of the fields that will be saved to this
                  *  section with the key being the position in the Section Editor
                  *  and the value being a Field object, passed by reference
                  */
                 Symphony::ExtensionManager()->notifyMembers('SectionPreEdit', '/blueprints/sections/', array('section_id' => $section_id, 'meta' => &$meta, 'fields' => &$fields));
                 if (!SectionManager::edit($section_id, $meta)) {
                     $canProceed = false;
                     $this->pageAlert(__('An unknown database occurred while attempting to create the section.'), Alert::ERROR);
                 }
             }
             if ($section_id && $canProceed) {
                 if ($edit) {
                     // Delete missing CF's
                     $id_list = array();
                     if (is_array($fields) && !empty($fields)) {
                         foreach ($fields as $position => $data) {
                             if (isset($data['id'])) {
                                 $id_list[] = $data['id'];
                             }
                         }
                     }
                     $missing_cfs = Symphony::Database()->fetchCol('id', "SELECT `id` FROM `tbl_fields` WHERE `parent_section` = '{$section_id}' AND `id` NOT IN ('" . @implode("', '", $id_list) . "')");
                     if (is_array($missing_cfs) && !empty($missing_cfs)) {
                         foreach ($missing_cfs as $id) {
                             FieldManager::delete($id);
                         }
                     }
                 }
                 // Save each custom field
                 if (is_array($fields) && !empty($fields)) {
                     foreach ($fields as $position => $data) {
                         $field = FieldManager::create($data['type']);
                         $field->setFromPOST($data);
                         $field->set('sortorder', (string) $position);
                         $field->set('parent_section', $section_id);
                         $newField = !(bool) $field->get('id');
                         $field->commit();
                         $field_id = $field->get('id');
                         if ($field_id) {
                             if ($newField) {
                                 /**
                                  * After creation of a Field.
                                  *
                                  * @delegate FieldPostCreate
                                  * @param string $context
                                  * '/blueprints/sections/'
                                  * @param Field $field
                                  *  The Field object, passed by reference
                                  * @param array $data
                                  *  The settings for ths `$field`, passed by reference
                                  */
                                 Symphony::ExtensionManager()->notifyMembers('FieldPostCreate', '/blueprints/sections/', array('field' => &$field, 'data' => &$data));
                             } else {
                                 /**
                                  * After editing of a Field.
                                  *
                                  * @delegate FieldPostEdit
开发者ID:davjand,项目名称:codecept-symphonycms-db,代码行数:67,代码来源:content.blueprintssections.php


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