Example #1
0
 protected function save()
 {
     if (!SPFactory::mainframe()->checkToken()) {
         Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
     }
     $id = SPRequest::cmd('filter_id');
     if ($id) {
         $this->validate('field.filter', 'filter');
         $filters = $this->getFilters();
         $name = SPRequest::string('filter_name', 'Filter Name');
         $msg = str_replace(array("\n", "\t", "\r"), null, SPLang::clean(SPRequest::string('filter_message', 'The data entered in the $field field contains not allowed characters')));
         $regex = SPLang::clean(SPRequest::raw('filter_regex', '/^[\\.*]+$/'));
         $regex = str_replace('[:apostrophes:]', '\\"' . "\\'", $regex);
         $regex = base64_encode(str_replace(array("\n", "\t", "\r"), null, $regex));
         $custom = 'custom';
         if (isset($filters[$id]) && !strlen($filters[$id]['options'])) {
             $regex = $filters[$id]['params'];
             $custom = null;
         }
         $filters[$id] = array('params' => $regex, 'key' => $id, 'value' => $name, 'description' => $msg, 'options' => $custom);
         SPFactory::registry()->saveDBSection($filters, 'fields_filter');
         $this->response(Sobi::Url('filter'), Sobi::Txt('FLR.MSG_FILTER_SAVED'), false, 'success');
     } else {
         $this->response(Sobi::Url('filter'), SPLang::e('FILTER_NOT_FOUND'), true, SPC::ERROR_MSG);
     }
 }
Example #2
0
 /**
  */
 public function execute()
 {
     SPFactory::mainframe()->cleanBuffer()->customHeader();
     if (SPFs::exists($this->file)) {
         echo SPFs::read($this->file);
     } else {
         echo json_encode(array('progress' => 0, 'message' => '', 'interval' => 100, 'type' => ''));
     }
     exit;
 }
Example #3
0
 /**
  */
 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);
 }
Example #4
0
 protected function save()
 {
     if (!SPFactory::mainframe()->checkToken()) {
         Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
     }
     $data = SPRequest::string('bankdata', null, true);
     $data = array('key' => 'bankdata', 'value' => $data, 'type' => 'application', 'id' => Sobi::Section(), 'section' => Sobi::Section());
     try {
         SPLang::saveValues($data);
     } catch (SPException $x) {
         $message = SPLang::e('DB_REPORTS_ERR', $x->getMessage());
         Sobi::Error('SPPaymentBt', $message, SPC::WARNING, 0, __LINE__, __FILE__);
         $this->response(Sobi::Back(), $message, false, 'error');
     }
     $this->response(Sobi::Back(), Sobi::Txt('MSG.ALL_CHANGES_SAVED'), false, 'success');
 }
Example #5
0
 protected function js()
 {
     $lang = SPLang::jsLang(true);
     if (count($lang)) {
         foreach ($lang as $term => $text) {
             unset($lang[$term]);
             $term = str_replace('SP.JS_', null, $term);
             $lang[$term] = $text;
         }
     }
     if (!SPRequest::int('deb')) {
         SPFactory::mainframe()->cleanBuffer();
         header('Content-type: text/javascript');
     }
     echo 'SobiPro.setLang( ' . json_encode($lang) . ' );';
     exit;
 }
Example #6
0
 protected function save()
 {
     if (!SPFactory::mainframe()->checkToken()) {
         Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
     }
     $this->validate('extensions.paypal', array('task' => 'paypal', 'pid' => Sobi::Section()));
     SPFactory::registry()->saveDBSection(array(array('key' => 'ppurl', 'value' => SPRequest::string('ppurl')), array('key' => 'ppemail', 'value' => SPRequest::string('ppemail')), array('key' => 'ppcc', 'value' => SPRequest::string('ppcc')), array('key' => 'pprurl', 'value' => SPRequest::string('pprurl'))), 'paypal_' . Sobi::Section());
     $data = array('key' => 'ppexpl', 'value' => SPRequest::string('ppexpl', null, true), 'type' => 'application', 'id' => Sobi::Section(), 'section' => Sobi::Section());
     try {
         SPLang::saveValues($data);
         $data['key'] = 'ppsubject';
         $data['value'] = SPRequest::string('ppsubject', true);
         SPLang::saveValues($data);
     } catch (SPException $x) {
         $message = SPLang::e('DB_REPORTS_ERR', $x->getMessage());
         Sobi::Error('SPPaymentBt', $message, SPC::WARNING, 0, __LINE__, __FILE__);
         $this->response(Sobi::Back(), $message, false, 'error');
     }
     $this->response(Sobi::Back(), Sobi::Txt('MSG.ALL_CHANGES_SAVED'), false, 'success');
 }
