function ListOfModulesLink() { $page = ModuleProductGroup::get()->filter(array("LevelOfProductsToShow" => 1))->first(); if ($page) { return $page->Link() . "#author_" . $this->owner->ScreenName; } }
function __construct($controller, $name, $moduleProductID = 0) { $fields = new FieldList(); $moduleProduct = null; if ($moduleProductID) { $fields->push(new HeaderField('AddEditModule', 'Edit ' . $controller->dataRecord->Title, 2)); $fields->push(new HiddenField('ModuleProductID', $moduleProductID, $moduleProductID)); $moduleProduct = ModuleProduct::get()->byID($moduleProductID); } else { $fields->push(new HeaderField('AddEditModule', $controller->dataRecord->Title, 2)); $fields->push(new HiddenField('ModuleProductID', 0, 0)); } $fields->push(new TextField('Code', 'Code (folder name)')); $moduleProductGroups = ModuleProductGroup::get()->filter(array("ParentID:GreaterThan" => 0)); if (ModuleProductGroup::get()->count()) { $types = array("" => " --- please select ---"); $types += ModuleProductGroup::get()->map($index = 'ID', $titleField = 'MenuTitle')->toArray(); } else { $types = array(); } //$fields->push(new DropdownField('ParentID','Type', $types, $controller->dataRecord->ID)); $fields->push(new TextField('Title', 'Title')); $fields->push(new TextareaField('MetaDescription', 'Three sentence Introduction')); $fields->push(new HtmlEditorField('Content', 'Long Description')); $fields->push(new TextField('AdditionalTags', 'Additional Keyword(s), comma separated')); $fields->push(new HeaderField('LinkHeader', 'Links', 4)); $fields->push(new TextField('MainURL', 'Home page')); $fields->push(new TextField('ReadMeURL', 'Read me file - e.g. http://www.mymodule.com/readme.md')); $fields->push(new TextField('DemoURL', 'Demo - e.g. http://demo.mymodule.com/')); $fields->push(new TextField('SvnURL', 'SVN repository - allowing you to checkout trunk or latest version - e.g. http://svn.mymodule.com/svn/trunk/')); $fields->push(new TextField('GitURL', 'GIT repository - e.g. https://github.com/my-github-username/silverstripe-my-module')); $fields->push(new TextField('OtherURL', 'Link to other repository or download URL - e.g. http://www.mymodule.com/downloads/')); $fields->push(new CheckboxSetField('EcommerceProductTags', 'Tags', EcommerceProductTag::get()->map()->toArray())); $member = Member::currentUser(); if ($member->inGroup("ADMIN")) { $fields->push(new CheckboxSetField('Authors', 'Author(s)', Member::get()->exclude("Email", "")->map("ID", "Email")->toArray())); $fields->push(new DropdownField('ParentID', 'Move to', ProductGroup::get()->map()->toArray())); $fields->push(new CheckboxField('ShowInMenus', 'Show in menus (unticking both boxes here will hide the module)')); $fields->push(new CheckboxField('ShowInSearch', 'Show in search (unticking both boxes here will hide the module)')); } else { $fields->push(new HiddenField('ShowInMenus', '', 0)); $fields->push(new HiddenField('ShowInSearch', '', 0)); $fields->push(new HiddenField('ParentID', '', $controller->dataRecord->ID)); if ($moduleProduct) { $moduleProduct->ParentID = $controller->dataRecord->ID; $moduleProduct->ShowInSearch = 0; $moduleProduct->ShowInMenus = 0; } } if ($moduleProduct && $moduleProduct->canEdit()) { if ($authors = $moduleProduct->Authors()) { $authorsIDArray = $authors->map("ID", "ID")->toArray(); $authorsIDArray[0] = 0; $fields->push($this->ManyManyComplexTableFieldAuthorsField($controller, $authorsIDArray)); //$controller, $name, $sourceClass, $fieldList = null, $detailFormFields = null, $sourceFilter = "", $sourceSort = "", $sourceJoin = "" } } $actions = new FieldList(new FormAction("submit", "submit")); $validator = new AddingModuleProduct_RequiredFields($moduleProductID, array('Code', 'Name', 'ParentID', 'MainURL')); parent::__construct($controller, $name, $fields, $actions, $validator); if ($moduleProduct) { $this->loadDataFrom($moduleProduct); } return $this; }