witam, przedstawiam do oceny mój kod klasy która będzie wykorzystana w cms klasie jeszcze brakuje pare rzeczy pisze ją od paru godzinek. widzicie w niej jakieś błędy może ulepszenia ?
<?php
include_once '_i/auto/Documents.php';
class Contents extends tblDocuments {
public function htmlchars($doc)
{
// Filter
return $result;
}
public function lstDocuments($_where='')
{
// List in array table documents
$doc = DB_DataObject::factory('documents');
if ($_where <> '') {
$doc->whereAdd("cat = $_where");
}
// Find element in table documents
$doc->find();
while($doc->fetch()) {
$result['data'][] = $doc->toArray();
}
return $result = isset($result) ?
$result : null; }
public function lstCat($_where='')
{
// Connect to table cat
$cat = DB_DataObject::factory('cat');
if ($_where <> '') {
$cat->whereAdd("parent = $_where");
}else{
$cat->whereAdd("parent = 0");
}
// Find element in table cat
$cat->find();
while($cat->fetch()) {
$result['data'][] = $cat->toArray();
}
return $result = isset($result) ?
$result : null; }
public function countCat($_where='')
{
// Count category
$cat = DB_DataObject::factory('cat');
if ($_where <> '') {
$cat->whereAdd("parent = $_where");
}
return $cat->find();
}
public function countDoc($_where='')
{
// Count document
$doc = DB_DataObject::factory('documents');
if ($_where <> '') {
$doc->whereAdd("cat = $_where");
}
return $doc->find();
}
public function addCat($_title, $_desc, $_parent)
{
// Add category
$cat = DB_DataObject::factory('cat');
$cat->Desc=$_desc;
$cat->Title=$_title;
$cat->parent=$_parent;
$cat->insert();
}
public function delCat($_id)
{
// Delete category
$cat = DB_DataObject::factory('cat');
$cat->get($_id);
return $cat->delete();
}
public function delDoc($_id)
{
// Delete document
$doc = DB_DataObject::factory('documents');
$doc->get($_id);
return $doc->delete();
}
public function addDoc($_title, $_desc, $_cat)
{
// Add document
$doc = DB_DataObject::factory('documents');
$doc->Desc=Contents::htmlchars($_desc);
$doc->Title=Contents::htmlchars($_title);
$doc->cat=$_cat;
$doc->CreateDate='NOW()';
$doc->insert();
}
public function editDoc($_id)
{
// Edit document
}
public function getDoc($_where='')
{
// Get in document
$doc = DB_DataObject::factory('documents');
if ($_where <> '') {
$doc->whereAdd("Id = $_where");
}else{
$doc->whereAdd("parent = 0");
}
// Find element in table document
$doc->find();
while($doc->fetch()) {
$result['data'][] = $doc->toArray();
// $result['html']['Desc'] = Contents::htmlchars($result['data']['0']['Desc']);
// $result['html']['Title'] = Contents::htmlchars($result['data']['0']['Title']);
}
return $result = isset($result) ?
$result : null;
}
}
?>
tak php5 a jest w kodzie cos co by mowiło ze to nie php 5?
a co robi wyciąga z bazy daną treść do cms , treści sa podzielone na kategorie, oczywiscie to cześć kodu i pewnie beda zmiany i duzo dojdzie ale juz chcial bym wiedziec co o tym sadzicie
Ten post edytował acztery 25.05.2006, 21:54:08