protected function init()
 {
     require_once ROOT . DS . 'vendor' . DS . 'hybridauth' . DS . 'hybridauth' . DS . 'hybridauth' . DS . 'Hybrid' . DS . 'Auth.php';
     //D:\xampp\htdocs\libu\vendor\hybridauth\hybridauth\hybridauth\Hybrid
     $config = array("base_url" => Router::url("/social_endpoint", true), "debug_mode" => $this->debug_mode, "debug_file" => $this->debug_file, "providers" => array("Google" => array("enabled" => true, "keys" => array("id" => "384547532967-of8s1pp85dl90dafblfao29ll2qjeglr.apps.googleusercontent.com", "secret" => "tbJRI1QoEwJ5fa8ZfLjitnne")), "Facebook" => array("enabled" => true, "keys" => array("id" => "719642394849027", "secret" => "e6f3739977461ff0339d71ad50490f6d"), "trustForwarded" => false)));
     $this->hybridauth = new \Hybrid_Auth($config);
 }
Beispiel #2
0
 /**
  * Asserts that current url matches route.
  *
  * @param array|string $route Route's array or name.
  * @param array $params Extra route parameters (i.e. prefix, _method, etc.)
  */
 public function seeCurrentRouteIs($route, $params = [])
 {
     if (!is_array($route)) {
         $route = ['_name' => $route];
     }
     $this->seeCurrentUrlEquals(Router::url($route + $params));
 }
 public function data_tables()
 {
     $current_developer = TableRegistry::get('Developers')->findById($this->request->session()->read('Developer.id'))->all()->first();
     $aColumns = ['report_id' => 'Reports.id', 'error_message' => 'Reports.error_message', 'error_name' => 'Reports.error_name', 'pma_version' => 'Reports.pma_version', 'exception_type' => 'Reports.exception_type', 'created_time' => 'Notifications.created'];
     $orderConditions = $this->OrderSearch->getOrder($aColumns);
     $searchConditions = $this->OrderSearch->getSearchConditions($aColumns);
     $aColumns['id'] = 'Notifications.id';
     $params = ['contain' => 'Reports', 'fields' => $aColumns, 'conditions' => ['AND' => [array('Notifications.developer_id ' => $current_developer['id']), $searchConditions]], 'order' => $orderConditions];
     //$current_developer = Sanitize::clean($current_developer);
     $pagedParams = $params;
     $pagedParams['limit'] = intval($this->request->query('iDisplayLength'));
     $pagedParams['offset'] = intval($this->request->query('iDisplayStart'));
     $rows = $this->Notifications->find('all', $pagedParams);
     //$rows = Sanitize::clean($rows);
     // Make the display rows array
     $dispRows = array();
     $tmp_row = array();
     foreach ($rows as $row) {
         $tmp_row[0] = '<input type="checkbox" name="notifs[]" value="' . $row['id'] . '"/>';
         $tmp_row[1] = '<a href="' . Router::url(array('controller' => 'reports', 'action' => 'view', $row['report_id'])) . '">' . $row['report_id'] . '</a>';
         $tmp_row[2] = $row['error_name'];
         $tmp_row[3] = $row['error_message'];
         $tmp_row[4] = $row['pma_version'];
         $tmp_row[5] = $row['exception_type'] ? 'php' : 'js';
         $tmp_row[6] = $row['created_time'];
         array_push($dispRows, $tmp_row);
     }
     $response = array('iTotalDisplayRecords' => count($dispRows), 'iTotalRecords' => $this->Notifications->find('all', $params)->count(), 'sEcho' => intval($this->request->query('sEcho')), 'aaData' => $dispRows);
     $this->autoRender = false;
     $this->response->body(json_encode($response));
     return $this->response;
 }
