PageRenderTime 54ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

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

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