Phalcon Framework 5.9.3

TypeError: sizeof(): Argument #1 ($value) must be of type Countable|array, string given

/var/www/fullrest-team/data/www/fullrest.net/Core/Model/PicItem.php (201)
#0sizeof
/var/www/fullrest-team/data/www/fullrest.net/Core/Model/PicItem.php (201)
<?php
namespace Core\Model;
 
use Core\Dict\ContentType;
use Core\Lib\Pic;
use Imagick;
use Phalcon\Mvc\Model;
use Phalcon\Di\Di;
 
class PicItem extends Model {
    private $item = [
        'flags' => [
            'isIcon'    => 0,
            'isImage'   => 0,
            'isStack'   => 0,
            'isContent' => 0
        ],
        'setts' => [],
        'thumb' => [
            'name' => '',
            'type' => ''
        ],
        'meta' => [
            'title' => '',
            'numbs' => ['stacks' => '', 'images' => '', 'variations' => ''],
            'url'   => '',
            'file'  => [
                'width'  => 0,
                'height' => 0,
                'type'   => ''
            ]
        ],
        'system' => [
            'type'  => '', // image|album
            'name'  => '',
            'id'    => 0,  // Айди картинки или стэка
            'order' => 0
        ],
        'access' => [
            'enabled' => 0,
            'age'     => 0,
            'private' => 0,
            'direct'  => 0,
            'editing' => 0
        ]
 
    ];
 