Beispiel #4
0
 /**
  * test setting parameters in beforeDispatch method
  *
  * @return void
  */
 public function testQueryStringAndCustomTime()
 {
     $folder = CACHE . 'views' . DS;
     $file = $folder . 'posts-home-coffee-life-sleep-sissies-coffee-life-sleep-sissies.html';
     $content = '<!--cachetime:' . (time() + WEEK) . ';ext:html-->Foo bar';
     file_put_contents($file, $content);
     Router::reload();
     Router::connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
     Router::connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
     Router::connect('/:controller/:action/*');
     $_GET = ['coffee' => 'life', 'sleep' => 'sissies'];
     $filter = new CacheFilter();
     $request = new Request('posts/home/?coffee=life&sleep=sissies');
     $response = new Response();
     $event = new Event(__CLASS__, $this, compact('request', 'response'));
     $filter->beforeDispatch($event);
     $result = $response->body();
     $expected = '<!--created:';
     $this->assertTextStartsWith($expected, $result);
     $expected = '-->Foo bar';
     $this->assertTextEndsWith($expected, $result);
     $result = $response->type();
     $expected = 'text/html';
     $this->assertEquals($expected, $result);
     $result = $response->header();
     $this->assertNotEmpty($result['Expires']);
     // + 1 week
     unlink($file);
 }
    public function defineElfinderBrowser($return = false)
    {
        $url = Router::url('/cakephp-tinymce-elfinder/Elfinders/elfinder');
        $clientOptions = Configure::read('TinymceElfinder.client_options');
        $title = Configure::read('TinymceElfinder.title');
        $str = '
		<script type="text/javascript">
		function elFinderBrowser (field_name, url, type, win) {
			  tinymce.activeEditor.windowManager.open({
			    file: "' . $url . '",
			    title: "' . $title . '",
			    width: ' . ($clientOptions['width'] + 20) . ',  
			    height: ' . ($clientOptions['height'] + 50) . ',
			    resizable: "' . $clientOptions['resizable'] . '"
			  }, {
			    setUrl: function (url) {
			      win.document.getElementById(field_name).value = url;
			    }
			  });
			  return false;
			}
		</script>';
        if ($return) {
            return $str;
        } else {
            echo $str;
        }
    }
Beispiel #6
0
 public function setUri($uri)
 {
     if (is_array($uri)) {
         $uri = Router::url($uri);
     }
     return parent::setUri($uri);
 }
 /**
  * Uploads a new file for the given FileField instance.
  *
  * @param string $name EAV attribute name
  * @throws \Cake\Network\Exception\NotFoundException When invalid slug is given,
  *  or when upload process could not be completed
  */
 public function upload($name)
 {
     $instance = $this->_getInstance($name);
     require_once Plugin::classPath('Field') . 'Lib/class.upload.php';
     $uploader = new \upload($this->request->data['Filedata']);
     if (!empty($instance->settings['extensions'])) {
         $exts = explode(',', $instance->settings['extensions']);
         $exts = array_map('trim', $exts);
         $exts = array_map('strtolower', $exts);
         if (!in_array(strtolower($uploader->file_src_name_ext), $exts)) {
             $this->_error(__d('field', 'Invalid file extension.'), 501);
         }
     }
     $response = '';
     $uploader->file_overwrite = false;
     $folder = normalizePath(WWW_ROOT . "/files/{$instance->settings['upload_folder']}/");
     $url = normalizePath("/files/{$instance->settings['upload_folder']}/", '/');
     $uploader->process($folder);
     if ($uploader->processed) {
         $response = json_encode(['file_url' => Router::url($url . $uploader->file_dst_name, true), 'file_size' => FileToolbox::bytesToSize($uploader->file_src_size), 'file_name' => $uploader->file_dst_name, 'mime_icon' => FileToolbox::fileIcon($uploader->file_src_mime)]);
     } else {
         $this->_error(__d('field', 'File upload error, details: {0}', $uploader->error), 502);
     }
     $this->viewBuilder()->layout('ajax');
     $this->title(__d('field', 'Upload File'));
     $this->set(compact('response'));
 }
