Exemplo n.º 1
0
 /**
  * @param string $title
  * @return string|void
  */
 public function setTitle($title)
 {
     $title = Sobi::Txt($title, array('section' => $this->get('section.name')));
     Sobi::Trigger('setTitle', $this->name(), array(&$title));
     SPFactory::header()->setTitle($title);
     $this->set($title, 'site_title');
 }
Exemplo n.º 2
0
 protected function translate()
 {
     $term = Sobi::Txt(SPRequest::cmd('term'));
     Sobi::Trigger('Translate', 'Text', array(&$term));
     SPFactory::mainframe()->cleanBuffer()->customHeader();
     echo json_encode(array('translation' => $term));
     exit;
 }
Exemplo n.º 3
0
 /**
  * @param string $title
  * @return string
  */
 public function setTitle($title)
 {
     $name = $this->get('entry.name');
     Sobi::Trigger('setTitle', $this->name(), array(&$title));
     $title = Sobi::Txt($title, array('entry_name' => $name));
     $this->set($name, 'entry_name');
     $title = parent::setTitle($title);
     return $title;
 }
Exemplo n.º 4
0
 public function __construct($id = 0)
 {
     parent::__construct($id);
     if (is_numeric($this->gid)) {
         $this->gid = array($this->gid);
     }
     $this->spGroups();
     /* include default visitor permissions */
     $this->gid[] = 0;
     $this->parentGids();
     Sobi::Trigger('UserGroup', 'Appoint', array($id, &$this->gid));
 }
Exemplo n.º 5
0
 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));
 }
Exemplo n.º 6
0
 /**
  * @param string $title
  * @return void
  */
 public function setTitle($title)
 {
     $name = $this->get('template_name');
     if (!strlen($name)) {
         $name = $this->get('file_name');
         $title = Sobi::Txt($title, array('path' => $name));
     } else {
         $title = Sobi::Txt($title, array('template' => $name));
     }
     Sobi::Trigger('setTitle', $this->name(), array(&$title));
     SPFactory::header()->setTitle($title);
     $this->set($title, 'site_title');
 }
Exemplo n.º 7
0
 /**
  * @param string $title
  * @return string
  */
 public function setTitle($title)
 {
     $name = $this->get('section.name');
     if ($name) {
         Sobi::Trigger('setTitle', $this->name(), array(&$title));
         $title = $name;
         //Sobi::Txt( $title, array( 'category_name' => $name ) );
         $this->set($name, 'category_name');
         $this->set($name, 'section_name');
         $this->set($title, 'site_title');
     }
     $title = parent::setTitle($title);
     return $title;
 }
Exemplo n.º 8
0
 /**
  */
 private function getSections()
 {
     try {
         $sections = SPFactory::db()->select('*', 'spdb_object', array('oType' => 'section'), 'id')->loadObjectList();
     } catch (SPException $x) {
         Sobi::Error($this->name(), SPLang::e('CANNOT_GET_SECTIONS_LIST', $x->getMessage()), SPC::WARNING, 500, __LINE__, __FILE__);
     }
     if (count($sections)) {
         foreach ($sections as $section) {
             if (Sobi::Can('section', 'access', $section->id, 'valid')) {
                 $s = SPFactory::Section($section->id);
                 $s->extend($section);
                 $this->_sections[] = $s;
             }
         }
         Sobi::Trigger($this->name(), __FUNCTION__, array(&$this->_sections));
     }
 }
Exemplo n.º 9
0
 public function __construct($id = 0)
 {
     parent::__construct($id);
     $this->gid[] = 0;
     // this array is really a bad joke :(
     foreach ($this->groups as $index => $value) {
         if (is_string($index) && !is_numeric($index)) {
             $this->gid[] = $value;
             $this->usertype = $index;
         } else {
             $this->gid[] = $index;
             $this->usertype = $value;
         }
     }
     $this->spGroups();
     /* include default visitor permissions */
     $this->parentGids();
     Sobi::Trigger('UserGroup', 'Appoint', array($id, &$this->gid));
 }
Exemplo n.º 10
0
 /**
  *
  */
 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();
 }
Exemplo n.º 11
0
 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());
 }
Exemplo n.º 12
0
 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));
 }
Exemplo n.º 13
0
 /**
  * Triggering plugin action
  *
  * @param string $action
  * @param string $subject
  * @param mixed $params
  * @return bool
  */
 public static function TriggerPlugin($action, $subject = null, $params = array())
 {
     return Sobi::Trigger($action, $subject, $params);
 }
