memo.xight.org

01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

2006-04-18 Tue

Bloginfluence

- 計算式

[(blog+posts+web links) + (bloglines subs * 2)] * 1+(Pagerank/10)


- Reference
Bloginfluence - Rate your influence in the blogosphere - SEO tool
http://www.bloginfluence.net/en/
- via
http://www.hyuki.com/t/200604.html#i20060418083210

カテゴリ: [Web Tool]

everystockphoto.com - Creative Common ライセンスの画像集

- Reference
everystockphoto.com - your source for free photos
http://www.everystockphoto.com/

カテゴリ: [Memo]

Niceform できれいなフォーム生成

- source

<script language="javascript" type="text/javascript"
src="niceforms.js"></script>
<style type="text/css" media="screen">@import
url(niceforms-default.css);</style>

- Reference
badboy.media.design :: articles :: Niceforms
http://www.badboy.ro/articles/2005-07-23/
- via
phpspot開発日誌 - Niceformでエレガントなフォーム生成
http://phpspot.org/blog/archives/2006/04/niceform.html

カテゴリ: [PHP]
内部リンク: [2006-06-19-16]

ime.nuからアクセスがあった際の調査方法

- Reference
地獄変00 - ime.nuからアクセスが! そんなときは…
http://blog.livedoor.jp/jigokuhen00/archives/6271017.html
2ちゃんねる検索
http://find.2ch.net/
はてな - ime.nuとは
http://d.hatena.ne.jp/keyword/ime.nu
はてな - ime.stとは
http://d.hatena.ne.jp/keyword/ime.st

カテゴリ: [2ch]

PHP で DOM を使って HTML を出力

- 準備

# aptitude install php4-domxml


- PHPをソースから入れている場合
php.iniを編集

extension_dir = "/usr/lib/php4/20020429"



- sample

// 文章を生成する
$doc = domxml_new_doc("1.0");
 
$root = $doc->create_element("html");  // ルートとなる要素生成 (<html>タグ)
$root->set_attribute('lang','ja');     // <html>タグに lang 属性を追加
$root = $doc->append_child($root);
 
// <head>タグ生成
$head = $doc->create_element("head");
$head = $root->append_child($head);
 
// <title>タグ生成
$title = $doc->create_element("title");
$title = $head->append_child($title);
 
// <title>タグの中にテキスト挿入
$text = $doc->create_text_node("This is the title");
$text = $title->append_child($text);
 
// HTMLを出力
echo $doc->html_dump_mem();


- output (インデント付与)
<html lang="ja">
  <head>
    <title>This is the title</title>
  </head>
</html>


- 応用例
都道府県の一覧の<select>タグを出力
function generateSelectHtml($items,$id,$default){
	$doc = domxml_new_doc("1.0");
	$root = $doc->create_element('select');
	$root->set_attribute('name',$id);
	$root->set_attribute('id',$id);
	$root= $doc->append_child($root);
	
	// 初期表示のテキストが設定されていたとき
	if (!empty($default)){
		$option = $doc->create_element('option');
		$option->set_attribute('value','');
		
		if(empty($_SESSION[$id])){
			$option->set_attribute('selected','selected');
		}
		
		/* Add text node */
		$text = $doc->create_text_node($default);
		$option->append_child($text);
		
		$root->append_child($option);
	}
 
	foreach($items as $i){
		$option = $doc->create_element('option');
		$option->set_attribute('value',$i);
		
		if ($_SESSION[$id] == $i){
			$option->set_attribute('selected','selected');
		}
		
		/* Add text node */
		$text = $doc->create_text_node($i);
		$option->append_child($text);
		
		$root->append_child($option);
	}
	return $doc->html_dump_mem();
}
 
function generatePrefSelectHtml(){
	$default = '都道府県を選択してください。';
	$items = array(
	'北海道',
	'青森県',
	'岩手県',
	'宮城県',
	'秋田県',
	'山形県',
	'福島県',
	'茨城県',
	'栃木県',
	'群馬県',
	'埼玉県',
	'千葉県',
	'東京都',
	'神奈川県',
	'新潟県',
	'富山県',
	'石川県',
	'福井県',
	'山梨県',
	'長野県',
	'岐阜県',
	'静岡県',
	'愛知県',
	'三重県',
	'滋賀県',
	'京都府',
	'大阪府',
	'兵庫県',
	'奈良県',
	'和歌山県',
	'鳥取県',
	'島根県',
	'岡山県',
	'広島県',
	'山口県',
	'徳島県',
	'香川県',
	'愛媛県',
	'高知県',
	'福岡県',
	'佐賀県',
	'長崎県',
	'熊本県',
	'大分県',
	'宮崎県',
	'鹿児島県',
	'沖縄県',
	);
	return generateSelectHtml($items,'pref',$default);
}


- usage
<?= generatePrefSelectHtml() ?>


- Reference
PHP: DomDocument->html_dump_mem - Manual
http://jp.php.net/manual/ja/function.domdocument-html-dump-mem.php

カテゴリ: [PHP]
2006-04 / 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

Color Reference

ChangeLogを検索
携帯電話からアクセス!

カテゴリ

最近の話題

リンク

過去ログ

Google

QR Code

Since
2002-11-28
Update
2008-02-20 21:23
Copyright © 2005 xight.org All Rights Reserved.