Server : Apache System : Linux indy02.toastserver.com 3.10.0-962.3.2.lve1.5.85.el7.x86_64 #1 SMP Thu Apr 18 15:18:36 UTC 2024 x86_64 User : palandch ( 1163) PHP Version : 7.1.33 Disable Function : NONE Directory : /home/palandch/www/core/model/modx/processors/element/ |
<?php /** * Export properties and output url to download to browser * * @package modx * @subpackage processors.element */ class modElementExportPropertiesProcessor extends modProcessor { public function checkPermissions() { return $this->modx->hasPermission('view_propertyset'); } public function getLanguageTopics() { return array('propertyset','element'); } public function process() { $download = $this->getProperty('download'); if (!empty($download)) { $o = $this->download($download); } else { $o = $this->export(); } return $o; } /** * Download the file * * @param string $file * @return bool|string */ public function download($file) { $fileName = $this->modx->getOption('core_path').'export/properties/'.$file; if (!is_file($fileName)) return ''; $output = file_get_contents($fileName); if (empty($output)) return ''; $id = $this->getProperty('id'); if (empty($id)) { $name = 'default'; } else { /** @var modPropertySet $propertySet */ $propertySet = $this->modx->getObject('modPropertySet',$id); if (empty($propertySet)) { $name = 'unknown'; } else { $name = $propertySet->get('name'); $name = strtolower(str_replace(' ','-',$name)); } } header('Content-Type: application/force-download'); header('Content-Disposition: attachment; filename="'.$name.'.properties.js"'); return $output; } /** * Export the properties into a temporary export file * * @return mixed */ public function export() { $data = $this->getProperty('data'); if (empty($data)) return $this->failure($this->modx->lexicon('propertyset_err_ns')); $f = 'export.js'; $fileName = $this->modx->getOption('core_path').'export/properties/'.$f; /** @var modCacheManager $cacheManager */ $cacheManager = $this->modx->getCacheManager(); $cacheManager->writeFile($fileName,$data); return $this->success($f); } } return 'modElementExportPropertiesProcessor';