Example #7
0
 private function download()
 {
     $Error = new DOMDocument('1.0', 'utf-8');
     $Error->formatOutput = true;
     $Root = $Error->createElement('errorLog');
     $Date = $Error->createAttribute('createdAt');
     $Date->appendChild($Error->createTextNode(date(DATE_RFC822)));
     $Root->appendChild($Date);
     $Site = $Error->createAttribute('site');
     $Site->appendChild($Error->createTextNode(Sobi::Cfg('live_site')));
     $Root->appendChild($Site);
     $Error->appendChild($Root);
     $levels = $this->levels();
     try {
         $errors = SPFactory::db()->select('*', 'spdb_errors', null, 'eid.desc')->loadAssocList();
     } catch (SPException $x) {
     }
     $c = 0;
     if (count($errors)) {
         foreach ($errors as $i => $err) {
             $c++;
             if ($c > Sobi::Cfg('err_log.limit', 50)) {
                 break;
             }
             $err['errNum'] = $levels[$err['errNum']];
             $Err = $Error->createElement('error');
             $Date = $Error->createAttribute('date');
             $Date->appendChild($Error->createTextNode($err['date']));
             $Err->appendChild($Date);
             $Level = $Error->createAttribute('level');
             $Level->appendChild($Error->createTextNode($err['errNum']));
             $Err->appendChild($Level);
             $Code = $Error->createAttribute('returnCode');
             $Code->appendChild($Error->createTextNode($err['errCode']));
             $Err->appendChild($Code);
             $Section = $Error->createAttribute('section');
             $Section->appendChild($Error->createTextNode($err['errSect']));
             $Err->appendChild($Section);
             $err['errBacktrace'] = unserialize(gzuncompress(base64_decode($err['errBacktrace'])));
             $err['errBacktrace'] = str_replace(SOBI_ROOT, null, $err['errBacktrace']);
             $err['errMsg'] = str_replace(SOBI_ROOT, null, $err['errMsg']);
             $err['errCont'] = unserialize(gzuncompress(base64_decode($err['errCont'])));
             $err['errCont'] = str_replace(SOBI_ROOT, null, $err['errCont']);
             $ErrMsg = $Error->createElement('message', $err['errMsg']);
             $Err->appendChild($ErrMsg);
             $ErrMsg = $Error->createElement('file', $err['errFile'] . ':' . $err['errLine']);
             $Err->appendChild($ErrMsg);
             $ErrUser = $Error->createElement('user');
             $Uid = $Error->createAttribute('uid');
             $Uid->appendChild($Error->createTextNode($err['errUid']));
             $ErrUser->appendChild($Uid);
             $UsrIp = $Error->createElement('ip', $err['errIp']);
             $ErrUser->appendChild($UsrIp);
             $UsrA = $Error->createElement('userAgent', $err['errUa']);
             $ErrUser->appendChild($UsrA);
             $UsrReq = $Error->createElement('requestedUri', htmlentities($err['errReq']));
             $ErrUser->appendChild($UsrReq);
             $UsrRef = $Error->createElement('referrerUri', str_replace(Sobi::Cfg('live_site'), null, htmlentities($err['errRef'])));
             $ErrUser->appendChild($UsrRef);
             $Err->appendChild($ErrUser);
             $ErrStack = $Error->createElement('callStack');
             $ErrStack->appendChild($Error->createCDATASection("\n" . stripslashes(var_export($err['errCont'], true)) . "\n"));
             $Err->appendChild($ErrStack);
             $ErrTrace = $Error->createElement('callTrace');
             $ErrTrace->appendChild($Error->createCDATASection("\n" . stripslashes(var_export($err['errBacktrace'], true)) . "\n"));
             $Err->appendChild($ErrTrace);
             $Root->appendChild($Err);
         }
     }
     $file = SPLoader::path('var.log.errors', 'front', false, 'xml');
     SPFs::write($file, $Error->saveXML());
     $fp = SPFs::read($file);
     SPFactory::mainframe()->cleanBuffer();
     header("Content-type: application/xml");
     header('Content-Disposition: attachment; filename=error.xml');
     echo $fp;
     flush();
     exit;
 }
