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


PHP FieldManager类代码示例

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


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

示例1: entrySaved

 public function entrySaved($context)
 {
     require_once MANIFEST . '/jit-recipes.php';
     require_once MANIFEST . '/jit-precaching.php';
     require_once TOOLKIT . '/class.fieldmanager.php';
     $fm = new FieldManager(Symphony::Engine());
     $section = $context['section'];
     if (!$section) {
         require_once TOOLKIT . '/class.sectionmanager.php';
         $sm = new SectionManager(Symphony::Engine());
         $section = $sm->fetch($context['entry']->get('section_id'));
     }
     // iterate over each field in this entry
     foreach ($context['entry']->getData() as $field_id => $data) {
         // get the field meta data
         $field = $fm->fetch($field_id);
         // iterate over the field => recipe mapping
         foreach ($cached_recipes as $cached_recipe) {
             // check a mapping exists for this section/field combination
             if ($section->get('handle') != $cached_recipe['section']) {
                 continue;
             }
             if ($field->get('element_name') != $cached_recipe['field']) {
                 continue;
             }
             // iterate over the recipes mapped for this section/field combination
             foreach ($cached_recipe['recipes'] as $cached_recipe_name) {
                 // get the file name, includes path relative to workspace
                 $file = $data['file'];
                 if (!isset($file) || is_null($file)) {
                     continue;
                 }
                 // trim the filename from path
                 $uploaded_file_path = explode('/', $file);
                 array_pop($uploaded_file_path);
                 // image path relative to workspace
                 if (is_array($uploaded_file_path)) {
                     $uploaded_file_path = implode('/', $uploaded_file_path);
                 }
                 // iterate over all JIT recipes
                 foreach ($recipes as $recipe) {
                     // only process if the recipe has a URL Parameter (name)
                     if (is_null($recipe['url-parameter'])) {
                         continue;
                     }
                     // if not using wildcard, only process specified recipe names
                     if ($cached_recipe_name != '*' && $cached_recipe_name != $recipe['url-parameter']) {
                         continue;
                     }
                     // process the image using the usual JIT URL and get the result
                     $image_data = file_get_contents(URL . '/image/' . $recipe['url-parameter'] . $file);
                     // create a directory structure that matches the JIT URL structure
                     General::realiseDirectory(WORKSPACE . '/image-cache/' . $recipe['url-parameter'] . $uploaded_file_path);
                     // save the image to disk
                     file_put_contents(WORKSPACE . '/image-cache/' . $recipe['url-parameter'] . $file, $image_data);
                 }
             }
         }
     }
 }
开发者ID:nickdunn,项目名称:jit_precaching,代码行数:60,代码来源:extension.driver.php

示例2: getXPath

 public function getXPath($entry)
 {
     $fieldManager = new FieldManager(Symphony::Engine());
     $entry_xml = new XMLElement('entry');
     $section_id = $entry->get('section_id');
     $data = $entry->getData();
     $fields = array();
     $entry_xml->setAttribute('id', $entry->get('id'));
     $associated = $entry->fetchAllAssociatedEntryCounts();
     if (is_array($associated) and !empty($associated)) {
         foreach ($associated as $section => $count) {
             $handle = Symphony::Database()->fetchVar('handle', 0, "\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\ts.handle\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t`tbl_sections` AS s\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\ts.id = '{$section}'\n\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t");
             $entry_xml->setAttribute($handle, (string) $count);
         }
     }
     // Add fields:
     foreach ($data as $field_id => $values) {
         if (empty($field_id)) {
             continue;
         }
         $field = $fieldManager->fetch($field_id);
         $field->appendFormattedElement($entry_xml, $values, false, null);
     }
     $xml = new XMLElement('data');
     $xml->appendChild($entry_xml);
     $dom = new DOMDocument();
     $dom->strictErrorChecking = false;
     $dom->loadXML($xml->generate(true));
     $xpath = new DOMXPath($dom);
     if (version_compare(phpversion(), '5.3', '>=')) {
         $xpath->registerPhpFunctions();
     }
     return $xpath;
 }
