示例#1
0
 /**
  * Create toolbar for default layout view
  *
  * @param midxed $params
  */
 private function _makeToolbarDefault($params = null)
 {
     global $mainframe;
     // Get the JComponent instance of JToolBar
     $bar =& JToolBar::getInstance('toolbar');
     // add title
     $title = Sh404sefHelperGeneral::makeToolbarTitle(JText16::_('COM_SH404SEF_PAGEIDS_MANAGER'), $icon = 'sh404sef', $class = 'sh404sef-toolbar-title');
     $mainframe->set('JComponentTitle', $title);
     // get toolbar object
     $bar =& JToolBar::getInstance('toolbar');
     $bar->addButtonPath(JPATH_COMPONENT . DS . 'classes');
     // add import button
     $params['class'] = 'modaltoolbar';
     $params['size'] = array('x' => 500, 'y' => 400);
     unset($params['onClose']);
     $url = 'index.php?option=com_sh404sef&c=wizard&task=start&tmpl=component&optype=import&opsubject=pageids';
     $bar->appendButton('Shpopuptoolbarbutton', 'import', $url, JText::_('Import'), $msg = '', $task = 'import', $list = false, $hidemenu = true, $params);
     // add import button
     $params['class'] = 'modaltoolbar';
     $params['size'] = array('x' => 500, 'y' => 300);
     unset($params['onClose']);
     $url = 'index.php?option=com_sh404sef&c=wizard&task=start&tmpl=component&optype=export&opsubject=pageids';
     $bar->appendButton('Shpopuptoolbarbutton', 'export', $url, JText::_('Export'), $msg = '', $task = 'export', $list = false, $hidemenu = true, $params);
     // separator
     JToolBarHelper::divider();
     // add delete button as an ajax call
     $params['class'] = 'modaltoolbar';
     $params['size'] = array('x' => 500, 'y' => 300);
     unset($params['onClose']);
     $url = 'index.php?option=com_sh404sef&c=pageids&task=confirmdelete&tmpl=component';
     $bar->appendButton('Shpopuptoolbarbutton', 'delete', $url, JText::_('Delete'), $msg = JText::_('VALIDDELETEITEMS', true), $task = 'purgeselected', $list = true, $hidemenu = true, $params);
     // separator
     JToolBarHelper::divider();
 }
示例#2
0
 /**
  * Attach css, js and create toolbar for Info view
  *
  * @param midxed $params
  */
 private function _makeViewInfo($params = null)
 {
     global $mainframe;
     // add our own css
     JHtml::styleSheet('list.css', Sh404sefHelperGeneral::getComponentUrl() . '/assets/css/');
     // add title
     $title = Sh404sefHelperGeneral::makeToolbarTitle(JText16::_('COM_SH404SEF_TITLE_SUPPORT'), $icon = 'sh404sef', $class = 'sh404sef-toolbar-title');
     $mainframe->set('JComponentTitle', $title);
 }
示例#3
0
 private function _doDefault($tpl)
 {
     // declare docoument mime type
     $document =& JFactory::getDocument();
     $document->setMimeEncoding('text/xml');
     // call helper to prepare response xml file content
     $response = Sh404sefHelperGeneral::prepareAjaxResponse($this);
     // echo it
     echo $response;
 }
示例#4
0
 public function display($tpl = null)
 {
     // declare docoument mime type
     $document = JFactory::getDocument();
     $document->setMimeEncoding('text/xml');
     // call helper to prepare response xml file content
     $response = Sh404sefHelperGeneral::prepareAjaxResponse($this);
     // echo it
     echo $response;
 }
示例#5
0
 public function display($tpl = null)
 {
     // version prefix
     $this->joomlaVersionPrefix = Sh404sefHelperGeneral::getJoomlaVersionPrefix();
     // get action
     $this->task = empty($this->task) ? 'delete' : $this->task;
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $document = JFactory::getDocument();
         // add modal css and js
         ShlHtmlBs_helper::addBootstrapCss(JFactory::getDocument());
         ShlHtmlBs_helper::addBootstrapModalFixCss(JFactory::getDocument());
         ShlHtmlBs_helper::addBootstrapJs(JFactory::getDocument());
         JHtml::styleSheet(Sh404sefHelperGeneral::getComponentUrl() . '/assets/css/j3_list.css');
         if (!empty($this->redirectTo) && !empty($this->message)) {
             // redirecting to parent page, but there's a message
             // let's enqueue it, so it's displayed after the redirect
             JFactory::getApplication()->enqueueMessage($this->message);
         }
     } else {
         // J2
         // if redirecting to another page, we need to simply send some javascript
         // to : a / close the popup, b / redirect the parent page to where we
         // want to go
         if (!empty($this->redirectTo)) {
             $js = 'window.addEvent( \'domready\', function () {
   setTimeout( \'shRedirectTo()\', 2000);
 });
 function shRedirectTo() {
   parent.window.location="' . $this->redirectTo . '";
   window.parent.SqueezeBox.close();
 }
 ';
             $document = JFactory::getDocument();
             $document->addScriptDeclaration($js);
         } else {
             // build the toolbar
             $toolBar = $this->_makeToolbar();
             $this->assignRef('toolbar', $toolBar);
             // add confirmation phrase to toolbar
             $this->assign('toolbarTitle', '<div class="headerconfirm" >' . JText::_('COM_SH404SEF_CONFIRM_TITLE') . '</div>');
             // link to  custom javascript
             JHtml::script(Sh404sefHelperGeneral::getComponentUrl() . '/assets/js/edit.js');
         }
         // add our own css
         JHtml::styleSheet(Sh404sefHelperGeneral::getComponentUrl() . '/assets/css/confirm.css');
     }
     // now display normally
     parent::display($this->joomlaVersionPrefix);
 }
示例#6
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());
     }
 }
示例#7
0
    public function display($tpl = null)
    {
        // version prefix
        $this->joomlaVersionPrefix = Sh404sefHelperGeneral::getJoomlaVersionPrefix();
        if (version_compare(JVERSION, '3.0', 'ge')) {
            $document = JFactory::getDocument();
            // add modal css and js
            ShlHtmlBs_helper::addBootstrapCss(JFactory::getDocument());
            ShlHtmlBs_helper::addBootstrapModalFixCss(JFactory::getDocument());
            ShlHtmlBs_helper::addBootstrapJs(JFactory::getDocument());
            // build the toolbar
            $this->toolbar = $this->_makeToolbarJ3();
        } else {
            // J2
            // if redirecting to another page, we need to simply send some javascript
            // to : a / close the popup, b / redirect the parent page to where we
            // want to go
            // push a title
            $this->assign('stepTitle', $this->pageTitle);
            if (!empty($this->redirectTo)) {
                $document = JFactory::getDocument();
                if (!empty($this->redirectTo)) {
                    $js = 'window.addEvent( \'domready\', function () {
      setTimeout( \'shRedirectTo()\', 100);
    });
    function shRedirectTo() {
      parent.window.location="' . $this->redirectTo . '";
    }

    ';
                    $document->addScriptDeclaration($js);
                }
            } else {
                // build the toolbar
                $toolbar = $this->_makeToolbarJ2();
                $this->assignRef('toolbar', $toolbar);
                // add our own css
                JHtml::styleSheet(Sh404sefHelperGeneral::getComponentUrl() . '/assets/css/wizard.css');
            }
            // collect any error
            $this->errors = $this->getErrors();
        }
        // now display normally
        parent::display($this->joomlaVersionPrefix);
    }
示例#8
0
 public function display($tpl = null)
 {
     // version prefix
     $this->joomlaVersionPrefix = Sh404sefHelperGeneral::getJoomlaVersionPrefix();
     // prepare the view, based on request
     // do we force reading updates from server ?
     $options = Sh404sefHelperAnalytics::getRequestOptions();
     // push display options into template
     $this->assign('options', $options);
     // call report specific methods to get data
     $method = '_makeView' . ucfirst($options['report']);
     if (is_callable(array($this, $method))) {
         $this->{$method}($tpl);
     }
     // flag to know if we should display placeholder for ajax fillin
     $this->assign('isAjaxTemplate', false);
     parent::display($this->joomlaVersionPrefix);
 }
示例#9
0
 /**
  * Ajax response handler for any configuration dialog
  * except quick control panel
  *
  * @param string $tpl
  */
 private function _doDefault($tpl)
 {
     // use Joomla wml object
     jimport('joomla.utilities.simplexml');
     // prepare elements of respn
     $this->assign('taskexecuted', $this->getLayout());
     $errors = $this->getError();
     $task = JRequest::getCmd('task');
     switch ($task) {
         case 'apply':
             // applying : dialog box not going to be closed
             if (($this->taskexecuted == 'default' || $this->taskexecuted == 'ext') && empty($errors)) {
                 // no errors, insert success messages
                 $this->assign('message', '<li>' . JText16::_('COM_SH404SEF_ELEMENT_SAVED') . '.</li><br /><li>' . JText16::_('COM_SH404SEF_MAY_NEED_PURGE_DIALOGBOX') . '</li>');
             } else {
                 if (empty($errors)) {
                     $this->assign('message', JText16::_('COM_SH404SEF_ELEMENT_SAVED'));
                 }
             }
             break;
         case 'save':
             // box is going to be close, we want to redirect so that message is displayed
             if (($this->taskexecuted == 'default' || $this->taskexecuted == 'ext') && empty($errors)) {
                 // no errors, tell user they must purge urls
                 $messagecode = 'COM_SH404SEF_MAY_NEED_PURGE';
             } else {
                 if (empty($errors)) {
                     // no errors, but no need to purge : seo settings, security settings, etc
                     $messagecode = 'COM_SH404SEF_ELEMENT_SAVED';
                 }
             }
             $this->assign('redirectTo', $this->defaultRedirectUrl);
             $this->assign('messagecode', $messagecode);
             break;
     }
     // use helper to prepare response
     $response = Sh404sefHelperGeneral::prepareAjaxResponse($this);
     // declare docoument mime type
     $document =& JFactory::getDocument();
     $document->setMimeEncoding('text/xml');
     // output resulting text, no need for a layout file I think
     echo $response;
 }