Example #8
0
 public static function userSelector($name, $value, $groups = null, $params = null, $icon = 'user', $header = 'USER_SELECT_HEADER', $format = '%user', $orderBy = 'id')
 {
     static $count = 0;
     static $session = null;
     if (!$session) {
         $session = SPFactory::user()->getUserState('userSelector', null, array());
     }
     $params = self::checkArray($params);
     if (!isset($params['id'])) {
         $params['id'] = SPLang::nid($name);
     }
     $user = null;
     SPFactory::header()->addJsFile('user_selector');
     $user = SPUser::getBaseData((int) $value);
     $settings = array('groups' => $groups, 'format' => $format, 'user' => Sobi::My('id'), 'ordering' => $orderBy, 'time' => microtime(true));
     if (count($session)) {
         foreach ($session as $id => $data) {
             if (microtime(true) - $data['time'] > 3600) {
                 unset($session[$id]);
             }
         }
     }
     $ssid = md5(microtime() . Sobi::My('id') . ++$count);
     $session[$ssid] =& $settings;
     SPFactory::user()->setUserState('userSelector', $session);
     $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;
         }
     }
     $modal = '<div class="response btn-group" data-toggle="buttons-radio"></div><br/><button class="btn btn-block hide more" type="button">' . Sobi::Txt('LOAD_MORE') . '</button>';
     $filter = '<input type="text" placeholder="' . Sobi::Txt('FILTER') . '" class="search pull-right spDisableEnter" name="q">';
     $id = $params['id'];
     $params = self::params($params);
     $f = "\n";
     $f .= '<div class="spUserSelector">';
     $f .= '<div class="input-append">';
     $f .= "\n\t";
     $f .= '<input type="text" value="' . $userData . '" ' . $params . ' name="' . $name . 'Holder" readonly="readonly" class="trigger user-name"/>';
     $f .= '<span class="add-on trigger"><i class="icon-' . $icon . '"></i></span>';
     $f .= '</div>';
     $f .= '<input type="hidden" value="' . $value . '" name="' . $name . '" rel="selected"/>';
     $f .= '<input type="hidden" value="' . $ssid . '" name="' . $name . 'Ssid"/>';
     $f .= '<input type="hidden" value="1" name="' . SPFactory::mainframe()->token() . '"/>';
     $f .= "\n\t";
     $f .= "\n";
     $f .= self::modalWindow(Sobi::Txt($header) . $filter, $id . '-window', $modal);
     $f .= '</div>';
     $f .= "\n";
     Sobi::Trigger('Field', ucfirst(__FUNCTION__), array(&$f));
     return "\n<!-- User Picker '{$name}' Output -->{$f}<!-- User Picker '{$name}' End -->\n\n";
 }
 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;
 }
Example #10
0
 protected function ajaxResponse($ajax, $message, $redirect, $type, $callback = 'SPExtensionInstaller')
 {
     if ($ajax) {
         if ($redirect) {
             SPFactory::message()->setMessage($message, false, $type);
         }
         $response = array('type' => $type, 'text' => $message, 'redirect' => $redirect ? Sobi::Url('extensions.installed') : false, 'callback' => $type == SPC::SUCCESS_MSG ? $callback : false);
         SPFactory::mainframe()->cleanBuffer()->customHeader();
         echo json_encode($response);
         exit;
     } elseif ($redirect) {
         SPFactory::message()->setMessage($message, false, $type);
         Sobi::Redirect(Sobi::Url('extensions.installed'));
     } else {
         return array('msg' => $message, 'msgtype' => $type);
     }
 }
Example #11
0
 /**
  * */
 public function ProxyDependency()
 {
     $path = json_decode(Sobi::Clean(SPRequest::string('path')), true);
     $values = $this->loadDependencyDefinition($path);
     SPFactory::mainframe()->cleanBuffer()->customHeader();
     exit(json_encode(array('options' => $values, 'path' => json_encode($path))));
 }
