mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Event hooks now allows for multiple form elements.
Also added $frm->renderHooks($data).
This commit is contained in:
@@ -671,6 +671,7 @@ class page_admin_ui extends e_admin_ui
|
||||
|
||||
|
||||
//triggerHook
|
||||
|
||||
$data = array(
|
||||
'method' =>'form',
|
||||
'table' =>'page',
|
||||
@@ -679,37 +680,12 @@ class page_admin_ui extends e_admin_ui
|
||||
'function' => 'createPage'
|
||||
);
|
||||
|
||||
$hooks = $e_event->triggerHook($data);
|
||||
if(!empty($hooks))
|
||||
{
|
||||
$text .= "
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
<fieldset id='core-cpage-create-hooks'>
|
||||
<legend>".LAN_HOOKS."</legend>
|
||||
<table class='adminform options'>
|
||||
<colgroup>
|
||||
<col class='col-label' />
|
||||
<col class='col-control' />
|
||||
</colgroup>
|
||||
<tbody>";
|
||||
|
||||
foreach($hooks as $hook)
|
||||
{
|
||||
if(!empty($hook))
|
||||
{
|
||||
$text .= "
|
||||
<tr>
|
||||
<td>".$hook['caption']."</td>
|
||||
<td>".$hook['text']."</td>
|
||||
</tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$text .= $frm->renderHooks($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
$text .= "
|
||||
</tbody>
|
||||
</table>
|
||||
|
@@ -2254,30 +2254,13 @@ class admin_newspost
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
|
||||
|
||||
//triggerHook
|
||||
$data = array('method'=>'form', 'table'=>'news', 'id'=>$id, 'plugin'=>'news', 'function'=>'create_item');
|
||||
$hooks = e107::getEvent()->triggerHook($data);
|
||||
if(!empty($hooks))
|
||||
{
|
||||
$text .= "
|
||||
<tr>
|
||||
<td colspan='2' >".LAN_HOOKS." </td>
|
||||
</tr>
|
||||
";
|
||||
foreach($hooks as $hook)
|
||||
{
|
||||
if(!empty($hook))
|
||||
{
|
||||
$text .= "
|
||||
<tr>
|
||||
<td>".$hook['caption']."</td>
|
||||
<td>".$hook['text']."</td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$data = array('method'=>'form', 'table'=>'news', 'id'=>$id, 'plugin'=>'news', 'function'=>'create_item');
|
||||
$text .= $frm->renderHooks($data);
|
||||
|
||||
$text .= "
|
||||
</tbody>
|
||||
</table>
|
||||
|
@@ -184,7 +184,18 @@ class e107_event
|
||||
case 'form':
|
||||
if(method_exists($class, "event_{$data['method']}"))
|
||||
{
|
||||
$text[] = $class->event_form($data);
|
||||
$ret = $class->event_form($data);
|
||||
|
||||
if(!isset($ret[0]))
|
||||
{
|
||||
$text[$hook][0] = $ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
$text[$hook] = $ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
//returns string message
|
||||
|
@@ -1551,6 +1551,47 @@ class e_form
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Render Table cells from hooks.
|
||||
* @param array $data
|
||||
* @return string
|
||||
*/
|
||||
function renderHooks($data)
|
||||
{
|
||||
$hooks = e107::getEvent()->triggerHook($data);
|
||||
|
||||
$text = "";
|
||||
|
||||
if(!empty($hooks))
|
||||
{
|
||||
foreach($hooks as $plugin => $hk)
|
||||
{
|
||||
$text .= "\n\n<!-- Hook : {$plugin} -->\n";
|
||||
|
||||
if(!empty($hk))
|
||||
{
|
||||
foreach($hk as $hook)
|
||||
{
|
||||
$text .= "\t\t\t<tr>\n";
|
||||
$text .= "\t\t\t<td>".$hook['caption']."</td>\n";
|
||||
$text .= "\t\t\t<td>".$hook['html']."";
|
||||
$text .= (varset($hook['help'])) ? "\n<span class='field-help'>".$hook['help']."</span>" : "";
|
||||
$text .= "</td>\n\t\t\t</tr>\n";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Render Table cells from field listing.
|
||||
* @param array $fieldarray - eg. $this->fields
|
||||
|
@@ -724,22 +724,8 @@ if ($action == 'ne' || $action == 'ed')
|
||||
//triggerHook
|
||||
$hid = ($action=='ed' ? intval($qs[1]) : '');
|
||||
$data = array('method'=>'form', 'table'=>'event', 'id'=>$hid, 'plugin'=>'calendar_menu', 'function'=>'CalendarCreate');
|
||||
$hooks = $e_event->triggerHook($data);
|
||||
if(!empty($hooks))
|
||||
{
|
||||
$text .= "<tr><td class='forumheader3' colspan='2' >".LAN_HOOKS." </td></tr>";
|
||||
foreach($hooks as $hook)
|
||||
{
|
||||
if(!empty($hook))
|
||||
{
|
||||
$text .= "
|
||||
<tr>
|
||||
<td class='forumheader3'>".$hook['caption']."</td>
|
||||
<td class='forumheader3'>".$hook['text']."</td>
|
||||
</tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
$text .= $frm->renderHooks($data);
|
||||
|
||||
|
||||
$text .= "
|
||||
<tr>
|
||||
|
@@ -921,23 +921,7 @@ class adminDownload extends download
|
||||
//triggerHook
|
||||
$data = array('method'=>'form', 'table'=>'download', 'id'=>$id, 'plugin'=>'download', 'function'=>'create_download');
|
||||
$hooks = $e107->e_event->triggerHook($data);
|
||||
if(!empty($hooks))
|
||||
{
|
||||
$text .= "<tr>
|
||||
<td colspan='2' >".LAN_HOOKS." </td>
|
||||
</tr>
|
||||
";
|
||||
foreach($hooks as $hook)
|
||||
{
|
||||
if(!empty($hook))
|
||||
{
|
||||
$text .= "<tr>
|
||||
<td class='label'>".$hook['caption']."</td>
|
||||
<td class='control'>".$hook['text']."</td>
|
||||
</tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$text .= " <tr style=''>
|
||||
<td colspan='2' style='text-align:center'>";
|
||||
|
@@ -935,24 +935,9 @@ $columnInfo = array(
|
||||
|
||||
//triggerHook
|
||||
$data = array('method'=>'form', 'table'=>'download', 'id'=>$id, 'plugin'=>'download', 'function'=>'create_download');
|
||||
$hooks = $e107->e_event->triggerHook($data);
|
||||
if(!empty($hooks))
|
||||
{
|
||||
$text .= "<tr>
|
||||
<td colspan='2' >".LAN_HOOKS." </td>
|
||||
</tr>
|
||||
";
|
||||
foreach($hooks as $hook)
|
||||
{
|
||||
if(!empty($hook))
|
||||
{
|
||||
$text .= "<tr>
|
||||
<td>".$hook['caption']."</td>
|
||||
<td>".$hook['text']."</td>
|
||||
</tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
$text .= $frm->renderHooks($data);
|
||||
|
||||
|
||||
|
||||
$text .= "
|
||||
<tr style=''>
|
||||
|
@@ -287,7 +287,7 @@ class forumAdmin
|
||||
$text = "<form method='post' action='".e_SELF."?".e_QUERY."'>";
|
||||
}
|
||||
$text .= "
|
||||
<table style='".ADMIN_WIDTH."' class='table adminlist'>
|
||||
<table class='table adminlist'>
|
||||
<tr>
|
||||
<td colspan='2' style='width:70%; text-align:center'>".FORLAN_28."</td>
|
||||
<td style='width:30%; text-align:center'>".FORLAN_80."</td>
|
||||
@@ -424,7 +424,7 @@ class forumAdmin
|
||||
|
||||
$text = "<div style='text-align:center'>
|
||||
<form method='post' action='".e_SELF.'?'.e_QUERY."'>
|
||||
<table style='".ADMIN_WIDTH."' class='table adminform'>
|
||||
<table class='table adminform'>
|
||||
|
||||
<tr>
|
||||
<td style='width:40%'>".FORLAN_31.":</td>
|
||||
|
@@ -804,22 +804,9 @@ class linkclass
|
||||
|
||||
//triggerHook
|
||||
$data = array('method'=>'form', 'table'=>'links_page', 'id'=>$row['link_id'], 'plugin'=>'links_page', 'function'=>'show_link_create');
|
||||
$hooks = $e_event->triggerHook($data);
|
||||
if(!empty($hooks))
|
||||
{
|
||||
$text .= "<tr><td class='fcaption' colspan='2' >".LAN_HOOKS." </td></tr>";
|
||||
foreach($hooks as $hook)
|
||||
{
|
||||
if(!empty($hook))
|
||||
{
|
||||
$text .= "
|
||||
<tr>
|
||||
<td style='width:30%; vertical-align:top;' class='forumheader3'>".$hook['caption']."</td>
|
||||
<td style='width:70%' class='forumheader3'>".$hook['text']."</td>
|
||||
</tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$text .= e107::getForm()->renderHooks($data);
|
||||
|
||||
|
||||
$text .= "
|
||||
<tr style='vertical-align:top'>
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Id: plugin.xml,v 1.1 2009-11-19 12:36:22 e107coders Exp $ -->
|
||||
<e107Plugin name="Pages" version="1.0" date="2012-08-01" compatibility="2.0" installRequired="false" >
|
||||
<category>menu</category>
|
||||
</e107Plugin>
|
@@ -161,7 +161,7 @@ class tagwords
|
||||
}
|
||||
$caption = $this->e107->tp->parseTemplate($this->template['caption'], true, $this->shortcodes);
|
||||
$text = $this->e107->tp->parseTemplate($this->template['form'], true, $this->shortcodes);
|
||||
return array('caption'=>$caption, 'text'=>$text);
|
||||
return array('caption'=>$caption, 'html'=>$text);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user