本文整理汇总了PHP中Page::onAfterWrite方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::onAfterWrite方法的具体用法?PHP Page::onAfterWrite怎么用?PHP Page::onAfterWrite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Page
的用法示例。
在下文中一共展示了Page::onAfterWrite方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onAfterWrite
public function onAfterWrite()
{
parent::onAfterWrite();
if ($this->isInsert) {
$blog = new BlogHolder();
$blog->ParentID = $this->ID;
$blog->Title = "News";
$blog->ShowInMenus = false;
$blog->write();
$blog->publish('Stage', 'Live');
$calendar = new Calendar();
$calendar->ParentID = $this->ID;
$calendar->Title = "Calendar";
$calendar->ShowInMenus = false;
$calendar->write();
$calendar->publish('Stage', 'Live');
$leaders = new ScoutGroupLeaders();
$leaders->ParentID = $this->ID;
$leaders->Title = "Leaders";
$leaders->ShowInMenus = false;
$leaders->write();
$leaders->publish('Stage', 'Live');
}
$this->isInsert = false;
}
示例2: onAfterWrite
function onAfterWrite()
{
if ($this->ID) {
$this->checkFolder();
}
parent::onAfterWrite();
}
示例3: onAfterWrite
/**
* Updates the Image.ExifDate database column of image objects when page is saved
*
* @return void
*/
function onAfterWrite()
{
parent::onAfterWrite();
// update Image.ExifDate database fields of all images assigned to actual page if image sort option is set "4:ExifDate"
// Todo: execute DB update on URL request instead page write to avoid timing issues when dealing with lots of big images
if (cwsFolderGalleryPage_Controller::getImageSortOption() == "ExifDate") {
cwsFolderGalleryImageExtension::writeExifDates($this->AlbumFolderID);
}
}
示例4: onAfterWrite
function onAfterWrite()
{
parent::onAfterWrite();
$path = Director::baseFolder() . "/.htaccess";
$curr_data = @file($path);
//Silverstripe is bad and should feel bad
$page = DataObject::get_by_id('BlogPage', $this->ID, false);
$extra = $page->BlogURL ? "RewriteCond %{REQUEST_URI} !^/" . $page->BlogURL : "";
$new_file = array();
// first remove any blog redirect already in the file
$remove_keys = array();
foreach ($curr_data as $key => $line) {
if (trim($line) == "### Blog Redirect ###") {
$remove_keys[] = $key;
$remove_keys[] = $key + 1;
}
}
foreach ($remove_keys as $key) {
unset($curr_data[$key]);
}
$ss_line = 0;
foreach ($curr_data as $line) {
if (trim($line) == "### SILVERSTRIPE START ###") {
$start = true;
}
if ($start && trim($line) == "RewriteCond %{REQUEST_FILENAME} !-f") {
$inside = true;
}
if (trim($line) == "### SILVERSTRIPE END ###") {
$inside = false;
}
if ($inside) {
$new_file[] = trim("### Blog Redirect ###");
$new_file[] = trim($extra);
$inside = false;
}
$new_file[] = trim($line);
}
$h = @fopen($path, "w");
fwrite($h, implode("\n", $new_file));
@fclose($h);
}
示例5: onAfterWrite
public function onAfterWrite()
{
if ($this->isChanged('ID')) {
$section = new MemberProfileFieldsSection();
$section->ParentID = $this->ID;
$section->write();
}
parent::onAfterWrite();
}
示例6: onAfterWrite
/**
* {@inheritdoc}
*
* Sets blog relationship on all categories and tags assigned to this post.
*/
public function onAfterWrite()
{
parent::onAfterWrite();
foreach ($this->Categories() as $category) {
/**
* @var BlogCategory $category
*/
$category->BlogID = $this->ParentID;
$category->write();
}
foreach ($this->Tags() as $tag) {
/**
* @var BlogTag $tag
*/
$tag->BlogID = $this->ParentID;
$tag->write();
}
}
示例7: onAfterWrite
public function onAfterWrite()
{
Multisites::inst()->build();
parent::onAfterWrite();
}
示例8: onAfterWrite
public function onAfterWrite()
{
parent::onAfterWrite();
// Don't do this stuff when we're publishing
if (!$this->extension_instances['Versioned']->migratingVersion) {
if ($this->isChanged('CopyContentFromID') && $this->CopyContentFromID != 0 && $this instanceof VirtualPage) {
$this->updateImageTracking();
}
}
// Check if page type has changed to a non-virtual page.
// Caution: Relies on the fact that the current instance is still of the old page type.
if ($this->isChanged('ClassName', 2)) {
$changed = $this->getChangedFields();
$classBefore = $changed['ClassName']['before'];
$classAfter = $changed['ClassName']['after'];
if ($classBefore != $classAfter) {
// Remove all database rows for the old page type to avoid inconsistent data retrieval.
// TODO This should apply to all page type changes, not only on VirtualPage - but needs
// more comprehensive testing as its a destructive operation
$removedTables = array_diff(ClassInfo::dataClassesFor($classBefore), ClassInfo::dataClassesFor($classAfter));
if ($removedTables) {
foreach ($removedTables as $removedTable) {
// Note: *_versions records are left intact
foreach (array('', 'Live') as $stage) {
if ($stage) {
$removedTable = "{$removedTable}_{$stage}";
}
DB::prepared_query("DELETE FROM \"{$removedTable}\" WHERE \"ID\" = ?", array($this->ID));
}
}
}
// Also publish the change immediately to avoid inconsistent behaviour between
// a non-virtual draft and a virtual live record (e.g. republishing the original record
// shouldn't republish the - now unrelated - changes on the ex-VirtualPage draft).
// Copies all stage fields to live as well.
// @todo Update get_one to support parameterised queries
$source = DataObject::get_by_id("SiteTree", $this->CopyContentFromID);
$this->copyFrom($source);
$this->publish('Stage', 'Live');
// Change reference on instance (as well as removing the underlying database tables)
$this->CopyContentFromID = 0;
}
}
}
示例9: onAfterWrite
function onAfterWrite()
{
parent::onAfterWrite();
// Don't do this stuff when we're publishing
if (!$this->extension_instances['Versioned']->migratingVersion) {
if ($this->isChanged('CopyContentFromID') && $this->CopyContentFromID != 0 && $this instanceof VirtualPage) {
$this->updateImageTracking();
}
}
}
示例10: onAfterWrite
/**
* (non-PHPdoc)
*
* @see SiteTree::onBeforeWrite()
*/
public function onAfterWrite()
{
parent::onAfterWrite();
// Skip on publishing
if (Versioned::get_live_stage() == Versioned::current_stage()) {
return;
}
// Update the values of all fields added from editable field
if ($this->ID && $this->many_many('Fields') && ($pageFields = $this->getEditableFields())) {
foreach ($pageFields as $pageField) {
// Set submitted value into the field
$field = $pageField->getFormField();
if (!$field) {
continue;
}
$field->setValue($this->{$pageField->Name});
// Extra fields to be saved
$value = $field->Value();
$sort = $pageField->Sort;
$group = $pageField->Group;
// Clone the editable field object
// Remove the current saved one
$pageFields->remove($pageField);
// Add the clone with the new extra data
$pageFields->add($pageField, ['Value' => $value, 'Sort' => $sort, 'Group' => $group]);
}
}
}
示例11: onAfterWrite
function onAfterWrite()
{
parent::onAfterWrite();
$this->RetrieveCampaigns();
}
示例12: onAfterWrite
public function onAfterWrite()
{
$this->addMemberAccountFields($this);
parent::onAfterWrite();
}
示例13: onAfterWrite
function onAfterWrite()
{
parent::onAfterWrite();
// Don't do this stuff when we're publishing
if (!$this->extension_instances['Versioned']->migratingVersion) {
if ($this->isChanged('CopyContentFromID') && $this->CopyContentFromID != 0 && $this instanceof VirtualPage) {
$this->updateImageTracking();
}
}
FormResponse::add("\$('Form_EditForm').reloadIfSetTo({$this->ID});", $this->ID . "_VirtualPage_onAfterWrite");
}
示例14: onAfterWrite
function onAfterWrite()
{
parent::onAfterWrite();
if ($this->ImageID) {
if ($normalImage = Image::get()->exclude(array("ClassName" => "Product_Image"))->byID($this->ImageID)) {
$normalImage = $normalImage->newClassInstance("Product_Image");
$normalImage->write();
}
}
}
示例15: onAfterWrite
function onAfterWrite()
{
parent::onAfterWrite();
// Update TreePosition for all children
$this->updateChildTreePositions(false);
}