PageRenderTime 43ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

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

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