Example #12
0
 /**
  * Executes the controller task
  * @return void
  */
 public function execute()
 {
     try {
         if (is_array($this->_ctrl)) {
             foreach ($this->_ctrl as &$c) {
                 $c->execute();
             }
         } else {
             if ($this->_ctrl instanceof SPControl) {
                 $this->_ctrl->execute();
             } else {
                 Sobi::Error('CoreCtrl', SPLang::e('No controller to execute'), SPC::ERROR, 500, __LINE__, __FILE__);
             }
         }
     } catch (SPException $x) {
         Sobi::Error('CoreCtrl', SPLang::e('No controller to execute %s', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
         //			Sobi::Error( 'CoreCtrl', SPLang::e( 'No controller to execute. %s', $x->getMessage() ), SPC::WARNING, 0, __LINE__, __FILE__ );
         //			Sobi::Redirect( Sobi::GetUserState( 'back_url', Sobi::Url() ), $x->getMessage(), SPC::ERROR_MSG );
     }
     /* send header data etc ...*/
     SPFactory::header()->send();
     SPFactory::mainframe()->endOut();
     /* redirect if any redirect has been set */
     SPFactory::mainframe()->redirect();
     error_reporting($this->_deb);
     restore_error_handler();
 }
Example #13
0
 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();
 }
Example #14
0
 /**
  * @deprecated since 1.1 replaced by {@link #Initialise()}
  * @param int $sid - section id
  * @param null $root - root of Joomla!
  * @param null $lang - language
  * @return null
  */
 public static function Init($root = null, $lang = null, $sid = 0)
 {
     static $loaded = false;
     if (!$loaded) {
         if (!defined('SOBI_CMS')) {
             define('SOBI_CMS', version_compare(JVERSION, '3.0.0', 'ge') ? 'joomla3' : (version_compare(JVERSION, '1.6.0', 'ge') ? 'joomla16' : 'joomla15'));
         }
         defined('SOBIPRO') || define('SOBIPRO', true);
         defined('SOBI_TASK') || define('SOBI_TASK', 'task');
         defined('SOBI_DEFLANG') || define('SOBI_DEFLANG', $lang);
         defined('SOBI_ACL') || define('SOBI_ACL', 'front');
         defined('SOBI_ROOT') || define('SOBI_ROOT', $root);
         defined('SOBI_MEDIA') || define('SOBI_MEDIA', implode('/', array($root, 'media', 'sobipro')));
         defined('SOBI_PATH') || define('SOBI_PATH', SOBI_ROOT . '/components/com_sobipro');
         defined('SOBI_LIVE_PATH') || define('SOBI_LIVE_PATH', 'components/com_sobipro');
         require_once SOBI_PATH . '/lib/base/fs/loader.php';
         SPLoader::loadController('sobipro');
         SPLoader::loadController('interface');
         SPLoader::loadClass('base.exception');
         SPLoader::loadClass('base.const');
         SPLoader::loadClass('base.object');
         SPLoader::loadClass('base.filter');
         SPLoader::loadClass('base.request');
         SPLoader::loadClass('cms.base.lang');
         SPLoader::loadClass('models.dbobject');
         SPLoader::loadClass('base.factory');
         SPLoader::loadClass('base.config');
         SPLoader::loadClass('cms.base.fs');
         // in case it is a CLI call
         if (isset($_SERVER['REQUEST_URI'])) {
             SPFactory::config()->set('live_site', JURI::root());
         }
         $loaded = true;
     }
     if ($sid) {
         $section = null;
         if ($sid) {
             $path = array();
             $id = $sid;
             $path[] = (int) $id;
             while ($id > 0) {
                 try {
                     $id = SPFactory::db()->select('pid', 'spdb_relations', array('id' => $id))->loadResult();
                     if ($id) {
                         $path[] = (int) $id;
                     }
                 } catch (SPException $x) {
                     Sobi::Error('ExtCoreCtrl', SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
                 }
             }
             $path = array_reverse($path);
             $section = SPFactory::object($path[0]);
         }
         /* set current section in the registry */
         SPFactory::registry()->set('current_section', $section->id);
         $_config =& SPFactory::config();
         /* load basic configuration settings */
         $_config->addIniFile('etc.config', true);
         $_config->addTable('spdb_config', $sid);
         /* initialise interface config setting */
         SPFactory::mainframe()->getBasicCfg();
         /* initialise config */
         $_config->init();
     }
 }
Example #15
0
 protected function view()
 {
     /* determine template package */
     $tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE);
     Sobi::ReturnPoint();
     $this->_task = 'user';
     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));
     $url = array('sid' => SPRequest::sid(), 'task' => 'list.user');
     if (SPRequest::int('uid')) {
         $url['uid'] = SPRequest::int('uid');
         $this->uid = (int) SPRequest::int('uid');
     } else {
         $this->uid = (int) Sobi::My('id');
     }
     $this->user = SPJoomlaUser::getBaseData((int) $this->uid);
     if (!$this->user) {
         throw new SPException(SPLang::e('UNAUTHORIZED_ACCESS'));
     }
     /* get the site to display */
     $site = SPRequest::int('site', 1);
     $eLimStart = ($site - 1) * $eLimit;
     $eOrder = $this->parseOrdering('entries', 'eorder', $this->tKey($this->template, 'entries_ordering', Sobi::Cfg('list.entries_ordering', 'name.asc')));
     $eCount = count($this->getEntries($eOrder, 0, 0, true, array('spo.owner' => $this->uid), true, Sobi::Section()));
     $entries = $this->getEntries($eOrder, $eLimit, $eLimStart, true, array('spo.owner' => $this->uid), true, Sobi::Section());
     //		$eCount = count( $this->_getEntries( 0, 0, true ) );
     //		$entries = $this->_getEntries( $eLimit, $site );
     $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);
     SPFactory::mainframe()->addToPathway(Sobi::Txt('UL.PATH_TITLE', array('username' => $this->user->username, 'user' => $this->user->name)), Sobi::Url('current'));
     SPFactory::header()->addTitle(Sobi::Txt('UL.TITLE', array('username' => $this->user->username, 'user' => $this->user->name, 'section' => $this->_model->get('name'))), array(ceil($eCount / $eLimit), $site));
     /* add pathway */
     /* 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();
 }
Example #16
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();
     }
 }
Example #17
0
 /**
  * @deprecated
  */
 public static function endOut()
 {
     return SPFactory::mainframe()->endOut();
 }
