mirror of
https://github.com/e107inc/e107.git
synced 2025-03-14 01:19:44 +01:00
New Addon: e_admin.php - extends the admin area fields and processing. Replacement for the old e_hook and e_event addons which were doing the same, but were not compatible with the v2.x admin-ui.
This commit is contained in:
parent
6b9256c872
commit
d128b52576
File diff suppressed because it is too large
Load Diff
@ -3962,7 +3962,11 @@ class e_admin_controller_ui extends e_admin_controller
|
||||
if($triggerName = $this->getEventTriggerName($_posted['etrigger_submit'])) // 'create' or 'update';
|
||||
{
|
||||
$eventData = array('newData'=>$_posted,'oldData'=>$old_data,'id'=> $id);
|
||||
$model->addMessageDebug('Admin-ui Trigger fired: <b>'.$triggerName.'</b> with data '.print_a($eventData,true));
|
||||
if(E107_DBG_ALLERRORS >0 )
|
||||
{
|
||||
$model->addMessageDebug('Admin-ui Trigger fired: <b>'.$triggerName.'</b> with data '.print_a($eventData,true));
|
||||
}
|
||||
|
||||
if($halt = e107::getEvent()->trigger($triggerName, $eventData))
|
||||
{
|
||||
$model->setMessages();
|
||||
@ -3990,7 +3994,10 @@ class e_admin_controller_ui extends e_admin_controller
|
||||
if($triggerName = $this->getEventTriggerName($_posted['etrigger_submit'],'after')) // 'created' or 'updated';
|
||||
{
|
||||
$eventData = array('newData'=>$_posted,'oldData'=>$old_data,'id'=> $id);
|
||||
$model->addMessageDebug('Admin-ui Trigger fired: <b>'.$triggerName.'</b> with data '.print_a($eventData,true));
|
||||
if(E107_DBG_ALLERRORS >0 )
|
||||
{
|
||||
$model->addMessageDebug('Admin-ui Trigger fired: <b>'.$triggerName.'</b> with data '.print_a($eventData,true));
|
||||
}
|
||||
e107::getEvent()->trigger($triggerName, $eventData);
|
||||
}
|
||||
|
||||
@ -4133,8 +4140,39 @@ class e_admin_ui extends e_admin_controller_ui
|
||||
}
|
||||
|
||||
$this->addTitle($this->pluginTitle, true)->parseAliases();
|
||||
|
||||
$this->initAdminAddons();
|
||||
}
|
||||
|
||||
|
||||
private function initAdminAddons()
|
||||
{
|
||||
$tmp = e107::getAddonConfig('e_admin', null, 'config', $this);
|
||||
|
||||
if(empty($tmp))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach($tmp as $plug=>$config)
|
||||
{
|
||||
foreach($config['fields'] as $k=>$v)
|
||||
{
|
||||
$v['data'] = false; // disable data-saving to db table. .
|
||||
$this->fields['x_'.$plug.'_'.$k] = $v; // ie. x_plugin_key
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($_POST))
|
||||
{
|
||||
e107::getAddonConfig('e_admin',null,'process', $this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Catch fieldpref submit
|
||||
* @return none
|
||||
@ -4689,7 +4727,12 @@ class e_admin_ui extends e_admin_controller_ui
|
||||
|
||||
if($triggerName = $this->getEventTriggerName('delete')) // trigger for before.
|
||||
{
|
||||
$this->getTreeModel()->addMessageDebug('Admin-ui Trigger fired: <b>'.$triggerName.'</b> with data '.print_a($eventData,true));
|
||||
|
||||
if(E107_DBG_ALLERRORS >0 )
|
||||
{
|
||||
$this->getTreeModel()->addMessageDebug('Admin-ui Trigger fired: <b>'.$triggerName.'</b> with data '.print_a($eventData,true));
|
||||
}
|
||||
|
||||
if($halt = e107::getEvent()->trigger($triggerName, $eventData))
|
||||
{
|
||||
$this->getTreeModel()->setMessages();
|
||||
@ -4703,8 +4746,11 @@ class e_admin_ui extends e_admin_controller_ui
|
||||
{
|
||||
if($triggerName = $this->getEventTriggerName('deleted')) // trigger for after.
|
||||
{
|
||||
$this->getTreeModel()->addMessageDebug('Admin-ui Trigger fired: <b>'.$triggerName.'</b>'); //FIXME - Why doesn't this display?
|
||||
e107::getEvent()->trigger($triggerName, $eventData);
|
||||
if(E107_DBG_ALLERRORS > 0)
|
||||
{
|
||||
$this->getTreeModel()->addMessageDebug('Admin-ui Trigger fired: <b>'.$triggerName.'</b>'); //FIXME - Why doesn't this display?
|
||||
}
|
||||
e107::getEvent()->trigger($triggerName, $eventData);
|
||||
}
|
||||
|
||||
$this->getTreeModel()->setMessages();
|
||||
|
@ -3411,7 +3411,7 @@ class e_form
|
||||
|
||||
$value = intval($value);
|
||||
|
||||
$wparms = (vartrue($parms['reverse'])) ? array(0=>$true, 1=>$false) : array(0=>$false, 1=>$true);
|
||||
$wparms = (vartrue($parms['reverse'])) ? array(0=>$true, 1=>$false) : array(0=>$false, 1=>$true);
|
||||
$dispValue = $wparms[$value];
|
||||
|
||||
return $this->renderInline($field, $id, $attributes['title'], $value, $dispValue, 'select', $wparms);
|
||||
@ -3751,6 +3751,7 @@ class e_form
|
||||
|
||||
case 'images':
|
||||
// return print_a($value, true);
|
||||
$ret = "";
|
||||
|
||||
for ($i=0; $i < 5; $i++)
|
||||
{
|
||||
@ -3970,6 +3971,12 @@ class e_form
|
||||
$ret = $this->radio_switch($key, $value, defset($lenabled, $lenabled), defset($ldisabled, $ldisabled),$parms);
|
||||
break;
|
||||
|
||||
case "checkbox":
|
||||
|
||||
$value = (isset($parms['value'])) ? $parms['value'] : $value;
|
||||
$ret = $this->checkbox($key, 1, $value,$parms);
|
||||
break;
|
||||
|
||||
case 'method': // Custom Function
|
||||
$ret = call_user_func_array(array($this, $key), array($value, 'write', $parms));
|
||||
break;
|
||||
|
@ -33,6 +33,7 @@ class news {
|
||||
|
||||
//FIXME - LANs
|
||||
//TODO - synch WIKI docs, add rewrite data to the event data
|
||||
//@Deprecated and no longer used by newspost.php
|
||||
function submit_item($news, $smessages = false)
|
||||
{
|
||||
$tp = e107::getParser();
|
||||
@ -235,64 +236,7 @@ class news {
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME - trackback should be hooked! */
|
||||
if($news['news_id'] && $pref['trackbackEnabled'])
|
||||
{
|
||||
|
||||
$excerpt = e107::getParser()->text_truncate(strip_tags(e107::getParser()->post_toHTML($news['news_body'])), 100, '...');
|
||||
|
||||
// $id=mysql_insert_id();
|
||||
$permLink = e107::getInstance()->base_path."comment.php?comment.news.".intval($news['news_id']);
|
||||
|
||||
require_once(e_PLUGIN."trackback/trackbackClass.php");
|
||||
$trackback = new trackbackClass();
|
||||
|
||||
if($_POST['trackback_urls'])
|
||||
{
|
||||
$urlArray = explode("\n", $_POST['trackback_urls']);
|
||||
foreach($urlArray as $pingurl)
|
||||
{
|
||||
if(!$terror = $trackback->sendTrackback($permLink, $pingurl, $news['news_title'], $excerpt))
|
||||
{
|
||||
$message .= "<br />successfully pinged {$pingurl}.";
|
||||
$emessage->add("Successfully pinged {$pingurl}.", E_MESSAGE_SUCCESS, $smessages);
|
||||
}
|
||||
else
|
||||
{
|
||||
$message .= "<br />was unable to ping {$pingurl}<br />[ Error message returned was : '{$terror}'. ]";
|
||||
$emessage->add("was unable to ping {$pingurl}<br />[ Error message returned was : '{$terror}'. ]", E_MESSAGE_ERROR, $smessages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['pingback_urls']))
|
||||
{
|
||||
if ($urlArray = $trackback->getPingUrls($news['news_body'])) //FIXME - missing method!!!
|
||||
{
|
||||
foreach($urlArray as $pingurl)
|
||||
{
|
||||
|
||||
if ($trackback -> sendTrackback($permLink, $pingurl, $news['news_title'], $excerpt))
|
||||
{
|
||||
$message .= "<br />successfully pinged {$pingurl}.";
|
||||
$emessage->add("Successfully pinged {$pingurl}.", E_MESSAGE_SUCCESS, $smessages);
|
||||
}
|
||||
else
|
||||
{
|
||||
$message .= "Pingback to {$pingurl} failed ...";
|
||||
$emessage->add("Pingback to {$pingurl} failed ...", E_MESSAGE_ERROR, $smessages);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$message .= "<br />No pingback addresses were discovered";
|
||||
$emessage->add("No pingback addresses were discovered", E_MESSAGE_INFO, $smessages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* end trackback */
|
||||
|
||||
//return $message;
|
||||
$data['message'] = $message;
|
||||
|
@ -27,6 +27,7 @@ class e107plugin
|
||||
{
|
||||
// Reserved Addon names.
|
||||
var $plugin_addons = array(
|
||||
'e_admin',
|
||||
'e_bb',
|
||||
'e_cron',
|
||||
'e_notify',
|
||||
|
70
e107_plugins/social/e_admin.php
Normal file
70
e107_plugins/social/e_admin.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
|
||||
//v2.x Standard for extending admin areas.
|
||||
|
||||
|
||||
class social_admin
|
||||
{
|
||||
private $twitterActive = false;
|
||||
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$pref = e107::pref('core','social_login');
|
||||
$this->twitterActive = vartrue($pref['Twitter']['keys']['key']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extend Admin-ui Parameters
|
||||
* @param $ui admin-ui object
|
||||
* @return array
|
||||
*/
|
||||
public function config($ui)
|
||||
{
|
||||
$action = $ui->getAction(); // current mode: create, edit, list
|
||||
$type = $ui->getEventName(); // 'wmessage', 'news' etc.
|
||||
|
||||
$config = array();
|
||||
|
||||
//TODO Add support for type='method'. (ie. extending the form-handler. )
|
||||
|
||||
switch($type)
|
||||
{
|
||||
case "page":
|
||||
case "news":
|
||||
|
||||
if($this->twitterActive == true)
|
||||
{
|
||||
$config['fields']['twitter'] = array ( 'title' =>"Post to Twitter", 'type' => 'text', 'tab'=>1, 'writeParms'=> array('size'=>'xxlarge', 'placeholder'=>'Type your tweet here.'), 'width' => 'auto', 'help' => '', 'readParms' => '', 'class' => 'left', 'thclass' => 'left', );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//Note: 'twitter' will be returned as $_POST['x_social_twitter']. ie. x_{PLUGIN_FOLDER}_{YOURKEY}
|
||||
|
||||
return $config;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process Posted Data.
|
||||
* @param $ui admin-ui object
|
||||
*/
|
||||
public function process($ui)
|
||||
{
|
||||
$data = $ui->getPosted();
|
||||
//e107::getHybridAuth('twitter');
|
||||
e107::getMessage()->addDebug(print_a($data,true));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
@ -11,17 +11,8 @@
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
|
||||
class e_event_social //FIXME should be social_event
|
||||
class e_event_social //FIXME should be 'social_event'
|
||||
{
|
||||
/*
|
||||
* all event methods have a single parameter
|
||||
* @param array $data array containing
|
||||
* @param string $method form,insert,update,delete
|
||||
* @param string $table the table name of the calling plugin
|
||||
* @param int $id item id of the record
|
||||
* @param string $plugin identifier for the calling plugin
|
||||
* @param string $function identifier for the calling function
|
||||
*/
|
||||
|
||||
/*
|
||||
* constructor
|
||||
@ -30,81 +21,8 @@ class e_event_social //FIXME should be social_event
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
* add form field
|
||||
* @param array $data
|
||||
*/
|
||||
function event_form($data)
|
||||
{
|
||||
|
||||
if($data['table'] == 'news' || $data['table'] == 'page')
|
||||
{
|
||||
return $this->socialForm($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* handle db create
|
||||
* @param array $data
|
||||
*/
|
||||
function event_create($data)
|
||||
{
|
||||
//print_a($data);
|
||||
$this->socialPost($data);
|
||||
}
|
||||
|
||||
/*
|
||||
* handle db update
|
||||
* @param array $data
|
||||
*/
|
||||
function event_update($data)
|
||||
{
|
||||
$this->socialPost($data);
|
||||
}
|
||||
|
||||
/*
|
||||
* handle db delete
|
||||
* @param array $data
|
||||
*/
|
||||
function event_delete($data)
|
||||
{
|
||||
// N/A
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TODO - Make functional.. using hybridAuth class.
|
||||
* ie. Admin enters a message, and the message + the newly generated link are submitted to Twitter or FB.
|
||||
*/
|
||||
|
||||
function socialForm($data='')
|
||||
{
|
||||
|
||||
//TODO Check Social Logins Pref for presence of FB and Twitter details.. if not found, return nothing.(see admin->preferences)
|
||||
|
||||
$frm = e107::getForm();
|
||||
|
||||
$input[0]['caption'] = "Post to Twitter";
|
||||
$input[0]['html'] = $frm->text('twitterPost','', 150); // Text to post.. Link will automatically be appended to message.
|
||||
$input[0]['help'] = "Enter a message to post a link to this item on Twitter"; // Text to post.. Link will automatically be appended to message.
|
||||
|
||||
|
||||
$input[1]['caption'] = "Post to Facebook";
|
||||
$input[1]['html'] = $frm->text('FacebookPost');
|
||||
|
||||
return $input;
|
||||
|
||||
}
|
||||
|
||||
//TODO Function to Post Data to Twitter or FB.
|
||||
// using hybridAuth class.
|
||||
function socialPost($data)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
} //end class
|
||||
|
||||
|
127
e107_plugins/trackback/e_admin.php
Normal file
127
e107_plugins/trackback/e_admin.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
|
||||
//v2.x Standard for extending admin areas.
|
||||
|
||||
|
||||
class trackback_admin
|
||||
{
|
||||
private $active = false;
|
||||
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$pref = e107::pref('core','trackbackEnabled');
|
||||
$this->active = vartrue($pref);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extend Admin-ui Parameters
|
||||
* @param $ui admin-ui object
|
||||
* @return array
|
||||
*/
|
||||
public function config($ui)
|
||||
{
|
||||
$action = $ui->getAction(); // current mode: create, edit, list
|
||||
$type = $ui->getEventName(); // 'wmessage', 'news' etc.
|
||||
|
||||
$config = array();
|
||||
|
||||
switch($type)
|
||||
{
|
||||
case "news":
|
||||
|
||||
if($this->active == true)
|
||||
{
|
||||
$config['fields']['urls'] = array ( 'title' =>LAN_NEWS_35, 'type' => 'textarea', 'tab'=>1, 'writeParms'=> array('size'=>'xxlarge', 'placeholder'=>''), 'width' => 'auto', 'help' => '', 'readParms' => '', 'class' => 'left', 'thclass' => 'left', );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//Note: 'urls' will be returned as $_POST['x_trackback_urls']. ie. x_{PLUGIN_FOLDER}_{YOURKEY}
|
||||
|
||||
return $config;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process Posted Data.
|
||||
* @param $ui admin-ui object
|
||||
*/
|
||||
public function process($ui)
|
||||
{
|
||||
$data = $ui->getPosted();
|
||||
e107::getMessage()->addDebug(print_a($data,true));
|
||||
|
||||
if($data['news_id'] && $this->active)
|
||||
{
|
||||
$excerpt = e107::getParser()->text_truncate(strip_tags(e107::getParser()->post_toHTML($data['news_body'])), 100, '...');
|
||||
|
||||
// $id=mysql_insert_id();
|
||||
$permLink = e107::getInstance()->base_path."comment.php?comment.news.".intval($data['news_id']);
|
||||
|
||||
require_once(e_PLUGIN."trackback/trackbackClass.php");
|
||||
$trackback = new trackbackClass();
|
||||
|
||||
if($data['x_trackback_urls'])
|
||||
{
|
||||
$urlArray = explode("\n", $data['x_trackback_urls']);
|
||||
foreach($urlArray as $pingurl)
|
||||
{
|
||||
if(!$terror = $trackback->sendTrackback($permLink, $pingurl, $data['news_title'], $excerpt))
|
||||
{
|
||||
|
||||
e107::getMessage()->add("Successfully pinged {$pingurl}.", E_MESSAGE_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
e107::getMessage()->add("was unable to ping {$pingurl}<br />[ Error message returned was : '{$terror}'. ]", E_MESSAGE_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if(isset($_POST['pingback_urls']))
|
||||
{
|
||||
if ($urlArray = $trackback->getPingUrls($data['news_body'])) //FIXME - missing method!!!
|
||||
{
|
||||
foreach($urlArray as $pingurl)
|
||||
{
|
||||
|
||||
if ($trackback->sendTrackback($permLink, $pingurl, $data['news_title'], $excerpt))
|
||||
{
|
||||
|
||||
e107::getMessage()->add("Successfully pinged {$pingurl}.", E_MESSAGE_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
e107::getMessage()->add("Pingback to {$pingurl} failed ...", E_MESSAGE_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
e107::getMessage()->add("No pingback addresses were discovered", E_MESSAGE_INFO, $smessages);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* end trackback */
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user