function updateCMSFields(FieldList $fields) { $subsites = Subsite::accessible_sites("CMS_ACCESS_CMSMain"); $subsitesMap = array(); if ($subsites && $subsites->Count()) { $subsitesMap = $subsites->map('ID', 'Title'); unset($subsitesMap[$this->owner->SubsiteID]); } // Master page edit field (only allowed from default subsite to avoid inconsistent relationships) $isDefaultSubsite = $this->owner->SubsiteID == 0 || $this->owner->Subsite()->DefaultSite; if ($isDefaultSubsite && $subsitesMap) { $fields->addFieldToTab('Root.Main', new DropdownField("CopyToSubsiteID", _t('SiteTreeSubsites.CopyToSubsite', "Copy page to subsite"), $subsitesMap, '')); $fields->addFieldToTab('Root.Main', $copyAction = new InlineFormAction("copytosubsite", _t('SiteTreeSubsites.CopyAction', "Copy"))); $copyAction->includeDefaultJS(false); } // replace readonly link prefix $subsite = $this->owner->Subsite(); $nested_urls_enabled = Config::inst()->get('SiteTree', 'nested_urls'); if ($subsite && $subsite->ID) { $baseUrl = Director::protocol() . $subsite->domain() . '/'; $baseLink = Controller::join_links($baseUrl, $nested_urls_enabled && $this->owner->ParentID ? $this->owner->Parent()->RelativeLink(true) : null); $urlsegment = $fields->dataFieldByName('URLSegment'); $urlsegment->setURLPrefix($baseLink); } }
public function getChildren() { if ($this->children->Count() == 0) { $inlineFormAction = new InlineFormAction("delete_unused_thumbnails", _t('Folder.DELETEUNUSEDTHUMBNAILS', 'Delete unused thumbnails')); $inlineFormAction->includeDefaultJS(false); $this->children = new FieldList(new LiteralField("UnusedAssets", "<h2>" . _t('Folder.UNUSEDFILESTITLE', 'Unused files') . "</h2>"), $this->getAssetList(), new FieldGroup(new LiteralField("UnusedThumbnails", "<h2>" . _t('Folder.UNUSEDTHUMBNAILSTITLE', 'Unused thumbnails') . "</h2>"), $inlineFormAction)); $this->children->setForm($this->form); } return $this->children; }
/** * Returns the edit form for this admin. * * @param type $id * @param type $fields * * @return Form */ public function getEditForm($id = null, $fields = null) { $fields = new FieldList(); $desc = _t('SilvercartNewsletterRecipientsAdmin.Description', 'Please choose your export context and press the export button to download a CSV list of email recipients.'); $descriptionField = new SilvercartAlertInfoField('SilvercartProductImagesDescription', str_replace(PHP_EOL, '<br/>', $desc)); $exportContextField = new DropdownField('ExportContext', _t('SilvercartNewsletterRecipientsAdmin.ExportContext', 'Export context')); $exportContextField->setSource(array('0' => _t('SilvercartNewsletterRecipientsAdmin.ExportAll', 'Export all customers'), '1' => _t('SilvercartNewsletterRecipientsAdmin.ExportAllNewsletterRecipients', 'Export all newsletter recipients'), '2' => _t('SilvercartNewsletterRecipientsAdmin.ExportAllNewsletterRecipientsWithAccount', 'Export all newsletter recipients with customer account'), '3' => _t('SilvercartNewsletterRecipientsAdmin.ExportAllNewsletterRecipientsWithoutAccount', 'Export all newsletter recipients without customer account'), '4' => _t('SilvercartNewsletterRecipientsAdmin.ExportAllNonNewsletterRecipients', 'Export all non-newsletter recipients'))); $doExportButton = new InlineFormAction('do_newsletter_recipients_export', _t('SilvercartNewsletterRecipientsAdmin.DoExport', 'Export as CSV')); $doExportButton->includeDefaultJS(false); $doExportButton->setAttribute('data-icon', 'download-csv'); $fields->push($descriptionField); $fields->push($exportContextField); $fields->push($doExportButton); $actions = new FieldList(); $form = new Form($this, "EditForm", $fields, $actions); $form->addExtraClass('cms-edit-form cms-panel-padded center ' . $this->BaseCSSClasses()); $form->loadDataFrom($this->request->getVars()); $this->extend('updateEditForm', $form); return $form; }
/** * Change the member dialog in the CMS * * This method updates the forms in the cms to allow the translations for * the defined translatable fields. */ function updateCMSFields(FieldSet &$fields) { if (!$this->stat('enabled')) { return false; } $creating = false; $baseClass = $this->owner->class; while (($p = get_parent_class($baseClass)) != "DataObject") { $baseClass = $p; } $allFields = $this->owner->getAllFields(); if (!self::is_default_lang()) { // Get the original version record, to show the original values if (!is_numeric($allFields['ID'])) { $originalLangID = Session::get($this->owner->ID . '_originalLangID'); $creating = true; } else { $originalLangID = $allFields['ID']; } $originalRecord = self::get_one_by_lang($this->owner->class, self::$default_lang, "`{$baseClass}`.ID = " . $originalLangID); $this->original_values = $originalRecord->getAllFields(); $alltasks = array('dup' => array()); foreach ($fields as $field) { if ($field->isComposite()) { $innertasks = $this->duplicateOrReplaceFields($field->FieldSet()); // more efficient and safe than array_merge_recursive $alltasks['dup'] = array_merge($alltasks['dup'], $innertasks['dup']); } } foreach ($alltasks['dup'] as $fieldname => $newfield) { // Duplicate the field $fields->replaceField($fieldname, $newfield); } } else { $alreadyTranslatedLangs = null; if (is_numeric($allFields['ID'])) { $alreadyTranslatedLangs = self::get_langs_by_id($baseClass, $allFields['ID']); } if (!$alreadyTranslatedLangs) { $alreadyTranslatedLangs = array(); } foreach ($alreadyTranslatedLangs as $i => $langCode) { $alreadyTranslatedLangs[$i] = i18n::get_language_name($langCode); } $fields->addFieldsToTab('Root', new Tab(_t('Translatable.TRANSLATIONS', 'Translations'), new HeaderField(_t('Translatable.CREATE', 'Create new translation'), 2), $langDropdown = new LanguageDropdownField("NewTransLang", _t('Translatable.NEWLANGUAGE', 'New language'), $alreadyTranslatedLangs), $createButton = new InlineFormAction('createtranslation', _t('Translatable.CREATEBUTTON', 'Create')))); if (count($alreadyTranslatedLangs)) { $fields->addFieldsToTab('Root.Translations', new FieldSet(new HeaderField(_t('Translatable.EXISTING', 'Existing translations:'), 3), new LiteralField('existingtrans', implode(', ', $alreadyTranslatedLangs)))); } $langDropdown->addExtraClass('languageDropdown'); $createButton->addExtraClass('createTranslationButton'); $createButton->includeDefaultJS(false); } }
/** * Return the FieldSet used to edit a dynamic template in the CMS. */ function getCMSFields() { $fileList = new DynamicTemplateFilesField("Files", "Files", $this); $titleField = $this->ID && $this->ID != "root" ? new TextField("Title", _t('Folder.TITLE')) : new HiddenField("Title"); // delete files button if ($this->canEdit()) { $deleteButton = new InlineFormAction('deletemarked', _t('Folder.DELSELECTED', 'Delete selected files'), 'delete'); $deleteButton->includeDefaultJS(false); } else { $deleteButton = new HiddenField('deletemarked'); } // link file button if ($this->canEdit()) { $fileButtons = new CompositeField($linkFileButton = new InlineFormAction('linkfile', _t('DynamicTemplate.LINKFILE', 'Link file(s) from theme'), 'link'), $copyFileButton = new InlineFormAction('copyfile', _t('DynamicTemplate.COPYFILE', 'Copy file(s) from theme'), 'copy'), $newFileButton = new InlineFormAction('newfile', _t('DynamicTemplate.NEWFILE', 'New file'), 'newfile')); $linkFileButton->includeDefaultJS(false); $newFileButton->includeDefaultJS(false); } else { $fileButtons = new HiddenField('linkfile'); } $propButtons = new CompositeField(); // $propButtons->push($exportButton = new InlineFormAction('exporttemplate', _t('DynamicTemplate.EXPORTTEMPLATE', 'Export'), 'export')); // $exportButton->includeDefaultJS(false); // if ($this->canEdit()) { // $propButtons->push($saveButton = new InlineFormAction('savetemplate', _t('DynamicTemplate.SAVETEMPLATE', 'Save'), 'save')); // $saveButton->includeDefaultJS(false); // } if ($this->canDelete()) { $propButtons->push($deleteButton = new InlineFormAction('deletetemplate', _t('DynamicTemplate.DELETETEMPLATE', 'Delete'), 'delete')); $deleteButton->includeDefaultJS(false); } if (DynamicTemplateAdmin::tarball_available()) { $exportTarballButton = new InlineFormAction('exportastarball', _t('DynamicTemplate.EXPORT', 'Export as tarball'), 'exportastarball'); $exportTarballButton->includeDefaultJS(false); $propButtons->push($exportTarballButton); } if (DynamicTemplateAdmin::zip_available()) { $exportZipButton = new InlineFormAction('exportaszip', _t('DynamicTemplate.EXPORT', 'Export as zip'), 'exportaszip'); $exportZipButton->includeDefaultJS(false); $propButtons->push($exportZipButton); } $titleField = $this->ID && $this->ID != "root" ? new TextField("Title", _t('Folder.TITLE')) : new HiddenField("Title"); if (!$this->canEdit()) { $titleField->setReadOnly(true); } $fields = new FieldSet(new HiddenField("Name"), new TabSet("Root", new Tab("Properties", _t('DynamicTemplate.PROPERTIESTAB', 'Properties'), $titleField, new ReadonlyField("URL", _t('Folder.URL', 'URL')), new ReadonlyField("Created", _t('Folder.CREATED', 'First Uploaded')), new ReadonlyField("LastEdited", _t('Folder.LASTEDITED', 'Last Updated')), $propButtons), new Tab("Files", _t('Folder.FILESTAB', "Files"), $fileList, $fileButtons, new HiddenField("FileIDs"), new HiddenField("DestFolderID")), new Tab("Upload", _t('Folder.UPLOADTAB', "Upload"), new LabelField('UploadPrompt', _t('DynamicTemplate.UPLOADPROMPT', 'Upload files to your template. Uploads will automatically be added to the right place.')), new LiteralField("UploadIframe", $this->getUploadIframe()))), new HiddenField("ID")); if (!$this->canEdit()) { $fields->removeFieldFromTab("Root", "Upload"); } $this->extend('updateCMSFields', $fields); return $fields; }
/** * Return the FieldSet used to edit this folder in the CMS. * You can modify this fieldset by subclassing folder, or by creating a {@link DataObjectDecorator} * and implemeting updateCMSFields(FieldSet $fields) on that decorator. */ function getCMSFields() { $nameField = ($this->ID > 0) ? new TextField("Name") : new HiddenField("Name"); $fileList = new AssetTableField( $this, "Files", "File", array("Title" => _t('Folder.TITLE', "Title"), "LinkedURL" => _t('Folder.FILENAME', "Filename")), "" ); $fileList->setFolder($this); $fileList->setPopupCaption(_t('Folder.VIEWEDITASSET', "View/Edit Asset")); $nameField = ($this->ID && $this->ID != "root") ? new TextField("Name", _t('Folder.TITLE')) : new HiddenField("Name"); if( $this->canEdit() ) { $deleteButton = new InlineFormAction('deletemarked',_t('Folder.DELSELECTED','Delete selected files'), 'delete'); $deleteButton->includeDefaultJS(false); } else { $deleteButton = new HiddenField('deletemarked'); } $fields = new FieldSet( new HiddenField("Title"), new TabSet("Root", new Tab("Files", _t('Folder.FILESTAB', "Files"), $nameField, $fileList, $deleteButton, new HiddenField("FileIDs"), new HiddenField("DestFolderID") ), new Tab("Details", _t('Folder.DETAILSTAB', "Details"), new ReadonlyField("URL", _t('Folder.URL', 'URL')), new ReadonlyField("ClassName", _t('Folder.TYPE','Type')), new ReadonlyField("Created", _t('Folder.CREATED','First Uploaded')), new ReadonlyField("LastEdited", _t('Folder.LASTEDITED','Last Updated')) ), new Tab("Upload", _t('Folder.UPLOADTAB', "Upload"), new LiteralField("UploadIframe", $this->getUploadIframe() ) ), new Tab("UnusedFiles", _t('Folder.UNUSEDFILESTAB', "Unused files"), new LiteralField("UnusedAssets", "<div id=\"UnusedAssets\"><h2>"._t('Folder.UNUSEDFILESTITLE', 'Unused files')."</h2>" ), $this->getAssetList(), new LiteralField("UnusedThumbnails", "</div> <div id=\"UnusedThumbnails\"> <h2>"._t('Folder.UNUSEDTHUMBNAILSTITLE', 'Unused thumbnails')."</h2> <button class=\"action\">"._t('Folder.DELETEUNUSEDTHUMBNAILS', 'Delete unused thumbnails')."</button> </div>" ) ) ), new HiddenField("ID") ); $this->extend('updateCMSFields', $fields); return $fields; }
/** * @return FormField|null */ function DeleteMarkedButton() { if (!$this->isReadonly()) { $deleteButton = new InlineFormAction('deletemarked', _t('Folder.DELSELECTED', 'Delete selected files'), 'delete'); $deleteButton->includeDefaultJS(false); return $deleteButton; } }
/** * Return the FieldSet used to edit this folder in the CMS. * You can modify this fieldset by subclassing folder, or by creating a {@link DataExtension} * and implemeting updateCMSFields(FieldList $fields) on that extension. */ function getCMSFields() { $fileList = new AssetTableField($this, "Files", "File", array("Title" => _t('Folder.TITLE', "Title"), "Filename" => _t('Folder.FILENAME', "Filename")), ""); $fileList->setFolder($this); $fileList->setPopupCaption(_t('Folder.VIEWEDITASSET', "View/Edit Asset")); $titleField = $this->ID && $this->ID != "root" ? new TextField("Title", _t('Folder.TITLE')) : new HiddenField("Title"); if ($this->canEdit()) { $deleteButton = new InlineFormAction('deletemarked', _t('Folder.DELSELECTED', 'Delete selected files'), 'delete'); $deleteButton->includeDefaultJS(false); } else { $deleteButton = new HiddenField('deletemarked'); } $fields = new FieldList(new HiddenField("Name"), new TabSet("Root", new Tab("Files", _t('Folder.FILESTAB', "Files"), $titleField, $fileList, new HiddenField("DestFolderID")), new Tab("Details", _t('Folder.DETAILSTAB', "Details"), new ReadonlyField("URL", _t('Folder.URL', 'URL')), new ReadonlyField("ClassName", _t('Folder.TYPE', 'Type')), new ReadonlyField("Created", _t('Folder.CREATED', 'First Uploaded')), new ReadonlyField("LastEdited", _t('Folder.LASTEDITED', 'Last Updated'))), new Tab("Upload", _t('Folder.UPLOADTAB', "Upload"), new LiteralField("UploadIframe", $this->getUploadIframe()))), new HiddenField("ID")); if (!$this->canEdit()) { $fields->removeFieldFromTab("Root", "Upload"); } $this->extend('updateCMSFields', $fields); return $fields; }
/** * If the record is not shown in the default language, this method * will try to autoselect a master language which is shown alongside * the normal formfields as a readonly representation. * This gives translators a powerful tool for their translation workflow * without leaving the translated page interface. * Translatable also adds a new tab "Translation" which shows existing * translations, as well as a formaction to create new translations based * on a dropdown with available languages. * * @todo This is specific to SiteTree and CMSMain * @todo Implement a special "translation mode" which triggers display of the * readonly fields, so you can translation INTO the "default language" while * seeing readonly fields as well. */ function updateCMSFields(FieldSet &$fields) { // Don't apply these modifications for normal DataObjects - they rely on CMSMain logic if (!$this->owner instanceof SiteTree) { return; } // used in CMSMain->init() to set language state when reading/writing record $fields->push(new HiddenField("Locale", "Locale", $this->owner->Locale)); // Don't allow translation of virtual pages because of data inconsistencies (see #5000) $excludedPageTypes = array('VirtualPage'); foreach ($excludedPageTypes as $excludedPageType) { if (is_a($this->owner, $excludedPageType)) { return; } } $excludeFields = array('ViewerGroups', 'EditorGroups', 'CanViewType', 'CanEditType'); // if a language other than default language is used, we're in "translation mode", // hence have to modify the original fields $creating = false; $baseClass = $this->owner->class; $allFields = $fields->toArray(); while (($p = get_parent_class($baseClass)) != "DataObject") { $baseClass = $p; } // try to get the record in "default language" $originalRecord = $this->owner->getTranslation(Translatable::default_locale()); // if no translation in "default language", fall back to first translation if (!$originalRecord) { $translations = $this->owner->getTranslations(); $originalRecord = $translations ? $translations->First() : null; } $isTranslationMode = $this->owner->Locale != Translatable::default_locale(); // Show a dropdown to create a new translation. // This action is possible both when showing the "default language" // and a translation. Include the current locale (record might not be saved yet). $alreadyTranslatedLocales = $this->getTranslatedLocales(); $alreadyTranslatedLocales[$this->owner->Locale] = $this->owner->Locale; if ($originalRecord && $isTranslationMode) { $originalLangID = Session::get($this->owner->ID . '_originalLangID'); // Remove parent page dropdown $fields->removeByName("ParentType"); $fields->removeByName("ParentID"); $translatableFieldNames = $this->getTranslatableFields(); $allDataFields = $fields->dataFields(); $transformation = new Translatable_Transformation($originalRecord); // iterate through sequential list of all datafields in fieldset // (fields are object references, so we can replace them with the translatable CompositeField) foreach ($allDataFields as $dataField) { if ($dataField instanceof HiddenField) { continue; } if (in_array($dataField->Name(), $excludeFields)) { continue; } if (in_array($dataField->Name(), $translatableFieldNames)) { // if the field is translatable, perform transformation $fields->replaceField($dataField->Name(), $transformation->transformFormField($dataField)); } else { // else field shouldn't be editable in translation-mode, make readonly $fields->replaceField($dataField->Name(), $dataField->performReadonlyTransformation()); } } } elseif ($this->owner->isNew()) { $fields->addFieldsToTab('Root', new Tab(_t('Translatable.TRANSLATIONS', 'Translations'), new LiteralField('SaveBeforeCreatingTranslationNote', sprintf('<p class="message">%s</p>', _t('Translatable.NOTICENEWPAGE', 'Please save this page before creating a translation'))))); } $fields->addFieldsToTab('Root', new Tab('Translations', _t('Translatable.TRANSLATIONS', 'Translations'), new HeaderField('CreateTransHeader', _t('Translatable.CREATE', 'Create new translation'), 2), $langDropdown = new LanguageDropdownField("NewTransLang", _t('Translatable.NEWLANGUAGE', 'New language'), $alreadyTranslatedLocales, 'SiteTree', 'Locale-English', $this->owner), $createButton = new InlineFormAction('createtranslation', _t('Translatable.CREATEBUTTON', 'Create')))); $createButton->includeDefaultJS(false); if ($alreadyTranslatedLocales) { $fields->addFieldToTab('Root.Translations', new HeaderField('ExistingTransHeader', _t('Translatable.EXISTING', 'Existing translations:'), 3)); $existingTransHTML = '<ul>'; foreach ($alreadyTranslatedLocales as $i => $langCode) { $existingTranslation = $this->owner->getTranslation($langCode); if ($existingTranslation) { $existingTransHTML .= sprintf('<li><a href="%s">%s</a></li>', sprintf('admin/show/%d/?locale=%s', $existingTranslation->ID, $langCode), i18n::get_locale_name($langCode)); } } $existingTransHTML .= '</ul>'; $fields->addFieldToTab('Root.Translations', new LiteralField('existingtrans', $existingTransHTML)); } $langDropdown->addExtraClass('languageDropdown'); $createButton->addExtraClass('createTranslationButton'); }
function updateCMSFields(FieldSet &$fields) { if(!$this->stat('enabled', true)) return false; // add hidden fields for the used language and original record $fields->push(new HiddenField("Lang", "Lang", $this->getLang()) ); $fields->push(new HiddenField("OriginalID", "OriginalID", $this->owner->OriginalID) ); // if a language other than default language is used, we're in "translation mode", // hence have to modify the original fields $isTranslationMode = (Translatable::default_lang() != $this->getLang() && $this->getLang()); if($isTranslationMode) { $originalLangID = Session::get($this->owner->ID . '_originalLangID'); $translatableFieldNames = $this->getTranslatableFields(); $allDataFields = $fields->dataFields(); $transformation = new Translatable_Transformation(Translatable::get_original($this->owner->class, $this->owner->ID)); // iterate through sequential list of all datafields in fieldset // (fields are object references, so we can replace them with the translatable CompositeField) foreach($allDataFields as $dataField) { if(in_array($dataField->Name(), $translatableFieldNames)) { //var_dump($dataField->Name()); // if the field is translatable, perform transformation $fields->replaceField($dataField->Name(), $transformation->transformFormField($dataField)); } else { // else field shouldn't be editable in translation-mode, make readonly $fields->replaceField($dataField->Name(), $dataField->performReadonlyTransformation()); } } } else { // if we're not in "translation mode", show a dropdown to create a new translation. // this action should just be possible when showing the default language, // you can't create new translations from within a "translation mode" form. $alreadyTranslatedLangs = array(); foreach ($alreadyTranslatedLangs as $i => $langCode) { $alreadyTranslatedLangs[$i] = i18n::get_language_name($langCode); } $fields->addFieldsToTab( 'Root', new Tab(_t('Translatable.TRANSLATIONS', 'Translations'), new HeaderField('CreateTransHeader', _t('Translatable.CREATE', 'Create new translation'), 2), $langDropdown = new LanguageDropdownField("NewTransLang", _t('Translatable.NEWLANGUAGE', 'New language'), $alreadyTranslatedLangs), $createButton = new InlineFormAction('createtranslation',_t('Translatable.CREATEBUTTON', 'Create')) ) ); if (count($alreadyTranslatedLangs)) { $fields->addFieldsToTab( 'Root.Translations', new FieldSet( new HeaderField('ExistingTransHeader', _t('Translatable.EXISTING', 'Existing translations:'), 3), new LiteralField('existingtrans',implode(', ',$alreadyTranslatedLangs)) ) ); } $langDropdown->addExtraClass('languageDropdown'); $createButton->addExtraClass('createTranslationButton'); $createButton->includeDefaultJS(false); } }
/** * If the record is not shown in the default language, this method * will try to autoselect a master language which is shown alongside * the normal formfields as a readonly representation. * This gives translators a powerful tool for their translation workflow * without leaving the translated page interface. * Translatable also adds a new tab "Translation" which shows existing * translations, as well as a formaction to create new translations based * on a dropdown with available languages. * * @todo This is specific to SiteTree and CMSMain * @todo Implement a special "translation mode" which triggers display of the * readonly fields, so you can translation INTO the "default language" while * seeing readonly fields as well. */ function updateCMSFields(FieldList $fields) { $this->addTranslatableFields($fields); // Show a dropdown to create a new translation. // This action is possible both when showing the "default language" // and a translation. Include the current locale (record might not be saved yet). $alreadyTranslatedLocales = $this->getTranslatedLocales(); $alreadyTranslatedLocales[$this->owner->Locale] = $this->owner->Locale; $alreadyTranslatedLocales = array_combine($alreadyTranslatedLocales, $alreadyTranslatedLocales); $fields->addFieldsToTab('Root', new Tab('Translations', _t('Translatable.TRANSLATIONS', 'Translations'), new HeaderField('CreateTransHeader', _t('Translatable.CREATE', 'Create new translation'), 2), $langDropdown = new LanguageDropdownField("NewTransLang", _t('Translatable.NEWLANGUAGE', 'New language'), $alreadyTranslatedLocales, 'SiteTree', 'Locale-English', $this->owner), $createButton = new InlineFormAction('createtranslation', _t('Translatable.CREATEBUTTON', 'Create')))); $createButton->includeDefaultJS(false); if ($alreadyTranslatedLocales) { $fields->addFieldToTab('Root.Translations', new HeaderField('ExistingTransHeader', _t('Translatable.EXISTING', 'Existing translations:'), 3)); $existingTransHTML = '<ul>'; foreach ($alreadyTranslatedLocales as $langCode) { $existingTranslation = $this->owner->getTranslation($langCode); if ($existingTranslation && $this->owner->ClassName == "SiteConfig") { $existingTransHTML .= sprintf('<li><a href="%s">%s</a></li>', sprintf('%s/?locale=%s', Director::baseURL() . "admin/settings", $langCode), i18n::get_locale_name($langCode)); } else { if ($existingTranslation && $existingTranslation->hasMethod('CMSEditLink')) { $existingTransHTML .= sprintf('<li><a href="%s">%s</a></li>', sprintf('%s/?locale=%s', $existingTranslation->CMSEditLink(), $langCode), i18n::get_locale_name($langCode)); } } } $existingTransHTML .= '</ul>'; $fields->addFieldToTab('Root.Translations', new LiteralField('existingtrans', $existingTransHTML)); } $langDropdown->addExtraClass('languageDropdown no-change-track'); $createButton->addExtraClass('createTranslationButton'); }
/** * Return the FieldSet used to edit a dynamic template in the CMS. */ function getCMSFields() { // // delete files button // if( $this->canEdit() ) { // $deleteButton = new InlineFormAction('deletemarked',_t('Folder.DELSELECTED','Delete selected files'), 'delete'); // $deleteButton->includeDefaultJS(false); // } else { // $deleteButton = new HiddenField('deletemarked'); // } // link file button if ($this->canEdit()) { $fileButtons = new CompositeField($linkFileButton = new InlineFormAction('linkfile', _t('DynamicTemplate.LINKFILE', 'Link file(s) from theme'), 'link'), $copyFileButton = new InlineFormAction('copyfile', _t('DynamicTemplate.COPYFILE', 'Copy file(s) from theme'), 'copy'), $newFileButton = new InlineFormAction('newfile', _t('DynamicTemplate.NEWFILE', 'New file'), 'newfile')); $linkFileButton->includeDefaultJS(false); $copyFileButton->includeDefaultJS(false); $newFileButton->includeDefaultJS(false); } else { $fileButtons = new HiddenField('linkfile'); } $propButtons = new CompositeField(); // $propButtons->push($exportButton = new InlineFormAction('exporttemplate', _t('DynamicTemplate.EXPORTTEMPLATE', 'Export'), 'export')); // $exportButton->includeDefaultJS(false); // if ($this->canEdit()) { // $propButtons->push($saveButton = new InlineFormAction('savetemplate', _t('DynamicTemplate.SAVETEMPLATE', 'Save'), 'save')); // $saveButton->includeDefaultJS(false); // } if (DynamicTemplateAdmin::tarball_available()) { $exportTarballButton = new InlineFormAction('exportastarball', _t('DynamicTemplate.EXPORT', 'Export as tarball'), 'exportastarball'); $exportTarballButton->includeDefaultJS(false); $propButtons->push($exportTarballButton); } if (DynamicTemplateAdmin::zip_available()) { $exportZipButton = new InlineFormAction('exportaszip', _t('DynamicTemplate.EXPORT', 'Export as zip'), 'exportaszip'); $exportZipButton->includeDefaultJS(false); $propButtons->push($exportZipButton); } // $titleField = ($this->ID && $this->ID != "root") ? new TextField("Title", _t('Folder.TITLE', 'Title')) : new HiddenField("Title"); $titleField = new TextField("Title", _t('Folder.TITLE', 'Title')); if (!$this->canEdit()) { $titleField->setReadOnly(true); } $nameField = new TextField("Name"); if (!$this->canEdit()) { $titleField->setReadOnly(true); } $fields = new FieldList($rootTabSet = new TabSet("Root", new Tab("Properties", _t('DynamicTemplate.PROPERTIESTAB', 'Properties'), $titleField, new ReadonlyField("URL", _t('Folder.URL', 'URL')), new ReadonlyField("Created", _t('Folder.CREATED', 'First Uploaded')), new ReadonlyField("LastEdited", _t('Folder.LASTEDITED', 'Last Updated')), new HiddenField("ID"), new HiddenField("ClassName", null, "DynamicTemplate"), $propButtons), new Tab("Upload", _t('Folder.UPLOADTAB', "Upload"), new LabelField('UploadPrompt', _t('DynamicTemplate.UPLOADPROMPT', 'Upload files to your template. Uploads will automatically be added to the right place.')), $this->getUploadField()))); // A DT can only have files if it has been saved at least once. This is also to avoid time out issue where DynamicTemplatesFileField::calc_tree // tries to find files from a DT with ID=0 if ($this->ID) { $fileList = new DynamicTemplateFilesField("Files", "Files", $this); $rootTabSet->push(new Tab("Files", _t('Folder.FILESTAB', "Files"), $fileList, $fileButtons, new HiddenField("FileIDs"), new HiddenField("DestFolderID"))); } if (!$this->canEdit()) { $fields->removeFieldFromTab("Root", "Upload"); } $this->extend('updateCMSFields', $fields); Session::set("dynamictemplates_currentID", $this->ID); return $fields; }
/** * Builds and returns the CMS fields. * * @return FieldList the CMS tabs and fields * * @author Sebastian Diel <*****@*****.**> * @since 22.02.2013 */ public function getCMSFieldsForSilvercart(FieldList $fields) { //$tab = $fields->findOrMakeTab('Root.Silvercart', 'SilverCart Shop'); //$tab->setTitle('SilverCart Shop'); // Build general toggle group $generalConfigurationField = ToggleCompositeField::create('GeneralConfiguration', $this->owner->fieldLabel('GeneralConfiguration'), array(SilvercartLanguageHelper::prepareLanguageDropdownField($this->owner, 'SiteTree', 'DefaultLocale'), new CheckboxField('useDefaultLanguageAsFallback', $this->owner->fieldLabel('useDefaultLanguageAsFallback')), new TextField('DefaultCurrency', $this->owner->fieldLabel('DefaultCurrency')), new DropdownField('DefaultPriceType', $this->owner->fieldLabel('DefaultPriceType'))))->setHeadingLevel(4)->setStartClosed(false); // Build email toggle group $emailConfigurationField = ToggleCompositeField::create('EmailConfiguration', $this->owner->fieldLabel('EmailConfiguration'), array(new TextField('EmailSender', $this->owner->fieldLabel('EmailSender')), new TextField('GlobalEmailRecipient', $this->owner->fieldLabel('GlobalEmailRecipient')), new TextField('DefaultMailRecipient', $this->owner->fieldLabel('DefaultMailRecipient')), new TextField('DefaultMailOrderNotificationRecipient', $this->owner->fieldLabel('DefaultMailOrderNotificationRecipient')), new TextField('DefaultContactMessageRecipient', $this->owner->fieldLabel('DefaultContactMessageRecipient'))))->setHeadingLevel(4); // Build customer toggle group $customerConfigurationField = ToggleCompositeField::create('CustomerConfiguration', $this->owner->fieldLabel('CustomerConfiguration'), array(new CheckboxField('enableBusinessCustomers', $this->owner->fieldLabel('enableBusinessCustomers')), new CheckboxField('enablePackstation', $this->owner->fieldLabel('enablePackstation')), new CheckboxField('demandBirthdayDateOnRegistration', $this->owner->fieldLabel('demandBirthdayDateOnRegistration'))))->setHeadingLevel(4); // Build product toggle group $productConfigurationField = ToggleCompositeField::create('ProductConfiguration', $this->owner->fieldLabel('ProductConfiguration'), array(new CheckboxField('enableStockManagement', $this->owner->fieldLabel('enableStockManagement')), new CheckboxField('isStockManagementOverbookable', $this->owner->fieldLabel('isStockManagementOverbookable')), new TextField('productsPerPage', $this->owner->fieldLabel('productsPerPage')), new TextField('productGroupsPerPage', $this->owner->fieldLabel('productGroupsPerPage')), new TextField('displayedPaginationPages', $this->owner->fieldLabel('displayedPaginationPages')), new UploadField('SilvercartNoImage', $this->owner->fieldLabel('SilvercartNoImage')), new CheckboxField('useStrictSearchRelevance', $this->owner->fieldLabel('useStrictSearchRelevance')), new DropdownField('StandardProductConditionID', $this->owner->fieldLabel('StandardProductConditionID'))))->setHeadingLevel(4); // Build checkout toggle group $checkoutConfigurationField = ToggleCompositeField::create('CheckoutConfiguration', $this->owner->fieldLabel('CheckoutConfiguration'), array(new CheckboxField('enableSSL', $this->owner->fieldLabel('enableSSL')), new CheckboxField('redirectToCartAfterAddToCart', $this->owner->fieldLabel('redirectToCartAfterAddToCart')), new CheckboxField('redirectToCheckoutWhenInCart', $this->owner->fieldLabel('redirectToCheckoutWhenInCart')), new CheckboxField('useProductDescriptionFieldForCart', $this->owner->fieldLabel('useProductDescriptionFieldForCart')), new DropdownField('productDescriptionFieldForCart', $this->owner->fieldLabel('productDescriptionFieldForCart')), new TextField('addToCartMaxQuantity', $this->owner->fieldLabel('addToCartMaxQuantity')), new CheckboxField('useMinimumOrderValue', $this->owner->fieldLabel('useMinimumOrderValue')), new SilvercartMoneyField('minimumOrderValue', $this->owner->fieldLabel('minimumOrderValue')), new CheckboxField('useFreeOfShippingCostsFrom', $this->owner->fieldLabel('useFreeOfShippingCostsFrom')), new SilvercartMoneyField('freeOfShippingCostsFrom', $this->owner->fieldLabel('freeOfShippingCostsFrom')), new CheckboxField('SkipShippingStepIfUnique', $this->owner->fieldLabel('SkipShippingStepIfUnique')), new CheckboxField('SkipPaymentStepIfUnique', $this->owner->fieldLabel('SkipPaymentStepIfUnique')), new CheckboxField('DisplayWeightsInKilogram', $this->owner->fieldLabel('DisplayWeightsInKilogram')), new CheckboxField('ShowTaxAndDutyHint', $this->owner->fieldLabel('ShowTaxAndDutyHint')), new CheckboxField('InvoiceAddressIsAlwaysShippingAddress', $this->owner->fieldLabel('InvoiceAddressIsAlwaysShippingAddress'))))->setHeadingLevel(4); // Build shop data toggle group $shopDataConfigurationField = ToggleCompositeField::create('ShopDataConfiguration', $this->owner->fieldLabel('ShopDataConfiguration'), array(new TextField('ShopName', $this->owner->fieldLabel('ShopName')), new TextField('ShopStreet', $this->owner->fieldLabel('ShopStreet')), new TextField('ShopStreetNumber', $this->owner->fieldLabel('ShopStreetNumber')), new TextField('ShopPostcode', $this->owner->fieldLabel('ShopPostcode')), new TextField('ShopCity', $this->owner->fieldLabel('ShopCity')), new DropdownField('ShopCountryID', $this->owner->fieldLabel('ShopCountry'), SilvercartCountry::getPrioritiveDropdownMap())))->setHeadingLevel(4); // Build security toggle group $securityConfigurationField = ToggleCompositeField::create('SecurityConfiguration', $this->owner->fieldLabel('SecurityConfiguration'), array(new TextareaField('userAgentBlacklist', $this->owner->fieldLabel('userAgentBlacklist'))))->setHeadingLevel(4); // Build example data toggle group $addExampleDataButton = new InlineFormAction('add_example_data', $this->owner->fieldLabel('addExampleData')); $addExampleConfigButton = new InlineFormAction('add_example_config', $this->owner->fieldLabel('addExampleConfig')); $exampleDataField = ToggleCompositeField::create('ExampleData', $this->owner->fieldLabel('addExampleData'), array($addExampleDataButton, $addExampleConfigButton))->setHeadingLevel(4); $addExampleDataButton->setRightTitle($this->owner->fieldLabel('addExampleDataDesc')); $addExampleDataButton->includeDefaultJS(false); $addExampleDataButton->setAttribute('data-icon', 'addpage'); $addExampleConfigButton->setRightTitle($this->owner->fieldLabel('addExampleConfigDesc')); $addExampleConfigButton->includeDefaultJS(false); $addExampleConfigButton->setAttribute('data-icon', 'addpage'); // Add groups to Root.Main $fields->addFieldToTab('Root.Main', $generalConfigurationField); $fields->addFieldToTab('Root.Main', $emailConfigurationField); $fields->addFieldToTab('Root.Main', $customerConfigurationField); $fields->addFieldToTab('Root.Main', $productConfigurationField); $fields->addFieldToTab('Root.Main', $checkoutConfigurationField); $fields->addFieldToTab('Root.Main', $shopDataConfigurationField); $fields->addFieldToTab('Root.Main', $securityConfigurationField); $fields->addFieldToTab('Root.Main', $exampleDataField); // Modify field data $fields->dataFieldByName('DefaultLocale')->setTitle($this->owner->fieldLabel('DefaultLocale')); $fields->dataFieldByName('EmailSender')->setRightTitle($this->owner->fieldLabel('EmailSenderRightTitle')); $fields->dataFieldByName('GlobalEmailRecipient')->setRightTitle($this->owner->fieldLabel('GlobalEmailRecipientRightTitle')); $fields->dataFieldByName('DefaultMailRecipient')->setRightTitle($this->owner->fieldLabel('DefaultMailRecipientRightTitle')); $fields->dataFieldByName('DefaultMailOrderNotificationRecipient')->setRightTitle($this->owner->fieldLabel('DefaultMailOrderNotificationRecipientRightTitle')); $fields->dataFieldByName('DefaultContactMessageRecipient')->setRightTitle($this->owner->fieldLabel('DefaultContactMessageRecipientRightTitle')); $fields->dataFieldByName('userAgentBlacklist')->setRightTitle($this->owner->fieldLabel('userAgentBlacklistRightTitle')); // Add i18n to DefaultPriceType source $i18nForDefaultPriceTypeField = array(); foreach ($this->owner->dbObject('DefaultPriceType')->enumValues() as $value => $label) { $i18nForDefaultPriceTypeField[$value] = _t('SilvercartCustomer.' . strtoupper($label), $label); } $fields->dataFieldByName('DefaultPriceType')->setSource($i18nForDefaultPriceTypeField); // Add i18n to productDescriptionFieldForCart source $i18nForProductDescriptionField = array(); foreach ($this->owner->dbObject('productDescriptionFieldForCart')->enumValues() as $productDescriptionField) { $i18nForProductDescriptionField[$productDescriptionField] = singleton('SilvercartProduct')->fieldLabel($productDescriptionField); } $fields->dataFieldByName('productDescriptionFieldForCart')->setSource($i18nForProductDescriptionField); $fields->dataFieldByName('StandardProductConditionID')->setEmptyString($this->owner->fieldLabel('StandardProductConditionEmptyString')); $this->getCMSFieldsForColorScheme($fields); return $fields; }