function updateCMSFields(FieldList $fields) { $individualPageNoteWith = _t("ShareThis.INDIVIDUAL_PAGE_NOTE_WITH", " (with the ability to turn them off/on on individual pages) "); $individualPageNoteWithout = _t("ShareThis.INDIVIDUAL_PAGE_NOTE_WITHOUT", " (without the ability to turn them off/on on individual pages) "); $shareThisExtra = '<h3 style="margin-top: 50px">Select Icons</h3>'; /* if($this->CanEditShareIcons()) { $addedLinks = array(); $obj = singleton('ShareThisDataObject'); $addedLinksShort['edit'] = DataObjectOneFieldUpdateController::popup_link('ShareThisDataObject', 'IncludeThisIcon'); $addedLinksLong['edit'] = DataObjectOneFieldUpdateController::popup_link('ShareThisDataObject', 'IncludeThisIconInExtendedList'); $addedLinksShort['sort'] = $obj->dataObjectSorterPopupLink('IncludeThisIcon', 1); $addedLinksLong['sort'] = $obj->dataObjectSorterPopupLink('IncludeThisIconInExtendedList', 1); if(count($addedLinksShort)) { $shareThisExtra .= '<p>main list: ' . implode(', ', $addedLinksShort) . '.</p>'; } if(count($addedLinksLong)) { $shareThisExtra .= '<p>long list: ' . implode(', ', $addedLinksLong) . '.</p>'; } } */ $shareThisTableField = new GridField('Share this options', null, ShareThisDataObject::get(), GridFieldConfig_RecordEditor::create()); //$shareThisTableField->setPermissions(array("edit", "add")); $socialNetworkExtra = '<h3 style="margin-top: 50px">Add / Edit / Delete Your Social Networking Home Pages (e.g. www.facebook.com/our-company-page)</h3>'; $socialNetworkTableField = new GridField('Join Us', null, SocialNetworkingLinksDataObject::get(), GridFieldConfig_RecordEditor::create()); //$socialNetworkTableField->setPermissions(array("edit", "add", "delete", "view")); if ($this->owner->AlwaysIncludeShareThisLinks) { $defaultShareThisCheckbox = new HiddenField('IncludeByDefaultShareThisLinks', true); } else { $defaultShareThisCheckbox = new CheckboxField('IncludeByDefaultShareThisLinks', 'Show links on every page by default ' . $individualPageNoteWith); } if ($this->owner->AlwaysIncludeSocialNetworkingLinks) { $defaultSocialNetworkingCheckbox = new HiddenField('IncludeByDefaultSocialNetworkingLinks', true); } else { $defaultSocialNetworkingCheckbox = new CheckboxField('IncludeByDefaultSocialNetworkingLinks', 'Include on every page by default ' . $individualPageNoteWith); } $fields->addFieldToTab('Root.SocialMedia', new TabSet('SocialNetworkingOptions', new Tab('ShareThis', new CheckboxField('AlwaysIncludeShareThisLinks', 'Show links on every page ' . $individualPageNoteWithout), $defaultShareThisCheckbox, new CheckboxField('ShareThisAllInOne', 'Add a \'share\' all-in-one button'), new LiteralField('shareThisExtra', $shareThisExtra), $shareThisTableField), new Tab('JoinUs', new CheckboxField('AlwaysIncludeSocialNetworkingLinks', 'Show links on every page ' . $individualPageNoteWithout), $defaultSocialNetworkingCheckbox, new LiteralField('socialNetworkExtra', $socialNetworkExtra), $socialNetworkTableField))); return $fields; }
function requireDefaultRecords() { parent::requireDefaultRecords(); $actualArray = ShareThisOptions::get_general_data(); Config::inst()->update("ShareThisSTE", "included_icons", array()); Config::inst()->update("ShareThisSTE", "excluded_icons", array()); ShareThisOptions::set_general_data(null); $fullArray = ShareThisOptions::get_general_data(); foreach ($fullArray as $key) { $object = ShareThisDataObject::get()->filter('Title', $key); if (!$object->exists()) { $object = new ShareThisDataObject(); $object->Title = $key; $style = 'excluded'; $object->IncludeThisIcon = false; if (in_array($key, $actualArray)) { $object->IncludeThisIcon = true; $style = 'included'; } $object->write(); DB::alteration_message("Added Bookmark Icon for {$key} ({$style})", 'created'); } } $inc = Config::inst()->get("ShareThisSTE", "included_icons"); foreach ($inc as $key) { $object = ShareThisDataObject::get()->filter(array('Title' => $key, 'IncludeThisIcon' => 0)); if ($object->exists()) { $object = $object->first(); $object->IncludeThisIcon = true; $object->write(); DB::alteration_message("Updated inclusion for {$key}", 'created'); } } $exc = Config::inst()->get("ShareThisSTE", "excluded_icons"); foreach ($exc as $key) { $object = ShareThisDataObject::get()->filter(array('Title' => $key, 'IncludeThisIcon' => 1)); if ($object->exists()) { $object = $object->first(); $object->IncludeThisIcon = false; $object->write(); DB::alteration_message("Updated inclusion for {$key}", 'created'); } } }
protected function makeBookmarks($field) { $finalBookmarks = array(); $bookmarks = ShareThisOptions::get_page_specific_data($this->owner->Title, $this->owner->Link(), $this->owner->MetaDescription); $objects = ShareThisDataObject::get()->filter($field, 1)->sort(array('Sort' => 'ASC', 'Title' => 'ASC')); if ($objects->count()) { foreach ($objects as $obj) { if (isset($bookmarks[$obj->Title])) { $finalBookmarks[$obj->Title] = $bookmarks[$obj->Title]; if ($obj->AlternativeIconID && $obj->AlternativeIcon()->exists()) { $finalBookmarks[$obj->Title]['icon'] = $obj->AlternativeIcon()->Link(); } } } } else { $finalBookmarks = $bookmarks; } return $finalBookmarks; }