1: <?php
2:
3: /*
4: * The MIT License (MIT)
5: *
6: * Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
7: *
8: * Permission is hereby granted, free of charge, to any person obtaining a copy of
9: * this software and associated documentation files (the "Software"), to deal in
10: * the Software without restriction, including without limitation the rights to
11: * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
12: * the Software, and to permit persons to whom the Software is furnished to do so,
13: * subject to the following conditions:
14: *
15: * The above copyright notice and this permission notice shall be included in all
16: * copies or substantial portions of the Software.
17: *
18: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20: * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21: * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22: * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23: * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24: */
25:
26: namespace Kint\Renderer\Rich;
27:
28: use Kint\Object\BasicObject;
29: use Kint\Renderer\RichRenderer;
30:
31: abstract class Plugin implements PluginInterface
32: {
33: protected $renderer;
34:
35: public function __construct(RichRenderer $r)
36: {
37: $this->renderer = $r;
38: }
39:
40: /**
41: * Renders a locked header.
42: *
43: * @param BasicObject $o
44: * @param string $content
45: */
46: public function renderLockedHeader(BasicObject $o, $content)
47: {
48: $header = '<dt class="kint-parent kint-locked">';
49:
50: if (RichRenderer::$access_paths && $o->depth > 0 && $ap = $o->getAccessPath()) {
51: $header .= '<span class="kint-access-path-trigger" title="Show access path">&rlarr;</span>';
52: }
53:
54: $header .= '<span class="kint-popup-trigger" title="Open in new window">&boxbox;</span><nav></nav>';
55:
56: if (null !== ($s = $o->getModifiers())) {
57: $header .= '<var>'.$s.'</var> ';
58: }
59:
60: if (null !== ($s = $o->getName())) {
61: $header .= '<dfn>'.$this->renderer->escape($s).'</dfn> ';
62:
63: if ($s = $o->getOperator()) {
64: $header .= $this->renderer->escape($s, 'ASCII').' ';
65: }
66: }
67:
68: if (null !== ($s = $o->getType())) {
69: $s = $this->renderer->escape($s);
70:
71: if ($o->reference) {
72: $s = '&amp;'.$s;
73: }
74:
75: $header .= '<var>'.$s.'</var> ';
76: }
77:
78: if (null !== ($s = $o->getSize())) {
79: $header .= '('.$this->renderer->escape($s).') ';
80: }
81:
82: $header .= $content;
83:
84: if (!empty($ap)) {
85: $header .= '<div class="access-path">'.$this->renderer->escape($ap).'</div>';
86: }
87:
88: return $header.'</dt>';
89: }
90: }
91: