March 17, 2010
WPHP

This module allows you to run PHP processes inside of Python, using a WSGI gateway. This way PHP applications can appear like normal Python WSGI applications, and WSGI middleware routing and filters can all be applied in front of them. For instance, WSGI middleware-based authentication or authorization, routing, deployment, or styling filters (like WSGIOverlay).

Posted via web from 原宿工業大学 | Comment »

March 11, 2010
Using PHP and XSLT to Create a Word 2007 Document

The following PHP code example shows how you transform XML data into the Open XML format. The code uses a DOMDocument object to load the XSLT and create an XSLTProcessor. The XSLTPRocessor’s transformToXML method is called to transform the XML data into the Open XML Wordprocessing format.

//Load the xml data and xslt and perform the transformation.  $xmlDocument = new DOMDocument();  $xmlDocument->load($xmlDataFile);    $xsltDocument = new DOMDocument();  $xsltDocument->load($xsltFile);    $xsltProcessor = new XSLTProcessor();  $xsltProcessor->importStylesheet($xsltDocument);    //After the transformation $newContentNew contains   //the XML data in the Open XML Wordprocessing format.  $newContent =  $xsltProcessor->transformToXML($xmlDocument);  

The following PHP example shows creating the output Word 2007 document. Open XML files are packaged following the Open Packaging Convention and can be treated as Zip files. A ZipArchive object is used to open the Word 2007 document for editing.

//Copy the Word 2007 template document to the output file.  if (copy($sourceTemplate, $outputDocument)) {    //Open XML files are packaged following the Open Packaging   //Conventions and can be treated as zip files when   //accessing their content.  $zipArchive = new ZipArchive();  $zipArchive->open($outputDocument);

The contents of a Word 2007 document are stored in the document.xml file. The following PHP code example shows how to update the Word 2007 document by using the content that contains the XML data by replacing the document.xml file and then closing the ZipArchive to save the changes.

  //Replace the content with the new content created above.  //In the Open XML Wordprocessing format content is stored  //in the document.xml file located in the word directory.  $zipArchive->addFromString("word/document.xml", $newContent);  $zipArchive->close();

XSLTを作るのがかなり大変。でも、rst2xml 用のスタイルシートを1回作れば幸せになれるかもしれない。

Posted via web from 原宿工業大学 | Comment »

March 9, 2010
Labs: PHP SPKit Lasso: SCM Repository

Documentation for GIT is available here.

Anonymous Git Access

This project’s GIT repository can be checked out through anonymous access with the following command(s).

git clone git://git.labs.libre-entreprise.org/spkitlasso.git

Developer GIT Access via SSH

Only project developers can access the GIT tree via this method. SSH must be installed on your client machine. Substitute developername with the proper values. Enter your site password when prompted.

git clone ssh://developername@git.labs.libre-entreprise.org/gitroot/spkitlasso.git

Posted via web from 原宿工業大学 | Comment »

March 5, 2010
simpleSAMLphp | Feide RnD

simpleSAMLphp

SimpleSAMLphp is a simple application written in native PHP that deals with authentication. SimpleSAMLphp supports several federation protocols, authentication mechanisms and can be used both for local authentication, as a service provider or as an identity provider.

Download simpleSAMLphp.

Support Protocols

SimpleSAMLphp version 1.3 supports the following protocols:

  • SAML 2.0 as a Service Provider.
  • SAML 2.0 as an Identity Provider.
  • Shiboleth 1.3 as a Service Provider.
  • Shiboleth 1.3 as an Identity Provider.
  • A-Select as a Service Provider (contribution from SurfNet).
  • A-Select as an Identity Provider (contribution from SurfNet).
  • CAS for remote authentication (contribution from Wayf.dk)
  • OpenID Provider support (experimental)
  • OpenID Consumer support (experimental)
  • WS-Federation as a Service Provider

Furthermore the following protocols exists for simpleSAMLphp but are not yet part of the stable release:

  • InfoCard as an Service Provider
  • PAPI as a Service Provider
  • PAPI as an Identity Provider

Expect these to be included in the stable release pretty soon. If you are impatient and want to use it right away, ask for more details on the mailing list.

Moreover, we plan to implement support for the OAuth protocol for delegated authentication sometime in near future.

Posted via web from 原宿工業大学 | Comment »

March 1, 2010
Doctrine: Django モデルで作ったテーブルをクエリ

Doctrineのブートストラップ


