Ejemplo n.º 1
0
 /**
  * Displays the view.
  *
  * @param  string $tpl the template name
  * 
  * @return void
  * @since  1.0
  */
 public function display($tpl = null)
 {
     JHTML::_('behavior.modal');
     JHTML::stylesheet('media/com_newsletter/css/admin.css');
     JHTML::stylesheet('media/com_newsletter/css/configuration.css');
     JHTML::script('media/com_newsletter/js/migur/js/core.js');
     JHTML::script('administrator/components/com_newsletter/views/configuration/configuration.js');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     EnvironmentHelper::showWarnings(array('checkJoomla', 'checkImap', 'checkLogs', 'checkAcl'));
     $this->general = JComponentHelper::getParams('com_newsletter');
     //$model = JModel::getInstance('extensions', 'NewsletterModel');
     //$this->modules = $model->getModules();
     //$this->plugins = $model->getPlugins();
     $this->modules = MigurModuleHelper::getSupported();
     $this->plugins = MigurPluginHelper::getSupported();
     $this->form = $this->get('Form');
     $this->addToolbar();
     parent::display($tpl);
 }
Ejemplo n.º 2
0
 /**
  * Displays the view.
  *
  * @param  string $tpl the template name
  *
  * @return void
  * @since  1.0
  */
 public function display($tpl = null)
 {
     JHTML::stylesheet('media/com_newsletter/css/admin.css');
     JHTML::stylesheet('media/com_newsletter/css/extension.css');
     JHTML::script('media/com_newsletter/js/migur/js/core.js');
     JHTML::script(JURI::root() . "/administrator/components/com_newsletter/views/extension/submitbutton.js");
     $type = JRequest::getString('type', '');
     $native = JRequest::getInt('native', null);
     $extensionId = JRequest::getInt('extension_id', 0);
     if ($type == 'plugin') {
         $exts = MigurPluginHelper::getSupported(array('extension_id' => $extensionId, 'native' => $native));
     } else {
         $exts = MigurModuleHelper::getSupported(array('extension_id' => $extensionId, 'native' => $native));
     }
     $lang = JFactory::getLanguage();
     $lang->load('com_content', JPATH_ADMINISTRATOR, null, false, false);
     $ext = $exts[0];
     $this->info = $ext->xml;
     if (JRequest::getString('layout') == 'edit') {
         $model = $this->getModel();
         $this->form = $model->getForm(array('module' => $ext->extension, 'native' => $ext->native, 'type' => $ext->type));
     }
     parent::display($tpl);
 }
