public static function View()
{
global $mf_domain;
$customWritePanelId = (int) $_REQUEST['custom-write-panel-id'];
$customWritePanels = RCCWP_CustomWritePanel::GetCustomWritePanels();
$customWritePanel = RCCWP_CustomWritePanel::Get($customWritePanelId);
$custom_groups = RCCWP_CustomWritePanel::GetCustomGroups($customWritePanelId);
// get default group id
foreach ($custom_groups as $group) {
if ($group->name == '__default' && $group->panel_id == $customWritePanelId) {
// traversal added extra condition to handle globals
$customDefaultGroupId = $group->id;
break;
}
}
?>
<script type="text/javascript" language="javascript">
function confirmBeforeDelete()
{
return confirm("<?php
_e('Are you sure you want to delete this custom Field?', $mf_domain);
?>
");
}
function confirmBeforeDeleteGroup()
{
return confirm("<?php
_e('Are you sure you want to delete this field group?\\n\\nNote: All fields that are part of this group will also be deleted!', $mf_domain);
?>
");
}
</script>
<div class="wrap">
<form action="<?php
echo RCCWP_ManagementPage::GetPanelPage() . "&mf_action=view-custom-write-panel";
?>
" method="post" id="posts-filter" name="SelectWritePanel">
<h2>
<?php
echo $customWritePanel->name;
?>
<span style="font-size:small">
<a href="<?php
echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('edit-custom-write-panel', $customWritePanel->id);
?>
" ><?php
_e('Edit', $mf_domain);
?>
</a>|
<a href="<?php
echo wp_nonce_url(RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('delete-custom-write-panel', $customWritePanel->id), 'delete-custom-write-panel');
?>
" onclick="return confirmBeforeDelete();"><?php
_e('Delete', $mf_domain);
?>
</a>|
<a href="<?php
echo wp_nonce_url(RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('export-custom-write-panel', $customWritePanel->id), 'export-custom-write-panel');
?>
" ><?php
_e('Export', $mf_domain);
?>
</a>
</span>
</h2>
<p id="post-search" style="margin-top:6px">
<strong>
<?php
_e('Choose a Write Panel', $mf_domain);
?>
<select name="custom-write-panel-id" style="margin-top:-2px" onchange="document.SelectWritePanel.submit()">
<?php
foreach ($customWritePanels as $panel) {
?>
<option <?php
echo $customWritePanelId == $panel->id ? ' selected ' : '';
?>
value="<?php
echo $panel->id;
?>
"><?php
echo $panel->name;
?>
</option>
<?php
}
?>
</select>
</strong>
<a href="<?php
echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-group');
?>
" class="button-secondary">+ <?php
_e('Create a Group', $mf_domain);
?>
</a>
<a href="<?php
echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . "&custom-group-id={$customDefaultGroupId}";
?>
" class="button-secondary">+ <?php
_e('Create a Field', $mf_domain);
?>
</a>
</p>
</form>
<br class="clear"/>
<?php
if (isset($_GET['save_order']) && $_GET['saved_order'] == "true") {
?>
<div id="message" class="updated">
Saved Order.
</div>
<?php
}
?>
<?php
foreach ($custom_groups as $group) {
?>
<?php
if ($group->name == "__default") {
?>
<h2>Magic Fields</h2>
<?php
} else {
?>
<h2 class="mf-no-default-group"><a href="<?php
echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('edit-custom-group') . "&custom-group-id={$group->id}";
?>
"><?php
echo $group->name;
?>
</a></strong>
<span class="mf_add_group_field">(<a href="<?php
echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . "&custom-group-id={$group->id}";
?>
"><?php
_e('create field', $mf_domain);
?>
</a>)</span>
<span class="mf_delete_group_field">(<a onclick="return confirmBeforeDeleteGroup();" href="<?php
echo wp_nonce_url(RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('delete-custom-group') . "&custom-group-id={$group->id}", 'delete-custom-group');
?>
"><?php
_e('delete', $mf_domain);
?>
</a>)</span>
</h2>
<?php
}
?>
<form action="<?php
echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('save-fields-order');
?>
" method="post" id="posts-filter" name="ImportWritePanelForm" enctype="multipart/form-data">
<?php
wp_nonce_field('save-fields-order');
?>
<table cellpadding="3" cellspacing="3" width="100%" class="widefat">
<thead>
<tr>
<th width="5%"></th>
<th width="20%" scope="col"><?php
_e('Label', $mf_domain);
?>
</th>
<th width="35%" scope="col"><?php
_e('Name (Order)', $mf_domain);
?>
</th>
<th width="20%" scope="col"><?php
_e('Type', $mf_domain);
?>
</th>
<th width="20%" scope="col"><?php
_e('Actions', $mf_domain);
?>
</th>
</tr>
</thead>
<tbody class="sortable">
<?php
RCCWP_CustomWritePanelPage::DisplayGroupFields($group->id);
?>
</tbody>
</table>
<?php
}
?>
</div>
<br />
<input type="submit" name="save_submit" value="<?php
_e('Save Order', $mf_domain);
?>
" id="save_order" />
</form>
<?php
}