ディレクトリがないとloadModelsでエラーになるので一旦コメントアウト。 (djtweet)hdknr@deblen:~/.ve/djtweet/apache/eccube-2.4.2/html/promocode$ more bootstrap.php
<?PHP
$DBS=’localhost’;
$DBN=’djcube’;
$DBU=$DBN;
$DBP=$DBN;
//
require_once “Doctrine.php”;
spl_autoload_register(array(‘Doctrine’, ‘autoload’));
$manager = Doctrine_Manager::getInstance();
//
$manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);
//Doctrine::loadModels(array(‘models/generated/’,’models’));
//Doctrine::loadModels(array(‘models’));
//
$con = Doctrine_Manager::connection(“mysql://$DBU:$DBP@$DBS/$DBN”)
 ?>

inspectスクリプト。


(djtweet)hdknr@deblen:~/.ve/djtweet/apache/eccube-2.4.2/html/promocode$ more inspectdb.php
<?PHP
require_once “bootstrap.php”;
Doctrine::generateModelsFromDb(‘models’, array(‘doctrine’), array(‘generateTableClasses’ => true));
 ?>

inspect実行。

(djtweet)hdknr@deblen:~/.ve/djtweet/apache/eccube-2.4.2/html/promocode$ php inspectdb.php

(djtweet)hdknr@deblen:~/.ve/djtweet/apache/eccube-2.4.2/html/promocode$ ls -R models/
models/:
AuthGroup.php                  AuthUserGroups.php                DjangoSession.php             DjcubePromotionentryTable.php
AuthGroupPermissions.php       AuthUserGroupsTable.php           DjangoSessionTable.php        DjcubeShop.php
AuthGroupPermissionsTable.php  AuthUserTable.php                 DjangoSite.php                DjcubeShopTable.php
AuthGroupTable.php             AuthUserUserPermissions.php       DjangoSiteTable.php           DjcubeUseragent.php
AuthMessage.php                AuthUserUserPermissionsTable.php  DjcubePromotion.php           DjcubeUseragentTable.php
AuthMessageTable.php           DjangoAdminLog.php                DjcubePromotionTable.php      generated
AuthPermission.php             DjangoAdminLogTable.php           DjcubePromotioncode.php
AuthPermissionTable.php        DjangoContentType.php             DjcubePromotioncodeTable.php
AuthUser.php                   DjangoContentTypeTable.php        DjcubePromotionentry.php models/generated:
BaseAuthGroup.php             BaseAuthUser.php                 BaseDjangoContentType.php  BaseDjcubePromotioncode.php
BaseAuthGroupPermissions.php  BaseAuthUserGroups.php           BaseDjangoSession.php      BaseDjcubePromotionentry.php
BaseAuthMessage.php           BaseAuthUserUserPermissions.php  BaseDjangoSite.php         BaseDjcubeShop.php
BaseAuthPermission.php        BaseDjangoAdminLog.php           BaseDjcubePromotion.php    BaseDjcubeUseragent.php

クエリのテストスクリプト。


(djtweet)hdknr@deblen:~/.ve/djtweet/apache/eccube-2.4.2/html/promocode$ more x.php
<?PHP
require_once(‘bootstrap.php’);
require_once(‘models/generated/BaseDjcubePromotionentry.php’);
require_once(‘models/generated/BaseDjcubePromotioncode.php’);
require_once(‘models/generated/BaseDjcubePromotion.php’); $e= Doctrine_Core::getTable(‘DjcubePromotionentry’)->findOnebyDigest(‘dafd005405a3575fc2214ac33a8ffa62’);
$c= Doctrine_Core::getTable(‘DjcubePromotioncode’)->find($e->promotioncode_id );
$p= Doctrine_Core::getTable(‘DjcubePromotion’)->find($c->promotion_id );

echo “promotion name is ‘$p->name’.\n”;
 ?> PromotionentryはPromotioncodeのFKもっているので、Djangoのモデルみたいに参照したときに勝手にクエリしてくれる、 とかないかな。

bootstrapを編集。


(djtweet)hdknr@deblen:~/.ve/djtweet/apache/eccube-2.4.2/html/promocode$ vi bootstrap.php

Doctrine::loadModels(array(‘models/generated/’,’models’));

実行

(djtweet)hdknr@deblen:~/.ve/djtweet/apache/eccube-2.4.2/html/promocode$ php x.php

promotion name is ‘secret’.

Posted via email from 原宿工業大学 | Comment »

The symfony and Doctrine book | 6章 - データを扱う | symfony | Web PHP Framework

finderマジックメソッド

1つのフィールドの値によってレコードを見つけるためにfindBy*()findOneBy*()マジックメソッドを活用できます。

$user = Doctrine::getTable('User')->findOneByUsername('jwage');  $users = Doctrine::getTable('User')->findByIsActive(1);

Posted via web from hdknr’s posterous | Comment »

[Doctrine] Baseクラスのオートロードに失敗

実行したところ
Fatal error: Class 'BaseUser' not found in /home/sites/doctrine.gomo.jp/web/models/User.php on line 13
Baseクラスの読み込みに失敗しました。動かすには
$manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);
ATTR_MODEL_LOADINGをMODEL_LOADING_CONSERVATIVEに設定してやると動くようになります。デフォルトではMODEL_LOADING_AGGRESSIVEになってます。

