mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 04:38:27 +01:00
Newsfeeds: Fixes #1495. Admin-area rewrite using admin-ui. Newsfeed class is now compatible with PHP7.
This commit is contained in:
parent
716678a3b7
commit
f6ca9f8883
@ -2213,8 +2213,13 @@ class pluginBuilder
|
||||
{
|
||||
$this->createFiles = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(vartrue($_POST['step']) == 4)
|
||||
{
|
||||
$this->step4();
|
||||
return null;
|
||||
}
|
||||
|
||||
if(vartrue($_GET['step']) == 3)
|
||||
{
|
||||
|
||||
@ -2222,11 +2227,7 @@ class pluginBuilder
|
||||
return null;
|
||||
}
|
||||
|
||||
if(vartrue($_POST['step']) == 4)
|
||||
{
|
||||
$this->step4();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(vartrue($_GET['newplugin']) && $_GET['step']==2)
|
||||
@ -2856,7 +2857,7 @@ class pluginBuilder
|
||||
case 'summary-summary':
|
||||
$help = EPL_ADLAN_142."<br />".EPL_ADLAN_143;
|
||||
$required = true;
|
||||
$size = 100;
|
||||
$size = 130;
|
||||
$placeholder= " ";
|
||||
$pattern = "[A-Za-z \.0-9]*";
|
||||
$xsize = 'block-level';
|
||||
|
@ -363,6 +363,13 @@ $text .= "<div class='field-spacer'>".$tp->parseTemplate("{IMAGESELECTOR={$parms
|
||||
$sLogo = siteinfo_shortcodes::sc_logo();
|
||||
*/
|
||||
|
||||
if(!empty($pref['sitebutton']) && strpos($pref['sitebutton'],'{')===false && file_exists(e_IMAGE.$pref['sitebutton']))
|
||||
{
|
||||
$pref['sitebutton'] = '{e_IMAGE}'.$pref['sitebutton'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
$text .= $frm->imagepicker('sitebutton',$pref['sitebutton'],'','help='.PRFLAN_225);
|
||||
|
||||
$text .= "
|
||||
|
@ -172,7 +172,7 @@ class ecache {
|
||||
/**
|
||||
*
|
||||
* @param string $CacheTag - name of tag for future retrieval - should NOT contain an MD5.
|
||||
* @param data $Data - data to be cached
|
||||
* @param string $Data - data to be cached
|
||||
* @param boolean $ForceCache [optional] if TRUE, writes cache even when disabled in admin prefs.
|
||||
* @param boolean $bRaw [optional] if TRUE, writes data exactly as provided instead of prefacing with php leadin
|
||||
* @param boolean $syscache [optional]
|
||||
|
@ -3570,7 +3570,18 @@ class e_form
|
||||
}
|
||||
|
||||
if(!is_array($attributes['writeParms'])) parse_str($attributes['writeParms'], $attributes['writeParms']);
|
||||
$value = vartrue($attributes['writeParms']['__options']['pre']).vartrue($attributes['writeParms'][$value]).vartrue($attributes['writeParms']['__options']['post']);
|
||||
|
||||
if(!empty($attributes['writeParms']['optArray']))
|
||||
{
|
||||
$radioValue = $attributes['writeParms']['optArray'][$value];
|
||||
}
|
||||
else
|
||||
{
|
||||
$radioValue = vartrue($attributes['writeParms'][$value]);
|
||||
}
|
||||
|
||||
|
||||
$value = vartrue($attributes['writeParms']['__options']['pre']).$radioValue.vartrue($attributes['writeParms']['__options']['post']);
|
||||
break;
|
||||
|
||||
case 'tags':
|
||||
|
@ -151,7 +151,7 @@ class MagpieRSS {
|
||||
// check for a namespace, and split if found
|
||||
$ns = false;
|
||||
if ( strpos( $element, ':' ) ) {
|
||||
list($ns, $el) = split( ':', $element, 2);
|
||||
list($ns, $el) = explode( ':', $element, 2);
|
||||
}
|
||||
if ( $ns and $ns != 'rdf' ) {
|
||||
$this->current_namespace = $ns;
|
||||
|
@ -23,7 +23,7 @@ if(isset($parms['caption'][e_LANGUAGE]))
|
||||
|
||||
$limit = vartrue($parms['count'],5);
|
||||
$tp = e107::getParser();
|
||||
$template = e107::getTemplate('news', 'news_menu', 'carousel', false, true);
|
||||
$template = e107::getTemplate('news', 'news_menu', 'carousel', true, true);
|
||||
|
||||
$nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'";
|
||||
|
||||
|
@ -1,217 +1,310 @@
|
||||
<?php
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* Plugin administration - newsfeeds
|
||||
*
|
||||
*
|
||||
*/
|
||||
require_once("../../class2.php");
|
||||
if (!getperms("P") || !e107::isInstalled('newsfeed'))
|
||||
/**
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2016 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
// Generated e107 Plugin Admin Area
|
||||
|
||||
require_once('../../class2.php');
|
||||
if (!getperms('P') || !e107::isInstalled('newsfeed'))
|
||||
{
|
||||
e107::redirect('admin');
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(e_ADMIN."auth.php");
|
||||
e107::lan('newsfeed',true);
|
||||
|
||||
define('NEWSFEED_LIST_CACHE_TAG', 'nomd5_newsfeeds');
|
||||
define('NEWSFEED_NEWS_CACHE_TAG', 'nomd5_newsfeeds_news_');
|
||||
|
||||
$frm = e107::getForm();
|
||||
$mes = e107::getMessage();
|
||||
|
||||
if (e_QUERY)
|
||||
class newsfeed_adminArea extends e_admin_dispatcher
|
||||
{
|
||||
list($action, $id) = explode(".", e_QUERY);
|
||||
$id = intval($id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$action = FALSE;
|
||||
$id = FALSE;
|
||||
|
||||
protected $modes = array(
|
||||
|
||||
'main' => array(
|
||||
'controller' => 'newsfeed_ui',
|
||||
'path' => null,
|
||||
'ui' => 'newsfeed_form_ui',
|
||||
'uipath' => null
|
||||
),
|
||||
|
||||
|
||||
);
|
||||
|
||||
|
||||
protected $adminMenu = array(
|
||||
|
||||
'main/list' => array('caption'=> LAN_MANAGE, 'perm' => 'P'),
|
||||
'main/create' => array('caption'=> LAN_CREATE, 'perm' => 'P'),
|
||||
|
||||
// 'main/custom' => array('caption'=> 'Custom Page', 'perm' => 'P')
|
||||
);
|
||||
|
||||
protected $adminMenuAliases = array(
|
||||
'main/edit' => 'main/list'
|
||||
);
|
||||
|
||||
protected $menuTitle = LAN_PLUGIN_NEWSFEEDS_NAME;
|
||||
}
|
||||
|
||||
if (isset($_POST['createFeed']) || isset($_POST['updateFeed']))
|
||||
|
||||
|
||||
|
||||
|
||||
class newsfeed_ui extends e_admin_ui
|
||||
{
|
||||
if ($_POST['newsfeed_url'] && $_POST['newsfeed_name'])
|
||||
{
|
||||
$feed['newsfeed_name'] = $tp->toDB($_POST['newsfeed_name']);
|
||||
$feed['newsfeed_description'] = $tp->toDB($_POST['newsfeed_description']);
|
||||
$feed['newsfeed_image'] = $tp->toDB($_POST['newsfeed_image'])."::".intval($_POST['newsfeed_showmenu'])."::".intval($_POST['newsfeed_showmain']);
|
||||
$feed['newsfeed_url'] = $tp->toDB($_POST['newsfeed_url']);
|
||||
$feed['newsfeed_active'] = intval($_POST['newsfeed_active']);
|
||||
$feed['newsfeed_updateint'] = intval($_POST['newsfeed_updateint']);
|
||||
$feed['newsfeed_data'] = ''; // Start with blank data feed
|
||||
$feed['newsfeed_timestamp'] = 0; // This should force an immediate update
|
||||
|
||||
if (isset($_POST['createFeed']))
|
||||
|
||||
protected $pluginTitle = LAN_PLUGIN_NEWSFEEDS_NAME;
|
||||
protected $pluginName = 'newsfeed';
|
||||
// protected $eventName = 'newsfeed-newsfeed'; // remove comment to enable event triggers in admin.
|
||||
protected $table = 'newsfeed';
|
||||
protected $pid = 'newsfeed_id';
|
||||
protected $perPage = 10;
|
||||
protected $batchDelete = true;
|
||||
protected $batchCopy = true;
|
||||
// protected $sortField = 'somefield_order';
|
||||
// protected $orderStep = 10;
|
||||
// protected $tabs = array('Tabl 1','Tab 2'); // Use 'tab'=>0 OR 'tab'=>1 in the $fields below to enable.
|
||||
|
||||
// protected $listQry = "SELECT * FROM `#tableName` WHERE field != '' "; // Example Custom Query. LEFT JOINS allowed. Should be without any Order or Limit.
|
||||
|
||||
protected $listOrder = 'newsfeed_id DESC';
|
||||
|
||||
protected $fields = array ( 'checkboxes' => array ( 'title' => '', 'type' => null, 'data' => null, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect', ),
|
||||
'newsfeed_id' => array ( 'title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
|
||||
'newsfeed_name' => array ( 'title' => LAN_TITLE, 'type' => 'text', 'data' => 'str', 'required'=>true, 'width' => 'auto', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
|
||||
'newsfeed_url' => array ( 'title' => LAN_URL, 'type' => 'url', 'data' => 'str', 'required'=>true, 'inline'=>true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => array('size'=>'xxlarge'), 'class' => 'left', 'thclass' => 'left', ),
|
||||
'newsfeed_data' => array ( 'title' => 'Data', 'type' => 'hidden', 'data' => false, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
|
||||
'newsfeed_timestamp' => array ( 'title' => 'Timestamp', 'type' => 'hidden', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
|
||||
'newsfeed_description' => array ( 'title' => LAN_DESCRIPTION, 'type' => 'textarea', 'data' => 'str', 'width' => '40%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
|
||||
'newsfeed_image' => array ( 'title' => NFLAN_11, 'type' => 'method', 'data' => 'str', 'width' => 'auto', 'help' => LAN_OPTIONAL, 'readParms' => 'thumb=80x80', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
|
||||
|
||||
'newsfeed_updateint' => array ( 'title' => NFLAN_18, 'type' => 'text', 'data' => 'int', 'inline'=>true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => array('default'=>3600), 'class' => 'left', 'thclass' => 'left', ),
|
||||
|
||||
'newsfeed_active' => array ( 'title' => NFLAN_12, 'type' => 'radio', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => array('default'=>3, 'optArray'=>array(NFLAN_13,NFLAN_14,NFLAN_20,NFLAN_21)), 'class' => 'left', 'thclass' => 'left', ),
|
||||
|
||||
'newsfeed_showmenu' => array('title'=>NFLAN_45, 'type'=>'method', 'data'=>false, 'class'=>'center', 'thclass'=>'center' ),
|
||||
'newsfeed_showmain' => array('title'=>NFLAN_46, 'type'=>'method', 'data'=>false, 'class'=>'center', 'thclass'=>'center'),
|
||||
|
||||
'options' => array ( 'title' => LAN_OPTIONS, 'type' => null, 'data' => null, 'width' => '8%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1', ),
|
||||
);
|
||||
|
||||
protected $fieldpref = array('newsfeed_name', 'newsfeed_url', 'newsfeed_updateint', 'newsfeed_active', 'newsfeed_showmenu', 'newsfeed_showmain');
|
||||
|
||||
|
||||
// protected $preftabs = array('General', 'Other' );
|
||||
protected $prefs = array(
|
||||
);
|
||||
|
||||
|
||||
public function init()
|
||||
{
|
||||
if ($sql->insert('newsfeed',$feed))
|
||||
if($this->getAction() == 'edit' || $this->getAction() == 'create')
|
||||
{
|
||||
$admin_log->logArrayAll('NEWSFD_01', $feed);
|
||||
$mes->addSuccess(LAN_CREATED);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mes->addError(LAN_CREATED_FAILED.': '.$sql->mySQLerror);
|
||||
$this->fields['newsfeed_updateint']['type'] = 'number';
|
||||
}
|
||||
// Set drop-down values (if any).
|
||||
|
||||
}
|
||||
elseif (isset($_POST['updateFeed']))
|
||||
|
||||
|
||||
// ------- Customize Create --------
|
||||
|
||||
public function beforeCreate($new_data)
|
||||
{
|
||||
$feed['WHERE'] = "newsfeed_id=".intval($_POST['newsfeed_id']);
|
||||
|
||||
if($sql->update('newsfeed',$feed))
|
||||
if(isset($new_data['newsfeed_showmenu']))
|
||||
{
|
||||
$admin_log->logArrayAll('NEWSFD_02', $feed);
|
||||
$mes->addSuccess(LAN_UPDATED);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mes->addInfo(LAN_NO_CHANGE.': '.$sql->mySQLerror);
|
||||
$new_data['newsfeed_image'] = e107::getParser()->toDB($new_data['newsfeed_image'])."::".intval($new_data['newsfeed_showmenu'])."::".intval($new_data['newsfeed_showmain']);
|
||||
}
|
||||
|
||||
return $new_data;
|
||||
}
|
||||
e107::getCache()->clear(NEWSFEED_LIST_CACHE_TAG); // This should actually clear all the newsfeed data in one go
|
||||
}
|
||||
else
|
||||
|
||||
public function afterCreate($new_data, $old_data, $id)
|
||||
{
|
||||
// do something
|
||||
e107::getCache()->clear(NEWSFEED_LIST_CACHE_TAG);
|
||||
e107::getCache()->clear(NEWSFEED_NEWS_CACHE_TAG);
|
||||
}
|
||||
|
||||
public function onCreateError($new_data, $old_data)
|
||||
{
|
||||
// do something
|
||||
}
|
||||
|
||||
|
||||
// ------- Customize Update --------
|
||||
|
||||
public function beforeUpdate($new_data, $old_data, $id)
|
||||
{
|
||||
if(isset($new_data['newsfeed_showmenu']))
|
||||
{
|
||||
$new_data['newsfeed_image'] = e107::getParser()->toDB($new_data['newsfeed_image'])."::".intval($new_data['newsfeed_showmenu'])."::".intval($new_data['newsfeed_showmain']);
|
||||
}
|
||||
|
||||
return $new_data;
|
||||
}
|
||||
|
||||
public function afterUpdate($new_data, $old_data, $id)
|
||||
{
|
||||
// do something
|
||||
e107::getCache()->clear(NEWSFEED_LIST_CACHE_TAG);
|
||||
e107::getCache()->clear(NEWSFEED_NEWS_CACHE_TAG);
|
||||
}
|
||||
|
||||
public function onUpdateError($new_data, $old_data, $id)
|
||||
{
|
||||
// do something
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// optional - a custom page.
|
||||
public function customPage()
|
||||
{
|
||||
$text = 'Hello World!';
|
||||
return $text;
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
class newsfeed_form_ui extends e_admin_form_ui
|
||||
{
|
||||
|
||||
|
||||
// Custom Method/Function
|
||||
function newsfeed_active($curVal,$mode)
|
||||
{
|
||||
$mes->addError(LAN_REQUIRED_BLANK);
|
||||
$frm = e107::getForm();
|
||||
|
||||
switch($mode)
|
||||
{
|
||||
case 'read': // List Page
|
||||
return $curVal;
|
||||
break;
|
||||
|
||||
case 'write': // Edit Page
|
||||
return $frm->text('newsfeed_active',$curVal, 255, 'size=large');
|
||||
break;
|
||||
|
||||
case 'filter':
|
||||
case 'batch':
|
||||
return array();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function newsfeed_image($curVal,$mode)
|
||||
{
|
||||
$frm = e107::getForm();
|
||||
|
||||
switch($mode)
|
||||
{
|
||||
case 'read': // List Page
|
||||
return $curVal;
|
||||
break;
|
||||
|
||||
case 'write': // Edit Page
|
||||
|
||||
$tmp = explode('::',$curVal);
|
||||
|
||||
return $frm->text('newsfeed_image',$tmp[0], 255, 'size=large');
|
||||
break;
|
||||
|
||||
case 'filter':
|
||||
case 'batch':
|
||||
return array();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function newsfeed_showmain($curVal,$mode)
|
||||
{
|
||||
$frm = e107::getForm();
|
||||
|
||||
switch($mode)
|
||||
{
|
||||
case 'read': // List Page
|
||||
$data = $this->getController()->getListModel()->get('newsfeed_image');
|
||||
list($image,$menu,$main) = explode('::',$data);
|
||||
|
||||
return intval($main);
|
||||
break;
|
||||
|
||||
case 'write': // Edit Page
|
||||
|
||||
$data = $this->getController()->getModel()->get('newsfeed_image');
|
||||
list($image,$menu,$main) = explode('::',$data);
|
||||
|
||||
if(empty($main))
|
||||
{
|
||||
$main = 10;
|
||||
}
|
||||
|
||||
return $frm->number('newsfeed_showmain',$main, 3);
|
||||
break;
|
||||
|
||||
case 'filter':
|
||||
case 'batch':
|
||||
return array();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function newsfeed_showmenu($curVal,$mode)
|
||||
{
|
||||
$frm = e107::getForm();
|
||||
|
||||
switch($mode)
|
||||
{
|
||||
case 'read': // List Page
|
||||
$data = $this->getController()->getListModel()->get('newsfeed_image');
|
||||
list($image,$menu,$main) = explode('::',$data);
|
||||
|
||||
return intval($menu);
|
||||
break;
|
||||
|
||||
case 'write': // Edit Page
|
||||
$data = $this->getController()->getModel()->get('newsfeed_image');
|
||||
list($image,$menu,$main) = explode('::',$data);
|
||||
|
||||
if(empty($menu))
|
||||
{
|
||||
$menu = 10;
|
||||
}
|
||||
|
||||
return $frm->number('newsfeed_showmenu',$menu, 3);
|
||||
break;
|
||||
|
||||
case 'filter':
|
||||
case 'batch':
|
||||
return array();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ns->tablerender($caption, $mes->render() . $text);
|
||||
|
||||
if($action == "delete")
|
||||
{
|
||||
$sql->db_Delete('newsfeed', 'newsfeed_id='.$id);
|
||||
e107::getLog()->add('NEWSFD_03','ID: '.$id,E_LOG_INFORMATIVE,'');
|
||||
$mes->addSuccess(LAN_DELETED);
|
||||
}
|
||||
new newsfeed_adminArea();
|
||||
|
||||
$ns->tablerender($caption, $mes->render() . $text);
|
||||
|
||||
|
||||
if($headline_total = $sql->db_Select("newsfeed"))
|
||||
{
|
||||
$nfArray = $sql->rows();
|
||||
|
||||
$text = "
|
||||
<table class='table table-striped'>
|
||||
<colgroup>
|
||||
<col style='width: 5%; text-align: center;' />
|
||||
<col style='width: 40%;' />
|
||||
<col style='width: 10%; text-align: center;' />
|
||||
<col style='width: 25%; text-align: center;' />
|
||||
<col style='width: 10%; text-align: center;' />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>".LAN_ID."</th>
|
||||
<th>".LAN_NAME."</th>
|
||||
<th>".NFLAN_26."</th>
|
||||
<th>".NFLAN_12."</th>
|
||||
<th class='center options'>".LAN_OPTIONS."</th>
|
||||
</tr>
|
||||
</thead>\n";
|
||||
|
||||
$active = array(NFLAN_13,NFLAN_14,NFLAN_20,NFLAN_21);
|
||||
|
||||
foreach($nfArray as $newsfeed)
|
||||
{
|
||||
extract($newsfeed); // FIXME
|
||||
|
||||
$text .= "
|
||||
<tr>
|
||||
<td>$newsfeed_id</td>
|
||||
<td><a href='$newsfeed_url' rel='external'>$newsfeed_name</a></td>
|
||||
<td>".($newsfeed_updateint ? $newsfeed_updateint : "3600")."</td>
|
||||
<td>".$active[$newsfeed_active]."</td>
|
||||
<td>
|
||||
<a class='btn btn-default btn-large' href='".e_SELF."?edit.".$newsfeed_id."'>".ADMIN_EDIT_ICON."</a>
|
||||
<a class='btn btn-default btn-large action delete' href='".e_SELF."?delete.".$newsfeed_id."' rel='no-confirm' title='".LAN_CONFDELETE."'>".ADMIN_DELETE_ICON."</a>
|
||||
</td>
|
||||
</tr>";
|
||||
}
|
||||
|
||||
$text .= "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$mes->addInfo(NFLAN_41);
|
||||
}
|
||||
|
||||
$ns->tablerender(NFLAN_07, $mes->render(). $text);
|
||||
|
||||
if($action == "edit")
|
||||
{
|
||||
if($sql->select("newsfeed", "*", "newsfeed_id=$id"))
|
||||
{
|
||||
$row = $sql->fetch();
|
||||
extract($row); // FIX
|
||||
list($newsfeed_image, $newsfeed_showmenu, $newsfeed_showmain) = explode("::", $newsfeed_image);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($newsfeed_showmenu, $newsfeed_showmain, $newsfeed_name, $newsfeed_url, $newsfeed_image, $newsfeed_description, $newsfeed_updateint, $newsfeed_active);
|
||||
}
|
||||
|
||||
$text = "
|
||||
<form method='post' action='".e_SELF."'>\n
|
||||
<table class='table'>
|
||||
<colgroup>
|
||||
<col class='col-label' />
|
||||
<col style='col-control' />
|
||||
</colgroup>
|
||||
<tr>
|
||||
<td>".LAN_NAME."</td>
|
||||
<td>".$frm->text('newsfeed_name', $newsfeed_name, '200')."</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>".LAN_URL."</td>
|
||||
<td>".$frm->text('newsfeed_url', $newsfeed_url, '250', 'size=xxlarge')."<span class='field-help'>".NFLAN_10."</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>".NFLAN_11."</td>
|
||||
<td>".$frm->text('newsfeed_image', $newsfeed_image, '200') /* TODO imagepicker? */."<span class='field-help'>".NFLAN_17."</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>".LAN_DESCRIPTION."</td>
|
||||
<td>".$frm->text('newsfeed_description', $newsfeed_description, '200')."<span class='field-help'>".NFLAN_37."</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>".NFLAN_18."</td>
|
||||
<td>".$frm->number('newsfeed_updateint',($newsfeed_updateint ? $newsfeed_updateint : 3600),5)."<span class='field-help'>".NFLAN_19."</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>".NFLAN_12."</td>
|
||||
<td>";
|
||||
$array = array(NFLAN_13,NFLAN_14,NFLAN_20,NFLAN_21);
|
||||
$text .=
|
||||
$frm->radio('newsfeed_active', $array, ($newsfeed_active ? $newsfeed_active : 0), true, NFLAN_22)."
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>".NFLAN_45."</td>
|
||||
<td>".$frm->number('newsfeed_showmenu', $newsfeed_showmenu ,5)."<span class='field-help'>".NFLAN_47."</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>".NFLAN_46."</td>
|
||||
<td>".$frm->number('newsfeed_showmain', $newsfeed_showmain ,5)."<span class='field-help'>".NFLAN_47."</span></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class='buttons-bar center'>
|
||||
".$frm->admin_button(($action == "edit" ? "updateFeed" : "createFeed"),($action == "edit" ? LAN_UPDATE : LAN_CREATE),'update')."
|
||||
</div>
|
||||
".($action == "edit" ? "<input type='hidden' name='newsfeed_id' value='$newsfeed_id' />" : "")."
|
||||
</form>
|
||||
";
|
||||
|
||||
$ns->tablerender(NFLAN_09, $mes->render() . $text);
|
||||
require_once(e_ADMIN."auth.php");
|
||||
e107::getAdminUI()->runPage();
|
||||
|
||||
require_once(e_ADMIN."footer.php");
|
||||
?>
|
||||
exit;
|
||||
|
@ -47,9 +47,8 @@ class newsfeedClass
|
||||
var $useCache; // Set if cache is available
|
||||
|
||||
// Constructor
|
||||
function newsfeedClass()
|
||||
function __construct()
|
||||
{
|
||||
global $e107;
|
||||
$this->validFeedList = FALSE;
|
||||
$this->newsList = array();
|
||||
$this->feedList = array();
|
||||
@ -57,7 +56,7 @@ class newsfeedClass
|
||||
$this->lastProcessed = 0;
|
||||
$this->truncateCount = 150; // Set a pref for these two later
|
||||
$this->truncateMore = '...';
|
||||
$this->useCache = $e107->ecache->UserCacheActive; // Have our own local copy - should be faster to access
|
||||
$this->useCache = e107::getCache()->UserCacheActive; // Have our own local copy - should be faster to access
|
||||
}
|
||||
|
||||
// Ensures the feed list is loaded - uses cache if available
|
||||
@ -71,13 +70,8 @@ class newsfeedClass
|
||||
}
|
||||
if($this->useCache) // Cache enabled - try to read from that first
|
||||
{
|
||||
|
||||
$eArrayStorage = e107::getArrayStorage();
|
||||
|
||||
global $e107;
|
||||
|
||||
|
||||
if (!$force && $temp = $e107->ecache->retrieve(NEWSFEED_LIST_CACHE_TAG))
|
||||
|
||||
if (!$force && $temp = e107::getCache()->retrieve(NEWSFEED_LIST_CACHE_TAG))
|
||||
{
|
||||
$this->feedList = e107::unserialize($temp);
|
||||
return;
|
||||
@ -97,7 +91,7 @@ class newsfeedClass
|
||||
{
|
||||
$nfID = $row['newsfeed_id'];
|
||||
|
||||
if (isset($row['newsfeed_data']))
|
||||
if (!empty($row['newsfeed_data']))
|
||||
{
|
||||
$this->newsList[$nfID]['newsfeed_data'] = $row['newsfeed_data']; // Pull out the actual news - might as well since we're here
|
||||
$this->newsList[$nfID]['newsfeed_timestamp'] = $row['newsfeed_timestamp'];
|
||||
@ -110,8 +104,8 @@ class newsfeedClass
|
||||
$this->validFeedList = TRUE;
|
||||
}
|
||||
|
||||
if ($this->useCache)
|
||||
{ // Cache enabled - we need to save some updated info
|
||||
if ($this->useCache) // Cache enabled - we need to save some updated info
|
||||
{
|
||||
$temp = e107::serialize($this->feedList, FALSE);
|
||||
e107::getCache()->set(NEWSFEED_LIST_CACHE_TAG,$temp);
|
||||
}
|
||||
@ -121,14 +115,13 @@ class newsfeedClass
|
||||
// Returns the info for a single feed - from cache or memory as appropriate. If time expired, updates the feed.
|
||||
function getFeed($feedID, $force = FALSE)
|
||||
{
|
||||
global $e107, $admin_log;
|
||||
|
||||
$tp = e107::getParser();
|
||||
$sql = e107::getDb();
|
||||
$eArrayStorage = e107::getArrayStorage();
|
||||
|
||||
$this->readFeedList(); // Make sure we've got the feed data.
|
||||
|
||||
// $force = true;
|
||||
|
||||
if (!isset($this->feedList[$feedID]))
|
||||
{
|
||||
if (NEWSFEED_DEBUG) echo "Invalid feed number: {$feedID}<br />";
|
||||
@ -140,14 +133,14 @@ class newsfeedClass
|
||||
$force = true;
|
||||
}
|
||||
|
||||
if ($force || !isset($this->newsList[$feedID]['newsfeed_data']) || !$this->newsList[$feedID]['newsfeed_data'])
|
||||
{ // No data already in memory
|
||||
if ($force || !($this->newsList[$feedID]['newsfeed_data'] = $e107->ecache->retrieve(NEWSFEED_NEWS_CACHE_TAG.$feedID, $this->feedList[$feedID]['newsfeed_updateint']/60)))
|
||||
if ($force || !isset($this->newsList[$feedID]['newsfeed_data']) || !$this->newsList[$feedID]['newsfeed_data']) // No data already in memory
|
||||
{
|
||||
if ($force || !($this->newsList[$feedID]['newsfeed_data'] = e107::getCache()->retrieve(NEWSFEED_NEWS_CACHE_TAG.$feedID, $this->feedList[$feedID]['newsfeed_updateint']/60)))
|
||||
{ // Need to re-read from source - either no cached data yet, or cache expired
|
||||
|
||||
if (NEWSFEED_DEBUG)
|
||||
{
|
||||
$admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Newsfeed update","Refresh item: ".$feedID,FALSE,LOG_TO_ROLLING);
|
||||
e107::getLog()->e_log_event(10,debug_backtrace(),"DEBUG","Newsfeed update","Refresh item: ".$feedID,FALSE,LOG_TO_ROLLING);
|
||||
}
|
||||
|
||||
require_once(e_HANDLER.'xml_class.php');
|
||||
@ -195,7 +188,7 @@ class newsfeedClass
|
||||
$dbData['newsfeed_description'] = $temp['newsfeed_description'];
|
||||
if ($this->useCache)
|
||||
{
|
||||
$e107->ecache->clear(NEWSFEED_LIST_CACHE_TAG); // Clear the newsfeed cache so its re-read next time
|
||||
e107::getCache()->clear(NEWSFEED_LIST_CACHE_TAG); // Clear the newsfeed cache so its re-read next time
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -206,10 +199,10 @@ class newsfeedClass
|
||||
}
|
||||
else
|
||||
{
|
||||
$temp['newsfeed_image_link'] = "<img src='".$this->feedList[$feedID]['newsfeed_image']."' alt='' />";
|
||||
$temp['newsfeed_image_link'] = !empty($newsfeed_image) ? "<img src='".$newsfeed_image."' alt='' />" : '';
|
||||
}
|
||||
|
||||
$serializedArray = $eArrayStorage->WriteArray($temp, FALSE);
|
||||
$serializedArray = e107::serialize($temp, false);
|
||||
|
||||
$now = time();
|
||||
$this->newsList[$feedID]['newsfeed_data'] = $serializedArray;
|
||||
@ -217,17 +210,20 @@ class newsfeedClass
|
||||
|
||||
if ($this->useCache)
|
||||
{
|
||||
$e107->ecache->set(NEWSFEED_NEWS_CACHE_TAG.$feedID,$serializedArray);
|
||||
e107::getCache()->set(NEWSFEED_NEWS_CACHE_TAG.$feedID, $serializedArray);
|
||||
}
|
||||
else
|
||||
{
|
||||
$dbData['newsfeed_data'] =addslashes($serializedArray);
|
||||
$dbData['newsfeed_data'] = $serializedArray;
|
||||
$dbData['newsfeed_timestamp'] = $now;
|
||||
}
|
||||
|
||||
if (count($dbData)) // Only write the feed data to DB if not using cache. Write description if changed
|
||||
{
|
||||
if(FALSE === $sql->db_UpdateArray('newsfeed', $dbData, " WHERE newsfeed_id=".$feedID))
|
||||
{
|
||||
|
||||
$dbData['WHERE'] = "newsfeed_id=".$feedID;
|
||||
|
||||
if(FALSE === $sql->update('newsfeed', $dbData))
|
||||
{
|
||||
if (NEWSFEED_DEBUG) echo NFLAN_48."<br /><br />".var_dump($dbData);
|
||||
}
|
||||
@ -254,8 +250,7 @@ class newsfeedClass
|
||||
{
|
||||
|
||||
$tp = e107::getParser();
|
||||
$sql = e107::getDb();
|
||||
|
||||
|
||||
global $NEWSFEED_MAIN_START, $NEWSFEED_MAIN, $NEWSFEED_MAIN_END;
|
||||
global $NEWSFEED_MENU_START, $NEWSFEED_MENU, $NEWSFEED_MENU_END;
|
||||
|
||||
@ -272,7 +267,12 @@ class newsfeedClass
|
||||
$this->readFeedList(); // Make sure we've got all the news feeds loaded
|
||||
|
||||
/* get template */
|
||||
if (file_exists(THEME."newsfeed_menu_template.php"))
|
||||
|
||||
if(file_exists(THEME."templates/newsfeed/newsfeed_menu_template.php")) //v2.x
|
||||
{
|
||||
include(THEME."templates/newsfeed/newsfeed_menu_template.php");
|
||||
}
|
||||
elseif(file_exists(THEME."newsfeed_menu_template.php")) //v1.x
|
||||
{
|
||||
include(THEME."newsfeed_menu_template.php");
|
||||
}
|
||||
@ -281,6 +281,8 @@ class newsfeedClass
|
||||
include(e_PLUGIN."newsfeed/templates/newsfeed_menu_template.php");
|
||||
}
|
||||
|
||||
$vars = array();
|
||||
|
||||
foreach($this->feedList as $nfID => $feed)
|
||||
{
|
||||
if (($filter == 0) || ($filter == $feed['newsfeed_id']))
|
||||
@ -292,10 +294,10 @@ class newsfeedClass
|
||||
$numtoshow = intval($where == 'main' ? $newsfeed_showmain : $newsfeed_showmenu);
|
||||
$numtoshow = ($numtoshow > 0 ? $numtoshow : 999);
|
||||
|
||||
$FEEDNAME = "<a href='".e_SELF."?show.{$feed['newsfeed_id']}'>".$tp->toHtml($feed['newsfeed_name'],false,'TITLE')."</a>";
|
||||
$FEEDDESCRIPTION = $feed['newsfeed_description'];
|
||||
$FEEDIMAGE = $rss['newsfeed_image_link'];
|
||||
$FEEDLANGUAGE = $rss['channel']['language'];
|
||||
$vars['FEEDNAME'] = "<a href='".e_SELF."?show.{$feed['newsfeed_id']}'>".$tp->toHtml($feed['newsfeed_name'],false,'TITLE')."</a>";
|
||||
$vars['FEEDDESCRIPTION'] = $feed['newsfeed_description'];
|
||||
$vars['FEEDIMAGE'] = $rss['newsfeed_image_link'];
|
||||
$vars['FEEDLANGUAGE'] = $rss['channel']['language'];
|
||||
|
||||
if($rss['channel']['lastbuilddate'])
|
||||
{
|
||||
@ -310,18 +312,18 @@ class newsfeedClass
|
||||
$pubbed = NFLAN_34;
|
||||
}
|
||||
|
||||
$FEEDLASTBUILDDATE = NFLAN_33.$pubbed;
|
||||
$FEEDCOPYRIGHT = $tp -> toHTML(vartrue($rss['channel']['copyright']), FALSE);
|
||||
$FEEDTITLE = "<a href='".$rss['channel']['link']."' rel='external'>".vartrue($rss['channel']['title'])."</a>";
|
||||
$FEEDLINK = $rss['channel']['link'];
|
||||
$vars['FEEDLASTBUILDDATE'] = NFLAN_33.$pubbed;
|
||||
$vars['FEEDCOPYRIGHT'] = $tp -> toHTML(vartrue($rss['channel']['copyright']), FALSE);
|
||||
$vars['FEEDTITLE'] = "<a href='".$rss['channel']['link']."' rel='external'>".vartrue($rss['channel']['title'])."</a>";
|
||||
$vars['FEEDLINK'] = $rss['channel']['link'];
|
||||
|
||||
if($feed['newsfeed_active'] == 2 or $feed['newsfeed_active'] == 3)
|
||||
{
|
||||
$LINKTOMAIN = "<a href='".e_PLUGIN."newsfeed/newsfeed.php?show.".$feed['newsfeed_id']."'>".NFLAN_39."</a>";
|
||||
$vars['LINKTOMAIN'] = "<a href='".e_PLUGIN."newsfeed/newsfeed.php?show.".$feed['newsfeed_id']."'>".NFLAN_39."</a>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$LINKTOMAIN = "";
|
||||
$vars['LINKTOMAIN'] = "";
|
||||
}
|
||||
|
||||
$data = "";
|
||||
@ -332,42 +334,43 @@ class newsfeedClass
|
||||
{
|
||||
$item = $rss['items'][$i];
|
||||
|
||||
$FEEDITEMLINK = "<a href='".$item['link']."' rel='external'>".$tp -> toHTML($item['title'], FALSE)."</a>\n";
|
||||
$FEEDITEMLINK = str_replace('&', '&', $FEEDITEMLINK);
|
||||
$feeditemtext = preg_replace("#\[[a-z0-9=]+\]|\[\/[a-z]+\]|\{[A-Z_]+\}#si", "", strip_tags($item['description']));
|
||||
$FEEDITEMCREATOR = $tp -> toHTML(vartrue($item['author']), FALSE);
|
||||
$vars['FEEDITEMLINK'] = "<a href='".$item['link']."' rel='external'>".$tp -> toHTML($item['title'], FALSE)."</a>\n";
|
||||
$vars['FEEDITEMLINK'] = str_replace('&', '&', $vars['FEEDITEMLINK']);
|
||||
$feeditemtext = preg_replace("#\[[a-z0-9=]+\]|\[\/[a-z]+\]|\{[A-Z_]+\}#si", "", strip_tags($item['description']));
|
||||
$vars['FEEDITEMCREATOR'] = $tp -> toHTML(vartrue($item['author']), FALSE);
|
||||
|
||||
if ($where == 'main')
|
||||
{
|
||||
if($NEWSFEED_COLLAPSE)
|
||||
if(!empty($NEWSFEED_COLLAPSE))
|
||||
{
|
||||
$FEEDITEMLINK = "<a href='#' onclick='expandit(this)'>".$tp -> toHTML($item['title'], FALSE)."</a>
|
||||
$vars['FEEDITEMLINK'] = "<a href='#' onclick='expandit(this)'>".$tp -> toHTML($item['title'], FALSE)."</a>
|
||||
<div style='display:none' >
|
||||
";
|
||||
$FEEDITEMTEXT = preg_replace("/[.*]/", "", $tp -> toHTML($item['description'], FALSE))."
|
||||
|
||||
$vars['FEEDITEMTEXT'] = preg_replace("/[.*]/", "", $tp -> toHTML($item['description'], FALSE))."
|
||||
<br /><br /><a href='".$item['link']."' rel='external'>".NFLAN_44."</a><br /><br />
|
||||
</div>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$FEEDITEMLINK = "<a href='".$item['link']."' rel='external'>".$tp -> toHTML($item['title'], FALSE)."</a>\n";
|
||||
$FEEDITEMLINK = str_replace('&', '&', $FEEDITEMLINK);
|
||||
$feeditemtext = preg_replace("#\[[a-z0-9=]+\]|\[\/[a-z]+\]|\{[A-Z_]+\}#si", "", $item['description']);
|
||||
$FEEDITEMTEXT = $tp -> toHTML($feeditemtext, FALSE)."\n";
|
||||
$vars['FEEDITEMLINK'] = "<a href='".$item['link']."' rel='external'>".$tp -> toHTML($item['title'], FALSE)."</a>\n";
|
||||
$vars['FEEDITEMLINK'] = str_replace('&', '&', $vars['FEEDITEMLINK']);
|
||||
$feeditemtext = preg_replace("#\[[a-z0-9=]+\]|\[\/[a-z]+\]|\{[A-Z_]+\}#si", "", $item['description']);
|
||||
$vars['FEEDITEMTEXT'] = $tp -> toHTML($feeditemtext, FALSE)."\n";
|
||||
}
|
||||
$data .= preg_replace("/\{(.*?)\}/e", '$\1', $NEWSFEED_MAIN);
|
||||
$data .= $tp->simpleParse( $NEWSFEED_MAIN, $vars);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->truncateCount)
|
||||
{
|
||||
$FEEDITEMTEXT = $tp->text_truncate($feeditemtext, $this->truncateCount, $this->truncateMore);
|
||||
$vars['FEEDITEMTEXT'] = $tp->text_truncate($feeditemtext, $this->truncateCount, $this->truncateMore);
|
||||
}
|
||||
else
|
||||
{
|
||||
$FEEDITEMTEXT = ''; // Might just want title
|
||||
$vars['FEEDITEMTEXT'] = ''; // Might just want title
|
||||
}
|
||||
$data .= preg_replace("/\{(.*?)\}/e", '$\1', $NEWSFEED_MENU);
|
||||
$data .= $tp->simpleParse($NEWSFEED_MENU, $vars);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
@ -376,13 +379,15 @@ class newsfeedClass
|
||||
|
||||
if ($where == 'main')
|
||||
{
|
||||
$BACKLINK = "<a href='".e_SELF."'>".NFLAN_31."</a>";
|
||||
$text = preg_replace("/\{(.*?)\}/e", '$\1', $NEWSFEED_MAIN_START).$data.preg_replace("/\{(.*?)\}/e", '$\1', $NEWSFEED_MAIN_END);
|
||||
$vars['BACKLINK'] = "<a href='".e_SELF."'>".NFLAN_31."</a>";
|
||||
$text = $tp->simpleParse($NEWSFEED_MAIN_START, $vars).$data.$tp->simpleParse( $NEWSFEED_MAIN_END, $vars);
|
||||
}
|
||||
else
|
||||
{
|
||||
$text .= preg_replace("/\{(.*?)\}/e", '$\1', $NEWSFEED_MENU_START) . $data . preg_replace("/\{(.*?)\}/e", '$\1', $NEWSFEED_MENU_END);
|
||||
$text .= $tp->simpleParse($NEWSFEED_MENU_START, $vars) . $data . $tp->simpleParse($NEWSFEED_MENU_END, $vars);
|
||||
}
|
||||
|
||||
//TODO Move the $vars into their own shortcode class and change simpleParse to parseTemplate();
|
||||
}
|
||||
|
||||
if($which == 'all')
|
||||
@ -391,7 +396,7 @@ class newsfeedClass
|
||||
}
|
||||
else
|
||||
{
|
||||
$ret['title'] = $feed['newsfeed_name']." ".$NEWSFEED_MAIN_CAPTION;
|
||||
$ret['title'] = $feed['newsfeed_name']." ".varset($NEWSFEED_MAIN_CAPTION);
|
||||
}
|
||||
$ret['text'] = $text;
|
||||
|
||||
|
@ -888,6 +888,7 @@ class poll_shortcodes extends e_shortcode
|
||||
public $answerOption = array();
|
||||
public $answerCount = 0;
|
||||
public $pollRenderType = null; // type
|
||||
public $pollRenderMode = null;
|
||||
public $pollPreview = false;
|
||||
public $pollVoteTotal = 0;
|
||||
public $pollCommentTotal = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user