Example #1
0
 /** displays the result from the queryList
  *
  * Parameters
  *	@content - array - additional content, paths etc to use with lister
  *	@listEvenLineTpl - string - file name for template used to format even line of results
  *	@noResultsTpl - string - template used for no results
  *	@listOddLineTpl - string - file name for template used to format odd line of results
  *	@overWrite - bool - content must over write the current, not be merged
  */
 function displayList($content, $listEvenLineTpl, $noResultsTpl, $listOddLineTpl = "", $overWrite = false)
 {
     $listing = "";
     if ($this->noResult) {
         $list = new Template($content, $noResultsTpl, false);
         $listing = $list->output();
     } else {
         $listEven = new Template($content, $listEvenLineTpl, false);
         if ($listOddLineTpl != "") {
             $listOdd = new Template($content, $listOddLineTpl, false);
         } else {
             $listOdd = new Template($content, $listEvenLineTpl, false);
         }
         $line = $this->pageStart;
         $i = 1;
         $evenLine = true;
         $this->db->move($line);
         $firstLine = true;
         while ($row = $this->db->fetchRow(true) and $i <= $this->listerSave->limit) {
             if (is_array($content)) {
                 $rowContent = array_merge($row, $content);
             } else {
                 $rowContent = $row;
             }
             if ($firstLine) {
                 $rowContent["SSP_firstLine"] = true;
             } else {
                 $rowContent["SSP_firstLine"] = false;
             }
             $displayLine = true;
             if ($this->processLine != "") {
                 if ($this->processLineObject === false) {
                     $rowContent = call_user_func($this->processLine, $rowContent);
                 } else {
                     $rowContent = call_user_func([$this->processLineObject, $this->processLine], $rowContent);
                 }
                 if (is_bool($rowContent) and !$rowContent) {
                     $displayLine = false;
                 } elseif (!is_array($rowContent)) {
                     trigger_error("Lister Lib: invalid result from {$this->processLine}", E_USER_ERROR);
                 }
             } elseif (!is_array($rowContent)) {
                 trigger_error("Lister Lib: invalid row content", E_USER_ERROR);
             }
             if ($displayLine) {
                 if ($evenLine) {
                     $listEven->restart($rowContent, $overWrite);
                     $listing .= $listEven->output();
                 } else {
                     $listOdd->restart($rowContent, $overWrite);
                     $listing .= $listOdd->output();
                 }
                 if ($evenLine) {
                     $evenLine = false;
                 } else {
                     $evenLine = true;
                 }
             }
             $i++;
             if ($firstLine) {
                 $this->pageFirstRecord = $rowContent;
                 $firstLine = false;
             }
         }
     }
     if (!$this->noResult) {
         $this->pageLastRecord = $rowContent;
     }
     return $listing;
 }
Example #2
0
*   Site by w34u
*   http://www.w34u.com
*   info@w34u.com
*   +44 (0)1273 201344
*   +44 (0)7833 512221
*
*   Project:	Simple Site Protection
*   Routine:	example4.php
*   Created:	27-May-2010
*   Descrip:	Template routines Example 4: Different ways of loading data and templates.
*				Various ways of loading data and template files.
*
*   Revision:	a
*   Rev. Date	27-May-2010
*   Descrip:	Created.
*/
namespace w34u\ssp;

require "../../sspadmin/includeheader.php";
$moreContent = new \stdClass();
$moreContent->moreContent = "Some more content";
$dynamicallyDefinedTemplate[] = "<h3>Dynamically defined template</h3>";
$dynamicallyDefinedTemplate[] = "<p>Creating a template on the fly, very useful for things like forms</p>";
$dynamicallyDefinedTemplate[] = "{:if:mainTitle} // line removed on execution";
$dynamicallyDefinedTemplate[] = "<p>Main content: {mainContent}</p>";
$dynamicallyDefinedTemplate[] = "{:endif:mainTitle} // line removed on execution";
$content = array("title" => 'Different ways of loading data and templates', "mainTitle" => "Different ways of loading data and templates", "mainContent" => "The data can be loaded from objects and after the template object has been defined.", "dynamic" => new Template("", $dynamicallyDefinedTemplate, false));
$page = new Template($content, "example4.tpl", false);
$page->restart($moreContent);
echo $page->output();
require './back.html';
Example #3
0
 /**
  * Process the form template to add the filter fields
  * @param array form data and fields
  * @return string - html for form
  */
 static function formFilterCreate($form)
 {
     // create search form
     $fields = new Template($form, "userListerSearchFields.tpl");
     $fields->replaceIndex = true;
     $fields->encode = false;
     $fieldsHtml = "";
     foreach ($form["fields"] as $key => $value) {
         $fields->indexNo = $key;
         $fields->restart($form);
         $fieldsHtml .= $fields->output();
     }
     $form["searchFields"] = $fieldsHtml;
     $formPage = new Template($form, $form["tplf"]);
     $formPage->encode = false;
     $tpl = $form["tpl"];
     $tpl->display = false;
     $tpl->setData("content", $formPage->output());
     return $tpl->output();
 }