10 Ways To Make Your Site Accessible Using Web Standards

I want to share this article I found really interesting and well explained. It talks about the step and standards to be followed if you want your site to be displayed nicely in all browsers.

This is one of my favourites blogs (if not MY favourite!) , check it out HERE.

Accesability

No Comments

Getting list elements with jQuery

I’m a jQuery newbie but i’ve been enjoying a lot with this “magic” framework and its plugins. I would like to publish some little functions I used in my last project hoping they can help someone as others help me :)

Html list Example :

<ul id="menu">
	<li><a>Link_1</a>
<ul>
	<li><a>Link_1_1</a></li>
	<li><a>Link_1_2</a></li>
</ul>
</li>
	<li><a>Link_2</a></li>
	<li><a>Link_3 </a></li>
</ul>
  1. Get the LEVEL of an element within the list:
?View Code JAVASCRIPT
$(document).ready(function() {
     $('#menu li a').click(function(){
          return $(this).parents("ul").length;
          //will returns 1 for elements link_1, link_2 and link_3,
          //and 2 for sublevels
      });
});
  1. Get UL parent  element of  a link
?View Code JAVASCRIPT
$(document).ready(function() {
     $('#menu li a').click(function(){
          return $(this).parent("li").parent("ul");
          //return $(this).parent("li").parent("ul").attr("id"); //if it has it
      });
});
  1. Get next UL element of a link
?View Code JAVASCRIPT
$(document).ready(function() {
     $('#menu li a').click(function(){
          return $(this).parent("li").children("ul:first");
          //return $(this).parent("li").children("ul:first").attr("id"); //if it has it
      });
});
No Comments

PHP UK Conference 2009

Since I started to be a PHP fan I’ve always wanted to be at this PHP Conferences. Finally I’m able to go to my first one (in London) and for those who are interested here is the link.

http://www.phpconference.co.uk/

The Conference will take place at the Olympia Conference Centre, London, the 27th of February. Definitely there are some talks I really want to look at:

The future’s so bright, I gotta wear shades!

by Aral Balkan

This is an awesome time to be a developer! The distinction between rich-client web, desktop, and mobile applications is narrowing. Web developers can now build cross-platform desktop apps using web technologies. Mac developers can now develop for the sexiest mobile phone on earth, and you have access to APIs and services that let you map the world, create real-time, multi-user experiences, and augment and expand reality in previously unimaginable ways.

Are you excited yet? You’ve got dynamic, rapid languages and frameworks like Python, Django, PHP, Rails, Objective-C and mature development environments like XCode, Visual Studio, and Eclipse. You have commodity hardware, commodity software, and free access to more information at your fingertips than has ever been available. And you have access to infinitely-scalable utility computing resources the likes of which only the largest corporations have hitherto been able to afford.

Yes, this is definitely a wonderful time to a be a developer. Join Aral as he shares with you the tools, technologies, and trends that excite him the most in 2009 and beyond. Get inspired, get motivated, then go out and build the next great thing to add your own page to this most exciting chapter in the history of the Internet.

Of Lambda Functions, Closures and Traits

by Sebastian Bergmann

Lambda functions and closures allow the quick definition of throw-away functions (for use with array_map(), for instance) that are not used elsewhere. Traits reduce some limitations of single inheritance by enabling the reuse method sets freely in several independent classes. This talk introduces the audience to the implementation of lambda functions, closures, and traits for PHP 5.4.

PHP powering Social Media

by Markus Franz

Social media services have become an integral part of the World Wide Web, and PHP is the premier application language for dynamic web applications. This talk shows how both worlds go together:

  • How does PHP help Web 2.0 to evolve?
  • What makes PHP so great for new web services?
  • Who has migrated from proprietary technologies for social media to PHP?

This is an introduction to media services and their specific project requirements, including case studies from large enterprises.

I hope to get some good stuffs to tell after this conference! I’m crossing fingers :) See you then…

No Comments

What type is that blog?

Today I’ve found this link of a blog called Typealyzer which is quite funny! Once you insert the link of your blog (or any you know) it displays inmediately what type of blog is, and also what part of your brain did you use during writing! hehe! Well, that’s my result. Judge yourself :)

INTJ - The Scientists

“The long-range thinking and individualistic type. They are especially good at looking at almost anything and figuring out a way of improving it - often with a highly creative and imaginative touch. They are intellectually curious and daring, but might be pshysically hesitant to try new things.

The Scientists enjoy theoretical work that allows them to use their strong minds and bold creativity. Since they tend to be so abstract and theoretical in their communication they often have a problem communcating their visions to other people and need to learn patience and use conrete examples. Since they are extremly good at concentrating they often have no trouble working alone. ”