Example #18
0
 protected function templatePath($tpl)
 {
     $file = explode('.', $tpl);
     if (strstr($file[0], 'cms:')) {
         $file[0] = str_replace('cms:', null, $file[0]);
         $file = SPFactory::mainframe()->path(implode('.', $file));
         $template = SPLoader::path($file, 'root', false, null);
     } else {
         $template = SOBI_PATH . '/usr/templates/' . str_replace('.', '/', $tpl);
     }
     return $template;
 }
Example #19
0
 /**
  * Delete cookie
  * @param $name - The name of the cookie.
  * @return bool
  */
 public static function delete($name)
 {
     $name = self::prefix . $name;
     return SPFactory::mainframe()->setCookie($name, '', time() - 36000);
 }
Example #20
0
 /**
  * @param string $action
  * @param string $subject
  * @param mixed $params
  * @return bool
  */
 public function trigger($action, $subject = null, $params = array())
 {
     static $actions = array();
     static $count = 0;
     $action = ucfirst($action) . ucfirst($subject);
     $action = str_replace('SP', null, $action);
     $task = Sobi::Reg('task', SPRequest::task());
     $task = strlen($task) ? $task : '*';
     if (strstr($task, '.')) {
         $t = explode('.', $task);
         $task = $t[0] . '.' . $t[1];
     }
     /**
      * Joomla! -> Unable to load renderer class
      */
     if ($action == 'ParseContent' && SPRequest::cmd('format') == 'raw') {
         return;
     }
     $actions[$count++] = $action;
     // this always
     SPFactory::mainframe()->trigger($action, $params);
     //	    SPConfig::debOut( $action, false, false, true );
     /**
      * An Application should not trigger other applications
      * Apps are running non parallel
      * Exception, if an app will an action to be
      * triggered this action has to begin with App
      */
     /*
      * it's important to write comments in own code ..
      * It may be also helpful to read own comments sometimes
      * How the hell "has to begin with App" == substr( $action, 0, 3 ) != 'App' ) ???
      * ========================================================================================
      * Note for intelligent people: it caused for example that the payment method wasn't delivered to the notification App
      */
     if ($count < 2 || substr($action, 0, 3) == 'App') {
         /* load all plugins having method for this action */
         if (!isset($this->_actions[$task])) {
             $this->load($task);
         }
         /* if there were any plugin for this action, check if these are loaded */
         if (count($this->_actions[$task])) {
             foreach ($this->_actions[$task] as $plugin) {
                 /* in case this plugin wasn't initialised */
                 if (!isset($this->_plugins[$plugin])) {
                     $this->initPlugin($plugin);
                 }
                 /* call the method */
                 if (isset($this->_plugins[$plugin]) && $this->_plugins[$plugin]->provide($action)) {
                     call_user_func_array(array($this->_plugins[$plugin], $action), $params);
                 }
             }
         }
     }
     //	    SPConfig::debOut( $action, true, false, true );
     unset($actions[$count]);
     $count--;
     return true;
 }