    public static function initById($id, $type, $access = [], $isApp = false)
    {
        $db = DI::getDefault()['db'];
 
        if($type == 'stack') {
            $result = $db->query('
                SELECT `pis`.*, `pi`.`pic_file_name`, `pi`.`pic_file_format` FROM `src_pic_images_stacks` AS `pis`
                LEFT JOIN `src_pic_images` AS `pi` ON `pi`.`stack_id`=`pis`.`stack_id` AND `pi`.`pic_is_icon` = 1
                WHERE `pis`.`stack_id` = '.$id);
 
            return PicItem::initBySqlArray($result->fetch(), $access, $isApp);
        }
        else {
            $result = $db->query(
                '
                    SELECT 
                        `spi`.*, 
                        `svs`.`stat_views` AS `views_count`, 
                        `svs`.`stat_unics` AS `views_unic` 
                    FROM 
                        `src_pic_images` AS `spi`, 
                        `stc_view_stat` AS `svs` 
                    WHERE 
                        `spi`.`pic_id` = '.$id.' AND 
                        `svs`.type_id='.ContentType::PIC.' AND 
                        `svs`.`content_id`=`spi`.`pic_id`
                '
            );
 
            return PicItem::initBySqlArray($result->fetch(), $access, $isApp);
        }
    }
 
 
    public static function initBySqlArray($sqlRowArray, $access = [], $isApp = false)
    {
        $item = new PicItem();
 
        if ($isApp)
            $urlPref = '#pic/';
        else
            $urlPref = '/';
 
        if(!isset($sqlRowArray['stack_order'])) {
            $item->configAsImage($sqlRowArray, $access, $urlPref);
        }
        else {
            $item->configAsStack($sqlRowArray, $access, $urlPref);
        }
 
        return $item;
    }
 
    public function onConstruct()
    {
        $user =  DI::getDefault()['user'];
 
        $this->item['setts'] = [
            'isDem'   => (int)$user->getSetting('pic', 'show_img_dem'),
            'isType'  => (int)$user->getSetting('pic', 'show_img_type'),
            'isStat'  => (int)$user->getSetting('pic', 'show_alb_stat')
        ];
    }
 
    public function getData()
    {
        return $this->item;
    }
 
 
    public function configAsImage($sqlRowArray, $access = [], $urlPref = '/')
    {
        $parentId   = (int)$sqlRowArray['parent_id'];
        $variations = !$sqlRowArray['pic_variations'] ? '' : (int)$sqlRowArray['pic_variations'];
 
        $this->item['flags']['isImage'] = 1;
        $this->item['flags']['isIcon']  = (int)$sqlRowArray['pic_is_icon'];
        $this->item['flags']['isContent']  = $sqlRowArray['pic_in_content'] ? 1 : 0;
 
        $this->item['thumb']['name'] = $sqlRowArray['pic_file_name'].'_150x150';
        $this->item['thumb']['type'] = $sqlRowArray['pic_file_format'];
 
        $this->item['meta']['title'] = $sqlRowArray['pic_file_title'];
        $this->item['meta']['descr'] = $sqlRowArray['pic_description'];
 
        $this->item['meta']['numbs']['variations'] = (int)$variations;
 
        $this->item['meta']['file']['width']  = $sqlRowArray['pic_file_width'];
        $this->item['meta']['file']['height'] = $sqlRowArray['pic_file_height'];
        $this->item['meta']['file']['type']   = $sqlRowArray['pic_file_format'];
        $this->item['meta']['file']['size']   = $sqlRowArray['pic_file_size'];
 
        if (isset($sqlRowArray['views_count'])) {
            $this->item['meta']['views']['count'] = $sqlRowArray['views_count'];
            $this->item['meta']['views']['unic']  = $sqlRowArray['views_unic'];
        }
 
 
        $this->item['system']['url']    = $urlPref.$sqlRowArray['pic_file_name'];
        $this->item['system']['type']   = 'image';
        $this->item['system']['name']   = $sqlRowArray['pic_file_name'];
        $this->item['system']['parent'] = $parentId;
        $this->item['system']['id']     = (int)$sqlRowArray['pic_id'];
        $this->item['system']['order']  = (int)$sqlRowArray['pic_order'];
        $this->item['system']['date']   = $sqlRowArray['pic_date_add'];
        $this->item['system']['owner']  = (int)$sqlRowArray['member_id'];
 
        if ($parentId) {
            $db = DI::getDefault()['db'];
 
            $row = $db->query('SELECT `pic_file_width`, `pic_file_height`, `pic_file_name`, `pic_file_title`
                               FROM `src_pic_images` WHERE `pic_id`='.$parentId)->fetch();
 
            $this->item['system']['prow'] = [
                'name'   => $row['pic_file_name'],
                'title'  => $row['pic_file_title'],
                'width'  => (int)$row['pic_file_width'],
                'height' => (int)$row['pic_file_height']
            ];
        }
 
 
        if (sizeof($access) == 5)
            $this->item['access'] = $access;
        else if ($access == 'self')
            $this->item['access'] = $this->getAccess('image');
    }
 
    public function configAsStack($sqlRowArray, $access = [], $urlPref = '/')
    {
        $title = $sqlRowArray['stack_title'] ? $sqlRowArray['stack_title'] : "Альбом ID: ".$sqlRowArray['stack_id'];
 
        $this->item['flags']['isStack'] = 1;
        $this->item['flags']['isContent']  = $sqlRowArray['stack_in_content'] ? 1 : 0;
 
        $this->item['meta']['title'] = $title;
        $this->item['meta']['numbs']['stacks'] = !$sqlRowArray['stack_stacks'] ? '' : (int)$sqlRowArray['stack_stacks'];
        $this->item['meta']['numbs']['images'] = !$sqlRowArray['stack_images'] ? '' : (int)$sqlRowArray['stack_images'];
 
        $this->item['system']['url']   = $urlPref.$sqlRowArray['stack_url'];
        $this->item['system']['type']  = 'album';
        $this->item['system']['name']  = $sqlRowArray['stack_url'];
        $this->item['system']['id']    = $sqlRowArray['stack_id'];
        $this->item['system']['order'] = $sqlRowArray['stack_order'];
        $this->item['system']['date']  = $sqlRowArray['stack_date_add'];
        $this->item['system']['owner'] = (int)$sqlRowArray['member_id'];
 
        if(!empty($sqlRowArray['pic_file_name'])) {
            $this->item['thumb']['name'] = $sqlRowArray['pic_file_name'].'_150x150';
            $this->item['thumb']['type'] = $sqlRowArray['pic_file_format'];
        }
 
        if (sizeof($access) == 5)
            $this->item['access'] = $access;
        else if ($access == 'self')
            $this->item['access'] = $this->getAccess('stack');
    }
 
    private function getAccess($type)
    {
        $user      = DI::getDefault()['user'];
        $db        = DI::getDefault()['db'];
 
        $type = $type == 'image' ? 'image' : 'stack';
        $id   = $this->item['system']['id'];
 
        $memberId  = $this->item['system']['owner'];
        $memberAge = $user->getAge();
        $isRoot    = $user->isRoot() || $user->hasRight('pic_root_access');
 
        $item = $db->query('SELECT * FROM `src_pic` WHERE `type`=\''.$type.'\' AND `id`='.$id)->fetch();
 
        $accesses =  [
            'enabled' => 0,
            'age'     => 0,
            'private' => 0,
            'direct'  => 0,
            'editing' => 0
        ];
 
        if ($memberId  && ($memberId == $user->getId() || $isRoot)) { // Либо хозяин, либо рут/модератор
            $accesses['editing'] = 1;
 
            if ($item['access_type'] == 'direct')
                $accesses['direct']  = 1;
            else if ($item['access_type'] == 'private')
                $accesses['private'] = 1;
 
            $accesses['age'] = (int)$item['access_age'];
 
        }
        else {
            if ($item['access_type'] == 'direct') {
                $accesses['enabled'] = 1;
                $accesses['direct']  = 1;
            }
            else if ($item['access_type'] == 'private') {
                $accesses['enabled'] = 1;
                $accesses['private'] = 1;
            }
 
            if ($memberAge < $item['access_age']) {
                $accesses['enabled'] = 1;
                $accesses['age']     = $item['access_age'];
            }
        }
 
        return $accesses;
    }
}
#1Core\Model\PicItem->configAsStack
/var/www/fullrest-team/data/www/fullrest.net/Core/Model/PicItem.php (96)
<?php
namespace Core\Model;
 
use Core\Dict\ContentType;
use Core\Lib\Pic;
use Imagick;
use Phalcon\Mvc\Model;
use Phalcon\Di\Di;
 
class PicItem extends Model {
    private $item = [
        'flags' => [
            'isIcon'    => 0,
            'isImage'   => 0,
            'isStack'   => 0,
            'isContent' => 0
        ],
        'setts' => [],
        'thumb' => [
            'name' => '',
            'type' => ''
        ],
        'meta' => [
            'title' => '',
            'numbs' => ['stacks' => '', 'images' => '', 'variations' => ''],
            'url'   => '',
            'file'  => [
                'width'  => 0,
                'height' => 0,
                'type'   => ''
            ]
        ],
        'system' => [
            'type'  => '', // image|album
            'name'  => '',
            'id'    => 0,  // Айди картинки или стэка
            'order' => 0
        ],
        'access' => [
            'enabled' => 0,
            'age'     => 0,
            'private' => 0,
            'direct'  => 0,
            'editing' => 0
        ]
 
    ];
 
    public static function initById($id, $type, $access = [], $isApp = false)
    {
        $db = DI::getDefault()['db'];
 
        if($type == 'stack') {
            $result = $db->query('
                SELECT `pis`.*, `pi`.`pic_file_name`, `pi`.`pic_file_format` FROM `src_pic_images_stacks` AS `pis`
                LEFT JOIN `src_pic_images` AS `pi` ON `pi`.`stack_id`=`pis`.`stack_id` AND `pi`.`pic_is_icon` = 1
                WHERE `pis`.`stack_id` = '.$id);
 
            return PicItem::initBySqlArray($result->fetch(), $access, $isApp);
        }
        else {
            $result = $db->query(
                '
                    SELECT 
                        `spi`.*, 
                        `svs`.`stat_views` AS `views_count`, 
                        `svs`.`stat_unics` AS `views_unic` 
                    FROM 
                        `src_pic_images` AS `spi`, 
                        `stc_view_stat` AS `svs` 
                    WHERE 
                        `spi`.`pic_id` = '.$id.' AND 
                        `svs`.type_id='.ContentType::PIC.' AND 
                        `svs`.`content_id`=`spi`.`pic_id`
                '
            );
 
            return PicItem::initBySqlArray($result->fetch(), $access, $isApp);
        }
    }
 
 
    public static function initBySqlArray($sqlRowArray, $access = [], $isApp = false)
    {
        $item = new PicItem();
 
        if ($isApp)
            $urlPref = '#pic/';
        else
            $urlPref = '/';
 
        if(!isset($sqlRowArray['stack_order'])) {
            $item->configAsImage($sqlRowArray, $access, $urlPref);
        }
        else {
            $item->configAsStack($sqlRowArray, $access, $urlPref);
        }
 
        return $item;
    }
 
    public function onConstruct()
    {
        $user =  DI::getDefault()['user'];
 
        $this->item['setts'] = [
            'isDem'   => (int)$user->getSetting('pic', 'show_img_dem'),
            'isType'  => (int)$user->getSetting('pic', 'show_img_type'),
            'isStat'  => (int)$user->getSetting('pic', 'show_alb_stat')
        ];
    }
 
    public function getData()
    {
        return $this->item;
    }
 
 
    public function configAsImage($sqlRowArray, $access = [], $urlPref = '/')
    {
        $parentId   = (int)$sqlRowArray['parent_id'];
        $variations = !$sqlRowArray['pic_variations'] ? '' : (int)$sqlRowArray['pic_variations'];
 
        $this->item['flags']['isImage'] = 1;
        $this->item['flags']['isIcon']  = (int)$sqlRowArray['pic_is_icon'];
        $this->item['flags']['isContent']  = $sqlRowArray['pic_in_content'] ? 1 : 0;
 
        $this->item['thumb']['name'] = $sqlRowArray['pic_file_name'].'_150x150';
        $this->item['thumb']['type'] = $sqlRowArray['pic_file_format'];
 
        $this->item['meta']['title'] = $sqlRowArray['pic_file_title'];
        $this->item['meta']['descr'] = $sqlRowArray['pic_description'];
 
        $this->item['meta']['numbs']['variations'] = (int)$variations;
 
        $this->item['meta']['file']['width']  = $sqlRowArray['pic_file_width'];
        $this->item['meta']['file']['height'] = $sqlRowArray['pic_file_height'];
        $this->item['meta']['file']['type']   = $sqlRowArray['pic_file_format'];
        $this->item['meta']['file']['size']   = $sqlRowArray['pic_file_size'];
 
        if (isset($sqlRowArray['views_count'])) {
            $this->item['meta']['views']['count'] = $sqlRowArray['views_count'];
            $this->item['meta']['views']['unic']  = $sqlRowArray['views_unic'];
        }
 
 
        $this->item['system']['url']    = $urlPref.$sqlRowArray['pic_file_name'];
        $this->item['system']['type']   = 'image';
        $this->item['system']['name']   = $sqlRowArray['pic_file_name'];
        $this->item['system']['parent'] = $parentId;
        $this->item['system']['id']     = (int)$sqlRowArray['pic_id'];
        $this->item['system']['order']  = (int)$sqlRowArray['pic_order'];
        $this->item['system']['date']   = $sqlRowArray['pic_date_add'];
        $this->item['system']['owner']  = (int)$sqlRowArray['member_id'];
 
        if ($parentId) {
            $db = DI::getDefault()['db'];
 
            $row = $db->query('SELECT `pic_file_width`, `pic_file_height`, `pic_file_name`, `pic_file_title`
                               FROM `src_pic_images` WHERE `pic_id`='.$parentId)->fetch();
 
            $this->item['system']['prow'] = [
                'name'   => $row['pic_file_name'],
                'title'  => $row['pic_file_title'],
                'width'  => (int)$row['pic_file_width'],
                'height' => (int)$row['pic_file_height']
            ];
        }
 
 
        if (sizeof($access) == 5)
            $this->item['access'] = $access;
        else if ($access == 'self')
            $this->item['access'] = $this->getAccess('image');
    }
 
    public function configAsStack($sqlRowArray, $access = [], $urlPref = '/')
    {
        $title = $sqlRowArray['stack_title'] ? $sqlRowArray['stack_title'] : "Альбом ID: ".$sqlRowArray['stack_id'];
 
        $this->item['flags']['isStack'] = 1;
        $this->item['flags']['isContent']  = $sqlRowArray['stack_in_content'] ? 1 : 0;
 
        $this->item['meta']['title'] = $title;
        $this->item['meta']['numbs']['stacks'] = !$sqlRowArray['stack_stacks'] ? '' : (int)$sqlRowArray['stack_stacks'];
        $this->item['meta']['numbs']['images'] = !$sqlRowArray['stack_images'] ? '' : (int)$sqlRowArray['stack_images'];
 
        $this->item['system']['url']   = $urlPref.$sqlRowArray['stack_url'];
        $this->item['system']['type']  = 'album';
        $this->item['system']['name']  = $sqlRowArray['stack_url'];
        $this->item['system']['id']    = $sqlRowArray['stack_id'];
        $this->item['system']['order'] = $sqlRowArray['stack_order'];
        $this->item['system']['date']  = $sqlRowArray['stack_date_add'];
        $this->item['system']['owner'] = (int)$sqlRowArray['member_id'];
 
        if(!empty($sqlRowArray['pic_file_name'])) {
            $this->item['thumb']['name'] = $sqlRowArray['pic_file_name'].'_150x150';
            $this->item['thumb']['type'] = $sqlRowArray['pic_file_format'];
        }
 
        if (sizeof($access) == 5)
            $this->item['access'] = $access;
        else if ($access == 'self')
            $this->item['access'] = $this->getAccess('stack');
    }
 
    private function getAccess($type)
    {
        $user      = DI::getDefault()['user'];
        $db        = DI::getDefault()['db'];
 
        $type = $type == 'image' ? 'image' : 'stack';
        $id   = $this->item['system']['id'];
 
        $memberId  = $this->item['system']['owner'];
        $memberAge = $user->getAge();
        $isRoot    = $user->isRoot() || $user->hasRight('pic_root_access');
 
        $item = $db->query('SELECT * FROM `src_pic` WHERE `type`=\''.$type.'\' AND `id`='.$id)->fetch();
 
        $accesses =  [
            'enabled' => 0,
            'age'     => 0,
            'private' => 0,
            'direct'  => 0,
            'editing' => 0
        ];
 
        if ($memberId  && ($memberId == $user->getId() || $isRoot)) { // Либо хозяин, либо рут/модератор
            $accesses['editing'] = 1;
 
            if ($item['access_type'] == 'direct')
                $accesses['direct']  = 1;
            else if ($item['access_type'] == 'private')
                $accesses['private'] = 1;
 
            $accesses['age'] = (int)$item['access_age'];
 
        }
        else {
            if ($item['access_type'] == 'direct') {
                $accesses['enabled'] = 1;
                $accesses['direct']  = 1;
            }
            else if ($item['access_type'] == 'private') {
                $accesses['enabled'] = 1;
                $accesses['private'] = 1;
            }
 
            if ($memberAge < $item['access_age']) {
                $accesses['enabled'] = 1;
                $accesses['age']     = $item['access_age'];
            }
        }
 
        return $accesses;
    }
}
#2Core\Model\PicItem::initBySqlArray
/var/www/fullrest-team/data/www/fullrest.net/Core/Model/PicItem.php (59)
<?php
namespace Core\Model;
 
use Core\Dict\ContentType;
use Core\Lib\Pic;
use Imagick;
use Phalcon\Mvc\Model;
use Phalcon\Di\Di;
 
class PicItem extends Model {
    private $item = [
        'flags' => [
            'isIcon'    => 0,
            'isImage'   => 0,
            'isStack'   => 0,
            'isContent' => 0
        ],
        'setts' => [],
        'thumb' => [
            'name' => '',
            'type' => ''
        ],
        'meta' => [
            'title' => '',
            'numbs' => ['stacks' => '', 'images' => '', 'variations' => ''],
            'url'   => '',
            'file'  => [
                'width'  => 0,
                'height' => 0,
                'type'   => ''
            ]
        ],
        'system' => [
            'type'  => '', // image|album
            'name'  => '',
            'id'    => 0,  // Айди картинки или стэка
            'order' => 0
        ],
        'access' => [
            'enabled' => 0,
            'age'     => 0,
            'private' => 0,
            'direct'  => 0,
            'editing' => 0
        ]
 
    ];
 
    public static function initById($id, $type, $access = [], $isApp = false)
    {
        $db = DI::getDefault()['db'];
 
        if($type == 'stack') {
            $result = $db->query('
                SELECT `pis`.*, `pi`.`pic_file_name`, `pi`.`pic_file_format` FROM `src_pic_images_stacks` AS `pis`
                LEFT JOIN `src_pic_images` AS `pi` ON `pi`.`stack_id`=`pis`.`stack_id` AND `pi`.`pic_is_icon` = 1
                WHERE `pis`.`stack_id` = '.$id);
 
            return PicItem::initBySqlArray($result->fetch(), $access, $isApp);
        }
        else {
            $result = $db->query(
                '
                    SELECT 
                        `spi`.*, 
                        `svs`.`stat_views` AS `views_count`, 
                        `svs`.`stat_unics` AS `views_unic` 
                    FROM 
                        `src_pic_images` AS `spi`, 
                        `stc_view_stat` AS `svs` 
                    WHERE 
                        `spi`.`pic_id` = '.$id.' AND 
                        `svs`.type_id='.ContentType::PIC.' AND 
                        `svs`.`content_id`=`spi`.`pic_id`
                '
            );
 
            return PicItem::initBySqlArray($result->fetch(), $access, $isApp);
        }
    }
 
 
    public static function initBySqlArray($sqlRowArray, $access = [], $isApp = false)
    {
        $item = new PicItem();
 
        if ($isApp)
            $urlPref = '#pic/';
        else
            $urlPref = '/';
 
        if(!isset($sqlRowArray['stack_order'])) {
            $item->configAsImage($sqlRowArray, $access, $urlPref);
        }
        else {
            $item->configAsStack($sqlRowArray, $access, $urlPref);
        }
 
        return $item;
    }
 
    public function onConstruct()
    {
        $user =  DI::getDefault()['user'];
 
        $this->item['setts'] = [
            'isDem'   => (int)$user->getSetting('pic', 'show_img_dem'),
            'isType'  => (int)$user->getSetting('pic', 'show_img_type'),
            'isStat'  => (int)$user->getSetting('pic', 'show_alb_stat')
        ];
    }
 
    public function getData()
    {
        return $this->item;
    }
 
 
    public function configAsImage($sqlRowArray, $access = [], $urlPref = '/')
    {
        $parentId   = (int)$sqlRowArray['parent_id'];
        $variations = !$sqlRowArray['pic_variations'] ? '' : (int)$sqlRowArray['pic_variations'];
 
        $this->item['flags']['isImage'] = 1;
        $this->item['flags']['isIcon']  = (int)$sqlRowArray['pic_is_icon'];
        $this->item['flags']['isContent']  = $sqlRowArray['pic_in_content'] ? 1 : 0;
 
        $this->item['thumb']['name'] = $sqlRowArray['pic_file_name'].'_150x150';
        $this->item['thumb']['type'] = $sqlRowArray['pic_file_format'];
 
        $this->item['meta']['title'] = $sqlRowArray['pic_file_title'];
        $this->item['meta']['descr'] = $sqlRowArray['pic_description'];
 
        $this->item['meta']['numbs']['variations'] = (int)$variations;
 
        $this->item['meta']['file']['width']  = $sqlRowArray['pic_file_width'];
        $this->item['meta']['file']['height'] = $sqlRowArray['pic_file_height'];
        $this->item['meta']['file']['type']   = $sqlRowArray['pic_file_format'];
        $this->item['meta']['file']['size']   = $sqlRowArray['pic_file_size'];
 
        if (isset($sqlRowArray['views_count'])) {
            $this->item['meta']['views']['count'] = $sqlRowArray['views_count'];
            $this->item['meta']['views']['unic']  = $sqlRowArray['views_unic'];
        }
 
 
        $this->item['system']['url']    = $urlPref.$sqlRowArray['pic_file_name'];
        $this->item['system']['type']   = 'image';
        $this->item['system']['name']   = $sqlRowArray['pic_file_name'];
        $this->item['system']['parent'] = $parentId;
        $this->item['system']['id']     = (int)$sqlRowArray['pic_id'];
        $this->item['system']['order']  = (int)$sqlRowArray['pic_order'];
        $this->item['system']['date']   = $sqlRowArray['pic_date_add'];
        $this->item['system']['owner']  = (int)$sqlRowArray['member_id'];
 
        if ($parentId) {
            $db = DI::getDefault()['db'];
 
            $row = $db->query('SELECT `pic_file_width`, `pic_file_height`, `pic_file_name`, `pic_file_title`
                               FROM `src_pic_images` WHERE `pic_id`='.$parentId)->fetch();
 
            $this->item['system']['prow'] = [
                'name'   => $row['pic_file_name'],
                'title'  => $row['pic_file_title'],
                'width'  => (int)$row['pic_file_width'],
                'height' => (int)$row['pic_file_height']
            ];
        }
 
 
        if (sizeof($access) == 5)
            $this->item['access'] = $access;
        else if ($access == 'self')
            $this->item['access'] = $this->getAccess('image');
    }
 
    public function configAsStack($sqlRowArray, $access = [], $urlPref = '/')
    {
        $title = $sqlRowArray['stack_title'] ? $sqlRowArray['stack_title'] : "Альбом ID: ".$sqlRowArray['stack_id'];
 
        $this->item['flags']['isStack'] = 1;
        $this->item['flags']['isContent']  = $sqlRowArray['stack_in_content'] ? 1 : 0;
 
        $this->item['meta']['title'] = $title;
        $this->item['meta']['numbs']['stacks'] = !$sqlRowArray['stack_stacks'] ? '' : (int)$sqlRowArray['stack_stacks'];
        $this->item['meta']['numbs']['images'] = !$sqlRowArray['stack_images'] ? '' : (int)$sqlRowArray['stack_images'];
 
        $this->item['system']['url']   = $urlPref.$sqlRowArray['stack_url'];
        $this->item['system']['type']  = 'album';
        $this->item['system']['name']  = $sqlRowArray['stack_url'];
        $this->item['system']['id']    = $sqlRowArray['stack_id'];
        $this->item['system']['order'] = $sqlRowArray['stack_order'];
        $this->item['system']['date']  = $sqlRowArray['stack_date_add'];
        $this->item['system']['owner'] = (int)$sqlRowArray['member_id'];
 
        if(!empty($sqlRowArray['pic_file_name'])) {
            $this->item['thumb']['name'] = $sqlRowArray['pic_file_name'].'_150x150';
            $this->item['thumb']['type'] = $sqlRowArray['pic_file_format'];
        }
 
        if (sizeof($access) == 5)
            $this->item['access'] = $access;
        else if ($access == 'self')
            $this->item['access'] = $this->getAccess('stack');
    }
 
    private function getAccess($type)
    {
        $user      = DI::getDefault()['user'];
        $db        = DI::getDefault()['db'];
 
        $type = $type == 'image' ? 'image' : 'stack';
        $id   = $this->item['system']['id'];
 
        $memberId  = $this->item['system']['owner'];
        $memberAge = $user->getAge();
        $isRoot    = $user->isRoot() || $user->hasRight('pic_root_access');
 
        $item = $db->query('SELECT * FROM `src_pic` WHERE `type`=\''.$type.'\' AND `id`='.$id)->fetch();
 
        $accesses =  [
            'enabled' => 0,
            'age'     => 0,
            'private' => 0,
            'direct'  => 0,
            'editing' => 0
        ];
 
        if ($memberId  && ($memberId == $user->getId() || $isRoot)) { // Либо хозяин, либо рут/модератор
            $accesses['editing'] = 1;
 
            if ($item['access_type'] == 'direct')
                $accesses['direct']  = 1;
            else if ($item['access_type'] == 'private')
                $accesses['private'] = 1;
 
            $accesses['age'] = (int)$item['access_age'];
 
        }
        else {
            if ($item['access_type'] == 'direct') {
                $accesses['enabled'] = 1;
                $accesses['direct']  = 1;
            }
            else if ($item['access_type'] == 'private') {
                $accesses['enabled'] = 1;
                $accesses['private'] = 1;
            }
 
            if ($memberAge < $item['access_age']) {
                $accesses['enabled'] = 1;
                $accesses['age']     = $item['access_age'];
            }
        }
 
        return $accesses;
    }
}
#3Core\Model\PicItem::initById
/var/www/fullrest-team/data/www/fullrest.net/Core/Modules/Pic/Controller/StackController.php (543)
<?
namespace Core\Modules\Pic\Controller;
use Core\Lib\JSONResponse;
use Core\Lib\Pic;
use Core\Lib\UserHandler;
use Core\Model\Image;
use Core\Model\Stack;
use Core\Model\PicItem;
use Phalcon;
use Phalcon\Mvc\Controller;
use DateTime;
 
/**
 *
 *
 * @property \Phalcon\Db\Adapter\Pdo\Mysql db
 * @property UserHandler user
 */
class StackController extends Controller
{
    private $isApp = true;
 
    public function initialize()
    {
        $siteId = $this->hostname->getSiteId();
 
        if ($siteId == 2)
            $this->isApp = false;
        else
            $this->isApp = true;
 
        return $this;
    }
 
 
  public function getAction($memberId, $stackId, $page, $contentOnly = 'false', $albumsOnly = 'false')
  {
        $memberId = (int)$memberId;
        $stackId  = (int)$stackId;
 
        $itemList = $this->getItemsList($memberId, $stackId, $this->getPages($page), $contentOnly, $albumsOnly);
 
        (new JSONResponse(JSONResponse::SUCCESS))->send($itemList);
  }
 
    /**
     * @param string $mode Значения могут быть before/after - определяет тип выборки: обратная или прямая, относительно
     *                     параметра сортировки.
     * @param string $itemType Значения могут быть stack/image определяет типа объекта, к которому привязывается выборка
     * @param integer $itemId  Идентификатор объекта, для которого делается выборка
     * @param integer $stackId Идентификатор стэка/альбома
     * @param integer $memberId Идентификатор ВЛАДЕЛЬЦА объектов
     * @param integer $num Количестко объектов для выборка
     * @param string $contentOnly
     */
    public function getItemsListAction($mode, $itemType, $itemId, $stackId, $memberId, $num, $contentOnly = 'false')
    {
        $itemType = ($itemType == 'album' || $itemType == 'stack') ? 'stack' : 'image';
        $itemId   = (int)$itemId;
        $memberId = (int)$memberId;
        $stackId  = (int)$stackId;
        $num      = (int)$num;
        $db = $this->db;
 
        if($stackId > 0)
            $sqlPart = ' `stack_id` = '.$stackId;
        else if($memberId > 0 && $stackId == 0)
            $sqlPart = ' `stack_id` = 0 AND `member_id` = '.$memberId;
 
        if($mode == 'before') {
            $sign  = '>';
            $order = ' ORDER BY `sort` ASC ';
        }
        else {
            $sign  = '<';
            $order = ' ORDER BY `sort` DESC ';
        }
 
 
 
        $sqlQuery = '
            SELECT * FROM (SELECT * FROM `src_pic`
            WHERE
                 `sort` '.$sign.' (SELECT `pc`.`sort` FROM `src_pic` AS `pc`
                                   WHERE `type`=\''.$itemType.'\' AND `pc`.`id`='.$itemId.')
 
                  AND '.$sqlPart.' AND `deleted`=0 '.$order.' LIMIT 0, '.$num.') AS `ss`
            ORDER BY `ss`.`sort` DESC';
 
 
 
        (new JSONResponse(JSONResponse::SUCCESS))->send($this->selectItems($db->query($sqlQuery)));
    }
 
    public function resetIconAction($stackName) {
        $stack = Stack::intByName($stackName);
        $stack->setDefaultIcon(true);
 
        (new JSONResponse(JSONResponse::SUCCESS))->send(PicItem::initById($stack->getId(), 'stack')->getData());
    }
 
    public function setIconAction($stackName, $imageId) {
        $stack = Stack::intByName($stackName);
        $stack->setIcon($imageId);
 
        (new JSONResponse(JSONResponse::SUCCESS))->send();
    }
 
    private $deleting = [
        'deleted'   => 0,
        'prevented' => 0
    ];
 
    public function deleteListAction($stackId = 0)
    {
 
        //TODO: проверка на права юзеров
 
        $stackId = (int)$stackId;
        $memberId = $this->user->getId();
        $deleteList = json_decode($this->request->getPost('list'), true);
 
        $len = sizeof($deleteList);
 
        if(!$len)
            (new JSONResponse(JSONResponse::SUCCESS))->send($this->deleting);
 
        for($a = 0; $a < $len; $a++) {
            $item = $deleteList[$a];
 
 
            if($item['type'] == 'album')
                $this->deleteStack((int)$item['id']);
            else
                $this->deleteImage((int)$item['id']);
        }
 
        Pic::recalcStack($stackId, $memberId);
        Pic::resortStack($stackId, $memberId);
 
        if ($stackId) {
            $stack = Stack::intById($stackId);
            $stack->setDefaultIcon(false);
        }
 
        (new JSONResponse(JSONResponse::SUCCESS))->send($this->deleting);
    }
 
    public function deleteAction($stackId = 0)
    {
 
        //TODO: проверка на права юзеров
 
        $memberId = $this->user->getId();
        $stackId  = (int)$stackId;
        $id       = (int)$this->request->getPost('id');
        $type     = $this->request->getPost('type');
 
        if($type == 'album')
            $this->deleteStack($id);
        else
            $this->deleteImage($id);
 
 
        Pic::recalcStack($stackId, $memberId);
        Pic::resortStack($stackId, $memberId);
    }
 
    public function restoreListAction()
    {
        $memberId = $this->user->getId();
        $deleteList = json_decode($this->request->getPost('list'), true);
 
        $len = sizeof($deleteList);
 
        if(!$len)
            return false;
 
        for($a = 0; $a < $len; $a++) {
            $item = $deleteList[$a];
 
 
            if($item['type'] == 'album')
                $this->restoreStack((int)$item['id']);
            else
                $this->restoreImage((int)$item['id']);
        }
 
        Pic::recalcStack(0, $memberId);
        Pic::resortStack(0, $memberId);
    }
 
    public function addAction($parentStackId, $order = 0)
    {
 
        //TODO: проверка на права юзеров
 
        $parentStackId = (int)$parentStackId;
        $memberId = $this->user->getId();
        $stackMId = $this->user->getId();
 
        if(!$memberId)
            return false;
 
        if(!$order)
            $order = Pic::getNextSortPos($memberId, $parentStackId);
 
        if($parentStackId) {
            $result = $this->db->query('SELECT * FROM `src_pic_images_stacks` WHERE stack_id = '.$parentStackId);
 
            if ($row = $result->fetch())
                $stackMId  = $row['member_id'];
 
        }
 
        $returned = Stack::add($this->user->getId(), $stackMId, $parentStackId, 0, true);
 
        (new JSONResponse(JSONResponse::SUCCESS))->send(PicItem::initById($returned->getId(), 'stack', 'self')->getData());
    }
 
 
    private function createStack($parentStackId, $order = 0)
    {
 
        //TODO: проверка на права юзеров
 
        $parentStackId = (int)$parentStackId;
        $memberId = $this->user->getId();
 
        if(!$memberId)
            return false;
 
        if(!$order)
            $order = Pic::getNextSortPos($memberId, $parentStackId);
 
        $name = Pic::createNameStack();
 
        $insertSql = 'INSERT INTO `src_pic_images_stacks` (`member_id`, `stack_parent_id`, `stack_order`, `stack_url`)
                      VALUES ('.$memberId.', '.$parentStackId.', '.$order.', \''.$name.'\')';
 
 
        $this->db->query($insertSql);
 
        $sql = 'SELECT * FROM `src_pic_images_stacks` WHERE `stack_url` = \''.$name.'\'';
 
        $picItem = PicItem::initBySqlArray($this->db->query($sql)->fetch());
 
        return $name;
    }
 
 
    public function getAlbumTreeAction($stackId = 0)
    {
        $memberId = $this->user->getId();
 
        $sql = '
        SELECT `pis`.`stack_in_content` AS `isContent`, `p`.`stack_id`    AS `parent_id`, `pis`.`stack_id` AS `stack_id`,
                `pis`.`stack_images`    AS `images`, `pis`.`stack_stacks` AS `stacks`, `pis`.`stack_url`   AS `url`,
                `pis`.`stack_title`     AS `title`
        FROM `src_pic` As `p`, `src_pic_images_stacks` AS `pis`
        WHERE 
          `p`.`type`=\'stack\' AND 
          `p`.`deleted`=0 AND 
          `p`.`member_id`='.$memberId.' AND 
          `pis`.`stack_id`=`p`.`id` AND
          `p`.`stack_id`='.(int)$stackId.'
        ORDER BY `p`.`sort` DESC';
 
        $result = $this->db->query($sql);
        $stackList = [];
 
        while($row = $result->fetch()) {
            $stackList[$row['parent_id']][] = $row;
        }
 
        (new JSONResponse(JSONResponse::SUCCESS))->send($stackList);
    }
 
 
 
    public function setTitleAction($stackId)
    {
 
        //TODO: проверка на права юзеров
 
        $title = htmlspecialchars($this->request->getPost('title'));
 
        $setTitle = 'UPDATE `src_pic_images_stacks` SET `stack_title`= ? WHERE `stack_id`= ? AND `member_id` = '.$this->user->getId();
 
        $this->db->execute($setTitle, [$title, $stackId]);
    }
 
    public function reorderAction($memberId, $stackId)
    {
 
        //TODO: проверка на права юзеров
 
        $memberId = (int)$memberId;
        $stackId  = (int)$stackId;
 
        $orderList = json_decode($this->request->getPost('order'), true);
 
 
        $updImage = 'UPDATE `src_pic_images` SET `pic_order`= ? WHERE `member_id` = ? AND `stack_id`= ? AND `pic_id`= ?';
        $updStack = 'UPDATE `src_pic_images_stacks` SET `stack_order`= ? WHERE `member_id` = ? AND `stack_parent_id`= ? AND `stack_id`= ?';
 
        foreach($orderList as $i => $v) {
            if($v['type'] != 'image')
                $this->db->execute($updStack, [$v['order'], $memberId, $stackId, $v['id']]);
            else
                $this->db->execute($updImage, [$v['order'], $memberId, $stackId, $v['id']]);
        }
 
        Pic::recalcStack($stackId, $memberId);
 
        (new JSONResponse(JSONResponse::SUCCESS))->send();
    }
 
    public function moveItemsAction($moveType, $moveIdTo, $stackIdFrom)
    {
 
        //TODO: проверка на права юзеров
 
        $moveIdTo    = (int)$moveIdTo;
        $stackIdFrom = (int)$stackIdFrom;
        $moveType    = $moveType == 'stack' ? 'stack' : 'image';
 
        $moveList = json_decode($this->request->getPost('list'), true);
        $moveLen  = sizeof($moveList);
        $memberId = $this->user->getId();
        $picStack = '';
        $stackName = '';
 
        if(!$moveLen)
            return false;
 
        if($moveType == 'image') {
            $result = $this->db->query('SELECT `pic_order`, `pic_file_name` FROM `src_pic_images` WHERE `pic_id` = '.$moveIdTo);
 
            $row = $result->fetch();
 
            $result = $this->db->query('SELECT * FROM `src_pic_images_stacks` WHERE stack_id = '.$stackIdFrom);
 
            if ($row2 = $result->fetch())
                $stackMId  = $row2['member_id'];
            else
                $stackMId = 0;
 
            $picStack = Stack::add($memberId, $stackMId, $stackIdFrom, $row['pic_order']);
 
            $moveIdTo = $picStack->getId();
            $moveList[] = $row['pic_file_name'];
 
 
            $moveLen  = sizeof($moveList);
        }
        else {
            if ($moveIdTo == 0) {
                $stackName = 'root';
            }
            else {
                $picStack = Stack::intById($moveIdTo);
 
                $stackName = $picStack->getUrl();
            }
 
 
        }
 
        $order = Pic::getNextSortPos($memberId, $moveIdTo);
 
        $updImage = 'UPDATE `src_pic_images`        SET `pic_order`   = ?, `stack_id`= ?        WHERE `member_id` = ? AND `stack_id`= ?        AND `pic_file_name`= ?';
        $updStack = 'UPDATE `src_pic_images_stacks` SET `stack_order` = ?, `stack_parent_id`= ? WHERE `member_id` = ? AND `stack_parent_id`= ? AND `stack_url`= ?';
 
        for($a = 0; $a < $moveLen; $a++) {
            $name = htmlspecialchars($moveList[$a]);
 
            if($name != $stackName)
                $this->db->execute($updStack, [$order+$a, $moveIdTo, $memberId, $stackIdFrom, $name]);
 
            $this->db->execute($updImage, [$order+$a, $moveIdTo, $memberId, $stackIdFrom, $name]);
        }
 
        Pic::resortStack($moveIdTo, $memberId);
        Pic::recalcStack($moveIdTo, $memberId);
 
        Pic::resortStack($stackIdFrom, $memberId);
        Pic::recalcStack($stackIdFrom, $memberId);
 
        if ($moveIdTo) {
            Stack::intById($moveIdTo)->setDefaultIcon(false);
        }
 
        if ($stackIdFrom) {
            Stack::intById($stackIdFrom)->setDefaultIcon(false);
        }
 
 
        if ($stackName != 'root') {
            $picStack->setDefaultIcon();
 
 
 
 
            (new JSONResponse(JSONResponse::SUCCESS))->send(PicItem::initById($picStack->getId(), 'stack', 'self', $this->isApp)->getData());
        }
        else {
            (new JSONResponse(JSONResponse::SUCCESS))->send();
        }
    }
 
    public function getNameAction($name, $contentOnly = 'false', $albumsOnly = 'false')
    {
        (new JSONResponse(JSONResponse::SUCCESS))->send($this->getName($name, $contentOnly, $albumsOnly));
    }
 
    public function getName($name, $contentOnly = 'false', $albumsOnly = 'false')
    {
        if(!$name)
            $name = '';
 
        $return = [
            'id'        => 0,
            'name'      => $name,
            'owner'     => $this->user->getId(),
            'parent'    => '',
            'parent_id' => 0,
            'items'     => 0,
            'title'     => '',
            'pages'     => 0,
            'editable'  => 0
        ];
 
        if($name != 'root' && $name != 'trash') {
            $result = $this->db->query('SELECT * FROM `src_pic_images_stacks` WHERE `stack_url` = \''.$name.'\'');
 
            $row = $result->fetch();
 
            if ($albumsOnly == "true") {
                $row['stack_images'] = 0;
            }
 
            $return['owner']     = $row['member_id'];
            $return['id']        = $row['stack_id'];
            $return['title']     = $row['stack_title'] ? $row['stack_title'] : 'Альбом ID: '.$return['id'];
            $return['items']     = $row['stack_images'] + $row['stack_stacks'];
            $return['pages']     = ceil(($return['items']) / 30);
            $return['parent_id'] = $row['stack_parent_id'];
 
            if($row['stack_parent_id']) {
                $result = $this->db->query('SELECT * FROM `src_pic_images_stacks` WHERE `stack_id` = '.$row['stack_parent_id']);
 
                $row = $result->fetch();
 
                $return['owner']  = $row['member_id'];
                $return['parent'] = $row['stack_url'];
            }
        }
        else if($name == 'trash') {
            $result = $this->db->query('
                SELECT COUNT(*) AS `count` FROM (
                    SELECT `p1`.* FROM `src_pic` AS `p1`
                    WHERE  `p1`.`deleted`=1 AND `p1`.`deleted_date` BETWEEN DATE_SUB(NOW(), INTERVAL 30 DAY) AND NOW()
                            AND `p1`.`member_id`='.$this->user->getId().' AND `p1`.`stack_id`=0
                  UNION
                    SELECT `p1`.* FROM `src_pic` AS `p1`, `src_pic` AS `p2`
                    WHERE  `p1`.`deleted`=1 AND `p1`.`deleted_date` BETWEEN DATE_SUB(NOW(), INTERVAL 30 DAY) AND NOW()
                            AND `p1`.`member_id`='.$this->user->getId().'
                            AND `p1`.`stack_id`=`p2`.`id` AND `p2`.`deleted`=0 AND `p2`.`type`=\'stack\'
                ) AS `res`'
            );
 
            $row = $result->fetch();
 
            $return['items'] = $row['count'];
            $return['pages'] = ceil($row['count'] / 30);
            $return['id']    = -1;
 
 
 
            $return['title'] = 'Удаленный контент';
 
            $contentOnly = 'false';
            $albumsOnly  = 'false';
        }
        else {
            $result = $this->db->query('SELECT * FROM `src_pic_statistics` WHERE `member_id` = '.$this->user->getId());
 
            $row = $result->fetch();
 
            if ($albumsOnly == "true") {
                $row['root_images'] = 0;
            }
 
            $return['items'] = $row['root_images'] + $row['root_stacks'];
            $return['pages'] = ceil(($row['root_images'] + $row['root_stacks']) / 30);
        }
 
 
        if ($contentOnly == 'true') {
            if ($return['id'] > 0) { // данные по конкретному альбому
                $sqlPart = ' `p1`.`stack_id` = '.$return['id'];
            }
            else if ($return['owner'] > 0 && $return['id'] == 0) { // данные по корневому каталогу юзера
                $sqlPart = ' `p1`.`stack_id` = 0 AND `p1`.`member_id` = '.$return['owner'];
            }
 
 
            $sqlText = 'SELECT COUNT(*) AS `count` FROM (';
 
            if ($albumsOnly == "false") {
                $sqlText .= '
              SELECT `p1`.* FROM `src_pic` AS `p1`, `src_pic_images` AS `pi`
                    WHERE  '.$sqlPart.' AND `p1`.`type`=\'image\' AND `pi`.`pic_id`=`p1`.id AND `pi`.`pic_in_content`=1
                  UNION';
            }
 
            $sqlText .= '
                    SELECT `p1`.* FROM `src_pic` AS `p1`, `src_pic_images_stacks` AS `pis`
                    WHERE  '.$sqlPart.' AND `p1`.`type`=\'stack\' AND `pis`.`stack_id`=`p1`.id
                                        AND `pis`.`stack_in_content`=1';
 
            $sqlText .= ') AS `res`';
 
 
            $row = $this->db->query($sqlText)->fetch();
 
            $return['items'] = $row['count'];
            $return['pages'] = ceil($row['count'] / 30);
        }
 
        $isRoot    = $this->user->isRoot() || $this->user->hasRight('pic_root_access');
 
        $return['editable'] = ($return['owner'] && ($return['owner'] == $this->user->getid() || $isRoot)) ? 1 : 0;
 
        //TODO: вот эту упоротость с проверкой доступ надо переделать
        if ($return['name'] != 'root') {
            if (!$return['editable']) {
                if ($name == 'trash' && $this->user->isGuest()) {
                    return ['restricted' => ['code' => 'guest', 'data' => '']];
                }
                else if ($return['id']) {
                    $data = PicItem::initById($return['id'], 'stack', 'self', $this->isApp)->getData();
 
                    if ($data['access']['enabled']) {
 
                        if ($data['access']['private']) {
                            return ['restricted' => ['code' => 'private', 'data' => '']];
                        }
                        else if ($data['access']['age']) {
                            return ['restricted' => ['code' => 'age', 'data' => $data['access']['age']]];
                        }
                    }
                }
            }
 
            if (!$return['id']) {
                return ['restricted' => ['code' => 'missing', 'data' => '']];
 
            }
        }
        //TODO: END//
 
        return $return;
    }
 
    public function getItemDataAction($name)
    {
        if(!$name)
            (new JSONResponse(JSONResponse::SUCCESS))->send(['status' => 'not_exists']);
 
        $res = $this->db->query('SELECT * FROM `src_pic_images_stacks` WHERE `stack_url` = \''.$name.'\'')->fetch();
 
        if(!$res)
            (new JSONResponse(JSONResponse::SUCCESS))->send(['status' => 'not_exists']);
 
        (new JSONResponse(JSONResponse::SUCCESS))->send(PicItem::initBySqlArray($res)->getData());
    }
 
 
    private function deleteStack($stackId)
    {
 
        //TODO: проверка на права юзеров
 
        $memberId = $this->user->getId();
        $stackId  = (int)$stackId;
        $status   = false;
        $status2  = false;
 
        $delItem = 'UPDATE `src_pic` SET `deleted`=1, `deleted_date`=NOW() WHERE `type` = ? AND `id`= ? AND `member_id`= ?';
 
        $images = $this->db->query(
            'SELECT `pi`.`pic_id` FROM `src_pic` AS `p`, `src_pic_images` AS `pi`
             WHERE  `p`.`type`=\'image\' AND `p`.`deleted`=0 AND `pi`.`stack_id`='.$stackId.' AND
                    `p`.`member_id`='.$memberId.' AND `pi`.`pic_id`=`p`.`id`');
 
        while($row = $images->fetch()) {
            $status2 = $this->deleteImage($row['pic_id']);
 
            if(!$status)
                $status = $status2;
        }
 
        $stacks = $this->db->query(
            'SELECT `pis`.`stack_in_content`, `pis`.`stack_id` FROM `src_pic` AS `p`, `src_pic_images_stacks` AS `pis`
             WHERE `p`.`type`=\'stack\' AND `p`.`deleted`=0 AND `pis`.`stack_parent_id`='.$stackId.' AND
                   `p`.`member_id`='.$memberId.' AND `pis`.`stack_id`=`p`.`id`');
 
        while($row = $stacks->fetch()) {
            $status2 = $this->deleteStack($row['stack_id']);
 
            if(!$status)
                $status = $status2;
        }
 
        if(!$status) {
            $this->db->execute($delItem, ['stack', $stackId, $memberId]);
            $this->deleting['deleted'] += 1;
        }
        else {
            $this->deleting['prevented'] += 1;
            $this->db->execute('UPDATE `src_pic_images_stacks` SET `stack_in_content`=1 WHERE `stack_id` = ?', [$stackId]);
        }
 
        Pic::resortStack($stackId, $memberId);
        Pic::recalcStack($stackId, $memberId);
 
        //$this->resortItems($stackId);
 
        return $status;
    }
 
    private function deleteImage($imageId)
    {
 
        //TODO: проверка на права юзеров
 
        $memberId = $this->user->getId();
 
        $delItem = 'UPDATE `src_pic` SET `deleted`=1, `deleted_date`=NOW() WHERE `type` = ? AND `id`= ? AND `member_id`= ?';
 
        $image = $this->db->query(
            'SELECT `pi`.`pic_in_content`, `pi`.`pic_id`, `pi`.`pic_is_icon`, `pi`.`stack_id` FROM `src_pic` AS `p`, `src_pic_images` AS `pi`
             WHERE  `p`.`type`=\'image\' AND `p`.`deleted`=0 AND `pi`.`pic_id`='.$imageId.' AND
                    `p`.`member_id`='.$memberId.' AND `pi`.`pic_id`=`p`.`id`');
 
        $row = $image->fetch();
 
        if($row) {
            if($row['pic_in_content']) {
                $this->deleting['prevented'] += 1;
 
                return true;
            }
 
            $this->db->execute($delItem, ['image', $row['pic_id'], $memberId]);
            $this->deleting['deleted'] += 1;
 
            if ($row['stack_id']) {
                $this->db->query(
                    'UPDATE `src_pic_images_stacks` SET `stack_icon_id`=0 WHERE `stack_id`='.$row['stack_id']
                );
            }
 
            $this->db->query('UPDATE `src_pic_images` SET `pic_is_icon`=0 WHERE `pic_id`='.$row['pic_id']);
        }
 
        return false;
    }
 
    private function restoreStack($stackId)
    {
 
        //TODO: проверка на права юзеров
 
        $memberId = $this->user->getId();
        $stackId  = (int)$stackId;
 
        $resItem = 'UPDATE `src_pic` SET `deleted`=0 WHERE `type` = ? AND `id`= ? AND `member_id`= ?';
 
        $images = $this->db->query(
            'SELECT `pi`.`pic_id` FROM `src_pic` AS `p`, `src_pic_images` AS `pi`
             WHERE  `p`.`type`=\'image\' AND `p`.`deleted`=1 AND `pi`.`stack_id`='.$stackId.' AND
                    `p`.`member_id`='.$memberId.' AND `pi`.`pic_id`=`p`.`id`');
 
        while($row = $images->fetch()) {
            $this->restoreImage($row['pic_id']);
        }
 
        $stacks = $this->db->query(
            'SELECT `pis`.`stack_in_content`, `pis`.`stack_id` FROM `src_pic` AS `p`, `src_pic_images_stacks` AS `pis`
             WHERE `p`.`type`=\'stack\' AND `p`.`deleted`=1 AND `pis`.`stack_parent_id`='.$stackId.' AND
                   `p`.`member_id`='.$memberId.' AND `pis`.`stack_id`=`p`.`id`');
 
 
        while($row = $stacks->fetch()) {
            $this->restoreStack($row['stack_id']);
        }
 
        $this->db->execute($resItem, ['stack', $stackId, $memberId]);
 
        $parent = $this->db->query('SELECT * FROM `src_pic` WHERE `type`=\'stack\' AND `id` = '.$stackId);
        $row    = $parent->fetch();
 
        if ($row) {
            Pic::resortStack($row['stack_id'], $memberId);
            Pic::recalcStack($row['stack_id'], $memberId);
        }
    }
 
 
    private function restoreImage($picId)
    {
 
        //TODO: проверка на права юзеров
 
        $memberId = $this->user->getId();
 
        $resItem = 'UPDATE `src_pic` SET `deleted`=0 WHERE `type` = ? AND `id`= ? AND `member_id`= ?';
 
        $this->db->execute($resItem, ['image', $picId, $memberId]);
 
        $parent = $this->db->query('SELECT * FROM `src_pic` WHERE `type`=\'image\' AND `id` = '.$picId);
        $row    = $parent->fetch();
 
        if ($row) {
            Pic::resortStack($row['stack_id'], $memberId);
            Pic::recalcStack($row['stack_id'], $memberId);
 
            if ($row['stack_id']) {
                $stack = Stack::intById($row['stack_id']);
                $stack->setDefaultIcon(false);
            }
        }
    }
 
    private function getPages($page)
    {
        if(strpos($page, '-')) { // мультистраничность
            $expl = explode('-', $page);
 
            $start = (int)$expl[0];
            $end   = (int)$expl[1];
 
            if($start <= 0)
                $start = 1;
 
            if($end <= 0)
                $end = 1;
 
            if($start > $end)
                $start = $end;
 
            $pages = ['start' => $start, 'end' => $end];
        }
        else { // указана 1 страница
            $page = (int)$page;
 
            $pages = ['start' => $page, 'end' => $page];
 
            if($page <= 0) {
                $pages = ['start' => 1, 'end' => 1];
            }
        }
 
        return $pages;
    }
 
    public function getItemsListByName($stackName, $pages)
    {
 
        $stack = $this->db->query('SELECT * FROM `src_pic_images_stacks` WHERE `stack_url`= \''.$stackName.'\'');
 
        $row = $stack->fetch();
 
        return $this->getItemsList($row['member_id'], $row['stack_id'], $pages);
 
    }
 
 
    public function getItemsList($memberId, $stackId, $pages, $contentOnly = 'false', $albumsOnly = 'false')
    {
        $db = $this->db;
 
        $sqlPart = '';
 
        $limitStep  = 30;
        $limitStart = abs((int)$pages['start'] - 1) * $limitStep;
        $limitEnd   = $limitStep + $limitStep * abs( $pages['end'] - $pages['start'] );
 
        if($stackId > 0) { // данные по конкретному альбому
            $sqlPart = ' `p1`.`stack_id` = '.$stackId;
        }
        else if($memberId > 0 && $stackId == 0) { // данные по корневому каталогу юзера
            $sqlPart = ' `p1`.`stack_id` = 0 AND `p1`.`member_id` = '.$memberId;
        }
 
        if($stackId < 0) {
            $sqlQuery = '
                SELECT `p1`.* FROM `src_pic` AS `p1`
                WHERE  `p1`.`deleted`=1 AND `p1`.`deleted_date` BETWEEN DATE_SUB(NOW(), INTERVAL 30 DAY) AND NOW() AND
                       `p1`.`member_id`='.$memberId.' AND
                       `p1`.`stack_id` =0
              UNION
                SELECT `p1`.* FROM `src_pic` AS `p1`, `src_pic` AS `p2`
                WHERE  `p1`.`deleted`=1 AND `p1`.`deleted_date` BETWEEN DATE_SUB(NOW(), INTERVAL 30 DAY) AND NOW() AND
                       `p1`.`member_id`='.$memberId.' AND
                       `p1`.`stack_id` =`p2`.`id`     AND `p2`.`deleted`=0 AND `p2`.`type`=\'stack\'
              ORDER BY `deleted_date` DESC, `id` ASC LIMIT '.$limitStart.', '.$limitEnd;
 
 
        }
        else {
            if ($contentOnly == 'true') {
                $sqlQuery = '';
 
                if ($albumsOnly == 'false') {
                    $sqlQuery = '
                    SELECT `p1`.* FROM `src_pic` AS `p1`, `src_pic_images` AS `pi`
                    WHERE  '.$sqlPart.' AND `p1`.`type`=\'image\' AND `pi`.`pic_id`=`p1`.id AND `pi`.`pic_in_content`=1
                    UNION';
                }
 
                $sqlQuery .= '
                    SELECT `p1`.* FROM `src_pic` AS `p1`, `src_pic_images_stacks` AS `pis`
                    WHERE  '.$sqlPart.' AND `p1`.`type`=\'stack\' AND `pis`.`stack_id`=`p1`.id AND `pis`.`stack_in_content`=1
                  ORDER BY `sort` DESC LIMIT '.$limitStart.', '.$limitEnd;
            }
            else {
                $aPart = $albumsOnly == 'true' ? ' AND `p1`.`type`=\'stack\' ' : '';
 
                $sqlQuery = 'SELECT * FROM `src_pic` AS `p1` WHERE '.$sqlPart.$aPart. ' AND `deleted`=0
                             ORDER BY `p1`.`sort` DESC LIMIT '.$limitStart.', '.$limitEnd;
            }
 
 
        }
 
        /*echo json_encode(*/  /*);*/
 
        return $this->selectItems($db->query($sqlQuery));
    }
 
    private function selectItems($picResultObj)
    {
        $db = $this->db;
 
        $picItems = [];
        $aliases  = [
            'stack' => [],
            'image' => []
        ];
 
        $accesses  = [
            'stack' => [],
            'image' => []
        ];
 
        $ids = [
            'stack' => [],
            'image' => []
        ];
 
        $del = [
            'stack' => [],
            'image' => []
        ];
 
        $counter = 0;
 
        $dateNow = new DateTime(date('Y-m-d H:i:s'));
 
        $memberId  = $this->user->getId();
        $memberAge = $this->user->getAge();
        $isRoot    = $this->user->isRoot() || $this->user->hasRight('pic_root_access');
 
        while($item = $picResultObj->fetch()) {
            $picItems[$counter] = [];
 
            $aliases[$item['type']][$item['id']] = $counter;
 
            $ids[$item['type']][] = $item['id'];
 
            if($item['deleted']) {
                $dateDel = new DateTime($item['deleted_date']);
                $interval = $dateDel->diff($dateNow);
                $del[$item['type']][$item['id']] = 30 - $interval->format('%a');
            }
            else
                $del[$item['type']][$item['id']] = 0;
 
            $accesses[$item['type']][$item['id']] =  [
                'enabled' => 0,
                'age'     => 0,
                'private' => 0,
                'direct'  => 0,
                'editing' => 0
            ];
 
            $counter++;
 
            if ($item['member_id'] == $memberId || $isRoot) { // Либо хозяин, либо рут/модератор
                $accesses[$item['type']][$item['id']]['editing']  = 1;
 
                if ($item['access_type'] == 'direct')
                    $accesses[$item['type']][$item['id']]['direct']  = 1;
                else if ($item['access_type'] == 'private')
                    $accesses[$item['type']][$item['id']]['private'] = 1;
 
                $accesses[$item['type']][$item['id']]['age']     = (int)$item['access_age'];
                continue;
            }
 
 
            if ($item['access_type'] == 'direct') {
                $accesses[$item['type']][$item['id']]['enabled'] = 1;
                $accesses[$item['type']][$item['id']]['direct']  = 1;
            }
            else if ($item['access_type'] == 'private') {
                $accesses[$item['type']][$item['id']]['enabled'] = 1;
                $accesses[$item['type']][$item['id']]['private'] = 1;
            }
 
            if ($memberAge < $item['access_age']) {
                $accesses[$item['type']][$item['id']]['enabled'] = 1;
                $accesses[$item['type']][$item['id']]['age']     = $item['access_age'];
            }
        }
 
        /*print_r($accesses);
 
        exit;*/
 
        if(sizeof($ids['stack'])) {
 
            $result  = $db->query('
                SELECT `pis`.*, `pi`.`pic_file_name`, `pi`.`pic_file_format` FROM `src_pic_images_stacks` AS `pis`
                LEFT JOIN `src_pic_images` AS `pi` ON `pi`.`stack_id`=`pis`.`stack_id` AND `pi`.`pic_is_icon` = 1
                WHERE `pis`.`stack_id` IN ('.implode(',', $ids['stack']).')');
 
            while($stack = $result->fetch()) {
                $access = $accesses['stack'][$stack['stack_id']];
 
                $picItems[$aliases['stack'][$stack['stack_id']]] = PicItem::initBySqlArray($stack, $access, $this->isApp)->getData();
 
                $picItems[$aliases['stack'][$stack['stack_id']]]['meta']['to_delete'] = $del['stack'][$stack['stack_id']];
            }
        }
 
        if(sizeof($ids['image'])) {
            $result  = $db->query('SELECT * FROM `src_pic_images` WHERE `pic_id` IN ('.implode(',', $ids['image']).')');
 
            while($stack = $result->fetch()) {
                $access = $accesses['image'][$stack['pic_id']];
 
                //print_r($access);
 
                $picItems[$aliases['image'][$stack['pic_id']]] = PicItem::initBySqlArray($stack, $access, $this->isApp)->getData();
 
                $picItems[$aliases['image'][$stack['pic_id']]]['meta']['to_delete'] = $del['image'][$stack['pic_id']];
            }
        }
 
        return $picItems;
    }
}
#4Core\Modules\Pic\Controller\StackController->getName
/var/www/fullrest-team/data/www/fullrest.net/Site/Pic/Controller/PicController.php (330)
<?php
//TODO: описание плана
/*
    1. eva-project.members - after insert : вставляем запись в fullres1_phalcon.scl_members
    2. eva-project.members - after update : правим таймеры, мейк группу и остальное
 
    3. eva-project.members_auth - after insert : ставляем запись в fullres1_phalcon.scl_members_auth
 
 
 
 
*/
 
namespace Site\Pic\Controller;
 
use Core\Lib\Calc;
use Core\Lib\Mustache;
use Core\Modules\Pic\Controller\ImageController;
use Core\Modules\Pic\Controller\StackController;
use Core\Extenders\ContentController;
use Phalcon\Db;
use Core\Lib;
 
class PicController extends ContentController
{
    private $pageStart = 1;
    private $pageEnd   = 1;
 
    private $idElizaPicRightBack       = 'elizaPicRightBack';
    private $idElizaPicRightPanel      = 'elizaPicRightPanel';
    private $idElizaPicRightPanelClose = 'elizaPicRightPanelClose';
 
    private $idElizaPicPluploadBtn  = 'elizaPicPluploadBtn';
    private $idElizaPicPluploadZone = 'elizaPicPluploadZone';
 
    private $idElizaPicFooter        = 'elizaPicFooter';
    private $idElizaPicFooterTitle   = 'elizaPicFooterTitle';
    private $idElizaPicFooterNext    = 'elizaPicFooterNext';
    private $idElizaPicFooterPrev    = 'elizaPicFooterPrev';
    private $idElizaPicFooterRoot    = 'elizaPicFooterRoot';
    private $idElizaPicFooterNumbers = 'elizaPicFooterNumbers';
    private $idElizaPicFooterAlbums  = 'elizaPicFooterAlbums';
    private $idElizaPicFooterContent = 'elizaPicFooterContent';
 
    private $idElizaPicTool         = 'elizaPicTool';
    private $idElizaPicToolStackExp = 'elizaPicToolExpand';
    private $idElizaPicToolAddImage = 'ElizaAppPic_addImage'; // К этому айдишнику привязан ЦСС; без надобности не менять.
    private $idElizaPicToolAddStack = 'elizaPicToolAddAlbum';
    private $idElizaPicToolTree     = 'elizaPicToolMoveToAlbum';
    private $idElizaPicToolTrash    = 'elizaPicToolDeleteItems';
    private $idElizaPicToolUnsel    = 'elizaPicToolRemoveSelect';
    
 
    public function initialize()
    {
        $this->overseer->setJSController('pic');
        $this->overseer->setJSAction('picInitialization');
 
        if ($this->request->get('page')) {
            $expl = explode('-', $this->request->get('page'));
 
            if (sizeof($expl) == 2) {
                $start = (int)$expl[0];
                $end   = (int)$expl[1];
 
                if($start <= 0) {
                    $start = 1;
                }
 
                if($end <= 0) {
                    $end = 1;
                }
 
                if($start > $end) {
                    $start = $end;
                }
            }
            else {
                $start = (int)$expl[0];
 
                if(!$start) {
                    $start = 1;
                }
 
                $end = $start;
            }
 
            $this->pageStart = $start;
            $this->pageEnd   = $end;
        }
    }
 
    public function indexAction() {
        if (!$this->user->getId())
            return;
 
        $this->generateHtmlForStack('', $this->user->getId(), 0);
    }
 
 
    public function stackAction($stackName) {
        $this->generateHtmlForStack($stackName, $this->user->getId(), 0);
    }
 
    /**
     * @param $imageName
     */
    public function imageAction($imageName)
    {
        if ($imageName == 'trash') {
            $this->trashAction();
            return;
        }
 
        $image = (new ImageController())->getPageData($imageName);
 
        if (isset($image['restricted'])) {
            $this->htmlGenerateRestrictedAccess('image', $image['restricted']);
 
            return;
        }
 
 
        $this->og->setTitle('Изображение: '.$image['image']['meta']['title']);
 
        if ($image['image']['meta']['descr']) {
            $this->og->setDescr($image['image']['meta']['descr']);
        }
        else {
            $this->og->setDescr('Страница изображения, расположенного на сервисе picain.ru');
        }
 
        $this->og->setImageUrl('/upl/t/'.$image['image']['system']['name'].'_150x150.'.$image['image']['meta']['file']['type']);
        $this->og->setImageType($image['image']['meta']['file']['type']);
        $this->og->setImageSize(150, 150);
 
        $rightContent = '';
        $rightHead    = '';
 
        if ($this->cookies->get('rightMenuActive') == 'true') {
            $rightHead = Mustache::renderWithBinds(
                'app/pic/image_right_head',
                [
                    'texted' => [
                        'text' => 'Информация',
                        'icon' => ['svg' => ['main' => 'ic-info'], 'size' => 'small']
                    ],
                    'close' => [
                        'id'    => $this->idElizaPicRightPanelClose,
                        'title' => 'панель информации'
                    ],
                    'lang' => [
                        'close' => 'Закрыть'
                    ]
                ]
            );
            
            $hostName = $this->request->getHttpHost();
 
            $copyPage   = 'http://'.$hostName.'/'. $image['image']['system']['name'];
            $copyUrl    = 'http://'.$hostName.'/'.$image['image']['system']['name'].'.'.$image['image']['meta']['file']['type'];
            $copyThumb  = 'http://'.$hostName.'/upl/t/'. $image['image']['system']['name'].'_150x150.'.$image['image']['meta']['file']['type'];
            $copyHtml   = '<a title=\''.$image['image']['meta']['title'].'\' href=\''.$copyPage.'\' target=\'_blank\'><img alt=\''.$image['image']['meta']['title'].'\' src=\''.$copyThumb.'\' /></a>';
            $copyBBCode = '[url='.$copyPage.'][img]'.$copyThumb.'[/img][/url]';
            $resolution = $image['image']['meta']['file']['width'].'×'.$image['image']['meta']['file']['height'];
 
            $info = [
                ['tag' => 'time', 'title' => 'Добавлено:',    'value' => Lib\DateFuncs::dateFormatTextedMonthAndTime($image['image']['system']['date']),],
                ['tag' => 'span', 'title' => 'Разрешение:',   'value' => $resolution],
                ['tag' => 'span', 'title' => 'Просмотры:',    'value' => $image['image']['meta']['views']['count']],
                ['tag' => 'span', 'title' => 'Размер файла:', 'value' => Calc::fileSize($image['image']['meta']['file']['size'])]
            ];
 
            $links_html = '';
    
            $links = [
                ['title' => 'Ссылка', 'value' => $copyUrl   ],
                ['title' => 'HTML',   'value' => $copyHtml  ],
                ['title' => 'BBCode', 'value' => $copyBBCode]
            ];
 
            for($a = 0; $a <3; $a++) {
                $item = $links[$a];
 
                $links_html .= Mustache::renderWithBinds(
                    'forms/base_input',
                    [
                        'title' => $item['title'],
                        'input' => [
                            'tag'    => 'input',
                            'class'  => 'input code',
                            'value'  =>  $item['value'],
                            'type'   => 'text',
                            'style'  => 'default',
                            'size'   => 'medium',
                            'tone'   => 'dark',
                            'radius' => 'rad',
                            'bg'     => 'grey 200',
                            'short'  =>  1
                        ],
                        'icon_left' => [
                            'tag'      => 'span',
                            'position' => 'left',
                            'tone'     => 'dark',
                            'bg'       => 'grey 200',
                            'icon' => [
                                'svg'    => ['main' => 'ic-earth'],
                                'size'   => 'small',
                                'radius' => 'rad'
                            ]
                        ]
                    ]
                );
            }
 
 
 
            $rightContent = Mustache::renderWithBinds(
                'app/pic/image_right_content',
                [
                    'id_descr' => 'elizaPicImageDescr',
                    'isChild'  => $image['image']['system']['parent'] ? 1 : 0,
                    'parent' =>  ''/*imageParent*/,
                    'member' =>  $image['member'],
                    'stack' =>  'stack',
                    'restrict' =>  $image['restrict'],
                    'description' =>  $image['description'],
                    'meta' =>  [
                        'title' =>        $image['image']['meta']['title'],
                        'description' => ''
                    ],
                    'info' =>    $info,
                    'links_html' => $links_html
                ]
            );
 
        }
 
        $windowHtml = $this->htmlGenerateWindow("image", json_encode($image),
            Mustache::renderWithBinds(
                'eliza/toolbar_panel', ['floated' => 'floated', 'size' => 'contentLarge'],
                [
                    'TOOLBAR_MIDDLE' => $this->htmlGenerateUserPanel($type = 'image', $image),
                    'TOOLBAR_RIGHT'  => Mustache::renderWithBinds(
                        'eliza/toolbar_button',
                        [
                            'tag'     => 'div',
                            'class'   => 'sep',
                            'default' => 0
                        ]
                    ).Mustache::renderWithBinds(
                        'eliza/toolbar_button',
                        [
                            'id'     => $this->idElizaPicRightPanel,
                            'tag'    => 'div',
                            'title'  => 'Правая панель',
                            'class'  => 'rpanel'. ($this->cookies->get('rightMenuActive') == 'true' ? ' active' : '' ),
                            'setts'  => ['type' => 'default', 'link' => 1, 'tip_h' => 'dtr'],
                            'icon'   => ['svg' => ['main' => 'ic-rpanel'], 'size' => 'small'],
                            'border' => ['enable' => 1, 'lines' => 'bottom', 'color' => 'blue']
                        ]
                    ).Mustache::renderWithBinds(
                            'eliza/toolbar_button',
                            [
                                'id'     => $this->idElizaPicRightBack,
                                'tag'    => 'div',
                                'title'  => 'Назад',
                                'class'  => 'back',
                                'setts'  => ['type' => 'default', 'link' => 1, 'tip_h' => 'dtr'],
                                'icon'   => ['svg' => ['main' => 'ic-arrow-left2'], 'size' => 'small'],
                                'border' => ['enable' => 1, 'lines' => 'bottom', 'color' => 'blue']
                            ]
                    )
                ]
            ),
            Mustache::renderWithBinds(
                'app/pic/image',
                [
 
                    'vcont'   => 'elizaPicImageCont',
                    'viewer'  => 'elizaPicImageViewer',
                    'cropper' => 'elizaPicImageCropper',
                    'title'   => $image['image']['meta']['title'],
                    'name'    => $image['image']['system']['name'],
                    'type'    => $image['image']['meta']['file']['type'],
                    'width'   => $image['image']['meta']['file']['width'],
                    'height'  => $image['image']['meta']['file']['height']
                ]
            ),
            $this->htmlGenerateFooter($type = 'image', $image),
            $rightContent,
            $rightHead
        );
 
        $windowHtml = mbereg_replace(
            'data-layout="cnt_content_content"',
            'data-layout="cnt_content_content" data-elz-bg="grey 900"',
            $windowHtml
        );
 
        if ($this->cookies->get('rightMenuActive') == 'true') {
            $windowHtml = mbereg_replace(
                'elz tplCLSgrid cells',
                'elz tplCLSgrid cells showside',
                $windowHtml
            );
 
        }
 
        $this->view->setVar('picHtml', $windowHtml);
    }
 
    public function trashAction() {
        if (!$this->user->getId())
            return;
 
        $this->generateHtmlForStack('trash', $this->user->getId(), -1);
    }
 
 
    public function generateHtmlForStack($stackName, $memberId, $stackId)
    {
        if ($stackName == '' && $this->user->isNotActivated()) {
            $this->htmlGenerateRestrictedAccess('stack', ['code' => 'activation', 'data' => '']);
            return;
        }
 
        $stackController = (new StackController())->initialize();
 
        $metaData = $stackController->getName($stackName ? $stackName : 'root');
 
        if ($metaData['restricted']) {
            $this->htmlGenerateRestrictedAccess('stack', $metaData['restricted']);
            return;
        }
 
        //die($metaData['pages']);
 
        if ($this->pageStart > $metaData['pages']) {
            $this->pageStart = $metaData['pages'];
        }
 
        if ($this->pageEnd > $metaData['pages']) {
            $this->pageEnd = $metaData['pages'];
        }
 
        if ($stackName == '' || $stackName == 'trash') {
            $state = "list ".($stackName ? "trash" : "root");
 
            $itemList = $stackController->getItemsList($memberId, $stackId, ['start' => $this->pageStart, 'end' => $this->pageEnd]);
        }
        else {
            $itemList = $stackController->getItemsListByName($stackName,    ['start' => $this->pageStart, 'end' => $this->pageEnd]);
 
            $state = "list album";
        }
 
        $contentHtml = '';
 
        if (/*(!$stackId && !$stackName) ||*/ $stackName == 'trash' || $this->pageStart > 1 || $metaData['owner'] != $this->user->getId() /*|| ($stackName && sizeof($itemList))*/) {
            $uploadCls = ' hide';
        }
        else {
            $uploadCls = '';
        }
 
 
        $contentHtml = '<div class="elz picCLSupload'.(!sizeof($itemList) ? ' empty' : '').$uploadCls.'">'.Mustache::renderWithBinds(
            'common/upload_zone',
            [
                'id'    => $this->idElizaPicPluploadBtn,
                'parent_id'   => $this->idElizaPicPluploadZone,
                'description' => !sizeof($itemList) ?
                    ('<p class="bb p al-center"><span class="bb fn-12">В этом альбоме ещё нет изображений</span>'.
                     '<br>Выберите изображения для загрузки, нажав на эту область, или перетащите файлы сюда<br>'.
                     '<span class="bb fn-8">Ограничение на размер файла: <b class="bb bold">10 mb</b></span>'.
                     '</p>')
                    :
                    ('<p class="bb p al-center"><span class="bb fn-12">Выберите файлы</span>'.
                     '<br>Или перетащите в эту область<br>'.
                     'Вы можете сделать снимок экрана и нажать <b class="bb bold">[Ctrl + V]</b><br>'.
                     '<span class="bb fn-8">Ограничение на размер файла: <b class="bb bold">10 mb</b></span>'.
                     '</p>'),
                'icon' => [
                    'svg' => [
                        'main' => $stackName == 'root' || $stackName == '' ? 'ic-image' : 'ic-images',
                        'sub' =>  'ic-plus'
                    ],
                    'color' => ['subbg' => 'blue']],
                'circle' => ['size' => 'large ', 'radius' => '55', 'color' => 'blue']
            ]
        ).'</div>';
        //}
 
 
        $contentHtml .= Mustache::renderWithBinds(
            'app/pic/items_list',
            [
                'id'   => 'elizaPicContentStackList',
                'list' => $itemList, 'iconEnabled' => $stackName == '' || $stackName == 'trash' ? 0 : 1,
                'lang' => [
                    'title1'    => 'Размер изображения',
                    'title2'    => 'Вариаций изображения',
                    'title3'    => 'Формат изображения',
                    'title4p1'  => 'Является',
                    'title4p2'  => 'Сделать',
                    'title4p3'  => 'иконкой альбома',
                    'title5'    => 'Альбомов внутри',
                    'title6'    => 'Изображений в альбоме',
                    'title7'    => 'Альбом',
                    'title8'    => 'Дней до удаления',
                    'title9'    => 'Изображение',
                    'title10'   => 'Иконка альбома',
                    'title11'   => 'Доступ ограничен',
                    'title12p1' => 'Доступно только пользователям старше',
                    'title12p2' => 'лет',
                    'title13'   => 'Доступно только вам',
                    'title14'   => 'Доступно только автору',
                    'title15'   => 'Доступно только по прямой ссылке'
                ]
            ]
        );
 
 
        $this->view->setVar('picHtml',
            $this->htmlGenerateWindow($state, json_encode($metaData),
                Mustache::renderWithBinds(
                    'eliza/toolbar_panel', ['floated' => 'floated', 'size' => 'contentLarge'],
                    [
                        'TOOLBAR_MIDDLE' => $this->htmlGenerateUserPanel($type = 'stack', $metaData, $stackName),
                        'TOOLBAR_RIGHT'  =>  Mustache::renderWithBinds(
                            'eliza/toolbar_button',
                            [
                                'id'     => $this->idElizaPicRightPanel,
                                'tag'    => 'div',
                                'title'  => 'Правая панель',
                                'class'  => 'rpanel hide',
                                'setts'  => ['type' => 'default', 'link' => 1, 'tip_h' => 'dtr'],
                                'icon'   => ['svg' => ['main' => 'ic-rpanel'], 'size' => 'small'],
                                'border' => ['enable' => 1, 'lines' => 'bottom', 'color' => 'blue']
                            ]
                        ).Mustache::renderWithBinds(
                                'eliza/toolbar_button',
                                [
                                    'id'     => $this->idElizaPicRightBack,
                                    'tag'    => 'div',
                                    'title'  => 'Назад',
                                    'class'  => 'back'.($stackName == '' ? ' hide' : ''),
                                    'setts'  => ['type' => 'default', 'link' => 1, 'tip_h' => 'dtr'],
                                    'icon'   => ['svg' => ['main' => 'ic-arrow-left2'], 'size' => 'small'],
                                    'border' => ['enable' => 1, 'lines' => 'bottom', 'color' => 'blue']
                                ]
                        )]
                ),
                Mustache::renderWithBinds(
                    'eliza/scroll_content',
                    ['id' => 'elizaPicContentScroll', 'abs' => 'abs'],
                    ['CONTENT' => $contentHtml]
                ),
                $this->htmlGenerateFooter($type = 'stack', $metaData)
            )
        );
    }
 
 
    private function htmlGenerateWindow($state, $data, $topHeader, $cntContent, $cntFooter, $rightContent = '', $rightHead = '') {
        return Mustache::renderWithBinds(
            'eliza/window',
            [
                'setts' => [
                    'id'     => 'ElizaAppPic',
                    'app'    => 'pic',
                    'state'  => $state,
                    'zindex' => 1,
                    'data'   => $data ? ' data-meta=\''.$data.'\' ' : '',
                    'isFullscreen' => 1
                ],
                'class'  => 'standalone',
                'enable' => [
                    'content' => ['cnt' => ['subfooter' => 1,'footer' => 1]],
                    'right'   => ['cnt' => [],'footer' => 1]
                ]
            ],
            [
                'TOP_HEADER' => $topHeader,
                'CNT_CONTENT_CONTENT'   => $cntContent,
                'CNT_CONTENT_FOOTER'    => $cntFooter,
                'CNT_CONTENT_SUBFOOTER' => Mustache::renderWithBinds(
                    'app/pic/image_slider',
                    [
                        'id' => [
                            'main'        => 'elizaPicImageSlider',
                            'list'        => 'elizaPicImageSliderList',
                            'crop'        => 'elizaPicImageSliderCrop',
                            'title'       => 'elizaPicImageSliderTitle',
                            'crop_create' => 'elizaPicThumbCreate',
                            'crop_form'   => 'elizaPicThumbForm'
                        ],
                        'lang' => [
                            'text' =>   'Изображения в альбоме',
                            'title1' => 'Закрыть',
                            'title2' => 'Создать новую миниатюру',
                            'item' =>   'Новая миниатюра'
                        ]
                    ]
                ),
                'RIGHT_CNT_CONTENT' => $rightContent,
                'RIGHT_HEADER'      => $rightHead
            ]
        );
    }
 
 
    private function htmlGenerateRestrictedAccess($type = 'stack', $meta) {
 
 
        $statuses = [
            'private' => [
                'icon' =>  ['name' => "ic-eye-blocked", 'bg' => "red 700", 'txt' => ""],
                'descr' => "Эта страница доступна только её автору."
            ],
            'age' => [
                'icon' =>  ['name' => "", 'bg' => "red 700", 'txt' => $meta['data'].'+'],
                'descr' => 'Эта страница запрещена для просмотра лицам, не достигшим возраста '.$meta['data'].' лет.'
            ],
            'missing' => [
                'icon' =>  ['name' => "", 'bg' => "red 700", 'txt' => "404"],
                'descr' => "Страница не найдена."
            ],
            'guest' => [
                'icon' =>  ['name' => "ic-user", 'bg' => "red 700", 'txt' => ""],
                'descr' => "Для доступа к функционалу требуется регистрация."
            ],
            'activation' => [
                'icon' =>  ['name' => "ic-key", 'bg' => "blue", 'txt' => ""],
                'descr' => "Для использования данного сервиса необходима активация."
            ]
        ];
 
        $data = $statuses[$meta['code']];
 
        $html = Mustache::renderWithBinds(
            'eliza/window',
            [
                'setts' => [
                    'id'    => 'ElizaAppPic',
                    'app'   =>   'pic',
                    'state' => 'default',
                    'isFullscreen' => 1,
                    'zindex' => 1
                ],
                'enable' => [
                    'content' => ['cnt' => ['subfooter' => 1,'footer' => 1]],
                    'right'   => ['cnt' => [],'footer' => 1]
                ]
            ],
            [
                'TOP_HEADER' => Mustache::renderWithBinds('eliza/toolbar_panel', ['floated' => 'floated', 'size' => 'contentLarge'], []),
                'CNT_CONTENT_CONTENT' => Mustache::renderWithBinds(
                    'eliza/forbidden',
                    [
                        'tone' => $type == 'image' ? 'light' : 'dark',
                        'icon' => [
                            'svg'   => ['main' => 'ic-lock', 'sub' =>  $data['icon']['name']],
                            'txt'   => ['sub' => $data['icon']['txt']],
                            'color' => ['subbg' => $data['icon']['bg']]
                        ],
                        'description' => $data['descr']
                    ]
                )
            ]
        );
 
        if ($type == 'image') {
            $html = mbereg_replace(
                'data-layout="cnt_content_content"',
                'data-layout="cnt_content_content" data-elz-bg="grey 900"',
                $html
            );
        }
        
        $this->view->setVar('picHtml', $html);
    }
 
 
 
 
    private function htmlGenerateUserPanel($type = 'stack', $metaData, $stackName ='') // stack, image, trash
    {
        $buttonsHtml = '';
        $buttonsTransformHtml = '';
        $buttons = [];
        $toolbarHtml = '';
 
        $editable = $type == 'stack' ? $metaData['editable'] : $metaData['image']['access']['editing'];
 
        if ($this->user->isNotActivated()) {
            return '';
        }
 
        if ($type == 'stack' && $editable) {
            $buttons = [];
 
            if ($stackName != "trash") {
                if ($stackName != '' && $stackName != 'root') {
                    $buttons[] = [
                        'id'    => 'elizaPicImagePageMeta',
                        'tag'   => 'div',
                        'title' => 'Редактировать описание',
                        'align' => 'right',
                        'icon'  => [
                            'svg'   => ['main' => 'ic-pencil'],
                            'size'  => 'small'
                        ]
                    ];
                }
 
                $buttons[] = [
                    'id'    => $this->idElizaPicToolAddImage,
                    'tag'   => 'label',
                    'title' => 'Загрузить изображения',
                    'align' => 'right',
                    'icon'  => [
                        'svg'   => ['main' => 'ic-image', 'sub' => 'ic-plus'],
                        'size'  => 'small',
                        'color' => ['subbg' => 'blue']]
                ];
 
                $buttons[] = [
                    'id'    => $this->idElizaPicToolAddStack,
                    'tag'   => 'div',
                    'title' => 'Добавить альбом',
                    'align' => 'right',
                    'icon'  => [
                        'svg'   => ['main' => 'ic-folder', 'sub' => 'ic-plus'],
                        'size'  => 'small',
                        'color' => ['subbg' => 'blue']]
                ];
 
                $buttons[] = [
                    'id'    => $this->idElizaPicToolTree,
                    'tag'   => 'div',
                    'title' => 'Проводник по альбомам',
                    'align' => 'right',
                    'icon'  => [
                        'svg'  => ['main' => 'ic-foldertree'],
                        'size' => 'small']
                ];
 
                /*$buttons = [
                    [
                        'id'    => 'ElizaAppPic_addImage',
                        'tag'   => 'label',
                        'title' => 'Загрузить изображения',
                        'align' => 'right',
                        'icon'  => [
                            'svg'   => ['main' => 'ic-image', 'sub' => 'ic-plus'],
                            'size'  => 'small',
                            'color' => ['subbg' => 'blue']]
                    ],
                    [
                        'id'    => 'ElizaAppPic_addAlbum',
                        'tag'   => 'div',
                        'title' => 'Добавить альбом',
                        'align' => 'right',
                        'icon'  => [
                            'svg'   => ['main' => 'ic-folder', 'sub' => 'ic-plus'],
                            'size'  => 'small',
                            'color' => ['subbg' => 'blue']]
                    ],
                    [
                        'id'    => 'ElizaAppPic_moveToAlbum',
                        'tag'   => 'div',
                        'title' => 'Проводник по альбомам',
                        'align' => 'right',
                        'icon'  => [
                            'svg'  => ['main' => 'ic-foldertree'],
                            'size' => 'small']
                    ],
                ];*/
            }
 
            $buttons[] = [
                'id'     => $this->idElizaPicToolTrash,
                'tag'    => 'a',
                'title'  => 'Показать удаленное',
                'align'  => 'right',
                'class'  => $stackName == 'trash' ? ' active' : '',
                'border' => [
                    'enable' => 1,
                    'lines'  => 'bottom',
                    'color'  => 'red 800'],
                'icon'  => [
                    'svg'  => ['main' => $stackName == 'trash' ? 'ic-loop' :'ic-trash'],
                    'size' => 'small'],
                'href' => '/trash'
            ];
 
            $length = sizeof($buttons);
 
            for($a = 0; $a < $length; $a++) {
                $item = $buttons[$a];
 
                $buttonsHtml .= Mustache::renderWithBinds(
                    'eliza/toolbar_button',
                    [
                        'id'    => $item['id'],
                        'tag'   => $item['tag'],
                        'title' => $item['title'],
                        'class' => isset($item['class']) ? $item['class'] : '',
                        'setts' => ['type' => 'default', 'align' => $item['align'], 'link' => 1],
                        'text'  => ['str' => $item['title'], 'align' => 'left'],
                        'icon'  => $item['icon'],
                        'href'  => isset($item['href']) ? $item['href'] : '',
                        'border'  => isset($item['border']) ? $item['border'] : ''
                    ]
                );
            }
 
            $toolbarHtml = Mustache::renderWithBinds(
                'eliza/toolbar_group',
                [
                    'active'   => '',
                    'position' => 'right',
                    'xsub'     => '320',
                    'v_pos'    => 'top',
                    'h_pos'    => 'right'
                ],
                [
                    'TOOL_TRIGGER' => Mustache::renderWithBinds(
                        'eliza/toolbar_button',
                        [
                            'id'    => $this->idElizaPicToolStackExp,
                            'tag'   => 'div',
                            'title' => 'Показать правую панель',
                            'setts' => ['type' => 'default', 'align' => 'right', 'link' => 1],
                            'icon'  => ['svg' => ['main' => 'ic-more1'], 'size' => 'small', 'radius' => 'rad']
                        ]),
                    'TOOL_LIST' => $buttonsHtml
                ]
            );
        }
        else if ($type == 'image'){
            $type = $metaData['image']['meta']['file']['type'];
            $name = $metaData['image']['system']['name'];
 
            $buttons[] = [
                'id'    => 'elizaPicImagePageDownload',
                'title' => 'Скачать изображение',
                'tag'   => 'a',
                'href' => '/'.$name.'.'.$type,
                'data' => ' download="'.$name.'.'.$type.'" ',
                'align' => 'right',
                'icon'  => ['svg' => ['main' => 'ic-download'], 'size' => 'small', 'radius' => 'rad']
            ];
 
            $buttonsTransform = [];
 
            if ($editable) {
                if (!$metaData['image']['system']['parent']) {
                    $buttons[] = [
                        'id'    => 'elizaPicImagePageTree',
                        'title' => 'Переместить изображение',
                        'tag'   => 'div',
                        'align' => 'right',
                        'icon'  => [
                            'svg'   => ['main' => 'ic-foldertree', 'sub' => 'ic-arrow-left'],
                            'size'  => 'small',
                            'color' => ['subbg' => 'blue']]
                    ];
                }
 
                $buttons[] = [
                    'id'    => 'elizaPicImagePageCrop',
                    'title' => 'Создать миниатюру',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => [
                        'svg'   => ['main' => 'ic-crop'],
                        'size'  => 'small'
                    ],
                    'border' => [
                        'enable' => 1,
                        'lines'  => 'bottom',
                        'color'  => 'green'
                    ]
                ];
 
                $buttons[] = [
                    'id'    => 'elizaPicImagePageEdit',
                    'title' => $metaData['image']['system']['parent'] ? 'Редактирование изображения' : 'Создать вариацию',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => [
                        'svg'   => ['main' => 'ic-wand', 'sub' => $metaData['image']['system']['parent'] ? 'ic-pencil' : 'ic-plus'],
                        'size'  => 'small',
                        'color' => ['subbg' => 'blue']],
                    'border' => [
                        'enable' => 1,
                        'lines'  => 'bottom',
                        'color'  => 'green'
                    ]
                ];
 
                $buttons[] = [
                    'id'    => 'elizaPicImagePageMeta',
                    'title' => 'Редактировать описание',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => [
                        'svg'   => ['main' => 'ic-pencil'],
                        'size'  => 'small']
                ];
 
                $buttons[] = [
                    'id'     => 'elizaPicImagePageDelete',
                    'title'  => 'Удалить',
                    'tag'    => 'div',
                    'align'  => 'right',
                    'icon'  => [
                        'svg'  => ['main' => 'ic-trash'],
                        'size' => 'small']
                ];
 
                $buttonsTransform[] = [
                    'id'    => 'elizaImageTransformMirrorHorizontal',
                    'title' => 'Отразить по горизонтали',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => ['svg' => ['main' => 'ic-mirror-h'], 'size' => 'small']
                ];
 
                $buttonsTransform[] = [
                    'id'    => 'elizaImageTransformMirrorVertical',
                    'title' => 'Отразить по вертикали',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => ['svg' => ['main' => 'ic-mirror-v'], 'size' => 'small']
                ];
 
                $buttonsTransform[] = [
                    'id'    => 'elizaImageTransformRotateLeft',
                    'title' => 'Повернуть против часовой стрелки',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => ['svg' => ['main' => 'ic-rotateclockcw'], 'size' => 'small']
                ];
 
                $buttonsTransform[] = [
                    'id'    => 'elizaImageTransformRotateRight',
                    'title' => 'Повернуть по часовой стрелке',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => ['svg' => ['main' => 'ic-rotateclockw'], 'size' => 'small']
                ];
 
                $length = sizeof($buttonsTransform);
 
                for($a = 0; $a < $length; $a++) {
                    $item = $buttonsTransform[$a];
 
                    $buttonsTransformHtml .= Mustache::renderWithBinds(
                        'eliza/toolbar_button',
                        [
                            'id'     => $item['id'],
                            'tag'    => $item['tag'],
                            'title'  => $item['title'],
                            'setts'  => ['type' => 'default', 'align' => $item['align'], 'link' => 1],
                            'text'   => ['str' => $item['title'], 'align' => 'left'],
                            'icon'   => $item['icon'],
                            'border' => isset($item['border']) ? $item['border'] : []
                        ]
                    );
                }
 
                $buttonsTransformHtml .= Mustache::renderWithBinds(
                    'eliza/toolbar_button',
                    [
                        'tag'     => 'div',
                        'class'   => 'sep',
                        'default' => 0,
                        'setts'   => ['align' => 'right']
                    ]
                );
            }
 
            $length = sizeof($buttons);
 
            for($a = 0; $a < $length; $a++) {
                $item = $buttons[$a];
 
                $buttonsHtml .= Mustache::renderWithBinds(
                    'eliza/toolbar_button',
                    [
                        'id'     => $item['id'],
                        'tag'    => $item['tag'],
                        'title'  => $item['title'],
                        'href'   => isset($item['href']) ? $item['href'] : '',
                        'data'   => isset($item['data']) ? $item['data'] : '',
                        'setts'  => ['type' => 'default', 'align' => $item['align'], 'link' => 1],
                        'text'   => ['str' => $item['title'], 'align' => 'left'],
                        'icon'   => $item['icon'],
                        'border' => isset($item['border']) ? $item['border'] : []
                    ]
                );
            }
 
            $toolbarHtml = ($editable ? Mustache::renderWithBinds(
                'eliza/toolbar_group',
                [
                    'id'       => 'elizaImageToolGroupTransform',
                    'active'   => '',
                    'ordered'  => 'ordered',
                    'position' => 'right',
                    'xsub'     => '768',
                    'v_pos'    => 'top',
                    'h_pos'    => 'right'
                ],
                [
                    'TOOL_TRIGGER' => Mustache::renderWithBinds(
                        'eliza/toolbar_button',
                        [
                            'id'    => 'elizaImageTransformExpand',
                            'tag'   => 'div',
                            'title' => 'Трансформация изображения',
                            'setts' => ['type' => 'default', 'align' => 'right', 'link' => 1],
                            'icon'  => ['svg' => ['main' => 'ic-fix'], 'size' => 'small', 'radius' => 'rad'],
                            'border' => [
                                'enable' => 1,
                                'lines'  => 'bottom',
                                'color'  => 'blue'
                            ]
                        ]),
                    'TOOL_LIST' => $buttonsTransformHtml
                ]
            ) : '').Mustache::renderWithBinds(
                    'eliza/toolbar_group',
                    [
                        'id'       => 'elizaImageToolGroupMain',
                        'active'   => '',
                        'ordered'  => 'ordered',
                        'position' => 'right',
                        'xsub'     => '540',
                        'v_pos'    => 'top',
                        'h_pos'    => 'right'
                    ],
                    [
                        'TOOL_TRIGGER' => Mustache::renderWithBinds(
                            'eliza/toolbar_button',
                            [
                                'id'    => 'elizaImageToolGroupExpand',
                                'tag'   => 'div',
                                'title' => 'Действия',
                                'setts' => ['type' => 'default', 'align' => 'right', 'link' => 1],
                                'icon'  => ['svg' => ['main' => 'ic-more1'], 'size' => 'small', 'radius' => 'rad'],
                                'border' => [
                                    'enable' => 1,
                                    'lines'  => 'bottom',
                                    'color'  => 'blue'
                                ]
                            ]),
                        'TOOL_LIST' => $buttonsHtml
                    ]
                );
        }
 
 
 
 
        return $toolbarHtml;
    }
 
 
    private function htmlGenerateFooter($type = 'stack', $metaData)
    {
        $htmlLeft   = '';
        $htmlMiddle = '';
        $htmlRight  = '';
 
        if ($type == 'stack') {
            $midButtons = [
                'left'  => ['class' => '', 'tag' => 'a'],
                'right' => ['class' => '', 'tag' => 'a'],
                'root'  => ['class' => '', 'tag' => 'a']
            ];
 
            if ($metaData['name'] === "root") {
                $rooTitle = "Перейти на первую страницу";
 
                if ($this->pageEnd === 1) {
                    $midButtons['root']['class'] = "disabled";
                }
            }
            else {
                $rooTitle = !$metaData['parent'] ? ($this->user->getId() ? "Перейти в корень" : "Перейти на главную страницу") : "Наверх";
            }
 
            if ($this->pageStart <= 1) {
                $midButtons['left']  = ['class' => 'disabled', 'tag' => 'div'];
            }
 
            if ($this->pageEnd >= $metaData['pages']) {
                $midButtons['right'] = ['class' => 'disabled', 'tag' => 'div'];
            }
 
            if (!$this->user->isNotActivated() || ($this->user->isNotActivated() && $metaData['name'] != "root")) {
                $htmlLeft .=  Mustache::renderWithBinds('eliza/toolbar_button',
                    [
                        'id'    => $this->idElizaPicFooterAlbums,
                        'tag'   => 'div',
                        'title' => 'Показать только альбомы',
                        'setts' => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtl'],
                        'icon'  => ['svg' => ['main' => 'ic-foldertree'], 'size' => 'small']
                    ]
                );
 
 
                $htmlLeft .=  Mustache::renderWithBinds('eliza/toolbar_button',
                    [
                        'id'    => $this->idElizaPicFooterContent,
                        'tag'   => 'div',
                        'title' => 'Показать только связанное с контентом',
                        'setts' => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtl'],
                        'icon'  => ['svg' => ['main' => 'ic-sharedfile'], 'size' => 'small']
                    ]
                );
            }
 
 
            $htmlLeft .=  Mustache::renderWithBinds('eliza/toolbar_title',
                [
                    'id'   => $this->idElizaPicFooterTitle,
                    'text' => $metaData['title']
                ]
            );
 
 
            $htmlMiddle .=  Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => $this->idElizaPicFooterPrev,
                    'tag'   => $midButtons['left']['tag'],
                    'href'  => '/'.($metaData['name'] == "root" ? '' : $metaData['name']).'?page='.($this->pageStart - 1),
                    'title' => 'Предыдущая страница',
                    'class' => $midButtons['left']['class'],
                    'setts' => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb'],
                    'icon'  => ['svg' => ['main' => 'ic-move-left'], 'size' => 'small']
                ]
            );
 
 
            $htmlMiddle .=  Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => $this->idElizaPicFooterRoot,
                    'tag'   => $midButtons['root']['tag'],
                    'href'  => '/'.($metaData['parent'] ? $metaData['parent'] : ''),
                    'title' => $rooTitle,
                    'class' => $midButtons['root']['class'],
                    'setts' => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb'],
                    'icon'  => ['svg' => ['main' => 'ic-gallery3'], 'size' => 'small']
                ]
            );
 
            $htmlMiddle .=  Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => $this->idElizaPicFooterNext,
                    'tag'   => $midButtons['right']['tag'],
                    'href'  => '/'.($metaData['name'] == "root" ? '' : $metaData['name']).'?page='.($this->pageEnd + 1),
                    'title' => 'Следующая страница',
                    'class' => $midButtons['right']['class'],
                    'setts' => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb'],
                    'icon'  => ['svg' => ['main' => 'ic-move-right'], 'size' => 'small']
                ]
            );
 
            $number = $this->pageStart != $this->pageEnd ? $this->pageStart.'-'.$this->pageEnd : $this->pageStart;
 
            $htmlRight .= Mustache::renderWithBinds(
                'eliza/toolbar_num_of_num',[
                    'id'      => $this->idElizaPicFooterNumbers,
                    'current' => $number,
                    'total'   => $metaData['pages'] ? $metaData['pages'] : 1
                ]
            );
 
            $htmlRight .= Mustache::renderWithBinds(
                'eliza/toolbar_button',[
                    'id'      => $this->idElizaPicToolUnsel,
                    'tag'     => 'div',
                    'title'   => 'Сбросить выделение',
                    'class'   => 'hide',
                    'setts' => ['type' => 'default', 'align' => 'right', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtr'],
                    'icon'  => ['svg' => ['main' => 'ic-selectremove'], 'size' => 'small']
                ]
            );
        }
        else {
            if ($metaData['image']['system']['parent']) {
                $upButton = '/'.$metaData['image']['system']['prow']['name'];
                $upTitle  = 'Перейти к оригиналу';
            }
            else {
                $upButton = $metaData['page']['up'] !== 'root' ? '/'.$metaData['page']['up'] : '/';
                $upTitle  = $metaData['page']['up'] !== 'root' ? 'Перейти в альбом' : ($this->user->getId() ? 'Перейти в корень' : 'Перейти на главную страницу');
            }
 
            $htmlLeft .=  Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'     => 'elizaPicImageFooterVariations',
                    'title'  => 'Вариации изображения',
                    'tag'    => 'div',
                    'class'  => !$metaData['image']['meta']['numbs']['variations'] && !$metaData['image']['system']['parent'] ? 'hide' : '',
                    'setts'  => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtl'],
                    'icon'   => ['svg' => ['main' => 'ic-wand'], 'size' => 'small'],
                    'border' => ['enable' => 1, 'lines' => 'top', 'color' => 'green']
                ]
            );
 
            $htmlLeft .=  Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'     => 'elizaPicImageFooterContent',
                    'tag'    => 'div',
                    'title'  => 'Связи с контентом',
                    'class'  => !$metaData['image']['flags']['isContent'] ? 'hide' : '',
                    'setts'  => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtl'],
                    'icon'   => ['svg' => ['main' => 'ic-sharedfile'], 'size' => 'small'],
                    'border' => ['enable' => 1, 'lines' => 'top', 'color' => 'orange']
                ]
            );
 
            $htmlLeft .=  Mustache::renderWithBinds('eliza/toolbar_title',
                [
                    'id'   => $this->idElizaPicFooterTitle,
                    'text' => $metaData['image']['meta']['title']
                ]
            );
 
 
            $htmlMiddle .= Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => $this->idElizaPicFooterPrev,
                    'tag'   => $metaData['page']['prev'] != "" ? 'a' : 'div',
                    'href'  => '/'.$metaData['page']['prev'],
                    'title' => 'Предыдущее изображение',
                    'class' => $metaData['page']['prev'] != "" && !$metaData['image']['system']['parent'] ? '' : 'disabled',
                    'setts' => ['type' => 'default', 'align' => 'left', 'link' => $metaData['page']['prev'] != "" ? 1 : 0, 'tip_v' => 'dtb'],
                    'icon'  => ['svg' => ['main' => 'ic-move-left'], 'size' => 'small']
                ]
            );
 
            $htmlMiddle .= Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => $this->idElizaPicFooterRoot,
                    'tag'   => 'a',
                    'href'  => $upButton,
                    'title' => $upTitle,
                    'class' => !$metaData['page']['up'] ? 'disabled' : '',
                    'setts' => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb'],
                    'icon'  => ['svg' => ['main' => 'ic-gallery3'], 'size' => 'small']
                ]
            );
 
            $htmlMiddle .= Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => $this->idElizaPicFooterNext,
                    'tag'   => $metaData['page']['next'] != "" ? 'a' : 'div',
                    'href'  => '/'.$metaData['page']['next'],
                    'title' => 'Следующее изображение"',
                    'class' => $metaData['page']['next'] != "" && !$metaData['image']['system']['parent'] ? '' : 'disabled',
                    'setts' => ['type' => 'default', 'align' => 'left', 'link' => $metaData['page']['next'] != "" ? 1 : 0, 'tip_v' => 'dtb'],
                    'icon'  => ['svg' => ['main' => 'ic-move-right'], 'size' => 'small']
                ]
            );
 
 
 
            $htmlRight .= Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => 'elizaPicImageFooterThumbs',
                    'tag'   => 'div',
                    'title' => 'Доступные миниатюры',
                    'setts' => ['type' => 'default', 'align' => 'right', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtr'],
                    'icon'  => ['svg' => ['main' => 'ic-crop2'], 'size' => 'small'],
                    'border' => ['enable' => 1, 'lines' => 'top', 'color' => 'blue']
                ]
            );
 