Tags:

No Comments

Converting a Multidimensional Array to One-dimensional in PHP

I believe this is a simple but useful function that can be used to “flat” a multidimensional array
to a one-dimensional in PHP. I need it today because I’m trying (still) to display some complex data
within multidimensional arrays in a CSV file. So, I think my first step is done! :)

< ?php
class arrayClass{
 
      function flatArray($data){
           /* Static to keep the value through the recursive function */
           static $finalArray = array();
	   foreach($data as $key => $value){
	      if(is_array($value)){
                    /*   An element is an array so
                      *  the function is called again to go deeper
                      */
		     $this->flatArray($value);
		}
		else{
                    /*   It's not an array, so push it into 
                     *   a final array (the result) and removes the value from the original array
                     */
		     array_push($finalArray, $value);
		     unset($data[$key]);
		}
	}
	return $finalArray;
     }
}
 
//---- Testing the function
 $data = array("one", "two", 
                     array(array("three", array("four", "five", "six")), 
                     "seven"), "eight");
 $ac = new arrayClass();
 var_dump($ac->flatArray($data));
?>

Tags: , ,

2 Comments

Pagination, full implementation

There is a lot of information about how to deal with pagination of multiple records. The “issue” comes when you have to use it on different tables, which means you have to write different functions for each one, right? not necessarily!

I will show you my solution reusing the same function no matter what table are you paginating.

1.- Get the column names of the table and return an array within the names:

function getColumnsNames($tableName){
 
$query = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.Columns
                where TABLE_NAME = '$tableName'";
$this->db->query($query);
if($this->db->num_rows()!=0){
		$i=-1;
		while($this->db->next_record()){
	                 $i++;
                        $columnsNamesArray[$i] = $this->db->Record["COLUMN_NAME"];
               }
                return $columnsNamesArray;
      }
     else
	  return false;
   }

2.- Implementation of the pagination itself for any table:

function pagination($tableName, $columnsNames, $recordSize, 
                           $startIndex, $orderBy, $orderMode){			 
 
        $query = "SELECT * 
                       FROM $tableName 
                       ORDER BY $orderBy $orderMode 
                       LIMIT $startIndex,$recordSize";				 			
	$this->db->query($query);				 
	if($this->db->num_rows()!=0){  
		$t = -1;
		while($this->db->next_record()){	
			$t++;
			foreach($columnsNames as $key => $name){
				$fieldValuesArray[$name] = $this->db->Record[$name];								  	
	 		}
			$finalResultArray[$t] = $fieldValuesArray;
			unset($fieldValuesArray);										
		}
		return $finalResultArray;
	}
	else{			  
	    return false;		
        }
}	
 
}

3.- Calling final function to invoke the two previous functions:

function getPagination($tableName, $recordSize, $startIndex, $orderBy, $orderMode){
 
$columns = $this->getColumnsNames($tableName);
return $this->pagination($tableName, $columns, $recordSize, 
                                    $startIndex, $orderBy, $orderMode);
}

Example: $this->getPagination(”USERS”, 100, 0, “USR_ID”, “ASC”);

And voila! :)

No Comments

Saving some code lines for queries results

To save some lines of code when returning a big amount of DB fields (over 10 is big for me :)) try something like this:

function getFieldsValues($db_record){
    foreach($db_record as $key =&gt; $value){
       if(!is_numeric($key))  $resultArray[$key] = $value;
     }
     return $resultArray;
}

Basically what it does is to take each record (parameter) and goes through it to get all the fields with their respective values, putting them into an array (resultArray).

No Comments

SQL query for pagination

Pagination of multiple records is a very common thing in most of the system when showing a large amount of data. So, why not do it by a SQL query? It guarantees that, no matter the server language you are coding, the result will be the same!

The query might be something like:

select * from TABLE_NAME limit RECORD_POSITION, NUM_ROWS;

Where:

RECORD_POSITION: the position of the first record to be shown
NUM_ROWS: number of rows you want to show

So, how do I get the RECORD_POSITION?

Well, first of all you need to find out the number of pages you are going to show (in PHP might be something like):

$numPages = floor($number_of_records/$rows_to_show);

And then:

RECORD_POSITION = ($currentPage - 1) * $rows_to_show; 

Notice that $currentPage will be a parameter, depending of what page the user is clicking on.

No Comments

Welcome to my blog!

This is something I really wanted to do: to have a blog! not just for fun but to be frequently updated and maintained. Now that has been my company’s initative I will be here around and I hope other people can contribute with the contents and feedback.

Welcome then to my blog!

No Comments