本文整理汇总了PHP中SectionManager类的典型用法代码示例。如果您正苦于以下问题:PHP SectionManager类的具体用法?PHP SectionManager怎么用?PHP SectionManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SectionManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: __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;
}
示例4: 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);
}
示例5: 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;
}
示例6: 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);
}
}
}
}
}
示例7: 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);
}
示例8: 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);
}
}
示例9: 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');
}
示例10: view
public function view()
{
$this->_driver = $this->_Parent->ExtensionManager->create('export_entry');
$this->target = $_GET['section'];
$this->fieldID = $_GET['field'];
if (!$this->validate()) {
$this->_status = self::STATUS_BAD;
$this->generate();
return false;
}
$sectionManager = new SectionManager($this->_Parent);
$entryManager = new EntryManager($this->_Parent);
$section = $sectionManager->fetch($this->target);
$fields = $section->fetchFields();
/* Get all the fields from the target section
** Loop them for the section Link field
*/
foreach ($fields as $field) {
if ($field->get("id") == $this->fieldID) {
if ($field->get('type') == "bilink") {
$linked_section_id = $field->get("linked_section_id");
$linked_field_id = $field->get("linked_field_id");
} else {
if ($field->get('type') == "selectbox_link") {
$linked_section_id = Symphony::Database()->fetchVar("parent_section_id", 0, "SELECT parent_section_id \n\t\t\t\t\t\t\tFROM `tbl_sections_association` \n\t\t\t\t\t\t\tWHERE `child_section_field_id` = {$field->get("id")}\n\t\t\t\t\t\t\tLIMIT 1");
$linked_field_id = $field->get("related_field_id");
} else {
if ($field->get('type') == "checkbox") {
$linked_section_id = false;
$el = new XMLElement("entry", 'Yes');
$el->setAttribute('id', 'yes');
$this->_Result->appendChild($el);
$el = new XMLElement("entry", 'No');
$el->setAttribute('id', 'no');
$this->_Result->appendChild($el);
}
}
}
}
}
if ($linked_section_id) {
/* Got the linked field, now get the other end of the
** link. Use the first Visible column as the output handle
*/
$linked_field_id = $this->_driver->fetchVisibleFieldID($linked_section_id);
/* Foreach entry in the linked section, display the first
** column to be selected
*/
$entries = $entryManager->fetch(null, $linked_section_id);
foreach ($entries as $entry) {
$data = current($entryManager->fetch($entry->get('id'), $linked_section_id));
$values = $data->getData($linked_field_id);
$el = new XMLElement("entry", General::sanitize($values['value']));
$el->setAttribute('id', $entry->get('id'));
$this->_Result->appendChild($el);
}
}
}
示例11: __viewIndex
public function __viewIndex()
{
$this->setPageType('table');
$this->setTitle(__('%1$s – %2$s', array(__('Symphony'), __('Member Roles'))));
if (is_null(extension_Members::getFieldHandle('role')) && !is_null(extension_Members::getMembersSection())) {
$this->pageAlert(__('There is no Member: Role field in the active Members section. <a href="%s%d/">Add Member: Role field?</a>', array(SYMPHONY_URL . '/blueprints/sections/edit/', extension_Members::getMembersSection())), Alert::NOTICE);
}
$this->appendSubheading(__('Member Roles'), Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/', __('Create a Role'), 'create button', NULL, array('accesskey' => 'c')));
$roles = RoleManager::fetch();
$aTableHead = array(array(__('Name'), 'col'), array(__('Members'), 'col'));
$aTableBody = array();
if (!is_array($roles) || empty($roles)) {
$aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead)))));
} else {
if (is_null(extension_Members::getMembersSection())) {
$aTableBody = array(Widget::TableRow(array(Widget::TableData(__('No Member section has been specified in <a href="%s">Preferences</a>. Please do this first.', array(SYMPHONY_URL . '/system/preferences/')), 'inactive', NULL, count($aTableHead)))));
} else {
$sectionManager = new SectionManager(Administration::instance());
$section = $sectionManager->fetch(extension_Members::getMembersSection());
$with_selected_roles = array();
$hasRoles = !is_null(extension_Members::getFieldHandle('role'));
foreach ($roles as $role) {
// Setup each cell
$td1 = Widget::TableData(Widget::Anchor($role->get('name'), Administration::instance()->getCurrentPageURL() . 'edit/' . $role->get('id') . '/', null, 'content'));
if ($role->get('id') != Role::PUBLIC_ROLE) {
$td1->appendChild(Widget::Input("items[{$role->get('id')}]", null, 'checkbox'));
}
// Get the number of members for this role, as long as it's not the Public Role.
if ($hasRoles && $role->get('id') != Role::PUBLIC_ROLE) {
$member_count = Symphony::Database()->fetchVar('count', 0, sprintf("SELECT COUNT(*) AS `count` FROM `tbl_entries_data_%d` WHERE `role_id` = %d", extension_Members::getField('role')->get('id'), $role->get('id')));
$td2 = Widget::TableData(Widget::Anchor("{$member_count}", SYMPHONY_URL . '/publish/' . $section->get('handle') . '/?filter=' . extension_Members::getFieldHandle('role') . ':' . $role->get('id')));
} else {
if ($role->get('id') == Role::PUBLIC_ROLE) {
$td2 = Widget::TableData(__('This is the role assumed by the general public.'));
} else {
$td2 = Widget::TableData(__('None'), 'inactive');
}
}
// Add cells to a row
$aTableBody[] = Widget::TableRow(array($td1, $td2));
if ($hasRoles && $role->get('id') != Role::PUBLIC_ROLE) {
$with_selected_roles[] = array("move::" . $role->get('id'), false, $role->get('name'));
}
}
}
}
$table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable');
$this->Form->appendChild($table);
$tableActions = new XMLElement('div');
$tableActions->setAttribute('class', 'actions');
$options = array(0 => array(null, false, __('With Selected...')), 2 => array('delete', false, __('Delete'), 'confirm'), 3 => array('delete-members', false, __('Delete Members'), 'confirm'));
if (count($with_selected_roles) > 0) {
$options[1] = array('label' => __('Move Members To'), 'options' => $with_selected_roles);
}
$tableActions->appendChild(Widget::Select('with-selected', $options));
$tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
$this->Form->appendChild($tableActions);
}
示例12: displaySettingsPanel
public function displaySettingsPanel(&$wrapper, $errors = NULL)
{
Field::displaySettingsPanel($wrapper, $errors);
$div = new XMLElement('div', NULL, array('class' => 'group'));
$label = Widget::Label('Options');
$sectionManager = new SectionManager($this->_engine);
$sections = $sectionManager->fetch(NULL, 'ASC', 'name');
$field_groups = array();
if (is_array($sections) && !empty($sections)) {
foreach ($sections as $section) {
$field_groups[$section->get('id')] = array('fields' => $section->fetchFields(), 'section' => $section);
}
}
$options = array();
foreach ($field_groups as $group) {
if (!is_array($group['fields'])) {
continue;
}
$fields = array();
foreach ($group['fields'] as $f) {
if ($f->get('id') != $this->get('id') && $f->canPrePopulate() && !is_null($this->get('related_field_id'))) {
$fields[] = array($f->get('id'), in_array($f->get('id'), $this->get('related_field_id')), $f->get('label'));
}
}
if (is_array($fields) && !empty($fields)) {
$options[] = array('label' => $group['section']->get('name'), 'options' => $fields);
}
}
$label->appendChild(Widget::Select('fields[' . $this->get('sortorder') . '][related_field_id][]', $options, array('multiple' => 'multiple')));
$div->appendChild($label);
// set field type
$label = Widget::Label('Field Type');
$type_options = array(array('select', $this->get('field_type') == 'select', 'Select Box'), array('autocomplete', $this->get('field_type') == 'autocomplete', 'Autocomplete Input'));
$label->appendChild(Widget::Select('fields[' . $this->get('sortorder') . '][field_type]', $type_options));
$div->appendChild($label);
// Allow selection of multiple items
$label = Widget::Label();
$input = Widget::Input('fields[' . $this->get('sortorder') . '][allow_multiple_selection]', 'yes', 'checkbox');
if ($this->get('allow_multiple_selection') == 'yes') {
$input->setAttribute('checked', 'checked');
}
$label->setValue($input->generate() . ' Allow selection of multiple options');
$div->appendChild($label);
if (isset($errors['related_field_id'])) {
$wrapper->appendChild(Widget::wrapFormElementWithError($div, $errors['related_field_id']));
} else {
$wrapper->appendChild($div);
}
## Maximum entries
$label = Widget::Label();
$input = Widget::Input('fields[' . $this->get('sortorder') . '][limit]', $this->get('limit'));
$input->setAttribute('size', '3');
$label->setValue('Limit to the ' . $input->generate() . ' most recent entries');
$wrapper->appendChild($label);
$this->appendShowColumnCheckbox($wrapper);
$this->appendRequiredCheckbox($wrapper);
}
示例13: __doit
private function __doit($source, $fields, &$result, $entry_id = NULL, $cookie = NULL)
{
include_once TOOLKIT . '/class.sectionmanager.php';
include_once TOOLKIT . '/class.entrymanager.php';
$sectionManager = new SectionManager($this->_Parent);
if (!($section = $sectionManager->fetch($source))) {
$result->setAttribute('result', 'error');
$result->appendChild(new XMLElement('message', 'Section is invalid'));
return false;
}
$entryManager = new EntryManager($this->_Parent);
if (isset($entry_id) && $entry_id != NULL) {
$entry =& $entryManager->fetch($entry_id);
$entry = $entry[0];
if (!is_object($entry)) {
$result->setAttribute('result', 'error');
$result->appendChild(new XMLElement('message', 'Invalid Entry ID specified. Could not create Entry object.'));
return false;
}
} else {
$entry =& $entryManager->create();
$entry->set('section_id', $source);
}
if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($fields, $errors, $entry->get('id') ? true : false)) {
$result->setAttribute('result', 'error');
$result->appendChild(new XMLElement('message', 'Entry encountered errors when saving.'));
foreach ($errors as $field_id => $message) {
$field = $entryManager->fieldManager->fetch($field_id);
$result->appendChild(new XMLElement($field->get('element_name'), NULL, array('type' => $fields[$field->get('element_name')] == '' ? 'missing' : 'invalid')));
}
if (isset($cookie) && is_object($cookie)) {
$result->appendChild($cookie);
}
return false;
} elseif (__ENTRY_OK__ != $entry->setDataFromPost($fields, $errors, false, $entry->get('id') ? true : false)) {
$result->setAttribute('result', 'error');
$result->appendChild(new XMLElement('message', 'Entry encountered errors when saving.'));
foreach ($errors as $err) {
$field = $entryManager->fieldManager->fetch($err['field_id']);
$result->appendChild(new XMLElement($field->get('element_name'), NULL, array('type' => 'invalid')));
}
if (isset($cookie) && is_object($cookie)) {
$result->appendChild($cookie);
}
return false;
} else {
if (!$entry->commit()) {
$result->setAttribute('result', 'error');
$result->appendChild(new XMLElement('message', 'Unknown errors where encountered when saving.'));
if (isset($cookie) && is_object($cookie)) {
$result->appendChild($cookie);
}
return false;
}
}
return $entry;
}
示例14: __construct
public function __construct(&$parent)
{
parent::__construct($parent);
$this->_uri = URL . '/symphony/extension/search_index';
$sectionManager = new SectionManager($this->_Parent);
$this->_sections = $sectionManager->fetch(NULL, 'ASC', 'name');
$this->_indexes = SearchIndex::getIndexes();
$this->_section = NULL;
$this->_index = NULL;
}
示例15: getSectionId
public function getSectionId()
{
$sectionManager = new SectionManager(Frontend::instance());
$section_id = $sectionManager->fetchIDFromHandle(General::sanitize($_REQUEST['MUUsource']));
if (!($section = $sectionManager->fetch($section_id))) {
return NULL;
} else {
return $section_id;
}
}