本文整理汇总了PHP中SectionManager::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP SectionManager::fetch方法的具体用法?PHP SectionManager::fetch怎么用?PHP SectionManager::fetch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SectionManager
的用法示例。
在下文中一共展示了SectionManager::fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initaliseAdminPageHead
public function initaliseAdminPageHead($context)
{
$page = Administration::instance()->Page;
if ($page instanceof contentPublish) {
$callback = Administration::instance()->getPageCallback();
if ($callback['context']['page'] !== 'edit') {
return;
}
$sm = new SectionManager(Administration::instance());
$current_section = $sm->fetch($sm->fetchIDFromHandle($callback['context']['section_handle']));
$current_section_hash = $this->serialiseSectionSchema($current_section);
$duplicate_sections = array();
foreach ($sm->fetch() as $section) {
$section_hash = $this->serialiseSectionSchema($section);
if ($section_hash == $current_section_hash && $section->get('handle')) {
$duplicate_sections[$section->get('handle')] = $section->get('name');
}
}
if (count($duplicate_sections) < 2) {
$duplicate_sections = NULL;
}
Administration::instance()->Page->addElementToHead(new XMLElement('script', "Symphony.Context.add('duplicate-entry', " . json_encode(array('current-section' => $callback['context']['section_handle'], 'duplicate-sections' => $duplicate_sections)) . ");", array('type' => 'text/javascript')), time());
$page->addScriptToHead(URL . '/extensions/duplicate_entry/assets/duplicate_entry.js', 10001);
// add particular css for SSM
Administration::instance()->Page->addElementToHead(new XMLElement('style', "body.inline.subsection #duplicate-entry { display: none; visibility: collapse }", array('type' => 'text/css')), time() + 101);
}
}
示例2: 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);
}
}
}
}
示例3: generate
function generate($items, $subsection_field, $subsection_id, $entry_id = NULL, $full = false)
{
if (!is_array($items)) {
$items = array($items);
}
$this->_Items = $items;
// Fetch subsection meta data
$meta = Administration::instance()->Database->fetch("SELECT filter_tags, caption, show_preview\n\t\t\t\tFROM tbl_fields_subsectionmanager\n\t\t\t\tWHERE field_id = '{$subsection_field}'\n\t\t\t\tLIMIT 1");
// Get display mode
if ($meta[0]['show_preview'] == 'yes') {
$mode = 'preview';
} else {
$mode = 'plain';
}
// Fetch entry data
$sectionManager = new SectionManager($this->_Parent);
$subsection = $sectionManager->fetch($subsection_id, 'ASC', 'name');
$fields = $subsection->fetchFields();
$entries = $this->__filterEntries($subsection_id, $fields, $meta[0]['filter_tags'], $entry_id);
// Check caption
$caption = $meta[0]['caption'];
if ($caption == '') {
// Fetch name of primary field in subsection
$primary = Administration::instance()->Database->fetch("SELECT element_name\n\t\t\t\t\tFROM tbl_fields\n\t\t\t\t\tWHERE parent_section = '{$subsection_id}'\n\t\t\t\t\tAND sortorder = '0'\n\t\t\t\t\tLIMIT 1");
$caption = '{$' . $primary[0]['element_name'] . '}';
}
// Layout subsection data
$data = $this->__layoutSubsection($entries, $fields, $caption, $mode, $full);
return $data;
}
示例4: createEntryFromPost
private function createEntryFromPost()
{
include_once TOOLKIT . '/class.sectionmanager.php';
include_once TOOLKIT . '/class.entrymanager.php';
// section id
$source = $this->getSection();
$section = SectionManager::fetch($source);
$fields = $section->fetchFields();
$entry = null;
if ($id > 0) {
// edit
$entry = EntryManager::fetch($id);
if (empty($entry)) {
throw new Exception(sprintf(__('Entry id %s not found'), $id));
}
$entry = $entry[0];
} else {
// create
$entry = EntryManager::create();
$entry->set('section_id', $source);
}
foreach ($fields as $f) {
$data = $this->getFieldValue($f->get('element_name'));
if ($data != null) {
$entry->setData($f->get('id'), $data);
}
}
if (!$entry->commit()) {
throw new Exception(sprintf('Could not create entry: %s', mysql_error()));
}
return $entry;
}
示例5: displaySettingsPanel
public function displaySettingsPanel(&$wrapper, $errors = NULL)
{
parent::displaySettingsPanel($wrapper, $errors);
$sectionManager = new SectionManager($this->_engine);
$sections = $sectionManager->fetch(NULL, 'ASC', 'sortorder');
$options = array();
// iterate over sections to build list of fields
if (is_array($sections) && !empty($sections)) {
foreach ($sections as $section) {
$section_fields = $section->fetchFields();
if (!is_array($section_fields)) {
continue;
}
$fields = array();
foreach ($section_fields as $f) {
// only show select box link fields
if ($f->get('type') == 'selectbox_link') {
$fields[] = array($f->get('id'), $this->get('related_sbl_id') == $f->get('id'), $f->get('label'));
}
}
if (!empty($fields)) {
$options[] = array('label' => $section->get('name'), 'options' => $fields);
}
}
}
$group = new XMLElement('div', NULL, array('class' => 'group'));
$label = Widget::Label(__('Child Select Box Link'));
$label->appendChild(Widget::Select('fields[' . $this->get('sortorder') . '][related_sbl_id]', $options));
if (isset($errors['related_sbl_id'])) {
$group->appendChild(Widget::wrapFormElementWithError($label, $errors['related_sbl_id']));
} else {
$group->appendChild($label);
}
$wrapper->appendChild($group);
}
示例6: view
function view()
{
$this->_Parent->Page->addStylesheetToHead(URL . '/extensions/members/assets/styles.css', 'screen', 70);
$create_button = Widget::Anchor('Create a New Role', extension_members::baseURL() . 'new/', 'Create a new role', 'create button');
$this->setPageType('table');
$this->appendSubheading('Member Roles ' . $create_button->generate(false));
$aTableHead = array(array('Name', 'col'), array('Members', 'col'));
$roles = $this->_driver->fetchRoles();
$aTableBody = array();
if (!is_array($roles) || empty($roles)) {
$aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None Found.'), 'inactive', NULL, count($aTableHead)))));
} else {
$sectionManager = new SectionManager($this->_Parent);
$section = $sectionManager->fetch($this->_Parent->Database->fetchVar('parent_section', 0, "SELECT `parent_section` FROM `tbl_fields` WHERE `id` = '" . $this->_driver->usernameAndPasswordField() . "' LIMIT 1"));
$bEven = true;
$role_field_name = $this->_Parent->Database->fetchVar('element_name', 0, "SELECT `element_name` FROM `tbl_fields` WHERE `id` = '" . $this->_driver->roleField() . "' LIMIT 1");
foreach ($roles as $role) {
$member_count = $this->_Parent->Database->fetchVar('count', 0, "SELECT COUNT(*) AS `count` FROM `tbl_entries_data_" . $this->_driver->roleField() . "` WHERE `role_id` = '" . $role->id() . "'");
## Setup each cell
$td1 = Widget::TableData(Widget::Anchor($role->name(), extension_members::baseURL() . 'edit/' . $role->id() . '/', NULL, 'content'));
$td2 = Widget::TableData(Widget::Anchor("{$member_count}", URL . '/symphony/publish/' . $section->get('handle') . '/?filter=' . $role_field_name . ':' . $role->id()));
## Add a row to the body array, assigning each cell to the row
$aTableBody[] = Widget::TableRow(array($td1, $td2), $bEven ? 'odd' : NULL);
$bEven = !$bEven;
}
}
$table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody));
$this->Form->appendChild($table);
}
示例7: fetchVisibleFieldID
function fetchVisibleFieldID($section)
{
$sectionManager = new SectionManager($this->_Parent);
$linked_section = $sectionManager->fetch($section);
$li_field = current($linked_section->fetchVisibleColumns());
return $li_field->get('id');
}
示例8: generate
public function generate($subsection_field, $subsection_id, $items = NULL, $recurse = 0, $flags = self::GETEVERYTHING)
{
static $done = array();
if ($done[$subsection_field] >= $recurse + 1) {
return array('options' => array(), 'html' => '', 'preview' => '');
}
$done[$subsection_field] += 1;
// Fetch subsection meta data
$meta = Symphony::Database()->fetch("SELECT filter_tags, caption, droptext, show_preview\n\t\t\t\tFROM tbl_fields_subsectionmanager\n\t\t\t\tWHERE field_id = '" . intval($subsection_field) . "'\n\t\t\t\tLIMIT 1");
// Get display mode
if ($meta[0]['show_preview'] == 1) {
$mode = 'preview';
$flags |= self::GETPREVIEW;
} else {
$mode = 'plain';
}
// Fetch entry data
$subsection = SectionManager::fetch($subsection_id, 'ASC', 'name');
$fields = $subsection->fetchFields();
$entries = $this->__filterEntries($subsection_id, $fields, $meta[0]['filter_tags'], $items, $flags & self::GETALLITEMS);
$droptext = $meta[0]['droptext'];
// Check caption
$caption = $meta[0]['caption'];
if ($caption == '') {
// Fetch name of primary field in subsection
$primary = Symphony::Database()->fetch("SELECT element_name\n\t\t\t\t\tFROM tbl_fields\n\t\t\t\t\tWHERE parent_section = '" . intval($subsection_id) . "'\n\t\t\t\t\tAND sortorder = '0'\n\t\t\t\t\tLIMIT 1");
$caption = '{$' . $primary[0]['element_name'] . '}';
}
// Layout subsection data
$data = $this->__layoutSubsection($entries, $fields, $caption, $droptext, $mode, $flags);
$done[$subsection_field] -= 1;
return $data;
}
示例9: initializeAdmin
public function initializeAdmin($context)
{
$page = Administration::instance()->Page;
$context = $page->getContext();
$callback = Administration::instance()->getPageCallback();
// only proceed on New or Edit publish pages
if ($page instanceof contentPublish and in_array($context['page'], array('new', 'edit'))) {
$page->addStylesheetToHead(URL . '/extensions/publish_tabs/assets/publish_tabs.publish.css', 'screen', 9001);
$page->addScriptToHead(URL . '/extensions/publish_tabs/assets/publish_tabs.publish.js', 9002);
include_once TOOLKIT . '/class.sectionmanager.php';
$section_id = SectionManager::fetchIDFromHandle($callback['context']['section_handle']);
$section = SectionManager::fetch($section_id);
if (!$section instanceof Section) {
return;
}
$tabs = array();
$current_tab = '';
$index = -1;
foreach ($section->fetchFieldsSchema() as $i => $field) {
if ($i == 0 && $field['type'] != 'publish_tabs') {
$current_tab = 'untitled-tab';
$tabs[++$index]['tab_id'] = $current_tab;
}
if ($field['type'] == 'publish_tabs') {
$current_tab = $field['id'];
$tabs[++$index]['tab_id'] = $current_tab;
} else {
$tabs[$index][$field['location']][] = 'field-' . $field['id'];
}
}
$page->addElementToHead(new XMLElement('script', "Symphony.Context.add('publish-tabs', " . json_encode($tabs) . ")", array('type' => 'text/javascript')), 9003);
}
}
示例10: 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);
}
}
}
}
}
示例11: findFields
public function findFields()
{
$sectionManager = new SectionManager($this->_engine);
$sections = $sectionManager->fetch(null, 'ASC', 'name');
$groups = $options = array();
if (is_array($sections) and !empty($sections)) {
foreach ($sections as $section) {
$groups[$section->get('id')] = array('fields' => $section->fetchFields(), 'section' => $section);
}
}
foreach ($groups as $group) {
if (!is_array($group['fields'])) {
continue;
}
$fields = array();
foreach ($group['fields'] as $field) {
if ($field->get('type') == 'groupname') {
$selected = $this->get('child_field_id') == $field->get('id');
$fields[] = array($field->get('id'), $selected, $field->get('label'));
}
}
if (empty($fields)) {
continue;
}
$options[] = array('label' => $group['section']->get('name'), 'options' => $fields);
}
return $options;
}
示例12: checkTemplates
private function checkTemplates($pageId, $prefix = '')
{
// Link templates:
$templates = Symphony::Database()->fetch(sprintf('SELECT * FROM `tbl_ckeditor_link_templates` WHERE `page_id` = %d;', $pageId));
$entryTree = array();
foreach ($templates as $template) {
$section = SectionManager::fetch($template['section_id']);
$entries = EntryManager::fetch(null, $template['section_id']);
$fields = $section->fetchFields();
foreach ($entries as $entry) {
$link = $template['link'];
// Replace the ID:
$link = str_replace('{$id}', $entry->get('id'), $link);
$data = $entry->getData();
foreach ($fields as $field) {
// Replace the placeholders with the value:
// Check if the field has a 'handle':
$testData = $field->processRawFieldData('test', $field->__OK__);
if (isset($testData['handle'])) {
$link = str_replace('{$' . $field->get('element_name') . '}', $data[$field->get('id')]['handle'], $link);
}
}
$entryTree[] = array('handle' => $data[$field->get('id')]['handle'], 'path' => '', 'url' => $link, 'title' => $prefix . ' › ' . General::sanitize($data[$template['field_id']]['value']));
}
}
return $entryTree;
}
示例13: __viewIndex
public function __viewIndex()
{
$sm = new SectionManager($this->_Parent);
$section = $sm->fetch($sm->fetchIDFromHandle($_GET['section']));
$field_id = $_GET['field'];
$fields = $section->fetchFields();
foreach ($fields as $field) {
if ($field->get('id') == $field_id) {
$upload_field = $field;
}
}
if (!$upload_field) {
die('0|Invalid Field ID');
}
$status = $upload_field->checkPostFieldData($_FILES['Filedata'], $message);
if ($status != Field::__OK__) {
die($status . '|' . $message);
}
$processData = $upload_field->processRawFieldData($_FILES['Filedata'], $status, $message);
if ($status != Field::__OK__) {
die($status . '|' . $message);
}
echo Field::__OK__ . '|' . $processData['file'];
die;
}
示例14: init
public static function init()
{
if (REST_API::getOutputFormat() == 'csv') {
REST_API::sendError(sprintf('%s output format not supported.', strtoupper(REST_API::getOutputFormat())), 401, 'xml');
}
$request_uri = REST_API::getRequestURI();
$section_reference = $request_uri[0];
$sections = NULL;
if (is_null($section_reference)) {
$sections = SectionManager::fetch();
} elseif (is_numeric($section_reference)) {
$sections = SectionManager::fetch($section_reference);
} else {
$section_id = SectionManager::fetchIDFromHandle($section_reference);
if ($section_id) {
$sections = SectionManager::fetch($section_id);
}
}
if (!is_array($sections)) {
$sections = array($sections);
}
if (!reset($sections) instanceof Section) {
REST_API::sendError(sprintf("Section '%s' not found.", $section_reference), 404);
}
self::$_sections = $sections;
}
示例15: saveVersion
public function saveVersion(&$context)
{
$section = $context['section'];
$entry = $context['entry'];
$fields = $context['fields'];
// if saved from an event, no section is passed, so resolve
// section object from the entry
if (is_null($section)) {
$sm = new SectionManager(Symphony::Engine());
$section = $sm->fetch($entry->get('section_id'));
}
// if we *still* can't resolve a section then something is
// probably quite wrong, so don't try and save version history
if (is_null($section)) {
return;
}
// does this section have en Entry Version field, should we store the version?
$has_entry_versions_field = FALSE;
// is this an update to an existing version, or create a new version?
$is_update = $fields['entry-versions'] != 'yes';
// find the Entry Versions field in the section and remove its presence from
// the copied POST array, so that its value is not saved against the version
foreach ($section->fetchFields() as $field) {
if ($field->get('type') == 'entry_versions') {
unset($fields[$field->get('element_name')]);
$has_entry_versions_field = TRUE;
}
}
if (!$has_entry_versions_field) {
return;
}
$version = EntryVersionsManager::saveVersion($entry, $fields, $is_update, $entry_version_field_name);
$context['messages'][] = array('version', 'passed', $version);
}