            $htmlRight .= Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => 'elizaPicImageFooterSiblings',
                    'tag'   => 'div',
                    'class'  => ((!$metaData['page']['prev']   && !$metaData['page']['next']) ||
                                   $metaData['stack'] == 'root' || $metaData['image']['system']['parent']) ? 'hide' : '',
                    'title' => 'Изображения в альбоме',
                    'setts' => ['type' => 'default', 'align' => 'right', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtr'],
                    'icon'  => ['svg' => ['main' => 'ic-gallery1'], 'size' => 'small'],
                    'border' => ['enable' => 1, 'lines' => 'top', 'color' => 'blue']
                ]
            );
        }
 
 
        return Mustache::renderWithBinds(
            'eliza/footer_1',
            [
                'id' => $this->idElizaPicFooter
            ],
            [
                'FOOTER_LEFT'   => $htmlLeft,
                'FOOTER_MIDDLE' => $htmlMiddle,
                'FOOTER_RIGHT'  => $htmlRight
            ]
        );
    }
 
 
//--//------------------------------------------------------------------------------------------------------------------
//--//  РАЗДЕЛ ГЕНЕРАЦИИ РОУТОВ
//--//------------------------------------------------------------------------------------------------------------------
 
    public function generateRoutes() {
        $this->routeGenDynamic();
    }
 
    private function routeGenDynamic() {
        $routeMap = [
            'indexPages' => [
                'pattern' => '/',     'controller' => 'Pic',
                'action'  => 'index', 'params'     => []
            ],
            'stack' => [
                'pattern' => '/([-_a-zA-Z0-9]{7})', 'controller' => 'Pic',
                'action'  => 'stack',             'params'     => ['stackName' => 1]
            ],
            'image' => [
                'pattern'    => '/([-_a-zA-Z0-9]{1,6}|[-_a-zA-Z0-9]{8}|[-_a-zA-Z0-9]{9,})',
                'controller' => 'Pic',
                'action'     => 'image',
                'params'     => ['imageName' => 1]
            ]
        ];
 
        $ch = new Lib\RouteCache($this->getSiteId(), $this->getModuleId());
        $ch->clearDynamicRoutes();
 
        foreach($routeMap as $i => $v) {
            $ch->insertDynamicRoute('picHandler', '', $v['pattern'], $v['controller'], $v['action'], $v['params']);
        }
    }
 
    private function calcSize($bytes)
    {
        if ($bytes >= 1073741824)
        {
            $bytes = number_format($bytes / 1073741824, 2) . ' GB';
        }
        elseif ($bytes >= 1048576)
        {
            $bytes = number_format($bytes / 1048576, 2) . ' MB';
        }
        elseif ($bytes >= 1024)
        {
            $bytes = number_format($bytes / 1024, 2) . ' KB';
        }
        elseif ($bytes > 1)
        {
            $bytes = $bytes . ' bytes';
        }
        elseif ($bytes == 1)
        {
            $bytes = $bytes . ' byte';
        }
        else
        {
            $bytes = '0 bytes';
        }
 
        return $bytes;
    }
}
#5Site\Pic\Controller\PicController->generateHtmlForStack
/var/www/fullrest-team/data/www/fullrest.net/Site/Pic/Controller/PicController.php (102)
<?php
//TODO: описание плана
/*
    1. eva-project.members - after insert : вставляем запись в fullres1_phalcon.scl_members
    2. eva-project.members - after update : правим таймеры, мейк группу и остальное
 
    3. eva-project.members_auth - after insert : ставляем запись в fullres1_phalcon.scl_members_auth
 
 
 
 
*/
 
