Exemplo n.º 1
0
 /**
  */
 public function execute()
 {
     switch ($this->_task) {
         case 'add':
             $this->setModel(SPLoader::loadModel('section'));
             $this->editForm();
             break;
         case 'edit':
             Sobi::Redirect(Sobi::Url(array('task' => 'config', 'sid' => SPRequest::sid())), null, true);
             break;
         case 'view':
         case 'entries':
             Sobi::ReturnPoint();
             $this->view($this->_task == 'entries', Sobi::GetUserState('entries_filter', 'sp_entries_filter', null));
             break;
         case 'toggle.enabled':
         case 'toggle.approval':
             $this->toggleState();
             break;
         default:
             /* case plugin didn't register this task, it was an error */
             if (!parent::execute()) {
                 Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
             }
             break;
     }
 }
Exemplo n.º 2
0
 public function execute()
 {
     $this->_task = strlen($this->_task) ? $this->_task : $this->_defTask;
     switch ($this->_task) {
         case 'list':
             $this->screen();
             Sobi::ReturnPoint();
             break;
         case 'edit':
         case 'add':
             $this->edit();
             break;
         case 'delete':
             $this->delete();
             break;
         case 'save':
             $this->save();
             break;
         default:
             /* case plugin didn't registered this task, it was an error */
             if (!parent::execute()) {
                 Sobi::Error('filter_ctrl', 'Task not found', SPC::WARNING, 404, __LINE__, __FILE__);
             }
             break;
     }
 }
Exemplo n.º 3
0
 public function execute()
 {
     $this->_task = strlen($this->_task) ? $this->_task : $this->_defTask;
     switch ($this->_task) {
         case 'list':
             $this->screen();
             Sobi::ReturnPoint();
             break;
         case 'purge':
             $this->purge();
             break;
         case 'download':
             $this->download();
             break;
         case 'details':
             $this->details();
             break;
         default:
             /* case plugin didn't registered this task, it was an error */
             if (!parent::execute()) {
                 Sobi::Error('error_ctrl', 'Task not found', SPC::WARNING, 404, __LINE__, __FILE__);
             }
             break;
     }
 }
Exemplo n.º 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);
 }
Exemplo n.º 5
0
 public function execute()
 {
     $this->_task = strlen($this->_task) ? $this->_task : $this->_defTask;
     switch ($this->_task) {
         case 'config':
             $this->screen();
             Sobi::ReturnPoint();
             break;
         case 'save':
             $this->save();
             break;
         default:
             Sobi::Error('SPPaymentBt', 'Task not found', SPC::NOTICE, 404, __LINE__, __FILE__);
             break;
     }
 }
Exemplo n.º 6
0
 /**
  */
 public function execute()
 {
     $this->_task = strlen($this->_task) ? $this->_task : $this->_defTask;
     switch ($this->_task) {
         case 'edit':
             $this->editFile();
             Sobi::ReturnPoint();
             break;
         case 'save':
         case 'saveAs':
         case 'compileSave':
             $this->save($this->_task == 'saveAs', $this->_task == 'compileSave');
             break;
         case 'info':
             $this->info();
             break;
         case 'deleteFile':
             $this->deleteFile();
             break;
         case 'delete':
             $this->delete();
             break;
         case 'compile':
             $this->compile();
             break;
         case 'clone':
             $this->cloneTpl();
             break;
         case 'list':
             $this->getTemplateFiles();
             break;
         case 'settings':
             $this->templateSettings();
             break;
         case 'saveConfig':
             $this->saveConfig();
             break;
         default:
             /* case plugin didn't registered this task, it was an error */
             if (!parent::execute()) {
                 Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
             }
             break;
     }
 }
Exemplo n.º 7
0
 /**
  */
 public function execute()
 {
     $r = false;
     SPRequest::set('task', $this->_type . '.' . $this->_task);
     switch ($this->_task) {
         case 'edit':
         case 'add':
             Sobi::ReturnPoint();
             SPLoader::loadClass('html.input');
             $this->editForm();
             break;
         case 'approve':
         case 'unapprove':
             $r = true;
             $this->approve($this->_task == 'approve');
             break;
         case 'publish':
         case 'unpublish':
         case 'hide':
             $r = true;
             $this->state($this->_task == 'publish');
             break;
         case 'submit':
             $this->submit();
             break;
         case 'details':
             $this->visible();
             $this->details();
             Sobi::ReturnPoint();
             break;
         case 'payment':
             $this->payment();
             break;
         default:
             if (!parent::execute()) {
                 Sobi::Error('entry_ctrl', SPLang::e('TASK_NOT_FOUND'), SPC::NOTICE, 404, __LINE__, $this->name());
             } else {
                 $r = true;
             }
             break;
     }
     return $r;
 }