示例#10
0
 public static function updateShurls()
 {
     $pageInfo =& Sh404sefFactory::getPageInfo();
     $sefConfig =& Sh404sefFactory::getConfig();
     $pageInfo->shURL = empty($pageInfo->shURL) ? '' : $pageInfo->shURL;
     if ($sefConfig->enablePageId && !$sefConfig->stopCreatingShurls) {
         try {
             jimport('joomla.utilities.string');
             $nonSefUrl = JString::ltrim($pageInfo->currentNonSefUrl, '/');
             $nonSefUrl = shSortURL($nonSefUrl);
             // make sure we have a language
             $nonSefUrl = shSetURLVar($nonSefUrl, 'lang', $pageInfo->currentLanguageShortTag);
             // remove tracking vars (Google Analytics)
             $nonSefUrl = Sh404sefHelperGeneral::stripTrackingVarsFromNonSef($nonSefUrl);
             // try to get the current shURL, if any
             $shURL = ShlDbHelper::selectResult('#__sh404sef_pageids', array('pageid'), array('newurl' => $nonSefUrl));
             // if none, we may have to create one
             if (empty($shURL)) {
                 $shURL = self::_createShurl($nonSefUrl);
             }
             // insert in head and header, if not empty
             if (!empty($shURL)) {
                 $fullShURL = JString::ltrim($pageInfo->getDefaultFrontLiveSite(), '/') . '/' . $shURL;
                 $document = JFactory::getDocument();
                 if ($sefConfig->insertShortlinkTag) {
                     $document->addHeadLink($fullShURL, 'shortlink');
                     // also add header, especially for HEAD requests
                     JResponse::setHeader('Link', '<' . $fullShURL . '>; rel=shortlink', true);
                 }
                 if ($sefConfig->insertRevCanTag) {
                     $document->addHeadLink($fullShURL, 'canonical', 'rev', array('type' => 'text/html'));
                 }
                 if ($sefConfig->insertAltShorterTag) {
                     $document->addHeadLink($fullShURL, 'alternate shorter');
                 }
                 // store for reuse
                 $pageInfo->shURL = $shURL;
             }
         } catch (Exception $e) {
             ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
         }
     }
 }
示例#11
0
 /**
  * Create toolbar for default layout view
  *
  * @param midxed $params
  */
 private function _makeToolbarDefault($params = null)
 {
     global $mainframe;
     // Get the JComponent instance of JToolBar
     $bar =& JToolBar::getInstance('toolbar');
     // add title
     $title = Sh404sefHelperGeneral::makeToolbarTitle(JText16::_('COM_SH404SEF_META_TAGS'), $icon = 'sh404sef', $class = 'sh404sef-toolbar-title');
     $mainframe->set('JComponentTitle', $title);
     // get toolbar object
     $bar =& JToolBar::getInstance('toolbar');
     $bar->addButtonPath(JPATH_COMPONENT . DS . 'classes');
     // add import button
     $params['class'] = 'modaltoolbar';
     $params['size'] = array('x' => 500, 'y' => 400);
     unset($params['onClose']);
     $url = 'index.php?option=com_sh404sef&c=wizard&task=start&tmpl=component&optype=import&opsubject=urls';
     // importing metas is same as importing urls, as export format is same
     $bar->appendButton('Shpopuptoolbarbutton', 'import', $url, JText::_('Import'), $msg = '', $task = 'import', $list = false, $hidemenu = true, $params);
     // add export button
     $params['class'] = 'modaltoolbar';
     $params['size'] = array('x' => 500, 'y' => 300);
     unset($params['onClose']);
     $url = 'index.php?option=com_sh404sef&c=wizard&task=start&tmpl=component&optype=export&opsubject=metas';
     $bar->appendButton('Shpopuptoolbarbutton', 'export', $url, JText::_('Export'), $msg = '', $task = 'export', $list = false, $hidemenu = true, $params);
     // separator
     JToolBarHelper::divider();
     // edit home page button
     $params['class'] = 'modalediturl';
     $params['size'] = array('x' => 700, 'y' => 500);
     $js = '\\function(){shAlreadySqueezed = false;if(parent.shReloadModal) parent.window.location=\'' . $this->defaultRedirectUrl . '\';parent.shReloadModal=true}';
     $params['onClose'] = $js;
     $bar->appendButton('Shpopupbutton', 'home', JText16::_('COM_SH404SEF_HOME_PAGE_ICON'), "index.php?option=com_sh404sef&c=editurl&task=edit&home=1&tmpl=component", $params);
     // separator
     JToolBarHelper::divider();
     // add save button as an ajax call
     $bar->addButtonPath(JPATH_COMPONENT . DS . 'classes');
     $params['class'] = 'savemeta';
     $params['id'] = 'savemeta';
     $params['closewindow'] = 0;
     $bar->appendButton('Shajaxbutton', 'save', 'Save', "index.php?option=com_sh404sef&c=metas&task=save&shajax=1&tmpl=component", $params);
     // separator
     JToolBarHelper::divider();
 }
示例#12
0
 public function display($tpl = null)
 {
     // version prefix
     $this->joomlaVersionPrefix = Sh404sefHelperGeneral::getJoomlaVersionPrefix();
     // get model and update context with current
     $model = $this->getModel();
     $context = $model->updateContext($this->_context . '.' . $this->getLayout());
     // get url id
     $notFoundUrlId = JRequest::getInt('notfound_url_id');
     // read url data from model
     $url = $model->getUrl($notFoundUrlId);
     // and push url into the template for display
     $this->assign('url', $url);
     if (version_compare(JVERSION, '3.0', 'ge')) {
         // add modal css and js
         ShlHtmlBs_helper::addBootstrapCss(JFactory::getDocument());
         ShlHtmlBs_helper::addBootstrapModalFixCss(JFactory::getDocument());
         ShlHtmlBs_helper::addBootstrapJs(JFactory::getDocument());
         // add title
         JToolbarHelper::title('sh404SEF: ' . JText::_('COM_SH404SEF_NOT_FOUND_ENTER_REDIRECT'));
         // CSS
         JHtml::styleSheet(Sh404sefHelperGeneral::getComponentUrl() . '/assets/css/configuration.css');
         JHtml::styleSheet(Sh404sefHelperGeneral::getComponentUrl() . '/assets/css/j3_list.css');
         // add tooltips
         // @TODO replace with a viable jQuery equivalent
         JHTML::_('behavior.tooltip');
     } else {
         // build the toolbar
         $toolBar = $this->_makeToolbar();
         $this->assignRef('toolbar', $toolBar);
         // add title.
         $this->assign('toolbarTitle', Sh404sefHelperGeneral::makeToolbarTitle(JText::_('COM_SH404SEF_NOT_FOUND_ENTER_REDIRECT'), $icon = 'sh404sef', $class = 'sh404sef-toolbar-title'));
         // add tooltips
         JHTML::_('behavior.tooltip');
     }
     // link to  custom javascript
     JHtml::script(Sh404sefHelperGeneral::getComponentUrl() . '/assets/js/' . $this->joomlaVersionPrefix . '_edit.js');
     // add our own css
     JHtml::styleSheet(Sh404sefHelperGeneral::getComponentUrl() . '/assets/css/' . $this->joomlaVersionPrefix . '_editurl.css');
     // now display normally
     parent::display($this->joomlaVersionPrefix);
 }
示例#13
0
    private function _addCss()
    {
        // add link to css
        JHtml::styleSheet('icon.css', 'administrator/templates/khepri/css/');
        JHtml::styleSheet('rounded.css', 'administrator/templates/khepri/css/');
        JHtml::styleSheet('system.css', 'administrator/templates/system/css/');
        $customCss = '
    <!--[if IE 7]>
<link href="templates/khepri/css/ie7.css" rel="stylesheet" type="text/css" />
<![endif]-->

<!--[if lte IE 6]>
<link href="templates/khepri/css/ie6.css" rel="stylesheet" type="text/css" />
<![endif]-->';
        // insert using addCustomtag, so that J! does not add any markup
        $document =& JFactory::getDocument();
        $document->addCustomTag($customCss);
        // add our own css
        JHtml::styleSheet('list.css', Sh404sefHelperGeneral::getComponentUrl() . '/assets/css/');
    }
示例#14
0
文件: shurl.php 项目: sangkasi/joomla
 public static function updateShurls()
 {
     $sefConfig =& shRouter::shGetConfig();
     // set the short link tag
     $shPageInfo =& shRouter::shPageInfo();
     $shPageInfo->shURL = '';
     if ($sefConfig->enablePageId && !$sefConfig->stopCreatingShurls) {
         try {
             jimport('joomla.utilities.string');
             $nonSefUrl = JString::ltrim($shPageInfo->shCurrentPageNonSef, '/');
             $nonSefUrl = shSortURL($nonSefUrl);
             // remove tracking vars (Google Analytics)
             $nonSefUrl = Sh404sefHelperGeneral::stripTrackingVarsFromNonSef($nonSefUrl);
             // try to get the current shURL, if any
             $shURL = Sh404sefHelperDb::selectResult('#__sh404sef_pageids', array('pageid'), array('newurl' => $nonSefUrl));
             // if none, we may have to create one
             if (empty($shURL)) {
                 $shURL = self::_createShurl($nonSefUrl);
             }
             // insert in head and header, if not empty
             if (!empty($shURL)) {
                 $fullShURL = JString::ltrim($GLOBALS['shConfigLiveSite'], '/') . '/' . $shURL;
                 $document =& JFactory::getDocument();
                 if ($sefConfig->insertShortlinkTag) {
                     $document->addHeadLink($fullShURL, 'shortlink');
                     // also add header, especially for HEAD requests
                     JResponse::setHeader('Link', '<' . $fullShURL . '>; rel=shortlink', true);
                 }
                 if ($sefConfig->insertRevCanTag) {
                     $document->addHeadLink($fullShURL, 'canonical', 'rev', array('type' => 'text/html'));
                 }
                 if ($sefConfig->insertAltShorterTag) {
                     $document->addHeadLink($fullShURL, 'alternate shorter');
                 }
                 // store for reuse
                 $shPageInfo->shURL = $shURL;
             }
         } catch (Sh404sefExceptionDefault $e) {
         }
     }
 }
示例#15
0
 /**
  * Saves data from the quickStart pane on main dashboard
  */
 public function saveqcontrol()
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     try {
         // get current settings for sh404SEF
         $params = Sh404sefHelperGeneral::getComponentParams($forceRead = true);
         // set params from the form
         $params->set('Enabled', JRequest::getInt('Enabled', 0));
         $params->set('canReadRemoteConfig', JRequest::getInt('canReadRemoteConfig', 0));
         $params->set('shRewriteMode', JRequest::getInt('shRewriteMode', 1));
         $params->set('shSecEnableSecurity', JRequest::getInt('shSecEnableSecurity', 1));
         // convert to json and store into db
         $textParams = $params->toString();
         ShlDbHelper::update('#__extensions', array('params' => $textParams), array('element' => 'com_sh404sef', 'type' => 'component'));
         JFactory::getApplication()->enqueueMessage(JText::_('COM_SH404SEF_ELEMENT_SAVED'));
     } catch (Exception $e) {
         JFactory::getApplication()->enqueueMessage(JText::_('COM_SH404SEF_ELEMENT_NOT_SAVED'), 'error');
     }
     parent::display();
 }
