/** * Generates configuration in NEON format. * @return string */ public function dump(array $data) { $tmp = array(); foreach ($data as $name => $secData) { if ($parent = NConfigHelpers::takeParent($secData)) { $name .= ' ' . self::INHERITING_SEPARATOR . ' ' . $parent; } $tmp[$name] = $secData; } return "# generated by Nette\n\n" . NNeon::encode($tmp, NNeon::BLOCK); }
<?php require '../../../../../../wp-load.php'; $shortcode = $_REQUEST['plugin']; $ver = $GLOBALS['aitThemeShortcodes'][$shortcode]; if ($ver == 1) { $ver = ''; } $configFile = dirname(__FILE__) . "/{$shortcode}/config{$ver}.neon"; if (!file_exists($configFile)) { $configFile = dirname(__FILE__) . "/{$shortcode}/config.neon"; } $data = NNeon::decode(file_get_contents($configFile, true)); if (isset($data['width'])) { $width = $data['width']; } else { $width = '640'; } if (isset($data['height'])) { $height = $data['height']; } else { $height = '700'; } if (isset($data['title'])) { $title = $data['title']; } else { $title = $shortcode . ' shortcodes'; } wp_enqueue_script('jquery'); wp_enqueue_script('thickbox'); wp_enqueue_style('thickbox');
/** * Decodes a NEON string. * @param string * @return mixed */ public static function decode($input) { if (!is_string($input)) { throw new InvalidArgumentException("Argument must be a string, " . gettype($input) . " given."); } if (!self::$tokenizer) { self::$tokenizer = new NTokenizer(self::$patterns, 'mi'); } $input = str_replace("\r", '', $input); self::$tokenizer->tokenize($input); $parser = new self; $res = $parser->parse(0); while (isset(self::$tokenizer->tokens[$parser->n])) { if (self::$tokenizer->tokens[$parser->n][0] === "\n") { $parser->n++; } else { $parser->error(); } } return $res; }
/** * Loads and parses Neon theme config files * @param string $filename Absoluth path to config file * @return array */ function loadConfig($filename) { $file = realpath($filename); if ($file === false) { return false; } $options = NNeon::decode(file_get_contents($file)); return $options; }