本文整理汇总了PHP中SPLang::nid方法的典型用法代码示例。如果您正苦于以下问题:PHP SPLang::nid方法的具体用法?PHP SPLang::nid怎么用?PHP SPLang::nid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPLang
的用法示例。
在下文中一共展示了SPLang::nid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
/**
* @return string
*/
public function display()
{
$this->_view[] = "\n <!-- Sobi Pro - admin side menu start -->";
$this->_view[] = "\n<div id=\"SPaccordionTabs\" class=\"SPmenuTabs\">";
$this->_view[] = '<div id="SPMenuCtrl">';
$this->_view[] = ' <button class="btn btn-mini btn-sobipro" id="SPMenuCtrlBt" type="button">-</button>';
$this->_view[] = '</div>';
$media = Sobi::Cfg('img_folder_live');
$this->_view[] = "\n<div class='well well-small'><a href=\"http://www.Sigsiu.NET\" target=\"_blank\" title=\"Sigsiu.NET Software Development\"><img src=\"{$media}/sp.png\" alt=\"Sigsiu.NET Software Development\" style=\"border-style:none;\" /></a></div>\n";
$fs = null;
if (count($this->_sections)) {
if ($this->_task == 'section.view') {
// $this->_task = 'section.entries';
$this->_open = 'AMN.ENT_CAT';
}
$this->_view[] = '<div class="accordion" id="SpMenu">';
foreach ($this->_sections as $section => $list) {
$sid = SPLang::nid($section);
$in = false;
if (!$fs) {
$fs = $sid;
}
if (!$this->_open && array_key_exists($this->_task, $list)) {
$this->_open = $sid;
$in = ' in';
}
if ($this->_open && $section == $this->_open) {
$in = ' in';
}
if (!$this->_open && array_key_exists($this->_task, $list)) {
$in = ' in';
}
$this->_view[] = '<div class="accordion-group">';
$this->_view[] = '<div class="accordion-heading">';
$this->_view[] = '<a class="accordion-toggle" data-toggle="collapse" data-parent="#SpMenu" href="#' . $sid . '">';
$this->_view[] = Sobi::Txt($section);
$this->_view[] = '</a>';
$this->_view[] = '</div>';
$this->_view[] = '<div id="' . $sid . '" class="accordion-body collapse' . $in . '">';
$this->_view[] = '<div class="accordion-inner">';
$this->_view[] = $this->section($list, $section);
$this->_view[] = '</div>';
$this->_view[] = '</div>';
$this->_view[] = '</div>';
}
$this->_view[] = '</div>';
}
$this->_view[] = "\n</div>\n";
$this->_view[] = '<div class="brand" style="display: inherit;">© <a href="http://www.sigsiu.net">Sigsiu.NET GmbH</a></div>';
$this->_view[] = "\n<!-- Sobi Pro - admin side menu end -->\n";
return implode("\n", $this->_view);
}
示例2: download
private function download()
{
// $file = SPLoader::path( 'tmp.info', 'front', false, 'txt' );
$cont = null;
$settings = array();
$settings['SobiPro'] = array('Version' => SPFactory::CmsHelper()->myVersion(true), 'Version_Num' => implode('.', SPFactory::CmsHelper()->myVersion()));
$file = SPLoader::path('tmp.info', 'front', false, 'txt');
// if ( SPFs::exists( $file ) ) {
// $cont = SPFs::read( $file );
// }
// $cont = explode( "\n", $cont );
// if ( count( $cont ) ) {
// foreach ( $cont as $line ) {
// if ( strstr( $line, '=' ) ) {
// $line = explode( "=", $line );
// $line[ 1 ] = explode( ';', $line[ 1 ] );
// $settings[ $line[ 0 ] ] = array( 'key' => $line[ 0 ], 'response' => $line[ 1 ][ 0 ], 'status' => $line[ 1 ][ 1 ] );
// }
// }
// }
$this->prepareStoredData($settings);
$settings['env'] = array('PHP_OS' => PHP_OS, 'php_uname' => php_uname(), 'PHP_VERSION_ID' => PHP_VERSION_ID);
$settings['ftp'] = $this->ftp();
$settings['curl'] = $this->curlFull();
$settings['exec']['response'] = $this->execResp();
$settings['SOBI_SETTINGS'] = SPFactory::config()->getSettings();
$c = SPFactory::db()->select('*', 'spdb_config')->loadObjectList();
$sections = SPFactory::db()->select(array('nid', 'id'), 'spdb_object', array('oType' => 'section'))->loadAssocList('id');
$as = array();
foreach ($c as $key) {
if ($key->section == 0 || !isset($sections[$key->section])) {
continue;
}
$key->section = $sections[$key->section]['nid'];
if (!isset($as[$key->section])) {
$as[$key->section] = array();
}
if (!isset($as[$key->section][$key->cSection])) {
$as[$key->section][$key->cSection] = array();
}
$_c = explode('_', $key->sKey);
if ($_c[count($_c) - 1] == 'array') {
$key->sValue = SPConfig::unserialize($key->sValue);
}
$as[$key->section][$key->cSection][$key->sKey] = $key->sValue;
}
$settings['SOBI_SETTINGS']['sections'] = $as;
$apps = SPFactory::db()->select('*', 'spdb_plugins')->loadObjectList();
foreach ($apps as $app) {
$settings['Apps'][$app->pid] = get_object_vars($app);
}
$settings['SOBI_SETTINGS']['mail']['smtphost'] = $settings['SOBI_SETTINGS']['mail']['smtphost'] ? 'SET' : 0;
$settings['SOBI_SETTINGS']['mail']['smtpuser'] = $settings['SOBI_SETTINGS']['mail']['smtpuser'] ? 'SET' : 0;
$settings['SOBI_SETTINGS']['mail']['smtppass'] = $settings['SOBI_SETTINGS']['mail']['smtppass'] ? 'SET' : 0;
$php = ini_get_all();
unset($php['extension_dir']);
unset($php['include_path']);
unset($php['mysql.default_user']);
unset($php['mysql.default_password']);
unset($php['mysqli.default_pw']);
unset($php['mysqli.default_user']);
unset($php['open_basedir']);
unset($php['pdo_mysql.default_socket']);
unset($php['sendmail_path']);
unset($php['session.name']);
unset($php['session.save_path']);
unset($php['soap.wsdl_cache_dir']);
unset($php['upload_tmp_dir']);
unset($php['doc_root']);
unset($php['docref_ext']);
unset($php['docref_root']);
unset($php['mysql.default_socket']);
$settings['PHP_SETTINGS'] = $php;
$php = get_loaded_extensions();
$settings['PHP_EXT'] = $php;
$out = SPFactory::Instance('types.array');
$data = $out->toXML($settings, 'settings');
$data = str_replace(array(SOBI_ROOT, '></'), array('REMOVED', '>0</'), $data);
$f = SPLang::nid($settings['SOBI_SETTINGS']['general']['site_name'] . '-' . date(DATE_RFC822));
SPFactory::mainframe()->cleanBuffer();
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
header("Content-type: application/xml");
header("Content-Disposition: attachment; filename=\"sobipro_system_{$f}.xml\"");
header('Content-Length: ' . strlen($data));
ob_clean();
flush();
echo $data;
exit;
}
示例3: hidden
public static function hidden($name, $value = null, $id = null, $params = array())
{
$data = self::createDataTag($params);
$id = $id ? $id : SPLang::nid($name);
$f = "\n<input type=\"hidden\" name=\"{$name}\" id=\"{$id}\" value=\"{$value}\" {$data}/>";
return "\n<!-- '{$name}' Output -->{$f}<!-- '{$name}' End -->\n\n";
}
示例4: nid
protected function nid($txt)
{
return $this->legacy ? strtolower(SPLang::nid($txt)) : SPLang::nid($txt);
}
示例5: parseOptsFile
protected function parseOptsFile($file)
{
$p = 0;
$group = null;
$gid = null;
$options = array();
if (is_array($file) && count($file)) {
foreach ($file as $key => $value) {
if (is_array($value)) {
if (strstr($key, ',')) {
$group = explode(',', $key);
$gid = SPLang::nid($group[0]);
$group = $group[1];
} else {
$gid = SPLang::nid($key, true, true);
$group = $key;
}
$options[] = array('id' => $gid, 'name' => $group, 'parent' => null, 'position' => ++$p);
if (count($value)) {
foreach ($value as $k => $v) {
if (is_numeric($k)) {
$k = SPLang::nid($v);
}
$options[] = array('id' => SPLang::nid($k), 'name' => $v, 'parent' => $gid, 'position' => ++$p);
}
}
} else {
$group = null;
$gid = null;
$options[] = array('id' => SPLang::nid($key), 'name' => $value, 'parent' => null, 'position' => ++$p);
}
}
}
return $options;
}
示例6: varName
/**
* Creates alias/nid suitable string
* @param string $txt
* @return string
*/
public static function varName($txt)
{
$pieces = explode(' ', $txt);
$txt = null;
for ($i = 0; $i < count($pieces); $i++) {
$pieces[$i] = SPLang::nid($pieces[$i]);
// preg_replace( '/[^a-z0-9_]/', null, strtolower( $pieces[ $i ] ) );
if ($i > 0) {
$pieces[$i] = ucfirst($pieces[$i]);
}
$txt .= $pieces[$i];
}
return $txt;
}
示例7: installExt
/**
* @param DOMDocument $def
* @param string $dir
* @return array | string
*/
protected function installExt($def, $dir)
{
$this->checkRequirements($def);
jimport('joomla.installer.installer');
jimport('joomla.installer.helper');
$installer = JInstaller::getInstance();
$type = JInstallerHelper::detectType($dir);
$xp = new DOMXPath($def);
try {
$installer->install($dir);
// it was core update - break now
if ($type == 'component') {
SPFactory::cache()->cleanAll();
return array('msg' => Sobi::Txt('CMS_SOBIPRO_UPDATE_INSTALLED', $def->getElementsByTagName('version')->item(0)->nodeValue), 'msgtype' => SPC::SUCCESS_MSG);
}
$msg = Sobi::Txt('CMSEX_INSTALLED', $type, $def->getElementsByTagName('name')->item(0)->nodeValue);
$this->id = SPLang::nid($def->getElementsByTagName('name')->item(0)->nodeValue);
$id = $xp->query('//filename[@module|@plugin]')->item(0);
$this->id = strlen($id->getAttribute('module')) ? $id->getAttribute('module') : $id->getAttribute('plugin');
if (strlen($def->documentElement->getAttribute('group'))) {
$this->id = $def->documentElement->getAttribute('group') . '_' . $this->id;
}
if ($this->id) {
$this->definition = new DOMDocument();
$this->definition->formatOutput = true;
$this->definition->preserveWhiteSpace = false;
$this->definition->appendChild($this->definition->createElement('SobiProApp'));
$root = $this->definition->getElementsByTagName('SobiProApp')->item(0);
$root->appendChild($this->definition->createElement('id', $this->id));
$root->appendChild($this->definition->createElement('type', $type));
$root->appendChild($this->definition->createElement('name', $def->getElementsByTagName('name')->item(0)->nodeValue));
$root->appendChild($this->definition->createElement('uninstall', 'cms.base.installer:remove'));
$this->definition->appendChild($root);
$dir = SPLoader::dirPath('etc.installed.' . $type . 's', 'front', false);
if (!SPFs::exists($dir)) {
SPFs::mkdir($dir);
}
$path = $dir . '/' . $this->id . '.xml';
$file = SPFactory::Instance('base.fs.file', $path);
$this->definition->normalizeDocument();
$file->content($this->definition->saveXML());
$file->save();
$this->storeData($type, $def);
}
return array('msg' => $msg, 'msgtype' => SPC::SUCCESS_MSG);
} catch (Exception $x) {
$this->error = Sobi::Txt('CMS_EXT_NOT_INSTALLED') . ' ' . $x->getMessage();
$this->errorType = SPC::ERROR_MSG;
return array('msg' => $this->error, 'msgtype' => SPC::ERROR_MSG);
}
}
示例8: renderButton
private function renderButton($button, $list = false)
{
$rel = null;
$onclick = null;
$title = '';
$class = isset($button['class']) ? ' ' . $button['class'] : null;
if (isset($button['type']) && $button['type'] == 'url') {
$rel = null;
$href = $this->getLink($button);
} elseif (!isset($button['task']) || !$button['task']) {
$href = $this->getLink($button);
} else {
$rel = $button['task'];
$href = '#';
}
if (!isset($button['label']) || !$button['label']) {
$label = $this->getLabel($button);
} else {
$label = $button['label'];
}
if (isset($button['confirm'])) {
$title = ' title="' . Sobi::Txt($button['confirm']) . '" ';
}
if ($button['element'] == 'button-legacy') {
$class .= ' legacy';
$onclick = 'onclick="Joomla.submitform(\'' . $rel . '\');"';
// damn SqueezeBox - download field license window
$rel = null;
}
$target = isset($button['target']) && $button['target'] ? " target=\"{$button['target']}\"" : null;
if (isset($button['buttons']) && count($button['buttons'])) {
$this->output[] = '<div class="btn-group">';
$this->output[] = "<a href=\"{$href}\" class=\"{$this->btClass}{$class}\"{$target} rel=\"{$rel}\">";
if (!(isset($button['icon']) && $button['icon'])) {
$icon = $this->getIcon($button, true);
} else {
$icon = $button['icon'];
}
$this->output[] = '<i class="icon-' . $icon . '"></i> ' . $label;
$this->output[] = '</a>';
$this->output[] = '<button class="' . $this->btClass . ' dropdown-toggle" data-toggle="dropdown"><span class="icon-caret-down"></span> </button>';
$this->output[] = '<div class="dropdown-menu" id="spmenu-' . SPLang::nid($button['task']) . '">';
$this->output[] = '<ul class="nav nav-stacked SpDropDownBt">';
foreach ($button['buttons'] as $bt) {
$this->renderButton($bt, true);
}
$this->output[] = '</ul>';
$this->output[] = '</div>';
$this->output[] = '</div>';
} elseif (!$list) {
$this->output[] = "<a href=\"{$href}\" rel=\"{$rel}\" class=\"{$this->btClass}{$class}\"{$target}{$onclick}{$title}>";
if (!(isset($button['icon']) && $button['icon'])) {
$icon = $this->getIcon($button);
} else {
$icon = $button['icon'];
}
$this->output[] = '<i class="icon-' . $icon . '"></i> ' . $label;
$this->output[] = '</a>';
} else {
if ($button['element'] == 'nav-header') {
$this->output[] = '<li class="nav-header">' . $button['label'] . '</li>';
} else {
$this->output[] = '<li><a href="' . $href . '"' . $target . $title . ' rel="' . $rel . '">';
if (!(isset($button['icon']) && $button['icon'])) {
$icon = $this->getIcon($button);
} else {
$icon = $button['icon'];
}
if (isset($button['selected'])) {
if (!$button['selected']) {
$icon = $this->icons['not-selected'];
} else {
$icon = $this->icons['selected'];
// $this->output[ ] = '<i class="icon-' . $this->icons[ 'selected' ] . '"></i> ';
}
}
$this->output[] = '<i class="icon-' . $icon . '"></i> ' . $label;
$this->output[] = '</a></li>';
}
}
}
示例9: xmlField
/**
* @param DOMNode $node
* @param array $element
* @param mixed $value
* @param bool $skipCondition
* @param null $subject
* @param $i
* @return void
*/
protected function xmlField($node, &$element, $value = null, $skipCondition = false, $subject = null, $i = -1)
{
if (!$skipCondition && !$this->xmlCondition($node)) {
return;
}
if (SPRequest::task() == 'entry.edit' && SPRequest::cmd('revision') && isset($element['attributes']['name'])) {
$i = str_replace('entry.', null, $element['attributes']['name']);
if (isset($this->_attr['revision'][$i])) {
$element['revisions-change'] = $element['attributes']['name'];
}
}
/** process all attributes */
$attributes = $node->attributes;
$params = array();
$args = array('type' => null, 'name' => null, 'value' => $value);
$adds = array('before' => null, 'after' => null);
$xml = array();
if ($attributes->length) {
/** @var DOMElement $attribute */
foreach ($attributes as $attribute) {
$xml[$attribute->nodeName] = $attribute->nodeValue;
switch ($attribute->nodeName) {
case 'name':
$args['id'] = SPLang::nid($attribute->nodeValue);
$element['id'] = $args['id'];
$params['id'] = $args['id'];
case 'name':
case 'type':
case 'width':
case 'height':
case 'prefix':
$args[$attribute->nodeName] = $attribute->nodeValue;
break;
case 'editor':
case 'multi':
$args[$attribute->nodeName] = $attribute->nodeValue == 'true' ? true : false;
break;
case 'selected':
/** if it is being called from a loop, we have to try it that way first */
if (strlen($subject)) {
$args[$attribute->nodeName] = $this->get($subject . '.' . $attribute->nodeValue, $i);
if ($args[$attribute->nodeName]) {
break;
}
}
case 'value':
if ($value) {
break;
}
/** no break here */
/** no break here */
case 'values':
$args[$attribute->nodeName] = $this->get($attribute->nodeValue);
break;
case 'value-parsed':
$args['value'] = $attribute->nodeValue;
break;
case 'value-text':
$args['value'] = Sobi::Txt($attribute->nodeValue);
break;
case 'label':
case 'header':
$element[$attribute->nodeName] = Sobi::Txt($attribute->nodeValue);
$args[$attribute->nodeName] = Sobi::Txt($attribute->nodeValue);
break;
case 'placeholder':
$params[$attribute->nodeName] = Sobi::Txt($attribute->nodeValue);
break;
default:
if (strstr($attribute->nodeValue, 'var:[')) {
$params[$attribute->nodeName] = $this->parseValue($attribute->nodeValue);
} else {
$params[$attribute->nodeName] = $attribute->nodeValue;
}
$args[$attribute->nodeName] = $params[$attribute->nodeName];
break;
}
}
}
if ($node->hasChildNodes()) {
foreach ($node->childNodes as $child) {
if (strstr($child->nodeName, '#')) {
continue;
}
/** @var DOMNode $child */
switch ($child->nodeName) {
case 'values':
if ($child->childNodes->length) {
$values = array();
/** @var DOMNode $value */
foreach ($child->childNodes as $value) {
//.........这里部分代码省略.........
示例10: addNewRule
public function addNewRule($name, $sections, $perms, $groups, $note = null)
{
SPLoader::loadClass('cms.base.users');
$db =& SPFactory::db();
try {
$db->insertUpdate('spdb_permissions_rules', array('rid' => 'NULL', 'name' => $name, 'nid' => SPLang::nid($name), 'validSince' => $db->getNullDate(), 'validUntil' => $db->getNullDate(), 'note' => $note, 'state' => 1));
$rid = $db->insertid();
} catch (SPException $x) {
Sobi::Error('ACL', SPLang::e('CANNOT_CREATE_RULE_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
$affectedGroups = array();
$gids = SPUser::availableGroups();
foreach ($gids as $id => $group) {
if (in_array($group, $groups) || in_array(strtolower($group), $groups)) {
$affectedGroups[] = array('rid' => $rid, 'gid' => $id);
}
}
try {
$db->insertArray('spdb_permissions_groups', $affectedGroups);
} catch (SPException $x) {
Sobi::Error('ACL', SPLang::e('CANNOT_INSERT_GROUPS_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
if (!count($this->_perms)) {
$this->loadPermissions();
}
$map = array();
foreach ($perms as $perm) {
$perm = explode('.', $perm);
$pid = $db->select('pid', 'spdb_permissions', array('subject' => $perm[0], 'action' => $perm[1], 'value' => $perm[2]))->loadResult();
if ($pid) {
foreach ($sections as $sid) {
$map[] = array('rid' => $rid, 'sid' => $sid, 'pid' => $pid);
}
}
}
if (count($map)) {
try {
$db->insertArray('spdb_permissions_map', $map, true);
} catch (SPException $x) {
Sobi::Error('ACL', SPLang::e('CANNOT_INSERT_GROUPS_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
}
return $rid;
}
示例11: save
/**
* Save existing field
*/
protected function save($clone = false)
{
$sets = array();
if (!SPFactory::mainframe()->checkToken()) {
Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
}
$fid = SPRequest::int('fid');
$field = SPFactory::Model('field', true);
if ($fid) {
$f = $this->loadField($fid);
$field->extend($f);
} else {
$field->loadType(SPRequest::cmd('field_fieldType'));
}
$nid = SPRequest::cmd('field_nid');
if (!$nid || !strstr($nid, 'field_')) {
/** give me my spaces back!!! */
$nid = strtolower(str_replace('-', '_', SPLang::nid('field_' . SPRequest::string('field_name'))));
SPRequest::set('field_nid', $nid);
}
$this->getRequest();
$this->validate($field);
if ($clone || !$fid) {
try {
$fid = $field->saveNew($this->attr);
$field->save($this->attr);
} catch (SPException $x) {
$this->response(Sobi::Url(array('task' => 'field.edit', 'fid' => $fid, 'sid' => SPRequest::sid())), $x->getMessage(), false, SPC::ERROR_MSG);
}
} else {
try {
$field->save($this->attr);
} catch (SPException $x) {
$this->response(Sobi::Url(array('task' => 'field.edit', 'fid' => $fid, 'sid' => SPRequest::sid())), $x->getMessage(), false, SPC::ERROR_MSG);
}
}
$alias = $field->get('nid');
$fieldSets = $field->get('sets');
if (is_array($fieldSets) && count($fieldSets)) {
$sets = array_merge($fieldSets, $sets);
}
$sets['fid'] = $field->get('fid');
$sets['field.nid'] = $alias;
/* in case we are changing the sort by field */
if (Sobi::Cfg('list.entries_ordering') == $alias && $field->get('nid') != $alias) {
SPFactory::config()->saveCfg('list.entries_ordering', $field->get('nid'));
}
SPFactory::cache()->cleanSection();
if ($this->_task == 'apply' || $clone) {
if ($clone) {
$msg = Sobi::Txt('FM.FIELD_CLONED');
$this->response(Sobi::Url(array('task' => 'field.edit', 'fid' => $fid, 'sid' => SPRequest::sid())), $msg);
} else {
$msg = Sobi::Txt('MSG.ALL_CHANGES_SAVED');
$this->response(Sobi::Url(array('task' => 'field.edit', 'fid' => $fid, 'sid' => SPRequest::sid())), $msg, false, 'success', array('sets' => $sets));
}
} else {
$this->response(Sobi::Back(), Sobi::Txt('MSG.ALL_CHANGES_SAVED'));
}
}
示例12: categories
/**
* @param $categories
* @param $sid
* @return void
*/
private function categories($categories, $sid)
{
for ($i = 0; $i < $categories->length; $i++) {
$category = $categories->item($i);
if ($category->nodeName == 'category') {
$name = $this->txt($category, 'name');
$introtext = $this->txt($category, 'introtext');
$description = $this->txt($category, 'description');
$icon = $this->txt($category, 'icon');
$cat = SPFactory::Model('category');
$cat->set('state', 1);
/* Additional data */
$options = $category->getElementsByTagName('option');
if ($options instanceof DOMNodeList && $options->length) {
foreach ($options as $option) {
$v = $option->nodeValue;
if (in_array($option->nodeValue, array('true', 'false'))) {
$v = $option->nodeValue == 'true' ? true : false;
}
$cat->set($option->getAttribute('attribute'), $v);
}
}
/* Base category data */
$cat->set('description', $description);
$cat->set('name', $name);
$cat->set('nid', SPLang::nid($name));
$cat->set('introtext', $introtext);
$cat->set('parent', $sid);
$cat->set('icon', $icon);
/* save the category */
$cat->save();
/* Handle subcats */
$childs = $this->xdef->query("childs/category", $category);
if ($childs && $childs->length) {
if ($childs instanceof DOMNodeList && $childs->length) {
$this->categories($childs, $cat->get('id'));
}
}
}
}
}
示例13: parseOrdering
/**
* @param string $subject
* @param string $col
* @param string $def
* @return string
*/
protected function parseOrdering($subject, $col, $def)
{
return Sobi::GetUserState($subject . '.ordering.' . SPLang::nid(Sobi::Section(true)), $col, $def);
}
示例14: cloneTpl
private function cloneTpl()
{
$dir = $this->dir(SPRequest::cmd('templateName'));
$newName = SPRequest::word('templateNewName', 'Duplicated Template', 'post');
$dirName = SPLang::nid($newName);
$dirNameOrg = $dirName;
$c = 1;
while (SPFs::exists(SPLoader::dirPath('usr.templates.' . $dirName, 'front', false))) {
$dirName = $dirNameOrg . '-' . $c++;
}
$newPath = SPLoader::dirPath('usr.templates.' . $dirName, 'front', false);
if (!SPFs::copy($dir, $newPath)) {
throw new SPException(SPLang::e('COULD_NOT_COPY_DIRECTORY', $dir, $newPath));
}
$defFile = SPLoader::path($newPath . '.template', 'absolute', true, 'xml');
if ($defFile) {
$fc = SPLoader::loadClass('base.fs.file');
$def = new DOMDocument();
$def->load($defFile);
$xdef = new DOMXPath($def);
$oldName = $xdef->query('/template/name')->item(0)->nodeValue;
$oldDesc = $xdef->query('/template/description')->item(0)->nodeValue;
$date = SPFactory::config()->date(time());
$xdef->query('/template/name')->item(0)->nodeValue = $newName;
$xdef->query('/template/creationDate')->item(0)->nodeValue = $date;
$xdef->query('/template/id')->item(0)->nodeValue = $dirName;
$newDesc = Sobi::Txt('TP.CLONE_NOTE', array('name' => $oldName, 'date' => $date));
$xdef->query('/template/description')->item(0)->nodeValue = "{$newDesc}\n{$oldDesc}";
$file = new $fc($defFile);
$file->content($def->saveXML());
$file->save();
}
$this->response(Sobi::Url(array('task' => 'template.info', 'template' => str_replace(SOBI_PATH . DS . 'usr' . DS . 'templates' . DS, null, $dirName))), Sobi::Txt('TP.DUPLICATED'), false, 'success');
}
示例15: save
/**
* (non-PHPdoc)
* @see Site/lib/models/SPDBObject#save()
*/
public function save($request = 'post')
{
$this->loadFields(Sobi::Section(), true);
// Thu, Feb 19, 2015 12:12:47 - it should be actually "beforeSave"
Sobi::Trigger($this->name(), 'Before' . ucfirst(__FUNCTION__), array($this->id));
/* save the base object data */
/* @var SPdb $db */
$db = SPFactory::db();
$db->transaction();
$clone = SPRequest::task() == 'entry.clone';
if (!$this->nid || $clone) {
$this->nid = strtolower(SPLang::nid(SPRequest::string($this->nameField, null, false, $request)));
$this->nid = $this->createAlias();
/** Thu, Jul 30, 2015 12:15:25 - what the hell was that? */
// $this->name = $this->nid;
}
if (!$this->id && Sobi::Cfg('entry.publish_limit', 0) && !defined('SOBI_ADM_PATH')) {
SPRequest::set('entry_createdTime', 0, $request);
SPRequest::set('entry_validSince', 0, $request);
SPRequest::set('entry_validUntil', 0, $request);
$this->validUntil = gmdate('Y-m-d H:i:s', time() + Sobi::Cfg('entry.publish_limit', 0) * 24 * 3600);
}
$preState = Sobi::Reg('object_previous_state');
parent::save($request);
$nameField = $this->nameField();
/* get the fields for this section */
foreach ($this->fields as $field) {
/* @var $field SPField */
try {
if ($field->enabled('form', $preState['new'])) {
$field->saveData($this, $request, $clone);
} else {
$field->finaliseSave($this, $request, $clone);
}
if ($field->get('id') == $nameField) {
/* get the entry name */
$this->name = $field->getRaw();
/* save the nid (name id) of the field where the entry name is saved */
$this->nameField = $field->get('nid');
}
} catch (SPException $x) {
if (SPRequest::task() != 'entry.clone') {
$db->rollback();
throw new SPException(SPLang::e('CANNOT_SAVE_FIELS_DATA', $x->getMessage()));
} else {
Sobi::Error($this->name(), SPLang::e('CANNOT_SAVE_FIELS_DATA', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
}
}
$values = array();
/* get categories */
$cats = Sobi::Reg('request_categories');
if (!count($cats)) {
$cats = SPRequest::arr('entry_parent', SPFactory::registry()->get('request_categories', array()), $request);
}
/* by default it should be comma separated string */
if (!count($cats)) {
$cats = SPRequest::string('entry_parent', null, $request);
if (strlen($cats) && strpos($cats, ',')) {
$cats = explode(',', $cats);
foreach ($cats as $i => $cat) {
$c = (int) trim($cat);
if ($c) {
$cats[$i] = $c;
} else {
unset($cats[$i]);
}
}
} elseif (strlen($cats)) {
$cats = array((int) $cats);
}
}
if (is_array($cats) && count($cats)) {
foreach ($cats as $i => $v) {
if (!$v) {
unset($cats[$i]);
}
}
}
if (is_array($cats) && count($cats)) {
/* get the ordering in these categories */
try {
$db->select('pid, MAX(position)', 'spdb_relations', array('pid' => $cats, 'oType' => 'entry'), null, 0, 0, false, 'pid');
$cPos = $db->loadAssocList('pid');
$currPos = $db->select(array('pid', 'position'), 'spdb_relations', array('id' => $this->id, 'oType' => 'entry'))->loadAssocList('pid');
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
}
/* set the right position */
foreach ($cats as $i => $cat) {
$copy = 0;
if (!$this->approved) {
$copy = isset($this->categories[$cats[$i]]) ? 0 : 1;
} else {
$db->delete('spdb_relations', array('id' => $this->id, 'oType' => 'entry'));
}
//.........这里部分代码省略.........