Exemplo n.º 8
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();
 }
Exemplo n.º 9
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();
 }
Exemplo n.º 10
0
 /**
  * @return bool
  */
 protected function view()
 {
     Sobi::ReturnPoint();
     /** @var $view SPAdmView */
     $view = $this->getView('config.' . $this->_task);
     $view->setCtrl($this);
     $IP = SPRequest::ip('REMOTE_ADDR', 0, 'SERVER');
     if ($this->_task == 'general') {
         $this->checkTranslation();
         $fields = $this->getNameFields();
         $nameFields = array();
         if (count($fields)) {
             foreach ($fields as $field) {
                 $nameFields[$field->get('fid')] = $field->get('name');
             }
         }
         $alphaFields = array();
         $fields = $this->getNameFields(true, Sobi::Cfg('alphamenu.field_types'));
         if (count($fields)) {
             if (count($fields)) {
                 foreach ($fields as $field) {
                     $alphaFields[$field->get('fid')] = $field->get('name');
                 }
             }
         }
         $templateList = $view->templatesList();
         $entriesOrdering = $view->namesFields(null, true);
         $view->assign($nameFields, 'nameFields');
         $view->assign($templateList, 'templatesList');
         $view->assign($entriesOrdering, 'entriesOrdering');
         $view->assign($alphaFields, 'alphaMenuFields');
         $view->assign($view->languages(), 'languages-list');
     }
     $view->addHidden($IP, 'current-ip');
     Sobi::Trigger($this->_task, $this->name(), array(&$view));
     $view->determineTemplate('config', $this->_task);
     $view->display();
     Sobi::Trigger('After' . ucfirst($this->_task), $this->name(), array(&$view));
     return true;
 }
Exemplo n.º 11
0
 /**
  * @return void
  */
 private function frontpage()
 {
     SPLoader::loadController('front', true);
     $this->setController(new SPAdminPanel());
     Sobi::ReturnPoint();
     $this->_ctrl->setTask(SPRequest::task());
 }
Exemplo n.º 12
0
 /**
  */
 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();
 }
Exemplo n.º 13
0
 private function section()
 {
     Sobi::ReturnPoint();
     /* create menu */
     $menu = SPFactory::Instance('views.adm.menu', 'extensions.manage', Sobi::Section());
     $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 = SPFactory::Instance('mlo.tree');
     /* set link */
     $tree->setHref(Sobi::Url(array('sid' => '{sid}')));
     $tree->setId('menuTree');
     /* set the task to expand the tree */
     $tree->setTask('category.expand');
     $tree->init(Sobi::Section());
     /* add the tree into the menu */
     $menu->addCustom('AMN.ENT_CAT', $tree->getTree());
     /* section model */
     $cSec = SPFactory::Model('section');
     $cSec->init(Sobi::Section());
     $db = SPFactory::db();
     $all = $db->select('*', 'spdb_plugins', array('!type' => Sobi::Cfg('apps.global_types_array'), 'enabled' => 1))->loadAssocList('pid');
     $list = $db->select('*', 'spdb_plugin_section', array('section' => Sobi::Section()))->loadAssocList('pid');
     if (count($all)) {
         foreach ($all as $id => $app) {
             if (isset($list[$id])) {
                 $all[$id]['enabled'] = $list[$id]['enabled'];
                 $all[$id]['position'] = $list[$id]['position'];
             } else {
                 $all[$id]['enabled'] = false;
                 $all[$id]['position'] = 9999;
             }
             $all[$id]['repository'] = null;
         }
     }
     /** @var $view SPExtensionsView */
     $view = SPFactory::View('extensions', true);
     $view->assign($this->_task, 'task')->assign($menu, 'menu')->assign(Sobi::Section(), 'sid')->assign($all, 'applications');
     Sobi::Trigger($this->_task, $this->name(), array(&$view));
     $view->display();
     Sobi::Trigger('After' . ucfirst($this->_task), $this->name(), array(&$view));
 }
Exemplo n.º 14
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();
 }