Exemplo n.º 14
0
 /**
  * @param array $cfg
  * @param string $template
  * @return $this
  */
 public function &setConfig($cfg, $template)
 {
     $this->_config = $cfg;
     if (isset($cfg[$template]) && count($cfg[$template])) {
         foreach ($cfg[$template] as $k => $v) {
             $this->_config[$k] = $v;
         }
     }
     if (isset($this->_config['general']['css_files'])) {
         $this->_config['general']['css_files'] = explode(',', $this->_config['general']['css_files']);
         foreach ($this->_config['general']['css_files'] as $file) {
             $this->loadCSSFile(trim($file));
         }
     }
     if (isset($this->_config['general']['js_files'])) {
         $this->_config['general']['js_files'] = explode(',', $this->_config['general']['js_files']);
         foreach ($this->_config['general']['js_files'] as $file) {
             if (trim($file)) {
                 $this->loadJsFile(trim($file));
             }
         }
     }
     if ($this->key('site_title')) {
         $this->setTitle($this->key('site_title'));
     }
     if (isset($this->_config['hidden'])) {
         foreach ($this->_config['hidden'] as $name => $defValue) {
             $this->addHidden(SPRequest::string($name, $defValue), $name);
         }
     }
     Sobi::Trigger('afterLoadConfig', $this->name(), array(&$this->_config));
     return $this;
 }
Exemplo n.º 15
0
 /**
  * Creating URL from a array for the current CMS
  * @param array $var
  * @param bool $js
  * @param bool $sef
  * @param bool $live
  * @param bool $forceItemId
  * @return string
  */
 public static function url($var = null, $js = false, $sef = true, $live = false, $forceItemId = false)
 {
     $url = self::baseUrl;
     if ($var == 'current') {
         return SPRequest::raw('REQUEST_URI', self::baseUrl, 'SERVER');
     }
     // don't remember why :(
     // Nevertheless it is generating & in URL fro ImEx
     //		$sef = Sobi::Cfg( 'disable_sef_globally', false ) ? false : ( defined( 'SOBIPRO_ADM' ) && !( $forceItemId ) ? false : $sef );
     $sef = Sobi::Cfg('disable_sef_globally', false) ? false : $sef;
     Sobi::Trigger('Create', 'Url', array(&$var, $js));
     if (is_array($var) && !empty($var)) {
         if (isset($var['option'])) {
             $url = str_replace('com_sobipro', $var['option'], $url);
             unset($var['option']);
         }
         if (isset($var['sid']) && (!defined('SOBIPRO_ADM') || $forceItemId) || defined('SOBIPRO_ADM') && $sef && $live) {
             if (!isset($var['Itemid']) || !$var['Itemid']) {
                 SPFactory::mainframe()->getItemid($var);
             }
         }
         if (isset($var['title'])) {
             if (Sobi::Cfg('url.title', true)) {
                 $var['title'] = trim(SPLang::urlSafe($var['title']));
                 $var['sid'] = $var['sid'] . ':' . $var['title'];
             }
             unset($var['title']);
         }
         if (isset($var['format']) && $var['format'] == 'raw' && $sef) {
             unset($var['format']);
         }
         foreach ($var as $k => $v) {
             if ($k == 'out') {
                 switch ($v) {
                     case 'html':
                         $var['tmpl'] = 'component';
                         unset($var['out']);
                         break;
                     case 'xml':
                         $var['tmpl'] = 'component';
                         $var['format'] = 'raw';
                     case 'raw':
                         $var['tmpl'] = 'component';
                         $var['format'] = 'raw';
                         break;
                     case 'json':
                         $var['out'] = 'json';
                         $var['format'] = 'raw';
                         $var['tmpl'] = 'component';
                         break;
                 }
             }
         }
         foreach ($var as $k => $v) {
             $url .= "&{$k}={$v}";
         }
     } elseif (is_string($var)) {
         if (strstr($var, 'index.php?')) {
             $url = null;
         } else {
             $url .= '&';
         }
         if (strstr($var, '=')) {
             $var = str_replace('&', '&', $var);
             $var = str_replace('&', '&', $var);
             $url .= $var;
         } else {
             $url .= SOBI_TASK . '=';
             $url .= $var;
         }
     } elseif (is_array($var)) {
     }
     if ($sef && !$live) {
         $url = JRoute::_($url, false);
     } else {
         $url = preg_replace('/&(?![#]?[a-z0-9]+;)/i', '&', $url);
     }
     if ($live) {
         /*
          * SubDir Issues:
          * when using SEF Joomla! router returns also the subdir
          * and JURI::base returns the subdir too
          * So if the URL should be SEF we have to remove the subdirectory once
          * Otherwise it doesn't pass the JRoute::_ method so there is no subdir included
          * */
         if ($sef) {
             $base = JURI::base(true);
             $root = str_replace($base, null, Sobi::Cfg('live_site'));
             $url = explode('/', $url);
             $url = $url[count($url) - 1];
             //                if ( defined( 'SOBIPRO_ADM' ) ) {
             //                    $router = JApplication::getInstance( 'site' )->getRouter();
             //                    $a = $router->build( $url );
             //                    $url = $router->build( $url )->toString();
             //                }
             if (!defined('SOBIPRO_ADM')) {
                 $url = JRoute::_($url, false);
             }
             $url = Sobi::FixPath("{$root}{$url}");
         } else {
             $adm = defined('SOBIPRO_ADM') ? SOBI_ADM_FOLDER : null;
             $url = Sobi::FixPath(Sobi::Cfg('live_site') . $adm . '/' . $url);
         }
     }
     $url = str_replace('%3A', ':', $url);
     // all urls in front are passed to the XML/XSL template are going to be encoded anyway
     $o = SPRequest::cmd('format', SPRequest::cmd('out'));
     if (!in_array($o, array('raw', 'xml')) && !defined('SOBI_ADM_PATH')) {
         $url = html_entity_decode($url);
     }
     $url = str_replace(' ', '%20', urldecode($url));
     return $js ? str_replace('amp;', null, $url) : $url;
 }
