WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Aspect-Oriented Programming Library fo PHP
Categories : PHP, PHP Classes, Aspect Oriented Programming Click here to Update Your Picture
Dmitry Sheiko
Date : Oct 14th 2005
Grade : 2 of 5 (graded 2 times)
Viewed : 6480
File : 4237.zip
Images : No Images for this code example.
Search : More code by Dmitry Sheiko
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

file:Sample.php
<?PHP
/*
When we are developing big complex projects Object-Oriented programming paradigm isn't able
to provide a clear structure of business logic components. Aspect-Oriented Programming
allows to separate business logic and through functionality (logging, caching, transaction control, etc).

AOP Library for PHP extends basic PHP capabilities using Aspect-Oriented constructions. You
can learn more about Aspect-Oriented Programming at http://en.wikipedia.org/wiki/Aspect-oriented_programming
*/
include("aop.lib.php");
$aspect1 = new Aspect();
$pc1 = $aspect1->pointcut("call Sample::Sample  or call Sample::Sample2");
$pc1->_before("print 'PreProcess<br />';");
$pc1->_after("print 'PostProcess<br />';");
$pc1->destroy();


Class
Sample {
    var
$aspect;
    function
Sample($aspect1) {
       
$this->aspect = &$aspect1;
       
Advice::_before($this->aspect);
        print
'Some business logic of Sample<br />';
       
Advice::_after($this->aspect);
    }
    function
Sample2() {
       
Advice::_before($this->aspect);
        print
'Some business logic of Sample2<br />';
       
Advice::_after($this->aspect);
    }
   
}

$Sample = new Sample(&$aspect1);
$Sample->Sample2();
?>



file:aop.lib.php
<?PHP
/*
* @package Aspect-Oriented Programming Library
* @author $Author: sheiko $ 
* @version $Id: oap.lib.php,v 1.0 2005/10/14 15:58:15 sheiko Exp $
* @since v.1.0
* @copyright (c) Dmitry Sheiko http://www.cmsdevelopment.com
*/

/**
* Aspect class, which declare an aspect
* @package Aspect-Oriented Programming Library
* @author $Author: sheiko $
*/
class Aspect {
   
    var
$pointcuts;
   
     
/**
    * Class constructor
    * @return object
    */     
   
function Aspect() {
       
$this->pointcuts = array("AAA");
        return
$this;
    }
   
   
/**
    * Add set of join points
    * @param string $CommandString special string in format "call MethodName1 or call MethodName2"
    * @return boolean
    */     
   
function pointcut($CommandString) {
        return new
Pointcut($CommandString, &$this->pointcuts);
    }

   
/**
    * Class destructor
    * @return boolean
    */         
   
function destroy() {
        unset(
$this);
    }
}

/**
* Pointcut class, which declare an pointcut of the aspect (http://en.wikipedia.org/wiki/Advice_in_aspect-oriented_programming)
* @package Aspect-Oriented Programming Library
* @author $Author: sheiko $
*/
class Pointcut extends Aspect {

