本文整理汇总了PHP中FieldManager::fetchFieldTypeFromID方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldManager::fetchFieldTypeFromID方法的具体用法?PHP FieldManager::fetchFieldTypeFromID怎么用?PHP FieldManager::fetchFieldTypeFromID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FieldManager
的用法示例。
在下文中一共展示了FieldManager::fetchFieldTypeFromID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeDSFilters
public function removeDSFilters($context)
{
//Check if there is a preview link field attached.
$has_preview_link = false;
if (!isset(self::$fieldManager)) {
self::$fieldManager = new fieldManager(Symphony::Engine());
}
if (is_array($context['elements'])) {
foreach ($context['elements'] as $element) {
$field_id = self::$fieldManager->fetchFieldIDFromElementName($element);
$field_type = self::$fieldManager->fetchFieldTypeFromID($field_id);
if ($field_type == 'preview_url') {
$has_preview_link = true;
}
}
}
$contents = $context['contents'];
$first_line = '$result = new XMLElement($this->dsParamROOTELEMENT);';
//CREATE THE HORRIBLE FILTER STRING
$this->dsFilter = ' //PREVIEW LINK EXTENSION: Remove Filters' . PHP_EOL;
$this->dsFilter .= ' if (!strpos($_SERVER[‘HTTP_USER_AGENT’],"Googlebot")) {' . PHP_EOL;
$this->dsFilter .= ' if(sha1($_GET["entryid"]) == $_GET["key"]) {' . PHP_EOL;
$this->dsFilter .= ' $filters = $this->dsParamFILTERS;' . PHP_EOL;
$this->dsFilter .= ' foreach($filters as $key=>$filter) {' . PHP_EOL;
$this->dsFilter .= ' unset($this->dsParamFILTERS[$key]);' . PHP_EOL;
$this->dsFilter .= ' }' . PHP_EOL;
$this->dsFilter .= ' $this->dsParamFILTERS["id"] = $_GET["entryid"];' . PHP_EOL;
$this->dsFilter .= ' }' . PHP_EOL;
$this->dsFilter .= ' }';
if ($has_preview_link) {
$contents = str_replace($first_line, $first_line . PHP_EOL . PHP_EOL . $this->dsFilter, $contents);
} else {
$contents = str_replace($this->dsFilter, '', $contents);
}
$this->dsContents = $contents;
}
示例2: generateView
public function generateView(XMLElement &$wrapper, $fieldname, $options, fieldSelectBox_Link_image $field)
{
parent::generateView($wrapper, $fieldname, $options, $field);
$alert = false;
$thumbSize = 100;
// text options
$editbtn_text = __('Edit Selection');
$editbtn_text_blank = __('Select Existing');
$editbtn_text_close = __('Done');
$createbtn_text = __('Create New');
$footer_text_blank = __('None');
$footer_text_drag = __('Drag to reorder');
$grid_columns = 6;
// CSS is set up to accept 1-10 here, perhaps this could be defined in field settings
$option_count = count($options[1]['options']);
// print_r($options, TRUE);
// set some default classes
$attributes = $wrapper->getAttribute('class');
$wrapper->setAttribute('class', $attributes . ' closed has' . $option_count);
// Create the imagegrid:
$imagegrid = new XMLElement('div', null, array('class' => 'sblp-imagegrid col' . $grid_columns));
foreach ($options as $optGroup) {
$container = new XMLElement('div', null, array('class' => 'container'));
if (isset($optGroup['label'])) {
foreach ($optGroup['options'] as $option) {
$section = SectionManager::fetch($optGroup['id']);
$id = $option[0];
$value = $option[2];
$attr = array('rel' => $id, 'class' => 'image', 'data-section' => $section->get('handle'));
$fileEntries = EntryManager::fetch($id);
// item
preg_match('/<*a[^>]*href*=*["\']?([^"\']*)/', html_entity_decode($value), $matches);
$href = str_replace(URL . '/workspace/', '', $matches[1]);
// $s3Href = array_values($fileEntries[0]->getData(0))[1]["value_formatted"];
// $imgTitle = array_values($fileEntries[0]->getData(0))[2]['value'];
foreach ($fileEntries[0]->getData(0) as $fields => $fe) {
$fieldType = FieldManager::fetchFieldTypeFromID($fields);
if ($fieldType == 'input') {
$imgTitle = $fe["value"];
}
if ($fieldType == 'reflection') {
$imgHref = $fe["value_formatted"];
}
}
if (empty($href)) {
// If no href could be found, the field selected for the relation probably isn't of the type 'upload':
// In this case, show a message to the user:
// $alert = true;
} else {
if (!empty($imgHref)) {
// $href = str_replace('https://', '', $s3Href);
}
}
// $img = '<img src="'.URL.'/image/2/'.$thumbSize.'/'.$thumbSize.'/5/1/'.$href.'" alt="thumb" width="'.$thumbSize.'" height="'.$thumbSize.'" />';
$img = '<img src="' . $imgHref . '" alt="' . $imgTitle . '" width="' . $thumbSize . '" height="' . $thumbSize . '" />';
// edit & delete
$actions = '';
if ($field->get('enable_edit') == 1) {
$actions .= '<a href="javascript:void(0)" class="edit" title="' . __('Edit this item') . '">' . __('Edit') . '</a>';
}
if ($field->get('enable_delete') == 1) {
$actions .= '<a href="javascript:void(0)" class="delete" title="' . __('Delete this item') . '">×</a>';
}
$actions .= '<div class="corner"></div>';
$actions .= '<a href="javascript:void(0)" title="' . $imgTitle . '" link="' . $imgHref . '" class="thumb insert-link">' . $img . '</a>';
$container->appendChild(new XMLElement('div', $actions, $attr));
}
}
$imagegrid->appendChild($container);
}
$wrapper->appendChild($imagegrid);
$imagegridfooter = new XMLElement('div', null, array('class' => 'sblp-imagegrid-footer'));
/* Add button */
if ($field->get('enable_create') == 1) {
$related_sections = $field->findRelatedSections();
usort($related_sections, function ($a, $b) {
return strcasecmp($a->get('name'), $b->get('name'));
});
}
if ($option_count >= 1) {
$imagegridfooter->appendChild(Widget::Anchor($editbtn_text, 'javascript:void(0)', null, 'edit button sblp-edit'));
}
if ($field->get('enable_create') == 1) {
$imagegridfooter->appendChild(Widget::Anchor($createbtn_text, URL . '/symphony/publish/' . $related_sections[0]->get('handle') . '/new/', null, 'create button sblp-add'));
}
/* Just to make the button text values accessible to JS*/
$imagegridfooter->appendChild(Widget::Input('editbtn_text', $editbtn_text, 'hidden'));
$imagegridfooter->appendChild(Widget::Input('editbtn_text_blank', $editbtn_text_blank, 'hidden'));
$imagegridfooter->appendChild(Widget::Input('editbtn_text_close', $editbtn_text_close, 'hidden'));
// $dragtext = $field->get('allow_multiple_selection') == 'yes' ? '<em>'.$footer_text_drag.'</em>' : '';
// $imagegridfooter->appendChild(new XMLElement('p', $dragtext, array('class' => 'dragtext')));
$wrapper->appendChild($imagegridfooter);
// send some data to JS
$wrapper->setAttribute('data-alert', $alert ? 'true' : 'false');
$wrapper->setAttribute('data-multiple', $field->get('allow_multiple_selection') == 'yes' ? 'true' : 'false');
// append assets only once
self::appendAssets();
}
示例3: eventPreSaveFilter
public function eventPreSaveFilter($context)
{
if ($context['fields'] === null && (RestEngine::getHTTPMethod() === 'put' || 'post')) {
$parsedData = RestEngine::parseBodyContent();
if ($context['entry_id'] === null && RestEngine::getHTTPMethod() === 'put') {
$pageID = RestEngine::getPageID();
$urlParams = $this::getPageURLParams();
//use the page ID to look up the format and uid param settings
$settings = RestResourceManager::getByPageID($pageID);
if (array_key_exists($settings['uid_parameter'], $urlParams)) {
$entryIDValue = $urlParams[$settings['uid_parameter']];
if ($settings['field_id'] == 0) {
// 0 stands for using the Entry ID number directly so just
// check to see if that entry number exists in the correct section
$entrySection = EntryManager::fetchEntrySectionID($entryIDValue);
if ($entrySection == $settings['section_id']) {
//good to go
$entryID = $entryIDValue;
}
} else {
$fieldType = FieldManager::fetchFieldTypeFromID($settings['field_id']);
//TODO: Eventually add in a more robust field type management to distinguish between value and handle based fields if necessary, or do it by array searching?
if ($fieldType != 'memberemail') {
$query = "SELECT `entry_id` FROM `tbl_entries_data_" . $settings['field_id'] . "` WHERE `handle` = '" . $entryIDValue . "' LIMIT 1";
} else {
$query = "SELECT `entry_id` FROM `tbl_entries_data_" . $settings['field_id'] . "` WHERE `value` = '" . $entryIDValue . "' LIMIT 1";
}
$entryID = Symphony::Database()->fetchVar('entry_id', 0, $query);
}
if (is_null($entryID)) {
//no matching entry
$context['messages'][] = array('restengine:invalid-id', FALSE, __('The specified resource "%1$s" does not exist.', array($entryIDValue)));
} else {
//good to go
$context['entry_id'] = $entryID;
}
} else {
$context['messages'][] = array('restengine:settings-error', FALSE, __('Invalid Rest Resource unique ID URL parameter: %1$s.', array($settings['uid_parameter'])));
//probably some kind of error needs returning here
}
}
if (is_array($parsedData) && !empty($parsedData['data']) && $parsedData['errors'] === null) {
//Create the post data cookie element.
General::array_to_xml($context['post_values'], $parsedData, true);
//TODO: check for field mapping
//TODO: Do we need to error when message body contains properties that we don't have fields for in the assigned section?
$context['fields'] = $parsedData['data'];
}
}
}