mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-02-10 18:05:10 +08:00
php: views-classes added
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
"psr-4": {
|
||||
"OnlineEditorsExamplePhp\\" : "",
|
||||
"OnlineEditorsExamplePhp\\Helpers\\" : "helpers/",
|
||||
"OnlineEditorsExamplePhp\\Views\\" : "views/",
|
||||
"Firebase\\JWT\\" : "lib/jwt/"
|
||||
}
|
||||
}
|
||||
|
||||
26
web/documentserver-example/php/views/DocEditorView.php
Normal file
26
web/documentserver-example/php/views/DocEditorView.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* (c) Copyright Ascensio System SIA 2023
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace OnlineEditorsExamplePhp\Views;
|
||||
|
||||
final class DocEditorView extends View
|
||||
{
|
||||
public function __construct($tempName = "docEditor")
|
||||
{
|
||||
parent::__construct($tempName);
|
||||
}
|
||||
}
|
||||
26
web/documentserver-example/php/views/IndexView.php
Normal file
26
web/documentserver-example/php/views/IndexView.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* (c) Copyright Ascensio System SIA 2023
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace OnlineEditorsExamplePhp\Views;
|
||||
|
||||
final class IndexView extends View
|
||||
{
|
||||
public function __construct($tempName = "index")
|
||||
{
|
||||
parent::__construct($tempName);
|
||||
}
|
||||
}
|
||||
47
web/documentserver-example/php/views/View.php
Normal file
47
web/documentserver-example/php/views/View.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* (c) Copyright Ascensio System SIA 2023
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace OnlineEditorsExamplePhp\Views;
|
||||
|
||||
class View
|
||||
{
|
||||
private $template;
|
||||
|
||||
const TEMPNAMES = [
|
||||
"index" => "index",
|
||||
"docEditor" => "doceditor",
|
||||
];
|
||||
|
||||
public function __construct($tempName)
|
||||
{
|
||||
$pathToTemplate = "./templates/".self::TEMPNAMES[$tempName].".tpl";
|
||||
if (file_exists($pathToTemplate)) {
|
||||
$this->template = file_get_contents($pathToTemplate);
|
||||
} else {
|
||||
$this->template = "";
|
||||
}
|
||||
}
|
||||
|
||||
public function parseTemplate($tagsValues = [])
|
||||
{
|
||||
$parsedTemplate = $this->template;
|
||||
foreach ($tagsValues as $tag => $value) {
|
||||
$parsedTemplate = str_replace($tag, $value, $parsedTemplate);
|
||||
}
|
||||
return $parsedTemplate;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user