Subversion Repositories oidplus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
226 daniel-mar 1
<?php
2
 
3
# if (!interface_exists('OIDPlusFieldExtenders')) throw new Exception('Required interface "OIDPlusFieldExtenders" not found.');
4
# if (!class_exists('OIDPlus')) throw new Exception('Required class "OIDPlus" not found.');
5
 
6
require_once __DIR__ . '/../../core/OIDPlusFieldExtenders.class.php';
7
 
8
class OIDDepthFieldExtender implements OIDPlusFieldExtenders {
9
        public static function processOID($oid, &$out, &$oidplusobj) {
10
                $out[] = 'oid-depth:'.self::oid_depth($oid);
11
        }
12
 
13
        protected static function oid_depth($oid) {
14
                # TODO: in oid_utils hinzufügen
15
                if ($oid == '.') return 0;
16
                if ($oid[0] != '.') $oid = ".$oid";
17
                return substr_count($oid, '.');
18
        }
19
}
20
 
21
require_once __DIR__ . '/../../core/2_OIDPlus.class.php';
22
OIDPlus::registerFieldExtender(new OIDDepthFieldExtender());