Lapi

Package:
Summary:
Query MySQL database from parameter lists
Groups:
Author:
Description:
This class can be used to query MySQL database from parameter lists.

It can connect to a MySQL database server and execute SQL SELECT, INSERT, UPDATE and DELETE from parameters that define tables, fields, field values, and conditions clauses.


DataBrasil

Package:
Summary:
Manipulate and convert dates
Groups:
Author:
Description:
This class can be used to manipulate and convert dates.

It can parse dates in different formats and extract the year, month, day and week day.

The class can also compute the number of days between dates and add or subtract days to a date.

The code and comments are in Portuguese.

In Portuguese:

Essa é uma classe simples de manipulação de datas no formato Timestamp, SQL para o formato brasileiro e vice-versa. Além de realizar algumas operações de adição e subtração de dias.


Making a Slick MobileApp Website with jQuery & CSS

As a web developer, you have to bring creativity and attention to detail to your work. It is often the little things that leave a lasting impression to a visitor. Be it a lovable character illustration, or unique slideshow, it is usually not the information you present that is memorable, but the way you present it.

Today we are making a complete jQuery & CSS website for a fictional mobile application. It is going to feature semantic markup and a progressively enhanced slideshow effect. It will allow the user to see four of the most popular smartphones running the mobile app.

Step 1 – XHTML

When building websites it is important that you lay your code in a semantic way. This would include using tags for what they were supposed to be used for. You should use headings for titles, paragraphs for text (instead of generic divs) and lists where applicable.

mobileapp.html

<div id="page">

    <h1 id="logoh1"><a href="/" id="logo">MobileApp - the most useful mobile app!</a></h1>

    <div id="phoneCarousel">
    	<div class="previous arrow"></div>
        <div class="next arrow"></div>

        <div id="stage">
            <img id="iphone" class="default" src="img/phones/iphone.png" width="270" height="400" alt="iPhone" />
            <img id="nexus" src="img/phones/nexus_one.png" width="270" height="400" alt="Nexus One" />
            <img id="nokia" src="img/phones/nokia.png" width="270" height="400" alt="Nokia" />
            <img id="blackberry" src="img/phones/blackberry.png" width="270" height="400" alt="BlackBerry" />
        </div>
    </div>

    <img class="availableAppStore" src="img/available_on_the_appstore.png" width="230" height="80" alt="Available on the Appstore" />

    <div class="text">
    	<h3><img src="img/thumb.png" alt="MobileApp" width="114" height="114" class="thumb" />A wonderful app</h3>
        <p>Lorem ipsum dolor sit amet.. </p>
    </div>

    <div class="text">
    	<h3><img src="img/thumb.png" alt="MobileApp" width="114" height="114" class="thumb" />More awesome facts</h3>
        <p>Lorem ipsum dolor sit amet.. </p>
    </div>

</div>

This is all the markup that is used to display the website. The h1 heading holds a hyperlink which is styled as the logo (the logo image is set as the background of the hyperlink and a negative text indent is used to hide the text of the link).

After this we have the #phoneCarousel div and inside it are the arrows and the stage. The phone images inside the stage are rotated with jQuery as you will see in a moment.

Lastly we have the Available on the Appstore badge, and two blocks of text.

Slick MobileApp Website - Slideshow

Slick MobileApp Website - Slideshow

Step 2 – CSS

CSS is responsible for converting our semantic markup into a true website. Take a closer look at the #stage styles in the second part of the code, as these are what make the animation possible.

styles.css – Part 1

body{
	font-size:14px;
	color:#515151;
	background:url('img/bg.png') repeat-x #f6f8f9;
	font-family:'Myriad Pro',Arial, Helvetica, sans-serif;
}

#logoh1{ margin:40px 0 0;}

#page{
	/* This the main container div */
	width:1000px;
	min-height:700px;
	margin:0 auto;
	background:url('img/bokeh.jpg') no-repeat 0 120px;
	position:relative;
	padding-top:1px;
}

#phoneCarousel{
	/*	This is the carousel section, it
		contains the stage and the arrows */
	height:390px;
	margin:90px auto 120px;
	position:relative;
	width:800px;
}

#phoneCarousel .arrow{
	/* The two arrows */
	width:44px;
	height:44px;
	background:url('img/arrows.png') no-repeat;
	position:absolute;
	top:50%;
	margin-top:-22px;
	left:0;
	cursor:pointer;
}

#phoneCarousel .next{
	/* Individual styles for the next icon */
	background-position:right top;
	left:auto;
	right:0;
}

/* Hover styles */

#phoneCarousel .arrow:hover{
	background-position:left bottom;
}

