当前位置: 首页>>代码示例>>PHP>>正文


PHP Page::validate方法代码示例

本文整理汇总了PHP中Grav\Common\Page\Page::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::validate方法的具体用法?PHP Page::validate怎么用?PHP Page::validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Grav\Common\Page\Page的用法示例。


在下文中一共展示了Page::validate方法的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;
 }
开发者ID:clee03,项目名称:metal,代码行数:50,代码来源:controller.php

示例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;
 }
开发者ID:getgrav,项目名称:grav-plugin-admin,代码行数:37,代码来源:admincontroller.php


注:本文中的Grav\Common\Page\Page::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。