Beispiel #8
0
 /**
  * Generate URL for given asset file. Depending on options passed provides full URL with domain name.
  * Also calls Helper::assetTimestamp() to add timestamp to local files
  *
  * @param string|array $path Path string or URL array
  * @param array $options Options array. Possible keys:
  *   `fullBase` Return full URL with domain name
  *   `pathPrefix` Path prefix for relative URLs
  *   `ext` Asset extension to append
  *   `plugin` False value will prevent parsing path as a plugin
  * @return string Generated URL
  */
 public function assetUrl($path, array $options = [])
 {
     if (is_array($path)) {
         return $this->build($path, !empty($options['fullBase']));
     }
     if (strpos($path, '://') !== false) {
         return $path;
     }
     if (!array_key_exists('plugin', $options) || $options['plugin'] !== false) {
         list($plugin, $path) = $this->_View->pluginSplit($path, false);
     }
     if (!empty($options['pathPrefix']) && $path[0] !== '/') {
         $path = $options['pathPrefix'] . $path;
     }
     if (!empty($options['ext']) && strpos($path, '?') === false && substr($path, -strlen($options['ext'])) !== $options['ext']) {
         $path .= $options['ext'];
     }
     if (preg_match('|^([a-z0-9]+:)?//|', $path)) {
         return $path;
     }
     if (isset($plugin)) {
         $path = Inflector::underscore($plugin) . '/' . $path;
     }
     $path = $this->_encodeUrl($this->assetTimestamp($this->webroot($path)));
     if (!empty($options['fullBase'])) {
         $path = rtrim(Router::fullBaseUrl(), '/') . '/' . ltrim($path, '/');
     }
     return $path;
 }
 /**
  * Setup method.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Router::plugin('DebugKit', function ($routes) {
         $routes->connect('/toolbar/clear_cache/*', ['plugin' => 'DebugKit', 'controller' => 'Toolbar', 'action' => 'clearCache']);
     });
 }
 /**
  * @return void
  */
 public function main()
 {
     self::_loadRoutes();
     $formatter = "%15s  %-20s  %-20s  %-10s";
     $this->out(sprintf($formatter, 'Method', 'URI Pattern', 'Controller/Action', 'extensions'));
     foreach (Router::routes() as $route) {
         if (isset($route->defaults['_method'])) {
             if (is_array($route->defaults['_method'])) {
                 $outputMethod = implode(',', $route->defaults['_method']);
             } else {
                 $outputMethod = $route->defaults['_method'];
             }
         } else {
             $outputMethod = 'GET';
         }
         $uriPattern = $route->template;
         if (isset($route->options['_ext']) && $route->options['_ext']) {
             $ext = implode(',', $route->options['_ext']);
         } else {
             $ext = "none";
         }
         //そもそもControllerが定義されていないものに関しては表示しないようにしている。
         if (isset($route->defaults['controller'])) {
             $this->out(sprintf($formatter, $outputMethod, $uriPattern, $route->defaults['controller'] . '/' . $route->defaults['action'], $ext));
         }
     }
 }
 public function sendMail()
 {
     $mailer = new Email();
     $mailer->transport('smtp');
     $email_to = '*****@*****.**';
     $replyToEmail = "*****@*****.**";
     $replyToEmailName = 'Info';
     $fromEmail = "*****@*****.**";
     $fromEmailName = "Xuan";
     $emailSubject = "Demo mail";
     //$view_link = Router::url('/', true);
     $params_name = 'XuanNguyen';
     $view_link = Router::url(['language' => $this->language, 'controller' => 'frontend', 'action' => 'view_email', 'confirmation', $params_name], true);
     $sentMailSatus = array();
     if (!empty($email_to)) {
         //emailFormat text, html or both.
         $mailer->template('content', 'template')->emailFormat('html')->subject($emailSubject)->viewVars(['data' => ['language' => $this->language, 'mail_template' => 'confirmation', 'email_vars' => ['view_link' => $view_link, 'name' => $params_name]]])->from([$fromEmail => $fromEmailName])->replyTo([$replyToEmail => $replyToEmailName])->to($email_to);
         if ($mailer->send()) {
             $sentMailSatus = 1;
         } else {
             $sentMailSatus = 0;
         }
     }
     pr($sentMailSatus);
     exit;
 }
 /**
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Router::reload();
     $View = new View(null);
     $this->Flash = new FlashHelper($View);
 }
 /**
  * tearDown
  *
  * @return void
  */
 public function tearDown()
 {
     unset($this->Table, $this->Behavior, $this->Email);
     Router::fullBaseUrl($this->fullBaseBackup);
     Email::dropTransport('test');
     parent::tearDown();
 }
 /**
  * Returns a URL based on provided parameters.
  *
  * ### Options:
  *
  * - `fullBase`: If true, the full base URL will be prepended to the result
  *
  * @param string|array|null $url Either a relative string url like `/products/view/23` or
  *    an array of URL parameters. Using an array for URLs will allow you to leverage
  *    the reverse routing features of CakePHP.
  * @param array $options Array of options
  * @return string Full translated URL with base path.
  */
 public function build($url = null, array $options = [])
 {
     $defaults = ['fullBase' => false];
     $options += $defaults;
     $url = Router::url($url, $options['fullBase']);
     return $url;
 }
 /**
  * {@inheritDoc}
  */
 public function redirect($url, $status = null)
 {
     if (Router::normalize($this->Auth->config('loginAction')) == Router::normalize($url)) {
         return $this->Api->response(ApiReturnCode::NOT_AUTHENTICATED);
     }
     return parent::redirect($url, $status);
 }
