Exemple #1
0
 private function load($task)
 {
     $db =& SPFactory::db();
     $adm = defined('SOBIPRO_ADM') ? 'adm.' : null;
     $cond = array($adm . '*', $adm . $task);
     if (strstr($task, '.')) {
         $t = explode('.', $task);
         $cond[] = $adm . $t[0] . '.*';
         $task = $t[0] . '.' . $t[1];
     }
     $this->_actions[$task] = null;
     try {
         $pids = $db->select('pid', 'spdb_plugin_task', array('onAction' => $cond))->loadResultArray();
     } catch (SPException $x) {
         Sobi::Error('Plugins', $x->getMessage(), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     if (!count($pids)) {
         $this->_actions[$task] = array();
     }
     // get section depend apps
     if (Sobi::Section() && count($pids)) {
         try {
             $this->_actions[$task] = $db->select('pid', 'spdb_plugin_section', array('section' => Sobi::Section(), 'enabled' => 1, 'pid' => $pids))->loadResultArray();
         } catch (SPException $x) {
             Sobi::Error('Plugins', $x->getMessage(), SPC::WARNING, 0, __LINE__, __FILE__);
         }
     } elseif (!(SPRequest::sid() || SPRequest::int('pid'))) {
         $this->_actions[$task] = $pids;
     }
     // here is a special exception for the custom listings
     // it can be l.alpha or list.alpha or listing.alpha
     if (preg_match('/^list\\..*/', $task) || preg_match('/^l\\..*/', $task)) {
         $this->_actions['listing' . '.' . $t[1]] = $pids;
     }
 }
Exemple #2
0
 /**
  */
 private function edit()
 {
     $id = $this->get('entry.id');
     if ($id) {
         $this->addHidden($id, 'entry.id');
     }
     $sid = SPRequest::int('pid') ? SPRequest::int('pid') : SPRequest::sid();
     $this->assign(Sobi::Url(array('task' => 'category.chooser', 'sid' => $sid, 'out' => 'html', 'multiple' => 1), true), 'cat_chooser_url');
 }
Exemple #3
0
 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;
 }
Exemple #4
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);
 }
Exemple #5
0
 public function execute()
 {
     $this->start = microtime(true);
     $sites = $this->getSites();
     $responses = array();
     $status = 'working';
     $message = null;
     $this->format = SPRequest::bool('fullFormat') ? self::FORMAT_FULL : self::FORMAT;
     //		$this->format = SPRequest::bool( 'fullFormat' ) ? self::FORMAT_FULL : self::FORMAT_FULL;
     $task = SPRequest::task();
     if (in_array($task, array('crawler.init', 'crawler.restart'))) {
         if ($task == 'crawler.restart') {
             SPFactory::cache()->cleanSection(Sobi::Section());
         }
         SPFactory::db()->truncate(self::DB_TABLE);
         $multiLang = Sobi::Cfg('lang.multimode', false);
         if ($multiLang) {
             $langs = SPFactory::CmsHelper()->getLanguages();
             if ($multiLang && $langs) {
                 foreach ($langs as $lang) {
                     $responses[] = $this->getResponse(Sobi::Cfg('live_site') . 'index.php?option=com_sobipro&sid=' . Sobi::Section() . '&lang=' . $lang);
                 }
             }
         }
         $responses[] = $this->getResponse(Sobi::Cfg('live_site') . 'index.php?option=com_sobipro&sid=' . Sobi::Section());
         $sites = $this->getSites();
     }
     if (!count($sites) && !in_array($task, array('crawler.init', 'crawler.restart'))) {
         $message = Sobi::Txt('CRAWL_URL_PARSED_DONE', SPFactory::db()->select('count(*)', self::DB_TABLE)->loadResult());
         SPFactory::db()->truncate(self::DB_TABLE);
         $this->response(array('status' => 'done', 'data' => array(), 'message' => $message));
     }
     if (count($sites)) {
         $i = 0;
         $timeLimit = SPRequest::int('timeLimit', self::TIME_LIMIT, 'get', true);
         foreach ($sites as $site) {
             if (!strlen($site)) {
                 continue;
             }
             $responses[] = $this->getResponse($site);
             $i++;
             if (microtime(true) - $this->start > $timeLimit) {
                 break;
             }
         }
         $message = Sobi::Txt('CRAWL_URL_PARSED_WORKING', $i, count($sites));
     }
     $this->response(array('status' => $status, 'data' => $responses, 'message' => $message));
 }
Exemple #6
0
 public function functions()
 {
     $functions = $this->get('functions');
     $out = array();
     $section = SPRequest::int('section');
     $out[] = '<form action="index.php" method="post">';
     $out[] = SPHtml_Input::select('function', $functions, null, false, array('id' => 'SobiProFunctions'));
     $out[] = '<input type="hidden" name="option" value="com_sobipro">';
     $out[] = '<input type="hidden" name="task" value="menu">';
     $out[] = '<input type="hidden" name="tmpl" value="component">';
     $out[] = '<input type="hidden" name="format" value="html">';
     $out[] = '<input type="hidden" name="mid" value="' . SPRequest::int('mid') . '">';
     $out[] = '<input type="hidden" name="section" value="' . $section . '">';
     $out[] = '</form>';
     echo implode("\n", $out);
 }
Exemple #7
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;
 }
Exemple #8
0
 protected function getTemplates($type)
 {
     $templates = array();
     $templates[''] = Sobi::Txt('SELECT_TEMPLATE_OVERRIDE');
     $template = SPFactory::db()->select('sValue', 'spdb_config', array('section' => SPRequest::int('section'), 'sKey' => 'template', 'cSection' => 'section'))->loadResult();
     $templateDir = $this->templatePath($template);
     $this->listTemplates($templates, $templateDir, $type);
     return $templates;
 }