Ejemplo n.º 3
0
 /**
  * Displays the view.
  *
  * @param  string $tpl the template name
  *
  * @return void
  * @since  1.0
  */
 public function display($tpl = null)
 {
     $isNew = !JRequest::getInt('newsletter_id', false);
     if ($isNew && !AclHelper::actionIsAllowed('newsletter.add') || !$isNew && !AclHelper::actionIsAllowed('newsletter.edit')) {
         $msg = $isNew ? 'JLIB_APPLICATION_ERROR_CREATE_RECORD_NOT_PERMITTED' : 'JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED';
         JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_newsletter&view=newsletters', false), JText::_($msg), 'error');
         return;
     }
     //TODO: Need to move css/js to SetDocument
     JHTML::stylesheet('media/com_newsletter/css/admin.css');
     JHTML::stylesheet('media/com_newsletter/css/newsletter.css');
     JHTML::script('media/com_newsletter/js/migur/js/core.js');
     JHTML::script('media/com_newsletter/js/migur/js/ajax.js');
     JHTML::script('media/com_newsletter/js/migur/js/widgets.js');
     JHTML::script('media/com_newsletter/js/migur/js/moodialog/MooDialog.js');
     JHTML::script('media/com_newsletter/js/migur/js/moodialog/MooDialog.Request.js');
     JHTML::script('media/com_newsletter/js/migur/js/moodialog/MooDialog.IFrame.js');
     JHTML::stylesheet('media/com_newsletter/js/migur/js/moodialog/css/MooDialog.css');
     JHTML::script('media/com_newsletter/js/migur/js/autocompleter/Observer.js');
     JHTML::script('media/com_newsletter/js/migur/js/autocompleter/Autocompleter.js');
     JHTML::script('media/com_newsletter/js/migur/js/autocompleter/Autocompleter.Local.js');
     JHTML::stylesheet('media/com_newsletter/js/migur/js/autocompleter/css/Autocompleter.css');
     JHTML::script('media/com_newsletter/js/migur/js/guide.js');
     JHTML::stylesheet('media/com_newsletter/css/guide.css');
     //TODO: Bulk-code. Need to refactor.
     JavascriptHelper::addObject('comParams', JComponentHelper::getParams('com_newsletter')->toArray());
     $nId = JRequest::getInt('newsletter_id');
     $script = $this->get('Script');
     $this->script = $script;
     // Get main form and data for newsletter
     $this->form = $this->get('Form', 'newsletter');
     $this->newsletter = $this->get('Item');
     $smtpModel = JModel::getInstance('SMtpProfile', 'NewsletterModelEntity');
     // Let's add J! profile
     $smtpp = $smtpModel->loadJoomla();
     JavascriptHelper::addObject('joomlaDe', JComponentHelper::getParams('com_newsletter')->toArray());
     // get the SmtpProfiles data
     $smtpprofilesManager = JModel::getInstance('smtpprofiles', 'NewsletterModel');
     $this->assignRef('smtpprofiles', $smtpprofilesManager->getAllItems('withDefault'));
     // get all the Extensions
     $this->modules = MigurModuleHelper::getSupported(array('withoutInfo' => true));
     $this->plugins = MigurPluginHelper::getSupported(array('withoutInfo' => true), 'com_newsletter.newsletter');
     // get the Extensions used in this newsletter
     $model = JModel::getInstance('newsletterext', 'NewsletterModel');
     $this->usedExts = $model->getExtensionsBy($nId);
     // Get a list of all templates
     $this->setModel(JModel::getInstance('templates', 'NewsletterModel'));
     $model = $this->getModel('templates');
     $templs = $model->getItems();
     $path = JPATH_COMPONENT . '/extensions/templates/';
     $filenames = JFolder::files($path, '^.*\\.xml$');
     if ($filenames === false) {
         JError::raiseError(500, implode("\n", array("Path {$path} not found")));
     }
     $this->templates = (object) array('items' => array(), 'path' => $path);
     $this->htmlTemplateId = null;
     foreach ($templs as $item) {
         $xml = new JSimpleXML();
         $xml->loadFile($path . $item->template);
         $str = trim($xml->document->template[0]->_data);
         $str = preg_replace('/<style.*>.*<\\/style>/s', '', $str);
         $str = str_replace('<position', '<div class="drop container-draggables"', $str);
         $id = strtolower(str_replace('.', '-', $item->template) . '-' . $item->t_style_id);
         $item->id = $id;
         $item->filename = $item->template;
         $item->template = $str;
         $this->templates->items[] = $item;
         if ($this->newsletter->t_style_id == $item->t_style_id) {
             $this->htmlTemplateId = $id;
             $this->t_style_id = $item->t_style_id;
         }
         unset($xml);
     }
     //attachments
     $this->attItems = array();
     $this->dynamicData = array('Name' => '[username]', 'Email' => '[useremail]', 'Site name' => '[sitename]', 'Subscription key' => '[subscription key]', 'Unsubscription link' => '[unsubscription link]', 'Confirmation link' => '[confirmation link]');
     $this->attItemslistDirn = "a.filename";
     $this->attItemslistOrder = "asc";
     // getting of an xml from
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     // We don't need toolbar in the modal window.
     if ($this->getLayout() !== 'modal') {
         $this->addToolbar();
     }
     $this->downloads = (array) DownloadHelper::getByNewsletterId($nId);
     JavascriptHelper::addObject('dataStorage', (object) array('htmlTemplate' => (object) array('template' => (object) array('id' => $this->htmlTemplateId), 'extensions' => (array) $this->usedExts), 'templates' => (array) $this->templates->items, 'modules' => (array) $this->modules, 'plugins' => (array) $this->plugins, 'newsletter' => NewsletterHelper::get($nId)));
     // Set the document
     $this->setDocument();
     parent::display($tpl);
 }
Ejemplo n.º 4
0
 /**
  * Method to trigger the events of Com_newsletter component's plugins
  * 
  * @param string $event - name of the event
  * 
  * @return boolean
  * @since  1.0
  */
 function triggerEvent($event)
 {
     $plugins = MigurPluginHelper::getUsedInNewsletter($this->getNewsletterId());
     foreach ($plugins as $plugin) {
         MigurPluginHelper::trigger($plugin->extension, $event, $plugin->params, $this);
     }
     return true;
 }