Login   Register  
PHP Classes
elePHPant
Icontem

File: examples.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Nathan Lucas  >  phpColourLover  >  examples.php  >  Download  
File: examples.php
Role: Example script
Content type: text/plain
Description: Usage examples.
Class: phpColourLover
Retrieve color elements from the COLOURLovers site
Author: By
Last change:
Date: 2008-04-06 16:57
Size: 1,207 bytes
 

Contents

Class file image Download
<?php
require_once("/path/to/phpColourLover/phpColourLove.php");

echo 
"<h4>Most recent color.</h4>\n";
// grab most recently added color: 
$color phpColourLover::Colors();
$color->limit(1);
$results $color->get("new");
$bg $results[0]['hex'];
echo 
"<div style=\"width:50px;height:50px;background:#".$bg.";\">&nbsp;</div>\n";
echo 
"<hr />\n";


echo 
"<h4>Top 5 palettes.</h4>\n";
// grab top 5 palettes:
$palettes phpColourLover::Palettes();
$palettes->limit(5);
$results $palettes->get("top"); 
foreach (
$results as $palette) {
    echo 
"<img src=\"".$palette['image']."\" />\n";
    echo 
"<br />\n";
}
echo 
"<hr />\n";


echo 
"<h4>gsmonk's details.</h4>\n";
// grab a lover account:
$lover phpColourLover::Lover("gsmonk");
$results $lover->get();
echo 
$results['lover']." has added ".$results['colors']." colors, ".$results['palettes']." palettes and ".$results['patterns']." patterns.\n";
echo 
"<hr />\n";


echo 
"<h4>Last pattern added by COLOURLover.</h4>\n";
// grab last pattern submitted by a lover:
$pattern phpColourLover::Patterns();
$pattern->lover("COLOURLover");
$pattern->limit(1);
$results $pattern->get("new");
$img $results[0]['image'];
echo 
"<img src=\"".$img."\" />\n";
?>