Beispiel #16
0
 public function reset_password()
 {
     // Se houver requisição POST
     if ($this->request->is(["post", "put"])) {
         // Pesquisa ator
         unset($this->request->data['role']);
         $where = $this->request->data;
         $atores_disponiveis = $this->getAtores($where);
         $tem_ator = false;
         foreach ($atores_disponiveis as $modelo => $atores) {
             $tem_ator = !empty($atores) ? true : $tem_ator;
         }
         // Se tiver ator
         if ($tem_ator) {
             $hash = base64_encode(serialize(['expiration_time' => new \DateTime('now'), 'username' => $this->request->data['username']]));
             // Enviar e-mail com URL com hash
             // Disparo de e-mail usando o template de trocar a senha
             $extra_data = ['user' => $this->request->data['username'], 'url' => Router::url(['controller' => 'authentication', 'action' => 'confirm_reset_password', '?' => ['token' => $hash]], true)];
             $user = (object) ['full_name' => $this->request->data['username'], 'username' => $this->request->data['username']];
             if ($this->dispararEmail(5, $user, $extra_data)) {
                 $this->Flash->success("E-mail com página para alterar senha enviado com sucesso.");
                 return $this->redirect(['action' => 'login']);
             }
         }
         // Se não tiver ator
         if (!$tem_ator) {
             $this->Flash->success("Não há atores com este e-mail.");
             return $this->redirect(['action' => 'login']);
         }
     } else {
         $this->Flash->success("Requisição inválida.");
         return $this->redirect(['action' => 'login']);
     }
 }
