本文整理汇总了PHP中SPFactory::Instance方法的典型用法代码示例。如果您正苦于以下问题:PHP SPFactory::Instance方法的具体用法?PHP SPFactory::Instance怎么用?PHP SPFactory::Instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPFactory
的用法示例。
在下文中一共展示了SPFactory::Instance方法的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: crawlSobiSection
protected function crawlSobiSection($sid)
{
$done = false;
$task = $this->cleanCache ? 'crawler.restart' : 'crawler.init';
$connection = SPFactory::Instance('services.remote');
while (!$done && time() - $this->start < $this->timeLimit) {
$url = $this->liveURL . "/index.php?option=com_sobipro&task={$task}&sid={$sid}&format=raw&tmpl=component&timeLimit={$this->loopTimeLimit}&fullFormat=1";
list($content, $response) = $this->SpConnect($connection, $url);
$task = 'crawler';
if ($response['http_code'] == 303) {
preg_match('/Location: (http.*)/', $content, $newUrl);
list($content, $response) = $this->SpConnect($connection, $newUrl[1]);
}
if ($response['http_code'] == 200) {
$content = substr($content, $response['header_size']);
$data = json_decode($content);
$done = $data->status == 'done';
$this->SpOut('');
$this->SpOut('============');
$this->SpOut("[ " . date(DATE_RFC2822) . " ] {$data->message}");
$this->SpOut('============');
foreach ($data->data as $row) {
$u = strip_tags($row->url);
$this->SpOut("{$u}\t{$row->count}\t{$row->code}\t{$row->time}");
}
} else {
$done = true;
$this->out('[ERROR] Invalid return code: ' . $response['http_code']);
}
}
}
示例3: check
protected function check($file)
{
$allowed = SPLoader::loadIniFile('etc.files');
$mType = SPFactory::Instance('services.fileinfo', $file)->mimeType();
if (strlen($mType) && !in_array($mType, $allowed)) {
SPFs::delete($file);
$this->message(array('type' => 'error', 'text' => SPLang::e('FILE_WRONG_TYPE', $mType), 'id' => ''));
}
return $mType;
}
示例4: getFunctionsLabel
protected function getFunctionsLabel()
{
if (isset($this->params->interpreter)) {
$interpreter = explode('.', $this->params->interpreter);
$function = array_pop($interpreter);
$obj = SPFactory::Instance(implode('.', $interpreter));
self::$functionsLabel = $obj->{$function}(self::$sid, self::$section);
} elseif (isset($this->params->text)) {
if (isset($this->params->loadTextFile)) {
SPLang::load($this->params->loadTextFile);
}
self::$functionsLabel = Sobi::Txt($this->params->text);
}
}
示例5: validate
public function validate()
{
$type = $this->type == 'SobiProApp' ? 'application' : $this->type;
$schemaDef = SPLoader::path('lib.services.installers.schemas.' . $type, 'front', false, 'xsd');
if (!SPFs::exists($schemaDef) || time() - filemtime($schemaDef) > 60 * 60 * 24 * 7) {
$connection = SPFactory::Instance('services.remote');
$def = "https://xml.sigsiu.net/SobiPro/{$type}.xsd";
$connection->setOptions(array('url' => $def, 'connecttimeout' => 10, 'header' => false, 'returntransfer' => true, 'ssl_verifypeer' => false, 'ssl_verifyhost' => 2));
$schema =& SPFactory::Instance('base.fs.file', SPLoader::path('lib.services.installers.schemas.' . $type, 'front', false, 'xsd'));
$file = $connection->exec();
if (!strlen($file)) {
throw new SPException(SPLang::e('CANNOT_ACCESS_SCHEMA_DEF', $def));
}
$schema->content($file);
$schema->save();
$schemaDef = $schema->filename();
}
if (!$this->definition->schemaValidate($schemaDef)) {
throw new SPException(SPLang::e('CANNOT_VALIDATE_SCHEMA_DEF_AT', str_replace(SOBI_ROOT . DS, null, $this->xmlFile), $def));
}
}
示例6: screen
private function screen()
{
$view =& SPFactory::View('view', true);
$view->setTemplate('config.help');
if (SPLoader::path('etc.repos.sobipro_core.repository', 'front', true, 'xml')) {
$repository = SPFactory::Instance('services.installers.repository');
$repository->loadDefinition(SPLoader::path("etc.repos.sobipro_core.repository", 'front', true, 'xml'));
try {
$repository->connect();
} catch (SPException $x) {
$view->assign(SPLang::e('REPO_ERR', $x->getMessage()), 'message');
}
try {
$response = $repository->help($repository->get('token'), SPRequest::cmd('mid'));
$view->assign($response, 'message');
} catch (SPException $x) {
$view->assign(SPLang::e('REPO_ERR', $x->getMessage()), 'message');
}
} else {
$view->assign(Sobi::Txt('MSG.HELP_ADD_CORE_REPO'), 'message');
}
$view->display();
}
示例7: 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;
}
示例8: 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();
}
示例9: save
public function save(&$attr)
{
static $lang = null;
static $defLang = null;
if (!$lang) {
$lang = Sobi::Lang();
$defLang = Sobi::DefLang();
}
$file = SPRequest::file('spfieldsopts', 'tmp_name');
if ($file) {
$data = parse_ini_file($file, true);
} elseif (is_string($attr['options'])) {
$data = parse_ini_string($attr['options'], true);
} else {
$data = null;
}
$options = $this->parseOptsFile($data);
if (!count($options) && count($attr['options'])) {
$p = 0;
$hold = array();
foreach ($attr['options'] as $o) {
if (is_numeric($o['id'])) {
$o['id'] = $this->nid . '_' . $o['id'];
}
if (isset($o['id'])) {
$i = 0;
$oid = $o['id'];
while (isset($hold[$oid])) {
$oid = $o['id'] . '_' . ++$i;
}
$options[] = array('id' => $oid, 'name' => $o['name'], 'parent' => null, 'position' => ++$p);
$hold[$oid] = $oid;
}
}
}
if (count($options)) {
unset($attr['options']);
$optionsArr = array();
$labelsArr = array();
$optsIds = array();
$defLabelsArr = array();
$duplicates = false;
foreach ($options as $i => $option) {
/* check for doubles */
foreach ($options as $pos => $opt) {
if ($i == $pos) {
continue;
}
if ($option['id'] == $opt['id']) {
$option['id'] = $option['id'] . '_' . substr((string) microtime(), 2, 8) . rand(1, 100);
$duplicates = true;
}
}
$optionsArr[] = array('fid' => $this->id, 'optValue' => $option['id'], 'optPos' => $option['position'], 'optParent' => $option['parent']);
$defLabelsArr[] = array('sKey' => $option['id'], 'sValue' => $option['name'], 'language' => $defLang, 'oType' => 'field_option', 'fid' => $this->id);
$labelsArr[] = array('sKey' => $option['id'], 'sValue' => $option['name'], 'language' => $lang, 'oType' => 'field_option', 'fid' => $this->id);
$optsIds[] = $option['id'];
}
if ($duplicates) {
SPFactory::message()->warning('FIELD_WARN_DUPLICATE_OPT_ID');
}
$db = SPFactory::db();
/* try to delete the existing labels */
try {
$db->delete('spdb_field_option', array('fid' => $this->id));
$db->delete('spdb_language', array('oType' => 'field_option', 'fid' => $this->id, '!sKey' => $optsIds));
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('CANNOT_STORE_FIELD_OPTIONS_DB_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
}
/* insert new values */
try {
$db->insertArray('spdb_field_option', $optionsArr);
$db->insertArray('spdb_language', $labelsArr, true);
if ($defLang != $lang) {
$db->insertArray('spdb_language', $defLabelsArr, false, true);
}
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('CANNOT_DELETE_SELECTED_OPTIONS', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
}
}
if (!isset($attr['params'])) {
$attr['params'] = array();
}
$myAttr = $this->getAttr();
$properties = array();
if (count($myAttr)) {
foreach ($myAttr as $property) {
$properties[$property] = isset($attr[$property]) ? $attr[$property] : null;
}
}
$this->sets['field.options'] = SPFactory::Instance('types.array')->toINIString($data);
/** handle upload of new definition file */
$XMLFile = SPRequest::file('select-list-dependency', 'tmp_name');
if ($XMLFile && file_exists($XMLFile)) {
$XMLFileName = SPRequest::file('select-list-dependency', 'name');
if (SPFs::getExt($XMLFileName) == 'zip') {
$arch = SPFactory::Instance('base.fs.archive');
$name = str_replace('.zip', null, $XMLFileName);
$path = SPLoader::dirPath('tmp.install.' . $name, 'front', false);
$c = 0;
//.........这里部分代码省略.........
示例10: array
protected function &createMenu($task = null)
{
if (!$task) {
$task = 'config.' . $this->_task;
}
/* load the menu definition */
if (Sobi::Section()) {
/* create menu */
$menu =& SPFactory::Instance('views.adm.menu', $task, Sobi::Section());
$cfg = SPLoader::loadIniFile('etc.adm.section_menu');
/* create new SigsiuTree */
$tree = SPFactory::Instance('mlo.tree');
/* set link */
$tree->setHref(Sobi::Url(array('sid' => '{sid}')));
$tree->setId('menuTree');
/* set the task to expand the tree */
$tree->setTask('category.expand');
$tree->init(Sobi::Section());
/* add the tree into the menu */
$menu->addCustom('AMN.ENT_CAT', $tree->getTree());
$seClass = SPLoader::loadModel('section');
$cSec = new $seClass();
$cSec->init(Sobi::Section());
} else {
$cfg = SPLoader::loadIniFile('etc.adm.config_menu');
/* create menu */
$menu =& SPFactory::Instance('views.adm.menu', $task);
}
Sobi::Trigger('Create', 'AdmMenu', array(&$cfg));
if (count($cfg)) {
foreach ($cfg as $section => $keys) {
$menu->addSection($section, $keys);
}
}
if (!Sobi::Section()) {
$menu->addCustom('GB.CFG.GLOBAL_TEMPLATES', $this->listTemplates());
}
Sobi::Trigger('AfterCreate', 'AdmMenu', array(&$menu));
return $menu;
}
示例11: remove
public function remove()
{
$pid = $this->xGetString('id');
$function = $this->xGetString('uninstall');
if ($function) {
$obj = explode(':', $function);
$function = $obj[1];
$obj = $obj[0];
return SPFactory::Instance($obj)->{$function}($this->definition);
}
$permissions = $this->xGetChilds('installLog/permissions/*');
if ($permissions && $permissions instanceof DOMNodeList) {
$permsCtrl =& SPFactory::Instance('ctrl.adm.acl');
for ($i = 0; $i < $permissions->length; $i++) {
$perm = explode('.', $permissions->item($i)->nodeValue);
$permsCtrl->removePermission($perm[0], $perm[1], $perm[2]);
}
}
/** it doesn't make much sense that way - a backup is ok but this action is called uninstall and not revert */
// $mods = $this->xGetChilds( 'installLog/modified/*' );
// if ( $mods && ( $mods instanceof DOMNodeList ) ) {
// $this->revert( $mods );
// }
$files = $this->xGetChilds('installLog/files/*');
if ($files && $files instanceof DOMNodeList) {
for ($i = 0; $i < $files->length; $i++) {
$file = $files->item($i)->nodeValue;
if (!strstr($file, SOBI_ROOT)) {
$file = Sobi::FixPath(SOBI_ROOT . "/{$file}");
}
if (SPFs::exists($file)) {
SPFs::delete($file);
}
}
}
$actions = $this->xGetChilds('installLog/actions/*');
if ($actions && $actions instanceof DOMNodeList) {
for ($i = 0; $i < $actions->length; $i++) {
try {
SPFactory::db()->delete('spdb_plugin_task', array('pid' => $pid, 'onAction' => $actions->item($i)->nodeValue));
} catch (SPException $x) {
Sobi::Error('installer', SPLang::e('Cannot remove plugin task "%s". Db query failed. Error: %s', $actions->item($i)->nodeValue, $x->getMessage()), SPC::WARNING, 0);
}
}
if ($this->xGetString('type') == 'payment') {
try {
SPFactory::db()->delete('spdb_plugin_task', array('pid' => $pid, 'onAction' => 'PaymentMethodView'));
} catch (SPException $x) {
Sobi::Error('installer', SPLang::e('Cannot remove plugin task "PaymentMethodView". Db query failed. Error: %s', $x->getMessage()), SPC::WARNING, 0);
}
}
}
$field = $this->xdef->query("/{$this->type}/fieldType[@typeId]");
if ($field && $field->length) {
try {
SPFactory::db()->delete('spdb_field_types', array('tid' => $field->item(0)->getAttribute('typeId')));
} catch (SPException $x) {
Sobi::Error('installer', SPLang::e('CANNOT_REMOVE_FIELD_DB_ERR', $field->item(0)->getAttribute('typeId'), $x->getMessage()), SPC::WARNING, 0);
}
}
$tables = $this->xGetChilds('installLog/sql/tables/*');
if ($tables && $tables instanceof DOMNodeList) {
for ($i = 0; $i < $tables->length; $i++) {
try {
SPFactory::db()->drop($tables->item($i)->nodeValue);
} catch (SPException $x) {
Sobi::Error('installer', SPLang::e('CANNOT_DROP_TABLE', $tables->item($i)->nodeValue, $x->getMessage()), SPC::WARNING, 0);
}
}
}
$inserts = $this->xGetChilds('installLog/sql/queries/*');
if ($inserts && $inserts instanceof DOMNodeList) {
for ($i = 0; $i < $inserts->length; $i++) {
$table = $inserts->item($i)->attributes->getNamedItem('table')->nodeValue;
$where = array();
$cols = $inserts->item($i)->childNodes;
if ($cols->length) {
for ($j = 0; $j < $cols->length; $j++) {
$where[$cols->item($j)->nodeName] = $cols->item($j)->nodeValue;
}
}
try {
SPFactory::db()->delete($table, $where, 1);
} catch (SPException $x) {
Sobi::Error('installer', SPLang::e('CANNOT_DELETE_DB_ENTRIES', $table, $x->getMessage()), SPC::WARNING, 0);
}
}
}
$type = strlen($this->xGetString('type')) ? $this->xGetString('type') : ($this->xGetString('fieldType') ? 'field' : null);
switch ($type) {
default:
case 'SobiProApp':
case 'plugin':
$t = Sobi::Txt('EX.PLUGIN_TYPE');
break;
case 'field':
$t = Sobi::Txt('EX.FIELD_TYPE');
break;
case 'payment':
$t = Sobi::Txt('EX.PAYMENT_METHOD_TYPE');
//.........这里部分代码省略.........
示例12: tree
protected function tree()
{
$selector = null;
$selectedCategories = array();
$tree = SPFactory::Instance('mlo.tree', Sobi::Cfg('list.categories_ordering'), array('preventParents' => !$this->catsWithChilds));
$tree->setHref('#');
$tree->setTask('category.chooser');
$tree->setId($this->nid);
$tree->disable(Sobi::Section());
$tree->init(Sobi::Section());
$params = array();
$params['maxcats'] = $this->catsMaxLimit;
$params['field'] = $this->nid;
$params['preventParents'] = !$this->catsWithChilds;
$setheight = '';
if ($this->height > 0) {
$setheight = " style=\"height: {$this->height}px;\"";
}
$addBtParams = array('class' => 'btn');
$delBtParams = array('class' => 'btn');
$selectParams = array();
SPFactory::header()->addJsFile('opt.field_category_tree')->addJsCode('SobiPro.jQuery( document ).ready( function () { new SigsiuTreeEdit( ' . json_encode($params) . '); } );');
$selector = $selector . '<div class="tree"' . $setheight . '>' . $tree->display(true) . '</div>';
if (count($this->_selectedCats)) {
$selected = SPLang::translateObject($this->_selectedCats, 'name', 'category');
if (count($selected)) {
$count = 0;
foreach ($selected as $category) {
if ($category['id'] == $this->sid && SPRequest::task() != 'entry.add') {
continue;
}
$selectedCategories[$category['id']] = $category['value'];
$count++;
if ($count == $this->catsMaxLimit) {
break;
}
}
}
}
if (count($selectedCategories) >= $this->catsMaxLimit) {
$addBtParams['disabled'] = 'disabled';
$selectParams['readonly'] = 'readonly';
} elseif (!count($selectedCategories)) {
$delBtParams['disabled'] = 'disabled';
}
$selector .= '<div class="selected">';
$selector .= SPHtml_Input::select($this->nid . '_list', $selectedCategories, null, true, $selectParams);
$selector .= SPHtml_Input::hidden($this->nid, 'json://' . json_encode(array_keys($selectedCategories)));
$selector .= '</div>';
$selector .= '<div class="buttons">';
$selector .= SPHtml_Input::button('addCategory', Sobi::Txt('CC.ADD_BT'), $addBtParams);
$selector .= SPHtml_Input::button('removeCategory', Sobi::Txt('CC.DEL_BT'), $delBtParams);
$selector .= '</div>';
$selector = '<div class="SigsiuTree" id="' . $this->nid . '_canvas">' . $selector . '</div>';
if ($this->modal) {
$selector = SPHtml_Input::modalWindow(Sobi::Txt('EN.SELECT_CAT_PATH'), $this->nid . '_modal', $selector, 'modaltree modal hide', 'CLOSE', null);
$field = SPHtml_Input::button('select-category', Sobi::Txt('EN.SELECT_CAT_PATH'), array('class' => 'btn btn-primary', 'href' => '#' . $this->nid . '_modal', 'data-toggle' => 'modal', 'id' => $this->nid . '_modal_fire'));
return $field . $selector;
} else {
return $selector;
}
}
示例13: view
protected function view()
{
/* determine template package */
$tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE);
Sobi::ReturnPoint();
$this->_task = 'date';
if (!$this->_model) {
$this->setModel('section');
$this->_model->init(Sobi::Section());
}
$this->visible();
/* 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));
$date = explode('.', SPRequest::cmd('date'));
$this->date['year'] = isset($date[0]) && $date[0] ? $date[0] : null;
$this->date['month'] = isset($date[1]) && $date[1] ? $date[1] : null;
$this->date['day'] = isset($date[2]) && $date[2] ? $date[2] : null;
if (!$this->date['year'] || !(int) $this->date['year']) {
throw new SPException(SPLang::e('INVALID_DATE_GIVEN'));
}
/* get the site to display */
$site = SPRequest::int('site', 1);
$eLimStart = ($site - 1) * $eLimit;
$conditions = array('spo.oType' => 'entry', 'year(createdTime)' => $this->date['year']);
$listing = 'year';
if ($this->date['month'] && $this->date['month'] < 13 && $this->date['month'] > 0) {
$conditions['month(createdTime)'] = $this->date['month'];
$listing = 'month';
}
if ($this->date['day'] && $this->date['day'] < 13 && $this->date['day'] > 0) {
$conditions['day(createdTime)'] = $this->date['day'];
$listing = 'date';
}
$eOrder = 'createdTime';
$eCount = count($this->getEntries($eOrder, 0, 0, true, $conditions, true, Sobi::Section()));
$entries = $this->getEntries($eOrder, $eLimit, $eLimStart, true, $conditions, true, Sobi::Section());
$url = array('sid' => SPRequest::sid(), 'task' => 'list.date', 'date' => SPRequest::cmd('date'));
$pn = SPFactory::Instance('helpers.pagenav_' . $this->tKey($this->template, 'template_type', 'xslt'), $eLimit, $eCount, $site, $url);
if (SPRequest::int('site', 0)) {
$url['site'] = SPRequest::int('site', 0);
}
SPFactory::header()->addCanonical(Sobi::Url($url, true, true, true));
/* handle meta data */
SPFactory::header()->objMeta($this->_model);
$date = $this->date;
$monthsNames = explode(',', Sobi::Txt('JS_CALENDAR_MONTHS'));
$date['month'] = isset($monthsNames[$date['month'] - 1]) ? trim($monthsNames[$date['month'] - 1]) : null;
SPFactory::mainframe()->addToPathway(Sobi::Txt('DL.PATH_TITLE_' . strtoupper($listing), $date), Sobi::Url('current'));
SPFactory::header()->addTitle(Sobi::Txt('DL.TITLE_' . strtoupper($listing), $date), 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->setConfig($this->_tCfg, $this->template);
$view->setTemplate($tplPackage . '.' . $this->templateType . '.' . $this->template);
$view->assign($pn->get(), 'navigation');
$view->assign(SPFactory::user()->getCurrent(), 'visitor');
$view->assign($entries, 'entries');
Sobi::Trigger('UserListing', 'View', array(&$view));
$view->display();
}
示例14: listFields
/**
* List all fields in this section
*/
private function listFields()
{
/* @var SPdb $db */
$ord = $this->parseOrdering('forder', 'position.asc');
SPLoader::loadClass('html.input');
Sobi::ReturnPoint();
/* create menu */
$sid = Sobi::Reg('current_section');
$menu = SPFactory::Instance('views.adm.menu', 'field.list', $sid);
$cfg = SPLoader::loadIniFile('etc.adm.section_menu');
Sobi::Trigger('Create', 'AdmMenu', array(&$cfg));
if (count($cfg)) {
foreach ($cfg as $section => $keys) {
$menu->addSection($section, $keys);
}
}
Sobi::Trigger('AfterCreate', 'AdmMenu', array(&$menu));
/* create new SigsiuTree */
$tree = SPLoader::loadClass('mlo.tree');
$tree = new $tree(Sobi::GetUserState('categories.order', 'corder', 'position.asc'));
/* set link */
$tree->setHref(Sobi::Url(array('sid' => '{sid}')));
$tree->setId('menuTree');
/* set the task to expand the tree */
$tree->setTask('category.expand');
$tree->init($sid);
/* add the tree into the menu */
$menu->addCustom('AMN.ENT_CAT', $tree->getTree());
try {
$results = SPFactory::db()->select('*', 'spdb_field', array('section' => $sid), $ord)->loadObjectList();
} catch (SPException $x) {
// SPConfig::debOut(SPFactory::db()->getQuery());
Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
$fields = array();
if (count($results)) {
foreach ($results as $result) {
$field = SPFactory::Model('field', true);
$field->extend($result);
$fields[] = $field;
}
}
$fieldTypes = $this->getFieldTypes();
$subMenu = array();
foreach ($fieldTypes as $type => $group) {
asort($group);
$subMenu[] = array('label' => $type, 'element' => 'nav-header');
foreach ($group as $t => $l) {
$subMenu[] = array('type' => null, 'task' => 'field.add.' . $t, 'label' => $l, 'icon' => 'tasks', 'element' => 'button');
}
}
SPFactory::View('field', true)->addHidden($sid, 'sid')->assign($fields, 'fields')->assign($subMenu, 'fieldTypes')->assign(Sobi::Section(true), 'section')->assign($menu, 'menu')->assign(Sobi::GetUserState('fields.order', 'forder', 'position.asc'), 'ordering')->assign($this->_task, 'task')->determineTemplate('field', 'list')->display();
}
示例15: 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;
}