本文整理汇总了PHP中SPRequest::sid方法的典型用法代码示例。如果您正苦于以下问题:PHP SPRequest::sid方法的具体用法?PHP SPRequest::sid怎么用?PHP SPRequest::sid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPRequest
的用法示例。
在下文中一共展示了SPRequest::sid方法的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: load
private function load($task)
{
$db =& SPFactory::db();
$adm = defined('SOBIPRO_ADM') ? 'adm.' : null;
$cond = array($adm . '*', $adm . $task);
if (strstr($task, '.')) {
$t = explode('.', $task);
$cond[] = $adm . $t[0] . '.*';
$task = $t[0] . '.' . $t[1];
}
$this->_actions[$task] = null;
try {
$pids = $db->select('pid', 'spdb_plugin_task', array('onAction' => $cond))->loadResultArray();
} catch (SPException $x) {
Sobi::Error('Plugins', $x->getMessage(), SPC::WARNING, 0, __LINE__, __FILE__);
}
if (!count($pids)) {
$this->_actions[$task] = array();
}
// get section depend apps
if (Sobi::Section() && count($pids)) {
try {
$this->_actions[$task] = $db->select('pid', 'spdb_plugin_section', array('section' => Sobi::Section(), 'enabled' => 1, 'pid' => $pids))->loadResultArray();
} catch (SPException $x) {
Sobi::Error('Plugins', $x->getMessage(), SPC::WARNING, 0, __LINE__, __FILE__);
}
} elseif (!(SPRequest::sid() || SPRequest::int('pid'))) {
$this->_actions[$task] = $pids;
}
// here is a special exception for the custom listings
// it can be l.alpha or list.alpha or listing.alpha
if (preg_match('/^list\\..*/', $task) || preg_match('/^l\\..*/', $task)) {
$this->_actions['listing' . '.' . $t[1]] = $pids;
}
}
示例3: 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');
}
示例4: chooser
public function chooser()
{
$pid = $this->get('category.parent');
$path = null;
if (!$pid) {
$pid = SPRequest::sid();
}
$this->assign($pid, 'parent');
$id = $this->get('category.id');
$id = $id ? $id : $pid;
if ($id) {
$path = $this->parentPath($id);
}
$this->assign($path, 'parent_path');
$this->assign(Sobi::Url(array('task' => 'category.parents', 'out' => 'json', 'format' => 'raw'), true), 'parent_ajax_url');
/* @TODO */
$tpl = str_replace(implode('/', array('usr', 'templates', 'category')), 'views/tpl/', $this->_template . '.php');
Sobi::Trigger('Display', $this->name(), array(&$this));
include $tpl;
Sobi::Trigger('AfterDisplay', $this->name());
}
示例5: cachedView
public function cachedView($xml, $template, $cacheId, $config = array())
{
$this->_xml = $xml;
Sobi::Trigger('Start', ucfirst(__FUNCTION__), array(&$this->_xml));
$templatePackage = SPLoader::translateDirPath(Sobi::Cfg('section.template'), 'templates');
$templateOverride = SPRequest::cmd('sptpl');
if ($templateOverride) {
if (strstr($templateOverride, '.')) {
$templateOverride = str_replace('.', '/', $templateOverride);
}
$template = $templateOverride . '.xsl';
}
if (file_exists(Sobi::FixPath($templatePackage . '/' . $template))) {
$template = Sobi::FixPath($templatePackage . '/' . $template);
} else {
$type = SPFactory::db()->select('oType', 'spdb_object', array('id' => SPRequest::sid()))->loadResult();
$template = $templatePackage . '/' . $type . '/' . $template;
}
SPFactory::registry()->set('current_template', $templatePackage);
$this->_templatePath = $templatePackage;
$this->_template = str_replace('.xsl', null, $template);
$ini = array();
if (count($config)) {
foreach ($config as $file) {
$file = parse_ini_file($file, true);
foreach ($file as $section => $keys) {
if (isset($ini[$section])) {
$ini[$section] = array_merge($ini[$section], $keys);
} else {
$ini[$section] = $keys;
}
}
}
}
$this->setConfig($ini, SPRequest::task('get'));
$this->parseXml();
$this->validateData($cacheId);
Sobi::Trigger('After', ucfirst(__FUNCTION__), array(&$this->_xml));
}
示例6: save
/**
* Save the config
*/
protected function save($apply, $clone = false)
{
$sid = Sobi::Section();
$this->authorise($sid);
if ($sid) {
$this->validate('config.general', array('task' => 'config.general', 'sid' => $sid));
} else {
$this->validate('config.global', array('task' => 'config.global'));
}
$fields = array();
$section = false;
$data = SPRequest::arr('spcfg', array());
// strange thing =8-O
if (!isset($data['alphamenu.extra_fields_array'])) {
$data['alphamenu.extra_fields_array'] = array();
}
if (!isset($data['template.icon_fonts_arr'])) {
$data['template.icon_fonts_arr'] = array();
}
foreach ($data as $k => $v) {
if (is_string($v)) {
$v = htmlspecialchars_decode($v);
}
// $k = str_replace( array( 'spcfg_', '.' ), array( null, '_' ), $k );
$k = str_replace('spcfg_', null, $k);
$s = explode('.', $k);
$s = $s[0];
if (!isset($fields[$s])) {
$fields[$s] = array();
}
$k = str_replace("{$s}.", null, $k);
$c = explode('_', $k);
if ($c[count($c) - 1] == 'array' && !is_array($v)) {
if (!strstr($v, '|')) {
$v = explode(',', $v);
} else {
$v = explode('|', $v);
}
}
$fields[$s][$k] = $v;
if (preg_match('/^section.*/', $k)) {
$section = true;
}
}
$values = array();
if (count($fields)) {
foreach ($fields as $sec => $keys) {
if (count($keys)) {
foreach ($keys as $k => $v) {
$values[] = array('sKey' => $k, 'sValue' => $v, 'section' => Sobi::Section(), 'critical' => 0, 'cSection' => $sec);
}
}
}
}
if ($section) {
/* @var $sec SPSection */
$sec = SPFactory::Model('section');
$sec->init(SPRequest::sid());
$sec->getRequest('section');
$sec->save(true);
}
Sobi::Trigger('SaveConfig', $this->name(), array(&$values));
try {
SPFactory::db()->insertArray('spdb_config', $values, true);
} catch (SPException $x) {
$this->response(Sobi::Back(), $x->getMessage(), false, SPC::ERROR_MSG);
}
if (!($section && !Sobi::Section())) {
SPFactory::cache()->cleanAll();
} else {
SPFactory::cache()->cleanSection();
}
Sobi::Trigger('After', 'SaveConfig', array(&$values));
$this->response(Sobi::Back(), Sobi::Txt('MSG.CONFIG_SAVED'), false, 'success');
}
示例7: display
/**
* @deprecated
*/
public function display($return = false)
{
$pn = null;
$pages = $this->limit > 0 ? ceil($this->count / $this->limit) : 0;
$sid = SPRequest::sid() ? SPRequest::sid() : Sobi::Section();
$pn .= '<div style="text-align:center;"><div class="pagination">';
$pn .= '<div class="limit">';
$pn .= Sobi::Txt('PN.DISPLAY');
$box = array();
foreach ($this->limits as $v) {
if ($v) {
$box[$v] = $v;
} else {
$box[-1] = Sobi::Txt('PN.ALL');
}
}
$pn .= SPHtml_Input::select($this->box, $box, $this->limit, false, array('onchange' => "{$this->boxFunc}( {$sid} )"));
$pn .= '</div>';
if ($pages > 1) {
if ($this->current == 1) {
$pn .= '<div class="button2-right off"><div class="start"><span>';
$pn .= Sobi::Txt('PN.START');
$pn .= '</span></div></div>';
$pn .= '<div class="button2-right off"><div class="prev"><span>';
$pn .= Sobi::Txt('PN.PREVIOUS');
$pn .= '</span></div></div>';
} else {
$link = " onclick=\"{$this->func}( 1, {$sid} )\" ";
$txt = Sobi::Txt('PN.START');
$pn .= "<div class=\"button2-right\"><div class=\"start\"><a href=\"#\"{$link} title=\"{$txt}\">{$txt}</a></div></div>";
$prevpage = $this->current - 1;
$txt = Sobi::Txt('PN.PREVIOUS');
$link = " onclick=\"{$this->func}( {$prevpage}, {$sid} )\" ";
$pn .= "<div class=\"button2-right\"><div class=\"start\"><a href=\"#\"{$link} title=\"{$txt}\">{$txt}</a></div></div>";
}
$pn .= '<div class="button2-left"><div class="page">';
for ($page = 1; $page <= $pages; $page++) {
if ($pages > 1000 && $page % 1000 != 0) {
continue;
} elseif ($pages > 100 && $page % 100 != 0) {
continue;
} elseif ($pages > 20 && $page % 5 != 0) {
continue;
}
$link = " onclick=\"{$this->func}( {$page}, {$sid} )\" ";
if ($page == $this->current) {
$pn .= '<span>' . $page . '</span>';
} else {
$pn .= "<a href=\"#\"{$link}\" title=\"{$page}\">{$page}</a>";
}
}
$pn .= '</div></div>';
if ($this->current == $pages) {
$pn .= '<div class="button2-left off"><div class="next"><span>';
$pn .= Sobi::Txt('PN.NEXT');
$pn .= '</span></div></div>';
$pn .= '<div class="button2-left off"><div class="end"><span>';
$pn .= Sobi::Txt('PN.END');
$pn .= '</span></div></div>';
} else {
$nextpage = $this->current + 1;
$link = " onclick=\"{$this->func}( {$nextpage}, {$sid} )\" ";
$txt = Sobi::Txt('PN.NEXT');
$pn .= "<div class=\"button2-left\"><div class=\"next\"><a href=\"#\"{$link}title=\"{$txt}\">{$txt}</a></div></div>";
$link = " onclick=\"{$this->func}( {$pages}, {$sid} )\" ";
$txt = Sobi::Txt('PN.END');
$pn .= "<div class=\"button2-left\"><div class=\"end\"><a href=\"#\"{$link}title=\"{$txt}\">{$txt}</a></div></div>";
}
$pn .= "<div class=\"limit\">";
$pn .= Sobi::Txt('PN.CURRENT_SITE', array('current' => $this->current, 'pages' => $pages));
$pn .= '</div></div>';
}
$pn .= '</div><br/>';
if ($return) {
return $pn;
} else {
echo $pn;
}
}
示例8: form
protected function form()
{
$ssid = 0;
/* determine template package */
$tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE);
/* load template config */
$this->template();
$this->tplCfg($tplPackage, 'search');
if ($this->template == 'results') {
$this->template = 'view';
}
if (!$this->_model) {
$this->setModel('section');
$this->_model->init(Sobi::Section());
}
/* handle meta data */
SPFactory::header()->objMeta($this->_model);
$section = SPFactory::Section(Sobi::Section());
SPFactory::header()->addKeyword($section->get('sfMetaKeys'))->addDescription($section->get('sfMetaDesc'));
/* add pathway */
SPFactory::mainframe()->addToPathway(Sobi::Txt('SH.PATH_TITLE'), Sobi::Url('current'));
SPFactory::mainframe()->setTitle(Sobi::Txt('SH.TITLE', array('section' => $this->_model->get('name'))));
Sobi::Trigger('OnFormStart', 'Search');
SPLoader::loadClass('mlo.input');
$view = SPFactory::View('search');
/* if we cannot transfer the search id in cookie */
if (!$this->session($ssid)) {
$view->addHidden($ssid, 'ssid');
}
if ($this->_task == 'results' && $ssid) {
/* get limits - if defined in template config - otherwise from the section config */
$eLimit = $this->tKey($this->template, 'entries_limit', Sobi::Cfg('search.entries_limit', Sobi::Cfg('list.entries_limit', 2)));
$eInLine = $this->tKey($this->template, 'entries_in_line', Sobi::Cfg('search.entries_in_line', Sobi::Cfg('list.entries_in_line', 2)));
/* get the site to display */
$site = SPRequest::int('site', 1);
$eLimStart = ($site - 1) * $eLimit;
$view->assign($eLimit, '$eLimit');
$view->assign($eLimStart, '$eLimStart');
$view->assign($eInLine, '$eInLine');
$entries = $this->getResults($ssid, $this->template);
$view->assign(count($this->_results), '$eCount');
$view->assign($this->_resultsByPriority, 'priorities');
$view->assign($entries, 'entries');
/* create page navigation */
$pnc = SPLoader::loadClass('helpers.pagenav_' . $this->tKey($this->template, 'template_type', 'xslt'));
$url = array('task' => 'search.results', 'sid' => SPRequest::sid());
if (!SPRequest::cmd('ssid', null, 'cookie')) {
$url['ssid'] = $ssid;
}
/* @var SPPageNavXSLT $pn */
$pn = new $pnc($eLimit, $this->_resultsCount, $site, $url);
$view->assign($pn->get(), 'navigation');
/**
* this is te special case:
* no matter what task we currently have - if someone called this we need the data for the V-Card
* Soe we have to trigger all these plugins we need and therefore also fake the task
*/
$task = 'list.custom';
SPFactory::registry()->set('task', $task);
} else {
$eLimit = -1;
$view->assign($eLimit, '$eCount');
}
/* load all fields */
$fields = $this->loadFields();
if (isset($this->_request['search_for'])) {
$view->assign($this->_request['search_for'], 'search_for');
$view->assign($this->_request['phrase'], 'search_phrase');
}
$view->assign($fields, 'fields');
$view->assign(SPFactory::user()->getCurrent(), 'visitor');
$view->assign($this->_task, 'task');
$view->addHidden(Sobi::Section(), 'sid');
$view->addHidden('search.search', 'task');
$view->setConfig($this->_tCfg, $this->template);
$view->setTemplate($tplPackage . '.' . $this->templateType . '.' . $this->template);
Sobi::Trigger('OnCreateView', 'Search', array(&$view));
$view->display();
}
示例9: field
/**
* Shows the field in the edit entry or add entry form
* @param bool $return return or display directly
* @return string
*/
public function field($return = false)
{
if (!$this->enabled) {
return false;
}
if (!$this->sid) {
$this->sid = SPRequest::sid();
}
$this->_selectedCats = $this->cleanData();
$this->loadCategories();
if (!$this->_selectedCats && $this->sid) {
$entry = SPFactory::Entry($this->sid);
$this->_selectedCats = array_keys($entry->get('categories'));
} else {
$this->cleanData();
}
if (!$this->_selectedCats || !count($this->_selectedCats)) {
$sid = SPRequest::sid();
if ($sid != Sobi::Section() && $sid != $this->sid) {
$this->_selectedCats = array(SPRequest::sid());
}
}
$this->showLabel = true;
if (!(int) $this->catsMaxLimit) {
$this->catsMaxLimit = 1;
}
if (count($this->_selectedCats) > $this->catsMaxLimit) {
$this->_selectedCats = array_slice($this->_selectedCats, 0, $this->catsMaxLimit);
}
switch ($this->method) {
case 'fixed':
$this->showLabel = false;
$this->isOutputOnly = true;
return null;
break;
case 'tree':
$field = $this->tree();
break;
case 'select':
$field = $this->select();
break;
case 'mselect':
$field = $this->mSelect();
break;
}
if (!$return) {
echo $field;
} else {
return $field;
}
}
示例10: saveData
/**
* Gets the data for a field and save it in the database
* @param SPEntry $entry
* @param string $request
* @param bool $clone
* @throws SPException
* @return bool
*/
public function saveData(&$entry, $request = 'POST', $clone = false)
{
if (!$this->enabled) {
return false;
}
$del = SPRequest::bool($this->nid . '_delete', false, $request);
if ($clone) {
$orgSid = SPRequest::sid();
$this->loadData($orgSid);
$files = $this->getExistingFiles();
$cloneFiles = array();
if (isset($files['original']) && file_exists(SOBI_ROOT . '/' . $files['original'])) {
return $this->cloneFiles($entry, $request, $files, $cloneFiles);
}
}
$fileSize = SPRequest::file($this->nid, 'size');
$cropped = null;
static $store = null;
$cache = false;
if ($store == null) {
$store = SPFactory::registry()->get('requestcache_stored');
}
if (is_array($store) && isset($store[$this->nid])) {
if (!strstr($store[$this->nid], 'file://') && !strstr($store[$this->nid], 'directory://')) {
$data = $store[$this->nid];
$cache = true;
$orgName = SPRequest::file($this->nid, 'name', $request);
} else {
SPRequest::set($this->nid, $store[$this->nid]);
$orgName = SPRequest::file($this->nid, 'name');
$data = SPRequest::file($this->nid, 'tmp_name');
}
} else {
$data = SPRequest::file($this->nid, 'tmp_name');
$orgName = SPRequest::file($this->nid, 'name');
}
$sPath = $this->parseName($entry, $orgName, $this->savePath);
$path = SPLoader::dirPath($sPath, 'root', false);
/** Wed, Oct 15, 2014 13:51:03
* Implemented a cropper with Ajax checker.
* This is the actual method to get those files
* Other methods left for BC
* */
if (!$data) {
$directory = SPRequest::string($this->nid, $store[$this->nid], false, $request);
if (strlen($directory)) {
list($data, $dirName, $files, $coordinates) = $this->getAjaxFiles($directory);
if (count($files)) {
foreach ($files as $file) {
if ($file == '.') {
continue;
}
if ($file == '..') {
continue;
}
if (strpos($file, 'icon_') !== false) {
continue;
}
if (strpos($file, 'resized_') !== false) {
continue;
}
if (strpos($file, 'cropped_') !== false) {
$cropped = $dirName . $file;
SPFs::upload($cropped, $path . basename($cropped));
continue;
}
if (strpos($file, '.var') !== false) {
continue;
}
$fileSize = filesize($dirName . $file);
$orgName = $file;
}
}
if (strlen($coordinates)) {
$coordinates = json_decode(SPLang::clean($coordinates), true);
/** @var SPImage $croppedImage */
$croppedImage = SPFactory::Instance('base.fs.image', $dirName . $orgName);
$croppedImage->crop($coordinates['width'], $coordinates['height'], $coordinates['x'], $coordinates['y']);
$cropped = 'cropped_' . $orgName;
$croppedImage->saveAs($path . $cropped);
}
$data = strlen($cropped) ? $cropped : $dirName . $file;
}
}
$files = array();
/* if we have an image */
if ($data && $orgName) {
if ($fileSize > $this->maxSize) {
throw new SPException(SPLang::e('FIELD_IMG_TOO_LARGE', $this->name, $fileSize, $this->maxSize));
}
if ($cropped) {
SPFs::upload($dirName . $orgName, $path . $orgName);
//.........这里部分代码省略.........
示例11: entries
/**
* @param $params
* @param bool $count
* @return array
*/
protected function entries($params, $count = false)
{
if ($params->get('fieldOrder')) {
$eOrder = $params->get('fieldOrder');
} else {
$eOrder = $params->get('spOrder');
}
$entriesRecursive = true;
$conditions = array();
$db = SPFactory::db();
$limits = $params->get('spLimit');
if ($limits) {
$limits = explode('::', $limits);
$fid = $limits[0];
$value = $limits[1] == 'group' ? $limits[2] : $limits[1];
$condition = array('fid' => $fid, 'optValue' => $value);
if ($limits[1] == 'group') {
$condition['optValue'] = $db->select('optValue', 'spdb_field_option', array('optParent' => $value, 'fid' => $fid))->loadResultArray();
}
$conditions['spo.id'] = $db->select('sid', 'spdb_field_option_selected', $condition)->loadResultArray();
if (!count($conditions['spo.id'])) {
return array();
}
}
$eDir = $params->get('spOrderDir');
$oPrefix = null;
/* get the site to display */
if ($params->get('engine') != 'static') {
$site = SPRequest::int('site', 1);
} else {
$site = 1;
}
$eLimit = $params->get('entriesLimit');
$eLimStart = ($site - 1) * $eLimit;
/* get the ordering and the direction */
if (strstr($eOrder, '.')) {
$eOrder = explode('.', $eOrder);
$eDir = $eOrder[1];
$eOrder = $eOrder[0];
}
$sid = $params->get('sid');
$section = $params->get('section');
$this->setModel($sid == $section ? 'section' : 'category');
$this->_model->init($sid);
$catId = SPRequest::int('pid');
$catId = $catId ? $catId : SPRequest::sid();
if ($params->get('autoListing', false) && $catId && $catId != Sobi::Section()) {
$entries = Sobi::GetUserData('currently-displayed-entries', array());
if (!count($entries) && $catId) {
$entries = SPFactory::Category($catId)->getChilds('entry', true, 1);
$entries = array_unique($entries);
}
if (count($entries)) {
$conditions['spo.id'] = $entries;
}
} else {
if ($entriesRecursive) {
$pids = $this->_model->getChilds('category', true);
// getChilds doesn't includes the category id itself
$pids[$this->_model->get('id')] = $this->_model->get('id');
if (is_array($pids)) {
$pids = array_keys($pids);
}
$conditions['sprl.pid'] = $pids;
} else {
$conditions['sprl.pid'] = $sid;
}
if ($sid == -1) {
unset($conditions['sprl.pid']);
}
}
if (count($conditions)) {
/* sort by field */
if (is_numeric($eOrder)) {
static $fields = array();
$specificMethod = false;
$field = isset($fields[$sid]) ? $fields[$sid] : null;
if (!$field) {
try {
$fType = $db->select('fieldType', 'spdb_field', array('fid' => $eOrder))->loadResult();
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('CANNOT_DETERMINE_FIELD_TYPE', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
if ($fType) {
$field = SPLoader::loadClass('opt.fields.' . $fType);
}
$fields[$sid] = $field;
}
if ($field && method_exists($field, 'sortBy')) {
$table = null;
$oPrefix = null;
$specificMethod = call_user_func_array(array($field, 'sortBy'), array(&$table, &$conditions, &$oPrefix, &$eOrder, &$eDir));
}
if (!$specificMethod) {
$table = $db->join(array(array('table' => 'spdb_field', 'as' => 'fdef', 'key' => 'fid'), array('table' => 'spdb_field_data', 'as' => 'fdata', 'key' => 'fid'), array('table' => 'spdb_object', 'as' => 'spo', 'key' => array('fdata.sid', 'spo.id')), array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => array('fdata.sid', 'sprl.id'))));
//.........这里部分代码省略.........
示例12: toggle
protected function toggle()
{
$plugin = SPRequest::cmd('eid');
$plugin = explode('.', $plugin);
$ptype = $plugin[0];
$plugin = $plugin[1];
$message = null;
if (SPRequest::sid()) {
try {
$app = SPFactory::db()->select('name', 'spdb_plugins', array('pid' => $plugin, 'type' => $ptype))->loadResult();
$state = !SPFactory::db()->select('enabled', 'spdb_plugin_section', array('section' => SPRequest::sid('get'), 'pid' => $plugin, 'type' => $ptype))->loadResult();
SPFactory::db()->replace('spdb_plugin_section', array('section' => SPRequest::sid('get'), 'pid' => $plugin, 'type' => $ptype, 'enabled' => $state, 0));
$message = $state ? Sobi::Txt('EX.APP_ENABLED', $app) : Sobi::Txt('EX.APP_DISABLED', $app);
$messageType = $state ? 'success' : 'warning';
} catch (SPException $x) {
$message = Sobi::Txt('EX.CANNOT_CHANGE_STATE_ERR', 'error');
$messageType = 'error';
Sobi::Error('extensions', SPLang::e('CANNOT_UPDATE_PLUGIN', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
} else {
try {
$app = SPFactory::db()->select(array('enabled', 'name'), 'spdb_plugins', array('pid' => $plugin, 'type' => $ptype))->loadObject();
SPFactory::db()->update('spdb_plugins', array('enabled' => !$app->enabled), array('type' => $ptype, 'pid' => $plugin));
$message = !$app->enabled ? Sobi::Txt('EX.APP_ENABLED', $app->name) : Sobi::Txt('EX.APP_DISABLED', $app->name);
$messageType = !$app->enabled ? 'success' : 'warning';
} catch (SPException $x) {
$message = Sobi::Txt('EX.CANNOT_CHANGE_STATE_ERR', 'error');
$messageType = 'error';
Sobi::Error('extensions', SPLang::e('CANNOT_UPDATE_PLUGIN', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
}
$this->response(Sobi::Back(), $message, false, $messageType);
}
示例13: sortBy
/**
* Static function to create the right SQL-Query if a entries list should be sorted by this field
* @param string $tables - table or tables join
* @param array $conditions - array with conditions
* @param string $oPrefix
* @param string $eOrder
* @param string $eDir
* @return void
*/
public static function sortBy(&$tables, &$conditions, &$oPrefix, &$eOrder, $eDir)
{
/* @var SPdb $db */
$db =& SPFactory::db();
$tables = $db->join(array(array('table' => 'spdb_field_option_selected', 'as' => 'sdata', 'key' => 'fid'), array('table' => 'spdb_object', 'as' => 'spo', 'key' => array('sdata.sid', 'spo.id')), array('table' => 'spdb_field_data', 'as' => 'fdata', 'key' => array('fdata.fid', 'sdata.fid')), array('table' => 'spdb_field', 'as' => 'fdef', 'key' => array('fdef.fid', 'sdata.fid')), array('table' => 'spdb_language', 'as' => 'ldata', 'key' => array('sdata.optValue', 'ldata.sKey')), array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => array('spo.id', 'sprl.id'))));
$oPrefix = 'spo.';
$conditions['spo.oType'] = 'entry';
if (!isset($conditions['sprl.pid'])) {
$conditions['sprl.pid'] = SPRequest::sid();
}
$conditions['ldata.oType'] = 'field_option';
$conditions['fdef.nid'] = $eOrder;
$eOrder = 'sValue.' . $eDir . ", field( language, '" . Sobi::Lang(false) . "', '" . Sobi::DefLang() . "' )";
return true;
}
示例14: entry
protected function entry($entry, $manager, $noId = false)
{
$en = array();
if (is_numeric($entry)) {
$en = $this->cachedEntry($entry, $manager, $noId);
}
if (!is_array($en) || !count($en)) {
if (is_numeric($entry)) {
$entry = SPFactory::Entry($entry);
}
$en['id'] = $entry->get('id');
$en['nid'] = $entry->get('nid');
$en['name'] = array('_complex' => 1, '_data' => $entry->get('name'), '_attributes' => array('lang' => Sobi::Lang(false)));
$en['url_array'] = array('title' => Sobi::Cfg('sef.alias', true) ? $entry->get('nid') : $entry->get('name'), 'pid' => $entry->get('primary'), 'sid' => $entry->get('id'));
if (strstr(SPRequest::task(), 'search') || $noId || Sobi::Cfg('section.force_category_id', false) && SPRequest::sid() == Sobi::Section()) {
$en['url'] = Sobi::Url(array('title' => Sobi::Cfg('sef.alias', true) ? $entry->get('nid') : $entry->get('name'), 'pid' => $entry->get('primary'), 'sid' => $entry->get('id')));
} else {
$en['url'] = Sobi::Url(array('title' => Sobi::Cfg('sef.alias', true) ? $entry->get('nid') : $entry->get('name'), 'pid' => SPRequest::sid(), 'sid' => $entry->get('id')));
}
if (Sobi::Cfg('list.entry_meta', true)) {
$en['meta'] = array('description' => $entry->get('metaDesc'), 'keys' => $this->metaKeys($entry), 'author' => $entry->get('metaAuthor'), 'robots' => $entry->get('metaRobots'));
}
if ($manager || Sobi::My('id') && Sobi::My('id') == $entry->get('owner') && Sobi::Can('entry', 'edit', 'own', Sobi::Section())) {
$en['edit_url'] = Sobi::Url(array('task' => 'entry.edit', 'pid' => SPRequest::sid(), 'sid' => $entry->get('id')));
} else {
if (isset($en['edit_url'])) {
unset($en['edit_url']);
}
}
$en['edit_url_array'] = array('task' => 'entry.edit', 'pid' => SPRequest::sid(), 'sid' => $entry->get('id'));
$en['created_time'] = $entry->get('createdTime');
$en['updated_time'] = $entry->get('updatedTime');
$en['valid_since'] = $entry->get('validSince');
$en['valid_until'] = $entry->get('validUntil');
$this->fixTimes($en);
if ($entry->get('state') == 0) {
$en['state'] = 'unpublished';
} else {
if (strtotime($entry->get('validUntil')) != 0 && strtotime($entry->get('validUntil')) < time()) {
$en['state'] = 'expired';
} elseif (strtotime($entry->get('validSince')) != 0 && strtotime($entry->get('validSince')) > time()) {
$en['state'] = 'pending';
} else {
$en['state'] = 'published';
}
}
$en['author'] = $entry->get('owner');
$en['counter'] = $entry->get('counter');
$en['approved'] = $entry->get('approved');
// $en[ 'confirmed' ] = $entry->get( 'confirmed' );
if (Sobi::Cfg('list.entry_cats', true)) {
$cats = $entry->get('categories');
$categories = array();
if (count($cats)) {
$cn = SPLang::translateObject(array_keys($cats), array('name', 'alias'));
}
foreach ($cats as $cid => $cat) {
$categories[] = array('_complex' => 1, '_data' => SPLang::clean($cn[$cid]['value']), '_attributes' => array('lang' => Sobi::Lang(false), 'id' => $cat['pid'], 'position' => $cat['position'], 'url' => Sobi::Url(array('sid' => $cat['pid'], 'title' => Sobi::Cfg('sef.alias', true) ? $cat['alias'] : $cat['name']))));
}
$en['categories'] = $categories;
}
$fields = $entry->getFields();
if (count($fields)) {
// foreach ( $fields as $field ) {
// if ( $field->enabled( 'vcard' ) && $field->get( 'id' ) != Sobi::Cfg( 'entry.name_field' ) ) {
// $struct = $field->struct();
// $options = null;
// if ( isset( $struct[ '_options' ] ) ) {
// $options = $struct[ '_options' ];
// unset( $struct[ '_options' ] );
// }
// $f[ $field->get( 'nid' ) ] = array(
// '_complex' => 1,
// '_data' => array(
// 'label' => array(
// '_complex' => 1,
// '_data' => $field->get( 'name' ),
// '_attributes' => array( 'lang' => Sobi::Lang( false ), 'show' => $field->get( 'withLabel' ) )
// ),
// 'data' => $struct,
// ),
// '_attributes' => array( 'id' => $field->get( 'id' ), 'type' => $field->get( 'type' ), 'suffix' => $field->get( 'suffix' ), 'position' => $field->get( 'position' ), 'css_class' => ( strlen( $field->get( 'cssClass' ) ) ? $field->get( 'cssClass' ) : 'spField' ) )
// );
// if ( Sobi::Cfg( 'list.field_description', false ) ) {
// $f[ $field->get( 'nid' ) ][ '_data' ][ 'description' ] = array( '_complex' => 1, '_xml' => 1, '_data' => $field->get( 'description' ) );
// }
// if ( $options ) {
// $f[ $field->get( 'nid' ) ][ '_data' ][ 'options' ] = $options;
// }
// if ( isset( $struct[ '_xml_out' ] ) && count( $struct[ '_xml_out' ] ) ) {
// foreach ( $struct[ '_xml_out' ] as $k => $v )
// $f[ $field->get( 'nid' ) ][ '_data' ][ $k ] = $v;
// }
// }
// }
$en['fields'] = $this->fieldStruct($fields, 'vcard');
}
SPFactory::cache()->addObj($entry, 'entry', $entry->get('id'))->addObj($en, 'entry_struct', $entry->get('id'));
unset($en['url_array']);
unset($en['edit_url_array']);
//.........这里部分代码省略.........
示例15: getEntries
/**
* @param string $eOrder
* @param int $eLimit
* @param int $eLimStart
* @param bool $count
* @param array $conditions
* @param bool $entriesRecursive
* @param int $pid
* @return array
*/
public function getEntries($eOrder, $eLimit = null, $eLimStart = null, $count = false, $conditions = array(), $entriesRecursive = false, $pid = 0)
{
/* var SPDb $db */
$db = SPFactory::db();
$entries = array();
$eDir = 'asc';
$oPrefix = null;
$conditions = is_array($conditions) ? $conditions : array();
/* get the ordering and the direction */
if (strstr($eOrder, '.')) {
$eOr = explode('.', $eOrder);
$eOrder = array_shift($eOr);
$eDir = implode('.', $eOr);
}
$pid = $pid ? $pid : SPRequest::sid();
/* if sort by name, then sort by the name field */
if ($eOrder == 'name') {
$eOrder = SPFactory::config()->nameField()->get('fid');
}
if ($entriesRecursive) {
$pids = $this->_model->getChilds('category', true);
if (is_array($pids)) {
$pids = array_keys($pids);
}
$pids[] = SPRequest::sid();
$conditions['sprl.pid'] = $pids;
} else {
$conditions['sprl.pid'] = $pid;
}
if ($pid == -1) {
unset($conditions['sprl.pid']);
}
/* sort by field */
if (strstr($eOrder, 'field_')) {
static $field = null;
$specificMethod = false;
if (!$field) {
try {
$fType = $db->select('fieldType', 'spdb_field', array('nid' => $eOrder, 'section' => Sobi::Section()))->loadResult();
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('CANNOT_DETERMINE_FIELD_TYPE', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
if ($fType) {
$field = SPLoader::loadClass('opt.fields.' . $fType);
}
}
if ($field && method_exists($field, 'customOrdering')) {
$table = null;
$oPrefix = null;
$specificMethod = call_user_func_array(array($field, 'customOrdering'), array(&$table, &$conditions, &$oPrefix, &$eOrder, &$eDir));
} elseif ($field && method_exists($field, 'sortBy')) {
$table = null;
$oPrefix = null;
$specificMethod = call_user_func_array(array($field, 'sortBy'), array(&$table, &$conditions, &$oPrefix, &$eOrder, &$eDir));
}
if (!$specificMethod) {
$table = $db->join(array(array('table' => 'spdb_field', 'as' => 'fdef', 'key' => 'fid'), array('table' => 'spdb_field_data', 'as' => 'fdata', 'key' => 'fid'), array('table' => 'spdb_object', 'as' => 'spo', 'key' => array('fdata.sid', 'spo.id')), array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => array('fdata.sid', 'sprl.id'))));
$oPrefix = 'spo.';
$conditions['spo.oType'] = 'entry';
$conditions['fdef.nid'] = $eOrder;
$eOrder = 'baseData.' . $eDir;
}
} elseif (strstr($eOrder, 'counter')) {
$table = $db->join(array(array('table' => 'spdb_object', 'as' => 'spo', 'key' => 'id'), array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => array('spo.id', 'sprl.id')), array('table' => 'spdb_counter', 'as' => 'spcounter', 'key' => array('spo.id', 'spcounter.sid'))));
$oPrefix = 'spo.';
$conditions['spo.oType'] = 'entry';
if (strstr($eOrder, '.')) {
$cOrder = explode('.', $eOrder);
$eOrder = 'spcounter.counter.' . $cOrder[1];
} else {
$eOrder = 'spcounter.counter.desc';
}
} else {
$table = $db->join(array(array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => 'id'), array('table' => 'spdb_object', 'as' => 'spo', 'key' => 'id')));
$conditions['spo.oType'] = 'entry';
$eOrder = $eOrder . '.' . $eDir;
$oPrefix = 'spo.';
if (strstr($eOrder, 'valid')) {
$eOrder = $oPrefix . $eOrder;
}
}
/* check user permissions for the visibility */
if (Sobi::My('id')) {
$this->userPermissionsQuery($conditions, $oPrefix);
if (isset($conditions[$oPrefix . 'state']) && $conditions[$oPrefix . 'state']) {
$conditions['sprl.copy'] = 0;
}
} else {
$conditions = array_merge($conditions, array($oPrefix . 'state' => '1', '@VALID' => $db->valid($oPrefix . 'validUntil', $oPrefix . 'validSince')));
$conditions['sprl.copy'] = '0';
//.........这里部分代码省略.........