Example #21
0
 private function dir($file)
 {
     $file = explode('.', $file);
     if (strstr($file[0], 'cms:')) {
         $file[0] = str_replace('cms:', null, $file[0]);
         $file = SPFactory::mainframe()->path(implode('.', $file));
         $file = SPLoader::dirPath($file, 'root', true);
     } else {
         $file = SPLoader::dirPath('usr.templates.' . implode('.', $file), 'front', true);
     }
     if (!$file) {
         $file = SPLoader::path('usr.templates.' . implode('.', $file), 'front', false);
         Sobi::Error($this->name(), SPLang::e('FILE_NOT_FOUND', $file), SPC::WARNING, 404, __LINE__, __FILE__);
     }
     return $file;
 }
Example #22
0
 /**
  * Save a rule
  *
  * @param bool $apply
  */
 protected function save($apply)
 {
     Sobi::Trigger('Save', 'Acl', array(&$this));
     if (!SPFactory::mainframe()->checkToken()) {
         Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
     }
     $rid = SPRequest::int('rid', 'null');
     $this->validate('acl.edit', array('task' => 'acl.edit', 'rid' => $rid));
     if ($rid) {
         $this->remove($rid);
     }
     $vs = SPRequest::timestamp('set_validSince');
     $vu = SPRequest::timestamp('set_validUntil');
     $vs = $vs ? date(Sobi::Cfg('db.date_format', 'Y-m-d H:i:s'), $vs) : null;
     $vu = $vu ? date(Sobi::Cfg('db.date_format', 'Y-m-d H:i:s'), $vu) : null;
     $name = SPRequest::string('set_name');
     $nid = SPRequest::cmd('set_nid');
     $note = SPRequest::string('set_note');
     $state = SPRequest::int('set_state', 1);
     $gids = SPRequest::arr('set_groups');
     $sids = SPRequest::arr('set_sections');
     $pf = SPRequest::arr('set_permissions', array());
     $pa = SPRequest::arr('set_adm_permissions', array());
     // if can publish any, then can see any unpublished
     if (in_array(20, $pf)) {
         $pf[] = 14;
     }
     // if can publish own, then can see own unpublished
     if (in_array(21, $pf)) {
         $pf[] = 12;
     }
     if (in_array(19, $pf)) {
         $pf[] = 15;
     }
     $perms = array_merge($pf, $pa);
     /* @var SPdb $db */
     $db = SPFactory::db();
     /* update or insert the rule definition */
     try {
         $db->insertUpdate('spdb_permissions_rules', array('rid' => $rid, 'name' => $name, 'nid' => $nid, 'validSince' => $vs, 'validUntil' => $vu, 'note' => $note, 'state' => $state));
     } catch (SPException $x) {
         Sobi::Error('ACL', SPLang::e('CANNOT_CREATE_RULE_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     $rid = (int) $rid ? (int) $rid : $db->insertid();
     /* insert the groups ids */
     if (count($gids)) {
         foreach ($gids as $i => $gid) {
             $gids[$i] = array('rid' => $rid, 'gid' => $gid);
         }
         try {
             $db->insertArray('spdb_permissions_groups', $gids);
         } catch (SPException $x) {
             Sobi::Error('ACL', SPLang::e('CANNOT_INSERT_GROUPS_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
     }
     try {
         $db->select('*', 'spdb_permissions', array('site' => 'adm', 'value' => 'global'));
         $admPermissions = $db->loadResultArray();
     } catch (SPException $x) {
         Sobi::Error('ACL', SPLang::e('CANNOT_GET_PERMISSIONS_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     /* create permission and section map */
     if (count($sids) && count($perms)) {
         $map = array();
         /* travel the sections */
         foreach ($sids as $sid) {
             foreach ($perms as $pid) {
                 if (in_array($pid, $admPermissions)) {
                     $map[] = array('rid' => $rid, 'sid' => 0, 'pid' => $pid);
                 } else {
                     $map[] = array('rid' => $rid, 'sid' => $sid, 'pid' => $pid);
                 }
             }
         }
         try {
             $db->insertArray('spdb_permissions_map', $map, true);
         } catch (SPException $x) {
             Sobi::Error('ACL', SPLang::e('CANNOT_INSERT_GROUPS_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
     }
     SPFactory::cache()->cleanAll();
     /* trigger plugins */
     Sobi::Trigger('AfterSave', 'Acl', array(&$this));
     /* set redirect */
     $this->response(Sobi::Url($apply ? array('task' => 'acl.edit', 'rid' => $rid) : 'acl'), Sobi::Txt('ACL_RULE_SAVED'), !$apply, SPC::SUCCESS_MSG, array('sets' => array('rid' => $rid)));
 }
Example #23
0
 protected function customOutput($output)
 {
     $header = $this->key('output.header', false);
     if ($this->key('output.clear', false)) {
         SPFactory::mainframe()->cleanBuffer();
     }
     if (strlen($header)) {
         header($header);
     }
     if (SPRequest::int('crawl')) {
         header('SobiPro: ' . Sobi::Section());
     }
     echo $output;
     if ($this->key('output.close', false)) {
         exit;
     }
 }
Example #24
0
 protected function save($apply, $clone = false)
 {
     if (!SPFactory::mainframe()->checkToken()) {
         Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
     }
     $sets = array();
     if (!$clone) {
         $sid = SPRequest::sid() ? SPRequest::sid() : SPRequest::int('entry_id');
     } else {
         $sid = 0;
     }
     $apply = (int) $apply;
     if (!$this->_model) {
         $this->setModel(SPLoader::loadModel($this->_type));
     }
     $this->_model->init($sid);
     $tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE);
     $this->tplCfg($tplPackage);
     $customClass = null;
     if (isset($this->_tCfg['general']['functions']) && $this->_tCfg['general']['functions']) {
         $customClass = SPLoader::loadClass('/' . str_replace('.php', null, $this->_tCfg['general']['functions']), false, 'templates');
         if (method_exists($customClass, 'BeforeStoreEntry')) {
             $customClass::BeforeStoreEntry($this->_model, $_POST);
         }
     }
     $preState = array('approved' => $this->_model->get('approved'), 'state' => $this->_model->get('state'), 'new' => !$this->_model->get('id'));
     SPFactory::registry()->set('object_previous_state', $preState);
     $this->_model->getRequest($this->_type);
     $this->authorise($this->_model->get('id') ? 'edit' : 'add');
     try {
         $this->_model->validate('post');
     } catch (SPException $x) {
         $back = Sobi::GetUserState('back_url', Sobi::Url(array('task' => 'entry.add', 'sid' => Sobi::Section())));
         $data = $x->getData();
         $this->response($back, $x->getMessage(), false, 'error', array('required' => $data['field']));
     }
     try {
         $this->_model->save();
     } catch (SPException $x) {
         $back = Sobi::GetUserState('back_url', Sobi::Url(array('task' => 'entry.add', 'sid' => Sobi::Section())));
         $this->response($back, $x->getMessage(), false, 'error');
     }
     $sid = $this->_model->get('id');
     $sets['sid'] = $sid;
     $sets['entry.nid'] = $this->_model->get('nid');
     $sets['entry.id'] = $sid;
     if ($customClass && method_exists($customClass, 'AfterStoreEntry')) {
         $customClass::AfterStoreEntry($this->_model);
     }
     if (SPRequest::string('history-note') || $this->_task == 'saveWithRevision' || Sobi::Cfg('entry.versioningAdminBehaviour', 1)) {
         $this->logChanges('save', SPRequest::string('history-note'));
     }
     if ($apply || $clone) {
         if ($clone) {
             $msg = Sobi::Txt('MSG.OBJ_CLONED', array('type' => Sobi::Txt($this->_model->get('oType'))));
             $this->response(Sobi::Url(array('task' => $this->_type . '.edit', 'sid' => $sid)), $msg);
         } else {
             $msg = Sobi::Txt('MSG.OBJ_SAVED', array('type' => Sobi::Txt($this->_model->get('oType'))));
             $this->response(Sobi::Url(array('task' => $this->_type . '.edit', 'sid' => $sid)), $msg, false, 'success', array('sets' => $sets));
         }
     } elseif ($this->_task == 'saveAndNew') {
         $msg = Sobi::Txt('MSG.ALL_CHANGES_SAVED');
         $sid = $this->_model->get('parent');
         if (!$sid) {
             $sid = Sobi::Section();
         }
         $this->response(Sobi::Url(array('task' => $this->_type . '.add', 'sid' => $sid)), $msg, true, 'success', array('sets' => $sets));
     } else {
         $this->response(Sobi::Back(), Sobi::Txt('MSG.OBJ_SAVED', array('type' => Sobi::Txt($this->_model->get('oType')))));
     }
 }
Example #25
0
 protected function message($response)
 {
     SPFactory::mainframe()->cleanBuffer()->customHeader();
     echo json_encode($response);
     exit;
 }
Example #26
0
 protected function response($status)
 {
     SPFactory::mainframe()->cleanBuffer()->customHeader();
     echo json_encode($status);
     exit;
 }
Example #27
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());
 }
Example #28
0
 public static function fields($sid = 0, $types = null)
 {
     if (!$sid) {
         $sid = SPRequest::sid('request', Sobi::Section(), false);
     }
     if (!$types) {
         $types = SPRequest::string('types', null);
         $types = SPFactory::config()->structuralData($types, true);
     }
     $fields = SPConfig::fields($sid, $types);
     if (SPRequest::bool('fields-xhr')) {
         SPFactory::mainframe()->cleanBuffer()->customHeader();
         exit(json_encode($fields));
     } else {
         return $fields;
     }
 }
Example #29
0
 /**
  * Creates the approved/unapproved symbol
  *
  * @param SPDataModel $row
  * @return string
  */
 public static function approval($row)
 {
     /* check state */
     $state = $row->get('approved') ? 1 : 0;
     SPLoader::loadClass('html.tooltip');
     /* get icons */
     $up = Sobi::Cfg('list_icons.unapproved');
     $pu = Sobi::Cfg('list_icons.approved');
     $img = $state == 1 ? $pu : $up;
     $action = $state ? $row->get('oType') . '.unapprove' : $row->get('oType') . '.approve';
     /* translate alternative text */
     $s = Sobi::Txt($row->get('oType') . '.approval_head');
     $a = Sobi::Txt('approval_' . ($state ? 'on' : 'off'));
     $img = SPTooltip::toolTip($a, $s, $img);
     /* if user has permission for this action */
     if (SPFactory::user()->can($action)) {
         $url = SPFactory::mainframe()->url(array('task' => $action, 'sid' => $row->get('id')));
         $img = "<a href=\"{$url}\">{$img}</a>";
     }
     return $img;
 }
Example #30
0
 /**
  * Parse text and replaces placeholders
  * @param string $text
  * @param SPDBObject $obj
  * @param bool $html
  * @param bool $dropEmpty
  * @return string
  */
 public static function replacePlaceHolders($text, $obj = null, $html = false, $dropEmpty = false)
 {
     preg_match_all('/{([a-zA-Z0-9\\-_\\:\\.\\%\\s]+)}/', $text, $placeHolders);
     if (count($placeHolders[1])) {
         foreach ($placeHolders[1] as $placeHolder) {
             $replacement = null;
             switch ($placeHolder) {
                 case 'section':
                 case 'section.id':
                 case 'section.name':
                     $replacement = Sobi::Section($placeHolder == 'section' || $placeHolder == 'section.name');
                     break;
                     /*
                      * eat own dog food is so true. Isn't it?!
                      */
                 /*
                  * eat own dog food is so true. Isn't it?!
                  */
                 case 'token':
                     $replacement = SPFactory::mainframe()->token();
                     break;
                 default:
                     if (strstr($placeHolder, 'date%')) {
                         $date = explode('%', $placeHolder);
                         $replacement = date($date[1]);
                         break;
                     }
                     if (strstr($placeHolder, 'cfg:')) {
                         $replacement = Sobi::Cfg(str_replace('cfg:', null, $placeHolder));
                         break;
                     } else {
                         if (strstr($placeHolder, 'messages')) {
                             $obj = SPFactory::registry()->get('messages');
                         }
                         $replacement = self::parseVal($placeHolder, $obj, $html);
                     }
             }
             if ($replacement && (is_string($replacement) || is_numeric($replacement))) {
                 $text = str_replace('{' . $placeHolder . '}', (string) $replacement, $text);
             } elseif ($dropEmpty) {
                 $text = str_replace('{' . $placeHolder . '}', null, $text);
             }
         }
     }
     return $text;
 }