Esempio n. 1
0
 public function Render($aMeta, $aData = array())
 {
     $aTimer['Start'] = microtime(true);
     $this->SetConfig($aMeta, $aData);
     $this->sResult = '';
     $this->ConstructGridData($aMeta);
     $aFlags = $this->ConstructFlags($aMeta);
     $aRel = $this->ConstructFlagMeta($aMeta);
     //        $this->sResult = "<script src=\"html/javascript/lib/grid.js\" type=\"text/javascript\"></script>\n";
     if (!empty($aMeta['identity']) && !empty($aMeta['workflow'])) {
         $sAction = !empty($aMeta['script']) ? $aMeta['script'] : 'form.php';
         $this->sResult .= "<form method=\"post\" action=\"" . BuildUrl($sAction) . "\" id=\"" . $aMeta['identity'] . "\">\n";
         $this->BuildIdentity($aMeta['identity']);
         $this->BuildWorkflow($aMeta['workflow']);
     }
     $this->sResult .= "<table class=\"" . implode(' ', $aFlags) . "\" rel=\"" . implode(' ', $aRel) . "\" id=\"" . $aMeta['identity'] . "-table\" cellspacing=\"0\">\n<thead>\n";
     // Build Headers
     !empty($aMeta['heading']) && ($this->sResult .= '<tr><td colspan="' . $this->iColSpan . '" class="grid-header">' . $aMeta['heading'] . '</td></tr>' . "\n");
     !empty($aMeta['subheading']) && ($this->sResult .= '<tr><td colspan="' . $this->iColSpan . '" class="grid-subheader">' . $aMeta['subheading'] . '</td></tr>' . "\n");
     !empty($aMeta['copy']) && ($this->sResult .= '<tr><td colspan="' . $this->iColSpan . '" class="grid-copy"><div>' . $aMeta['copy'] . '</div></td></tr>' . "\n");
     // Build quick actions (if required, i.e.: more than 10 entries)
     if (in_array('checkbox', $aFlags) && count($this->aData) > 10) {
         $this->sResult .= '<tr><td colspan="' . $this->iColSpan . '" class="grid-quick-select">' . '<span class="clickable checkbox-list-select-all">All</span> | <span class="clickable checkbox-list-select-none">None</span> | <span class="clickable checkbox-list-select-invert">Invert</span>' . "</td></tr>\n";
     }
     $this->sResult .= "</thead>\n";
     $this->Build($aMeta);
     $this->sResult .= "</table>\n";
     if (!empty($aMeta['identity']) && !empty($aMeta['workflow'])) {
         $this->sResult .= "</form>\n";
     }
     $aTimer['End'] = microtime(true);
     //		$this->sResult .= '<div class="timer">Time taken to generate: ' . ($aTimer['End'] - $aTimer['Start']) . 's </div>';
     return $this->sResult;
 }
Esempio n. 2
0
 private function RenderList()
 {
     $sResult = '';
     if (!empty($this->aMeta['script'])) {
         $sResult .= "<script>\r\n\$(document).ready(function()\r\n{\r\n    \$.getJSON('" . BuildUrl($this->aMeta['script']) . "',\r\n    function(data)\r\n    {\r\n        \$.each(data, function(i,item)\r\n        {\r\n            \$('#" . $this->aMeta['id'] . "').append('<option value=\"' + item.value + '\" ' + (\"" . $this->aMeta['value'] . "\" == item.value ? 'selected=\"true\"' : '') + '>' + item.name + '</option>');\r\n        });\r\n    });\r\n});\r\n        </script>";
     }
     switch ($this->aMeta['render-mode']) {
         case 'radio':
             $this->aAttributes['type'] = 'radio';
             $sResult .= $this->RenderRadioList();
             break;
         case 'checkbox':
             $this->aAttributes['type'] = 'checkbox';
             $sResult .= $this->RenderCheckList();
             break;
         case 'select':
         default:
             $sResult .= $this->RenderSelectList();
             break;
     }
     return $sResult . $this->RenderExtras();
 }
