Skip to content

Instantly share code, notes, and snippets.

@thezenmonkey
Last active June 9, 2016 00:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thezenmonkey/36f1f6892efc08969712d68d3c5240f0 to your computer and use it in GitHub Desktop.
Save thezenmonkey/36f1f6892efc08969712d68d3c5240f0 to your computer and use it in GitHub Desktop.
Silverstripe CMS Batch Action to Create Translations for Translatable
<?php
class CMSBatchActions_TranslateTo extends CMSBatchAction {
public function getActionTitle() {
return _t('CMSBatchActions.TRANSLATETO', 'Translate to...');
}
public function run(SS_List $pages) {
$status = array(
'modified'=>array()
);
foreach($pages as $page) {
$id = $page->ID;
$status['modified'][$id] = array(
'TreeTitle' => $page->TreeTitle
);
}
return $this->response(_t('CMSBatchActions.Translated', 'Translation Create'), $status);
}
public function applicablePages($ids) {
return $this->applicablePagesHelper($ids, 'canEdit', false, true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment