/** * Handle static elements before ObjectAdapter * adds to MODX * * @param bool $overwrite * @return bool|int */ public function addToMODx($overwrite = false) { unset($this->myFields['propertySets']); $fields = $this->myFields; $class = $this->getClass(); $allStatic = $this->modx->getOption('allStatic', $this->helpers->props, false); if ($class != 'modPropertySet' && $class != 'modPlugin' && $allStatic) { $fields['static'] = true; } /* Handle static elements */ if (isset($fields['static']) && !empty($fields['static'])) { $projectDir = str_replace(MODX_ASSETS_PATH . 'mycomponents/', '', $this->helpers->props['targetRoot']); $dir = 'assets/mycomponents/'; $dir .= $projectDir . 'core/components/' . $this->helpers->props['packageNameLower'] . '/'; $path = $this->helpers->getCodeDir($dir, $this->dbClass); if (isset($this->myFields['filename'])) { $fileName = $this->myFields['filename']; } else { $fileName = $this->helpers->getFileName($this->getName(), $this->dbClass); } $path .= '/' . $fileName; $this->myFields['source'] = $this->modx->getOption('default_media_source'); $this->myFields['static_file'] = $path; $this->helpers->sendLog(modX::LOG_LEVEL_INFO, ' ' . $this->modx->lexicon('mc_set_static_path_to') . ' ' . $path); } return parent::addToMODx($overwrite); }
/** * Create alias if empty before ObjectAdapter adds to MODX * @param bool $overwrite * @return bool|int */ public final function addToMODx($overwrite = false) { /* @var $modx modX */ $fields =& $this->myFields; $this->fieldsToIds($fields); if (!isset($fields['alias']) || empty($fields['alias'])) { $fields['alias'] = str_replace(' ', '-', strtolower($fields['pagetitle'])); } $this->myFields =& $fields; return parent::addToMODx($overwrite); }