Ejemplo n.º 1
0
 /**
  * check if we're
  * given the needed
  * keys. Additionally add
  * client checks
  *
  * token string
  * expires integer
  */
 public function setup($data)
 {
     if (is_object($data[0])) {
         $data = Converter::toArray($data[0]);
     }
     foreach ($data as $k => $d) {
         if (!in_array($k, array("token", "expires"))) {
             throw new CatapultApiException("{$k} is not a valid key for endpoint token");
         }
     }
     $arr = array('token', 'expires');
     foreach ($arr as $a) {
         if (isset($data[$a])) {
             $this->{$a} = $data[$a];
         }
     }
     // important don't serialize
     // when sending in a Endpoints object
     $this->serialize = FALSE;
 }
Ejemplo n.º 2
0
 /**
  * check if we're 
  * given the needed
  * keys. Additionally add
  * client checks 
  *
  * password > 6 characters
  * realm is four point
  * username no check here
  */
 public function setup($data)
 {
     if (is_object($data[0])) {
         $data = Converter::toArray($data[0]);
     }
     foreach ($data as $k => $d) {
         if (!in_array($k, array("username", "password", "realm"))) {
             throw new CatapultApiException("{$k} is not a valid key for endpoint credentials");
         }
     }
     $arr = array('username', 'password', 'realm');
     foreach ($arr as $a) {
         if (isset($data[$a])) {
             $this->{$a} = $data[$a];
         }
     }
     // important don't serialize
     // when sending in a Endpoints object
     $this->serialize = FALSE;
 }
Ejemplo n.º 3
0
<?php

include_once 'Converter.php';
//Create a json test string
$testString = '{"name":"oreofeolurin","sex":"male","country":"nigeria","origin":"Ilaro"}';
//Call our toArray function on it
$array = Converter::toArray($testString);
//Header for array section
echo "<h4>Array</h4>";
//Lets make sure the right format was used
if ($array == NULL) {
    echo "Bad JSON";
} else {
    var_dump($array);
}
echo "<br/>";
//Header for json object section
echo "<h4>JSON</h4>";
//lets get our decoded array as test array
$testArray = $array;
//Call our toJson function on it
$json = Converter::toJson($testArray);
//Lets Handle success/failure
if ($json) {
    var_dump($json);
} else {
    echo "Error ecoding json";
}
Ejemplo n.º 4
0
 public function __construct()
 {
     $data = Ensure::Input(func_get_args(), Converter::toArray(json_decode(file_get_contents("php://input"))));
     parent::_init($data, new Call());
 }
Ejemplo n.º 5
0
 /**
  * make all 
  * properties an array
  *
  */
 public function toArray()
 {
     $proto = Converter::toArray($this);
     $not = array('primary_method', 'lastUpdate', 'subfunctions', 'client', 'path', 'hasPath');
     // we only need key value
     foreach ($proto as $k => $p) {
         if (in_array($k, $not)) {
             unset($proto[$k]);
         }
     }
     return $proto;
 }
Ejemplo n.º 6
0
        if (preg_match('#(^|\\n)(\\t| {1,3})(?:[^ ])#', $request['content'])) {
            Notify::error($speak->notify_invalid_indent_character);
            Guardian::memorize($request);
        }
        $k = Text::parse(str_replace(array('Menu::', '()'), "", $request['key']), '->array_key');
        if (!$key) {
            if (isset($menus[$k])) {
                Notify::error(Config::speak('notify_exist', '<code>Menu::' . $k . '()</code>'));
            }
        } else {
            unset($menus[$key]);
        }
        if ($k === "" || $k === '__') {
            Notify::error(Config::speak('notify_error_empty_field', $speak->name));
        }
        $menus[$k] = Converter::toArray($request['content'], S, '    ');
        $P = array('data' => $request);
        if (!Notify::errors()) {
            ksort($menus);
            File::serialize($menus)->saveTo(STATE . DS . 'menu.txt', 0600);
            Notify::success(Config::speak('notify_success_' . (!$key ? 'created' : 'updated'), $speak->menu));
            Weapon::fire(array('on_menu_update', 'on_menu_' . (!$key ? 'construct' : 'repair')), array($G, $P));
            Guardian::kick($key !== $k ? $config->manager->slug . '/menu' : $config->manager->slug . '/menu/repair/key:' . $key);
        }
    }
    Shield::lot(array('segment' => 'menu', 'id' => $key, 'content' => $menu_raw))->attach('manager');
});
/**
 * Menu Killer
 * -----------
 */
