Use the elgg_* versions instead.
부터: 1.9.0
예제 #1
0
파일: SimpleCache.php 프로젝트: elgg/elgg
 /**
  * Get the URL for the cached view.
  *
  * Recommended usage is to just pass the entire view name as the first and only arg:
  *
  * ```
  * $blog_js = $simpleCache->getUrl('blog/save_draft.js');
  * $favicon = $simpleCache->getUrl('graphics/favicon.ico');
  * ```
  *
  * For backwards compatibility with older versions of Elgg, you can also pass
  * "js" or "css" as the first arg, with the rest of the view name as the second arg:
  *
  * ```
  * $blog_js = $simpleCache->getUrl('js', 'blog/save_draft.js');
  * ```
  *
  * This automatically registers the view with Elgg's simplecache.
  *
  * @param string $view    The full view name
  * @param string $subview If the first arg is "css" or "js", the rest of the view name
  *
  * @return string
  */
 function getUrl($view, $subview = '')
 {
     // handle `getUrl('js', 'js/blog/save_draft')`
     if (($view === 'js' || $view === 'css') && 0 === strpos($subview, $view . '/')) {
         $view = $subview;
         $subview = '';
     }
     // handle `getUrl('js', 'blog/save_draft')`
     if (!empty($subview)) {
         $view = "{$view}/{$subview}";
     }
     $view = $this->views->canonicalizeViewName($view);
     // should be normalized to canonical form by now: `getUrl('blog/save_draft.js')`
     $this->registerView($view);
     return $this->getRoot() . $view;
 }
예제 #2
0
 public function testCanListViews()
 {
     $views = $this->views->listViews('default');
     $this->assertTrue(in_array('interpreted.js', $views));
     $this->assertTrue(in_array('static.js', $views));
     $this->assertEmpty($this->views->listViews('fake_viewtype'));
 }
예제 #3
0
 public function testCanAlterViewOutput()
 {
     $this->hooks->registerHandler('view', 'js/interpreted.js', function ($h, $t, $v, $p) {
         return '// Hello';
     });
     $this->assertEquals("// Hello", $this->views->renderView('js/interpreted.js'));
 }
예제 #4
0
 /**
  * @dataProvider getExampleNormalizedViews
  */
 public function testDefaultNormalizeBehavior($canonical, $alias)
 {
     $this->assertEquals($canonical, $this->views->canonicalizeViewName($alias));
 }