PageRenderTime 71ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/administrator/components/com_acymailing/extensions/plg_acymailing_tagcontent/tagcontent.php

https://github.com/viollarr/alab
PHP | 1002 lines | 996 code | 0 blank | 6 comment | 252 complexity | 224bf8e9e90738872e5aaae98a3e32e5 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, AGPL-3.0, Apache-2.0, BSD-3-Clause, GPL-3.0
  1. <?php
  2. /**
  3. * @copyright Copyright (C) 2009-2012 ACYBA SARL - All rights reserved.
  4. * @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
  5. */
  6. defined('_JEXEC') or die('Restricted access');
  7. ?>
  8. <?php
  9. class plgAcymailingTagcontent extends JPlugin
  10. {
  11. function plgAcymailingTagcontent(&$subject, $config){
  12. parent::__construct($subject, $config);
  13. if(!isset($this->params)){
  14. $plugin =& JPluginHelper::getPlugin('acymailing', 'tagcontent');
  15. $this->params = new JParameter( $plugin->params );
  16. }
  17. }
  18. function acymailing_getPluginType() {
  19. $app =& JFactory::getApplication();
  20. if($this->params->get('frontendaccess') == 'none' AND !$app->isAdmin()) return;
  21. $onePlugin = null;
  22. $onePlugin->name = JText::_('JOOMLA_CONTENT');
  23. $onePlugin->function = 'acymailingtagcontent_show';
  24. $onePlugin->help = 'plugin-tagcontent';
  25. return $onePlugin;
  26. }
  27. function acymailingtagcontent_show(){
  28. $app =& JFactory::getApplication();
  29. $pageInfo = null;
  30. $my = JFactory::getUser();
  31. $paramBase = ACYMAILING_COMPONENT.'.tagcontent';
  32. $pageInfo->filter->order->value = $app->getUserStateFromRequest( $paramBase.".filter_order", 'filter_order', 'a.id','cmd' );
  33. $pageInfo->filter->order->dir = $app->getUserStateFromRequest( $paramBase.".filter_order_Dir", 'filter_order_Dir', 'desc', 'word' );
  34. $pageInfo->search = $app->getUserStateFromRequest( $paramBase.".search", 'search', '', 'string' );
  35. $pageInfo->search = JString::strtolower( $pageInfo->search );
  36. $pageInfo->filter_cat = $app->getUserStateFromRequest( $paramBase.".filter_cat", 'filter_cat','','int' );
  37. $pageInfo->contenttype = $app->getUserStateFromRequest( $paramBase.".contenttype", 'contenttype',$this->params->get('default_type','|type:intro'),'string' );
  38. $pageInfo->author = $app->getUserStateFromRequest( $paramBase.".author", 'author',$this->params->get('default_author',''),'string' );
  39. $pageInfo->titlelink = $app->getUserStateFromRequest( $paramBase.".titlelink", 'titlelink',$this->params->get('default_titlelink','|link'),'string' );
  40. $pageInfo->lang = $app->getUserStateFromRequest( $paramBase.".lang", 'lang','','string' );
  41. $pageInfo->pict = $app->getUserStateFromRequest( $paramBase.".pict", 'pict',$this->params->get('default_pict',1),'string' );
  42. $pageInfo->limit->value = $app->getUserStateFromRequest( $paramBase.'.list_limit', 'limit', $app->getCfg('list_limit'), 'int' );
  43. $pageInfo->limit->start = $app->getUserStateFromRequest( $paramBase.'.limitstart', 'limitstart', 0, 'int' );
  44. $picts = array();
  45. $picts[] = JHTML::_('select.option', "1",JText::_('JOOMEXT_YES'));
  46. $pictureHelper = acymailing_get('helper.acypict');
  47. if($pictureHelper->available()) $picts[] = JHTML::_('select.option', "resized",JText::_('RESIZED'));
  48. $picts[] = JHTML::_('select.option', "0",JText::_('JOOMEXT_NO'));
  49. $db =& JFactory::getDBO();
  50. $searchFields = array('a.id','a.title','a.alias','a.created_by','b.name','b.username');
  51. if(!empty($pageInfo->search)){
  52. $searchVal = '\'%'.$db->getEscaped($pageInfo->search,true).'%\'';
  53. $filters[] = implode(" LIKE $searchVal OR ",$searchFields)." LIKE $searchVal";
  54. }
  55. if(!empty($pageInfo->filter_cat)){
  56. $filters[] = "a.catid = ".$pageInfo->filter_cat;
  57. }
  58. if($this->params->get('displayart','all') == 'onlypub'){
  59. $filters[] = "a.state = 1";
  60. }else{
  61. $filters[] = "a.state != -2";
  62. }
  63. if(!$app->isAdmin()){
  64. if(version_compare(JVERSION,'1.6.0','<')){
  65. $filters[] = 'a.`access` <= ' . (int)$my->get('aid');
  66. }else{
  67. $groups = implode(',', $my->authorisedLevels());
  68. $filters[] = 'a.`access` IN ('.$groups.')';
  69. }
  70. }
  71. if($this->params->get('frontendaccess') == 'author' AND !$app->isAdmin()){
  72. $filters[] = "a.created_by = ".intval($my->id);
  73. }
  74. $whereQuery = '';
  75. if(!empty($filters)){
  76. $whereQuery = ' WHERE ('.implode(') AND (',$filters).')';
  77. }
  78. $query = 'SELECT SQL_CALC_FOUND_ROWS a.id,a.created,a.title,a.alias,a.catid,a.sectionid,b.name,b.username,a.created_by FROM '.acymailing_table('content',false).' as a';
  79. $query .=' LEFT JOIN `#__users` AS b ON b.id = a.created_by';
  80. if(!empty($whereQuery)) $query.= $whereQuery;
  81. if(!empty($pageInfo->filter->order->value)){
  82. $query .= ' ORDER BY '.$pageInfo->filter->order->value.' '.$pageInfo->filter->order->dir;
  83. }
  84. $db->setQuery($query,$pageInfo->limit->start,$pageInfo->limit->value);
  85. $rows = $db->loadObjectList();
  86. if(!empty($pageInfo->search)){
  87. $rows = acymailing_search($pageInfo->search,$rows);
  88. }
  89. $db->setQuery('SELECT FOUND_ROWS()');
  90. $pageInfo->elements->total = $db->loadResult();
  91. $pageInfo->elements->page = count($rows);
  92. if(version_compare(JVERSION,'1.6.0','<')){
  93. $query = 'SELECT a.id, a.id as catid, a.title as category, b.title as section, b.id as secid from #__categories as a ';
  94. $query .= 'INNER JOIN #__sections as b on a.section = b.id ORDER BY b.ordering,a.ordering';
  95. $db->setQuery($query);
  96. $categories = $db->loadObjectList('id');
  97. $categoriesValues = array();
  98. $categoriesValues[] = JHTML::_('select.option', '',JText::_('ACY_ALL'));
  99. $currentSec = '';
  100. foreach($categories as $catid => $oneCategorie){
  101. if($currentSec != $oneCategorie->section){
  102. if(!empty($currentSec)) $this->values[] = JHTML::_('select.option', '</OPTGROUP>');
  103. $categoriesValues[] = JHTML::_('select.option', '<OPTGROUP>',$oneCategorie->section);
  104. $currentSec = $oneCategorie->section;
  105. }
  106. $categoriesValues[] = JHTML::_('select.option', $catid,$oneCategorie->category);
  107. }
  108. }else{
  109. $query = "SELECT * from #__categories WHERE `extension` = 'com_content' ORDER BY lft ASC";
  110. $db->setQuery($query);
  111. $categories = $db->loadObjectList('id');
  112. $categoriesValues = array();
  113. $categoriesValues[] = JHTML::_('select.option', '',JText::_('ACY_ALL'));
  114. foreach($categories as $catid => $oneCategorie){
  115. $categories[$catid]->title = str_repeat('- - ',$categories[$catid]->level).$categories[$catid]->title;
  116. $categoriesValues[] = JHTML::_('select.option', $catid,$categories[$catid]->title);
  117. }
  118. }
  119. jimport('joomla.html.pagination');
  120. $pagination = new JPagination( $pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value );
  121. jimport('joomla.html.pane');
  122. $tabs =& JPane::getInstance('tabs');
  123. echo $tabs->startPane( 'joomlacontent_tab');
  124. echo $tabs->startPanel( JText::_( 'JOOMLA_CONTENT' ), 'joomlacontent_content');
  125. ?>
  126. <br style="font-size:1px"/>
  127. <script language="javascript" type="text/javascript">
  128. <!--
  129. var selectedContents = new Array();
  130. function applyContent(contentid,rowClass){
  131. if(selectedContents[contentid]){
  132. window.document.getElementById('content'+contentid).className = rowClass;
  133. delete selectedContents[contentid];
  134. }else{
  135. window.document.getElementById('content'+contentid).className = 'selectedrow';
  136. selectedContents[contentid] = 'content';
  137. }
  138. updateTag();
  139. }
  140. function updateTag(){
  141. var tag = '';
  142. var otherinfo = '';
  143. for(var i=0; i < document.adminForm.contenttype.length; i++){
  144. if (document.adminForm.contenttype[i].checked){ selectedtype = document.adminForm.contenttype[i].value; otherinfo += document.adminForm.contenttype[i].value; }
  145. }
  146. for(var i=0; i < document.adminForm.titlelink.length; i++){
  147. if (document.adminForm.titlelink[i].checked){ otherinfo += document.adminForm.titlelink[i].value; }
  148. }
  149. if(selectedtype != '|type:title'){
  150. for(var i=0; i < document.adminForm.author.length; i++){
  151. if (document.adminForm.author[i].checked){ otherinfo += document.adminForm.author[i].value; }
  152. }
  153. for(var i=0; i < document.adminForm.pict.length; i++){
  154. if (document.adminForm.pict[i].checked){ otherinfo += '|pict:'+document.adminForm.pict[i].value; }
  155. }
  156. }
  157. if(window.document.getElementById('jflang') && window.document.getElementById('jflang').value != ''){
  158. otherinfo += '|lang:';
  159. otherinfo += window.document.getElementById('jflang').value;
  160. }
  161. for(var i in selectedContents){
  162. if(selectedContents[i] == 'content'){
  163. tag = tag + '{joomlacontent:'+i+otherinfo+'}<br/>';
  164. }
  165. }
  166. setTag(tag);
  167. }
  168. //-->
  169. </script>
  170. <table width="100%" class="adminform">
  171. <tr>
  172. <td>
  173. <?php echo JText::_('DISPLAY'); ?>
  174. </td>
  175. <td colspan="2">
  176. <?php $contentType = acymailing_get('type.content'); echo $contentType->display('contenttype',$pageInfo->contenttype);?>
  177. </td>
  178. <td>
  179. <?php $jflanguages = acymailing_get('type.jflanguages');
  180. $jflanguages->onclick = 'onchange="updateTag();"';
  181. echo $jflanguages->display('lang',$pageInfo->lang); ?>
  182. </td>
  183. </tr>
  184. <tr>
  185. <td>
  186. <?php echo JText::_('CLICKABLE_TITLE'); ?>
  187. </td>
  188. <td>
  189. <?php $titlelinkType = acymailing_get('type.titlelink'); echo $titlelinkType->display('titlelink',$pageInfo->titlelink);?>
  190. </td>
  191. <td>
  192. <?php echo JText::_('AUTHOR_NAME'); ?>
  193. </td>
  194. <td>
  195. <?php $authorname = acymailing_get('type.authorname'); echo $authorname->display('author',$pageInfo->author);?>
  196. </td>
  197. </tr>
  198. <tr>
  199. <td><?php echo JText::_('DISPLAY_PICTURES'); ?></td>
  200. <td><?php echo JHTML::_('select.radiolist', $picts, 'pict' , 'size="1" onclick="updateTag();"', 'value', 'text', $pageInfo->pict); ?></td>
  201. <td></td>
  202. <td></td>
  203. </tr>
  204. </table>
  205. <table>
  206. <tr>
  207. <td width="100%">
  208. <?php echo JText::_( 'JOOMEXT_FILTER' ); ?>:
  209. <input type="text" name="search" id="acymailingsearch" value="<?php echo $pageInfo->search;?>" class="text_area" onchange="document.adminForm.submit();" />
  210. <button onclick="this.form.submit();"><?php echo JText::_( 'JOOMEXT_GO' ); ?></button>
  211. <button onclick="document.getElementById('acymailingsearch').value='';this.form.submit();"><?php echo JText::_( 'JOOMEXT_RESET' ); ?></button>
  212. </td>
  213. <td nowrap="nowrap">
  214. <?php echo JHTML::_('select.genericlist', $categoriesValues, 'filter_cat', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', (int) $pageInfo->filter_cat ); ?>
  215. </td>
  216. </tr>
  217. </table>
  218. <table class="adminlist" cellpadding="1" width="100%">
  219. <thead>
  220. <tr>
  221. <th class="title">
  222. </th>
  223. <th class="title">
  224. <?php echo JHTML::_('grid.sort', JText::_( 'FIELD_TITLE'), 'a.title', $pageInfo->filter->order->dir,$pageInfo->filter->order->value ); ?>
  225. </th>
  226. <th class="title">
  227. <?php echo JHTML::_('grid.sort', JText::_( 'ACY_AUTHOR'), 'b.name', $pageInfo->filter->order->dir,$pageInfo->filter->order->value ); ?>
  228. </th>
  229. <th class="title">
  230. <?php echo JHTML::_('grid.sort', JText::_( 'ACY_CREATED' ), 'a.created', $pageInfo->filter->order->dir, $pageInfo->filter->order->value ); ?>
  231. </th>
  232. <th class="title titleid">
  233. <?php echo JHTML::_('grid.sort', JText::_( 'ACY_ID' ), 'a.id', $pageInfo->filter->order->dir, $pageInfo->filter->order->value ); ?>
  234. </th>
  235. </tr>
  236. </thead>
  237. <tfoot>
  238. <tr>
  239. <td colspan="5">
  240. <?php echo $pagination->getListFooter(); ?>
  241. <?php echo $pagination->getResultsCounter(); ?>
  242. </td>
  243. </tr>
  244. </tfoot>
  245. <tbody>
  246. <?php
  247. $k = 0;
  248. for($i = 0,$a = count($rows);$i<$a;$i++){
  249. $row =& $rows[$i];
  250. ?>
  251. <tr id="content<?php echo $row->id?>" class="<?php echo "row$k"; ?>" onclick="applyContent(<?php echo $row->id.",'row$k'"?>);" style="cursor:pointer;">
  252. <td class="acytdcheckbox"></td>
  253. <td>
  254. <?php
  255. $text = '<b>'.JText::_('JOOMEXT_ALIAS').': </b>'.$row->alias;
  256. echo acymailing_tooltip($text, $row->title, '', $row->title);
  257. ?>
  258. </td>
  259. <td>
  260. <?php
  261. if(!empty($row->name)){
  262. $text = '<b>'.JText::_('JOOMEXT_NAME').' : </b>'.$row->name;
  263. $text .= '<br/><b>'.JText::_('ACY_USERNAME').' : </b>'.$row->username;
  264. $text .= '<br/><b>'.JText::_('ACY_ID').' : </b>'.$row->created_by;
  265. echo acymailing_tooltip($text, $row->name, '', $row->name);
  266. }
  267. ?>
  268. </td>
  269. <td align="center">
  270. <?php echo JHTML::_('date', $row->created, JText::_('DATE_FORMAT_LC4') ); ?>
  271. </td>
  272. <td align="center">
  273. <?php echo $row->id; ?>
  274. </td>
  275. </tr>
  276. <?php
  277. $k = 1-$k;
  278. }
  279. ?>
  280. </tbody>
  281. </table>
  282. <input type="hidden" name="boxchecked" value="0" />
  283. <input type="hidden" name="filter_order" value="<?php echo $pageInfo->filter->order->value; ?>" />
  284. <input type="hidden" name="filter_order_Dir" value="<?php echo $pageInfo->filter->order->dir; ?>" />
  285. <?php
  286. echo $tabs->endPanel();
  287. echo $tabs->startPanel( JText::_( 'TAG_CATEGORIES' ), 'joomlacontent_auto');
  288. $type = JRequest::getString('type');
  289. ?>
  290. <br style="font-size:1px"/>
  291. <script language="javascript" type="text/javascript">
  292. <!--
  293. var selectedCategories = new Array();
  294. <?php if(version_compare(JVERSION,'1.6.0','<')){ ?>
  295. function applyAutoContent(secid,catid,rowClass){
  296. if(selectedCategories[secid] && selectedCategories[secid][catid]){
  297. window.document.getElementById('content_sec'+secid+'_cat'+catid).className = rowClass;
  298. delete selectedCategories[secid][catid];
  299. }else{
  300. if(!selectedCategories[secid]) selectedCategories[secid] = new Array();
  301. if(secid == 0){
  302. for(var isec in selectedCategories){
  303. for(var icat in selectedCategories[isec]){
  304. if(selectedCategories[isec][icat] == 'content'){
  305. window.document.getElementById('content_sec'+isec+'_cat'+icat).className = 'row0';
  306. delete selectedCategories[isec][icat];
  307. }
  308. }
  309. }
  310. }else{
  311. if(selectedCategories[0] && selectedCategories[0][0]){
  312. window.document.getElementById('content_sec0_cat0').className = 'row0';
  313. delete selectedCategories[0][0];
  314. }
  315. if(catid == 0){
  316. for(var icat in selectedCategories[secid]){
  317. if(selectedCategories[secid][icat] == 'content'){
  318. window.document.getElementById('content_sec'+secid+'_cat'+icat).className = 'row0';
  319. delete selectedCategories[secid][icat];
  320. }
  321. }
  322. }else{
  323. if(selectedCategories[secid][0]){
  324. window.document.getElementById('content_sec'+secid+'_cat0').className = 'row0';
  325. delete selectedCategories[secid][0];
  326. }
  327. }
  328. }
  329. window.document.getElementById('content_sec'+secid+'_cat'+catid).className = 'selectedrow';
  330. selectedCategories[secid][catid] = 'content';
  331. }
  332. updateAutoTag();
  333. }
  334. <?php }else{ ?>
  335. function applyAutoContent(catid,rowClass){
  336. if(selectedCategories[catid]){
  337. window.document.getElementById('content_cat'+catid).className = rowClass;
  338. delete selectedCategories[catid];
  339. }else{
  340. window.document.getElementById('content_cat'+catid).className = 'selectedrow';
  341. selectedCategories[catid] = 'content';
  342. }
  343. updateAutoTag();
  344. }
  345. <?php } ?>
  346. function updateAutoTag(){
  347. tag = '{autocontent:';
  348. <?php if(version_compare(JVERSION,'1.6.0','<')){ ?>
  349. for(var isec in selectedCategories){
  350. for(var icat in selectedCategories[isec]){
  351. if(selectedCategories[isec][icat] == 'content'){
  352. if(icat != 0){
  353. tag += 'cat'+icat+'-';
  354. }else{
  355. tag += 'sec'+isec+'-';
  356. }
  357. }
  358. }
  359. }
  360. <?php }else{ ?>
  361. for(var icat in selectedCategories){
  362. if(selectedCategories[icat] == 'content'){
  363. tag += icat+'-';
  364. }
  365. }
  366. <?php } ?>
  367. if(document.adminForm.min_article && document.adminForm.min_article.value && document.adminForm.min_article.value!=0){ tag += '|min:'+document.adminForm.min_article.value; }
  368. if(document.adminForm.max_article.value && document.adminForm.max_article.value!=0){ tag += '|max:'+document.adminForm.max_article.value; }
  369. if(document.adminForm.contentorder.value){ tag += document.adminForm.contentorder.value; }
  370. if(document.adminForm.contentfilter && document.adminForm.contentfilter.value){ tag += document.adminForm.contentfilter.value; }
  371. if(document.adminForm.meta_article && document.adminForm.meta_article.value){ tag += '|meta:'+document.adminForm.meta_article.value; }
  372. for(var i=0; i < document.adminForm.contenttypeauto.length; i++){
  373. if (document.adminForm.contenttypeauto[i].checked){selectedtype = document.adminForm.contenttypeauto[i].value; tag += document.adminForm.contenttypeauto[i].value; }
  374. }
  375. for(var i=0; i < document.adminForm.titlelinkauto.length; i++){
  376. if (document.adminForm.titlelinkauto[i].checked){ tag += document.adminForm.titlelinkauto[i].value; }
  377. }
  378. if(selectedtype != '|type:title'){
  379. for(var i=0; i < document.adminForm.authorauto.length; i++){
  380. if (document.adminForm.authorauto[i].checked){ tag += document.adminForm.authorauto[i].value; }
  381. }
  382. for(var i=0; i < document.adminForm.pictauto.length; i++){
  383. if (document.adminForm.pictauto[i].checked){ tag += '|pict:'+document.adminForm.pictauto[i].value; }
  384. }
  385. if(document.adminForm.cols && document.adminForm.cols.value > 1){ tag += '|cols:'+document.adminForm.cols.value; }
  386. }
  387. if(window.document.getElementById('jflangauto') && window.document.getElementById('jflangauto').value != ''){
  388. tag += '|lang:';
  389. tag += window.document.getElementById('jflangauto').value;
  390. }
  391. tag += '}';
  392. setTag(tag);
  393. }
  394. //-->
  395. </script>
  396. <table width="100%" class="adminform">
  397. <tr>
  398. <td>
  399. <?php echo JText::_('DISPLAY');?>
  400. </td>
  401. <td colspan="2">
  402. <?php $contentType = acymailing_get('type.content'); $contentType->onclick = "updateAutoTag();"; echo $contentType->display('contenttypeauto',$this->params->get('default_type','|type:intro'));?>
  403. </td>
  404. <td>
  405. <?php $jflanguages = acymailing_get('type.jflanguages');
  406. $jflanguages->onclick = 'onchange="updateAutoTag();"';
  407. $jflanguages->id = 'jflangauto';
  408. echo $jflanguages->display('langauto'); ?>
  409. </td>
  410. </tr>
  411. <tr>
  412. <td>
  413. <?php echo JText::_('CLICKABLE_TITLE'); ?>
  414. </td>
  415. <td>
  416. <?php $titlelinkType = acymailing_get('type.titlelink'); $titlelinkType->onclick = "updateAutoTag();"; echo $titlelinkType->display('titlelinkauto',$this->params->get('default_titlelink','|link'));?>
  417. </td>
  418. <td>
  419. <?php echo JText::_('AUTHOR_NAME'); ?>
  420. </td>
  421. <td>
  422. <?php $authorname = acymailing_get('type.authorname'); $authorname->onclick = "updateAutoTag();"; echo $authorname->display('authorauto',$this->params->get('default_author',''));?>
  423. </td>
  424. </tr>
  425. <tr>
  426. <td><?php echo JText::_('DISPLAY_PICTURES'); ?></td>
  427. <td><?php echo JHTML::_('select.radiolist', $picts, 'pictauto' , 'size="1" onclick="updateAutoTag();"', 'value', 'text', $this->params->get('default_pict','1')); ?></td>
  428. <td><?php echo JText::_('FIELD_COLUMNS'); ?></td>
  429. <td><input name="cols" size="10" value="1" onchange="updateAutoTag();"/></td>
  430. </tr>
  431. <tr>
  432. <td>
  433. <?php echo JText::_('MAX_ARTICLE'); ?>
  434. </td>
  435. <td>
  436. <input name="max_article" size="10" value="20" onchange="updateAutoTag();"/>
  437. </td>
  438. <td>
  439. <?php echo JText::_('ACY_ORDER'); ?>
  440. </td>
  441. <td>
  442. <?php $ordertype = acymailing_get('type.contentorder'); $ordertype->onclick = "updateAutoTag();"; echo $ordertype->display('contentorder','|order:id'); ?>
  443. </td>
  444. </tr>
  445. <?php if($this->params->get('metaselect')){ ?>
  446. <tr>
  447. <td>
  448. <?php echo JText::_('META_KEYWORDS'); ?>
  449. </td>
  450. <td colspan="3">
  451. <input name="meta_article" size="50" value="" onchange="updateAutoTag();"/>
  452. </td>
  453. </tr>
  454. <?php } ?>
  455. <?php if($type == 'autonews') { ?>
  456. <tr>
  457. <td>
  458. <?php echo JText::_('MIN_ARTICLE'); ?>
  459. </td>
  460. <td>
  461. <input name="min_article" size="10" value="1" onchange="updateAutoTag();"/>
  462. </td>
  463. <td>
  464. <?php echo JText::_('JOOMEXT_FILTER'); ?>
  465. </td>
  466. <td>
  467. <?php $filter = acymailing_get('type.contentfilter'); $filter->onclick = "updateAutoTag();"; echo $filter->display('contentfilter','|filter:created'); ?>
  468. </td>
  469. </tr>
  470. <?php } ?>
  471. </table>
  472. <table class="adminlist" cellpadding="1" width="100%">
  473. <thead>
  474. <tr>
  475. <th class="title"></th>
  476. <?php if(version_compare(JVERSION,'1.6.0','<')){ ?>
  477. <th class="title">
  478. <?php echo JText::_( 'SECTION'); ?>
  479. </th>
  480. <?php } ?>
  481. <th class="title">
  482. <?php echo JText::_( 'TAG_CATEGORIES'); ?>
  483. </th>
  484. </tr>
  485. </thead>
  486. <tbody>
  487. <?php
  488. $k = 0;
  489. if(version_compare(JVERSION,'1.6.0','<')){
  490. ?>
  491. <tr id="content_sec0_cat0" class="<?php echo "row$k"; ?>" onclick="applyAutoContent(0,0,'<?php echo "row$k" ?>');" style="cursor:pointer;">
  492. <td class="acytdcheckbox"></td>
  493. <td style="font-weight: bold;">
  494. <?php
  495. echo JText::_('ACY_ALL');
  496. ?>
  497. </td>
  498. <td style="text-align:center;font-weight: bold;">
  499. <?php
  500. echo JText::_('ACY_ALL');
  501. ?>
  502. </td>
  503. </tr>
  504. <?php
  505. }
  506. $k = 1-$k;
  507. $currentSection = '';
  508. foreach($categories as $row){
  509. if(version_compare(JVERSION,'1.6.0','<') AND $currentSection != $row->section){
  510. ?>
  511. <tr id="content_sec<?php echo $row->secid ?>_cat0" class="<?php echo "row$k"; ?>" onclick="applyAutoContent(<?php echo $row->secid ?>,0,'<?php echo "row$k" ?>');" style="cursor:pointer;">
  512. <td class="acytdcheckbox"></td>
  513. <td style="font-weight: bold;">
  514. <?php
  515. echo $row->section;
  516. ?>
  517. </td>
  518. <td style="text-align:center;font-weight: bold;">
  519. <?php
  520. echo JText::_('ACY_ALL');
  521. ?>
  522. </td>
  523. </tr>
  524. <?php
  525. $k = 1-$k;
  526. $currentSection = $row->section;
  527. }
  528. if(version_compare(JVERSION,'1.6.0','<')){
  529. ?>
  530. <tr id="content_sec<?php echo $row->secid ?>_cat<?php echo $row->catid?>" class="<?php echo "row$k"; ?>" onclick="applyAutoContent(<?php echo $row->secid ?>,<?php echo $row->catid ?>,'<?php echo "row$k" ?>');" style="cursor:pointer;">
  531. <td class="acytdcheckbox"></td>
  532. <td>
  533. </td>
  534. <td>
  535. <?php
  536. echo $row->category;
  537. ?>
  538. </td>
  539. </tr>
  540. <?php
  541. }else{ ?>
  542. <tr id="content_cat<?php echo $row->id ?>" class="<?php echo "row$k"; ?>" onclick="applyAutoContent(<?php echo $row->id ?>,'<?php echo "row$k" ?>');" style="cursor:pointer;">
  543. <td class="acytdcheckbox"></td>
  544. <td>
  545. <?php
  546. echo $row->title;
  547. ?>
  548. </td>
  549. </tr>
  550. <?php }
  551. $k = 1-$k;
  552. }
  553. ?>
  554. </tbody>
  555. </table>
  556. <?php
  557. echo $tabs->endPanel();
  558. echo $tabs->endPane();
  559. }
  560. function acymailing_replacetags(&$email,$send = true){
  561. $this->_replaceAuto($email);
  562. $this->_replaceArticles($email);
  563. }
  564. function _replaceArticles(&$email){
  565. $match = '#{joomlacontent:(.*)}#Ui';
  566. $variables = array('subject','body','altbody');
  567. $found = false;
  568. foreach($variables as $var){
  569. if(empty($email->$var)) continue;
  570. $found = preg_match_all($match,$email->$var,$results[$var]) || $found;
  571. if(empty($results[$var][0])) unset($results[$var]);
  572. }
  573. if(!$found) return;
  574. require_once JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php';
  575. if($this->params->get('integration') == 'flexicontent' AND file_exists(JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'helpers'.DS.'route.php')){
  576. require_once JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'helpers'.DS.'route.php';
  577. }
  578. $mailerHelper = acymailing_get('helper.mailer');
  579. $htmlreplace = array();
  580. $textreplace = array();
  581. $subjectreplace = array();
  582. foreach($results as $var => $allresults){
  583. foreach($allresults[0] as $i => $oneTag){
  584. if(isset($htmlreplace[$oneTag])) continue;
  585. $article = $this->_replaceContent($allresults,$i);
  586. $htmlreplace[$oneTag] = $article;
  587. $textreplace[$oneTag] = $mailerHelper->textVersion($article);
  588. $subjectreplace[$oneTag] = strip_tags($article);
  589. }
  590. }
  591. $email->body = str_replace(array_keys($htmlreplace),$htmlreplace,$email->body);
  592. $email->altbody = str_replace(array_keys($textreplace),$textreplace,$email->altbody);
  593. $email->subject = str_replace(array_keys($subjectreplace),$subjectreplace,$email->subject);
  594. }
  595. function _replaceContent(&$results,$i){
  596. $arguments = explode('|',strip_tags($results[1][$i]));
  597. $tag = new stdClass();
  598. $tag->id = (int) $arguments[0];
  599. for($i=1,$a=count($arguments);$i<$a;$i++){
  600. $args = explode(':',$arguments[$i]);
  601. $arg0 = trim($args[0]);
  602. if(isset($args[1])){
  603. $tag->$arg0 = $args[1];
  604. }else{
  605. $tag->$arg0 = true;
  606. }
  607. }
  608. if(version_compare(JVERSION,'1.6.0','<')){
  609. $query = 'SELECT a.*,b.name as authorname, c.alias as catalias, c.title as cattitle, s.alias as secalias, s.title as sectitle FROM '.acymailing_table('content',false).' as a ';
  610. $query .= 'LEFT JOIN '.acymailing_table('users',false).' as b ON a.created_by = b.id ';
  611. $query .= ' LEFT JOIN '.acymailing_table('categories',false).' AS c ON c.id = a.catid ';
  612. $query .= ' LEFT JOIN '.acymailing_table('sections',false).' AS s ON s.id = a.sectionid ';
  613. $query .= 'WHERE a.id = '.$tag->id.' LIMIT 1';
  614. }else{
  615. $query = 'SELECT a.*,b.name as authorname, c.alias as catalias, c.title as cattitle FROM '.acymailing_table('content',false).' as a ';
  616. $query .= 'LEFT JOIN '.acymailing_table('users',false).' as b ON a.created_by = b.id ';
  617. $query .= ' LEFT JOIN '.acymailing_table('categories',false).' AS c ON c.id = a.catid ';
  618. $query .= 'WHERE a.id = '.$tag->id.' LIMIT 1';
  619. }
  620. $db =& JFactory::getDBO();
  621. $db->setQuery($query);
  622. $article = $db->loadObject();
  623. $result = '';
  624. if(empty($article)){
  625. $app =& JFactory::getApplication();
  626. if($app->isAdmin()){
  627. $app->enqueueMessage('The article "'.$tag->id.'" could not be loaded','notice');
  628. }
  629. return $result;
  630. }
  631. if(!empty($tag->lang)){
  632. $langid = (int) substr($tag->lang,strpos($tag->lang,',')+1);
  633. if(!empty($langid)){
  634. $query = "SELECT reference_field, value FROM `#__jf_content` WHERE `published` = 1 AND `reference_table` = 'content' AND `language_id` = $langid AND `reference_id` = ".$tag->id;
  635. $db->setQuery($query);
  636. $translations = $db->loadObjectList();
  637. if(!empty($translations)){
  638. foreach($translations as $oneTranslation){
  639. if(!empty($oneTranslation->value)){
  640. $translatedfield = $oneTranslation->reference_field;
  641. $article->$translatedfield = $oneTranslation->value;
  642. }
  643. }
  644. }
  645. }
  646. }
  647. if($this->params->get('integration') == 'jreviews' AND !empty($article->images)){
  648. $firstpict = explode('|',trim(reset(explode("\n",$article->images))). '|||||||');
  649. if(!empty($firstpict[0])){
  650. $myPict = '<img src="' . ACYMAILING_LIVE . 'images/stories/' . $firstpict[0] . '" hspace="5" style="margin:5px" align="left" border="' . intval($firstpict[5]) . '" />';
  651. $article->introtext = $myPict.$article->introtext;
  652. }
  653. }
  654. $completeId = $article->id;
  655. $completeCat = $article->catid;
  656. if(!empty($article->alias)) $completeId.=':'.$article->alias;
  657. if(!empty($article->catalias)) $completeCat .= ':'.$article->catalias;
  658. if(empty($tag->itemid)){
  659. if(version_compare(JVERSION,'1.6.0','<')){
  660. $completeSec = $article->sectionid;
  661. if(!empty($article->secalias)) $completeSec .= ':'.$article->secalias;
  662. if($this->params->get('integration') == 'flexicontent' && class_exists('FlexicontentHelperRoute')){
  663. $link = FlexicontentHelperRoute::getItemRoute($completeId,$completeCat,$completeSec);
  664. }else{
  665. $link = ContentHelperRoute::getArticleRoute($completeId,$completeCat,$completeSec);
  666. }
  667. }else{
  668. if($this->params->get('integration') == 'flexicontent' && class_exists('FlexicontentHelperRoute')){
  669. $link = FlexicontentHelperRoute::getItemRoute($completeId,$completeCat);
  670. }else {
  671. $link = ContentHelperRoute::getArticleRoute($completeId,$completeCat);
  672. }
  673. }
  674. }else{
  675. $link = 'index.php?option=com_content&view=article&id='.$completeId.'&catid='.$completeCat;
  676. }
  677. if($this->params->get('integration') == 'flexicontent' && !class_exists('FlexicontentHelperRoute')){
  678. $link = 'index.php?option=com_flexicontent&view=items&id='.$completeId;
  679. }elseif($this->params->get('integration') == 'jaggyblog'){
  680. $link = 'index.php?option=com_jaggyblog&task=viewpost&id='.$completeId;
  681. }
  682. if(!empty($tag->itemid)) $link .= '&Itemid='.$tag->itemid;
  683. if(!empty($tag->lang)) $link.= (strpos($link,'?') ? '&' : '?') . 'lang='.substr($tag->lang, 0,strpos($tag->lang,','));
  684. if(!empty($tag->autologin)) $link.= (strpos($link,'?') ? '&' : '?') . 'user={usertag:username|urlencode}&passw={usertag:password|urlencode}';
  685. $link = acymailing_frontendLink($link);
  686. $styleTitle = '';
  687. $styleTitleEnd = '';
  688. if($tag->type != "title"){
  689. $styleTitle = '<h2 class="acymailing_title">';
  690. $styleTitleEnd = '</h2>';
  691. }
  692. if(empty($tag->notitle)){
  693. if(!empty($tag->link)){
  694. $result .= '<a href="'.$link.'" ';
  695. if($tag->type != "title") $result .= 'style="text-decoration:none" name="content-'.$article->id.'" ';
  696. $result .= 'target="_blank" >'.$styleTitle.$article->title.$styleTitleEnd.'</a>';
  697. }else{
  698. $result .= $styleTitle.$article->title.$styleTitleEnd;
  699. }
  700. }
  701. if(!empty($tag->author)){
  702. $authorName = empty($article->created_by_alias) ? $article->authorname : $article->created_by_alias;
  703. if($tag->type == 'title') $result .= '<br/>';
  704. $result .= '<span class="authorname">'.$authorName.'</span><br/>';
  705. }
  706. if(!empty($tag->created)){
  707. if($tag->type == 'title') $result .= '<br/>';
  708. $dateFormat = empty($tag->dateformat) ? JText::_('DATE_FORMAT_LC2') : $tag->dateformat;
  709. $result .= '<span class="createddate">'.JHTML::_( 'date', $article->created, $dateFormat).'</span><br/>';
  710. }
  711. if(!isset($tag->pict) AND $tag->type != 'title'){
  712. if($this->params->get('removepictures','never') == 'always' || ($this->params->get('removepictures','never') == 'intro' AND $tag->type == "intro")){
  713. $tag->pict = 0;
  714. }else{
  715. $tag->pict = 1;
  716. }
  717. }
  718. if(strpos($article->introtext,'jseblod') !== false AND file_exists(ACYMAILING_ROOT.'plugins'.DS.'content'.DS.'cckjseblod.php')){
  719. global $mainframe;
  720. include_once(ACYMAILING_ROOT.'plugins'.DS.'content'.DS.'cckjseblod.php');
  721. if(function_exists('plgContentCCKjSeblod')){
  722. $paramsContent =& JComponentHelper::getParams('com_content');
  723. $article->text = $article->introtext.$article->fulltext;
  724. plgContentCCKjSeblod($article,$paramsContent);
  725. $article->introtext = $article->text;
  726. $article->fulltext = '';
  727. }
  728. }
  729. if($tag->type != "title"){
  730. $contentText = '';
  731. if($tag->type == "intro"){
  732. $forceReadMore = false;
  733. $wordwrap = $this->params->get('wordwrap',0);
  734. if(!empty($wordwrap) AND empty($article->fulltext)){
  735. $newintrotext = strip_tags($article->introtext,'<br><img>');
  736. $numChar = strlen($newintrotext);
  737. if($numChar > $wordwrap){
  738. $stop = strlen($newintrotext);
  739. for($i=$wordwrap;$i<$numChar;$i++){
  740. if($newintrotext[$i] == " "){
  741. $stop = $i;
  742. $forceReadMore = true;
  743. break;
  744. }
  745. }
  746. $article->introtext = substr($newintrotext,0,$stop).'...';
  747. }
  748. }
  749. }
  750. if(empty($article->fulltext) OR $tag->type != "text"){
  751. $contentText .= $article->introtext;
  752. }
  753. if($tag->type != "intro" AND !empty($article->fulltext)){
  754. if( $tag->type != "text" && !empty($article->introtext)){
  755. $contentText .= '<br />';
  756. }
  757. $contentText .= $article->fulltext;
  758. }
  759. if(!empty($tag->wrap)){
  760. $newtext = strip_tags($contentText,'<br><img>');
  761. $numChar = strlen($newtext);
  762. if($numChar > $tag->wrap){
  763. $stop = strlen($newtext);
  764. for($i=$tag->wrap;$i<$numChar;$i++){
  765. if($newtext[$i] == " "){
  766. $stop = $i;
  767. $forceReadMore = true;
  768. break;
  769. }
  770. }
  771. $contentText = substr($newtext,0,$stop).'...';
  772. }
  773. }
  774. $result .= $contentText;
  775. if($tag->type == "intro"){
  776. if(empty($tag->noreadmore) AND (!empty($article->fulltext) OR $forceReadMore)){
  777. $readMoreText = empty($tag->readmore) ? JText::_('JOOMEXT_READ_MORE') : $tag->readmore;
  778. $result .= '<a style="text-decoration:none;" target="_blank" href="'.$link.'"><span class="acymailing_readmore">'.$readMoreText.'</span></a>';
  779. }
  780. }
  781. $result = '<div class="acymailing_content">'.$result.'</div>';
  782. }
  783. if(!empty($tag->theme)){
  784. if(preg_match('#<img[^>]*>#Uis',$article->introtext.$article->fulltext,$pregresult)){
  785. $cleanContent = strip_tags($result,'<p><br><span><ul><li><h1><h2><h3><h4><a>');
  786. $tdwidth = (empty($tag->maxwidth) ? $this->params->get('maxwidth',150) : $tag->maxwidth) + 20;
  787. $result = '<div class="acymailing_content"><table cellspacing="0" width="500" cellpadding="0" border="0" ><tr><td class="contentpicture" width="'.$tdwidth.'" valign="top" align="center"><a href="'.$link.'" target="_blank" style="border:0px;text-decoration:none">'.$pregresult[0].'</a></td><td class="contenttext">'.$cleanContent.'</td></tr></table></div>';
  788. }
  789. }
  790. if(file_exists(ACYMAILING_MEDIA.'plugins'.DS.'tagcontent_html.php')){
  791. ob_start();
  792. require(ACYMAILING_MEDIA.'plugins'.DS.'tagcontent_html.php');
  793. $result = ob_get_clean();
  794. }elseif(file_exists(ACYMAILING_MEDIA.'plugins'.DS.'tagcontent.php')){
  795. ob_start();
  796. require(ACYMAILING_MEDIA.'plugins'.DS.'tagcontent.php');
  797. $result = ob_get_clean();
  798. }
  799. if($tag->type != 'title' AND $this->params->get('removejs','yes') == 'yes'){
  800. $result = $this->_removeJS($result);
  801. }
  802. if(isset($tag->pict)){
  803. $pictureHelper = acymailing_get('helper.acypict');
  804. $pictureHelper->maxHeight = empty($tag->maxheight) ? $this->params->get('maxheight',150) : $tag->maxheight;
  805. $pictureHelper->maxWidth = empty($tag->maxwidth) ? $this->params->get('maxwidth',150) : $tag->maxwidth;
  806. if($tag->pict == '0'){
  807. $result = $pictureHelper->removePictures($result);
  808. }elseif($tag->pict == 'resized'){
  809. if($pictureHelper->available()){
  810. $result = $pictureHelper->resizePictures($result);
  811. }elseif($app->isAdmin()){
  812. $app->enqueueMessage($pictureHelper->error,'notice');
  813. }
  814. }
  815. }
  816. return $result;
  817. }
  818. function _replaceAuto(&$email){
  819. $this->acymailing_generateautonews($email);
  820. if(!empty($this->tags)){
  821. $email->body = str_replace(array_keys($this->tags),$this->tags,$email->body);
  822. if(!empty($email->altbody)) $email->altbody = str_replace(array_keys($this->tags),$this->tags,$email->altbody);
  823. foreach($this->tags as $tag => $result){
  824. $email->subject = str_replace($tag,strip_tags(str_replace('</tr><tr>',' | ',$result)),$email->subject);
  825. }
  826. }
  827. }
  828. function acymailing_generateautonews(&$email){
  829. $return = null;
  830. $return->status = true;
  831. $return->message = '';
  832. $time = time();
  833. $match = '#{autocontent:(.*)}#Ui';
  834. $variables = array('subject','body','altbody');
  835. $found = false;
  836. foreach($variables as $var){
  837. if(empty($email->$var)) continue;
  838. $found = preg_match_all($match,$email->$var,$results[$var]) || $found;
  839. if(empty($results[$var][0])) unset($results[$var]);
  840. }
  841. if(!$found) return $return;
  842. $this->tags = array();
  843. $db =& JFactory::getDBO();
  844. foreach($results as $var => $allresults){
  845. foreach($allresults[0] as $i => $oneTag){
  846. if(isset($this->tags[$oneTag])) continue;
  847. $arguments = explode('|',strip_tags($allresults[1][$i]));
  848. $allcats = explode('-',$arguments[0]);
  849. $parameter = null;
  850. for($a=1;$a<count($arguments);$a++){
  851. $args = explode(':',$arguments[$a]);
  852. $arg0 = trim($args[0]);
  853. if(isset($args[1])){
  854. $parameter->$arg0 = $args[1];
  855. }else{
  856. $parameter->$arg0 = true;
  857. }
  858. }
  859. $selectedArea = array();
  860. foreach($allcats as $oneCat){
  861. if(version_compare(JVERSION,'1.6.0','<')){
  862. $sectype = substr($oneCat,0,3);
  863. $num = substr($oneCat,3);
  864. if(empty($num)) continue;
  865. if($sectype=='cat'){
  866. $selectedArea[] = 'catid = '.(int) $num;
  867. }elseif($sectype=='sec'){
  868. $selectedArea[] = 'sectionid = '.(int) $num;
  869. }
  870. }else{
  871. if(empty($oneCat)) continue;
  872. $selectedArea[] = (int) $oneCat;
  873. }
  874. }
  875. $query = 'SELECT a.id FROM `#__content` as a ';
  876. $where = array();
  877. if(!empty($parameter->featured)){
  878. $query .= 'JOIN `#__content_frontpage` as b ON a.id = b.content_id ';
  879. $where[] = 'b.content_id IS NOT NULL';
  880. }
  881. if(!empty($selectedArea)){
  882. if(version_compare(JVERSION,'1.6.0','<')){
  883. $where[] = implode(' OR ',$selectedArea);
  884. }else{
  885. $where[] = '`catid` IN ('.implode(',',$selectedArea).')';
  886. }
  887. }
  888. if(!empty($parameter->excludedcats)){
  889. $excludedCats = explode('-',$parameter->excludedcats);
  890. JArrayHelper::toInteger($excludedCats);
  891. $where[] = '`catid` NOT IN ("'.implode('","',$excludedCats).'")';
  892. }
  893. if(!empty($parameter->filter) AND !empty($email->params['lastgenerateddate'])){
  894. $condition = '`publish_up` >\''.date( 'Y-m-d H:i:s',$email->params['lastgenerateddate'] - date('Z')).'\'';
  895. $condition .= ' OR `created` >\''.date( 'Y-m-d H:i:s',$email->params['lastgenerateddate'] - date('Z')).'\'';
  896. if($parameter->filter == 'modify'){
  897. $condition .= ' OR (';
  898. $condition .= ' `modified` > \''.date( 'Y-m-d H:i:s',$email->params['lastgenerateddate'] - date('Z')).'\'';
  899. if(!empty($parameter->maxpublished)) $condition .= ' AND `publish_up` > \''.date( 'Y-m-d H:i:s',time() - date('Z') - ((int)$parameter->maxpublished*60*60*24)).'\'';
  900. $condition .= ')';
  901. }
  902. $where[] = $condition;
  903. }
  904. if(!empty($parameter->maxcreated)){
  905. $date = strtotime($parameter->maxcreated);
  906. if(empty($date)){
  907. acymailing_display('Wrong date format ('.$parameter->maxcreated.' in '.$oneTag.'), please use YYYY-MM-DD','warning');
  908. }
  909. $where[] = '`created` < '.$db->Quote(date('Y-m-d H:i:s',$date));
  910. }
  911. if(!empty($parameter->mincreated)){
  912. $date = strtotime($parameter->mincreated);
  913. if(empty($date)){
  914. acymailing_display('Wrong date format ('.$parameter->mincreated.' in '.$oneTag.'), please use YYYY-MM-DD','warning');
  915. }
  916. $where[] = '`created` > '.$db->Quote(date('Y-m-d H:i:s',$date));
  917. }
  918. if(!empty($parameter->meta)){
  919. $allMetaTags = explode(',',$parameter->meta);
  920. $metaWhere = array();
  921. foreach($allMetaTags as $oneMeta){
  922. if(empty($oneMeta)) continue;
  923. $metaWhere[] = "`metakey` LIKE '%".$db->getEscaped($oneMeta,true)."%'";
  924. }
  925. if(!empty($metaWhere)) $where[] = implode(' OR ',$metaWhere);
  926. }
  927. $where[] = '`publish_up` < \'' .date( 'Y-m-d H:i:s',$time - date('Z')).'\'';
  928. $where[] = '`publish_down` > \''.date( 'Y-m-d H:i:s',$time - date('Z')).'\' OR `publish_down` = 0';
  929. $where[] = 'state = 1';
  930. if(version_compare(JVERSION,'1.6.0','<')){
  931. if(isset($parameter->access)){
  932. $where[] = 'access <= '.intval($parameter->access);
  933. }else{
  934. if($this->params->get('contentaccess','registered') == 'registered') $where[] = 'access <= 1';
  935. elseif($this->params->get('contentaccess','registered') == 'public') $where[] = 'access = 0';
  936. }
  937. }elseif(isset($parameter->access)){
  938. $where[] = 'access = '.intval($parameter->access);
  939. }
  940. $query .= ' WHERE ('.implode(') AND (',$where).')';
  941. if(!empty($parameter->order)){
  942. if($parameter->order == 'rand'){
  943. $query .= ' ORDER BY rand()';
  944. }else{
  945. $ordering = explode(',',$parameter->order);
  946. $query .= ' ORDER BY `'.acymailing::secureField($ordering[0]).'` '.acymailing::secureField($ordering[1]);
  947. }
  948. }
  949. $start = '';
  950. if(!empty($parameter->start)) $start = intval($parameter->start).',';
  951. if(empty($parameter->max)) $parameter->max = 100;
  952. $query .= ' LIMIT '.$start.(int) $parameter->max;
  953. $db->setQuery($query);
  954. $allArticles = $db->loadResultArray();
  955. if(!empty($parameter->min) AND count($allArticles)< $parameter->min){
  956. $return->status = false;
  957. $return->message = 'Not enough articles for the tag '.$oneTag.' : '.count($allArticles).' / '.$parameter->min.' between '.acymailing_getDate($email->params['lastgenerateddate']).' and '.acymailing_getDate($time);
  958. }
  959. $stringTag = '';
  960. if(!empty($allArticles)){
  961. if(file_exists(ACYMAILING_MEDIA.'plugins'.DS.'autocontent.php')){
  962. ob_start();
  963. require(ACYMAILING_MEDIA.'plugins'.DS.'autocontent.php');
  964. $stringTag = ob_get_clean();
  965. }else{
  966. $arrayElements = array();
  967. foreach($allArticles as $oneArticleId){
  968. $args = array();
  969. $args[] = 'joomlacontent:'.$oneArticleId;
  970. if(!empty($parameter->type)) $args[] = 'type:'.$parameter->type;
  971. if(!empty($parameter->link)) $args[] = 'link';
  972. if(!empty($parameter->author)) $args[] = 'author';
  973. if(!empty($parameter->autologin)) $args[] = 'autologin';
  974. if(!empty($parameter->lang)) $args[] = 'lang:'.$parameter->lang;
  975. if(!empty($parameter->theme)) $args[] = 'theme:'.$parameter->theme;
  976. if(!empty($parameter->notitle)) $args[] = 'notitle';
  977. if(!empty($parameter->created)) $args[] = 'created';
  978. if(!empty($parameter->itemid)) $args[] = 'itemid:'.$parameter->itemid;
  979. if(!empty($parameter->noreadmore)) $args[] = 'noreadmore';
  980. if(isset($parameter->pict)) $args[] = 'pict:'.$parameter->pict;
  981. if(!empty($parameter->wrap)) $args[] = 'wrap:'.$parameter->wrap;
  982. if(!empty($parameter->maxwidth)) $args[] = 'maxwidth:'.$parameter->maxwidth;
  983. if(!empty($parameter->maxheight)) $args[] = 'maxheight:'.$parameter->maxheight;
  984. if(!empty($parameter->readmore)) $args[] = 'readmore:'.$parameter->readmore;
  985. if(!empty($parameter->dateformat)) $args[] = 'dateformat:'.$parameter->dateformat;
  986. $arrayElements[] = '{'.implode('|',$args).'}';
  987. }
  988. $acypluginsHelper = acymailing::get('helper.acyplugins');
  989. $stringTag = $acypluginsHelper->getFormattedResult($arrayElements,$parameter);
  990. }
  991. }
  992. $this->tags[$oneTag] = $stringTag;
  993. }
  994. }
  995. return $return;
  996. }
  997. function _removeJS($text){
  998. $text = preg_replace("#(onmouseout|onmouseover|onclick|onfocus|onload|onblur) *= *\"(?:(?!\").)*\"#iU",'',$text);
  999. $text = preg_replace("#< *script(?:(?!< */ *script *>).)*< */ *script *>#isU",'',$text);
  1000. return $text;
  1001. }
  1002. }//endclass