Exemplo n.º 16
0
 private function editFile()
 {
     if (Sobi::Section() && Sobi::Cfg('section.template') == SPC::DEFAULT_TEMPLATE) {
         SPFactory::message()->warning(Sobi::Txt('TP.DEFAULT_WARN', 'https://www.sigsiu.net/help_screen/template.info'), false)->setSystemMessage();
     }
     $file = SPRequest::cmd('file');
     $file = $this->file($file);
     $ext = SPFs::getExt($file);
     $fileContent = SPFs::read($file);
     $path = str_replace('\\', '/', SOBI_PATH);
     if (strstr($file, $path)) {
         $filename = str_replace($path . '/usr/templates/', null, $file);
     } else {
         $filename = str_replace(SOBI_ROOT, null, $file);
     }
     $menu = $this->createMenu();
     if (Sobi::Section()) {
         $menu->setOpen('AMN.APPS_SECTION_TPL');
     } else {
         $menu->setOpen('GB.CFG.GLOBAL_TEMPLATES');
     }
     /** @var $view SPAdmTemplateView */
     $view = SPFactory::View('template', true)->assign($fileContent, 'file_content')->assign($filename, 'file_name')->assign($ext, 'file_ext')->assign($menu, 'menu')->assign($this->_task, 'task')->assign(Sobi::Section(), 'sid')->addHidden(SPRequest::cmd('file'), 'fileName')->addHidden($filename, 'filePath')->determineTemplate('template', 'edit');
     Sobi::Trigger('Edit', $this->name(), array(&$file, &$view));
     $view->display();
 }