开发者ID:nickdunn,项目名称:reflectionfield,代码行数:34,代码来源:extension.driver.php

示例3: 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

示例4: findAllFields

 public function findAllFields($section_id)
 {
     $fieldManager = new FieldManager(Symphony::Engine());
     $fields = $fieldManager->fetch(NULL, $section_id, 'ASC', 'sortorder', NULL, NULL, 'AND (type != "fop")');
     if (is_array($fields) && !empty($fields)) {
         foreach ($fields as $field) {
             $options[] = 'entry/' . $field->get('element_name');
         }
     }
     return $options;
 }
开发者ID:nanymor,项目名称:fop,代码行数:11,代码来源:field.fop.php

示例5: view

 public function view()
 {
     $sectionManager = new SectionManager(Administration::instance());
     $fieldManager = new FieldManager(Administration::instance());
     // Fetch sections & populate a dropdown with the available upload fields
     $section = $sectionManager->fetch($_GET['section']);
     foreach ($section->fetchFields() as $field) {
         if (!preg_match(Extension_BulkImporter::$supported_fields['upload'], $field->get('type'))) {
             continue;
         }
         $element = new XMLElement("field", General::sanitize($field->get('label')), array('id' => $field->get('id'), 'type' => $field->get('type')));
         $this->_Result->appendChild($element);
     }
     // Check to see if any Sections link to this using the Section Associations table
     $associations = Symphony::Database()->fetch(sprintf("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t`child_section_field_id`\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`tbl_sections_association`\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t`parent_section_id` = %d\n\t\t\t\t", Symphony::Database()->cleanValue($_GET['section'])));
     if (is_array($associations) && !empty($associations)) {
         foreach ($associations as $related_field) {
             $field = $fieldManager->fetch($related_field['child_section_field_id']);
             if (!preg_match(Extension_BulkImporter::$supported_fields['section'], $field->get('type'))) {
                 continue;
             }
             $element = new XMLElement("section", General::sanitize($field->get('label')), array('id' => $field->get('id'), 'type' => $field->get('type'), 'section' => $sectionManager->fetch($field->get('parent_section'))->get('name')));
             $this->_Result->appendChild($element);
         }
     }
     // Check for Subsection Manager
     if (Symphony::ExtensionManager()->fetchStatus('subsectionmanager') == EXTENSION_ENABLED) {
         $associations = Symphony::Database()->fetch(sprintf("\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t`field_id`\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t`tbl_fields_subsectionmanager`\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t`subsection_id` = %d\n\t\t\t\t\t", Symphony::Database()->cleanValue($_GET['section'])));
         if (is_array($associations) && !empty($associations)) {
             foreach ($associations as $related_field) {
                 $field = $fieldManager->fetch($related_field['field_id']);
                 if (!preg_match(Extension_BulkImporter::$supported_fields['section'], $field->get('type'))) {
                     continue;
                 }
                 $element = new XMLElement("section", General::sanitize($field->get('label')), array('id' => $field->get('id'), 'type' => $field->get('type'), 'section' => $sectionManager->fetch($field->get('parent_section'))->get('name')));
                 $this->_Result->appendChild($element);
             }
         }
     }
     // Check for BiLink
     if (Symphony::ExtensionManager()->fetchStatus('bilinkfield') == EXTENSION_ENABLED) {
         $associations = Symphony::Database()->fetch(sprintf("\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t`field_id`\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t`tbl_fields_bilink`\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t`linked_section_id` = %d\n\t\t\t\t\t", Symphony::Database()->cleanValue($_GET['section'])));
         if (is_array($associations) && !empty($associations)) {
             foreach ($associations as $related_field) {
                 $field = $fieldManager->fetch($related_field['field_id']);
                 if (!preg_match(Extension_BulkImporter::$supported_fields['section'], $field->get('type'))) {
                     continue;
                 }
                 $element = new XMLElement("section", General::sanitize($field->get('label')), array('id' => $field->get('id'), 'type' => $field->get('type'), 'section' => $sectionManager->fetch($field->get('parent_section'))->get('name')));
                 $this->_Result->appendChild($element);
             }
         }
     }
 }