namespace Site\Pic\Controller;
 
use Core\Lib\Calc;
use Core\Lib\Mustache;
use Core\Modules\Pic\Controller\ImageController;
use Core\Modules\Pic\Controller\StackController;
use Core\Extenders\ContentController;
use Phalcon\Db;
use Core\Lib;
 
class PicController extends ContentController
{
    private $pageStart = 1;
    private $pageEnd   = 1;
 
    private $idElizaPicRightBack       = 'elizaPicRightBack';
    private $idElizaPicRightPanel      = 'elizaPicRightPanel';
    private $idElizaPicRightPanelClose = 'elizaPicRightPanelClose';
 
    private $idElizaPicPluploadBtn  = 'elizaPicPluploadBtn';
    private $idElizaPicPluploadZone = 'elizaPicPluploadZone';
 
    private $idElizaPicFooter        = 'elizaPicFooter';
    private $idElizaPicFooterTitle   = 'elizaPicFooterTitle';
    private $idElizaPicFooterNext    = 'elizaPicFooterNext';
    private $idElizaPicFooterPrev    = 'elizaPicFooterPrev';
    private $idElizaPicFooterRoot    = 'elizaPicFooterRoot';
    private $idElizaPicFooterNumbers = 'elizaPicFooterNumbers';
    private $idElizaPicFooterAlbums  = 'elizaPicFooterAlbums';
    private $idElizaPicFooterContent = 'elizaPicFooterContent';
 