Exemplo n.º 17
0
 /**
  * @param string $task
  */
 function __construct($task)
 {
     SPLoader::loadClass('base.exception');
     set_error_handler('SPExceptionHandler');
     $this->_err = ini_set('display_errors', 'on');
     $this->_mem = memory_get_usage();
     $this->_time = microtime();
     $this->_task = $task;
     /* load all needed classes */
     SPLoader::loadClass('base.factory');
     SPLoader::loadClass('base.object');
     SPLoader::loadClass('base.const');
     SPLoader::loadClass('base.filter');
     SPLoader::loadClass('base.request');
     SPLoader::loadClass('sobi');
     SPLoader::loadClass('base.config');
     /* authorise access */
     $this->checkAccess();
     /* initialise mainframe interface to CMS */
     $this->_mainframe =& SPFactory::mainframe();
     /* get sid if any */
     $this->_sid = SPRequest::sid();
     /* determine section */
     $this->getSection();
     /* initialise config */
     $this->createConfig();
     ini_set('display_errors', Sobi::Cfg('debug.display_errors', false));
     $this->_deb = error_reporting(Sobi::Cfg('debug.level', 0));
     /* trigger plugin */
     Sobi::Trigger('AdminStart');
     /* initialise translator and load language files */
     SPLoader::loadClass('cms.base.lang');
     SPLang::setLang(Sobi::Lang());
     try {
         SPLang::registerDomain('admin');
     } catch (SPException $x) {
         Sobi::Error('CoreCtrl', SPLang::e('Cannot register language domain: %s.', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     /* load admin html files */
     SPFactory::header()->initBase(true);
     /** @noinspection PhpParamsInspection */
     if ($this->_section) {
         $sectionName = SPLang::translateObject($this->_section, 'name', 'section');
         SPFactory::registry()->set('current_section_name', SPLang::clean($sectionName[$this->_section]['value']));
     }
     if ($this->_section && !Sobi::Cfg('section.template')) {
         SPFactory::config()->set('template', SPC::DEFAULT_TEMPLATE, 'section');
     }
     /* check if it wasn't plugin custom task */
     if (!Sobi::Trigger('custom', 'task', array($this, SPRequest::task()))) {
         /* if not, start to route */
         try {
             $this->route();
         } catch (SPException $x) {
             Sobi::Error('CoreCtrl', SPLang::e('Cannot route: %s.', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
         }
     }
     return true;
 }
Exemplo n.º 18
0
 /**
  */
 public function execute()
 {
     switch ($this->_task) {
         case 'panel':
             $this->getSections();
             /** @var $view SPAdmPanelView */
             $view = SPFactory::View('front', true)->assign($acl, 'acl')->assign($this->_sections, 'sections')->assign($this->getNews(), 'news')->assign(Sobi::GetUserState('sections.order', 'order', 'name.asc'), 'order')->assign(SPFactory::CmsHelper()->myVersion(true), 'version')->assign(Sobi::Cfg('cpanel.show_entries', false), 'show-entries')->assign($this->getState(), 'system-state');
             if (Sobi::Cfg('cpanel.show_entries', false)) {
                 $view->assign($this->getEntries(), 'entries');
             }
             SPLang::load('com_sobipro.about');
             $view->determineTemplate('front', 'cpanel');
             Sobi::Trigger('Panel', 'View', array(&$view));
             $view->display();
             break;
         default:
             /* case plugin didn't registered this task, it was an error */
             if (!parent::execute()) {
                 Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
             }
             break;
     }
 }
Exemplo n.º 19
0
 public static function userGetter($name, $value, $params = null, $class = null, $format = '%user')
 {
     $params = self::checkArray($params);
     if (!isset($params['id'])) {
         $params['id'] = SPLang::nid($name);
     }
     if ($class) {
         $params['class'] = $class;
     }
     $user = null;
     $user = SPUser::getBaseData((int) $value);
     $userData = null;
     if ($user) {
         $replacements = array();
         preg_match_all('/\\%[a-z]*/', $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 ($placeholders as $attribute) {
                 if (isset($user->{$attribute})) {
                     $format = str_replace('%' . $attribute, $user->{$attribute}, $format);
                 }
             }
             $userData = $format;
         }
     }
     $params = self::params($params);
     $f = "\n";
     $f .= '<div class="spOutput">';
     $f .= "\n\t";
     $f .= '<span ' . $params . '>' . $userData . '</span>';
     $f .= "\n";
     $f .= '</div>';
     $f .= "\n";
     Sobi::Trigger('Field', ucfirst(__FUNCTION__), array(&$f));
     return "\n<!-- User Getter '{$name}' Output -->{$f}<!-- User Getter '{$name}' End -->\n\n";
 }
Exemplo n.º 20
0
 /**
  * Send the header via the mainframe interface
  */
 public function sendHeader()
 {
     if (count($this->_store)) {
         if (count($this->js)) {
             $jsCode = null;
             foreach ($this->js as $js) {
                 $jsCode .= "\n\t" . str_replace("\n", "\n\t", $js);
             }
             $this->js = array("\n<script type=\"text/javascript\">\n/*<![CDATA[*/{$jsCode}\n/*]]>*/\n</script>\n");
         }
         if (count($this->css)) {
             $cssCode = null;
             foreach ($this->css as $css) {
                 $cssCode .= "\n\t" . str_replace("\n", "\n\t", $css);
             }
             $this->css = array("<style type=\"text/css\">\n{$cssCode}\n</style>");
         }
         // Thu, May 8, 2014 13:10:19 - changed order of meta keys and meta description
         // See #1231
         $this->head['keywords'] = array_reverse($this->keywords);
         $this->head['author'] = $this->author;
         $this->head['robots'] = $this->robots;
         $this->head['description'] = array_reverse($this->description);
         $this->head['css'] = $this->_cssFiles();
         $this->head['js'] = $this->_jsFiles();
         $this->head['links'] = $this->links;
         $this->head['css'] = array_merge($this->head['css'], $this->css);
         $this->head['js'] = array_merge($this->head['js'], $this->js);
         $this->head['raw'] = $this->raw;
         Sobi::Trigger('Header', 'Send', array(&$this->head));
         SPFactory::mainframe()->addHead($this->head);
         if (count($this->title)) {
             SPFactory::mainframe()->setTitle($this->title);
         }
         SPFactory::cache()->storeView($this->_store);
         $this->reset();
     }
 }
Exemplo n.º 21
0
 /**
  */
 public function loadTable()
 {
     parent::loadTable();
     /* @var SPdb $db */
     $db =& SPFactory::db();
     $this->icon = SPLang::clean($this->icon);
     try {
         $db->select(array('position', 'pid'), 'spdb_relations', array('id' => $this->id));
         $r = $db->loadObject();
         Sobi::Trigger($this->name(), ucfirst(__FUNCTION__), array(&$r));
         $this->position = $r->position;
         $this->parent = $r->pid;
     } catch (SPException $x) {
         Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     if (SPRequest::task() != 'category.edit') {
         if ($this->parseDesc == SPC::GLOBAL_SETTING) {
             $this->parseDesc = Sobi::Cfg('category.parse_desc', true);
         }
         if ($this->parseDesc) {
             Sobi::Trigger('Parse', 'Content', array(&$this->description));
         }
     }
 }
Exemplo n.º 22
0
 /**
  * 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');
 }
Exemplo n.º 23
0
 /**
  *
  */
 public function displayForm()
 {
     Sobi::Trigger('Display', $this->name(), array(&$this));
     $action = $this->key('action');
     echo '<div class="SobiPro" id="SobiPro">' . "\n";
     if ($this->get('_compatibility')) {
         echo SPFactory::AdmToolbar()->render();
         echo $this->legacyMessages();
     }
     echo $action ? "\n<form action=\"{$action}\" method=\"post\" name=\"adminForm\" id=\"SPAdminForm\" enctype=\"multipart/form-data\" accept-charset=\"utf-8\" >\n" : null;
     foreach ($this->_templates as $tpl) {
         $template = SPLoader::path($tpl, 'adm.template');
         if (!$template) {
             $tpl = SPLoader::translatePath($tpl, 'adm.template', false);
             Sobi::Error($this->name(), SPLang::e('CANNOT_LOAD_TEMPLATE_AT', $tpl), SPC::ERROR, 500, __LINE__, __FILE__);
         } else {
             include $template;
         }
     }
     if (count($this->_hidden)) {
         $this->_hidden[SPFactory::mainframe()->token()] = 1;
         $prefix = null;
         if (!$this->get('_compatibility')) {
             $prefix = 'SP_';
         }
         foreach ($this->_hidden as $name => $value) {
             echo "\n<input type=\"hidden\" name=\"{$name}\" id=\"{$prefix}{$name}\" value=\"{$value}\"/>";
         }
     }
     echo $action ? "\n</form>\n" : null;
     echo '</div>';
     Sobi::Trigger('AfterDisplay', $this->name());
 }
Exemplo n.º 24
0
 /**
  * @param string $tooltip
  * @param string $title
  * @return string
  */
 public static function _($tooltip, $title, $img = null)
 {
     Sobi::Trigger('Tooltip', 'Show', array(&$tooltip, &$title));
     return self::toolTip($tooltip, $title, $img, null, $title);
 }
Exemplo n.º 25
0
 /**
  * Saves whole section in the db registry
  * @param array $values
  * @param string $section
  * @return void
  */
 public function saveDBSection($values, $section)
 {
     foreach ($values as $i => $value) {
         $value['section'] = $section;
         $value['params'] = isset($value['params']) ? $value['params'] : null;
         $value['description'] = isset($value['description']) ? $value['description'] : null;
         $value['options'] = isset($value['options']) ? $value['options'] : null;
         $values[$i] = $value;
     }
     Sobi::Trigger('Registry', 'SaveDb', array(&$values));
     try {
         SPFactory::db()->delete('spdb_registry', array('section' => $section));
         SPFactory::db()->insertArray('spdb_registry', $values);
     } catch (SPException $x) {
         Sobi::Error(__FUNCTION__, SPLang::e('Cannot save registry section. Db reports %s.', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
 }
Exemplo n.º 26
0
 protected function details()
 {
     $this->_type = 'entry_details';
     $type = $this->key('template_type', 'xslt');
     if ($type != 'php' && Sobi::Cfg('global.disable_xslt', false)) {
         $type = 'php';
     }
     if ($type == 'xslt') {
         $this->_attr = $this->entryData();
         SPFactory::header()->addCanonical($this->_attr['entry']['_data']['url']);
         Sobi::Trigger('EntryView', ucfirst(__FUNCTION__), array(&$this->_attr));
     }
 }
Exemplo n.º 27
0
 /**
  * @param string $task
  */
 public function setTask($task)
 {
     $this->_task = strlen($task) ? $task : $this->_defTask;
     $helpTask = $this->_type . '.' . $this->_task;
     Sobi::Trigger($this->name(), __FUNCTION__, array(&$this->_task));
     SPFactory::registry()->set('task', $helpTask);
 }
Exemplo n.º 28
0
 public function addCustom($section, $html, $before = false)
 {
     $i = $before ? 'before' : 'after';
     Sobi::Trigger('addCustom', 'SPAdmSiteMenu', array($html, $section));
     $this->_custom[$section][$i][] = $html;
 }
Exemplo n.º 29
0
 public function display()
 {
     $this->_type = 'search';
     $type = $this->key('template_type', 'xslt');
     if ($type != 'php' && Sobi::Cfg('global.disable_xslt', false)) {
         $type = 'php';
     }
     if ($type == 'xslt') {
         $searchData = array();
         $fields = $this->get('fields');
         $visitor = $this->get('visitor');
         $p = $this->get('priorities');
         $priorities = array();
         if (is_array($p) && count($p)) {
             foreach ($p as $priority => $eids) {
                 if (is_array($eids) && count($eids)) {
                     foreach ($eids as $sid) {
                         $priorities[$sid] = $priority;
                     }
                 }
             }
         }
         $entries = $this->get('entries');
         $searchData['section'] = array('_complex' => 1, '_data' => Sobi::Section(true), '_attributes' => array('id' => Sobi::Section(), 'lang' => Sobi::Lang(false)));
         $searchPhrase = $this->get('search_for');
         $phrase = $this->get('search_phrase');
         $searchPhrase = strlen($searchPhrase) ? $searchPhrase : Sobi::Txt('SH.SEARCH_FOR_BOX');
         SPFactory::header()->addJsCode('var spSearchDefStr = "' . Sobi::Txt('SH.SEARCH_FOR_BOX') . '"');
         if ($this->get('$eInLine')) {
             $searchData['entries_in_line'] = $this->get('$eInLine');
         }
         if ($this->get('$eCount') >= 0) {
             $searchData['message'] = Sobi::Txt('SH.SEARCH_FOUND_RESULTS', array('count' => $this->get('$eCount')));
         }
         $this->menu($searchData);
         $this->alphaMenu($searchData);
         $fData = array();
         if (Sobi::Cfg('search.show_searchbox', true)) {
             $fData['searchbox'] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => Sobi::Txt('SH.SEARCH_FOR'), '_attributes' => array('lang' => Sobi::Lang(false))), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::text('sp_search_for', $searchPhrase, array('class' => Sobi::Cfg('search.form_box_def_css', 'SPSearchBox'), 'id' => 'SPSearchBox')))), '_attributes' => array('position' => 1, 'css_class' => 'SPSearchBox'));
         }
         if (Sobi::Cfg('search.top_button', true)) {
             $fData['top_button'] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => Sobi::Txt('SH.SEARCH_START'), '_attributes' => array('lang' => Sobi::Lang())), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::submit('search', Sobi::Txt('SH.START'), array('id' => 'top_button')))), '_attributes' => array('position' => 1, 'css_class' => 'SPSearchButton'));
         }
         if (Sobi::Cfg('search.show_phrase', true)) {
             $fData['phrase'] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => Sobi::Txt('SH.FIND_ENTRIES_THAT_HAVE'), '_attributes' => array('lang' => Sobi::Lang(false))), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::radioList('spsearchphrase', array('all' => Sobi::Txt('SH.FIND_ENTRIES_THAT_HAVE_ALL_WORDS'), 'any' => Sobi::Txt('SH.FIND_ENTRIES_THAT_HAVE_ANY_WORDS'), 'exact' => Sobi::Txt('SH.FIND_ENTRIES_THAT_HAVE_EXACT_PHRASE')), 'spsearchphrase', strlen($phrase) ? $phrase : Sobi::Cfg('search.form_searchphrase_def', 'all'), null, 'right'))), '_attributes' => array('position' => 1, 'css_class' => 'SPSearchPhrase'));
         }
         if (count($fields)) {
             foreach ($fields as $field) {
                 $data = $field->searchForm();
                 $suffix = $field->get('searchMethod') != 'range' ? $field->get('suffix') : null;
                 if (strlen($data)) {
                     $fData[$field->get('nid')] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => $field->get('name'), '_attributes' => array('lang' => Sobi::Lang())), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => $data)), '_attributes' => array('id' => $field->get('id'), 'type' => $field->get('type'), 'suffix' => $suffix, 'position' => $field->get('position'), 'css_class' => strlen($field->get('cssClass')) ? $field->get('cssClass') : 'spField'));
                 }
             }
         }
         if (Sobi::Cfg('search.bottom_button', false)) {
             $fData['bottom_button'] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => Sobi::Txt('SH.SEARCH_START'), '_attributes' => array('lang' => Sobi::Lang(false))), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::submit('search', Sobi::Txt('SH.START')))), '_attributes' => array('position' => 1, 'css_class' => 'SPSearchButton'));
         }
         $searchData['fields'] = $fData;
         if (count($entries)) {
             $this->loadNonStaticData($entries);
             $manager = Sobi::Can('entry', 'edit', '*', Sobi::Section()) ? true : false;
             foreach ($entries as $entry) {
                 $en = $this->entry($entry, $manager);
                 $searchData['entries'][] = array('_complex' => 1, '_attributes' => array('id' => $en['id'], 'search-priority' => isset($priorities[$en['id']]) ? $priorities[$en['id']] : 'undefined'), '_data' => $en);
             }
             $this->navigation($searchData);
         }
         $searchData['visitor'] = $this->visitorArray($visitor);
         $this->_attr = $searchData;
     }
     Sobi::Trigger($this->_type, ucfirst(__FUNCTION__), array(&$this->_attr));
     parent::display($this->_type);
 }