Esempio n. 3
0
 public function Render($aMeta, $aData = array())
 {
     $aTimer['Start'] = microtime(true);
     $this->sResult = '';
     if (empty($aMeta['identity'])) {
         throw new Exception('No identity specified');
     }
     //empty($aData) && $aData = Session::GetInput($aMeta['identity']);
     $this->SetConfig($aMeta, $aData);
     $sAction = !empty($aMeta['script']) ? $aMeta['script'] : 'form.php';
     $this->sResult .= "<form method=\"post\" " . $this->___GetFormEncoding($aMeta) . " action=\"" . BuildUrl($sAction) . "\" id=\"" . $aMeta['identity'] . "\">\n";
     $this->sResult .= "<table class=\"form\" id=\"" . $aMeta['identity'] . "-table\">\n";
     $this->Build($aMeta);
     $this->sResult .= "</table>\n";
     // Enable Validation for this Form
     $this->sResult .= "\r\n        <script>\r\n        \$(document).ready(function()\r\n        {\r\n\t\t\t\$('#" . $aMeta['identity'] . "').validator({\r\n\t\t\t\tinputEvent: \tblur,\r\n\t\t    \tmessageClass:   'validation-error'\r\n    \t\t});\r\n    \t});\r\n        </script>\r\n        ";
     $this->sResult .= "</form>\n";
     $aTimer['End'] = microtime(true);
     //		$this->sResult .= '<div class="timer">Time taken to generate: ' . ($aTimer['End'] - $aTimer['Start']) . 's </div>';
     return $this->sResult;
 }
Esempio n. 4
0
	<meta http-equiv="Content-Language" content="English" />
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

 	<link rel="stylesheet" type="text/css" href="../html/css/Builder.css" media="screen" />

	<!-- Include Core Javascript Files -->
	<script src="../html/javascript/jquery-1.3.2.min.js" type="text/javascript"></script>
	<script src="../html/javascript/jquery.tools.min.js" type="text/javascript"></script>
    <script src="../html/javascript/form.js" type="text/javascript"></script>
	<script src="../html/javascript/grid.js" type="text/javascript"></script>	
	
	
	<!-- standalone page styling (can be removed) -->
 	<script src="../html/javascript/tiny_mce/tiny_mce_dev.js" type="text/javascript"></script>
</head>

<body>
<?php 
require_once '../lib/Builder.php';
try {
    $aMeta = array('identity' => 'company-grid', 'heading' => 'Companies', 'columns' => array(array('name' => 'id', 'label' => '', 'type' => 'checkbox'), array('name' => 'id', 'label' => 'Id', 'sort' => 'numeric'), array('name' => 'name', 'label' => 'Name', 'sort' => 'alpha', 'link' => array('path' => BuildUrl('company.php'), 'param' => array(array('name' => 'id', 'key' => 'id')))), array('name' => 'category', 'label' => 'Category', 'sort' => 'alpha'), array('name' => 'description', 'label' => 'Description', 'format' => 'truncate|40,...')), 'paging' => array('num-records' => 5), 'action' => array('footer' => array(array('class' => 'add', 'name' => 'Add New Company'), array('class' => 'delete', 'name' => 'Delete Company'))));
    $aCompanies = array(array('id' => 1, 'name' => 'Company A', 'category' => 'Service', 'description' => 'Company A provides a service'), array('id' => 2, 'name' => 'Company B', 'category' => 'Manufactorer', 'description' => 'Company B makes plastic cup holders'), array('id' => 3, 'name' => 'Company C', 'category' => 'Retail', 'description' => 'Company C sells the items that Company B makes'), array('id' => 4, 'name' => 'Company D', 'category' => 'Service', 'description' => 'Company D provides a service'), array('id' => 5, 'name' => 'Company E', 'category' => 'Manufactorer', 'description' => 'Company E makes plastic cup holders'), array('id' => 6, 'name' => 'Company F', 'category' => 'Retail', 'description' => 'Company F sells the items that Company E makes'), array('id' => 7, 'name' => 'Company G', 'category' => 'Service', 'description' => 'Company G provides a service'), array('id' => 8, 'name' => 'Company H', 'category' => 'Manufactorer', 'description' => 'Company H makes plastic cup holders'), array('id' => 9, 'name' => 'Company I', 'category' => 'Retail', 'description' => 'Company I sells the items that Company H makes'), array('id' => 10, 'name' => 'Company J', 'category' => 'Service', 'description' => 'Company J provides a service'), array('id' => 11, 'name' => 'Company K', 'category' => 'Manufactorer', 'description' => 'Company K makes plastic cup holders'), array('id' => 12, 'name' => 'Company L', 'category' => 'Retail', 'description' => 'Company L sells the items that Company K makes'));
    // Build our form
    $oGrid = new Builder_Grid();
    echo $oGrid->Render($aMeta, $aCompanies);
} catch (Exception $oException) {
    echo 'Exception: ' . $oException->getMessage();
}
?>
</body>
</html>
Esempio n. 5
0
 	<script src="../html/javascript/tiny_mce/tiny_mce_dev.js" type="text/javascript"></script>
