/** * Edit module form. * * @param Curry_PageModuleWrapper $wrapper * @return Curry_Form|null */ protected function getModuleForm(Curry_PageModuleWrapper $wrapper) { $form = new Curry_Form(array('action' => url('', $_GET), 'method' => 'post', 'elements' => array('pid_editmodule' => array('hidden')))); if ($wrapper->hasData()) { $subform = $wrapper->createObject()->showBack(); if ($subform == null) { return null; } if (!$subform instanceof Curry_Form_SubForm) { throw new Exception($wrapper->getClassName() . '::showBack() did not return an instance of Curry_Form_SubForm.'); } if (!$subform->getLegend()) { $subform->setLegend($wrapper->getName() . ' (' . $wrapper->getClassName() . ')'); } if (!$subform instanceof Curry_Form_MultiForm) { $subform->setDecorators(array('FormElements')); } $form->addSubForm($subform, 'module' . $wrapper->getPageModuleId()); $buttons = array('save'); $form->addElement('submit', 'save', array('label' => 'Save')); if ($wrapper->isDeletable()) { $form->addElement('submit', 'delete', array('label' => 'Remove content')); $buttons[] = 'delete'; } $form->addDisplayGroup($buttons, 'dg1', array('class' => 'horizontal-group')); } else { $form->addElement('submit', 'create', array('label' => $wrapper->isInherited() ? 'Override content' : 'Create content')); } return $form; }
/** * Get "copy code" for module. * * @param Curry_PageModuleWrapper $module * @return array */ public static function getModuleCode(Curry_PageModuleWrapper $module) { $datas = array(); $moduleDatas = ModuleDataQuery::create()->filterByPageModule($module->getPageModule())->filterByPageRevision($module->getPageRevision())->orderByLangcode()->find(); foreach ($moduleDatas as $moduleData) { $datas[] = self::getModuleDataCode($moduleData); } return array("is_inherited" => $module->isInherited(), "uid" => $module->getPageModule()->getUid(), "name" => $module->getName(), "module_class" => $module->getClassName(), "inherit" => true, "target" => $module->getTarget(), "content_visibility" => $module->getPageModule()->getContentVisibility(), "search_visibility" => $module->getPageModule()->getSearchVisibility(), "datas" => $datas); }
/** * Module properties form. * * @param Curry_PageModuleWrapper $pageModuleWrapper * @return Curry_Form */ public static function getModulePropertiesForm(Curry_PageModuleWrapper $pageModuleWrapper) { $form = new Curry_Form(array('action' => url('', $_GET), 'method' => 'post', 'elements' => array('pid_moduleproperties' => array('hidden'), 'name' => array('text', array('label' => 'Name', 'required' => true, 'value' => $pageModuleWrapper->getPageModule()->getName(), 'description' => 'The name of this module. If you have many modules of the same type on the same page this will help you to seperate them from each other.')), 'target' => array('text', array('label' => 'Target', 'description' => 'Specifies what variable in the page-template to attach this module to.', 'required' => true, 'value' => $pageModuleWrapper->getTarget())), 'content_visibility' => array('select', array('label' => 'Content Visibility', 'description' => 'Set the visibility of this module in the Content backend module.', 'multiOptions' => PageModulePeer::$contentVisiblityOptions, 'value' => $pageModuleWrapper->getPageModule()->getContentVisibility(), 'required' => true)), 'search_visibility' => array('checkbox', array('label' => 'Search Visibility', 'description' => 'If this module should be rendered when indexing pages.', 'value' => $pageModuleWrapper->getPageModule()->getSearchVisibility(), 'required' => true))))); $showSelect = array("true" => "Yes", "false" => "No"); $defaultTemplate = $pageModuleWrapper->isInherited() ? "[ Inherit ]" : "[ None ]"; $template = $pageModuleWrapper->getModuleData()->getTemplate(); $templatesSelect = Curry_Backend_Template::getTemplateSelect(); if ($template && !array_key_exists($template, $templatesSelect)) { $templatesSelect[$template] = $template . ' <MISSING!>'; } $form->addSubForm(new Curry_Form_SubForm(array('legend' => $pageModuleWrapper->isInherited() ? 'Override inherited settings' : 'Inherited settings', 'elements' => array('template' => $pageModuleWrapper->hasTemplate() ? array('select', array('label' => 'Template', 'multiOptions' => array(null => $defaultTemplate) + $templatesSelect, 'value' => $template)) : array('select', array('label' => 'Template', 'multiOptions' => array("None"), 'disabled' => 'disabled')), 'show' => array('select', array('label' => 'Show', 'multiOptions' => $pageModuleWrapper->isInherited() ? array('' => "[ Inherit ]") + $showSelect : $showSelect, 'value' => self::bool2str($pageModuleWrapper->getModuleData()->getEnabled())))))), 'local'); $form->addElement('submit', 'save', array('label' => 'Save')); return $form; }