public function getSourceEntries($params) { $entries = $this->entries($params); $entries = $this->entries($params); $view = new SPEntriesDJMTView(); $view->assign($this->_model, 'section'); $view->assign(SPFactory::user()->getCurrent(), 'visitor'); $view->assign($entries, 'entries'); $view->assign($params, 'params'); return $view->getEntires(); }
protected function search() { if (!SPFactory::mainframe()->checkToken()) { Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__); } // $selected = SPRequest::int( 'selected', 0 ); $ssid = SPRequest::base64('ssid'); $query = SPRequest::string('q', null); $session = SPFactory::user()->getUserState('userSelector', null, array()); $setting = $session[$ssid]; /* get the site to display */ $site = SPRequest::int('site', 1); $eLim = Sobi::Cfg('user_selector.entries_limit', 18); $eLimStart = ($site - 1) * $eLim; $params = array(); if ($query) { $q = '%' . $query . '%'; $params = SPFactory::db()->where(array('name' => $q, 'username' => $q, 'email' => $q), 'OR'); } try { $count = SPFactory::db()->select('COUNT(*)', '#__users', $params, $setting['ordering'])->loadResult(); $data = SPFactory::db()->select(array('id', 'name', 'username', 'email', 'registerDate', 'lastvisitDate'), '#__users', $params, $setting['ordering'], $eLim, $eLimStart)->loadAssocList(); } catch (SPException $x) { echo $x->getMessage(); exit; } $response = array('sites' => ceil($count / $eLim), 'site' => $site); if (count($data)) { $replacements = array(); preg_match_all('/\\%[a-z]*/', $setting['format'], $replacements); $placeholders = array(); if (isset($replacements[0]) && count($replacements[0])) { foreach ($replacements[0] as $placeholder) { $placeholders[] = str_replace('%', null, $placeholder); } } if (count($replacements)) { foreach ($data as $index => $user) { $txt = $setting['format']; foreach ($placeholders as $attribute) { if (isset($user[$attribute])) { $txt = str_replace('%' . $attribute, $user[$attribute], $txt); } } $data[$index]['text'] = $txt; } } $response['users'] = $data; } SPFactory::mainframe()->cleanBuffer(); echo json_encode($response); exit; }
/** */ 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); }
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"; }
/** */ protected function parseOrdering() { $order = Sobi::GetUserState('sections.order', 'order', 'name.asc'); $ord = $order; $dir = 'asc'; if (strstr($order, '.')) { $ord = explode('.', $ord); $dir = $ord[1]; $ord = $ord[0]; } if ($ord == 'position') { $ord = 'name'; } if ($ord == 'name') { /* @var SPdb $db */ $db =& SPFactory::db(); try { $db->select('id', 'spdb_language', array('oType' => 'section', 'sKey' => 'name', 'language' => Sobi::Lang()), 'sValue.' . $dir); $fields = $db->loadResultArray(); if (!count($fields) && Sobi::Lang() != Sobi::DefLang()) { $db->select('id', 'spdb_language', array('oType' => 'section', 'sKey' => 'name', 'language' => Sobi::DefLang()), 'sValue.' . $dir); $fields = $db->loadResultArray(); } } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 500, __LINE__, __FILE__); return false; } if (count($fields)) { $fields = implode(',', $fields); $ord = "field( id, {$fields} )"; } else { $ord = 'id.' . $dir; } } else { $ord = isset($dir) && strlen($dir) ? $ord . '.' . $dir : $ord; } SPFactory::user()->setUserState('sections.order', $ord); return $ord; }
private function section($section, $tab) { $v = null; if (isset($this->_custom[$tab]['before']) && is_array($this->_custom[$tab]['before'])) { foreach ($this->_custom[$tab]['before'] as $html) { $v .= "\n\t\t\t{$html}"; } } if (count($section)) { $v .= "\n\t\t\t<ul>"; foreach ($section as $pos => $label) { if (!SPFactory::user()->can($pos)) { continue; } if (strlen($label) < 3) { $label = str_replace('.', '_', $pos); } $label = Sobi::Txt($label); if ($this->_sid) { $url = Sobi::Url(array('task' => $pos, 'pid' => $this->_sid)); } else { $url = Sobi::Url(array('task' => $pos)); } if (SPRequest::task() == $pos || $this->_task == $pos) { $v .= "\n\t\t\t\t<li><a href=\"{$url}\" class=\"SPMenuActive\">{$label}</a></li>"; } else { $v .= "\n\t\t\t\t<li><a href=\"{$url}\">{$label}</a></li>"; } } $v .= "\n\t\t\t</ul>"; } if (isset($this->_custom[$tab]['after']) && is_array($this->_custom[$tab]['after'])) { foreach ($this->_custom[$tab]['after'] as $html) { $v .= "\n\t\t\t{$html}"; } } return $v; }
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(); }
/** * Check access permissions * @return bool */ private function checkAccess() { $this->_user =& SPFactory::user(); /* authorise access permissions */ if (!$this->_user->can('panel')) { Sobi::Error('CoreCtrl', 'UNAUTHORIZED_ACCESS', SPC::ERROR, 403, __LINE__, __FILE__); exit; } /* authorise task permissions */ if (SPRequest::task()) { if (!$this->_user->can(SPRequest::task())) { Sobi::Error('CoreCtrl', 'UNAUTHORIZED_ACCESS', SPC::ERROR, 403, __LINE__, __FILE__); // Sobi::Error( 'CoreCtrl', SPLang::e( 'UNAUTHORIZED_ACCESS_TASK', SPRequest::task() ), SPC::ERROR, 403, __LINE__, __FILE__ ); exit; } } }
protected function parseXml() { $header = $this->_xml->getElementsByTagName('header')->item(0); if ($header->hasChildNodes()) { foreach ($header->childNodes as $node) { if (!strstr($node->nodeName, '#')) { $params = array(); $this->parseParams($node, $params); $this->callHeader($node->nodeName, $params[$node->nodeName]); } } } $data = $this->_xml->getElementsByTagName('cache-data')->item(0); if ($data && $data->hasChildNodes()) { foreach ($data->childNodes as $node) { if (!strstr($node->nodeName, '#')) { $params = array(); $this->parseParams($node, $params); if (isset($params['hidden']) && is_array($params['hidden']) && count($params['hidden'])) { foreach ($params['hidden'] as $k => $v) { $this->addHidden($v, $k); } } if (isset($params['request']) && is_array($params['request']) && count($params['request'])) { foreach ($params['request'] as $k => $v) { SPRequest::set($k, $v, 'get'); } } if (isset($params['pathway']) && is_array($params['pathway']) && count($params['pathway'])) { foreach ($params['pathway'] as $v) { SPFactory::mainframe()->addToPathway($v['name'], $v['url']); } } } } } $visitor = $this->visitorArray(SPFactory::user()->getCurrent()); if (is_array($visitor) && isset($visitor['_data'])) { $this->importData($this->_xml->documentElement, $visitor, 'visitor'); } $messages = SPFactory::message()->getMessages(); $info = array(); if (count($messages)) { foreach ($messages as $type => $content) { $info[$type] = array_values($content); } } if (is_array($info)) { $this->importData($this->_xml->documentElement, $info, 'messages'); } $this->_xml->formatOutput = true; }
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(); }
/** */ private function listRules() { Sobi::ReturnPoint(); $order = SPFactory::user()->getUserState('acl.order', 'position', 'rid.asc'); try { $rules = SPFactory::db()->select('*', 'spdb_permissions_rules', null, $order)->loadObjectList(); } catch (SPException $x) { Sobi::Error('ACL', SPLang::e('Db reports %s.', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__); } $menu = $this->createMenu('acl'); /** @var $view SPAclView */ SPFactory::View('acl', true)->assign($this->_task, 'task')->assign($rules, 'rules')->assign($menu, 'menu')->determineTemplate('acl', 'list')->display(); }
protected function view() { /* determine template package */ $tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE); Sobi::ReturnPoint(); $this->_task = 'date'; if (!$this->_model) { $this->setModel('section'); $this->_model->init(Sobi::Section()); } $this->visible(); /* load template config */ $this->template(); $this->tplCfg($tplPackage); /* get limits - if defined in template config - otherwise from the section config */ $eLimit = $this->tKey($this->template, 'entries_limit', Sobi::Cfg('list.entries_limit', 2)); $eInLine = $this->tKey($this->template, 'entries_in_line', Sobi::Cfg('list.entries_in_line', 2)); $date = explode('.', SPRequest::cmd('date')); $this->date['year'] = isset($date[0]) && $date[0] ? $date[0] : null; $this->date['month'] = isset($date[1]) && $date[1] ? $date[1] : null; $this->date['day'] = isset($date[2]) && $date[2] ? $date[2] : null; if (!$this->date['year'] || !(int) $this->date['year']) { throw new SPException(SPLang::e('INVALID_DATE_GIVEN')); } /* get the site to display */ $site = SPRequest::int('site', 1); $eLimStart = ($site - 1) * $eLimit; $conditions = array('spo.oType' => 'entry', 'year(createdTime)' => $this->date['year']); $listing = 'year'; if ($this->date['month'] && $this->date['month'] < 13 && $this->date['month'] > 0) { $conditions['month(createdTime)'] = $this->date['month']; $listing = 'month'; } if ($this->date['day'] && $this->date['day'] < 13 && $this->date['day'] > 0) { $conditions['day(createdTime)'] = $this->date['day']; $listing = 'date'; } $eOrder = 'createdTime'; $eCount = count($this->getEntries($eOrder, 0, 0, true, $conditions, true, Sobi::Section())); $entries = $this->getEntries($eOrder, $eLimit, $eLimStart, true, $conditions, true, Sobi::Section()); $url = array('sid' => SPRequest::sid(), 'task' => 'list.date', 'date' => SPRequest::cmd('date')); $pn = SPFactory::Instance('helpers.pagenav_' . $this->tKey($this->template, 'template_type', 'xslt'), $eLimit, $eCount, $site, $url); if (SPRequest::int('site', 0)) { $url['site'] = SPRequest::int('site', 0); } SPFactory::header()->addCanonical(Sobi::Url($url, true, true, true)); /* handle meta data */ SPFactory::header()->objMeta($this->_model); $date = $this->date; $monthsNames = explode(',', Sobi::Txt('JS_CALENDAR_MONTHS')); $date['month'] = isset($monthsNames[$date['month'] - 1]) ? trim($monthsNames[$date['month'] - 1]) : null; SPFactory::mainframe()->addToPathway(Sobi::Txt('DL.PATH_TITLE_' . strtoupper($listing), $date), Sobi::Url('current')); SPFactory::header()->addTitle(Sobi::Txt('DL.TITLE_' . strtoupper($listing), $date), array(ceil($eCount / $eLimit), $site)); /* get view class */ $view = SPFactory::View('listing'); $view->assign($eLimit, '$eLimit'); $view->assign($eLimStart, '$eLimStart'); $view->assign($eCount, '$eCount'); $view->assign($eInLine, '$eInLine'); $view->assign($this->_task, 'task'); $view->assign($this->_model, 'section'); $view->setConfig($this->_tCfg, $this->template); $view->setTemplate($tplPackage . '.' . $this->templateType . '.' . $this->template); $view->assign($pn->get(), 'navigation'); $view->assign(SPFactory::user()->getCurrent(), 'visitor'); $view->assign($entries, 'entries'); Sobi::Trigger('UserListing', 'View', array(&$view)); $view->display(); }
/** * Details view * @return void */ private function details() { /* determine template package */ $tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE); /* load template config */ $this->template(); $this->tplCfg($tplPackage); if ($this->_model->get('oType') != 'entry') { Sobi::Error('Entry', sprintf('Serious security violation. Trying to save an object which claims to be an entry but it is a %s. Task was %s', $this->_model->get('oType'), SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__); exit; } /* add pathway */ SPFactory::mainframe()->addObjToPathway($this->_model); $this->_model->countVisit(); $this->_model->loadFields(Sobi::Reg('current_section')); $class = SPLoader::loadView('entry'); $view = new $class($this->template); $view->assign($this->_model, 'entry'); $view->assign(SPFactory::user()->getCurrent(), 'visitor'); $view->assign($this->_task, 'task'); $view->setConfig($this->_tCfg, $this->template); $view->setTemplate($tplPackage . '.' . $this->templateType . '.' . $this->template); Sobi::Trigger($this->name(), __FUNCTION__, array(&$view)); SPFactory::header()->objMeta($this->_model); $view->display(); SPFactory::cache()->addObj($this->_model, 'entry', $this->_model->get('id')); }
protected function form() { $ssid = 0; /* determine template package */ $tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE); /* load template config */ $this->template(); $this->tplCfg($tplPackage, 'search'); if ($this->template == 'results') { $this->template = 'view'; } if (!$this->_model) { $this->setModel('section'); $this->_model->init(Sobi::Section()); } /* handle meta data */ SPFactory::header()->objMeta($this->_model); $section = SPFactory::Section(Sobi::Section()); SPFactory::header()->addKeyword($section->get('sfMetaKeys'))->addDescription($section->get('sfMetaDesc')); /* add pathway */ SPFactory::mainframe()->addToPathway(Sobi::Txt('SH.PATH_TITLE'), Sobi::Url('current')); SPFactory::mainframe()->setTitle(Sobi::Txt('SH.TITLE', array('section' => $this->_model->get('name')))); Sobi::Trigger('OnFormStart', 'Search'); SPLoader::loadClass('mlo.input'); $view = SPFactory::View('search'); /* if we cannot transfer the search id in cookie */ if (!$this->session($ssid)) { $view->addHidden($ssid, 'ssid'); } if ($this->_task == 'results' && $ssid) { /* get limits - if defined in template config - otherwise from the section config */ $eLimit = $this->tKey($this->template, 'entries_limit', Sobi::Cfg('search.entries_limit', Sobi::Cfg('list.entries_limit', 2))); $eInLine = $this->tKey($this->template, 'entries_in_line', Sobi::Cfg('search.entries_in_line', Sobi::Cfg('list.entries_in_line', 2))); /* get the site to display */ $site = SPRequest::int('site', 1); $eLimStart = ($site - 1) * $eLimit; $view->assign($eLimit, '$eLimit'); $view->assign($eLimStart, '$eLimStart'); $view->assign($eInLine, '$eInLine'); $entries = $this->getResults($ssid, $this->template); $view->assign(count($this->_results), '$eCount'); $view->assign($this->_resultsByPriority, 'priorities'); $view->assign($entries, 'entries'); /* create page navigation */ $pnc = SPLoader::loadClass('helpers.pagenav_' . $this->tKey($this->template, 'template_type', 'xslt')); $url = array('task' => 'search.results', 'sid' => SPRequest::sid()); if (!SPRequest::cmd('ssid', null, 'cookie')) { $url['ssid'] = $ssid; } /* @var SPPageNavXSLT $pn */ $pn = new $pnc($eLimit, $this->_resultsCount, $site, $url); $view->assign($pn->get(), 'navigation'); /** * this is te special case: * no matter what task we currently have - if someone called this we need the data for the V-Card * Soe we have to trigger all these plugins we need and therefore also fake the task */ $task = 'list.custom'; SPFactory::registry()->set('task', $task); } else { $eLimit = -1; $view->assign($eLimit, '$eCount'); } /* load all fields */ $fields = $this->loadFields(); if (isset($this->_request['search_for'])) { $view->assign($this->_request['search_for'], 'search_for'); $view->assign($this->_request['phrase'], 'search_phrase'); } $view->assign($fields, 'fields'); $view->assign(SPFactory::user()->getCurrent(), 'visitor'); $view->assign($this->_task, 'task'); $view->addHidden(Sobi::Section(), 'sid'); $view->addHidden('search.search', 'task'); $view->setConfig($this->_tCfg, $this->template); $view->setTemplate($tplPackage . '.' . $this->templateType . '.' . $this->template); Sobi::Trigger('OnCreateView', 'Search', array(&$view)); $view->display(); }
/** * * @param int $id * @return \JUser * @internal param $id */ public function &getUser($id = 0) { return SPFactory::user()->getInstance($id); }
protected function reject() { if (!SPFactory::mainframe()->checkToken()) { Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__); } if ($this->authorise('manage')) { $changes = array(); $objects = array('entry' => $this->_model, 'user' => SPFactory::user(), 'author' => SPFactory::Instance('cms.base.user', $this->_model->get('owner'))); $messages =& SPFactory::registry()->get('messages'); $reason = SPLang::replacePlaceHolders(SPRequest::string('reason', null, true, 'post'), $objects); $objects['reason'] = nl2br($reason); $messages['rejection'] = $objects; SPFactory::registry()->set('messages', $messages); $this->_model->setMessage($reason, 'reason'); if (SPRequest::bool('unpublish', false, 'post')) { $this->_model->changeState(0, $reason, false); $changes[] = 'unpublish'; } if (SPRequest::bool('trigger_unpublish', false, 'post')) { Sobi::Trigger('Entry', 'AfterChangeState', array($this->_model, 0, 'messages' => $this->_model->get('messages'))); } if (SPRequest::bool('discard', false, 'post')) { $changes[] = 'discard'; $data = $this->_model->discard(false); } if (SPRequest::bool('trigger_unapprove', false, 'post')) { Sobi::Trigger('Entry', 'AfterUnapprove', array($this->_model, 0)); } Sobi::Trigger('Entry', 'AfterReject', array($this->_model, 0)); SPFactory::message()->logAction('reject', $this->_model->get('id'), $data, $reason); $this->response(Sobi::Back(), Sobi::Txt('ENTRY_REJECTED', $this->_model->get('name')), true, SPC::SUCCESS_MSG); } }
/** * Returns selected property of the currently visiting user * e.g Sobi::My( 'id' ); Sobi::My( 'name' ); * * @param string $property * @return mixed */ public static function My($property) { static $user = null; if (!$user) { $user =& SPFactory::user(); } return $user->get($property); }
/** * Filter variable from request * @param string $value * @return string */ public static function filter($value) { if (class_exists('SPFactory')) { if (SPFactory::user()->isAdmin()) { return stripslashes($value); } } self::createFilter(); $a = self::$filter->filter(stripslashes($value)); return $a; }
/** * @todo Enter description here... * * @param array $ordering * @param string $type * @param string $id * @param string $fname * @return string */ public static function tableHeader($ordering, $type, $id = 'sid', $fname = 'order', $def = 'position.asc') { $header = array(); $current = SPFactory::user()->getUserState($type . '.order', $fname, $def); if (strstr($current, '.')) { $current = explode('.', $current); $newDirect = trim($current[1]) == 'asc' ? 'desc' : 'asc'; $current = $current[0]; } $sid = SPRequest::sid() ? SPRequest::sid() : SPRequest::int('pid'); if (is_array($ordering) && count($ordering)) { foreach ($ordering as $order => $active) { $class = null; $params = array(); if (is_array($active)) { $params = $active; $active = $active['type']; } switch ($active) { case SP_TBL_HEAD_RAW: $header[$order] = Sobi::Txt($type . '.header_' . $order); break; case 1: case 3: case 4: case 5: case 6: $direction = 'asc'; $ico = null; $aico = null; if (isset($params['order'])) { $sortBy = $params['order']; } else { $sortBy = $order; } $label = Sobi::Txt($type . '.header_' . $order); $title = Sobi::Txt($type . '.header_order_by_' . $order); if ($sortBy == $current) { $class = "class=\"selected\""; $ico = Sobi::Cfg('list_icons.sort_direction_' . ($newDirect == 'asc' ? 'desc' : 'asc')); $ico = " <img src=\"{$ico}\"/> "; $direction = $newDirect; } if ($active == SP_TBL_HEAD_SORTABLE_FIELD) { $label = $params['label']; $title = Sobi::Txt('LIST.ORDER_BY_FIELD', array('field' => $label)); } if ($active == SP_TBL_HEAD_STATE) { SPLoader::loadClass('html.tooltip'); $msg = Sobi::Txt('LIST.MAKE_SELECTION'); $onclk = " onclick=\"if( document.adminForm.boxchecked.value == 0 ) { alert( '{$msg}' ); } else { submitbutton( '{$type}.publish' ); }\""; $url = "#"; $ai = Sobi::Cfg('list_icons.enable'); $s = Sobi::Txt('LIST.ENABLE_S', array('type' => Sobi::Txt(strtoupper($type)))); $a = Sobi::Txt($type . '.enable_expl'); $aico = SPTooltip::toolTip($a, $s, $ai); $aico = " <span class=\"headerStateIcons\"><a href=\"{$url}\"{$onclk}>{$aico}</a></span>"; $ui = Sobi::Cfg('list_icons.disable'); $s = Sobi::Txt('LIST.DISABLE_S', array('type' => Sobi::Txt(strtoupper($type)))); $a = Sobi::Txt($type . '.disable_expl'); $uico = SPTooltip::toolTip($a, $s, $ui); $onclk = " onclick=\"if( document.adminForm.boxchecked.value == 0 ) { alert( '{$msg}' ); } else { submitbutton( '{$type}.hide' ); }\""; $uico = " <span class=\"headerStateIcons\"><a href=\"{$url}\"{$onclk}>{$uico}</a></span>"; $aico .= $uico; } if ($active == SP_TBL_HEAD_APPROVAL) { SPLoader::loadClass('html.tooltip'); $msg = Sobi::Txt('LIST.MAKE_SELECTION'); $onclk = " onclick=\"if( document.adminForm.boxchecked.value == 0 ) { alert( '{$msg}' ); } else { submitbutton( '{$type}.approve' ); }\""; $url = "#"; $ai = Sobi::Cfg('list_icons.approve'); $s = Sobi::Txt($type . '.approve'); $a = Sobi::Txt($type . '.approve_expl'); $aico = SPTooltip::toolTip($a, $s, $ai); $aico = " <span class=\"headerAppIcons\"><a href=\"{$url}\"{$onclk}>{$aico}</a></span>"; $ui = Sobi::Cfg('list_icons.disable'); $s = Sobi::Txt($type . '.unapprove'); $a = Sobi::Txt($type . '.unapprove_expl'); $uico = SPTooltip::toolTip($a, $s, $ui); $onclk = " onclick=\"if( document.adminForm.boxchecked.value == 0 ) { alert( '{$msg}' ); } else { submitbutton( '{$type}.unapprove' ); }\""; $uico = " <span class=\"headerAppIcons\"><a href=\"{$url}\"{$onclk}>{$uico}</a></span>"; $aico .= $uico; } if ($active == SP_TBL_HEAD_ORDER) { SPLoader::loadClass('html.tooltip'); $url = "#"; $onclk = " onclick=\"SPReorder( '{$type}', {$sid} );\" "; $aico = " <span class=\"headerStateIcons\"><a href=\"{$url}\" title=\"{$a}\">{$aico}</a></span>"; $ui = Sobi::Cfg('list_icons.order'); $s = Sobi::Txt($type . '.save_order'); $a = Sobi::Txt($type . '.save_order_expl'); $uico = SPTooltip::toolTip($a, $s, $ui); $uico = " <span class=\"headerOrderIcon\"><a href=\"{$url}\"{$onclk}>{$uico}</a></span>"; $aico .= $uico; } $header[$order] = "<a {$class} href=\"javascript:SPOrdering( '{$sortBy}','{$direction}', '{$fname}', {$sid} );\" title=\"{$title}\">{$label}</a> {$ico}{$aico}"; break; case SP_TBL_HEAD_SELECTION_BOX: $name = Sobi::Txt($type . '.header_toggle'); $header[$order] = "<input type=\"checkbox\" name=\"toggle\" id=\"toggel_{$id}\" title=\"{$name}\" value=\"1\" onclick=\"SPCheckListElements('{$id}', this );\"/>"; break; } } } return $header; }
/** * Returns selected property of the currently visiting user * e.g SobiPro::My( 'id' ); SobiPro::My( 'name' ); * * @param string $property * @return mixed */ public static function My($property) { if (in_array($property, array('password', 'block', 'sendEmail', 'activation', 'params'))) { return false; } static $user = null; if (!$user) { $user =& SPFactory::user(); } return $user->get($property); }