示例#16
0
 public function display($tpl = null)
 {
     // prepare the view, based on request
     // do we force reading updates from server ?
     $options = Sh404sefHelperAnalytics::getRequestOptions();
     $method = '_makeView' . ucfirst($options['report']);
     if (is_callable(array($this, $method))) {
         $this->{$method}($tpl);
     }
     // push display options into template
     $this->assign('options', $options);
     // add our javascript
     JHTML::script('cp.js', Sh404sefHelperGeneral::getComponentUrl() . '/assets/js/');
     // add Joomla calendar behavior, needed to input start and end dates
     if ($options['showFilters'] == 'yes') {
         JHTML::_('behavior.calendar');
     }
     // add our own css
     JHtml::styleSheet('cp.css', Sh404sefHelperGeneral::getComponentUrl() . '/assets/css/');
     // add tooltips handler
     JHTML::_('behavior.tooltip');
     // add title
     $app =& JFactory::getApplication();
     $title = Sh404sefHelperGeneral::makeToolbarTitle(JText16::_('COM_SH404SEF_ANALYTICS_MANAGER'), $icon = 'sh404sef', $class = 'sh404sef-toolbar-title');
     $app->set('JComponentTitle', $title);
     // add a div to display our ajax-call-in-progress indicator
     // Get the JComponent instance of JToolBar
     $bar =& JToolBar::getInstance('toolbar');
     $bar->addButtonPath(JPATH_COMPONENT . DS . 'classes');
     $html = '<div id="sh-progress-cpprogress"></div>';
     $bar->appendButton('custom', $html, 'sh-progress-button-cpprogress');
     // add quick control panel loader
     $js = 'window.addEvent(\'domready\', function(){  shSetupAnalytics({report:" ' . $options['report'] . '"});});';
     $document =& JFactory::getDocument();
     $document->addScriptDeclaration($js);
     // flag to know if we should display placeholder for ajax fillin
     $this->assign('isAjaxTemplate', true);
     parent::display($tpl = null);
 }
示例#17
0
 /**
  * Method to get the field input markup.
  *
  * @return	string	The field input markup.
  */
 protected function getInput()
 {
     $text = JText::_('COM_SH404SEF_CONFIGURE_SHLIB_PLUGIN');
     $link = '<span class = "btn sh404sef-textinput"><a href="' . Sh404sefHelperGeneral::getShLibPluginLink() . '" target="_blank">' . $text . '</a></span>';
     return $link;
     $html = '';
     $class = $this->element['class'] ? (string) $this->element['class'] : '';
     // Build the class for the label.
     $class = !empty($this->description) ? 'hasTip' : '';
     $class = $this->required == true ? $class . ' required' : $class;
     // Add the opening label tag and main attributes attributes.
     $field = '<fieldset id="' . $this->id . ' class="' . $class . '"';
     // If a description is specified, use it to build a tooltip.
     $label = '<label for=""';
     if (!empty($this->description)) {
         $label .= ' title="' . htmlspecialchars(trim($text, ':') . '::' . ($this->translateDescription ? JText::_($this->description) : $this->description), ENT_COMPAT, 'UTF-8') . '"';
     }
     // Add the label text and closing tag.
     $label .= "></label>";
     $field .= '><span class = "sh404sef-additionaltext">' . $link . '</span></fieldset>';
     $html[] = $field;
     return implode('', $html);
 }
示例#18
0
 public function display($tpl = null)
 {
     // version prefix
     $this->joomlaVersionPrefix = Sh404sefHelperGeneral::getJoomlaVersionPrefix();
     if ($this->getLayout() != 'close') {
         // get model
         $model = $this->getModel();
         // ask for the form
         $this->form = $model->getForm();
         // prepare layouts objects, to be used by sub-layouts
         $this->layoutRenderer = array();
         $this->layoutRenderer['default'] = new ShlMvcLayout_File('com_sh404sef.configuration.fields.default', sh404SEF_LAYOUTS);
         $this->layoutRenderer['shlegend'] = new ShlMvcLayout_File('com_sh404sef.configuration.fields.legend', sh404SEF_LAYOUTS);
         $this->layoutRenderer['Rules'] = new ShlMvcLayout_File('com_sh404sef.configuration.fields.rules', sh404SEF_LAYOUTS);
         if (version_compare(JVERSION, '3.0', 'ge')) {
             ShlHtmlBs_helper::addBootstrapCss(JFactory::getDocument());
             ShlHtmlBs_helper::addBootstrapModalFixCss(JFactory::getDocument());
             ShlHtmlBs_helper::addBootstrapJs(JFactory::getDocument());
             JHtml::styleSheet(Sh404sefHelperGeneral::getComponentUrl() . '/assets/css/j3_list.css');
         }
     }
     parent::display($this->joomlaVersionPrefix);
 }
示例#19
0
 /**
  * Builds a (non routed) Joomla url according to default values
  * of controller, task, view and layout
  *
  * @param array $userVars optional set of variables to override default vars, or add more to url
  * @return string the target url, not routed
  */
 protected function _getDefaultRedirect($userVars = array())
 {
     // get default values of the controller
     $defaultVars = array('c' => $this->_returnController, 'layout' => $this->_returnLayout, 'view' => $this->_returnView, 'task' => $this->_returnTask);
     // override default vars with user defined vars
     $vars = array_merge($defaultVars, $userVars);
     // strip empty vars
     foreach ($vars as $key => $value) {
         if ($value == '') {
             unset($vars[$key]);
         }
     }
     return Sh404sefHelperGeneral::buildUrl($vars);
 }
示例#20
0
          <td class="shl-list-shurl">
            <?php 
        echo empty($url->pageid) ? '' : ShlHtmlBs_Helper::badge($this->escape($url->pageid), 'info');
        ?>
          </td>

          <td class="shl-list-sef">
            <?php 
        echo '<input type="hidden" name="metaid[' . $url->id . ']" value="' . (empty($url->metaid) ? 0 : $url->metaid) . '" />';
        echo '<input type="hidden" name="newurls[' . $url->id . ']" value="' . (empty($url->nonsefurl) ? '' : $this->escape($url->nonsefurl)) . '" />';
        // link to full meta edit
        $anchor = empty($url->oldurl) ? '(-)' : $this->escape($url->oldurl);
        $anchor .= '<br/><i>(' . $this->escape($url->nonsefurl) . ')</i>';
        $params = array();
        $linkData = array('c' => 'editurl', 'task' => 'edit', 'view' => 'editurl', 'startOffset' => '1', 'cid[]' => $url->id, 'tmpl' => 'component');
        $targetUrl = Sh404sefHelperGeneral::buildUrl($linkData);
        $displayedUrl = empty($url->oldurl) ? $url->nonsefurl : $url->oldurl;
        $params['linkTitle'] = JText::_('COM_SH404SEF_MODIFY_META_TITLE') . ' ' . $this->escape($displayedUrl);
        $modalTitle = '';
        $params['linkClass'] = 'shl-list-sef';
        $params['linkType'] = 'a';
        $name = '-editurl-' . $url->id;
        echo ShlHtmlModal_helper::modalLink($name, $anchor, $targetUrl, Sh404sefFactory::getPConfig()->windowSizes['editurl']['x'], Sh404sefFactory::getPConfig()->windowSizes['editurl']['y'], $top = 0, $left = 0, $onClose = '', $modalTitle, $params);
        // small preview icon
        $sefConfig =& Sh404sefFactory::getConfig();
        $link = JURI::root() . ltrim($sefConfig->shRewriteStrings[$sefConfig->shRewriteMode], '/') . (empty($url->oldurl) ? $url->nonsefurl : $url->oldurl);
        echo '&nbsp;<a href="' . $this->escape($link) . '" target="_blank" title="' . JText::_('COM_SH404SEF_PREVIEW') . ' ' . $this->escape($url->oldurl) . '">';
        echo '<img src=\'components/com_sh404sef/assets/images/external-black.png\' border=\'0\' alt=\'' . JText::_('COM_SH404SEF_PREVIEW') . '\' />';
        echo '</a>';
        ?>
          </td>
  /**
   * Check if user set parameters and request
   * data allow inserting tracking snippet
   */
  protected function _shouldInsertSnippet() {

    // get config
    $sefConfig = & Sh404sefFactory::getConfig();

    // check if we have a tracking code, no need to insert snippet if no tracking code
    if (empty( $sefConfig->analyticsId)) {
      return false;
    }

    // check if we are set to include tracking code for current user
    $user = JFactory::getUser();
    if ( !empty( $sefConfig->analyticsMaxUserLevel) && $sefConfig->analyticsMaxUserLevel != 'Public Frontend' && Sh404sefHelperGeneral::compareGroups( $user->usertype, $sefConfig->analyticsMaxUserLevel) == 1) {
      return false;
    }

    // check if current IP is on exclusion list
    if( !empty( $sefConfig->analyticsExcludeIP)) {
      $ip = empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR'];
      $exclude = Sh404sefHelperGeneral::checkIPList( $ip, $sefConfig->analyticsExcludeIP);
      if ($exclude) {
        return false;
      }
    }

    return true;
  }
示例#22
0
 function shGetCurrentNonSef()
 {
     // remove Google tracking vars, would prevent us to find the correct meta tags
     $nonSef = Sh404sefHelperGeneral::stripTrackingVarsFromNonSef(Sh404sefFactory::getPageInfo()->shCurrentPageNonSef);
     // normalize, set variables in alpha order
     return shSortUrl($nonSef);
 }
示例#23
0
 private function _addFilters()
 {
     // component selector
     JHtmlSidebar::addFilter(JText::_('COM_SH404SEF_ALL_COMPONENTS'), 'filter_component', JHtml::_('select.options', Sh404sefHelperGeneral::getComponentsList(), 'element', 'name', $this->options->filter_component, true));
     // language list
     JHtmlSidebar::addFilter(JText::_('COM_SH404SEF_ALL_LANGUAGES'), 'filter_language', JHtml::_('select.options', JHtml::_('contentlanguage.existing', $all = false, $translate = true), 'value', 'text', $this->options->filter_language, false));
     // select custom
     $data = array(array('value' => Sh404sefHelperGeneral::COM_SH404SEF_ONLY_CUSTOM, 'text' => JText::_('COM_SH404SEF_ONLY_CUSTOM')), array('value' => Sh404sefHelperGeneral::COM_SH404SEF_ONLY_AUTO, 'text' => JText::_('COM_SH404SEF_ONLY_AUTO')));
     JHtmlSidebar::addFilter(JText::_('COM_SH404SEF_ALL_URL_TYPES'), 'filter_url_type', JHtml::_('select.options', $data, 'value', 'text', $this->options->filter_url_type, true));
 }
