1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

120 lines
2.2 KiB
PHP

<?php
//v2.x Standard for extending admin areas.
class _blank_admin implements e_admin_addon_interface
{
public function load($event, $ids)
{
// $data = e107::getDb()->retrieve("blank","*", "blank_table='".$event."' AND blank_pid IN(".$ids.")",true);
/* $ret = array();
foreach($data as $row)
{
$id = (int) $row['can_pid'];
$ret[$id]['url'] = $row['can_url'];
}
return $ret;
*/
return array(
3 => array('url'=>'http://myurl.com'),
);
}
/**
* Extend Admin-ui Parameters
* @param $ui admin-ui object
* @return array
*/
public function config(e_admin_ui $ui)
{
$action = $ui->getAction(); // current mode: create, edit, list
$type = $ui->getEventName(); // 'wmessage', 'news' etc. (core or plugin)
$id = $ui->getId();
$config = array();
$defaultValue = 'http://';
switch($type)
{
case 'news': // hook into the news admin form.
$config['fields']['url'] = array ('title' => 'Custom Field', 'type' => 'url', 'tab' =>1, 'writeParms' => array('size' =>'xxlarge', 'placeholder' =>'', 'default' =>$defaultValue), 'width' => 'auto', 'help' => '', 'readParms' => '', 'class' => 'left', 'thclass' => 'left', );
$config['batchOptions'] = array('custom' => 'Custom Batch Command');
break;
}
//Note: 'urls' will be returned as $_POST['x__blank_url']. ie. x_{PLUGIN_FOLDER}_{YOURFIELDKEY}
return $config;
}
/**
* Process Posted Data.
* @param object $ui admin-ui
* @param int|array $id - Primary ID of the record being created/edited/deleted or array data of a batch process.
*/
public function process(e_admin_ui $ui, $id=null)
{
$data = $ui->getPosted(); // ie $_POST field-data
$type = $ui->getEventName(); // eg. 'news'
$action = $ui->getAction(); // current mode: create, edit, list, batch
$changed = $ui->getModel()->dataHasChanged(); // true when data has changed from what is in the DB.
if($action === 'delete')
{
return;
}
if($action === 'batch')
{
$id = (array) $id;
$arrayOfRecordIds = $id['ids'];
$command = $id['cmd'];
return;
}
/*
if(!empty($id) )
{
if(!empty($data['x__blank_url']))
{
// eg. Save the data in 'blank' plugin table. .
}
}
*/
}
}