Skip to content

Commit

Permalink
ENHANCEMENT Removed CMSMain->jsDeclaration(), it was replicating func…
Browse files Browse the repository at this point in the history
…tionality already present in Convert::raw2js()

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92671 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
chillu committed Nov 21, 2009
1 parent 8b89a26 commit b99ee16
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions code/CMSMain.php
Expand Up @@ -197,7 +197,7 @@ public function generateDataTreeHints() {
}

// Put data hints into a script tag at the top
Requirements::customScript("siteTreeHints = " . $this->jsDeclaration($def) . ";");
Requirements::customScript("siteTreeHints = " . Convert::raw2json($def) . ";");
}

public function generateTreeStylingJS() {
Expand Down Expand Up @@ -238,33 +238,6 @@ public function generateTreeStylingJS() {
Requirements::customScript($js);
}

/**
* Return a javascript instanciation of this array
*/
protected function jsDeclaration($array) {
if(is_array($array)) {
$object = false;
foreach(array_keys($array) as $key) {
if(!is_numeric($key)) {
$object = true;
break;
}
}

if($object) {
foreach($array as $k => $v) {
$parts[] = "$k : " . $this->jsDeclaration($v);
}
return " {\n " . implode(", \n", $parts) . " }\n";
} else {
foreach($array as $part) $parts[] = $this->jsDeclaration($part);
return " [ " . implode(", ", $parts) . " ]\n";
}
} else {
return "'" . addslashes($array) . "'";
}
}

/**
* Populates an array of classes in the CMS
* which allows the user to change the page type.
Expand Down

0 comments on commit b99ee16

Please sign in to comment.