/** * <p>Templates controller</p> * <p>This function is the controller to view the templates view</p> * @author Joobi Limited <wwww.joobi.co> */ function templates($action, $task, $template_id) { $my = JFactory::getUser(); $css = '.icon-48-templates { background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/templates.png)}'; $doc = JFactory::getDocument(); $doc->addStyleDeclaration($css, $type = 'text/css'); $img = 'templates.png'; $templatesearch = JRequest::getVar('templatesearch', ''); $showTemplates = true; // defined toggle for publish and unpublish of mailings $willRedirect = false; $checkToggle = false; $cid = JRequest::getVar('cid'); if (empty($template_id)) { if (!empty($cid) && is_array($cid)) { $template_id = $cid[key($cid)]; } } else { if (empty($cid)) { $cid[] = $template_id; } } if (!empty($task) && $task == 'togle') { $checkToggle = true; // $id = JRequest::getVar( 'templateid' ); $id = $template_id; $col = JRequest::getVar('col'); $template_id = !empty($id) && !empty($col) ? $id : $template_id; $task = !empty($template_id) && !empty($col) ? $col : $task; $willRedirect = true; } switch ($task) { case 'new': case 'add': $showTemplates = false; $template = null; $form['main'] = " <form action='index.php' method='post' name='adminForm' enctype='multipart/form-data' id=\"adminForm\"> \n"; $message = isset($message) ? $message : ''; backHTML::_header(_JNEWS_TEMPLATES, 'templates.png', $message, $task, $action); backHTML::formStart('template', 0, ''); echo jNews_TemplatesHTML::createTemplate($template, $form); $go[] = jnews::makeObj('act', $action); backHTML::formEnd($go); break; case 'edit': $showTemplates = false; $template = jNews_Templates::loadOneTemplate('*', $template_id); $form['main'] = " <form action='index.php' method='post' name='adminForm' enctype='multipart/form-data' id=\"adminForm\">"; $message = isset($message) ? $message : ''; backHTML::_header(_JNEWS_TEMPLATES, 'templates.png', $message, $task, $action); backHTML::formStart('template', 0, ''); echo jNews_TemplatesHTML::createTemplate($template, $form); $go[] = jnews::makeObj('act', $action); $go[] = jnews::makeObj('template_id', $template_id); backHTML::formEnd($go); break; case 'save': JRequest::checkToken() or die('Invalid Token'); $message = jnews::printYN(jNews_Templates::saveTemplate($task, $template_id), _JNEWS_TEMPLATE_SAVED, _JNEWS_ERROR); jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates', $message); break; case 'apply': JRequest::checkToken() or die('Invalid Token'); $message = ''; $message .= jnews::printYN(jNews_Templates::saveTemplate($task, $template_id), _JNEWS_TEMPLATE_SAVED, _JNEWS_ERROR); $id = empty($template_id) ? jNews_Templates::loadOneTemplate('template_id', '', 'template_id', 'DESC') : $template_id; $converMessage = JRequest::getVar('message', '', '', 'string', JREQUEST_ALLOWRAW); if (!empty($converMessage)) { $message .= '<br/>'; $message .= implode("", $converMessage); } jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates&task=edit&template_id=' . $id, $message); break; case 'publish': if (!$checkToggle) { JRequest::checkToken() or die('Invalid Token'); } $message = jnews::printYN(jNews_Templates::updateTemplate($cid, 'published', true), 'Successfully published template!', 'Error publishing the template!'); jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates', $message); break; case 'unpublish': if (!$checkToggle) { JRequest::checkToken() or die('Invalid Token'); } $condition = jNews_Templates::updateTemplate($cid, 'published', false); if ($condition) { $message = jnews::printM('ok', 'Successfully unpublished template!'); } else { $message = jnews::printM('defaulterror', 'Unable to unpublished default template!'); } // $message = jnews::defaultYN( jNews_Templates::updateTemplate($template_id,'published', false) , 'Successfully unpublished template!' , 'Unable to unpublished default template!' ); if ($willRedirect) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates', $message); } break; case 'copy': JRequest::checkToken() or die('Invalid Token'); $message = jnews::printYN(jNews_Templates::copyTemplate($template_id), _JNEWS_TEMPLATE . _JNEWS_SUCCESS_COPIED, _JNEWS_ERROR); $showTemplates = true; break; case 'default': $success = false; //set all the templates to premium = 0 if (jNews_Templates::updateTemplate($template_id, 'default', false, false)) { $success = true; } //set the template published and premium if ($success) { jNews_Templates::updateTemplate($template_id, 'default', true, true); } $message = jnews::printYN($success, 'Successfully set the template to default!', 'Unable to set template to default!'); jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates', $message); break; case 'delete': JRequest::checkToken() or die('Invalid Token'); $showTemplates = true; $isDefault = jNews_Templates::loadOneTemplate('premium', $template_id); if (!$isDefault) { $message = jnews::printYN(jNews_Templates::deleteTemplate($cid), _JNEWS_TEMPLATE . _JNEWS_SUCCESS_DELETED, _JNEWS_ERROR); } else { $message = jnews::printM('red', _JNEWS_TEMPLATE_DEFAULT_NODEL); } break; case 'cpanel': backHTML::controlPanel(); return true; break; case 'toggle': JRequest::checkToken() or die('Invalid Token'); // main toggle for all usage $listid = JRequest::getVar('listid'); $column = JRequest::getVar('col'); if (!empty($listid) && !empty($column)) { $passObj = new stdClass(); $passObj->tableName = '#__jnews_lists'; $passObj->columnName = $column; $passObj->whereColumn = 'id'; $passObj->whereColumnValue = $listid; jnews::toggle($passObj); } jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates'); break; case 'tempupload': // HTML for upload template // JRequest::checkToken() or die( 'Invalid Token' ); $html = '<form action="index.php?option=' . JNEWS_OPTION . '&act=templates&task=upload" method="post" name="adminForm" enctype="multipart/form-data" id="adminForm">'; $html .= '<table style="width:100%;padding:100px;">'; $html .= '<tr>'; $html .= '<td style="text-align:center;"> <input type="FILE" name="tempupload"> </td>'; $html .= '</tr><tr">'; $html .= '<td style="text-align:center;padding:20px;"> <input type="submit" value="Upload Template" style="width:130px;height:25px;"> </td>'; $html .= '</tr>'; $html .= '</table>'; if (version_compare(JVERSION, '3.0.0', '<')) { $html .= JHTML::_('form.token'); } else { $html .= JHtml::_('form.token'); } $html .= '</form><br/><br/>'; echo $html; $showTemplates = false; break; case 'sendtest': JRequest::checkToken() or die('Invalid Token'); //we save first the template $saveStatus = jNews_Templates::saveTemplate($task, $template_id); //then we send it if the template is successfully saved if ($saveStatus) { $message = jnews::printM('ok', _JNEWS_TEMPLATE_SAVED); $my = JFactory::getUser(); $mailing = new stdClass(); $receiver = new stdClass(); $status = false; $mailing->id = 1; $mailing->html = 1; $mailing->images = ''; $mailing->attachments = ''; $mailing->subject = jNews_Templates::loadOneTemplate('name', $template_id); $mailing->htmlcontent = jNews_Templates::loadOneTemplate('body', $template_id); $mailing->template_id = $template_id; $receiver->name = $my->name; $receiver->email = $my->email; $receiver->receive_html = 1; $receiver->user_id = $my->id; $mailerC = new jNews_ProcessMail(); $sendStatus = $mailerC->send($mailing, $receiver); $success = 'Template ' . $mailing->subject . ' successfully sent to ' . $receiver->email; $error = 'There is a problem in sending the template ' . $mailing->subject . ' <br/>' . _JNEWS_SENDTEST_CONFIGERROR; $message = $sendStatus ? jnews::printM('ok', $success) : jnews::printM('error', $error); } else { //otherwise we give an error message $message = jnews::printM('error', _JNEWS_ERROR); } jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates&task=edit&template_id=' . $template_id, $message); break; case 'upload': JRequest::checkToken() or die('Invalid Token'); $db = JFactory::getDBO(); $fileName = $_FILES['tempupload']['name']; $folderName = substr($fileName, 0, -4); // explode to array to compare and check if the uploaded file is a zip file $type = $_FILES['tempupload']['type']; // if zip is not found then return to previous upload page if (strtolower($type) != 'application/zip') { if (strtolower(substr($fileName, -4)) != '.zip') { if (version_compare(JVERSION, '1.6.0', '<')) { //j15 echo "<script> alert('" . addslashes(_JNEWS_UPLOAD_ZIP_INVALID) . "'); document.location.href='index.php?option='.JNEWS_OPTION.'&act=templates';</script>"; } else { if (version_compare(JVERSION, '3.0.0', '<')) { echo "<script> alert('" . addslashes(_JNEWS_UPLOAD_ZIP_INVALID) . "'); window.parent.SqueezeBox.close();</script>"; } else { echo "<script> alert('" . addslashes(_JNEWS_UPLOAD_ZIP_INVALID) . "'); jQuery(window.top.document).find(\"div.modal-backdrop\").click(); </script>"; } } break; } } $result = jNews_Templates::uploadTemplate(); if ($result) { // if success // read index.html of file for template body content $tempPath = JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'media' . DS . JNEWS_OPTION . DS . 'templates' . DS; $file = fopen($tempPath . $folderName . DS . 'index.html', "r") or exit("Unable to open file!"); $tempbody = array(); while (!feof($file)) { $tempbody[] = fgets($file); } //endwhile fclose($file); $tempbody = implode(' ', $tempbody); $standardCSSA = array(); $extraCSSStyles = ''; if (is_file($tempPath . $folderName . DS . 'css' . DS . 'style.css')) { //new template package with style.css file //we get here the css codes from the uploaded template $cssfile = fopen($tempPath . $folderName . DS . 'css' . DS . 'style.css', "r") or exit("Unable to open file!"); $cssstyle = array(); while (!feof($cssfile)) { $cssstyle[] = fgets($cssfile); } //endwhile fclose($cssfile); $cssstyle = implode(' ', $cssstyle); $cleanCSSstyle = jNews_Templates::cleanCSSComments($cssstyle); //cleancsscomments @(require_once JNEWSPATH_CLASS . 'class.cssinlinestyles.php'); if (class_exists('CSSToInlineStyles')) { $newCSSProcess = new CSSToInlineStyles(); $newCSSProcess->setCSS($cleanCSSstyle); $newCSSProcess->processCSS(); //we define the predefined selectors for the css $standardSelectorsA = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'a', 'ul', 'li', '.unsubscribe', '.subscriptions', '.content', '.title', '.readmore', '.online', '.aca_content', '.aca_title', '.aca_readmore', '.aca_online', '.aca_subscribe', '.aca_unsubscribe', '.aca_subscriptions'); $standardCSSA = $newCSSProcess->getStandardCSSTag($newCSSProcess->cssRules, $standardSelectorsA); $extraCSSStyles = $newCSSProcess->getExtraCSSTag($newCSSProcess->cssRules, $standardSelectorsA); } } // replace source image paths from 'images/' to 'media/.../templates/$FOLDERNAME/' $bodyImgA = JRequest::getVar('bodyImg'); if (is_file($tempPath . $folderName . DS . 'css' . DS . 'style.css')) { //new template package // $body = preg_replace('#images\/#', JNEWS_JPATH_LIVE . '/media/'. JNEWS_OPTION . '/templates/' . $folderName .'/images/', $tempbody); $origin = '"images/'; $destination = '"' . JNEWS_JPATH_LIVE . '/media/' . JNEWS_OPTION . '/templates/' . $folderName . '/images/'; $body = str_replace($origin, $destination, $tempbody); } else { // $body = preg_replace('#images\/#', JNEWS_JPATH_LIVE . '/media/'. JNEWS_OPTION . '/templates/'. $folderName.'/' , $tempbody); $origin = 'media/' . JNEWS_OPTION . '/templates/' . $folderName . '/'; $destination = JNEWS_JPATH_LIVE . '/media/' . JNEWS_OPTION . '/templates/' . $folderName . '/'; $body = str_replace($origin, $destination, $tempbody); } $template = null; $template->name = ucfirst($folderName); $template->description = ''; $template->created = time(); $template->body = addslashes($body); $template->altbody = ''; $template->premium = 0; $template->namekey = $folderName; $template->published = 1; $template->styles = addslashes(serialize($standardCSSA)); $template->csstyle = addslashes($extraCSSStyles); $template->thumbnail = ''; $templateA = (array) $template; $query = 'SELECT * FROM `#__jnews_templates` WHERE `namekey` = \'' . $template->namekey . '\' '; $db->setQuery($query); $findresult = $db->loadObject(); if (empty($findresult)) { // store template $status = jNews_Templates::storeTemplate($templateA); } else { //update template $query = 'UPDATE `#__jnews_templates` SET `body` = \'' . $template->body . '\' , `availability` = 1 WHERE `namekey`= \'' . $template->namekey . '\' AND `template_id`=' . $findresult->template_id; $db->setQuery($query); $status = $db->query(); } // upload success // display success message if ($status) { if (version_compare(JVERSION, '1.6.0', '<')) { //j15 echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_SUCCESS) . "'); document.location.href='index.php?option=" . JNEWS_OPTION . "&act=templates';</script>"; } else { //j16 echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_SUCCESS) . "'); window.parent.location.reload();</script>"; } } } else { // failed uploading // display an error message if (version_compare(JVERSION, '1.6.0', '<')) { //j15 echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_FAIL) . "'); document.location.href='index.php?option=" . JNEWS_OPTION . "&act=templates';</script>"; } else { if (version_compare(JVERSION, '3.0.0', '<')) { echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_FAIL) . "'); window.parent.SqueezeBox.close();</script>"; } else { echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_FAIL) . "'); jQuery(window.top.document).find(\"div.modal-backdrop\").click(); </script>"; } } } $showTemplates = false; break; case 'preview': $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">"; $forms['filter'] = " <form name='jnewsFilterForm' method='POST' action='index.php'> \n"; $id = JRequest::getInt('template_id', 0, 'request'); $body = jNews_Templates::loadOneTemplate('body', $id); jNews_Templates::includeStyles($body, $id); jNews_TemplatesHTML::previewTemplate($body, $forms); $showTemplates = false; break; case 'assign': $templatesearch = JRequest::getVar('templatesearch', ''); $linkTh = jNews_Tools::completeLink('option=' . JNEWS_OPTION, true, false, true); $forms['main'] = "<form action=" . $linkTh . " method='post' name='adminForm' id=\"adminForm\">"; $paginationStart = JRequest::getVar('pg'); if (!empty($paginationStart)) { $limitstart = 0; $limitend = $paginationStart; } else { $app = JFactory::getApplication(); $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int'); $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int'); } $limittotal = jNews_Templates::countTemplates(1, 1); $setLimit = new stdClass(); $setLimit->total = !empty($limittotal) ? $limittotal : 0; $setLimit->start = !empty($limitstart) ? $limitstart : 0; $setLimit->end = !empty($limitend) ? $limitend : 20; $templates = jNews_Templates::getTemplates(true, false, $templatesearch, $setLimit->start, $setLimit->end, null, 1); //first param to true to show only the published jNews_TemplatesHTML::assignTemplate($templates, $forms, $setLimit, $templatesearch); $showTemplates = false; break; } if ($showTemplates) { $start = JRequest::getVar('start', '0'); $templatesearch = JRequest::getVar('templatesearch', ''); $limit = -1; $message = isset($message) ? $message : ''; backHTML::_header(_JNEWS_TEMPLATES, $img, $message, $task, $action); $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">"; $forms['filter'] = " <form name='jnewsFilterForm' method='POST' action='index.php'> \n"; backHTML::formStart('show_template', '', ''); // added this code for pagination =========================== $paginationStart = JRequest::getVar('pg'); $app = JFactory::getApplication(); if (!empty($paginationStart)) { $limitstart = 0; $limitend = $paginationStart; } else { $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int'); $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int'); } $setSort = new stdClass(); $setSort->orderValue = $app->getUserStateFromRequest(JNEWS_OPTION . '.templates.filter_order', 'filter_order', 'premium', 'cmd'); $setSort->orderDir = $app->getUserStateFromRequest(JNEWS_OPTION . '.templates.filter_order_Dir', 'filter_order_Dir', 'desc', 'word'); $limittotal = jNews_Templates::countTemplates(); $setLimit = new stdClass(); $setLimit->total = !empty($limittotal) ? $limittotal : 0; $setLimit->start = !empty($limitstart) ? $limitstart : 0; $setLimit->end = !empty($limitend) ? $limitend : $limittotal; // recheck start if ($setLimit->total == $setLimit->end) { $setLimit->start = 0; } $templates = jNews_Templates::getTemplates(false, false, $templatesearch, $setLimit->start, $setLimit->end, $setSort); //recheck limit total [pagination] if (isset($setLimit->total) && !empty($templatesearch)) { $setLimit->total = !empty($temps) ? count($templates) : $setLimit->total; } jNews_TemplatesHTML::displayTemplateList($templates, $forms, $setLimit->start, $setLimit->end, $templatesearch, $action, $setLimit, $setSort); $go[] = jnews::makeObj('act', 'templates'); $go[] = jnews::makeObj('filter_order', $setSort->orderValue); $go[] = jnews::makeObj('filter_order_Dir', $setSort->orderDir); backHTML::formEnd($go); } return true; }
public static function insertTemplate($editor) { ?> <table style="border: 1px solid #000; width: 100%;" cellpadding="10" cellspacing="5"> <tbody> <tr> <td> <?php $applyEditor = $editor->setContent($editor->_name, 'newbody'); $script = "function changeTemplate(newbody,newaltbody,template_id){\n\t\t\tif(newbody.length>2){" . $applyEditor . "}\n\t\t\tvar vartextarea =\$('altbody'); if(newaltbody.length>2){vartextarea.setHTML(newaltbody);}\n\t\t\tvar vartempid =\$('tempid'); vartempid.value = tempid;}\n\t\t\t"; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($script); $templates = jNews_Templates::getTemplates(false, false, '', -1, 3); $i = 0; if (!empty($templates)) { foreach ($templates as $template) { $imgPath = $template->thumbnail; $img = jnews::imageResize($imgPath, 100, 100, $template->thumbnail); $html = ''; $html = '<a href="#" onclick="changeTemplate(document.getElementById(\'jnewshtmlcontent\').innerHTML, document.getElementById(\'jnewsaltbody\').innerHTML, ' . $template->template_id . ');">'; $html .= '<div style="margin:5px; float: left; border: 1px solid #000;">' . $img . '</div>'; $html .= '<div id="jnewshtmlcontent" style="display:none;">' . $template->body . '</div>'; $html .= '<div id ="jnewsaltbody" style="display:none;">' . $template->altbody . '</div>'; $html .= '</a>'; echo $html; $i = $i + 1; } } ?> </td> </tr> </tbody> </table> <?php }
public static function prepList($listEdit, $listType) { $lists = array(); $jour = array(); $listEdit->unsubscribesend = isset($listEdit->unsubscribesend) ? $listEdit->unsubscribesend : ''; $listEdit->unsubscribenotifyadmin = isset($listEdit->unsubscribenotifyadmin) ? $listEdit->unsubscribenotifyadmin : ''; $mainframe = JFactory::getApplication(); $my = JFactory::getUser(); $acl = JFactory::getACL(); $jour[] = jnews::HTML_SelectOption('1800', 'Every 30 minutes'); $jour[] = jnews::HTML_SelectOption('3600', 'Every hour'); $jour[] = jnews::HTML_SelectOption('43200', 'Every 12 hours'); $jour[] = jnews::HTML_SelectOption('1', _JNEWS_AUTO_DAY_CH1); $jour[] = jnews::HTML_SelectOption('3', _JNEWS_AUTO_DAY_CH3); $jour[] = jnews::HTML_SelectOption('5', _JNEWS_AUTO_DAY_CH5); $jour[] = jnews::HTML_SelectOption('6', _JNEWS_AUTO_DAY_CH6); $jour[] = jnews::HTML_SelectOption('7', _JNEWS_AUTO_DAY_CH7); $jour[] = jnews::HTML_SelectOption('8', _JNEWS_AUTO_DAY_CH8); $jour[] = jnews::HTML_SelectOption('9', _JNEWS_AUTO_DAY_CH9); $auto_option[] = jnews::HTML_SelectOption('0', _JNEWS_AUTO_OPTION_NO_SYNC); $auto_option[] = jnews::HTML_SelectOption('1', _JNEWS_AUTO_OPTION_NEW); //we get all of the templates available and published $templates = jNews_Templates::getTemplatesForPicklist(); $list_templates = array(); foreach ($templates as $oneTemplate) { $list_templates[] = jnews::HTML_SelectOption($oneTemplate->template_id, $oneTemplate->name); } //enfor $templateID = !empty($listEdit->template) ? $listEdit->template : ''; $lists['list_templates'] = jnews::HTML_GenericList($list_templates, 'templatelist', 'class="inputbox"', 'value', 'text', $templateID); if ($mainframe->isAdmin()) { if ($listEdit->new_letter == 1 && $listType != 2) { $auto_option[] = jnews::HTML_SelectOption('2', _JNEWS_AUTO_OPTION_ALL); } } $lists['delay_min'] = jnews::HTML_GenericList($jour, 'delay_min', 'class="inputbox" size="1"', 'value', 'text', $listEdit->delay_min); $lists['auto_add'] = jnews::HTML_GenericList($auto_option, 'auto_add', 'class="inputbox"', 'value', 'text', $listEdit->auto_add); $lists['published'] = jnews::HTML_BooleanList('published', 'class="inputbox"', $listEdit->published); $lists['hidden'] = jnews::HTML_BooleanList('hidden', 'class="inputbox"', $listEdit->hidden); $lists_option = jNews_ListType::getListOption(2); $lists['list_type'] = jNews_ListsHTML::aca_radioList($lists_option, 'list_type', 'class="inputbox"', $listEdit->list_type); $lists['html_mailings'] = jnews::HTML_BooleanList('html', 'class="inputbox"', $listEdit->html); $lists['unsubscribesend'] = jnews::HTML_BooleanList("unsubscribesend", 'class="inputbox"', $listEdit->unsubscribesend); $lists['subnotifysend'] = jnews::HTML_BooleanList("subnotifysend", 'class="inputbox"', $listEdit->subnotifysend); $lists['unsubscribenotifyadmin'] = jnews::HTML_BooleanList("unsubscribenotifyadmin", 'class="inputbox"', $listEdit->unsubscribenotifyadmin); $lists['footer'] = jnews::HTML_BooleanList("footer", 'class="inputbox"', $listEdit->footer); return $lists; }
public static function assignTemplate() { $templatesearch = JRequest::getVar('templatesearch', ''); $link = jNews_Tools::completeLink('option=' . JNEWS_OPTION, true, false, true); //second para from false to true $action = JRequest::getString('act', '', 'request'); $link .= '&task=assign&act=' . $action; $forms['main'] = " <form action='{$link}' method='post' name='adminForm' id=\"adminForm\">"; $paginationStart = JRequest::getVar('pg'); if (!empty($paginationStart)) { $limitstart = 0; $limitend = $paginationStart; } else { $app = JFactory::getApplication(); $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int'); $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int'); } $limittotal = jNews_Templates::countTemplates(1, 1); $setLimit = new stdClass(); $setLimit->total = !empty($limittotal) ? $limittotal : 0; $setLimit->start = !empty($limitstart) ? $limitstart : 0; $setLimit->end = !empty($limitend) ? $limitend : 20; $templates = jNews_Templates::getTemplates(true, false, $templatesearch, $setLimit->start, $setLimit->end, null, 1); jNews_TemplatesHTML::assignTemplate($templates, $forms, $setLimit, $templatesearch); return true; }
function mailing($action, $task, $listId, $listType, $mailingId, $message) { $showMailings = false; $db = JFactory::getDBO(); switch ($task) { case 'edit': $issue_nb = JRequest::getInt('issue_nb', 1); $mailingType = JRequest::getVar('listype'); $isEdit = JRequest::getVar('isEdit', true); $mySess = JFactory::getSession(); $mySess->set('listype', $mailingType, 'LType'); if (!empty($listId)) { $list = jNews_Lists::getOneList($listId); } else { $list = jNews_Lists::getListFirstEntry(); } $new = empty($mailingId) || $mailingId == 0 ? true : false; $mailing = jNews_Mailing::getOneMailing($list, $mailingId, $issue_nb, $new, false, true); $mailing->mailing_type = $mailingType; // if(empty($isEdit)) $isEdit = true; // set default mailing parameters $my = JFactory::getUser(); $subscribers = jNews_Subscribers::getSubscriberInfoFromUserId($my->id); if (!isset($subscribers)) { $subscribers = new stdClass(); } $subscribers->name = isset($subscribers->name) ? $subscribers->name : ''; $subscribers->email = isset($subscribers->email) ? $subscribers->email : ''; // $mailing->fromname = ( !isset( $mailing->fromname ) || empty( $mailing->fromname ) ) ? $subscribers->name : $mailing->fromname; // $mailing->fromemail = ( !isset( $mailing->fromemail ) || empty( $mailing->fromemail ) ) ? $subscribers->email : $mailing->fromemail; // $mailing->frombounce = ( !isset( $mailing->frombounce ) || empty( $mailing->frombounce ) ) ? $GLOBALS[JNEWS.'sendmail_from'] : $mailing->frombounce; $show = jNews_ListType::showType($mailing->mailing_type, 'editmailing'); if ($mailing->published != 1 or $mailing->mailing_type != 1 or isset($show['admin']) and $show['admin']) { $forms['main'] = " <form action='index.php' method='post' enctype='multipart/form-data' name='adminForm' id=\"adminForm\">"; jNews_Mailing::_header($task, $action, $mailing->mailing_type, $message, 'edit'); jNews_MailingsHTML::editMailing($mailing, $new, $listId, $forms, $show, $isEdit); $go[] = jnews::makeObj('act', $action); backHTML::formEnd($go); } else { $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">"; jNews_Mailing::_header($task, $action, $mailing->mailing_type, $message); //backHTML::formStart(); jNews_MailingsHTML::viewMailing($mailing, $forms); $go[] = jnews::makeObj('act', 'mailing'); $go[] = jnews::makeObj('task', 'viewmailing'); $go[] = jnews::makeObj('mailingid', $mailing->id); backHTML::formEnd($go); } break; case 'new': case 'add': // check if atleast one list exist and published // if false then restrict entry $mailingType = JRequest::getVar('listype'); $type = $mailingType == 2 ? 2 : 1; $result = jNews_Lists::checkListNotEmpty($type); if (!$result) { if ($type == 2) { $disp = addslashes(_JNEWS_CHECKCAMPAIGNFOUND); } else { $disp = addslashes(_JNEWS_CHECKLISTFOUND); } echo "<script> alert('" . $disp . "'); window.history.go(-1);</script>\n"; break; } $mailingType = JRequest::getVar('listype'); if (empty($listId)) { $listId = JRequest::getVar('listid'); } if (!empty($listId)) { $mailingType = jNews_Lists::getListType($listId) == 2 ? 2 : 1; } JRequest::setVar('listype', $mailingType); $total = jNews_Mailing::countMailings($listId, $mailingType); $total++; jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&task=edit&mailingid=0&issue_nb=' . $total . '&listype=' . $mailingType . '&listid=' . $listId . '&isEdit=0'); //mariap break; case 'saveSend': JRequest::checkToken() or die('Invalid Token'); $mySess = JFactory::getSession(); $mailingType = $mySess->get('listype', '', 'LType'); $status = checkMailingSave($mailingType); if (!$status) { return false; } jNews_Mailing::saveMailing($mailingId, $listId); case 'sendready': //we update the senddate of the newsletter jNews_Mailing::updatesenddate($mailingId); jNews_MailingsHTML::sendReady($mailingId, $listId, $listType); break; case 'generate': if (class_exists('jNews_Auto')) { $still = false; $message = jnews::printYN(jNews_Auto::processQueue(true, true, $still, true), 'Queue processed', _JNEWS_ERROR); jNews_Auto::displayStatus(); } return; break; case 'send': $queueC = new jNews_Queue(); $queueC->checkForNewsletters($mailingId); $queueCount = jNews_Queue::getQueueCount($mailingId); $totalSub = JRequest::setVar('totalsend', $queueCount); $linkURL = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=mailing&task=continuesend&mailingid=' . $mailingId . '&totalsend=' . $totalSub, true, false, true); jNews_Tools::redirect($linkURL); break; case 'continuesend': $queueC = new jNews_Queue(); //we update the senddate of the mailing to be now to be able to continue the sending and send it after we click continue // $queueC->updateSenddateToNow($mailingId); $totalSend = JRequest::getVar('totalsend', 0, '', 'int'); $alreadySent = JRequest::getVar('alreadysent', 0, '', 'int'); $queueC->start = $alreadySent; $queueC->total = $totalSend; $queueC->pause = $GLOBALS[JNEWS . 'pause_time']; $queueC->sendQueue(false, $mailingId, false, true); ob_start(); exit; break; case 'testspam': if (empty($message)) { $message = _JNEWS_MESSAGE_NOT; } $mailingId = $mailingId == 0 ? jNews_Mailing::getLastMailingId() : $mailingId; $my = JFactory::getUser(); if ($listId > 0) { $archivemailing = jNews_Mailing::getMailingView($mailingId, $listId); } else { $archivemailing = jNews_Mailing::getMailingView($mailingId); } $mailing = new stdClass(); $receivers = new stdClass(); $receivers->email = '*****@*****.**'; $receivers->name = $archivemailing->fromname; $receivers->receive_html = 1; $receivers->id = jNews_Subscribers::getSubscriberIdFromUserId($my->id); //if email are different we dont replace because we want to make sure the spam cehck count the fact that //sender and bounce back are different if ($archivemailing->fromemail == $archivemailing->frombounce) { $archivemailing->frombounce = $my->email; } $archivemailing->fromemail = $my->email; $mailerC = new jNews_ProcessMail(); $status = $mailerC->send($archivemailing, $receivers); $message = jnews::printYN($status, _JNEWS_SPAMTEXT_MESSAGE_SENT_SUCCESSFULLY, $message); $link = 'http://www.joobi.co/index.php?option=com_jlinks&controller=redirect&link=SpamCheck&alt=jnewsdoc_glossary'; $iFrame = '<iframe src="' . $link . '" width="100%" height="680px" scrolling="auto"></iframe>'; echo $iFrame; break; case 'savePreview': JRequest::checkToken() or die('Invalid Token'); $status = checkMailingSave($mailingType); if (!$status) { return false; } if ($mailingType == 7) { $mailing = JRequest::getVar('mailing', ''); $ContentStatus = checkTag(); if (!$ContentStatus) { return false; } } jNews_Mailing::saveMailing($mailingId, $listId); case 'preview': $emailaddress = JRequest::getVar('emailaddress', ''); $mailingId = $mailingId == 0 ? jNews_Mailing::getLastMailingId() : $mailingId; if (!empty($emailaddress)) { $status = jNews_Mailing::sendTestEmail($mailingId, $listId); if (empty($message)) { $message = _JNEWS_MESSAGE_NOT; } $message = jnews::printYN($status, _JNEWS_MESSAGE_SENT_SUCCESSFULLY, $message); } if ($listId > 0) { $archivemailing = jNews_Mailing::getMailingView($mailingId, $listId); } else { $archivemailing = jNews_Mailing::getMailingView($mailingId); } $doc = JFactory::getDocument(); $css = '.icon-48-preview{ background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/preview.png)}'; $doc->addStyleDeclaration($css, $type = 'text/css'); $title = _JNEWS_PREVIEW_TITLE . ': ' . $archivemailing->subject; backHTML::_header(_JNEWS_PREVIEW_TITLE, 'preview.png', $message, $task, $action); //new view for the preview mailing echo '<table cellpadding="0" cellspacing="2" border="0" width="100%"><tr><td width="40%">'; jNews_MailingsHTML::previewMailingHTML($mailingId, $listId, $listType, $archivemailing->html); echo '</td><td width="60%">'; $forms['main'] = ''; $list = jNews_Lists::getOneList($archivemailing->list_id); $textonly = ''; $mailerC = new jNews_ProcessMail(); $queueInfo = new stdClass(); $queueInfo->mailingid = $mailingId; $queueInfo->listid = @$listId; $mailerC->getContent($archivemailing->images, $archivemailing->html, $archivemailing->textonly, $archivemailing->subject, false, true, $queueInfo); //new $archivemailing->subject if ($archivemailing->html == 1) { if (empty($template_id)) { $template_id = $archivemailing->template_id; } if (!empty($template_id)) { jNews_Templates::includeStyles($archivemailing->htmlcontent, $template_id); } } else { $archivemailing->textonly = jNews_ProcessMail::htmlToText($archivemailing->textonly); } //new view for the preview mailing jNews_MailingsHTML::viewHeading($archivemailing); echo '</td></tr><tr><td colspan="2">'; jNews_MailingsHTML::viewMailing($archivemailing, $forms); echo '</td></tr></tbody></table>'; if ($mailingId == 0) { JRequest::setVar('mailingid', $mailingId); } break; case 'view': $mailingType = JRequest::getVar('listype'); if (!empty($mailingType)) { $mySess = JFactory::getSession(); $mySess->set('listype', $mailingType, 'LType'); } if ($mailingId != 0) { if ($listId > 0) { $archivemailing = jNews_Mailing::getMailingView($mailingId, $listId); } else { $archivemailing = jNews_Mailing::getMailingView($mailingId); } if (empty($template_id)) { $template_id = $archivemailing->template_id; } if (!empty($template_id)) { jNews_Templates::includeStyles($archivemailing->htmlcontent, $template_id); } $forms['main'] = "<form action='index.php?option=" . JNEWS_OPTION . "&act=mailing&listype=" . $listType . "&listid=" . $listId . "' method='post' name='adminForm' id=\"adminForm\">"; jNews_Mailing::_header($task, $action, $listType, $message); backHTML::formStart('show_mailing', 0, ''); jNews_MailingsHTML::viewMailing($archivemailing, $forms); $go[] = jnews::makeObj('act', 'mailing'); $go[] = jnews::makeObj('task', 'viewmailing'); $go[] = jnews::makeObj('listId', $archivemailing->list_id); //listid to listId--original backHTML::formEnd($go); } break; case 'deletequeue': //implement here what are we going to do with the delete queueu column on the mailing $mailingID = JRequest::getVar('mailingid'); $mailingType = JRequest::getVar('listype'); if (!empty($mailingID)) { $db = JFactory::getDBO(); $db->setQuery('DELETE FROM `#__jnews_queue` WHERE `mailing_id` = ' . $mailingID); $db->query(); $message = jnews::printYN(true, _JNEWS_MAILING_QUEUE_DELETED, _JNEWS_ERROR); } else { $message = jnews::printYN(false, _JNEWS_MAILING_QUEUE_DELETED, _JNEWS_ERROR); } jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType, $message); break; case 'deleteMailing': JRequest::checkToken() or die('Invalid Token'); $d['mailing'] = jNews_Mailing::getOneMailing('', $mailingId, '', $new); $message = jnews::printYN(jNews_Mailing::delete($d), @constant($GLOBALS[JNEWS . 'listname' . $d['mailing']->list_type]) . '"' . $d['mailing']->subject . '"' . _JNEWS_SUCCESS_DELETED, _JNEWS_ERROR); $showMailings = true; break; case 'cancel': $url = 'index.php?option=' . JNEWS_OPTION . '&act=mailing&mailingid=' . $mailingId; $url .= (!empty($listId) ? '&listid=' . $listId : '') . '&listype=' . $mailingType; jNews_Tools::redirect($url); break; case 'copy': JRequest::checkToken() or die('Invalid Token'); $message = jnews::printYN(jNews_Mailing::copyMailing($mailingId), _JNEWS_MAILING_COPY, _JNEWS_ERROR); $showMailings = true; break; case 'cancelMailing': $showMailings = true; break; case 'publishMailing': JRequest::checkToken() or die('Invalid Token'); $mailing = jNews_Mailing::getOneMailing('', $mailingId, '', $new); $message = jnews::printYN(jNews_Mailing::publishMailing($mailingId), @constant($GLOBALS[JNEWS . 'listname' . $mailing->mailing_type]) . ' ' . _JNEWS_PUBLISHED, _JNEWS_ERROR); $mailingType = jNews_Mailing::getMailingInfoz($mailingId); jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType); break; case 'unpublishMailing': JRequest::checkToken() or die('Invalid Token'); $mailing = jNews_Mailing::getOneMailing('', $mailingId, '', $new); $message = jnews::printYN(jNews_Mailing::unpublishMailing($mailingId), @constant($GLOBALS[JNEWS . 'listname' . $mailing->mailing_type]) . ' ' . _JNEWS_UNPUBLISHED, _JNEWS_ERROR); $mailingType = jNews_Mailing::getMailingInfoz($mailingId); jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType . '&listid=' . $listId); break; case 'cpanel': backHTML::controlPanel(); break; case 'save': JRequest::checkToken() or die('Invalid Token'); $subject = JRequest::getVar('subject', ''); if (empty($subject)) { echo "<script> alert('subject needs to be not empty'); window.history.go(-1);</script>\n"; return false; } if (!isset($mailingType)) { $mySess = JFactory::getSession(); $mailingType = $mySess->get('listype', '', 'LType'); } $status = checkMailingSave($mailingType); if ($mailingType == 7) { $mailing = JRequest::getVar('mailing', ''); $ContentStatus = checkTag(); if (!$ContentStatus) { return false; } } if (!$status) { return false; } $message = jnews::printYN(jNews_Mailing::saveMailing($mailingId, $listId), _JNEWS_MAILING_SAVED, _JNEWS_ERROR); if (!empty($mailingtype)) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType . '&listid=' . $listId); } else { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType . '&listid=' . $listId); $showMailings = true; unset($GLOBALS["task"]); unset($_REQUEST["task"]); } break; case 'apply': JRequest::checkToken() or die('Invalid Token'); $mailingid = JRequest::getVar('mailingid', '0'); if (!isset($mailingType)) { $mySess = JFactory::getSession(); $mailingType = $mySess->get('listype', '', 'LType'); } $status = checkMailingSave($mailingType); if ($mailingType == 7) { $mailing = JRequest::getVar('mailing', ''); $ContentStatus = checkTag(); if (!$ContentStatus) { return false; } } if (!$status) { return false; } $message = jnews::printYN(jNews_Mailing::saveMailing($mailingId, $listId), _JNEWS_MAILING_SAVED, _JNEWS_ERROR); $mailingid = $mailingid == 0 ? jNews_Mailing::getLastMailingId() : $mailingid; if (!empty($mailingtype)) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&task=edit&listype=' . $mailingType . '&mailingid=' . $mailingid . '&listid=' . $listId); } else { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&task=edit&listype=' . $mailingType . '&mailingid=' . $mailingid . '&listid=' . $listId); $showMailings = true; unset($GLOBALS["task"]); unset($_REQUEST["task"]); } break; case 'show': $id = JRequest::getVar('mailingid'); $mySess = JFactory::getSession(); $mailingType = JRequest::getVar('listype', 0); $listId = JRequest::getVar('listid', 0); $link = 'index.php?option=' . JNEWS_OPTION . '&act=mailing&listype=' . $mailingType . '&listid=' . $listId; jNews_Tools::redirect($link); $showMailings = true; break; case 'toggle': $listid = JRequest::getVar('listid'); $column = JRequest::getVar('col'); $mailingid = JRequest::getVar('mailingid'); if (!empty($mailingid) && !empty($column)) { $passObj = new stdClass(); $passObj->tableName = '#__jnews_mailings'; $passObj->columnName = $column; $passObj->whereColumn = 'id'; $passObj->whereColumnValue = $mailingid; jnews::toggle($passObj); } if ($listType == 1) { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listid=' . $listid . '&listype=1'); } else { jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=mailing&listid=' . $listid . '&listype=2'); } break; default: $showMailings = true; break; } if ($showMailings) { if (empty($listType)) { $listType = JRequest::getVar('listype', 0); } if (empty($listId)) { $listId = JRequest::getVar('listid', 0); } $paginationStart = JRequest::getVar('pg'); if (!empty($paginationStart)) { $limitstart = 0; $limitend = $paginationStart; } else { $app = JFactory::getApplication(); $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int'); $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int'); } $limittotal = jNews_Mailing::countMailings(0, $listType); $setLimit = new stdClass(); $setLimit->total = !empty($limittotal) ? $limittotal : 0; $setLimit->start = !empty($limitstart) ? $limitstart : 0; $setLimit->end = !empty($limitend) ? $limitend : $limittotal; if ($setLimit->total == $setLimit->end) { $setLimit->start = 0; } jNews_Mailing::showMailings($task, $action, $listId, $listType, $message, true, _JNEWS_MENU_MAILING, $setLimit); } return true; }
/** send emails * @param bool $showHTML show report on the screen * @param object $mailing contain the information of mailing * @param objectlist $receivers all receivers * @params $type (1-all types of mailings, 2-confirmation email) */ function send($oneQueue, $receiver) { // we should verify that the data we get is teh proper value if (!is_object($oneQueue)) { return false; } $tags = null; ### create the mail $mail = jNews_ProcessMail::getMailer($oneQueue); //$frompreview param is to determine if the sending is called by 'Send Test Email' if (empty($mail)) { return false; } $tags['issuenb'] = $oneQueue->issue_nb; ### create content $this->getContent($oneQueue->images, $oneQueue->htmlcontent, $oneQueue->textonly, $oneQueue->subject, true, false, $oneQueue); //new $oneQueue->subject if ($this->cancelMailing) { $this->cancelMailing = false; return true; // we return true even though the mail was not sent because empty. Need improvement... } if (!empty($receiver->user_id)) { $tags['user_id'] = $receiver->user_id; } //Forced HTML Mailing Only? if ($GLOBALS[JNEWS . 'forced_html']) { $receiver->receive_html = 1; } $tname = explode(" ", $receiver->name); $firstname = $tname[0]; $toUser = $GLOBALS[JNEWS . 'minisendmail'] ? '' : $receiver->name; $mail->AddAddress($receiver->email, $toUser); $username = empty($receiver->username) ? $firstname : $receiver->username; if (version_compare(JVERSION, '3.0.0', '<')) { $date = JHTML::_('date', jnews::getNow(), JText::_('DATE_FORMAT_LC1'), JNEWS_TIME_OFFSET); } else { $date = JHtml::_('date', jnews::getNow(), JText::_('DATE_FORMAT_LC1'), JNEWS_TIME_OFFSET); } $replaceWhat = array('{tag:name}', '{tag:firstname}', '{tag:username}', '{tag:date}'); $replaceBy = array($receiver->name, $firstname, $username, $date); $sujetReplaced = str_replace($replaceWhat, $replaceBy, $oneQueue->subject); if (class_exists('jNews_Auto')) { jNews_Auto::tags($sujetReplaced, $tags); } $mail->Subject = $sujetReplaced; if (!empty($oneQueue->html) && $receiver->receive_html) { $this->html = true; $mail->IsHTML(true); $ashtml = 1; $mail->Body = jNews_ProcessMail::replaceTags($oneQueue->htmlcontent, $receiver, $oneQueue, $ashtml, $tags); $mail->AltBody = jNews_ProcessMail::replaceTags($oneQueue->textonly, $receiver, $oneQueue, $ashtml, $tags); //this line is added when jLinks is integrated with jNews //variables used in integration of jLinks static $mailCatID = null; static $convertedLinks = null; if (empty($oneQueue->mailing_type)) { $oneQueue->mailing_type = 1; } $mainframe = JFactory::getApplication(); JPluginHelper::importPlugin('jnews'); $jomsocial = $mainframe->triggerEvent('jnewsbot_jomsocial_members', array(&$mail->Body, &$mail->AltBody, $receiver)); $this->_linkReplacement($oneQueue->mailing_type, $oneQueue->id, $oneQueue->subject, $mail, $mailCatID, $convertedLinks, $receiver->id); jNews_ProcessMail::replaceClass($mail->Body, $mail->AltBody, $receiver); if (!empty($oneQueue->template_id)) { jNews_Templates::includeStyles($mail->Body, $oneQueue->template_id); } } else { //text only email $this->html = false; $mail->IsHTML(false); $mail->AltBody = ''; $ashtml = 0; $mail->Body = jNews_ProcessMail::replaceTags($oneQueue->textonly, $receiver, $oneQueue, $ashtml, $tags); $mail->AltBody = $this->_safe_utf8_encode($mail->Body, $mail->CharSet); $simpleText = ''; jNews_ProcessMail::replaceClass($mail->Body, $simpleText, $receiver); if (version_compare(JVERSION, '1.6.0', '<')) { //j15 $imgfolders = DS . 'images' . DS . 'stories'; } else { //j16 $imgfolders = DS . 'images' . DS . 'sampledata'; } if (!empty($oneQueue->images)) { foreach ($oneQueue->images as $image) { $img = explode('|', $image); $attrib = explode("/", $img[0]); $path = JNEWS_JPATH_ROOT . $imgfolders; if (count($img) == 1) { $imageName = $img[0]; } else { $imageName = $attrib[count($attrib) - 1]; for ($index = 0; $index < sizeof($attrib) - 1; $index++) { $path .= $attrib[$index] . '/'; } } $mail->AddAttachment($path . $imageName); } //endofreach } } jNews_ProcessMail::normalizeURL($mail->Body); if (!empty($oneQueue->html) && $receiver->receive_html) { $this->_addHTMLTagToBody($mail->Body, $sujetReplaced); } if ($GLOBALS[JNEWS . 'embed_images']) { $this->_embedImages($mail); } $mail->addCustomHeader("X-SubscriberID: " . base64_encode($receiver->email)); // DKIM code addition by Amod begins $mail = $this->_addDKIM2($mail); // DKIM code addition by Amod ends $status = $mail->Send(); if (version_compare(JVERSION, '1.6.0', '<')) { //j15 $mailErrorCount = $mail->error_count; } else { //j16 $mailErrorCount = !empty($mail->ErrorInfo) ? 1 : 0; } //we prompt message regarding the status of the sending if there is an error if (!empty($mail->ErrorInfo)) { echo '<br><span style="color:red;">' . $mail->ErrorInfo . '</span>'; } if ($status && $mailErrorCount < 1) { return true; } else { jNews_ProcessMail::failMailReason($mail); return false; } }
public static function getMailingTemplate($mailingId = '') { $db = JFactory::getDBO(); if (empty($mailingId)) { $template = jNews_Templates::loadOneTemplate('*', '', 'template_id', 'DESC', true); $template_id = JRequest::getVar('template_id', $template->template_id); } else { $query = 'SELECT `template_id` FROM `#__jnews_mailings` WHERE `id`=' . $mailingId; $db->setQuery($query); $template_id = $db->loadResult(); } if (empty($template_id)) { $template = jNews_Templates::loadOneTemplate('*', '', 'template_id', 'DESC', true); $template_id = JRequest::getVar('template_id', $template->template_id); } return $template_id; }
public static function _styles($styles) { $script = 'function addNewStyle() { var divnewstyle=window.document.getElementById("divnewstyle"); var input = document.createElement(\'input\'); var input2 = document.createElement(\'input\'); input.type = \'text\'; input2.type = \'text\'; input.size = \'30\'; input2.size = \'30\'; input.name = \'otherstyles[classname][]\'; input2.name = \'otherstyles[style][]\'; input.setAttribute(\'style\', \'margin-top:4px;\'); input2.setAttribute(\'style\', \'margin-top:4px; margin-left: 68px;\'); input.value = "' . _JNEWS_TEMPLATE_STYLE_NEWC . '"; input2.value = "' . _JNEWS_TEMPLATE_STYLE_NEWAPPLIED . '"; divnewstyle.appendChild(document.createElement(\'br\')); divnewstyle.appendChild(input); divnewstyle.appendChild(input2);} function removeStyle( child ) { var child = document.getElementById(\'child\'); var parent = document.getElementById(\'jNewsStyles\'); parent.removeChild(\'child\'); }'; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($script); ?> <div id="jNewsStyles" class="visible"> <input type="hidden" value="0" name="stylechosen"> <fieldset class="adminform" width="100%"> <legend><?php echo 'Styles'; ?> </legend> <table width="100%"> <tr> <td><span style="<?php echo jNews_Templates::escapeVal(@$styles['style_h1']); ?> "><?php echo _JNEWS_TEMPLATE_STYLE_TH1; ?> </span></td> <td><input type="text" size="50" name="styles[style_h1]" value="<?php echo jNews_Templates::escapeVal(@$styles['style_h1']); ?> "/></td> </tr> <tr> <td><span style="<?php echo jNews_Templates::escapeVal(@$styles['style_h2']); ?> "><?php echo _JNEWS_TEMPLATE_STYLE_TH2; ?> </span></td> <td><input type="text" size="50" name="styles[style_h2]" value="<?php echo jNews_Templates::escapeVal(@$styles['style_h2']); ?> "/></td> </tr> <tr> <td><span style="<?php echo jNews_Templates::escapeVal(@$styles['style_h3']); ?> "><?php echo _JNEWS_TEMPLATE_STYLE_TH3; ?> </span></td> <td><input type="text" size="50" name="styles[style_h3]" value="<?php echo jNews_Templates::escapeVal(@$styles['style_h3']); ?> "/></td> </tr> <tr> <td><span style="<?php echo jNews_Templates::escapeVal(@$styles['style_h4']); ?> "><?php echo _JNEWS_TEMPLATE_STYLE_TH4; ?> </span></td> <td><input type="text" size="50" name="styles[style_h4]" value="<?php echo jNews_Templates::escapeVal(@$styles['style_h4']); ?> "/></td> </tr> <tr> <td><span style="<?php echo jNews_Templates::escapeVal(@$styles['style_h5']); ?> "><?php echo _JNEWS_TEMPLATE_STYLE_TH5; ?> </span></td> <td><input type="text" size="50" name="styles[style_h5]" value="<?php echo jNews_Templates::escapeVal(@$styles['style_h5']); ?> "/></td> </tr> <tr> <td><span style="<?php echo jNews_Templates::escapeVal(@$styles['style_h6']); ?> "><?php echo _JNEWS_TEMPLATE_STYLE_TH6; ?> </span></td> <td><input type="text" size="50" name="styles[style_h6]" value="<?php echo jNews_Templates::escapeVal(@$styles['style_h6']); ?> "/></td> </tr> <tr> <tr> <td><span style="<?php echo jNews_Templates::escapeVal(@$styles['style_a']); ?> ">a</span></td> <td><input type="text" size="50" name="styles[style_a]" value="<?php echo jNews_Templates::escapeVal(@$styles['style_a']); ?> "/></td> </tr> <tr> <td><ul style="<?php echo jNews_Templates::escapeVal(@$styles['style_ul']); ?> "><li style="<?php echo jNews_Templates::escapeVal(@$styles['style_li']); ?> ">ul</li><li style="<?php echo jNews_Templates::escapeVal(@$styles['style_li']); ?> ">li</li></ul></td> <td><input type="text" size="50" name="styles[style_ul]" value="<?php echo jNews_Templates::escapeVal(@$styles['style_ul']); ?> "/> <br/><input type="text" size="50" name="styles[style_li]" value="<?php echo jNews_Templates::escapeVal(@$styles['style_li']); ?> "/></td> </tr> <tr> <td><span style="<?php echo jNews_Templates::escapeVal(@$styles['aca_unsubscribe']); ?> "><?php echo _JNEWS_TEMPLATE_STYLE_UNSUB; ?> </span></td> <td><input type="text" size="50" name="styles[aca_unsubscribe]" value="<?php echo jNews_Templates::escapeVal(@$styles['aca_unsubscribe']); ?> "/></td> </tr> <tr> <td><span style="<?php echo jNews_Templates::escapeVal(@$styles['aca_subscribe']); ?> "><?php echo _JNEWS_TEMPLATE_STYLE_SUB; ?> </span></td> <td><input type="text" size="50" name="styles[aca_subscribe]" value="<?php echo jNews_Templates::escapeVal(@$styles['aca_subscribe']); ?> "/></td> </tr> <tr> <td><span style="<?php echo jNews_Templates::escapeVal(@$styles['aca_content']); ?> "><?php echo _JNEWS_TEMPLATE_STYLE_CONTENT; ?> </span></td> <td><input type="text" size="50" name="styles[aca_content]" value="<?php echo jNews_Templates::escapeVal(@$styles['aca_content']); ?> "/></td> </tr> <tr> <td><span style="<?php echo jNews_Templates::escapeVal(@$styles['aca_title']); ?> "><?php echo _JNEWS_TEMPLATE_STYLE_CHEAD; ?> </span></td> <td><input type="text" size="50" name="styles[aca_title]" value="<?php echo jNews_Templates::escapeVal(@$styles['aca_title']); ?> "/></td> </tr> <tr> <td><span style="<?php echo jNews_Templates::escapeVal(@$styles['aca_readmore']); ?> "><?php echo _JNEWS_TEMPLATE_STYLE_CREADMORE; ?> </span></td> <td><input type="text" size="50" name="styles[aca_readmore]" value="<?php echo jNews_Templates::escapeVal(@$styles['aca_readmore']); ?> "/></td> </tr> <tr> <td><span style="<?php echo jNews_Templates::escapeVal(@$styles['aca_online']); ?> "><?php echo _JNEWS_TEMPLATE_STYLE_VONLINE; ?> </span></td> <td><input type="text" size="50" name="styles[aca_online]" value="<?php echo jNews_Templates::escapeVal(@$styles['aca_online']); ?> "/></td> </tr> <?php if ($GLOBALS[JNEWS . 'show_jcalpro'] and class_exists('jNews_Pro')) { $jcal .= ''; $jcal .= '<tr><td><span style="' . jNews_Templates::escapeVal(@$styles['aca_jcalcontent']) . '">' . _JNEWS_TEMPLATE_STYLE_JCALCONTENT . '</span></td>'; $jcal .= '<td><input type="text" size="30" name="styles[aca_jcalcontent]" value="' . jNews_Templates::escapeVal(@$styles['aca_jcalcontent']) . '"/></td></tr>'; $jcal .= '<tr><td><span style="' . jNews_Templates::escapeVal(@$styles['aca_jcaltitle']) . '">' . _JNEWS_TEMPLATE_STYLE_JCALTITLE . '</span></td>'; $jcal .= '<td><input type="text" size="30" name="styles[aca_jcaltitle]" value="' . jNews_Templates::escapeVal(@$styles['aca_jcaltitle']) . '"/></td></tr>'; echo $jcal; unset($styles['aca_jcalcontent']); unset($styles['aca_jcaltitle']); } ?> <?php unset($styles['aca_unsubscribe']); unset($styles['aca_subscribe']); unset($styles['aca_content']); unset($styles['aca_title']); unset($styles['aca_readmore']); unset($styles['aca_online']); unset($styles['style_a']); unset($styles['style_ul']); unset($styles['style_li']); unset($styles['style_h1']); unset($styles['style_h2']); unset($styles['style_h3']); unset($styles['style_h4']); unset($styles['style_h5']); unset($styles['style_h6']); unset($styles['color_bg']); if (!empty($styles) && $GLOBALS[JNEWS . 'level'] > 2) { foreach ($styles as $className => $style) { ?> <tr> <td> <span id="jnews<?php echo $className; ?> " style="<?php echo jNews_Templates::escapeVal($style); ?> "><?php echo $className; ?> </span> </td> <td> <input id="jnews<?php echo $className; ?> " type="text" size="50" name="styles[<?php echo $className; ?> ]" value="<?php echo jNews_Templates::escapeVal($style); ?> "/> </td> </tr> <?php } } ?> <tr> </table> <?php if ($GLOBALS[JNEWS . 'level'] > 2) { ?> <div id="divnewstyle"></div> <a href="javascript:void(0);" onclick='addNewStyle()'><?php echo _JNEWS_TEMPLATE_STYLE_NEW; ?> </a> <?php } ?> </fieldset> </div> <?php }
public static function openZip($archive) { $ata = null; $metadata = null; $data = file_get_contents($archive); if (!($data = JFile::read($archive))) { return false; } $metadata_arr = jNews_Templates::readZipInfo($data); if (isset($metadata_arr[0]) && is_array($metadata_arr[0])) { $metadata = explode("/", $metadata_arr[0]['name']); return $metadata[0]; } return false; return true; }