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/template/ |
<?php require_once (dirname(dirname(__FILE__)).'/duplicate.class.php'); /** * Duplicate a Template. * * * @param integer $id The ID of the template to duplicate. * @param string $name (optional) The name of the new template. Defaults to Untitled * Template. * * @package modx * @subpackage processors.element.template */ class modTemplateDuplicateProcessor extends modElementDuplicateProcessor { public $classKey = 'modTemplate'; public $languageTopics = array('template'); public $permission = 'new_template'; public $objectType = 'template'; public $nameField = 'templatename'; public function afterSave() { $this->duplicateTemplateVariables(); return parent::afterSave(); } public function duplicateTemplateVariables() { $c = $this->modx->newQuery('modTemplateVarTemplate'); $c->where(array( 'templateid' => $this->object->get('id'), )); $c->sortby('rank','ASC'); $templateVarTemplates = $this->modx->getCollection('modTemplateVarTemplate',$c); /** @var modTemplateVarTemplate $templateVarTemplate */ foreach ($templateVarTemplates as $templateVarTemplate) { /** @var modTemplateVarTemplate $newTemplateVarTemplate */ $newTemplateVarTemplate = $this->modx->newObject('modTemplateVarTemplate'); $newTemplateVarTemplate->set('tmplvarid',$templateVarTemplate->get('tmplvarid')); $newTemplateVarTemplate->set('rank',$templateVarTemplate->get('rank')); $newTemplateVarTemplate->set('templateid',$this->newObject->get('id')); $newTemplateVarTemplate->save(); } } } return 'modTemplateDuplicateProcessor';