示例#24
0
 function shInsertOpenGraphData(&$buffer)
 {
     // get sh404sef config
     $sefConfig =& Sh404sefFactory::getConfig();
     $pageInfo =& Sh404sefFactory::getPageInfo();
     if (empty($sefConfig->shMetaManagementActivated) || !isset($sefConfig) || empty($pageInfo->currentNonSefUrl) || !empty($pageInfo->httpStatus) && $pageInfo->httpStatus == 404) {
         return;
     }
     $nonSef = shGetCurrentNonSef();
     $customData = shGetCustomMetaData($nonSef);
     // user can disable per url
     if ($customData->og_enable == SH404SEF_OPTION_VALUE_NO || empty($sefConfig->enableOpenGraphData) && $customData->og_enable == SH404SEF_OPTION_VALUE_USE_DEFAULT) {
         return;
     }
     $openGraphData = '';
     $ogNameSpace = '';
     $fbNameSpace = '';
     // add locale -  FB use underscore in language tags
     $locale = str_replace('-', '_', JFactory::getLanguage()->getTag());
     $openGraphData .= "\n" . '  <meta property="og:locale" content="' . $locale . '" />';
     // insert title
     if (!empty($pageInfo->pageTitle)) {
         $openGraphData .= "\n" . '  <meta property="og:title" content="' . $pageInfo->pageTitle . '" />';
     }
     // insert description
     if (($sefConfig->ogEnableDescription && $customData->og_enable_description == SH404SEF_OPTION_VALUE_USE_DEFAULT || $customData->og_enable_description == SH404SEF_OPTION_VALUE_YES) && !empty($pageInfo->pageDescription)) {
         $openGraphData .= "\n" . '  <meta property="og:description" content="' . $pageInfo->pageDescription . '" />';
     }
     // insert type
     $content = $customData->og_type == SH404SEF_OPTION_VALUE_USE_DEFAULT ? $sefConfig->ogType : $customData->og_type;
     if (!empty($content)) {
         $openGraphData .= "\n" . '  <meta property="og:type" content="' . $content . '" />';
     }
     // insert url. If any, we insert the canonical url rather than current, to consolidate
     $content = empty($pageInfo->pageCanonicalUrl) ? $pageInfo->currentSefUrl : $pageInfo->pageCanonicalUrl;
     $content = Sh404sefHelperGeneral::stripTrackingVarsFromSef($content);
     $openGraphData .= "\n" . '  <meta property="og:url" content="' . htmlspecialchars($content, ENT_COMPAT, 'UTF-8') . '" />';
     // insert image
     $content = empty($customData->og_image) ? $sefConfig->ogImage : $customData->og_image;
     if (!empty($content)) {
         $content = JURI::root(false, '') . JString::ltrim($content, '/');
         $openGraphData .= "\n" . '  <meta property="og:image" content="' . $content . '" />';
     }
     // insert site name
     if ($sefConfig->ogEnableSiteName && $customData->og_enable_site_name == SH404SEF_OPTION_VALUE_USE_DEFAULT || $customData->og_enable_site_name == SH404SEF_OPTION_VALUE_YES) {
         $content = empty($customData->og_site_name) ? $sefConfig->ogSiteName : $customData->og_site_name;
         $content = empty($content) ? JFactory::getApplication()->getCfg('sitename') : $content;
         if (!empty($content)) {
             $content = htmlspecialchars(shCleanUpDesc($content), ENT_COMPAT, 'UTF-8');
             $openGraphData .= "\n" . '  <meta property="og:site_name" content="' . $content . '" />';
         }
     }
     // insert location
     // disabled: Facebook removed all of that after reducing number of object types to bare minimum
     if (false && ($sefConfig->ogEnableLocation && $customData->og_enable_location == SH404SEF_OPTION_VALUE_USE_DEFAULT || $customData->og_enable_location == SH404SEF_OPTION_VALUE_YES)) {
         $content = empty($customData->og_latitude) ? $sefConfig->ogLatitude : $customData->og_latitude;
         if (!empty($content)) {
             $content = htmlspecialchars(shCleanUpDesc($content), ENT_COMPAT, 'UTF-8');
             $openGraphData .= "\n" . '  <meta property="og:latitude" content="' . $content . '" />';
         }
         $content = empty($customData->og_longitude) ? $sefConfig->ogLongitude : $customData->og_longitude;
         if (!empty($content)) {
             $content = htmlspecialchars(shCleanUpDesc($content), ENT_COMPAT, 'UTF-8');
             $openGraphData .= "\n" . '  <meta property="og:longitude" content="' . $content . '" />';
         }
         $content = empty($customData->og_street_address) ? $sefConfig->ogStreetAddress : $customData->og_street_address;
         if (!empty($content)) {
             $content = htmlspecialchars(shCleanUpDesc($content), ENT_COMPAT, 'UTF-8');
             $openGraphData .= "\n" . '  <meta property="og:street-address" content="' . $content . '" />';
         }
         $content = empty($customData->og_locality) ? $sefConfig->ogLocality : $customData->og_locality;
         if (!empty($content)) {
             $content = htmlspecialchars(shCleanUpDesc($content), ENT_COMPAT, 'UTF-8');
             $openGraphData .= "\n" . '  <meta property="og:locality" content="' . $content . '" />';
         }
         $content = empty($customData->og_postal_code) ? $sefConfig->ogPostalCode : $customData->og_postal_code;
         if (!empty($content)) {
             $content = htmlspecialchars(shCleanUpDesc($content), ENT_COMPAT, 'UTF-8');
             $openGraphData .= "\n" . '  <meta property="og:postal-code" content="' . $content . '" />';
         }
         $content = empty($customData->og_region) ? $sefConfig->ogRegion : $customData->og_region;
         if (!empty($content)) {
             $content = htmlspecialchars(shCleanUpDesc($content), ENT_COMPAT, 'UTF-8');
             $openGraphData .= "\n" . '  <meta property="og:region" content="' . $content . '" />';
         }
         $content = empty($customData->og_country_name) ? $sefConfig->ogCountryName : $customData->og_country_name;
         if (!empty($content)) {
             $content = htmlspecialchars(shCleanUpDesc($content), ENT_COMPAT, 'UTF-8');
             $openGraphData .= "\n" . '  <meta property="og:country-name" content="' . $content . '" />';
         }
     }
     // insert contact
     // disabled: Facebook removed all of that after reducing number of object types to bare minimum
     if (false && ($sefConfig->ogEnableContact && $customData->og_enable_contact == SH404SEF_OPTION_VALUE_USE_DEFAULT || $customData->og_enable_contact == SH404SEF_OPTION_VALUE_YES)) {
         $content = empty($customData->og_email) ? $sefConfig->ogEmail : $customData->og_email;
         if (!empty($content)) {
             $content = htmlspecialchars(shCleanUpDesc($content), ENT_COMPAT, 'UTF-8');
             $openGraphData .= "\n" . '  <meta property="og:email" content="' . $content . '" />';
         }
         $content = empty($customData->og_phone_number) ? $sefConfig->ogPhoneNumber : $customData->og_phone_number;
         if (!empty($content)) {
             $content = htmlspecialchars(shCleanUpDesc($content), ENT_COMPAT, 'UTF-8');
             $openGraphData .= "\n" . '  <meta property="og:phone_number" content="' . $content . '" />';
         }
         $content = empty($customData->og_fax_number) ? $sefConfig->ogFaxNumber : $customData->og_fax_number;
         if (!empty($content)) {
             $content = htmlspecialchars(shCleanUpDesc($content), ENT_COMPAT, 'UTF-8');
             $openGraphData .= "\n" . '  <meta property="og:fax_number" content="' . $content . '" />';
         }
     }
     if (!empty($openGraphData)) {
         $ogNameSpace = 'xmlns:og="http://ogp.me/ns#"';
     }
     // insert fb admin id
     if (!empty($sefConfig->fbAdminIds) && $customData->og_enable_fb_admin_ids == SH404SEF_OPTION_VALUE_USE_DEFAULT || $customData->og_enable_fb_admin_ids == SH404SEF_OPTION_VALUE_YES) {
         $content = empty($customData->fb_admin_ids) ? $sefConfig->fbAdminIds : $customData->fb_admin_ids;
         if ($customData->og_enable_fb_admin_ids != SH404SEF_OPTION_VALUE_NO && !empty($content)) {
             $openGraphData .= "\n" . '  <meta property="fb:admins" content="' . $content . '" />';
             $fbNameSpace = 'xmlns:fb="https://www.facebook.com/2008/fbml"';
         }
     }
     // actually insert the tags
     if (!empty($openGraphData)) {
         $buffer = shInsertCustomTagInBuffer($buffer, '<head>', 'after', $openGraphData, 'first');
     }
     if (!empty($fbNameSpace) || !empty($ogNameSpace)) {
         // insert as well namespaces
         $buffer = str_replace('<html ', '<html ' . $ogNameSpace . ' ' . $fbNameSpace . ' ', $buffer);
     }
 }
示例#25
0
 /**
  * Builds up an html link using the various parts supplied
  *
  * @param $view a JView object, to be able to escape output text
  * @param $linkData an array of key/value pairs to build up the target links
  * @param $elementData an array holding element data : title, class, rel
  * @param $modal boolean, if true, required stuff to make the link open in modal box is added
  * @param $hasTip boolean, if true, required stuff to turn elementData['title'] into a tooltip is added
  * @param $extra an array holding key/value pairs, will be added as raw attributes to the link
  */
 public static function makeLink($view, $linkData, $elementData, $modal = false, $modalOptions = array(), $hasTip = false, $extra = array())
 {
     // calculate target link
     if ($modal) {
         $linkData['tmpl'] = 'component';
     }
     $url = Sh404sefHelperGeneral::buildUrl($linkData);
     $url = JRoute::_($url);
     // calculate title
     $title = empty($elementData['title']) ? '' : $elementData['title'];
     $title = is_null($view) ? $title : $view->escape($title);
     $attribs = array();
     // calculate class
     $class = empty($elementData['class']) ? '' : $elementData['class'];
     if ($hasTip) {
         $class .= ' ' . $hasTip;
     }
     // store title in attributes array
     if (!empty($title)) {
         $attribs['title'] = $title;
     }
     // store in attributes array
     if (!empty($class)) {
         $attribs['class'] = $class;
     }
     // calculate modal information
     $rel = empty($elementData['rel']) || is_null($view) ? '' : $view->escape($elementData['rel']);
     if ($modal) {
         $modalOptionsString = Sh404sefHelperHtml::makeSqueezeboxOptions($modalOptions);
         $rel .= ' {handler: \'iframe\'' . (empty($modalOptionsString) ? '' : ', ' . $modalOptionsString) . '}';
     }
     // store in attributes array
     if (!empty($rel)) {
         $attribs['rel'] = $rel;
     }
     // any custom attibutes ?
     if (!empty($extra)) {
         foreach ($extra as $key => $value) {
             $attribs[$key] = $value;
         }
     }
     // finish link
     $anchor = empty($elementData['anchor']) ? $title : $elementData['anchor'];
     return JHTML::link($url, $anchor, $attribs);
 }