Exemple #9
0
 /**
  * Route task
  */
 public function execute()
 {
     /* parent class executes the plugins */
     $r = false;
     $task = $this->_task;
     if (strstr($this->_task, '.')) {
         $task = explode('.', $this->_task);
         $this->_fieldType = $task[1];
         $task = $task[0];
     }
     switch ($task) {
         case 'list':
             $r = true;
             $this->listFields();
             break;
         case 'add':
         case 'edit':
             $r = true;
             $this->edit();
             break;
         case 'cancel':
             $r = true;
             $this->checkIn();
             $this->response(Sobi::Back());
             break;
         case 'addNew':
             $r = true;
             Sobi::Redirect(Sobi::Url(array('task' => 'field.edit', 'fid' => $this->saveNew(), 'sid' => SPRequest::sid())));
             break;
         case 'apply':
         case 'save':
             $r = true;
             $this->save();
             break;
         case 'clone':
             $r = true;
             $this->save(true);
             break;
         case 'delete':
             $r = true;
             SPFactory::cache()->cleanSection();
             $this->response(Sobi::Url(array('task' => 'field.list', 'pid' => Sobi::Section())), $this->delete(), true);
             break;
         case 'reorder':
             $r = true;
             $this->reorder();
             break;
         case 'revisions':
             $r = true;
             $this->revisions();
             break;
         case 'up':
         case 'down':
             $r = true;
             $this->singleReorder($this->_task == 'up');
             break;
         case 'hide':
         case 'publish':
         case 'setRequired':
         case 'setNotRequired':
         case 'setEditable':
         case 'setNotEditable':
         case 'setFee':
         case 'setFree':
         case 'toggle':
             $r = true;
             $this->authorise($this->_task);
             SPFactory::cache()->cleanSection();
             $this->response(Sobi::Back(), $this->changeState($task), true);
             break;
         default:
             /* case plugin didn't registered this task, it was an error */
             if (!Sobi::Trigger('Execute', $this->name(), array(&$this))) {
                 $fid = SPRequest::int('fid');
                 $method = $this->_task;
                 if ($fid) {
                     SPLoader::loadModel('field', true);
                     $fdata = $this->loadField($fid);
                     $field = new SPAdmField();
                     $field->extend($fdata);
                     try {
                         $field->{$method}();
                     } catch (SPException $x) {
                         Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
                     }
                 } elseif (!parent::execute()) {
                     Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
                 }
             }
             break;
     }
     return $r;
 }