</head>

<body>
<?php 
require_once '../lib/Builder.php';
try {
    $aCompanies = array(array('id' => 1, 'name' => 'Company A', 'category' => 'Service', 'description' => 'Company A provides a service', 'coords' => '28,-81'), array('id' => 4, 'name' => 'Company D', 'category' => 'Service', 'description' => 'Company D provides a service', 'coords' => '40,-80'), array('id' => 7, 'name' => 'Company G', 'category' => 'Service', 'description' => 'Company G provides a service', 'coords' => '50,15'), array('id' => 10, 'name' => 'Company J', 'category' => 'Service', 'description' => 'Company J provides a service', 'coords' => '50,15'), array('id' => 2, 'name' => 'Company B', 'category' => 'Manufactorer', 'description' => 'Company B makes plastic cup holders', 'coords' => '50,50'), array('id' => 5, 'name' => 'Company E', 'category' => 'Manufactorer', 'description' => 'Company E makes plastic cup holders', 'coords' => '40,30'), array('id' => 8, 'name' => 'Company H', 'category' => 'Manufactorer', 'description' => 'Company H makes plastic cup holders', 'coords' => '30,40'), array('id' => 11, 'name' => 'Company K', 'category' => 'Manufactorer', 'description' => 'Company K makes plastic cup holders', 'coords' => '0,30'), array('id' => 3, 'name' => 'Company C', 'category' => 'Retail', 'description' => 'Company C sells the items that Company B makes', 'coords' => '20,15'), array('id' => 6, 'name' => 'Company F', 'category' => 'Retail', 'description' => 'Company F sells the items that Company E makes', 'coords' => '15,20'), array('id' => 9, 'name' => 'Company I', 'category' => 'Retail', 'description' => 'Company I sells the items that Company H makes', 'coords' => '51.513016,-0.056305'), array('id' => 12, 'name' => 'Company L', 'category' => 'Retail', 'description' => 'Company L sells the items that Company K makes', 'coords' => '30,0'));
    $oColumn1 = new Builder_Helper_Column();
    $oColumn1->SetName('id')->SetType('checkbox');
    $oColumn2 = new Builder_Helper_Column();
    $oColumn2->SetName('id')->SetLabel('Id')->SetSort(Builder_Grid::SORT_NUMERIC);
    $oParam = new Builder_Helper_Link_Param();
    $oParam->SetName('id')->SetKey('id');
    $oLink = new Builder_Helper_Link();
    $oLink->SetPath(BuildUrl('company.php'))->SetParam($oParam);
    $oColumn3 = new Builder_Helper_Column();
    $oColumn3->SetName('name')->SetLabel('Name')->SetSort(Builder_Grid::SORT_ALPHA)->SetLink($oLink);
    $oColumn4 = new Builder_Helper_Column();
    $oColumn4->SetName('category')->SetLabel('Category')->SetSort(Builder_Grid::SORT_ALPHA);
    $oColumn5 = new Builder_Helper_Column();
    $oColumn5->SetName('coords')->SetLabel('Map')->SetFormat('coordinates');
    $oColumn6 = new Builder_Helper_Column();
    $oColumn6->SetName('description')->SetLabel('Description')->SetFormat('truncate', array(40, '...'));
    $oColumns = new Builder_Helper_Columns();
    $oColumns->AddColumn($oColumn1)->AddColumn($oColumn2)->AddColumn($oColumn3)->AddColumn($oColumn4)->AddColumn($oColumn5)->AddColumn($oColumn6);
    $oAction1 = new Builder_Helper_Action();
    $oAction1->SetName('Add New Company')->SetClass('add');
    $oAction2 = new Builder_Helper_Action();
    $oAction1->SetName('Delete Company')->SetClass('delete');
    $oActions = new Builder_Helper_Actions();