本文整理汇总了PHP中EntryManager类的典型用法代码示例。如果您正苦于以下问题:PHP EntryManager类的具体用法?PHP EntryManager怎么用?PHP EntryManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EntryManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __trigger
protected function __trigger()
{
$result = new XMLElement(self::ROOTELEMENT);
$success = false;
self::__init();
$db = ASDCLoader::instance();
$Members = $this->_Parent->ExtensionManager->create('members');
$Members->initialiseCookie();
if ($Members->isLoggedIn() !== true) {
$result->appendChild(new XMLElement('error', 'Must be logged in.'));
$result->setAttribute('status', 'error');
return $result;
}
$Members->initialiseMemberObject();
// Make sure we dont accidently use an expired code
extension_Members::purgeCodes();
$em = new EntryManager($this->_Parent);
$entry = end($em->fetch((int) $Members->Member->get('id')));
$email = $entry->getData(self::findFieldID('email-address', 'members'));
$name = $entry->getData(self::findFieldID('name', 'members'));
$success = $Members->emailNewMember(array('entry' => $entry, 'fields' => array('username-and-password' => $entry->getData(self::findFieldID('username-and-password', 'members')), 'name' => $name['value'], 'email-address' => $email['value'])));
if ($success == true && isset($_REQUEST['redirect'])) {
redirect($_REQUEST['redirect']);
}
$result->setAttribute('result', $success === true ? 'success' : 'error');
return $result;
}
示例2: __trigger
protected function __trigger()
{
self::__init();
$db = ASDCLoader::instance();
$success = false;
$Members = $this->_Parent->ExtensionManager->create('members');
$Members->initialiseCookie();
if ($Members->isLoggedIn() !== true) {
redirect(URL . '/forbidden/');
}
$Members->initialiseMemberObject();
// Make sure we dont accidently use an expired token
extension_Members::purgeCodes();
$activation_row = $db->query(sprintf("SELECT * FROM `tbl_members_codes` WHERE `token` = '%s' AND `member_id` = %d LIMIT 1", $db->escape($_POST['fields']['code']), (int) $Members->Member->get('id')))->current();
// No code, you are a spy!
if ($activation_row === false) {
redirect(URL . '/members/activate/failed/');
}
// Got this far, all is well.
$db->query(sprintf("UPDATE `tbl_entries_data_%d` SET `role_id` = %d WHERE `entry_id` = %d LIMIT 1", $Members->roleField(), 3, (int) $Members->Member->get('id')));
extension_Members::purgeTokens((int) $Members->Member->get('id'));
$em = new EntryManager($this->_Parent);
$entry = end($em->fetch((int) $Members->Member->get('id')));
$email = $entry->getData(self::findFieldID('email-address', 'members'));
$name = $entry->getData(self::findFieldID('name', 'members'));
$Members->emailNewMember(array('section' => $Members->memberSectionHandle(), 'entry' => $entry, 'fields' => array('username-and-password' => $entry->getData(self::findFieldID('username-and-password', 'members')), 'name' => $name['value'], 'email-address' => $email['value'])));
redirect(URL . '/members/activate/success/');
}
示例3: view
public function view()
{
$section_handle = (string) $this->context[0];
$page = isset($this->context[1]) ? (int) $this->context[1] : 1;
if (empty($section_handle)) {
die('Invalid section handle');
}
$config = (object) Symphony::Configuration()->get('elasticsearch');
ElasticSearch::init();
$type = ElasticSearch::getTypeByHandle($section_handle);
if ($page === 1) {
// delete all documents in this index
$query = new Elastica_Query(array('query' => array('match_all' => array())));
$type->type->deleteByQuery($query);
}
// get new entries
$em = new EntryManager(Symphony::Engine());
$entries = $em->fetchByPage($page, $type->section->get('id'), (int) $config->{'reindex-batch-size'}, NULL, NULL, FALSE, FALSE, TRUE);
foreach ($entries['records'] as $entry) {
ElasticSearch::indexEntry($entry, $type->section);
}
$entries['total-entries'] = 0;
// last page, count how many entries in the index
if ($entries['remaining-pages'] == 0) {
// wait a few seconds, allow HTTP requests to complete...
sleep(5);
$entries['total-entries'] = $type->type->count();
}
header('Content-type: application/json');
echo json_encode(array('pagination' => array('total-pages' => (int) $entries['total-pages'], 'total-entries' => (int) $entries['total-entries'], 'remaining-pages' => (int) $entries['remaining-pages'], 'next-page' => $page + 1)));
exit;
}
示例4: 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;
}
示例5: 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);
}
}
}
示例6: __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;
}
示例7: appendScriptToHead
public function appendScriptToHead($context)
{
$this->static_section_name = '';
$entryManager = new EntryManager($this->_Parent);
$sections = $this->_Parent->Database->fetch("SELECT section_id AS id, handle FROM tbl_fields_static_section LEFT JOIN tbl_sections ON tbl_fields_static_section.section_id = tbl_sections.id");
$this->section_data = array('handles' => array(), 'entries' => array());
foreach ($sections as $key => $value) {
$this->section_data['handles'][] = $value['handle'];
$result = $entryManager->fetch(NULL, $value['id'], NULL, NULL, NULL, NULL, false, false);
if (count($result) > 0) {
$this->section_data['entries'][] = $result[0]['id'];
} else {
$this->section_data['entries'][] = NULL;
}
}
$this->_page = Administration::instance()->Page;
$section_handle = $this->_page->_context['section_handle'];
$context = $this->_page->_context['page'];
$url_entry = $this->_page->_context['entry_id'];
$flag = $this->_page->_context['flag'];
if (isset($section_handle)) {
$section = $this->_Parent->Database->fetchRow(0, "SELECT id, name FROM tbl_sections WHERE handle='{$section_handle}'");
$field = $this->_Parent->Database->fetchRow(0, "SELECT id FROM tbl_fields_static_section WHERE section_id=" . $section['id']);
if ($field) {
$entry = $this->getSectionEntry($section_handle);
if ($context == 'new' && $entry) {
redirect(URL . '/symphony/publish/' . $section_handle . '/edit/' . $entry . '/');
}
if ($context == 'index') {
if ($entry) {
redirect(URL . '/symphony/publish/' . $section_handle . '/edit/' . $entry . '/');
} else {
redirect(URL . '/symphony/publish/' . $section_handle . '/new/');
}
}
if ($context == 'edit') {
if (!$entry) {
redirect(URL . '/symphony/publish/' . $section_handle . '/new/');
}
if ($url_entry != $entry) {
redirect(URL . '/symphony/publish/' . $section_handle . '/edit/' . $entry . '/');
}
}
if ($flag == 'saved' || $flag == 'created') {
$flag_msg = 'Entry updated at %1$s.';
if ($flag == 'created') {
$flag_msg = 'Entry created at %1$s.';
}
$this->_page->pageAlert(__($flag_msg, array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__))), Alert::SUCCESS);
}
$this->static_section_name = $section['name'];
}
}
}
示例8: __deleteMembers
private function __deleteMembers($role_id)
{
$sql = "SELECT `entry_id` FROM `tbl_entries_data_" . $this->_driver->roleField() . "` WHERE `role_id` = {$role_id}";
$members = Administration::Database()->fetchCol('entry_id', $sql);
###
# Delegate: Delete
# Description: Prior to deletion of entries. Array of Entries is provided.
# The array can be manipulated
Administration::instance()->ExtensionManager->notifyMembers('Delete', '/publish/', array('entry_id' => &$checked));
$entryManager = new EntryManager($this->_Parent);
$entryManager->delete($members);
}
示例9: __filterEntries
function __filterEntries($subsection_id, $fields, $filter, $entry_id)
{
// Fetch taglist, select and upload fields
$tag_fields = array();
foreach ($fields as $field) {
if (in_array($field->get('type'), array('taglist', 'select'))) {
$tag_fields[] = $field->get('id');
}
}
// Fetch entry data
$entryManager = new EntryManager($this->_Parent);
$entries = $entryManager->fetch($entry_id, $subsection_id);
// Setup filter
$gogoes = array();
$nonos = array();
$filters = array();
if ($filter != '') {
$filters = explode(', ', $filter);
}
foreach ($filters as $filter) {
$operator = substr($filter, 0, 1);
if ($operator == '-') {
$nonos[] = substr($filter, 1);
} else {
$gogoes[] = $filter;
}
}
// Filter entries and add select options
$field_data = array();
if (is_array($entries) && !empty($entries)) {
foreach ($entries as $entry) {
// Collect taglist and select field values
$tags = array();
foreach ($tag_fields as $field_id) {
$tag_values = $entry_data[$field_id]['value'];
if (!is_array($tag_values)) {
$tag_values = array($tag_values);
}
$tags = array_merge($tags, $tag_values);
}
// Investigate entry exclusion
$filter_nonos = array_intersect($tags, $nonos);
// Investigate entry inclusion
$filter_gogoes = array_intersect($tags, $gogoes);
// Filter entries
if (empty($filter_nonos) && (!empty($filter_gogoes) || empty($gogoes))) {
$entry_data[] = array('data' => $entry->getData(), 'id' => $entry->get('id'));
}
}
}
// Return filtered entry data
return $entry_data;
}
示例10: __viewIndex
/**
* Builds captions based on $_POST values.
*
* @return json object - { id: caption }
*/
public function __viewIndex()
{
$related_section_id = intval($_POST['related_section_id']);
$field_id = intval($_POST['field_id']);
$items = explode(',', $_POST['items']);
$id = array();
foreach ($items as $item) {
array_push($id, intval($item));
}
// fetch field data
$sectionManager = new SectionManager($this->_Parent);
$section = $sectionManager->fetch($related_section_id, 'ASC', 'name');
$fields = $section->fetchFields();
// fetch entry data
$entryManager = new EntryManager($this->_Parent);
$entries = $entryManager->fetch($id, $related_section_id);
// create formated captions
$result = array();
$template = Administration::instance()->Database->fetch("SELECT `caption` \n\t\t\t\tFROM `tbl_fields_mediathek` \n\t\t\t\tWHERE `related_section_id` = " . $related_section_id . " \n\t\t\t\tAND `field_id`= " . $field_id . " \n\t\t\t\tLIMIT 0 , 1");
$template = $template[0]['caption'];
if (empty($template)) {
$template = '{$' . $fields[0]->get('element_name') . '}';
}
foreach ($entries as $entry) {
$caption = $template;
$file = '';
$entry_data = $entry->getData();
foreach ($fields as $field) {
$field_name = $field->get('element_name');
$field_id = $field->get('id');
$field_data = $entry_data[$field_id]['value'];
if (is_array($field_data)) {
$field_value = implode(', ', $field_data);
} elseif (empty($field_data) && $entry_data[$field_id]['file']) {
$field_value = $entry_data[$field_id]['file'];
} else {
$field_value = $field_data;
}
$caption = str_replace('{$' . $field_name . '}', $field_value, $caption);
// get file
if (strpos($field->get('type'), 'upload') !== false && !empty($entry_data[$field->get('id')]['file'])) {
$file = $this->buildAttachment($entry_data[$field->get('id')]['file']);
}
}
$result[$entry->_fields['id']] = '<span>' . $caption . '</span>' . $file;
}
if (empty($result)) {
exit;
}
echo json_encode($result);
exit;
}
示例11: grab
function grab($param = array())
{
extract($this->_env, EXTR_PREFIX_ALL, 'env');
include_once TOOLKIT . '/class.entrymanager.php';
$entryManager = new EntryManager($this->_parent);
$section_id = $entryManager->fetchSectionIDFromHandle($this->__resolveDefine("dsFilterPARENTSECTION"));
$schema = $entryManager->fetchEntryFieldSchema($section_id, NULL, $this->_dsFilterCUSTOMFIELD);
$schema = $schema[0];
##Check the cache
$hash_id = md5(get_class($this));
if ($param['caching'] && ($cache = $this->check_cache($hash_id))) {
return $cache;
exit;
}
##------------------------------
##Create the XML container
$xml = new XMLElement("categories-list");
$xml->setAttribute("section", "customfield");
##Populate the XML
if (empty($schema) || !is_array($schema)) {
$xml->addChild(new XMLElement("error", "No Records Found."));
return $xml;
} else {
$ops = preg_split('/,/', $schema['values'], -1, PREG_SPLIT_NO_EMPTY);
$ops = array_map("trim", $ops);
$xml->addChild(new XMLElement("name", $schema['name']));
$xml->setAttribute("handle", $schema['handle']);
$options = new XMLElement("options");
foreach ($ops as $o) {
if ($schema['type'] == 'multiselect') {
$table = 'tbl_entries2customfields_list';
} else {
$table = 'tbl_entries2customfields';
}
$count = $this->_db->fetchVar('count', 0, "SELECT count(id) AS `count` FROM `{$table}` WHERE `field_id` = '" . $schema['id'] . "' AND value_raw = '{$o}' ");
$xO = new XMLElement("option", $o);
$xO->setAttribute('entry-count', $count);
$xO->setAttribute('handle', Lang::createHandle($o, $this->_parent->getConfigVar('handle_length', 'admin')));
$options->addChild($xO);
}
$xml->addChild($options);
}
##------------------------------
##Write To Cache
if ($param['caching']) {
$result = $xml->generate($param['indent'], $param['indent-depth']);
$this->write_to_cache($hash_id, $result, $this->_cache_sections);
return $result;
}
return $xml;
}
示例12: unserializeEntry
public function unserializeEntry($entry_id, $version)
{
$entry = unserialize(file_get_contents(MANIFEST . '/versions/' . $entry_id . '/' . $version . '.dat'));
$entryManager = new EntryManager(Symphony::Engine());
$new_entry = $entryManager->create();
$new_entry->set('id', $entry['id']);
$new_entry->set('author_id', $entry['author_id']);
$new_entry->set('section_id', $entry['section_id']);
$new_entry->set('creation_date', $entry['creation_date']);
$new_entry->set('creation_date_gmt', $entry['creation_date_gmt']);
foreach ($entry['data'] as $field_id => $value) {
$new_entry->setData($field_id, $value);
}
return $new_entry;
}
示例13: view
public function view()
{
$entryManager = new EntryManager(Administration::instance());
$field = $entryManager->fieldManager->fetch($_GET['field']);
$section = $entryManager->sectionManager->fetch($field->get('parent_section'));
$entry_column = current($section->fetchVisibleColumns());
// Display the first column from every entry in the linked section
$entries = $entryManager->fetch(null, $field->get('parent_section'));
foreach ($entries as $entry) {
$values = $entry->getData($entry_column->get('id'));
$el = new XMLElement("entry", General::sanitize($values['value']));
$el->setAttribute('id', $entry->get('id'));
$this->_Result->appendChild($el);
}
}
示例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);
$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;
}
示例15: 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;
}