2015-04-07 19:49:11 -07:00
< ? php
//v2.x Standard for extending admin areas.
class social_admin
{
private $twitterActive = false ;
function __construct ()
{
$pref = e107 :: pref ( 'core' , 'social_login' );
2015-04-15 12:49:39 -07:00
2016-06-26 10:34:44 -07:00
if ( ! empty ( $pref ) && ! empty ( $pref [ 'Twitter' ]) && is_array ( $pref [ 'Twitter' ]))
2015-04-15 12:49:39 -07:00
{
$this -> twitterActive = vartrue ( $pref [ 'Twitter' ][ 'keys' ][ 'key' ]);
}
2015-04-07 19:49:11 -07:00
}
/**
* 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 )
{
2015-05-13 01:22:05 -07:00
$config [ 'fields' ][ 'twitter' ] = array ( 'title' => " Post to Twitter " , 'type' => 'text' , 'tab' => 2 , 'writeParms' => array ( 'size' => 'xxlarge' , 'placeholder' => 'Type your tweet here.' ), 'width' => 'auto' , 'help' => '' , 'readParms' => '' , 'class' => 'left' , 'thclass' => 'left' , );
2015-04-07 19:49:11 -07:00
}
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
*/
2015-12-12 00:16:16 -08:00
public function process ( $ui , $id = 0 )
2015-04-07 19:49:11 -07:00
{
$data = $ui -> getPosted ();
2015-12-12 00:16:16 -08:00
$action = $ui -> getAction (); // current mode: create, edit, list
2015-04-07 19:49:11 -07:00
//e107::getHybridAuth('twitter');
2015-12-12 00:16:16 -08:00
e107 :: getMessage () -> addDebug ( " e107_plugins/social/e_admin.php :: process method called. " );
e107 :: getMessage () -> addDebug ( " ID: " . $id );
e107 :: getMessage () -> addDebug ( " Action: " . $action );
2015-04-07 19:49:11 -07:00
e107 :: getMessage () -> addDebug ( print_a ( $data , true ));
}
}
?>