/** * Match a plain URL. * * @access public */ public function testComplexRoutes() { // Set up the reflection class $reflection = new ReflectionMethod('Core\\Router', 'routeTest'); $reflection->setAccessible(true); // Here be variable routes // One directory, one variable $route = new Core\Route('Foo'); $route->setRoute('foo/:bar')->setFormat(array('bar' => '\\d+'))->setEndpoint(array('controller' => 'Foo')); // Passes $this->assertTrue($reflection->invoke(new Core\Router(), array('foo', '1'), $route)); $this->assertTrue($reflection->invoke(new Core\Router(), array('foo', '12'), $route)); $this->assertTrue($reflection->invoke(new Core\Router(), array('foo', '123'), $route)); $this->assertTrue($reflection->invoke(new Core\Router(), array('foo', '123', 'foo'), $route)); // Fails $this->assertFalse($reflection->invoke(new Core\Router(), array('foo'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo/:bar'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo/bar'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo/a123'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo/1a23'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo/12a3'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo/a123a'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo/12-3'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo/12_3'), $route)); // Two directories, two variables $route = new Core\Route('Foo'); $route->setRoute('foo/:bar/hello/:world')->setFormat(array('bar' => '\\d+'))->setEndpoint(array('controller' => 'Foo')); // Passes $this->assertTrue($reflection->invoke(new Core\Router(), array('foo', '1', 'hello', 'world'), $route)); $this->assertTrue($reflection->invoke(new Core\Router(), array('foo', '123', 'hello', 'abc123'), $route)); $this->assertTrue($reflection->invoke(new Core\Router(), array('foo', '123', 'hello', 'ab-c12-3'), $route)); $this->assertTrue($reflection->invoke(new Core\Router(), array('foo', '123', 'hello', 'ab_c12_3'), $route)); $this->assertTrue($reflection->invoke(new Core\Router(), array('foo', '1', 'hello', 'world', 'foo'), $route)); // Fails // Missing parameters $this->assertFalse($reflection->invoke(new Core\Router(), array('foo'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo', '1'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo', '1', 'hello'), $route)); // Wrong basic parameters $this->assertFalse($reflection->invoke(new Core\Router(), array('bar', '1', 'hello', 'world'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo', '1', 'bar', 'world'), $route)); // Wrong number type $this->assertFalse($reflection->invoke(new Core\Router(), array('foo', 'bar', 'hello', 'world'), $route)); // Incorrect default data types, not matching [\w\-]+ $this->assertFalse($reflection->invoke(new Core\Router(), array('foo', '1', 'hello', 'wo"rld'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo', '1', 'hello', 'wo\'rld'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo', '1', 'hello', 'wo<rld'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo', '1', 'hello', 'wo>rld'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo', '1', 'hello', 'wo@rld'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo', '1', 'hello', 'wo!rld'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo', '1', 'hello', 'wo£rld'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo', '1', 'hello', 'wo$rld'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo', '1', 'hello', 'wo%rld'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo', '1', 'hello', 'wo&rld'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo', '1', 'hello', 'wo+rld'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo', '1', 'hello', 'wo.rld'), $route)); $this->assertFalse($reflection->invoke(new Core\Router(), array('foo', '1', 'hello', 'wo rld'), $route)); }
<div class="wWrapper"> <?php echo Core\Widgets::get('header', array('config' => $_config)); ?> <div class="wConteiner"> <div class="wSize"> <?php echo $_breadcrumbs; ?> <?php echo $_content; ?> <?php if (!Core\Route::param('alias')) { ?> <?php echo Core\Widgets::get('banners'); ?> <?php } ?> </div> <div class="clear"></div> </div> </div> <div class="clear"></div> <?php echo Core\Widgets::get('footer', array('counters' => Core\Arr::get($_seo, 'counters'), 'config' => $_config));
<!--">--> <!-- </div>--> <div style="display: inline-block;"> <label class="control-label" style="display: block;">Статус</label> <select name="status"> <option value="null">Все</option> <option value="1" <?php echo $_GET['status'] == "1" ? 'selected' : ''; ?> >Опубликовано</option> <option value="0" <?php echo $_GET['status'] == "0" ? 'selected' : ''; ?> >Не опубликовано</option> </select> </div> <input class="button btn-primary" style="display: inline-block;" type="submit" name="send" value="Поиск"> <a href="/backend/organizer/inner/<?php echo Core\Route::param('id'); ?> " style="display: inline-block;"> <i class="fa-refresh"></i> <span class="">Сбросить</span> </a> </form> </div> </div> </div>
?> <a href="<?php echo Core\HTML::media('images/slider/big/' . $obj->image); ?> " rel="lightbox"> <img src="<?php echo Core\HTML::media('images/slider/small/' . $obj->image); ?> " /> </a> <br /> <?php if (Core\User::caccess() == 'edit') { ?> <a href="/backend/<?php echo Core\Route::controller(); ?> /delete_image/<?php echo $obj->id; ?> ">Удалить изображение</a> <?php } ?> <?php } else { ?> <input type="file" name="file" /> <?php } ?>
<div class="toolbar no-padding"> <div class="btn-group"> <?php if (Core\User::caccess() == 'edit') { ?> <a title="Сохранить" href="#" class="btn btn-lg text-success bs-tooltip btn-save"><i class="fa-check"></i> <span class="hidden-xx">Сохранить</span></a> <?php } ?> <a title="Закрыть" href="<?php echo $list_link ? $list_link : '/backend/' . Core\Route::controller() . '/index'; ?> " class="btn btn-lg text-danger bs-tooltip"><i class="fa-times-circle"></i> <span class="hidden-xx">Закрыть</span></a> </div> </div> <script> $('.toolbar').on('click', '.btn-save', function(e){ e.preventDefault(); $('form#myForm input[type="submit"]').click(); }); </script>
<li> <a title="Редактировать" href="<?php echo '/backend/seo/' . Core\Route::controller() . '/edit/' . $obj->id; ?> "><i class="fa-pencil"></i> Редактировать ссылку</a> </li> <?php } ?> <?php if (Core\User::caccess() == 'edit') { ?> <li class="divider"></li> <li> <a title="Удалить" onclick="return confirm('Это действие необратимо. Продолжить?');" href="<?php echo '/backend/seo/' . Core\Route::controller() . '/delete/' . $obj->id; ?> "><i class="fa-trash-o text-danger"></i> Удалить ссылку</a> </li> <?php } ?> </ul> </li> </ul> </td> </tr> </table> </div> </li> <?php
<label class="control-label" style="display: block;">Дата до</label> <input name="date_po" class="form-control fPicker" value="<?php echo Core\Arr::get($_GET, 'date_po', NULL); ?> "> </div> <div style="display: inline-block;"> <label class="control-label" style="display: block;">Статус</label> <select name="status"> <option value="">Все</option> <option value="success" <?php echo $_GET['status'] == 'success' ? 'selected' : ''; ?> >Оплачено</option> </select> </div> <input class="button btn-primary" style="display: inline-block;" type="submit" name="send" value="Поиск"> <a href="/backend/cassier/<?php echo Core\Route::param('id') ? 'inner/' . Core\Route::param('id') : 'index'; ?> " style="display: inline-block;"> <i class="fa-refresh"></i> <span class="">Сбросить</span> </a> </form> </div> </div> </div>
?> ">Личный кабинет</a> </div> <div class="menuElement <?php echo Core\Route::action() == 'orders' ? 'current' : ''; ?> "> <a href="<?php echo Core\HTML::link('user/orders'); ?> ">Мои заказы</a> </div> <div class="menuElement <?php echo Core\Route::action() == 'profile' ? 'current' : ''; ?> "> <a href="<?php echo Core\HTML::link('user/profile'); ?> ">Мои данные</a> </div> <div class="menuElement <?php echo Core\Route::action() == 'change_password' ? 'current' : ''; ?> "> <a href="<?php echo Core\HTML::link('user/change_password'); ?> ">Изменить пароль</a> </div> </div>
public function __construct($name, \Closure $callback) { \Core\Route::$group = $name; call_user_func($callback, new \Core\Controller()); \Core\Route::$group = null; }
// PHPExcel if (strpos($className, 'PHPExcel') !== FALSE || strpos($className, 'Minify') !== FALSE) { if ($className == 'PHPExcel') { $className = 'PHPExcel_PHPExcel'; } $fileName = HOST . '/Plugins/' . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; if (file_exists($fileName)) { require_once $fileName; return false; } } // If I18n $arr = explode('\\', $className); if (end($arr) == 'I18n') { return; } // else $className = ltrim($className, '\\'); $fileName = ''; $namespace = ''; if ($lastNsPos = strrpos($className, '\\')) { $namespace = substr($className, 0, $lastNsPos); $className = substr($className, $lastNsPos + 1); $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; } $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; require '../' . $fileName; } spl_autoload_register('autoload'); Core\Route::factory()->execute(); Plugins\Profiler\Profiler::view();
?> </ul> <?php } ?> </li> <?php } ?> <?php } ?> </ul> <div class="reset_block"> <a href="<?php echo Core\HTML::link('catalog/' . Core\Route::param('alias')); ?> " class="reset_but"> <span>Сбросить ВСЕ фильтры</span> </a> </div> </form> <script> $(function(){ $('label.checkBlock').on('click', function(){ if( $(this).find('input').prop('disabled') ) { return false; } window.location.href = $(this).find('a').attr('href'); });
<div class="small_filt" id="catalogSort" data-uri="<?php echo str_replace('/page/' . Core\Route::param('page'), '', Core\Arr::get($_SERVER, 'REQUEST_URI')); ?> " data-get="<?php echo Core\Route::controller() == 'search' ? 'query=' . Core\Arr::get($_GET, 'query') : ''; ?> "> <div class="small_filt1"> <p>выводить ПО:</p> <select name="per_page" id="select1"> <?php $limit = Core\Config::get('limit'); ?> <?php for ($i = Core\Config::get('limit'); $i < Core\Config::get('limit') * 5; $i += Core\Config::get('limit')) { ?> <option value="<?php echo $i; ?> " <?php echo Core\Arr::get($_GET, 'per_page') == $i ? 'selected' : ''; ?> ><?php echo $i; ?> </option> <?php } ?> </select> <p>на странице</p>
</div> </div> </td> <td width="45" valign="top" class="icon-column status-column"> <?php echo Core\View::widget(array('status' => $obj->status, 'id' => $obj->id), 'StatusList'); ?> </td> <td class="nav-column icon-column" valign="top"> <ul class="table-controls"> <li> <a title="Управление" href="javascript:void(0);" class="bs-tooltip dropdownToggle"><i class="fa-cog"></i> </a> <ul class="dropdownMenu pull-right"> <li> <a title="Редактировать" href="<?php echo '/backend/' . Core\Route::controller() . '/edit/' . $obj->id; ?> "><i class="fa-pencil"></i> Редактировать</a> </li> </ul> </li> </ul> </td> </tr> </table> </div> </li> <?php } ?> </ol>
<?php $controller = Core\Route::controller(); $action = Core\Route::action(); ?> <ul> <li <?php echo ($controller == 'catalog' and in_array($action, array('index', 'list', 'groups', 'item'))) ? 'class="active_li_top"' : ''; ?> > <a href="<?php echo Core\HTML::link('catalog'); ?> "><div>каталог</div></a><div class="list top_list"> <ul> <?php foreach ($result[0] as $main) { ?> <li> <a href="<?php echo Core\HTML::link('catalog/' . $main->alias); ?> " class="title_li"><?php echo $main->name; ?> </a> <?php if (isset($result[$main->id])) { ?> <ul> <?php
<?php require_once CORE_PATH . '/classes/uri.php'; require_once CORE_PATH . '/classes/input.php'; require_once CORE_PATH . '/classes/route.php'; require_once CORE_PATH . '/classes/db.php'; require_once CORE_PATH . '/classes/controller.php'; require_once APP_PATH . '/classes/model/image.php'; require_once APP_PATH . '/classes/model/pet.php'; require_once APP_PATH . '/classes/model/user.php'; require_once APP_PATH . '/classes/model/basket.php'; require_once APP_PATH . '/classes/model/message.php'; require_once APP_PATH . '/classes/user.php'; require_once APP_PATH . '/classes/basket.php'; require_once APP_PATH . '/classes/pet.php'; require_once APP_PATH . '/classes/image.php'; require_once APP_PATH . '/classes/message.php'; require_once APP_PATH . '/classes/threadedMessage.php'; try { Core\Db::connect(); } catch (Exception $ex) { echo $ex->getMessage(); } echo Core\Route::execute();
<?php /** * Created by PhpStorm. * User: darevski * Date: 14.09.15 * Time: 22:35 */ namespace Application; include_once 'Core/Psr4AutoLoaderClass.php'; $loader = new Core\Psr4AutoloaderClass(); $loader->register(); $loader->addNamespace('Application\\Core', $_SERVER['DOCUMENT_ROOT'] . '/Application/Core'); $loader->addNamespace('Application\\Controllers', $_SERVER['DOCUMENT_ROOT'] . '/Application/Controllers'); $loader->addNamespace('Application\\Exceptions', $_SERVER['DOCUMENT_ROOT'] . '/Application/Exceptions'); $loader->addNamespace('Application\\Models', $_SERVER['DOCUMENT_ROOT'] . '/Application/Models'); try { $Route = new Core\Route(); $Route->start(); } catch (Exceptions\UFO_Except $error) { $error->classification_error($error); } catch (Exceptions\SQL_Except $error) { echo "Произошла ошибка при работе с базой данных"; // обработка ошибок при работе с базой данных }