MODEL_LOADING_CONSERVATIVEはクラス名とそのパスを保持していて、そのクラスが必要な時に読み込まれるいわゆるLasy loadです。その際指定したフォルダにフォルダがあった場合はしたの階層もリスト化します。

対してMODEL_LOADING_AGGRESSIVEはDoctrine::loadModelsで指定したフォルダにあるクラスを一気にrequireします。指定したフォルダの直下のクラスしか読み込まないようです。

Posted via web from 原宿工業大学 | Comment »

lion|framework • View topic - fatal error on Doctrine::loadModels(‘models’);

Re: fatal error on Doctrine::loadModels(‘models’);

Postby mkingston on Wed Oct 14, 2009 6:03 pm

It was indeed a path issue. I first separated the “generated” folder from the models folder and added the following to the includepath.xml and it all started working correctly:

<!— Base Model classes —>
<cluster name=”Base” path=”/generated/…”>
<class name=”*” file=”*.class.php”/>
<interface name=”*” file=”*.php”/>
</cluster>

Thanks for pointing me in the right direction… I’m starting to catch on a little!

Thanks again,

Merrill

Posted via web from 原宿工業大学 | Comment »

February 20, 2010
PHP:動的にコードファイルを読み込む

includeを使うみたい。

promo.php <?PHP
$promo=’blue’.’.php’;

if (file_exists($promo))
{
    include $promo;
    main();
}
 ?>
blue.php

<?PHP
echo “I’m BLUE”;
function main()
{
    echo “I’m blue”;
}
 ?>

Posted via email from 原宿工業大学 | Comment »

4:35am  |   URL: http://hdknr.com/post/399006920/php
FILED UNDER: include PHP 
Bookmark and Share
February 10, 2010
Doctrine : inspecting database to generate models like Django inspectdb

(djtweet)hdknr@deblen:~/.ve/djtweet/apache/www$ more bootstrap.php
(djtweet)hdknr@deblen:~/.ve/djtweet/apache/www$ more inspectdb.php
require_once “bootstrap.php”;
Doctrine::generateModelsFromDb(‘models’, array(‘doctrine’),
array(‘generateTableClasses’ => true));
?>
(djtweet)hdknr@deblen:~/.ve/djtweet/apache/www$ sudo -u www-data php
inspectdb.php

hdknr@deblen:~/.ve/djtweet/apache/www$ tree -R models/ models/

|— AuthGroup.php |— AuthGroupPermissions.php

|— AuthGroupPermissionsTable.php |— AuthGroupTable.php

|— AuthMessage.php |— AuthMessageTable.php

|— AuthPermission.php |— AuthPermissionTable.php

|— AuthUser.php |— AuthUserGroups.php

|— AuthUserGroupsTable.php |— AuthUserTable.php

|— AuthUserUserPermissions.php |— AuthUserUserPermissionsTable.php

|— DiaryDiary.php |— DiaryDiaryTable.php

|— DiaryPart.php |— DiaryPartTable.php

|— DiaryPublisher.php |— DiaryPublisherTable.php

|— DjangoAdminLog.php |— DjangoAdminLogTable.php

|— DjangoContentType.php |— DjangoContentTypeTable.php

|— DjangoSession.php |— DjangoSessionTable.php

|— DjangoSite.php |— DjangoSiteTable.php

|— Tweets.php |— Tweets20090815.php

|— Tweets20090815Table.php |— TweetsBk.php

|— TweetsBkTable.php |— TweetsTable.php

|— TweetsTweet.php |— TweetsTweetTable.php