    private $idElizaPicTool         = 'elizaPicTool';
    private $idElizaPicToolStackExp = 'elizaPicToolExpand';
    private $idElizaPicToolAddImage = 'ElizaAppPic_addImage'; // К этому айдишнику привязан ЦСС; без надобности не менять.
    private $idElizaPicToolAddStack = 'elizaPicToolAddAlbum';
    private $idElizaPicToolTree     = 'elizaPicToolMoveToAlbum';
    private $idElizaPicToolTrash    = 'elizaPicToolDeleteItems';
    private $idElizaPicToolUnsel    = 'elizaPicToolRemoveSelect';
    
 
    public function initialize()
    {
        $this->overseer->setJSController('pic');
        $this->overseer->setJSAction('picInitialization');
 
        if ($this->request->get('page')) {
            $expl = explode('-', $this->request->get('page'));
 
            if (sizeof($expl) == 2) {
                $start = (int)$expl[0];
                $end   = (int)$expl[1];
 
                if($start <= 0) {
                    $start = 1;
                }
 
                if($end <= 0) {
                    $end = 1;
                }
 
                if($start > $end) {
                    $start = $end;
                }
            }
            else {
                $start = (int)$expl[0];
 
                if(!$start) {
                    $start = 1;
                }
 
                $end = $start;
            }
 
            $this->pageStart = $start;
            $this->pageEnd   = $end;
        }
    }
 