示例#26
0
    /**
     * Creates the item page
     *
     * @since 1.0
     */
    function display($tpl = null)
    {
        // ********************************
        // Initialize variables, flags, etc
        // ********************************
        global $globalcats;
        $categories = $globalcats;
        $app = JFactory::getApplication();
        $dispatcher = JDispatcher::getInstance();
        $document = JFactory::getDocument();
        $config = JFactory::getConfig();
        $session = JFactory::getSession();
        $user = JFactory::getUser();
        $db = JFactory::getDBO();
        $option = JRequest::getVar('option');
        $nullDate = $db->getNullDate();
        // Get the COMPONENT only parameters
        // Get component parameters
        $params = new JRegistry();
        $cparams = JComponentHelper::getParams('com_flexicontent');
        $params->merge($cparams);
        $params = clone JComponentHelper::getParams('com_flexicontent');
        // Some flags
        $enable_translation_groups = flexicontent_db::useAssociations();
        //$params->get("enable_translation_groups");
        $print_logging_info = $params->get('print_logging_info');
        if ($print_logging_info) {
            global $fc_run_times;
        }
        // *****************
        // Load JS/CSS files
        // *****************
        // Add css to document
        $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VERSION);
        $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VERSION);
        // Fields common CSS
        $document->addStyleSheetVersion(JURI::root(true) . '/components/com_flexicontent/assets/css/flexi_form_fields.css', FLEXI_VERSION);
        // Add JS frameworks
        flexicontent_html::loadFramework('select2');
        $prettycheckable_added = flexicontent_html::loadFramework('prettyCheckable');
        flexicontent_html::loadFramework('flexi-lib');
        // Add js function to overload the joomla submitform validation
        JHTML::_('behavior.formvalidation');
        // load default validation JS to make sure it is overriden
        $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/admin.js', FLEXI_VERSION);
        $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/validate.js', FLEXI_VERSION);
        // Add js function for custom code used by FLEXIcontent item form
        $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/itemscreen.js', FLEXI_VERSION);
        // ***********************
        // Get data from the model
        // ***********************
        if ($print_logging_info) {
            $start_microtime = microtime(true);
        }
        $model = $this->getModel();
        $item = $model->getItem();
        $form = $this->get('Form');
        if ($print_logging_info) {
            $fc_run_times['get_item_data'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
        }
        // ***************************
        // Get Associated Translations
        // ***************************
        if ($enable_translation_groups) {
            $langAssocs = $this->get('LangAssocs');
        }
        $langs = FLEXIUtilities::getLanguages('code');
        // Get item id and new flag
        $cid = $model->getId();
        $isnew = !$cid;
        // Create and set a unique item id for plugins that needed it
        if ($cid) {
            $unique_tmp_itemid = $cid;
        } else {
            $unique_tmp_itemid = $app->getUserState('com_flexicontent.edit.item.unique_tmp_itemid');
            $unique_tmp_itemid = $unique_tmp_itemid ? $unique_tmp_itemid : date('_Y_m_d_h_i_s_', time()) . uniqid(true);
        }
        //print_r($unique_tmp_itemid);
        JRequest::setVar('unique_tmp_itemid', $unique_tmp_itemid);
        // Get number of subscribers
        $subscribers = $model->getSubscribersCount();
        // ******************
        // Version Panel data
        // ******************
        // Get / calculate some version related variables
        $versioncount = $model->getVersionCount();
        $versionsperpage = $params->get('versionsperpage', 10);
        $pagecount = (int) ceil($versioncount / $versionsperpage);
        // Data need by version panel: (a) current version page, (b) currently active version
        $current_page = 1;
        $k = 1;
        $allversions = $model->getVersionList();
        foreach ($allversions as $v) {
            if ($k > 1 && ($k - 1) % $versionsperpage == 0) {
                $current_page++;
            }
            if ($v->nr == $item->version) {
                break;
            }
            $k++;
        }
        // Finally fetch the version data for versions in current page
        $versions = $model->getVersionList(($current_page - 1) * $versionsperpage, $versionsperpage);
        // Create display of average rating
        $ratings = $model->getRatingDisplay();
        // *****************
        // Type related data
        // *****************
        // Get available types and the currently selected/requested type
        $types = $model->getTypeslist();
        $typesselected = $model->getTypesselected();
        // Get and merge type parameters
        $tparams = $this->get('Typeparams');
        $tparams = new JRegistry($tparams);
        $params->merge($tparams);
        // Apply type configuration if it type is set
        // Get user allowed permissions on the item ... to be used by the form rendering
        // Also hide parameters panel if user can not edit parameters
        $perms = $this->_getItemPerms($item);
        if (!$perms['canparams']) {
            $document->addStyleDeclaration('#details-options {display:none;}');
        }
        // ******************
        // Create the toolbar
        // ******************
        $toolbar = JToolBar::getInstance('toolbar');
        $tip_class = FLEXI_J30GE ? ' hasTooltip' : ' hasTip';
        // SET toolbar title
        if ($cid) {
            JToolBarHelper::title(JText::_('FLEXI_EDIT_ITEM'), 'itemedit');
            // Editing existing item
        } else {
            JToolBarHelper::title(JText::_('FLEXI_NEW_ITEM'), 'itemadd');
            // Creating new item
        }
        // **************
        // Common Buttons
        // **************
        // Applying new item type is a special case that has not loaded custom fieds yet
        JToolBarHelper::apply($item->type_id ? 'items.apply' : 'items.apply_type', !$isnew ? 'FLEXI_APPLY' : ($typesselected->id ? 'FLEXI_ADD' : 'FLEXI_APPLY_TYPE'), false);
        /*if (!$isnew || $item->version) flexicontent_html::addToolBarButton(
        		'FLEXI_FAST_APPLY', $btn_name='apply_ajax', $full_js="Joomla.submitbutton('items.apply_ajax')", $msg_alert='', $msg_confirm='',
        		$btn_task='items.apply_ajax', $extra_js='', $btn_list=false, $btn_menu=true, $btn_confirm=false, $btn_class="".$tip_class, $btn_icon="icon-loop",
        		'data-placement="bottom" title="Fast saving, without reloading the form. <br/><br/>Note: new files will not be uploaded, <br/>- in such a case please use \'Apply\'"');*/
        if (!$isnew || $item->version) {
            JToolBarHelper::save('items.save');
        }
        if (!$isnew || $item->version) {
            JToolBarHelper::custom('items.saveandnew', 'savenew.png', 'savenew.png', 'FLEXI_SAVE_AND_NEW', false);
        }
        JToolBarHelper::cancel('items.cancel');
        // ***********************
        // Add a preview button(s)
        // ***********************
        //$_sh404sef = JPluginHelper::isEnabled('system', 'sh404sef') && $config->get('sef');
        $_sh404sef = defined('SH404SEF_IS_RUNNING') && $config->get('sef');
        if ($cid) {
            // Domain URL and autologin vars
            $server = JURI::getInstance()->toString(array('scheme', 'host', 'port'));
            $autologin = '';
            //$params->get('autoflogin', 1) ? '&fcu='.$user->username . '&fcp='.$user->password : '';
            // Check if we are in the backend, in the back end we need to set the application to the site app instead
            // we do not remove 'isAdmin' check so that we can copy later without change, e.g. to a plugin
            $isAdmin = JFactory::getApplication()->isAdmin();
            if ($isAdmin && !$_sh404sef) {
                JFactory::$application = JApplication::getInstance('site');
            }
            // Create the URL
            $item_url = FlexicontentHelperRoute::getItemRoute($item->id . ':' . $item->alias, $categories[$item->catid]->slug) . ($item->language != '*' ? '&lang=' . substr($item->language, 0, 2) : '');
            $item_url = $_sh404sef ? Sh404sefHelperGeneral::getSefFromNonSef($item_url, $fullyQualified = true, $xhtml = false, $ssl = null) : JRoute::_($item_url);
            // Check if we are in the backend again
            // In backend we need to remove administrator from URL as it is added even though we've set the application to the site app
            if ($isAdmin && !$_sh404sef) {
                $admin_folder = str_replace(JURI::root(true), '', JURI::base(true));
                $item_url = str_replace($admin_folder . '/', '/', $item_url);
                // Restore application
                JFactory::$application = JApplication::getInstance('administrator');
            }
            $previewlink = $item_url . (strstr($item_url, '?') ? '&amp;' : '?') . 'preview=1' . $autologin;
            //$previewlink     = str_replace('&amp;', '&', $previewlink);
            //$previewlink = JRoute::_(JURI::root() . FlexicontentHelperRoute::getItemRoute($item->id.':'.$item->alias, $categories[$item->catid]->slug)) .$autologin;
            // PREVIEW for latest version
            if (!$params->get('use_versioning', 1) || $item->version == $item->current_version && $item->version == $item->last_version) {
                $toolbar->appendButton('Custom', '<button class="preview btn btn-small btn-info spaced-btn" onClick="window.open(\'' . $previewlink . '\');"><span title="' . JText::_('Preview') . '" class="icon-screen"></span>' . JText::_('Preview') . '</button>', 'preview');
            } else {
                // Add a preview button for (currently) LOADED version of the item
                $previewlink_loaded_ver = $previewlink . '&version=' . $item->version;
                $toolbar->appendButton('Custom', '<button class="preview btn btn-small" onClick="window.open(\'' . $previewlink_loaded_ver . '\');" target="_blank"><span title="' . JText::_('Preview') . '" class="icon-screen"></span>' . JText::_('FLEXI_PREVIEW_FORM_LOADED_VERSION') . ' [' . $item->version . ']</button>', 'preview');
                // Add a preview button for currently ACTIVE version of the item
                $previewlink_active_ver = $previewlink . '&version=' . $item->current_version;
                $toolbar->appendButton('Custom', '<button class="preview btn btn-small" onClick="window.open(\'' . $previewlink_active_ver . '\');" target="_blank"><span title="' . JText::_('Preview') . '" class="icon-screen"></span>' . JText::_('FLEXI_PREVIEW_FRONTEND_ACTIVE_VERSION') . ' [' . $item->current_version . ']</button>', 'preview');
                // Add a preview button for currently LATEST version of the item
                $previewlink_last_ver = $previewlink;
                //'&version='.$item->last_version;
                $toolbar->appendButton('Custom', '<button class="preview btn btn-small" onClick="window.open(\'' . $previewlink_last_ver . '\');" target="_blank"><span title="' . JText::_('Preview') . '" class="icon-screen"></span>' . JText::_('FLEXI_PREVIEW_LATEST_SAVED_VERSION') . ' [' . $item->last_version . ']</button>', 'preview');
            }
            JToolBarHelper::spacer();
            JToolBarHelper::divider();
            JToolBarHelper::spacer();
        }
        // ************************
        // Add modal layout editing
        // ************************
        if ($perms['cantemplates']) {
            JToolBarHelper::divider();
            if (!$isnew || $item->version) {
                flexicontent_html::addToolBarButton('FLEXI_EDIT_LAYOUT', $btn_name = 'apply_ajax', $full_js = "var url = jQuery(this).attr('data-href'); fc_showDialog(url, 'fc_modal_popup_container'); return false;", $msg_alert = '', $msg_confirm = '', $btn_task = 'items.apply_ajax', $extra_js = '', $btn_list = false, $btn_menu = true, $btn_confirm = false, $btn_class = "btn-info" . $tip_class, $btn_icon = "icon-pencil", 'data-placement="bottom" data-href="index.php?option=com_flexicontent&amp;view=template&amp;type=items&amp;tmpl=component&amp;ismodal=1&amp;folder=' . $item->itemparams->get('ilayout', $tparams->get('ilayout', 'default')) . '" title="Edit the display layout of this item. <br/><br/>Note: this layout maybe assigned to content types or other items, thus changing it will effect them too"');
            }
        }
        // Check if saving an item that translates an original content in site's default language
        $site_default = substr(flexicontent_html::getSiteDefaultLang(), 0, 2);
        $is_content_default_lang = $site_default == substr($item->language, 0, 2);
        // *****************************************************************************
        // Get (CORE & CUSTOM) fields and their VERSIONED values and then
        // (a) Apply Content Type Customization to CORE fields (label, description, etc)
        // (b) Create the edit html of the CUSTOM fields by triggering 'onDisplayField'
        // *****************************************************************************
        if ($print_logging_info) {
            $start_microtime = microtime(true);
        }
        $fields = $this->get('Extrafields');
        $item->fields =& $fields;
        if ($print_logging_info) {
            $fc_run_times['get_field_vals'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
        }
        if ($print_logging_info) {
            $start_microtime = microtime(true);
        }
        $jcustom = $app->getUserState('com_flexicontent.edit.item.custom');
        //print_r($jcustom);
        foreach ($fields as $field) {
            // a. Apply CONTENT TYPE customizations to CORE FIELDS, e.g a type specific label & description
            // NOTE: the field parameters are already created so there is not need to call this for CUSTOM fields, which do not have CONTENT TYPE customizations
            if ($field->iscore) {
                FlexicontentFields::loadFieldConfig($field, $item);
            }
            // b. Create field 's editing HTML (the form field)
            // NOTE: this is DONE only for CUSTOM fields, since form field html is created by the form for all CORE fields, EXCEPTION is the 'text' field (see bellow)
            if (!$field->iscore) {
                if (isset($jcustom[$field->name])) {
                    $field->value = array();
                    foreach ($jcustom[$field->name] as $i => $_val) {
                        $field->value[$i] = $_val;
                    }
                }
                $is_editable = !$field->valueseditable || $user->authorise('flexicontent.editfieldvalues', 'com_flexicontent.field.' . $field->id);
                if ($is_editable) {
                    FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayField', array(&$field, &$item));
                    if ($field->untranslatable) {
                        $field->html = (!isset($field->html) ? '<div class="fc-mssg-inline fc-warning" style="margin:0 4px 6px 4px; max-width: unset;">' . JText::_('FLEXI_PLEASE_PUBLISH_THIS_PLUGIN') . '</div><div class="clear"></div>' : '') . '<div class="alert alert-info fc-small fc-iblock" style="margin:0 4px 6px 4px; max-width: unset;">' . JText::_('FLEXI_FIELD_VALUE_IS_NON_TRANSLATABLE') . '</div>' . "\n" . (isset($field->html) ? '<div class="clear"></div>' . $field->html : '');
                    }
                } else {
                    if ($field->valueseditable == 1) {
                        $field->html = '<div class="fc-mssg fc-note">' . JText::_($field->parameters->get('no_acc_msg_form') ? $field->parameters->get('no_acc_msg_form') : 'FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>';
                    } else {
                        if ($field->valueseditable == 2) {
                            FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayFieldValue', array(&$field, $item));
                            $field->html = '<div class="fc-mssg fc-note">' . JText::_($field->parameters->get('no_acc_msg_form') ? $field->parameters->get('no_acc_msg_form') : 'FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>' . "\n" . $field->display;
                        } else {
                            if ($field->valueseditable == 3) {
                                FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayFieldValue', array(&$field, $item));
                                $field->html = $field->display;
                            } else {
                                if ($field->valueseditable == 4) {
                                    $field->html = '';
                                    $field->formhidden = 4;
                                }
                            }
                        }
                    }
                }
            }
            // c. Create main text field, via calling the display function of the textarea field (will also check for tabs)
            if ($field->field_type == 'maintext') {
                if (isset($item->item_translations)) {
                    $shortcode = substr($item->language, 0, 2);
                    foreach ($item->item_translations as $lang_id => $t) {
                        if ($shortcode == $t->shortcode) {
                            continue;
                        }
                        $field->name = array('jfdata', $t->shortcode, 'text');
                        $field->value[0] = html_entity_decode($t->fields->text->value, ENT_QUOTES, 'UTF-8');
                        FLEXIUtilities::call_FC_Field_Func('textarea', 'onDisplayField', array(&$field, &$item));
                        $t->fields->text->tab_labels = $field->tab_labels;
                        $t->fields->text->html = $field->html;
                        unset($field->tab_labels);
                        unset($field->html);
                    }
                }
                $field->name = 'text';
                // NOTE: We use the text created by the model and not the text retrieved by the CORE plugin code, which maybe overwritten with JoomFish/Falang data
                $field->value[0] = $item->text;
                // do not decode special characters this was handled during saving !
                // Render the field's (form) HTML
                FLEXIUtilities::call_FC_Field_Func('textarea', 'onDisplayField', array(&$field, &$item));
            }
        }
        if ($print_logging_info) {
            $fc_run_times['render_field_html'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
        }
        // *************************
        // Get tags used by the item
        // *************************
        $usedtagsIds = $this->get('UsedtagsIds');
        // NOTE: This will normally return the already set versioned value of tags ($item->tags)
        $usedtags = $model->getUsedtagsData($usedtagsIds);
        // *******************************
        // Get categories used by the item
        // *******************************
        if ($isnew) {
            // Case for preselected main category for new items
            $maincat = $item->catid ? $item->catid : JRequest::getInt('maincat', 0);
            if (!$maincat) {
                $maincat = $app->getUserStateFromRequest($option . '.items.filter_cats', 'filter_cats', '', 'int');
            }
            if ($maincat) {
                $selectedcats = array($maincat);
                $item->catid = $maincat;
            } else {
                $selectedcats = array();
            }
            if ($tparams->get('cid_default')) {
                $selectedcats = $tparams->get('cid_default');
            }
            if ($tparams->get('catid_default')) {
                $item->catid = $tparams->get('catid_default');
            }
        } else {
            // NOTE: This will normally return the already set versioned value of categories ($item->categories)
            $selectedcats = $this->get('Catsselected');
        }
        //$selectedcats 	= $isnew ? array() : $fields['categories']->value;
        //echo "<br/>row->tags: "; print_r($item->tags);
        //echo "<br/>usedtagsIds: "; print_r($usedtagsIds);
        //echo "<br/>usedtags (data): "; print_r($usedtags);
        //echo "<br/>row->categories: "; print_r($item->categories);
        //echo "<br/>selectedcats: "; print_r($selectedcats);
        // *********************************************************************************************
        // Build select lists for the form field. Only few of them are used in J1.6+, since we will use:
        // (a) form XML file to declare them and then (b) getInput() method form field to create them
        // *********************************************************************************************
        // First clean form data, we do this after creating the description field which may contain HTML
        JFilterOutput::objectHTMLSafe($item, ENT_QUOTES);
        $lists = array();
        // build state list
        $non_publishers_stategrp = $perms['isSuperAdmin'] || $item->state == -3 || $item->state == -4;
        $special_privelege_stategrp = $item->state == 2 || $perms['canarchive'] || ($item->state == -2 || $perms['candelete']);
        $state = array();
        // Using <select> groups
        if ($non_publishers_stategrp || $special_privelege_stategrp) {
            $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_PUBLISHERS_WORKFLOW_STATES'));
        }
        $state[] = JHTML::_('select.option', 1, JText::_('FLEXI_PUBLISHED'));
        $state[] = JHTML::_('select.option', 0, JText::_('FLEXI_UNPUBLISHED'));
        $state[] = JHTML::_('select.option', -5, JText::_('FLEXI_IN_PROGRESS'));
        // States reserved for workflow
        if ($non_publishers_stategrp) {
            $state[] = JHTML::_('select.optgroup', '');
            $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_NON_PUBLISHERS_WORKFLOW_STATES'));
        }
        if ($item->state == -3 || $perms['isSuperAdmin']) {
            $state[] = JHTML::_('select.option', -3, JText::_('FLEXI_PENDING'));
        }
        if ($item->state == -4 || $perms['isSuperAdmin']) {
            $state[] = JHTML::_('select.option', -4, JText::_('FLEXI_TO_WRITE'));
        }
        // Special access states
        if ($special_privelege_stategrp) {
            $state[] = JHTML::_('select.optgroup', '');
            $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_SPECIAL_ACTION_STATES'));
        }
        if ($item->state == 2 || $perms['canarchive']) {
            $state[] = JHTML::_('select.option', 2, JText::_('FLEXI_ARCHIVED'));
        }
        if ($item->state == -2 || $perms['candelete']) {
            $state[] = JHTML::_('select.option', -2, JText::_('FLEXI_TRASHED'));
        }
        // Close last <select> group
        if ($non_publishers_stategrp || $special_privelege_stategrp) {
            $state[] = JHTML::_('select.optgroup', '');
        }
        $fieldname = 'jform[state]';
        $elementid = 'jform_state';
        $class = 'use_select2_lib';
        $attribs = 'class="' . $class . '"';
        $lists['state'] = JHTML::_('select.genericlist', $state, $fieldname, $attribs, 'value', 'text', $item->state, $elementid);
        if (!FLEXI_J16GE) {
            $lists['state'] = str_replace('<optgroup label="">', '</optgroup>', $lists['state']);
        }
        // *** BOF: J2.5 SPECIFIC SELECT LISTS
        if (FLEXI_J16GE) {
            // build featured flag
            $fieldname = 'jform[featured]';
            $elementid = 'jform_featured';
            /*
            $options = array();
            $options[] = JHTML::_('select.option',  0, JText::_( 'FLEXI_NO' ) );
            $options[] = JHTML::_('select.option',  1, JText::_( 'FLEXI_YES' ) );
            $attribs = FLEXI_J16GE ? ' style ="float:none!important;" '  :  '';   // this is not right for J1.5' style ="float:left!important;" ';
            $lists['featured'] = JHTML::_('select.radiolist', $options, $fieldname, $attribs, 'value', 'text', $item->featured, $elementid);
            */
            $classes = !$prettycheckable_added ? '' : ' use_prettycheckable ';
            $attribs = ' class="' . $classes . '" ';
            $i = 1;
            $options = array(0 => JText::_('FLEXI_NO'), 1 => JText::_('FLEXI_YES'));
            $lists['featured'] = '';
            foreach ($options as $option_id => $option_label) {
                $checked = $option_id == $item->featured ? ' checked="checked"' : '';
                $elementid_no = $elementid . '_' . $i;
                if (!$prettycheckable_added) {
                    $lists['featured'] .= '<label class="fccheckradio_lbl" for="' . $elementid_no . '">';
                }
                $extra_params = !$prettycheckable_added ? '' : ' data-labeltext="' . JText::_($option_label) . '" data-labelPosition="right" data-customClass="fcradiocheck"';
                $lists['featured'] .= ' <input type="radio" id="' . $elementid_no . '" data-element-grpid="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="' . $option_id . '" ' . $checked . $extra_params . ' />';
                if (!$prettycheckable_added) {
                    $lists['featured'] .= '&nbsp;' . JText::_($option_label) . '</label>';
                }
                $i++;
            }
        }
        // *** EOF: J1.5 SPECIFIC SELECT LISTS
        // build version approval list
        $fieldname = 'jform[vstate]';
        $elementid = 'jform_vstate';
        /*
        $options = array();
        $options[] = JHTML::_('select.option',  1, JText::_( 'FLEXI_NO' ) );
        $options[] = JHTML::_('select.option',  2, JText::_( 'FLEXI_YES' ) );
        $attribs = FLEXI_J16GE ? ' style ="float:left!important;" '  :  '';   // this is not right for J1.5' style ="float:left!important;" ';
        $lists['vstate'] = JHTML::_('select.radiolist', $options, $fieldname, $attribs, 'value', 'text', 2, $elementid);
        */
        $classes = !$prettycheckable_added ? '' : ' use_prettycheckable ';
        $attribs = ' class="' . $classes . '" ';
        $i = 1;
        $options = array(1 => JText::_('FLEXI_NO'), 2 => JText::_('FLEXI_YES'));
        $lists['vstate'] = '';
        foreach ($options as $option_id => $option_label) {
            $checked = $option_id == 2 ? ' checked="checked"' : '';
            $elementid_no = $elementid . '_' . $i;
            if (!$prettycheckable_added) {
                $lists['vstate'] .= '<label class="fccheckradio_lbl" for="' . $elementid_no . '">';
            }
            $extra_params = !$prettycheckable_added ? '' : ' data-labeltext="' . JText::_($option_label) . '" data-labelPosition="right" data-customClass="fcradiocheck"';
            $lists['vstate'] .= ' <input type="radio" id="' . $elementid_no . '" data-element-grpid="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="' . $option_id . '" ' . $checked . $extra_params . ' />';
            if (!$prettycheckable_added) {
                $lists['vstate'] .= '&nbsp;' . JText::_($option_label) . '</label>';
            }
            $i++;
        }
        // build field for notifying subscribers
        if (!$subscribers) {
            $lists['notify'] = !$isnew ? JText::_('FLEXI_NO_SUBSCRIBERS_EXIST') : '';
        } else {
            // b. Check if notification emails to subscribers , were already sent during current session
            $subscribers_notified = $session->get('subscribers_notified', array(), 'flexicontent');
            if (!empty($subscribers_notified[$item->id])) {
                $lists['notify'] = JText::_('FLEXI_SUBSCRIBERS_ALREADY_NOTIFIED');
            } else {
                // build favs notify field
                $fieldname = 'jform[notify]';
                $elementid = 'jform_notify';
                /*
                $attribs = FLEXI_J16GE ? ' style ="float:none!important;" '  :  '';   // this is not right for J1.5' style ="float:left!important;" ';
                $lists['notify'] = '<input type="checkbox" name="jform[notify]" id="jform_notify" '.$attribs.' /> '. $lbltxt;
                */
                $classes = !$prettycheckable_added ? '' : ' use_prettycheckable ';
                $attribs = ' class="' . $classes . '" ';
                $lbltxt = $subscribers . ' ' . JText::_($subscribers > 1 ? 'FLEXI_SUBSCRIBERS' : 'FLEXI_SUBSCRIBER');
                if (!$prettycheckable_added) {
                    $lists['notify'] .= '<label class="fccheckradio_lbl" for="' . $elementid . '">';
                }
                $extra_params = !$prettycheckable_added ? '' : ' data-labeltext="' . $lbltxt . '" data-labelPosition="right" data-customClass="fcradiocheck"';
                $lists['notify'] = ' <input type="checkbox" id="' . $elementid . '" data-element-grpid="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="1" ' . $extra_params . ' checked="checked" />';
                if (!$prettycheckable_added) {
                    $lists['notify'] .= '&nbsp;' . $lbltxt . '</label>';
                }
            }
        }
        // Retrieve author configuration
        $authorparams = flexicontent_db::getUserConfig($user->id);
        // Get author's maximum allowed categories per item and set js limitation
        $max_cat_assign = intval($authorparams->get('max_cat_assign', 0));
        $document->addScriptDeclaration('
			max_cat_assign_fc = ' . $max_cat_assign . ';
			existing_cats_fc  = ["' . implode('","', $selectedcats) . '"];
		');
        JText::script('FLEXI_TOO_MANY_ITEM_CATEGORIES', true);
        // Creating categorories tree for item assignment, we use the 'create' privelege
        $actions_allowed = array('core.create');
        // Featured categories form field
        $featured_cats_parent = $params->get('featured_cats_parent', 0);
        $featured_cats = array();
        $enable_featured_cid_selector = $perms['multicat'] && $perms['canchange_featcat'];
        if ($featured_cats_parent) {
            $featured_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $featured_cats_parent, $depth_limit = 0);
            $disabled_cats = $params->get('featured_cats_parent_disable', 1) ? array($featured_cats_parent) : array();
            $featured_sel = array();
            foreach ($selectedcats as $item_cat) {
                if (isset($featured_tree[$item_cat])) {
                    $featured_sel[] = $item_cat;
                }
            }
            $class = "use_select2_lib select2_list_selected";
            $attribs = 'class="' . $class . '" multiple="multiple" size="8"';
            $attribs .= $enable_featured_cid_selector ? '' : ' disabled="disabled"';
            $fieldname = 'jform[featured_cid][]';
            $lists['featured_cid'] = ($enable_featured_cid_selector ? '' : '<label class="label" style="float:none; margin:0 6px 0 0 !important;">locked</label>') . flexicontent_cats::buildcatselect($featured_tree, $fieldname, $featured_sel, 3, $attribs, true, true, $actions_allowed, $require_all = true, $skip_subtrees = array(), $disable_subtrees = array(), $custom_options = array(), $disabled_cats);
        } else {
            // Do not display, if not configured or not allowed to the user
            $lists['featured_cid'] = false;
        }
        // Multi-category form field, for user allowed to use multiple categories
        $lists['cid'] = '';
        $enable_cid_selector = $perms['multicat'] && $perms['canchange_seccat'];
        if (1) {
            if ($tparams->get('cid_allowed_parent')) {
                $cid_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $tparams->get('cid_allowed_parent'), $depth_limit = 0);
                $disabled_cats = $tparams->get('cid_allowed_parent_disable', 1) ? array($tparams->get('cid_allowed_parent')) : array();
            } else {
                $cid_tree =& $categories;
                $disabled_cats = array();
            }
            // Get author's maximum allowed categories per item and set js limitation
            $max_cat_assign = !$authorparams ? 0 : intval($authorparams->get('max_cat_assign', 0));
            $document->addScriptDeclaration('
				max_cat_assign_fc = ' . $max_cat_assign . ';
				existing_cats_fc  = ["' . implode('","', $selectedcats) . '"];
			');
            $class = "mcat use_select2_lib select2_list_selected";
            $class .= $max_cat_assign ? " validate-fccats" : " validate";
            $attribs = 'class="' . $class . '" multiple="multiple" size="20"';
            $attribs .= $enable_cid_selector ? '' : ' disabled="disabled"';
            $fieldname = 'jform[cid][]';
            $skip_subtrees = $featured_cats_parent ? array($featured_cats_parent) : array();
            $lists['cid'] = ($enable_cid_selector ? '' : '<label class="label" style="float:none; margin:0 6px 0 0 !important;">locked</label>') . flexicontent_cats::buildcatselect($cid_tree, $fieldname, $selectedcats, false, $attribs, true, true, $actions_allowed, $require_all = true, $skip_subtrees, $disable_subtrees = array(), $custom_options = array(), $disabled_cats);
        } else {
            if (count($selectedcats) > 1) {
                foreach ($selectedcats as $catid) {
                    $cat_titles[$catid] = $globalcats[$catid]->title;
                }
                $lists['cid'] .= implode(', ', $cat_titles);
            } else {
                $lists['cid'] = false;
            }
        }
        // Main category form field
        $class = 'scat use_select2_lib';
        if ($perms['multicat']) {
            $class .= ' validate-catid';
        } else {
            $class .= ' required';
        }
        $attribs = 'class="' . $class . '"';
        $fieldname = 'jform[catid]';
        $enable_catid_selector = $isnew && !$tparams->get('catid_default') || !$isnew && empty($item->catid) || $perms['canchange_cat'];
        if ($tparams->get('catid_allowed_parent')) {
            $catid_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $tparams->get('catid_allowed_parent'), $depth_limit = 0);
            $disabled_cats = $tparams->get('catid_allowed_parent_disable', 1) ? array($tparams->get('catid_allowed_parent')) : array();
        } else {
            $catid_tree =& $categories;
            $disabled_cats = array();
        }
        $lists['catid'] = false;
        if (!empty($catid_tree)) {
            $disabled = $enable_catid_selector ? '' : ' disabled="disabled"';
            $attribs .= $disabled;
            $lists['catid'] = ($enable_catid_selector ? '' : '<label class="label" style="float:none; margin:0 6px 0 0 !important;">locked</label>') . flexicontent_cats::buildcatselect($catid_tree, $fieldname, $item->catid, 2, $attribs, true, true, $actions_allowed, $require_all = true, $skip_subtrees = array(), $disable_subtrees = array(), $custom_options = array(), $disabled_cats);
        } else {
            if (!$isnew && $item->catid) {
                $lists['catid'] = $globalcats[$item->catid]->title;
            }
        }
        //buid types selectlist
        $class = 'required use_select2_lib';
        $attribs = 'class="' . $class . '"';
        $fieldname = 'jform[type_id]';
        $elementid = 'jform_type_id';
        $lists['type'] = flexicontent_html::buildtypesselect($types, $fieldname, $typesselected->id, 1, $attribs, $elementid, $check_perms = true);
        //build languages list
        $allowed_langs = !$authorparams ? null : $authorparams->get('langs_allowed', null);
        $allowed_langs = !$allowed_langs ? null : FLEXIUtilities::paramToArray($allowed_langs);
        if (!$isnew && $allowed_langs) {
            $allowed_langs[] = $item->language;
        }
        // We will not use the default getInput() function of J1.6+ since we want to create a radio selection field with flags
        // we could also create a new class and override getInput() method but maybe this is an overkill, we may do it in the future
        $lists['languages'] = flexicontent_html::buildlanguageslist('jform[language]', 'class="use_select2_lib"', $item->language, 2, $allowed_langs);
        // Label for current item state: published, unpublished, archived etc
        switch ($item->state) {
            case 0:
                $published = JText::_('FLEXI_UNPUBLISHED');
                break;
            case 1:
                $published = JText::_('FLEXI_PUBLISHED');
                break;
            case -1:
                $published = JText::_('FLEXI_ARCHIVED');
                break;
            case -3:
                $published = JText::_('FLEXI_PENDING');
                break;
            case -5:
                $published = JText::_('FLEXI_IN_PROGRESS');
                break;
            case -4:
            default:
                $published = JText::_('FLEXI_TO_WRITE');
                break;
        }
        // **************************************************************
        // Handle Item Parameters Creation and Load their values for J1.5
        // In J1.6+ we declare them in the item form XML file
        // **************************************************************
        if (JHTML::_('date', $item->publish_down, 'Y') <= 1969 || $item->publish_down == $db->getNullDate() || empty($item->publish_down)) {
            $form->setValue('publish_down', null, '');
            // Setting to text will break form date element
        }
        // ****************************
        // Handle Template related work
        // ****************************
        // (a) Get the templates structures used to create form fields for template parameters
        $themes = flexicontent_tmpl::getTemplates();
        $tmpls_all = $themes->items;
        // (b) Get Content Type allowed templates
        $allowed_tmpls = $tparams->get('allowed_ilayouts');
        $type_default_layout = $tparams->get('ilayout', 'default');
        if (empty($allowed_tmpls)) {
            $allowed_tmpls = array();
        } else {
            if (!is_array($allowed_tmpls)) {
                $allowed_tmpls = explode("|", $allowed_tmpls);
            }
        }
        // (c) Add default layout, unless all templates allowed (=array is empty)
        if (count($allowed_tmpls) && !in_array($type_default_layout, $allowed_tmpls)) {
            $allowed_tmpls[] = $type_default_layout;
        }
        // (d) Create array of template data according to the allowed templates for current content type
        if (count($allowed_tmpls)) {
            foreach ($tmpls_all as $tmpl) {
                if (in_array($tmpl->name, $allowed_tmpls)) {
                    $tmpls[] = $tmpl;
                }
            }
        } else {
            $tmpls = $tmpls_all;
        }
        // (e) Apply Template Parameters values into the form fields structures
        foreach ($tmpls as $tmpl) {
            $jform = new JForm('com_flexicontent.template.item', array('control' => 'jform', 'load_data' => true));
            $jform->load($tmpl->params);
            $tmpl->params = $jform;
            foreach ($tmpl->params->getGroup('attribs') as $field) {
                $fieldname = $field->__get('fieldname');
                $value = $item->itemparams->get($fieldname);
                if (strlen($value)) {
                    $tmpl->params->setValue($fieldname, 'attribs', $value);
                }
            }
        }
        // ******************************
        // Assign data to VIEW's template
        // ******************************
        $this->assignRef('document', $document);
        $this->assignRef('lists', $lists);
        $this->assignRef('row', $item);
        if (FLEXI_J16GE) {
            $this->assignRef('form', $form);
        } else {
            $this->assignRef('editor', $editor);
            $this->assignRef('pane', $pane);
            $this->assignRef('formparams', $formparams);
        }
        if ($enable_translation_groups) {
            $this->assignRef('lang_assocs', $langAssocs);
        }
        if (FLEXI_FISH || FLEXI_J16GE) {
            $this->assignRef('langs', $langs);
        }
        $this->assignRef('typesselected', $typesselected);
        $this->assignRef('published', $published);
        $this->assignRef('nullDate', $nullDate);
        $this->assignRef('subscribers', $subscribers);
        $this->assignRef('fields', $fields);
        $this->assignRef('versions', $versions);
        $this->assignRef('ratings', $ratings);
        $this->assignRef('pagecount', $pagecount);
        $this->assignRef('params', $params);
        $this->assignRef('tparams', $tparams);
        $this->assignRef('tmpls', $tmpls);
        $this->assignRef('usedtags', $usedtags);
        $this->assignRef('perms', $perms);
        $this->assignRef('current_page', $current_page);
        // Clear custom form data from session
        $app->setUserState($form->option . '.edit.' . $form->context . '.custom', false);
        $app->setUserState($form->option . '.edit.' . $form->context . '.jfdata', false);
        $app->setUserState($form->option . '.edit.' . $form->context . '.unique_tmp_itemid', false);
        if ($print_logging_info) {
            $start_microtime = microtime(true);
        }
        parent::display($tpl);
        if ($print_logging_info) {
            $fc_run_times['form_rendering'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
        }
    }
示例#27
0
 protected function _export($start)
 {
     // do we have a valid filename
     $this->_filename = Sh404sefHelperFiles::createFileName($this->_filename, 'sh404sef_export_' . $this->_context);
     // put some data in the file
     $end = $start + self::MAX_PAGEIDS_PER_STEP + 1;
     $end = $end > $this->_total ? $this->_total : $end;
     // fetch pageIds record from model
     $model = ShlMvcModel_Base::getInstance('aliases', 'Sh404sefModel');
     $model->setContext('aliases.default');
     $options = (object) array('layout' => 'default', 'includeHomeData' => true);
     $records = $model->getList($options, $returnZeroElement = false, $start, $forcedLimit = self::MAX_PAGEIDS_PER_STEP);
     // do we need a header written to the file, for first record
     $header = $start == 0 ? Sh404sefHelperGeneral::getExportHeaders($this->_context) . "\n" : '';
     // format them for text file output
     $data = '';
     $counter = $start;
     $glue = Sh404sefHelperFiles::$stringDelimiter . Sh404sefHelperFiles::$fieldDelimiter . Sh404sefHelperFiles::$stringDelimiter;
     if (!empty($records)) {
         foreach ($records as $record) {
             $counter++;
             if ($record->newurl == sh404SEF_HOMEPAGE_CODE) {
                 $record->newurl = '__ Homepage __';
             }
             $textRecord = $record->alias . $glue . $record->oldurl . $glue . $record->newurl . $glue . $record->type . $glue . $record->hits . Sh404sefHelperFiles::$stringDelimiter;
             $line = Sh404sefHelperFiles::$stringDelimiter . $counter . $glue . $textRecord;
             $data .= $line . "\n";
         }
     }
     // prepare data for storage
     if (!empty($header)) {
         // first record written to file, prepend header
         $data = $header . $data;
     }
     // store in file
     $status = Sh404sefHelperFiles::appendToFile($this->_filename, $data);
     // return any error
     return $status;
 }
示例#28
0
function shGetNameFromIsoCode($langCode)
{
    static $shLangNameCache = null;
    global $shMosConfig_lang, $shMosConfig_locale, $shLangNameCache;
    if (empty($shLangNameCache)) {
        $type = shIsMultilingual();
        if ($type !== false) {
            $languages = Sh404sefHelperGeneral::getInstalledLanguagesList();
            foreach ($languages as $language) {
                $jfIsoCode = empty($language->shortcode) ? $language->iso : $language->shortcode;
                $shLangNameCache[$jfIsoCode] = $language->code;
            }
            return empty($shLangNameCache[$langCode]) ? $shMosConfig_locale : $shLangNameCache[$langCode];
        } else {
            // no joomfish, so it has to be default language
            return $shMosConfig_locale;
        }
    } else {
        return empty($shLangNameCache[$langCode]) ? $shMosConfig_locale : $shLangNameCache[$langCode];
    }
}
示例#29
0
 protected function _export($start)
 {
     // do we have a valid filename
     $this->_filename = Sh404sefHelperFiles::createFileName($this->_filename, 'sh404sef_export_' . $this->_context);
     // put some data in the file
     $end = $start + self::MAX_PAGEIDS_PER_STEP + 1;
     $end = $end > $this->_total ? $this->_total : $end;
     // fetch shURLs record from model
     $model =& JModel::getInstance('urls', 'Sh404sefModel');
     $model->setContext('urls.view404');
     $options = (object) array('layout' => 'view404');
     $records = $model->getList($options, $returnZeroElement = false, $start, $forcedLimit = self::MAX_PAGEIDS_PER_STEP);
     // do we need a header written to the file, for first record
     $header = $start == 0 ? Sh404sefHelperGeneral::getExportHeaders($this->_context) . "\n" : '';
     // format them for text file output
     $data = '';
     $counter = $start;
     $glue = Sh404sefHelperFiles::$stringDelimiter . Sh404sefHelperFiles::$fieldDelimiter . Sh404sefHelperFiles::$stringDelimiter;
     if (!empty($records)) {
         foreach ($records as $record) {
             $counter++;
             $textRecord = $record->oldurl . $glue . $record->newurl . $glue . $record->cpt . $glue . $record->rank . $glue . $record->dateadd . $glue . '' . $glue . '' . $glue . '' . $glue . '' . $glue . '' . Sh404sefHelperFiles::$stringDelimiter;
             $line = Sh404sefHelperFiles::$stringDelimiter . $counter . $glue . $textRecord;
             $data .= $line . "\n";
         }
     }
     // prepare data for storage
     if (!empty($header)) {
         // first record written to file, prepend header
         $data = $header . $data;
     }
     // store in file
     $status = Sh404sefHelperFiles::appendToFile($this->_filename, $data);
     // return any error
     return $status;
 }
示例#30
0
 /**
  * Create toolbar for 404 pages template
  *
  * @param midxed $params
  */
 private function _makeToolbarView404($params = null)
 {
     $mainframe =& JFactory::getApplication();
     // Get the JComponent instance of JToolBar
     $bar =& JToolBar::getInstance('toolbar');
     // and connect to our buttons
     $bar->addButtonPath(JPATH_COMPONENT . DS . 'classes');
     // add title
     $title = Sh404sefHelperGeneral::makeToolbarTitle(JText::_('COM_SH404SEF_404_MANAGER'), $icon = 'sh404sef', $class = 'sh404sef-toolbar-title');
     $mainframe->set('JComponentTitle', $title);
     // add edit button
     $params['class'] = 'modaltoolbar';
     $params['size'] = array('x' => 800, 'y' => 600);
     unset($params['onClose']);
     $url = 'index.php?option=com_sh404sef&c=editurl&task=edit&tmpl=component';
     $bar->appendButton('Shpopuptoolbarbutton', 'edit', $url, JText::_('Edit'), $msg = '', $task = 'edit', $list = true, $hidemenu = true, $params);
     // add delete button
     $params['class'] = 'modaltoolbar';
     $params['size'] = array('x' => 500, 'y' => 300);
     unset($params['onClose']);
     $url = 'index.php?option=com_sh404sef&c=editurl&task=confirmdelete404&tmpl=component';
     $bar->appendButton('Shpopuptoolbarbutton', 'delete', $url, JText::_('Delete'), $msg = JText::_('VALIDDELETEITEMS', true), $task = 'delete', $list = true, $hidemenu = true, $params);
     // separator
     JToolBarHelper::divider();
     // add import button
     $params['class'] = 'modaltoolbar';
     $params['size'] = array('x' => 500, 'y' => 300);
     unset($params['onClose']);
     $url = 'index.php?option=com_sh404sef&c=wizard&task=start&tmpl=component&optype=export&opsubject=view404';
     $bar->appendButton('Shpopuptoolbarbutton', 'export', $url, JText::_('Export'), $msg = '', $task = 'export', $list = false, $hidemenu = true, $params);
     // separator
     JToolBarHelper::divider();
     // add purge and purge selected  buttons
     $params['class'] = 'modaltoolbar';
     $params['size'] = array('x' => 500, 'y' => 300);
     unset($params['onClose']);
     $url = 'index.php?option=com_sh404sef&c=urls&task=confirmpurge404&tmpl=component';
     $bar->appendButton('Shpopuptoolbarbutton', 'purge', $url, JText::_('COM_SH404SEF_PURGE'), $msg = JText::_('VALIDDELETEITEMS', true), $task = 'purge', $list = false, $hidemenu = true, $params);
     // separator
     JToolBarHelper::divider();
 }