示例#1
0
文件: Page.php 项目: peteryu1/october
 /**
  * Creates an instance of the object and associates it with a CMS theme.
  * @param \Cms\Classes\Theme $theme Specifies the theme the object belongs to.
  */
 public function __construct(Theme $theme = null)
 {
     parent::__construct($theme);
     $this->settingsValidationMessages = ['url.regex' => Lang::get('cms::lang.page.invalid_url')];
 }
示例#2
0
 public function onSave()
 {
     $this->validateRequestTheme();
     $type = Request::input('templateType');
     $templatePath = trim(Request::input('templatePath'));
     $template = $templatePath ? $this->loadTemplate($type, $templatePath) : $this->createTemplate($type);
     $settings = Request::input('settings') ?: [];
     $settings = $this->upgradeSettings($settings);
     $templateData = [];
     if ($settings) {
         $templateData['settings'] = $settings;
     }
     $fields = ['markup', 'code', 'fileName', 'content'];
     foreach ($fields as $field) {
         if (array_key_exists($field, $_POST)) {
             $templateData[$field] = Request::input($field);
         }
     }
     if (!empty($templateData['markup']) && Config::get('cms.convertLineEndings', false) === true) {
         $templateData['markup'] = $this->convertLineEndings($templateData['markup']);
     }
     if (!Request::input('templateForceSave') && $template->mtime) {
         if (Request::input('templateMtime') != $template->mtime) {
             throw new ApplicationException('mtime-mismatch');
         }
     }
     $template->fill($templateData);
     $template->save();
     /*
      * Extensibility
      */
     Event::fire('cms.template.save', [$this, $template, $type]);
     $this->fireEvent('template.save', [$template, $type]);
     Flash::success(Lang::get('cms::lang.template.saved'));
     $result = ['templatePath' => $template->fileName, 'templateMtime' => $template->mtime, 'tabTitle' => $this->getTabTitle($type, $template)];
     if ($type == 'page') {
         $result['pageUrl'] = URL::to($template->url);
         $router = new Router($this->theme);
         $router->clearCache();
         CmsCompoundObject::clearCache($this->theme);
     }
     return $result;
 }
示例#3
0
文件: Content.php 项目: nnmer/october
 /**
  * Initializes a cache item.
  * @param array &$item The cached item array.
  */
 protected function initCacheItem(&$item)
 {
     parent::initCacheItem($item);
     $item['parsed-markup'] = $this->parsedMarkup;
 }
示例#4
0
 /**
  * Creates the class instance
  * @param \Cms\Classes\CmsCompoundObject A reference to a CMS object to parse.
  */
 public function __construct(CmsCompoundObject $object)
 {
     $this->object = $object;
     $this->filePath = $object->getFullPath();
 }
示例#5
0
 /**
  * Creates an instance of the object and associates it with a CMS theme.
  * @param array $attributes
  */
 public function __construct(array $attributes = [])
 {
     parent::__construct($attributes);
     $this->customMessages = ['url.regex' => Lang::get('cms::lang.page.invalid_url')];
 }