    public function indexAction() {
        if (!$this->user->getId())
            return;
 
        $this->generateHtmlForStack('', $this->user->getId(), 0);
    }
 
 
    public function stackAction($stackName) {
        $this->generateHtmlForStack($stackName, $this->user->getId(), 0);
    }
 
    /**
     * @param $imageName
     */
    public function imageAction($imageName)
    {
        if ($imageName == 'trash') {
            $this->trashAction();
            return;
        }
 
        $image = (new ImageController())->getPageData($imageName);
 
        if (isset($image['restricted'])) {
            $this->htmlGenerateRestrictedAccess('image', $image['restricted']);
 
            return;
        }
 
 
        $this->og->setTitle('Изображение: '.$image['image']['meta']['title']);
 
        if ($image['image']['meta']['descr']) {
            $this->og->setDescr($image['image']['meta']['descr']);
        }
        else {
            $this->og->setDescr('Страница изображения, расположенного на сервисе picain.ru');
        }
 
        $this->og->setImageUrl('/upl/t/'.$image['image']['system']['name'].'_150x150.'.$image['image']['meta']['file']['type']);
        $this->og->setImageType($image['image']['meta']['file']['type']);
        $this->og->setImageSize(150, 150);
 
        $rightContent = '';
        $rightHead    = '';
 
        if ($this->cookies->get('rightMenuActive') == 'true') {
            $rightHead = Mustache::renderWithBinds(
                'app/pic/image_right_head',
                [
                    'texted' => [
                        'text' => 'Информация',
                        'icon' => ['svg' => ['main' => 'ic-info'], 'size' => 'small']
                    ],
                    'close' => [
                        'id'    => $this->idElizaPicRightPanelClose,
                        'title' => 'панель информации'
                    ],
                    'lang' => [
                        'close' => 'Закрыть'
                    ]
                ]
            );
            
            $hostName = $this->request->getHttpHost();
 
            $copyPage   = 'http://'.$hostName.'/'. $image['image']['system']['name'];
            $copyUrl    = 'http://'.$hostName.'/'.$image['image']['system']['name'].'.'.$image['image']['meta']['file']['type'];
            $copyThumb  = 'http://'.$hostName.'/upl/t/'. $image['image']['system']['name'].'_150x150.'.$image['image']['meta']['file']['type'];
            $copyHtml   = '<a title=\''.$image['image']['meta']['title'].'\' href=\''.$copyPage.'\' target=\'_blank\'><img alt=\''.$image['image']['meta']['title'].'\' src=\''.$copyThumb.'\' /></a>';
            $copyBBCode = '[url='.$copyPage.'][img]'.$copyThumb.'[/img][/url]';
            $resolution = $image['image']['meta']['file']['width'].'×'.$image['image']['meta']['file']['height'];
 
            $info = [
                ['tag' => 'time', 'title' => 'Добавлено:',    'value' => Lib\DateFuncs::dateFormatTextedMonthAndTime($image['image']['system']['date']),],
                ['tag' => 'span', 'title' => 'Разрешение:',   'value' => $resolution],
                ['tag' => 'span', 'title' => 'Просмотры:',    'value' => $image['image']['meta']['views']['count']],
                ['tag' => 'span', 'title' => 'Размер файла:', 'value' => Calc::fileSize($image['image']['meta']['file']['size'])]
            ];
 
            $links_html = '';
    
            $links = [
                ['title' => 'Ссылка', 'value' => $copyUrl   ],
                ['title' => 'HTML',   'value' => $copyHtml  ],
                ['title' => 'BBCode', 'value' => $copyBBCode]
            ];
 
            for($a = 0; $a <3; $a++) {
                $item = $links[$a];
 
                $links_html .= Mustache::renderWithBinds(
                    'forms/base_input',
                    [
                        'title' => $item['title'],
                        'input' => [
                            'tag'    => 'input',
                            'class'  => 'input code',
                            'value'  =>  $item['value'],
                            'type'   => 'text',
                            'style'  => 'default',
                            'size'   => 'medium',
                            'tone'   => 'dark',
                            'radius' => 'rad',
                            'bg'     => 'grey 200',
                            'short'  =>  1
                        ],
                        'icon_left' => [
                            'tag'      => 'span',
                            'position' => 'left',
                            'tone'     => 'dark',
                            'bg'       => 'grey 200',
                            'icon' => [
                                'svg'    => ['main' => 'ic-earth'],
                                'size'   => 'small',
                                'radius' => 'rad'
                            ]
                        ]
                    ]
                );
            }
 
 
 
            $rightContent = Mustache::renderWithBinds(
                'app/pic/image_right_content',
                [
                    'id_descr' => 'elizaPicImageDescr',
                    'isChild'  => $image['image']['system']['parent'] ? 1 : 0,
                    'parent' =>  ''/*imageParent*/,
                    'member' =>  $image['member'],
                    'stack' =>  'stack',
                    'restrict' =>  $image['restrict'],
                    'description' =>  $image['description'],
                    'meta' =>  [
                        'title' =>        $image['image']['meta']['title'],
                        'description' => ''
                    ],
                    'info' =>    $info,
                    'links_html' => $links_html
                ]
            );
 
        }
 
        $windowHtml = $this->htmlGenerateWindow("image", json_encode($image),
            Mustache::renderWithBinds(
                'eliza/toolbar_panel', ['floated' => 'floated', 'size' => 'contentLarge'],
                [
                    'TOOLBAR_MIDDLE' => $this->htmlGenerateUserPanel($type = 'image', $image),
                    'TOOLBAR_RIGHT'  => Mustache::renderWithBinds(
                        'eliza/toolbar_button',
                        [
                            'tag'     => 'div',
                            'class'   => 'sep',
                            'default' => 0
                        ]
                    ).Mustache::renderWithBinds(
                        'eliza/toolbar_button',
                        [
                            'id'     => $this->idElizaPicRightPanel,
                            'tag'    => 'div',
                            'title'  => 'Правая панель',
                            'class'  => 'rpanel'. ($this->cookies->get('rightMenuActive') == 'true' ? ' active' : '' ),
                            'setts'  => ['type' => 'default', 'link' => 1, 'tip_h' => 'dtr'],
                            'icon'   => ['svg' => ['main' => 'ic-rpanel'], 'size' => 'small'],
                            'border' => ['enable' => 1, 'lines' => 'bottom', 'color' => 'blue']
                        ]
                    ).Mustache::renderWithBinds(
                            'eliza/toolbar_button',
                            [
                                'id'     => $this->idElizaPicRightBack,
                                'tag'    => 'div',
                                'title'  => 'Назад',
                                'class'  => 'back',
                                'setts'  => ['type' => 'default', 'link' => 1, 'tip_h' => 'dtr'],
                                'icon'   => ['svg' => ['main' => 'ic-arrow-left2'], 'size' => 'small'],
                                'border' => ['enable' => 1, 'lines' => 'bottom', 'color' => 'blue']
                            ]
                    )
                ]
            ),
            Mustache::renderWithBinds(
                'app/pic/image',
                [
 
                    'vcont'   => 'elizaPicImageCont',
                    'viewer'  => 'elizaPicImageViewer',
                    'cropper' => 'elizaPicImageCropper',
                    'title'   => $image['image']['meta']['title'],
                    'name'    => $image['image']['system']['name'],
                    'type'    => $image['image']['meta']['file']['type'],
                    'width'   => $image['image']['meta']['file']['width'],
                    'height'  => $image['image']['meta']['file']['height']
                ]
            ),
            $this->htmlGenerateFooter($type = 'image', $image),
            $rightContent,
            $rightHead
        );
 
        $windowHtml = mbereg_replace(
            'data-layout="cnt_content_content"',
            'data-layout="cnt_content_content" data-elz-bg="grey 900"',
            $windowHtml
        );
 
        if ($this->cookies->get('rightMenuActive') == 'true') {
            $windowHtml = mbereg_replace(
                'elz tplCLSgrid cells',
                'elz tplCLSgrid cells showside',
                $windowHtml
            );
 
        }
 
        $this->view->setVar('picHtml', $windowHtml);
    }
 