    var
$Methods;
    var
$pointcuts;

     
/**
    * Class constructor
    * @return object
    */         
   
function Pointcut($CommandString, $pointcutsReference) {
       
$this->Methods = array();
       
$this->pointcuts = &$pointcutsReference;

       
// Validate Input Parameters
       
if(!is_string($CommandString)) trigger_error("CommandString parameter must be STRING", E_USER_ERROR);
       
       
// Parse CommandString
       
$this->Methods = split(" ", strtolower( preg_replace("/\s\s+/", " ", preg_replace("/(call\s|or\s)/is", "", trim($CommandString)))));
        if(!
$this->Methods) trigger_error("CommandString does not contain methods names", E_USER_ERROR);
        return
true;
    }

   
/**
    * Processing of start point
    * @param string $EvalCode
    * @return boolean
    */         
   
function _before($EvalCode) {
       
$this->__apply("_before", $EvalCode);
        return
true;
    }
   
/**
    * Processing of finish point
    * @param string $EvalCode
    * @return boolean
    */         
   
function _after($EvalCode) {
       
$this->__apply("_after", $EvalCode);
        return
true;
    }
       
   
/**
    * Private service method
    * @param string $Point (_before|_after)
    * @param string $EvalCode
    * @return boolean
    */         
   
   
function __apply($Point, $EvalCode) {
       
$Method = '';
       
// Validate Input Parameters
       
if(!$EvalCodetrigger_error("This function parameter is invalid. Value of the parameter has to satisfy the eval code syntax", E_USER_ERROR);
        if(!
$this->Methods) trigger_error("There is a need to define pointcut", E_USER_ERROR);
        foreach(
$this->Methods as $Method) {
           
$this->pointcuts[$Method][$Point] = $EvalCode;
        }
        return
true;
    }
   
     
/**
    * Class destructor
    * @return boolean
    */         
   
function destroy() {
        unset(
$this);
    }
   
}

/**
* Advice service function package (http://en.wikipedia.org/wiki/Advice_in_aspect-oriented_programming)
* @package Aspect-Oriented Programming Library
* @author $Author: sheiko $
*/

class Advice {
   
/**
    * Parent method name getting
    * @return boolean
    */     
   
function getMethodName() {
       
$backtrace = debug_backtrace();
        return
$backtrace[2]["class"]."::".$backtrace[2]["function"];
    }
   
/**
    * _Before process declaration
    * @param object $AspectObj
    * @return boolean
    */     
   
function _before($AspectObj) {
       
$MethodName = '';
        if (
gettype($AspectObj)!="object") trigger_error("This function parameter is invalid. Value of the parameter has to satisfy the Aspect object requirements", E_USER_ERROR);
        if(
$AspectObj->pointcuts [Advice::getMethodName()]["_before"]) {
           
$Result = @eval($AspectObj->pointcuts [Advice::getMethodName()]["_before"]." return true;" );
            if(!
$Result) _trigger::error("_before process of the applied Aspect contains incorrect eval code");
        }
        return
true;
    }
   
/**
    * _After process declaration
    * @param object $AspectObj
    * @return boolean
    */     
   
function _after($AspectObj) {
       
$MethodName = '';
        if (
gettype($AspectObj)!="object") trigger_error("This function parameter is invalid. Value of the parameter has to satisfy the Aspect object requirements", E_USER_ERROR);
        if(
$AspectObj->pointcuts [Advice::getMethodName()]["_after"]) {
           
$Result = @eval($AspectObj->pointcuts [Advice::getMethodName()]["_after"]." return true;" );
            if(!
$Result) _trigger::error("_after process of the applied Aspect contains incorrect eval code");
        }
        return
true;
    }
}

/**
* Trigger service function package
* @package Aspect-Oriented Programming Library
* @author $Author: sheiko $
*/
class _trigger {
   
/**
    * Error trigger
    * @param string $ErrorMessage
    * @return boolean
    */     
   
function error($ErrorMessage) {
       
$backtrace = debug_backtrace();
       
$index = 2;
        die(
"<b>AOP Error:</b> ".$ErrorMessage." in <b>".$backtrace[$index]["file"]."</b> on line <b>".$backtrace[$index]["line"]."</b>");
        return
true;
    }
}
?>



Blueshoes PHP Application Framework
Categories : PHP, Frameworks, PHP Classes
Automatic generation of HTML code for a table. OO interface. Can define colspan, rowspan, table style, cell style, and data style. Simple, but effective.
Categories : PHP, PHP Classes, HTML, HTML and PHP
A class for sending email; it has support for To:, Cc:, Bcc: and Reply-To: headers. It requires that you have sendmail installed.
Categories : Email, PHP Classes, PHP
Request Method Class - seful for situations like form processing or API development. Requires PHP5 for the magic __call() method.
Categories : PHP, PHP Classes, HTTP, Headers
Class to convert any document, that can be read by MS Word, to another format supported by Word.
Categories : PHP Classes, PHP, Windows 2000, Microsoft Word, WinNT
Simple Mini Poll class library (SimPoll)
Categories : PHP, PHP Classes, Databases, MySQL, Complete Programs
base64 with encryption - encode and decode sessions
Categories : PHP, PHP Classes, Encryption, Sessions
.htpassword manager for apache
Categories : PHP, PHP Classes, Authentication, Apache
Freshmeat.net XML-RPC - This class is meant to query Freshmeat for information about registered projects.
Categories : PHP, PHP Classes, XML, Web Services
ADODB Database Wrapper Abstraction Library for PHP: MySQL, MSSQL, Oracle, Interbase,ODBC, Microsoft Access and FoxPro.
Categories : PHP Classes, Databases, PHP, General SQL, ODBC
Parsing Simple Template Files and Data
Categories : PHP, PHP Classes, Templates, Regexps
PHP MIME Decoder. This class decodes Mime Encoded email message. Attachments are stored in a director. Works with Multipart/alternative, multipart/mixed etc. see http://p3mail.com for example.
Categories : PHP, PHP Classes, Email
XPertMailer - Sends TRUE Mails
Categories : PHP, Mail, SMTP, PHP Classes
My Box - PHP Class that calculates the volumetric weight of a package.
Categories : PHP, Object Oriented, PHP Classes, Beginner Guides, Payment Gateways
HTML_Graphs uses PHP to provide a consistent interface for creating HTML based charts. The user of the class sets up arrays that are passed to html_graph() which then takes care of all the messy HTML layout.
Categories : Graphics, Arrays, PHP, PHP Classes, Charts and Graphs