本文整理汇总了PHP中SPFactory::header方法的典型用法代码示例。如果您正苦于以下问题:PHP SPFactory::header方法的具体用法?PHP SPFactory::header怎么用?PHP SPFactory::header使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPFactory
的用法示例。
在下文中一共展示了SPFactory::header方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialise
private function initialise()
{
static $loaded = false;
if (!$loaded || true) {
defined('DS') || define('DS', DIRECTORY_SEPARATOR);
require_once JPATH_SITE . '/components/com_sobipro/lib/sobi.php';
Sobi::Initialise();
if (SOBI_CMS == 'joomla3') {
SPFactory::header()->initBase(true)->addJsFile(array('sobipro', 'jqnc', 'adm.sobipro', 'adm.jnmenu', 'jquery-base64'));
} else {
SPFactory::header()->initBase(true)->addJsFile(array('sobipro', 'jquery', 'adm.sobipro', 'adm.jnmenu', 'jquery-migrate', 'jquery-base64'))->addCSSCode('#toolbar-box { display: block }');
}
$loaded = true;
SPLoader::loadClass('mlo.input');
SPLoader::loadClass('models.datamodel');
SPLoader::loadClass('models.dbobject');
SPLoader::loadModel('section');
$model = JModelLegacy::getInstance('MenusModelItem')->getItem();
self::$mid = $model->id;
if (isset($model->params['SobiProSettings']) && strlen($model->params['SobiProSettings'])) {
$this->params = json_decode(base64_decode($model->params['SobiProSettings']));
}
$jsString = json_encode(array('component' => Sobi::Txt('SOBI_NATIVE_TASKS'), 'buttonLabel' => Sobi::Txt('SOBI_SELECT_FUNCTIONALITY')));
SPFactory::header()->addJsCode("SpStrings = {$jsString}; ");
}
}
示例2: __construct
public function __construct($task = null, $sid = 0)
{
SPFactory::header()->addCSSFile('menu', true)->addJsFile('menu', true);
$this->_task = $task ? $task : SPRequest::task();
$this->_sid = $sid;
SPFactory::registry()->set('adm_menu', $this);
}
示例3: onBeforeCompileHead
public function onBeforeCompileHead()
{
// if the class exists it means something initialised it so we can send the header
if (class_exists('SPFactory')) {
SPFactory::header()->sendHeader();
}
}
示例4: edit
private function edit()
{
$jsFiles = array('codemirror.codemirror');
$ext = $this->get('file_ext');
$mode = null;
switch (strtolower($ext)) {
case 'xsl':
case 'xml':
$jsFiles[] = 'codemirror.mode.xml.xml';
break;
case 'less':
$jsFiles[] = 'codemirror.mode.less.less';
break;
case 'css':
$jsFiles[] = 'codemirror.mode.css.css';
break;
case 'js':
$jsFiles[] = 'codemirror.mode.javascript.javascript';
break;
case 'php':
$jsFiles[] = 'codemirror.mode.clike.clike';
$jsFiles[] = 'codemirror.mode.php.php';
$jsFiles[] = 'codemirror.mode.htmlmixed.htmlmixed';
$jsFiles[] = 'codemirror.mode.xml.xml';
$jsFiles[] = 'codemirror.mode.javascript.javascript';
$jsFiles[] = 'codemirror.mode.css.css';
$mode = 'application/x-httpd-php';
break;
case 'ini':
$jsFiles[] = 'codemirror.mode.properties.properties';
break;
}
SPFactory::header()->addJsFile($jsFiles)->addCssFile('codemirror.codemirror')->addJsCode('SobiPro.jQuery( document ).ready( function () { SPInitTplEditor( "' . $mode . '") } );');
}
示例5: __construct
/**
* @param bool $useCookies
* @param string $cssFile - separate CSS file
* @param string $prefix
* @return sobiTabs
* @deprecated
*/
public function __construct($useCookies = true, $cssFile = 'tabs', $prefix = null)
{
$this->useCookies = $useCookies ? 1 : 0;
$this->prefix = $prefix;
if ($cssFile) {
SPFactory::header()->addCssFile($cssFile);
}
SPFactory::header()->addJsFile('tabs');
}
示例6: 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');
}
示例7: view
/**
*/
protected function view()
{
/* determine template package */
$tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE);
Sobi::ReturnPoint();
/* load template config */
$this->template();
$this->tplCfg($tplPackage);
/* get limits - if defined in template config - otherwise from the section config */
$eLimit = $this->tKey($this->template, 'entries_limit', Sobi::Cfg('list.entries_limit', 2));
$eInLine = $this->tKey($this->template, 'entries_in_line', Sobi::Cfg('list.entries_in_line', 2));
$cInLine = $this->tKey($this->template, 'categories_in_line', Sobi::Cfg('list.categories_in_line', 2));
$cLim = $this->tKey($this->template, 'categories_limit', -1);
$entriesRecursive = $this->tKey($this->template, 'entries_recursive', Sobi::Cfg('list.entries_recursive', false));
/* get the site to display */
$site = SPRequest::int('site', 1);
$eLimStart = ($site - 1) * $eLimit;
/* get the right ordering */
$eOrder = $this->parseOrdering('entries', 'eorder', $this->tKey($this->template, 'entries_ordering', Sobi::Cfg('list.entries_ordering', 'name.asc')));
$cOrder = $this->parseOrdering('categories', 'corder', $this->tKey($this->template, 'categories_ordering', Sobi::Cfg('list.categories_ordering', 'name.asc')));
$orderings = array('entries' => $eOrder, 'categories' => $cOrder);
/* get entries */
$eCount = count($this->getEntries($eOrder, 0, 0, true, null, $entriesRecursive));
$entries = $this->getEntries($eOrder, $eLimit, $eLimStart, false, null, $entriesRecursive);
$categories = array();
if ($cLim) {
$categories = $this->getCats($cOrder, $cLim);
}
/* create page navigation */
$url = array('sid' => SPRequest::sid(), 'title' => Sobi::Cfg('sef.alias', true) ? $this->_model->get('nid') : $this->_model->get('name'));
if (SPRequest::cmd('sptpl')) {
$url['sptpl'] = SPRequest::cmd('sptpl');
}
$pnc = SPLoader::loadClass('helpers.pagenav_' . $this->tKey($this->template, 'template_type', 'xslt'));
/* @var SPPageNavXSLT $pn */
$pn = new $pnc($eLimit, $eCount, $site, array('sid' => SPRequest::sid(), 'title' => Sobi::Cfg('sef.alias', true) ? $this->_model->get('nid') : $this->_model->get('name')));
/* handle meta data */
SPFactory::header()->objMeta($this->_model);
/* add pathway */
SPFactory::mainframe()->addObjToPathway($this->_model, array(ceil($eCount / $eLimit), $site));
$this->_model->countVisit();
/* get view class */
// $class = SPLoader::loadView( $this->_type );
$view = SPFactory::View($this->_type);
// $view = new $class( $this->template );
$view->assign($eLimit, '$eLimit')->assign($eLimStart, '$eLimStart')->assign($eCount, '$eCount')->assign($cInLine, '$cInLine')->assign($eInLine, '$eInLine')->assign($this->_task, 'task')->assign($this->_model, $this->_type)->setConfig($this->_tCfg, $this->template)->setTemplate($tplPackage . '.' . $this->templateType . '.' . $this->template)->assign($categories, 'categories')->assign($pn->get(), 'navigation')->assign(SPFactory::user()->getCurrent(), 'visitor')->assign($entries, 'entries')->assign($orderings, 'orderings');
Sobi::Trigger($this->name(), 'View', array(&$view));
$view->display($this->_type);
}
示例8: fields
/**
* Enter description here...
*
*/
protected function fields()
{
SPLoader::loadClass('html.tabs');
SPFactory::header()->addCssFile('tabs', true);
$t = new SPHtml_Tabs(true, null);
$tabs = $this->get('fields');
if (count($tabs)) {
$t->startPane('fields_' . $this->get('task'));
foreach ($tabs as $tab => $keys) {
$t->startTab(Sobi::Txt($tab), str_replace(' ', '_', $tab));
echo '<table class="admintable" style="width: 100%;">';
$c = 0;
foreach ($keys as $key => $params) {
$class = $c % 2;
$c++;
$params = explode('|', $params);
$p = array();
/* at first we need the label */
$label = Sobi::Txt(array_shift($params));
$label2 = null;
if (strstr($label, ':')) {
$label = explode(':', $label);
$label2 = $label[1];
$label = $label[0];
}
/* get the field type */
$p[0] = array_shift($params);
if (preg_match('/^section.*/', $key)) {
/* put the field name */
$p[1] = $key;
/* get the current value */
$p[2] = $this->get($key);
} elseif (!strstr($key, 'spacer')) {
/* put the field name */
$p[1] = 'spcfg_' . $key;
/* get the current value */
$p[2] = Sobi::Cfg($key, '');
}
if (strstr($key, 'spacer')) {
if ($key == 'spacer_pby') {
$this->pby();
} else {
echo "<tr class=\"row{$class}\">";
echo '<th colspan="2" class="spConfigTableHeader">';
$this->txt($label);
echo '</th>';
echo '</tr>';
}
} else {
if (strstr($key, '_array') && count($p[2]) && $p[2]) {
$p[2] = implode(',', $p[2]);
}
/* and all other parameters */
if (count($params)) {
foreach ($params as $param) {
$p[] = $param;
}
}
echo "<tr class=\"row{$class}\">";
echo '<td class="key" style="min-width:200px;">';
$this->txt($label);
echo '</td>';
echo '<td>';
$this->parseField($p);
if ($label2) {
$this->txt($label2);
}
echo '</td>';
echo '</tr>';
}
}
echo '</table>';
$t->endTab();
}
$t->endPane();
}
}
示例9: getNews
private function getNews()
{
$out = array();
$path = SPLoader::path('etc.news', 'front', false, 'xml');
if (SPFs::exists($path) && time() - filemtime($path) < 60 * 60 * 12) {
$content = SPFs::read(SPLoader::path('etc.news', 'front', false, 'xml'));
} else {
try {
$connection = SPFactory::Instance('services.remote');
$news = 'http://rss.sigsiu.net';
$connection->setOptions(array('url' => $news, 'connecttimeout' => 10, 'header' => false, 'returntransfer' => true));
$file = SPFactory::Instance('base.fs.file', $path);
$content = $connection->exec();
$cinf = $connection->info();
if (isset($cinf['http_code']) && $cinf['http_code'] != 200) {
return Sobi::Error('about', sprintf('CANNOT_GET_NEWS', $news, $cinf['http_code']), SPC::WARNING, 0, __LINE__, __FILE__);
}
$file->content($content);
$file->save();
} catch (SPException $x) {
return Sobi::Error('about', SPLang::e('CANNOT_LOAD_NEWS', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
}
try {
if (strlen($content)) {
$news = new DOMXPath(DOMDocument::loadXML($content));
$atom = false;
if ($atom) {
//Atom
$news->registerNamespace('atom', 'http://www.w3.org/2005/Atom');
$out['title'] = $news->query('/atom:feed/atom:title')->item(0)->nodeValue;
$items = $news->query('/atom:feed/atom:entry[*]');
$c = 5;
$open = false;
foreach ($items as $item) {
$date = $item->getElementsByTagName('updated')->item(0)->nodeValue;
if (!$open && time() - strtotime($date) < 60 * 60 * 24) {
$open = true;
}
$feed = array('url' => $item->getElementsByTagName('link')->item(0)->nodeValue, 'title' => $item->getElementsByTagName('title')->item(0)->nodeValue, 'content' => $item->getElementsByTagName('content')->item(0)->nodeValue);
if (!$c--) {
break;
}
$out['feeds'][] = $feed;
}
} else {
//RSS
$out['title'] = $news->query('/rss/channel/title')->item(0)->nodeValue;
$items = $news->query('/rss/channel/item[*]');
$c = 5;
$open = false;
foreach ($items as $item) {
$date = $item->getElementsByTagName('pubDate')->item(0)->nodeValue;
if (!$open && time() - strtotime($date) < 60 * 60 * 24) {
$open = true;
}
$feed = array('url' => $item->getElementsByTagName('link')->item(0)->nodeValue, 'title' => $item->getElementsByTagName('title')->item(0)->nodeValue, 'content' => $item->getElementsByTagName('description')->item(0)->nodeValue, 'image' => $item->getElementsByTagName('enclosure')->item(0)->attributes->getNamedItem('url')->nodeValue);
if (!$c--) {
break;
}
$out['feeds'][] = $feed;
}
}
}
if ($open) {
SPFactory::header()->addJsCode('SobiPro.jQuery( document ).ready( function () { SobiPro.jQuery( \'#SobiProNews\' ).trigger(\'click\'); } );');
}
} catch (DOMException $x) {
return Sobi::Error('about', SPLang::e('CANNOT_LOAD_NEWS', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
return $out;
}
示例10: details
protected function details()
{
$this->_type = 'entry_details';
$type = $this->key('template_type', 'xslt');
if ($type != 'php' && Sobi::Cfg('global.disable_xslt', false)) {
$type = 'php';
}
if ($type == 'xslt') {
$this->_attr = $this->entryData();
SPFactory::header()->addCanonical($this->_attr['entry']['_data']['url']);
Sobi::Trigger('EntryView', ucfirst(__FUNCTION__), array(&$this->_attr));
}
}
示例11: view
protected function view()
{
/* determine template package */
$tplPckg = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE);
Sobi::ReturnPoint();
$this->_task = 'alpha';
if (!$this->_model) {
$this->setModel('section');
$this->_model->init(Sobi::Section());
}
$this->visible();
/* load template config */
$this->template();
$this->tplCfg($tplPckg);
/* get limits - if defined in template config - otherwise from the section config */
$eLimit = $this->tKey($this->template, 'entries_limit', Sobi::Cfg('list.entries_limit', 2));
$eInLine = $this->tKey($this->template, 'entries_in_line', Sobi::Cfg('list.entries_in_line', 2));
/* get the site to display */
$site = SPRequest::int('site', 1);
$eLimStart = ($site - 1) * $eLimit;
$eCount = count($this->getEntries(0, 0, true));
$entries = $this->getEntries($eLimit, $site);
$compare = $this->_field ? $this->_field : $this->_nid;
if (strlen($compare) && $compare != Sobi::Cfg('alphamenu.primary_field')) {
$t = 'list.alpha.' . strtolower($this->_letter) . '.' . $this->_nid;
} else {
$t = 'list.alpha.' . strtolower($this->_letter);
}
$pn = SPFactory::Instance('helpers.pagenav_' . $this->tKey($this->template, 'template_type', 'xslt'), $eLimit, $eCount, $site, array('sid' => SPRequest::sid(), 'task' => $t));
$cUrl = array('sid' => SPRequest::sid(), 'task' => $t);
if (SPRequest::int('site', 0)) {
$cUrl['site'] = SPRequest::int('site', 0);
}
SPFactory::header()->addCanonical(Sobi::Url($cUrl, true, true, true));
/* handle meta data */
SPFactory::header()->objMeta($this->_model);
$letter = urldecode(SPRequest::cmd('letter'));
/* add pathway */
if (!$this->_fieldType) {
SPFactory::mainframe()->addToPathway(Sobi::Txt('AL.PATH_TITLE', array('letter' => $letter)), Sobi::Url('current'));
SPFactory::header()->addTitle(Sobi::Txt('AL.TITLE', array('letter' => $letter, 'section' => $this->_model->get('name'))), array(ceil($eCount / $eLimit), $site));
} else {
$field = SPFactory::Model('field');
$field->init($this->_field);
SPFactory::mainframe()->addToPathway(Sobi::Txt('AL.PATH_TITLE_FIELD', array('letter' => $letter, 'field' => $field->get('name'))), Sobi::Url('current'));
SPFactory::header()->addTitle(Sobi::Txt('AL.TITLE_FIELD', array('letter' => $letter, 'section' => $this->_model->get('name'), 'field' => $field->get('name'))), array(ceil($eCount / $eLimit), $site));
}
/* get view class */
$view = SPFactory::View('listing');
$view->assign($eLimit, '$eLimit');
$view->assign($eLimStart, '$eLimStart');
$view->assign($eCount, '$eCount');
$view->assign($eInLine, '$eInLine');
$view->assign($this->_task, 'task');
$view->assign($this->_model, 'section');
$view->assign(Sobi::Txt('AL.PATH_TITLE', array('letter' => $this->_letter)), 'listing_name');
$view->setConfig($this->_tCfg, $this->template);
$view->setTemplate($tplPckg . '.' . $this->templateType . '.' . $this->template);
$view->assign($pn->get(), 'navigation');
$view->assign(SPFactory::user()->getCurrent(), 'visitor');
$view->assign($entries, 'entries');
Sobi::Trigger('AlphaListing', 'View', array(&$view));
$view->display();
}
示例12: createValidationScript
/**
* @param SPField[] $fields
* @return void
*/
protected function createValidationScript($fields)
{
/* get input filters */
$registry =& SPFactory::registry();
$registry->loadDBSection('fields_filter');
$filters = $registry->get('fields_filter');
$validate = array();
foreach ($fields as $field) {
$filter = $field->get('filter');
if ($filter && isset($filters[$filter])) {
$f = new stdClass();
$f->name = $field->get('nid');
$f->filter = base64_decode($filters[$filter]['params']);
$f->msg = Sobi::Txt('[JS]' . $filters[$filter]['description']);
$validate[] = $f;
}
}
if (count($validate)) {
Sobi::Trigger($this->name(), __FUNCTION__, array(&$validate));
$validate = json_encode($validate);
$header =& SPFactory::header();
$header->addJsVarFile('efilter', md5($validate), array('OBJ' => addslashes($validate)));
}
}
示例13: startScript
private function startScript($current)
{
$path = SPFactory::config()->getParentPath($current);
if (!$this->getChilds($path[count($path) - 1])) {
unset($path[count($path) - 1]);
}
unset($path[0]);
$func = $this->_id . '_stmExpand';
$script = null;
if (count($path)) {
foreach ($path as $i => $cid) {
$retard = $i * 150;
$script .= "\t\twindow.setTimeout( '{$func}( {$cid}, {$i}, 0 )', {$retard} );\n";
}
SPFactory::header()->addJsCode("\tSobiPro.onReady( function () { \n{$script}\n \t} );");
}
}
示例14: defined
* Name: Sigrid Suski & Radek Suski, Sigsiu.NET GmbH
* Email: sobi[at]sigsiu.net
* Url: http://www.Sigsiu.NET
* @copyright Copyright (C) 2006 - 2015 Sigsiu.NET GmbH (http://www.sigsiu.net). All rights reserved.
* @license GNU/GPL Version 3
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation, and under the additional terms according section 7 of GPL v3.
* See http://www.gnu.org/licenses/gpl.html and http://sobipro.sigsiu.net/licenses.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* $Date$
* $Revision$
* $Author$
* $HeadURL$
*/
defined('SOBIPRO') || exit('Restricted access');
SPFactory::header()->addCSSCode('legend { color: #0b55c4; font-size: 12px!important; font-weight: bold;}');
SPFactory::header()->addCSSCode('.sigsiuTree {height: 330px;}');
?>
<script language="javascript" type="text/javascript">
var selectedCat = 0;
var selectedCatName = '';
var selectedCats = new Array();
var selectedCatNames = new Array();
var selectedPath = '';
var selCid = 0;
if( parent.document.getElementById( 'category.path' ) ) {
var SPObjType = 'category';
}
else {
var SPObjType = 'entry';
}
var maxCat = <?php
示例15: setTitle
/**
* @param string $title
* @return string
*/
public function setTitle($title)
{
if (strstr($title, '{')) {
$title = (array) SPFactory::config()->structuralData('json://' . $title);
$task = SPRequest::task();
$title = $title[$task];
}
$title = $this->parseValue(Sobi::Txt($title));
Sobi::Trigger('setTitle', $this->name(), array(&$title));
SPFactory::header()->setTitle($title);
$this->set($title, 'site_title');
return $title;
}