Exemple #10
0
 /**
  * get the right section
  * @return void
  */
 private function getSection()
 {
     $pid = SPRequest::int('pid');
     $pid = $pid ? $pid : $this->_sid;
     if ($pid) {
         $this->_model = SPFactory::object($pid);
         /** @noinspection PhpParamsInspection
          * @var $this ->_model stdClass
          */
         if ($this->_model->oType == 'section') {
             $this->_section = $this->_model->id;
         } else {
             $db = SPFactory::db();
             $path = array();
             $id = $pid;
             while ($id > 0) {
                 try {
                     $db->select('pid', 'spdb_relations', array('id' => $id));
                     $id = $db->loadResult();
                     if ($id) {
                         $path[] = (int) $id;
                     }
                 } catch (SPException $x) {
                     Sobi::Error('CoreCtrl', SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
                 }
             }
             $path = array_reverse($path);
             $this->_section = $path[0];
         }
     } else {
         $this->_section = '0';
     }
     SPFactory::registry()->set('current_section', $this->_section);
 }
Exemple #11
0
 public function save($attr)
 {
     /* @var SPdb $db */
     $db = SPFactory::db();
     $base = $attr;
     $this->loadType();
     /* clean input */
     if (isset($attr['name'])) {
         $base['name'] = $db->escape($attr['name']);
     } else {
         $base['name'] = 'missing name - something went wrong';
     }
     if (isset($attr['nid'])) {
         $base['nid'] = $this->nid($db->escape(preg_replace('/[^[:alnum:]\\-\\_]/', null, $attr['nid'])), false);
     }
     if (isset($attr['cssClass'])) {
         $base['cssClass'] = $db->escape(preg_replace('/[^[:alnum:]\\-\\_ ]/', null, $attr['cssClass']));
     }
     if (isset($attr['notice'])) {
         $base['notice'] = $attr['notice'];
     }
     if (isset($attr['showIn'])) {
         $base['showIn'] = $db->escape(preg_replace('/[^[:alnum:]\\.\\-\\_]/', null, $attr['showIn']));
     }
     if (isset($attr['filter'])) {
         $base['filter'] = preg_replace('/[^[:alnum:]\\.\\-\\_]/', null, $attr['filter']);
     }
     if (isset($attr['fieldType'])) {
         $base['fieldType'] = preg_replace('/[^[:alnum:]\\.\\-\\_]/', null, $attr['fieldType']);
     }
     if (isset($attr['type'])) {
         $base['fieldType'] = preg_replace('/[^[:alnum:]\\.\\-\\_]/', null, $attr['type']);
     }
     if (isset($attr['enabled'])) {
         $base['enabled'] = (int) $attr['enabled'];
     }
     if (isset($attr['required'])) {
         $base['required'] = (int) $attr['required'];
     }
     if (isset($attr['adminField'])) {
         $base['adminField'] = (int) $attr['adminField'];
     }
     if ($attr['adminField']) {
         $attr['required'] = false;
     }
     if (isset($attr['editable'])) {
         $base['editable'] = (int) $attr['editable'];
     }
     if (isset($attr['inSearch'])) {
         $base['inSearch'] = (int) $attr['inSearch'];
     }
     if (isset($attr['editLimit'])) {
         $base['editLimit'] = (int) $attr['editLimit'];
     }
     $base['editLimit'] = isset($base['editLimit']) && $base['editLimit'] > 0 ? $base['editLimit'] : -1;
     if (isset($attr['isFree'])) {
         $base['isFree'] = (int) $attr['isFree'];
     }
     if (isset($attr['withLabel'])) {
         $base['withLabel'] = (int) $attr['withLabel'];
     }
     if (isset($attr['fee'])) {
         $base['fee'] = (double) str_replace(',', '.', $attr['fee']);
     }
     if (isset($attr['addToMetaDesc'])) {
         $base['addToMetaDesc'] = (int) $attr['addToMetaDesc'];
     }
     if (isset($attr['addToMetaKeys'])) {
         $base['addToMetaKeys'] = (int) $attr['addToMetaKeys'];
     }
     if (isset($attr['uniqueData'])) {
         $base['uniqueData'] = (int) $attr['uniqueData'];
     }
     /* both strpos are removed because it does not allow to have one parameter only */
     //      if( isset( $attr[ 'allowedAttributes' ] ) && strpos( $attr[ 'allowedAttributes' ], '|' ) )
     if (isset($attr['allowedAttributes'])) {
         $att = SPFactory::config()->structuralData($attr['allowedAttributes'], true);
         if (count($att)) {
             foreach ($att as $i => $k) {
                 $att[$i] = trim($k);
             }
         }
         $base['allowedAttributes'] = SPConfig::serialize($att);
     }
     if (isset($attr['allowedTags'])) {
         $tags = SPFactory::config()->structuralData($attr['allowedTags'], true);
         if (count($tags)) {
             foreach ($tags as $i => $k) {
                 $tags[$i] = trim($k);
             }
         }
         $base['allowedTags'] = SPConfig::serialize($tags);
     }
     if (isset($attr['admList'])) {
         $base['admList'] = (int) $attr['admList'];
     }
     if (isset($attr['description'])) {
         $base['description'] = $attr['description'];
     } else {
         $base['description'] = null;
     }
     if (isset($attr['suffix'])) {
         $base['suffix'] = $db->escape($attr['suffix']);
     } else {
         $base['suffix'] = null;
     }
     $this->version++;
     $base['version'] = $this->version;
     /* section id is needed only if it was new field */
     if (!(isset($attr['section']) && $attr['section'])) {
         if (!SPRequest::int('fid')) {
             $base['section'] = SPRequest::sid();
         }
     }
     /* bind attributes to this object */
     foreach ($attr as $a => $v) {
         $a = trim($a);
         if ($this->has($a)) {
             $this->{$a} = $v;
         }
     }
     if ($this->_type && method_exists($this->_type, 'save')) {
         $this->_type->save($base);
     }
     /* get database columns and their ordering */
     $cols = $db->getColumns('spdb_field');
     $values = array();
     /* and sort the properties in the same order */
     foreach ($cols as $col) {
         if (array_key_exists($col, $base)) {
             $values[$col] = $base[$col];
         }
     }
     /* save field */
     try {
         $db->update('spdb_field', $values, array('fid' => $this->fid));
     } catch (SPException $x) {
         Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
     }
     /* save language dependent properties */
     $labels = array();
     $defLabels = array();
     $labels[] = array('sKey' => 'name', 'sValue' => $base['name'], 'language' => Sobi::Lang(), 'id' => 0, 'oType' => 'field', 'fid' => $this->fid);
     $labels[] = array('sKey' => 'description', 'sValue' => $base['description'], 'language' => Sobi::Lang(), 'id' => 0, 'oType' => 'field', 'fid' => $this->fid);
     $labels[] = array('sKey' => 'suffix', 'sValue' => $base['suffix'], 'language' => Sobi::Lang(), 'id' => 0, 'oType' => 'field', 'fid' => $this->fid);
     if (Sobi::Lang() != Sobi::DefLang()) {
         $defLabels[] = array('sKey' => 'name', 'sValue' => $base['name'], 'language' => Sobi::DefLang(), 'id' => 0, 'oType' => 'field', 'fid' => $this->fid);
         $defLabels[] = array('sKey' => 'suffix', 'sValue' => $base['suffix'], 'language' => Sobi::DefLang(), 'id' => 0, 'oType' => 'field', 'fid' => $this->fid);
         $defLabels[] = array('sKey' => 'description', 'sValue' => $base['description'], 'language' => Sobi::DefLang(), 'id' => 0, 'oType' => 'field', 'fid' => $this->fid);
     }
     if (count($labels)) {
         try {
             if (Sobi::Lang() != Sobi::DefLang()) {
                 $db->insertArray('spdb_language', $defLabels, false, true);
             }
             $db->insertArray('spdb_language', $labels, true);
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('CANNOT_SAVE_FIELD_DB_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
         }
     }
     SPFactory::cache()->cleanSection();
 }
Exemple #12
0
 public function languages()
 {
     $subMenu = array();
     if (Sobi::Cfg('lang.multimode', false)) {
         $availableLanguages = SPFactory::CmsHelper()->availableLanguages();
         $sectionLength = 30;
         if (count($availableLanguages)) {
             $sid = SPRequest::sid();
             if (!$sid) {
                 $sid = Sobi::Section();
             }
             $subMenu = array();
             $task = SPRequest::task();
             $url = array('sid' => $sid, 'task' => $task, 'sp-language' => null);
             if ($task == 'field.edit') {
                 $url = array('sid' => $sid, 'task' => $task, 'fid' => SPRequest::int('fid'), 'sp-language' => null);
             }
             foreach ($availableLanguages as $language) {
                 $url['sp-language'] = $language['tag'];
                 $subMenu[] = array('type' => 'url', 'task' => '', 'url' => $url, 'label' => strlen($language['name']) < $sectionLength ? $language['name'] : substr($language['name'], 0, $sectionLength - 3) . ' ...', 'icon' => 'file', 'element' => 'button', 'selected' => $language['tag'] == Sobi::Lang());
             }
         }
     }
     return $subMenu;
 }
Exemple #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();
 }
Exemple #14
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;
     }
 }
