90 | - Kirby CMS Version
91 |
92 |
93 | - Kirby Toolkit Version
94 |
95 |
96 | - URL
97 |
98 | -
99 | The URL for your site seems to be setup incorrectly
100 | URL in your config:
101 | Detected URL:
102 |
103 |
104 |
105 |
106 |
107 | - Subfolder
108 |
109 | -
110 | You might want to set the subfolder in your config file
111 | Subfolder in site/config/config.php:
112 | Detected Subfolder:
113 |
114 |
115 | - Your site seems not to be running in a subfolder
116 |
117 | - Your site seems to be running in a subfolder
118 |
119 |
120 | - Root
121 |
122 |
123 | - System Folder
124 |
125 |
126 | - Content Folder
127 |
128 |
129 | - Site Folder
130 |
131 |
132 | - Templates Folder
133 |
134 |
135 |
136 | - Your templates folder could not be found
137 |
138 |
139 | - Default Template
140 |
141 | -
142 | Your default template is missing
143 |
144 |
145 |
146 |
147 |
148 | - Cache Folder
149 |
150 | - Your cache folder could not be found
151 |
152 | - Your cache folder seems not to be writable
153 |
154 |
155 |
156 |
157 | - Cache Data Structure
158 |
159 |
160 | - Cache HTML
161 |
162 |
163 | - URL-Rewriting
164 |
165 | - Can't detect url rewriting. You are probably not running Kirby on Apache. You might need to setup your own rewrite rules depending on your server setup.
166 |
167 | - url rewriting is enabled
168 |
169 | - mod_rewrite seems not to be available
170 |
171 | - url rewriting is disabled
172 |
173 |
174 | - Your PHP Version
175 |
176 |
177 |
178 | - - this version is not compatible!!!
179 |
180 |
181 | - Your Server Software
182 |
183 |
184 | - Installed Plugins
185 |
186 |
187 | - Installed Snippets
188 |
189 |
190 | - Your config files
191 |
192 |
193 | - Your entire config
194 |
195 |
196 | - PHP Error Reporting
197 |
198 |
199 |
200 |
201 |
202 |
203 |
--------------------------------------------------------------------------------
/kirby/parsers/defaults.php:
--------------------------------------------------------------------------------
1 | youtube(array(
19 | 'youtube' => $url,
20 | 'width' => $width,
21 | 'height' => $height,
22 | 'class' => $class
23 | ));
24 | }
25 |
26 | function vimeo($url, $width=false, $height=false, $class=false) {
27 | $name = kirbytext::classname();
28 | $obj = new $name;
29 | return $obj->vimeo(array(
30 | 'vimeo' => $url,
31 | 'width' => $width,
32 | 'height' => $height,
33 | 'class' => $class
34 | ));
35 | }
36 |
37 | function flash($url, $width=false, $height=false) {
38 | $name = kirbytext::classname();
39 | $obj = new $name;
40 | return $obj->flash($url, $width, $height);
41 | }
42 |
43 | function twitter($username, $text=false, $title=false, $class=false) {
44 | $name = kirbytext::classname();
45 | $obj = new $name;
46 | return $obj->twitter(array(
47 | 'twitter' => $username,
48 | 'text' => $text,
49 | 'title' => $title,
50 | 'class' => $class
51 | ));
52 | }
53 |
54 | function gist($url, $file=false) {
55 | $name = kirbytext::classname();
56 | $obj = new $name;
57 | return $obj->gist(array(
58 | 'gist' => $url,
59 | 'file' => $file
60 | ));
61 | }
62 |
63 | class kirbytext {
64 |
65 | var $obj = null;
66 | var $text = null;
67 | var $mdown = true;
68 | var $smartypants = true;
69 | var $tags = array('gist', 'twitter', 'date', 'image', 'file', 'link', 'email', 'youtube', 'vimeo');
70 | var $attr = array('text', 'file', 'width', 'height', 'link', 'popup', 'class', 'title', 'alt', 'rel', 'lang', 'target', 'download');
71 |
72 | static function init($text=false, $mdown=true, $smartypants=true) {
73 |
74 | $classname = self::classname();
75 | $kirbytext = new $classname($text, $mdown, $smartypants);
76 | return $kirbytext->get();
77 |
78 | }
79 |
80 | function __construct($text=false, $mdown=true, $smartypants=true) {
81 |
82 | $this->text = $text;
83 | $this->mdown = $mdown;
84 | $this->smartypants = $smartypants;
85 |
86 | // pass the parent page if available
87 | if(is_object($this->text)) $this->obj = $this->text->parent;
88 |
89 | }
90 |
91 | function get() {
92 |
93 | $text = preg_replace_callback('!(?=[^\]])\((' . implode('|', $this->tags) . '):(.*?)\)!i', array($this, 'parse'), (string)$this->text);
94 | $text = preg_replace_callback('!```(.*?)```!is', array($this, 'code'), $text);
95 |
96 | $text = ($this->mdown) ? markdown($text) : $text;
97 | $text = ($this->smartypants) ? smartypants($text) : $text;
98 |
99 | return $text;
100 |
101 | }
102 |
103 | function code($code) {
104 |
105 | $code = @$code[1];
106 | $lines = explode("\n", $code);
107 | $first = trim(array_shift($lines));
108 | $code = implode("\n", $lines);
109 | $code = trim($code);
110 |
111 | if(function_exists('highlight')) {
112 | $result = '';
113 | $result .= '';
114 | $result .= highlight($code, (empty($first)) ? 'php-html' : $first);
115 | $result .= '
';
116 | $result .= '
';
117 | } else {
118 | $result = '';
119 | $result .= '';
120 | $result .= htmlspecialchars($code);
121 | $result .= '
';
122 | $result .= '
';
123 | }
124 |
125 | return $result;
126 |
127 | }
128 |
129 | function parse($args) {
130 |
131 | $method = strtolower(@$args[1]);
132 | $string = @$args[0];
133 |
134 | if(empty($string)) return false;
135 | if(!method_exists($this, $method)) return $string;
136 |
137 | $replace = array('(', ')');
138 | $string = str_replace($replace, '', $string);
139 | $attr = array_merge($this->tags, $this->attr);
140 | $search = preg_split('!(' . implode('|', $attr) . '):!i', $string, false, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
141 | $result = array();
142 | $num = 0;
143 |
144 | foreach($search AS $key) {
145 |
146 | if(!isset($search[$num+1])) break;
147 |
148 | $key = trim($search[$num]);
149 | $value = trim($search[$num+1]);
150 |
151 | $result[ $key ] = $value;
152 | $num = $num+2;
153 |
154 | }
155 |
156 | return $this->$method($result);
157 |
158 | }
159 |
160 | function url($url, $lang=false, $metadata=false) {
161 |
162 | $file = false;
163 |
164 | if(preg_match('!(http|https)\:\/\/!i', $url)) {
165 | return (!$metadata) ? $url : array(
166 | 'url' => $url,
167 | 'file' => $file
168 | );
169 | }
170 |
171 | if($files = $this->relatedFiles()) {
172 | $file = $files->find($url);
173 | $url = ($file) ? $file->url() : url($url, $lang);
174 | }
175 |
176 | return (!$metadata) ? $url : array(
177 | 'url' => $url,
178 | 'file' => $file
179 | );
180 |
181 | }
182 |
183 | // get the current related page object
184 | function relatedPage() {
185 | global $site;
186 | return ($this->obj) ? $this->obj : $site->pages()->active();
187 | }
188 |
189 | // get related files for the related page
190 | function relatedFiles() {
191 | $object = $this->relatedPage();
192 | return ($object) ? $object->files() : null;
193 | }
194 |
195 | function link($params) {
196 |
197 | $url = @$params['link'];
198 |
199 | // sanitize the url
200 | if(empty($url)) $url = '/';
201 |
202 | // language attribute is only allowed when lang support is activated
203 | $lang = (!empty($params['lang']) && c::get('lang.support')) ? $params['lang'] : false;
204 |
205 | // get the full href
206 | $href = $this->url($url, $lang);
207 |
208 | $linkAttributes = $this->attr(array(
209 | 'href' => $href,
210 | 'rel' => @$params['rel'],
211 | 'class' => @$params['class'],
212 | 'title' => html(@$params['title']),
213 | ));
214 |
215 | // get the text
216 | $text = (empty($params['text'])) ? $href : $params['text'];
217 |
218 | return '' . html($text) . '';
219 |
220 | }
221 |
222 | function image($params) {
223 |
224 | $url = @$params['image'];
225 | $alt = @$params['alt'];
226 | $title = @$params['title'];
227 |
228 | // alt is just an alternative for text
229 | if(!empty($params['text'])) $alt = $params['text'];
230 |
231 | // get metadata (url + file) for the image url
232 | $imageMeta = $this->url($url, $lang = false, $metadata = true);
233 |
234 | // try to get the title from the image object and use it as alt text
235 | if($imageMeta['file']) {
236 |
237 | if(empty($alt) && $imageMeta['file']->alt() != '') {
238 | $alt = $imageMeta['file']->alt();
239 | }
240 |
241 | if(empty($title) && $imageMeta['file']->title() != '') {
242 | $title = $imageMeta['file']->title();
243 | }
244 |
245 | // last resort for no alt text
246 | if(empty($alt)) $alt = $title;
247 |
248 | }
249 |
250 | $imageAttributes = $this->attr(array(
251 | 'src' => $imageMeta['url'],
252 | 'width' => @$params['width'],
253 | 'height' => @$params['height'],
254 | 'class' => @$params['class'],
255 | 'title' => html($title),
256 | 'alt' => html($alt)
257 | ));
258 |
259 | $image = '
';
260 |
261 | if(!empty($params['link'])) {
262 |
263 | // build the href for the link
264 | $href = ($params['link'] == 'self') ? $url : $params['link'];
265 |
266 | $linkAttributes = $this->attr(array(
267 | 'href' => $this->url($href),
268 | 'rel' => @$params['rel'],
269 | 'class' => @$params['class'],
270 | 'title' => html(@$params['title']),
271 | ));
272 |
273 | return '' . $image . '';
274 |
275 | }
276 |
277 | return $image;
278 |
279 | }
280 |
281 | function file($params) {
282 |
283 | $url = @$params['file'];
284 | $text = @$params['text'];
285 | $class = @$params['class'];
286 | $rel = @$params['rel'];
287 | $title = @$params['title'];
288 | $download = @$params['download'];
289 | $target = self::target($params);
290 |
291 | if(empty($text)) $text = str_replace('_', '\_', $url); // ignore markdown italic underscores in filenames
292 | if(!empty($class)) $class = ' class="' . $class . '"';
293 | if(!empty($rel)) $rel = ' rel="' . $rel . '"';
294 | if(!empty($download)) $download = ' download="' . html($download) . '"';
295 | if(!empty($title)) $title = ' title="' . html($title) . '"';
296 |
297 | return '' . html($text) . '';
298 |
299 | }
300 |
301 | static function attr($name, $value = null) {
302 | if(is_array($name)) {
303 | $attributes = array();
304 | foreach($name as $key => $val) {
305 | $a = self::attr($key, $val);
306 | if($a) $attributes[] = $a;
307 | }
308 | return implode(' ', $attributes);
309 | }
310 |
311 | if(empty($value)) return false;
312 | return $name . '="' . $value . '"';
313 | }
314 |
315 | static function date($params) {
316 | $format = @$params['date'];
317 | return (str::lower($format) == 'year') ? date('Y') : date($format);
318 | }
319 |
320 | static function target($params) {
321 | if(empty($params['popup']) && empty($params['target'])) return false;
322 | if(empty($params['popup'])) {
323 | return ' target="' . $params['target'] . '"';
324 | } else {
325 | return ' target="_blank"';
326 | }
327 | }
328 |
329 | static function email($params) {
330 |
331 | $url = @$params['email'];
332 | $class = @$params['class'];
333 | $title = @$params['title'];
334 |
335 | if(empty($url)) return false;
336 | return str::email($url, @$params['text'], $title, $class);
337 |
338 | }
339 |
340 | static function twitter($params) {
341 |
342 | $username = @$params['twitter'];
343 | $class = @$params['class'];
344 | $title = @$params['title'];
345 | $target = self::target($params);
346 |
347 | if(empty($username)) return false;
348 |
349 | $username = str_replace('@', '', $username);
350 | $url = 'http://twitter.com/' . $username;
351 |
352 | // add a css class if available
353 | if(!empty($class)) $class = ' class="' . $class . '"';
354 | if(!empty($title)) $title = ' title="' . html($title) . '"';
355 |
356 | if(empty($params['text'])) return '@' . html($username) . '';
357 |
358 | return '' . html($params['text']) . '';
359 |
360 | }
361 |
362 | static function youtube($params) {
363 |
364 | $url = @$params['youtube'];
365 | $class = @$params['class'];
366 | $id = false;
367 |
368 | // http://www.youtube.com/embed/d9NF2edxy-M
369 | if(@preg_match('!youtube.com\/embed\/([a-z0-9_-]+)!i', $url, $array)) {
370 | $id = @$array[1];
371 | // http://www.youtube.com/watch?feature=player_embedded&v=d9NF2edxy-M#!
372 | } elseif(@preg_match('!v=([a-z0-9_-]+)!i', $url, $array)) {
373 | $id = @$array[1];
374 | // http://youtu.be/d9NF2edxy-M
375 | } elseif(@preg_match('!youtu.be\/([a-z0-9_-]+)!i', $url, $array)) {
376 | $id = @$array[1];
377 | }
378 |
379 | // no id no result!
380 | if(empty($id)) return false;
381 |
382 | // build the embed url for the iframe
383 | $url = 'https://www.youtube.com/embed/' . $id;
384 |
385 | // default width and height if no custom values are set
386 | if(empty($params['width'])) $params['width'] = c::get('kirbytext.video.width');
387 | if(empty($params['height'])) $params['height'] = c::get('kirbytext.video.height');
388 |
389 | // add a classname to the iframe
390 | if(!empty($class)) $class = ' class="' . $class . '"';
391 |
392 | return '';
393 |
394 | }
395 |
396 | static function vimeo($params) {
397 |
398 | $url = @$params['vimeo'];
399 | $class = @$params['class'];
400 |
401 | // get the uid from the url
402 | @preg_match('!vimeo.com\/([a-z0-9_-]+)!i', $url, $array);
403 | $id = a::get($array, 1);
404 |
405 | // no id no result!
406 | if(empty($id)) return false;
407 |
408 | // build the embed url for the iframe
409 | $url = 'https://player.vimeo.com/video/' . $id;
410 |
411 | // default width and height if no custom values are set
412 | if(empty($params['width'])) $params['width'] = c::get('kirbytext.video.width');
413 | if(empty($params['height'])) $params['height'] = c::get('kirbytext.video.height');
414 |
415 | // add a classname to the iframe
416 | if(!empty($class)) $class = ' class="' . $class . '"';
417 |
418 | return '';
419 |
420 | }
421 |
422 | static function flash($url, $w, $h) {
423 |
424 | if(!$w) $w = c::get('kirbytext.video.width');
425 | if(!$h) $h = c::get('kirbytext.video.height');
426 |
427 | return '';
428 |
429 | }
430 |
431 | static function gist($params) {
432 | $url = @$params['gist'] . '.js';
433 | $file = @$params['file'];
434 | if(!empty($file)) {
435 | $url = $url .= '?file=' . $file;
436 | }
437 | return '';
438 | }
439 |
440 | static function classname() {
441 | return class_exists('kirbytextExtended') ? 'kirbytextExtended' : 'kirbytext';
442 | }
443 |
444 | function addTags() {
445 | $args = func_get_args();
446 | $this->tags = array_merge($this->tags, $args);
447 | }
448 |
449 | function addAttributes($attr) {
450 | $args = func_get_args();
451 | $this->attr = array_merge($this->attr, $args);
452 | }
453 |
454 | }
455 |
456 |
--------------------------------------------------------------------------------
/kirby/parsers/yaml.php:
--------------------------------------------------------------------------------
1 |
14 | * @author Chris Wanstrath
15 | * @link http://code.google.com/p/spyc/
16 | * @copyright Copyright 2005-2006 Chris Wanstrath, 2006-2011 Vlad Andersen
17 | * @license http://www.opensource.org/licenses/mit-license.php MIT License
18 | * @package Spyc
19 | */
20 |
21 | if (!function_exists('spyc_load')) {
22 | /**
23 | * Parses YAML to array.
24 | * @param string $string YAML string.
25 | * @return array
26 | */
27 | function spyc_load ($string) {
28 | return Spyc::YAMLLoadString($string);
29 | }
30 | }
31 |
32 | if (!function_exists('spyc_load_file')) {
33 | /**
34 | * Parses YAML to array.
35 | * @param string $file Path to YAML file.
36 | * @return array
37 | */
38 | function spyc_load_file ($file) {
39 | return Spyc::YAMLLoad($file);
40 | }
41 | }
42 |
43 | /**
44 | * The Simple PHP YAML Class.
45 | *
46 | * This class can be used to read a YAML file and convert its contents
47 | * into a PHP array. It currently supports a very limited subsection of
48 | * the YAML spec.
49 | *
50 | * Usage:
51 | *
52 | * $Spyc = new Spyc;
53 | * $array = $Spyc->load($file);
54 | *
55 | * or:
56 | *
57 | * $array = Spyc::YAMLLoad($file);
58 | *
59 | * or:
60 | *
61 | * $array = spyc_load_file($file);
62 | *
63 | * @package Spyc
64 | */
65 | class Spyc {
66 |
67 | // SETTINGS
68 |
69 | const REMPTY = "\0\0\0\0\0";
70 |
71 | /**
72 | * Setting this to true will force YAMLDump to enclose any string value in
73 | * quotes. False by default.
74 | *
75 | * @var bool
76 | */
77 | public $setting_dump_force_quotes = false;
78 |
79 | /**
80 | * Setting this to true will forse YAMLLoad to use syck_load function when
81 | * possible. False by default.
82 | * @var bool
83 | */
84 | public $setting_use_syck_is_possible = false;
85 |
86 |
87 |
88 | /**#@+
89 | * @access private
90 | * @var mixed
91 | */
92 | private $_dumpIndent;
93 | private $_dumpWordWrap;
94 | private $_containsGroupAnchor = false;
95 | private $_containsGroupAlias = false;
96 | private $path;
97 | private $result;
98 | private $LiteralPlaceHolder = '___YAML_Literal_Block___';
99 | private $SavedGroups = array();
100 | private $indent;
101 | /**
102 | * Path modifier that should be applied after adding current element.
103 | * @var array
104 | */
105 | private $delayedPath = array();
106 |
107 | /**#@+
108 | * @access public
109 | * @var mixed
110 | */
111 | public $_nodeId;
112 |
113 | /**
114 | * Load a valid YAML string to Spyc.
115 | * @param string $input
116 | * @return array
117 | */
118 | public function load ($input) {
119 | return $this->__loadString($input);
120 | }
121 |
122 | /**
123 | * Load a valid YAML file to Spyc.
124 | * @param string $file
125 | * @return array
126 | */
127 | public function loadFile ($file) {
128 | return $this->__load($file);
129 | }
130 |
131 | /**
132 | * Load YAML into a PHP array statically
133 | *
134 | * The load method, when supplied with a YAML stream (string or file),
135 | * will do its best to convert YAML in a file into a PHP array. Pretty
136 | * simple.
137 | * Usage:
138 | *
139 | * $array = Spyc::YAMLLoad('lucky.yaml');
140 | * print_r($array);
141 | *
142 | * @access public
143 | * @return array
144 | * @param string $input Path of YAML file or string containing YAML
145 | */
146 | public static function YAMLLoad($input) {
147 | $Spyc = new Spyc;
148 | return $Spyc->__load($input);
149 | }
150 |
151 | /**
152 | * Load a string of YAML into a PHP array statically
153 | *
154 | * The load method, when supplied with a YAML string, will do its best
155 | * to convert YAML in a string into a PHP array. Pretty simple.
156 | *
157 | * Note: use this function if you don't want files from the file system
158 | * loaded and processed as YAML. This is of interest to people concerned
159 | * about security whose input is from a string.
160 | *
161 | * Usage:
162 | *
163 | * $array = Spyc::YAMLLoadString("---\n0: hello world\n");
164 | * print_r($array);
165 | *
166 | * @access public
167 | * @return array
168 | * @param string $input String containing YAML
169 | */
170 | public static function YAMLLoadString($input) {
171 | $Spyc = new Spyc;
172 | return $Spyc->__loadString($input);
173 | }
174 |
175 | /**
176 | * Dump YAML from PHP array statically
177 | *
178 | * The dump method, when supplied with an array, will do its best
179 | * to convert the array into friendly YAML. Pretty simple. Feel free to
180 | * save the returned string as nothing.yaml and pass it around.
181 | *
182 | * Oh, and you can decide how big the indent is and what the wordwrap
183 | * for folding is. Pretty cool -- just pass in 'false' for either if
184 | * you want to use the default.
185 | *
186 | * Indent's default is 2 spaces, wordwrap's default is 40 characters. And
187 | * you can turn off wordwrap by passing in 0.
188 | *
189 | * @access public
190 | * @return string
191 | * @param array $array PHP array
192 | * @param int $indent Pass in false to use the default, which is 2
193 | * @param int $wordwrap Pass in 0 for no wordwrap, false for default (40)
194 | */
195 | public static function YAMLDump($array,$indent = false,$wordwrap = false) {
196 | $spyc = new Spyc;
197 | return $spyc->dump($array,$indent,$wordwrap);
198 | }
199 |
200 |
201 | /**
202 | * Dump PHP array to YAML
203 | *
204 | * The dump method, when supplied with an array, will do its best
205 | * to convert the array into friendly YAML. Pretty simple. Feel free to
206 | * save the returned string as tasteful.yaml and pass it around.
207 | *
208 | * Oh, and you can decide how big the indent is and what the wordwrap
209 | * for folding is. Pretty cool -- just pass in 'false' for either if
210 | * you want to use the default.
211 | *
212 | * Indent's default is 2 spaces, wordwrap's default is 40 characters. And
213 | * you can turn off wordwrap by passing in 0.
214 | *
215 | * @access public
216 | * @return string
217 | * @param array $array PHP array
218 | * @param int $indent Pass in false to use the default, which is 2
219 | * @param int $wordwrap Pass in 0 for no wordwrap, false for default (40)
220 | */
221 | public function dump($array,$indent = false,$wordwrap = false) {
222 | // Dumps to some very clean YAML. We'll have to add some more features
223 | // and options soon. And better support for folding.
224 |
225 | // New features and options.
226 | if ($indent === false or !is_numeric($indent)) {
227 | $this->_dumpIndent = 2;
228 | } else {
229 | $this->_dumpIndent = $indent;
230 | }
231 |
232 | if ($wordwrap === false or !is_numeric($wordwrap)) {
233 | $this->_dumpWordWrap = 40;
234 | } else {
235 | $this->_dumpWordWrap = $wordwrap;
236 | }
237 |
238 | // New YAML document
239 | $string = "---\n";
240 |
241 | // Start at the base of the array and move through it.
242 | if ($array) {
243 | $array = (array)$array;
244 | $previous_key = -1;
245 | foreach ($array as $key => $value) {
246 | if (!isset($first_key)) $first_key = $key;
247 | $string .= $this->_yamlize($key,$value,0,$previous_key, $first_key, $array);
248 | $previous_key = $key;
249 | }
250 | }
251 | return $string;
252 | }
253 |
254 | /**
255 | * Attempts to convert a key / value array item to YAML
256 | * @access private
257 | * @return string
258 | * @param $key The name of the key
259 | * @param $value The value of the item
260 | * @param $indent The indent of the current node
261 | */
262 | private function _yamlize($key,$value,$indent, $previous_key = -1, $first_key = 0, $source_array = null) {
263 | if (is_array($value)) {
264 | if (empty ($value))
265 | return $this->_dumpNode($key, array(), $indent, $previous_key, $first_key, $source_array);
266 | // It has children. What to do?
267 | // Make it the right kind of item
268 | $string = $this->_dumpNode($key, self::REMPTY, $indent, $previous_key, $first_key, $source_array);
269 | // Add the indent
270 | $indent += $this->_dumpIndent;
271 | // Yamlize the array
272 | $string .= $this->_yamlizeArray($value,$indent);
273 | } elseif (!is_array($value)) {
274 | // It doesn't have children. Yip.
275 | $string = $this->_dumpNode($key, $value, $indent, $previous_key, $first_key, $source_array);
276 | }
277 | return $string;
278 | }
279 |
280 | /**
281 | * Attempts to convert an array to YAML
282 | * @access private
283 | * @return string
284 | * @param $array The array you want to convert
285 | * @param $indent The indent of the current level
286 | */
287 | private function _yamlizeArray($array,$indent) {
288 | if (is_array($array)) {
289 | $string = '';
290 | $previous_key = -1;
291 | foreach ($array as $key => $value) {
292 | if (!isset($first_key)) $first_key = $key;
293 | $string .= $this->_yamlize($key, $value, $indent, $previous_key, $first_key, $array);
294 | $previous_key = $key;
295 | }
296 | return $string;
297 | } else {
298 | return false;
299 | }
300 | }
301 |
302 | /**
303 | * Returns YAML from a key and a value
304 | * @access private
305 | * @return string
306 | * @param $key The name of the key
307 | * @param $value The value of the item
308 | * @param $indent The indent of the current node
309 | */
310 | private function _dumpNode($key, $value, $indent, $previous_key = -1, $first_key = 0, $source_array = null) {
311 | // do some folding here, for blocks
312 | if (is_string ($value) && ((strpos($value,"\n") !== false || strpos($value,": ") !== false || strpos($value,"- ") !== false ||
313 | strpos($value,"*") !== false || strpos($value,"#") !== false || strpos($value,"<") !== false || strpos($value,">") !== false || strpos ($value, ' ') !== false ||
314 | strpos($value,"[") !== false || strpos($value,"]") !== false || strpos($value,"{") !== false || strpos($value,"}") !== false) || strpos($value,"&") !== false || strpos($value, "'") !== false || strpos($value, "!") === 0 ||
315 | substr ($value, -1, 1) == ':')
316 | ) {
317 | $value = $this->_doLiteralBlock($value,$indent);
318 | } else {
319 | $value = $this->_doFolding($value,$indent);
320 | }
321 |
322 | if ($value === array()) $value = '[ ]';
323 | if (in_array ($value, array ('true', 'TRUE', 'false', 'FALSE', 'y', 'Y', 'n', 'N', 'null', 'NULL'), true)) {
324 | $value = $this->_doLiteralBlock($value,$indent);
325 | }
326 | if (trim ($value) != $value)
327 | $value = $this->_doLiteralBlock($value,$indent);
328 |
329 | if (is_bool($value)) {
330 | $value = ($value) ? "true" : "false";
331 | }
332 |
333 | if ($value === null) $value = 'null';
334 | if ($value === "'" . self::REMPTY . "'") $value = null;
335 |
336 | $spaces = str_repeat(' ',$indent);
337 |
338 | //if (is_int($key) && $key - 1 == $previous_key && $first_key===0) {
339 | if (is_array ($source_array) && array_keys($source_array) === range(0, count($source_array) - 1)) {
340 | // It's a sequence
341 | $string = $spaces.'- '.$value."\n";
342 | } else {
343 | // if ($first_key===0) throw new Exception('Keys are all screwy. The first one was zero, now it\'s "'. $key .'"');
344 | // It's mapped
345 | if (strpos($key, ":") !== false || strpos($key, "#") !== false) { $key = '"' . $key . '"'; }
346 | $string = rtrim ($spaces.$key.': '.$value)."\n";
347 | }
348 | return $string;
349 | }
350 |
351 | /**
352 | * Creates a literal block for dumping
353 | * @access private
354 | * @return string
355 | * @param $value
356 | * @param $indent int The value of the indent
357 | */
358 | private function _doLiteralBlock($value,$indent) {
359 | if ($value === "\n") return '\n';
360 | if (strpos($value, "\n") === false && strpos($value, "'") === false) {
361 | return sprintf ("'%s'", $value);
362 | }
363 | if (strpos($value, "\n") === false && strpos($value, '"') === false) {
364 | return sprintf ('"%s"', $value);
365 | }
366 | $exploded = explode("\n",$value);
367 | $newValue = '|';
368 | $indent += $this->_dumpIndent;
369 | $spaces = str_repeat(' ',$indent);
370 | foreach ($exploded as $line) {
371 | $newValue .= "\n" . $spaces . ($line);
372 | }
373 | return $newValue;
374 | }
375 |
376 | /**
377 | * Folds a string of text, if necessary
378 | * @access private
379 | * @return string
380 | * @param $value The string you wish to fold
381 | */
382 | private function _doFolding($value,$indent) {
383 | // Don't do anything if wordwrap is set to 0
384 |
385 | if ($this->_dumpWordWrap !== 0 && is_string ($value) && strlen($value) > $this->_dumpWordWrap) {
386 | $indent += $this->_dumpIndent;
387 | $indent = str_repeat(' ',$indent);
388 | $wrapped = wordwrap($value,$this->_dumpWordWrap,"\n$indent");
389 | $value = ">\n".$indent.$wrapped;
390 | } else {
391 | if ($this->setting_dump_force_quotes && is_string ($value) && $value !== self::REMPTY)
392 | $value = '"' . $value . '"';
393 | }
394 |
395 |
396 | return $value;
397 | }
398 |
399 | // LOADING FUNCTIONS
400 |
401 | private function __load($input) {
402 | $Source = $this->loadFromSource($input);
403 | return $this->loadWithSource($Source);
404 | }
405 |
406 | private function __loadString($input) {
407 | $Source = $this->loadFromString($input);
408 | return $this->loadWithSource($Source);
409 | }
410 |
411 | private function loadWithSource($Source) {
412 | if (empty ($Source)) return array();
413 | if ($this->setting_use_syck_is_possible && function_exists ('syck_load')) {
414 | $array = syck_load (implode ('', $Source));
415 | return is_array($array) ? $array : array();
416 | }
417 |
418 | $this->path = array();
419 | $this->result = array();
420 |
421 | $cnt = count($Source);
422 | for ($i = 0; $i < $cnt; $i++) {
423 | $line = $Source[$i];
424 |
425 | $this->indent = strlen($line) - strlen(ltrim($line));
426 | $tempPath = $this->getParentPathByIndent($this->indent);
427 | $line = self::stripIndent($line, $this->indent);
428 | if (self::isComment($line)) continue;
429 | if (self::isEmpty($line)) continue;
430 | $this->path = $tempPath;
431 |
432 | $literalBlockStyle = self::startsLiteralBlock($line);
433 | if ($literalBlockStyle) {
434 | $line = rtrim ($line, $literalBlockStyle . " \n");
435 | $literalBlock = '';
436 | $line .= $this->LiteralPlaceHolder;
437 | $literal_block_indent = strlen($Source[$i+1]) - strlen(ltrim($Source[$i+1]));
438 | while (++$i < $cnt && $this->literalBlockContinues($Source[$i], $this->indent)) {
439 | $literalBlock = $this->addLiteralLine($literalBlock, $Source[$i], $literalBlockStyle, $literal_block_indent);
440 | }
441 | $i--;
442 | }
443 |
444 | while (++$i < $cnt && self::greedilyNeedNextLine($line)) {
445 | $line = rtrim ($line, " \n\t\r") . ' ' . ltrim ($Source[$i], " \t");
446 | }
447 | $i--;
448 |
449 |
450 |
451 | if (strpos ($line, '#')) {
452 | if (strpos ($line, '"') === false && strpos ($line, "'") === false)
453 | $line = preg_replace('/\s+#(.+)$/','',$line);
454 | }
455 |
456 | $lineArray = $this->_parseLine($line);
457 |
458 | if ($literalBlockStyle)
459 | $lineArray = $this->revertLiteralPlaceHolder ($lineArray, $literalBlock);
460 |
461 | $this->addArray($lineArray, $this->indent);
462 |
463 | foreach ($this->delayedPath as $indent => $delayedPath)
464 | $this->path[$indent] = $delayedPath;
465 |
466 | $this->delayedPath = array();
467 |
468 | }
469 | return $this->result;
470 | }
471 |
472 | private function loadFromSource ($input) {
473 | if (!empty($input) && strpos($input, "\n") === false && file_exists($input))
474 | return file($input);
475 |
476 | return $this->loadFromString($input);
477 | }
478 |
479 | private function loadFromString ($input) {
480 | $lines = explode("\n",$input);
481 | foreach ($lines as $k => $_) {
482 | $lines[$k] = rtrim ($_, "\r");
483 | }
484 | return $lines;
485 | }
486 |
487 | /**
488 | * Parses YAML code and returns an array for a node
489 | * @access private
490 | * @return array
491 | * @param string $line A line from the YAML file
492 | */
493 | private function _parseLine($line) {
494 | if (!$line) return array();
495 | $line = trim($line);
496 | if (!$line) return array();
497 |
498 | $array = array();
499 |
500 | $group = $this->nodeContainsGroup($line);
501 | if ($group) {
502 | $this->addGroup($line, $group);
503 | $line = $this->stripGroup ($line, $group);
504 | }
505 |
506 | if ($this->startsMappedSequence($line))
507 | return $this->returnMappedSequence($line);
508 |
509 | if ($this->startsMappedValue($line))
510 | return $this->returnMappedValue($line);
511 |
512 | if ($this->isArrayElement($line))
513 | return $this->returnArrayElement($line);
514 |
515 | if ($this->isPlainArray($line))
516 | return $this->returnPlainArray($line);
517 |
518 |
519 | return $this->returnKeyValuePair($line);
520 |
521 | }
522 |
523 | /**
524 | * Finds the type of the passed value, returns the value as the new type.
525 | * @access private
526 | * @param string $value
527 | * @return mixed
528 | */
529 | private function _toType($value) {
530 | if ($value === '') return null;
531 | $first_character = $value[0];
532 | $last_character = substr($value, -1, 1);
533 |
534 | $is_quoted = false;
535 | do {
536 | if (!$value) break;
537 | if ($first_character != '"' && $first_character != "'") break;
538 | if ($last_character != '"' && $last_character != "'") break;
539 | $is_quoted = true;
540 | } while (0);
541 |
542 | if ($is_quoted)
543 | return strtr(substr ($value, 1, -1), array ('\\"' => '"', '\'\'' => '\'', '\\\'' => '\''));
544 |
545 | if (strpos($value, ' #') !== false && !$is_quoted)
546 | $value = preg_replace('/\s+#(.+)$/','',$value);
547 |
548 | if (!$is_quoted) $value = str_replace('\n', "\n", $value);
549 |
550 | if ($first_character == '[' && $last_character == ']') {
551 | // Take out strings sequences and mappings
552 | $innerValue = trim(substr ($value, 1, -1));
553 | if ($innerValue === '') return array();
554 | $explode = $this->_inlineEscape($innerValue);
555 | // Propagate value array
556 | $value = array();
557 | foreach ($explode as $v) {
558 | $value[] = $this->_toType($v);
559 | }
560 | return $value;
561 | }
562 |
563 | if (strpos($value,': ')!==false && $first_character != '{') {
564 | $array = explode(': ',$value);
565 | $key = trim($array[0]);
566 | array_shift($array);
567 | $value = trim(implode(': ',$array));
568 | $value = $this->_toType($value);
569 | return array($key => $value);
570 | }
571 |
572 | if ($first_character == '{' && $last_character == '}') {
573 | $innerValue = trim(substr ($value, 1, -1));
574 | if ($innerValue === '') return array();
575 | // Inline Mapping
576 | // Take out strings sequences and mappings
577 | $explode = $this->_inlineEscape($innerValue);
578 | // Propagate value array
579 | $array = array();
580 | foreach ($explode as $v) {
581 | $SubArr = $this->_toType($v);
582 | if (empty($SubArr)) continue;
583 | if (is_array ($SubArr)) {
584 | $array[key($SubArr)] = $SubArr[key($SubArr)]; continue;
585 | }
586 | $array[] = $SubArr;
587 | }
588 | return $array;
589 | }
590 |
591 | if ($value == 'null' || $value == 'NULL' || $value == 'Null' || $value == '' || $value == '~') {
592 | return null;
593 | }
594 |
595 | if ( is_numeric($value) && preg_match ('/^(-|)[1-9]+[0-9]*$/', $value) ){
596 | $intvalue = (int)$value;
597 | if ($intvalue != PHP_INT_MAX)
598 | $value = $intvalue;
599 | return $value;
600 | }
601 |
602 | if (in_array($value,
603 | array('true', 'on', '+', 'yes', 'y', 'True', 'TRUE', 'On', 'ON', 'YES', 'Yes', 'Y'))) {
604 | return true;
605 | }
606 |
607 | if (in_array(strtolower($value),
608 | array('false', 'off', '-', 'no', 'n'))) {
609 | return false;
610 | }
611 |
612 | if (is_numeric($value)) {
613 | if ($value === '0') return 0;
614 | if (rtrim ($value, 0) === $value)
615 | $value = (float)$value;
616 | return $value;
617 | }
618 |
619 | return $value;
620 | }
621 |
622 | /**
623 | * Used in inlines to check for more inlines or quoted strings
624 | * @access private
625 | * @return array
626 | */
627 | private function _inlineEscape($inline) {
628 | // There's gotta be a cleaner way to do this...
629 | // While pure sequences seem to be nesting just fine,
630 | // pure mappings and mappings with sequences inside can't go very
631 | // deep. This needs to be fixed.
632 |
633 | $seqs = array();
634 | $maps = array();
635 | $saved_strings = array();
636 |
637 | // Check for strings
638 | $regex = '/(?:(")|(?:\'))((?(1)[^"]+|[^\']+))(?(1)"|\')/';
639 | if (preg_match_all($regex,$inline,$strings)) {
640 | $saved_strings = $strings[0];
641 | $inline = preg_replace($regex,'YAMLString',$inline);
642 | }
643 | unset($regex);
644 |
645 | $i = 0;
646 | do {
647 |
648 | // Check for sequences
649 | while (preg_match('/\[([^{}\[\]]+)\]/U',$inline,$matchseqs)) {
650 | $seqs[] = $matchseqs[0];
651 | $inline = preg_replace('/\[([^{}\[\]]+)\]/U', ('YAMLSeq' . (count($seqs) - 1) . 's'), $inline, 1);
652 | }
653 |
654 | // Check for mappings
655 | while (preg_match('/{([^\[\]{}]+)}/U',$inline,$matchmaps)) {
656 | $maps[] = $matchmaps[0];
657 | $inline = preg_replace('/{([^\[\]{}]+)}/U', ('YAMLMap' . (count($maps) - 1) . 's'), $inline, 1);
658 | }
659 |
660 | if ($i++ >= 10) break;
661 |
662 | } while (strpos ($inline, '[') !== false || strpos ($inline, '{') !== false);
663 |
664 | $explode = explode(', ',$inline);
665 | $stringi = 0; $i = 0;
666 |
667 | while (1) {
668 |
669 | // Re-add the sequences
670 | if (!empty($seqs)) {
671 | foreach ($explode as $key => $value) {
672 | if (strpos($value,'YAMLSeq') !== false) {
673 | foreach ($seqs as $seqk => $seq) {
674 | $explode[$key] = str_replace(('YAMLSeq'.$seqk.'s'),$seq,$value);
675 | $value = $explode[$key];
676 | }
677 | }
678 | }
679 | }
680 |
681 | // Re-add the mappings
682 | if (!empty($maps)) {
683 | foreach ($explode as $key => $value) {
684 | if (strpos($value,'YAMLMap') !== false) {
685 | foreach ($maps as $mapk => $map) {
686 | $explode[$key] = str_replace(('YAMLMap'.$mapk.'s'), $map, $value);
687 | $value = $explode[$key];
688 | }
689 | }
690 | }
691 | }
692 |
693 |
694 | // Re-add the strings
695 | if (!empty($saved_strings)) {
696 | foreach ($explode as $key => $value) {
697 | while (strpos($value,'YAMLString') !== false) {
698 | $explode[$key] = preg_replace('/YAMLString/',$saved_strings[$stringi],$value, 1);
699 | unset($saved_strings[$stringi]);
700 | ++$stringi;
701 | $value = $explode[$key];
702 | }
703 | }
704 | }
705 |
706 | $finished = true;
707 | foreach ($explode as $key => $value) {
708 | if (strpos($value,'YAMLSeq') !== false) {
709 | $finished = false; break;
710 | }
711 | if (strpos($value,'YAMLMap') !== false) {
712 | $finished = false; break;
713 | }
714 | if (strpos($value,'YAMLString') !== false) {
715 | $finished = false; break;
716 | }
717 | }
718 | if ($finished) break;
719 |
720 | $i++;
721 | if ($i > 10)
722 | break; // Prevent infinite loops.
723 | }
724 |
725 | return $explode;
726 | }
727 |
728 | private function literalBlockContinues ($line, $lineIndent) {
729 | if (!trim($line)) return true;
730 | if (strlen($line) - strlen(ltrim($line)) > $lineIndent) return true;
731 | return false;
732 | }
733 |
734 | private function referenceContentsByAlias ($alias) {
735 | do {
736 | if (!isset($this->SavedGroups[$alias])) { echo "Bad group name: $alias."; break; }
737 | $groupPath = $this->SavedGroups[$alias];
738 | $value = $this->result;
739 | foreach ($groupPath as $k) {
740 | $value = $value[$k];
741 | }
742 | } while (false);
743 | return $value;
744 | }
745 |
746 | private function addArrayInline ($array, $indent) {
747 | $CommonGroupPath = $this->path;
748 | if (empty ($array)) return false;
749 |
750 | foreach ($array as $k => $_) {
751 | $this->addArray(array($k => $_), $indent);
752 | $this->path = $CommonGroupPath;
753 | }
754 | return true;
755 | }
756 |
757 | private function addArray ($incoming_data, $incoming_indent) {
758 |
759 | // print_r ($incoming_data);
760 |
761 | if (count ($incoming_data) > 1)
762 | return $this->addArrayInline ($incoming_data, $incoming_indent);
763 |
764 | $key = key ($incoming_data);
765 | $value = isset($incoming_data[$key]) ? $incoming_data[$key] : null;
766 | if ($key === '__!YAMLZero') $key = '0';
767 |
768 | if ($incoming_indent == 0 && !$this->_containsGroupAlias && !$this->_containsGroupAnchor) { // Shortcut for root-level values.
769 | if ($key || $key === '' || $key === '0') {
770 | $this->result[$key] = $value;
771 | } else {
772 | $this->result[] = $value; end ($this->result); $key = key ($this->result);
773 | }
774 | $this->path[$incoming_indent] = $key;
775 | return;
776 | }
777 |
778 |
779 |
780 | $history = array();
781 | // Unfolding inner array tree.
782 | $history[] = $_arr = $this->result;
783 | foreach ($this->path as $k) {
784 | $history[] = $_arr = $_arr[$k];
785 | }
786 |
787 | if ($this->_containsGroupAlias) {
788 | $value = $this->referenceContentsByAlias($this->_containsGroupAlias);
789 | $this->_containsGroupAlias = false;
790 | }
791 |
792 |
793 | // Adding string or numeric key to the innermost level or $this->arr.
794 | if (is_string($key) && $key == '<<') {
795 | if (!is_array ($_arr)) { $_arr = array (); }
796 |
797 | $_arr = array_merge ($_arr, $value);
798 | } else if ($key || $key === '' || $key === '0') {
799 | if (!is_array ($_arr))
800 | $_arr = array ($key=>$value);
801 | else
802 | $_arr[$key] = $value;
803 | } else {
804 | if (!is_array ($_arr)) { $_arr = array ($value); $key = 0; }
805 | else { $_arr[] = $value; end ($_arr); $key = key ($_arr); }
806 | }
807 |
808 | $reverse_path = array_reverse($this->path);
809 | $reverse_history = array_reverse ($history);
810 | $reverse_history[0] = $_arr;
811 | $cnt = count($reverse_history) - 1;
812 | for ($i = 0; $i < $cnt; $i++) {
813 | $reverse_history[$i+1][$reverse_path[$i]] = $reverse_history[$i];
814 | }
815 | $this->result = $reverse_history[$cnt];
816 |
817 | $this->path[$incoming_indent] = $key;
818 |
819 | if ($this->_containsGroupAnchor) {
820 | $this->SavedGroups[$this->_containsGroupAnchor] = $this->path;
821 | if (is_array ($value)) {
822 | $k = key ($value);
823 | if (!is_int ($k)) {
824 | $this->SavedGroups[$this->_containsGroupAnchor][$incoming_indent + 2] = $k;
825 | }
826 | }
827 | $this->_containsGroupAnchor = false;
828 | }
829 |
830 | }
831 |
832 | private static function startsLiteralBlock ($line) {
833 | $lastChar = substr (trim($line), -1);
834 | if ($lastChar != '>' && $lastChar != '|') return false;
835 | if ($lastChar == '|') return $lastChar;
836 | // HTML tags should not be counted as literal blocks.
837 | if (preg_match ('#<.*?>$#', $line)) return false;
838 | return $lastChar;
839 | }
840 |
841 | private static function greedilyNeedNextLine($line) {
842 | $line = trim ($line);
843 | if (!strlen($line)) return false;
844 | if (substr ($line, -1, 1) == ']') return false;
845 | if ($line[0] == '[') return true;
846 | if (preg_match ('#^[^:]+?:\s*\[#', $line)) return true;
847 | return false;
848 | }
849 |
850 | private function addLiteralLine ($literalBlock, $line, $literalBlockStyle, $indent = -1) {
851 | $line = self::stripIndent($line, $indent);
852 | if ($literalBlockStyle !== '|') {
853 | $line = self::stripIndent($line);
854 | }
855 | $line = rtrim ($line, "\r\n\t ") . "\n";
856 | if ($literalBlockStyle == '|') {
857 | return $literalBlock . $line;
858 | }
859 | if (strlen($line) == 0)
860 | return rtrim($literalBlock, ' ') . "\n";
861 | if ($line == "\n" && $literalBlockStyle == '>') {
862 | return rtrim ($literalBlock, " \t") . "\n";
863 | }
864 | if ($line != "\n")
865 | $line = trim ($line, "\r\n ") . " ";
866 | return $literalBlock . $line;
867 | }
868 |
869 | function revertLiteralPlaceHolder ($lineArray, $literalBlock) {
870 | foreach ($lineArray as $k => $_) {
871 | if (is_array($_))
872 | $lineArray[$k] = $this->revertLiteralPlaceHolder ($_, $literalBlock);
873 | else if (substr($_, -1 * strlen ($this->LiteralPlaceHolder)) == $this->LiteralPlaceHolder)
874 | $lineArray[$k] = rtrim ($literalBlock, " \r\n");
875 | }
876 | return $lineArray;
877 | }
878 |
879 | private static function stripIndent ($line, $indent = -1) {
880 | if ($indent == -1) $indent = strlen($line) - strlen(ltrim($line));
881 | return substr ($line, $indent);
882 | }
883 |
884 | private function getParentPathByIndent ($indent) {
885 | if ($indent == 0) return array();
886 | $linePath = $this->path;
887 | do {
888 | end($linePath); $lastIndentInParentPath = key($linePath);
889 | if ($indent <= $lastIndentInParentPath) array_pop ($linePath);
890 | } while ($indent <= $lastIndentInParentPath);
891 | return $linePath;
892 | }
893 |
894 |
895 | private function clearBiggerPathValues ($indent) {
896 |
897 |
898 | if ($indent == 0) $this->path = array();
899 | if (empty ($this->path)) return true;
900 |
901 | foreach ($this->path as $k => $_) {
902 | if ($k > $indent) unset ($this->path[$k]);
903 | }
904 |
905 | return true;
906 | }
907 |
908 |
909 | private static function isComment ($line) {
910 | if (!$line) return false;
911 | if ($line[0] == '#') return true;
912 | if (trim($line, " \r\n\t") == '---') return true;
913 | return false;
914 | }
915 |
916 | private static function isEmpty ($line) {
917 | return (trim ($line) === '');
918 | }
919 |
920 |
921 | private function isArrayElement ($line) {
922 | if (!$line) return false;
923 | if ($line[0] != '-') return false;
924 | if (strlen ($line) > 3)
925 | if (substr($line,0,3) == '---') return false;
926 |
927 | return true;
928 | }
929 |
930 | private function isHashElement ($line) {
931 | return strpos($line, ':');
932 | }
933 |
934 | private function isLiteral ($line) {
935 | if ($this->isArrayElement($line)) return false;
936 | if ($this->isHashElement($line)) return false;
937 | return true;
938 | }
939 |
940 |
941 | private static function unquote ($value) {
942 | if (!$value) return $value;
943 | if (!is_string($value)) return $value;
944 | if ($value[0] == '\'') return trim ($value, '\'');
945 | if ($value[0] == '"') return trim ($value, '"');
946 | return $value;
947 | }
948 |
949 | private function startsMappedSequence ($line) {
950 | return ($line[0] == '-' && substr ($line, -1, 1) == ':');
951 | }
952 |
953 | private function returnMappedSequence ($line) {
954 | $array = array();
955 | $key = self::unquote(trim(substr($line,1,-1)));
956 | $array[$key] = array();
957 | $this->delayedPath = array(strpos ($line, $key) + $this->indent => $key);
958 | return array($array);
959 | }
960 |
961 | private function returnMappedValue ($line) {
962 | $array = array();
963 | $key = self::unquote (trim(substr($line,0,-1)));
964 | $array[$key] = '';
965 | return $array;
966 | }
967 |
968 | private function startsMappedValue ($line) {
969 | return (substr ($line, -1, 1) == ':');
970 | }
971 |
972 | private function isPlainArray ($line) {
973 | return ($line[0] == '[' && substr ($line, -1, 1) == ']');
974 | }
975 |
976 | private function returnPlainArray ($line) {
977 | return $this->_toType($line);
978 | }
979 |
980 | private function returnKeyValuePair ($line) {
981 | $array = array();
982 | $key = '';
983 | if (strpos ($line, ':')) {
984 | // It's a key/value pair most likely
985 | // If the key is in double quotes pull it out
986 | if (($line[0] == '"' || $line[0] == "'") && preg_match('/^(["\'](.*)["\'](\s)*:)/',$line,$matches)) {
987 | $value = trim(str_replace($matches[1],'',$line));
988 | $key = $matches[2];
989 | } else {
990 | // Do some guesswork as to the key and the value
991 | $explode = explode(':',$line);
992 | $key = trim($explode[0]);
993 | array_shift($explode);
994 | $value = trim(implode(':',$explode));
995 | }
996 | // Set the type of the value. Int, string, etc
997 | $value = $this->_toType($value);
998 | if ($key === '0') $key = '__!YAMLZero';
999 | $array[$key] = $value;
1000 | } else {
1001 | $array = array ($line);
1002 | }
1003 | return $array;
1004 |
1005 | }
1006 |
1007 |
1008 | private function returnArrayElement ($line) {
1009 | if (strlen($line) <= 1) return array(array()); // Weird %)
1010 | $array = array();
1011 | $value = trim(substr($line,1));
1012 | $value = $this->_toType($value);
1013 | $array[] = $value;
1014 | return $array;
1015 | }
1016 |
1017 |
1018 | private function nodeContainsGroup ($line) {
1019 | $symbolsForReference = 'A-z0-9_\-';
1020 | if (strpos($line, '&') === false && strpos($line, '*') === false) return false; // Please die fast ;-)
1021 | if ($line[0] == '&' && preg_match('/^(&['.$symbolsForReference.']+)/', $line, $matches)) return $matches[1];
1022 | if ($line[0] == '*' && preg_match('/^(\*['.$symbolsForReference.']+)/', $line, $matches)) return $matches[1];
1023 | if (preg_match('/(&['.$symbolsForReference.']+)$/', $line, $matches)) return $matches[1];
1024 | if (preg_match('/(\*['.$symbolsForReference.']+$)/', $line, $matches)) return $matches[1];
1025 | if (preg_match ('#^\s*<<\s*:\s*(\*[^\s]+).*$#', $line, $matches)) return $matches[1];
1026 | return false;
1027 |
1028 | }
1029 |
1030 | private function addGroup ($line, $group) {
1031 | if ($group[0] == '&') $this->_containsGroupAnchor = substr ($group, 1);
1032 | if ($group[0] == '*') $this->_containsGroupAlias = substr ($group, 1);
1033 | //print_r ($this->path);
1034 | }
1035 |
1036 | private function stripGroup ($line, $group) {
1037 | $line = trim(str_replace($group, '', $line));
1038 | return $line;
1039 | }
1040 | }
1041 |
1042 | // Enable use of Spyc from command line
1043 | // The syntax is the following: php spyc.php spyc.yaml
1044 |
1045 | define ('SPYC_FROM_COMMAND_LINE', false);
1046 |
1047 | do {
1048 | if (!SPYC_FROM_COMMAND_LINE) break;
1049 | if (empty ($_SERVER['argc']) || $_SERVER['argc'] < 2) break;
1050 | if (empty ($_SERVER['PHP_SELF']) || $_SERVER['PHP_SELF'] != 'spyc.php') break;
1051 | $file = $argv[1];
1052 | printf ("Spyc loading file: %s\n", $file);
1053 | print_r (spyc_load_file ($file));
1054 | } while (0);
--------------------------------------------------------------------------------
/kirby/system.php:
--------------------------------------------------------------------------------
1 | load();
66 |
67 |
--------------------------------------------------------------------------------
/license.mdown:
--------------------------------------------------------------------------------
1 | #Kirby End User License Agreement
2 |
3 |
4 | This End User License Agreement (the "Agreement") is a binding legal agreement between you and the Bastian Allgeier GmbH (the "Author"). By installing or using the Kirby CMS (the "Software"), you agree to be bound by the terms of this Agreement. If you do not agree to the Agreement, do not download, install, or use the Software. Installation or use of the Software signifies that you have read, understood, and agreed to be bound by the Agreement.
5 |
6 | Revised on: 13 March, 2014
7 |
8 | ##Usage
9 |
10 | This Agreement grants a non-exclusive, non-transferable license to install and use a single instance of the Software on a specific Website. Additional Software licenses must be purchased in order to install and use the Software on additional Websites. The Author reserves the right to determine whether use of the Software qualifies under this Agreement. The Author owns all rights, title and interest to the Software (including all intellectual property rights) and reserves all rights to the Software that are not expressly granted in this Agreement.
11 |
12 | ##Backups
13 |
14 | You may make copies of the Software in any machine readable form solely for back-up purposes, provided that you reproduce the Software in its original form and with all proprietary notices on the back-up copy. All rights to the Software not expressly granted herein are reserved by the Author.
15 |
16 | ##Technical Support
17 |
18 | Technical support is provided as described on . No representations or guarantees are made regarding the response time in which support questions are answered.
19 |
20 | ##Refund Policy
21 |
22 | We offer a 14-day, money back refund policy.
23 |
24 | ##Restrictions
25 |
26 | You understand and agree that you shall only use the Software in a manner that complies with any and all applicable laws in the jurisdictions in which you use the Software. Your use shall be in accordance with applicable restrictions concerning privacy and intellectual property rights.
27 |
28 | ###You may not:
29 |
30 | Distribute derivative works based on the Software;
31 | Reproduce the Software except as described in this Agreement;
32 | Sell, assign, license, disclose, distribute, or otherwise transfer or make available the Software or its Source Code, in whole or in part, in any form to any third parties;
33 | Use the Software to provide services to others;
34 | Remove or alter any proprietary notices on the Software.
35 |
36 | ##No Warranty
37 |
38 | THE SOFTWARE IS OFFERED ON AN "AS-IS" BASIS AND NO WARRANTY, EITHER EXPRESSED OR IMPLIED, IS GIVEN. THE AUTHOR EXPRESSLY DISCLAIMS ALL WARRANTIES OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. YOU ASSUME ALL RISK ASSOCIATED WITH THE QUALITY, PERFORMANCE, INSTALLATION AND USE OF THE SOFTWARE INCLUDING, BUT NOT LIMITED TO, THE RISKS OF PROGRAM ERRORS, DAMAGE TO EQUIPMENT, LOSS OF DATA OR SOFTWARE PROGRAMS, OR UNAVAILABILITY OR INTERRUPTION OF OPERATIONS. YOU ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USE THE SOFTWARE AND ASSUME ALL RISKS ASSOCIATED WITH ITS USE.
39 |
40 | ##Term, Termination, and Modification.
41 |
42 | You may use the Software under this Agreement until either party terminates this Agreement as set forth in this paragraph. Either party may terminate the Agreement at any time, upon written notice to the other party. Upon termination, all licenses granted to you will terminate, and you will immediately uninstall and cease all use of the Software. The Sections entitled "No Warranty," "Indemnification," and "Limitation of Liability" will survive any termination of this Agreement.
43 |
44 | The Author may modify the Software and this Agreement with notice to you either in email or by publishing content on the Software website, including but not limited to changing the functionality or appearance of the Software, and such modification will become binding on you unless you terminate this Agreement.
45 |
46 | ##Indemnification.
47 |
48 | By accepting the Agreement, you agree to indemnify and otherwise hold harmless the Author, its officers, employers, agents, subsidiaries, affiliates and other partners from any direct, indirect, incidental, special, consequential or exemplary damages arising out of, relating to, or resulting from your use of the Software or any other matter relating to the Software.
49 |
50 | ##Limitation of Liability.
51 |
52 | YOU EXPRESSLY UNDERSTAND AND AGREE THAT THE AUTHOR SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES, INCLUDING BUT NOT LIMITED TO, DAMAGES FOR LOSS OF PROFITS, GOODWILL, USE, DATA OR OTHER INTANGIBLE LOSSES (EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES). SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF THE LIMITATION OR EXCLUSION OF LIABILITY FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES. ACCORDINGLY, SOME OF THE ABOVE LIMITATIONS MAY NOT APPLY TO YOU. IN NO EVENT WILL THE AUTHOR'S TOTAL CUMULATIVE DAMAGES EXCEED THE FEES YOU PAID TO THE AUTHOR UNDER THIS AGREEMENT IN THE MOST RECENT TWELVE-MONTH PERIOD.
53 |
54 | #Definitions
55 |
56 | ##Definition of Website
57 |
58 | A "Website" is defined as a single domain including sub-domains that operate as a single entity. What constitutes a single entity shall be at the sole discretion of the Author.
59 |
60 | ##Definition of Source Code
61 |
62 | The "Source Code" is defined as the contents of all HTML, CSS, JavaScript, and PHP files provided with the Software and includes all related image files and database schemas.
63 |
64 | ##Definition of an Update
65 |
66 | An "Update" of the Software is defined as that which adds minor functionality enhancements or any bug fix to the current version. This class of release is identified by the change of the revision to the right of the decimal point, i.e. X.1 to X.2
67 |
68 | The assignment to the category of Update or Upgrade shall be at the sole discretion of the Author.
69 |
70 | ##Definition of an Upgrade
71 |
72 | An "Upgrade" is a major release of the Software and is defined as that which incorporates major new features or enhancement that increase the core functionality of the software. This class of release is identified by the change of the revision to the left of the decimal point, i.e. 4.X to 5.X
73 |
74 | The assignment to the category of Update or Upgrade shall be at the sole discretion of the Author.
75 |
--------------------------------------------------------------------------------
/readme.mdown:
--------------------------------------------------------------------------------
1 | # Kirby 1
2 |
3 | **Deprecated. See http://github.com/getkirby**
4 |
5 |
--------------------------------------------------------------------------------
/site/cache/index.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getkirby-v1/starterkit/d547c0abcdf9e100abc55972243b7d83a783d867/site/cache/index.html
--------------------------------------------------------------------------------
/site/config/config.php:
--------------------------------------------------------------------------------
1 |
2 | copyright()) ?>
3 |
4 |
5 |