本文整理汇总了PHP中Grav\Common\Page\Page::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::filter方法的具体用法?PHP Page::filter怎么用?PHP Page::filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grav\Common\Page\Page
的用法示例。
在下文中一共展示了Page::filter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: taskSaveas
/**
* Save the current page in a different language. Automatically switches to that language.
*
* @return bool True if the action was performed.
*/
protected function taskSaveas()
{
if (!$this->authorizeTask('save', $this->dataPermissions())) {
return;
}
// $reorder = false;
$data = $this->post;
$language = $data['lang'];
if ($language) {
$this->grav['session']->admin_lang = $language ?: 'en';
}
// /** @var Page\Pages $pages */
$pages = $this->grav['pages'];
$uri = $this->grav['uri'];
$obj = $this->admin->page($uri->route());
$this->preparePage($obj, false, $language);
$file = $obj->file();
if ($file) {
$filename = substr($obj->name(), 0, -strlen('.' . $language . '.md'));
if (substr($filename, -3, 1) == '.') {
if (substr($filename, -2) == substr($language, 0, 2)) {
$filename = str_replace(substr($filename, -2), $language, $filename);
}
} elseif (substr($filename, -6, 1) == '.') {
if (substr($filename, -5) == substr($language, 0, 5)) {
$filename = str_replace(substr($filename, -5), $language, $filename);
}
} else {
$filename .= '.' . $language;
}
$path = $obj->path() . DS . $filename . '.md';
$aFile = File::instance($path);
$aFile->save();
$aPage = new Page\Page();
$aPage->init(new \SplFileInfo($path), $language . '.md');
$aPage->header($obj->header());
$aPage->rawMarkdown($obj->rawMarkdown());
$aPage->validate();
$aPage->filter();
$aPage->save();
}
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.SUCCESSFULLY_SWITCHED_LANGUAGE'), 'info');
$this->setRedirect('/' . $language . $uri->route());
return true;
}
示例2: taskSaveas
/**
* Save the current page in a different language. Automatically switches to that language.
*
* @return bool True if the action was performed.
*/
protected function taskSaveas()
{
if (!$this->authorizeTask('save', $this->dataPermissions())) {
return false;
}
$data = (array) $this->data;
$language = $data['lang'];
if ($language) {
$this->grav['session']->admin_lang = $language ?: 'en';
}
$uri = $this->grav['uri'];
$obj = $this->admin->page($uri->route());
$this->preparePage($obj, false, $language);
$file = $obj->file();
if ($file) {
$filename = $this->determineFilenameIncludingLanguage($obj->name(), $language);
$path = $obj->path() . DS . $filename;
$aFile = File::instance($path);
$aFile->save();
$aPage = new Page();
$aPage->init(new \SplFileInfo($path), $language . '.md');
$aPage->header($obj->header());
$aPage->rawMarkdown($obj->rawMarkdown());
$aPage->validate();
$aPage->filter();
$aPage->save();
$this->grav->fireEvent('onAdminAfterSave', new Event(['page' => $obj]));
}
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.SUCCESSFULLY_SWITCHED_LANGUAGE'), 'info');
$this->setRedirect('/' . $language . $uri->route());
return true;
}