Система управления «Сайт PRO»
Версия 20240107

Класс Property

Объект $Property: Cms\Root\Data\Property наследует Cms\Site\Base

Объект «Свойство страницы»

Исходный код
class Property extends \Cms\Site\Base { … }

Свойства

$name

$Property->name

Имя свойства

Исходный код
    var $name;

$title

$Property->title

Название свойства

Исходный код
    var $title;

$module

$Property->module

Модуль

Исходный код
    var $module;

$enable

$Property->enable

Свойство включено

Исходный код
    var $enable;

$root

$Property->root

Свойство является системным

Исходный код
    var $root;

$site

$Property->site

Свойство является локальным

Исходный код
    var $site;

$data

$Property->data = array();

Информация о свойстве

Исходный код
    var $data = array();

Методы

__construct()

new Property($module=null, $name=null);
Исходный код
    function __construct($module = null, $name = null) {
        $this->module = $module;
        $this->name = $this->data['name'] = $name;
    }

get()

$Property->get($key, $default=null);
Исходный код
    function get($key, $default = null) {
        return isset($this->$key) ? $this->$key : $default;
    }

set()

$Property->set($key, $value);
Исходный код
    function set($key, $value) {
        if ($key[0] === '_' || $key === 'root' || $key === 'site' || $key === 'module') $this->$key = $value;
        else $this->$key = $this->data[$key] = $value;
        if ($key === 'enabled') if ($Type = $this->loadModule()) $Type->resetEnabledFieldList();
    }

getName()

$Property->getName();
Исходный код
    function getName() {
        return $this->name;
    }

getTitle()

$Property->getTitle();
Исходный код
    function getTitle() {
        return $this->title ? $this->title : $this->name;
    }

displayTitle()

$Property->displayTitle();
Исходный код
    function displayTitle() {
        return htmlspecialchars($this->getTitle());
    }

getModule()

$Property->getModule();
Исходный код
    function getModule() {
        return $this->module;
    }

loadModule()

$Property->loadModule();
Исходный код
    function loadModule() {
        if ($module = $this->getModule()) {
            return $this->Main()->Modules()->getModule($module);
        }
    }

isEnabled()

$Property->isEnabled();
Исходный код
    function isEnabled() {
        return $this->enable ? true : false;
    }

isRoot()

$Property->isRoot();
Исходный код
    function isRoot() {
        return $this->root ? true : false;
    }

isSite()

$Property->isSite();
Исходный код
    function isSite() {
        return $this->site ? true : false;
    }

addPropertyData()

$Property->addPropertyData(array $propertyData, $override=true);
Исходный код
    function addPropertyData(array $propertyData, $override = true) {
        foreach ($propertyData as $k => $v) {
            if ($k === 'module') {
                $this->$k = $v;
            } elseif ($override || !isset($this->$k)) {
                $this->set($k, $v);
            }
        }
    }

getPropertyData()

$Property->getPropertyData();
Исходный код
    function getPropertyData() {
        $r = $this->data;
        $r['site'] = 'Y';
        return $r;
    }

getPanel()

$Property->getPanel();
Исходный код
    function getPanel() {
        return array(
            'edit' => array(
                'href' => $this->Main()->href('/admin/modules') . '?a=property&module=' . rawurldecode($this->getModule()) . '&property=' . rawurlencode($this->getName()),
                'image' => 'edit',
            ),
        );
    }

displayPageForm()

$Property->displayPageForm($form='data_property');
Исходный код
    function displayPageForm($form = 'data_property') {
        if (!isset($form)) return;
        $Main = $this->Main();
        $Form = $this->Form();
        $Property = $this;
        $document = $Form->load($form, $Property);
        if ($Form->store($document)) {
            if ($Property->save()) {
                return $Property->href();
            }
        }
        return $document;
    }

href()

$Property->href();
Исходный код
    function href() {
        return $this->Main()->href('/admin/modules') . '?module=' . rawurlencode($this->getModule()) . '&property=' . rawurlencode($this->getName());
    }

save()

$Property->save();
Исходный код
    function save() {
        $this->set('site', 'Y');
        if ($Type = $this->loadModule()) return $Type->save();
    }