Exemplo n.º 1
0
 public function display($tpl = null)
 {
     // version prefix
     $this->joomlaVersionPrefix = Sh404sefHelperGeneral::getJoomlaVersionPrefix();
     // get model and update context with current
     $model = ShlMvcModel_Base::getInstance('urls', 'Sh404sefModel');
     $context = $model->setContext($this->_context . '.' . $this->getLayout());
     // display type: simple for very large sites/slow slq servers
     $sefConfig = Sh404sefFactory::getConfig();
     // store it
     $model = $this->setModel($model, true);
     // read data from model
     $list = $model->getList((object) array('layout' => $this->getLayout(), 'getMetaData' => true, 'simpleUrlList' => true, 'slowServer' => $sefConfig->slowServer));
     // and push it into the view for display
     $this->assign('items', $list);
     $this->assign('itemCount', count($this->items));
     $this->assign('contentcs', Sh404sefHelperGeneral::getDataMD5($this->items, array('metatitle', 'metadesc')));
     $this->assign('pagination', $model->getPagination((object) array('layout' => $this->getLayout(), 'simpleUrlList' => true, 'slowServer' => $sefConfig->slowServer)));
     $options = $model->getDisplayOptions();
     $this->assign('options', $options);
     $this->assign('helpMessage', JText::_('COM_SH404SEF_META_HELP'));
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $document = JFactory::getDocument();
         // add our own css and js
         JHtml::styleSheet(Sh404sefHelperGeneral::getComponentUrl() . '/assets/css/' . $this->joomlaVersionPrefix . '_list.css');
         JHtml::script(Sh404sefHelperGeneral::getComponentUrl() . '/assets/js/shajax.js');
         JHtml::script(Sh404sefHelperGeneral::getComponentUrl() . '/assets/js/j3.js');
         // add modal css and js
         ShlHtmlBs_helper::addBootstrapCss(JFactory::getDocument());
         ShlHtmlBs_helper::addBootstrapJs(JFactory::getDocument());
         // variable for modal, not used in 3..x+
         $params = array();
         $this->_addFilters();
         // render submenu sidebar
         $this->sidebar = Sh404sefHelperHtml::renderSubmenu();
     } else {
         // add our own css
         JHtml::styleSheet(Sh404sefHelperGeneral::getComponentUrl() . '/assets/css/' . $this->joomlaVersionPrefix . '_urls.css');
         // link to  custom javascript
         JHtml::script(Sh404sefHelperGeneral::getComponentUrl() . '/assets/js/list.js');
         JHtml::script(Sh404sefHelperGeneral::getComponentUrl() . '/assets/js/metas.js');
         // add behaviors and styles as needed
         $modalSelector = 'a.modalediturl';
         $js = '\\function(){window.parent.shAlreadySqueezed = false;if(window.parent.shReloadModal) {parent.window.location=\'' . $this->defaultRedirectUrl . '\';window.parent.shReloadModal=true}}';
         $params = array('overlayOpacity' => 0, 'classWindow' => 'sh404sef-popup', 'classOverlay' => 'sh404sef-popup', 'onClose' => $js);
         Sh404sefHelperHtml::modal($modalSelector, $params);
         $this->assign('optionsSelect', $this->_makeOptionsSelect($options));
         // add our own css
         JHtml::styleSheet(Sh404sefHelperGeneral::getComponentUrl() . '/assets/css/list.css');
     }
     // build the toolbar
     $toolbarMethod = '_makeToolbar' . ucfirst($this->getLayout() . ucfirst($this->joomlaVersionPrefix));
     if (is_callable(array($this, $toolbarMethod))) {
         $this->{$toolbarMethod}($params);
     }
     // now display normally
     parent::display($this->joomlaVersionPrefix);
 }