Exemple #15
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($this->_type);
         $orderings = $this->get('orderings');
         $categories = $this->get('categories');
         $entries = $this->get('entries');
         $cUrl = array('title' => Sobi::Cfg('sef.alias', true) ? $current->get('nid') : $current->get('name'), 'sid' => $current->get('id'));
         if (SPRequest::int('site', 0)) {
             $cUrl['site'] = SPRequest::int('site', 0);
         }
         SPFactory::header()->addCanonical(Sobi::Url($cUrl, true, true, true));
         $data = array();
         $data['id'] = $current->get('id');
         $data['counter'] = $current->get('counter');
         $data['section'] = array('_complex' => 1, '_data' => Sobi::Section(true), '_attributes' => array('id' => Sobi::Section(), 'lang' => Sobi::Lang(false)));
         $data['name'] = array('_complex' => 1, '_data' => $current->get('name'), '_attributes' => array('lang' => Sobi::Lang(false)));
         if (Sobi::Cfg('category.show_desc') || $current->get('oType') == 'section') {
             $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)));
         }
         $showIcon = $current->get('showIcon');
         if ($showIcon == SPC::GLOBAL_SETTING) {
             $showIcon = Sobi::Cfg('category.show_icon', true);
         }
         if ($showIcon && $current->get('icon')) {
             if (SPFs::exists(Sobi::Cfg('images.category_icons') . '/' . $current->get('icon'))) {
                 $data['icon'] = Sobi::FixPath(Sobi::Cfg('images.category_icons_live') . $current->get('icon'));
             }
         }
         $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');
         $data['number_of_subcats'] = Sobi::Cfg('list.num_subcats');
         $this->menu($data);
         $this->alphaMenu($data);
         $data['visitor'] = $this->visitorArray($visitor);
         if (count($categories)) {
             $this->loadNonStaticData($categories);
             foreach ($categories as $category) {
                 $cat = $this->category($category);
                 $data['categories'][] = array('_complex' => 1, '_attributes' => array('id' => $cat['id'], 'nid' => $cat['nid']), '_data' => $cat);
             }
             if (strstr($orderings['categories'], 'name') && Sobi::Cfg('lang.multimode', false)) {
                 usort($data['categories'], 'self::orderByName');
                 if ($orderings['categories'] == 'name.desc') {
                     $data['categories'] = array_reverse($data['categories']);
                 }
             }
         }
         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'], 'nid' => $en['nid']), '_data' => $en);
             }
             if (strstr($orderings['entries'], 'name') && Sobi::Cfg('lang.multimode', false)) {
                 usort($data['entries'], 'self::orderByName');
                 if ($orderings['entries'] == 'name.desc') {
                     $data['entries'] = array_reverse($data['entries']);
                 }
             }
             $this->navigation($data);
         }
         $this->fixTimes($data);
         $this->_attr = $data;
     }
     Sobi::Trigger($this->_type, ucfirst(__FUNCTION__), array(&$this->_attr));
 }
Exemple #16
0
 private function screen()
 {
     $eLimit = Sobi::GetUserState('adm.errors.limit', 'elimit', Sobi::Cfg('adm_list.entries_limit', 25));
     $eLimStart = SPRequest::int('errSite', 1);
     $LimStart = $eLimStart ? ($eLimStart - 1) * $eLimit : $eLimStart;
     $eCount = 0;
     try {
         $eCount = SPFactory::db()->select('COUNT(eid)', 'spdb_errors')->loadResult();
     } catch (SPException $x) {
     }
     if ($eLimit == -1) {
         $eLimit = $eCount;
     }
     try {
         $errors = SPFactory::db()->select(array('eid', 'date', 'errNum', 'errCode', 'errFile', 'errLine', 'errMsg', 'errUid', 'errSect', 'errReq'), 'spdb_errors', null, 'eid.desc', $eLimit, $LimStart)->loadAssocList();
     } catch (SPException $x) {
     }
     $l = $this->levels();
     $menu = $this->createMenu('error');
     /** @var $view SPAdmView */
     SPFactory::View('error', true)->assign($this->_task, 'task')->assign($menu, 'menu')->assign($errors, 'errors')->assign($l, 'levels')->assign($eLimit, 'errors-limit')->assign($eCount, 'errors-count')->assign($eLimStart, 'errors-site')->display();
 }
Exemple #17
0
 /**
  * @see #can
  * @param string $section
  * @param string $subject
  * @param string $action
  * @param string $value
  * @return bool
  */
 public function authorise($section, $subject, $action, $value)
 {
     if ($this->isAdmin()) {
         return true;
     }
     /* translate automatic created request */
     switch ($action) {
         case 'cancel':
             return true;
             break;
         case 'save':
         case 'submit':
             $id = SPRequest::int('sid', SPRequest::int('rid'));
             $action = $id ? 'edit' : 'add';
         case 'enable':
         case 'hide':
         case 'disable':
             $action = 'manage';
             break;
         case 'apply':
             $action = 'edit';
         case 'details':
         case 'view':
             $action = 'access';
     }
     if (in_array($subject, array('acl', 'config', 'extensions'))) {
         $action = 'manage';
         $section = 0;
     }
     if (!$section) {
         $value = 'global';
         if (in_array(SPRequest::task(), $this->_special)) {
             return true;
         }
     }
     /* admin panel or site front */
     $site = SOBI_ACL;
     /* initialise */
     $auth = false;
     /* if not initialised */
     if (!isset($this->_permissions[$section]) || !count($this->_permissions[$section])) {
         $this->getPermissions();
     }
     /* if already requested, return the answer */
     $i = "[{$site}][{$section}][{$action}][{$subject}][{$value}]";
     if (isset($this->_prequest[$i])) {
         return $this->_prequest[$i];
     }
     if (isset($this->_permissions[$section])) {
         if (isset($this->_permissions[$section][$subject])) {
             if (isset($this->_permissions[$section][$subject][$action])) {
                 if (isset($this->_permissions[$section][$subject][$action][$value])) {
                     $auth = $this->_permissions[$section][$subject][$action][$value];
                 } elseif (isset($this->_permissions[$section][$subject][$action]['*'])) {
                     $auth = $this->_permissions[$section][$subject][$action]['*'];
                 }
             } elseif (isset($this->_permissions[$section][$subject]['*'])) {
                 $auth = $this->_permissions[$section][$subject]['*'];
             }
         } elseif (isset($this->_permissions[$section]['*'])) {
             $auth = $this->_permissions[$section]['*'];
         }
     }
     // @@ just for tests
     //		$a = ( $auth ) ? 'GRANTED' : 'DENIED';//var_export( debug_backtrace( false ), true ) ;
     //		SPConfig::debOut("{$action} {$subject} {$value} === {$a} ");
     /* store the answer for future request */
     $this->_prequest[$i] = $auth;
     return $auth;
 }
Exemple #18
0
 public function ProxyCount()
 {
     SPLoader::loadClass('env.browser');
     SPLoader::loadClass('env.cookie');
     $browser = SPBrowser::getInstance();
     $this->nid = str_replace(array('.count', '.'), array(null, '_'), SPRequest::task());
     $ident = $this->nid . '_' . SPRequest::int('eid');
     $check = SPRequest::cmd('count_' . $ident, null, 'cookie');
     if (!$check) {
         $data = array('date' => 'FUNCTION:NOW()', 'uid' => Sobi::My('id'), 'sid' => SPRequest::int('eid'), 'fid' => $this->nid, 'ip' => SPRequest::ip('REMOTE_ADDR', 0, 'SERVER'), 'section' => Sobi::Section(), 'browserData' => $browser->get('browser'), 'osData' => $browser->get('system'), 'humanity' => $browser->get('humanity'));
         SPCookie::set('count_' . $ident, 1, SPCookie::hours(2));
         SPFactory::db()->insert('spdb_field_url_clicks', $data);
     }
 }
