本文整理汇总了PHP中SpoonHTTP类的典型用法代码示例。如果您正苦于以下问题:PHP SpoonHTTP类的具体用法?PHP SpoonHTTP怎么用?PHP SpoonHTTP使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SpoonHTTP类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: parse
/**
* Parse the correct messages into the template
*/
protected function parse()
{
parent::parse();
// grab the error-type from the parameters
$errorType = $this->getParameter('type');
// set correct headers
switch ($errorType) {
case 'module-not-allowed':
case 'action-not-allowed':
SpoonHTTP::setHeadersByCode(403);
break;
case 'not-found':
SpoonHTTP::setHeadersByCode(404);
break;
}
// querystring provided?
if ($this->getParameter('querystring') !== null) {
// split into file and parameters
$chunks = explode('?', $this->getParameter('querystring'));
// get extension
$extension = SpoonFile::getExtension($chunks[0]);
// if the file has an extension it is a non-existing-file
if ($extension != '' && $extension != $chunks[0]) {
// set correct headers
SpoonHTTP::setHeadersByCode(404);
// give a nice error, so we can detect which file is missing
echo 'Requested file (' . htmlspecialchars($this->getParameter('querystring')) . ') not found.';
// stop script execution
exit;
}
}
// assign the correct message into the template
$this->tpl->assign('message', BL::err(SpoonFilter::toCamelCase(htmlspecialchars($errorType), '-')));
}
开发者ID:nickmancol,项目名称:forkcms-rhcloud,代码行数:37,代码来源:index.php
示例2: validateForm
/**
* Validate the form
*/
protected function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
$fields = $this->frm->getFields();
$fields['email']->isFilled(BL::err('FieldIsRequired'));
if ($this->frm->isCorrect()) {
//--Get the mail
$mailing = BackendMailengineModel::get($this->id);
//--Get the template
$template = BackendMailengineModel::getTemplate($mailing['template_id']);
//--Create basic mail
$text = BackendMailengineModel::createMail($mailing, $template);
$mailing['from_email'] = $template['from_email'];
$mailing['from_name'] = html_entity_decode($template['from_name']);
$mailing['reply_email'] = $template['reply_email'];
$mailing['reply_name'] = html_entity_decode($template['reply_name']);
$emails = explode(',', $fields['email']->getValue());
if (!empty($emails)) {
foreach ($emails as $email) {
$email = trim($email);
if (\SpoonFilter::isEmail($email)) {
//--Send test mailing
BackendMailengineModel::sendMail(html_entity_decode($mailing['subject']), $text, $email, 'Test Recepient', $mailing);
}
}
}
//--Redirect
\SpoonHTTP::redirect(BackendModel::createURLForAction('index', $this->module) . "&id=" . $this->id . "&report=TestEmailSend");
}
}
$this->frm->parse($this->tpl);
}
开发者ID:Comsa-Veurne,项目名称:modules,代码行数:36,代码来源:Test.php
示例3: outputCSV
/**
* Output a CSV-file as a download
*
* @param string $filename The name of the file.
* @param array $array The array to convert.
* @param array[optional] $columns The column names you want to use.
* @param array[optional] $excludeColumns The columns you want to exclude.
*/
public static function outputCSV($filename, array $array, array $columns = null, array $excludeColumns = null)
{
// get settings
$splitCharacter = BackendAuthentication::getUser()->getSetting('csv_split_character');
$lineEnding = BackendAuthentication::getUser()->getSetting('csv_line_ending');
// reformat
if ($lineEnding == '\\n') {
$lineEnding = "\n";
}
if ($lineEnding == '\\r\\n') {
$lineEnding = "\r\n";
}
// convert into CSV
$csv = SpoonFileCSV::arrayToString($array, $columns, $excludeColumns, $splitCharacter, '"', $lineEnding);
// set headers for download
$headers[] = 'Content-type: application/csv; charset=' . SPOON_CHARSET;
$headers[] = 'Content-Disposition: attachment; filename="' . $filename;
$headers[] = 'Content-Length: ' . strlen($csv);
$headers[] = 'Pragma: no-cache';
// overwrite the headers
SpoonHTTP::setHeaders($headers);
// ouput the CSV
echo $csv;
exit;
}
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:33,代码来源:csv.php
示例4: execute
/**
* Execute the action
*/
public function execute()
{
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// init vars
$templates = array();
$theme = BackendModel::getModuleSetting('core', 'theme');
$files[] = BACKEND_PATH . '/core/layout/editor_templates/templates.js';
$themePath = FRONTEND_PATH . '/themes/' . $theme . '/core/layout/editor_templates/templates.js';
if (SpoonFile::exists($themePath)) {
$files[] = $themePath;
}
// loop all files
foreach ($files as $file) {
// process file
$templates = array_merge($templates, $this->processFile($file));
}
// set headers
SpoonHTTP::setHeaders('Content-type: text/javascript');
// output the templates
if (!empty($templates)) {
echo 'CKEDITOR.addTemplates(\'default\', { imagesPath: \'/\', templates:' . "\n";
echo json_encode($templates) . "\n";
echo '});';
}
exit;
}
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:30,代码来源:templates.php
示例5: parse
/**
* Parse the ical and output into the browser.
*
* @param bool[optional] $headers Should the headers be set? (Use false if you're debugging).
*/
public function parse($headers = true)
{
// set headers
if ((bool) $headers) {
SpoonHTTP::setHeaders('Content-Disposition: inline; filename=' . SpoonFilter::urlise($this->getTitle()) . '.ics');
}
// call the parent
parent::parse($headers);
}
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:14,代码来源:ical.php
示例6: parse
/**
* Parse the iCal and output into the browser.
*
* @param bool $headers Should the headers be set? (Use false if you're debugging).
*/
public function parse($headers = true)
{
// set headers
if ((bool) $headers) {
\SpoonHTTP::setHeaders('Content-Disposition: inline; filename=' . CommonUri::getUrl($this->getTitle()) . '.ics');
}
// call the parent
parent::parse($headers);
}
开发者ID:arashrasoulzadeh,项目名称:forkcms,代码行数:14,代码来源:Ical.php
示例7: parse
/**
* Export the templates as XML.
*/
protected function parse()
{
$xml = Model::createTemplateXmlForExport($this->selectedTheme);
$filename = 'templates_' . BackendModel::getUTCDate('d-m-Y') . '.xml';
$headers = array('Content-type: text/xml', 'Content-disposition: attachment; filename="' . $filename . '"');
\SpoonHTTP::setHeaders($headers);
echo $xml;
exit;
}
开发者ID:arashrasoulzadeh,项目名称:forkcms,代码行数:12,代码来源:ExportThemeTemplates.php
示例8: display
/**
* Output the template into the browser
* Will also assign the interfacelabels and all user-defined constants.
*
* @param string $template The path for the template.
* @param bool[optional] $customHeaders Are there custom headers set?
*/
public function display($template, $customHeaders = false)
{
$this->parseConstants();
$this->parseAuthenticatedUser();
$this->parseDebug();
$this->parseLabels();
$this->parseLocale();
$this->parseVars();
// parse headers
if (!$customHeaders) {
SpoonHTTP::setHeaders('Content-type: text/html;charset=' . SPOON_CHARSET);
}
parent::display($template);
}
开发者ID:richsage,项目名称:forkcms,代码行数:21,代码来源:template.php
示例9: createXML
/**
* Create the XML based on the locale items.
*/
private function createXML()
{
$charset = BackendModel::getContainer()->getParameter('kernel.charset');
// create XML
$xmlOutput = BackendLocaleModel::createXMLForExport($this->locale);
// xml headers
$headers[] = 'Content-Disposition: attachment; filename="locale_' . BackendModel::getUTCDate('d-m-Y') . '.xml"';
$headers[] = 'Content-Type: application/octet-stream;charset=' . $charset;
$headers[] = 'Content-Length: ' . strlen($xmlOutput);
// set headers
\SpoonHTTP::setHeaders($headers);
// output XML
echo $xmlOutput;
exit;
}
开发者ID:arashrasoulzadeh,项目名称:forkcms,代码行数:18,代码来源:ExportAnalyse.php
示例10: createXML
/**
* Create the XML based on the locale items.
*
* @return void
*/
private function createXML()
{
// create XML
$xmlOutput = BackendLocaleModel::createXMLForExport($this->locale);
// xml headers
$headers[] = 'Content-Disposition: attachment; filename="locale_' . BackendModel::getUTCDate('d-m-Y') . '.xml"';
$headers[] = 'Content-Type: application/octet-stream;charset=utf-8';
$headers[] = 'Content-Length: ' . strlen($xmlOutput);
// set headers
SpoonHTTP::setHeaders($headers);
// output XML
echo $xmlOutput;
// stop script
exit;
}
开发者ID:netconstructor,项目名称:forkcms,代码行数:20,代码来源:export_analyse.php
示例11: createCsv
/**
* Create the CSV.
*
* @return void
*/
private function createCsv()
{
// create csv
$csv = SpoonFileCSV::arrayToString($this->rows, $this->columnHeaders);
// set headers for download
$headers[] = 'Content-type: application/csv; charset=utf-8';
$headers[] = 'Content-Disposition: attachment; filename="' . date('Ymd_His') . '.csv"';
$headers[] = 'Content-Length: ' . strlen($csv);
$headers[] = 'Pragma: no-cache';
// overwrite the headers
SpoonHTTP::setHeaders($headers);
// output
echo $csv;
// exit here
exit;
}
开发者ID:netconstructor,项目名称:forkcms,代码行数:21,代码来源:export_data.php
示例12: __construct
/**
* Check if all required settings have been set
*
* @param string $module The module.
*/
public function __construct($module)
{
parent::__construct($module);
$error = false;
$action = Spoon::exists('url') ? Spoon::get('url')->getAction() : null;
// analytics session token
if (BackendModel::getModuleSetting('analytics', 'session_token') === null) {
$error = true;
}
// analytics table id
if (BackendModel::getModuleSetting('analytics', 'table_id') === null) {
$error = true;
}
// missing settings, so redirect to the index-page to show a message (except on the index- and settings-page)
if ($error && $action != 'settings' && $action != 'index') {
SpoonHTTP::redirect(BackendModel::createURLForAction('index'));
}
}
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:23,代码来源:config.php
示例13: validateForm
/**
* Validate the form
*
* @return void
*/
private function validateForm()
{
// is the form submitted?
if ($this->frm->isSubmitted()) {
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// validate fields
$this->frm->getField('title')->isFilled(BL::err('TitleIsRequired'));
$this->frm->getField('street')->isFilled(BL::err('FieldIsRequired'));
$this->frm->getField('number')->isFilled(BL::err('FieldIsRequired'));
$this->frm->getField('zip')->isFilled(BL::err('FieldIsRequired'));
$this->frm->getField('city')->isFilled(BL::err('FieldIsRequired'));
// no errors?
if ($this->frm->isCorrect()) {
// build item
$item['language'] = BL::getWorkingLanguage();
$item['title'] = $this->frm->getField('title')->getValue();
$item['text'] = $this->frm->getField('text')->getValue();
$item['street'] = $this->frm->getField('street')->getValue();
$item['number'] = $this->frm->getField('number')->getValue();
$item['zip'] = $this->frm->getField('zip')->getValue();
$item['city'] = $this->frm->getField('city')->getValue();
$item['country'] = $this->frm->getField('country')->getValue();
// geocode address
$url = 'http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($item['street'] . ' ' . $item['number'] . ', ' . $item['zip'] . ' ' . $item['city'] . ', ' . SpoonLocale::getCountry($item['country'], BL::getWorkingLanguage())) . '&sensor=false';
$geocode = json_decode(SpoonHTTP::getContent($url));
$item['lat'] = isset($geocode->results[0]->geometry->location->lat) ? $geocode->results[0]->geometry->location->lat : null;
$item['lng'] = isset($geocode->results[0]->geometry->location->lng) ? $geocode->results[0]->geometry->location->lng : null;
// insert the item
$id = BackendLocationModel::insert($item);
// add search index
// if(is_callable(array('BackendSearchModel', 'addIndex'))) BackendSearchModel::addIndex($this->getModule(), (int) $id, array('title' => $item['title'], 'text' => $item['text']));
// everything is saved, so redirect to the overview
if ($item['lat'] && $item['lng']) {
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item));
// redirect
$this->redirect(BackendModel::createURLForAction('index') . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $id);
} else {
$this->redirect(BackendModel::createURLForAction('edit') . '&id=' . $id);
}
}
}
}
开发者ID:netconstructor,项目名称:forkcms,代码行数:49,代码来源:add.php
示例14: __construct
/**
* You have to specify the action and module so we know what to do with this instance
*
* @param string $action The action to load.
* @param string $module The module to load.
*/
public function __construct($action, $module)
{
$this->setModule($module);
$this->setAction($action);
$this->loadConfig();
$allowed = false;
// is this an allowed action
if (BackendAuthentication::isAllowedAction($action, $this->getModule())) {
$allowed = true;
}
// is this an allowed AJAX-action?
if (!$allowed) {
// set correct headers
SpoonHTTP::setHeadersByCode(403);
// output
$fakeAction = new BackendBaseAJAXAction('', '');
$fakeAction->output(BackendBaseAJAXAction::FORBIDDEN, null, 'Not logged in.');
}
}
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:25,代码来源:ajax_action.php
示例15: validateForm
/**
* Validate form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
if ($this->frm->isCorrect()) {
if (!empty($this->records)) {
$teller = 0;
foreach ($this->records as $key => $record) {
if ($teller < $this->frm->getField("number_of_items")->getValue()) {
$data = array();
//--Create url
$url = 'http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($record['address'] . ', ' . $record['zipcode'] . ' ' . $record['city'] . ', ' . \SpoonLocale::getCountry($record['country'], BL::getWorkingLanguage())) . '&sensor=false';
//--Get lat
$geocode = json_decode(\SpoonHTTP::getContent($url));
//--Sleep between the requests
sleep(0.05);
//--Check result
$data['lat'] = isset($geocode->results[0]->geometry->location->lat) ? $geocode->results[0]->geometry->location->lat : null;
$data['lng'] = isset($geocode->results[0]->geometry->location->lng) ? $geocode->results[0]->geometry->location->lng : null;
if ($data['lat'] != null) {
BackendAddressesModel::update($record['id'], $data);
$this->response .= "<strong>" . $record['company'] . "</strong> - " . $record['address'] . " " . $record['zipcode'] . " " . $record['city'] . " <i>(Lat: " . $data['lat'] . ", Lng: " . $data['lng'] . ")</i><br/>";
//--Delete from array
unset($this->records[$key]);
} else {
$data['lat'] = "notfound";
$data['lng'] = "notfound";
BackendAddressesModel::update($record['id'], $data);
$this->responseError .= "<strong>" . $record['company'] . "</strong> - " . $record['address'] . " " . $record['zipcode'] . " " . $record['city'] . "<br/>";
}
} else {
break;
}
//--Add teller
$teller++;
}
$this->tpl->assign("responseError", $this->responseError);
$this->tpl->assign("response", $this->response);
}
}
}
}
开发者ID:Comsa-Veurne,项目名称:modules,代码行数:44,代码来源:UpdateLatLng.php
示例16: display
/**
* Output the template into the browser
* Will also assign the interfacelabels and all user-defined constants.
*
* @return void
* @param string $template The path for the template.
* @param bool[optional] $customHeaders Are there custom headers set?
*/
public function display($template, $customHeaders = false)
{
// parse constants
$this->parseConstants();
// parse authenticated user
$this->parseAuthenticatedUser();
// check debug
$this->parseDebug();
// parse the label
$this->parseLabels();
// parse locale
$this->parseLocale();
// parse some vars
$this->parseVars();
// parse headers
if (!$customHeaders) {
SpoonHTTP::setHeaders('Content-type: text/html;charset=utf-8');
}
// call the parent
parent::display($template);
}
开发者ID:netconstructor,项目名称:forkcms,代码行数:29,代码来源:template.php
示例17: downloadCSV
/**
* Sets the headers so we may download the CSV file in question
*
* @param string $path The full path to the CSV file you wish to download.
* @return array
*/
private function downloadCSV($path)
{
// check if the file exists
if (!SpoonFile::exists($path)) {
throw new SpoonFileException('The file ' . $path . ' doesn\'t exist.');
}
// fetch the filename from the path string
$explodedFilename = explode('/', $path);
$filename = end($explodedFilename);
// set headers for download
$headers[] = 'Content-type: application/csv; charset=' . SPOON_CHARSET;
$headers[] = 'Content-Disposition: attachment; filename="' . $filename . '"';
$headers[] = 'Pragma: no-cache';
// overwrite the headers
SpoonHTTP::setHeaders($headers);
// get the file contents
$content = SpoonFile::getContent($path);
// output the file contents
echo $content;
exit;
}
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:27,代码来源:addresses.php
示例18: validateForm
/**
* Validate the form based on the variables in $_POST
*
* @return void
*/
private function validateForm()
{
// form submitted
if ($this->frm->isSubmitted()) {
// required fields
$this->frm->getField('email')->isEmail('Please provide a valid e-mailaddress.');
$this->frm->getField('password')->isFilled('This field is required.');
$this->frm->getField('confirm')->isFilled('This field is required.');
if ($this->frm->getField('password')->getValue() != $this->frm->getField('confirm')->getValue()) {
$this->frm->getField('confirm')->addError('The passwords do not match.');
}
// all valid
if ($this->frm->isCorrect()) {
// update session
SpoonSession::set('email', $this->frm->getField('email')->getValue());
SpoonSession::set('password', $this->frm->getField('password')->getValue());
SpoonSession::set('confirm', $this->frm->getField('confirm')->getValue());
// redirect
SpoonHTTP::redirect('index.php?step=7');
}
}
}
开发者ID:netconstructor,项目名称:forkcms,代码行数:27,代码来源:step_6.php
示例19: readFromFeed
/**
* Reads an feed into a SpoonRSS object.
*
* @return SpoonRSS Returns as an instance of SpoonRSS.
* @param string $URL An URL where the feed is located or the XML of the feed.
* @param string[optional] $type The type of feed, possible values are: url, string.
*/
public static function readFromFeed($URL, $type = 'url')
{
// redefine var
$URL = (string) $URL;
$type = (string) SpoonFilter::getValue($type, array('url', 'string'), 'url');
// validate
if ($type == 'url' && !SpoonFilter::isURL($URL)) {
throw new SpoonFeedException('This (' . SpoonFilter::htmlentities($URL) . ') isn\'t a valid URL.');
}
if (!self::isValid($URL, $type)) {
throw new SpoonFeedException('Invalid feed');
}
// load xmlstring
if ($type == 'url') {
$xmlString = SpoonHTTP::getContent($URL);
} else {
$xmlString = $URL;
}
// convert to simpleXML
$XML = @simplexml_load_string($xmlString);
// validate the feed
if ($XML === false) {
throw new SpoonFeedException('Invalid rss-string.');
}
// get title, link and description
$title = (string) $XML->channel->title;
$link = (string) $XML->channel->link;
$description = (string) $XML->channel->description;
// create instance
$RSS = new SpoonFeedRSS($title, $link, $description);
// add items
foreach ($XML->channel->item as $item) {
// try to read
try {
// read xml
$item = SpoonFeedRSSItem::readFromXML($item);
$RSS->addItem($item);
} catch (Exception $e) {
// ignore exceptions
}
}
// add category
if (isset($XML->channel->category)) {
foreach ($XML->channel->category as $category) {
if (isset($category['domain'])) {
$RSS->addCategory((string) $category, (string) $category['domain']);
} else {
$RSS->addCategory((string) $category);
}
}
}
// add skip day
if (isset($XML->channel->skipDays)) {
// loop ski-days
foreach ($XML->channel->skipDays->day as $day) {
// try to add
try {
// add skip-day
$RSS->addSkipDay((string) $day);
} catch (Exception $e) {
// ignore exceptions
}
}
}
// add skip hour
if (isset($XML->channel->skipHours)) {
foreach ($XML->channel->skipHours->hour as $hour) {
// try to add
try {
// add skip hour
$RSS->addSkipHour((int) $hour);
} catch (Exception $e) {
// ignore exceptions
}
}
}
// set cloud
if (isset($XML->channel->cloud['domain']) && isset($XML->channel->cloud['port']) && isset($XML->channel->cloud['path']) && isset($XML->channel->cloud['registerProce-dure']) && isset($XML->channel->cloud['protocol'])) {
// read attributes
$cloudDomain = (string) $XML->channel->cloud['domain'];
$cloudPort = (int) $XML->channel->cloud['port'];
$cloudPath = (string) $XML->channel->cloud['path'];
$cloudRegisterProcedure = (string) $XML->channel->cloud['registerProce-dure'];
$cloudProtocol = (string) $XML->channel->cloud['protocol'];
// set property
$RSS->setCloud($cloudDomain, $cloudPort, $cloudPath, $cloudRegisterProcedure, $cloudProtocol);
}
// set copyright
if (isset($XML->channel->copyright)) {
$copyright = (string) $XML->channel->copyright;
$RSS->setCopyright($copyright);
}
// set docs
//.........这里部分代码省略.........
开发者ID:jincongho,项目名称:clienthub,代码行数:101,代码来源:rss.php
示例20: exceptionAJAXHandler
/**
* This method will be called by the Spoon Exception handler and is specific for exceptions thrown in AJAX-actions
*
* @param object $exception The exception that was thrown.
* @param string $output The output that should be mailed.
*/
public static function exceptionAJAXHandler($exception, $output)
{
\SpoonHTTP::setHeaders('content-type: application/json');
$response = array('code' => $exception->getCode() != 0 ? $exception->getCode() : 500, 'message' => $exception->getMessage());
echo json_encode($response);
exit;
}
开发者ID:arashrasoulzadeh,项目名称:forkcms,代码行数:13,代码来源:Init.php
注:本文中的SpoonHTTP类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论