本文整理汇总了PHP中Sobi::Cfg方法的典型用法代码示例。如果您正苦于以下问题:PHP Sobi::Cfg方法的具体用法?PHP Sobi::Cfg怎么用?PHP Sobi::Cfg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sobi
的用法示例。
在下文中一共展示了Sobi::Cfg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extract
/**
* @param string $to - path where the archive should be extracted to
* @return bool
*/
public function extract($to)
{
$r = false;
$ext = SPFs::getExt($this->_filename);
switch ($ext) {
case 'zip':
$zip = new ZipArchive();
if ($zip->open($this->_filename) === true) {
SPException::catchErrors(SPC::WARNING);
try {
$zip->extractTo($to);
$zip->close();
$r = true;
} catch (SPException $x) {
$t = Sobi::FixPath(Sobi::Cfg('fs.temp') . DS . md5(microtime()));
SPFs::mkdir($t, 0777);
$dir = SPFactory::Instance('base.fs.directory', $t);
if ($zip->extractTo($t)) {
$zip->close();
$dir->moveFiles($to);
$r = true;
}
SPFs::delete($dir->getPathname());
}
SPException::catchErrors(0);
}
break;
}
return $r;
}
示例2: 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()))));
}
}
}
示例3: 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);
}
示例4: __construct
/**
* @param string $definition
* @param string $type
* @return SPInstaller
*/
public function __construct($definition, $type = null)
{
$this->type = $type;
$this->xmlFile = $definition;
$this->definition = new DOMDocument(Sobi::Cfg('xml.version', '1.0'), Sobi::Cfg('xml.encoding', 'UTF-8'));
$this->definition->load($this->xmlFile);
$this->xdef = new DOMXPath($this->definition);
$this->root = dirname($this->xmlFile);
}
示例5: nameField
private function nameField()
{
/* get the field id of the field contains the entry name */
if ($this->section == Sobi::Section() || !$this->section) {
$nameField = Sobi::Cfg('entry.name_field');
} else {
$nameField = SPFactory::db()->select('sValue', 'spdb_config', array('section' => $this->section, 'sKey' => 'name_field', 'cSection' => 'entry'))->loadResult();
}
return $nameField ? $nameField : Sobi::Cfg('entry.name_field');
}
示例6: getRevision
public function getRevision($rev)
{
if (Sobi::Cfg('entry.versioning', true)) {
$log = (array) SPFactory::db()->select('*', 'spdb_history', array('revision' => $rev))->loadObject('revision');
if (count($log)) {
$log['changes'] = SPConfig::unserialize($log['changes']);
}
return $log;
} else {
return array();
}
}
示例7: view
private function view()
{
$type = $this->key('template_type', 'xslt');
if ($type != 'php' && Sobi::Cfg('global.disable_xslt', false)) {
$type = 'php';
}
if ($type == 'xslt') {
$visitor = $this->get('visitor');
$current = $this->get('section');
$categories = $this->get('categories');
$entries = $this->get('entries');
$data = array();
$data['id'] = $current->get('id');
$data['section'] = array('_complex' => 1, '_data' => Sobi::Section(true), '_attributes' => array('id' => Sobi::Section(), 'lang' => Sobi::Lang(false)));
$data['name'] = array('_complex' => 1, '_data' => $this->get('listing_name'), '_attributes' => array('lang' => Sobi::Lang(false)));
if (Sobi::Cfg('category.show_desc')) {
$desc = $current->get('description');
if (Sobi::Cfg('category.parse_desc')) {
Sobi::Trigger('prepare', 'Content', array(&$desc, $current));
}
$data['description'] = array('_complex' => 1, '_cdata' => 1, '_data' => $desc, '_attributes' => array('lang' => Sobi::Lang(false)));
}
$data['meta'] = array('description' => $current->get('metaDesc'), 'keys' => $this->metaKeys($current), 'author' => $current->get('metaAuthor'), 'robots' => $current->get('metaRobots'));
$data['entries_in_line'] = $this->get('$eInLine');
$data['categories_in_line'] = $this->get('$cInLine');
$this->menu($data);
$this->alphaMenu($data);
$data['visitor'] = $this->visitorArray($visitor);
if (count($categories)) {
foreach ($categories as $category) {
if (is_numeric($category)) {
$category = SPFactory::Category($category);
}
$data['categories'][] = array('_complex' => 1, '_attributes' => array('id' => $category->get('id'), 'nid' => $category->get('nid')), '_data' => $this->category($category));
unset($category);
}
}
if (count($entries)) {
$this->loadNonStaticData($entries);
$manager = Sobi::Can('entry', 'edit', '*', Sobi::Section()) ? true : false;
foreach ($entries as $eid) {
$en = $this->entry($eid, $manager);
$data['entries'][] = array('_complex' => 1, '_attributes' => array('id' => $en['id']), '_data' => $en);
}
$this->navigation($data);
}
$this->_attr = $data;
}
// general listing trigger
Sobi::Trigger('Listing', ucfirst(__FUNCTION__), array(&$this->_attr));
// specific lisitng trigger
Sobi::Trigger($this->_type, ucfirst(__FUNCTION__), array(&$this->_attr));
}
示例8: 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;
}
示例9: 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);
}
示例10: 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);
}
示例11: errors
private function errors()
{
$errors = $this->get('errors');
$levels = $this->get('levels');
$icons = array('error' => Sobi::Cfg('list_icons.err_err'), 'warning' => Sobi::Cfg('list_icons.err_warn'), 'notice' => Sobi::Cfg('list_icons.err_notice'), 'details' => Sobi::Cfg('list_icons.err_details'));
/* create the header */
if (count($errors)) {
foreach ($errors as $i => $error) {
$error['errFile'] = str_replace(SOBI_ADM_PATH, null, $error['errFile']);
$error['errFile'] = str_replace(SOBI_PATH, null, $error['errFile']);
$error['errFile'] = str_replace(SOBI_ROOT, null, $error['errFile']);
$error['errFile'] = $error['errFile'] . ': ' . $error['errLine'];
if ($error['errReq']) {
$error['errReq'] = "<a href=\"{$error['errReq']}\" target=\"_blank\">{$error['errReq']}</a>";
}
$level = $levels[$error['errNum']];
switch ($error['errNum']) {
case E_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_USER_ERROR:
case E_RECOVERABLE_ERROR:
$error['errNum'] = "<img src=\"{$icons['error']}\" alt=\"{$level}\" title=\"{$level}\"/><br/>{$level}";
break;
case E_WARNING:
case E_CORE_WARNING:
case E_COMPILE_WARNING:
case E_USER_WARNING:
$error['errNum'] = "<img src=\"{$icons['warning']}\" alt=\"{$level}\" title=\"{$level}\"/><br/>{$level}";
break;
case E_NOTICE:
case E_USER_NOTICE:
case E_STRICT:
case E_USER_WARNING:
case E_DEPRECATED:
case E_USER_DEPRECATED:
$error['errNum'] = "<img src=\"{$icons['notice']}\" alt=\"{$level}\" title=\"{$level}\"/><br/>{$level}";
break;
}
$error['errMsg'] = str_replace(SOBI_ROOT, null, $error['errMsg']);
$error['errMsg'] = str_replace('href=\'function.', 'target="_blank" href=\'http://php.net/manual/en/function.', $error['errMsg']);
$dh = Sobi::Url(array('task' => 'error.details', 'eid' => $error['eid']));
$error['details'] = "<a href=\"{$dh}\"><img src=\"{$icons['details']}\"/></a>";
$errors[$i] = $error;
}
}
// Sobi::Error( 'H', date( DATE_RFC1123 ), SPC::ERROR );
$this->assign($errors, 'errors');
}
示例12: edit
/**
*/
private function edit()
{
$pid = $this->get('category.parent');
$path = null;
if (!$pid) {
$pid = SPRequest::int('pid');
}
$this->assign($pid, 'parent');
$id = $this->get('category.id');
if ($id) {
$this->addHidden($id, 'category.id');
}
if (!strstr($this->get('category.icon'), 'font')) {
if ($this->get('category.icon') && SPFs::exists(Sobi::Cfg('images.category_icons') . '/' . $this->get('category.icon'))) {
$i = Sobi::FixPath(Sobi::Cfg('images.category_icons_live') . $this->get('category.icon'));
$this->assign($i, 'category_icon');
} else {
$i = Sobi::FixPath(Sobi::Cfg('images.category_icons_live') . Sobi::Cfg('icons.default_selector_image', 'image.png'));
$this->assign($i, 'category_icon');
}
}
// else {
// $i = SPLang::clean( $this->get( 'category.icon' ) );
// $this->assign( $i, 'category_icon' );
// }
/* if editing - get the full path. Otherwise get the path of the parent element */
$id = $id ? $id : $pid;
if ($this->get('category.id')) {
$path = $this->parentPath($id);
$parentCat = $this->parentPath($id, false, true);
} else {
$path = $this->parentPath(SPRequest::sid());
$parentCat = $this->parentPath(SPRequest::sid(), false, true, 1);
}
$this->assign($path, 'parent_path');
$this->assign($parentCat, 'parent_cat');
if (SPRequest::sid()) {
$this->assign(Sobi::Url(array('task' => 'category.chooser', 'sid' => SPRequest::sid(), 'out' => 'html'), true), 'cat_chooser_url');
} elseif (SPRequest::int('pid')) {
$this->assign(Sobi::Url(array('task' => 'category.chooser', 'pid' => SPRequest::int('pid'), 'out' => 'html'), true), 'cat_chooser_url');
}
$this->assign(Sobi::Url(array('task' => 'category.icon', 'out' => 'html'), true), 'icon_chooser_url');
}
示例13: Error
/**
* @param string $section - error section. I.e. Entry controller
* @param string $msg - main message
* @param int $type - error type
* @param int $code - error code
* @param int $line - file line
* @param string $file - file name
* @param null $sMsg
* @internal param string $smsg - additional message
* @return null
*/
public static function Error($section, $msg, $type = SPC::NOTICE, $code = 0, $line = null, $file = null, $sMsg = null)
{
if ($type == 0) {
$type = SPC::NOTICE;
}
/*
* Mi., Jul 4, 2012
* So now could someone explain me what was the sense of the code below and why trigger_error was commented out??!!
*
* Mi., Jul 4, 2012
* Ok, it doesn't make much sense.
* This is what actually should be removed.
* if( Sobi::Cfg( 'debug.level', 0 ) < $type ) { return true; }
* It was the problem with the ACL when error reporting was disabled.
* But why the hell I removed the damn trigger_error from it?!!!
* Being sloppy again?!!!!
* Frack me - it means that since 20.07.2011 the whole error reporting went in nirvana??
*/
if ($type == E_USER_ERROR) {
$rType = E_ERROR;
$code = $code ? $code : 500;
} elseif ($type == E_USER_WARNING) {
$rType = E_WARNING;
} else {
$rType = $type;
}
if (Sobi::Cfg('debug.level', 0) >= $rType) {
if ($file) {
$sMsg .= sprintf('In file %s at line %d', $file, $line);
}
if (SPRequest::task()) {
$sMsg .= ' [ ' . SPRequest::task() . ' ]';
}
$error = array('section' => $section, 'message' => $msg, 'code' => $code, 'file' => $file, 'line' => $line, 'content' => $sMsg);
trigger_error('json://' . json_encode($error), $type);
}
if ($code) {
SPLoader::loadClass('base.mainframe');
SPLoader::loadClass('cms.base.mainframe');
SPFactory::mainframe()->runAway($msg, $code, SPConfig::getBacktrace());
}
return null;
}
示例14: SpSendMail
/**
* @param array $recipient Recipient e-mail address
* @param string $subject E-mail subject
* @param string $body Message body
* @param bool $html - HTML mail or plain text
* @param array $replyto Reply to email address
* @param array $cc CC e-mail address
* @param array $bcc BCC e-mail address
* @param string $attachment Attachment file name
* @param array $cert - pem certificate
* @param array $from - array( from, fromname )
* @internal param array $replytoname Reply to name
* @return boolean True on success
*/
public static function SpSendMail($recipient, $subject, $body, $html = false, $replyto = null, $cc = null, $bcc = null, $attachment = null, $cert = null, $from = null)
{
$from = is_array($from) ? $from : array(Sobi::Cfg('mail.from'), Sobi::Cfg('mail.fromname'));
$mail = new self();
$mail->setSender($from);
$mail->setSubject($subject);
$mail->setBody($body);
if ($html) {
$mail->IsHTML(true);
}
if ($cert) {
$mail->Sign($cert['certificate'], $cert['key'], $cert['password']);
}
$mail->addRecipient($recipient);
$mail->addCC($cc);
$mail->addBCC($bcc);
$mail->addAttachment($attachment);
$mail->addReplyTo($replyto);
return $mail->Send();
}
示例15: display
/**
*
*/
public function display()
{
$this->_type = 'frontpage';
$type = $this->key('template_type', 'xslt');
if ($type != 'php' && Sobi::Cfg('global.disable_xslt', false)) {
$type = 'php';
}
if ($type == 'xslt') {
$sections = $this->get('sections');
$data = array();
if (count($sections)) {
foreach ($sections as $section) {
$s = array('name' => array('_complex' => 1, '_data' => $section->get('name'), '_attributes' => array('lang' => Sobi::Lang(false))), 'description' => array('_complex' => 1, '_cdata' => 1, '_data' => $section->get('description'), '_attributes' => array('lang' => Sobi::Lang(false))), 'createdTime' => $section->get('createdTime'), 'meta' => array('description' => $section->get('metaDesc'), 'keys' => $this->metaKeys($section), 'author' => $section->get('metaAuthor'), 'robots' => $section->get('metaRobots')), 'owner' => $section->get('owner'), 'version' => $section->get('version'), 'validSince' => $section->get('validSince'), 'validUntil' => $section->get('validUntil'), 'url' => Sobi::Url(array('sid' => $section->get('id'))));
$data[] = array('_complex' => 1, '_data' => $s, '_attributes' => array('id' => $section->get('id'), 'nid' => $section->get('nid')));
}
}
$this->assign($data, 'sections');
Sobi::Trigger($this->_type, ucfirst(__FUNCTION__), array(&$this->_attr));
}
parent::display();
}