|— TweetsTweets.php |— TweetsTweetsTable.php

|— TweetsTwitter.php |— TweetsTwitterTable.php

`— generated |— BaseAuthGroup.php

|— BaseAuthGroupPermissions.php |— BaseAuthMessage.php

|— BaseAuthPermission.php |— BaseAuthUser.php

|— BaseAuthUserGroups.php |— BaseAuthUserUserPermissions.php

|— BaseDiaryDiary.php |— BaseDiaryPart.php

|— BaseDiaryPublisher.php |— BaseDjangoAdminLog.php

|— BaseDjangoContentType.php |— BaseDjangoSession.php

|— BaseDjangoSite.php |— BaseTweets.php

|— BaseTweets20090815.php |— BaseTweetsBk.php

|— BaseTweetsTweet.php |— BaseTweetsTweets.php

`— BaseTweetsTwitter.php 1 directory, 60 files

hdknr@deblen:~/.ve/djtweet/apache/www$ more models/TweetsTweet.php /**
* TweetsTweet
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME##
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
class TweetsTweet extends BaseTweetsTweet
{

}
hdknr@deblen:~/.ve/djtweet/apache/www$ more
models/generated/BaseTweetsTweet.php
/**
* BaseTweetsTweet
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @property integer $id
* @property string $author_id
* @property string $author_name
* @property string $author_nickname
* @property string $author_uri
* @property timestamp $published
* @property timestamp $updated
* @property string $link
* @property string $title
* @property string $content
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME##
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
abstract class BaseTweetsTweet extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName(‘tweets_tweet’);
$this->hasColumn(‘id’, ‘integer’, 4, array(
‘type’ => ‘integer’,
‘length’ => 4,
‘fixed’ => false,
‘unsigned’ => false,
‘primary’ => true,
‘autoincrement’ => true,
));
$this->hasColumn(‘author_id’, ‘string’, 20, array(
‘type’ => ‘string’,
‘length’ => 20,
‘fixed’ => false,
‘unsigned’ => false,
‘primary’ => false,
‘notnull’ => true,
‘autoincrement’ => false,
));
$this->hasColumn(‘author_name’, ‘string’, 50, array(
‘type’ => ‘string’,
‘length’ => 50,
‘fixed’ => false,
‘unsigned’ => false,
‘primary’ => false,
‘notnull’ => true,
‘autoincrement’ => false,
));
$this->hasColumn(‘author_nickname’, ‘string’, 50, array(
‘type’ => ‘string’,
‘length’ => 50,
‘fixed’ => false,
‘unsigned’ => false,
‘primary’ => false,
‘notnull’ => true,
‘autoincrement’ => false,
));
$this->hasColumn(‘author_uri’, ‘string’, 256, array(
‘type’ => ‘string’,
‘length’ => 256,
‘fixed’ => false,
‘unsigned’ => false,
‘primary’ => false,
‘notnull’ => true,
‘autoincrement’ => false,
));
$this->hasColumn(‘published’, ‘timestamp’, null, array(
‘type’ => ‘timestamp’,
‘fixed’ => false,
‘unsigned’ => false,
‘primary’ => false,
‘notnull’ => true,
‘autoincrement’ => false,
));
$this->hasColumn(‘updated’, ‘timestamp’, null, array(
‘type’ => ‘timestamp’,
‘fixed’ => false,
‘unsigned’ => false,
‘primary’ => false,
‘notnull’ => true,
‘autoincrement’ => false,
));
$this->hasColumn(‘link’, ‘string’, 255, array(
‘type’ => ‘string’,
‘length’ => 255,
‘fixed’ => false,
‘unsigned’ => false,
‘primary’ => false,
‘notnull’ => true,
‘autoincrement’ => false,
));
$this->hasColumn(‘title’, ‘string’, 256, array(
‘type’ => ‘string’,
‘length’ => 256,
‘fixed’ => false,
‘unsigned’ => false,
‘primary’ => false,
‘notnull’ => true,
‘autoincrement’ => false,
));
$this->hasColumn(‘content’, ‘string’, 256, array(
‘type’ => ‘string’,
‘length’ => 256,
‘fixed’ => false,
‘unsigned’ => false,
‘primary’ => false,
‘notnull’ => true,
‘autoincrement’ => false,
));
}

public function setUp()
{
parent::setUp(); }
}

Posted via email from 原宿工業大学 | Comment »