    public function trashAction() {
        if (!$this->user->getId())
            return;
 
        $this->generateHtmlForStack('trash', $this->user->getId(), -1);
    }
 
 
    public function generateHtmlForStack($stackName, $memberId, $stackId)
    {
        if ($stackName == '' && $this->user->isNotActivated()) {
            $this->htmlGenerateRestrictedAccess('stack', ['code' => 'activation', 'data' => '']);
            return;
        }
 
        $stackController = (new StackController())->initialize();
 
        $metaData = $stackController->getName($stackName ? $stackName : 'root');
 
        if ($metaData['restricted']) {
            $this->htmlGenerateRestrictedAccess('stack', $metaData['restricted']);
            return;
        }
 
        //die($metaData['pages']);
 
        if ($this->pageStart > $metaData['pages']) {
            $this->pageStart = $metaData['pages'];
        }
 
        if ($this->pageEnd > $metaData['pages']) {
            $this->pageEnd = $metaData['pages'];
        }
 
        if ($stackName == '' || $stackName == 'trash') {
            $state = "list ".($stackName ? "trash" : "root");
 
            $itemList = $stackController->getItemsList($memberId, $stackId, ['start' => $this->pageStart, 'end' => $this->pageEnd]);
        }
        else {
            $itemList = $stackController->getItemsListByName($stackName,    ['start' => $this->pageStart, 'end' => $this->pageEnd]);
 
            $state = "list album";
        }
 
        $contentHtml = '';
 
        if (/*(!$stackId && !$stackName) ||*/ $stackName == 'trash' || $this->pageStart > 1 || $metaData['owner'] != $this->user->getId() /*|| ($stackName && sizeof($itemList))*/) {
            $uploadCls = ' hide';
        }
        else {
            $uploadCls = '';
        }
 
 
        $contentHtml = '<div class="elz picCLSupload'.(!sizeof($itemList) ? ' empty' : '').$uploadCls.'">'.Mustache::renderWithBinds(
            'common/upload_zone',
            [
                'id'    => $this->idElizaPicPluploadBtn,
                'parent_id'   => $this->idElizaPicPluploadZone,
                'description' => !sizeof($itemList) ?
                    ('<p class="bb p al-center"><span class="bb fn-12">В этом альбоме ещё нет изображений</span>'.
                     '<br>Выберите изображения для загрузки, нажав на эту область, или перетащите файлы сюда<br>'.
                     '<span class="bb fn-8">Ограничение на размер файла: <b class="bb bold">10 mb</b></span>'.
                     '</p>')
                    :
                    ('<p class="bb p al-center"><span class="bb fn-12">Выберите файлы</span>'.
                     '<br>Или перетащите в эту область<br>'.
                     'Вы можете сделать снимок экрана и нажать <b class="bb bold">[Ctrl + V]</b><br>'.
                     '<span class="bb fn-8">Ограничение на размер файла: <b class="bb bold">10 mb</b></span>'.
                     '</p>'),
                'icon' => [
                    'svg' => [
                        'main' => $stackName == 'root' || $stackName == '' ? 'ic-image' : 'ic-images',
                        'sub' =>  'ic-plus'
                    ],
                    'color' => ['subbg' => 'blue']],
                'circle' => ['size' => 'large ', 'radius' => '55', 'color' => 'blue']
            ]
        ).'</div>';
        //}
 
 
        $contentHtml .= Mustache::renderWithBinds(
            'app/pic/items_list',
            [
                'id'   => 'elizaPicContentStackList',
                'list' => $itemList, 'iconEnabled' => $stackName == '' || $stackName == 'trash' ? 0 : 1,
                'lang' => [
                    'title1'    => 'Размер изображения',
                    'title2'    => 'Вариаций изображения',
                    'title3'    => 'Формат изображения',
                    'title4p1'  => 'Является',
                    'title4p2'  => 'Сделать',
                    'title4p3'  => 'иконкой альбома',
                    'title5'    => 'Альбомов внутри',
                    'title6'    => 'Изображений в альбоме',
                    'title7'    => 'Альбом',
                    'title8'    => 'Дней до удаления',
                    'title9'    => 'Изображение',
                    'title10'   => 'Иконка альбома',
                    'title11'   => 'Доступ ограничен',
                    'title12p1' => 'Доступно только пользователям старше',
                    'title12p2' => 'лет',
                    'title13'   => 'Доступно только вам',
                    'title14'   => 'Доступно только автору',
                    'title15'   => 'Доступно только по прямой ссылке'
                ]
            ]
        );
 
 
        $this->view->setVar('picHtml',
            $this->htmlGenerateWindow($state, json_encode($metaData),
                Mustache::renderWithBinds(
                    'eliza/toolbar_panel', ['floated' => 'floated', 'size' => 'contentLarge'],
                    [
                        'TOOLBAR_MIDDLE' => $this->htmlGenerateUserPanel($type = 'stack', $metaData, $stackName),
                        'TOOLBAR_RIGHT'  =>  Mustache::renderWithBinds(
                            'eliza/toolbar_button',
                            [
                                'id'     => $this->idElizaPicRightPanel,
                                'tag'    => 'div',
                                'title'  => 'Правая панель',
                                'class'  => 'rpanel hide',
                                'setts'  => ['type' => 'default', 'link' => 1, 'tip_h' => 'dtr'],
                                'icon'   => ['svg' => ['main' => 'ic-rpanel'], 'size' => 'small'],
                                'border' => ['enable' => 1, 'lines' => 'bottom', 'color' => 'blue']
                            ]
                        ).Mustache::renderWithBinds(
                                'eliza/toolbar_button',
                                [
                                    'id'     => $this->idElizaPicRightBack,
                                    'tag'    => 'div',
                                    'title'  => 'Назад',
                                    'class'  => 'back'.($stackName == '' ? ' hide' : ''),
                                    'setts'  => ['type' => 'default', 'link' => 1, 'tip_h' => 'dtr'],
                                    'icon'   => ['svg' => ['main' => 'ic-arrow-left2'], 'size' => 'small'],
                                    'border' => ['enable' => 1, 'lines' => 'bottom', 'color' => 'blue']
                                ]
                        )]
                ),
                Mustache::renderWithBinds(
                    'eliza/scroll_content',
                    ['id' => 'elizaPicContentScroll', 'abs' => 'abs'],
                    ['CONTENT' => $contentHtml]
                ),
                $this->htmlGenerateFooter($type = 'stack', $metaData)
            )
        );
    }
 
 
    private function htmlGenerateWindow($state, $data, $topHeader, $cntContent, $cntFooter, $rightContent = '', $rightHead = '') {
        return Mustache::renderWithBinds(
            'eliza/window',
            [
                'setts' => [
                    'id'     => 'ElizaAppPic',
                    'app'    => 'pic',
                    'state'  => $state,
                    'zindex' => 1,
                    'data'   => $data ? ' data-meta=\''.$data.'\' ' : '',
                    'isFullscreen' => 1
                ],
                'class'  => 'standalone',
                'enable' => [
                    'content' => ['cnt' => ['subfooter' => 1,'footer' => 1]],
                    'right'   => ['cnt' => [],'footer' => 1]
                ]
            ],
            [
                'TOP_HEADER' => $topHeader,
                'CNT_CONTENT_CONTENT'   => $cntContent,
                'CNT_CONTENT_FOOTER'    => $cntFooter,
                'CNT_CONTENT_SUBFOOTER' => Mustache::renderWithBinds(
                    'app/pic/image_slider',
                    [
                        'id' => [
                            'main'        => 'elizaPicImageSlider',
                            'list'        => 'elizaPicImageSliderList',
                            'crop'        => 'elizaPicImageSliderCrop',
                            'title'       => 'elizaPicImageSliderTitle',
                            'crop_create' => 'elizaPicThumbCreate',
                            'crop_form'   => 'elizaPicThumbForm'
                        ],
                        'lang' => [
                            'text' =>   'Изображения в альбоме',
                            'title1' => 'Закрыть',
                            'title2' => 'Создать новую миниатюру',
                            'item' =>   'Новая миниатюра'
                        ]
                    ]
                ),
                'RIGHT_CNT_CONTENT' => $rightContent,
                'RIGHT_HEADER'      => $rightHead
            ]
        );
    }
 
 
    private function htmlGenerateRestrictedAccess($type = 'stack', $meta) {
 
 
        $statuses = [
            'private' => [
                'icon' =>  ['name' => "ic-eye-blocked", 'bg' => "red 700", 'txt' => ""],
                'descr' => "Эта страница доступна только её автору."
            ],
            'age' => [
                'icon' =>  ['name' => "", 'bg' => "red 700", 'txt' => $meta['data'].'+'],
                'descr' => 'Эта страница запрещена для просмотра лицам, не достигшим возраста '.$meta['data'].' лет.'
            ],
            'missing' => [
                'icon' =>  ['name' => "", 'bg' => "red 700", 'txt' => "404"],
                'descr' => "Страница не найдена."
            ],
            'guest' => [
                'icon' =>  ['name' => "ic-user", 'bg' => "red 700", 'txt' => ""],
                'descr' => "Для доступа к функционалу требуется регистрация."
            ],
            'activation' => [
                'icon' =>  ['name' => "ic-key", 'bg' => "blue", 'txt' => ""],
                'descr' => "Для использования данного сервиса необходима активация."
            ]
        ];
 
        $data = $statuses[$meta['code']];
 
        $html = Mustache::renderWithBinds(
            'eliza/window',
            [
                'setts' => [
                    'id'    => 'ElizaAppPic',
                    'app'   =>   'pic',
                    'state' => 'default',
                    'isFullscreen' => 1,
                    'zindex' => 1
                ],
                'enable' => [
                    'content' => ['cnt' => ['subfooter' => 1,'footer' => 1]],
                    'right'   => ['cnt' => [],'footer' => 1]
                ]
            ],
            [
                'TOP_HEADER' => Mustache::renderWithBinds('eliza/toolbar_panel', ['floated' => 'floated', 'size' => 'contentLarge'], []),
                'CNT_CONTENT_CONTENT' => Mustache::renderWithBinds(
                    'eliza/forbidden',
                    [
                        'tone' => $type == 'image' ? 'light' : 'dark',
                        'icon' => [
                            'svg'   => ['main' => 'ic-lock', 'sub' =>  $data['icon']['name']],
                            'txt'   => ['sub' => $data['icon']['txt']],
                            'color' => ['subbg' => $data['icon']['bg']]
                        ],
                        'description' => $data['descr']
                    ]
                )
            ]
        );
 
        if ($type == 'image') {
            $html = mbereg_replace(
                'data-layout="cnt_content_content"',
                'data-layout="cnt_content_content" data-elz-bg="grey 900"',
                $html
            );
        }
        
        $this->view->setVar('picHtml', $html);
    }
 
 
 
 
    private function htmlGenerateUserPanel($type = 'stack', $metaData, $stackName ='') // stack, image, trash
    {
        $buttonsHtml = '';
        $buttonsTransformHtml = '';
        $buttons = [];
        $toolbarHtml = '';
 
        $editable = $type == 'stack' ? $metaData['editable'] : $metaData['image']['access']['editing'];
 
        if ($this->user->isNotActivated()) {
            return '';
        }
 
        if ($type == 'stack' && $editable) {
            $buttons = [];
 
            if ($stackName != "trash") {
                if ($stackName != '' && $stackName != 'root') {
                    $buttons[] = [
                        'id'    => 'elizaPicImagePageMeta',
                        'tag'   => 'div',
                        'title' => 'Редактировать описание',
                        'align' => 'right',
                        'icon'  => [
                            'svg'   => ['main' => 'ic-pencil'],
                            'size'  => 'small'
                        ]
                    ];
                }
 
                $buttons[] = [
                    'id'    => $this->idElizaPicToolAddImage,
                    'tag'   => 'label',
                    'title' => 'Загрузить изображения',
                    'align' => 'right',
                    'icon'  => [
                        'svg'   => ['main' => 'ic-image', 'sub' => 'ic-plus'],
                        'size'  => 'small',
                        'color' => ['subbg' => 'blue']]
                ];
 
                $buttons[] = [
                    'id'    => $this->idElizaPicToolAddStack,
                    'tag'   => 'div',
                    'title' => 'Добавить альбом',
                    'align' => 'right',
                    'icon'  => [
                        'svg'   => ['main' => 'ic-folder', 'sub' => 'ic-plus'],
                        'size'  => 'small',
                        'color' => ['subbg' => 'blue']]
                ];
 
                $buttons[] = [
                    'id'    => $this->idElizaPicToolTree,
                    'tag'   => 'div',
                    'title' => 'Проводник по альбомам',
                    'align' => 'right',
                    'icon'  => [
                        'svg'  => ['main' => 'ic-foldertree'],
                        'size' => 'small']
                ];
 
                /*$buttons = [
                    [
                        'id'    => 'ElizaAppPic_addImage',
                        'tag'   => 'label',
                        'title' => 'Загрузить изображения',
                        'align' => 'right',
                        'icon'  => [
                            'svg'   => ['main' => 'ic-image', 'sub' => 'ic-plus'],
                            'size'  => 'small',
                            'color' => ['subbg' => 'blue']]
                    ],
                    [
                        'id'    => 'ElizaAppPic_addAlbum',
                        'tag'   => 'div',
                        'title' => 'Добавить альбом',
                        'align' => 'right',
                        'icon'  => [
                            'svg'   => ['main' => 'ic-folder', 'sub' => 'ic-plus'],
                            'size'  => 'small',
                            'color' => ['subbg' => 'blue']]
                    ],
                    [
                        'id'    => 'ElizaAppPic_moveToAlbum',
                        'tag'   => 'div',
                        'title' => 'Проводник по альбомам',
                        'align' => 'right',
                        'icon'  => [
                            'svg'  => ['main' => 'ic-foldertree'],
                            'size' => 'small']
                    ],
                ];*/
            }
 
            $buttons[] = [
                'id'     => $this->idElizaPicToolTrash,
                'tag'    => 'a',
                'title'  => 'Показать удаленное',
                'align'  => 'right',
                'class'  => $stackName == 'trash' ? ' active' : '',
                'border' => [
                    'enable' => 1,
                    'lines'  => 'bottom',
                    'color'  => 'red 800'],
                'icon'  => [
                    'svg'  => ['main' => $stackName == 'trash' ? 'ic-loop' :'ic-trash'],
                    'size' => 'small'],
                'href' => '/trash'
            ];
 
            $length = sizeof($buttons);
 
            for($a = 0; $a < $length; $a++) {
                $item = $buttons[$a];
 
                $buttonsHtml .= Mustache::renderWithBinds(
                    'eliza/toolbar_button',
                    [
                        'id'    => $item['id'],
                        'tag'   => $item['tag'],
                        'title' => $item['title'],
                        'class' => isset($item['class']) ? $item['class'] : '',
                        'setts' => ['type' => 'default', 'align' => $item['align'], 'link' => 1],
                        'text'  => ['str' => $item['title'], 'align' => 'left'],
                        'icon'  => $item['icon'],
                        'href'  => isset($item['href']) ? $item['href'] : '',
                        'border'  => isset($item['border']) ? $item['border'] : ''
                    ]
                );
            }
 
            $toolbarHtml = Mustache::renderWithBinds(
                'eliza/toolbar_group',
                [
                    'active'   => '',
                    'position' => 'right',
                    'xsub'     => '320',
                    'v_pos'    => 'top',
                    'h_pos'    => 'right'
                ],
                [
                    'TOOL_TRIGGER' => Mustache::renderWithBinds(
                        'eliza/toolbar_button',
                        [
                            'id'    => $this->idElizaPicToolStackExp,
                            'tag'   => 'div',
                            'title' => 'Показать правую панель',
                            'setts' => ['type' => 'default', 'align' => 'right', 'link' => 1],
                            'icon'  => ['svg' => ['main' => 'ic-more1'], 'size' => 'small', 'radius' => 'rad']
                        ]),
                    'TOOL_LIST' => $buttonsHtml
                ]
            );
        }
        else if ($type == 'image'){
            $type = $metaData['image']['meta']['file']['type'];
            $name = $metaData['image']['system']['name'];
 
            $buttons[] = [
                'id'    => 'elizaPicImagePageDownload',
                'title' => 'Скачать изображение',
                'tag'   => 'a',
                'href' => '/'.$name.'.'.$type,
                'data' => ' download="'.$name.'.'.$type.'" ',
                'align' => 'right',
                'icon'  => ['svg' => ['main' => 'ic-download'], 'size' => 'small', 'radius' => 'rad']
            ];
 
            $buttonsTransform = [];
 
            if ($editable) {
                if (!$metaData['image']['system']['parent']) {
                    $buttons[] = [
                        'id'    => 'elizaPicImagePageTree',
                        'title' => 'Переместить изображение',
                        'tag'   => 'div',
                        'align' => 'right',
                        'icon'  => [
                            'svg'   => ['main' => 'ic-foldertree', 'sub' => 'ic-arrow-left'],
                            'size'  => 'small',
                            'color' => ['subbg' => 'blue']]
                    ];
                }
 
                $buttons[] = [
                    'id'    => 'elizaPicImagePageCrop',
                    'title' => 'Создать миниатюру',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => [
                        'svg'   => ['main' => 'ic-crop'],
                        'size'  => 'small'
                    ],
                    'border' => [
                        'enable' => 1,
                        'lines'  => 'bottom',
                        'color'  => 'green'
                    ]
                ];
 
                $buttons[] = [
                    'id'    => 'elizaPicImagePageEdit',
                    'title' => $metaData['image']['system']['parent'] ? 'Редактирование изображения' : 'Создать вариацию',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => [
                        'svg'   => ['main' => 'ic-wand', 'sub' => $metaData['image']['system']['parent'] ? 'ic-pencil' : 'ic-plus'],
                        'size'  => 'small',
                        'color' => ['subbg' => 'blue']],
                    'border' => [
                        'enable' => 1,
                        'lines'  => 'bottom',
                        'color'  => 'green'
                    ]
                ];
 
                $buttons[] = [
                    'id'    => 'elizaPicImagePageMeta',
                    'title' => 'Редактировать описание',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => [
                        'svg'   => ['main' => 'ic-pencil'],
                        'size'  => 'small']
                ];
 
                $buttons[] = [
                    'id'     => 'elizaPicImagePageDelete',
                    'title'  => 'Удалить',
                    'tag'    => 'div',
                    'align'  => 'right',
                    'icon'  => [
                        'svg'  => ['main' => 'ic-trash'],
                        'size' => 'small']
                ];
 
                $buttonsTransform[] = [
                    'id'    => 'elizaImageTransformMirrorHorizontal',
                    'title' => 'Отразить по горизонтали',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => ['svg' => ['main' => 'ic-mirror-h'], 'size' => 'small']
                ];
 
                $buttonsTransform[] = [
                    'id'    => 'elizaImageTransformMirrorVertical',
                    'title' => 'Отразить по вертикали',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => ['svg' => ['main' => 'ic-mirror-v'], 'size' => 'small']
                ];
 
                $buttonsTransform[] = [
                    'id'    => 'elizaImageTransformRotateLeft',
                    'title' => 'Повернуть против часовой стрелки',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => ['svg' => ['main' => 'ic-rotateclockcw'], 'size' => 'small']
                ];
 
                $buttonsTransform[] = [
                    'id'    => 'elizaImageTransformRotateRight',
                    'title' => 'Повернуть по часовой стрелке',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => ['svg' => ['main' => 'ic-rotateclockw'], 'size' => 'small']
                ];
 
                $length = sizeof($buttonsTransform);
 
                for($a = 0; $a < $length; $a++) {
                    $item = $buttonsTransform[$a];
 
                    $buttonsTransformHtml .= Mustache::renderWithBinds(
                        'eliza/toolbar_button',
                        [
                            'id'     => $item['id'],
                            'tag'    => $item['tag'],
                            'title'  => $item['title'],
                            'setts'  => ['type' => 'default', 'align' => $item['align'], 'link' => 1],
                            'text'   => ['str' => $item['title'], 'align' => 'left'],
                            'icon'   => $item['icon'],
                            'border' => isset($item['border']) ? $item['border'] : []
                        ]
                    );
                }
 
                $buttonsTransformHtml .= Mustache::renderWithBinds(
                    'eliza/toolbar_button',
                    [
                        'tag'     => 'div',
                        'class'   => 'sep',
                        'default' => 0,
                        'setts'   => ['align' => 'right']
                    ]
                );
            }
 
            $length = sizeof($buttons);
 
            for($a = 0; $a < $length; $a++) {
                $item = $buttons[$a];
 
                $buttonsHtml .= Mustache::renderWithBinds(
                    'eliza/toolbar_button',
                    [
                        'id'     => $item['id'],
                        'tag'    => $item['tag'],
                        'title'  => $item['title'],
                        'href'   => isset($item['href']) ? $item['href'] : '',
                        'data'   => isset($item['data']) ? $item['data'] : '',
                        'setts'  => ['type' => 'default', 'align' => $item['align'], 'link' => 1],
                        'text'   => ['str' => $item['title'], 'align' => 'left'],
                        'icon'   => $item['icon'],
                        'border' => isset($item['border']) ? $item['border'] : []
                    ]
                );
            }
 
            $toolbarHtml = ($editable ? Mustache::renderWithBinds(
                'eliza/toolbar_group',
                [
                    'id'       => 'elizaImageToolGroupTransform',
                    'active'   => '',
                    'ordered'  => 'ordered',
                    'position' => 'right',
                    'xsub'     => '768',
                    'v_pos'    => 'top',
                    'h_pos'    => 'right'
                ],
                [
                    'TOOL_TRIGGER' => Mustache::renderWithBinds(
                        'eliza/toolbar_button',
                        [
                            'id'    => 'elizaImageTransformExpand',
                            'tag'   => 'div',
                            'title' => 'Трансформация изображения',
                            'setts' => ['type' => 'default', 'align' => 'right', 'link' => 1],
                            'icon'  => ['svg' => ['main' => 'ic-fix'], 'size' => 'small', 'radius' => 'rad'],
                            'border' => [
                                'enable' => 1,
                                'lines'  => 'bottom',
                                'color'  => 'blue'
                            ]
                        ]),
                    'TOOL_LIST' => $buttonsTransformHtml
                ]
            ) : '').Mustache::renderWithBinds(
                    'eliza/toolbar_group',
                    [
                        'id'       => 'elizaImageToolGroupMain',
                        'active'   => '',
                        'ordered'  => 'ordered',
                        'position' => 'right',
                        'xsub'     => '540',
                        'v_pos'    => 'top',
                        'h_pos'    => 'right'
                    ],
                    [
                        'TOOL_TRIGGER' => Mustache::renderWithBinds(
                            'eliza/toolbar_button',
                            [
                                'id'    => 'elizaImageToolGroupExpand',
                                'tag'   => 'div',
                                'title' => 'Действия',
                                'setts' => ['type' => 'default', 'align' => 'right', 'link' => 1],
                                'icon'  => ['svg' => ['main' => 'ic-more1'], 'size' => 'small', 'radius' => 'rad'],
                                'border' => [
                                    'enable' => 1,
                                    'lines'  => 'bottom',
                                    'color'  => 'blue'
                                ]
                            ]),
                        'TOOL_LIST' => $buttonsHtml
                    ]
                );
        }
 
 
 
 
        return $toolbarHtml;
    }
 
 
    private function htmlGenerateFooter($type = 'stack', $metaData)
    {
        $htmlLeft   = '';
        $htmlMiddle = '';
        $htmlRight  = '';
 
        if ($type == 'stack') {
            $midButtons = [
                'left'  => ['class' => '', 'tag' => 'a'],
                'right' => ['class' => '', 'tag' => 'a'],
                'root'  => ['class' => '', 'tag' => 'a']
            ];
 
            if ($metaData['name'] === "root") {
                $rooTitle = "Перейти на первую страницу";
 
                if ($this->pageEnd === 1) {
                    $midButtons['root']['class'] = "disabled";
                }
            }
            else {
                $rooTitle = !$metaData['parent'] ? ($this->user->getId() ? "Перейти в корень" : "Перейти на главную страницу") : "Наверх";
            }
 
            if ($this->pageStart <= 1) {
                $midButtons['left']  = ['class' => 'disabled', 'tag' => 'div'];
            }
 
            if ($this->pageEnd >= $metaData['pages']) {
                $midButtons['right'] = ['class' => 'disabled', 'tag' => 'div'];
            }
 
            if (!$this->user->isNotActivated() || ($this->user->isNotActivated() && $metaData['name'] != "root")) {
                $htmlLeft .=  Mustache::renderWithBinds('eliza/toolbar_button',
                    [
                        'id'    => $this->idElizaPicFooterAlbums,
                        'tag'   => 'div',
                        'title' => 'Показать только альбомы',
                        'setts' => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtl'],
                        'icon'  => ['svg' => ['main' => 'ic-foldertree'], 'size' => 'small']
                    ]
                );
 
 
                $htmlLeft .=  Mustache::renderWithBinds('eliza/toolbar_button',
                    [
                        'id'    => $this->idElizaPicFooterContent,
                        'tag'   => 'div',
                        'title' => 'Показать только связанное с контентом',
                        'setts' => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtl'],
                        'icon'  => ['svg' => ['main' => 'ic-sharedfile'], 'size' => 'small']
                    ]
                );
            }
 
 
            $htmlLeft .=  Mustache::renderWithBinds('eliza/toolbar_title',
                [
                    'id'   => $this->idElizaPicFooterTitle,
                    'text' => $metaData['title']
                ]
            );
 
 
            $htmlMiddle .=  Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => $this->idElizaPicFooterPrev,
                    'tag'   => $midButtons['left']['tag'],
                    'href'  => '/'.($metaData['name'] == "root" ? '' : $metaData['name']).'?page='.($this->pageStart - 1),
                    'title' => 'Предыдущая страница',
                    'class' => $midButtons['left']['class'],
                    'setts' => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb'],
                    'icon'  => ['svg' => ['main' => 'ic-move-left'], 'size' => 'small']
                ]
            );
 
 
            $htmlMiddle .=  Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => $this->idElizaPicFooterRoot,
                    'tag'   => $midButtons['root']['tag'],
                    'href'  => '/'.($metaData['parent'] ? $metaData['parent'] : ''),
                    'title' => $rooTitle,
                    'class' => $midButtons['root']['class'],
                    'setts' => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb'],
                    'icon'  => ['svg' => ['main' => 'ic-gallery3'], 'size' => 'small']
                ]
            );
 
            $htmlMiddle .=  Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => $this->idElizaPicFooterNext,
                    'tag'   => $midButtons['right']['tag'],
                    'href'  => '/'.($metaData['name'] == "root" ? '' : $metaData['name']).'?page='.($this->pageEnd + 1),
                    'title' => 'Следующая страница',
                    'class' => $midButtons['right']['class'],
                    'setts' => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb'],
                    'icon'  => ['svg' => ['main' => 'ic-move-right'], 'size' => 'small']
                ]
            );
 
            $number = $this->pageStart != $this->pageEnd ? $this->pageStart.'-'.$this->pageEnd : $this->pageStart;
 
            $htmlRight .= Mustache::renderWithBinds(
                'eliza/toolbar_num_of_num',[
                    'id'      => $this->idElizaPicFooterNumbers,
                    'current' => $number,
                    'total'   => $metaData['pages'] ? $metaData['pages'] : 1
                ]
            );
 
            $htmlRight .= Mustache::renderWithBinds(
                'eliza/toolbar_button',[
                    'id'      => $this->idElizaPicToolUnsel,
                    'tag'     => 'div',
                    'title'   => 'Сбросить выделение',
                    'class'   => 'hide',
                    'setts' => ['type' => 'default', 'align' => 'right', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtr'],
                    'icon'  => ['svg' => ['main' => 'ic-selectremove'], 'size' => 'small']
                ]
            );
        }
        else {
            if ($metaData['image']['system']['parent']) {
                $upButton = '/'.$metaData['image']['system']['prow']['name'];
                $upTitle  = 'Перейти к оригиналу';
            }
            else {
                $upButton = $metaData['page']['up'] !== 'root' ? '/'.$metaData['page']['up'] : '/';
                $upTitle  = $metaData['page']['up'] !== 'root' ? 'Перейти в альбом' : ($this->user->getId() ? 'Перейти в корень' : 'Перейти на главную страницу');
            }
 
            $htmlLeft .=  Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'     => 'elizaPicImageFooterVariations',
                    'title'  => 'Вариации изображения',
                    'tag'    => 'div',
                    'class'  => !$metaData['image']['meta']['numbs']['variations'] && !$metaData['image']['system']['parent'] ? 'hide' : '',
                    'setts'  => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtl'],
                    'icon'   => ['svg' => ['main' => 'ic-wand'], 'size' => 'small'],
                    'border' => ['enable' => 1, 'lines' => 'top', 'color' => 'green']
                ]
            );
 
            $htmlLeft .=  Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'     => 'elizaPicImageFooterContent',
                    'tag'    => 'div',
                    'title'  => 'Связи с контентом',
                    'class'  => !$metaData['image']['flags']['isContent'] ? 'hide' : '',
                    'setts'  => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtl'],
                    'icon'   => ['svg' => ['main' => 'ic-sharedfile'], 'size' => 'small'],
                    'border' => ['enable' => 1, 'lines' => 'top', 'color' => 'orange']
                ]
            );
 
            $htmlLeft .=  Mustache::renderWithBinds('eliza/toolbar_title',
                [
                    'id'   => $this->idElizaPicFooterTitle,
                    'text' => $metaData['image']['meta']['title']
                ]
            );
 
 
            $htmlMiddle .= Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => $this->idElizaPicFooterPrev,
                    'tag'   => $metaData['page']['prev'] != "" ? 'a' : 'div',
                    'href'  => '/'.$metaData['page']['prev'],
                    'title' => 'Предыдущее изображение',
                    'class' => $metaData['page']['prev'] != "" && !$metaData['image']['system']['parent'] ? '' : 'disabled',
                    'setts' => ['type' => 'default', 'align' => 'left', 'link' => $metaData['page']['prev'] != "" ? 1 : 0, 'tip_v' => 'dtb'],
                    'icon'  => ['svg' => ['main' => 'ic-move-left'], 'size' => 'small']
                ]
            );
 
            $htmlMiddle .= Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => $this->idElizaPicFooterRoot,
                    'tag'   => 'a',
                    'href'  => $upButton,
                    'title' => $upTitle,
                    'class' => !$metaData['page']['up'] ? 'disabled' : '',
                    'setts' => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb'],
                    'icon'  => ['svg' => ['main' => 'ic-gallery3'], 'size' => 'small']
                ]
            );
 
            $htmlMiddle .= Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => $this->idElizaPicFooterNext,
                    'tag'   => $metaData['page']['next'] != "" ? 'a' : 'div',
                    'href'  => '/'.$metaData['page']['next'],
                    'title' => 'Следующее изображение"',
                    'class' => $metaData['page']['next'] != "" && !$metaData['image']['system']['parent'] ? '' : 'disabled',
                    'setts' => ['type' => 'default', 'align' => 'left', 'link' => $metaData['page']['next'] != "" ? 1 : 0, 'tip_v' => 'dtb'],
                    'icon'  => ['svg' => ['main' => 'ic-move-right'], 'size' => 'small']
                ]
            );
 
 
 
            $htmlRight .= Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => 'elizaPicImageFooterThumbs',
                    'tag'   => 'div',
                    'title' => 'Доступные миниатюры',
                    'setts' => ['type' => 'default', 'align' => 'right', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtr'],
                    'icon'  => ['svg' => ['main' => 'ic-crop2'], 'size' => 'small'],
                    'border' => ['enable' => 1, 'lines' => 'top', 'color' => 'blue']
                ]
            );
 
            $htmlRight .= Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => 'elizaPicImageFooterSiblings',
                    'tag'   => 'div',
                    'class'  => ((!$metaData['page']['prev']   && !$metaData['page']['next']) ||
                                   $metaData['stack'] == 'root' || $metaData['image']['system']['parent']) ? 'hide' : '',
                    'title' => 'Изображения в альбоме',
                    'setts' => ['type' => 'default', 'align' => 'right', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtr'],
                    'icon'  => ['svg' => ['main' => 'ic-gallery1'], 'size' => 'small'],
                    'border' => ['enable' => 1, 'lines' => 'top', 'color' => 'blue']
                ]
            );
        }
 
 
        return Mustache::renderWithBinds(
            'eliza/footer_1',
            [
                'id' => $this->idElizaPicFooter
            ],
            [
                'FOOTER_LEFT'   => $htmlLeft,
                'FOOTER_MIDDLE' => $htmlMiddle,
                'FOOTER_RIGHT'  => $htmlRight
            ]
        );
    }
 
 
