public function getTreeAction() { $classesList = new Object_Class_List(); $classesList->setOrderKey("name"); $classesList->setOrder("asc"); $classes = $classesList->load(); $classItems = array(); foreach ($classes as $classItem) { $classItems[] = array("id" => $classItem->getId(), "text" => $classItem->getName(), "icon" => $classItem->getIcon(), "propertyVisibility" => $classItem->getPropertyVisibility(), "qtipCfg" => array("title" => "ID: " . $classItem->getId())); } $this->_helper->json($classItems); }
public function getTreeAction() { $allowed = $this->getRequest()->getParam('allowed'); $classesList = new Object_Class_List(); $classesList->setOrderKey("name"); $classesList->setOrder("asc"); if ($allowed) { $classesList->setCondition(Pimcore_Resource_Mysql::get()->quoteInto('id IN (?)', explode(',', $allowed))); } $classes = $classesList->load(); $classItems = array(); foreach ($classes as $classItem) { $classItems[] = array("id" => $classItem->getId(), "text" => $classItem->getName(), "icon" => $classItem->getIcon(), "propertyVisibility" => $classItem->getPropertyVisibility(), "qtipCfg" => array("title" => "ID: " . $classItem->getId())); } $this->_helper->json($classItems); }
/** * finds all objects which hold a reference to a specific user * * @static * @param integer $userId * @return Object_Concrete[] */ public static function getObjectsReferencingUser($userId) { $userObjects = array(); $classesList = new Object_Class_List(); $classesList->setOrderKey("name"); $classesList->setOrder("asc"); $classes = $classesList->load(); $classesToCheck = array(); if (is_array($classes)) { foreach ($classes as $class) { $fieldDefinitions = $class->getFieldDefinitions(); $dataKeys = array(); if (is_array($fieldDefinitions)) { foreach ($fieldDefinitions as $tag) { if ($tag instanceof Object_Class_Data_User) { $dataKeys[] = $tag->getName(); } } } if (is_array($dataKeys) and count($dataKeys) > 0) { $classesToCheck[$class->getName()] = $dataKeys; } } } foreach ($classesToCheck as $classname => $fields) { $listName = "Object_" . ucfirst($classname) . "_List"; $list = new $listName(); $conditionParts = array(); foreach ($fields as $field) { $conditionParts[] = $field . "='" . $userId . "'"; } $list->setCondition(implode(" AND ", $conditionParts)); $objects = $list->load(); $userObjects = array_merge($userObjects, $objects); } return $userObjects; }
<?php $classList = new Object_Class_List(); $classes = $classList->load(); foreach ($classes as $c) { $fd = $c->getFieldDefinitions(); $changed = false; foreach ($fd as $key => $def) { if ($def->fieldtype == "href" or $def->fieldtype == "multihref") { $def->setAssetsAllowed(true); $def->setObjectsAllowed(true); $def->setDocumentsAllowed(true); $changed = true; } } if ($changed) { $c->save(); } } ?> <b>Release Notes (292):</b> <br /> - Objects: check on types/classes of href, multihref and objects<br />
/** * @return void */ public function delete() { $fieldCollectionFolder = PIMCORE_CLASS_DIRECTORY . "/objectbricks"; $fieldFile = $fieldCollectionFolder . "/" . $this->getKey() . ".psf"; @unlink($fieldFile); $fieldClassFolder = PIMCORE_CLASS_DIRECTORY . "/Object/Objectbrick/Data"; $fieldClass = $fieldClassFolder . "/" . ucfirst($this->getKey()) . ".php"; @unlink($fieldClass); $processedClasses = array(); if (!empty($this->classDefinitions)) { foreach ($this->classDefinitions as $cl) { unset($this->oldClassDefinitions[$cl['classname']]); if (!$processedClasses[$cl['classname']]) { $class = Object_Class::getById($cl['classname']); $this->getResource()->delete($class); $processedClasses[$cl['classname']] = true; foreach ($class->getFieldDefinitions() as $fieldDef) { if ($fieldDef instanceof Object_Class_Data_Objectbricks) { $allowedTypes = $fieldDef->getAllowedTypes(); $idx = array_search($this->getKey(), $allowedTypes); if ($idx !== false) { array_splice($allowedTypes, $idx, 1); } $fieldDef->setAllowedTypes($allowedTypes); } } $class->save(); } } } // update classes $classList = new Object_Class_List(); $classes = $classList->load(); if (is_array($classes)) { foreach ($classes as $class) { foreach ($class->getFieldDefinitions() as $fieldDef) { if ($fieldDef instanceof Object_Class_Data_Objectbricks) { if (in_array($this->getKey(), $fieldDef->getAllowedTypes())) { //remove objectbrick from class //$this->getResource()->delete($class); break; } } } } } }
<?php $list = new Object_Class_List(); $classes = $list->load(); if (!empty($classes)) { foreach ($classes as $class) { $class->save(); } }
*/ include dirname(__FILE__) . "/../../../../pimcore/cli/startup.php"; // todo move to composer's post install scripts if (!is_dir(PIMCORE_DOCUMENT_ROOT . '/data')) { mkdir(PIMCORE_DOCUMENT_ROOT . '/data'); } if (!is_dir(PIMCORE_DOCUMENT_ROOT . '/data/classes')) { mkdir(PIMCORE_DOCUMENT_ROOT . '/data/classes'); } if (!is_dir(PIMCORE_DOCUMENT_ROOT . '/data/fieldcollections')) { mkdir(PIMCORE_DOCUMENT_ROOT . '/data/fieldcollections'); } if (!is_dir(PIMCORE_DOCUMENT_ROOT . '/data/objectbricks')) { mkdir(PIMCORE_DOCUMENT_ROOT . '/data/objectbricks'); } $classesList = new Object_Class_List(); $classesList->setOrderKey("name"); $classesList->setOrder("asc"); $classes = $classesList->load(); $files = glob(PIMCORE_DOCUMENT_ROOT . '/data/classes/*'); // get all file names foreach ($files as $file) { // iterate files if (is_file($file)) { unlink($file); } // delete file } /** @var Object_Class $class */ foreach ($classes as $class) { $json = Object_Class_Service::generateClassDefinitionJson($class);
public function delete() { $fieldCollectionFolder = PIMCORE_CLASS_DIRECTORY . "/fieldcollections"; $fieldFile = $fieldCollectionFolder . "/" . $this->getKey() . ".psf"; @unlink($fieldFile); $fieldClassFolder = PIMCORE_CLASS_DIRECTORY . "/Object/Fieldcollection/Data"; $fieldClass = $fieldClassFolder . "/" . ucfirst($this->getKey()) . ".php"; @unlink($fieldClass); // update classes $classList = new Object_Class_List(); $classes = $classList->load(); if (is_array($classes)) { foreach ($classes as $class) { foreach ($class->getFieldDefinitions() as $fieldDef) { if ($fieldDef instanceof Object_Class_Data_Fieldcollections) { if (in_array($this->getKey(), $fieldDef->getAllowedTypes())) { $this->getResource()->delete($class); break; } } } } } }