![]() |
CMSimple_XH
|
FileEditクラス階層 は、バックエンドのファイルの編集を処理します。 その実装は、 テンプレートメソッドパターンを頻繁に使用します 。
2つの主要なブランチはTextFileEdit と ArrayFileEdit です。
The FileEdit class hierarchie is responsible for the handling of the
editing of files in the back-end. Its implementation makes heavy use of
the template method pattern. The two main branches are TextFileEdit and ArrayFileEdit.
TextFileEdit のあらかじめ定義されたサブクラスは、テキストファイルの内容を編集するためのシンプルなテキストエリアを提供します
The predefined concrete subclasses of TextFileEdit offer a simple textarea to edit the content of a text file.
このブランチでは、データを格納するファイルを配列構造で編集できます。 定義済みのサブクラスは、コアとプラグインの構成オプションと言語文字列を格納するために使用される2次元のPHP配列を処理します。 生成されたフォームはカテゴリのオプションをグループ化します。 これらのオプションは、次のタイプを持つことができます。
これらのタイプは、ファイル metaconfig.php で指定できます。 例えば CMS設定のmetaconfig.php
This branch offers editing of files storing data in an array
structure. The predefined subclasses handle two- dimensional PHP arrays,
which are used to store the configuration options and language strings
of the core and plugins. The generated forms group the options in
categories. The options can have the following types, which can be
specified in a file metaconfig.php.
編集フォームを表示するには:: form()を呼び出す必要があります。 フォームのsubmission :: submit()を呼び出す必要があります。
例えば
To display the edit form ::form() has to be called; to handle the form submission ::submit() has to be called. For instance:
require_once $pth['folder']['classes'] . 'FileEdit.php'; $editor = new XH_CoreConfigFileEdit(); if ($save) { $o .= $editor->submit(); } else { $o .= $editor->form(); }
階層の適切なクラスを拡張することによって、オンラインで編集可能な他のフォーマットでも他のファイルを作成することが可能です。
例:
By
means of extending an appropriate class of the hierarchy, it is
possible to make other files even in other formats editable online. An
example:
require_once $pth['folder']['classes'] . 'FileEdit.php'; class MyTextFileEdit extends XH_TextFileEdit { function MyTextFileEdit() { $this->filename = 'path/of/the/file'; $this->params = array('what' => 'my_file', 'action' => 'save'); $this->redir = "?what=my_file&action=edit"; $this->textareaName = 'my_textarea'; parent::XH_TextFileEdit(); } } if (isset($_REQUEST['what']) && $_REQUEST['what'] == 'my_file') { $fileEditor = new MyTextFileEdit(); if ($_REQUEST['action'] == 'save') { $o .= $fileEditor->submit(); } else { $o .= $fileEditor->form(); } }