<?php
abstract class TaweBaseItem extends TaweQueryBase {
protected $moduleName;
protected $parent;
function __construct($moduleName, $parent) {
parent::__construct();
$this->moduleName = $moduleName;
if ($parent) {
if (!is_a($parent, TaweBaseListItem)) exit($moduleName." invalid parent class given"); // TODO: aweError
$this->parent = $parent;
}
}
function call($functionName, $arguments) {
return call_user_func_array(array($this, $functionName), $arguments);
}
protected function makeListForm($items, $formTemplate) {
global $templateAreola;
global $tempFormContent;
return str_replace($templateAreola.$tempFormContent.$templateAreola,$items,$formTemplate);
}
protected function makeListItem($dataLine, $itemTemplate, $templateName, $fileTmp = "") {
global $templateAreola;
global $aweSqlPrimaryKey;
global $addressBase;
global $addressTemplateString;
global $pagedataDir;
global $pagedataGfx;
global $fileTemplateString;
global $fileNamesSeparator;
$result = massReplace($dataLine, $itemTemplate, $templateAreola);
$result = tempReplace(
$addressTemplateString,
$addressBase.$this->makeAddress($dataLine[$aweSqlPrimaryKey]),
$result,
$templateAreola
);
// FILE LIKING
if (!is_array($fileTmp)) $file[0] = $fileTmp; else $file = $fileTmp;
if ($fileTmp) {
for ($i=0; $i<sizeof($file); $i++) {
$table = explode($fileNamesSeparator, $file[$i]);
if (sizeof($table)==2) {$fileStr = $table[0]; $fileNof = $table[1];}
else {$fileStr = $file[$i]; $fileNof = "";};
$filePath = $pagedataGfx.$this->moduleName."/".$templateName."/";
$fileName = sprintf($fileStr,$dataLine[$aweSqlPrimaryKey]);
$location = $filePath.$fileName;
if (!is_file($location) && $fileNof)
$fileName = $fileNof;
if (!$i) $result = tempReplace($fileTemplateString, $filePath.$fileName, $result, $templateAreola);
$result = tempReplace($fileTemplateString.$i, $filePath.$fileName, $result, $templateAreola);
}
}
return $result;
}
}