function get_parent_classes($class = null, $plist = array())
 {
     $class = $class ? $class : $this;
     $parent = get_parent_class($class);
     if ($parent) {
         $plist[] = $parent;
         $plist = get_parent_classes($parent, $plist);
     }
     return $plist;
 }
Ejemplo n.º 2
0
 protected static function allschema()
 {
     $schema = [];
     foreach (class_real_uses(get_called_class()) as $trait) {
         if (!function_exists($func = "{$trait}__schema")) {
             continue;
         }
         $schema[] = $func();
     }
     foreach (get_parent_classes(get_called_class()) as $class) {
         $schema[] = $class::schema();
     }
     $schema[] = static::schema();
     return array_merge(...$schema);
 }
Ejemplo n.º 3
0
function class_real_uses($class)
{
    static $caches = [];
    if (isset($caches[$class])) {
        return $caches[$class];
    }
    $traits = [];
    foreach (get_parent_classes($class) as $parent) {
        $traits[] = class_uses_recursive($parent);
    }
    $traits[] = class_uses_recursive($class);
    $traits = array_filter($traits);
    return $caches[$class] = $traits ? array_unique(array_merge(...$traits)) : [];
}
Ejemplo n.º 4
0
	function render () {
		
		// Create the template using the class-tree to find a template file
		$t = new Template(get_parent_classes($this, 'frix/form/%s'));
		
		// Set field type
		def($this->attrs['type'], $this->type);
		
		// Set name and id attributes (if not set)
		def($this->attrs['name'], $this->name);
		def($this->attrs['id'], 'id_' . $this->attrs['name']);
		
		// Fill the context values
		$context = array(
			'field' => $this,
		);
		
		// Return the rendered template
		return $t->render($context);
		
	}
Ejemplo n.º 5
0
 public function VarDump($var, $depth = 0)
 {
     if ($depth == 0) {
         self::$object_cache = array();
     }
     if (!isset(self::$id_count)) {
         self::$id_count = 1;
     }
     $_replace = array("\n" => '<i>&#92;n</i>', "\r" => '<i>&#92;r</i>', "\t" => '<i>&#92;t</i>');
     if (is_array($var)) {
         $results = '<b style="color:white;background-color:blue">Array (' . count($var) . ')</b>';
         if (!empty($var)) {
             self::$id_count++;
             $results = '<span onClick="swap_content(\'debug' . self::$id_count . '\')" style="cursor:pointer;white-space:nowrap;color:white;background-color:blue">' . $results . '</span>';
             $results .= '<span id="debug' . self::$id_count . '" style="display:none;white-space:nowrap;background-color:blue">';
             foreach ($var as $curr_key => $curr_val) {
                 $return = self::VarDump($curr_val, $depth + 1);
                 $results .= "<br />" . str_repeat('&nbsp;', $depth * 2) . '<b style="color:white;background-color:blue">' . strtr($curr_key, $_replace) . ' =&gt;</b> ' . $return;
             }
             $results .= '</span>';
         }
     } else {
         if (is_object($var)) {
             $seen = false;
             if (!self::$DebugRD && is_a($var, 'RD')) {
                 $results = 'RDT_HTMLDebug::DebugRD == false';
             } else {
                 foreach (self::$object_cache as $object) {
                     if ($object === $var) {
                         $seen = true;
                     }
                 }
                 if (!$seen) {
                     self::$object_cache[] = $var;
                     if (in_array('BaseObject', get_parent_classes($var))) {
                         $object_vars = $var->toArray();
                         $object_name = 'Propel BaseObject';
                     } else {
                         $object_vars = get_object_vars($var);
                         $object_name = 'Object';
                     }
                     $results = '<b style="color:white;background-color:blue">' . get_class($var) . ' ' . $object_name . ' (' . count($object_vars) . ')</b>';
                     if (!empty($object_vars)) {
                         self::$id_count++;
                         $results = "<span onClick=\"swap_content('debug" . self::$id_count . "')\" style=\"cursor:pointer;white-space:nowrap\">" . $results . '</span></b>';
                         $results .= "<span id=\"debug" . self::$id_count . "\" style=\"display:none;white-space:nowrap;background-color:blue\">";
                         foreach ($object_vars as $curr_key => $curr_val) {
                             $return = self::VarDump($curr_val, $depth + 1);
                             $results .= '<br />' . str_repeat('&nbsp;', $depth * 2) . '<b style="color:white;background-color:blue">' . strtr($curr_key, $_replace) . ' =&gt;</b> ' . $return;
                         }
                         $results .= '</span>';
                     }
                 } else {
                     $results = 'recursion blocked';
                 }
             }
         } else {
             if (is_resource($var)) {
                 $results = '<i style="color:white;background-color:red">' . (string) $var . '</i>';
             } else {
                 if (is_bool($var)) {
                     $results = '<b style="color:';
                     $results .= $var ? 'green">true' : 'red">false';
                     $results .= '</b>';
                     /*  } else if (is_binary($var)) {
                        	$results = '<b style="red">BINARY</b>'; */
                 } else {
                     if (is_float($var) || is_int($var)) {
                         $results = '<b style="color:red">' . (string) $var . '</b>';
                     } else {
                         if (is_null($var)) {
                             $results = '<b style="color:red">NULL</b>';
                         } else {
                             if ($var === "" || $var === '') {
                                 $results = '<i style="color:white;background-color:red">empty</i>';
                             } else {
                                 $results = '<i style="color:white;background-color:green">"' . strtr(htmlspecialchars($var), $_replace) . '"</i>';
                             }
                         }
                     }
                 }
             }
         }
     }
     //		    if (!self::$SwapContentDisplayed) {
     $results .= self::$SwapContentJS;
     self::$SwapContentDisplayed = true;
     //		   	}
     return $results;
 }
Ejemplo n.º 6
0
Archivo: Form.php Proyecto: ricobl/frix
	function render () {
		
		// Create the template using the class-tree to find a template file
		$t = new Template(get_parent_classes($this, 'frix/form/%s'));
		
		// Fill the context values
		$context = array(
			'label' => $this,
			'contents' => $this->contents,
		);
		
		// Return the rendered template
		return $t->render($context);
		
	}