public function jsonTranslationsSystemAction() { $this->getResponse()->setHeader("Content-Type", "text/javascript", true); $language = $this->_getParam("language"); $languageFile = Pimcore_Tool_Admin::getLanguageFile($language); if (!is_file($languageFile)) { $languageFile = Pimcore_Tool_Admin::getLanguageFile("en"); } $row = 1; $handle = fopen($languageFile, "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $translations[$data[0]] = $data[1]; } fclose($handle); $broker = Pimcore_API_Plugin_Broker::getInstance(); $pluginTranslations = $broker->getTranslations($language); //$pluginTranslations = $this->getApiPluginBroker()->getTranslations($language); $translations = array_merge($pluginTranslations, $translations); $this->view->translations = $translations; }
public function logoutAction() { $adminSession = new Zend_Session_Namespace("pimcore_admin"); if ($adminSession->user instanceof User) { Pimcore_API_Plugin_Broker::getInstance()->preLogoutUser($adminSession->user); $adminSession->user = null; $adminSession->frozenuser = null; } Zend_Session::destroy(); Zend_Session::regenerateId(); $this->_redirect("/admin/login/"); }
public function logoutAction() { $adminSession = new Zend_Session_Namespace("pimcore_admin"); if ($adminSession->user instanceof User) { Pimcore_API_Plugin_Broker::getInstance()->preLogoutUser($adminSession->user); $adminSession->user = null; $adminSession->frozenuser = null; } setcookie("pimcore_admin_sid", "", time() - 3600); unset($_COOKIE['pimcore_admin_sid']); $this->_redirect("/admin/login/"); }
$validJobs = explode(",", $opts->getOption("job")); } // create manager $manager = Schedule_Manager_Factory::getManager("maintenance.pid", $forceType); $manager->setValidJobs($validJobs); // register scheduled tasks $manager->registerJob(new Schedule_Maintenance_Job("scheduledtasks", new Schedule_Task_Executor(), "execute")); $manager->registerJob(new Schedule_Maintenance_Job("logmaintenance", new Pimcore_Log_Maintenance(), "mail")); $manager->registerJob(new Schedule_Maintenance_Job("httperrorlog", new Pimcore_Log_Maintenance(), "httpErrorLogCleanup")); $manager->registerJob(new Schedule_Maintenance_Job("sanitycheck", "Element_Service", "runSanityCheck")); $manager->registerJob(new Schedule_Maintenance_Job("cleanupoldpidfiles", "Schedule_Manager_Factory", "cleanupOldPidFiles"), true); $manager->registerJob(new Schedule_Maintenance_Job("versioncleanup", new Version(), "maintenanceCleanUp")); $manager->registerJob(new Schedule_Maintenance_Job("redirectcleanup", "Redirect", "maintenanceCleanUp")); $manager->registerJob(new Schedule_Maintenance_Job("cleanupbrokenviews", "Pimcore_Resource", "cleanupBrokenViews")); // call plugins $plugins = Pimcore_API_Plugin_Broker::getInstance()->getPlugins(); foreach ($plugins as $plugin) { $id = get_class($plugin); $jobRegistered = null; if (method_exists($plugin, "maintenanceForce")) { $jobRegistered = $manager->registerJob(new Schedule_Maintenance_Job($id, $plugin, "maintenanceForce"), true); } else { if (method_exists($plugin, "maintainance")) { //legacy hack $jobRegistered = $manager->registerJob(new Schedule_Maintenance_Job($id, $plugin, "maintainance")); } else { if (method_exists($plugin, "maintenance")) { $jobRegistered = $manager->registerJob(new Schedule_Maintenance_Job($id, $plugin, "maintenance")); } } }
/** * @return void */ public function delete() { if ($this->getId() == 1) { throw new Exception("root-node cannot be deleted"); } Pimcore_API_Plugin_Broker::getInstance()->preDeleteAsset($this); // remove childs if ($this->hasChilds()) { foreach ($this->getChilds() as $child) { $child->delete(); } } // remove file on filesystem $fsPath = PIMCORE_ASSET_DIRECTORY . $this->getPath() . $this->getFilename(); if ($this->getType() != "folder") { if (is_file($fsPath) && is_writable($fsPath)) { unlink($fsPath); } } else { if (is_dir($fsPath) && is_writable($fsPath)) { recursiveDelete($fsPath, true); } } $versions = $this->getVersions(); foreach ($versions as $version) { $version->delete(); } // remove permissions $this->getResource()->deleteAllPermissions(); // remove all properties $this->getResource()->deleteAllProperties(); // remove all tasks $this->getResource()->deleteAllTasks(); // remove dependencies $d = $this->getDependencies(); $d->cleanAllForElement($this); // remove from resource $this->getResource()->delete(); // empty object cache $this->clearDependedCache(); //set object to registry Zend_Registry::set("asset_" . $this->getId(), null); }
/** * Deletes the document * * @return void */ public function delete() { Pimcore_API_Plugin_Broker::getInstance()->preDeleteDocument($this); // remove childs if ($this->hasChilds()) { foreach ($this->getChilds() as $child) { $child->delete(); } } // remove all properties $this->getResource()->deleteAllProperties(); // remove permissions $this->getResource()->deleteAllPermissions(); // remove dependencies $d = $this->getDependencies(); $d->cleanAllForElement($this); $this->getResource()->delete(); // clear cache $this->clearDependedCache(); //set object to registry Zend_Registry::set("document_" . $this->getId(), null); Pimcore_API_Plugin_Broker::getInstance()->postDeleteDocument($this); }
/** * $directCall is true when the method is called from outside (eg. directly in the controller "save only version") * it is false when the method is called by $this->update() * @param bool $setModificationDate * @param bool $directCall * @return Version */ public function saveVersion($setModificationDate = true, $directCall = true) { if ($setModificationDate) { $this->setO_modificationDate(time()); } // hook should be also called if "save only new version" is selected if ($directCall) { Pimcore_API_Plugin_Broker::getInstance()->preUpdateObject($this); } // scheduled tasks are saved always, they are not versioned! if ($directCall) { $this->saveScheduledTasks(); } $version = null; // only create a new version if there is at least 1 allowed if (Pimcore_Config::getSystemConfig()->objects->versions) { // create version $version = new Version(); $version->setCid($this->getO_Id()); $version->setCtype("object"); $version->setDate($this->getO_modificationDate()); $version->setUserId($this->getO_userModification()); $version->setData($this); $version->save(); } // hook should be also called if "save only new version" is selected if ($directCall) { Pimcore_API_Plugin_Broker::getInstance()->postUpdateObject($this); } return $version; }
/** * @return void */ protected function update() { Pimcore_API_Plugin_Broker::getInstance()->preUpdateObject($this); if (!$this->getKey() && $this->getId() != 1) { $this->delete(); throw new Exception("Object requires key, object with id " . $this->getId() . " deleted"); } // set mod date $this->setO_modificationDate(time()); // save properties $this->getO_Properties(); $this->getResource()->deleteAllProperties(); if (is_array($this->getO_Properties()) and count(is_array($this->getO_Properties())) > 0) { foreach ($this->getO_Properties() as $property) { if (!$property->getInherited()) { $property->setResource(null); $property->setCid($this->getO_Id()); $property->setCpath($this->getO_Path() . $this->getO_Key()); $property->save(); } } } // save permissions $this->getO_Permissions(); $this->getResource()->deleteAllPermissions(); if (is_array($this->o_permissions)) { foreach ($this->o_permissions as $permission) { $permission->setId(null); $permission->setCid($this->getO_Id()); $permission->setCpath($this->getO_FullPath()); $permission->save(); } } // save dependencies $d = $this->getDependencies(); $d->clean(); foreach ($this->resolveDependencies() as $requirement) { if ($requirement["id"] == $this->getO_id() && $requirement["type"] == "object") { // dont't add a reference to yourself continue; } else { $d->addRequirement($requirement["id"], $requirement["type"]); } } $d->save(); if ($this->_oldPath) { $this->getResource()->updateChildsPaths($this->_oldPath); } // empty object cache $this->clearDependedCache(); //set object to registry Zend_Registry::set("object_" . $this->getId(), $this); }
public static function initPlugins() { // add plugin include paths $autoloader = Zend_Loader_Autoloader::getInstance(); try { $pluginConfigs = Pimcore_ExtensionManager::getPluginConfigs(); if (!empty($pluginConfigs)) { $includePaths = array(get_include_path()); //adding plugin include paths and namespaces if (count($pluginConfigs) > 0) { foreach ($pluginConfigs as $p) { if (!Pimcore_ExtensionManager::isEnabled("plugin", $p["plugin"]["pluginName"])) { continue; } if (is_array($p['plugin']['pluginIncludePaths']['path'])) { foreach ($p['plugin']['pluginIncludePaths']['path'] as $path) { $includePaths[] = PIMCORE_PLUGINS_PATH . $path; } } else { if ($p['plugin']['pluginIncludePaths']['path'] != null) { $includePaths[] = PIMCORE_PLUGINS_PATH . $p['plugin']['pluginIncludePaths']['path']; } } if (is_array($p['plugin']['pluginNamespaces']['namespace'])) { foreach ($p['plugin']['pluginNamespaces']['namespace'] as $namespace) { $autoloader->registerNamespace($namespace); } } else { if ($p['plugin']['pluginNamespaces']['namespace'] != null) { $autoloader->registerNamespace($p['plugin']['pluginNamespaces']['namespace']); } } } } set_include_path(implode(PATH_SEPARATOR, $includePaths)); $broker = Pimcore_API_Plugin_Broker::getInstance(); //registering plugins foreach ($pluginConfigs as $p) { if (!Pimcore_ExtensionManager::isEnabled("plugin", $p["plugin"]["pluginName"])) { continue; } $jsPaths = array(); if (is_array($p['plugin']['pluginJsPaths']['path'])) { $jsPaths = $p['plugin']['pluginJsPaths']['path']; } else { if ($p['plugin']['pluginJsPaths']['path'] != null) { $jsPaths[0] = $p['plugin']['pluginJsPaths']['path']; } } //manipulate path for frontend if (is_array($jsPaths) and count($jsPaths) > 0) { for ($i = 0; $i < count($jsPaths); $i++) { if (is_file(PIMCORE_PLUGINS_PATH . $jsPaths[$i])) { $jsPaths[$i] = "/plugins" . $jsPaths[$i]; } } } $cssPaths = array(); if (is_array($p['plugin']['pluginCssPaths']['path'])) { $cssPaths = $p['plugin']['pluginCssPaths']['path']; } else { if ($p['plugin']['pluginCssPaths']['path'] != null) { $cssPaths[0] = $p['plugin']['pluginCssPaths']['path']; } } //manipulate path for frontend if (is_array($cssPaths) and count($cssPaths) > 0) { for ($i = 0; $i < count($cssPaths); $i++) { if (is_file(PIMCORE_PLUGINS_PATH . $cssPaths[$i])) { $cssPaths[$i] = "/plugins" . $cssPaths[$i]; } } } try { $className = $p['plugin']['pluginClassName']; if (!empty($className) && Pimcore_Tool::classExists($className)) { $plugin = new $className($jsPaths, $cssPaths); if ($plugin instanceof Pimcore_API_Plugin_Abstract) { $broker->registerPlugin($plugin); } } } catch (Exeption $e) { Logger::err("Could not instantiate and register plugin [" . $p['plugin']['pluginClassName'] . "]"); } } Zend_Registry::set("Pimcore_API_Plugin_Broker", $broker); } } catch (Exception $e) { Logger::alert("there is a problem with the plugin configuration"); Logger::alert($e); } }
/** * Save the current object as version * * @return void */ public function saveVersion($setModificationDate = true, $callPluginHook = true) { // hook should be also called if "save only new version" is selected if ($callPluginHook) { Pimcore_API_Plugin_Broker::getInstance()->preUpdateDocument($this); } // set date if ($setModificationDate) { $this->setModificationDate(time()); } // scheduled tasks are saved always, they are not versioned! $this->saveScheduledTasks(); // create version $version = new Version(); $version->setCid($this->getId()); $version->setCtype("document"); $version->setDate($this->getModificationDate()); $version->setUserId($this->getUserModification()); $version->setData($this); $version->save(); // hook should be also called if "save only new version" is selected if ($callPluginHook) { Pimcore_API_Plugin_Broker::getInstance()->postUpdateDocument($this); } }
/** * @return void */ public function update() { parent::update(); $this->getResource()->update(); Pimcore_API_Plugin_Broker::getInstance()->postUpdateObject($this); }
public function logoutAction() { $adminSession = Pimcore_Tool_Authentication::getSession(); if ($adminSession->user instanceof User) { Pimcore_API_Plugin_Broker::getInstance()->preLogoutUser($adminSession->user); $adminSession->user = null; } Zend_Session::destroy(); // cleanup pimcore-cookies => 315554400 => strtotime('1980-01-01') setcookie("pimcore_opentabs", false, 315554400, "/"); $this->_redirect("/admin/login/"); }