开发者ID:brendo,项目名称:bulkimporter,代码行数:54,代码来源:content.ajaxsectioninfo.php

示例6: process

 public static function process($options = array())
 {
     $default = array('entries' => array(), 'section' => null, 'field_name' => null, 'iptc' => true, 'exif' => true);
     $options = array_merge($default, $options);
     self::checkRequirements($options['exif']);
     if (!$options['field_name'] || !$options['entries'] || !$options['section']) {
         self::throwEx('Missing required option');
     }
     $root = new XMLElement(self::getRootElement());
     $field = FieldManager::fetchFieldIDFromElementName($options['field_name'], $options['section']->get('id'));
     foreach ($options['entries'] as $entry) {
         $data = $entry->getData($field);
         $rel = $data['file'];
         $img = WORKSPACE . $rel;
         $xml = new XMLElement('image', null, array('path' => $rel, 'entry_id' => $entry->get('id')));
         if ($options['iptc']) {
             $result = self::processIptc($img);
             $xml->appendChild($result);
         }
         if ($options['exif']) {
             $result = self::processExif($img);
             $xml->appendChild($result);
         }
         $root->appendChild($xml);
     }
     return $root;
 }
开发者ID:alpacaaa,项目名称:image_info,代码行数:27,代码来源:class.images_info.php

示例7: view

 public function view()
 {
     $this->addHeaderToPage('Content-Type', 'text/html');
     $field_id = $this->_context[0];
     $entry_id = $this->_context[1];
     $this->_context['entry_id'] = $entry_id;
     try {
         $entry = EntryManager::fetch($entry_id);
         $entry = $entry[0];
         if (!is_a($entry, 'Entry')) {
             $this->_status = 404;
             return;
         }
         $field = FieldManager::fetch($field_id);
         if (!is_a($field, 'Field')) {
             $this->_status = 404;
             return;
         }
         $field->set('id', $field_id);
         $entry_data = $entry->getData();
         $data = new XMLElement('field');
         $field->displayPublishPanel($data, $entry_data[$field_id]);
         echo $data->generate(true);
         exit;
         $this->_Result->appendChild($data);
     } catch (Exception $e) {
     }
 }
开发者ID:jonmifsud,项目名称:email_newsletter_manager,代码行数:28,代码来源:content.publishfield.php

示例8: appendErrors

 /**
  * Appends errors generated from fields during the execution of an Event
  *
  * @param XMLElement $result
  * @param array $fields
  * @param array $errors
  * @param object $post_values
  * @throws Exception
  * @return XMLElement
  */
 public static function appendErrors(XMLElement $result, array $fields, $errors, $post_values)
 {
     $result->setAttribute('result', 'error');
     $result->appendChild(new XMLElement('message', __('Entry encountered errors when saving.'), array('message-id' => EventMessages::ENTRY_ERRORS)));
     foreach ($errors as $field_id => $message) {
         $field = FieldManager::fetch($field_id);
         // Do a little bit of a check for files so that we can correctly show
         // whether they are 'missing' or 'invalid'. If it's missing, then we
         // want to remove the data so `__reduceType` will correctly resolve to
         // missing instead of invalid.
         // @see https://github.com/symphonists/s3upload_field/issues/17
         if (isset($_FILES['fields']['error'][$field->get('element_name')])) {
             $upload = $_FILES['fields']['error'][$field->get('element_name')];
             if ($upload === UPLOAD_ERR_NO_FILE) {
                 unset($fields[$field->get('element_name')]);
             }
         }
         if (is_array($fields[$field->get('element_name')])) {
             $type = array_reduce($fields[$field->get('element_name')], array('SectionEvent', '__reduceType'));
         } else {
             $type = $fields[$field->get('element_name')] == '' ? 'missing' : 'invalid';
         }
         $error = self::createError($field, $type, $message);
         $result->appendChild($error);
     }
     if (isset($post_values) && is_object($post_values)) {
         $result->appendChild($post_values);
     }
     return $result;
 }
