/** * <p>public static function to create the view of the template list where the user can assign a template to a newsletter.</p> * @param mixed $templates - the array object list of templates in the database */ public static function assignTemplate($templates, $forms, $setLimit, $templatesearch) { if (version_compare(JVERSION, '3.0.0', '<')) { JHTML::_('behavior.modal'); } else { JHtml::_('behavior.modal'); } if (version_compare(JVERSION, '3.0.0', '<')) { JHTML::_('behavior.mootools'); } else { JHtmlBehavior::framework(); } $action = JRequest::getString('act', '', 'request'); $js = "function assignTemplate(templateid){var templatebody = window.document.getElementById('templatebody_'+templateid).innerHTML;\n\t \tvar templatealtbody = window.document.getElementById('templatealtbody_'+templateid).innerHTML;\n\t \twindow.top.changeTemplate(templatebody, templatealtbody,templateid);"; if (version_compare(JVERSION, '1.6.0', '<')) { //1.5 $js .= " window.top.document.getElementById('sbox-window').close();"; } else { if (version_compare(JVERSION, '3.0.0', '<')) { $js .= " window.parent.SqueezeBox.close();"; } else { $js .= 'jQuery(window.top.document).find("div.modal-backdrop").click();'; } } $js .= "}"; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js); ?> <style type="text/css"> div#pagination { background-color: #006699; margin: auto; padding: 0 8px; color: #FFFFFF; } div.template-container { border-bottom: 1px dotted #000000; padding: 5px; margin-top: 10px; float: left; width: 596px; cursor:pointer; } div.template-container:hover { background-color: #CCFFFF; } div.template-container div#image { float:left; margin-right: 5px; } div.template-container div#name { clear: right; border: 1px solid #000; font-weight: bold; font-size: 1.2em; } div.template-container div#description { margin-top: 5px; } </style> <?php echo $forms['main']; ?> <div id="pagination"> <?php // for search $limit = -1; $hidden = '<input type="hidden" name="limit" value="' . $limit . '" />'; $toSearch = new stdClass(); //$toSearch->forms = ''; $toSearch->hidden = $hidden; $toSearch->listsearch = $templatesearch; $toSearch->id = 'templatesearch'; //echo jnews::setTop($toSearch, null, $setLimit, null, true); echo jnews::setTop($toSearch, null); ?> </div> <?php foreach ($templates as $countMeNow => $template) { if ($template->availability == 1 && $template->published == 1) { if (empty($template->thumbnail)) { $template->thumbnail = 'sample-image.png'; } $findposhttp = strpos($template->thumbnail, 'http://'); $findposwww = strpos($template->thumbnail, 'www.'); if ($findposhttp === false || $findposwww === false) { $path = $template->thumbnail; $img = '<img src="' . $path . '" alt="' . $template->name . '">'; } else { $path = $template->thumbnail; $img = '<img src="' . $path . '" alt="' . $template->name . '">'; } ?> <div class="template-container" onclick="assignTemplate(<?php echo $template->template_id; ?> );"> <div id="image"><?php echo $img; ?> </div> <div id="name" style="text-indent:10px"><?php echo $template->name; ?> </div> <div id="description" style="text-indent:25px" ><?php echo jnews::stringTruncate($template->description, 400, ".", "..."); ?> </div> <div id="templatebody_<?php echo $template->template_id; ?> " style="display:none;"><?php echo $template->body; ?> </div> <div id="templatealtbody_<?php echo $template->template_id; ?> " style="display:none;"><?php echo $template->altbody; ?> </div> </div> <?php } } $css = 'margin:auto;'; echo jnews::setPaginationBot($setLimit, $css); ?> <input type="hidden" value="<?php echo JNEWS_OPTION; ?> " name="option"/> <input type="hidden" value="<?php echo $action; ?> " name="act"/> <input type="hidden" value="assign" name="task"/> <input type="hidden" value="0" name="boxchecked" id="boxcount"/> </form> <?php }