本文整理汇总了PHP中SPRequest类的典型用法代码示例。如果您正苦于以下问题:PHP SPRequest类的具体用法?PHP SPRequest怎么用?PHP SPRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SPRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: menu
protected function menu(&$data)
{
if (Sobi::Cfg('general.top_menu', true)) {
$data['menu'] = array('front' => array('_complex' => 1, '_data' => Sobi::Reg('current_section_name'), '_attributes' => array('lang' => Sobi::Lang(false), 'url' => Sobi::Url(array('sid' => Sobi::Section())))));
if (Sobi::Can('section.search')) {
$data['menu']['search'] = array('_complex' => 1, '_data' => Sobi::Txt('MN.SEARCH'), '_attributes' => array('lang' => Sobi::Lang(false), 'url' => Sobi::Url(array('task' => 'search', 'sid' => Sobi::Section()))));
}
if (Sobi::Can('entry', 'add', 'own', Sobi::Section())) {
$data['menu']['add'] = array('_complex' => 1, '_data' => Sobi::Txt('MN.ADD_ENTRY'), '_attributes' => array('lang' => Sobi::Lang(false), 'url' => Sobi::Url(array('task' => 'entry.add', 'sid' => SPRequest::sid()))));
}
}
}
示例2: progress
public function progress($percent, $message = null, $type = SPC::INFO_MSG, $interval = 1000)
{
$this->id = SPRequest::cmd('ProgressMsg', null, 'cookie');
$percent = ceil($percent);
$this->msg = strlen($message) ? $message : $this->msg;
$this->status($message, $percent, $interval, $type);
}
示例3: init
/**
* Simple initialisation method
*
*/
public function init()
{
if (self::$cs) {
Sobi::Error('config', SPLang::e('CRITICAL_SECTION_VIOLATED'), SPC::ERROR, 500, __LINE__, __CLASS__);
}
/* define critical section to avoid infinite loops */
self::$cs = true;
$nameField = self::key('entry.name_field');
if ($nameField) {
$fc = SPLoader::loadModel('field');
$field = new $fc();
$field->init($nameField);
$this->set('name_field_nid', $field->get('nid'), 'entry');
$this->set('name_field_id', $field->get('fid'), 'entry');
}
if (defined('SOBIPRO_ADM')) {
if (self::key('language.adm_domain')) {
SPLang::registerDomain(self::key('language.adm_domain'));
}
} else {
if (self::key('language.domain')) {
SPLang::registerDomain(self::key('language.domain'));
}
}
/* set allowed request attributes and tags */
SPRequest::setTagsAllowed($this->key('html.allowed_tags_array'));
SPRequest::setAttributesAllowed($this->key('html.allowed_attributes_array'));
$this->_store['general']['root'] = SOBI_ROOT;
$this->_store['general']['path'] = SOBI_PATH;
$this->_store['general']['cms'] = SOBI_CMS;
$this->_store['general']['live_path'] = SOBI_LIVE_PATH;
/* leave critical section */
self::$cs = false;
}
示例4: upload
protected function upload()
{
$ident = SPRequest::cmd('ident', null, 'post');
$data = SPRequest::file($ident, 'tmp_name');
$secret = md5(Sobi::Cfg('secret'));
if ($data) {
$properties = SPRequest::file($ident);
$fileName = md5(SPRequest::file($ident, 'name') . time() . $secret);
$path = SPLoader::dirPath("tmp.files.{$secret}", 'front', false) . '/' . $fileName;
/** @var $file SPFile */
$file = SPFactory::Instance('base.fs.file');
if (!$file->upload($data, $path)) {
$this->message(array('type' => 'error', 'text' => SPLang::e('CANNOT_UPLOAD_FILE'), 'id' => ''));
}
$path = $file->getPathname();
$type = $this->check($path);
$properties['tmp_name'] = $path;
SPFs::write($path . '.var', SPConfig::serialize($properties));
$response = array('type' => 'success', 'text' => Sobi::Txt('FILE_UPLOADED', $properties['name'], $type), 'id' => 'file://' . $fileName, 'data' => array('name' => $properties['name'], 'type' => $properties['type'], 'size' => $properties['size']));
} else {
$response = array('type' => 'error', 'text' => SPLang::e('CANNOT_UPLOAD_FILE_NO_DATA'), 'id' => '');
}
// $field = SPRequest::cmd( 'field', null );
$this->message($response);
}
示例5: install
public function install()
{
$id = $this->xGetString('id');
$name = $this->xGetString('name');
if (SPLoader::dirPath('usr.templates.' . $id) && !SPRequest::bool('force')) {
throw new SPException(SPLang::e('TEMPLATE_INST_DUPLICATE', $name) . ' ' . Sobi::Txt('FORCE_TPL_UPDATE', Sobi::Url(array('task' => 'extensions.install', 'force' => 1, 'root' => basename($this->root) . '/' . basename($this->xmlFile)))));
}
$requirements = $this->xGetChilds('requirements/*');
if ($requirements && $requirements instanceof DOMNodeList) {
SPFactory::Instance('services.installers.requirements')->check($requirements);
}
$language = $this->xGetChilds('language/file');
$folder = @$this->xGetChilds('language/@folder')->item(0)->nodeValue;
if ($language && $language instanceof DOMNodeList && $language->length) {
$langFiles = array();
foreach ($language as $file) {
$adm = false;
if ($file->attributes->getNamedItem('admin')) {
$adm = $file->attributes->getNamedItem('admin')->nodeValue == 'true' ? true : false;
}
$langFiles[$file->attributes->getNamedItem('lang')->nodeValue][] = array('path' => Sobi::FixPath("{$this->root}/{$folder}/" . trim($file->nodeValue)), 'name' => $file->nodeValue, 'adm' => $adm);
}
SPFactory::CmsHelper()->installLang($langFiles, false, true);
}
$path = SPLoader::dirPath('usr.templates.' . $id, 'front', false);
if (SPRequest::bool('force')) {
/** @var $from SPDirectory */
$from = SPFactory::Instance('base.fs.directory', $this->root);
$from->moveFiles($path);
} else {
if (!SPFs::move($this->root, $path)) {
throw new SPException(SPLang::e('CANNOT_MOVE_DIRECTORY', $this->root, $path));
}
}
if (!SPRequest::bool('force')) {
$section = $this->xGetChilds('install');
if ($section instanceof DOMNodeList && $section->length) {
$this->section($id);
}
}
//05 Oct 2015 Kishore
$exec = $this->xGetString('exec');
if ($exec && SPFs::exists($path . DS . $exec)) {
include_once "{$path}/{$exec}";
}
/** @var $dir SPDirectory */
$dir =& SPFactory::Instance('base.fs.directory', $path);
$zip = array_keys($dir->searchFile('.zip', false));
if (count($zip)) {
foreach ($zip as $file) {
SPFs::delete($file);
}
}
Sobi::Trigger('After', 'InstallTemplate', array($id));
$dir =& SPFactory::Instance('base.fs.directory', SPLoader::dirPath('tmp.install'));
$dir->deleteFiles();
return Sobi::Txt('TP.TEMPLATE_HAS_BEEN_INSTALLED', array('template' => $name));
}
示例6: edit
/**
*/
private function edit()
{
$id = $this->get('entry.id');
if ($id) {
$this->addHidden($id, 'entry.id');
}
$sid = SPRequest::int('pid') ? SPRequest::int('pid') : SPRequest::sid();
$this->assign(Sobi::Url(array('task' => 'category.chooser', 'sid' => $sid, 'out' => 'html', 'multiple' => 1), true), 'cat_chooser_url');
}
示例7: display
/**
* @param string The control name
* @param string The contents of the text area
* @param string The width of the text area (px or %)
* @param string The height of the text area (px or %)
* @param boolean True and the editor buttons will be displayed
* @param array Associative array of editor parameters
* @return string
*/
public function display($name, $html, $width, $height, $buttons, $params)
{
if (SPRequest::cmd('format') != 'raw') {
// public function display($name, $html, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null, $params = array())
$editor = JEditor::getInstance(JFactory::getConfig()->get('editor'));
// JFactory::getEditor()->display( $name, $html, $width, $height, '75', '20', $buttons, $params );
return $editor->display($name, $html, $width, $height, 75, 20, $buttons, null, null, null, $params);
}
}
示例8: setTitle
/**
* @param string $title
* @return string|void
*/
public function setTitle($title)
{
if (strstr(SPRequest::task(), '.add')) {
$title = str_replace('EDIT', 'ADD', $title);
}
$title = Sobi::Txt($title, array('field' => $this->get('field.name'), 'field_type' => $this->get('field.fieldType')));
Sobi::Trigger('setTitle', $this->name(), array(&$title));
SPFactory::header()->setTitle($title);
$this->set($title, 'site_title');
}
示例9: search
protected function search()
{
if (!SPFactory::mainframe()->checkToken()) {
Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
}
// $selected = SPRequest::int( 'selected', 0 );
$ssid = SPRequest::base64('ssid');
$query = SPRequest::string('q', null);
$session = SPFactory::user()->getUserState('userSelector', null, array());
$setting = $session[$ssid];
/* get the site to display */
$site = SPRequest::int('site', 1);
$eLim = Sobi::Cfg('user_selector.entries_limit', 18);
$eLimStart = ($site - 1) * $eLim;
$params = array();
if ($query) {
$q = '%' . $query . '%';
$params = SPFactory::db()->where(array('name' => $q, 'username' => $q, 'email' => $q), 'OR');
}
try {
$count = SPFactory::db()->select('COUNT(*)', '#__users', $params, $setting['ordering'])->loadResult();
$data = SPFactory::db()->select(array('id', 'name', 'username', 'email', 'registerDate', 'lastvisitDate'), '#__users', $params, $setting['ordering'], $eLim, $eLimStart)->loadAssocList();
} catch (SPException $x) {
echo $x->getMessage();
exit;
}
$response = array('sites' => ceil($count / $eLim), 'site' => $site);
if (count($data)) {
$replacements = array();
preg_match_all('/\\%[a-z]*/', $setting['format'], $replacements);
$placeholders = array();
if (isset($replacements[0]) && count($replacements[0])) {
foreach ($replacements[0] as $placeholder) {
$placeholders[] = str_replace('%', null, $placeholder);
}
}
if (count($replacements)) {
foreach ($data as $index => $user) {
$txt = $setting['format'];
foreach ($placeholders as $attribute) {
if (isset($user[$attribute])) {
$txt = str_replace('%' . $attribute, $user[$attribute], $txt);
}
}
$data[$index]['text'] = $txt;
}
}
$response['users'] = $data;
}
SPFactory::mainframe()->cleanBuffer();
echo json_encode($response);
exit;
}
示例10: execute
public function execute()
{
$this->start = microtime(true);
$sites = $this->getSites();
$responses = array();
$status = 'working';
$message = null;
$this->format = SPRequest::bool('fullFormat') ? self::FORMAT_FULL : self::FORMAT;
// $this->format = SPRequest::bool( 'fullFormat' ) ? self::FORMAT_FULL : self::FORMAT_FULL;
$task = SPRequest::task();
if (in_array($task, array('crawler.init', 'crawler.restart'))) {
if ($task == 'crawler.restart') {
SPFactory::cache()->cleanSection(Sobi::Section());
}
SPFactory::db()->truncate(self::DB_TABLE);
$multiLang = Sobi::Cfg('lang.multimode', false);
if ($multiLang) {
$langs = SPFactory::CmsHelper()->getLanguages();
if ($multiLang && $langs) {
foreach ($langs as $lang) {
$responses[] = $this->getResponse(Sobi::Cfg('live_site') . 'index.php?option=com_sobipro&sid=' . Sobi::Section() . '&lang=' . $lang);
}
}
}
$responses[] = $this->getResponse(Sobi::Cfg('live_site') . 'index.php?option=com_sobipro&sid=' . Sobi::Section());
$sites = $this->getSites();
}
if (!count($sites) && !in_array($task, array('crawler.init', 'crawler.restart'))) {
$message = Sobi::Txt('CRAWL_URL_PARSED_DONE', SPFactory::db()->select('count(*)', self::DB_TABLE)->loadResult());
SPFactory::db()->truncate(self::DB_TABLE);
$this->response(array('status' => 'done', 'data' => array(), 'message' => $message));
}
if (count($sites)) {
$i = 0;
$timeLimit = SPRequest::int('timeLimit', self::TIME_LIMIT, 'get', true);
foreach ($sites as $site) {
if (!strlen($site)) {
continue;
}
$responses[] = $this->getResponse($site);
$i++;
if (microtime(true) - $this->start > $timeLimit) {
break;
}
}
$message = Sobi::Txt('CRAWL_URL_PARSED_WORKING', $i, count($sites));
}
$this->response(array('status' => $status, 'data' => $responses, 'message' => $message));
}
示例11: save
protected function save()
{
if (!SPFactory::mainframe()->checkToken()) {
Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
}
$data = SPRequest::string('bankdata', null, true);
$data = array('key' => 'bankdata', 'value' => $data, 'type' => 'application', 'id' => Sobi::Section(), 'section' => Sobi::Section());
try {
SPLang::saveValues($data);
} catch (SPException $x) {
$message = SPLang::e('DB_REPORTS_ERR', $x->getMessage());
Sobi::Error('SPPaymentBt', $message, SPC::WARNING, 0, __LINE__, __FILE__);
$this->response(Sobi::Back(), $message, false, 'error');
}
$this->response(Sobi::Back(), Sobi::Txt('MSG.ALL_CHANGES_SAVED'), false, 'success');
}
示例12: functions
public function functions()
{
$functions = $this->get('functions');
$out = array();
$section = SPRequest::int('section');
$out[] = '<form action="index.php" method="post">';
$out[] = SPHtml_Input::select('function', $functions, null, false, array('id' => 'SobiProFunctions'));
$out[] = '<input type="hidden" name="option" value="com_sobipro">';
$out[] = '<input type="hidden" name="task" value="menu">';
$out[] = '<input type="hidden" name="tmpl" value="component">';
$out[] = '<input type="hidden" name="format" value="html">';
$out[] = '<input type="hidden" name="mid" value="' . SPRequest::int('mid') . '">';
$out[] = '<input type="hidden" name="section" value="' . $section . '">';
$out[] = '</form>';
echo implode("\n", $out);
}
示例13: js
protected function js()
{
$lang = SPLang::jsLang(true);
if (count($lang)) {
foreach ($lang as $term => $text) {
unset($lang[$term]);
$term = str_replace('SP.JS_', null, $term);
$lang[$term] = $text;
}
}
if (!SPRequest::int('deb')) {
SPFactory::mainframe()->cleanBuffer();
header('Content-type: text/javascript');
}
echo 'SobiPro.setLang( ' . json_encode($lang) . ' );';
exit;
}
示例14: PaymentMethodView
/**
* This function have to add own string into the given array
* Basically: $methods[ $this->id ] = "Some String To Output";
* Optionally the value can be also SobiPro Arr2XML array.
* Check the documentation for more information
* @param array $methods
* @param SPEntry $entry
* @param array $payment
* @param bool $message
* @return void
*/
public function PaymentMethodView(&$methods, $entry, &$payment, $message = false)
{
$data = SPFactory::registry()->loadDBSection('paypal_' . Sobi::Section())->get('paypal_' . Sobi::Section());
if (!count($data)) {
$data = SPFactory::registry()->loadDBSection('paypal')->get('paypal');
}
$cfg = SPLoader::loadIniFile('etc.paypal');
$rp = $cfg['general']['replace'];
$to = $cfg['general']['replace'] == ',' ? '.' : ',';
$amount = str_replace($rp, $to, $payment['summary']['sum_brutto']);
$values = array('entry' => $entry, 'amount' => preg_replace('/[^0-9\\.,]/', null, $amount), 'ppurl' => SPLang::replacePlaceHolders($data['ppurl']['value'], $entry), 'ppemail' => SPLang::replacePlaceHolders($data['ppemail']['value'], $entry), 'pprurl' => SPLang::replacePlaceHolders($data['pprurl']['value'], $entry), 'ppcc' => SPLang::replacePlaceHolders($data['ppcc']['value'], $entry));
$expl = SPLang::replacePlaceHolders(SPLang::getValue('ppexpl', 'plugin', Sobi::Section()), $values);
$subject = SPLang::replacePlaceHolders(SPLang::getValue('ppsubject', 'plugin', Sobi::Section()), $values);
$values['expl'] = $expl;
$values['subject'] = $subject;
$values['ip'] = SPRequest::ip('REMOTE_ADDR', 0, 'SERVER');
$methods[$this->id] = array('content' => $message ? $this->raw($cfg, $values) : $this->content($cfg, $values), 'title' => Sobi::Txt('APP.PPP.PAY_TITLE'));
}
示例15: install
public function install()
{
$id = $this->xGetString('id');
$name = $this->xGetString('name');
if (SPLoader::dirPath('usr.templates.' . $id) && !SPRequest::bool('force')) {
throw new SPException(SPLang::e('TEMPLATE_INST_DUPLICATE', $name) . ' ' . Sobi::Txt('FORCE_TPL_UPDATE', Sobi::Url(array('task' => 'extensions.install', 'force' => 1, 'root' => basename($this->root) . '/' . basename($this->xmlFile)))));
}
$requirements = $this->xGetChilds('requirements/*');
if ($requirements && $requirements instanceof DOMNodeList) {
SPFactory::Instance('services.installers.requirements')->check($requirements);
}
$path = SPLoader::dirPath('usr.templates.' . $id, 'front', false);
if (SPRequest::bool('force')) {
/** @var $from SPDirectory */
$from = SPFactory::Instance('base.fs.directory', $this->root);
$from->moveFiles($path);
} else {
if (!SPFs::move($this->root, $path)) {
throw new SPException(SPLang::e('CANNOT_MOVE_DIRECTORY', $this->root, $path));
}
}
if (!SPRequest::bool('force')) {
$section = $this->xGetChilds('install');
if ($section instanceof DOMNodeList && $section->length) {
$this->section($id);
}
}
$exec = $this->xGetString('exec');
if ($exec && SPFs::exists($this->root . DS . $exec)) {
include_once "{$this->root}/{$exec}";
}
/** @var $dir SPDirectory */
$dir =& SPFactory::Instance('base.fs.directory', $path);
$zip = array_keys($dir->searchFile('.zip', false));
if (count($zip)) {
foreach ($zip as $file) {
SPFs::delete($file);
}
}
Sobi::Trigger('After', 'InstallTemplate', array($id));
$dir =& SPFactory::Instance('base.fs.directory', SPLoader::dirPath('tmp.install'));
$dir->deleteFiles();
return Sobi::Txt('TP.TEMPLATE_HAS_BEEN_INSTALLED', array('template' => $name));
}