本文整理汇总了PHP中SectionManager::fetchIDFromHandle方法的典型用法代码示例。如果您正苦于以下问题:PHP SectionManager::fetchIDFromHandle方法的具体用法?PHP SectionManager::fetchIDFromHandle怎么用?PHP SectionManager::fetchIDFromHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SectionManager
的用法示例。
在下文中一共展示了SectionManager::fetchIDFromHandle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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);
}
}
示例3: init
public static function init()
{
if (REST_API::getOutputFormat() == 'csv' && !REST_API::getHTTPMethod() == 'get') {
REST_API::sendError(sprintf('%s output format not supported for %s requests.', strtoupper(REST_API::getOutputFormat()), strtoupper(REST_API::getHTTPMethod())), 401, 'xml');
}
$request_uri = REST_API::getRequestURI();
self::$_section_handle = $request_uri[0];
self::$_entry_id = $request_uri[1];
$section_id = SectionManager::fetchIDFromHandle(self::$_section_handle);
if (!$section_id) {
REST_API::sendError('Section not found.', 404);
}
self::$_section_id = $section_id;
self::setDatasourceParam('included_elements', $_REQUEST['fields']);
self::setDatasourceParam('limit', $_REQUEST['limit']);
self::setDatasourceParam('page', $_REQUEST['page']);
self::setDatasourceParam('sort', $_REQUEST['sort']);
self::setDatasourceParam('order', $_REQUEST['order']);
self::setDatasourceParam('groupby', $_REQUEST['groupby']);
$filters = $_REQUEST['filter'];
if (!is_null($filters) && !is_array($filters)) {
$filters = array($filters);
}
self::setDatasourceParam('filters', $filters);
}
示例4: hasInstance
public static function hasInstance($ext_name = NULL, $section_handle)
{
$sid = SectionManager::fetchIDFromHandle($section_handle);
$section = SectionManager::fetch($sid);
$fm = $section->fetchFields($ext_name);
return is_array($fm) && !empty($fm);
}
示例5: __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;
}
示例6: 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);
}
}
示例7: 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;
}
}
示例8: findSection
public static function findSection($handle)
{
if (!is_numeric($handle)) {
$handle = SectionManager::fetchIDFromHandle($handle);
}
$ret = SectionManager::fetch($handle);
if (!is_object($ret)) {
self::throwEx('Section does not exist');
}
return $ret;
}
示例9: initaliseAdminPageHead
public function initaliseAdminPageHead($context)
{
$page = $context['oPage'];
$assets_path = '/extensions/massuploadutility/assets/';
// to check if it's an excluded section
$section_id = SectionManager::fetchIDFromHandle($page->_context['section_handle']);
if ($page instanceof contentPublish and $page->_context['page'] == 'new' and $this->validateSection($section_id) and $this->validateUser()) {
Administration::instance()->Page->addStylesheetToHead(URL . $assets_path . 'massuploadutility.css', 'screen', 14145);
Administration::instance()->Page->addScriptToHead(URL . $assets_path . 'massuploadutility.publish.js', 14156);
Administration::instance()->Page->addScriptToHead(URL . $assets_path . 'jquery.html5_upload.js', 14156);
}
}
示例10: appendScripts
public function appendScripts($context)
{
$callback = $context['parent']->getPageCallback();
if (in_array($callback['driver'], array('blueprintspages', 'blueprintsutilities'))) {
$context['parent']->Page->addScriptToHead(URL . '/extensions/zencoding/assets/zen_textarea.min.js', 1000, false);
}
if ($callback['driver'] == 'publish') {
$sectionManager = new SectionManager($context['parent']);
$section_id = $sectionManager->fetchIDFromHandle($callback['context']['section_handle']);
if ($this->__isAllowedSection($section_id)) {
$context['parent']->Page->addScriptToHead(URL . '/extensions/zencoding/assets/zen_textarea.min.js', 1000, false);
}
}
}
示例11: __viewIndex
public function __viewIndex()
{
header('content-type: text/javascript');
$sm = new SectionManager($this->_Parent);
$section_id = $sm->fetchIDFromHandle($_GET['section']);
$section = $sm->fetch($section_id);
$em = new EntryManager($this->_Parent);
$entry_id = $_GET['entry'];
$e = $em->fetch($entry_id);
$fields = array();
$data = $e[0]->getData();
foreach ($section->fetchFieldsSchema() as $field) {
// Set field names and take strange date field name into account
$field['element_name'] = $field['type'] == 'date' ? 'fields[' . $field['element_name'] . ']' . $field['element_name'] : 'fields[' . $field['element_name'] . ']';
// Populate field elements with value, depending on field type
switch ($field['type']) {
case 'author':
$fields[$field['element_name']] = $data[$field['id']]['author_id'];
break;
case 'upload':
$fields[$field['element_name']] = $data[$field['id']]['file'];
break;
case 'selectbox_link':
$fields[$field['element_name']] = $data[$field['id']]['relation_id'];
break;
case 'input':
case 'textarea':
case 'taglist':
case 'select':
case 'checkbox':
case 'date':
case 'order_entries':
$fields[$field['element_name']] = $data[$field['id']]['value'];
break;
default:
if (!empty($data[$field['id']]['value'])) {
$fields[$field['element_name']] = $data[$field['id']]['value'];
} else {
// Fall back on first array element
// Add field type to switch for accurate specification
$fields[$field['element_name']] = $data[$field['id']][0];
}
break;
}
}
echo 'jQuery(document).ready(function() { jQuery(\'form\').populate(' . json_encode($fields) . ")});\n";
exit;
}
示例12: dAdminPagePreGenerate
public function dAdminPagePreGenerate($context)
{
$callback = Administration::instance()->getPageCallback();
if ($callback['context']['page'] === 'edit') {
/** @var $cxt XMLElement */
$cxt = $context['oPage']->Context;
if (!$cxt instanceof XMLElement) {
return;
}
$actions = $cxt->getChildByName('ul', 0);
// append list of actions if missing
if (!$actions instanceof XMLElement) {
$ul = new XMLelement('ul', null, array('class' => 'actions'));
$cxt->appendChild($ul);
$actions = $cxt->getChildByName('ul', 0);
}
// fetch entries
$section_id = SectionManager::fetchIDFromHandle($callback['context']['section_handle']);
$section = SectionManager::fetch($section_id);
EntryManager::setFetchSorting($section->getSortingField(), $section->getSortingOrder());
$entries = EntryManager::fetch(null, $section_id, null, null, null, null, null, false, false);
// get next and prev
$entry_id = $prev_id = $next_id = $callback['context']['entry_id'];
$count = count($entries);
for ($i = 0; $i < $count; $i++) {
if ($entries[$i]['id'] == $entry_id) {
$prev_id = $i == 0 ? $entries[$count - 1]['id'] : $entries[$i - 1]['id'];
$next_id = $i == $count - 1 ? $entries[0]['id'] : $entries[$i + 1]['id'];
break;
}
}
if ($prev_id == $entry_id && $next_id == $entry_id) {
return;
}
// add buttons
$li = new XMLelement('li', null, array('class' => 'entry-nav'));
if ($prev_id !== $entry_id) {
$li->appendChild(Widget::Anchor(__('← Previous'), SYMPHONY_URL . $callback['pageroot'] . 'edit/' . $prev_id, null, 'button entry-nav-prev', null, array('accesskey' => 'z')));
}
if ($next_id !== $entry_id) {
$li->appendChild(Widget::Anchor(__('Next →'), SYMPHONY_URL . $callback['pageroot'] . 'edit/' . $next_id, null, 'button entry-nav-next', null, array('accesskey' => 'x')));
}
$actions->appendChild($li);
}
}
示例13: getSection
/**
* Get a Section object from a handle or ID. If section is not found, returns null
*
* @param $section (optional) - section handle or ID. If null, section handle will be taken form $callback
*
* @return null|Section
*/
public static function getSection($section = null)
{
if ($section instanceof Section) {
return $section;
}
if ($section === null) {
$callback = Administration::instance()->getPageCallback();
if (!isset($callback['context']['section_handle'])) {
return null;
}
$section = $callback['context']['section_handle'];
}
$section_id = is_numeric($section) ? $section : SectionManager::fetchIDFromHandle($section);
$s = SectionManager::fetch($section_id);
if (!$s instanceof Section) {
return null;
}
return $s;
}
示例14: __viewIndex
public function __viewIndex()
{
header('content-type: text/javascript');
$sm = new SectionManager($this->_Parent);
$section_id = $sm->fetchIDFromHandle($_GET['section']);
$section = $sm->fetch($section_id);
$fields = array();
foreach ($section->fetchFilterableFields() as $field) {
$html = new XMLElement('html');
$field->displayPublishPanel($html);
$dom = new DomDocument();
$dom->loadXML($html->generate());
$xpath = new DomXPath($dom);
$count = 0;
// if the generated HTML contains a file upload element
foreach ($xpath->query("//*[name()='input' and @type='file']") as $file) {
$fields[$field->get('element_name')]['section'] = $_GET['section'];
$fields[$field->get('element_name')]['field_id'] = $field->get('id');
$fields[$field->get('element_name')]['handle'] = $field->get('element_name');
$fields[$field->get('element_name')]['destination'] = $field->get('destination');
// if a validator regular expression has been set we need to parse and explode into Uploadify syntax
if ($field->get('validator')) {
$validator = str_replace('$/i', '', $field->get('validator'));
$validator = trim($validator, '():?[]\\/.');
$validator = explode('|', $validator);
foreach ($validator as $type) {
if ($type == 'jpe?g') {
$fields[$field->get('element_name')]['types'] .= '*.jpg;*.jpeg;';
} else {
$fields[$field->get('element_name')]['types'] .= '*.' . $type . ';';
}
}
$fields[$field->get('element_name')]['types'] = trim($fields[$field->get('element_name')]['types'], ';');
} else {
$fields[$field->get('element_name')]['types'] = '*.*';
}
}
}
echo 'var upload_fields = ', json_encode($fields), ";\n";
echo 'var PHPSESSID = "', session_id(), "\";\n";
exit;
}
示例15: adminPagePostCallback
public function adminPagePostCallback($context)
{
// check if logged in
if (!Administration::instance()->isLoggedIn()) {
return;
}
// check driver
if ($context['callback']['driver'] !== 'publish') {
return;
}
// get context
$page = $context['callback']['context']['page'];
$section = $context['callback']['context']['section_handle'];
// check section
if (!($section = SectionManager::fetchIDFromHandle($section))) {
return;
}
if (!($section = SectionManager::fetch($section))) {
return;
}
// check setting
if ($section->get('single') !== 'yes') {
return;
}
// set flag
$this->single = true;
// check page
if ($page === 'edit') {
return;
}
// check entries
if ($entries = EntryManager::fetch(null, $section->get('id'), 1, 0)) {
// set entry
$context['callback']['context']['entry_id'] = current($entries)->get('id');
// reroute
$context['callback']['context']['page'] = 'edit';
} else {
// reroute
$context['callback']['context']['page'] = 'new';
}
}