开发者ID:jurajkapsz,项目名称:symphony-2,代码行数:40,代码来源:class.event.section.php

示例9: commit

 public function commit()
 {
     if (!parent::commit()) {
         return false;
     }
     $id = $this->get('id');
     if ($id === false) {
         return false;
     }
     fieldMemberUsername::createSettingsTable();
     $fields = array('field_id' => $id, 'validator' => $this->get('validator'));
     return FieldManager::saveSettings($id, $fields);
 }
开发者ID:andrewminton,项目名称:members,代码行数:13,代码来源:field.memberusername.php

示例10: grab

 public function grab(array &$param_pool = NULL)
 {
     // remove placeholder elements
     unset($this->dsParamINCLUDEDELEMENTS);
     // fill with all included elements if none are set
     if (is_null(REST_Entries::getDatasourceParam('included_elements'))) {
         // get all fields in this section
         $fields = FieldManager::fetchFieldsSchema(REST_Entries::getSectionId());
         // add them to the data source
         foreach ($fields as $field) {
             $this->dsParamINCLUDEDELEMENTS[] = $field['element_name'];
         }
         // also add pagination
         $this->dsParamINCLUDEDELEMENTS[] = 'system:pagination';
     } else {
         $this->dsParamINCLUDEDELEMENTS = explode(',', REST_Entries::getDatasourceParam('included_elements'));
     }
     // fill the other parameters
     if (!is_null(REST_Entries::getDatasourceParam('limit'))) {
         $this->dsParamLIMIT = REST_Entries::getDatasourceParam('limit');
     }
     if (!is_null(REST_Entries::getDatasourceParam('page'))) {
         $this->dsParamSTARTPAGE = REST_Entries::getDatasourceParam('page');
     }
     if (!is_null(REST_Entries::getDatasourceParam('sort'))) {
         $this->dsParamSORT = REST_Entries::getDatasourceParam('sort');
     }
     if (!is_null(REST_Entries::getDatasourceParam('order'))) {
         $this->dsParamORDER = REST_Entries::getDatasourceParam('order');
     }
     // Do grouping
     if (!is_null(REST_Entries::getDatasourceParam('groupby'))) {
         $field_id = FieldManager::fetchFieldIDFromElementName(REST_Entries::getDatasourceParam('groupby'), REST_Entries::getSectionId());
         if ($field_id) {
             $this->dsParamGROUP = $field_id;
         }
     }
     // if API is calling a known entry, filter on System ID only
     if (!is_null(REST_Entries::getEntryId())) {
         $this->dsParamFILTERS['id'] = REST_Entries::getEntryId();
     } elseif (REST_Entries::getDatasourceParam('filters')) {
         foreach (REST_Entries::getDatasourceParam('filters') as $field_handle => $filter_value) {
             $filter_value = rawurldecode($filter_value);
             $field_id = FieldManager::fetchFieldIDFromElementName($field_handle, REST_Entries::getSectionId());
             if (is_numeric($field_id)) {
                 $this->dsParamFILTERS[$field_id] = $filter_value;
             }
         }
     }
     return $this->execute($param_pool);
 }
开发者ID:MST-SymphonyCMS,项目名称:rest_api,代码行数:51,代码来源:data.rest_api_entries.php

示例11: commit

 /**
  * Persist field configuration
  */
 function commit()
 {
     // set up standard Field settings
     if (!parent::commit()) {
         return FALSE;
     }
     $id = $this->get('id');
     if ($id === FALSE) {
         return FALSE;
     }
     $fields = array();
     $fields['field_id'] = $id;
     return FieldManager::saveSettings($id, $fields);
 }
