public function parse($value) { $images = is_array($value) ? $value : cmsModel::yamlToArray($value); $html = ''; $small_preset = false; $a_class = ''; foreach ($images as $key => $paths) { if (!isset($paths[$this->getOption('size_full')])) { continue; } $title = empty($this->item['title']) ? $this->name : $this->item['title']; if ($this->getOption('first_image_emphasize') && !$small_preset) { $small_preset = $this->getOption('size_full'); $a_class = 'first_type_images'; } else { $small_preset = $this->getOption('size_small'); $a_class = 'second_type_images'; } if (!empty($paths['original']) && strtolower(pathinfo($paths['original'], PATHINFO_EXTENSION)) === 'gif') { $html .= html_gif_image($paths, 'small', $title . ' ' . $key, array('class' => 'img-' . $this->getName())); } else { $html .= '<a title="' . htmlspecialchars($title) . '" class="img-' . $this->getName() . ' ' . $a_class . '" href="' . html_image_src($paths, $this->getOption('size_full'), true) . '">' . html_image($paths, $small_preset, $title . ' ' . $key) . '</a>'; } } if ($html) { $html .= '<script>$(function() { icms.modal.bindGallery(".img-' . $this->getName() . '"); });</script>'; } return $html; }
public function parse($value) { $images = is_array($value) ? $value : cmsModel::yamlToArray($value); $html = ''; foreach ($images as $key => $paths) { if (!isset($paths[$this->getOption('size_full')])) { continue; } $html .= '<a class="img-' . $this->getName() . '" href="' . html_image_src($paths, $this->getOption('size_full'), true) . '">' . html_image($paths, 'small', (empty($this->item['title']) ? $this->name : $this->item['title']) . ' ' . $key) . '</a>'; } if ($html) { $html .= '<script>$(document).ready(function() { icms.modal.bindGallery(".img-' . $this->getName() . '"); });</script>'; } return $html; }
public function showUploadForm($album_id) { if (!cmsUser::isAllowed('albums', 'add')) { cmsCore::error404(); } $user = cmsUser::getInstance(); $content_model = cmsCore::getModel('content'); $ctype = $content_model->getContentTypeByName('albums'); $albums = $content_model->filterEqual('user_id', $user->id)->filterOr()->filterEqual('is_public', 1)->orderByList(array(array('by' => 'is_public', 'to' => 'asc'), array('by' => 'date_pub', 'to' => 'desc')))->getContentItems('albums'); if (!$albums) { $this->redirect(href_to('albums', 'add')); } if ($this->request->has('submit')) { $album_id = $this->request->get('album_id'); if (!isset($albums[$album_id])) { $this->redirectBack(); } if (!$this->request->has('photos')) { $this->redirectBack(); } $album = $albums[$album_id]; $photos_titles = $this->request->get('photos'); $this->model->assignAlbumId($album_id); $this->model->updateAlbumCoverImage($album['id'], $photos_titles); $this->model->updateAlbumPhotosCount($album_id, sizeof($photos_titles)); $this->model->updatePhotoTitles($album_id, $photos_titles); $activity_thumb_images = array(); $photos = $this->model->getPhotosByIdsList(array_keys($photos_titles)); $photos_count = count($photos); if ($photos_count > 5) { $photos = array_slice($photos, 0, 4); } if ($photos_count) { foreach ($photos as $photo) { $activity_thumb_images[] = array('url' => href_to('photos', 'view', $photo['id']), 'src' => html_image_src($photo['image'], 'small')); } } $activity_controller = cmsCore::getController('activity'); $activity_controller->addEntry($this->name, "add.photos", array('user_id' => $user->id, 'subject_title' => $album['title'], 'subject_id' => $album['id'], 'subject_url' => href_to('albums', $album['slug'] . '.html'), 'is_private' => isset($album['is_private']) ? $album['is_private'] : 0, 'group_id' => isset($album['parent_id']) ? $album['parent_id'] : null, 'images' => $activity_thumb_images, 'images_count' => $photos_count)); $this->redirect(href_to('albums', $albums[$album_id]['slug'] . '.html')); } $photos = $this->model->getOrphanPhotos(); if (!isset($albums[$album_id])) { $album_id = false; } cmsTemplate::getInstance()->render('upload', array('ctype' => $ctype, 'albums' => $albums, 'photos' => $photos, 'album_id' => $album_id)); }
public function parse($value) { $images = is_array($value) ? $value : cmsModel::yamlToArray($value); $html = ''; foreach ($images as $key => $paths) { if (!isset($paths[$this->getOption('size_full')])) { continue; } if (!empty($paths['original']) && strtolower(pathinfo($paths['original'], PATHINFO_EXTENSION)) === 'gif') { $html .= html_gif_image($paths, 'small', (empty($this->item['title']) ? $this->name : $this->item['title']) . ' ' . $key, array('class' => 'img-' . $this->getName())); } else { $html .= '<a class="img-' . $this->getName() . '" href="' . html_image_src($paths, $this->getOption('size_full'), true) . '">' . html_image($paths, 'small', (empty($this->item['title']) ? $this->name : $this->item['title']) . ' ' . $key) . '</a>'; } } if ($html) { $html .= '<script>$(function() { icms.modal.bindGallery(".img-' . $this->getName() . '"); });</script>'; } return $html; }
<div class="image"> <?php if ($url) { ?> <a style="background-image:url('<?php echo html_image_src($image, 'normal', true); ?> ')" href="<?php echo $url; ?> "></a> <?php } else { ?> <div style="background-image:url('<?php echo html_image_src($image, 'normal', true); ?> ')"></div> <?php } ?> </div> <?php } ?> <div class="info"> <?php if ($is_show_details) { ?> <div class="details"> <span class="author">
<div class="image"> <?php if ($url) { ?> <a style="background-image:url('<?php echo html_image_src($image, $size, true); ?> ')" href="<?php echo $url; ?> "></a> <?php } else { ?> <div style="background-image:url('<?php echo html_image_src($image, $size, true); ?> ')"></div> <?php } ?> </div> <?php } else { ?> <div class="image"> <?php if ($url) { ?> <a href="<?php echo $url;
$first_url = href_to($ctype['name'], $first_item['slug']) . '.html'; ?> <td class="slide"> <a href="<?php echo $first_url; ?> "> <?php foreach ($items as $id => $item) { ?> <img alt="<?php html($item['title']); ?> " src="<?php echo html_image_src($item[$image_field], 'big', true); ?> " class="slide-<?php echo $id; ?> "> <?php } ?> <div class="heading" style="position:absolute; left:0; bottom:0; z-index:2"> <h2><?php echo $first_item['title']; ?> </h2><br> <div class="teaser"> <?php
private function getDownloadImages($photo) { $downloads = array(); $presets = cmsCore::getModel('images')->getPresetsList(); if (isset($photo['image']['original'])) { $photo['sizes']['original'] = array('width' => $photo['width'], 'height' => $photo['height']); $presets['original'] = LANG_PARSER_IMAGE_SIZE_ORIGINAL; } $selected = $isset = false; foreach ($photo['image'] as $preset => $path) { $show = true; if (!empty($this->options['download_view'][$preset]) && !$this->cms_user->isInGroups($this->options['download_view'][$preset])) { $show = false; } if (!empty($this->options['download_hide'][$preset]) && $this->cms_user->isInGroups($this->options['download_hide'][$preset])) { $show = false; } if (!$isset && $show) { $selected = $isset = true; } else { $selected = false; } $downloads[$preset] = array('link' => $show ? href_to('photos', 'download', array($photo['id'], $preset)) . '?hash=' . $this->getDownloadHash() : '', 'size' => $photo['sizes'][$preset]['width'] . '×' . $photo['sizes'][$preset]['height'], 'name' => $presets[$preset], 'preset' => $preset, 'image' => $show ? html_image_src($photo['image'], $preset, true) : '', 'select' => $selected); } return $downloads; }
<a href="<?php echo $next_photo_url; ?> "> <?php echo html_image($photo['image'], 'big', $photo['title']); ?> </a> </div> <div class="image-nav"> <?php if ($is_origs && isset($photo['image']['original'])) { ?> <a href="<?php echo html_image_src($photo['image'], 'original', true); ?> " target="_blank" class="ajax-modal ajaxlink"><?php echo LANG_PHOTOS_SHOW_ORIG; ?> </a> <?php } ?> </div> <div id="album-nav"> <div class="arrow arr-prev"><a href="javascript:"></a></div> <div id="photos-slider"> <ul> <?php
<?php foreach ($photo['image'] as $preset => $path) { ?> <?php if ($preset == $small_preset) { continue; } ?> <a title="<?php echo $photo['sizes'][$preset]['width']; ?> x <?php echo $photo['sizes'][$preset]['height']; ?> " rel="edit_list" href="<?php echo html_image_src($photo['image'], $preset, true); ?> "></a> <?php } ?> <?php } ?> </div> <div class="info"> <div class="title"> <?php echo html_input('text', 'photos[' . $photo['id'] . ']', $photo['title']); ?> </div>
public function run($profile, $do = false) { if (!cmsUser::isLogged()) { cmsCore::error404(); } $user = cmsUser::getInstance(); // если нужно, передаем управление другому экшену if ($do) { $this->runAction('profile_edit_' . $do, array($profile) + array_slice($this->params, 2)); return; } // проверяем наличие доступа if ($profile['id'] != $user->id && !$user->is_admin) { cmsCore::error404(); } // Получаем поля $content_model = cmsCore::getModel('content'); $content_model->setTablePrefix(''); $content_model->orderBy('ordering'); $fields = $content_model->getContentFields('{users}'); // Строим форму $form = new cmsForm(); // Разбиваем поля по группам $fieldsets = cmsForm::mapFieldsToFieldsets($fields, function ($field, $user) { // проверяем что группа пользователя имеет доступ к редактированию этого поля if ($field['groups_edit'] && !$user->isInGroups($field['groups_edit'])) { return false; } return true; }); // Добавляем поля в форму foreach ($fieldsets as $fieldset) { $fieldset_id = $form->addFieldset($fieldset['title']); foreach ($fieldset['fields'] as $field) { // добавляем поле в форму $form->addField($fieldset_id, $field['handler']); } } // Добавляем поле выбора часового пояса $config = cmsConfig::getInstance(); $fieldset_id = $form->addFieldset(LANG_TIME_ZONE); $form->addField($fieldset_id, new fieldList('time_zone', array('default' => $config->time_zone, 'generator' => function ($item) { return cmsCore::getTimeZones(); }))); // Форма отправлена? $is_submitted = $this->request->has('submit'); if ($is_submitted) { // Парсим форму и получаем поля записи $new = $form->parse($this->request, $is_submitted, $profile); $old = $profile; $profile = array_merge($profile, $new); // Проверям правильность заполнения $errors = $form->validate($this, $profile); if (!$errors) { $is_allowed = cmsEventsManager::hookAll('user_profile_update', $profile, true); if ($is_allowed !== true && in_array(false, $is_allowed)) { $errors = true; } } if (!$errors) { // Обновляем профиль и редиректим на его просмотр $this->model->updateUser($profile['id'], $profile); // Отдельно обновляем часовой пояс в сессии cmsUser::sessionSet('user_data:time_zone', $profile['time_zone']); // Постим уведомление о смене аватара в ленту if (!$this->model->isAvatarsEqual($new['avatar'], $old['avatar'])) { $activity_controller = cmsCore::getController('activity'); $activity_controller->deleteEntry($this->name, "avatar", $profile['id']); if (!empty($new['avatar'])) { $activity_controller->addEntry($this->name, "avatar", array('user_id' => $profile['id'], 'subject_title' => $profile['nickname'], 'subject_id' => $profile['id'], 'subject_url' => href_to('users', $profile['id']), 'is_private' => 0, 'group_id' => null, 'images' => array(array('url' => href_to('users', $profile['id']), 'src' => html_image_src($new['avatar'], 'normal'))), 'images_count' => 1)); } } $this->redirectTo('users', $profile['id']); } if ($errors) { cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } } return cmsTemplate::getInstance()->render('profile_edit', array('do' => 'edit', 'id' => $profile['id'], 'profile' => $profile, 'form' => $form, 'errors' => isset($errors) ? $errors : false)); }
$first_url = href_to($ctype['name'], $first_item['slug']) . '.html'; ?> <td class="slide"> <a href="<?php echo $first_url; ?> "> <?php foreach ($items as $id => $item) { ?> <img alt="<?php html($item['title']); ?> " src="<?php echo html_image_src($item[!empty($big_image_field) ? $big_image_field : $image_field], $big_image_preset ? $big_image_preset : 'big', true); ?> " class="slide-<?php echo $id; ?> "> <?php } ?> <div class="heading" style="position:absolute; left:0; bottom:0; z-index:2"> <h2><?php echo $first_item['title']; ?> </h2><br> <div class="teaser"> <?php
/** * Возвращает тег <img> * @param array|yaml $image Все размеры заданного изображения * @param string $size_preset Название пресета * @param string $alt Замещающий текст изображения * @param array $attributes Массив аттрибутов тега * @return string */ function html_image($image, $size_preset = 'small', $alt = '', $attributes = array()) { $size = $size_preset == 'micro' ? 'width="32" height="32"' : ''; $src = html_image_src($image, $size_preset, true); if (!$src) { return false; } $attr_str = html_attr_str($attributes); $class = isset($attributes['class']) ? ' class="' . $attributes['class'] . '"' : ''; return '<img src="' . $src . '" ' . $size . ' alt="' . htmlspecialchars($alt) . '" ' . $attr_str . $class . ' />'; }
public function showUploadForm($album_id) { if (!cmsUser::isAllowed('albums', 'add')) { cmsCore::error404(); } $content_model = cmsCore::getModel('content'); $ctype = $content_model->getContentTypeByName('albums'); if ($album_id) { $album = $content_model->getContentItem('albums', $album_id); if ($album) { if ($this->cms_user->id == $album['id']) { $content_model->disablePrivacyFilter(); } } } if ($this->cms_user->is_admin) { $content_model->disablePrivacyFilter(); } $albums = $content_model->filterEqual('user_id', $this->cms_user->id)->filterOr()->filterEqual('is_public', 1)->orderByList(array(array('by' => 'is_public', 'to' => 'asc'), array('by' => 'date_pub', 'to' => 'desc')))->getContentItems('albums'); if (!$albums) { $this->redirect(href_to('albums', 'add')); } $album_id = $album_id ? (int) $album_id : $this->request->get('album_id', 0); if ($this->request->has('submit')) { if (!isset($albums[$album_id])) { $this->redirectBack(); } if (!$this->request->has('photos')) { $this->redirectBack(); } if (!$this->request->has('content')) { $this->redirectBack(); } $album = $albums[$album_id]; // данные $photo_titles = $this->request->get('photos', array()); $photo_contents = $this->request->get('content', array()); $photo_is_privates = $this->request->get('is_private', array()); $photo_types = array(); if (!empty($this->options['types'])) { $photo_types = $this->request->get('type', array()); } if (!$photo_titles) { $this->redirectBack(); } // по ключам названий определяем id фотографий $_photo_ids = array_keys($photo_titles); // ключи могут быть только числовые $photo_ids = array_filter($_photo_ids, function ($v) { return is_numeric($v); }); if (!$photo_ids) { $this->redirectBack(); } // формируем массив для каждой фотографии $photo_list = array(); $last_order = $this->model->filterEqual('album_id', $album['id'])->getNextOrdering('photos'); foreach ($photo_ids as $photo_id) { // эти данные должны существовать, пусть даже и пустые // если их нет, значит запрос подделанный if (!isset($photo_titles[$photo_id]) || !isset($photo_contents[$photo_id])) { $this->model->deletePhoto($photo_id); continue; } $_photo = array('date_pub' => null, 'album_id' => $album['id'], 'title' => strip_tags($photo_titles[$photo_id] ? $photo_titles[$photo_id] : sprintf(LANG_PHOTOS_PHOTO_UNTITLED, $photo_id)), 'content_source' => $photo_contents[$photo_id] ? $photo_contents[$photo_id] : null, 'content' => $photo_contents[$photo_id] ? cmsEventsManager::hook('html_filter', $photo_contents[$photo_id]) : null, 'is_private' => isset($photo_is_privates[$photo_id]) ? (int) $photo_is_privates[$photo_id] : 0, 'type' => isset($photo_types[$photo_id]) ? (int) $photo_types[$photo_id] : null, 'ordering' => $last_order); $photo_list[$photo_id] = $_photo; $last_order++; } $photos = $this->model->assignPhotoList($photo_list); $activity_thumb_images = array(); $photos_count = count($photos); if ($photos_count > 5) { $photos = array_slice($photos, 0, 4); } if ($photos_count) { foreach ($photos as $photo) { $_presets = array_keys($photo['image']); $small_preset = end($_presets); $activity_thumb_images[] = array('url' => href_to_rel('photos', $photo['slug'] . '.html'), 'src' => html_image_src($photo['image'], $small_preset)); } } cmsCore::getController('activity')->addEntry($this->name, 'add.photos', array('user_id' => $this->cms_user->id, 'subject_title' => $album['title'], 'subject_id' => $album['id'], 'subject_url' => href_to_rel('albums', $album['slug'] . '.html'), 'is_private' => isset($album['is_private']) ? $album['is_private'] : 0, 'group_id' => isset($album['parent_id']) ? $album['parent_id'] : null, 'images' => $activity_thumb_images, 'images_count' => $photos_count)); $this->redirect(href_to('albums', $albums[$album_id]['slug'] . '.html')); } $photos = $this->model->getOrphanPhotos($this->cms_user->id); if (!isset($albums[$album_id])) { $album_id = false; } $_albums_select = array(); $num = 0; foreach ($albums as $album) { if (!empty($album['parent_title'])) { if ($album['is_public']) { $album['title'] = '[' . LANG_PHOTOS_PUBLIC_ALBUM . '] ' . $album['title']; } $_albums_select[$album['parent_title']][] = $album; } elseif ($album['is_public']) { $_albums_select[LANG_PHOTOS_PUBLIC_ALBUMS][] = $album; } else { $_albums_select[LANG_PHOTOS_USER_ALBUMS][] = $album; } } $albums_select = array('' => ''); foreach ($_albums_select as $album_type => $_albums) { $albums_select['opt' . $num] = array($album_type); foreach ($_albums as $album) { $albums_select[$album['id']] = $album['title']; } $num++; } $this->cms_template->render('upload', array('title' => LANG_PHOTOS_UPLOAD, 'is_edit' => false, 'ctype' => $ctype, 'albums' => $albums, 'album' => isset($albums[$album_id]) ? $albums[$album_id] : array(), 'albums_select' => $albums_select, 'photos' => $photos, 'preset_big' => $this->options['preset'], 'types' => !empty($this->options['types']) ? array('' => LANG_PHOTOS_NO_TYPE) + $this->options['types'] : array(), 'album_id' => $album_id)); }
?> " itemprop="name"> <?php html($photo['title']); ?> </a> </h3> <a href="<?php echo $photo_url; ?> " title="<?php html($photo['title']); ?> "> <img src="<?php echo html_image_src($photo['image'], $preset_small, true, false); ?> " title="<?php html($photo['title']); ?> " alt="<?php html($photo['title']); ?> " itemprop="thumbnail" /> </a> <div class="info"> <div class="photo-counts"> <span class="hits-count" title="<?php echo LANG_HITS; ?> ">
?> </div> <?php if ($is_private) { ?> <?php echo html_image(default_images('private', $ctype['photos_options']['preset_small']), $ctype['photos_options']['preset_small'], $item['title']); ?> <?php } else { ?> <a href="<?php echo href_to($ctype['name'], $item['slug'] . '.html'); ?> " style="background-image: url(<?php echo html_image_src($item['cover_image'], $ctype['photos_options']['preset_small'], true); ?> );"> <?php if (!empty($item['cover_image'])) { ?> <?php echo html_image($item['cover_image'], $ctype['photos_options']['preset_small'], $item['title']); ?> <?php unset($item['cover_image']); ?> <?php } ?> <div class="photos_album_title_wrap">
/** * Возвращает тег HTML gif изображения * @param array|yaml $image Все размеры заданного изображения * @param string $size_preset Название пресета * @param string $alt Замещающий текст изображения * @param array $attributes Массив аттрибутов тега * @return string */ function html_gif_image($image, $size_preset = 'small', $alt = '', $attributes = array()) { $class = isset($attributes['class']) ? $attributes['class'] : ''; if ($size_preset == 'micro') { $class .= ' micro_image'; } $original_src = html_image_src($image, 'original', true); $preview_src = html_image_src($image, $size_preset, true); if (!$preview_src) { return ''; } return '<a class="ajax-modal gif_image ' . $class . '" href="' . $original_src . '" ' . html_attr_str($attributes) . '> <span class="background_overlay"></span> <span class="image_label">gif</span> <img src="' . $preview_src . '" alt="' . htmlspecialchars($alt) . '" /> </a>'; }
<div class="item <?php if ($is_first) { ?> item-first<?php } ?> "> <?php if ($image_field && !empty($item[$image_field])) { ?> <?php if ($is_first) { ?> <div class="image"> <a style="background-image:url('<?php echo html_image_src($item[$image_field], $size, true); ?> ')" href="<?php echo $url; ?> "></a> </div> <?php } else { ?> <div class="image"> <a href="<?php echo $url; ?> "><?php echo html_image($item[$image_field], $size, $item['title']);
/** * Возвращает тег <img> * @param array|yaml $image Все размеры заданного изображения * @param string $size_preset Название пресета * @param string $alt Замещающий текст изображения * @return string */ function html_image($image, $size_preset = 'small', $alt = '') { $size = $size_preset == 'micro' ? 'width="32" height="32"' : ''; $src = html_image_src($image, $size_preset, true); if (!$src) { return false; } return '<img src="' . $src . '" ' . $size . ' alt="' . htmlspecialchars($alt) . '" />'; }
<div class="widget_content_list tiles-big"> <?php foreach ($items as $item) { ?> <?php $url = href_to($ctype['name'], $item['slug']) . '.html'; ?> <div class="item"> <?php if ($image_field && !empty($item[$image_field])) { ?> <div class="image"> <a style="background-image:url('<?php echo html_image_src($item[$image_field], 'normal', true); ?> ')" href="<?php echo $url; ?> "></a> </div> <?php } ?> <div class="info"> <?php if ($is_show_details) { ?> <div class="details"> <span class="author">