Commit 5ee24d93 authored by pookey's avatar pookey

moving website out of trunk. it has external dependencies on symfonys SVN...

moving website out of trunk. it has external dependencies on symfonys SVN server - which sometimes is unstable. It is causing problems preventing peopel checking out trunk at the moment
parent b908e2f9
default:
enabled: off
with_layout: false
lifetime: 86400
<?php
// include project configuration
include(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php');
// symfony bootstraping
require_once($sf_symfony_lib_dir.'/util/sfCore.class.php');
sfCore::bootstrap($sf_symfony_lib_dir, $sf_symfony_data_dir);
cli:
controller:
class: sfConsoleController
request:
class: sfConsoleRequest
response:
class: sfConsoleResponse
test:
storage:
class: sfSessionTestStorage
#all:
# controller:
# class: sfFrontWebController
#
# request:
# class: sfWebRequest
#
# response:
# class: sfWebResponse
#
# user:
# class: myUser
#
# storage:
# class: sfSessionStorage
# param:
# session_name: symfony
#
# view_cache:
# class: sfFileCache
# param:
# automaticCleaningFactor: 0
# cacheDir: %SF_TEMPLATE_CACHE_DIR%
rendering: ~
web_debug: ~
security: ~
# generally, you will want to insert your own filters here
cache: ~
common: ~
flash: ~
execution: ~
#all:
# default_culture: en
# source: XLIFF
# debug: off
# cache: on
# untranslated_prefix: "[T]"
# untranslated_suffix: "[/T]"
prod:
enabled: off
level: err
rotate: on
purge: off
#all:
# enabled: on
# level: debug
# rotate: off
# period: 7
# history: 10
# purge: on
# loggers:
# sf_web_debug:
# class: sfWebDebugLogger
# param:
# condition: %SF_WEB_DEBUG%
# sf_file_debug:
# class: sfFileLogger
# param:
# file: %SF_LOG_DIR%/%SF_APP%_%SF_ENVIRONMENT%.log
# default rules
homepage:
url: /
param: { module: blog_posts, action: index }
default_symfony:
url: /symfony/:action/*
param: { module: default }
default_index:
url: /:module
param: { action: index }
default:
url: /:module/:action/*
default:
is_secure: on
\ No newline at end of file
prod:
.settings:
no_script_name: off
dev:
.settings:
# E_ALL | E_STRICT = 4095
error_reporting: 4095
web_debug: on
cache: off
no_script_name: off
etag: off
test:
.settings:
# E_ALL | E_STRICT & ~E_NOTICE = 2047
error_reporting: 2047
cache: off
web_debug: off
no_script_name: off
etag: off
all:
.actions:
default_module: default # Default module and action to be called when
default_action: index # A routing rule doesn't set it
error_404_module: default # To be called when a 404 error is raised
error_404_action: error404 # Or when the requested URL doesn't match any route
login_module: sfGuardAuth # To be called when a non-authenticated user
login_action: signin # Tries to access a secure page
secure_module: sfGuardAuth # To be called when a user doesn't have
secure_action: secure # The credentials required for an action
module_disabled_module: default # To be called when a user requests
module_disabled_action: disabled # A module disabled in the module.yml
unavailable_module: default # To be called when a user requests a page
unavailable_action: unavailable # From an application disabled via the available setting below
.settings:
available: on # Enable the whole application. Switch to off to redirect all requests to the unavailable module and action.
# Optional features. Deactivating unused features boots performance a bit.
use_database: on # Enable database manager. Set to off if you don't use a database.
use_security: on # Enable security features (login and credentials). Set to off for public applications.
use_flash: on # Enable flash parameter feature. Set to off if you never use the set_flash() method in actions.
i18n: off # Enable interface translation. Set to off if your application should not be translated.
check_symfony_version: off # Enable check of symfony version for every request. Set to on to have symfony clear the cache automatically when the framework is upgraded. Set to off if you always clear the cache after an upgrade.
use_process_cache: on # Enable symfony optimizations based on PHP accelerators. Set to off for tests or when you have enabled a PHP accelerator in your server but don't want symfony to use it internally.
compressed: off # Enable PHP response compression. Set to on to compress the outgoing HTML via the PHP handler.
check_lock: off # Enable the application lock system triggered by the clear-cache and disable tasks. Set to on to have all requests to disabled applications redirected to the $sf_symfony_data_dir/web/arrors/unavailable.php page.
# Output escaping settings
escaping_strategy: bc # Determines how variables are made available to templates. Accepted values: bc, both, on, off. The value off deactivates escaping completely and gives a slight boost.
escaping_method: ESC_ENTITIES # Function or helper used for escaping. Accepted values: ESC_RAW, ESC_ENTITIES, ESC_JS, ESC_JS_NO_ENTITIES.
# Routing settings
suffix: . # Default suffix for generated URLs. If set to a single dot (.), no suffix is added. Possible values: .html, .php, and so on.
no_script_name: off # Enable the front controller name in generated URLs
# Validation settings, used for error generation by the Validation helper
validation_error_prefix: ' &darr;&nbsp;'
validation_error_suffix: ' &nbsp;&darr;'
validation_error_class: form_error
validation_error_id_prefix: error_for_
# Cache settings
cache: off # Enable the template cache
etag: on # Enable etag handling
# Logging and debugging settings
web_debug: off # Enable the web debug toolbar
error_reporting: 341 # Determines which events are logged. The default value is E_PARSE | E_COMPILE_ERROR | E_ERROR | E_CORE_ERROR | E_USER_ERROR = 341
# Assets paths
rich_text_js_dir: js/tiny_mce
prototype_web_dir: /sf/prototype
admin_web_dir: /sf/sf_admin
web_debug_web_dir: /sf/sf_web_debug
# Helpers included in all templates by default
standard_helpers: [Partial, Cache, Form]
# Activated modules from plugins or from the symfony core
enabled_modules: [default, sfGuardAuth, sfGuardUser, sfGuardGroup, sfGuardPermission]
# Charset used for the response
charset: utf-8
# Miscellaneous
strip_comments: on # Remove comments in core framework classes as defined in the core_compile.yml
autoloading_functions: ~ # Functions called when a class is requested and this it is not already loaded. Expects an array of callables. Used by the framework bridges.
timeout: 1800 # Session timeout, in seconds
max_forwards: 5
path_info_array: SERVER
path_info_key: PATH_INFO
url_format: PATH
# ORM
orm: propel
default:
http_metas:
content-type: text/html
metas:
title: symfony project
robots: index, follow
description: symfony project
keywords: symfony, project
language: en
stylesheets: [main]
javascripts: []
has_layout: on
layout: layout
<?php
class myUser extends sfGuardSecurityUser
{
}
<?php
/**
* blog_posts actions.
*
* @package doctrine_website
* @subpackage blog_posts
* @author Your name here
* @version SVN: $Id: actions.class.php 1415 2006-06-11 08:33:51Z fabien $
*/
class blog_postsActions extends autoblog_postsActions
{
}
generator:
class: sfDoctrineAdminGenerator
param:
model_class: BlogPost
theme: default
edit:
display: [name, body]
fields:
body:
type: textarea_tag
params: size=60x15
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<?php include_http_metas() ?>
<?php include_metas() ?>
<?php include_title() ?>
<link rel="shortcut icon" href="/favicon.ico" />
</head>
<body>
<?php echo $sf_data->getRaw('sf_content') ?>
</body>
</html>
default:
enabled: off
with_layout: false
lifetime: 86400
<?php
// include project configuration
include(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php');
// symfony bootstraping
require_once($sf_symfony_lib_dir.'/util/sfCore.class.php');
sfCore::bootstrap($sf_symfony_lib_dir, $sf_symfony_data_dir);
cli:
controller:
class: sfConsoleController
request:
class: sfConsoleRequest
response:
class: sfConsoleResponse
test:
storage:
class: sfSessionTestStorage
#all:
# controller:
# class: sfFrontWebController
#
# request:
# class: sfWebRequest
#
# response:
# class: sfWebResponse
#
# user:
# class: myUser
#
# storage:
# class: sfSessionStorage
# param:
# session_name: symfony
#
# view_cache:
# class: sfFileCache
# param:
# automaticCleaningFactor: 0
# cacheDir: %SF_TEMPLATE_CACHE_DIR%
rendering: ~
web_debug: ~
security: ~
# generally, you will want to insert your own filters here
cache: ~
common: ~
flash: ~
execution: ~
#all:
# default_culture: en
# source: XLIFF
# debug: off
# cache: on
# untranslated_prefix: "[T]"
# untranslated_suffix: "[/T]"
prod:
enabled: off
level: err
rotate: on
purge: off
#all:
# enabled: on
# level: debug
# rotate: off
# period: 7
# history: 10
# purge: on
# loggers:
# sf_web_debug:
# class: sfWebDebugLogger
# param:
# condition: %SF_WEB_DEBUG%
# sf_file_debug:
# class: sfFileLogger
# param:
# file: %SF_LOG_DIR%/%SF_APP%_%SF_ENVIRONMENT%.log
# default rules
homepage:
url: /
param: { module: main, action: index }
trac_register:
url: /trac/register
param: { module: main, action: trac_register }
blog:
url: /blog
param: { module: blog, action: index }
blog_post:
url: /blog/:slug
param: { module: blog, action: view }
api_documentation_page:
url: /documentation/api/:q
param: { module: api_documentation, action: index }
about:
url: /about
param: { module: main, action: about }
download:
url: /download
param: { module: main, action: download }
manual_chapter:
url: /documentation/manual/:chapter
param: { module: manual, action: index }
manual:
url: /documentation/manual/*
param: { module: manual, action: index }
api_documentation:
url: /documentation/api
param: { module: api_documentation, action: index }
trac:
url: /trac
param: { module: main, action: trac }
default_symfony:
url: /symfony/:action/*
param: { module: default }
default_index:
url: /:module
param: { action: index }
default:
url: /:module/:action/*
prod:
.settings:
no_script_name: on
dev:
.settings:
# E_ALL | E_STRICT = 4095
error_reporting: 4095
web_debug: on
cache: off
no_script_name: off
etag: off
test:
.settings:
# E_ALL | E_STRICT & ~E_NOTICE = 2047
error_reporting: 2047
cache: off
web_debug: off
no_script_name: off
etag: off
all:
.actions:
default_module: default # Default module and action to be called when
default_action: index # A routing rule doesn't set it
error_404_module: default # To be called when a 404 error is raised
error_404_action: error404 # Or when the requested URL doesn't match any route
login_module: sfGuardAuth # To be called when a non-authenticated user
login_action: signin # Tries to access a secure page
secure_module: sfGuardAuth # To be called when a user doesn't have
secure_action: secure # The credentials required for an action
module_disabled_module: default # To be called when a user requests
module_disabled_action: disabled # A module disabled in the module.yml
unavailable_module: default # To be called when a user requests a page
unavailable_action: unavailable # From an application disabled via the available setting below
.settings:
available: on # Enable the whole application. Switch to off to redirect all requests to the unavailable module and action.
# Optional features. Deactivating unused features boots performance a bit.
use_database: on # Enable database manager. Set to off if you don't use a database.
use_security: on # Enable security features (login and credentials). Set to off for public applications.
use_flash: on # Enable flash parameter feature. Set to off if you never use the set_flash() method in actions.
i18n: off # Enable interface translation. Set to off if your application should not be translated.
check_symfony_version: off # Enable check of symfony version for every request. Set to on to have symfony clear the cache automatically when the framework is upgraded. Set to off if you always clear the cache after an upgrade.
use_process_cache: on # Enable symfony optimizations based on PHP accelerators. Set to off for tests or when you have enabled a PHP accelerator in your server but don't want symfony to use it internally.
compressed: off # Enable PHP response compression. Set to on to compress the outgoing HTML via the PHP handler.
check_lock: off # Enable the application lock system triggered by the clear-cache and disable tasks. Set to on to have all requests to disabled applications redirected to the $sf_symfony_data_dir/web/arrors/unavailable.php page.
# Output escaping settings
escaping_strategy: bc # Determines how variables are made available to templates. Accepted values: bc, both, on, off. The value off deactivates escaping completely and gives a slight boost.
escaping_method: ESC_ENTITIES # Function or helper used for escaping. Accepted values: ESC_RAW, ESC_ENTITIES, ESC_JS, ESC_JS_NO_ENTITIES.
# Routing settings
suffix: . # Default suffix for generated URLs. If set to a single dot (.), no suffix is added. Possible values: .html, .php, and so on.
no_script_name: off # Enable the front controller name in generated URLs
# Validation settings, used for error generation by the Validation helper
validation_error_prefix: ' &darr;&nbsp;'
validation_error_suffix: ' &nbsp;&darr;'
validation_error_class: form_error
validation_error_id_prefix: error_for_
# Cache settings
cache: off # Enable the template cache
etag: on # Enable etag handling
# Logging and debugging settings
web_debug: off # Enable the web debug toolbar
error_reporting: 341 # Determines which events are logged. The default value is E_PARSE | E_COMPILE_ERROR | E_ERROR | E_CORE_ERROR | E_USER_ERROR = 341
# Assets paths
rich_text_js_dir: js/tiny_mce
prototype_web_dir: /sf/prototype
admin_web_dir: /sf/sf_admin
web_debug_web_dir: /sf/sf_web_debug
# Helpers included in all templates by default
standard_helpers: [Partial, Cache, Form]
# Activated modules from plugins or from the symfony core
enabled_modules: [default, sfGuardAuth, sfGuardRegister, sfGuardForgotPassword]
# Charset used for the response
charset: utf-8
# Miscellaneous
strip_comments: on # Remove comments in core framework classes as defined in the core_compile.yml
autoloading_functions: ~ # Functions called when a class is requested and this it is not already loaded. Expects an array of callables. Used by the framework bridges.
timeout: 1800 # Session timeout, in seconds
max_forwards: 5
path_info_array: SERVER
path_info_key: PATH_INFO
url_format: PATH
# ORM
orm: propel
default:
http_metas:
content-type: text/html
metas:
title: Doctrine - Open Source PHP 5 ORM
robots: index, follow
description: Doctrine is a Open Source OO PHP 5 ORM
keywords: doctrine, php, database, orm
language: en
stylesheets: [main, layout]
javascripts: []
has_layout: on
layout: layout
<?php
class myUser extends sfGuardSecurityUser
{
}
<?php
/**
* api_documentation actions.
*
* @package doctrine_website
* @subpackage api_documentation
* @author Your name here
* @version SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z fabien $
*/
class api_documentationActions extends sfActions
{
/**
* Executes index action
*
*/
public function executeIndex()
{
}
}
default:
stylesheets: [main, layout, api_documentation]
layout: api_documentation_layout
\ No newline at end of file
<?php
function get_documentation($q)
{
$docPath = dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))))).DIRECTORY_SEPARATOR.'api_documentation'.DIRECTORY_SEPARATOR.'trunk';
if( $q )
{
$q = str_replace('-sep-', '/', $q);
return get_documentation_html($docPath.'/'.$q, $q);
} else {
return get_documentation_html($docPath.'/index.html', $q);
}
}
function process_documentation($html, $q)
{
//preg_match_all('/a href="(.*)"/', $html, $matches);
preg_match_all('/<a\s[^>]*href=\"([^\"]*)\"[^>]*>/siU', $html, $matches);
$matchValues = $matches[1];
$matches = $matches[0];
foreach($matches AS $key => $match)
{
$value = $matchValues[$key];
if( $value[0] != '#' )
{
$urlQ = str_replace('../', '/', $value);
$urlQ = str_replace('/', '-sep-', $urlQ);
$html = str_replace($match, '<a href="'.url_for('@api_documentation_page?q='.$urlQ).'">', $html);
}
}
return $html;
}
function get_documentation_html($path)
{
ob_start();
if( file_exists($path) )
{
include($path);
$html = ob_get_contents();
ob_end_clean();
return process_documentation($html, $path);
}
}
\ No newline at end of file
<?php
use_helper('ApiDocumentation');
$documentation = get_documentation($sf_request->getParameter('q'));
echo $documentation;
\ No newline at end of file
<?php
/**
* blog actions.
*
* @package doctrine_website
* @subpackage blog
* @author Your name here
* @version SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z fabien $
*/
class blogActions extends sfActions
{
/**
* Executes index action
*
*/
public function executeIndex()
{
$blogPostTable = Doctrine_Manager::getInstance()->getTable('BlogPost');
$this->latestBlogPosts = $blogPostTable->retrieveLatest(5);
}
public function executeView()
{
$slug = $this->getRequestParameter('slug');
$blogPostTable = Doctrine_Manager::getInstance()->getTable('BlogPost');
$this->blogPost = $blogPostTable->retrieveBySlug($slug);
}
}
<?php
class blogComponents extends sfComponents
{
public function executeLatest_blog_posts()
{
$blogPostTable = Doctrine_Manager::getInstance()->getTable('BlogPost');
$this->latestBlogPosts = $blogPostTable->retrieveLatest(5);
}
}
\ No newline at end of file
<?php use_helper('Date'); ?>
<div id="latest_blog_posts">
<h3>Latest Blog Posts</h3>
<ul>
<?php foreach($latestBlogPosts AS $blogPost): ?>
<li><?php echo link_to($blogPost->getName(), '@blog_post?slug='.$blogPost->getSlug()); ?> - <?php echo distance_of_time_in_words(strtotime($blogPost->getCreatedAt())); ?> ago.</li>
<?php endforeach; ?>
</ul>
</div>
\ No newline at end of file
<?php use_helper('Date'); ?>
<div class="content" id="blog">
<h1>Doctrine Blog</h2>
<?php foreach($latestBlogPosts AS $blogPost): ?>
<div class="blog_post">
<h2><?php echo link_to($blogPost->getName(), '@blog_post?slug='.$blogPost->getSlug()); ?></h2>
<h3>Posted <?php echo distance_of_time_in_words(strtotime($blogPost->getCreatedAt())); ?> ago.</h3>
<p><?php echo $blogPost->getBody(); ?></p>
</div>
<?php endforeach; ?>
</div>
<?php slot('right'); ?>
<?php echo get_partial('latest_blog_posts', array('latestBlogPosts' => $latestBlogPosts)); ?>
<?php end_slot(); ?>
\ No newline at end of file
<?php use_helper('Date'); ?>
<div class="content" id="blog_post">
<h1><?php echo $blogPost->getName(); ?></h1>
<h3>Posted <?php echo distance_of_time_in_words(strtotime($blogPost->getCreatedAt())); ?> ago.</h3>
<p><?php echo $blogPost->getBody(); ?></p>
</div>
<?php slot('right'); ?>
<input type="button" name="back_to_blog" value="Back to Blog" onClick="javascript: location.href = '<?php echo url_for('@blog'); ?>';" />
<br/><br/>
<?php echo get_component('blog', 'latest_blog_posts'); ?>
<?php end_slot(); ?>
<?php
/**
* main actions.
*
* @package doctrine_website
* @subpackage main
* @author Your name here
* @version SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z fabien $
*/
class mainActions extends sfActions
{
/**
* Executes index action
*
*/
public function executeIndex()
{
}
public function executeAbout()
{
}
public function executeDownload()
{
}
public function executeTrac()
{
$this->redirect('http://phpdoctrine.net/trac');
}
public function executeTrac_register()
{
$this->redirect('http://phpdoctrine.net/trac/register');
}
}
Doctrine is an ORM (object relational mapper) for PHP 5.2.x+ that sits on top of a powerful DBAL (database abstraction layer).
One of its key features is the ability to optionally write database queries in an OO (object oriented)
SQL-dialect called DQL inspired by Hibernates HQL. This provides developers with a powerful alternative to SQL
that maintains a maximum of flexibility without requiring needless code duplication.
\ No newline at end of file
<ul>
<li><?php echo link_to('DQL (Doctrine Query Language)', '@manual_chapter?chapter=dql-doctrine-query-language'); ?></li>
<li><?php echo link_to('Native SQL', '@manual_chapter?chapter=native-sql'); ?></li>
<li><?php echo link_to('Class Templates', '@manual_chapter?chapter=class-templates'); ?></li>
<li><?php echo link_to('Hierarchical Data', '@manual_chapter?chapter=hierarchical-data'); ?></li>
<li><?php echo link_to('Transactions', '@manual_chapter?chapter=transactions'); ?></li>
<li><?php echo link_to('Caching', '@manual_chapter?chapter=caching'); ?></li>
<li><?php echo link_to('Searching', '@manual_chapter?chapter=searching'); ?></li>
<li><?php echo link_to('Plugins', '@manual_chapter?chapter=Plugins'); ?></li>
</ul>
\ No newline at end of file
<div class="content" id="about">
<h1>About Doctrine</h1>
<a name="what"></a>
<div id="what_is">
<h2>What is Doctrine?</h2>
<?php echo get_partial('main/about_paragraph'); ?>
</div>
<a name="who"></a>
<div id="who">
<h2>Who is behind Doctrine?</h2>
<p>Here is a list of the people mainly responsible for Doctrine. Many other people not on this list contribute, they can be found
<?php echo link_to('here', 'http://phpdoctrine.net/trac/wiki/developers'); ?>.</p>
<ul>
<li><strong>Konsta Vesterinen(zYne-)</strong> - Konsta is the project founder and lead developer of Doctrine.</li>
<li><strong>Roman S. Borschel(romanb)</strong> - Assists in the development of Doctrine through suggestions and small code contributions.</li>
<li><strong>Ian P. Christian(pookey)</strong> - Hosts trac and SVN. Helps with testing and occasionally writes a line of code.</li>
<li><strong>Janne Vanhala(jepso)</strong> - The lead developer of the official Doctrine subproject Sensei. Creator of the documentation tool Doctrine uses.</li>
<li><strong><?php echo mail_to('jonwage@gmail.com', 'Jonathan H. Wage'); ?></strong>(jwage) - Website, Documentation, Packaging Releases, Bug Fixes, etc</li>
</ul>
</div>
<a name="involved"></a>
<div id="get_involved">
<h2>Want to get involved?</h2>
You can contribute to the Doctrine development in many different ways. First start by <?php echo link_to('registering for trac', '@trac_register'); ?>
access. Once you done that you can begin submitting tickets for issues/bugs you discover while working with Doctrine. If you wish to contribute directly to the code,
you must request svn commit access in IRC from either pookey or <?php echo mail_to('jonwage@gmail.com', 'jwage'); ?>.
</div>
</div>
<?php slot('right'); ?>
<h3>Quickjump</h3>
<ul>
<li><?php echo link_to('What?', '@about#what'); ?></li>
<li><?php echo link_to('Who?', '@about#who'); ?></li>
<li><?php echo link_to('Get Involved!', '@about#involved'); ?></li>
</ul>
<br/>
<h3>Key Features</h3>
<?php echo get_partial('main/key_features_list'); ?>
<?php end_slot(); ?>
\ No newline at end of file
<div class="content" id="download">
<h1>Download Doctrine</h1>
<div id="package">
<h3>Latest Package</h3>
<p><a href="http://doctrine.pengus.net/trac/attachment/wiki/packages/Doctrine-1.0.0RC1.tgz?format=raw">Doctrine-1.0.0RC1.tgz</a></p>
</div>
<div id="svn">
<h3>SVN</h3>
<p>svn co http://doctrine.pengus.net/svn/trunk .</p>
</div>
</div>
\ No newline at end of file
<div class="content" id="homepage">
<h1>Doctrine - Open Source PHP 5 ORM</h1>
<p><?php echo get_partial('main/about_paragraph'); ?></p>
<div id="key_features">
<h3>Key Features</h3>
<?php echo get_partial('main/key_features_list'); ?>
</div>
</div>
<?php slot('right'); ?>
<div id="download_latest_release">
<h3>Download Latest Release</h3>
<ul>
<li><a href="http://doctrine.pengus.net/trac/attachment/wiki/packages/Doctrine-1.0.0RC1.tgz?format=raw">Doctrine-1.0.0RC1.tgz</a></li>
</ul>
</div>
<?php echo get_component('blog', 'latest_blog_posts'); ?>
<?php end_slot(); ?>
\ No newline at end of file
<?php
/**
* Returns the revision of a SVN controlled file.
*
* The revision is acquired by executing the 'svn info' command for the file and
* parsing the last changed revision from the output.
*
* @param $file string filename
* @return int|false revision of the file, or false on failure
*/
function getSvnRevision($file)
{
$cmd = 'HOME=/tmp /usr/bin/svn info ' . escapeshellarg($file);
exec($cmd, $output);
foreach ($output as $line) {
if (preg_match('/^Last Changed Rev: ([0-9]+)$/', $line, $matches)) {
return $matches[1];
}
}
return false;
}
/**
* Wraps a Doctrine_Cache_Db and suppresses all exceptions thrown by caching
* operations. Uses Sqlite as database backend.
*/
class Cache
{
protected $_cache = null;
/**
* Constructs a cache object.
*
* If cache table does not exist, creates one.
*
* @param $cacheFile string filename of the sqlite database
*/
public function __construct($cacheFile)
{
try {
$dsn = 'sqlite:' . $cacheFile;
$dbh = new PDO($dsn);
$conn = Doctrine_Manager::connection($dbh);
$options = array(
'connection' => $conn,
'tableName' => 'cache'
);
$this->_cache = new Doctrine_Cache_Db($options);
try {
$this->_cache->createTable();
} catch (Doctrine_Connection_Exception $e) {
if ($e->getPortableCode() !== Doctrine::ERR_ALREADY_EXISTS) {
$this->_cache = null;
}
}
} catch (Exception $e) {
$this->_cache = null;
}
}
/**
* Fetches a cache record from cache.
*
* @param $id string the id of the cache record
* @return string fetched cache record, or false on failure
*/
public function fetch($id)
{
if ($this->_cache !== null) {
try {
return $this->_cache->fetch($id);
} catch (Exception $e) {
return false;
}
}
return false;
}
/**
* Saves a cache record to cache.
*
* @param $data mixed the data to be saved to cache
* @param $id string the id of the cache record
* @return bool True on success, false on failure
*/
public function save($data, $id)
{
if ($this->_cache !== null) {
try {
return $this->_cache->save($data, $id);
} catch (Exception $e) {
return false;
}
}
return false;
}
/**
* Deletes all cached records from cache.
*
* @return True on success, false on failure
*/
public function deleteAll()
{
if ($this->_cache !== null) {
try {
return $this->_cache->deleteAll();
} catch (Exception $e) {
return false;
}
}
return false;
}
}
/**
* manual actions.
*
* @package doctrine_website
* @subpackage manual
* @author Your name here
* @version SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z fabien $
*/
class manualActions extends sfActions
{
/**
* Executes index action
*
*/
public function executeIndex()
{
error_reporting(E_ALL);
$trunk = dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))));
$vendorPath = $trunk.DIRECTORY_SEPARATOR.'vendor';
$manualPath = $trunk.DIRECTORY_SEPARATOR.'manual';
$doctrinePath = $trunk.DIRECTORY_SEPARATOR.'lib';
$includePath = $doctrinePath.PATH_SEPARATOR.$vendorPath.PATH_SEPARATOR.$manualPath.DIRECTORY_SEPARATOR.'new'.DIRECTORY_SEPARATOR.'lib';
set_include_path($includePath);
require_once('Sensei/Sensei.php');
require_once('Text/Wiki.php');
spl_autoload_register(array('Doctrine', 'autoload'));
spl_autoload_register(array('Sensei', 'autoload'));
// Temporary directory used by cache and LaTeX to Pdf conversion
$tempDir = $manualPath.DIRECTORY_SEPARATOR.'new'.DIRECTORY_SEPARATOR.'tmp';
// The file where cached data is saved
$cacheFile = $tempDir.DIRECTORY_SEPARATOR.'cache.sq3';
$cache = new Cache($cacheFile);
// Fetch the revision of cached data
$cacheRev = $cache->fetch('revision');
// Check the revision of documentation files
$revision = getSvnRevision('.');
// Is current SVN revision greater than the revision of cached data?
if ($revision > $cacheRev) {
$cache->deleteAll(); // cached data is not valid anymore
$cache->save($revision, 'revision');
}
// Load table of contents from cache
$this->toc = $cache->fetch('toc');
// If table of contents was not cached, parse it from documentation files
if ( ! $this->toc instanceof Sensei_Doc_Toc) {
$this->toc = new Sensei_Doc_Toc($manualPath.'/new/docs/en.txt');
$cache->save($this->toc, 'toc');
}
$format = $this->getRequestParameter('format');
// Which format to output docs
if ($format) {
$format = ucfirst(strtolower($format));
switch ($format) {
case 'Xhtml':
case 'Latex':
case 'Pdf':
break;
default:
$format = 'Xhtml'; // default if invalid format is specified
break;
}
} else {
$format = 'Xhtml'; // default if no format is specified
}
$this->rendererClass = 'Sensei_Doc_Renderer_' . $format;
$this->renderer = new $this->rendererClass($this->toc);
$this->renderer->setOptions(array(
'title' => 'Doctrine Manual',
'author' => 'Konsta Vesterinen',
'version' => 'Rev. ' . $revision,
'subject' => 'Object relational mapping',
'keywords' => 'PHP, ORM, object relational mapping, Doctrine, database'
));
$cacheId = $format;
switch ($format) {
case 'Latex':
$this->renderer->setOption('template', file_get_contents($manualPath.'/new/templates/latex.tpl.php'));
$headers = array(
'Content-Type: application/latex',
'Content-Disposition: attachment; filename=doctrine-manual.tex'
);
break;
case 'Pdf':
$this->renderer->setOption('template', file_get_contents($manualPath.'/new/templates/latex.tpl.php'));
$this->renderer->setOptions(array(
'temp_dir' => $tempDir,
'pdflatex_path' => '/usr/bin/pdflatex',
'lock' => true
));
$headers = array(
'Content-Type: application/pdf',
'Content-Disposition: attachment; filename=doctrine-manual.pdf'
);
break;
case 'Xhtml':
default:
$this->renderer->setOption('template', file_get_contents(dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'templates/xhtml.tpl.php'));
$viewIndex = true;
if ($this->getRequest()->hasParameter('one-page')) {
$viewIndex = false;
}
if ($this->getRequest()->hasParameter('chapter')) {
$section = $this->toc->findByPath($this->getRequestParameter('chapter'));
if ($section && $section->getLevel() === 1) {
$title = $this->renderer->getOption('title') . ' - Chapter '
. $section->getIndex() . ' ' . $section->getName();
$this->renderer->setOptions(array(
'section' => $section,
'url_prefix' => '?chapter=',
'title' => $title
));
$cacheId .= '-' . $section->getPath();
$viewIndex = false;
}
}
break;
}
if (isset($viewIndex) && $viewIndex) {
$title = $this->renderer->getOption('title');
$this->title = $title;
$this->renderer->setOption('url_prefix', '?one-page');
} else {
$this->output = $cache->fetch($cacheId);
if ($this->output === false) {
try {
$this->output = $this->renderer->render();
} catch (Exception $e) {
die($e->getMessage());
}
$cache->save($this->output, $cacheId);
}
if (isset($headers)) {
foreach ($headers as $header) {
header($header);
}
}
}
if( $format == 'Latex' OR $format == 'Pdf' )
{
echo $this->output;
exit;
}
}
}
default:
stylesheets: [main, layout, manual]
javascripts: [mootools.v1.11.js, manual_tree]
layout: manual_layout
<div class="content">
<h1><?php echo link_to('Doctrine Manual', '@manual'); ?></h1>
</div>
<div class="content" id="manual">
<?php if( isset($output) ): ?>
<?php echo $output; ?>
<?php else: ?>
<p>There are several different versions of this manual available online:
<ul>
<li>View as <a href="?one-page">all chapters in one page</a>.</li>
<li>View as <a href="?chapter=<?php echo $toc->findByIndex('1.')->getPath(); ?>">one chapter per page</a>.</li>
<li>Download the <a href="?format=pdf">PDF version</a>.</li>
</ul>
</p>
<?php endif; ?>
</div>
<?php slot('right'); ?>
<h2>Table of Contents</h2>
<?php echo $renderer->renderToc(); ?>
<?php end_slot(); ?>
\ No newline at end of file
<h1>Copyright Doctrine 2006-2007 - Powered by <?php echo link_to('symfony', 'http://www.symfony-project.com', 'target=_BLANK'); ?> and sponsored by <?php echo link_to('CentreSource', 'http://www.centresource.com', 'target=_BLANK'); ?></h1>
\ No newline at end of file
<h1><?php echo link_to('Doctrine', '@homepage'); ?></h1>
<h2>$follow->the('doctrine');</h2>
\ No newline at end of file
<ul>
<li id="first"><?php echo link_to('home', '@homepage'); ?></li>
<li><?php echo link_to('about', '@about'); ?></li>
<li><?php echo link_to('download', '@download'); ?></li>
<li><?php echo link_to('manual', '@manual'); ?></li>
<li><?php echo link_to('api docs', '@api_documentation'); ?></li>
<li><?php echo link_to('blog', '@blog'); ?></li>
<li id="last"><?php echo link_to('trac', '@trac'); ?></li>
</ul>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<?php include_http_metas() ?>
<?php include_metas() ?>
<?php include_title() ?>
<link rel="shortcut icon" href="/favicon.ico" />
</head>
<body>
<div id="wrapper">
<div id="header">
<?php echo get_partial('global/header'); ?>
</div>
<div id="menu">
<?php echo get_partial('global/menu'); ?>
</div>
<div id="left">
&nbsp;
</div>
<?php echo $sf_data->getRaw('sf_content') ?>
<div id="footer">
<?php echo get_partial('global/footer'); ?>
</div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<?php include_http_metas() ?>
<?php include_metas() ?>
<?php include_title() ?>
<link rel="shortcut icon" href="/favicon.ico" />
</head>
<body>
<div id="wrapper">
<div id="header">
<?php echo get_partial('global/header'); ?>
</div>
<div id="menu">
<?php echo get_partial('global/menu'); ?>
</div>
<div id="left">
&nbsp;
</div>
<?php if( has_slot('right') ): ?>
<div id="right">
<?php echo get_slot('right'); ?>
</div>
<?php endif; ?>
<div id="content">
<?php echo $sf_data->getRaw('sf_content') ?>
</div>
<div id="footer">
<?php echo get_partial('global/footer'); ?>
</div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<?php include_http_metas() ?>
<?php include_metas() ?>
<?php include_title() ?>
<link rel="shortcut icon" href="/favicon.ico" />
<?php include_stylesheets() ?>
<!--[if gte IE 5.5]>
<![if lt IE 7]>
<?php echo stylesheet_tag('manual_iefix') ?>
<![endif]>
<![endif]-->
</head>
<body>
<div id="wrapper">
<div id="header">
<?php echo get_partial('global/header'); ?>
</div>
<div id="menu">
<?php echo get_partial('global/menu'); ?>
</div>
<div id="left">
&nbsp;
</div>
<?php if( has_slot('right') ): ?>
<div id="right">
<?php echo get_slot('right'); ?>
</div>
<?php endif; ?>
<div id="content">
<?php echo $sf_data->getRaw('sf_content') ?>
</div>
<div id="footer">
<?php echo get_partial('global/footer'); ?>
</div>
</div>
</body>
</html>
<?php
// symfony directories
$sf_symfony_lib_dir = '/usr/local/php5/lib/php/symfony';
$sf_symfony_data_dir = '/usr/local/php5/lib/php/data/symfony';
#all:
# doctrine:
# class: sfDoctrineDatabase
# param:
# dsn: mysql://user:pass@localhost/doctrine
\ No newline at end of file
---
BlogPost:
tableName: blog_post
columns:
id:
type: integer
size: 4
primary: true
autoincrement: true
created_at:
type: timestamp
updated_at:
type: timestamp
name:
type: string
size: 255
slug:
type: string
size: 255
unique: true
body:
type: clob
\ No newline at end of file
[symfony]
name=doctrine_website
.svn
/web/uploads/*
/cache/*
/log/*
INSERT INTO `blog_post` (`id`, `created_at`, `updated_at`, `name`, `slug`, `body`) VALUES
(1, '2007-09-06 11:37:00', '2007-09-06 11:41:06', 'Test Blog Post', 'test-blog-post', 'This is a test blog post!!');
INSERT INTO `sf_guard_user` (`id`, `created_at`, `updated_at`, `username`, `algorithm`, `salt`, `password`, `last_login`, `is_active`, `is_super_admin`) VALUES
(1, '2007-09-06 11:25:14', '2007-09-06 11:25:36', 'admin', 'sha1', '9dc8c66967e1bfb0e25884958a209796', '9861d585ef106d4eef607a86ad451696a926b5d3', '2007-09-06 11:25:36', 1, 1);
\ No newline at end of file
CREATE TABLE sf_guard_user_permission(
created_at DATETIME,
updated_at DATETIME,
user_id INTEGER,
permission_id INTEGER,
PRIMARY KEY(user_id,
permission_id));
CREATE TABLE sf_guard_user_group(
created_at DATETIME,
updated_at DATETIME,
group_id INTEGER,
user_id INTEGER,
PRIMARY KEY(group_id,
user_id));
CREATE TABLE sf_guard_user(
id INTEGER PRIMARY KEY AUTOINCREMENT,
created_at DATETIME,
updated_at DATETIME,
username VARCHAR(128)
NOT NULL,
algorithm VARCHAR(128)
DEFAULT 'sha1' NOT NULL,
salt VARCHAR(128)
NOT NULL,
password VARCHAR(128)
NOT NULL,
last_login DATETIME,
is_active INTEGER DEFAULT 1 NOT NULL,
is_super_admin INTEGER DEFAULT 0 NOT NULL);
CREATE TABLE sf_guard_remember_key(
id INTEGER PRIMARY KEY AUTOINCREMENT,
created_at DATETIME,
updated_at DATETIME,
user_id INTEGER,
remember_key VARCHAR(32),
ip_address VARCHAR(15));
CREATE TABLE sf_guard_permission(
id INTEGER PRIMARY KEY AUTOINCREMENT,
created_at DATETIME,
updated_at DATETIME,
name VARCHAR(255)
NOT NULL,
description VARCHAR(4000));
CREATE TABLE sf_guard_group_permission(
created_at DATETIME,
updated_at DATETIME,
group_id INTEGER,
permission_id INTEGER NOT NULL,
PRIMARY KEY(group_id,
permission_id));
CREATE TABLE sf_guard_group(
id INTEGER PRIMARY KEY AUTOINCREMENT,
created_at DATETIME,
updated_at DATETIME,
name VARCHAR(255)
NOT NULL,
description VARCHAR(4000));
<?php
class Common
{
public static function createSlug($text)
{
$text = strtolower($text);
// strip all non word chars
$text = preg_replace('/\W/', ' ', $text);
// replace all white space sections with a dash
$text = preg_replace('/\ +/', '-', $text);
// trim dashes
$text = preg_replace('/\-$/', '', $text);
$text = preg_replace('/^\-/', '', $text);
return $text;
}
}
\ No newline at end of file
<?php
/*
* Edit this file to customise your model class
*
* auto-generated by the sfDoctrine plugin
*/
class BlogPost extends BaseBlogPost
{
public function filterSetName($name)
{
$this->setSlug(Common::createSlug($name));
return $name;
}
}
<?php
/*
* Edit this file to customise your model table
*
* auto-generated by the sfDoctrine plugin
*/
class BlogPostTable extends Doctrine_Table
{
public function retrieveLatest($num)
{
$query = new Doctrine_Query();
$query->from('BlogPost p');
$query->limit($num);
$query->orderby('p.created_at DESC');
return $query->execute();
}
public function retrieveBySlug($slug)
{
$query = new Doctrine_Query();
$query->from('BlogPost p');
$query->where('p.slug = ?', $slug);
$query->limit(1);
return $query->execute()->getFirst();
}
}
<?php
/*
* Base class; DO NOT EDIT
*
* auto-generated by the sfDoctrine plugin
*/
class BaseBlogPost extends sfDoctrineRecord
{
public function setTableDefinition()
{
$this->setTableName('blog_post');
$this->hasColumn('id', 'integer', 4, array ( 'primary' => true, 'autoincrement' => true,));
$this->hasColumn('created_at', 'timestamp', null, array ());
$this->hasColumn('updated_at', 'timestamp', null, array ());
$this->hasColumn('name', 'string', 255, array ());
$this->hasColumn('slug', 'string', 255, array ( 'unique' => true,));
$this->hasColumn('body', 'clob', null, array ());
}
public function setUp()
{
}
}
<?php
/*
* Base class; DO NOT EDIT
*
* auto-generated by the sfDoctrine plugin
*/
class BasesfGuardGroup extends sfDoctrineRecord
{
public function setTableDefinition()
{
$this->setTableName('sf_guard_group');
$this->hasColumn('id', 'integer', 4, array ( 'primary' => true, 'autoincrement' => true,));
$this->hasColumn('created_at', 'timestamp', null, array ());
$this->hasColumn('updated_at', 'timestamp', null, array ());
$this->hasColumn('name', 'string', 255, array ( 'notnull' => true,));
$this->hasColumn('description', 'string', 4000, array ());
}
public function setUp()
{
$this->hasMany('sfGuardUser as users', array('refClass' => 'sfGuardUserGroup', 'local' => 'group_id', 'foreign' => 'user_id'));
$this->hasMany('sfGuardPermission as permissions', array('refClass' => 'sfGuardGroupPermission', 'local' => 'group_id', 'foreign' => 'permission_id'));
}
}
<?php
/*
* Base class; DO NOT EDIT
*
* auto-generated by the sfDoctrine plugin
*/
class BasesfGuardGroupPermission extends sfDoctrineRecord
{
public function setTableDefinition()
{
$this->setTableName('sf_guard_group_permission');
$this->hasColumn('created_at', 'timestamp', null, array ());
$this->hasColumn('updated_at', 'timestamp', null, array ());
$this->hasColumn('group_id', 'integer', 4, array ( 'primary' => true,));
$this->hasColumn('permission_id', 'integer', 4, array ( 'notnull' => true, 'primary' => true,));
}
public function setUp()
{
$this->hasOne('sfGuardGroup as sfGuardGroup', array('local' => 'group_id', 'foreign' => 'id'));
$this->hasOne('sfGuardPermission as sfGuardPermission', array('local' => 'permission_id', 'foreign' => 'id'));
}
}
<?php
/*
* Base class; DO NOT EDIT
*
* auto-generated by the sfDoctrine plugin
*/
class BasesfGuardPermission extends sfDoctrineRecord
{
public function setTableDefinition()
{
$this->setTableName('sf_guard_permission');
$this->hasColumn('id', 'integer', 4, array ( 'primary' => true, 'autoincrement' => true,));
$this->hasColumn('created_at', 'timestamp', null, array ());
$this->hasColumn('updated_at', 'timestamp', null, array ());
$this->hasColumn('name', 'string', 255, array ( 'notnull' => true,));
$this->hasColumn('description', 'string', 4000, array ());
}
public function setUp()
{
$this->hasMany('sfGuardUser as users', array('refClass' => 'sfGuardUserPermission', 'local' => 'permission_id', 'foreign' => 'user_id'));
$this->hasMany('sfGuardGroup as groups', array('refClass' => 'sfGuardGroupPermission', 'local' => 'permission_id', 'foreign' => 'group_id'));
}
}
<?php
/*
* Base class; DO NOT EDIT
*
* auto-generated by the sfDoctrine plugin
*/
class BasesfGuardRememberKey extends sfDoctrineRecord
{
public function setTableDefinition()
{
$this->setTableName('sf_guard_remember_key');
$this->hasColumn('id', 'integer', 4, array ( 'primary' => true, 'autoincrement' => true,));
$this->hasColumn('created_at', 'timestamp', null, array ());
$this->hasColumn('updated_at', 'timestamp', null, array ());
$this->hasColumn('user_id', 'integer', 4, array ( 'primary' => true,));
$this->hasColumn('remember_key', 'string', 32, array ());
$this->hasColumn('ip_address', 'string', 15, array ( 'primary' => true,));
}
public function setUp()
{
$this->hasOne('sfGuardUser as user', array('local' => 'user_id', 'foreign' => 'id', 'onDelete' => 'CASCADE'));
}
}
<?php
/*
* Base class; DO NOT EDIT
*
* auto-generated by the sfDoctrine plugin
*/
class BasesfGuardUser extends sfDoctrineRecord
{
public function setTableDefinition()
{
$this->setTableName('sf_guard_user');
$this->hasColumn('id', 'integer', 4, array ( 'primary' => true, 'autoincrement' => true,));
$this->hasColumn('created_at', 'timestamp', null, array ());
$this->hasColumn('updated_at', 'timestamp', null, array ());
$this->hasColumn('username', 'string', 128, array ( 'notnull' => true,));
$this->hasColumn('algorithm', 'string', 128, array ( 'default' => 'sha1', 'notnull' => true,));
$this->hasColumn('salt', 'string', 128, array ( 'notnull' => true,));
$this->hasColumn('password', 'string', 128, array ( 'notnull' => true,));
$this->hasColumn('last_login', 'timestamp', null, array ());
$this->hasColumn('is_active', 'boolean', null, array ( 'default' => 1, 'notnull' => true,));
$this->hasColumn('is_super_admin', 'boolean', null, array ( 'default' => 0, 'notnull' => true,));
}
public function setUp()
{
$this->hasMany('sfGuardGroup as groups', array('refClass' => 'sfGuardUserGroup', 'local' => 'user_id', 'foreign' => 'group_id'));
$this->hasMany('sfGuardPermission as permissions', array('refClass' => 'sfGuardUserPermission', 'local' => 'user_id', 'foreign' => 'permission_id'));
$this->hasMany('sfGuardRememberKey as remember_key', array('local' => 'id', 'foreign' => 'user_id'));
}
}
<?php
/*
* Base class; DO NOT EDIT
*
* auto-generated by the sfDoctrine plugin
*/
class BasesfGuardUserGroup extends sfDoctrineRecord
{
public function setTableDefinition()
{
$this->setTableName('sf_guard_user_group');
$this->hasColumn('created_at', 'timestamp', null, array ());
$this->hasColumn('updated_at', 'timestamp', null, array ());
$this->hasColumn('group_id', 'integer', 4, array ( 'primary' => true,));
$this->hasColumn('user_id', 'integer', 4, array ( 'primary' => true,));
}
public function setUp()
{
$this->hasOne('sfGuardGroup as sfGuardGroup', array('local' => 'group_id', 'foreign' => 'id'));
$this->hasOne('sfGuardUser as sfGuardUser', array('local' => 'user_id', 'foreign' => 'id'));
}
}
<?php
/*
* Base class; DO NOT EDIT
*
* auto-generated by the sfDoctrine plugin
*/
class BasesfGuardUserPermission extends sfDoctrineRecord
{
public function setTableDefinition()
{
$this->setTableName('sf_guard_user_permission');
$this->hasColumn('created_at', 'timestamp', null, array ());
$this->hasColumn('updated_at', 'timestamp', null, array ());
$this->hasColumn('user_id', 'integer', 4, array ( 'primary' => true,));
$this->hasColumn('permission_id', 'integer', 4, array ( 'primary' => true,));
}
public function setUp()
{
$this->hasOne('sfGuardUser as sfGuardUser', array('local' => 'user_id', 'foreign' => 'id'));
$this->hasOne('sfGuardPermission as sfGuardPermission', array('local' => 'permission_id', 'foreign' => 'id'));
}
}
<?php
/*
* Edit this file to customise your model class
*
* auto-generated by the sfDoctrine plugin
*/
class sfGuardGroup extends PluginsfGuardGroup
{
}
<?php
/*
* Edit this file to customise your model class
*
* auto-generated by the sfDoctrine plugin
*/
class sfGuardGroupPermission extends PluginsfGuardGroupPermission
{
}
<?php
/*
* Edit this file to customise your model table
*
* auto-generated by the sfDoctrine plugin
*/
class sfGuardGroupPermissionTable extends PluginsfGuardGroupPermissionTable
{
}
<?php
/*
* Edit this file to customise your model table
*
* auto-generated by the sfDoctrine plugin
*/
class sfGuardGroupTable extends PluginsfGuardGroupTable
{
}
<?php
/*
* Edit this file to customise your model class
*
* auto-generated by the sfDoctrine plugin
*/
class sfGuardPermission extends PluginsfGuardPermission
{
}
<?php
/*
* Edit this file to customise your model table
*
* auto-generated by the sfDoctrine plugin
*/
class sfGuardPermissionTable extends PluginsfGuardPermissionTable
{
}
<?php
/*
* Edit this file to customise your model class
*
* auto-generated by the sfDoctrine plugin
*/
class sfGuardRememberKey extends PluginsfGuardRememberKey
{
}
<?php
/*
* Edit this file to customise your model table
*
* auto-generated by the sfDoctrine plugin
*/
class sfGuardRememberKeyTable extends PluginsfGuardRememberKeyTable
{
}
<?php
/*
* Edit this file to customise your model class
*
* auto-generated by the sfDoctrine plugin
*/
class sfGuardUser extends PluginsfGuardUser
{
}
<?php
/*
* Edit this file to customise your model class
*
* auto-generated by the sfDoctrine plugin
*/
class sfGuardUserGroup extends PluginsfGuardUserGroup
{
}
<?php
/*
* Edit this file to customise your model table
*
* auto-generated by the sfDoctrine plugin
*/
class sfGuardUserGroupTable extends PluginsfGuardUserGroupTable
{
}
<?php
/*
* Edit this file to customise your model class
*
* auto-generated by the sfDoctrine plugin
*/
class sfGuardUserPermission extends PluginsfGuardUserPermission
{
}
<?php
/*
* Edit this file to customise your model table
*
* auto-generated by the sfDoctrine plugin
*/
class sfGuardUserPermissionTable extends PluginsfGuardUserPermissionTable
{
}
<?php
/*
* Edit this file to customise your model table
*
* auto-generated by the sfDoctrine plugin
*/
class sfGuardUserTable extends PluginsfGuardUserTable
{
}
Copyright (c) 2004-2006 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
sfDoctrine symfony plugin
=========================
Overview
--------
The sfDoctrine plugin allows you to totally replace propel with doctrine (http://www.phpdoctrine.com/) which is a powerful and easy-to-use ORM.
Contents
--------
This plugin contains:
- necessary tools to use doctrine: the main tool is sfDoctrine::getTable() which will allow you to send queries
- pake tasks that convert between doctrine and propel schema formats and build doctrine model classes automatically
- an admin generator: to use it just specify sfDoctrineAdmin as the main class in your generator.yml config
You will find more information in the wiki page dedicated to sfDoctrine: http://www.symfony-project.com/trac/wiki/sfDoctrine.
License
-------
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
<?php
/*
* This file is part of the sfDoctrine package.
* (c) 2006-2007 Olivier Verdier <Olivier.Verdier@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* @package symfony.plugins
* @subpackage sfDoctrine
* @author Olivier Verdier <Olivier.Verdier@gmail.com>
* @version SVN: $Id: sfDoctrineDatabaseSchema.class.php 3455 2007-02-14 16:17:48Z chtito $
*/
/*
- class: contains a bunch of columns, toMany relationships, inheritance
information, i18n information
- table: a special class that is actually a table
- column: contains the doctrine properties (name, type, size) and the toOne relation information
*/
class sfDoctrineDatabaseSchema
{
// the class descriptions
protected $classes = array();
// a subset of the array above: classes which are also tables
protected $tables = array();
public function getClasses()
{
return $this->classes;
}
protected function getClass($className)
{
if (isset($this->classes[$className]))
return $this->classes[$className];
throw new sfDoctrineSchemaException(sprintf('The class "%s" has no description', $className));
}
// retrieves a class object from its table name
protected function findClassByTableName($tableName)
{
foreach ($this->tables as $table)
if ($table->getName() == $tableName)
{
$tableClasses = $table->getClasses();
if (count($tableClasses) != 1)
throw new sfDoctrineSchemaException(sprintf('No unique class is associated to table "%s"', $tableName));
return array_pop($tableClasses);
}
throw new sfDoctrineSchemaException(sprintf('Table "%s" not found', $tableName));
}
// set the one to many and many to many relationships
// finds out what are the foreign classes or foreign tables
protected function fixRelationships()
{
foreach ($this->classes as $className => $class)
{
foreach ($class->getColumns() as $relCol)
if ($relation = $relCol->getRelation())
{
// if no foreignClass was specified (import from propel) we find it out
if (!$relation->get('foreignClass'))
{
$foreignClass = $this->findClassByTableName($relation->get('foreignTable'));
$relation->set('foreignClass', $foreignClass->getPhpName());
}
// if foreignTable was not set (only used for export to propel)
// we figure it out
if (!$relation->get('foreignTable'))
{
$className = $relation->get('foreignClass');
$relation->set('foreignTable', $this->getClass($className)->getTableName());
}
// the relation is a many2many
if ($relation->get('counterpart'))
{
$counterpartRel = $class->getRelation($relation->get('counterpart'));
$relation->set('otherClass', $counterpartRel->get('foreignClass'));
}
// we copy all the toOne relations to the corresponding
// foreign class
$rel = $relCol->getRelation();
$this->getClass($rel->get('foreignClass'))->addToMany($rel); // FIXME: don't copy here
}
}
}
// exports the current schema as a propel xml file
public function asPropelXml()
{
$xml = new SimpleXmlElement(sprintf('<?xml version="1.0" encoding="UTF-8" ?>
<database name="%s" defaultIdMethod="native"></database>', 'connection'));
foreach ($this->tables as $table)
{
$table->addPropelXmlClasses($xml);
}
return array('source'=>$xml->asXml());
}
// exports the current schema in a sfDoctrine yml file
public function asDoctrineYml()
{
$ymlClasses = array();
foreach ($this->classes as $class)
{
$ymlClasses[$class->getPhpName()] = $class->asDoctrineYml();
}
return array('source'=>sfYaml::dump($ymlClasses));
}
public function debug()
{
$debug = array();
foreach ($this->classes as $class)
{
$debug[$class->getPhpName()] = $class->debug();
}
return $debug;
}
}
class sfDoctrineSchemaException extends sfException
{
public function __construct($message = null, $code = 0)
{
$this->setName('sfDoctrineSchemaException');
parent::__construct($message, $code);
}
}
\ No newline at end of file
<?php
/*
* This file is part of the sfDoctrine package.
* (c) 2006-2007 Olivier Verdier <Olivier.Verdier@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* @package symfony.plugins
* @subpackage sfDoctrine
* @author Olivier Verdier <Olivier.Verdier@gmail.com>
* @version SVN: $Id: sfDoctrineRelationSchema.class.php 4705 2007-07-24 20:45:46Z Jonathan.Wage $
*/
class sfDoctrineRelationSchema
{
protected $relationInfo = array();
public function __construct($relationInfo)
{
foreach ($relationInfo as $key => $value)
{
$this->set($key, $value);
}
}
public function set($key, $value)
{
// we set the default foreign name
if ($key == 'foreignClass')
{
if (!isset($this->relationInfo['foreignName']))
{
$this->relationInfo['foreignName'] = $value;
}
}
$this->relationInfo[$key] = $value;
}
public function get($key)
{
if (isset($this->relationInfo[$key]))
{
return $this->relationInfo[$key];
}
else if (isset($this->relationInfo['options']))
{
if ($option = $this->relationInfo['options']->get($key))
{
return $option;
}
}
return null;
}
public function asDoctrineYml()
{
$output = array();
foreach(array('foreignClass', 'foreignReference', 'localName', 'foreignName', 'cascadeDelete', 'unique') as $key)
{
if ($value = $this->get($key))
{
$output[$key] = $value;
}
}
// FIXME: this is clumsy: change the schema syntax?
if ($verb == 'owns')
{
$output['cascadeDelete'] = true;
}
return $output;
}
public function asPhpArray($array)
{
$phpArray = 'array(';
if( !empty($array) )
{
foreach($array AS $key => $value)
{
$phpArray .= "'{$key}' => '{$value}', ";
}
$phpArray = substr($phpArray, 0, strlen($phpArray) - 2);
}
$phpArray .= ')';
return $phpArray;
}
public function asOnePhp()
{
// special behaviour for xref tables with cascade delete
$verb = ($this->get('cascadeDelete') && ($this->get('counterpart') || $this->get('unique'))) ? 'owns' : 'has';
$options['local'] = $this->get('localReference');
$options['foreign'] = $this->get('foreignReference');
//support old and new cascade declarations
if ($verb == 'owns' || $this->get('cascadeDelete') === true)
{
$options['onDelete'] = 'CASCADE';
}
if ($this->get('onDelete'))
{
$options['onDelete'] = strtoupper($this->get('onDelete'));
}
$phpOptions = $this->asPhpArray($options);
return "\$this->$verb"."One('{$this->get('foreignClass')} as {$this->get('foreignName')}', $phpOptions);";
}
public function asManyPhp()
{
$quantity = $this->get('unique') ? 'One':'Many';
// using "owns" for cascade delete except in xref table
$verb = ($this->get('cascadeDelete') && !$this->get('counterpart')) ? 'has':'has';
$otherClass = $this->get('localClass');
if ($quantity == 'Many' && $this->get('counterpart'))
{
$localReference = $this->relationInfo['localReference'];
$foreignReference = $this->relationInfo['options']->get('counterpart');
$otherClass = $this->get('otherClass');
} else {
$localReference = $this->get('foreignReference');
$foreignReference = $this->get('localReference');
}
$localClass = $this->get('localClass');
// Set refClass to localClass if it is a Many-Many relationship
if ($quantity == 'Many' && $this->get('counterpart'))
{
$refClass = $this->get('localClass');
}
if (isset($refClass) && $refClass)
{
$options['refClass'] = $refClass;
}
if ($localReference)
{
$options['local'] = $localReference;
}
if ($foreignReference)
{
$options['foreign'] = $foreignReference;
}
$phpOptions = $this->asPhpArray($options);
return "\$this->$verb$quantity('$otherClass as {$this->get('localName')}', $phpOptions);";
}
public function debug()
{
return $this->relationInfo;
}
}
\ No newline at end of file
<?php
/*
* This file is part of the sfDoctrine package.
* (c) 2006-2007 Olivier Verdier <Olivier.Verdier@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* @package symfony.plugins
* @subpackage sfDoctrine
* @author Olivier Verdier <Olivier.Verdier@gmail.com>
* @version SVN: $Id: sfDoctrineSchemaDoctrineLoader.class.php 3455 2007-02-14 16:17:48Z chtito $
*/
class sfDoctrineSchemaDoctrineLoader extends sfDoctrineDatabaseSchema
{
// recursively finds out what a class table is
// FIXME: check for infinite loop?
protected function parentTable($class)
{
if ($class->hasTable())
return $class->getTable();
return $this->parentTable($this->getClass($class->getParentClassName()));
}
// associate a table to each class
protected function fixTables()
{
foreach ($this->classes as $className => $class)
{
$table = $this->parentTable($class);
$table->addClass($class);
}
}
// set up the necessary fields in the i18n table: culture, id
protected function addI18nFields()
{
foreach ($this->classes as $className => $class)
{
if (!$class->hasI18n())
continue;
$i18nClass = $this->getClass($class->getI18n('class'));
$cultureColumn = new sfDoctrineColumnSchema($class->getI18n('cultureField'), array('type'=> 'string', 'size'=> 100, 'primary'=> true));
$i18nClass->addColumn($cultureColumn);
// add the foreign key to the main table
$idDesc = array('foreignClass'=>$className, 'localName'=>$i18nClass->getPhpName(), 'onDelete'=>'cascade', 'primary'=>true);
$i18nClass->addColumn(new sfDoctrineColumnSchema('id', $idDesc));
}
}
// adds the class key fields
protected function addInheritanceFields()
{
foreach ($this->classes as $className => $class)
if ($class->hasOneTableInheritance())
{
$inh = $class->getInheritance();
$class->getTable()->addColumn(new sfDoctrineColumnSchema($inh['keyField'], array('type'=>'integer')));
}
}
public function load($file, $package = null)
{
$schema = sfYaml::load($file);
foreach ($schema as $className => $cd)
{
if (!isset($cd['tableName']) && !isset($cd['inheritance']))
throw new sfDoctrineSchemaException(sprintf('Class "%s" must have either a table or a parent', $className));
$class = new sfDoctrineClassSchema($className, $cd);
// add a table if necessary
if (isset($cd['tableName']))
{
// this top class is actually a table
$table = new sfDoctrineTableSchema($cd['tableName'], $package);
$table->addClass($class);
$this->tables[$cd['tableName']] = $table;
}
$this->classes[$className] = $class;
}
}
public function process()
{
$this->fixTables();
$this->addI18nFields();
$this->fixRelationships();
$this->addInheritanceFields();
}
}
\ No newline at end of file
<?php
/*
* This file is part of the sfDoctrine package.
* (c) 2006-2007 Olivier Verdier <Olivier.Verdier@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* @package symfony.plugins
* @subpackage sfDoctrine
* @author Olivier Verdier <Olivier.Verdier@gmail.com>
* @version SVN: $Id: sfDoctrineSchemaPropelLoader.class.php 3455 2007-02-14 16:17:48Z chtito $
*/
class sfDoctrineSchemaPropelLoader extends sfDoctrineDatabaseSchema
{
// get the attributes parsed by the sfPropelDatabaseSchema class
protected function getAttribute($tag, $attribute)
{
return isset($tag['_attributes'][$attribute]) ? $tag['_attributes'][$attribute] : null;
}
public function load($file, $package = null)
{
// we figure out what kind of file we are given
$type = array_pop(explode('.', $file));
$type2method = array('yml'=>'loadYAML', 'xml'=>'loadXML');
if (isset($type2method[$type]))
$method = $type2method[$type];
else
throw new sfDoctrineSchemaException(sprintf('Unkwnown method for extension "%s"', $type));
$propelDatabaseSchema = new sfPropelDatabaseSchema();
$propelDatabaseSchema->$method($file);
$data = $propelDatabaseSchema->asArray();
foreach ($propelDatabaseSchema->getTables() as $tb_name => $tableDesc)
{
// special table class
// propel has only such classes (no inheritance support)
$table = new sfDoctrineTableSchema($tb_name, $package);
$this->tables[$tb_name] = $table;
if (!($className = $this->getAttribute($tableDesc, 'phpName')))
$className = sfInflector::camelize($tb_name); // wild guess
$class = new sfDoctrineClassSchema($className);
$table->addClass($class);
// columns
foreach ($propelDatabaseSchema->getChildren($tableDesc) as $col_name => $columnDescription)
{
if (($col_name == 'id')) // id is automatically generated in doctrine
continue;
$docCol = new sfDoctrineColumnSchema($col_name, $columnDescription, true);
$class->addColumn($docCol);
}
$this->classes[$class->getPhpName()] = $class;
}
}
public function process()
{
$this->fixRelationships();
}
}
\ No newline at end of file
<?php
/*
* This file is part of the sfDoctrine package.
* (c) 2006-2007 Olivier Verdier <Olivier.Verdier@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* @package symfony.plugins
* @subpackage sfDoctrine
* @author Olivier Verdier <Olivier.Verdier@gmail.com>
* @version SVN: $Id: sfDoctrineTableSchema.class.php 3455 2007-02-14 16:17:48Z chtito $
*/
class sfDoctrineTableSchema extends sfDoctrineClassSchema
{
// the classes associated to that table
protected $classes;
// table name
protected $name;
// package of that table (usually either a plugin name, or a propel schema name)
protected $package;
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
public function __construct($tableName, $package)
{
$this->setName($tableName);
$this->package = $package;
}
public function addClass($class)
{
// we add the class and try to avoid duplication
$this->classes[$class->getPhpName()] = $class;
$class->setTable($this);
}
public function getClasses()
{
return $this->classes;
}
// exports this table in propel xml format
public function addPropelXmlClasses(&$node)
{
$t = $node->addChild('table');
$t->addAttribute('name', $this->getName());
$t->addAttribute('phpName', $this->getPhpName());
foreach($this->classes as $class)
{
$class->addPropelXmlColumns($t);
}
}
public function getPackage()
{
return $this->package;
}
}
autoload:
Doctrine:
name: Doctrine classes
ext: .php
path: %SF_PLUGINS_DIR%/sfDoctrinePlugin/lib/doctrine
recursive: on
doctrine_model_classes:
name: Doctrine model classes
ext: .class.php
path: %SF_LIB_DIR%/model/doctrine
config/doctrine.yml:
class: sfDoctrineConfigHandler
config/schemas.yml:
class: sfDoctrineSchemasConfigHandler
all:
#doctrine attributes
attributes:
#automatic table creation (none, tables, constraints, all)
export: all
#default fetch mode (immediate, batch, lazy, offset, lazy_offset)
# fetchmode: immediate
#collection limit (integer 1+)
# coll_limit: 5
#global event listener
# listener: sfDoctrineEventListener
#enable doctrine side validation (true, false)
validate: false
# enable quoting
quote_identifier: false
all:
orm: doctrine
# default_database: <your default connection here>
\ No newline at end of file
<?php
/**
* ##MODULE_NAME## actions.
*
* @package ##PROJECT_NAME##
* @subpackage ##MODULE_NAME##
* @author ##AUTHOR_NAME##
* @version SVN: $Id: actions.class.php,v 1.1 2006/12/08 18:49:35 nathanael Exp $
*/
class ##MODULE_NAME##Actions extends auto##MODULE_NAME##Actions
{
}
generator:
class: sfDoctrineAdminGenerator
param:
model_class: ##MODEL_CLASS##
theme: crud
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment