Beispiel #1
0
    JError::raiseError(403, JText::_("ALERTNOTAUTH"));
}
$vars = JRequest::getVar('vars');
$option = $vars['option'];
$comp_file = JRequest::getVar('comp');
$file = dirname(__FILE__) . DS . 'components' . DS . $option . DS . $comp_file . '.xml';
$template = '';
$xml =& JFactory::getXMLParser('Simple');
$xml->loadFile($file);
if (isset($xml->document) && isset($xml->document->_children)) {
    require_once JPATH_PLUGINS . DS . 'system' . DS . 'nonumberelements' . DS . 'helpers' . DS . 'parameters.php';
    $parameters =& NNParameters::getParameters();
    $xml_template = $parameters->getObjectFromXML($xml->document->_children);
    if (isset($xml_template->params) && isset($xml_template->params->required)) {
        require_once dirname(__FILE__) . DS . 'helper.php';
        if (!is_object($xml_template->params->required) || modAddToMenu::checkRequiredFields($xml_template->params->required, $vars)) {
            $template = $xml_template->params;
        }
    }
}
if (!$template) {
    return;
}
$lang =& JFactory::getLanguage();
$lang->load('mod_addtomenu', JPATH_ADMINISTRATOR);
$lang->load('com_menus', JPATH_ADMINISTRATOR);
$lang->load($comp_file, JPATH_ADMINISTRATOR);
$insert = JRequest::getVar('insert');
if ($insert) {
    insertMenuItem($template);
} else {
Beispiel #2
0
 function render(&$params)
 {
     $option = JRequest::getCmd('option');
     $this->vars = array();
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     require_once JPATH_PLUGINS . DS . 'system' . DS . 'nonumberelements' . DS . 'helpers' . DS . 'parameters.php';
     $parameters =& NNParameters::getParameters();
     $folder = dirname(__FILE__) . DS . 'components' . DS . $option;
     $comp_file = '';
     foreach (JFolder::files($folder, '.xml') as $filename) {
         $file = $folder . DS . $filename;
         $xml =& JFactory::getXMLParser('Simple');
         $xml->loadFile($file);
         if (isset($xml->document) && isset($xml->document->_children)) {
             $template = $parameters->getObjectFromXML($xml->document->_children);
             if (isset($template->params) && isset($template->params->required)) {
                 if (!is_object($template->params->required) || modAddToMenu::checkRequiredFields($template->params->required)) {
                     $template = $template->params;
                     $comp_file = JFile::stripExt($filename);
                     break;
                 }
             }
         }
     }
     if (!$comp_file) {
         return;
     }
     JHTML::_('behavior.modal');
     require_once JPATH_PLUGINS . DS . 'system' . DS . 'nonumberelements' . DS . 'helpers' . DS . 'functions.php';
     $this->functions =& NNFunctions::getFunctions();
     $mt_version = $this->functions->getJSVersion();
     $document =& JFactory::getDocument();
     $document->addScript(JURI::root(true) . '/administrator/modules/mod_addtomenu/addtomenu/js/script' . $mt_version . '.js');
     $document->addStyleSheet(JURI::root(true) . '/administrator/modules/mod_addtomenu/addtomenu/css/style.css');
     // set height for popup
     $popup_height = 320;
     if (isset($template->adjust_height)) {
         $popup_height += $template->adjust_height;
     }
     if (isset($template->extras) && is_object($template->extras) && isset($template->extras->extra)) {
         if (!is_array($template->extras->extra)) {
             $template->extras->extra = array($template->extras->extra);
         }
         $haselements = 0;
         // + heights of elements
         foreach ($template->extras->extra as $element) {
             if (isset($element->type)) {
                 $haselements = 1;
                 switch ($element->type) {
                     case 'radio':
                         // add height for every line
                         $popup_height += 8 + 16 * count($element['value']);
                         break;
                     case 'textarea':
                         $popup_height += 111;
                         break;
                     case 'hidden':
                     case 'toggler':
                         // no height
                         break;
                     default:
                         $popup_height += 24;
                         break;
                 }
             }
         }
         if ($haselements) {
             // + height of title
             $popup_height += 23;
         }
     }
     $link = 'index.php?nn_qp=1';
     $link .= '&folder=administrator.modules.mod_addtomenu.addtomenu';
     $link .= '&file=addtomenu.inc.php';
     $link .= '&comp=' . $comp_file;
     $uri =& JFactory::getURI();
     $url_query = $uri->getQuery(1);
     foreach ($url_query as $key => $val) {
         $this->vars[$key] = $val;
     }
     if (!isset($this->vars['option'])) {
         $this->vars['option'] = $option;
     }
     foreach ($this->vars as $key => $val) {
         if (is_array($val)) {
             $val = $val['0'];
         }
         $link .= '&vars[' . $key . ']=' . $val;
     }
     $text = JText::_($params->get('icon_text', 'ADD_TO_MENU'));
     $title = $text;
     $class = '';
     if ($params->get('display_link', 'both') == 'text') {
         $class = 'no_icon';
     } else {
         if ($params->get('display_link', 'both') == 'icon') {
             $text = '';
             $class = 'no_text';
         }
     }
     if ($params->get('display_tooltip', 1)) {
         JHTML::_('behavior.tooltip');
         $class .= ' hasTip';
         $title = JText::_('ADD_TO_MENU') . '::' . JText::_('Add') . ': ' . JText::_($template->name);
     }
     echo '<a href="' . $link . '" onfocus="this.blur();" id="addtomenu" class="modal" rel="{handler: \'iframe\', size: {x: 400, y: ' . $popup_height . '}}"><span class="' . $class . '"  title="' . $title . '">' . $text . '</span></a>';
 }
 function render()
 {
     $option = JRequest::getCmd('option');
     $this->vars = array();
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     $comp_file = '';
     $folder = JPATH_ADMINISTRATOR . '/components/' . $option . '/addtomenu';
     if (!JFolder::exists($folder)) {
         $folder = JPATH_ADMINISTRATOR . '/modules/mod_addtomenu/addtomenu/components/' . $option;
     }
     foreach (JFolder::files($folder, '.xml') as $filename) {
         $file = $folder . '/' . $filename;
         $xml = JFactory::getXMLParser('Simple');
         $xml->loadFile($file);
         if (isset($xml->document) && isset($xml->document->_children)) {
             $template = $this->parameters->getObjectFromXML($xml->document->_children);
             if (isset($template->params) && isset($template->params->required)) {
                 if (!is_object($template->params->required) || modAddToMenu::checkRequiredFields($template->params->required)) {
                     $template = $template->params;
                     $comp_file = JFile::stripExt($filename);
                     break;
                 }
             }
         }
     }
     if (!$comp_file) {
         return;
     }
     $opt = $option;
     // load the admin language file
     if ($opt == 'com_categories') {
         $opt = JRequest::getCmd('extension', 'com_content');
     }
     $lang = JFactory::getLanguage();
     if ($lang->getTag() != 'en-GB') {
         // Loads English language file as fallback (for undefined stuff in other language file)
         $lang->load('mod_addtomenu', JPATH_ADMINISTRATOR, 'en-GB');
         $lang->load($opt, JPATH_ADMINISTRATOR, 'en-GB');
         $lang->load($opt . '.sys', JPATH_ADMINISTRATOR, 'en-GB');
     }
     $lang->load('mod_addtomenu', JPATH_ADMINISTRATOR, null, 1);
     $lang->load($opt, JPATH_ADMINISTRATOR, null, 1);
     $lang->load($opt . '.sys', JPATH_ADMINISTRATOR, null, 1);
     JHtml::_('behavior.modal');
     require_once JPATH_PLUGINS . '/system/nnframework/helpers/versions.php';
     $version = NoNumberVersions::getXMLVersion('addtomenu', 'module', 1, 1);
     $nn_version = NoNumberVersions::getXMLVersion(null, null, null, 1);
     $document = JFactory::getDocument();
     $document->addStyleSheet(JURI::root(true) . '/plugins/system/nnframework/css/status.css' . $nn_version);
     $document->addScript(JURI::root(true) . '/administrator/modules/mod_addtomenu/addtomenu/js/script.js' . $version);
     $document->addStyleSheet(JURI::root(true) . '/administrator/modules/mod_addtomenu/addtomenu/css/style.css' . $version);
     // set height for popup
     $popup_width = 600 + (int) $this->params->adjust_modal_w;
     $popup_height = 320 + (int) $this->params->adjust_modal_h;
     if (isset($template->adjust_height)) {
         $popup_height += (int) $template->adjust_height;
     }
     if (isset($template->extras) && is_object($template->extras) && isset($template->extras->extra)) {
         if (!is_array($template->extras->extra)) {
             $template->extras->extra = array($template->extras->extra);
         }
         $haselements = 0;
         // + heights of elements
         foreach ($template->extras->extra as $element) {
             if (isset($element->type)) {
                 $haselements = 1;
                 switch ($element->type) {
                     case 'radio':
                         // add height for every line
                         $popup_height += 8 + 16 * count($element->values->value);
                         break;
                     case 'textarea':
                         $popup_height += 111;
                         break;
                     case 'hidden':
                     case 'toggler':
                         // no height
                         break;
                     default:
                         $popup_height += 24;
                         break;
                 }
             }
         }
         if ($haselements) {
             // + height of title
             $popup_height += 23;
         }
     }
     $link = 'index.php?nn_qp=1';
     $link .= '&folder=administrator.modules.mod_addtomenu.addtomenu';
     $link .= '&file=addtomenu.inc.php';
     $link .= '&comp=' . $comp_file;
     $uri = JFactory::getURI();
     $url_query = $uri->getQuery(1);
     foreach ($url_query as $key => $val) {
         $this->vars[$key] = $val;
     }
     if (!isset($this->vars['option'])) {
         $this->vars['option'] = $option;
     }
     foreach ($this->vars as $key => $val) {
         if (is_array($val)) {
             $val = $val['0'];
         }
         $link .= '&vars[' . $key . ']=' . $val;
     }
     $text = JText::_($this->params->icon_text);
     $title = $text;
     $class = '';
     if ($this->params->display_link == 'text') {
         $class = 'no_icon';
     } else {
         if ($this->params->display_link == 'icon') {
             $text = '';
             $class = 'no_text';
         }
     }
     if ($this->params->display_tooltip) {
         JHtml::_('behavior.tooltip');
         $class .= ' hasTip';
         $title = JText::_('ADD_TO_MENU') . '::' . JText::_($template->name);
     }
     $html = '<a href="' . $link . '" onfocus="this.blur();" class="nn_status_link modal" rel="{handler: \'iframe\', size: {x: ' . $popup_width . ', y: ' . $popup_height . '}}"><span class="nn_status_text ' . $class . '"  title="' . $title . '">' . $text . '</span></a>';
     $html = '<span class="addtomenu_status nn_status">' . $html . '</span>';
     echo $html;
 }