Exemple #1
0
 public static function parseConfig($path)
 {
     try {
         $content = file_get_contents($path);
         self::$params = Neon::decode($content);
     } catch (Exception $e) {
         error_log($e->getMessage());
         throw new configException('Cannot load config file');
     }
 }
Exemple #2
0
 /**
  * Generates configuration in NEON format.
  * @param  array
  * @return string
  */
 public function dump(array $data)
 {
     $tmp = array();
     foreach ($data as $name => $secData) {
         if ($parent = ConfigHelpers::takeParent($secData)) {
             $name .= ' ' . self::INHERITING_SEPARATOR . ' ' . $parent;
         }
         $tmp[$name] = $secData;
     }
     return "# generated by Nette\n\n" . Neon::encode($tmp, Neon::BLOCK);
 }
Exemple #3
0
 protected function attached($presenter)
 {
     parent::attached($presenter);
     if (!$presenter instanceof Presenter) {
         return;
     }
     //připojen presenter
     if (!isset($presenter->page)) {
         throw new InvalidStateException('FieldsPlugin attached to uncompatible Presenter');
     }
     $this->page = $presenter->page;
     $this->template->page = $presenter->page;
     $this->template->lang = $presenter->lang;
     $this->template->setTranslator(new TranslationsModel($presenter->lang));
     //parse fields
     $json = $this->page->getParent()->getMeta('.sectionFields');
     $sectionFields = array();
     try {
         if ($json) {
             $sectionFields = Neon::decode($json);
         }
     } catch (Exception $e) {
         $m = htmlspecialchars($e->getMessage());
         $this->error .= "<div class='control-group' title=\"{$m}\">.sectionFields not valid</div>";
     }
     $fields = array();
     $json = $this->page->getMeta('.fields');
     try {
         if ($json) {
             $fields = Neon::decode($json);
         }
     } catch (Exception $e) {
         $m = htmlspecialchars($e->getMessage() . "\"");
         $this->error .= "<div class='control-group' title=\"{$m}\">.fields not valid</div>";
     }
     $fields = array_merge($fields, $sectionFields);
     foreach ($fields as $k => $f) {
         if (substr($k, -1) == '_') {
             $k .= $this->page->lang;
         }
         $this->fields[$k] = $f;
     }
 }
Exemple #4
0
<pre>
<?php 
require 'Neon.php';
$data = Neon::decode('
# neon file - edit it now!

name: Homer

address:
	street: 742 Evergreen Terrace
	city: Springfield
	country: USA

phones: { home: 555-6528, work: 555-7334 }

children:
	- Bart
	- Lisa
	- Maggie


entity: Column(type="integer")

');
print_r($data);
echo '<hr>';
$neon = Neon::encode($data, Neon::BLOCK);
echo $neon;
Exemple #5
0
 /**
  * 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::$re) {
         self::$re = '~(' . implode(')|(', self::$patterns) . ')~Ami';
     }
     $parser = new self();
     $parser->tokenize($input);
     $res = $parser->parse(0);
     while (isset($parser->tokens[$parser->n])) {
         if ($parser->tokens[$parser->n][0] === "\n") {
             $parser->n++;
         } else {
             $parser->error();
         }
     }
     return $res;
 }
Exemple #6
0
        if ($data['operationResult'] == 'SUCCESS') {
            $people = array();
            foreach ($data['searchResults']['nameValuePairs'] as $key => $value) {
                $people[$key] = $value;
                foreach ($people as $person) {
                    foreach ($person['nameValuePair'] as $pair) {
                        if (isset($pair['name'])) {
                            $name = $pair['name'];
                        } else {
                            $name = null;
                        }
                        if (isset($pair['value'])) {
                            $value = $pair['value'];
                        } else {
                            $value = null;
                        }
                        $data['searchResults'][$key][$name] = $value;
                    }
                }
            }
            unset($data['searchResults']['nameValuePairs']);
            return $data;
        } else {
            return $data;
        }
    }
}
/* Start the NeonCRM Session */
$neon = new Neon();
$keys = array('orgId' => $neonId, 'apiKey' => $neonKey);
$neon->login($keys) or die("Failed to login to the NeonCRM System with OrgID " . $orgId . ".  Check the login/API settings in .ht_neon.php!  Error returned: " . $neon['responsemessage']);
Exemple #7
0
<?php

require_once '.ht_neon.php';
require_once 'neon.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>NeonCRM Test</title>
</head>

<body>

<?php 
echo "<p>hi</p>\n";
$neon = new Neon();
$keys = array('orgId' => $neonId, 'apiKey' => $neonKey);
$neon->login($keys);
$request = array('method' => 'common/listCustomFields', 'parameters' => array('searchCriteria.component' => 'Event'));
$result = $neon->go($request);
echo "<pre>\n";
var_dump($result);
echo "</pre>\n";
echo "<p>post.</p>\n";
?>
</body>
</html>
Exemple #8
0
 /**
  * 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 Tokenizer(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;
 }
Exemple #9
0
 /**
  * For each source check for a config file and mix in the options.
  * 
  * @internal
  * @param  array|string  $sources
  * @return array
  */
 protected function config($sources)
 {
     $sources = (array) $sources;
     $options = Config::get('apigen::default');
     $options['source'] = array();
     // Walk through each source and mix in any ApiGen options found.  If
     // no options are found then we just add the source to the list.
     foreach ($sources as $path) {
         if (is_file($path . 'apigen.neon')) {
             $config = Neon::decode(file_get_contents($path . 'apigen.neon'));
             // Do not allow the user to override the destination, this
             // should be done using the bundle config file instead.
             unset($config['destination']);
         } else {
             $config = array();
         }
         // If apigen.neon did not specify a source then we shall do it
         // ourselves.  Note: source needs to be absolute or relative to
         // the base path, not the bundle path.
         if (!isset($config['source'])) {
             $config['source'] = $path;
         }
         // Recursively merge in the config so we get all the excludes.
         $options = array_merge_recursive($options, $config);
     }
     // Only allow a title when there's once source
     if (count($sources) > 1 and isset($options['title'])) {
         unset($options['title']);
     }
     return $options;
 }
Exemple #10
0
<?php

/**
 * Template Name: Events Page
 *
 * @package aaron
 * The template for displaying all pages.
 */
require_once __DIR__ . '/../library/php/neon.php';
$neon = new Neon();
$keys = array('orgId' => 'taasc', 'apiKey' => '801b431ffc67a58a5f238b75c65db18a');
$neon->login($keys);
get_header();
?>
		<main id="main" class="site-main" role="main">
      <div class="single-page-content">
        <iframe src="http://taasc.z2systems.com/np/clients/taasc/publicaccess/eventCalendarSmall.jsp" scrolling="no" frameborder="no" allowtransparency="true" width="100%" height="'+height+'"></iframe>

        <p><?php 
date_default_timezone_set('US/Eastern');
$today_month_val = date("n");
$today_day_val = date("j");
$today_year_val = date("Y");
echo $today_month_val;
echo $today_day_val;
echo $today_year_val;
?>
</p>
  		<?php 
while (have_posts()) {
    the_post();