Класс Photos
Объект $Photos:
Объект «Фотоальбом»
Исходный код
class Photos extends \Cms\Site\Page { … }
Методы
register()
$Photos->register(&$Main);
Регистрация
Исходный код
function register(&$Main) {
$Main->addTable("image", array( "parent", "type", "title", "order", "login", "image", "width", "height", "date" ));
$Main->openType("photo");
$Main->addType("photos", "Фотоальбом");
return array(
"list" => "photo",
"title" => "Фотоальбом",
);
}
getPanel()
$Photos->getPanel();
Панель инструментов
Исходный код
function getPanel() {
if (!strlen($this->id)) return array();
return array(
"-" => array(
"href" => "?a=page&p=&type=photos&parent=" . urlencode($this->id),
"title" => "Создать фотоальбом",
"image" => "add",
"can" => "add|edit",
),
"html" => array(
"href" => "?a=html&p=" . urlencode($this->id),
"title" => "Редактировать фотоальбом",
"image" => "html",
"can" => "html|edit",
),
"page" => array(
"href" => "?a=page&p=" . urlencode($this->id),
"title" => "Свойства фотоальбома",
"image" => "edit",
"can" => "page|edit",
),
"menu" => array(
"href" => "?a=menu&p=" . urlencode($this->id),
"title" => "Показывать в меню",
"image" => "menu",
"can" => "menu|edit",
),
"move" => array(
"href" => "?a=move&p=" . urlencode($this->id),
"title" => "Переместить страницу",
"image" => "move",
"can" => "move|edit",
),
"sort" => array(
"href" => "?a=sort&p=" . urlencode($this->id),
"title" => "Изменить порядок фотографий",
"image" => "sort",
"can" => "sort|edit",
),
"upload" => array(
"href" => "?a=upload&p=" . urlencode($this->id),
"title" => "Загрузить фотографии",
"image" => "add",
"can" => "upload|edit",
),
"pages" => array(
"href" => "?a=pages&p=" . urlencode($this->id),
"title" => "Редактировать фотографии",
"image" => "edit",
"can" => "pages|edit",
),
"deletes" => array(
"href" => "?a=deletes&p=" . urlencode($this->id),
"title" => "Удалить фотографии",
"image" => "delete",
"can" => "deletes|edit",
),
"delete" => array(
"href" => "?a=delete&p=" . urlencode($this->id),
"title" => "Удалить фотоальбом",
"image" => "delete",
"can" => "delete",
),
);
}
displayPagesForm()
$Photos->displayPagesForm($form="photo");
Форма редактирования дочерних страниц
Параметры:
Имя | Описание |
---|---|
$form |
|
Возвращает: array|string|null
Исходный код
function displayPagesForm($form = "photo") {
return parent::displayPagesForm($form);
}
displayUploadForm()
$Photos->displayUploadForm($form="upload");
Исходный код
function displayUploadForm($form = "upload") {
$root = $this->root();
$Main = $this->Main();
$Form = $this->Form();
$Page = $this;
$document = $Form->load($form, $Page);
if ($Form->store($document)) {
foreach ($document->fields as $name => $field) {
if ($field->type == "image" && strlen($field->value)) {
list($width, $height) = @getimagesize($root . $field->value);
if (!$width || !$height) continue;
$row = array(
"id" => "",
"parent" => $Page->id,
"type" => "photo",
"title" => "",
"image" => $field->value,
"width" => $width,
"height" => $height,
);
$Item = $Main->load($row);
$Item->save();
}
}
foreach ($document->fields as $name => $field) if ($field->type == "multiup" && is_array($field->value)) {
foreach ($field->value as $image) if (strlen($image)) {
list($width, $height) = @getimagesize($root . $image);
if (!$width || !$height) continue;
$row = array(
"id" => "",
"parent" => $Page->id,
"type" => "photo",
"title" => "",
"image" => $image,
"width" => $width,
"height" => $height,
);
$Item = $Main->load($row);
$Item->save();
if (!$Page->image) {
$Page->image = $image;
$Page->save();
}
}
}
return $Page->href();
}
return $document;
}