Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 16 additions & 21 deletions controllers/DynamicdropdownController.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* This source file is subject to the new BSD license that is
* This source file is subject to the new BSD license that is
* available through the world-wide-web at this URL:
* http://www.pimcore.org/license
*
Expand All @@ -27,8 +27,8 @@ public function optionsAction() {

$filter = new \Zend_Filter_PregReplace(array("match" => "@[^a-zA-Z0-9/\-_]@", "replace" => ""));
$parentFolderPath = $filter->filter($this->_getParam("source_parent"));


if ($parentFolderPath) {
// remove trailing slash
if($parentFolderPath != "/") {
Expand All @@ -37,7 +37,7 @@ public function optionsAction() {

// correct wrong path (root-node problem)
$parentFolderPath = str_replace("//","/",$parentFolderPath);

$folder = Object_Folder::getByPath($parentFolderPath);
if ($folder) {
$options = $this->walk_path($folder);
Expand All @@ -64,7 +64,7 @@ private function walk_path($folder, $options = null, $path = "") {
if ($folder) {

$source = $this->_getParam("source_methodname");

if (Pimcore_Version::getRevision() > 3303) {
$object_name = "Pimcore\\Model\\Object\\" . ucfirst($this->_getParam("source_classname"));
} else {
Expand All @@ -81,39 +81,34 @@ private function walk_path($folder, $options = null, $path = "") {
$current_lang = $languages[0]; // TODO: Is this sensible?
}
foreach ($children as $child) {
$class = get_class($child);
switch ($class) {
case "Object_Folder":
/**
* @var Object_Folder $child
*/

if ($child instanceof \Pimcore\Model\Object\Folder) {
/* Case: Folder*/
$key = $child->getProperty("Taglabel") != "" ? $child->getProperty("Taglabel") : $child->getKey();
if ($this->_getParam("source_recursive") == "true")
$options = $this->walk_path($child, $options, $path.$this->separator.$key);
break;
case $object_name:

} elseif (is_a($child, $object_name)) {
/* Case: Object*/
$key = $usesI18n ? $child->$source($current_lang) : $child->$source();
$options[] = array(
"value" => $child->getId(),
"key" => ltrim($path.$this->separator.$key, $this->separator)
);
if ($this->_getParam("source_recursive") == "true")
$options = $this->walk_path($child, $options, $path.$this->separator.$key);
break;
$options = $this->walk_path($child, $options, $path . $this->separator . $key);
}
}
}
return $options;
}

/**
* Produces the json for the "available methods" dropdown in the backend.
* used by pimcore.object.classes.data.dynamicDropdown
*/
public function methodsAction() {
$methods = array();

$filter = new Zend_Filter_PregReplace(array("match" => "@[^a-zA-Z0-9_\-]@", "replace" => ""));
$class_name = $filter->filter($this->_getParam("classname"));
if (!empty($class_name)) {
Expand All @@ -134,7 +129,7 @@ public function methodsAction() {
*/
private function isUsingI18n(Pimcore\Model\Object\Concrete $object, $method) {
$modelId = $object->getClassId();

// Stolen from Object_Class_Resource - it's protected there.
$file = PIMCORE_CLASS_DIRECTORY."/definition_".$modelId.".psf";
if(!is_file($file)) {
Expand All @@ -143,9 +138,9 @@ private function isUsingI18n(Pimcore\Model\Object\Concrete $object, $method) {
$tree = unserialize(file_get_contents($file));
$definition = $this->parse_tree($tree, array());
return $definition[$method];

}

private function parse_tree($tree, $definition) {
$class = get_class($tree);
if (is_a($tree, "Object_Class_Layout") || is_a($tree, "Object_Class_Data_Localizedfields")) { // Did I forget something?
Expand Down