本文整理汇总了PHP中Symphony::Engine方法的典型用法代码示例。如果您正苦于以下问题:PHP Symphony::Engine方法的具体用法?PHP Symphony::Engine怎么用?PHP Symphony::Engine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symphony
的用法示例。
在下文中一共展示了Symphony::Engine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: appendAssets
/**
* Append assets
*/
public function appendAssets()
{
$callback = Symphony::Engine()->getPageCallback();
if ($callback['driver'] == 'publish' && $callback['context']['page'] === 'index') {
Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/association_field/assets/association_field.publish.css');
}
}
示例2: 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;
}
示例3: 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);
}
示例4: getXPath
public function getXPath($entry)
{
$fieldManager = new FieldManager(Symphony::Engine());
$entry_xml = new XMLElement('entry');
$section_id = $entry->get('section_id');
$data = $entry->getData();
$fields = array();
$entry_xml->setAttribute('id', $entry->get('id'));
$associated = $entry->fetchAllAssociatedEntryCounts();
if (is_array($associated) and !empty($associated)) {
foreach ($associated as $section => $count) {
$handle = Symphony::Database()->fetchVar('handle', 0, "\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\ts.handle\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t`tbl_sections` AS s\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\ts.id = '{$section}'\n\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t");
$entry_xml->setAttribute($handle, (string) $count);
}
}
// Add fields:
foreach ($data as $field_id => $values) {
if (empty($field_id)) {
continue;
}
$field = $fieldManager->fetch($field_id);
$field->appendFormattedElement($entry_xml, $values, false, null);
}
$xml = new XMLElement('data');
$xml->appendChild($entry_xml);
$dom = new DOMDocument();
$dom->strictErrorChecking = false;
$dom->loadXML($xml->generate(true));
$xpath = new DOMXPath($dom);
if (version_compare(phpversion(), '5.3', '>=')) {
$xpath->registerPhpFunctions();
}
return $xpath;
}
示例5: eventPreSaveFilter
public function eventPreSaveFilter(array $context)
{
if (!in_array('xss-fail', $context['event']->eParamFILTERS) && !in_array('validate-xsrf', $context['event']->eParamFILTERS)) {
return;
}
$contains_xss = FALSE;
// Loop over the fields to check for XSS, this loop will
// break as soon as XSS is detected
foreach ($context['fields'] as $field => $value) {
if (is_array($value)) {
if (self::detectXSSInArray($value) === FALSE) {
continue;
}
$contains_xss = TRUE;
break;
} else {
if (self::detectXSS($value) === FALSE) {
continue;
}
$contains_xss = TRUE;
break;
}
}
// Detect XSS filter
if (in_array('xss-fail', $context['event']->eParamFILTERS) && $contains_xss === TRUE) {
$context['messages'][] = array('xss', FALSE, __("Possible XSS attack detected in submitted data"));
}
// Validate XSRF token filter
if (in_array('validate-xsrf', $context['event']->eParamFILTERS)) {
if (Symphony::Engine()->isXSRFEnabled() && is_session_empty() === false && XSRF::validateRequest(true) === false) {
$context['messages'][] = array('xsrf', FALSE, __("Request was rejected for having an invalid cross-site request forgery token."));
}
}
}
示例6: __trigger
protected function __trigger()
{
$result = null;
$actionName = $this->getActionName();
$requestMethod = $this->getRequestMethod();
$requestArray = $this->getRequestArray();
if ($_SERVER['REQUEST_METHOD'] == $requestMethod && isset($requestArray[$actionName])) {
$result = new XMLElement($actionName);
$r = new XMLElement('result');
$id = intval($_POST['id']);
try {
$this->validate();
$entry = $this->createEntryFromPost($id);
$this->visitEntry($entry);
$r->setAttribute('success', 'yes');
$r->setAttribute('id', $entry->get('id'));
} catch (Exception $ex) {
$xmlEx = new XMLElement('error');
$showMsg = $ex instanceof InsertSectionException || Symphony::Engine()->isLoggedIn();
$errorMessage = $showMsg ? $ex->getMessage() : __('A Fatal error occured');
$xmlEx->setValue($errorMessage);
$result->appendChild($xmlEx);
$r->setAttribute('success', 'no');
Symphony::Log()->pushExceptionToLog($ex, true);
}
$result->appendChild($r);
} else {
throw new FrontendPageNotFoundException();
}
return $result;
}
示例7: __authenticate
private static function __authenticate()
{
$logged_in = Symphony::Engine()->isLoggedIn();
if (!$logged_in) {
self::sendError('API is private. Authentication failed.', 403);
}
}
示例8: __construct
/**
* The constructor for the `XSLTPage` ensures that an `XSLTProcessor`
* is available, and then sets an instance of it to `$this->Proc`, otherwise
* it will throw a `SymphonyErrorPage` exception.
*/
public function __construct()
{
if (!XsltProcess::isXSLTProcessorAvailable()) {
Symphony::Engine()->throwCustomError(__('No suitable XSLT processor was found.'));
}
$this->Proc = new XsltProcess();
}
示例9: __construct
public function __construct()
{
$this->_XSLTProc = new XsltProcess();
$this->_XML = new XMLElement("data");
$this->viewDir = ENVIEWS . '/recipientgroups';
parent::__construct(Symphony::Engine());
}
示例10: start
public function start()
{
if (!is_object($this->getTemplate())) {
$this->setStatus('error-template');
return;
}
if (!is_object($this->getSender())) {
$this->setStatus('error-sender');
return;
}
if (empty($this->_recipientgroups)) {
$this->setStatus('error-recipients');
return;
}
// Never start if the newsletter is sending or completed
if ($this->getStatus() == 'sending' || $this->getStatus() == 'completed') {
return;
}
$this->generatePAuth();
Symphony::Database()->query("CREATE TABLE IF NOT EXISTS `tbl_tmp_email_newsletters_sent_" . $this->getId() . "` (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `email` varchar(255),\n `result` varchar(255),\n PRIMARY KEY (`id`),\n KEY `email` (`email`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
Symphony::Database()->query('DELETE FROM `tbl_tmp_email_newsletters_sent_' . $this->getId() . '` WHERE `result` = \'idle\'');
$this->setStatus('sending');
$author_id = 0;
if (Symphony::Engine() instanceof Administration) {
$author_id = Symphony::Author()->get('id');
} elseif (Symphony::Engine() instanceof Frontend && Symphony::ExtensionManager()->fetchStatus('members') == EXTENSION_ENABLED) {
$Members = Symphony::ExtensionManager()->create('members');
$author_id = $Members->getMemberDriver()->getMemberID();
}
Symphony::Database()->update(array('started_on' => date('Y-m-d H:i:s', time()), 'started_by' => $author_id), 'tbl_email_newsletters', 'id = ' . $this->getId());
EmailBackgroundProcess::spawnProcess($this->getId(), $this->getPAuth());
}
示例11: 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);
}
}
}
}
}
示例12: appendStyles
public function appendStyles($context)
{
$callback = Administration::instance()->getPageCallback();
if (is_a(Symphony::Engine(), 'Administration')) {
Symphony::Engine()->Page->addScriptToHead(URL . '/extensions/email_newsletter_manager/assets/email_newsletter_manager.admin.js', 70);
Symphony::Engine()->Page->addStylesheetToHead(URL . '/extensions/email_newsletter_manager/assets/email_newsletter_manager.recipientgroups.preview.css', 'screen', 1000);
}
}
示例13: processRawFieldData
public function processRawFieldData($data, &$status, $simulate = false, $entry_id = null)
{
$status = self::__OK__;
$author = 'frontend user';
if (Symphony::Engine() instanceof Administration) {
$author = Administration::instance()->Author->getFullName();
}
return array('value' => '', 'last_modified' => DateTimeObj::get('Y-m-d H:i:s', time()), 'last_modified_author' => $author);
}
示例14: appendAssets
/**
* Append assets to the page head
* @param object $context
*/
public function appendAssets($context)
{
$callback = Symphony::Engine()->getPageCallback();
if ($callback['context']['page'] == 'edit') {
Administration::instance()->Page->addScriptToHead(URL . '/extensions/folio_overrides/assets/folio_overrides.fields.js');
Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/folio_overrides/assets/folio_overrides.fields.css');
}
Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/folio_overrides/assets/folio_overrides.css');
}
示例15: appendAssets
/**
* Append assets
*/
public function appendAssets()
{
$callback = Symphony::Engine()->getPageCallback();
if ($callback['driver'] == 'publish') {
Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/association_ui_selector/assets/aui.selector.publish.css');
Administration::instance()->Page->addScriptToHead(URL . '/extensions/association_ui_selector/assets/selectize.js');
Administration::instance()->Page->addScriptToHead(URL . '/extensions/association_ui_selector/assets/aui.selector.publish.js');
}
}