#phoneCarousel .next:hover{
	background-position:right bottom;
}

After defining the  body styles we can move on to styling the #page div, which holds everything together. Its background image is offset 120px vertically, so it matches the background of the body, filling the full width of the page.

Next is the #phoneCarousel div. It has a relative positioning applied, so the stage (where all the animations take place) can be properly centered. The previous/next arrows are styled as well.

styles.css – Part 2

#logo{
	background:url('img/logo.png') no-repeat;
	height:40px;
	text-indent:-9999px;
	width:210px;
	display:block;
}

#stage{
	/* The stage contains the animated phone images */
	left:50%;
	margin-left:-350px;
	position:absolute;
	width:700px;
	height:100%;
}

#stage img{
	/* Hiding all the images by default */
	display:none;
}

#stage .default{
	/*	This class is applied only to the iphone img by default
		and it is the only one visible if JS is disabled */
	display:block;
	left:50%;
	margin-left:-135px;
	position:absolute;
}

#stage .animationReady{
	/* This class is assigned to the images on load */
	display:block;
	position:absolute;
	top:0;
	left:0;
}

.text{	margin-top:70px;width:700px;}

.text p,
.text h3{
	padding-bottom:15px;
	line-height:1.4;
	text-align:justify;
}

.text h3{	font-size:30px;}
.text p{	font-size:20px;}

.thumb{	float:left;margin-right:40px;}

.availableAppStore{float:right;}

In the second part of the stylesheet, we continue with the #stage styles. The phone pictures are hidden by default, so if JavaScript is disabled, the user is not left with a bunch of scattered images.

As you will see in the next step, the animation is achieved through changing the top and left CSS properties. For this to work, the images must be absolutely positioned. This is why the .animatonReady class is assigned on load with jQuery (if JS is disabled, this style would not be applied).

Lastly we style the text blocks, which explain details about our fictional MobileApp.

Text Blocks

Text Blocks

Step 3 – jQuery

When you click on one of the arrows, an animation starts, which uses sine and cosine calculations to move and scale down the images, creating the illusion of a circular movement. It is not as complicated as it sounds, as you can see for yourself from the code below.

script.js

$(document).ready(function(){

	var deg=0;

	/* Storing all the images into a variable */

	var images	= $('#stage img').removeClass('default').addClass('animationReady');
	var dim		= { width:images.width(),height:images.height()};

	var cnt = images.length;

	/* Finding the centers of the animation container: */
	var centerX = $('#stage').width()/2;
	var centerY = $('#stage').height()/2 - dim.height/2;

	function rotate(step,total){
		// This function will loop through all the phone images, and rotate them
		// with "step" degrees (10 in this implementation) till total > 0

		/* Increment the degrees: */
		deg+=step;

		var eSin,eCos,newWidth,newHeight,q;

		/* Loop through all the images: */
		for(var i=0;i<cnt;i++){

			/* Calculate the sine and cosine for the i-th image */

			q = ((360/cnt)*i+deg)*Math.PI/180;
			eSin		= Math.sin(q);
			eCos		= Math.cos(q);

			/*
			/	With the sine value, we can calculate the vertical movement,
			/	and the cosine will give us the horizontal movement.
			*/

			q = (0.6+eSin*0.4);
			newWidth	= q*dim.width;
			newHeight	= q*dim.height;

			/*
			/	We are using the calculated sine value (which is in the range
			/	of -1 to 1) to calculate the opacity and z-index. The
 			/	frontmost image has a sine value of 1, while the backmost
			/	one has a sine value of -1.
			*/

			// eq() extracts the image at the i-th position:

			images.eq(i).css({
				top			: centerY+15*eSin,
				left		: centerX+200*eCos,
				opacity		: 0.8+eSin*0.2,
				marginLeft	: -newWidth/2,
				zIndex		: Math.round(80+eSin*20)
			}).width(newWidth).height(newHeight);
		}

		total-=Math.abs(step);
		if(total<=0) return false;

		// Setting the function to be run again in 40 milliseconds (equals to 25 frames per second):
		setTimeout(function(){rotate(step,total)},40);

	}

	// Running the animation once at load time (and moving the iPhone into view):
	rotate(10,360/cnt);

	$('#phoneCarousel .previous').click(function(){
		// 360/cnt lets us distribute the phones evenly in a circle
		rotate(-10,360/cnt);
	});

	$('#phoneCarousel .next').click(function(){
		rotate(10,360/cnt);
	});
});

