public function generateRedis()
 {
     $namespace = \Zule\Tools\Config::zc()->framework->application_namespace;
     $columns = [];
     foreach ($_POST['column'] as $col) {
         if ($col) {
             $columns[] = ['name' => $col, 'camel' => camel($col), 'l_camel' => lCamel($col)];
         }
     }
     $model = $_POST['model_name'];
     $s = new \Smarty();
     $s->assign('model_name', camel($model));
     $s->assign('namespace', $namespace . '\\Models');
     $s->assign('system', 'Zule');
     $s->assign('class_name', camel($model));
     $s->assign('extend_path', '\\Zule\\Models\\Model');
     $s->assign('impl_date', date('Y-m-d H:i:s'));
     $s->assign('use_unsafe_setters', 0);
     $s->assign('table_name', $model);
     $s->assign('columns', $columns);
     $s->assign('primary_key', $model);
     $gen = new Generator("../models/" . camel($model) . '.php');
     $gen->generate($s, 'model_redis');
     $s->assign('namespace', $namespace . '\\Models\\Data');
     $s->assign('extend_path', '\\Zule\\Models\\Data\\Redis');
     $gen = new Generator("../models/Data/" . camel($model) . '.php');
     $gen->generate($s, 'gateway_redis');
 }
Example #2
0
 public function awaken()
 {
     // Get database columns & primary keys
     $db = \Zule\Tools\DB::zdb();
     foreach ($db->describeTable($this->tableName) as $column) {
         if (in_array($this->tableName . '_' . $column['COLUMN_NAME'], array_keys($_POST))) {
             // column wants getters/setters
             $col = $column['COLUMN_NAME'];
             $this->columns[$col] = ['name' => $col, 'camel' => camel($col), 'l_camel' => lCamel($col)];
             if ($column['PRIMARY']) {
                 $this->primaryKeys[] = $col;
             }
         } else {
             if ($column['PRIMARY']) {
                 // no getter/setter set for primary, but gateway still exists
                 $this->primaryKeys[] = $column['COLUMN_NAME'];
             }
         }
     }
     return $this;
 }
 // $table is scheduled for generation
 $s = new \Smarty();
 $model = $_POST["class_{$table}"];
 $s->assign('model_name', $model);
 $s->assign('namespace', $namespace);
 $s->assign('system', $system);
 $s->assign('php_open', '<?php');
 $columns = [];
 $camels = [];
 $lCamels = [];
 foreach ($db->describeTable($table) as $column) {
     if (in_array($table . '_' . $column['COLUMN_NAME'], array_keys($_POST))) {
         // column wants getters/setters
         $col = $column['COLUMN_NAME'];
         $columns[] = $col;
         $camels[$col] = camel($col);
         $lCamels[$col] = lCamel($col);
         if ($column['PRIMARY']) {
             $primaryKey = $col;
         }
     } else {
         if ($column['PRIMARY']) {
             // no getter/setter set for primary, but gateway still exists
             $primaryKey = $column['COLUMN_NAME'];
         }
     }
 }
 $s->assign('generate_gateway', isset($_POST['make_gateway']) ? yes : no);
 $s->assign('columns', $columns);
 $s->assign('camels', $camels);
 $s->assign('lCamels', $lCamels);
Example #4
0
File: Frix.php Project: ricobl/frix
	static function app ($app_name) {
		
		if (!array_key_exists($app_name, Frix::$app_cache)) {
			
			// Import app definition file
			import(join_path(array(Frix::config('APPS', $app_name), 'app.php')));
			
			// Convert app-name to app-classname: news -> NewsApp
			// $app_class = ucfirst(strtolower($app_name)) . 'App';
			$app_class = camel($app_name) . 'App';
			
			// Create a new instance of the app in the cache
			Frix::$app_cache[$app_name] = new $app_class($app_name);
			
		}
		
		// Return the app from the cache
		return Frix::$app_cache[$app_name];
		
	}
Example #5
0
<?php

require_once '../tools/Loader.php';
$s = new Smarty();
function camel($name)
{
    $name[0] = strtoupper($name[0]);
    while ($pos = strpos($name, '_')) {
        $f = substr($name, 0, $pos);
        $l = substr($name, $pos + 1);
        $l[0] = strtoupper($l[0]);
        $name = $f . $l;
    }
    return $name;
}
$db = \Zule\Tools\DB::zdb();
$dbTables = $db->listTables();
$tables = [];
$names = [];
foreach ($_POST as $table => $useless) {
    if (in_array($table, $dbTables)) {
        $names[$table] = camel($table);
        $tables[$table] = [];
        foreach ($db->describeTable($table) as $column) {
            $tables[$table][] = $column['COLUMN_NAME'];
        }
    }
}
$s->assign('tables', $tables);
$s->assign('names', $names);
$s->display('models2.tpl');
Example #6
0
 /**
  * @param $array
  * @param bool|false $inForeach
  * @return array|string
  */
 protected function arrayToCamelcase($array, $inForeach = false)
 {
     $result = [];
     foreach ($array as $value) {
         if (is_array($value)) {
             $result += $this->arrayToCamelcase($value, true);
         }
         $value = explode('.', $value);
         $value = end($value);
         $result[] = $value;
     }
     return $inForeach ? $result : $this->str - camel(implode('_', $result));
 }
Example #7
0
 /**
  * Provides dynamic calls.
  *
  * @param $name
  * @param array $arguments
  * @throws \PragmaRX\ZipCode\Exceptions\PropertyDoesNotExists
  * @return mixed
  */
 public function __call($name, array $arguments)
 {
     if (substr($name, 0, 3) == 'get') {
         $property = substr($name, 3);
         $possibleNames = [$property, snake($property), studly($property), camel($property)];
         foreach ($possibleNames as $name) {
             if (isset($this->publicProperties[$name])) {
                 return $this->publicProperties[$name];
             }
         }
     }
     throw new PropertyDoesNotExists("Property '{$name}' does not exists in Result object.");
 }
Example #8
0
	private function context_options ($app_name, $model_slug) {
		
		// Get app
		$app = $this->context_app($app_name);
		
		$admin = Frix::app('admin');
		
		// Save model slug
		$this->model_slug = $model_slug;
		// Convert slug to class-name: cms_page -> CmsPage
		$this->model_name = camel($model_slug);
		// Get the Options from the registry
		$this->options = $admin->registry[$app_name][$this->model_name];
		
		// Add to the context
		self::$context['options'] = $this->options;
		self::$context['model'] = $this->options->meta;
		
		// Add 'Items' to the breadcrumbs
		$this->context_breadcrumbs($this->options->meta->verbose_name_plural, url(self::$root, $this->options->meta->admin_url));
		
		return $this->options;
		
	}