Subversion Repositories oidplus

Compare Revisions

No changes between revisions

Regard whitespace Rev 1117 → Rev 1118

/trunk/dev/box_texts/box_texts.psd
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/plugins/viathinksoft/language/dede/messages.xml
526,6 → 526,14
</message>
<message>
<source><![CDATA[
Append ".php" at the end to mark a node as leaf node (i.e. Interface/Class rather than Namespace)
]]></source>
<target><![CDATA[
Fügen Sie ".php" am Ende hinzu, damit das Objekt als PHP-Klasse oder -Interface gekennzeichnet wird.
]]></target>
</message>
<message>
<source><![CDATA[
Application Identifier (ISO/IEC 7816)
]]></source>
<target><![CDATA[
1518,6 → 1526,14
</message>
<message>
<source><![CDATA[
Currently, no PHP Namespace is registered in the system.
]]></source>
<target><![CDATA[
Derzeit sind keine PHP-Namensräume in diesem System registriert.
]]></target>
</message>
<message>
<source><![CDATA[
Currently, no misc. objects are registered in the system.
]]></source>
<target><![CDATA[
3870,6 → 3886,14
</message>
<message>
<source><![CDATA[
Namespace
]]></source>
<target><![CDATA[
Namensraum
]]></target>
</message>
<message>
<source><![CDATA[
Nested transactions are not supported by this database plugin.
]]></source>
<target><![CDATA[
4742,6 → 4766,14
</message>
<message>
<source><![CDATA[
PHP Namespaces
]]></source>
<target><![CDATA[
PHP-Namensräume
]]></target>
</message>
<message>
<source><![CDATA[
PHP configuration file(s)
]]></source>
<target><![CDATA[
5214,6 → 5246,14
</message>
<message>
<source><![CDATA[
Please select a PHP Namespace in the tree view at the left to show its contents.
]]></source>
<target><![CDATA[
Bitte selektieren Sie einen PHP-Namensraum in der Baumansicht, um dessen Inhalt anzuzeigen.
]]></target>
</message>
<message>
<source><![CDATA[
Please select a network block in the tree view at the left to show its contents.
]]></source>
<target><![CDATA[
/trunk/plugins/viathinksoft/objectTypes/java/OIDplusJava.class.php
123,8 → 123,12
*/
public function jsTreeNodeName(OIDplusObject $parent = null): string {
if ($parent == null) return $this->objectTypeTitle();
return $this->java;
if ($parent->isRoot()) {
return substr($this->nodeId(), strlen($parent->nodeId()));
} else {
return substr($this->nodeId(), strlen($parent->nodeId())+1);
}
}
 
/**
* @return string
/trunk/plugins/viathinksoft/objectTypes/php/OIDplusObjectTypePluginPhp.class.php
0,0 → 1,35
<?php
 
/*
* OIDplus 2.0
* Copyright 2019 - 2023 Daniel Marschall, ViaThinkSoft
*
* 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 ViaThinkSoft\OIDplus;
 
// phpcs:disable PSR1.Files.SideEffects
\defined('INSIDE_OIDPLUS') or die;
// phpcs:enable PSR1.Files.SideEffects
 
class OIDplusObjectTypePluginPhp extends OIDplusObjectTypePlugin {
 
/**
* @return string
*/
public static function getObjectTypeClassName(): string {
return OIDplusPhp::class;
}
 
}
/trunk/plugins/viathinksoft/objectTypes/php/OIDplusPhp.class.php
0,0 → 1,277
<?php
 
/*
* OIDplus 2.0
* Copyright 2019 - 2023 Daniel Marschall, ViaThinkSoft
*
* 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 ViaThinkSoft\OIDplus;
 
// phpcs:disable PSR1.Files.SideEffects
\defined('INSIDE_OIDPLUS') or die;
// phpcs:enable PSR1.Files.SideEffects
 
class OIDplusPhp extends OIDplusObject {
private $php;
 
/**
* @param $php
*/
public function __construct($php) {
// TODO: syntax checks
$this->php = $php;
}
 
/**
* @param string $node_id
* @return OIDplusPhp|null
*/
public static function parse(string $node_id)/*: ?OIDplusPhp*/ {
@list($namespace, $php) = explode(':', $node_id, 2);
if ($namespace !== self::ns()) return null;
return new self($php);
}
 
/**
* @return string
*/
public static function objectTypeTitle(): string {
return _L('PHP Namespaces');
}
 
/**
* @return string
*/
public static function objectTypeTitleShort(): string {
return _L('Namespace');
}
 
/**
* @return string
*/
public static function ns(): string {
return 'php';
}
 
/**
* @return string
*/
public static function root(): string {
return self::ns().':';
}
 
/**
* @return bool
*/
public function isRoot(): bool {
return $this->php == '';
}
 
/**
* @param bool $with_ns
* @return string
*/
public function nodeId(bool $with_ns=true): string {
return $with_ns ? self::root().$this->php : $this->php;
}
 
/**
* @param string $str
* @return string
* @throws OIDplusException
*/
public function addString(string $str): string {
if ($this->isRoot()) {
$str = ltrim($str,'\\');
return self::root().$str;
} else {
if (strpos($str,'\\') !== false) throw new OIDplusException(_L('Please only submit one arc.'));
return $this->nodeId() . '\\' . $str;
}
}
 
/**
* @param OIDplusObject $parent
* @return string
*/
public function crudShowId(OIDplusObject $parent): string {
return $this->php;
}
 
/**
* @return string
* @throws OIDplusException
*/
public function crudInsertPrefix(): string {
return $this->isRoot() ? '' : substr($this->addString(''), strlen(self::ns())+1);
}
 
/**
* @param OIDplusObject|null $parent
* @return string
*/
public function jsTreeNodeName(OIDplusObject $parent = null): string {
if ($parent == null) return $this->objectTypeTitle();
if ($parent->isRoot()) {
return substr($this->nodeId(), strlen($parent->nodeId()));
} else {
return substr($this->nodeId(), strlen($parent->nodeId())+1);
}
}
 
/**
* @return string
*/
public function defaultTitle(): string {
return $this->php;
}
 
/**
* @return bool
*/
public function isLeafNode(): bool {
return substr($this->php, -4) === '.php';
}
 
/**
* @param string $title
* @param string $content
* @param string $icon
* @return void
* @throws OIDplusException
*/
public function getContentPage(string &$title, string &$content, string &$icon) {
$icon = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
 
if ($this->isRoot()) {
$title = OIDplusPhp::objectTypeTitle();
 
$res = OIDplus::db()->query("select * from ###objects where parent = ?", array(self::root()));
if ($res->any()) {
$content = '<p>'._L('Please select a PHP Namespace in the tree view at the left to show its contents.').'</p>';
} else {
$content = '<p>'._L('Currently, no PHP Namespace is registered in the system.').'</p>';
}
 
if (!$this->isLeafNode()) {
if (OIDplus::authUtils()->isAdminLoggedIn()) {
$content .= '<h2>'._L('Manage root objects').'</h2>';
} else {
$content .= '<h2>'._L('Available objects').'</h2>';
}
$content .= '%%CRUD%%';
}
} else {
$title = $this->getTitle();
 
$content = '<h3>'.explode(':',$this->nodeId())[1].'</h3>';
 
$content .= '<h2>'._L('Description').'</h2>%%DESC%%'; // TODO: add more meta information about the object type
 
if (OIDplus::baseConfig()->getValue('PLUGIN_PHP_TYPE_LINK_TO_WEBFAN', false)) {
$content .= '<p><strong><a webfan-php-class-link="'.$this->nodeId(false).'" href="https://webfan.de/install/?source='.urlencode($this->nodeId(false)).'" target="_blank">Soure Code</a></strong></p>';
}
 
if (!$this->isLeafNode()) {
if ($this->userHasWriteRights()) {
$content .= '<h2>'._L('Create or change subordinate objects').'</h2>';
$content .= '<p>'._L('Append ".php" at the end to mark a node as leaf node (i.e. Interface/Class rather than Namespace)').'</p>';
} else {
$content .= '<h2>'._L('Subordinate objects').'</h2>';
}
$content .= '%%CRUD%%';
}
}
}
 
/**
* @param array|null $row
* @return string|null
* @throws OIDplusException
*/
public function getIcon(array $row=null) {
$in_login_treenode = false;
foreach (debug_backtrace() as $trace) {
// If we are inside the "Login" area (i.e. "Root object links"), we want the
// correct icon, not a folder icon!
if ($trace['class'] === OIDplusPagePublicLogin::class) $in_login_treenode = true;
}
 
if (!$in_login_treenode && !$this->isLeafNode()) return null; // foldericon
 
return parent::getIcon($row);
}
 
/**
* @return OIDplusPhp|null
*/
public function one_up()/*: ?OIDplusPhp*/ {
$oid = $this->php;
 
$p = strrpos($oid, '\\');
if ($p === false) return self::parse($oid);
if ($p == 0) return self::parse('\\');
 
$oid_up = substr($oid, 0, $p);
 
return self::parse(self::ns().':'.$oid_up);
}
 
/**
* @param $to
* @return int|null
*/
public function distance($to) {
if (!is_object($to)) $to = OIDplusObject::parse($to);
if (!($to instanceof $this)) return null;
 
$a = $to->php;
$b = $this->php;
 
if (substr($a,0,1) == '\\') $a = substr($a,1);
if (substr($b,0,1) == '\\') $b = substr($b,1);
 
$ary = explode('\\', $a);
$bry = explode('\\', $b);
 
$min_len = min(count($ary), count($bry));
 
for ($i=0; $i<$min_len; $i++) {
if ($ary[$i] != $bry[$i]) return null;
}
 
return count($ary) - count($bry);
}
 
/**
* @return string
*/
public function getDirectoryName(): string {
if ($this->isRoot()) return $this->ns();
if (OIDplus::baseConfig()->getValue('PLUGIN_PHP_TYPE_LINK_TO_WEBFAN', false)) {
return $this->ns().str_replace(['\\', "/"], [\DIRECTORY_SEPARATOR, \DIRECTORY_SEPARATOR], $this->nodeId(false));
} else {
return $this->ns().'_'.md5($this->nodeId(false));
}
}
 
/**
* @param string $mode
* @return string
*/
public static function treeIconFilename(string $mode): string {
return 'img/'.$mode.'_icon16.png';
}
}
/trunk/plugins/viathinksoft/objectTypes/php/img/general_icon16.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/plugins/viathinksoft/objectTypes/php/img/index.html
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/plugins/viathinksoft/objectTypes/php/img/main_icon.png
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/plugins/viathinksoft/objectTypes/php/img/own_icon16.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/plugins/viathinksoft/objectTypes/php/img/root_icon16.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/plugins/viathinksoft/objectTypes/php/index.html
--- trunk/plugins/viathinksoft/objectTypes/php/manifest.xml (nonexistent)
+++ trunk/plugins/viathinksoft/objectTypes/php/manifest.xml (revision 1118)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<manifest
+ xmlns="urn:oid:1.3.6.1.4.1.37476.2.5.2.5.10.1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:oid:1.3.6.1.4.1.37476.2.5.2.5.10.1 https://oidplus.viathinksoft.com/oidplus/plugins/manifest_plugin_objectTypes.xsd">
+
+ <type>ViaThinkSoft\OIDplus\OIDplusObjectTypePlugin</type>
+
+ <info>
+ <name>PHP Namespaces</name>
+ <author>ViaThinkSoft</author>
+ <license>Apache 2.0</license>
+ <version />
+ <descriptionHTML />
+ <oid>1.3.6.1.4.1.37476.2.5.2.4.8.12</oid>
+ </info>
+
+ <php>
+ <mainclass>ViaThinkSoft\OIDplus\OIDplusObjectTypePluginPhp</mainclass>
+ </php>
+
+</manifest>