Angel’s Blog

Someone right now is looking pretty tired, staring at a laptop trying to get inspired…

extContent in action (part1)


Basic templates management. In the following video you will see how to split and organize the template of your future site

Content adding and editing:

Menus (templates, structure, usage)

Content Indexing and php tags options

Here you can find the final result :  http://dev.ajaxinside.de/projects/extcontent/


extContent concept


Application Environment (XFCE like TaskBar and Custom WindowManager)

Content Management

Menu’s Structures

Indexing of Content Tables

This is just a technology preview developed with extJS 3.0

You can find more detailed videos here

I am not planning a release in the near future.


SDB pre-release


Get the Flash Player to see the wordTube Media Player.

Used Technologie:
the ExtJS framework,
custom php to handle the server-side stuff,
a lot of patience and sleepless nights


Eclipse for web development


After some sleepless nights I succeed to pack up an Eclipse distribution that almost match all my needs.
It’s made for php, extjs (javascript) development with all the extra tools you will need like Zend Debugger, FTP / SSH client, SVN and etc.

Here a small list of everything extra added :

JRE is included but you can replace it with another one to match your arhitechture (jre folder). Currently there is a version for Windows. If i have some time i will added and one for Linux and OSX. Basically you can use the configuration and features folders and copy them over another eclipse build, but i never tried it.

I am not the author of anything ! I just combined some free plugins and features. If you care about licenses and etc., please take a look on the vendor’s sites. It’s all free software, but you never know …

This software comes with absolute no guarantee, so please use on your own risk.

Installation:

Unpack and start.

Download here


OC – beta 1 (preview)


Get the Flash Player to see the wordTube Media Player.

OC – Operatives Controlling Application

Developed with extjs 2.2 framework + custom php framework

Current status – Development + bugfixing


How a little server-side coder became a desktop application developer


I always know that one day i will write cool desktop application. After some researching i start using the extjs framework for AJAX. If you don’t know it, don’t waste time and give it a try!

Now… take a look on the uploaded pictures. This + Adobe AIR = native platform independent desktop application…

How cool can this be ?!


My Common class for JSON & php


I always wanted to share some source, so i will do it now. It’s a very basic Common class in php for connecting to database and executing queries. Nothing special but may help to somebody new to php.
This Class provides a easy way to get a JSON formated output from your mysql queries and update the records back to the database.
Works only with php 5.2 or higher !

  1. class Common {
  2.  
  3.  function json2query($table_name, $primary_key=null, $output) {
  4.   $output = str_replace('\\','',$output);
  5.   $counter = 0;
  6.   $array = json_decode($output, true);
  7.   foreach ($array as $key=>$value) {
  8.    $query = array();
  9.    foreach ($value as $field_name=>$field_value) {
  10.     if ($primary_key==$field_name) {
  11.      $where_clause = $field_name.'='.$field_value;
  12.     } else {
  13.      array_push($query,'`'.$field_name.'`='.SQLFiendly($field_value));
  14.     }
  15.    }
  16.  
  17.    $array_query[$counter++] = sprintf('UPDATE %s SET %s WHERE %s',$table_name, implode(",",$query), $where_clause);
  18.  
  19.   }
  20.   return $array_query;
  21.  }
  22.  /**
  23.   * Enter description here…
  24.   *
  25.   * @param unknown_type $search
  26.   * @param unknown_type $replace
  27.   * @param unknown_type $subject
  28.   * @return unknown
  29.   */
  30.  function StrReplaceFirst($search, $replace, $subject) {
  31.   // replaces the first occurance of $search in $subject with $replace;
  32.   // returns $subject unchanged if no match
  33.   // may be rewritten with regexpressions if there are volunteers
  34.   if ((!$subject) or (!$search)) return $subject;
  35.   $sp = strpos($subject, $search);
  36.   if ($sp!==false) {
  37.    return (substr($subject, 0, $sp) . $replace . substr($subject, $sp+strlen($search)));
  38.   } else {
  39.    return $subject;
  40.   }
  41.  
  42.  }
  43.  
  44.  /**
  45.   * Enter description here…
  46.   *
  47.   * @param unknown_type $theValue
  48.   * @param unknown_type $theType
  49.   * @param unknown_type $theDefinedValue
  50.   * @param unknown_type $theNotDefinedValue
  51.   * @return unknown
  52.   */
  53.  function sqlValue($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {
  54.   $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
  55.   switch ($theType) {
  56.   case "text":
  57.    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  58.   break;
  59.   case "int":
  60.    $theValue = ($theValue !== "") ? intval($theValue) : "NULL";
  61.   break;
  62.   }
  63.  
  64.  return $theValue;
  65.  }
  66.  
  67.  function dbconnect() {
  68.   global $config;
  69.   $link = mysql_pconnect($config['host'], $config['username'], $config['password'])
  70.    or exit(mysql_error());
  71.   mysql_select_db($config['database'], $link);
  72.   return true;
  73.  }
  74.  
  75.  /**
  76.   * Enter description here…
  77.   *
  78.   * @param unknown_type $result
  79.   * @param unknown_type $total
  80.   * @return unknown
  81.   */
  82.  function mysqlresult2array($result, $total = true) {
  83.   $array=array();
  84.   $total = mysql_num_rows($result);
  85.   //$array['total'] = $total;
  86.   while ($row=mysql_fetch_assoc($result)) {
  87.    //var_dump($row);
  88.    $array[]=$row;
  89.   }
  90.  
  91.    mysql_free_result($result);
  92.    return '{"data":'.json_encode($array).'}';
  93.  }
  94.  
  95.  /**
  96.   * Enter description here…
  97.   *
  98.   * @param unknown_type $query
  99.   * @param unknown_type $values
  100.   * @return unknown
  101.   */
  102.  function query($query, $values=NULL) {
  103.   $this->dbconnect();
  104.   if (is_array($values)) {
  105.    foreach ($values as $value=>$type) {
  106.     $query = $this->StrReplaceFirst('%s', $this->sqlValue($value, $type), $query);
  107.    }
  108.   }
  109.  
  110.   $execute = mysql_query($query) or print mysql_error()."\n
  111. <h1>".$query."</h1>
  112. ";
  113.  
  114.   if (preg_match('/SELECT/', $query)) {
  115.    return $this-&gt;mysqlresult2array($execute);
  116.   } else {
  117.    return true;
  118.   }
  119.  
  120.  }
  121.  
  122.  /**
  123.   * Enter description here…
  124.   *
  125.   * @param unknown_type $url
  126.   */
  127.  function goto($url=null) {
  128.   if (!empty($url)) {
  129.    header('Location: '.$url);
  130.   } else {
  131.  
  132.   }
  133.  }
  134. }

And a really simple usage:

  1. $a = new Common();
  2. $json_output = $a-&gt;query('SELECT * FROM table WHERE 1');
  3. echo $json_output;

It’s time for php 5.2 or higher !


I was wondering, when i will switch to php 5.x ?! So now i will tell you the reason, it’s called JSON !

After starting working with extjs, i was searching for a faster way to develop a stable solution, without writing 18 hours / day. Here it is, it’s called JSON and it’s a way to transfer data between php arrays (from example) and a browser-side ajax objects.

The miracle functions are called : json_encode and json_decode

I will write some simple code when i get some free time.