453 lines
8.8 KiB
PHP
453 lines
8.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Klasa struktury menu
|
|
*
|
|
*/
|
|
class Structure extends DataObject {
|
|
|
|
/**
|
|
* nazwa tabeli
|
|
*/
|
|
static $tableName = 'mf_structure';
|
|
|
|
/**
|
|
* nazwa klucza tabeli
|
|
*/
|
|
static $classTablePK = 'id_mf_structure';
|
|
|
|
/**
|
|
* nazwa klasy
|
|
*/
|
|
static $className = __CLASS__;
|
|
|
|
/**
|
|
* tabela mapująca pola z bazy SQL na pola klasy.
|
|
*/
|
|
static $fields = array(
|
|
'id_mf_structure' => 'id',
|
|
'id_parent' => 'idParent',
|
|
'id_content' => 'idContent',
|
|
'id_main' => 'idMain',
|
|
'id_router' => 'idRouter',
|
|
'id_router_detail' => 'idRouterDetail',
|
|
'id_router_page' => 'idRouterPage',
|
|
'lang' => 'lang',
|
|
'sort' => 'sort',
|
|
'publication' => 'publication',
|
|
'publication_menu' => 'publicationMenu',
|
|
'type' => 'type',
|
|
'name' => 'name',
|
|
'subname' => 'subname',
|
|
'element_name' => 'elementName',
|
|
'menu_name' => 'menuName',
|
|
'url' => 'url',
|
|
'url_label' => 'urlLabel',
|
|
'banner' => 'banner',
|
|
'copy' => 'copy',
|
|
'location' => 'location',
|
|
'id_mf_picture' => 'idPicture',
|
|
'id_mf_picture_mini' => 'idPictureMini',
|
|
'url_redirect' => 'urlRedirect'
|
|
);
|
|
protected $id;
|
|
private $idParent;
|
|
private $idContent;
|
|
private $idMain;
|
|
private $idRouter;
|
|
private $idRouterDetail;
|
|
private $idRouterPage;
|
|
private $lang;
|
|
private $sort = 1;
|
|
private $publication;
|
|
private $publicationMenu;
|
|
private $type;
|
|
private $name;
|
|
private $subname;
|
|
private $elementName;
|
|
private $menuName;
|
|
private $url;
|
|
private $urlLabel;
|
|
private $banner;
|
|
private $location;
|
|
private $copy;
|
|
private $idPicture = 0;
|
|
private $idPictureMini = 0;
|
|
private $urlRedirect = null;
|
|
private $picture;
|
|
private $pictureMini;
|
|
private $haveChildren;
|
|
public $arrayChildren = array();
|
|
public $content;
|
|
|
|
public function GetId() {
|
|
return $this->id;
|
|
}
|
|
|
|
public function SetId($id) {
|
|
$this->id = $id;
|
|
}
|
|
|
|
public function GetName() {
|
|
return $this->name;
|
|
}
|
|
|
|
public function SetName($s) {
|
|
$this->name = $s;
|
|
}
|
|
|
|
public function GetSubname() {
|
|
return $this->subname;
|
|
}
|
|
|
|
public function SetSubname($s) {
|
|
$this->subname = $s;
|
|
}
|
|
|
|
public function GetNameUpper() {
|
|
return Utils::TextToUpper($this->name);
|
|
}
|
|
|
|
public function GetArrayName($lang) {
|
|
return Utils::TextToUpperArray($this->name, $lang);
|
|
}
|
|
|
|
public function GetElementName() {
|
|
if (!$this->elementName) {
|
|
$this->elementName = $this->name;
|
|
}
|
|
return $this->elementName;
|
|
}
|
|
|
|
public function SetElementName($s) {
|
|
$this->elementName = $s;
|
|
}
|
|
|
|
public function GetMenuName() {
|
|
return $this->menuName;
|
|
}
|
|
|
|
public function SetMenuName($s) {
|
|
$this->menuName = $s;
|
|
}
|
|
|
|
public function GetIdParent() {
|
|
return $this->idParent;
|
|
}
|
|
|
|
public function SetIdParent($s) {
|
|
$this->idParent = $s;
|
|
}
|
|
|
|
public function GetIdContent() {
|
|
return $this->idContent;
|
|
}
|
|
|
|
public function SetIdContent($s) {
|
|
$this->idContent = $s;
|
|
}
|
|
|
|
public function GetIdMain() {
|
|
return $this->idMain;
|
|
}
|
|
|
|
public function SetIdMain($s) {
|
|
$this->idMain = $s;
|
|
}
|
|
|
|
public function GetLang() {
|
|
return $this->lang;
|
|
}
|
|
|
|
public function SetLang($s) {
|
|
$this->lang = $s;
|
|
}
|
|
|
|
public function GetIdRouter() {
|
|
return $this->idRouter;
|
|
}
|
|
|
|
public function SetIdRouter($s) {
|
|
$this->idRouter = $s;
|
|
}
|
|
|
|
public function GetIdRouterDetail() {
|
|
return $this->idRouterDetail;
|
|
}
|
|
|
|
public function SetIdRouterDetail($s) {
|
|
$this->idRouterDetail = $s;
|
|
}
|
|
|
|
public function GetIdRouterPage() {
|
|
return $this->idRouterPage;
|
|
}
|
|
|
|
public function SetIdRouterPage($s) {
|
|
$this->idRouterPage = $s;
|
|
}
|
|
|
|
public function GetSort() {
|
|
return $this->sort;
|
|
}
|
|
|
|
public function SetSort($s) {
|
|
$this->sort = $s;
|
|
}
|
|
|
|
public function GetPublication() {
|
|
return $this->publication;
|
|
}
|
|
|
|
public function SetPublication($s) {
|
|
$this->publication = $s;
|
|
}
|
|
|
|
public function GetPublicationMenu() {
|
|
return $this->publicationMenu;
|
|
}
|
|
|
|
public function SetPublicationMenu($s) {
|
|
$this->publicationMenu = $s;
|
|
}
|
|
|
|
public function GetUrl() {
|
|
return $this->url;
|
|
}
|
|
|
|
public function SetUrl($s) {
|
|
$this->url = $s;
|
|
}
|
|
|
|
public function GetUrlWithType() {
|
|
return Router::GenerateUrl($this->urlLabel);
|
|
}
|
|
public function GetUrlInAdmin() {
|
|
return Router::GenerateUrl($this->urlLabel, null, APP_SITE_URL);
|
|
}
|
|
|
|
public function GetType() {
|
|
return $this->type;
|
|
}
|
|
|
|
public function SetType($s) {
|
|
$this->type = $s;
|
|
}
|
|
|
|
public function GetUrlLabel() {
|
|
return $this->urlLabel;
|
|
}
|
|
|
|
public function GetUrlLabelDetail() {
|
|
return $this->urlLabel . 'Detail';
|
|
}
|
|
|
|
public function SetUrlLabel($s) {
|
|
$this->urlLabel = $s;
|
|
}
|
|
|
|
public function GetCopy() {
|
|
return $this->copy;
|
|
}
|
|
|
|
public function SetCopy($s) {
|
|
$this->copy = $s;
|
|
}
|
|
|
|
public function GetLocation() {
|
|
return $this->location;
|
|
}
|
|
|
|
public function SetLocation($s) {
|
|
$this->location = $s;
|
|
}
|
|
|
|
public function GetBanner() {
|
|
return $this->banner;
|
|
}
|
|
|
|
public function SetBanner($s) {
|
|
$this->banner = $s;
|
|
}
|
|
|
|
public function GetBannerTh() {
|
|
return str_replace('.jpg', '_th.jpg', $this->banner);
|
|
}
|
|
|
|
public function GetHaveChildren() {
|
|
return $this->haveChildren;
|
|
}
|
|
|
|
public function SetHaveChildren($s) {
|
|
$this->haveChildren = $s;
|
|
}
|
|
|
|
public function SetArrayChildren($s) {
|
|
$this->arrayChildren = $s;
|
|
}
|
|
|
|
public function AddChildren($obj) {
|
|
$this->arrayChildren = array_merge_recursive($this->arrayChildren, $obj);
|
|
}
|
|
|
|
public function GetArrayChildren() {
|
|
return $this->arrayChildren;
|
|
}
|
|
|
|
public function GetMainFileName() {
|
|
return Utils::ClearString($this->GetMenuName());
|
|
}
|
|
|
|
public function GetBannerWhitUrl() {
|
|
if (file_exists(PATH_STATIC_CONTENT . "/upload/Structure/" . $this->id . "/" . $this->banner)) {
|
|
return URL_STATIC_CONTENT . "/upload/Structure/" . $this->id . "/" . $this->banner;
|
|
}
|
|
}
|
|
|
|
public function GetBannerThWhitUrl() {
|
|
if (file_exists(PATH_STATIC_CONTENT . "/upload/Structure/" . $this->id . "/" . $this->GetBannerTh())) {
|
|
//Utils::ArrayDisplay();
|
|
return URL_STATIC_CONTENT . "/upload/Structure/" . $this->id . "/" . $this->GetBannerTh();
|
|
}
|
|
}
|
|
|
|
public function setSimpleArticle_MfArticleDescription($content) {
|
|
$this->content = $content;
|
|
}
|
|
|
|
public function getSimpleArticle_MfArticleDescription() {
|
|
return $this->content;
|
|
}
|
|
|
|
public function getContent() {
|
|
return $this->content;
|
|
}
|
|
|
|
public function SetIdPicture($idPicture) {
|
|
$this->idPicture = $idPicture;
|
|
}
|
|
|
|
public function GetIdPicture() {
|
|
return $this->idPicture;
|
|
}
|
|
|
|
public function SetIdPictureMini($idPictureMini) {
|
|
$this->idPictureMini = $idPictureMini;
|
|
}
|
|
|
|
public function GetIdPictureMini() {
|
|
return $this->idPictureMini;
|
|
}
|
|
|
|
public function SetUrlRedirect($urlRedirect) {
|
|
$this->urlRedirect = $urlRedirect;
|
|
}
|
|
|
|
public function GetUrlRedirect() {
|
|
if ($this->urlRedirect) {
|
|
$pos = strpos($this->urlRedirect, 'http://');
|
|
//Utils::ArrayDisplay($pos);
|
|
if ($pos === false) {
|
|
//Utils::ArrayDisplay($this->urlRedirect);
|
|
return 'http://' . $this->urlRedirect;
|
|
} else {
|
|
return $this->urlRedirect;
|
|
}
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public function SetPicture($picture) {
|
|
$this->picture = $picture;
|
|
}
|
|
|
|
public function GetPicture() {
|
|
if (!$this->picture && (int) $this->idPicture > 0) {
|
|
$this->picture = PictureDAL::GetById($this->GetIdPicture());
|
|
}
|
|
|
|
return $this->picture;
|
|
}
|
|
|
|
public function GetPictureUrl() {
|
|
if ($this->GetPicture()) {
|
|
return Config::Get('URL_STATIC_CONTENT') . '/upload/Structure/' . $this->GetPicture()->GetLink();
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public function SetPictureMini($pictureMini) {
|
|
$this->pictureMini = $pictureMini;
|
|
}
|
|
|
|
public function GetPictureMini() {
|
|
if (!$this->pictureMini && (int) $this->idPictureMini > 0) {
|
|
$this->pictureMini = PictureDAL::GetById($this->GetIdPictureMini());
|
|
}
|
|
|
|
return $this->pictureMini;
|
|
}
|
|
|
|
public function GetPictureMiniUrl() {
|
|
if ($this->GetPictureMini()) {
|
|
return Config::Get('URL_STATIC_CONTENT') . '/upload/Structure/' . $this->GetPictureMini()->GetLink();
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Konstruktor klasy
|
|
*
|
|
* @param integer $id
|
|
* @param string $name
|
|
*/
|
|
public function __construct($id = -1, $idContent = '-1', $idParent = 0, $idMain = 0, $idRouter = '-1', $lang = 1, $sort = 0, $publication = 0, $name = null, $menuName = '', $url = null, $urlLabel = null) {
|
|
$this->SetId($id);
|
|
$this->SetIdContent($idContent);
|
|
;
|
|
$this->SetIdParent($idParent);
|
|
;
|
|
$this->SetIdMain($idMain);
|
|
$this->SetLang($lang);
|
|
$this->SetIdRouter($idRouter);
|
|
$this->SetName($name);
|
|
$this->SetMenuName($menuName);
|
|
$this->SetPublication($publication);
|
|
$this->SetUrl($url);
|
|
$this->SetUrlLabel($urlLabel);
|
|
}
|
|
|
|
/**
|
|
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
|
* @return string
|
|
*/
|
|
public function GetTableName() {
|
|
return self::$tableName;
|
|
}
|
|
|
|
/**
|
|
* Pobiera taablice mapującą pola klasy na pola tabeli
|
|
* @return array
|
|
*/
|
|
public function GetFields() {
|
|
return self::$fields;
|
|
}
|
|
|
|
/**
|
|
* Pobiera nazwę klasy
|
|
* @return string
|
|
*/
|
|
public function GetClassName() {
|
|
return self::$className;
|
|
}
|
|
|
|
public function GetClassTablePK() {
|
|
return self::$classTablePK;
|
|
}
|
|
|
|
}
|
|
|
|
?>
|