Exemplo n.º 30
0
 /**
  * (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();
     if (!$this->nid || SPRequest::task() == 'entry.clone') {
         $this->nid = SPRequest::string($this->nameField, null, false, $request);
         $this->nid = $this->createAlias();
         $this->name = $this->nid;
     }
     if (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);
             } else {
                 $field->finaliseSave($this, $request);
             }
             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'));
             }
             if (isset($currPos[$cat])) {
                 $pos = $currPos[$cat]['position'];
             } else {
                 $pos = isset($cPos[$cat]) ? $cPos[$cat]['MAX(position)'] : 0;
                 $pos++;
             }
             $values[] = array('id' => $this->id, 'pid' => $cats[$i], 'oType' => 'entry', 'position' => $pos, 'validSince' => $this->validSince, 'validUntil' => $this->validUntil, 'copy' => $copy);
         }
         try {
             $db->insertArray('spdb_relations', $values, true);
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
         }
     } elseif (!count($this->categories)) {
         throw new SPException(SPLang::e('MISSING_CAT'));
     }
     /* trigger possible state changes */
     if ($preState['approved'] != $this->approved) {
         if ($this->approved) {
             $this->approveFields(true);
             // it's being done by the method above - removing
             //Sobi::Trigger( $this->name(), 'AfterApprove', array( $this->id, $this->approved ) );
         }
     }
     if ($preState['state'] != $this->state) {
         Sobi::Trigger($this->name(), 'AfterChangeState', array($this->id, $this->state));
     }
     SPFactory::cache()->purgeSectionVars();
     SPFactory::cache()->deleteObj('entry', $this->id);
     if (count($cats)) {
         foreach ($cats as $cat) {
             SPFactory::cache()->deleteObj('category', $cat);
         }
     }
     Sobi::Trigger($this->name(), 'After' . ucfirst($preState['new'] ? __FUNCTION__ : 'Update'), array(&$this));
 }