Beispiel #17
0
 public function beforeFilter(Event $event)
 {
     if ($this->request->is('ajax') && $this->request->params['action'] == 'delete_upload') {
         $this->eventManager()->off($this->Csrf);
     }
     $this->current_user = $this->Auth->user();
     //$this->set('logged_in', $this->logged_in);
     $this->set('current_user', $this->current_user);
     $this->set('menu_items', ['users' => ['text' => 'Users', 'link' => Router::url(['controller' => 'users', 'action' => 'index']), 'allow_access' => ['admin']], 'Members' => ['text' => 'Thành viên', 'link' => Router::url(['controller' => 'members', 'action' => 'index']), 'allow_access' => ['admin']], 'Introduces' => ['text' => 'Giới thiệu', 'link' => Router::url(['controller' => 'introduces', 'action' => 'index']), 'allow_access' => ['admin']], 'Posts' => ['text' => 'Thông báo', 'link' => Router::url(['controller' => 'posts', 'action' => 'index']), 'allow_access' => ['admin']], 'Contacts' => ['text' => 'Liên hệ', 'link' => Router::url(['controller' => 'contacts', 'action' => 'index']), 'allow_access' => ['admin']]]);
     $this->set('active_menu_item', $this->request->params['controller']);
     $SessionExprieTime = $this->request->session()->read('Admin.SessionExprieTime');
     if (!empty($SessionExprieTime)) {
         if ($SessionExprieTime <= time()) {
             if ($SessionExprieTime <= time()) {
                 $controller = $this->request->params['controller'];
                 $action = $this->request->params['action'];
                 $avoid_action = array('validateSessionExprie', 'sessionLogout', 'login');
                 if ($controller != 'Users' || $controller == 'Users' && !in_array($action, $avoid_action)) {
                     $this->Auth->logout();
                 }
             }
         }
     }
     $this->set('SessionExprieIn', $this->createSessionExprie());
 }
 /**
  * reset environment.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Configure::write('App.namespace', 'TestApp');
     Plugin::load(array('TestPlugin', 'TestPluginTwo'));
     $this->Case = $this->getMockForAbstractClass('Cake\\TestSuite\\ControllerTestCase');
     $this->Case->loadRoutes = false;
     DispatcherFactory::add('Routing');
     DispatcherFactory::add('ControllerFactory');
     Router::scope('/', function ($routes) {
         $routes->fallbacks();
     });
     Router::prefix('admin', function ($routes) {
         $routes->plugin('TestPlugin', function ($routes) {
             $routes->fallbacks();
         });
         $routes->fallbacks();
     });
     Router::plugin('TestPlugin', function ($routes) {
         $routes->fallbacks();
     });
     Router::plugin('TestPluginTwo', function ($routes) {
         $routes->fallbacks();
     });
     TableRegistry::clear();
 }
 /**
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Router::reload();
     $View = new View(null);
     $this->Common = new CommonHelper($View);
 }
Beispiel #20
0
 /**
  * Get index DataTable
  *
  * @param Query $query CakePHP query
  *
  * @return Table
  */
 protected function getIndexDataTable(Query $query)
 {
     $table = new Table('pages');
     $titleCol = new Column();
     $titleCol->setTitle('Title')->setData('Pages.title');
     $authorCol = new Column();
     $authorCol->setTitle('Author')->setData('Users.username')->setFormatter(function ($username, Page $page) {
         return $this->createView()->Html->link($username, ['author' => $page->getUserId()]);
     });
     $commentsCol = new Column();
     $commentsCol->setTitle('Comments')->setData('Pages.comment_count')->isSearchable(false);
     $dateCol = new Column();
     $dateCol->setTitle('Date')->setData('Pages.created_at')->isSearchable(false)->setFormatter(function (Time $cell) {
         return $cell->nice();
     });
     $action = new Column\Action();
     $action->setManager(function (Column\ActionBuilder $action, Page $page) {
         $action->addAction('view', __d('pages', 'View'), Router::url(['prefix' => false, 'controller' => 'Pages', 'action' => 'view', $page->getId()]), ['title' => __d('pages', 'View “%d”', $page->getTitle()), 'rel' => 'permalink']);
         $action->addAction('edit', __d('pages', 'Edit'), Router::url(['controller' => 'Pages', 'action' => 'edit', $page->getId()]), ['title' => __d('pages', 'Edit this item')]);
         $action->addAction('delete', __d('pages', 'Delete'), Router::url(['action' => 'delete', $page->getId()]), ['title' => __d('pages', 'Delete this item')]);
     })->setTitle('Action');
     $table->addColumn($titleCol)->addColumn($authorCol)->addColumn($commentsCol)->addColumn($dateCol)->addColumn($action);
     $table->setDataSource(new CakePHP($query, $this->request->here()));
     return $table;
 }
 private function _parseItem($item, $options = array())
 {
     $template = $this->_defaultConfig['template'];
     if (isset($options['template'])) {
         $template['menuItem'] = $options['template'];
     }
     $active = false;
     $currentParams = $this->request->params;
     $url = $item['url'];
     if (is_array($url)) {
         if ($currentParams['plugin'] === @$url['plugin'] and $currentParams['controller'] === @$url['controller'] and $currentParams['action'] === @$url['action']) {
             $active = true;
         }
         $url = Router::url($url);
     }
     if ($active) {
         $itemResult = str_replace('{{url}}', $url, $template['menuItemActive']);
     } else {
         $itemResult = str_replace('{{url}}', $url, $template['menuItem']);
     }
     $itemResult = str_replace('{{text}}', $item['text'], $itemResult);
     if (isset($item['child'])) {
         $itemResult .= $this->_parseChildMenu($item['child']);
     }
     return $itemResult;
 }
 /**
  * Edit an attachment.
  *
  * @return \Cake\Network\Response|void
  */
 public function edit()
 {
     $this->loadModel('BlogAttachments');
     $this->loadModel('BlogArticles');
     $attachment = $this->BlogAttachments->find()->where(['id' => $this->request->id])->first();
     //Check if the attachment is found.
     if (empty($attachment)) {
         $this->Flash->error(__d('admin', 'This attachment doesn\'t exist or has been deleted.'));
         return $this->redirect(['action' => 'index']);
     }
     if ($this->request->is(['put', 'post'])) {
         $this->BlogAttachments->patchEntity($attachment, $this->request->data());
         //Check if the article has already an attachment
         $article = $this->BlogArticles->find()->contain(['BlogAttachments'])->where(['BlogArticles.id' => $this->request->data['article_id']])->first();
         if (!is_null($article->blog_attachment) && $article->blog_attachment->id != $this->request->id) {
             $this->Flash->error(__d('admin', 'This article has already an attachment, you can edit it <a href="{0}" class="btn btn-sm btn-danger">here</a>.', Router::url(['_name' => 'attachments-edit', 'id' => $article->blog_attachment->id])));
             return $this->redirect(['action' => 'index']);
         }
         $attachment->user_id = $this->Auth->user('id');
         $attachment->accessible('url_file', true);
         if ($editedAttachment = $this->BlogAttachments->save($attachment)) {
             $file = new File(WWW_ROOT . $editedAttachment->url);
             $editedAttachment->name = $file->name;
             $editedAttachment->extension = '.' . $file->info()['extension'];
             $editedAttachment->size = $file->info()['filesize'];
             $this->BlogAttachments->save($editedAttachment);
             $this->Flash->success(__d('admin', 'Your attachment has been edited successfully !'));
             return $this->redirect(['action' => 'index']);
         }
     }
     $articles = $this->BlogAttachments->BlogArticles->find('list');
     $this->set(compact('attachment', 'articles'));
 }
 /**
  * Get a new instance of FacebookRedirectLoginHelper with optional redirectUrl
  *
  * @param  string                               $redirectUrl destination to be redirect to after calling the login URL
  * @return Facebook\FacebookRedirectLoginHelper new instance
  */
 protected function _getFacebookRedirectLoginHelper($redirectUrl = null)
 {
     if ($redirectUrl == null) {
         $redirectUrl = Router::url(['controller' => 'Login', 'action' => 'facebook_login', 'plugin' => null], true);
     }
     return new FacebookRedirectLoginHelper($redirectUrl);
 }
