@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * WpShop Help bootstrap file |
@@ -8,17 +8,17 @@ discard block |
||
8 | 8 | * @subpackage modules |
9 | 9 | * |
10 | 10 | */ |
11 | -DEFINE( 'WPS_HELP_VERSION', '1.0.1' ); |
|
12 | -DEFINE( 'WPS_HELP_DIR', basename(dirname(__FILE__))); |
|
13 | -DEFINE( 'WPS_HELP_PATH', dirname( __FILE__ ) ); |
|
14 | -DEFINE( 'WPS_HELP_URL', str_replace( str_replace( "\\", "/", ABSPATH), site_url() . '/', str_replace( "\\", "/", WPS_HELP_PATH ) ) ); |
|
11 | +DEFINE('WPS_HELP_VERSION', '1.0.1'); |
|
12 | +DEFINE('WPS_HELP_DIR', basename(dirname(__FILE__))); |
|
13 | +DEFINE('WPS_HELP_PATH', dirname(__FILE__)); |
|
14 | +DEFINE('WPS_HELP_URL', str_replace(str_replace("\\", "/", ABSPATH), site_url() . '/', str_replace("\\", "/", WPS_HELP_PATH))); |
|
15 | 15 | |
16 | 16 | /** Define the templates directories */ |
17 | -DEFINE( 'WPS_HELP_TEMPLATES_MAIN_DIR', WPS_HELP_PATH . '/templates/'); |
|
17 | +DEFINE('WPS_HELP_TEMPLATES_MAIN_DIR', WPS_HELP_PATH . '/templates/'); |
|
18 | 18 | |
19 | -require_once( WPS_HELP_PATH . '/controller/wps_help_menus_ctr.php' ); |
|
20 | -require_once( WPS_HELP_PATH . '/controller/wps_help_bubble_ctr.php' ); |
|
21 | -require_once( WPS_HELP_PATH . '/controller/wps_help_tabs_ctr.php' ); |
|
19 | +require_once(WPS_HELP_PATH . '/controller/wps_help_menus_ctr.php'); |
|
20 | +require_once(WPS_HELP_PATH . '/controller/wps_help_bubble_ctr.php'); |
|
21 | +require_once(WPS_HELP_PATH . '/controller/wps_help_tabs_ctr.php'); |
|
22 | 22 | |
23 | 23 | /** Instanciate task management*/ |
24 | 24 | global $wps_help_menu; |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Fichier de définition du modèle des taxinomies / File for term model definition |
4 | 6 | * |
@@ -26,9 +26,9 @@ |
||
26 | 26 | } |
27 | 27 | |
28 | 28 | public function help_tab_static() |
29 | - { |
|
29 | + { |
|
30 | 30 | ob_start(); |
31 | - require( wpshop_tools::get_template_part( WPS_HELP_DIR, WPS_HELP_TEMPLATES_MAIN_DIR, "backend", "wps_tabs_static_tpl") ); |
|
31 | + require( wpshop_tools::get_template_part( WPS_HELP_DIR, WPS_HELP_TEMPLATES_MAIN_DIR, "backend", "wps_tabs_static_tpl") ); |
|
32 | 32 | $result .= ob_get_contents(); |
33 | 33 | ob_end_clean(); |
34 | 34 | return $result; |
@@ -1,25 +1,25 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | class wps_help_tabs_ctr |
3 | 3 | { |
4 | 4 | private $help_tabs; |
5 | 5 | |
6 | 6 | public function __construct() { |
7 | - add_action( "load-{$GLOBALS['pagenow']}", array( $this, 'create_help_tabs' ), 20 ); |
|
7 | + add_action("load-{$GLOBALS['pagenow']}", array($this, 'create_help_tabs'), 20); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | public function create_help_tabs() |
11 | 11 | { |
12 | - if( is_array( $this->help_tabs ) ) { |
|
12 | + if (is_array($this->help_tabs)) { |
|
13 | 13 | $screen = get_current_screen(); |
14 | - foreach ( $this->help_tabs as $id => $data ) |
|
14 | + foreach ($this->help_tabs as $id => $data) |
|
15 | 15 | { |
16 | - if( is_array($data['pages']) && in_array( $screen->id, $data['pages'] ) ) { |
|
17 | - $screen->add_help_tab( array( |
|
16 | + if (is_array($data['pages']) && in_array($screen->id, $data['pages'])) { |
|
17 | + $screen->add_help_tab(array( |
|
18 | 18 | 'id' => $id |
19 | 19 | ,'title' => $data['title'] |
20 | 20 | ,'content' => $this->help_tab_static() |
21 | - ,'callback' => array( $this, 'help_tab_content' ) |
|
22 | - ) ); |
|
21 | + ,'callback' => array($this, 'help_tab_content') |
|
22 | + )); |
|
23 | 23 | } |
24 | 24 | } |
25 | 25 | } |
@@ -28,23 +28,23 @@ discard block |
||
28 | 28 | public function help_tab_static() |
29 | 29 | { |
30 | 30 | ob_start(); |
31 | - require( wpshop_tools::get_template_part( WPS_HELP_DIR, WPS_HELP_TEMPLATES_MAIN_DIR, "backend", "wps_tabs_static_tpl") ); |
|
31 | + require(wpshop_tools::get_template_part(WPS_HELP_DIR, WPS_HELP_TEMPLATES_MAIN_DIR, "backend", "wps_tabs_static_tpl")); |
|
32 | 32 | $result .= ob_get_contents(); |
33 | 33 | ob_end_clean(); |
34 | 34 | return $result; |
35 | 35 | } |
36 | 36 | |
37 | - public function help_tab_content( $screen, $tab ) |
|
37 | + public function help_tab_content($screen, $tab) |
|
38 | 38 | { |
39 | 39 | $id = $tab['id']; |
40 | - $title = $tab['callback'][0]->help_tabs[ $tab['id'] ]['title']; |
|
41 | - $content = $tab['callback'][0]->help_tabs[ $tab['id'] ]['content']; |
|
42 | - $pages = $tab['callback'][0]->help_tabs[ $tab['id'] ]['pages']; |
|
43 | - require( wpshop_tools::get_template_part( WPS_HELP_DIR, WPS_HELP_TEMPLATES_MAIN_DIR, "backend", "wps_tab_content_tpl") ); |
|
40 | + $title = $tab['callback'][0]->help_tabs[$tab['id']]['title']; |
|
41 | + $content = $tab['callback'][0]->help_tabs[$tab['id']]['content']; |
|
42 | + $pages = $tab['callback'][0]->help_tabs[$tab['id']]['pages']; |
|
43 | + require(wpshop_tools::get_template_part(WPS_HELP_DIR, WPS_HELP_TEMPLATES_MAIN_DIR, "backend", "wps_tab_content_tpl")); |
|
44 | 44 | } |
45 | 45 | |
46 | - public function set_help_tab( $ID, $title, $content, $pages ) { |
|
47 | - $this->help_tabs[$ID] = array( 'title' => $title, 'content' => $content, 'pages' => $pages ); |
|
46 | + public function set_help_tab($ID, $title, $content, $pages) { |
|
47 | + $this->help_tabs[$ID] = array('title' => $title, 'content' => $content, 'pages' => $pages); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @return string |
53 | 53 | */ |
54 | 54 | public static function display_current_id_page() { |
55 | - add_action( "load-{$GLOBALS['pagenow']}", array( 'wps_help_tabs_ctr', 'get_current_id_page' ), 20 ); |
|
55 | + add_action("load-{$GLOBALS['pagenow']}", array('wps_help_tabs_ctr', 'get_current_id_page'), 20); |
|
56 | 56 | } |
57 | 57 | public static function get_current_id_page() { |
58 | 58 | $screen = get_current_screen(); |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Fichier de définition du modèle des taxinomies / File for term model definition |
4 | 6 | * |
@@ -1,3 +1,3 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | ?> |
3 | -<p style="text-align: center;"><i><?php _e( 'Help of plugin WPShop', 'wpshop' )?></i></p> |
|
4 | 3 | \ No newline at end of file |
4 | +<p style="text-align: center;"><i><?php _e('Help of plugin WPShop', 'wpshop')?></i></p> |
|
5 | 5 | \ No newline at end of file |
@@ -1,3 +1,5 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | ?> |
3 | 5 | <p><?php echo $content; ?></p> |
4 | 6 | \ No newline at end of file |
@@ -1,3 +1,3 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | ?> |
3 | 3 | <p><?php echo $content; ?></p> |
4 | 4 | \ No newline at end of file |
@@ -1,3 +1,5 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | ?> |
3 | 5 | <p><?php echo $content; ?></p> |
4 | 6 | \ No newline at end of file |
@@ -19,210 +19,210 @@ |
||
19 | 19 | */ |
20 | 20 | class Segment implements IteratorAggregate, Countable |
21 | 21 | { |
22 | - protected $xml; |
|
23 | - protected $xmlParsed = ''; |
|
24 | - protected $name; |
|
25 | - protected $children = array(); |
|
26 | - protected $vars = array(); |
|
27 | - public $manif_vars = array(); |
|
22 | + protected $xml; |
|
23 | + protected $xmlParsed = ''; |
|
24 | + protected $name; |
|
25 | + protected $children = array(); |
|
26 | + protected $vars = array(); |
|
27 | + public $manif_vars = array(); |
|
28 | 28 | protected $images = array(); |
29 | 29 | protected $odf; |
30 | 30 | protected $file; |
31 | - /** |
|
32 | - * Constructor |
|
33 | - * |
|
34 | - * @param string $name name of the segment to construct |
|
35 | - * @param string $xml XML tree of the segment |
|
36 | - */ |
|
37 | - public function __construct($name, $xml, $odf) |
|
38 | - { |
|
39 | - $this->name = (string) $name; |
|
40 | - $this->xml = (string) $xml; |
|
31 | + /** |
|
32 | + * Constructor |
|
33 | + * |
|
34 | + * @param string $name name of the segment to construct |
|
35 | + * @param string $xml XML tree of the segment |
|
36 | + */ |
|
37 | + public function __construct($name, $xml, $odf) |
|
38 | + { |
|
39 | + $this->name = (string) $name; |
|
40 | + $this->xml = (string) $xml; |
|
41 | 41 | $this->odf = $odf; |
42 | - $zipHandler = $this->odf->getConfig('ZIP_PROXY'); |
|
43 | - $this->file = new $zipHandler(); |
|
44 | - $this->_analyseChildren($this->xml); |
|
45 | - } |
|
46 | - /** |
|
47 | - * Returns the name of the segment |
|
48 | - * |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public function getName() |
|
52 | - { |
|
53 | - return $this->name; |
|
54 | - } |
|
55 | - /** |
|
56 | - * Does the segment have children ? |
|
57 | - * |
|
58 | - * @return bool |
|
59 | - */ |
|
60 | - public function hasChildren() |
|
61 | - { |
|
62 | - return $this->getIterator()->hasChildren(); |
|
63 | - } |
|
64 | - /** |
|
65 | - * Countable interface |
|
66 | - * |
|
67 | - * @return int |
|
68 | - */ |
|
69 | - public function count() |
|
70 | - { |
|
71 | - return count($this->children); |
|
72 | - } |
|
73 | - /** |
|
74 | - * IteratorAggregate interface |
|
75 | - * |
|
76 | - * @return Iterator |
|
77 | - */ |
|
78 | - public function getIterator() |
|
79 | - { |
|
80 | - return new RecursiveIteratorIterator(new SegmentIterator($this->children), 1); |
|
81 | - } |
|
82 | - /** |
|
83 | - * Replace variables of the template in the XML code |
|
84 | - * All the children are also called |
|
85 | - * |
|
86 | - * @return string |
|
87 | - */ |
|
88 | - public function merge() |
|
89 | - { |
|
90 | - $this->xmlParsed .= str_replace(array_keys($this->vars), array_values($this->vars), $this->xml); |
|
91 | - if ($this->hasChildren()) { |
|
92 | - foreach ($this->children as $child) { |
|
93 | - $this->xmlParsed = str_replace($child->xml, ($child->xmlParsed=="")?$child->merge():$child->xmlParsed, $this->xmlParsed); |
|
94 | - $child->xmlParsed = ''; |
|
95 | - //Store all image names used in child segments in current segment array |
|
42 | + $zipHandler = $this->odf->getConfig('ZIP_PROXY'); |
|
43 | + $this->file = new $zipHandler(); |
|
44 | + $this->_analyseChildren($this->xml); |
|
45 | + } |
|
46 | + /** |
|
47 | + * Returns the name of the segment |
|
48 | + * |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public function getName() |
|
52 | + { |
|
53 | + return $this->name; |
|
54 | + } |
|
55 | + /** |
|
56 | + * Does the segment have children ? |
|
57 | + * |
|
58 | + * @return bool |
|
59 | + */ |
|
60 | + public function hasChildren() |
|
61 | + { |
|
62 | + return $this->getIterator()->hasChildren(); |
|
63 | + } |
|
64 | + /** |
|
65 | + * Countable interface |
|
66 | + * |
|
67 | + * @return int |
|
68 | + */ |
|
69 | + public function count() |
|
70 | + { |
|
71 | + return count($this->children); |
|
72 | + } |
|
73 | + /** |
|
74 | + * IteratorAggregate interface |
|
75 | + * |
|
76 | + * @return Iterator |
|
77 | + */ |
|
78 | + public function getIterator() |
|
79 | + { |
|
80 | + return new RecursiveIteratorIterator(new SegmentIterator($this->children), 1); |
|
81 | + } |
|
82 | + /** |
|
83 | + * Replace variables of the template in the XML code |
|
84 | + * All the children are also called |
|
85 | + * |
|
86 | + * @return string |
|
87 | + */ |
|
88 | + public function merge() |
|
89 | + { |
|
90 | + $this->xmlParsed .= str_replace(array_keys($this->vars), array_values($this->vars), $this->xml); |
|
91 | + if ($this->hasChildren()) { |
|
92 | + foreach ($this->children as $child) { |
|
93 | + $this->xmlParsed = str_replace($child->xml, ($child->xmlParsed=="")?$child->merge():$child->xmlParsed, $this->xmlParsed); |
|
94 | + $child->xmlParsed = ''; |
|
95 | + //Store all image names used in child segments in current segment array |
|
96 | 96 | foreach ($child->manif_vars as $file) |
97 | - $this->manif_vars[] = $file; |
|
98 | - $child->manif_vars=array(); |
|
99 | - } |
|
100 | - } |
|
101 | - $reg = "/\[!--\sBEGIN\s$this->name\s--\](.*)\[!--\sEND\s$this->name\s--\]/smU"; |
|
102 | - $this->xmlParsed = preg_replace($reg, '$1', $this->xmlParsed); |
|
103 | - $this->file->open($this->odf->getTmpfile()); |
|
104 | - foreach ($this->images as $imageKey => $imageValue) { |
|
97 | + $this->manif_vars[] = $file; |
|
98 | + $child->manif_vars=array(); |
|
99 | + } |
|
100 | + } |
|
101 | + $reg = "/\[!--\sBEGIN\s$this->name\s--\](.*)\[!--\sEND\s$this->name\s--\]/smU"; |
|
102 | + $this->xmlParsed = preg_replace($reg, '$1', $this->xmlParsed); |
|
103 | + $this->file->open($this->odf->getTmpfile()); |
|
104 | + foreach ($this->images as $imageKey => $imageValue) { |
|
105 | 105 | if ($this->file->getFromName('Pictures/' . $imageValue) === false) { |
106 | 106 | $this->file->addFile($imageKey, 'Pictures/' . $imageValue); |
107 | 107 | } |
108 | - } |
|
108 | + } |
|
109 | 109 | |
110 | - $this->file->close(); |
|
111 | - return $this->xmlParsed; |
|
112 | - } |
|
113 | - /** |
|
114 | - * Analyse the XML code in order to find children |
|
115 | - * |
|
116 | - * @param string $xml |
|
117 | - * @return Segment |
|
118 | - */ |
|
119 | - protected function _analyseChildren($xml) |
|
120 | - { |
|
121 | - // $reg2 = "#\[!--\sBEGIN\s([\S]*)\s--\](?:<\/text:p>)?(.*)(?:<text:p\s.*>)?\[!--\sEND\s(\\1)\s--\]#sm"; |
|
122 | - $reg2 = "#\[!--\sBEGIN\s([\S]*)\s--\](.*)\[!--\sEND\s(\\1)\s--\]#smU"; |
|
123 | - preg_match_all($reg2, $xml, $matches); |
|
124 | - for ($i = 0, $size = count($matches[0]); $i < $size; $i++) { |
|
125 | - if ($matches[1][$i] != $this->name) { |
|
126 | - $this->children[$matches[1][$i]] = new self($matches[1][$i], $matches[0][$i], $this->odf); |
|
127 | - } else { |
|
128 | - $this->_analyseChildren($matches[2][$i]); |
|
129 | - } |
|
130 | - } |
|
131 | - return $this; |
|
132 | - } |
|
133 | - /** |
|
134 | - * Assign a template variable to replace |
|
135 | - * |
|
136 | - * @param string $key |
|
137 | - * @param string $value |
|
138 | - * @throws SegmentException |
|
139 | - * @return Segment |
|
140 | - */ |
|
141 | - public function setVars($key, $value, $encode = true, $charset = 'ISO-8859') |
|
142 | - { |
|
143 | - if (strpos($this->xml, $this->odf->getConfig('DELIMITER_LEFT') . $key . $this->odf->getConfig('DELIMITER_RIGHT')) === false) { |
|
144 | - throw new SegmentException("var $key not found in {$this->getName()}"); |
|
145 | - } |
|
110 | + $this->file->close(); |
|
111 | + return $this->xmlParsed; |
|
112 | + } |
|
113 | + /** |
|
114 | + * Analyse the XML code in order to find children |
|
115 | + * |
|
116 | + * @param string $xml |
|
117 | + * @return Segment |
|
118 | + */ |
|
119 | + protected function _analyseChildren($xml) |
|
120 | + { |
|
121 | + // $reg2 = "#\[!--\sBEGIN\s([\S]*)\s--\](?:<\/text:p>)?(.*)(?:<text:p\s.*>)?\[!--\sEND\s(\\1)\s--\]#sm"; |
|
122 | + $reg2 = "#\[!--\sBEGIN\s([\S]*)\s--\](.*)\[!--\sEND\s(\\1)\s--\]#smU"; |
|
123 | + preg_match_all($reg2, $xml, $matches); |
|
124 | + for ($i = 0, $size = count($matches[0]); $i < $size; $i++) { |
|
125 | + if ($matches[1][$i] != $this->name) { |
|
126 | + $this->children[$matches[1][$i]] = new self($matches[1][$i], $matches[0][$i], $this->odf); |
|
127 | + } else { |
|
128 | + $this->_analyseChildren($matches[2][$i]); |
|
129 | + } |
|
130 | + } |
|
131 | + return $this; |
|
132 | + } |
|
133 | + /** |
|
134 | + * Assign a template variable to replace |
|
135 | + * |
|
136 | + * @param string $key |
|
137 | + * @param string $value |
|
138 | + * @throws SegmentException |
|
139 | + * @return Segment |
|
140 | + */ |
|
141 | + public function setVars($key, $value, $encode = true, $charset = 'ISO-8859') |
|
142 | + { |
|
143 | + if (strpos($this->xml, $this->odf->getConfig('DELIMITER_LEFT') . $key . $this->odf->getConfig('DELIMITER_RIGHT')) === false) { |
|
144 | + throw new SegmentException("var $key not found in {$this->getName()}"); |
|
145 | + } |
|
146 | 146 | $value = $encode ? htmlspecialchars($value) : $value; |
147 | 147 | $value = ($charset == 'ISO-8859') ? utf8_encode($value) : $value; |
148 | - $this->vars[$this->odf->getConfig('DELIMITER_LEFT') . $key . $this->odf->getConfig('DELIMITER_RIGHT')] = str_replace("\n", "<text:line-break/>", $value); |
|
149 | - return $this; |
|
150 | - } |
|
151 | - /** |
|
152 | - * Assign a template variable as a picture |
|
153 | - * |
|
154 | - * @param string $key name of the variable within the template |
|
155 | - * @param string $value path to the picture |
|
156 | - * @param string $page anchor to page number (or -1 if anchor-type is aschar) |
|
157 | - * @param string $width width of picture (keep original if null) |
|
158 | - * @param string $height height of picture (keep original if null) |
|
159 | - * @param string $offsetX offset by horizontal (not used if $page = -1) |
|
160 | - * @param string $offsetY offset by vertical (not used if $page = -1) |
|
161 | - * @throws OdfException |
|
162 | - * @return Segment |
|
163 | - */ |
|
164 | - public function setImage($key, $value, $page=null, $width=null, $height=null, $offsetX=null, $offsetY=null) |
|
165 | - { |
|
166 | - $filename = strtok(strrchr($value, '/'), '/.'); |
|
167 | - $file = substr(strrchr($value, '/'), 1); |
|
168 | - $size = @getimagesize($value); |
|
169 | - if ($size === false) { |
|
170 | - throw new OdfException("Invalid image"); |
|
171 | - } |
|
172 | - if (!$width && !$height) { |
|
173 | - list ($width, $height) = $size; |
|
174 | - $width *= Odf::PIXEL_TO_CM; |
|
175 | - $height *= Odf::PIXEL_TO_CM; |
|
176 | - } |
|
177 | - $anchor = $page == -1 ? 'text:anchor-type="aschar"' : "text:anchor-type=\"page\" text:anchor-page-number=\"{$page}\" svg:x=\"{$offsetX}cm\" svg:y=\"{$offsetY}cm\""; |
|
178 | - $xml = <<<IMG |
|
148 | + $this->vars[$this->odf->getConfig('DELIMITER_LEFT') . $key . $this->odf->getConfig('DELIMITER_RIGHT')] = str_replace("\n", "<text:line-break/>", $value); |
|
149 | + return $this; |
|
150 | + } |
|
151 | + /** |
|
152 | + * Assign a template variable as a picture |
|
153 | + * |
|
154 | + * @param string $key name of the variable within the template |
|
155 | + * @param string $value path to the picture |
|
156 | + * @param string $page anchor to page number (or -1 if anchor-type is aschar) |
|
157 | + * @param string $width width of picture (keep original if null) |
|
158 | + * @param string $height height of picture (keep original if null) |
|
159 | + * @param string $offsetX offset by horizontal (not used if $page = -1) |
|
160 | + * @param string $offsetY offset by vertical (not used if $page = -1) |
|
161 | + * @throws OdfException |
|
162 | + * @return Segment |
|
163 | + */ |
|
164 | + public function setImage($key, $value, $page=null, $width=null, $height=null, $offsetX=null, $offsetY=null) |
|
165 | + { |
|
166 | + $filename = strtok(strrchr($value, '/'), '/.'); |
|
167 | + $file = substr(strrchr($value, '/'), 1); |
|
168 | + $size = @getimagesize($value); |
|
169 | + if ($size === false) { |
|
170 | + throw new OdfException("Invalid image"); |
|
171 | + } |
|
172 | + if (!$width && !$height) { |
|
173 | + list ($width, $height) = $size; |
|
174 | + $width *= Odf::PIXEL_TO_CM; |
|
175 | + $height *= Odf::PIXEL_TO_CM; |
|
176 | + } |
|
177 | + $anchor = $page == -1 ? 'text:anchor-type="aschar"' : "text:anchor-type=\"page\" text:anchor-page-number=\"{$page}\" svg:x=\"{$offsetX}cm\" svg:y=\"{$offsetY}cm\""; |
|
178 | + $xml = <<<IMG |
|
179 | 179 | <draw:frame draw:style-name="fr1" draw:name="$filename" {$anchor} svg:width="{$width}cm" svg:height="{$height}cm" draw:z-index="3"><draw:image xlink:href="Pictures/$file" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame> |
180 | 180 | IMG; |
181 | - $this->images[$value] = $file; |
|
182 | - $this->manif_vars[] = $file; //save image name as array element |
|
183 | - $this->setVars($key, $xml, false); |
|
184 | - return $this; |
|
185 | - } |
|
186 | - /** |
|
187 | - * Shortcut to retrieve a child |
|
188 | - * |
|
189 | - * @param string $prop |
|
190 | - * @return Segment |
|
191 | - * @throws SegmentException |
|
192 | - */ |
|
193 | - public function __get($prop) |
|
194 | - { |
|
195 | - if (array_key_exists($prop, $this->children)) { |
|
196 | - return $this->children[$prop]; |
|
197 | - } else { |
|
198 | - throw new SegmentException('child ' . $prop . ' does not exist'); |
|
199 | - } |
|
200 | - } |
|
201 | - /** |
|
202 | - * Proxy for setVars |
|
203 | - * |
|
204 | - * @param string $meth |
|
205 | - * @param array $args |
|
206 | - * @return Segment |
|
207 | - */ |
|
208 | - public function __call($meth, $args) |
|
209 | - { |
|
210 | - try { |
|
211 | - array_unshift($args,$meth); |
|
212 | - return call_user_func_array(array($this,'setVars'),$args); |
|
213 | - } catch (SegmentException $e) { |
|
214 | - throw new SegmentException("method $meth nor var $meth exist"); |
|
215 | - } |
|
216 | - } |
|
217 | - /** |
|
218 | - * Returns the parsed XML |
|
219 | - * |
|
220 | - * @return string |
|
221 | - */ |
|
222 | - public function getXmlParsed() |
|
223 | - { |
|
224 | - return $this->xmlParsed; |
|
225 | - } |
|
181 | + $this->images[$value] = $file; |
|
182 | + $this->manif_vars[] = $file; //save image name as array element |
|
183 | + $this->setVars($key, $xml, false); |
|
184 | + return $this; |
|
185 | + } |
|
186 | + /** |
|
187 | + * Shortcut to retrieve a child |
|
188 | + * |
|
189 | + * @param string $prop |
|
190 | + * @return Segment |
|
191 | + * @throws SegmentException |
|
192 | + */ |
|
193 | + public function __get($prop) |
|
194 | + { |
|
195 | + if (array_key_exists($prop, $this->children)) { |
|
196 | + return $this->children[$prop]; |
|
197 | + } else { |
|
198 | + throw new SegmentException('child ' . $prop . ' does not exist'); |
|
199 | + } |
|
200 | + } |
|
201 | + /** |
|
202 | + * Proxy for setVars |
|
203 | + * |
|
204 | + * @param string $meth |
|
205 | + * @param array $args |
|
206 | + * @return Segment |
|
207 | + */ |
|
208 | + public function __call($meth, $args) |
|
209 | + { |
|
210 | + try { |
|
211 | + array_unshift($args,$meth); |
|
212 | + return call_user_func_array(array($this,'setVars'),$args); |
|
213 | + } catch (SegmentException $e) { |
|
214 | + throw new SegmentException("method $meth nor var $meth exist"); |
|
215 | + } |
|
216 | + } |
|
217 | + /** |
|
218 | + * Returns the parsed XML |
|
219 | + * |
|
220 | + * @return string |
|
221 | + */ |
|
222 | + public function getXmlParsed() |
|
223 | + { |
|
224 | + return $this->xmlParsed; |
|
225 | + } |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | ?> |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | require 'SegmentIterator.php'; |
3 | 3 | class SegmentException extends Exception |
4 | 4 | {} |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function __construct($name, $xml, $odf) |
38 | 38 | { |
39 | - $this->name = (string) $name; |
|
40 | - $this->xml = (string) $xml; |
|
39 | + $this->name = (string)$name; |
|
40 | + $this->xml = (string)$xml; |
|
41 | 41 | $this->odf = $odf; |
42 | 42 | $zipHandler = $this->odf->getConfig('ZIP_PROXY'); |
43 | 43 | $this->file = new $zipHandler(); |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | $this->xmlParsed .= str_replace(array_keys($this->vars), array_values($this->vars), $this->xml); |
91 | 91 | if ($this->hasChildren()) { |
92 | 92 | foreach ($this->children as $child) { |
93 | - $this->xmlParsed = str_replace($child->xml, ($child->xmlParsed=="")?$child->merge():$child->xmlParsed, $this->xmlParsed); |
|
93 | + $this->xmlParsed = str_replace($child->xml, ($child->xmlParsed == "") ? $child->merge() : $child->xmlParsed, $this->xmlParsed); |
|
94 | 94 | $child->xmlParsed = ''; |
95 | 95 | //Store all image names used in child segments in current segment array |
96 | 96 | foreach ($child->manif_vars as $file) |
97 | 97 | $this->manif_vars[] = $file; |
98 | - $child->manif_vars=array(); |
|
98 | + $child->manif_vars = array(); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | $reg = "/\[!--\sBEGIN\s$this->name\s--\](.*)\[!--\sEND\s$this->name\s--\]/smU"; |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * @throws OdfException |
162 | 162 | * @return Segment |
163 | 163 | */ |
164 | - public function setImage($key, $value, $page=null, $width=null, $height=null, $offsetX=null, $offsetY=null) |
|
164 | + public function setImage($key, $value, $page = null, $width = null, $height = null, $offsetX = null, $offsetY = null) |
|
165 | 165 | { |
166 | 166 | $filename = strtok(strrchr($value, '/'), '/.'); |
167 | 167 | $file = substr(strrchr($value, '/'), 1); |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | <draw:frame draw:style-name="fr1" draw:name="$filename" {$anchor} svg:width="{$width}cm" svg:height="{$height}cm" draw:z-index="3"><draw:image xlink:href="Pictures/$file" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame> |
180 | 180 | IMG; |
181 | 181 | $this->images[$value] = $file; |
182 | - $this->manif_vars[] = $file; //save image name as array element |
|
182 | + $this->manif_vars[] = $file; //save image name as array element |
|
183 | 183 | $this->setVars($key, $xml, false); |
184 | 184 | return $this; |
185 | 185 | } |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | public function __call($meth, $args) |
209 | 209 | { |
210 | 210 | try { |
211 | - array_unshift($args,$meth); |
|
212 | - return call_user_func_array(array($this,'setVars'),$args); |
|
211 | + array_unshift($args, $meth); |
|
212 | + return call_user_func_array(array($this, 'setVars'), $args); |
|
213 | 213 | } catch (SegmentException $e) { |
214 | 214 | throw new SegmentException("method $meth nor var $meth exist"); |
215 | 215 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | require 'SegmentIterator.php'; |
3 | 5 | class SegmentException extends Exception |
4 | 6 | {} |
@@ -93,8 +95,9 @@ discard block |
||
93 | 95 | $this->xmlParsed = str_replace($child->xml, ($child->xmlParsed=="")?$child->merge():$child->xmlParsed, $this->xmlParsed); |
94 | 96 | $child->xmlParsed = ''; |
95 | 97 | //Store all image names used in child segments in current segment array |
96 | - foreach ($child->manif_vars as $file) |
|
97 | - $this->manif_vars[] = $file; |
|
98 | + foreach ($child->manif_vars as $file) { |
|
99 | + $this->manif_vars[] = $file; |
|
100 | + } |
|
98 | 101 | $child->manif_vars=array(); |
99 | 102 | } |
100 | 103 | } |
@@ -21,11 +21,11 @@ |
||
21 | 21 | { |
22 | 22 | protected $zipArchive; |
23 | 23 | protected $filename; |
24 | - /** |
|
25 | - * Class constructor |
|
26 | - * |
|
27 | - * @throws PhpZipProxyException |
|
28 | - */ |
|
24 | + /** |
|
25 | + * Class constructor |
|
26 | + * |
|
27 | + * @throws PhpZipProxyException |
|
28 | + */ |
|
29 | 29 | public function __construct() |
30 | 30 | { |
31 | 31 | if (! class_exists('ZipArchive')) { |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | require_once 'ZipInterface.php'; |
3 | 3 | class PhpZipProxyException extends Exception |
4 | 4 | { } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function __construct() |
30 | 30 | { |
31 | - if (! class_exists('ZipArchive')) { |
|
31 | + if (!class_exists('ZipArchive')) { |
|
32 | 32 | throw new PhpZipProxyException('Zip extension not loaded - check your php settings, PHP5.2 minimum with zip extension |
33 | 33 | is required for using PhpZipProxy'); ; |
34 | 34 | } |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Fichier de définition du modèle des taxinomies / File for term model definition |
4 | 6 | * |
@@ -20,115 +20,115 @@ discard block |
||
20 | 20 | */ |
21 | 21 | class Odf |
22 | 22 | { |
23 | - protected $config = array( |
|
24 | - 'ZIP_PROXY' => 'PclZipProxy', |
|
25 | - 'DELIMITER_LEFT' => '{', |
|
26 | - 'DELIMITER_RIGHT' => '}', |
|
23 | + protected $config = array( |
|
24 | + 'ZIP_PROXY' => 'PclZipProxy', |
|
25 | + 'DELIMITER_LEFT' => '{', |
|
26 | + 'DELIMITER_RIGHT' => '}', |
|
27 | 27 | 'PATH_TO_TMP' => null |
28 | 28 | ); |
29 | - protected $file; |
|
30 | - protected $contentXml; |
|
31 | - protected $manifestXml; // To store content of manifest.xml file |
|
32 | - protected $tmpfile; |
|
33 | - protected $images = array(); |
|
34 | - protected $vars = array(); |
|
35 | - protected $manif_vars = array(); // array to store image names |
|
36 | - protected $segments = array(); |
|
37 | - const PIXEL_TO_CM = 0.026458333; |
|
38 | - /** |
|
39 | - * Class constructor |
|
40 | - * |
|
41 | - * @param string $filename the name of the odt file |
|
42 | - * @throws OdfException |
|
43 | - */ |
|
44 | - public function __construct($filename, $config = array()) |
|
45 | - { |
|
46 | - if (! is_array($config)) { |
|
47 | - throw new OdfException('Configuration data must be provided as array'); |
|
48 | - } |
|
49 | - foreach ($config as $configKey => $configValue) { |
|
50 | - if (array_key_exists($configKey, $this->config)) { |
|
51 | - $this->config[$configKey] = $configValue; |
|
52 | - } |
|
53 | - } |
|
54 | - if (! class_exists($this->config['ZIP_PROXY'])) { |
|
55 | - throw new OdfException($this->config['ZIP_PROXY'] . ' class not found - check your php settings'); |
|
56 | - } |
|
57 | - $zipHandler = $this->config['ZIP_PROXY']; |
|
58 | - $this->file = new $zipHandler(); |
|
59 | - if ($this->file->open($filename) !== true) { |
|
60 | - throw new OdfException("Error while Opening the file '$filename' - Check your odt file"); |
|
61 | - } |
|
62 | - if (($this->contentXml = $this->file->getFromName('content.xml')) === false) { |
|
63 | - throw new OdfException("Nothing to parse - check that the content.xml file is correctly formed"); |
|
64 | - } |
|
65 | - if (($this->manifestXml = $this->file->getFromName('META-INF/manifest.xml')) === false) { |
|
66 | - throw new OdfException("Something is wrong with META-INF/manifest.xm in source file '$filename'"); |
|
67 | - } |
|
29 | + protected $file; |
|
30 | + protected $contentXml; |
|
31 | + protected $manifestXml; // To store content of manifest.xml file |
|
32 | + protected $tmpfile; |
|
33 | + protected $images = array(); |
|
34 | + protected $vars = array(); |
|
35 | + protected $manif_vars = array(); // array to store image names |
|
36 | + protected $segments = array(); |
|
37 | + const PIXEL_TO_CM = 0.026458333; |
|
38 | + /** |
|
39 | + * Class constructor |
|
40 | + * |
|
41 | + * @param string $filename the name of the odt file |
|
42 | + * @throws OdfException |
|
43 | + */ |
|
44 | + public function __construct($filename, $config = array()) |
|
45 | + { |
|
46 | + if (! is_array($config)) { |
|
47 | + throw new OdfException('Configuration data must be provided as array'); |
|
48 | + } |
|
49 | + foreach ($config as $configKey => $configValue) { |
|
50 | + if (array_key_exists($configKey, $this->config)) { |
|
51 | + $this->config[$configKey] = $configValue; |
|
52 | + } |
|
53 | + } |
|
54 | + if (! class_exists($this->config['ZIP_PROXY'])) { |
|
55 | + throw new OdfException($this->config['ZIP_PROXY'] . ' class not found - check your php settings'); |
|
56 | + } |
|
57 | + $zipHandler = $this->config['ZIP_PROXY']; |
|
58 | + $this->file = new $zipHandler(); |
|
59 | + if ($this->file->open($filename) !== true) { |
|
60 | + throw new OdfException("Error while Opening the file '$filename' - Check your odt file"); |
|
61 | + } |
|
62 | + if (($this->contentXml = $this->file->getFromName('content.xml')) === false) { |
|
63 | + throw new OdfException("Nothing to parse - check that the content.xml file is correctly formed"); |
|
64 | + } |
|
65 | + if (($this->manifestXml = $this->file->getFromName('META-INF/manifest.xml')) === false) { |
|
66 | + throw new OdfException("Something is wrong with META-INF/manifest.xm in source file '$filename'"); |
|
67 | + } |
|
68 | 68 | |
69 | - $this->file->close(); |
|
69 | + $this->file->close(); |
|
70 | 70 | |
71 | - $tmp = tempnam($this->config['PATH_TO_TMP'], md5(uniqid())); |
|
72 | - copy($filename, $tmp); |
|
73 | - $this->tmpfile = $tmp; |
|
74 | - $this->_moveRowSegments(); |
|
75 | - } |
|
76 | - /** |
|
77 | - * Assing a template variable |
|
78 | - * |
|
79 | - * @param string $key name of the variable within the template |
|
80 | - * @param string $value replacement value |
|
81 | - * @param bool $encode if true, special XML characters are encoded |
|
82 | - * @throws OdfException |
|
83 | - * @return odf |
|
84 | - */ |
|
85 | - public function setVars($key, $value, $encode = true, $charset = 'ISO-8859') |
|
86 | - { |
|
87 | - if (strpos($this->contentXml, $this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT']) === false) { |
|
88 | - throw new OdfException("var $key not found in the document"); |
|
89 | - } |
|
90 | - $value = $encode ? htmlspecialchars($value) : $value; |
|
91 | - $value = ($charset == 'ISO-8859') ? utf8_encode($value) : $value; |
|
92 | - $this->vars[$this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT']] = str_replace("\n", "<text:line-break/>", $value); |
|
93 | - return $this; |
|
94 | - } |
|
95 | - /** |
|
96 | - * Assign a template variable as a picture |
|
97 | - * |
|
98 | - * @param string $key name of the variable within the template |
|
99 | - * @param string $value path to the picture |
|
100 | - * @throws OdfException |
|
101 | - * @return odf |
|
102 | - */ |
|
103 | - public function setImage($key, $value) |
|
104 | - { |
|
105 | - $filename = strtok(strrchr($value, '/'), '/.'); |
|
106 | - $file = substr(strrchr($value, '/'), 1); |
|
107 | - $size = @getimagesize($value); |
|
108 | - if ($size === false) { |
|
109 | - throw new OdfException("Invalid image"); |
|
110 | - } |
|
111 | - list ($width, $height) = $size; |
|
112 | - $width *= self::PIXEL_TO_CM; |
|
113 | - $height *= self::PIXEL_TO_CM; |
|
114 | - $xml = <<<IMG |
|
71 | + $tmp = tempnam($this->config['PATH_TO_TMP'], md5(uniqid())); |
|
72 | + copy($filename, $tmp); |
|
73 | + $this->tmpfile = $tmp; |
|
74 | + $this->_moveRowSegments(); |
|
75 | + } |
|
76 | + /** |
|
77 | + * Assing a template variable |
|
78 | + * |
|
79 | + * @param string $key name of the variable within the template |
|
80 | + * @param string $value replacement value |
|
81 | + * @param bool $encode if true, special XML characters are encoded |
|
82 | + * @throws OdfException |
|
83 | + * @return odf |
|
84 | + */ |
|
85 | + public function setVars($key, $value, $encode = true, $charset = 'ISO-8859') |
|
86 | + { |
|
87 | + if (strpos($this->contentXml, $this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT']) === false) { |
|
88 | + throw new OdfException("var $key not found in the document"); |
|
89 | + } |
|
90 | + $value = $encode ? htmlspecialchars($value) : $value; |
|
91 | + $value = ($charset == 'ISO-8859') ? utf8_encode($value) : $value; |
|
92 | + $this->vars[$this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT']] = str_replace("\n", "<text:line-break/>", $value); |
|
93 | + return $this; |
|
94 | + } |
|
95 | + /** |
|
96 | + * Assign a template variable as a picture |
|
97 | + * |
|
98 | + * @param string $key name of the variable within the template |
|
99 | + * @param string $value path to the picture |
|
100 | + * @throws OdfException |
|
101 | + * @return odf |
|
102 | + */ |
|
103 | + public function setImage($key, $value) |
|
104 | + { |
|
105 | + $filename = strtok(strrchr($value, '/'), '/.'); |
|
106 | + $file = substr(strrchr($value, '/'), 1); |
|
107 | + $size = @getimagesize($value); |
|
108 | + if ($size === false) { |
|
109 | + throw new OdfException("Invalid image"); |
|
110 | + } |
|
111 | + list ($width, $height) = $size; |
|
112 | + $width *= self::PIXEL_TO_CM; |
|
113 | + $height *= self::PIXEL_TO_CM; |
|
114 | + $xml = <<<IMG |
|
115 | 115 | <draw:frame draw:style-name="fr1" draw:name="$filename" text:anchor-type="char" svg:width="{$width}cm" svg:height="{$height}cm" draw:z-index="3"><draw:image xlink:href="Pictures/$file" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame> |
116 | 116 | IMG; |
117 | - $this->images[$value] = $file; |
|
118 | - $this->manif_vars[] = $file; //save image name as array element |
|
119 | - $this->setVars($key, $xml, false); |
|
120 | - return $this; |
|
121 | - } |
|
122 | - /** |
|
123 | - * Move segment tags for lines of tables |
|
124 | - * Called automatically within the constructor |
|
125 | - * |
|
126 | - * @return void |
|
127 | - */ |
|
128 | - private function _moveRowSegments() |
|
129 | - { |
|
130 | - // Search all possible rows in the document |
|
131 | - $reg1 = "#<table:table-row[^>]*>(.*)</table:table-row>#smU"; |
|
117 | + $this->images[$value] = $file; |
|
118 | + $this->manif_vars[] = $file; //save image name as array element |
|
119 | + $this->setVars($key, $xml, false); |
|
120 | + return $this; |
|
121 | + } |
|
122 | + /** |
|
123 | + * Move segment tags for lines of tables |
|
124 | + * Called automatically within the constructor |
|
125 | + * |
|
126 | + * @return void |
|
127 | + */ |
|
128 | + private function _moveRowSegments() |
|
129 | + { |
|
130 | + // Search all possible rows in the document |
|
131 | + $reg1 = "#<table:table-row[^>]*>(.*)</table:table-row>#smU"; |
|
132 | 132 | preg_match_all($reg1, $this->contentXml, $matches); |
133 | 133 | for ($i = 0, $size = count($matches[0]); $i < $size; $i++) { |
134 | 134 | // Check if the current row contains a segment row.* |
@@ -146,189 +146,189 @@ discard block |
||
146 | 146 | $this->contentXml = str_replace($matches[0][$i], $replacedXML, $this->contentXml); |
147 | 147 | } |
148 | 148 | } |
149 | - } |
|
150 | - /** |
|
151 | - * Merge template variables |
|
152 | - * Called automatically for a save |
|
153 | - * |
|
154 | - * @return void |
|
155 | - */ |
|
156 | - private function _parse() |
|
157 | - { |
|
158 | - $this->contentXml = str_replace(array_keys($this->vars), array_values($this->vars), $this->contentXml); |
|
159 | - } |
|
160 | - /** |
|
161 | - * Add the merged segment to the document |
|
162 | - * |
|
163 | - * @param Segment $segment |
|
164 | - * @throws OdfException |
|
165 | - * @return odf |
|
166 | - */ |
|
167 | - public function mergeSegment(Segment $segment) |
|
168 | - { |
|
169 | - if (! array_key_exists($segment->getName(), $this->segments)) { |
|
170 | - throw new OdfException($segment->getName() . 'cannot be parsed, has it been set yet ?'); |
|
171 | - } |
|
172 | - $string = $segment->getName(); |
|
149 | + } |
|
150 | + /** |
|
151 | + * Merge template variables |
|
152 | + * Called automatically for a save |
|
153 | + * |
|
154 | + * @return void |
|
155 | + */ |
|
156 | + private function _parse() |
|
157 | + { |
|
158 | + $this->contentXml = str_replace(array_keys($this->vars), array_values($this->vars), $this->contentXml); |
|
159 | + } |
|
160 | + /** |
|
161 | + * Add the merged segment to the document |
|
162 | + * |
|
163 | + * @param Segment $segment |
|
164 | + * @throws OdfException |
|
165 | + * @return odf |
|
166 | + */ |
|
167 | + public function mergeSegment(Segment $segment) |
|
168 | + { |
|
169 | + if (! array_key_exists($segment->getName(), $this->segments)) { |
|
170 | + throw new OdfException($segment->getName() . 'cannot be parsed, has it been set yet ?'); |
|
171 | + } |
|
172 | + $string = $segment->getName(); |
|
173 | 173 | // $reg = '@<text:p[^>]*>\[!--\sBEGIN\s' . $string . '\s--\](.*)\[!--.+END\s' . $string . '\s--\]<\/text:p>@smU'; |
174 | 174 | $reg = '@\[!--\sBEGIN\s' . $string . '\s--\](.*)\[!--.+END\s' . $string . '\s--\]@smU'; |
175 | - $this->contentXml = preg_replace($reg, $segment->getXmlParsed(), $this->contentXml); |
|
176 | - return $this; |
|
177 | - } |
|
178 | - /** |
|
179 | - * Display all the current template variables |
|
180 | - * |
|
181 | - * @return string |
|
182 | - */ |
|
183 | - public function printVars() |
|
184 | - { |
|
185 | - return print_r('<pre>' . print_r($this->vars, true) . '</pre>', true); |
|
186 | - } |
|
187 | - /** |
|
188 | - * Display the XML content of the file from odt document |
|
189 | - * as it is at the moment |
|
190 | - * |
|
191 | - * @return string |
|
192 | - */ |
|
193 | - public function __toString() |
|
194 | - { |
|
195 | - return $this->contentXml; |
|
196 | - } |
|
197 | - /** |
|
198 | - * Display loop segments declared with setSegment() |
|
199 | - * |
|
200 | - * @return string |
|
201 | - */ |
|
202 | - public function printDeclaredSegments() |
|
203 | - { |
|
204 | - return '<pre>' . print_r(implode(' ', array_keys($this->segments)), true) . '</pre>'; |
|
205 | - } |
|
206 | - /** |
|
207 | - * Declare a segment in order to use it in a loop |
|
208 | - * |
|
209 | - * @param string $segment |
|
210 | - * @throws OdfException |
|
211 | - * @return Segment |
|
212 | - */ |
|
213 | - public function setSegment($segment) |
|
214 | - { |
|
215 | - if (array_key_exists($segment, $this->segments)) { |
|
216 | - return $this->segments[$segment]; |
|
217 | - } |
|
218 | - // $reg = "#\[!--\sBEGIN\s$segment\s--\]<\/text:p>(.*)<text:p\s.*>\[!--\sEND\s$segment\s--\]#sm"; |
|
219 | - $reg = "#\[!--\sBEGIN\s$segment\s--\](.*)\[!--\sEND\s$segment\s--\]#sm"; |
|
220 | - if (preg_match($reg, html_entity_decode($this->contentXml), $m) == 0) { |
|
221 | - throw new OdfException("'$segment' segment not found in the document"); |
|
222 | - } |
|
223 | - $this->segments[$segment] = new Segment($segment, $m[1], $this); |
|
224 | - return $this->segments[$segment]; |
|
225 | - } |
|
226 | - /** |
|
227 | - * Save the odt file on the disk |
|
228 | - * |
|
229 | - * @param string $file name of the desired file |
|
230 | - * @throws OdfException |
|
231 | - * @return void |
|
232 | - */ |
|
233 | - public function saveToDisk($file = null) |
|
234 | - { |
|
235 | - if ($file !== null && is_string($file)) { |
|
236 | - if (file_exists($file) && !(is_file($file) && is_writable($file))) { |
|
237 | - throw new OdfException('Permission denied : can\'t create ' . $file); |
|
238 | - } |
|
239 | - $this->_save(); |
|
240 | - copy($this->tmpfile, $file); |
|
241 | - } else { |
|
242 | - $this->_save(); |
|
243 | - } |
|
244 | - } |
|
245 | - /** |
|
246 | - * Internal save |
|
247 | - * |
|
248 | - * @throws OdfException |
|
249 | - * @return void |
|
250 | - */ |
|
251 | - private function _save() |
|
252 | - { |
|
253 | - $this->file->open($this->tmpfile); |
|
254 | - $this->_parse(); |
|
255 | - if (! $this->file->addFromString('content.xml', $this->contentXml) ) { |
|
256 | - throw new OdfException('Error during file export addFromString'); |
|
257 | - } |
|
175 | + $this->contentXml = preg_replace($reg, $segment->getXmlParsed(), $this->contentXml); |
|
176 | + return $this; |
|
177 | + } |
|
178 | + /** |
|
179 | + * Display all the current template variables |
|
180 | + * |
|
181 | + * @return string |
|
182 | + */ |
|
183 | + public function printVars() |
|
184 | + { |
|
185 | + return print_r('<pre>' . print_r($this->vars, true) . '</pre>', true); |
|
186 | + } |
|
187 | + /** |
|
188 | + * Display the XML content of the file from odt document |
|
189 | + * as it is at the moment |
|
190 | + * |
|
191 | + * @return string |
|
192 | + */ |
|
193 | + public function __toString() |
|
194 | + { |
|
195 | + return $this->contentXml; |
|
196 | + } |
|
197 | + /** |
|
198 | + * Display loop segments declared with setSegment() |
|
199 | + * |
|
200 | + * @return string |
|
201 | + */ |
|
202 | + public function printDeclaredSegments() |
|
203 | + { |
|
204 | + return '<pre>' . print_r(implode(' ', array_keys($this->segments)), true) . '</pre>'; |
|
205 | + } |
|
206 | + /** |
|
207 | + * Declare a segment in order to use it in a loop |
|
208 | + * |
|
209 | + * @param string $segment |
|
210 | + * @throws OdfException |
|
211 | + * @return Segment |
|
212 | + */ |
|
213 | + public function setSegment($segment) |
|
214 | + { |
|
215 | + if (array_key_exists($segment, $this->segments)) { |
|
216 | + return $this->segments[$segment]; |
|
217 | + } |
|
218 | + // $reg = "#\[!--\sBEGIN\s$segment\s--\]<\/text:p>(.*)<text:p\s.*>\[!--\sEND\s$segment\s--\]#sm"; |
|
219 | + $reg = "#\[!--\sBEGIN\s$segment\s--\](.*)\[!--\sEND\s$segment\s--\]#sm"; |
|
220 | + if (preg_match($reg, html_entity_decode($this->contentXml), $m) == 0) { |
|
221 | + throw new OdfException("'$segment' segment not found in the document"); |
|
222 | + } |
|
223 | + $this->segments[$segment] = new Segment($segment, $m[1], $this); |
|
224 | + return $this->segments[$segment]; |
|
225 | + } |
|
226 | + /** |
|
227 | + * Save the odt file on the disk |
|
228 | + * |
|
229 | + * @param string $file name of the desired file |
|
230 | + * @throws OdfException |
|
231 | + * @return void |
|
232 | + */ |
|
233 | + public function saveToDisk($file = null) |
|
234 | + { |
|
235 | + if ($file !== null && is_string($file)) { |
|
236 | + if (file_exists($file) && !(is_file($file) && is_writable($file))) { |
|
237 | + throw new OdfException('Permission denied : can\'t create ' . $file); |
|
238 | + } |
|
239 | + $this->_save(); |
|
240 | + copy($this->tmpfile, $file); |
|
241 | + } else { |
|
242 | + $this->_save(); |
|
243 | + } |
|
244 | + } |
|
245 | + /** |
|
246 | + * Internal save |
|
247 | + * |
|
248 | + * @throws OdfException |
|
249 | + * @return void |
|
250 | + */ |
|
251 | + private function _save() |
|
252 | + { |
|
253 | + $this->file->open($this->tmpfile); |
|
254 | + $this->_parse(); |
|
255 | + if (! $this->file->addFromString('content.xml', $this->contentXml) ) { |
|
256 | + throw new OdfException('Error during file export addFromString'); |
|
257 | + } |
|
258 | 258 | |
259 | - $lastpos=strrpos($this->manifestXml, "\n", -15); //find second last newline in the manifest.xml file |
|
260 | - $manifdata = ""; |
|
259 | + $lastpos=strrpos($this->manifestXml, "\n", -15); //find second last newline in the manifest.xml file |
|
260 | + $manifdata = ""; |
|
261 | 261 | |
262 | - //Enter all images description in $manifdata variable |
|
262 | + //Enter all images description in $manifdata variable |
|
263 | 263 | |
264 | - foreach ($this->manif_vars as $val) |
|
265 | - { |
|
266 | - $ext = substr(strrchr($val, '.'), 1); |
|
267 | - $manifdata = $manifdata.'<manifest:file-entry manifest:media-type="image/'.$ext.'" manifest:full-path="Pictures/'.$val.'"/>'."\n"; |
|
268 | - } |
|
269 | - //Place content of $manifdata variable in manifest.xml file at appropriate place |
|
270 | - $this->manifestXml = substr_replace($this->manifestXml, "\n".$manifdata, $lastpos+1, 0); |
|
264 | + foreach ($this->manif_vars as $val) |
|
265 | + { |
|
266 | + $ext = substr(strrchr($val, '.'), 1); |
|
267 | + $manifdata = $manifdata.'<manifest:file-entry manifest:media-type="image/'.$ext.'" manifest:full-path="Pictures/'.$val.'"/>'."\n"; |
|
268 | + } |
|
269 | + //Place content of $manifdata variable in manifest.xml file at appropriate place |
|
270 | + $this->manifestXml = substr_replace($this->manifestXml, "\n".$manifdata, $lastpos+1, 0); |
|
271 | 271 | |
272 | - if (! $this->file->addFromString('META-INF/manifest.xml', $this->manifestXml)) { |
|
273 | - throw new OdfException('Error during manifest file export'); |
|
274 | - } |
|
275 | - foreach ($this->images as $imageKey => $imageValue) { |
|
276 | - $this->file->addFile($imageKey, 'Pictures/' . $imageValue); |
|
277 | - } |
|
278 | - $this->file->close(); // seems to bug on windows CLI sometimes |
|
279 | - } |
|
280 | - /** |
|
281 | - * Export the file as attached file by HTTP |
|
282 | - * |
|
283 | - * @param string $name (optionnal) |
|
284 | - * @throws OdfException |
|
285 | - * @return void |
|
286 | - */ |
|
287 | - public function exportAsAttachedFile($name="") |
|
288 | - { |
|
289 | - $this->_save(); |
|
290 | - if (headers_sent($filename, $linenum)) { |
|
291 | - throw new OdfException("headers already sent ($filename at $linenum)"); |
|
292 | - } |
|
272 | + if (! $this->file->addFromString('META-INF/manifest.xml', $this->manifestXml)) { |
|
273 | + throw new OdfException('Error during manifest file export'); |
|
274 | + } |
|
275 | + foreach ($this->images as $imageKey => $imageValue) { |
|
276 | + $this->file->addFile($imageKey, 'Pictures/' . $imageValue); |
|
277 | + } |
|
278 | + $this->file->close(); // seems to bug on windows CLI sometimes |
|
279 | + } |
|
280 | + /** |
|
281 | + * Export the file as attached file by HTTP |
|
282 | + * |
|
283 | + * @param string $name (optionnal) |
|
284 | + * @throws OdfException |
|
285 | + * @return void |
|
286 | + */ |
|
287 | + public function exportAsAttachedFile($name="") |
|
288 | + { |
|
289 | + $this->_save(); |
|
290 | + if (headers_sent($filename, $linenum)) { |
|
291 | + throw new OdfException("headers already sent ($filename at $linenum)"); |
|
292 | + } |
|
293 | 293 | |
294 | - if( $name == "" ) |
|
295 | - { |
|
296 | - $name = md5(uniqid()) . ".odt"; |
|
297 | - } |
|
294 | + if( $name == "" ) |
|
295 | + { |
|
296 | + $name = md5(uniqid()) . ".odt"; |
|
297 | + } |
|
298 | 298 | |
299 | - header('Content-type: application/vnd.oasis.opendocument.text'); |
|
300 | - header('Content-Disposition: attachment; filename="'.$name.'"'); |
|
301 | - readfile($this->tmpfile); |
|
302 | - } |
|
303 | - /** |
|
304 | - * Returns a variable of configuration |
|
305 | - * |
|
306 | - * @return string The requested variable of configuration |
|
307 | - */ |
|
308 | - public function getConfig($configKey) |
|
309 | - { |
|
310 | - if (array_key_exists($configKey, $this->config)) { |
|
311 | - return $this->config[$configKey]; |
|
312 | - } |
|
313 | - return false; |
|
314 | - } |
|
315 | - /** |
|
316 | - * Returns the temporary working file |
|
317 | - * |
|
318 | - * @return string le chemin vers le fichier temporaire de travail |
|
319 | - */ |
|
320 | - public function getTmpfile() |
|
321 | - { |
|
322 | - return $this->tmpfile; |
|
323 | - } |
|
324 | - /** |
|
325 | - * Delete the temporary file when the object is destroyed |
|
326 | - */ |
|
327 | - public function __destruct() { |
|
328 | - if (file_exists($this->tmpfile)) { |
|
329 | - unlink($this->tmpfile); |
|
330 | - } |
|
331 | - } |
|
299 | + header('Content-type: application/vnd.oasis.opendocument.text'); |
|
300 | + header('Content-Disposition: attachment; filename="'.$name.'"'); |
|
301 | + readfile($this->tmpfile); |
|
302 | + } |
|
303 | + /** |
|
304 | + * Returns a variable of configuration |
|
305 | + * |
|
306 | + * @return string The requested variable of configuration |
|
307 | + */ |
|
308 | + public function getConfig($configKey) |
|
309 | + { |
|
310 | + if (array_key_exists($configKey, $this->config)) { |
|
311 | + return $this->config[$configKey]; |
|
312 | + } |
|
313 | + return false; |
|
314 | + } |
|
315 | + /** |
|
316 | + * Returns the temporary working file |
|
317 | + * |
|
318 | + * @return string le chemin vers le fichier temporaire de travail |
|
319 | + */ |
|
320 | + public function getTmpfile() |
|
321 | + { |
|
322 | + return $this->tmpfile; |
|
323 | + } |
|
324 | + /** |
|
325 | + * Delete the temporary file when the object is destroyed |
|
326 | + */ |
|
327 | + public function __destruct() { |
|
328 | + if (file_exists($this->tmpfile)) { |
|
329 | + unlink($this->tmpfile); |
|
330 | + } |
|
331 | + } |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | ?> |
335 | 335 | \ No newline at end of file |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | require 'zip/PclZipProxy.php'; |
3 | 3 | require 'zip/PhpZipProxy.php'; |
4 | 4 | require 'Segment.php'; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | ); |
29 | 29 | protected $file; |
30 | 30 | protected $contentXml; |
31 | - protected $manifestXml; // To store content of manifest.xml file |
|
31 | + protected $manifestXml; // To store content of manifest.xml file |
|
32 | 32 | protected $tmpfile; |
33 | 33 | protected $images = array(); |
34 | 34 | protected $vars = array(); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __construct($filename, $config = array()) |
45 | 45 | { |
46 | - if (! is_array($config)) { |
|
46 | + if (!is_array($config)) { |
|
47 | 47 | throw new OdfException('Configuration data must be provided as array'); |
48 | 48 | } |
49 | 49 | foreach ($config as $configKey => $configValue) { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $this->config[$configKey] = $configValue; |
52 | 52 | } |
53 | 53 | } |
54 | - if (! class_exists($this->config['ZIP_PROXY'])) { |
|
54 | + if (!class_exists($this->config['ZIP_PROXY'])) { |
|
55 | 55 | throw new OdfException($this->config['ZIP_PROXY'] . ' class not found - check your php settings'); |
56 | 56 | } |
57 | 57 | $zipHandler = $this->config['ZIP_PROXY']; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | <draw:frame draw:style-name="fr1" draw:name="$filename" text:anchor-type="char" svg:width="{$width}cm" svg:height="{$height}cm" draw:z-index="3"><draw:image xlink:href="Pictures/$file" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame> |
116 | 116 | IMG; |
117 | 117 | $this->images[$value] = $file; |
118 | - $this->manif_vars[] = $file; //save image name as array element |
|
118 | + $this->manif_vars[] = $file; //save image name as array element |
|
119 | 119 | $this->setVars($key, $xml, false); |
120 | 120 | return $this; |
121 | 121 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function mergeSegment(Segment $segment) |
168 | 168 | { |
169 | - if (! array_key_exists($segment->getName(), $this->segments)) { |
|
169 | + if (!array_key_exists($segment->getName(), $this->segments)) { |
|
170 | 170 | throw new OdfException($segment->getName() . 'cannot be parsed, has it been set yet ?'); |
171 | 171 | } |
172 | 172 | $string = $segment->getName(); |
@@ -252,11 +252,11 @@ discard block |
||
252 | 252 | { |
253 | 253 | $this->file->open($this->tmpfile); |
254 | 254 | $this->_parse(); |
255 | - if (! $this->file->addFromString('content.xml', $this->contentXml) ) { |
|
255 | + if (!$this->file->addFromString('content.xml', $this->contentXml)) { |
|
256 | 256 | throw new OdfException('Error during file export addFromString'); |
257 | 257 | } |
258 | 258 | |
259 | - $lastpos=strrpos($this->manifestXml, "\n", -15); //find second last newline in the manifest.xml file |
|
259 | + $lastpos = strrpos($this->manifestXml, "\n", -15); //find second last newline in the manifest.xml file |
|
260 | 260 | $manifdata = ""; |
261 | 261 | |
262 | 262 | //Enter all images description in $manifdata variable |
@@ -264,12 +264,12 @@ discard block |
||
264 | 264 | foreach ($this->manif_vars as $val) |
265 | 265 | { |
266 | 266 | $ext = substr(strrchr($val, '.'), 1); |
267 | - $manifdata = $manifdata.'<manifest:file-entry manifest:media-type="image/'.$ext.'" manifest:full-path="Pictures/'.$val.'"/>'."\n"; |
|
267 | + $manifdata = $manifdata . '<manifest:file-entry manifest:media-type="image/' . $ext . '" manifest:full-path="Pictures/' . $val . '"/>' . "\n"; |
|
268 | 268 | } |
269 | 269 | //Place content of $manifdata variable in manifest.xml file at appropriate place |
270 | - $this->manifestXml = substr_replace($this->manifestXml, "\n".$manifdata, $lastpos+1, 0); |
|
270 | + $this->manifestXml = substr_replace($this->manifestXml, "\n" . $manifdata, $lastpos + 1, 0); |
|
271 | 271 | |
272 | - if (! $this->file->addFromString('META-INF/manifest.xml', $this->manifestXml)) { |
|
272 | + if (!$this->file->addFromString('META-INF/manifest.xml', $this->manifestXml)) { |
|
273 | 273 | throw new OdfException('Error during manifest file export'); |
274 | 274 | } |
275 | 275 | foreach ($this->images as $imageKey => $imageValue) { |
@@ -284,20 +284,20 @@ discard block |
||
284 | 284 | * @throws OdfException |
285 | 285 | * @return void |
286 | 286 | */ |
287 | - public function exportAsAttachedFile($name="") |
|
287 | + public function exportAsAttachedFile($name = "") |
|
288 | 288 | { |
289 | 289 | $this->_save(); |
290 | 290 | if (headers_sent($filename, $linenum)) { |
291 | 291 | throw new OdfException("headers already sent ($filename at $linenum)"); |
292 | 292 | } |
293 | 293 | |
294 | - if( $name == "" ) |
|
294 | + if ($name == "") |
|
295 | 295 | { |
296 | 296 | $name = md5(uniqid()) . ".odt"; |
297 | 297 | } |
298 | 298 | |
299 | 299 | header('Content-type: application/vnd.oasis.opendocument.text'); |
300 | - header('Content-Disposition: attachment; filename="'.$name.'"'); |
|
300 | + header('Content-Disposition: attachment; filename="' . $name . '"'); |
|
301 | 301 | readfile($this->tmpfile); |
302 | 302 | } |
303 | 303 | /** |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Fichier de définition du modèle des taxinomies / File for term model definition |
4 | 6 | * |
@@ -15,42 +15,42 @@ |
||
15 | 15 | */ |
16 | 16 | class SegmentIterator implements RecursiveIterator |
17 | 17 | { |
18 | - private $ref; |
|
19 | - private $key; |
|
20 | - public function __construct(array $ref) |
|
21 | - { |
|
22 | - $this->ref = $ref; |
|
23 | - $this->key = 0; |
|
24 | - $this->keys = array_keys($this->ref); |
|
25 | - } |
|
26 | - public function hasChildren() |
|
27 | - { |
|
28 | - return $this->valid() && $this->current() instanceof Segment; |
|
29 | - } |
|
30 | - public function current() |
|
31 | - { |
|
32 | - return $this->ref[$this->keys[$this->key]]; |
|
33 | - } |
|
34 | - function getChildren() |
|
35 | - { |
|
36 | - return new self($this->current()->children); |
|
37 | - } |
|
38 | - public function key() |
|
39 | - { |
|
40 | - return $this->key; |
|
41 | - } |
|
42 | - public function valid() |
|
43 | - { |
|
44 | - return array_key_exists($this->key, $this->keys); |
|
45 | - } |
|
46 | - public function rewind() |
|
47 | - { |
|
48 | - $this->key = 0; |
|
49 | - } |
|
50 | - public function next() |
|
51 | - { |
|
52 | - $this->key ++; |
|
53 | - } |
|
18 | + private $ref; |
|
19 | + private $key; |
|
20 | + public function __construct(array $ref) |
|
21 | + { |
|
22 | + $this->ref = $ref; |
|
23 | + $this->key = 0; |
|
24 | + $this->keys = array_keys($this->ref); |
|
25 | + } |
|
26 | + public function hasChildren() |
|
27 | + { |
|
28 | + return $this->valid() && $this->current() instanceof Segment; |
|
29 | + } |
|
30 | + public function current() |
|
31 | + { |
|
32 | + return $this->ref[$this->keys[$this->key]]; |
|
33 | + } |
|
34 | + function getChildren() |
|
35 | + { |
|
36 | + return new self($this->current()->children); |
|
37 | + } |
|
38 | + public function key() |
|
39 | + { |
|
40 | + return $this->key; |
|
41 | + } |
|
42 | + public function valid() |
|
43 | + { |
|
44 | + return array_key_exists($this->key, $this->keys); |
|
45 | + } |
|
46 | + public function rewind() |
|
47 | + { |
|
48 | + $this->key = 0; |
|
49 | + } |
|
50 | + public function next() |
|
51 | + { |
|
52 | + $this->key ++; |
|
53 | + } |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | ?> |
57 | 57 | \ No newline at end of file |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | /** |
3 | 3 | * Segments iterator |
4 | 4 | * You need PHP 5.2 at least |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | } |
50 | 50 | public function next() |
51 | 51 | { |
52 | - $this->key ++; |
|
52 | + $this->key++; |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Fichier de définition du modèle des taxinomies / File for term model definition |
4 | 6 | * |
@@ -1,31 +1,31 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | /** |
3 | 3 | * Author: Christophe DALOZ DE LOS RIOS - Eoxia dev team <[email protected]> |
4 | 4 | */ |
5 | 5 | |
6 | -if ( extension_loaded('gd') ) { |
|
6 | +if (extension_loaded('gd')) { |
|
7 | 7 | global $ajax; |
8 | 8 | |
9 | 9 | $upload_dir = wp_upload_dir(); |
10 | 10 | |
11 | - DEFINE( 'WPS_BARCODE_VERSION', 1.0 ); |
|
12 | - DEFINE( 'WPS_BARCODE_PATH', str_replace( "\\", "/", plugin_dir_path( __FILE__ ) ) ); |
|
13 | - DEFINE( 'WPS_BARCODE_URL', str_replace( str_replace( "\\", "/", ABSPATH), |
|
14 | - site_url() . '/', WPS_BARCODE_PATH ) ); |
|
15 | - DEFINE( 'WPS_BARCODE_JSCRIPTS', plugins_url('/assets/js', __FILE__) ); |
|
16 | - DEFINE( 'WPS_BARCODE_FONTS', WPS_BARCODE_PATH.'assets/fonts' ); |
|
17 | - DEFINE( 'WPS_BARCODE_UPLOAD', $upload_dir[ 'basedir' ] . '/wps_barcode/'); |
|
11 | + DEFINE('WPS_BARCODE_VERSION', 1.0); |
|
12 | + DEFINE('WPS_BARCODE_PATH', str_replace("\\", "/", plugin_dir_path(__FILE__))); |
|
13 | + DEFINE('WPS_BARCODE_URL', str_replace(str_replace("\\", "/", ABSPATH), |
|
14 | + site_url() . '/', WPS_BARCODE_PATH)); |
|
15 | + DEFINE('WPS_BARCODE_JSCRIPTS', plugins_url('/assets/js', __FILE__)); |
|
16 | + DEFINE('WPS_BARCODE_FONTS', WPS_BARCODE_PATH . 'assets/fonts'); |
|
17 | + DEFINE('WPS_BARCODE_UPLOAD', $upload_dir['basedir'] . '/wps_barcode/'); |
|
18 | 18 | |
19 | 19 | /** Load plugin translation */ |
20 | - load_plugin_textdomain( 'wps_barcode', false, dirname( plugin_basename( __FILE__ ) ).'/languages/' ); |
|
20 | + load_plugin_textdomain('wps_barcode', false, dirname(plugin_basename(__FILE__)) . '/languages/'); |
|
21 | 21 | |
22 | 22 | /** Define the templates directories */ |
23 | - DEFINE( 'WPS_BARCODE_TEMPLATES_TPL_DIR', WPS_BARCODE_PATH . '/templates/'); |
|
23 | + DEFINE('WPS_BARCODE_TEMPLATES_TPL_DIR', WPS_BARCODE_PATH . '/templates/'); |
|
24 | 24 | |
25 | - require_once( WPS_BARCODE_PATH . 'controller/wps_barcode.ctr.php' ); |
|
26 | - require_once( WPS_BARCODE_PATH . 'controller/wps_barcode_settings.ctr.php' ); |
|
27 | - require_once( WPS_BARCODE_PATH . 'controller/wps_barcode_metabox.ctr.php' ); |
|
28 | - require_once( WPS_BARCODE_PATH . 'controller/wps_barcode_ajax.ctr.php' ); |
|
25 | + require_once(WPS_BARCODE_PATH . 'controller/wps_barcode.ctr.php'); |
|
26 | + require_once(WPS_BARCODE_PATH . 'controller/wps_barcode_settings.ctr.php'); |
|
27 | + require_once(WPS_BARCODE_PATH . 'controller/wps_barcode_metabox.ctr.php'); |
|
28 | + require_once(WPS_BARCODE_PATH . 'controller/wps_barcode_ajax.ctr.php'); |
|
29 | 29 | |
30 | 30 | new wps_barcode(); |
31 | 31 | new wps_barcode_settings(); |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Fichier de définition du modèle des taxinomies / File for term model definition |
4 | 6 | * |