Ejemplo n.º 7
0
 private static function __fields(&$results, $FP)
 {
     // Initialize custom field(s) with the default value(s) so that
     // user(s) don't have to write `isset()` function multiple time(s)
     // just to prevent error message(s) because of the object key(s)
     // that is not available in the old post(s).
     $fields = self::state_field(null, array(), true, rtrim($FP, ':'));
     foreach ($fields as $k => $v) {
         $s = isset($results['fields'][$k]) && trim($results['fields'][$k]) !== "" ? $results['fields'][$k] : "";
         if ($s === "") {
             // For `option` field type, the first option will be used as the default value
             if ($v['type'] === 'option' || $v['type'] === 'o') {
                 $vv = array_keys(Converter::toArray($v['value']));
                 if (isset($v['placeholder']) && trim($v['placeholder']) !== "") {
                     // do nothing ...
                 } else {
                     $s = isset($vv[0]) ? $vv[0] : "";
                 }
                 // For `boolean` field type, empty value is equal to `false`
             } else {
                 if ($v['type'] === 'boolean' || $v['type'] === 'b') {
                     $s = false;
                 }
             }
         } else {
             // For `file` field type, the original custom field value is used to limit the file extension
             // So we have to check the existence of the file first. If it does not exist, then it may be
             // contained with the file extension(s), not with a file name
             if ($v['type'] === 'file' || $v['type'] === 'f') {
                 $e = File::E($s, false);
                 $s = $e !== false ? File::exist(SUBSTANCE . DS . $e . DS . $s, "") : "";
             }
         }
         $results['fields'][$k] = $s;
     }
     unset($fields, $s);
 }
Ejemplo n.º 8
0
 public function __construct()
 {
     $data = Ensure::Input(func_get_args, Converter::toArray(json_decode(file_get_contents("php://input"))));
     return new ConferenceMember($data);
 }
Ejemplo n.º 9
0
     $html .= '</label>';
 } else {
     if ($type === 'boolean' || $type === 'b') {
         $html .= '<div class="grid-group grid-group-boolean">';
         $html .= '<span class="grid span-2"></span>';
         $html .= '<span class="grid span-4">';
         $html .= Form::checkbox('fields[' . $key . '][value]', !empty($value['value']) ? $value['value'] : 1, isset($field[$key]) && !empty($field[$key]), $value['title']) . $description;
         $html .= '</span>';
         $html .= '</div>';
     } else {
         if ($type === 'option' || $type === 'o') {
             $html .= '<label class="grid-group grid-group-option">';
             $html .= '<span class="grid span-2 form-label">' . $title . '</span>';
             $html .= '<span class="grid span-4">';
             $select = isset($field[$key]) ? $field[$key] : "";
             $options = Converter::toArray($value['value'], S, '  ');
             if (isset($value['placeholder']) && trim($value['placeholder']) !== "") {
                 $options = array("" => $value['placeholder']) + $options;
             }
             $html .= Form::select('fields[' . $key . '][value]', $options, $select, array('class' => 'select-block'));
             $html .= '</span>';
             $html .= '</label>';
         } else {
             if ($type === 'file' || $type === 'f') {
                 $v = isset($value['value']) && $value['value'] !== "" ? $value['value'] : false;
                 $vv = isset($field[$key]) && $field[$key] !== "" ? File::E($field[$key]) . DS . File::path($field[$key]) : false;
                 $has_file = $vv !== false && file_exists(SUBSTANCE . DS . $vv) && is_file(SUBSTANCE . DS . $vv);
                 $html .= '<div class="grid-group grid-group-file' . ($has_file ? ' grid-group-boolean' : "") . '">';
                 $html .= !$has_file ? '<span class="grid span-2 form-label">' . $title . '</span>' : '<span class="grid span-2"></span>';
                 $html .= '<span class="grid span-4">';
                 if (!$has_file) {
Ejemplo n.º 10
0
 public function __construct()
 {
     $data = Ensure::Input(func_get_args(), Converter::toArray(json_decode("php://input")));
     return parent::_init($data, new Conference());
 }