Exemple #19
0
 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();
 }
Exemple #20
0
 protected function getResults($ssid, $template)
 {
     $results = array();
     /* case some plugin overwrites this method */
     Sobi::Trigger('GetResults', 'Search', array(&$results, &$ssid, &$template));
     if (count($results)) {
         return $results;
     }
     /* get limits - if defined in template config - otherwise from the section config */
     $eLimit = $this->tKey($template, 'entries_limit', Sobi::Cfg('search.entries_limit', Sobi::Cfg('list.entries_limit', 2)));
     $eInLine = $this->tKey($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;
     try {
         $this->_db->select(array('entriesResults', 'requestData'), 'spdb_search', array('ssid' => $ssid));
         $r = $this->_db->loadAssocList();
         if (strlen($r[0]['entriesResults'])) {
             $store = SPConfig::unserialize($r[0]['entriesResults']);
             if ($store['results']) {
                 $this->_results = array_unique(explode(',', $store['results']));
                 $this->_resultsByPriority = $store['resultsByPriority'];
             }
             $this->_resultsCount = count($this->_results);
         }
         $this->_request = SPConfig::unserialize($r[0]['requestData']);
         SPFactory::registry()->set('requestcache', $this->_request);
         if (count($this->_results)) {
             $r = array_slice($this->_results, $eLimStart, $eLimit);
             /* so we have a results */
             foreach ($r as $i => $sid) {
                 $results[$i] = (int) $sid;
                 //$results[ $i ] = new $eClass();
                 //$results[ $i ]->init( $sid );
             }
         }
     } catch (SPException $x) {
         Sobi::Error($this->name(), SPLang::e('CANNOT_GET_SESSION_DB_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
     }
     Sobi::SetUserData('currently-displayed-entries', $results);
     return $results;
 }
Exemple #21
0
 private function getLink($button)
 {
     $link = '#';
     if (isset($button['type'])) {
         switch ($button['type']) {
             case 'help':
                 $link = 'https://www.sigsiu.net/help_screen/' . Sobi::Reg('help_task', SPRequest::task());
                 break;
             case 'url':
                 if (isset($button['sid']) && $button['sid'] == 'true') {
                     $link = Sobi::Url(array('task' => $button['task'], 'sid' => SPRequest::sid('request', SPRequest::int('pid'), true)));
                 } else {
                     $link = Sobi::Url($button['task'] ? $button['task'] : $button['url']);
                 }
                 break;
         }
     }
     return $link;
 }
Exemple #22
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();
 }
 protected function view()
 {
     $msg = null;
     $store = array();
     Sobi::SetUserData('requirements', $store);
     $home = SPRequest::int('init') ? Sobi::Url(null, true) : Sobi::Url('config', true);
     /** @var $view SPAdmView */
     //		header( 'Cache-Control: no-cache, must-revalidate' );
     //		header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
     SPFactory::View('view', true)->assign(SPRequest::int('init'), 'init')->addHidden($home, 'redirect')->determineTemplate('config', 'requirements')->display();
 }
Exemple #24
0
 /**
  */
 private function editForm()
 {
     if ($this->_task != 'add') {
         $sid = SPRequest::sid();
         $sid = $sid ? $sid : SPRequest::int('pid');
     } else {
         $this->authorise($this->_task, 'own');
         $this->_model = null;
         $sid = SPRequest::int('pid');
         //			$section = SPFactory::Section( Sobi::Section() );
     }
     if ($this->_model && $this->_model->isCheckedOut()) {
         Sobi::Redirect(Sobi::Url(array('sid' => SPRequest::sid())), Sobi::Txt('EN.IS_CHECKED_OUT', $this->_model->get('name')), SPC::ERROR_MSG, true);
     }
     /* determine template package */
     $tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE);
     /* load template config */
     $this->template();
     $this->tplCfg($tplPackage);
     /* check if we have stored last edit in cache */
     $this->getCache(SPRequest::string('editentry', null, false, 'cookie'), 'editcache');
     $section = SPFactory::Model('section');
     $section->init(Sobi::Section());
     SPFactory::cache()->setJoomlaCaching(false);
     if ($this->_model) {
         /* handle meta data */
         SPFactory::header()->objMeta($this->_model);
         /* add pathway */
         SPFactory::mainframe()->addObjToPathway($this->_model);
     } else {
         /* handle meta data */
         SPFactory::header()->objMeta($section);
         if ($this->_task == 'add') {
             SPFactory::header()->addKeyword($section->get('efMetaKeys'))->addDescription($section->get('efMetaDesc'));
         }
         SPFactory::mainframe()->addToPathway(Sobi::Txt('EN.ADD_PATH_TITLE'), Sobi::Url('current'));
         SPFactory::mainframe()->setTitle(Sobi::Txt('EN.ADD_TITLE', array('section' => $section->get('name'))));
         /* add pathway */
         SPFactory::mainframe()->addObjToPathway($section);
         $this->setModel(SPLoader::loadModel('entry'));
     }
     $this->_model->formatDatesToEdit();
     $id = $this->_model->get('id');
     if (!$id) {
         $this->_model->set('state', 1);
     }
     if ($this->_task != 'add' && !$this->authorise($this->_task, $this->_model->get('owner') == Sobi::My('id') ? 'own' : '*')) {
         throw new SPException(SPLang::e('YOU_ARE_NOT_AUTH_TO_EDIT_THIS_ENTRY'));
     }
     $this->_model->loadFields(Sobi::Reg('current_section'));
     /* get fields for this section */
     $fields = $this->_model->get('fields');
     if (!count($fields)) {
         throw new SPException(SPLang::e('CANNOT_GET_FIELDS_IN_SECTION', Sobi::Reg('current_section')));
     }
     /* create the validation script to check if required fields are filled in and the filters, if any, match */
     $this->createValidationScript($fields);
     /* check out the model */
     $this->_model->checkOut();
     $class = SPLoader::loadView('entry');
     $view = new $class($this->template);
     $view->assign($this->_model, 'entry');
     $cache = Sobi::Reg('editcache');
     /* get the categories */
     if (isset($cache) && isset($cache['entry_parent'])) {
         $cats = explode(',', $cache['entry_parent']);
     } else {
         $cats = $this->_model->getCategories(true);
     }
     if (count($cats)) {
         $tCats = array();
         foreach ($cats as $cid) {
             $tCats2 = SPFactory::config()->getParentPath((int) $cid, true);
             if (is_array($tCats2) && count($tCats2)) {
                 $tCats[] = implode(Sobi::Cfg('string.path_separator', ' > '), $tCats2);
             }
         }
         if (count($tCats)) {
             $view->assign(implode("\n", $tCats), 'parent_path');
         }
         $view->assign(implode(", ", $cats), 'parents');
     } else {
         $parent = $sid == Sobi::Reg('current_section') ? 0 : $sid;
         if ($parent) {
             $view->assign(implode(Sobi::Cfg('string.path_separator', ' > '), SPFactory::config()->getParentPath($parent, true)), 'parent_path');
         }
         $view->assign($parent, 'parents');
     }
     $view->assign($this->_task, 'task');
     $view->assign($fields, 'fields');
     $view->assign($id, 'id');
     $view->assign($id, 'sid');
     $view->assign(SPFactory::user()->getCurrent(), 'visitor');
     $view->setConfig($this->_tCfg, $this->template);
     $view->setTemplate($tplPackage . '.' . $this->templateType . '.' . ($this->template == 'add' ? 'edit' : $this->template));
     $view->addHidden($sid ? $sid : SPRequest::sid(), 'pid');
     $view->addHidden($id, 'sid');
     $view->addHidden(SPRequest::int('pid') && SPRequest::int('pid') != $id ? SPRequest::int('pid') : Sobi::Section(), 'pid');
     $view->addHidden('entry.submit', SOBI_TASK);
     Sobi::Trigger($this->name(), __FUNCTION__, array(&$view));
     $view->display();
 }
Exemple #25
0
 /**
  * Creating array of additional variables depend on the CMS
  * @internal param array $var
  * @return string
  */
 public function form()
 {
     return array('option' => 'com_sobipro', 'Itemid' => SPRequest::int('Itemid'));
 }
Exemple #26
0
 /**
  */
 protected function view($allEntries, $term = null)
 {
     if ($allEntries) {
         SPRequest::set('task', 'section.entries');
     } else {
         SPRequest::set('task', 'section.view');
     }
     /* @var SPdb $db */
     $db = SPFactory::db();
     $c = array();
     $e = array();
     if (!Sobi::Section()) {
         Sobi::Error('Section', SPLang::e('Missing section identifier'), SPC::ERROR, 500, __LINE__, __FILE__);
     }
     $this->_model->init(Sobi::Section());
     /* get the lists ordering and limits */
     $eLimit = Sobi::GetUserState('entries.limit', 'elimit', Sobi::Cfg('admin.entries-limit', 25));
     $cLimit = Sobi::GetUserState('categories.limit', 'climit', Sobi::Cfg('admin.categories-limit', 15));
     $eLimStart = SPRequest::int('eSite', 0);
     $cLimStart = SPRequest::int('cSite', 0);
     /* get child categories and entries */
     /* @todo: need better method - the query can be very large with lot of entries */
     if (!$allEntries) {
         $e = $this->_model->getChilds();
         $c = $this->_model->getChilds('category');
     } elseif (!($term && $allEntries)) {
         $c = $this->_model->getChilds('category', true);
         $c[] = Sobi::Section();
         if (count($c)) {
             try {
                 $e1 = $db->dselect('id', 'spdb_relations', array('pid' => $c, 'oType' => 'entry'))->loadResultArray();
                 $e2 = $db->dselect('sid', 'spdb_field_data', array('section' => Sobi::Section(), 'fid' => Sobi::Cfg('entry.name_field')))->loadResultArray();
                 $e = array_merge($e1, $e2);
                 $e = array_unique($e);
             } catch (SPException $x) {
                 Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
             }
         }
     } else {
         try {
             $e = $db->dselect('sid', 'spdb_field_data', array('section' => Sobi::Section(), 'fid' => Sobi::Cfg('entry.name_field'), 'baseData' => "%{$term}%"))->loadResultArray();
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
     }
     // just in case the given site is grater than all existing sites
     $cCount = count($c);
     $cPages = ceil($cCount / $cLimit);
     if ($cLimStart > $cPages) {
         $cLimStart = $cPages;
         SPRequest::set('cSite', $cPages);
     }
     $eCount = count($e);
     $ePages = ceil($eCount / $eLimit);
     if ($eLimStart > $ePages) {
         $eLimStart = $ePages;
         SPRequest::set('eSite', $ePages);
     }
     $entries = array();
     $categories = array();
     /* if there are entries in the root */
     if (count($e)) {
         try {
             $Limit = $eLimit > 0 ? $eLimit : 0;
             $LimStart = $eLimStart ? ($eLimStart - 1) * $eLimit : $eLimStart;
             $eOrder = $this->parseOrdering('entries', 'eorder', 'position.asc', $Limit, $LimStart, $e);
             $results = $db->select('id', 'spdb_object', array('id' => $e, 'oType' => 'entry'), $eOrder, $Limit, $LimStart)->loadResultArray();
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
         foreach ($results as $i => $entry) {
             $entries[$i] = $entry;
         }
     }
     /* if there are categories in the root */
     if (count($c)) {
         try {
             $LimStart = $cLimStart ? ($cLimStart - 1) * $cLimit : $cLimStart;
             $Limit = $cLimit > 0 ? $cLimit : 0;
             $cOrder = $this->parseOrdering('categories', 'corder', 'order.asc', $Limit, $LimStart, $c);
             $results = $db->select('id', 'spdb_object', array('id' => $c, 'oType' => 'category'), $cOrder, $Limit, $LimStart)->loadResultArray();
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
         foreach ($results as $i => $category) {
             $categories[$i] = SPFactory::Category($category);
         }
     }
     /* create menu */
     $mClass = SPLoader::loadClass('views.adm.menu');
     $menu = new $mClass('section.' . $this->_task, Sobi::Section());
     /* load the menu definition */
     $cfg = SPLoader::loadIniFile('etc.adm.section_menu');
     Sobi::Trigger('Create', 'AdmMenu', array(&$cfg));
     if (count($cfg)) {
         foreach ($cfg as $section => $keys) {
             $menu->addSection($section, $keys);
         }
     }
     Sobi::Trigger('AfterCreate', 'AdmMenu', array(&$menu));
     /* create new SigsiuTree */
     $tree = SPLoader::loadClass('mlo.tree');
     $tree = new $tree(Sobi::GetUserState('categories.order', 'corder', 'order.asc'));
     /* set link */
     $tree->setHref(Sobi::Url(array('sid' => '{sid}')));
     $tree->setId('menuTree');
     /* set the task to expand the tree */
     $tree->setTask('category.expand');
     $tree->init(Sobi::Reg('current_section'));
     /* add the tree into the menu */
     $menu->addCustom('AMN.ENT_CAT', $tree->getTree());
     $entriesName = SPFactory::config()->nameField()->get('name');
     $entriesField = SPFactory::config()->nameField()->get('nid');
     $view = SPFactory::View('section', true);
     $view->assign($entriesName, 'entries_name')->assign($entriesField, 'entries_field')->assign($eLimit, 'entries-limit')->assign($cLimit, 'categories-limit')->assign(SPRequest::int('eSite', 1), 'entries-site')->assign(SPRequest::int('cSite', 1), 'categories-site')->assign($cCount, 'categories-count')->assign($eCount, 'entries-count')->assign($this->_task, 'task')->assign($term, 'filter')->assign($this->customCols(), 'fields')->assign($this->_model, 'section')->assign($categories, 'categories')->assign($entries, 'entries')->assign(SPFactory::config()->nameField()->get('name'), 'entries_name')->assign($menu, 'menu')->assign(Sobi::GetUserState('entries.eorder', 'eorder', 'order.asc'), 'ordering')->assign(Sobi::GetUserState('categories.corder', 'corder', 'order.asc'), 'corder')->assign(Sobi::Section(true), 'category')->addHidden(Sobi::Section(), 'pid')->addHidden(SPRequest::sid(), 'sid');
     Sobi::Trigger('Section', 'View', array(&$view));
     $view->display();
 }
Exemple #27
0
 /**
  */
 private function edit()
 {
     $rid = SPRequest::int('rid');
     SPLoader::loadClass('cms.base.users');
     $db = SPFactory::db();
     try {
         $sections = $db->select('*', 'spdb_object', array('oType' => 'section'))->loadObjectList();
         $admPermissions = $db->select('*', 'spdb_permissions', array('site' => 'adm', 'published' => 1))->loadObjectList();
         $frontPermissions = $db->select('*', 'spdb_permissions', array('site' => 'front', 'published' => 1))->loadObjectList();
     } catch (SPException $x) {
         Sobi::Error('ACL', SPLang::e('Db reports %s.', $x->getMessage()), SPC::WARNING, 500, __LINE__, __FILE__);
     }
     /** @var $view SPAclView */
     $view = SPFactory::View('acl', true);
     $view->assign($this->_task, 'task');
     $view->assign($sections, 'sections');
     $view->assign($admPermissions, 'adm_permissions');
     $view->assign($frontPermissions, 'permissions');
     if ($rid) {
         try {
             $rule = $db->select('*', 'spdb_permissions_rules', array('rid' => $rid))->loadAssocList('rid');
             $rule = $rule[$rid];
             if ($rule['validSince'] == $db->getNullDate()) {
                 $rule['validSince'] = null;
             }
             if ($rule['validUntil'] == $db->getNullDate()) {
                 $rule['validUntil'] = null;
             }
             $view->assign($rule['name'], 'rule');
             $rule['groups'] = $db->select('gid', 'spdb_permissions_groups', array('rid' => $rid))->loadResultArray();
             $rule['permissions'] = $db->select('*', 'spdb_permissions_map', array('rid' => $rid))->loadAssocList();
             $view->assign($rule, 'set');
         } catch (SPException $x) {
             Sobi::Error('ACL', SPLang::e('Db reports %s.', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
     } else {
         $rule = array('validUntil' => $db->getNullDate(), 'validSince' => $db->getNullDate(), 'name' => '', 'nid' => '', 'note' => '', 'permissions' => array());
         $view->assign($rule, 'set');
     }
     $userGroups = $this->userGroups();
     $view->assign($userGroups, 'groups');
     $view->display();
 }
Exemple #28
0
    /**
     */
    private function editForm()
    {
        $sid = SPRequest::int('pid');
        $sid = $sid ? $sid : SPRequest::sid();
        $view = SPFactory::View('entry', true);
        $this->checkTranslation();
        /* if adding new */
        if (!$this->_model) {
            $this->setModel(SPLoader::loadModel('entry'));
        }
        $this->_model->formatDatesToEdit();
        $id = $this->_model->get('id');
        if (!$id) {
            $this->_model->set('state', 1);
            $this->_model->set('approved', 1);
        } else {
            $view->assign($view->languages(), 'languages-list');
        }
        $this->_model->loadFields(Sobi::Reg('current_section'), true);
        $this->_model->formatDatesToEdit();
        if ($this->_model->isCheckedOut()) {
            SPFactory::message()->error(Sobi::Txt('EN.IS_CHECKED_OUT', $this->_model->get('name')), false);
        } else {
            /* check out the model */
            $this->_model->checkOut();
        }
        /* get fields for this section */
        /* @var SPEntry $this ->_model */
        $fields = $this->_model->get('fields');
        if (!count($fields)) {
            throw new SPException(SPLang::e('CANNOT_GET_FIELDS_IN_SECTION', Sobi::Reg('current_section')));
        }
        $revisionChange = false;
        $rev = SPRequest::cmd('revision');
        $revisionsDelta = array();
        if ($rev) {
            $revision = SPFactory::message()->getRevision(SPRequest::cmd('revision'));
            if (isset($revision['changes']) && count($revision['changes'])) {
                SPFactory::message()->warning(Sobi::Txt('HISTORY_REVISION_WARNING', $revision['changedAt']), false);
                foreach ($fields as $i => $field) {
                    if ($field->get('enabled') && $field->enabled('form')) {
                        if (isset($revision['changes']['fields'][$field->get('nid')])) {
                            $revisionData = $revision['changes']['fields'][$field->get('nid')];
                        } else {
                            $revisionData = null;
                        }
                        $currentData = $field->getRaw();
                        if (is_array($revisionData) && !is_array($currentData)) {
                            try {
                                $currentData = SPConfig::unserialize($currentData);
                            } catch (SPException $x) {
                            }
                        }
                        if ($revisionData || $currentData) {
                            if (md5(serialize($currentData)) != md5(serialize($revisionData))) {
                                $field->revisionChanged()->setRawData($revisionData);
                            }
                        }
                        $fields[$i] = $field;
                    }
                }
                unset($revision['changes']['fields']);
                foreach ($revision['changes'] as $attr => $value) {
                    if ($value != $this->_model->get($attr)) {
                        $revisionsDelta[$attr] = $value;
                        $this->_model->setRevData($attr, $value);
                    }
                }
                $revisionChange = true;
            } else {
                SPFactory::message()->error(Sobi::Txt('HISTORY_REVISION_NOT_FOUND'), false)->setSystemMessage();
            }
        }
        $f = array();
        foreach ($fields as $field) {
            if ($field->get('enabled') && $field->enabled('form')) {
                $f[] = $field;
            }
        }
        /* create the validation script to check if required fields are filled in and the filters, if any, match */
        $this->createValidationScript($fields);
        $view->assign($this->_model, 'entry');
        /* get the categories */
        $cats = $this->_model->getCategories(true);
        if (count($cats)) {
            $tCats = array();
            foreach ($cats as $cid) {
                /* ROTFL ... damn I like arrays ;-) */
                $tCats2 = SPFactory::config()->getParentPath($cid, true);
                if (is_array($tCats2) && count($tCats2)) {
                    $tCats[] = implode(Sobi::Cfg('string.path_separator'), $tCats2);
                }
            }
            if (count($tCats)) {
                $view->assign(implode("\n", $tCats), 'parent_path');
            }
            $view->assign(implode(", ", $cats), 'parents');
        } elseif ($this->_model->get('valid')) {
            $parent = $sid == Sobi::Reg('current_section') ? 0 : $sid;
            if ($parent) {
                $view->assign(implode(Sobi::Cfg('string.path_separator', ' > '), SPFactory::config()->getParentPath($parent, true)), 'parent_path');
            }
            $view->assign($parent, 'parents');
        } else {
            $n = null;
            $view->assign($n, 'parents');
            $view->assign($n, 'parent_path');
        }
        $history = array();
        $messages = SPFactory::message()->getHistory($id);
        if (count($messages)) {
            foreach ($messages as $message) {
                $message['change'] = Sobi::Txt('HISTORY_CHANGE_TYPE_' . str_replace('-', '_', strtoupper($message['change'])));
                $message['site'] = Sobi::Txt('HISTORY_CHANGE_AREA_' . strtoupper($message['site']));
                if (strlen($message['reason'])) {
                    $message['status'] = 1;
                } else {
                    $message['status'] = 0;
                }
                $history[] = $message;
            }
        }
        $versioningAdminBehaviour = Sobi::Cfg('entry.versioningAdminBehaviour', 1);
        if ($versioningAdminBehaviour || !Sobi::Cfg('entry.versioning', true)) {
            SPFactory::header()->addJsCode('
				SobiPro.jQuery( document ).ready( function () { SobiPro.jQuery( "[rel=\'entry.saveWithRevision\']" ).parent().css( "display", "none" ); } );
			');
        }
        $view->assign($this->_task, 'task')->assign($f, 'fields')->assign($id, 'id')->assign($history, 'history')->assign($revisionChange, 'revision-change')->assign($revisionsDelta, 'revision')->assign($versioningAdminBehaviour, 'history-behaviour')->assign(SPFactory::CmsHelper()->userSelect('entry.owner', $this->_model->get('owner') ? $this->_model->get('owner') : ($this->_model->get('id') ? 0 : Sobi::My('id')), true), 'owner')->assign(Sobi::Reg('current_section'), 'sid')->determineTemplate('entry', 'edit')->addHidden($rev, 'revision')->addHidden($sid, 'pid');
        $view->display();
    }
Exemple #29
0
 /**
  * @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 = "&nbsp;<img src=\"{$ico}\"/>&nbsp;";
                         $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 = "&nbsp;<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 = "&nbsp;<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 = "&nbsp;<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 = "&nbsp;<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 = "&nbsp;<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 = "&nbsp;<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>&nbsp;{$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;
 }
Exemple #30
0
 /**
  * @param SPEntry $entry
  * @param string $request
  * @throws SPException
  * @return string
  * @throw SPException
  */
 private function verify($entry, $request)
 {
     $data = SPRequest::arr($this->nid, array(), $request);
     if (!$data) {
         $dataString = SPRequest::string($this->nid, null, false, $request);
         if (strstr($dataString, '://')) {
             $data = SPFactory::config()->structuralData($dataString);
         } else {
             $dataString = SPRequest::int($this->nid, 0, $request);
             if ($dataString) {
                 $data = array($dataString);
             }
         }
     } else {
         if (count($data) > $this->catsMaxLimit && count($data) > 1) {
             $data = array_slice($data, 0, $this->catsMaxLimit);
         }
     }
     $dexs = count($data);
     /* check if it was required */
     if ($this->required && !$dexs && $this->method != 'fixed') {
         throw new SPException(SPLang::e('FIELD_REQUIRED_ERR', $this->name));
     }
     /* check if there was an adminField */
     if ($this->adminField && $dexs && $this->method != 'fixed') {
         if (!Sobi::Can('entry.adm_fields.edit')) {
             throw new SPException(SPLang::e('FIELD_NOT_AUTH', $this->name));
         }
     }
     /* check if it was free */
     if (!$this->isFree && $this->fee && $dexs) {
         SPFactory::payment()->add($this->fee, $this->name, $entry->get('id'), $this->fid);
     }
     /* check if it was editLimit */
     if ($this->editLimit == 0 && !Sobi::Can('entry.adm_fields.edit') && $dexs) {
         throw new SPException(SPLang::e('FIELD_NOT_AUTH_EXP', $this->name));
     }
     /* check if it was editable */
     if (!$this->editable && !Sobi::Can('entry.adm_fields.edit') && $dexs && $entry->get('version') > 1) {
         throw new SPException(SPLang::e('FIELD_NOT_AUTH_NOT_ED', $this->name));
     }
     if (!$dexs) {
         $data = array();
     }
     $this->setData($data);
     return $data;
 }