//--//------------------------------------------------------------------------------------------------------------------
//--//  РАЗДЕЛ ГЕНЕРАЦИИ РОУТОВ
//--//------------------------------------------------------------------------------------------------------------------
 
    public function generateRoutes() {
        $this->routeGenDynamic();
    }
 
    private function routeGenDynamic() {
        $routeMap = [
            'indexPages' => [
                'pattern' => '/',     'controller' => 'Pic',
                'action'  => 'index', 'params'     => []
            ],
            'stack' => [
                'pattern' => '/([-_a-zA-Z0-9]{7})', 'controller' => 'Pic',
                'action'  => 'stack',             'params'     => ['stackName' => 1]
            ],
            'image' => [
                'pattern'    => '/([-_a-zA-Z0-9]{1,6}|[-_a-zA-Z0-9]{8}|[-_a-zA-Z0-9]{9,})',
                'controller' => 'Pic',
                'action'     => 'image',
                'params'     => ['imageName' => 1]
            ]
        ];
 
        $ch = new Lib\RouteCache($this->getSiteId(), $this->getModuleId());
        $ch->clearDynamicRoutes();
 
        foreach($routeMap as $i => $v) {
            $ch->insertDynamicRoute('picHandler', '', $v['pattern'], $v['controller'], $v['action'], $v['params']);
        }
    }
 
    private function calcSize($bytes)
    {
        if ($bytes >= 1073741824)
        {
            $bytes = number_format($bytes / 1073741824, 2) . ' GB';
        }
        elseif ($bytes >= 1048576)
        {
            $bytes = number_format($bytes / 1048576, 2) . ' MB';
        }
        elseif ($bytes >= 1024)
        {
            $bytes = number_format($bytes / 1024, 2) . ' KB';
        }
        elseif ($bytes > 1)
        {
            $bytes = $bytes . ' bytes';
        }
        elseif ($bytes == 1)
        {
            $bytes = $bytes . ' byte';
        }
        else
        {
            $bytes = '0 bytes';
        }
 
        return $bytes;
    }
}
#6Site\Pic\Controller\PicController->stackAction
#7Phalcon\Dispatcher\AbstractDispatcher->callActionMethod
#8Phalcon\Dispatcher\AbstractDispatcher->dispatch
#9Phalcon\Mvc\Application->handle
/var/www/fullrest-team/data/www/fullrest.net/public/index.php (299)
<?
use Core\Modules\Utils\Controller\MinController;
use Phalcon\Di\Di;
use Phalcon\Mvc\Model;
use Phalcon\Mvc\Dispatcher as MvcDispatcher;
use \Phalcon\Mvc\Dispatcher as PhDispatcher;
 
// SET GLOBAL sql_mode = "NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ALLOW_INVALID_DATES"
Model::setup(
    array(
        'notNullValidations' => false
    )
);
 
mb_internal_encoding("UTF-8");
 
set_time_limit (0);
ini_set('display_errors', 1);
error_reporting(E_ALL /*^ 'E_DEPRECATED'*/ );
date_default_timezone_set( 'Europe/Moscow' );
 
(new Phalcon\Support\Debug())->listen(true, true);
 
require_once('../Core/Lib/Vendor/autoload.php');
 
try {
  $Loader = new Phalcon\Autoload\Loader();
 
  $Loader->setNamespaces(
    [
      'Core\Lib'        => '../Core/Lib/',
            'Core\Lib\Navigation' => '../Core/Lib/Navigation/',
      'Core\Controller' => '../Core/Controller/',
            'Core\Extenders'  => '../Core/Extenders/',
            'Core\Model'      => '../Core/Model/'
    ],
    true
  )->register();
 
  $DI = new Phalcon\Di\FactoryDefault();
 
 
    $DI->get('dispatcher')->setEventsManager($DI->get('eventsManager'));
 
    $DI->set('url', function() {
        $url = new \Phalcon\Url();
        $url->setBaseUri('/');
 
        return $url;
    }, true);
 
  $DI->setShared('debug', 'Core\Lib\Debug')->resolve();
 
 
  $App = new Phalcon\Mvc\Application($DI);
 
  $DI->setShared('loader', $Loader);
 
    $DI->setShared('overseer', function () {
        return Core\Lib\Overseer::getInstance();
    });
 
    $DI->setShared('og', function () {
        return Core\Lib\OpenGraph::getInstance();
    });
 
    $DI->setShared('resconf', function () {
        return Core\Lib\ResourcesConfigurator::getInstance();
    });
 
  $DI->setShared('hostname', function () {
    $Hostname = new Core\Lib\Hostname();
        $Hostname->setHostnameConfigDir('../Cache/Sites/');
    $Hostname->initialize();
 
    return $Hostname;
  })->resolve();
 
  $DI->getShared('debug')->resolve($DI['hostname']->config->debug);
 
    $DI->set('db', function() use ($DI) {
        $config = require_once('../Config/mysql.php');
 
        $db = new Phalcon\Db\Adapter\Pdo\Mysql(array(
            "host"     => $config['host'],
            "username" => $config['username'],
            "password" => $config['password'],
            "dbname"   => $config['name'],
            'charset'   =>'UTF8',
            'options' =>[
                PDO::ATTR_DEFAULT_FETCH_MODE  =>  PDO::FETCH_ASSOC,
                PDO::MYSQL_ATTR_INIT_COMMAND  => 'SET NAMES UTF8'
            ]
        ));
 
        $db->query(
            '
                SET 
                    character_set_results = \'utf8\', 
                    character_set_client = \'utf8\', 
                    character_set_connection = \'utf8\', 
                    character_set_database = \'utf8\', 
                    character_set_server = \'utf8\'
            '
        );
 
        return $db;
    });
 
 
 
    //echo '<pre>';
    //print_r($mysqli->get_charset ());
 
 
 
  $DI->set('modelsMetadata', function () {
    return new \Phalcon\Mvc\Model\MetaData\Stream(
      [
        'metaDataDir' => '../Cache/Metadata/'
      ]
    );
  });
 
    $DI->set('cookies', function() {
        $Cookies = new Phalcon\Http\Response\Cookies();
        $Cookies->useEncryption(false);
        return $Cookies;
    });
 
    /*$DI->set('crypt', function() {
        $Crypt = new Phalcon\Crypt();
        $Crypt->setKey('KTr]t[S&gt;ATN');
        return $Crypt;
    });*/
 
 
    $DI->setShared('session', function () {
        $session = new Phalcon\Session\Manager();
        $files = new Phalcon\Session\Adapter\Stream();
        $session->setAdapter($files)->start();
 
        return $session;
    });
 
 
    $DI->setShared('user', function () {
    return Core\Lib\UserHandler::getInstance();
  });
 
  $DI->set('security', function () {
    $Security = new Core\Lib\Security();
 
    return $Security;
  });
 
  $DI->set('assets', function () use ($DI) {
    $Assets = new Phalcon\Assets\Manager(new Phalcon\Html\TagFactory(new Phalcon\Html\Escaper()));
 
        $js  = $Assets->collection('js');
        $css = $Assets->collection('css');
 
        $user = $DI['user'];
 
        if ($user->getSetting('tools', 'dev_compress_css')) {
            $css->addCss('/min/common_'.$DI['overseer']->getSiteName().'_css_ver'.$DI['resconf']->getVerCss().'.css');
        }
        else {
            $sysCss = (new MinController())->minCssSystemApp(true);
 
            foreach($sysCss as $i => $v) {
                $len = sizeof($v);
 
                for($a = 0; $a < $len; $a++) {
                    $css->addCss($i.$v[$a]);
                }
            }
 
            $configCss = $DI['hostname']->config['system']['css'];
 
            $name   = $DI['hostname']->config['system']['package']['name'];
            $path      = 'design/'.mb_strtolower($name).'/';
 
            if (sizeof($configCss)) {
                foreach($configCss as $i => $v) {
                    $css->addCss($path.$v);
                }
            }
        }
 
        if (false && $user->getSetting('tools', 'dev_compress_js') && $DI['hostname']->config['meta']['site_id'] != 0) {
            $js->addJs('/min/common_'.$DI['overseer']->getSiteName().'_js_ver'.$DI['resconf']->getVerJS().'_ru.js', false, false, array('async' => 'async'));
        }
        else {
            $sysJs = $DI['db']->query(
                '
                    SELECT
                        `srjg`.`group_folder`,
                        `srj`.`js_name`,
                        `srj`.`js_lang`
                    FROM `sys_resources_js` AS `srj`, `sys_resources_js_groups` AS `srjg`
                    WHERE `srjg`.`group_id`=`srj`.`group_id` AND `srj`.`js_type`=\'system\' AND `srj`.`js_skip`=0
                    ORDER BY `srjg`.`group_order` ASC, `srj`.`js_order` ASC
                '
            );
 
            while($row = $sysJs->fetch()) {
                if ($row['js_lang']) {
                    $js->addJs('/api/utils/builder/buildLangForJSByDirFile?file='.$row['group_folder'].$row['js_name'].'&trans='.$row['js_lang']);
                }
                else {
                    $js->addJs($row['group_folder'].$row['js_name']);
                }
            }
 
 
            $modules   = $DI['hostname']->config['system']['package']['modules'];
            $name      = $DI['hostname']->config['system']['package']['name'];
            $siteId    = $DI['hostname']->config['meta']['site_id'];
            $packageId = $DI['hostname']->config['system']['package']['id'];
 
            if($packageId) {
                $packageJs = $DI['db']->query('SELECT * FROM `sys_resources_js` WHERE `package_id`='.$packageId.' AND `js_type`=\'package\' ORDER BY `js_order` ASC');
 
                while($row = $packageJs->fetch()) {
                    if ($row['js_lang']) {
                        $js->addJs('/api/utils/builder/buildLangForJSByDirFile?file='.'js/'.$row['js_name'].'&trans='.$row['js_lang']);
                    }
                    else {
                        $js->addJs('js/'.$row['js_name']);
                    }
                }
            }
 
 
 
            $siteJs = $DI['db']->query('SELECT * FROM `sys_resources_js` WHERE `site_id`='.$siteId.' AND `js_type`=\'site\' ORDER BY `js_order` ASC');
 
 
            while($row = $siteJs->fetch()) {
                if ($row['js_lang']) {
                    $js->addJs('/api/utils/builder/buildLangForJSByDirFile?file='.'js/'.$row['js_name'].'&trans='.$row['js_lang']);
                }
                else {
                    $js->addJs('js/'.$row['js_name']);
                }
            }
 
            $js->addJs('js/packages/'.$name.'.js');
 
            if (sizeof($modules)) {
                foreach($modules as $i => $v) {
                    $addr = 'js/controllers/'.$name.'/'.$i.'.js';
 
                    if (!is_readable($addr))
                        continue;
 
                    $js->addJs($addr);
                }
            }
 
            $js->addJs('js/main.js');
        }
 
    return $Assets;
  });
 
  $DI->set('view', function () use ($DI) {
    $EventManager = new \Phalcon\Events\Manager();
 
//    Пример обработки события в \Core\Lib\Mustache (line 42)
//    $EventManager->attach('mustache:testEvent', function () {
//      die('WOO WOOOOOOOOOOOOOOOOOOO!!!!11');
//    });
 
    //$View = new Phalcon\Mvc\View();
 
        $View = new \Core\Extenders\MvcView();
 
    $View->setEventsManager($EventManager);
 
    $View->setViewsDir($DI['hostname']->config->view->path);
    $View->setLayoutsDir('layouts/');
    $View->setPartialsDir('partials/');
    $View->setMainView('main');
 
    $Engine = new Core\Lib\Mustache($View, $DI);
 
    $NativeEngine = new Phalcon\Mvc\View\Engine\Php($View, $DI);
 
    $View->registerEngines([
      '.hbs' => $Engine,
      '.phtml' => $NativeEngine
    ]);
 
    return $View;
  });
 
    $html = $App->handle($_SERVER["REQUEST_URI"])->getContent();
 
    if ($DI['request']->isAjax()) {
 
        (new \Core\Lib\JSONResponse(\Core\Lib\JSONResponse::SUCCESS))->send(
            [
                'status' => 'success',
                'hapi' => [
                    'title'      => $DI['overseer']->getMetaTitle(),
                    'container'  => $DI['overseer']->getJSContainer(),
                    'package'    => $DI['overseer']->getJSPackage(),
                    'controller' => $DI['overseer']->getJSController(),
                    'action'     => $DI['overseer']->getJSAction()
                ],
                'html' => $html
            ]
        );
    }
    else
        echo $html;
 
 
    
 
 
} catch (Core\Lib\ApiException $apiException) {
 
  if ($DI['hostname']->config->debug->enableApi) {
    $DI['debug']->onUncaughtException($apiException);
  }
 
  (new Core\Lib\JSONResponse(\Core\Lib\JSONResponse::ERROR))->send($apiException);
 
  //$DI['response']->setHeader('Content-type', 'application/json')
  //  ->setJsonContent(["status" => false, "error" => ["message" => $apiException->getMessage()]])->send();
} catch (Phalcon\Exception $e) {
  if ($DI['hostname']->config->debug->enable && !$DI['hostname']->checkMode(Core\Lib\Hostname::API_MODE)) {
    $DI['debug']->onUncaughtException($e);
  }
 
  echo "Error: {$e->getMessage()}<br>{$e->getFile()}:{$e->getLine()}";
}
KeyValue
_url/YWiIytO
KeyValue
REDIRECT_REDIRECT_HTTPSon
REDIRECT_REDIRECT_STATUS200
REDIRECT_HTTPSon
REDIRECT_STATUS200
HTTPSon
HTTP_HOSTpic.fullrest.ru
HTTP_X_FORWARDED_PROTOhttps
HTTP_X_FORWARDED_PORT443
HTTP_CONNECTIONclose
HTTP_ACCEPT*/*
HTTP_USER_AGENTMozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
HTTP_ACCEPT_ENCODINGgzip, br, zstd, deflate
PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SERVER_SIGNATURE<address>Apache/2.4.62 (Debian) Server at pic.fullrest.ru Port 80</address>\n
SERVER_SOFTWAREApache/2.4.62 (Debian)
SERVER_NAMEpic.fullrest.ru
SERVER_ADDR127.0.0.1
SERVER_PORT80
REMOTE_ADDR216.73.216.75
DOCUMENT_ROOT/var/www/fullrest-team/data/www/fullrest.net
REQUEST_SCHEMEhttp
CONTEXT_PREFIX
CONTEXT_DOCUMENT_ROOT/var/www/fullrest-team/data/www/fullrest.net
SERVER_ADMINwebmaster@fullrest.net
SCRIPT_FILENAME/var/www/fullrest-team/data/www/fullrest.net/public/index.php
REMOTE_PORT45610
REDIRECT_URL/public/YWiIytO
REDIRECT_QUERY_STRING_url=/YWiIytO
GATEWAY_INTERFACECGI/1.1
SERVER_PROTOCOLHTTP/1.0
REQUEST_METHODGET
QUERY_STRING_url=/YWiIytO
REQUEST_URI/YWiIytO
SCRIPT_NAME/public/index.php
PHP_SELF/public/index.php
REQUEST_TIME_FLOAT1751322931.0577
REQUEST_TIME1751322931
#Path
0/var/www/fullrest-team/data/www/fullrest.net/public/index.php
1/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/autoload.php
2/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/composer/autoload_real.php
3/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/composer/platform_check.php
4/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/composer/ClassLoader.php
5/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/composer/autoload_static.php
6/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Debug.php
7/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Hostname.php
8/var/www/fullrest-team/data/www/fullrest.net/Cache/Sites/hostnames.php
9/var/www/fullrest-team/data/www/fullrest.net/Cache/Sites/Configs/config_sid_2.php
10/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Overseer.php
11/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/OpenGraph.php
12/var/www/fullrest-team/data/www/fullrest.net/Config/global.loader.php
13/var/www/fullrest-team/data/www/fullrest.net/Config/global.router.php
14/var/www/fullrest-team/data/www/fullrest.net/Config/global.modules.php
15/var/www/fullrest-team/data/www/fullrest.net/Cache/Sites/Routes/routes_sid_2.php
16/var/www/fullrest-team/data/www/fullrest.net/Core/Extenders/MvcView.php
17/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Mustache.php
18/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/compat.php
19/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Cache.php
20/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Cache/AbstractCache.php
21/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Cache/FilesystemCache.php
22/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Cache/NoopCache.php
23/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Compiler.php
24/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Context.php
25/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Engine.php
26/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Exception.php
27/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Exception/InvalidArgumentException.php
28/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Exception/LogicException.php
29/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Exception/RuntimeException.php
30/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Exception/SyntaxException.php
31/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Exception/UnknownFilterException.php
32/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Exception/UnknownHelperException.php
33/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Exception/UnknownTemplateException.php
34/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/HelperCollection.php
35/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/LambdaHelper.php
36/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Loader.php
37/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Loader/ArrayLoader.php
38/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Loader/MutableLoader.php
39/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Loader/CascadingLoader.php
40/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Loader/FilesystemLoader.php
41/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Loader/InlineLoader.php
42/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Loader/ProductionFilesystemLoader.php
43/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Loader/StringLoader.php
44/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Logger.php
45/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Logger/AbstractLogger.php
46/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Logger/StreamLogger.php
47/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Parser.php
48/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Source.php
49/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Source/FilesystemSource.php
50/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Template.php
51/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Tokenizer.php
52/var/www/fullrest-team/data/www/fullrest.net/Core/Extenders/MustacheLoaderWithMinifier.php
53/var/www/fullrest-team/data/www/fullrest.net/Site/Pic/Controller/PicController.php
54/var/www/fullrest-team/data/www/fullrest.net/Core/Extenders/ContentController.php
55/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/UserHandler.php
56/var/www/fullrest-team/data/www/fullrest.net/Core/Modules/Pic/Controller/StackController.php
57/var/www/fullrest-team/data/www/fullrest.net/Config/mysql.php
58/var/www/fullrest-team/data/www/fullrest.net/Core/Model/PicItem.php
Memory
Usage2097152