开发者ID:symphonists,项目名称:search_index,代码行数:17,代码来源:field.search_index.php

示例12: commit

 public function commit()
 {
     if (!Field::commit()) {
         return false;
     }
     $id = $this->get('id');
     if ($id === false) {
         return false;
     }
     $fields = array();
     $fields['field_id'] = $id;
     $fields['pre_populate'] = $this->get('pre_populate') ? $this->get('pre_populate') : 'no';
     $fields['mode'] = $this->get('mode') ? $this->get('mode') : 'normal';
     return FieldManager::saveSettings($id, $fields);
 }
开发者ID:symphonists,项目名称:datemodified,代码行数:15,代码来源:field.datemodified.php

示例13: commit

 public function commit()
 {
     if (!parent::commit()) {
         return false;
     }
     $id = $this->get('id');
     if ($id === false) {
         return false;
     }
     $state = $this->get('default_state');
     $entries = (int) $this->get('unique_entries');
     $steal = $this->get('unique_steal');
     $fields = array('field_id' => $id, 'default_state' => $state ? $state : 'off', 'unique_entries' => $entries > 0 ? $entries : 1, 'unique_steal' => $steal ? $steal : 'off');
     return FieldManager::saveSettings($id, $fields);
 }
开发者ID:symphonists,项目名称:uniquecheckboxfield,代码行数:15,代码来源:field.uniquecheckbox.php

示例14: prepareTableValue

 public function prepareTableValue($data, XMLElement $link = NULL, $entry_id = NULL)
 {
     // build this entry fully
     $entries = EntryManager::fetch($entry_id);
     if ($entries === false) {
         return parent::prepareTableValue(NULL, $link, $entry_id);
     }
     $entry = reset(EntryManager::fetch($entry_id));
     // get the first field inside this tab
     $field_id = Symphony::Database()->fetchVar('id', 0, "SELECT `id` FROM `tbl_fields` WHERE `parent_section` = '" . $this->get('parent_section') . "' AND `sortorder` = " . ($this->get('sortorder') + 1) . " ORDER BY `sortorder` LIMIT 1");
     if ($field_id === NULL) {
         return parent::prepareTableValue(NULL, $link, $entry_id);
     }
     $field = FieldManager::fetch($field_id);
     // get the first field's value as a substitude for the tab's return value
     return $field->prepareTableValue($entry->getData($field_id), $link, $entry_id);
 }
开发者ID:henrysingleton,项目名称:publish_tabs,代码行数:17,代码来源:field.publish_tabs.php

示例15: appendErrors

 /**
  * Appends errors generated from fields during the execution of an Event
  *
  * @param XMLElement $result
  * @param array $fields
  * @param array $errors
  * @param object $post_values
  * @return XMLElement
  */
 public static function appendErrors(XMLElement $result, array $fields, $errors, $post_values)
 {
     $result->setAttribute('result', 'error');
     $result->appendChild(new XMLElement('message', __('Entry encountered errors when saving.')));
     foreach ($errors as $field_id => $message) {
         $field = FieldManager::fetch($field_id);
         if (is_array($fields[$field->get('element_name')])) {
             $type = array_reduce($fields[$field->get('element_name')], array('SectionEvent', '__reduceType'));
         } else {
             $type = $fields[$field->get('element_name')] == '' ? 'missing' : 'invalid';
         }
         $result->appendChild(new XMLElement($field->get('element_name'), null, array('label' => General::sanitize($field->get('label')), 'type' => $type, 'message' => General::sanitize($message))));
     }
     if (isset($post_values) && is_object($post_values)) {
         $result->appendChild($post_values);
     }
     return $result;
 }
开发者ID:nils-werner,项目名称:symphony-2,代码行数:27,代码来源:class.event.section.php


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