To start an animation you just need to call the rotate function with two arguments – a step, and a total rotation, both of which are numbers. Step can be negative, which would mean that the rotation is run in the opposite way. Each time the function is run, total is decremented with the absolute value of the step, and once it reaches zero the animation is stopped.

In a number of places in this code, you can see that I’ve used a specific calculation – 360/cnt. This is done to distribute the phones evenly (360 being the number of degrees in a circle).  This way you can add or remove images and they will be properly animated.

Slick MobileApp Website

Slick MobileApp Website

With this our Slick MobleApp Website is complete!

Wrapping it up

Today we made a complete jQuery & CSS website for a fictional mobile application. You are free to modify the code and use it any way you see fit. If you liked the tutorial be sure to subscribe to our RSS feed, follow us on twitter, or leave a comment in the section below.

MiniGal Nano

MiniGal Nano is a very simple and user friendly PHP/HTML/CSS image gallery script. There is no backend, just upload it to your server along with your images and you're good to go. Simple editing of the configuration file gives you control of some features.

Habari

Habari is different While there are a number of technical reasons that highlight the differences and advantages Habari has over other blogging packages, a major component of what makes Habari different is its community participation model. Users who demonstrate a level of quality contributions to the project are granted more privileges within the project. Features * Modular, object-oriented core for easy extensibility * Supports multiple database backends (MySQL, SQLite, PostgreSQL) * Uses prepared statements throughout to protect against SQL injection attacks * Media silos to directly access various ways of media storage, like Flickr, Viddler, or the server's filesystem * Atom Publishing Protocol support * Multiple users (authors) * Multiple sites on one installation * Support for static content ("pages") * Plugins * Tagging * Importers for Serendipity and WordPress

FlatPress

FlatPress is an open-source standard-compliant multi-lingual extensible blogging engine which does not require a DataBase Management System to work. You don’t need MySQL because FlatPress stores all of its content on text files. All you need is some web space supporting PHP4 (or later). Features * Standard-compliant (XHTML valid) * Plugin support * Widget system * Easy to customize with themes (powered by Smarty)

Text Parse

Package:
Summary:
Get statistics and beautify text strings
Groups:
Author:
Description:
This class can be used to get statistics and beautify text strings.

It can analyze a given text string and get the total length, the number of non-whitespace characters, number of letters, number of spaces and tabs, number of symbol characters, number of words and number of sentences.

The class can also beautify the text by removing exceeding spaces, punctuation and line breaks.


Advanced file upload and ajax upload

Package:
Summary:
Validate and process file uploads
Groups:
Author:
Description:
This class can be used to validate and process file uploads.

It can check if the uploaded files have one of the allowed file name extensions and MIME types, and does not exceed the allowed file limits.

Image files are opened to verify they really contain image data of the determined format.

The class can move the uploaded files to a given directory if it exists and has write permissions.

The idiom of the error messages is configurable from a list of supported idioms.


Simple CSV Reader

Package:
Summary:
Read and sort CSV file data into array
Groups:
Author:
Description:
This class can be used to read and sort CSV file data into array.

It can open a CSV file and read its data into a bidimensional array.

The retrieved data array can also be sorted.

In Portuguese:

Uma classe simples para a conversão de arquivos CSV para array.

Os arquivos CSV devem conter os cabeçalhos.


Fast Curl

Package:
Summary:
Send HTTP requests using Curl extension
Groups:
Author:
Description:
This package can be used to send HTTP requests using Curl extension.

There are two classes: one for sending regular HTTP requests and another to send multiple parallel requests.

Both classes can send HTTP requests directly or via proxy, securely using SSL or not, setting the referrer URL, cookies, custom headers, etc...

Constructor will initialize curl handle with most common values althought you can set custom values like url, referrer, proxy, exec_mode, cookies, custom_headers, timeout and ssl. (By default you can use HTTP/HTTPS with need of caring about keys, certs, etc...)

Apart from constructor, EVERY CURLOPT can be set with a simple assignment instead of using curl_setopt() or any "obscure" method.

For instance:

$fc->url = 'http://phpclasses.org';

and retrieved like this:

$url = $fc->url;

There are two methods to execute requests:

exec(...) -> It returns a FRESH response.

fetch(...) -> It returns LAST response. (You can use a regex pattern to parse response).

FastCurlMulti is a container of FastCurl objects. Use it to make parallel requests.

For instance:

$fcm = new FastCurlMulti();
$fcm->add($fc1);
$fcm->add($fc2);
$fcm->exec();

Destructors will free any thing that has to be free. Do not worry.


DOC HERE -> http://tonikelope.es/fastcurl/doc/

DOWNLOAD HERE -> http://tonikelope.es/fastcurl/


Powered by Gewgley