<?
/**
 * appRain CMF
 *
 * LICENSE
 *
 * This source file is subject to the MIT license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.opensource.org/licenses/mit-license.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@apprain.com so we can send you a copy immediately.
 *
 * @copyright  Copyright (c) 2010 appRain, Team. (http://www.apprain.com)
 * @license    http://www.opensource.org/licenses/mit-license.php MIT license
 *
 * HELP
 *
 * Official Website
 * http://www.apprain.com/
 *
 * Download Link
 * http://www.apprain.com/download
 *
 * Documents Link
 * http ://www.apprain.com/docs
 */
?>
<form method="post" action="<?php echo $this->baseUrl("/page/manage-snip/{$action}");?>" id="snip-manager">
<?php
	App::Helper('Toolbar')->setTitle("SNIP Manager");    
    if(isset($id)) {
        App::Helper('Toolbar')->setBtnfileManager()->setBtnCustomHtml('<input type="button" onclick="window.location = siteInfo.baseUrl + \'/page/manage-snip/delete/' . $id . '\'" value="Delete" /> ' . App::Helper("Html")->ButtonTag("Button[View][Page]","View Page",array("onclick"=>"document.location='" . $this->baseurl("/page/view/{$id}") . "';")));
    }
    else {
        App::Helper('Toolbar')->setBtnfileManager();
    }
    App::Helper('Toolbar')->setBtnBack()->Render(array('code'=>'page_manager_top'));
?>

<?php
	$Grid = App::Module('DataGrid')->setDisplay('FormListing')
		->addRow(
			$this->__("Name ") . App::Helper('Html')->helpTag('page-manager-snip-name'),
			App::Module('AdminPanelUi')->pageNameInputBox($action,'Snip',$id)
		)
		->addRow(
			$this->__("Code ") . App::Helper('Html')->helpTag('page-manager-snip-content') . App::Helper('Html')->helpTag('page-manager-snip-content-example','Example'),
			App::Helper("Html")->textareaTag('data[Page][content]', App::PageManager()->FieldValueById($id,'content'),array("rows" => "22","class" => "textarea large check_notempty","id" => "page_content","longdesc"=>"Please enter snip content"))
		)
		->addRow('','<div class="page-message" >&nbsp;</div>')
		->Render();
?>
<?php App::Helper('Toolbar')->setFormJustified(true)->setBtnSave()->setBtnBack()->Render(array('code'=>'snip_bottom'));?>
<input name="data[Page][id]" type="hidden" value="<?php echo $id; ?>" />
</form>
<?php App::Helper('JavaScript')->setAjax(array("debug" => false, "autoHide" => false,"messagElement"=>".page-message","loaderElement"=>".page-message"))->appForm('#snip-manager');?>