Exemplo n.º 15
0
 /**
  * List all fields in this section
  */
 private function listFields()
 {
     /* @var SPdb $db */
     $ord = $this->parseOrdering('forder', 'position.asc');
     SPLoader::loadClass('html.input');
     Sobi::ReturnPoint();
     /* create menu */
     $sid = Sobi::Reg('current_section');
     $menu = SPFactory::Instance('views.adm.menu', 'field.list', $sid);
     $cfg = SPLoader::loadIniFile('etc.adm.section_menu');
     Sobi::Trigger('Create', 'AdmMenu', array(&$cfg));
     if (count($cfg)) {
         foreach ($cfg as $section => $keys) {
             $menu->addSection($section, $keys);
         }
     }
     Sobi::Trigger('AfterCreate', 'AdmMenu', array(&$menu));
     /* create new SigsiuTree */
     $tree = SPLoader::loadClass('mlo.tree');
     $tree = new $tree(Sobi::GetUserState('categories.order', 'corder', 'position.asc'));
     /* set link */
     $tree->setHref(Sobi::Url(array('sid' => '{sid}')));
     $tree->setId('menuTree');
     /* set the task to expand the tree */
     $tree->setTask('category.expand');
     $tree->init($sid);
     /* add the tree into the menu */
     $menu->addCustom('AMN.ENT_CAT', $tree->getTree());
     try {
         $results = SPFactory::db()->select('*', 'spdb_field', array('section' => $sid), $ord)->loadObjectList();
     } catch (SPException $x) {
         //			SPConfig::debOut(SPFactory::db()->getQuery());
         Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     $fields = array();
     if (count($results)) {
         foreach ($results as $result) {
             $field = SPFactory::Model('field', true);
             $field->extend($result);
             $fields[] = $field;
         }
     }
     $fieldTypes = $this->getFieldTypes();
     $subMenu = array();
     foreach ($fieldTypes as $type => $group) {
         asort($group);
         $subMenu[] = array('label' => $type, 'element' => 'nav-header');
         foreach ($group as $t => $l) {
             $subMenu[] = array('type' => null, 'task' => 'field.add.' . $t, 'label' => $l, 'icon' => 'tasks', 'element' => 'button');
         }
     }
     SPFactory::View('field', true)->addHidden($sid, 'sid')->assign($fields, 'fields')->assign($subMenu, 'fieldTypes')->assign(Sobi::Section(true), 'section')->assign($menu, 'menu')->assign(Sobi::GetUserState('fields.order', 'forder', 'position.asc'), 'ordering')->assign($this->_task, 'task')->determineTemplate('field', 'list')->display();
 }
Exemplo n.º 16
0
 /**
  */
 public function execute()
 {
     /* parent class executes the plugins */
     $r = false;
     switch ($this->_task) {
         case 'edit':
         case 'add':
             SPLoader::loadClass('html.input');
             $this->editForm();
             break;
         case 'view':
             Sobi::ReturnPoint();
             SPLoader::loadClass('html.input');
             $this->view();
             break;
         case 'clone':
             $r = true;
             $this->_model = null;
             SPRequest::set('category_id', 0, 'post');
             SPRequest::set('category_state', 0, 'post');
             $this->save(false, true);
             break;
         case 'reorder':
             $r = true;
             $this->reorder();
             break;
         case 'up':
         case 'down':
             $r = true;
             $this->singleReorder($this->_task == 'up');
             break;
         case 'approve':
         case 'unapprove':
             $r = true;
             $this->approval($this->_task == 'approve');
             break;
         case 'hide':
         case 'publish':
             $r = true;
             $this->state($this->_task == 'publish');
             break;
         case 'toggle.enabled':
         case 'toggle.approval':
             $r = true;
             $this->toggleState();
             break;
         case 'delete':
             /** Wed, Jan 15, 2014 11:05:28
              * in the administrator are we can delete category only from the list
              * Preventing deletion of THIS category (Issue #1162)
              * Basically if there was no array of $cids something went wrong
              */
             $cids = SPRequest::arr('c_sid', array());
             if (count($cids)) {
                 parent::execute();
             } else {
                 $this->response(Sobi::Back(), SPLang::e('DELETE_CAT_NO_ID'), false, SPC::ERROR_MSG);
             }
             break;
         default:
             /* case plugin didn't registered this task, it was an error */
             if (!parent::execute()) {
                 Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
             }
             break;
     }
     return $r;
 }