PluginProbe
Depicter — Popup & Slider Builder / trunk
Depicter — Popup & Slider Builder vtrunk
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / Front / Symbols.php

Symbols.php in Depicter — Popup & Slider Builder trunk, at app/src/Front/Symbols.php

76 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Depicter\Front;
3
4
5 use Depicter\Html\Html;
6
7 class Symbols
8 {
9
10 private $symbols = [];
11
12 private $clipPathIDs = [];
13
14 /**
15 * Add symbol id to symbols list
16 *
17 * @param string $symbolID
18 * @return void
19 */
20 public function add( $symbolID ) {
21 if ( !in_array( $symbolID, $this->symbols ) ) {
22 $this->symbols[] = $symbolID;
23 }
24 }
25
26 /**
27 * Add symbol id to symbols list
28 *
29 * @param string $symbolID
30 * @return void
31 */
32 public function addClipPath( $clipPathID ) {
33 if ( !in_array( $clipPathID, $this->clipPathIDs ) ) {
34 $this->clipPathIDs[] = $clipPathID;
35 }
36 }
37
38 /**
39 * Render registered svg symbols
40 *
41 * @return string|\TypeRocket\Html\Html
42 */
43 public function render() {
44 $symbolsContent = '';
45
46 $clipPathContent = '';
47 if ( !empty( $this->symbols ) ) {
48 foreach ( $this->symbols as $key => $symbolID ) {
49 if ( file_exists( DEPICTER_PLUGIN_PATH .'/resources/scripts/svg-symbols/' . $symbolID . '.svg' ) ) {
50 $symbolsContent .= \Depicter::storage()->filesystem()->read( DEPICTER_PLUGIN_PATH .'/resources/scripts/svg-symbols/' . $symbolID . '.svg' );
51 }
52 }
53
54 $symbolsContent = Html::el('svg', [ 'xmlns' => "http://www.w3.org/2000/svg" ], $symbolsContent );
55 }
56
57 if ( !empty( $this->clipPathIDs ) ) {
58 foreach ( $this->clipPathIDs as $key => $clipPathID ) {
59 if ( file_exists( DEPICTER_PLUGIN_PATH .'/resources/scripts/svg-symbols/clipPaths/' . $clipPathID . '.svg' ) ) {
60 $clipPathContent .= \Depicter::storage()->filesystem()->read( DEPICTER_PLUGIN_PATH .'/resources/scripts/svg-symbols/clipPaths/' . $clipPathID . '.svg' ). "\n";
61 }
62 }
63
64 $clipPathContent = "\n" .Html::el('defs', [], "\n" . $clipPathContent );
65 $clipPathContent = Html::el('svg', [
66 //'xmlns' => "http://www.w3.org/2000/svg",
67 'width' => '0',
68 'height' => '0',
69 'class' => 'depicter-svg-clip-paths'
70 ], $clipPathContent . "\n" );
71 }
72
73 return $symbolsContent . "\n". $clipPathContent;
74 }
75 }
76