<?php /** * This file is part of the Morfy. * * (c) Romanenko Sergey / Awilum <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ // Add {block name=block-name} shortcode Shortcode::add('block', function ($attributes) { if (isset($attributes['name'])) { return Blocks::get($attributes['name']); } }); // Add {site_url} shortcode Shortcode::add('site_url', function () { return Url::getBase(); });
<?php /** * Breadcrumb Plugin * Based on idea from https://github.com/tovic/breadcrumb-plugin-for-fansoro-cms * * @package Fansoro * @subpackage Plugins * @author Pavel Belousov / pafnuty * @version 1.1.0 * @license https://github.com/pafnuty-fansoro-plugins/fansoro-plugin-breadcrumb/blob/master/LICENSE MIT */ Action::add('breadcrumb', function () { // Configuration data $config = Config::get('plugins.breadcrumb'); // Get current URI segments $paths = Url::getUriSegments(); // Count total paths $total_paths = count($paths); // Path lifter $lift = ''; // Breadcrumb's data $data = []; for ($i = 0; $i < $total_paths; $i++) { $lift .= '/' . $paths[$i]; $page = Pages::getPage(file_exists(STORAGE_PATH . '/pages/' . $lift . '/index.md') || file_exists(STORAGE_PATH . '/pages/' . $lift . '.md') ? $lift : '404'); $data[Url::getBase() . $lift] = ['title' => $page['title'], 'current' => rtrim(Url::getCurrent(), '/') === rtrim(Url::getBase() . $lift, '/')]; } $template = Template::factory(THEMES_PATH . '/' . Config::get('system.theme')); $template->display('/plugins/breadcrumb/breadcrumb.tpl', ['home' => rtrim(Url::getCurrent(), '/') === rtrim(Url::getBase(), '/') ? true : Url::getBase(), 'config' => $config, 'branch' => $data]); });
/** * Morfy Social Sharing Buttons Plugin based on Likely * * (c) Evgeny Steblinsky / volter9 <volter9.github.io> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ class Likely { /** * @param string $title * @param string $url * @param array|string $classes */ public static function buttons($title = '', $url = '', $classes = '') { $classes = is_array($classes) ? implode(' ', $classes) : $classes; $template = Template::factory(PLUGINS_PATH . '/likely/templates/'); $template->display('likely.tpl', compact('title', 'url', 'classes')); } } Action::add('theme_header', function () { $base = Url::getBase(); printf('<link href="%s/plugins/likely/bower_components/ilyabirman-likely/release/likely.css" rel="stylesheet">', $base); }); Action::add('theme_footer', function () { $base = Url::getBase(); printf('<script src="%s/plugins/likely/bower_components/ilyabirman-likely/release/likely.js"></script>', $base); });
File::delete(STORAGE_PATH . '/pages' . Request::get('del') . '.md'); Request::redirect(Url::getBase()); } else { die('crsf detect !'); } } // remove Cache if (Request::get('clearcache') == 'true') { if (Request::get('token')) { if (Dir::exists(CACHE_PATH . '/doctrine/')) { Dir::delete(CACHE_PATH . '/doctrine/'); } if (Dir::exists(CACHE_PATH . '/fenom/')) { Dir::delete(CACHE_PATH . '/fenom/'); } Request::redirect(Url::getBase()); } else { die('crsf detect !'); } } // logout if (Request::post('access_logout')) { Session::delete(Config::get('plugins.edit.name') . '_user'); Request::redirect(Url::getCurrent()); } // show template $template->display('admin.tpl', ['title' => $name, 'content' => $page, 'current' => $url, 'directory' => Dir::scan(STORAGE_PATH . '/pages')]); } else { // login if (Request::post('access_login')) { if (Request::post('token')) {
/** * Social Meta Plugin * * @package Fansoro * @subpackage Plugins * @author Pavel Belousov / pafnuty * @version 1.2.0 * @license https://github.com/pafnuty-fansoro-plugins/fansoro-plugin-socialmeta/blob/master/LICENSE MIT */ Action::add('theme_meta', function () { if (!class_exists('resize')) { require_once PLUGINS_PATH . '/socialmeta/classes/resize.php'; } require_once PLUGINS_PATH . '/socialmeta/classes/SocialMeta.php'; $config = Config::get('plugins.socialmeta'); $page = Pages::getCurrentPage(); $socialMeta = new SocialMeta(); $title = $page['title']; $description = $page['description'] ? $page['description'] : $page['content']; $description = $socialMeta->textLimit($description, 250); $twitterImage = isset($page['twitter_image']) ? Url::getBase() . $page['twitter_image'] : $socialMeta->getImage($page['content'], $config['twitter']['noimage'], '600x330', '100'); $facebookImage = isset($page['og_image']) ? Url::getBase() . $page['og_image'] : $socialMeta->getImage($page['content'], $config['facebook']['noimage'], '600x315', '100'); $arTwitter = ['twitter:card' => 'summary_large_image', 'twitter:site' => '@' . $config['twitter']['author'], 'twitter:creator' => '@' . $config['twitter']['author'], 'twitter:domain' => Url::getBase(), 'twitter:title' => $title, 'twitter:description' => $description, 'twitter:image' => $twitterImage]; $arFacebook = ['og:type' => 'website', 'og:site_name' => Config::get('site.title'), 'og:url' => $page['url'], 'og:title' => $title, 'og:description' => $description, 'og:image' => $facebookImage]; foreach ($arTwitter as $name => $content) { echo '<meta name="' . $name . '" content="' . $content . '">'; } foreach ($arFacebook as $property => $content) { echo '<meta property="' . $property . '" content="' . $content . '">'; } }, '100');
<?php /** * Emoji plugin for Fansoro * * @package Fansoro * @subpackage Plugins * @author Pavel Belousov / pafnuty * @version 1.1.0 * @license https://github.com/pafnuty-fansoro-plugins/fansoro-plugin-emoji/blob/master/LICENSE MIT * */ Action::add('theme_header', function () { echo '<link rel="stylesheet" href="' . Url::getBase() . '/plugins/emoji/assets/css/emoji.css">'; }); Action::add('theme_footer', function () { echo '<script src="' . Url::getBase() . '/plugins/emoji/assets/js/emojify.min.js"></script>'; echo '<script src="' . Url::getBase() . '/plugins/emoji/assets/js/emoji.js"></script>'; });
public static function init() { // login vars $user = trim(Config::get('plugins.gallery.email')); $password = trim(Config::get('plugins.gallery.password')); $token = trim(Config::get('plugins.gallery.token')); $hash = md5($token . $password); // get plugin info //var_dump(json_encode(Config::get('plugins.gallery'),true)); $template = Template::factory(PLUGINS_PATH . '/gallery/templates/'); $template->setOptions(['strip' => false]); $jsonFile = ''; $format = ''; $thumbnails_path = ''; $photos_path = ''; $json = ''; $info = ''; // check if dir exists if not create if (!Dir::exists(ROOT_DIR . '/public/gallery')) { Dir::create(ROOT_DIR . '/public/gallery'); } if (!Dir::exists(ROOT_DIR . '/public/gallery/thumbnails')) { Dir::create(ROOT_DIR . '/public/gallery/thumbnails'); } if (!Dir::exists(ROOT_DIR . '/public/gallery/galleries')) { Dir::create(ROOT_DIR . '/public/gallery/galleries'); } if (!File::exists(ROOT_DIR . '/public/gallery/gallery.json')) { File::setContent(ROOT_DIR . '/public/gallery/gallery.json', '[]'); } else { $jsonFile = ROOT_DIR . '/public/gallery/gallery.json'; $format = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'JPG', 'JPEG'); $thumbnails_path = ROOT_DIR . '/public/gallery/thumbnails/'; $photos_path = ROOT_DIR . '/public/gallery/galleries/'; // decode json $json = json_decode(File::getContent($jsonFile), true); } // show loginbtn if (Session::exists(Config::get('plugins.gallery.name') . '_user')) { // logout if (Request::post('access_logout')) { Session::delete(Config::get('plugins.gallery.name') . '_user'); Request::redirect(Url::getBase() . '/' . strtolower(Config::get('plugins.gallery.name'))); } // create gallery if (Request::post('createGallery')) { if (Request::post('token')) { // id $id = time(); // json array remenber encode $json[$id] = array('id' => $id, 'title' => Request::post('title') ? Request::post('title') : 'No title', 'desc' => Request::post('desc') ? Request::post('desc') : 'No desc', 'thumbnail' => '/public/gallery/thumbnails/' . $id . '.png', 'photos' => ROOT_DIR . '/public/gallery/galleries/' . $id . '/'); Dir::create($photos_path . $id); // save content if (File::setContent($jsonFile, json_encode($json))) { self::upload('thumbnail', 'thumbnail', $format, $thumbnails_path, $id); self::upload('photos', 'photos', $format, $photos_path, $id); return self::set_msg('Success The gallery has been created'); } } else { die('Crsf detect!'); } } // update gallery if (Request::post('updateGallery')) { if (Request::post('token')) { // json array remenber encode $id = Request::post('update_id'); $json[$id] = array('id' => $id, 'title' => Request::post('update_title') ? Request::post('update_title') : 'No title', 'desc' => Request::post('update_desc') ? Request::post('update_desc') : 'No desc', 'thumbnail' => '/public/gallery/thumbnails/' . $id . '.png', 'photos' => ROOT_DIR . '/public/gallery/galleries/' . $id . '/'); // save content if (File::setContent($jsonFile, json_encode($json))) { //upload images self::upload('thumbnail', 'update_thumbnail', $format, $thumbnails_path, $id); self::upload('photos', 'update_photos', $format, $photos_path, $id); return self::set_msg('Success The gallery has been updated'); } } else { die('Crsf detect!'); } } // resize gallery if (Request::post('resizeGallery')) { if (Request::post('token')) { $uid = Request::post('gallery_id'); $w = Request::post('gallery_w'); $h = Request::post('gallery_h'); $files = File::scan($photos_path . $uid); foreach ($files as $file) { // Load the original image $image = new SimpleImage($file); $image->resize($w, $h, true); $image->save($file); } return self::set_msg('Success The gallery Photos, has been resized'); } } // resize thumbnail if (Request::post('resizeThumbnail')) { if (Request::post('token')) { $uid = Request::post('gallery_id'); $tw = Request::post('gallery_tw'); $th = Request::post('gallery_th'); $dir = ROOT_DIR . '/public/gallery/thumbnails/' . $uid . '.png'; // Load the original image $image = new SimpleImage($dir); $image->resize($tw, $th, true); $image->save($dir); return self::set_msg('Success The gallery Thumbnail, has been created'); } } // remove file if (Request::get('rem')) { $file = base64_decode(Request::get('rem')); $uid = Request::get('id'); File::delete($file); self::set_msg('Success The Image has been deleted'); } // remove gallery if (Request::get('del')) { $id_of_gallery = Request::get('del'); unset($json[$id_of_gallery]); if (File::setContent($jsonFile, json_encode($json))) { File::delete(ROOT_DIR . '/public/gallery/thumbnails/' . $id_of_gallery . '.png'); Dir::delete($photos_path . $id_of_gallery); self::set_msg('Success The Gallery ' . $id_of_gallery . ' has been deleted'); Request::redirect(Url::getBase() . '/gallery'); } } // show template return $template->display('admin.tpl', ['info' => self::get_msg(), 'title' => Config::get('plugins.gallery.name') . ' Admin Area', 'root_dir' => ROOT_DIR, 'info' => $info, 'content' => $json ? array_reverse($json) : '']); } else { // login access if (Request::post('access_login')) { if (Request::post('token')) { if (Request::post('password') == $password && Request::post('email') == $user) { @Session::start(); Session::set(Config::get('plugins.gallery.name') . '_user', $hash); // show admin template Request::redirect(Url::getBase() . '/gallery'); } else { // password not correct show error $template->display('partials/error.tpl', ['title' => 'Access Error', 'content' => Config::get('plugins.gallery.errorPassword')]); } } else { // crsf die('crsf detect'); } } // template return $template->display('home.tpl', ['root_dir' => ROOT_DIR, 'content' => $json ? array_reverse($json) : '']); } }
/** * Get page * * <code> * $page = Pages::getPage('downloads'); * </code> * * @access public * @param string $url Url * @return array */ public static function getPage($url) { // If url is empty that its a homepage if ($url) { $file = STORAGE_PATH . '/pages/' . $url; } else { $file = STORAGE_PATH . '/pages/' . 'index'; } // Select the file if (is_dir($file)) { $file = STORAGE_PATH . '/pages/' . $url . '/index.md'; } else { $file .= '.md'; } // Get 404 page if file not exists if (!file_exists($file)) { $file = STORAGE_PATH . '/pages/' . '404.md'; Response::status(404); } // Create Unique Cache ID for requested page $page_cache_id = md5('page' . ROOT_DIR . $file . filemtime($file)); if (Cache::driver()->contains($page_cache_id) && Config::get('system.pages.flush_cache') == false) { return Cache::driver()->fetch($page_cache_id); } else { $content = file_get_contents($file); $_page = explode('---', $content, 3); $page = Yaml::parse($_page[1]); $url = str_replace(STORAGE_PATH . '/pages', Url::getBase(), $file); $url = str_replace('index.md', '', $url); $url = str_replace('.md', '', $url); $url = str_replace('\\', '/', $url); $url = rtrim($url, '/'); $page['url'] = $url; $_content = $_page[2]; // Parse page for summary <!--more--> if (($pos = strpos($_content, "<!--more-->")) === false) { $_content = Filter::apply('content', $_content); } else { $_content = explode("<!--more-->", $_content); $_content['summary'] = Filter::apply('content', $_content[0]); $_content['content'] = Filter::apply('content', $_content[0] . $_content[1]); } if (is_array($_content)) { $page['summary'] = $_content['summary']; $page['content'] = $_content['content']; } else { $page['content'] = $_content; } $page['slug'] = basename($file, '.md'); // Overload page title, keywords and description if needed empty($page['title']) and $page['title'] = Config::get('site.title'); empty($page['keywords']) and $page['keywords'] = Config::get('site.keywords'); empty($page['description']) and $page['description'] = Config::get('site.description'); Cache::driver()->save($page_cache_id, $page); return $page; } }
</div><!--//content_inner--> </div><!--//content--> <div id="footer"> <p> Missoula Adoptables was created for Software Engineering at the University of Montana-Missoula by Jon-Michael Deldin and Evan Cummings. </p> <p> Contact us at <a href="mailto:<?php echo Site::getInstance()->getEmail(); ?> "> <?php echo Site::getInstance()->getEmail(); ?> </a> </p> </div> <script src="<?php Url::getBase(); ?> /js/site.js"></script> </body> </html>
/** * Poll for Fansoro CMS. * * @author Moncho Varela * * @version 1.0.0 * * @license MIT */ Action::add('theme_footer', function () { echo '<script> var current = "' . Url::getCurrent() . '"; var pollDb = "' . Url::getBase() . '/plugins/poll/db/db.json"; </script>'; echo '<script src="' . Url::getBase() . '/plugins/poll/assets/poll.js"></script>'; }); /* * Description: add function * Example: {Poll(1,'Do you like Fansoro?','yes','no')} */ function Poll($id, $question, $answer1 = 'Yes', $answer2 = 'No') { // values $id = isset($id) ? $id : ''; $question = isset($question) ? $question : ''; $answer1 = isset($answer1) ? $answer1 : ''; $answer2 = isset($answer2) ? $answer2 : ''; // json dir $dir = PLUGINS_PATH . '/poll/db/db.json'; // clear vars init
public function logout() { Session::instance()->vanish(); Url::redirectTo(Url::getBase()); }
public function logoutPage() { Session::destroy(); header('Location: ' . Url::getBase() . '/login'); exit; }
<?php /** * Morfy Githubser Plugin. * * (c) Moncho Varela / Nakome <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ // add javascript file Action::add('theme_footer', function () { echo '<script type="text/javascript" src="' . Url::getBase() . '/plugins/githubser/githubser.js"></script>'; }); // add Shortcode {Githubser name="nakome"} ShortCode::add('Githubser', function ($a) { extract($a); $name = $name ? $name : ''; return '<section> <script type="text/javascript">var githubUsername = "******";</script> <div id="githubUser"></div> </section>'; });
<?php /** * Youtube for Fansoro CMS * Based on https://togetherjs.com/#tryitout-section. * * @author Moncho Varela * * @version 1.0.0 * * @license MIT */ Action::add('theme_footer', function () { echo '<script type="text/javascript" src="' . Url::getBase() . '/plugins/channel/assets/channel-dist.js"></script>'; }); ShortCode::add('Channel', function ($attr) { extract($attr); //{Channel name="nakome" limit="50"} $name = isset($name) ? $name : Config::get('plugins.channel.username'); $limit = isset($limit) ? $limit : 1; $quality = isset($quality) ? $quality : 'false'; $quantity = isset($quantity) ? $quantity : 8; // template factory $template = Template::factory(PLUGINS_PATH . '/' . Config::get('plugins.channel.name') . '/templates/'); $template->setOptions(['strip' => false]); return $template->fetch('gallery.tpl', ['name' => $name, 'limit' => $limit, 'quality' => $quality, 'quantity' => $quantity, 'apikey' => Config::get('plugins.channel.apikey')]); });
/** * Description: Producto Details Shortcode * Shortcode to get details of product item. */ public static function item_detail($attributes, $content) { // Extract attributes extract($attributes); if (isset($id)) { $id = $id; } else { $id = ''; } if (isset($url)) { $url = $url; } else { $url = ''; } if (isset($title)) { $title = $title; } else { $title = ''; } if (isset($description)) { $description = $description; } else { $description = ''; } if (isset($image)) { $image = $image; } else { $image = ''; } if (isset($price)) { $price = $price; } else { $price = ''; } $template = Template::factory(PLUGINS_PATH . '/shipcart/templates/'); $template->setOptions(['strip' => false]); // show template return $template->fetch('item_detail.tpl', ['id' => $id, 'url' => Url::getBase() . $url, 'title' => $title, 'description' => $description, 'image' => Url::getBase() . $image, 'price' => $price, 'content' => Filter::apply('content', $content)]); }
foreach ($data as $key => $value) { ?> <div class="client-block"> <a href="<?php echo Url::getBase(); ?> /clients/website/<?php echo $value['id']; ?> "> <img src="<?php echo $value['image']; ?> "> </a> <br> <h2> <a href="<?php echo Url::getBase(); ?> /clients/website/<?php echo $value['id']; ?> "><?php echo $value['title']; ?> </a> </h2> </div> <?php }
<div class="animal_container"> <?php $i = 0; ?> <?php foreach ($animals as $animal) { ?> <div class="animal <?php echo ($i & 1) === 0 ? "left" : "right"; $i++; ?> "> <div class="photo"> <img width="100" src="<?php echo $animal->hasImage() ? $animal->getImage() : Url::getBase() . "/img/no-photo.png"; ?> " alt="Photo of <?php echo $animal->getName(); ?> "> </div> <div class="details"> <table> <tr> <th>Name:</th> <td><?php echo $animal->getName(); ?> </td>
if (!class_exists('resize')) { require_once PLUGINS_PATH . '/thumb/classes/resize.php'; } // Изменяем размер $resizeImg = new resize($imgResized); $resizeImg->resizeImage($imgSize[0], $imgSize[1], $method); // Сохраняем картинку в заданную папку $resizeImg->saveImage($dir . $fileName, $quality); } $imgResized = Url::getBase() . $imageDir . $fileName; } $title = isset($title) ? $title : ''; $alt = isset($alt) ? $alt : ''; $class = isset($class) ? $class . ' popup-image' : 'popup-image'; $gallery = isset($gallery) ? '-gallery' : ''; $imageLink = '<a class="' . $class . $gallery . '" href="' . $content . '" title="' . $title . '"><img src="' . $imgResized . '" alt="' . $alt . '"></a>'; return $imageLink; } return ''; }); Action::add('theme_header', function () { if (Config::get('plugins.thumb.loadcss')) { echo '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.min.css">'; } }); Action::add('theme_footer', function () { if (Config::get('plugins.thumb.loadjs')) { echo '<script src="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.min.js"></script>'; echo '<script src="' . Url::getBase() . '/plugins/thumb/assets/js/thumb.js"></script>'; } });
* For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /* * fn: {Action::run('Edit')} */ Action::add('Edit', function () { // login vars $user = trim(Config::get('plugins.edit.email')); $password = trim(Config::get('plugins.edit.password')); $token = trim(Config::get('plugins.edit.token')); $hash = md5($token . $password); // get plugin info //var_dump(json_encode(Config::getConfig(),true)); // current url $url = str_replace(Url::getBase(), '', Url::getCurrent()); $page = ''; $name = ''; // empty = index.md if ($url == trim('/')) { $name = trim('/index.md'); $page = File::getContent(STORAGE_PATH . '/pages' . $name); // blog = blog/index.md } elseif ($url == trim('/blog')) { $name = trim('/blog/index.md'); $page = File::getContent(STORAGE_PATH . '/pages' . $name); /* // for another index folder names }else if($url == trim('/foldername ')){ $name = trim('/foldername/index.md'); $page = File::getContent(STORAGE_PATH.'/pages'.$name);
/** * @param $data * @param string $noimage * @param $size * @param string $quality * @param string $number * @param string $resizeType * @param bool|true $grabRemote * * @return array|string */ public function getImage($data, $noimage = '', $size, $quality = '90', $number = '1', $resizeType = 'crop', $grabRemote = true) { $resizeType = $resizeType == '' || !$resizeType ? 'auto' : $resizeType; $quality = $quality == '' || !$quality ? '100' : $quality; $noimage = Url::getBase() . $noimage; // Задаём папку для загрзки картинок по умолчанию. $uploadDir = '/storage/social/'; // Задаём папку для картинок $imageDir = $uploadDir . $size . '/'; $dir = ROOT_DIR . $imageDir; // $data = stripslashes($data); $arImages = array(); if (preg_match_all('/<img(?:\\s[^<>]*?)?\\bsrc\\s*=\\s*(?|"([^"]*)"|\'([^\']*)\'|([^<>\'"\\s]*))[^<>]*>/i', $data, $m)) { $i = 1; // Счётчик // Если регулярка нашла картинку — работаем. if (isset($m[1])) { foreach ($m[1] as $key => $url) { // Если номер картинки меньше, чем требуется — проходим мимо. if ($number != 'all' && $i < (int) $number) { // Не забываем прибавить счётчик. $i++; continue; } $imageItem = $url; // Удаляем текущий домен из строки. $urlShort = str_ireplace(Url::getBase(), '', $imageItem); // Проверяем наша картинка или чужая. $isRemote = preg_match('~^http(s)?://~', $urlShort) ? true : false; // Проверяем разрешено ли тянуть сторонние картинки. $grabRemoteOn = $grabRemote ? true : false; // Отдаём заглушку, если ничего нет. if (!$urlShort) { $imageItem = $noimage; continue; } // Если внешняя картинка и запрещего грабить картинки к себе — возвращаем её. if ($isRemote && !$grabRemoteOn) { $imgResized = $urlShort; continue; } // Работаем с картинкой // Если есть параметр size — включаем ресайз картинок if ($size) { // Создаём и назначаем права, если нет таковых if (!is_dir($dir)) { @mkdir($dir, 0755, true); @chmod($dir, 0755); } if (!chmod($dir, 0755)) { @chmod($dir, 0755); } // Присваиваем переменной значение картинки (в т.ч. если это внешняя картинка) $imgResized = $urlShort; // Если не внешняя картинка — подставляем корневю дирректорию, чтоб ресайзер понял что ему дают. if (!$isRemote) { $imgResized = ROOT_DIR . $urlShort; } // Определяем новое имя файла $fileName = $size . '_' . $resizeType . '_' . strtolower(basename($imgResized)); // Если картинки нет в папке обработанных картинок if (!file_exists($dir . $fileName)) { // Если картинка локальная, или картинка внешняя и разрешено тянуть внешние — обработаем её. if (!$isRemote || $grabRemoteOn && $isRemote) { // Разделяем высоту и ширину $imgSize = explode('x', $size); // Если указана только одна величина - присваиваем второй первую, будет квадрат для exact, auto и crop, иначе класс ресайза жестоко тупит, ожидая вторую переменную. if (count($imgSize) == '1') { $imgSize[1] = $imgSize[0]; } // @TODO: по хорошему надо бы вынести ресайз в отдельный метод на случай, если понадобится другой класс для ресайза. // Подрубаем класс для картинок $resizeImg = new resize($imgResized); $resizeImg->resizeImage($imgSize[0], $imgSize[1], $resizeType); $resizeImg->saveImage($dir . $fileName, $quality); // Сохраняем картинку в заданную папку } } $imgResized = Url::getBase() . '/storage' . $imageDir . $fileName; } else { // Если параметра imgSize нет - отдаём исходную картинку $imgResized = $urlShort; } // Отдаём дальше результат обработки. $imageItem = $imgResized; $arImages[$i] = $imageItem; if ($number == $i) { break; } $i++; } } } else { // Если регулярка не нашла картинку - отдадим заглушку $arImages[$number] = $noimage; } // Если хотим все картинки — не вопрос, получим массив. if ($number == 'all') { return $arImages; } // По умолчанию возвращаем отдну картинку (понимаю, что метод должен возвращать всегда один тип данных, но это сделано из-за совместимости версий) return $arImages[$number]; }
<?php /** * Created by Boomerang * Project: CMS(Site) * Date: 05 Month 2013 Year * Site created on PHP,MySQL */ /*include '../../constants.php'; include '../../libraries/application/loader.php'; loader::init();*/ $baseurl = Url::getBase(); $app = new Application(); $config = $app->getConfig(); $template = $config->template; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Главная</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="<?php echo $baseurl; ?> /templates/<?php echo $template; ?> /css/main.css"/>