Elgg  Version 1.11
ViewFilter.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg\Amd;
3 
15 class ViewFilter {
23  private function getAmdName($name) {
24  $pieces = explode("/", $name); // [js, elgg, module.js]
25  if (count($pieces) <= 1 || $pieces[0] != 'js') {
26  return '';
27  }
28 
29  array_shift($pieces); // [elgg, module.js]
30  $basename = basename(array_pop($pieces), ".js"); // module
31  array_push($pieces, $basename); // [elgg, module]
32 
33  return implode("/", $pieces); // elgg/module
34  }
35 
44  public function filter($viewName, $content) {
45  $amdName = $this->getAmdName($viewName);
46 
47  if (!empty($amdName)) {
48  $content = preg_replace('/^define\(([^\'"])/m', "define(\"$amdName\", \$1", $content, 1);
49  }
50 
51  return $content;
52  }
53 }
54 
if($guid==elgg_get_logged_in_user_guid()) $name
Definition: delete.php:21
filter($viewName, $content)
Inserts the AMD name into $content and returns the new value.
Definition: ViewFilter.php:44
$content
Set robots.txt action.
Definition: set_robots.php:6