Exemplo n.º 2
0
 /**
  * Save a list of meta data as edited by
  * user in backend
  */
 public function save()
 {
     // first check if anything was modified
     $originalMd5 = JRequest::getString('contentcs');
     $dataSet = array();
     $ids = JRequest::getVar('metaid', array(0), 'post', 'array');
     $titles = JRequest::getVar('metatitle', array(), 'post', 'array');
     $descs = JRequest::getVar('metadesc', array(), 'post', 'array');
     $newurls = JRequest::getVar('newurls', array(), 'post', 'array');
     // calculate md5 of incoming data and compare to stored value
     foreach ($ids as $id => $value) {
         $t = array();
         $t['meta_id'] = $value;
         $t['metatitle'] = $titles[$id];
         $t['metadesc'] = $descs[$id];
         $t['newurl'] = $newurls[$id];
         $dataSet[] = $t;
     }
     $newMd5 = Sh404sefHelperGeneral::getDataMD5($dataSet, array('metatitle', 'metadesc'), $asObject = false);
     $dataModified = $originalMd5 != $newMd5;
     // if nothing changed, display message and return to meta data list
     if ($dataModified) {
         // we did change something, ask model to save it
         $model = $this->getModel('metas', 'Sh404sefModel');
         $model->saveSet($dataSet);
         // check errors and display if not ajax call
         $error = $model->getError();
         if (!empty($error)) {
             $this->setError($error);
         }
     } else {
         // did not change data, display that
         $this->setError(JText::_('COM_SH404SEF_DATA_NOT_MODIFIED'));
     }
     // check if ajax call, we'll return differently
     $isAjax = JRequest::getInt('shajax') == 1;
     // finally return
     if ($isAjax) {
         // ajax : send xml response
         $this->display();
     } else {
         // not ajax, enqueue message and go back to list
         $this->enqueuemessages(array($error), 'error');
         $this->setRedirect($this->_getDefaultRedirect());
     }
 }
Exemplo n.º 3
0
 public function display($tpl = null)
 {
     // get model and update context with current
     $model =& JModel::getInstance('urls', 'Sh404sefModel');
     $context = $model->setContext($this->_context . '.' . $this->getLayout());
     // display type: simple for very large sites/slow slq servers
     $sefConfig =& shRouter::shGetConfig();
     // store it
     $model =& $this->setModel($model, true);
     // read data from model
     $list =& $model->getList((object) array('layout' => $this->getLayout(), 'getMetaData' => true, 'simpleUrlList' => true, 'slowServer' => $sefConfig->slowServer));
     // and push it into the view for display
     $this->assign('items', $list);
     $this->assign('itemCount', count($this->items));
     $this->assign('contentcs', Sh404sefHelperGeneral::getDataMD5($this->items, array('metatitle', 'metadesc')));
     $this->assign('pagination', $model->getPagination((object) array('layout' => $this->getLayout(), 'simpleUrlList' => true, 'slowServer' => $sefConfig->slowServer)));
     $options = $model->getDisplayOptions();
     $this->assign('options', $options);
     $this->assign('optionsSelect', $this->_makeOptionsSelect($options));
     $this->assign('helpMessage', JText16::_('COM_SH404SEF_META_HELP'));
     // add behaviors and styles as needed
     $modalSelector = 'a.modalediturl';
     $js = '\\function(){shAlreadySqueezed = false;if(parent.shReloadModal) {parent.window.location=\'' . $this->defaultRedirectUrl . '\';parent.shReloadModal=true}}';
     $params = array('overlayOpacity' => 0, 'classWindow' => 'sh404sef-popup', 'classOverlay' => 'sh404sef-popup', 'onClose' => $js);
     Sh404sefHelperHtml::modal($modalSelector, $params);
     // build the toolbar
     $toolbarMethod = '_makeToolbar' . ucfirst($this->getLayout());
     if (is_callable(array($this, $toolbarMethod))) {
         $this->{$toolbarMethod}($params);
     }
     // add our own css
     JHtml::styleSheet('list.css', Sh404sefHelperGeneral::getComponentUrl() . '/assets/css/');
     // link to  custom javascript
     JHtml::script('list.js', Sh404sefHelperGeneral::getComponentUrl() . '/assets/js/');
     JHtml::script('metas.js', Sh404sefHelperGeneral::getComponentUrl() . '/assets/js/');
     // now display normally
     parent::display($tpl);
 }