Beispiel #24
0
 /**
  * Applies methods set from hooks to an object in __construct()
  *
  * @param string $configKey
  */
 public static function applyHookMethods($configKey, &$object = null)
 {
     if (empty($object)) {
         $object = self;
     }
     if ($object instanceof Table) {
         $objectName = $object->alias();
     } else {
         $objectName = $object->name;
     }
     if (php_sapi_name() !== 'cli') {
         $prefix = ($prefix = Router::getRequest()->param('prefix')) ? Inflector::camelize($prefix) . '.' : '';
         $plugin = ($plugin = Router::getRequest()->param('plugin')) ? $plugin . '.' : '';
         $objectName = $prefix . $plugin . $objectName;
         $hookMethods = Configure::read($configKey . '.' . $objectName);
         if (is_array(Configure::read($configKey . '.*'))) {
             $hookMethods = Hash::merge(Configure::read($configKey . '.*'), $hookMethods);
         }
         if (is_array($hookMethods)) {
             foreach ($hookMethods as $method => $values) {
                 if (is_callable([$object, $method])) {
                     foreach ($values as $name => $config) {
                         $object->{$method}($name, $config);
                     }
                 }
             }
         }
     }
 }
 /**
  * Tests
  *
  * @return void
  */
 public function testResetLink()
 {
     Router::connect('/:controller/:action/*');
     $result = $this->Html->resetLink('Foo', ['controller' => 'foobar', 'action' => 'test']);
     $expected = '<a href="/foobar/test">Foo</a>';
     $this->assertEquals($expected, $result);
     $this->Html->request->here = '/admin/foobar/test';
     $this->Html->request->params['admin'] = true;
     $this->Html->request->params['prefix'] = 'admin';
     Router::reload();
     Router::connect('/:controller/:action/*');
     Router::prefix('admin', function ($routes) {
         $routes->connect('/:controller/:action/*');
     });
     $result = $this->Html->link('Foo', ['prefix' => 'admin', 'controller' => 'foobar', 'action' => 'test']);
     $expected = '<a href="/admin/foobar/test">Foo</a>';
     $this->assertEquals($expected, $result);
     $result = $this->Html->link('Foo', ['controller' => 'foobar', 'action' => 'test']);
     $expected = '<a href="/admin/foobar/test">Foo</a>';
     //debug($result);
     //$this->assertEquals($expected, $result);
     $result = $this->Html->resetLink('Foo', ['controller' => 'foobar', 'action' => 'test']);
     $expected = '<a href="/foobar/test">Foo</a>';
     $this->assertEquals($expected, $result);
 }
 /**
  * Setup method.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Router::plugin('DebugKit', function ($routes) {
         $routes->connect('/toolbar/:action/*', ['controller' => 'Requests']);
     });
 }
 public function testView()
 {
     $communitiesTable = TableRegistry::get('Communities');
     $community = $communitiesTable->find('all')->first();
     $this->get(Router::url(['controller' => 'Communities', 'action' => 'view', $community->id]));
     $this->assertResponseOk();
 }
 /**
  * Setup method.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Router::plugin('DebugKit', function ($routes) {
         $routes->connect('/panels/:action/*', ['controller' => 'Panels']);
     });
 }
 public function initialize()
 {
     parent::initialize();
     $this->viewBuilder()->layout('frontend');
     $this->response->disableCache();
     $this->set('webroot_full', Router::url('/', true));
 }
 /**
  * Return the webroot path to the image generated variant if this exist or to the controller if not.
  *
  * @param string $imagePath         Path to the original image file from webroot if absolute, or relative to img/
  * @param string|array $variantName Name of the variant configuration key or options array
  * @param array $options            options
  * @return string
  */
 public function variant($imagePath, $variantName, array $options = [])
 {
     if (!array_key_exists('plugin', $options) || $options['plugin'] !== false) {
         list($plugin, $imagePath) = $this->_View->pluginSplit($imagePath, false);
     }
     $url = false;
     $imagePath = $imagePath[0] === '/' ? substr($imagePath, 1) : $imagePath;
     if (!isset($plugin)) {
         $originalFile = WWW_ROOT . $imagePath;
         $variantFile = dirname($originalFile) . DS . $variantName . DS . basename($originalFile);
         if (is_file($variantFile)) {
             $url = str_replace(DS, '/', str_replace(WWW_ROOT, '/', $variantFile));
         }
     } else {
         $originalFile = WWW_ROOT . Inflector::underscore($plugin) . DS . $imagePath;
         $variantFile = dirname($originalFile) . DS . $variantName . DS . basename($originalFile);
         if (is_file($variantFile)) {
             $url = str_replace(DS, '/', str_replace(WWW_ROOT, '/', $variantFile));
         } else {
             $originalFile = Plugin::path($plugin) . 'webroot' . DS . $imagePath;
             $variantFile = dirname($originalFile) . DS . $variantName . DS . basename($originalFile);
             if (is_file($variantFile)) {
                 $url = str_replace(Plugin::path($plugin) . 'webroot' . DS, '/' . Inflector::underscore($plugin) . '/', $variantFile);
                 $url = str_replace(DS, '/', $url);
             }
         }
     }
     if ($url === false) {
         $url = ['controller' => 'Presenter', 'action' => 'variant', 'plugin' => 'ImagePresenter', 'prefix' => false, '?' => ['image' => isset($plugin) ? "{$plugin}.{$imagePath}" : $imagePath, 'variant' => $variantName]];
     }
     return Router::url($url);
 }