<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>alexyz.com</title>
	<atom:link href="http://alexyz.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://alexyz.com</link>
	<description>developer notes:</description>
	<lastBuildDate>Tue, 07 Sep 2010 00:51:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Drupal Notes 7: module custom content type, hook_filter(), custom hook, mail API, sends themed email to all members, creates an action and a trigger</title>
		<link>http://alexyz.com/drupal-notes-7-module-with-custom-content-type-filter-custom-hook-mail-api-sends-themed-email-to-all-members-creates-an-action-and-a-trigger/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=drupal-notes-7-module-with-custom-content-type-filter-custom-hook-mail-api-sends-themed-email-to-all-members-creates-an-action-and-a-trigger</link>
		<comments>http://alexyz.com/drupal-notes-7-module-with-custom-content-type-filter-custom-hook-mail-api-sends-themed-email-to-all-members-creates-an-action-and-a-trigger/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 00:44:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=524</guid>
		<description><![CDATA[a few of the hooks utilized in this module:

<span style="color: #ff00ff;">hook_help()</span>, <span style="color: #ff00ff;">hook_node_info()</span>, <span style="color: #ff00ff;">hook_form()</span>, <span style="color: #ff00ff;">hook_filter()</span>, <span style="color: #ff00ff;">hook_filter_tips()</span><span style="color: #000000;">,</span>
<span style="color: #ff00ff;">hook_action_info()</span>, <span style="color: #ff00ff;">hook_theme()</span>, <span style="color: #ff00ff;">hook_mail()</span>, <span style="color: #ff00ff;">hook_install()</span>

<span style="color: #000000;"><strong>Biggest concept herein:</strong> </span><span style="color: #0000ff;">module_invoke_all()
</span>

<strong>Step 1:</strong> <span style="color: #0000ff;">sitenews.info</span>

<span style="color: #ff0000;">; $Id$</span>
name = "sitenews"
description = "Sends an email news message to all members"
core = 6.x
php = 5.1
; dependencies = "trigger"

<strong>Step 2:</strong> <span style="color: #0000ff;">sitenews.module</span>

<span style="color: #ff0000;">&#60;?php</span>

<span style="color: #ff0000;">// $Id$
/**
* sitenews Module
* Adds  ... <a href="http://alexyz.com/drupal-notes-7-module-with-custom-content-type-filter-custom-hook-mail-api-sends-themed-email-to-all-members-creates-an-action-and-a-trigger/">READ MORE</a>]]></description>
			<content:encoded><![CDATA[<p>a few of the hooks utilized in this module:</p>
<p><span style="color: #ff00ff;">hook_help()</span>, <span style="color: #ff00ff;">hook_node_info()</span>, <span style="color: #ff00ff;">hook_form()</span>, <span style="color: #ff00ff;">hook_filter()</span>, <span style="color: #ff00ff;">hook_filter_tips()</span><span style="color: #000000;">,</span><br />
<span style="color: #ff00ff;">hook_action_info()</span>, <span style="color: #ff00ff;">hook_theme()</span>, <span style="color: #ff00ff;">hook_mail()</span>, <span style="color: #ff00ff;">hook_install()</span></p>
<p><span style="color: #000000;"><strong>Biggest concept herein:</strong> </span><span style="color: #0000ff;">module_invoke_all()<br />
</span></p>
<p><strong>Step 1:</strong> <span style="color: #0000ff;">sitenews.info</span></p>
<p><span style="color: #ff0000;">; $Id$</span><br />
name = &#8220;sitenews&#8221;<br />
description = &#8220;Sends an email news message to all members&#8221;<br />
core = 6.x<br />
php = 5.1<br />
; dependencies = &#8220;trigger&#8221;</p>
<p><strong>Step 2:</strong> <span style="color: #0000ff;">sitenews.module</span></p>
<p><span style="color: #ff0000;">&lt;?php</span></p>
<p><span style="color: #ff0000;">// $Id$<br />
/**<br />
* sitenews Module<br />
* Adds a content type<br />
* Provides an action for admininstrators<br />
* Sends emails to all members<br />
* Defines a new hook and a new filter as well<br />
* @file<br />
*/<br />
/**<br />
* Implementation of hook_help()<br />
*/</span><br />
function sitenews<span style="color: #ff00ff;">_help</span>($path, $arg){<br />
if($path == &#8216;admin/help#sitenews&#8217;){<br />
$txt = &#8216;Keep members current via email.&#8217;<br />
. &#8216;You will need a trigger to the corresponding action.&#8217;<br />
. &#8216;Recommendation: the node publish event should be tied to the action.&#8217;;<br />
$replace = array();<br />
return &#8216;&lt;p&gt;&#8217; . <span style="color: #ff00ff;">t</span>($txt, $replace) . &#8216;&lt;/p&gt;&#8217;;<br />
}<br />
}<br />
<span style="color: #ff00ff;">/**<br />
* Create the sitenewsbrief&#8217; content type<br />
* Implements hook_node_info()<br />
*/</span><br />
function sitenews<span style="color: #ff00ff;">_node_info</span>(){<br />
return array(<br />
&#8216;newsbrief&#8217; =&gt; array(<br />
&#8216;module&#8217; =&gt; &#8216;sitenews&#8217;,<br />
&#8216;name&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;News Brief&#8217;),<br />
&#8216;description&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8220;A newsletter to all members&#8221;),<br />
&#8216;has_title&#8217; =&gt; TRUE,<br />
&#8216;title_label&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Title&#8217;),<br />
&#8216;has_body&#8217; =&gt; TRUE,<br />
&#8216;body_label&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;News Brief&#8217;),<br />
)<br />
);<br />
}<br />
<span style="color: #ff00ff;">/**<br />
* Create the form for editing sitenewsbrief nodes<br />
* Implements hook_form()<br />
*/</span><br />
function sitenews<span style="color: #ff00ff;">_form</span>(&amp;$node){<br />
$type = <span style="color: #ff00ff;">node_get_types</span>(&#8216;type&#8217;, $node);<br />
if($type-&gt;has_title){<br />
$form['title'] = array(<br />
&#8216;#type&#8217; =&gt; &#8216;textfield&#8217;,<br />
&#8216;#title&#8217; =&gt; <span style="color: #ff00ff;">check_plain</span>($type-&gt;title_label),<br />
&#8216;#required&#8217; =&gt; true,<br />
&#8216;#default_value&#8217; =&gt; $node-&gt;title,<br />
&#8216;#weight&#8217; =&gt; -5,<br />
);<br />
}<br />
if($type-&gt;has_body){<br />
$form['body_field'] = <span style="color: #ff00ff;">node_body_field</span>(<br />
$node,<br />
$type-&gt;<span style="color: #ff00ff;">body_label</span>,<br />
$type-&gt;<span style="color: #ff00ff;">min_word_count</span><br />
);<br />
}<br />
<span style="color: #008000;">return</span> $form;<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Implements hook_filter()<br />
*/</span><br />
function sitenews<span style="color: #ff00ff;">_filter</span>($op, $delta = 0, $format = -1, $text = &#8221;){<br />
<span style="color: #008000;">global </span>$user;</p>
<p>if($op == &#8216;list&#8217;){<br />
$list = array(<br />
0 =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Newsletter Brief Placeholders&#8217;),<br />
1 =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Remove ALL HTML/XML Tags&#8217;),<br />
);<br />
<span style="color: #008000;">return</span> $list;<br />
}</p>
<p><span style="color: #008000;">switch</span>($delta){<br />
// Delta 0 is for replacing placeholders<br />
<span style="color: #008000;">case</span> 0:<br />
<span style="color: #008000;">switch</span> ($op)<br />
{<br />
<span style="color: #008000;">case</span> &#8216;description&#8217;:<br />
<span style="color: #008000;">return</span> <span style="color: #ff00ff;">t</span>(&#8216;Replaces <span style="color: #ff00ff;">{{salutation}}</span> with newsletter brief &#8216;<br />
. &#8216;salutation, and <span style="color: #ff00ff;">{{brief name}}</span> with the newsletter brief &#8216;<br />
. &#8216;name.&#8217;);<br />
case &#8216;prepare&#8217;:<br />
<span style="color: #008000;">return</span> $text;<br />
<span style="color: #008000;">case</span> &#8216;process&#8217;:<br />
$text = <span style="color: #0000ff;">str_replace</span>(<br />
&#8216;<span style="color: #ff00ff;">{{salutation}}</span>&#8216;,<br />
<span style="color: #ff00ff;">variable_get</span>(&#8216;sitenews_salutation&#8217;, &#8216;Dear Community Member&#8217;),<br />
$text<br />
);<br />
$text = <span style="color: #0000ff;">str_replace</span>(<br />
&#8216;<span style="color: #ff00ff;">{{brief name}}</span>&#8216;,<br />
<span style="color: #ff00ff;">variable_get</span>(&#8216;sitenews_name&#8217;, &#8216;Site News&#8217;),<br />
$text<br />
);<br />
<span style="color: #008000;">return</span> $text;<br />
<span style="color: #008000;">case</span> &#8216;settings&#8217;:<br />
$form['sitenews_filter'] = array(<br />
&#8216;#type&#8217; =&gt; &#8216;fieldset&#8217;,<br />
&#8216;#title&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Site Newsletter Filters&#8217;),<br />
&#8216;#collapsible&#8217; =&gt; true,<br />
&#8216;#collapsed&#8217; =&gt; false,<br />
);<br />
$form['sitenews_filter']['sitenews_salutation'] = array(<br />
&#8216;#type&#8217; =&gt; &#8216;textfield&#8217;,<br />
&#8216;#description&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;The greeting&#8217;),<br />
&#8216;#title&#8217; =&gt;<span style="color: #ff00ff;"> t</span>(&#8216;Salutation&#8217;),<br />
&#8216;#default_value&#8217; =&gt; <span style="color: #ff00ff;">variable_get</span>(&#8216;sitenews_salutation&#8217;, &#8216;Dear Community Member,&#8217;),<br />
);<br />
$form['sitenews_filter']['sitenews_name'] = array(<br />
&#8216;#type&#8217; =&gt; &#8216;textfield&#8217;,<br />
&#8216;#description&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Title of the site newsletter&#8217;),<br />
&#8216;#title&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Site Newsletter Name&#8217;),<br />
&#8216;#default_value&#8217; =&gt; <span style="color: #ff00ff;">variable_get</span>(&#8216;sitenews_name&#8217;, &#8216;Site Newsletter&#8217;),<br />
);<br />
<span style="color: #008000;">return</span> $form;<br />
}<br />
<span style="color: #008000;">case</span> 1:<br />
<span style="color: #008000;">switch</span>($op)<br />
{<br />
<span style="color: #008000;">case</span> &#8216;description&#8217;:<br />
<span style="color: #008000;">return</span> <span style="color: #ff00ff;">t</span>(&#8216;Removes all tags (HTML or XML elements).&#8217;);<br />
<span style="color: #008000;">case</span> &#8216;prepare&#8217;:<br />
<span style="color: #008000;">return</span> $text;<br />
<span style="color: #008000;">case</span> &#8216;process&#8217;:<br />
<span style="color: #008000;">return</span> <span style="color: #0000ff;">strip_tags</span>($text);<br />
} <span style="color: #ff0000;">// end switch for $op</span><br />
} <span style="color: #ff0000;">// end outer switch</span><br />
}<br />
<span style="color: #ff0000;">/**<br />
* Formatting instruction tips for content creators<br />
* Implements hook_format_info()<br />
*/</span><br />
function sitenews<span style="color: #ff00ff;">_filter_tips</span>($delta, $format, $long){<br />
<span style="color: #008000;">switch</span>($delta){<br />
<span style="color: #008000;">case</span> 0:<br />
$text = &#8220;Instances of <span style="color: #ff00ff;">{{brief name}}</span> will be &#8221;<br />
. &#8220;replaced by the global name for site newsletter.&#8221;<br />
. &#8221; <span style="color: #ff00ff;">{{salutation}}</span> will be replaced with the global &#8221;<br />
. &#8220;greeting message.&#8221;;<br />
if($long){<br />
$text .= &#8220;Site Newsletter name and salutation text &#8221;<br />
. &#8220;can be configured from the administration interface.&#8221;;<br />
}<br />
<span style="color: #008000;">return</span> $text;<br />
<span style="color: #008000;">case</span> 1:<br />
$text = &#8220;HTML and XML tags will be removed from the final output&#8221;;<br />
return $text;<br />
}<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Get a format ID by name<br />
* This returns an Input Format ID that can be passed to check_marckup() to filter content<br />
* If a matching format isn&#8217;t found, the default format is returned<br />
* @param $name<br />
* String name of the format<br />
* @return<br />
* The ID (an integer) of the format<br />
*/</span><br />
function sitenews<span style="color: #ff00ff;">_get_format</span>($name){<br />
$res = <span style="color: #ff00ff;">db_query</span>(<br />
&#8220;<span style="color: #008000;">SELECT format FROM {filter_formats} WHERE name = &#8216;%s&#8217;</span>&#8220;,<br />
$name<br />
);<br />
$format = <span style="color: #ff00ff;">db_fetch_object</span>($res);<br />
if($format){<br />
<span style="color: #008000;">return</span> $format-&gt;format;<br />
} else {<br />
<span style="color: #008000;">return</span> <span style="color: #ff00ff;">FILTER_FORMAT_DEFAULT</span>;<br />
}<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Implements hook_action_info()<br />
*/</span><br />
function sitenews<span style="color: #ff00ff;">_action_info</span>(){<br />
<span style="color: #ff00ff;">watchdog</span>(&#8216;<span style="color: #ff00ff;">action</span>&#8216;,&#8221;Called sitenews_action_info&#8221;);<br />
$actions['sitenews_send_action'] = array(<br />
&#8216;type&#8217; =&gt; &#8216;node&#8217;,<br />
&#8216;description&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Send site news as email to all users.&#8217;),<br />
&#8216;configurable&#8217; =&gt; FALSE,<br />
&#8216;hooks&#8217; =&gt; array(<br />
&#8216;nodeapi&#8217; =&gt; array(&#8216;insert&#8217;,'update&#8217;,'presave&#8217;),<br />
)<br />
);<br />
return $actions;<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Action: Send an email message to all users<br />
*/</span><br />
function sitenews<span style="color: #ff00ff;">_send_action</span>(&amp;$object, $context){<br />
// If not a published sitenews, skip<br />
if(!$object-&gt;status || $object-&gt;type != &#8216;newsbrief&#8217;){<br />
<span style="color: #008000;">return</span>;<br />
}<br />
<span style="color: #ff0000;">// Get addresses</span><br />
$q = &#8220;<span style="color: #008000;">SELECT mail, status FROM {users} &#8221;<br />
. &#8220;WHERE status != 0 AND uid &gt; 0</span>&#8220;;<br />
$results = <span style="color: #ff00ff;">db_query</span>($q);<br />
$addresses = array();<br />
while($obj = <span style="color: #ff00ff;">db_fetch_object</span>($results)){<br />
$addresses[] = $obj-&gt;mail;<br />
}<br />
if(count($addresses) == 0){<br />
<span style="color: #ff00ff;">watchdog</span>(<br />
&#8216;sitenews&#8217;,<br />
&#8216;No user email addresses were found&#8217;,<br />
array(),<br />
<span style="color: #ff00ff;">WATCHDOG_ERROR</span><br />
);<br />
<span style="color: #008000;">return</span>;<br />
}<br />
<span style="color: #ff0000;">// Execute hook_sitenews()</span><br />
<strong><span style="color: #ff00ff;">$content = module_invoke_all(&#8216;sitenews&#8217;);</span></strong><br />
<span style="color: #ff0000;">// Build params</span><br />
$params = array(<br />
&#8216;node&#8217; =&gt; $object,<br />
&#8216;to&#8217; =&gt; implode(&#8216;, &#8216;, $addresses),<br />
&#8216;subject&#8217; =&gt; $object-&gt;title,<br />
&#8216;context&#8217; =&gt; $context,<br />
&#8216;additional content&#8217; =&gt; $content,<br />
);<br />
$message = <span style="color: #ff00ff;">_sitenews_do_message</span>($object, $params);<br />
<span style="color: #ff00ff;">watchdog</span>(<br />
&#8216;<span style="color: #ff00ff;">actions</span>&#8216;,<br />
&#8216;Site News &#8220;Send action fired. Sending to !mail&#8217;,<br />
array(&#8216;!mail&#8217; =&gt; $params['to'])<br />
);<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Internal function to prepare a message and pass it on to the mailer<br />
* @param $node<br />
* The news brief node<br />
* @param $params<br />
* An array of params<br />
*/</span><br />
function <span style="color: #ff00ff;">_sitenews_do_message</span>(&amp;$node, $params){<br />
$node = $params['node'];<br />
$content = $params['additional content'];<br />
<span style="color: #ff0000;">// Theme the main node:</span><br />
$params['body'] = <span style="color: #ff00ff;">theme</span>(&#8216;sitenews_newsbrief&#8217;, $node);<br />
<span style="color: #ff0000;">// See common.inc (element_sort() and drupal_render()</span><br />
<span style="color: #0000ff;">uasort</span>($content, &#8216;element_sort&#8217;);<br />
<span style="color: #ff0000;">// Render each block of content;</span><br />
foreach($content as $item){<br />
$params['body'] .=<span style="color: #ff00ff;"> theme</span>(&#8216;sitenews_msgblock&#8217;, $item);<br />
}<br />
<span style="color: #ff0000;">// Send the mail:</span><br />
<span style="color: #ff00ff;">drupal_mail</span>(<br />
&#8216;sitenews&#8217;,<br />
&#8216;sendsitenews&#8217;,<br />
$params['to'],<br />
language_default(),<br />
$params,<br />
<span style="color: #ff00ff;">variable_get</span>(&#8216;site_mail&#8217;,NULL),<br />
TRUE<br />
);<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Implements hook_theme()<br />
*/</span><br />
function sitenews<span style="color: #ff00ff;">_theme</span>(){<br />
<span style="color: #008000;">return</span> array(<br />
&#8216;sitenews_msgblock&#8217; =&gt; array(<br />
&#8216;arguments&#8217; =&gt; array(&#8216;block&#8217; =&gt; NULL),<br />
),<br />
&#8216;sitenews_newsbrief&#8217; =&gt; array(<br />
&#8216;arguments&#8217; =&gt; array(&#8216;node&#8217; =&gt; NULL),<br />
),<br />
);<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Theme to display a news brief in a sitenews message block<br />
* @param $node<br />
* The news brief node object<br />
*/</span><br />
function <span style="color: #ff00ff;">theme_sitenews_newsbrief</span>($node){<br />
$format = <span style="color: #ff00ff;">sitenews_get_format</span>(&#8216;Tagless text&#8217;);<br />
$text = <span style="color: #0000ff;">strtoupper</span>(check_markup($node-&gt;title, $format)) . &#8220;\n\n&#8221;;<br />
$text .= <span style="color: #ff00ff;">check_markup</span>($node-&gt;body, $format) . &#8220;\n\n&#8221;;<br />
return $text;<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Theme for email messages<br />
* @param $block<br />
* A block with #title and #body set<br />
*/</span><br />
function <span style="color: #ff00ff;">theme_sitenews_msgblock</span>($block){<br />
$msg = array();<br />
if(!empty($block['#title'])){<br />
$title = <span style="color: #0000ff;">strtoupper</span>($block['#title']);<br />
for ($i = 0; $i &lt; strlen($title); ++$i){<br />
$underline .= &#8216;=&#8217;;<br />
}<br />
$msg[] = $title;<br />
$msg[] = $underline;<br />
}<br />
$msg[] = $block['#body'] .&#8221;\n&#8221;; // &lt;&#8211; extra newline<br />
return<span style="color: #0000ff;"> implode</span>(&#8220;\n&#8221;, $msg);<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Implementation of hook_mail()<br />
*/</span><br />
function sitenews<span style="color: #ff00ff;">_mail</span>($key, &amp;$message, $params){<br />
<span style="color: #008000;">switch</span>($key){<br />
<span style="color: #008000;">case</span> &#8216;sendsitenews&#8217;:<br />
$message['to'] = $params['to'];<br />
$message['subject'] = $params['subject'];<br />
$message['body'] = $params['body'];<br />
}<br />
}</p>
<p><strong>Step 3:</strong> <span style="color: #0000ff;">sitenews.install</span></p>
<p><span style="color: #ff0000;">&lt;?php</span></p>
<p>// $Id$<br />
/**<br />
* Install the newsletter module<br />
* @file<br />
*/<br />
/**<br />
* Implements hook_intall()<br />
*/<br />
function sitenews<span style="color: #ff00ff;">_install</span>(){<br />
$name = &#8216;Tagless text&#8217;;<br />
<span style="color: #ff0000;">// Check to see if the format already exists</span><br />
$res = <span style="color: #ff00ff;">db_query</span>(<br />
&#8220;<span style="color: #008000;">SELECT name FROM {filter_formats} WHERE name = &#8216;%s&#8217;</span>&#8220;,<br />
$name<br />
);<br />
$has_format = <span style="color: #ff00ff;">db_result</span>($res);<br />
<span style="color: #ff0000;">// Create format</span><br />
if (!$has_format){<br />
<span style="color: #ff00ff;">db_query</span>(<br />
&#8220;<span style="color: #008000;">INSERT INTO {filter_formats} (name) VALUES (&#8216;%s&#8217;)</span>&#8220;,<br />
$name<br />
);<br />
}<br />
$res = <span style="color: #ff00ff;">db_query</span>(<br />
&#8220;<span style="color: #008000;">SELECT format FROM {filter_formats} WHERE name = &#8216;%s&#8217;</span>&#8220;,<br />
$name<br />
);<br />
$format = <span style="color: #ff00ff;">db_fetch_object</span>($res);<br />
$q = &#8220;<span style="color: #008000;">INSERT INTO {filters} (format, module, delta, weight) &#8221;<br />
. &#8220;VALUES(%d, &#8216;newsletter&#8217;, %d, %d)</span>&#8220;;<br />
<span style="color: #ff0000;">// First, insert the &#8220;Newsletter Brief Placeholders&#8221; filter:</span><br />
<span style="color: #ff00ff;">db_query</span>($q, $format-&gt;format, 0, 10);<br />
<span style="color: #ff0000;">// Second, insert the &#8220;Remove ALL HTML/XML Tags&#8221; filter:</span><br />
<span style="color: #ff00ff;">db_query</span>($q, $format-&gt;format, 1, 0);<br />
}</p>
<p><strong>Step 4: </strong>add to <span style="color: #0000ff;">module_sitenews()</span> to any modules that will be contributing content to these automatically generated email newsletters, example from <span style="color: #0000ff;">personality module</span> (Drupal Notes 6) follows:</p>
<p>function <span style="color: #ff00ff;">personality_theme()</span>{<br />
return array(<br />
&#8216;personality_info&#8217; =&gt; array(<br />
&#8216;template&#8217; =&gt; &#8216;personality_info&#8217;,<br />
&#8216;arguments&#8217; =&gt; array(<br />
&#8216;dates&#8217; =&gt; NULL,<br />
&#8216;life&#8217; =&gt; NULL,<br />
&#8216;works&#8217; =&gt; NULL,<br />
),<br />
),<br />
<span style="color: #ff0000;">// NEW</span><br />
&#8216;personality_sitenews&#8217; =&gt; array(<br />
&#8216;arguments&#8217; =&gt; array(&#8216;node&#8217; =&gt; NULL),<br />
),<br />
);<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Theme function for sitenews<br />
*/</span><br />
function <span style="color: #ff00ff;">theme_personality_sitenews</span>($node){<br />
$options = array(&#8216;absolute&#8217; =&gt; TRUE);<br />
$url = <span style="color: #ff00ff;">url</span>(&#8216;node/&#8217;. $node-&gt;nid, $options);<br />
$title = <span style="color: #0000ff;">strip_tags</span>($node-&gt;title);<br />
$body = <span style="color: #0000ff;">strip_tags</span>($node-&gt;teaser); // &lt;&#8211; Summary<br />
$text = <span style="color: #0000ff;">implode</span>(&#8220;\n&#8221;, array($title, $body, $url));<br />
$text .= &#8220;\n&#8221;;<br />
<span style="color: #008000;">return</span> $text;<br />
}</p>
<p><span style="color: #ff0000;">/*<br />
* Implements hook_sitenews() in sitenews module<br />
*/</span><br />
function <span style="color: #ff00ff;">personality_sitenews</span>(){<br />
$q = &#8220;<span style="color: #008000;">SELECT nid, created FROM {node} &#8221;<br />
. &#8220;WHERE status = 1 AND type = &#8216;personality&#8217; &#8221;<br />
. &#8220;ORDER BY created DESC</span>&#8220;;<br />
$results = <span style="color: #ff00ff;">db_query_range</span>($q, 0, 3);<br />
$new_bios = array();<br />
while ($row = <span style="color: #ff00ff;">db_fetch_object</span>($results)){<br />
$node = <span style="color: #ff00ff;">node_load</span>($row-&gt;nid);<br />
$new_bios[] =<span style="color: #ff00ff;"> theme</span>(&#8216;personality_sitenews&#8217;, $node);<br />
}<br />
$content['personality'] = array(<br />
&#8216;#weight&#8217; =&gt; 0,<br />
&#8216;#title&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Recent Biographies&#8217;),<br />
&#8216;#body&#8217; =&gt; <span style="color: #0000ff;">implode</span>(&#8220;\n&#8221;, $new_bios),<br />
);<br />
<span style="color: #008000;">return</span> $content;<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/drupal-notes-7-module-with-custom-content-type-filter-custom-hook-mail-api-sends-themed-email-to-all-members-creates-an-action-and-a-trigger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drupal Notes 6: module + new content type (non CCK)</title>
		<link>http://alexyz.com/drupal-notes-6-module-new-content-type-non-cck/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=drupal-notes-6-module-new-content-type-non-cck</link>
		<comments>http://alexyz.com/drupal-notes-6-module-new-content-type-non-cck/#comments</comments>
		<pubDate>Sun, 05 Sep 2010 21:19:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Drupal]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=512</guid>
		<description><![CDATA[<strong><span style="color: #0000ff;">Description:</span></strong> Module that uses a new content type (non CCK), that uses the <strong>Schema API</strong>, <strong>Node API</strong>, <strong>Database API</strong>, <strong>Forms API</strong> and the following hooks:

<span style="color: #ff00ff;">hook_form()</span>, <span style="color: #ff00ff;">hook_install()</span>, <span style="color: #ff00ff;">hook_uninstall()</span>, <span style="color: #ff00ff;">hook_schema()</span>, <span style="color: #ff00ff;">hook_node_info()</span>, <span style="color: #ff00ff;">hook_perm()</span>, <span style="color: #ff00ff;">hook_access()</span>, <span style="color: #ff00ff;">hook_insert()</span>, <span style="color: #ff00ff;">hook_update()</span>, <span style="color: #ff00ff;">hook_delete()</span>, <span style="color: #ff00ff;">hook_nodeapi()</span>, <span style="color: #ff00ff;">hook_load()</span>, <span style="color: #ff00ff;">hook_view()</span>, <span style="color: #ff00ff;">hook_theme()</span>

<strong>Step 1: <span style="color: #0000ff;">sites/all/modules/personality</span></strong> folder

<strong>Step 2: <span style="color: #0000ff;">personality.info</span></strong>

<span style="color: #ff0000;">; $Id$</span>
name  ... <a href="http://alexyz.com/drupal-notes-6-module-new-content-type-non-cck/">READ MORE</a>]]></description>
			<content:encoded><![CDATA[<p><strong><span style="color: #0000ff;">Description:</span></strong> Module that uses a new content type (non CCK), that uses the <strong>Schema API</strong>, <strong>Node API</strong>, <strong>Database API</strong>, <strong>Forms API</strong> and the following hooks:</p>
<p><span style="color: #ff00ff;">hook_form()</span>, <span style="color: #ff00ff;">hook_install()</span>, <span style="color: #ff00ff;">hook_uninstall()</span>, <span style="color: #ff00ff;">hook_schema()</span>, <span style="color: #ff00ff;">hook_node_info()</span>, <span style="color: #ff00ff;">hook_perm()</span>, <span style="color: #ff00ff;">hook_access()</span>, <span style="color: #ff00ff;">hook_insert()</span>, <span style="color: #ff00ff;">hook_update()</span>, <span style="color: #ff00ff;">hook_delete()</span>, <span style="color: #ff00ff;">hook_nodeapi()</span>, <span style="color: #ff00ff;">hook_load()</span>, <span style="color: #ff00ff;">hook_view()</span>, <span style="color: #ff00ff;">hook_theme()</span></p>
<p><strong>Step 1: <span style="color: #0000ff;">sites/all/modules/personality</span></strong> folder</p>
<p><strong>Step 2: <span style="color: #0000ff;">personality.info</span></strong></p>
<p><span style="color: #ff0000;">; $Id$</span><br />
name = &#8220;Personality Content (Node) Type&#8221;<br />
description = &#8220;This provides a custom content type to store simple online personalities&#8221;<br />
core = 6.x<br />
php = 5.1</p>
<p><strong>Step 3: <span style="color: #0000ff;">personality.install</span></strong></p>
<p><span style="color: #ff0000;">&lt;?php</span></p>
<p><span style="color: #ff0000;">// $Id$<br />
/**<br />
* Install the personality module, including its content (node) type.<br />
* @file<br />
*/</span><br />
<span style="color: #ff0000;">/**<br />
* Implementation of hook_install()<br />
*/</span><br />
<span style="color: #0000ff;">function</span> personality<span style="color: #ff00ff;">_install</span>(){<br />
<span style="color: #ff00ff;">drupal_install_schema</span>(&#8216;personality&#8217;);<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Implementation of hook_uninstall()<br />
*/</span><br />
<span style="color: #0000ff;">function</span> personality<span style="color: #ff00ff;">_uninstall</span>(){<br />
<span style="color: #ff00ff;">drupal_uninstall_schema</span>(&#8216;personality&#8217;);<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Implementation of hook_schema()<br />
*/</span><br />
<span style="color: #0000ff;">function</span> personality<span style="color: #ff00ff;">_schema</span>(){<br />
$schema['personality'] = array(<br />
&#8216;fields&#8217; =&gt; array(<br />
&#8216;vid&#8217; =&gt; array(<br />
&#8216;type&#8217; =&gt; &#8216;int&#8217;,<br />
&#8216;unsigned&#8217; =&gt; TRUE,<br />
&#8216;not null&#8217; =&gt; TRUE,<br />
&#8216;default&#8217; =&gt; 0,<br />
),<br />
&#8216;nid&#8217; =&gt; array(<br />
&#8216;type&#8217; =&gt; &#8216;int&#8217;,<br />
&#8216;unsigned&#8217; =&gt; TRUE,<br />
&#8216;not null&#8217; =&gt; TRUE,<br />
&#8216;default&#8217; =&gt;0,<br />
),<br />
&#8216;dates&#8217; =&gt; array(<br />
&#8216;type&#8217; =&gt; &#8216;varchar&#8217;,<br />
&#8216;length&#8217; =&gt; 127,<br />
&#8216;not null&#8217; =&gt; TRUE,<br />
&#8216;default&#8217; =&gt; &#8221;,<br />
),<br />
<span style="color: #ff0000;">// Note: On MySQL, text fields cannot have default values</span><br />
&#8216;life&#8217; =&gt; array(<br />
&#8216;type&#8217; =&gt; &#8216;text&#8217;,<br />
&#8216;not null&#8217; =&gt; FALSE<br />
),<br />
&#8216;works&#8217; =&gt; array(<br />
&#8216;type&#8217; =&gt; &#8216;text&#8217;,<br />
&#8216;not null&#8217; =&gt; FALSE<br />
),<br />
),<br />
&#8216;indexes&#8217; =&gt; array(<br />
&#8216;nid&#8217; =&gt; array(&#8216;nid&#8217;),<br />
),<br />
<span style="color: #ff0000;">// Version is primary key.  Could do nid, vid.</span><br />
&#8216;primary key&#8217; =&gt; array(&#8216;vid&#8217;),<br />
);<br />
<span style="color: #008000;">return</span> $schema;<br />
}</p>
<p><strong>Step 4: <span style="color: #0000ff;">personality.module</span></strong></p>
<p><span style="color: #ff0000;">&lt;?php</span></p>
<p>// $Id$<br />
/**<br />
* Provides the Personality content type<br />
* @file<br />
*/<br />
/**<br />
* Implementation of hook_help()<br />
*/<br />
<span style="color: #0000ff;">function</span> personality<span style="color: #ff00ff;">_help</span>($path, $arg){<br />
if($path == &#8216;admin/help#personality&#8217;){<br />
$txt = &#8216;A personality is a description of a person\&#8217;s person.  Should include a brief summary, biography, date of birth, optionally date of death, and accomplishments.&#8217;;<br />
$replace = array();<br />
<span style="color: #008000;">return</span> &#8216;&lt;p&gt;&#8217; . <span style="color: #ff00ff;">t</span>($text, $replace) . &#8216;&lt;/p&gt;&#8217;;<br />
}<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Imnplementation of hook_node_info()<br />
*/</span><br />
<span style="color: #0000ff;">function</span> personality_node<span style="color: #ff00ff;">_info</span>(){<br />
<span style="color: #008000;">return</span> array(<br />
&#8216;personality&#8217; =&gt; array(<br />
&#8216;name&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Personality&#8217;),<br />
&#8216;module&#8217; =&gt; &#8216;personality&#8217;,<br />
&#8216;description&#8217; =&gt;<span style="color: #ff00ff;"> t</span>(&#8216;A personality of a person.&#8217;),<br />
&#8216;has_title&#8217; =&gt; TRUE,<br />
&#8216;title_label&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Personality of&#8217;),<br />
&#8216;has_body&#8217; =&gt; TRUE,<br />
&#8216;body_label&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Overview&#8217;),<br />
)<br />
);<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Implementation of hook_form()<br />
*/</span><br />
<span style="color: #0000ff;">function</span> personality<span style="color: #ff00ff;">_form</span>(&amp;$node){<br />
$type = node_get_types(&#8216;type&#8217;, $node);<br />
<span style="color: #ff0000;">//Existing files: title (Personality of) and body (Overview)</span><br />
if($type-&gt;has_title){<br />
$form['title'] = array(<br />
&#8216;#type&#8217; =&gt; &#8216;textfield&#8217;,<br />
&#8216;#title&#8217; =&gt; <span style="color: #ff00ff;">check_plain</span>($type-&gt;title_label),<br />
&#8216;#required&#8217; =&gt; TRUE,<br />
&#8216;#default_value&#8217; =&gt; $node-&gt;title,<br />
&#8216;#weight&#8217; =&gt; -5,<br />
);<br />
}<br />
if($type-&gt;has_body){<br />
$form['body_field'] = <span style="color: #ff00ff;">node_body_field</span>(<br />
$node,<br />
$type-&gt;body_label,<br />
$type-&gt;min_word_count<br />
);<br />
}<br />
<span style="color: #ff0000;">// Our custom fields: Dates, Life, Works</span><br />
$form['dates'] = array(<br />
&#8216;#type&#8217; =&gt; &#8216;textfield&#8217;,<br />
&#8216;#size&#8217; =&gt; 50,<br />
&#8216;#maxlength&#8217; =&gt; 127,<br />
&#8216;#title&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Dates&#8217;),<br />
&#8216;#description&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Birth and death dates.&#8217;),<br />
&#8216;#default_value&#8217; =&gt; isset($node-&gt;dates) ? $node-&gt;dates : &#8221;,<br />
);<br />
$form['life'] = array(<br />
&#8216;#type&#8217; =&gt; &#8216;textarea&#8217;,<br />
&#8216;#title&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Life&#8217;),<br />
&#8216;#cols&#8217; =&gt; 50,<br />
&#8216;#rows&#8217; =&gt; 15,<br />
&#8216;#description&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;A description of this perons\&#8217;s life.&#8217;),<br />
&#8216;#default_value&#8217; =&gt; isset($node-&gt;life) ? $node-life : &#8221;,<br />
);<br />
$form['works'] = array(<br />
&#8216;#type&#8217; =&gt; &#8216;textarea&#8217;,<br />
&#8216;#title&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Works&#8217;),<br />
&#8216;#cols&#8217; =&gt; 50,<br />
&#8216;#rows&#8217; =&gt; 5,<br />
&#8216;#description&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;This person\&#8217;s Personality&#8217;),<br />
&#8216;#default_value&#8217; =&gt; isset($node-&gt;works) ? $node-&gt;works : &#8221;,<br />
);<br />
<span style="color: #008000;">return</span> $form;<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Implements hook_perm()<br />
* Responsible for registering new permissions<br />
*/</span><br />
<span style="color: #0000ff;">function</span> personality<span style="color: #ff00ff;">_perm</span>(){<br />
<span style="color: #008000;">return</span> array(<br />
&#8216;create personality node&#8217;,<br />
&#8216;edit personality nodes&#8217;,<br />
&#8216;delete personality nodes&#8217;,<br />
);<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Implementation of hook_access()<br />
* which implements our new permissions<br />
*/</span><br />
<span style="color: #0000ff;">function</span> personality<span style="color: #ff00ff;">_access</span>($op, $node, $account){<br />
switch($op){<br />
case &#8216;create&#8217;:<br />
<span style="color: #008000;">return</span> <span style="color: #ff00ff;">user_access</span>(&#8216;create personality node&#8217;, $account);<br />
case &#8216;update&#8217;:<br />
<span style="color: #008000;">return</span> <span style="color: #ff00ff;">user_access</span>(&#8216;edit personality nodes&#8217;, $account);<br />
case &#8216;delete&#8217;:<br />
<span style="color: #008000;">return</span> <span style="color: #ff00ff;">user_access</span>(&#8216;delete personality nodes&#8217;, $account);<br />
}<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Implements hook_insert()<br />
*/</span><br />
<span style="color: #0000ff;">function</span> personality<span style="color: #ff00ff;">_insert</span>($node){<br />
if(!isset($node-&gt;life)){<br />
$node-&gt;life = &#8221;;<br />
}<br />
if(!isset($node-&gt;works)){<br />
$node-&gt;works = &#8221;;<br />
}<br />
<span style="color: #ff00ff;">db_query</span>(<br />
&#8220;<span style="color: #008080;">INSERT INTO {personality} (vid, nid, dates, life, works) VALUES (%d, %d, &#8216;%s&#8217;, &#8216;%s&#8217;, &#8216;%s&#8217;)</span>&#8220;,<br />
$node-&gt;vid,<br />
$node-&gt;nid,<br />
$node-&gt;dates,<br />
$node-&gt;life,<br />
$node-&gt;works<br />
);<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Implements hook_update()<br />
*/</span><br />
<span style="color: #0000ff;">function</span> personality<span style="color: #ff00ff;">_update</span>($node){<br />
if($node-&gt;revision){<br />
personality_insert($node);<br />
}<br />
else{<br />
<span style="color: #ff00ff;">db_query</span>(<br />
&#8220;<span style="color: #008080;">UPDATE {personality} SET dates = &#8216;&amp;s&#8217;, life = &#8216;%s&#8217;, works = &#8216;%s&#8217; WHERE vid = %d</span>&#8220;,<br />
$node-&gt;dates,<br />
$node-&gt;life,<br />
$node-&gt;works,<br />
$node-&gt;vid<br />
);<br />
}<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Implements hook_delete()<br />
*/</span><br />
<span style="color: #0000ff;">function</span> personality<span style="color: #ff00ff;">_delete</span>($node){<br />
<span style="color: #ff00ff;">db_query</span>(<br />
&#8220;<span style="color: #008080;">DELETE FROM {personality} WHERE nid = %d</span>&#8220;,<br />
$node-&gt;nid<br />
);<br />
}<br />
<span style="color: #ff0000;">/**<br />
* This implementation deletes node revisions<br />
* Implements hook_nodeapi()<br />
*/</span><br />
<span style="color: #0000ff;">function</span> personality<span style="color: #ff00ff;">_nodeapi</span>(&amp;$node, $op, $teaser, $page){<br />
if($op == &#8216;delete revision&#8217;){<br />
<span style="color: #ff00ff;">db_query</span>(<br />
&#8216;<span style="color: #008080;">DELETE FROM {personality} WHERE vid = %d</span>&#8216;,<br />
$node-&gt;vid<br />
);<br />
}<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Implementation of hook_load()<br />
*/</span><br />
<span style="color: #0000ff;">function</span> personality<span style="color: #ff00ff;">_load</span>($node){<br />
$result = <span style="color: #ff00ff;">db_query</span>(<br />
&#8216;<span style="color: #008080;">SELECT dates, life, works FROM {personality} WHERE vid = %d</span>&#8216;,<br />
$node-&gt;vid<br />
);<br />
<span style="color: #008000;">return</span> <span style="color: #ff00ff;">db_fetch_object</span>($result);<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Implementation of hook_view()<br />
*/</span><br />
<span style="color: #0000ff;">function</span> personality<span style="color: #ff00ff;">_view</span>($node, $teaser = FALSE, $page = FALSE){<br />
$node = <span style="color: #ff00ff;">node_prepare</span>($node, $teaser);<br />
$dates = <span style="color: #ff00ff;">check_plain</span>($node-&gt;dates);<br />
$life = <span style="color: #ff00ff;">check_markup</span>($node-&gt;life);<br />
$works = <span style="color: #ff00ff;">check_markup</span>($node-&gt;works);<br />
<span style="color: #ff0000;">// Add theme</span><br />
$node-&gt;content['personality_info'] = array(<br />
&#8216;#value&#8217; =&gt; <span style="color: #ff00ff;">theme</span>(&#8216;personality_info&#8217;, $dates, $life, $works),<br />
&#8216;#weight&#8217; =&gt; 1,<br />
);<br />
<span style="color: #008000;">return</span> $node;<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Implements hook_theme()<br />
*/</span><br />
<span style="color: #0000ff;">function</span> personality<span style="color: #ff00ff;">_theme</span>(){<br />
<span style="color: #008000;">return</span> array(<br />
&#8216;personality_info&#8217; =&gt; array(<br />
&#8216;template&#8217; =&gt; &#8216;personality_info&#8217;,<br />
&#8216;arguments&#8217; =&gt; array(<br />
&#8216;dates&#8217; =&gt; NULL,<br />
&#8216;life&#8217; =&gt; NULL,<br />
&#8216;works&#8217; =&gt; NULL,<br />
),<br />
),<br />
);<br />
}</p>
<p><strong>Step 5: <span style="color: #0000ff;">personality_info.tpl.php</span></strong> template theme file</p>
<p><span style="color: #ff0000;">&lt;?php</span></p>
<p>// $Id$<br />
/**<br />
* Template to display personality nodes.<br />
*<br />
* Fields available:<br />
* $dates: cleaned plain text string<br />
* $life: cleaned HTML string<br />
* $works: cleaned HTML string<br />
*/<br />
?&gt;<br />
&lt;div&gt;<br />
&lt;h2&gt;<span style="color: #ff0000;">&lt;?php</span> print <span style="color: #ff00ff;">t</span>(&#8216;Dates&#8217;); <span style="color: #ff0000;">?&gt;</span>:&lt;/h2&gt;<br />
<span style="color: #ff0000;">&lt;?php</span> print $dates; <span style="color: #ff0000;">?&gt;</span><br />
&lt;h2&gt;<span style="color: #ff0000;">&lt;?php</span> print <span style="color: #ff00ff;">t</span>(&#8216;Life&#8217;);<span style="color: #ff0000;"> ?&gt;</span>:&lt;/h2&gt;<br />
<span style="color: #ff0000;">&lt;?php</span> print $life; <span style="color: #ff0000;">?&gt;</span><br />
&lt;h2&gt;<span style="color: #ff0000;">&lt;?php</span> print<span style="color: #ff00ff;"> t</span>(&#8216;Works&#8217;);<span style="color: #ff0000;"> ?&gt;</span>:&lt;/h2&gt;<br />
<span style="color: #ff0000;">&lt;?php</span> print $works; <span style="color: #ff0000;">?&gt;</span><br />
&lt;/div&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/drupal-notes-6-module-new-content-type-non-cck/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drupal Notes 5: admin module emails users from profile: hook_mail(), hook_mail_alter(), hook_help(), hook_menu(), Forms API, hook_user()</title>
		<link>http://alexyz.com/drupal-notes-5-admin-module-emails-users-from-profile-hook_mail-hook_mail_alter-hook_help-hook_menu-forms-api-hook_user/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=drupal-notes-5-admin-module-emails-users-from-profile-hook_mail-hook_mail_alter-hook_help-hook_menu-forms-api-hook_user</link>
		<comments>http://alexyz.com/drupal-notes-5-admin-module-emails-users-from-profile-hook_mail-hook_mail_alter-hook_help-hook_menu-forms-api-hook_user/#comments</comments>
		<pubDate>Sun, 05 Sep 2010 00:30:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Drupal]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=505</guid>
		<description><![CDATA[For this module it's best that your development environment is configured to send live emails.
If it's local, xampp perhaps, and not currently configured as such,
you may want to refer to this post first:
<a href="http://alexyz.com/sending-mail-xampp-gmail/">http://alexyz.com/sending-mail-xampp-gmail/</a>

<strong>Step 1</strong>, of course, create a <strong>new folder entitled <span style="color: #0000ff;">emailusers</span></strong> in <strong>sites/all/modules</strong>

<strong>Step 2</strong>, in that folder, <strong>create <span style="color: #0000ff;">emailusers.info</span></strong>, containing the following
<em>(if you've read Notes 1-4 this should all be very familiar already)</em>:

<span style="color: #ff0000;">;$Id$</span>
name = "emailusers"
description = "admin module for emailing users from  ... <a href="http://alexyz.com/drupal-notes-5-admin-module-emails-users-from-profile-hook_mail-hook_mail_alter-hook_help-hook_menu-forms-api-hook_user/">READ MORE</a>]]></description>
			<content:encoded><![CDATA[<p>For this module it&#8217;s best that your development environment is configured to send live emails.<br />
If it&#8217;s local, xampp perhaps, and not currently configured as such,<br />
you may want to refer to this post first:<br />
<a href="http://alexyz.com/sending-mail-xampp-gmail/">http://alexyz.com/sending-mail-xampp-gmail/</a></p>
<p><strong>Step 1</strong>, of course, create a <strong>new folder entitled <span style="color: #0000ff;">emailusers</span></strong> in <strong>sites/all/modules</strong></p>
<p><strong>Step 2</strong>, in that folder, <strong>create <span style="color: #0000ff;">emailusers.info</span></strong>, containing the following<br />
<em>(if you&#8217;ve read Notes 1-4 this should all be very familiar already)</em>:</p>
<p><span style="color: #ff0000;">;$Id$</span><br />
name = &#8220;emailusers&#8221;<br />
description = &#8220;admin module for emailing users from within their profile&#8221;<br />
core = 6.x<br />
php = 5.1</p>
<p><strong>Step 3</strong>, <strong>create <span style="color: #0000ff;">emailusers.module</span></strong> in same folder, contents thereof follow:</p>
<p><span style="color: #ff0000;">&lt;?php</span></p>
<p><span style="color: #ff0000;">// $Id$<br />
/**<br />
* This module provides an email interface for administrators.<br />
* Using this module, administrators can send email to a user from the<br />
* user&#8217;s &#8220;view&#8221; page.<br />
* @file<br />
*/<br />
<span style="color: #ff0000;">/**</span></span><span style="color: #ff0000;"><br />
* Implementation hook_help()<br />
*/</span><br />
function emailusers<span style="color: #ff00ff;">_help</span>($path, $arg){<br />
if($path == &#8216;admin/help#emailusers&#8217;){<br />
$txt = &#8216;This module provides a way for an administrator to send&#8217;<br />
. &#8216;email to a user. &#8216;<br />
. &#8216;It assumes that the Drupal mailer is configured.&#8217;;<br />
return &#8216;&lt;p&gt;&#8217; . t($txt) . &#8216;&lt;/p&gt;&#8217;;<br />
}<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Implementation of hook_munu()<br />
*/</span><br />
function emailusers<span style="color: #ff00ff;">_menu</span>(){<br />
<span style="color: #ff0000;">// Need to pass User ID via placeholder %,<br />
// thus URL will be available here: ?q=admin/emailusers/compose/userIdHere</span><br />
$items['admin/emailusers/compose/<span style="color: #ff00ff;">%</span>'] = array(<br />
&#8216;title&#8217; =&gt; &#8216;Compose a Message&#8217;,<br />
&#8216;page callback&#8217; =&gt; &#8216;emailusers_compose&#8217;,<br />
&#8216;page arguments&#8217; =&gt; <span style="color: #ff00ff;">array(3)</span>, <span style="color: #ff0000;">// &lt;- userId (from % in node path)</span><br />
&#8216;access arguments&#8217; =&gt; array(&#8216;administer users&#8217;),<br />
&#8216;type&#8217; =&gt; <span style="color: #ff00ff;">MENU_CALLBACK</span>,<br />
);<br />
return $items;<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Compose a message.<br />
* This creates the form necessary to compose an email message.<br />
*<br />
* @param $to<br />
* The address to send to.<br />
* @return<br />
* HTML.<br />
*/</span><br />
function emailusers<span style="color: #ff00ff;">_compose</span>($userid){<br />
$userid =<span style="color: #ff00ff;"> intval</span>($userid);<br />
if($userid == 0){<br />
return <span style="color: #ff00ff;">t</span>(&#8216;User ID must be an integer.&#8217;);<br />
}<br />
$account = <span style="color: #ff00ff;">user_load</span>($userid);<br />
if(<span style="color: #008000;">empty</span>($account)){<br />
return <span style="color: #ff00ff;">t</span>(&#8216;No such user found.&#8217;);<br />
}<br />
$to = $account-&gt;mail;<br />
$sb = &#8216;&lt;p&gt;&#8217;<br />
. <span style="color: #ff00ff;">t</span>(&#8216;Send a message to @email.&#8217;, array(&#8216;@email&#8217; =&gt; $to))<br />
. &#8216;&lt;/p&gt;&#8217;;<br />
$sb .= <span style="color: #ff00ff;">drupal_get_form</span>(&#8216;emailusers_compose_form&#8217;, <span style="color: #ff00ff;">$account</span>);<br />
<span style="color: #ff0000;">// <span style="color: #008000;">Forms API / FAPI</span><br />
// <span style="color: #008000;">http://drupal.org/node/751826</span><br />
// <span style="color: #008000;">http://api.drupal.org/api/drupal/developer&#8211;topics&#8211;forms_api_reference.html/6</span></span><br />
return $sb;<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Form constructor<br />
*/</span><br />
function emailusers_compose<span style="color: #ff00ff;">_form</span>($context, <span style="color: #ff00ff;">$account</span>){<br />
<span style="color: #ff0000;">// This is a value only &#8212; equivalent to a hidden field<br />
// except that it is never renered into the HTML</span><br />
<span style="color: #ff0000;"><span style="color: #ff00ff;">$form['to']</span> </span>= array(<br />
&#8216;#type&#8217; =&gt; &#8216;value&#8217;,<br />
&#8216;#value&#8217; =&gt; $account,<br />
);<br />
<span style="color: #ff0000;">// Create a fieldset for the body:</span><br />
$form['message'] = array(<br />
&#8216;#type&#8217; =&gt; &#8216;fieldset&#8217;,<br />
&#8216;#title&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Compose the Message&#8217;),<br />
);<br />
<span style="color: #ff0000;">// Textfield for subject of the body</span><br />
$form['message']['subject'] = array(<br />
&#8216;#type&#8217; =&gt; &#8216;textfield&#8217;,<br />
&#8216;#title&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Subject&#8217;),<br />
&#8216;#size&#8217; =&gt; 50,<br />
&#8216;#maxlength&#8217; =&gt; 255,<br />
&#8216;#description&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;The subject of the email message.&#8217;),<br />
);<br />
<span style="color: #ff0000;">// And a text area for the body.</span><br />
$form['message']['body'] = array(<br />
&#8216;#type&#8217; =&gt; &#8216;textarea&#8217;,<br />
&#8216;#title&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Message&#8217;),<br />
&#8216;#cols&#8217; =&gt; 50,<br />
&#8216;#rows&#8217; =&gt; 5,<br />
&#8216;#description&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;The body of the email message.&#8217;),<br />
);<br />
<span style="color: #ff0000;">// Create a fieldset for details</span><br />
$form['details'] = array(<br />
&#8216;#type&#8217; =&gt; &#8216;fieldset&#8217;,<br />
&#8216;#title&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8220;Details&#8221;),<br />
);<br />
<span style="color: #ff0000;">// Checkbox: if checked, CC the author too</span><br />
$form['details']['cc_me'] = array(<br />
&#8216;#type&#8217; =&gt; &#8216;checkbox&#8217;,<br />
&#8216;#title&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;BCC Yourself&#8217;),<br />
&#8216;#default_value&#8217; =&gt; 1,<br />
&#8216;#description&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;If this is checked, the message will also be sent to you.&#8217;),<br />
);<br />
<span style="color: #ff0000;">// Finally, a submit button:</span><br />
$form['submit'] = array(<br />
&#8216;#type&#8217; =&gt; &#8216;submit&#8217;,<br />
&#8216;#value&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Send Mail&#8217;),<br />
);<br />
return $form;<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Form submission handler, which functions like a hook.<br />
* Note that the params $form and &amp;$form_state are new in D6.<br />
* They replace $form_id and $form_values.<br />
*/</span><br />
function emailusers_compose_form<span style="color: #ff00ff;">_submit</span>($form, &amp;$form_state){<br />
$form_values = $form_state['values'];<br />
$account = $form_values['to'];<br />
<span style="color: #ff00ff;">drupal_mail</span>(<br />
&#8216;emailusers&#8217;,<br />
&#8216;composemessage&#8217;,<br />
$account-&gt;mail,<br />
<span style="color: #ff00ff;">user_preferred_language</span>($account),<br />
$form_values,<br />
<span style="color: #ff00ff;">variable_get</span>(&#8216;site_mail&#8217;, null),<br />
true<span style="color: #ff0000;"> // Automatically send</span><br />
);<br />
<span style="color: #ff0000;">// drupal_mail will invoke hook_mail(), or in this case, emailusers_mail(), below</span><br />
$form_state['redirect'] = <span style="color: #008000;">sprintf</span>(&#8216;user/%d&#8217;, $account-&gt;uid);<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Implementation of hook_mail()<br />
*/</span><br />
function emailusers<span style="color: #ff00ff;">_mail</span>($key, &amp;$message, $params){<br />
<span style="color: #ff0000;">// Just catch calls to this hook from compose form.</span><br />
if ($key == &#8216;composemessage&#8217;){<br />
$language = $params['language'];<br />
$account = $params['to'];<br />
if($params['cc_me']){<br />
<span style="color: #ff0000;">// Look up current user&#8217;s email address:<br />
//$my_account = user_load(null);</span><br />
$message['headers']['bcc'] = <span style="color: #ff00ff;">$GLOBALS['user']-&gt;mail</span>;<br />
}<br />
$message['to'] = $account-&gt;mail;<br />
$message['subject'] = <span style="color: #ff00ff;">t</span>(&#8216;Drupal Message: &#8216;, array(), $language-&gt;language);<br />
<span style="color: #ff0000;">// If these were automatically-generated messages<br />
// they should be run through t()<br />
// but since text is user-entered<br />
// don&#8217;t use t()</span><br />
$message['subject'] .= $params['subject'];<br />
<span style="color: #ff0000;">//$message['body'] = $params['body'];</span><br />
$message['body'][] = $params['body'];<br />
}<br />
}<br />
<span style="color: #ff0000;">/**<br />
* Implements hook_mail_alter()<br />
* !! Note: similar, and also of interest are hook_link_alter() &amp; hook_menu_alter()<br />
* simply put, _alter hooks alter data right after their parent hooks are called, but before output<br />
* also important to note: this _alter() below will augment ALL emails sent to the Mail API<br />
* not just those from this module!<br />
*/</span><br />
function emailusers_mail<span style="color: #ff00ff;">_alter</span>(&amp;$message){<br />
$append = &#8220;\n==================================\n&#8221;<br />
. &#8220;This message was sent from !site_name (!website). &#8221;<br />
. &#8220;If you believe this message to be a case of abuse, &#8221;<br />
. &#8220;please contact !site_email.\n&#8221;;<br />
$args = array(<br />
&#8216;!website&#8217; =&gt; <span style="color: #ff00ff;">url</span>(&#8221;, array(&#8216;absolute&#8217; =&gt; true)),<br />
&#8216;!site_email&#8217; =&gt; variable_get(&#8216;site_mail&#8217;, null),<br />
&#8216;!site_name&#8217; =&gt; variable_get(&#8216;site_name&#8217;, &#8216;Unknown&#8217;),<br />
);<br />
<span style="color: #000000;">$message['body'] .= t($append, $args);</span><br />
<span style="color: #ff0000;">//$message['body'][] = t($append, $args);</span><br />
}<br />
<span style="color: #ff0000;">/**<br />
* Implementation of hook_user().<br />
*/</span><br />
function emailusers<span style="color: #ff00ff;">_user</span>($op, &amp;$edit, &amp;$account, $category){<br />
if($op == &#8216;view&#8217; &amp;&amp; <span style="color: #ff00ff;">user_access</span>(&#8216;<span style="color: #ff00ff;">administer users</span>&#8216;)){<br />
<span style="color: #ff0000;">// Create the outer &#8220;block&#8221;</span><br />
$account-&gt;content['EmailUsers'] = array(<br />
&#8216;#type&#8217; =&gt; &#8216;<span style="color: #ff00ff;">user_profile_category</span>&#8216;,<br />
&#8216;#attributes&#8217; =&gt; array(&#8216;class&#8217; =&gt; &#8216;user-member&#8217;),<br />
&#8216;#weight&#8217; =&gt; 0,<br />
&#8216;#title&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Contact user&#8217;),<br />
);<br />
<span style="color: #ff0000;">// Create the content of the block</span><br />
$account-&gt;content['EmailUsers']['EmailLink'] = array(<br />
&#8216;#type&#8217; =&gt; &#8216;<span style="color: #ff00ff;">user_profile_item</span>&#8216;,<br />
&#8216;#title&#8217; =&gt; <span style="color: #ff00ff;">t</span>(&#8216;Send a message to this user from the site administrator.&#8217;),<br />
&#8216;#value&#8217; =&gt; <span style="color: #ff00ff;">l</span>(<br />
&#8216;Email&#8217;,<br />
&#8216;admin/emailusers/compose/&#8217; . $account-&gt;uid<br />
),<br />
);<br />
}<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/drupal-notes-5-admin-module-emails-users-from-profile-hook_mail-hook_mail_alter-hook_help-hook_menu-forms-api-hook_user/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drupal Notes 4: enhance our module with jQuery AJAX/JSON</title>
		<link>http://alexyz.com/drupal-notes-4-enhance-our-module-with-jquery-ajaxjson/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=drupal-notes-4-enhance-our-module-with-jquery-ajaxjson</link>
		<comments>http://alexyz.com/drupal-notes-4-enhance-our-module-with-jquery-ajaxjson/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 20:16:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=494</guid>
		<description><![CDATA[<strong>create <span style="color: #008000;">quoteDisplay.js</span></strong> to contain:

var quoteDisplay = {}; <span style="color: #ff0000;">// JS Namespace Object Creation</span>
if(<span style="color: #ff00ff;">Drupal.jsEnabled</span>){
<span style="color: #0000ff;">$</span>(document).ready(
<span style="color: #008000;">function</span>(){
<span style="color: #0000ff;">$</span>("#quoteDisplay-origin")<span style="color: #0000ff;">.after</span>("&#60;a&#62;Next &#38;raquo;&#60;/a&#62;")<span style="color: #0000ff;">.next().click</span>(quoteDisplay.randQuote);
}
);
<span style="color: #ff0000;">/**
* A function to fetch quotes from the server,
* and display in the designated area.
*/</span>
quoteDisplay.randQuote =<span style="color: #008000;"> function</span>(){
<span style="color: #0000ff;">$.get</span>(<span style="color: #ff00ff;">Drupal.settings.quoteDisplay.json_url</span>, <span style="color: #008000;">function</span>(data){
myQuote = <span style="color: #ff00ff;">Drupal.parseJson(data)</span>;
if(!myQuote.status &#124;&#124; myQuotes.status == 0){
<span style="color: #0000ff;">$</span>("#quoteDisplay-origin")<span style="color: #0000ff;">.text</span>(myQuote.quote.origin);
<span style="color: #0000ff;">$</span>("#quoteDisplay-text")<span style="color: #0000ff;">.text</span>(myQuote.quote.text);
}
}); <span style="color: #ff0000;">// End inline function</span>
}
}

<strong>add this line</strong>  ... <a href="http://alexyz.com/drupal-notes-4-enhance-our-module-with-jquery-ajaxjson/">READ MORE</a>]]></description>
			<content:encoded><![CDATA[<p><strong>create <span style="color: #008000;">quoteDisplay.js</span></strong> to contain:</p>
<p>var quoteDisplay = {}; <span style="color: #ff0000;">// JS Namespace Object Creation</span><br />
if(<span style="color: #ff00ff;">Drupal.jsEnabled</span>){<br />
<span style="color: #0000ff;">$</span>(document).ready(<br />
<span style="color: #008000;">function</span>(){<br />
<span style="color: #0000ff;">$</span>(&#8220;#quoteDisplay-origin&#8221;)<span style="color: #0000ff;">.after</span>(&#8220;&lt;a&gt;Next &amp;raquo;&lt;/a&gt;&#8221;)<span style="color: #0000ff;">.next().click</span>(quoteDisplay.randQuote);<br />
}<br />
);<br />
<span style="color: #ff0000;">/**<br />
* A function to fetch quotes from the server,<br />
* and display in the designated area.<br />
*/</span><br />
quoteDisplay.randQuote =<span style="color: #008000;"> function</span>(){<br />
<span style="color: #0000ff;">$.get</span>(<span style="color: #ff00ff;">Drupal.settings.quoteDisplay.json_url</span>, <span style="color: #008000;">function</span>(data){<br />
myQuote = <span style="color: #ff00ff;">Drupal.parseJson(data)</span>;<br />
if(!myQuote.status || myQuotes.status == 0){<br />
<span style="color: #0000ff;">$</span>(&#8220;#quoteDisplay-origin&#8221;)<span style="color: #0000ff;">.text</span>(myQuote.quote.origin);<br />
<span style="color: #0000ff;">$</span>(&#8220;#quoteDisplay-text&#8221;)<span style="color: #0000ff;">.text</span>(myQuote.quote.text);<br />
}<br />
}); <span style="color: #ff0000;">// End inline function</span><br />
}<br />
}</p>
<p><strong>add this line</strong> to <strong><span style="color: #008000;">quoteDisplay.module</span> </strong>file&#8217;s<strong> theme_quoteDisplay()</strong> function (after &#8220;drupal_add_js&#8221; line, before &#8220;$output = &#8216;</p>
<p><span style="color: #ff00ff;">drupal_add_js</span>($module_path . &#8216;/quoteDisplay.js&#8217;);<br />
$opts = array(&#8216;absolute&#8217; =&gt; TRUE);<br />
$json_url = <span style="color: #ff00ff;">url</span>(&#8216;quoteDisplay.json&#8217;, $opts);<br />
<span style="color: #ff00ff;">drupal_add_js</span>(<br />
array(&#8216;quoteDisplay&#8217; =&gt;<br />
array(&#8220;json_url&#8221; =&gt; $json_url)), &#8216;<span style="color: #ff00ff;">setting</span>&#8216;);</p>
<p><strong>also add these function</strong>s to our <span style="color: #008000;"><strong>quoteDisplay.module</strong></span> file:</p>
<p><span style="color: #ff0000;">/*<br />
* Callback to handle requests for </span>quoteDisplay<span style="color: #ff0000;"> content.<br />
* @return<br />
* JSON data.<br />
*/</span><br />
<span style="color: #008000;">function</span> quoteDisplay_item(){<br />
$item = _quoteDisplay_get_quote();<br />
<span style="color: #ff00ff;">drupal_set_header</span>(&#8216;Content-Type: text/plain; charset: utf-8&#8242;);<br />
printf(<br />
&#8216;<span style="color: #ff0000;">{ &#8220;quote&#8221;: { &#8220;origin&#8221;: &#8220;%s&#8221;, &#8220;text&#8221;: &#8220;%s&#8221; } }</span>&#8216;,<br />
$item-&gt;title,<br />
$item-&gt;body<br />
);<br />
}</p>
<p><span style="color: #ff0000;">/**<br />
* Implementation of hook_menu()<br />
* registers quoteDisplay.json<br />
* will call quoteDisplay_item() when called<br />
* anyone that may access content may access this path<br />
* MENU_CALLBACK below is a bitmask,<br />
* that doesn&#8217;t authomatically create links to this item in the menu or elsewhere,<br />
* it simnply makes this accessible by URL,<br />
* more than 20 such bitmask types may be used,<br />
* see documentation.<br />
*/</span><br />
<span style="color: #000000;"><span style="color: #008000;">function</span> quoteDisplay_menu(){</span><br />
$items['quoteDisplay.json'] = array(<br />
&#8216;title&#8217; =&gt; &#8216;Quote Display AJAX Gateway&#8217;,<br />
&#8216;page callback&#8217; =&gt; &#8216;quoteDisplay_item&#8217;,<br />
&#8216;access arguments&#8217; =&gt; array(&#8216;access content&#8217;),<br />
&#8216;type&#8217; =&gt; <span style="color: #ff0000;">MENU_CALLBACK</span>,<br />
);<br />
<span style="color: #008000;">return</span> $items;<br />
}</p>
<p><span style="color: #008000;">now hit the url to see your JSON return! (you may need to clear your drupal cache of course)<br />
<strong>http://localhost/yourDrupalSiteName/?q=quoteDisplay.json</strong></span></p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/drupal-notes-4-enhance-our-module-with-jquery-ajaxjson/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drupal Notes 3: a themed module for a new content type</title>
		<link>http://alexyz.com/drupal-notes-3-a-themed-module-for-a-new-content-type/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=drupal-notes-3-a-themed-module-for-a-new-content-type</link>
		<comments>http://alexyz.com/drupal-notes-3-a-themed-module-for-a-new-content-type/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 07:11:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Drupal]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=491</guid>
		<description><![CDATA[<strong>create</strong> a new <span style="color: #008000;">content type</span>, create some entries
<strong>create</strong> a new theme (see earlier notes for how)

<strong>quoteDisplay.info</strong> contains the following:

<span style="color: #008000;"><span style="color: #ff0000;">; $Id$</span>
name = "Quote Display"
description = "Dynamic display of  quotes."
core = 6.x
php = 5.1</span>

<strong>quoteDisplay.module</strong> contains this:

<span style="color: #ff0000;">&#60;?php

// $Id$
/**
* @file
* Module for dynamic display of pithy philosophy quotes.
*/</span>

<span style="color: #ff0000;">/**
* Implementation of hook_help()
*/</span>
function quoteDisplay_help($path, $arg)
{
if ($path == 'admin/help#quoteDisplay')
{
$txt = 'This module displays philosophical quotes in blocks. ' .
'It assumes the existence of a content type named  ... <a href="http://alexyz.com/drupal-notes-3-a-themed-module-for-a-new-content-type/">READ MORE</a>]]></description>
			<content:encoded><![CDATA[<p><strong>create</strong> a new <span style="color: #008000;">content type</span>, create some entries<br />
<strong>create</strong> a new theme (see earlier notes for how)</p>
<p><strong>quoteDisplay.info</strong> contains the following:</p>
<p><span style="color: #008000;"><span style="color: #ff0000;">; $Id$</span><br />
name = &#8220;Quote Display&#8221;<br />
description = &#8220;Dynamic display of  quotes.&#8221;<br />
core = 6.x<br />
php = 5.1</span></p>
<p><strong>quoteDisplay.module</strong> contains this:</p>
<p><span style="color: #ff0000;">&lt;?php</p>
<p>// $Id$<br />
/**<br />
* @file<br />
* Module for dynamic display of pithy philosophy quotes.<br />
*/</span></p>
<p><span style="color: #ff0000;">/**<br />
* Implementation of hook_help()<br />
*/</span><br />
function quoteDisplay_help($path, $arg)<br />
{<br />
if ($path == &#8216;admin/help#quoteDisplay&#8217;)<br />
{<br />
$txt = &#8216;This module displays philosophical quotes in blocks. &#8216; .<br />
&#8216;It assumes the existence of a content type named &#8220;quote&#8221;.&#8217;;<br />
return &#8216;&lt;p&gt;&#8217; . t($txt) . &#8216;&lt;/p&gt;&#8217;;<br />
}<br />
}</p>
<p><span style="color: #ff0000;">/**<br />
* Implementation of hook_block()<br />
*/</span><br />
function quoteDisplay_block($op = &#8216;list&#8217;, $delta = 0, $edit = array())<br />
{<br />
switch($op)<br />
{<br />
case &#8216;list&#8217;:<br />
$blocks[0]['info'] = t(&#8216;Philosophical Quotes&#8217;);<br />
return $blocks;<br />
case &#8216;view&#8217;:<br />
$item = _quoteDisplay_get_quote();<br />
if(!empty($item))<br />
{<br />
$content = theme(&#8216;quoteDisplay_quote&#8217;,<br />
check_plain($item-&gt;body),<br />
check_plain($item-&gt;title));<br />
$blocks['subject'] = t(&#8216;Pithy Quote&#8217;);<br />
$blocks['content'] = $content;<br />
return $blocks;<br />
}<br />
}<br />
}</p>
<p><span style="color: #ff0000;">/*<br />
* Return a quote from the Drupal database<br />
*/</span><br />
function _quoteDisplay_get_quote()<br />
{<br />
<span style="color: #ff00ff;">$sql = &#8220;SELECT nid FROM {node} &#8220;.<br />
&#8220;WHERE status = 1 AND type = &#8216;quote&#8217; ORDER BY RAND() LIMIT 1&#8243;;<br />
$res = db_query($sql);<br />
$item = db_fetch_object($res);<br />
$quote = node_load($item-&gt;nid);<br />
return $quote;</span><br />
}<br />
<span style="color: #ff0000;"><br />
/*<br />
* Implementation of hook_theme().<br />
*/</span><br />
function quoteDisplay_theme()<br />
{<br />
return array(<br />
&#8216;quoteDisplay_quote&#8217; =&gt; array(<br />
&#8216;arguments&#8217; =&gt; array(<br />
&#8216;text&#8217; =&gt; NULL,<br />
&#8216;origin&#8217; =&gt; NULL<br />
),<br />
),<br />
);<br />
}</p>
<p><span style="color: #ff0000;">/*<br />
* Theme function for theming quotes.<br />
*<br />
* @param $text<br />
* The quote content as a string.<br />
* @param $origin<br />
* The original source of the quote, as a string.<br />
* @return<br />
* An HTML themed string.<br />
*/</span><br />
function theme_quoteDisplay_quote($text, $origin)<br />
{<br />
$module_path = <span style="color: #ff00ff;">drupal_get_path(&#8216;module&#8217;,&#8217;</span>quoteDisplay<span style="color: #ff00ff;">&#8216;)</span>;<br />
$full_path = $module_path . &#8216;/quoteDisplay.css&#8217;;<br />
<span style="color: #ff00ff;">drupal_add_css($full_path);</span><br />
$output = &#8216;&lt;div id=&#8221;quoteDisplay-text&#8221;&gt;&#8217; . t($text) . &#8216;&lt;/div&gt;&lt;div id=&#8221;quoteDisplay-origin&#8221;&gt;&#8217; . t($origin) . &#8216;&lt;/div&gt;&#8217;;<br />
return $output;<br />
}</p>
<p><strong>quoteDisplay</strong><strong>.css</strong> (also in /sites/all/modules/quoteDisplay) contains:</p>
<p>#quoteDisplay-text:first-letter{<br />
font-size:18pt;<br />
font-weight:bold;<br />
}<br />
#quoteDisplay-origin{<br />
font-style: oblique;<br />
text-align: right;<br />
margin-right: 5px;<br />
}</p>
<p>Note:</p>
<p>This module thus has a default &#8220;theme&#8221; of its own.  This may be overridden via CSS, or via a quoteDisplay.tpl.php file placed within the themes/module/currentTheme folder</p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/drupal-notes-3-a-themed-module-for-a-new-content-type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drupal Notes 2: sub-theme derivative of bluemarine : Theme inheritance, overriding, preprocessing</title>
		<link>http://alexyz.com/drupal-notes-2-sub-theme-derivative-of-bluemarine-minor-css-changes-only-theme-inheritance-overriding/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=drupal-notes-2-sub-theme-derivative-of-bluemarine-minor-css-changes-only-theme-inheritance-overriding</link>
		<comments>http://alexyz.com/drupal-notes-2-sub-theme-derivative-of-bluemarine-minor-css-changes-only-theme-inheritance-overriding/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 01:22:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Drupal]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=482</guid>
		<description><![CDATA[<strong>add folder to:</strong>
sites/all/themes(createThis)/subThemeName(createThis)/

<strong>create <span style="color: #ff0000;">subThemeName.info</span> (in newly created folder):</strong>
<span style="color: #ff0000;">; $Id$</span>
name = subThemeName
description = blah blah blah blah blah
version = 1.0
core = 6.x
base theme = <strong>bluemarine</strong>
stylesheets[all][] = descartes-style.css <span style="color: #ff0000;">// copy images from parent theme into sub-theme.</span>
stylesheets[all][] = new.css

<strong>finally, create above mentioned <span style="color: #ff0000;">new.css</span> (</strong><strong>in newly created folder) </strong><strong>and add styles you'd like to modify, example:</strong>
<span style="color: #ff0000;">/*
** Style to override the styles.css in
** bluemarine.css
*/</span>

<span style="color: #ff0000;">/*
* Plain white right nav.
*/</span>
#sidebar-right{
border-left: 1px solid #ea940c;
background-color: white;
}

<strong>ready to  ... <a href="http://alexyz.com/drupal-notes-2-sub-theme-derivative-of-bluemarine-minor-css-changes-only-theme-inheritance-overriding/">READ MORE</a>]]></description>
			<content:encoded><![CDATA[<p><strong>add folder to:</strong><br />
sites/all/themes(createThis)/subThemeName(createThis)/</p>
<p><strong>create <span style="color: #ff0000;">subThemeName.info</span> (in newly created folder):</strong><br />
<span style="color: #ff0000;">; $Id$</span><br />
name = subThemeName<br />
description = blah blah blah blah blah<br />
version = 1.0<br />
core = 6.x<br />
base theme = <strong>bluemarine</strong><br />
stylesheets[all][] = descartes-style.css <span style="color: #ff0000;">// copy images from parent theme into sub-theme.</span><br />
stylesheets[all][] = new.css</p>
<p><strong>finally, create above mentioned <span style="color: #ff0000;">new.css</span> (</strong><strong>in newly created folder) </strong><strong>and add styles you&#8217;d like to modify, example:</strong><br />
<span style="color: #ff0000;">/*<br />
** Style to override the styles.css in<br />
** bluemarine.css<br />
*/</span></p>
<p><span style="color: #ff0000;">/*<br />
* Plain white right nav.<br />
*/</span><br />
#sidebar-right{<br />
border-left: 1px solid #ea940c;<br />
background-color: white;<br />
}</p>
<p><strong>ready to go further? copy any of the following over from bluemarine into yourNewSubTheme and edit away:</strong><br />
<span style="color: #008000;">page.tpl.php</span> (<span style="color: #ff0000;">hint: start here</span>), <span style="color: #008000;">block.tpl.php</span>, <span style="color: #008000;">box.tpl.php</span>, <span style="color: #008000;">comment.tpl.php</span></p>
<p><strong>even further, you&#8217;ve moved $breadcrumb in <span style="color: #008000;">page.tpl.php</span> to where you&#8217;d like it, but you want to edit INSIDE that&#8230;</strong><br />
these <span style="color: #008000;">PHPTemplate functions</span> that render content can be found in <span style="color: #008000;">yourSite/includes/theme.inc</span><br />
find the one that spits out the content you&#8217;d like to modify, and then create a template.php in your new theme directory and override that function&#8230;<br />
example: <span style="color: #008000;">theme_breadcrumb()</span> uses<span style="color: #ffcc00;"> <strong><span style="color: #000000;">&#8220;&gt;&gt;&#8221;</span></strong></span><strong><span style="color: #000000;"> </span></strong>as separators, in<br />
<span style="color: #008000;">yourSite/sites/all/themes/yourNewTheme/template.php</span> (make it)<br />
overwrite <span style="color: #008000;">theme_breadcrumb()</span> via something like this:</p>
<p><span style="color: #ff0000;">&lt;?php<br />
// $Id$<br />
/**<br />
* @page<br />
* Override theme_() functions for the youNewTheme.<br />
*/</span></p>
<p><span style="color: #ff0000;">// Overrides theme_breadcrumb()</span><br />
function<span style="color: #008000;"> phptemplate_</span>breadcrumb($breadcrumb){<br />
if (empty($breadcrumb)) return;<br />
$sep = &#8216;&lt;div&gt;<span style="color: #000000;"><strong>&amp;nbsp;&amp;nbsp;</strong></span>&lt;/div&gt;&#8217;;<br />
$breadcrumb_string = &#8216;&lt;div&gt;&#8217; . implode($sep, $breadcrumb) . &#8216;&lt;/div&gt;&#8217;;<br />
return $breadcrumb_string;<br />
} <span style="color: #ff0000;">// end of template.php example</span></p>
<p>other <span style="color: #008000;">PHPTemplate theme functions</span> from <span style="color: #008000;">includes/theme.inc</span> to investigate:<br />
<span style="color: #008000;">theme_image()</span>, <span style="color: #008000;">theme_links()</span>,<span style="color: #008000;"> theme_progress_bar()</span>, <span style="color: #008000;">theme_username()</span>,<span style="color: #008000;"> theme_table()<span style="color: #000000;">,</span> theme_item_list()<br />
</span><br />
<strong>called as follows:</strong><br />
$variable = theme(&#8216;functionName&#8217;, $arg1, $arg2, &#8230;) , <strong>which looks like this:</strong><br />
$crumb = theme(&#8216;item_list&#8217;, $breadcrumb, null, &#8216;ul&#8217;, array(&#8216;class&#8217;=&gt;&#8217;breadcrumb-items&#8217;));</p>
<p><span style="color: #ff0000;">IMPORTANT NOTES/REMEMBER</span>:<br />
- a <span style="color: #ff0000;">phptemplate_block()</span> function redefined in <span style="color: #ff0000;">template.php</span> will <strong>override</strong> a <span style="color: #ff0000;">block.tpl.php </span>file in template folder!<br />
- if you want to preprocess CONTENT before it&#8217;s passed to template.php, thus, instead use <span style="color: #ff0000;">phptemplate_preprocess_functions()</span>!<br />
- if you&#8217;re <strong>NOT </strong>making a sub-theme, add to .info this line: <span style="color: #ff0000;">engine=phptemplate</span> instead of using the base theme line<br />
- don&#8217;t forget to make a nice <span style="color: #ff0000;">screenshot.png</span> (150&#215;90)</p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/drupal-notes-2-sub-theme-derivative-of-bluemarine-minor-css-changes-only-theme-inheritance-overriding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drupal Notes 1: module hook_block(), hook_help(), check_plain(), check_url(), watchdog(), t(), l(), placeholders(!,%,@)</title>
		<link>http://alexyz.com/drupal-notes-1-module-hook_block-hook_help-check_plain-check_url-watchdog-t-l-placeholders/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=drupal-notes-1-module-hook_block-hook_help-check_plain-check_url-watchdog-t-l-placeholders</link>
		<comments>http://alexyz.com/drupal-notes-1-module-hook_block-hook_help-check_plain-check_url-watchdog-t-l-placeholders/#comments</comments>
		<pubDate>Sun, 29 Aug 2010 21:12:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=473</guid>
		<description><![CDATA[<strong>Create:</strong>
<span style="color: #008000;">moduleName.info</span> &#38; <span style="color: #008000;">moduleName.info</span>, save them in sites, all, modules

<strong>.info example content:</strong>
<span style="color: #ff0000;">;$Id$</span> <span style="color: #ff00ff;">// This will be substituted by Drupal CVS</span>
name = "ModuleNameHere"
description = "Displays items blah blah blah"
core = 6.x
php = 5.1

<strong>.module beginnings...:</strong>
<span style="color: #ff0000;">// $Id$ </span> <span style="color: #ff00ff;">// This will be substituted by Drupal CVS</span>
<span style="color: #ff0000;">/**
* @file</span> <span style="color: #ff00ff;">// This denotes that this comment refers to this whole file</span>
<span style="color: #ff0000;">* Description Here Of</span> <span style="color: #ff0000;">Module...</span>
<span style="color: #ff0000;">*  ... <a href="http://alexyz.com/drupal-notes-1-module-hook_block-hook_help-check_plain-check_url-watchdog-t-l-placeholders/">READ MORE</a>]]></description>
			<content:encoded><![CDATA[<p><strong>Create:</strong><br />
<span style="color: #008000;">moduleName.info</span> &amp; <span style="color: #008000;">moduleName.info</span>, save them in sites, all, modules</p>
<p><strong>.info example content:</strong><br />
<span style="color: #ff0000;">;$Id$</span> <span style="color: #ff00ff;">// This will be substituted by Drupal CVS</span><br />
name = &#8220;ModuleNameHere&#8221;<br />
description = &#8220;Displays items blah blah blah&#8221;<br />
core = 6.x<br />
php = 5.1</p>
<p><strong>.module beginnings&#8230;:</strong><br />
<span style="color: #ff0000;">// $Id$ </span> <span style="color: #ff00ff;">// This will be substituted by Drupal CVS</span><br />
<span style="color: #ff0000;">/**<br />
* @file</span> <span style="color: #ff00ff;">// This denotes that this comment refers to this whole file</span><br />
<span style="color: #ff0000;">* Description Here Of</span> <span style="color: #ff0000;">Module&#8230;</span><br />
<span style="color: #ff0000;">* @see http://www.goodreads.com</span><span style="color: #ff00ff;"> // Drupal doc is generated by doxygen, this links to a ref</span><br />
<span style="color: #ff0000;">*/</span></p>
<p><span style="color: #ff0000;">/**<br />
* Implementation of hook_block()<br />
*/</span><br />
<span style="color: #008000;">function</span> moduleName<span style="color: #ff00ff;">_block</span>(<span style="color: #008000;">$op=&#8217;list&#8217;, $delta=0, $edit=array()</span>){<br />
switch($op){<br />
case &#8216;list&#8217;:<br />
<span style="color: #ff00ff;">$blocks[0]['info'] </span>= <span style="color: #ff00ff;">t(</span>&#8216;Module Info Title&#8217;<span style="color: #ff00ff;">)</span>;<br />
return $blocks;<br />
case &#8216;view&#8217;:<br />
$url = &#8216;http://www.moduleXML.com/review/list_rss/&#8217;;<br />
<span style="color: #ff00ff;">$blocks['subject']</span> = <span style="color: #ff00ff;">t(</span>&#8216;Module Subject&#8217;<span style="color: #ff00ff;">)</span>;<br />
<span style="color: #ff00ff;">$blocks['content'] </span>= &#8220;Module Content Dynamic or Static&#8230;&#8221;;<br />
return $blocks;<br />
}<br />
}</p>
<p><span style="color: #ff0000;">/**<br />
* Implementation of hook_help()<br />
*/</span><br />
<span style="color: #008000;">function</span> moduleName<span style="color: #ff00ff;">_help</span>($path, $arg){<br />
if($path == &#8216;admin/help#moduleName){<br />
$txt = &#8216;The moduleName module uses the <span style="color: #008000;">!subThisHolder_url</span> API &#8216;;<br />
$link = <span style="color: #ff00ff;">l(</span>&#8216;copyForTheAnchorTag&#8217;, &#8216;http://www.moduleName.com&#8217;<span style="color: #ff00ff;">)</span>;<br />
<span style="color: #ff00ff;">$replace = array(</span>&#8216;<span style="color: #008000;">!subThisHolder_url</span>&#8216; =&gt; $link<span style="color: #ff00ff;">)</span>;<br />
return &#8216;&lt;p&gt;&#8217; . <span style="color: #ff00ff;">t(</span>$txt, $replace<span style="color: #ff00ff;">) </span>. &#8216;&lt;/p&gt;&#8217;;<br />
}<br />
}<span style="color: #ff00ff;"> //end of example .module code&#8230;</span></p>
<p><strong>Other things useful of note:</strong></p>
<p><span style="color: #ff00ff;"><span style="color: #000000;">The watchdog() function:</span></span> <a href="http://api.drupal.org/api/function/watchdog/6">http://api.drupal.org/api/function/watchdog/6</a><br />
<span style="color: #ff00ff;">watchdog(</span>&#8216;loggingCategoryNameThisModuleNameMostLikely&#8217;, $msg, $varsToSubIntoMsg, WATCHDOG_WARNING<span style="color: #ff00ff;">)</span>:<br />
logging options:<br />
WATCHDOG_EMERG<br />
WATCHDOG_ALERT<br />
WATCHDOG_CRITICAL<br />
WATCHDOG_ERROR<br />
WATCHDOG_WARNING<br />
WATCHDOG_NOTICE<br />
WATCHDOG_INFO<br />
WATCHDOG_DEBUG</p>
<p><strong>check_plain()</strong> &#8211; <a href="http://api.drupal.org/api/function/check_plain/6">http://api.drupal.org/api/function/check_plain/6</a></p>
<p><strong>check_url() </strong>- <a href="http://api.drupal.org/api/function/check_url/6">http://api.drupal.org/api/function/check_url/6</a></p>
<p><strong>t()</strong> example:</p>
<p><span style="color: #ff00ff;">t(</span>&#8216;Replacing %value by !urlHere for @emailPerhaps &#8216;, array(&#8216;%value&#8217;=&gt;&#8217;test&#8217;, &#8216;@emailPerhaps&#8217;=&gt;$email, &#8216;!urlHere&#8217;=&gt;&#8217;http://blah.com&#8217;<span style="color: #ff00ff;">)</span><span style="color: #ff00ff;">;</span></p>
<p><span style="color: #ff00ff;">!placeholders</span> replaced as is, <span style="color: #ff00ff;">@placeholders</span> replaced effectively &#8220;escaped by&#8221; check_plain(), <span style="color: #ff00ff;">%placeholders </span>are replaced themed as well</p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/drupal-notes-1-module-hook_block-hook_help-check_plain-check_url-watchdog-t-l-placeholders/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Interface and Abstract Class example</title>
		<link>http://alexyz.com/php-interface-and-abstract-class-example-good-stuff/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=php-interface-and-abstract-class-example-good-stuff</link>
		<comments>http://alexyz.com/php-interface-and-abstract-class-example-good-stuff/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 03:05:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=459</guid>
		<description><![CDATA[<span style="color: #ff0000;">&#60;?php</span>

<span style="color: #0000ff;">abstract</span> class animal
{
abstract function getowned();
private $age;

protected function __construct($age) {
$this-&#62;age = $age;
}

public function getage()
{
return $this-&#62;age;
}
}
<span style="color: #0000ff;">interface</span> insurable {
public function getvalue();
}

class pet <span style="color: #0000ff;">extends</span> animal<span style="color: #0000ff;"> implements</span> insurable {
private $name;
public function __construct($name,$age) {
parent::__construct($age);
$this-&#62;name = $name;
}
public function getname() {
return $this-&#62;name;
}
public function getowned() {
return ("Owner String");
}
public function getvalue() {
return ("Priceless");
}
}

class house<span style="color: #0000ff;"> implements</span> insurable {
public function getvalue() {
return ("Rising fast");
}

}

$charlie = new pet("Charlie",6);
$catage = $charlie -&#62; getage();
$catname = $charlie -&#62; getname();
print "$catname is $catage years old!&#60;br&#62;&#60;br&#62;";

if  ... <a href="http://alexyz.com/php-interface-and-abstract-class-example-good-stuff/">READ MORE</a>]]></description>
			<content:encoded><![CDATA[<p><span style="color: #ff0000;">&lt;?php</span></p>
<p><span style="color: #0000ff;">abstract</span> class animal<br />
{<br />
abstract function getowned();<br />
private $age;</p>
<p>protected function __construct($age) {<br />
$this-&gt;age = $age;<br />
}</p>
<p>public function getage()<br />
{<br />
return $this-&gt;age;<br />
}<br />
}<br />
<span style="color: #0000ff;">interface</span> insurable {<br />
public function getvalue();<br />
}</p>
<p>class pet <span style="color: #0000ff;">extends</span> animal<span style="color: #0000ff;"> implements</span> insurable {<br />
private $name;<br />
public function __construct($name,$age) {<br />
parent::__construct($age);<br />
$this-&gt;name = $name;<br />
}<br />
public function getname() {<br />
return $this-&gt;name;<br />
}<br />
public function getowned() {<br />
return (&#8220;Owner String&#8221;);<br />
}<br />
public function getvalue() {<br />
return (&#8220;Priceless&#8221;);<br />
}<br />
}</p>
<p>class house<span style="color: #0000ff;"> implements</span> insurable {<br />
public function getvalue() {<br />
return (&#8220;Rising fast&#8221;);<br />
}</p>
<p>}</p>
<p>$charlie = new pet(&#8220;Charlie&#8221;,6);<br />
$catage = $charlie -&gt; getage();<br />
$catname = $charlie -&gt; getname();<br />
print &#8220;$catname is $catage years old!&lt;br&gt;&lt;br&gt;&#8221;;</p>
<p>if ($charlie instanceof pet) print (&#8220;charlie is a pet&lt;br&gt;&#8221;);<br />
if ($charlie instanceof animal) print (&#8220;charlie is an animal&lt;br&gt;&#8221;);<br />
if ($charlie instanceof house) print (&#8220;charlie is a house&lt;br&gt;&#8221;);<br />
if ($charlie instanceof insurable) print (&#8220;charlie is insurable&lt;br&gt;&#8221;);</p>
<p><span style="color: #ff0000;">?&gt;</span><br />
reference: <a href="http://www.wellho.net/resources/ex.php4?item=h108/animal3.php">http://www.wellho.net/resources/ex.php4?item=h108/animal3.php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/php-interface-and-abstract-class-example-good-stuff/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>simple PHP namespace example</title>
		<link>http://alexyz.com/simple-php-namespace-example/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=simple-php-namespace-example</link>
		<comments>http://alexyz.com/simple-php-namespace-example/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 22:22:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=454</guid>
		<description><![CDATA[<span style="color: #0000ff;">Foo.class.php</span>

<span style="color: #ff0000;">&#60;?php</span>
class Foo
{
function Simple()
{
$var = "Hello";
return $var;
}
}
<span style="color: #ff0000;">?&#62;</span>

<span style="color: #ff0000;"><span style="color: #0000ff;">namespace.php</span></span>

<span style="color: #ff0000;">&#60;?php</span>
<span style="color: #ff9900;">namespace Second;</span>
include('Foo.class.php');

class Foo
{
function Simple()
{
$var = "Hello in Second Namespace&#60;br /&#62;";
return $var;
}
}

$fooSecond = new \Second\Foo();
echo $fooSecond-&#62;Simple();
<span style="color: #008000;">//option 1
//$fooFirst = new \Foo();
//$fooFirst-&#62;Simple();
//option 2</span>
echo \Foo::Simple();
<span style="color: #ff0000;">?&#62;</span>]]></description>
			<content:encoded><![CDATA[<p><span style="color: #0000ff;">Foo.class.php</span></p>
<p><span style="color: #ff0000;">&lt;?php</span><br />
class Foo<br />
{<br />
function Simple()<br />
{<br />
$var = &#8220;Hello&#8221;;<br />
return $var;<br />
}<br />
}<br />
<span style="color: #ff0000;">?&gt;</span></p>
<p><span style="color: #ff0000;"><span style="color: #0000ff;">namespace.php</span></span></p>
<p><span style="color: #ff0000;">&lt;?php</span><br />
<span style="color: #ff9900;">namespace Second;</span><br />
include(&#8216;Foo.class.php&#8217;);</p>
<p>class Foo<br />
{<br />
function Simple()<br />
{<br />
$var = &#8220;Hello in Second Namespace&lt;br /&gt;&#8221;;<br />
return $var;<br />
}<br />
}</p>
<p>$fooSecond = new \Second\Foo();<br />
echo $fooSecond-&gt;Simple();<br />
<span style="color: #008000;">//option 1<br />
//$fooFirst = new \Foo();<br />
//$fooFirst-&gt;Simple();<br />
//option 2</span><br />
echo \Foo::Simple();<br />
<span style="color: #ff0000;">?&gt;</span></p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/simple-php-namespace-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>simple PHP __autoload example</title>
		<link>http://alexyz.com/simple-php-__autoload-example/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=simple-php-__autoload-example</link>
		<comments>http://alexyz.com/simple-php-__autoload-example/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 21:40:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=452</guid>
		<description><![CDATA[<span style="color: #0000ff;">Foo.class.php</span>

<span style="color: #ff0000;">&#60;?php</span>
class Foo
{
public static $varz;
public static function Simple()
{
self::$varz = "Hello";
return self::$varz;
}
}
<span style="color: #ff0000;">?&#62;</span>

<span style="color: #0000ff;">index.php (in the same directory)</span>

<span style="color: #ff0000;">&#60;?php</span>
function __autoload($classname) {
include("$classname.class.php");
}

<span style="color: #008000;">//include "Foo.class.php"; //no longer needed!</span>

$foo = new Foo();
echo $foo-&#62;Simple();
<span style="color: #ff0000;">?&#62;</span>]]></description>
			<content:encoded><![CDATA[<p><span style="color: #0000ff;">Foo.class.php</span></p>
<p><span style="color: #ff0000;">&lt;?php</span><br />
class Foo<br />
{<br />
public static $varz;<br />
public static function Simple()<br />
{<br />
self::$varz = &#8220;Hello&#8221;;<br />
return self::$varz;<br />
}<br />
}<br />
<span style="color: #ff0000;">?&gt;</span></p>
<p><span style="color: #0000ff;">index.php (in the same directory)</span></p>
<p><span style="color: #ff0000;">&lt;?php</span><br />
function __autoload($classname) {<br />
include(&#8220;$classname.class.php&#8221;);<br />
}</p>
<p><span style="color: #008000;">//include &#8220;Foo.class.php&#8221;; //no longer needed!</span></p>
<p>$foo = new Foo();<br />
echo $foo-&gt;Simple();<br />
<span style="color: #ff0000;">?&gt;</span></p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/simple-php-__autoload-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>simple ob_start(), flush(), ob_gzhandler, sleep(),  HEREDOC examples</title>
		<link>http://alexyz.com/simple-ob_start-flush-ob_gzhandler-examples/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=simple-ob_start-flush-ob_gzhandler-examples</link>
		<comments>http://alexyz.com/simple-ob_start-flush-ob_gzhandler-examples/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 09:11:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=448</guid>
		<description><![CDATA[<span style="color: #0000ff;">//ob_start()</span>

<span style="color: #ff0000;">&#60;?php</span>
ob_start();
print "Hello First!\n";
ob_end_flush();

ob_start();
print "Hello Second!\n";
ob_end_clean();

ob_start();
print "Hello Third!\n";
<span style="color: #ff0000;">?&#62; </span>

//outputs "Hello First! Hello Third!"

<span style="color: #0000ff;">//flush()</span>

&#60;HTML&#62;
&#60;BODY&#62;
&#60;DIV ID="flushme"&#62;
Hello, world!
&#60;/DIV&#62;
<span style="color: #ff0000;">&#60;?php</span> flush(); sleep(2); <span style="color: #ff0000;">?&#62;</span>
&#60;SCRIPT&#62;
d = document.getElementById("flushme");
d.innerHTML = "Goodbye, Perl!";
&#60;/SCRIPT&#62;
<span style="color: #ff0000;">&#60;?php</span> flush(); sleep(2); <span style="color: #ff0000;">?&#62;</span>
&#60;SCRIPT&#62;
d.innerHTML = "Goodnight, New York!";
&#60;/SCRIPT&#62;
&#60;/BODY&#62;
&#60;/HTML&#62;

<span style="color: #0000ff;">// compressed output</span>

<span style="color: #ff0000;">&#60;?php</span>
ob_start('ob_gzhandler');
print "My content\n";
ob_end_flush();
<span style="color: #ff0000;">?&#62; </span>

<span style="color: #0000ff;">// sleep</span>

<span style="color: #ff0000;">&#60;?php</span>
ob_implicit_flush(true);
for($i=0;$i&#60;5;$i++)
{
$dis=&#60;&#60;&#60;DIS
&#60;div style="width:200px; background-color:lime;border:1px; text-align:center;text-decoration:blink;"&#62;
$i
&#60;/div&#62;
DIS;
echo $dis;

sleep(5);
//flush();
}
<span style="color: #ff0000;">?&#62;</span>]]></description>
			<content:encoded><![CDATA[<p><span style="color: #0000ff;">//ob_start()</span></p>
<p><span style="color: #ff0000;">&lt;?php</span><br />
ob_start();<br />
print &#8220;Hello First!\n&#8221;;<br />
ob_end_flush();</p>
<p>ob_start();<br />
print &#8220;Hello Second!\n&#8221;;<br />
ob_end_clean();</p>
<p>ob_start();<br />
print &#8220;Hello Third!\n&#8221;;<br />
<span style="color: #ff0000;">?&gt; </span></p>
<p>//outputs &#8220;Hello First! Hello Third!&#8221;</p>
<p><span style="color: #0000ff;">//flush()</span></p>
<p>&lt;HTML&gt;<br />
&lt;BODY&gt;<br />
&lt;DIV ID=&#8221;flushme&#8221;&gt;<br />
Hello, world!<br />
&lt;/DIV&gt;<br />
<span style="color: #ff0000;">&lt;?php</span> flush(); sleep(2); <span style="color: #ff0000;">?&gt;</span><br />
&lt;SCRIPT&gt;<br />
d = document.getElementById(&#8220;flushme&#8221;);<br />
d.innerHTML = &#8220;Goodbye, Perl!&#8221;;<br />
&lt;/SCRIPT&gt;<br />
<span style="color: #ff0000;">&lt;?php</span> flush(); sleep(2); <span style="color: #ff0000;">?&gt;</span><br />
&lt;SCRIPT&gt;<br />
d.innerHTML = &#8220;Goodnight, New York!&#8221;;<br />
&lt;/SCRIPT&gt;<br />
&lt;/BODY&gt;<br />
&lt;/HTML&gt;</p>
<p><span style="color: #0000ff;">// compressed output</span></p>
<p><span style="color: #ff0000;">&lt;?php</span><br />
ob_start(&#8216;ob_gzhandler&#8217;);<br />
print &#8220;My content\n&#8221;;<br />
ob_end_flush();<br />
<span style="color: #ff0000;">?&gt; </span></p>
<p><span style="color: #0000ff;">// sleep</span></p>
<p><span style="color: #ff0000;">&lt;?php</span><br />
ob_implicit_flush(true);<br />
for($i=0;$i&lt;5;$i++)<br />
{<br />
$dis=&lt;&lt;&lt;DIS<br />
&lt;div style=&#8221;width:200px; background-color:lime;border:1px; text-align:center;text-decoration:blink;&#8221;&gt;<br />
$i<br />
&lt;/div&gt;<br />
DIS;<br />
echo $dis;</p>
<p>sleep(5);<br />
//flush();<br />
}<br />
<span style="color: #ff0000;">?&gt;</span></p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/simple-ob_start-flush-ob_gzhandler-examples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>memory jogger: Chain of responsibility, Polymorphism, Design Pattern reference, Decorator pattern, Singleton</title>
		<link>http://alexyz.com/memory-jogger-chain-of-responsibility-polymorphism-design-pattern-reference-decorator-pattern-singleton/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=memory-jogger-chain-of-responsibility-polymorphism-design-pattern-reference-decorator-pattern-singleton</link>
		<comments>http://alexyz.com/memory-jogger-chain-of-responsibility-polymorphism-design-pattern-reference-decorator-pattern-singleton/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 20:52:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Reference]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=442</guid>
		<description><![CDATA[Good stuff, take a moment to refresh and review:

Chain of responsibility:
<a href="http://en.wikipedia.org/wiki/Chain-of-responsibility_pattern">http://en.wikipedia.org/wiki/Chain-of-responsibility_pattern</a>
Polymorphism:
<a href="http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming">http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming</a>
JavaScript really OOP?:
<a href="http://articles.techrepublic.com.com/5100-10878_11-1044656.html">http://articles.techrepublic.com.com/5100-10878_11-1044656.html</a>
<a href="http://mckoss.com/jscript/object.htm">http://mckoss.com/jscript/object.htm</a>
JS Prototype object:
<a href="http://www.javascriptkit.com/javatutors/proto4.shtml">http://www.javascriptkit.com/javatutors/proto4.shtml</a>
Design Patterns reference/list:
<a href="http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29">http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29</a>
Decorator Pattern:
<a href="http://en.wikipedia.org/wiki/Decorator_pattern">http://en.wikipedia.org/wiki/Decorator_pattern</a>
Loose Coupling def:
<a href="http://en.wikipedia.org/wiki/Loose_coupling">http://en.wikipedia.org/wiki/Loose_coupling</a>
Singleton Pattern:
<a href="http://en.wikipedia.org/wiki/Singleton_pattern">http://en.wikipedia.org/wiki/Singleton_pattern</a>]]></description>
			<content:encoded><![CDATA[<p>Good stuff, take a moment to refresh and review:</p>
<p>Chain of responsibility:<br />
<a href="http://en.wikipedia.org/wiki/Chain-of-responsibility_pattern">http://en.wikipedia.org/wiki/Chain-of-responsibility_pattern</a><br />
Polymorphism:<br />
<a href="http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming">http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming</a><br />
JavaScript really OOP?:<br />
<a href="http://articles.techrepublic.com.com/5100-10878_11-1044656.html">http://articles.techrepublic.com.com/5100-10878_11-1044656.html</a><br />
<a href="http://mckoss.com/jscript/object.htm">http://mckoss.com/jscript/object.htm</a><br />
JS Prototype object:<br />
<a href="http://www.javascriptkit.com/javatutors/proto4.shtml">http://www.javascriptkit.com/javatutors/proto4.shtml</a><br />
Design Patterns reference/list:<br />
<a href="http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29">http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29</a><br />
Decorator Pattern:<br />
<a href="http://en.wikipedia.org/wiki/Decorator_pattern">http://en.wikipedia.org/wiki/Decorator_pattern</a><br />
Loose Coupling def:<br />
<a href="http://en.wikipedia.org/wiki/Loose_coupling">http://en.wikipedia.org/wiki/Loose_coupling</a><br />
Singleton Pattern:<br />
<a href="http://en.wikipedia.org/wiki/Singleton_pattern">http://en.wikipedia.org/wiki/Singleton_pattern</a></p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/memory-jogger-chain-of-responsibility-polymorphism-design-pattern-reference-decorator-pattern-singleton/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQl sub query example 2</title>
		<link>http://alexyz.com/mysql-sub-query-example-2/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mysql-sub-query-example-2</link>
		<comments>http://alexyz.com/mysql-sub-query-example-2/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 21:09:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=440</guid>
		<description><![CDATA[<span style="color: #ff0000;">SELECT</span>
q.questionId,
q.question,
q.questionTopic,
q.questionDate,
q.courseId,
q.customerId,
v.voted_this
<span style="color: #ff0000;">FROM</span>
" . $course_database_questions_table_name . " <span style="color: #ff0000;">q</span>
<span style="color: #ff0000;">LEFT JOIN</span>
<span style="color: #800000;">(SELECT <span style="color: #000000;">questionId</span> <span style="color: #ff0000;">voted_this</span> FROM <span style="color: #000000;">votes</span> WHERE <span style="color: #000000;">customerId = '" . $customer_id . "'</span>) v</span>
<span style="color: #ff0000;">ON</span>
q.questionId = v.voted_this
<span style="color: #ff0000;">WHERE</span>
q.courseId = " . $courseId . "
<span style="color: #ff0000;">ORDER BY</span> q.questionDate <span style="color: #ff0000;">DESC</span>]]></description>
			<content:encoded><![CDATA[<p><span style="color: #ff0000;">SELECT</span><br />
q.questionId,<br />
q.question,<br />
q.questionTopic,<br />
q.questionDate,<br />
q.courseId,<br />
q.customerId,<br />
v.voted_this<br />
<span style="color: #ff0000;">FROM</span><br />
&#8221; . $course_database_questions_table_name . &#8221; <span style="color: #ff0000;">q</span><br />
<span style="color: #ff0000;">LEFT JOIN</span><br />
<span style="color: #800000;">(SELECT <span style="color: #000000;">questionId</span> <span style="color: #ff0000;">voted_this</span> FROM <span style="color: #000000;">votes</span> WHERE <span style="color: #000000;">customerId = &#8216;&#8221; . $customer_id . &#8220;&#8216;</span>) v</span><br />
<span style="color: #ff0000;">ON</span><br />
q.questionId = v.voted_this<br />
<span style="color: #ff0000;">WHERE</span><br />
q.courseId = &#8221; . $courseId . &#8221;<br />
<span style="color: #ff0000;">ORDER BY</span> q.questionDate <span style="color: #ff0000;">DESC</span></p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/mysql-sub-query-example-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL sub query example &#8211; nice</title>
		<link>http://alexyz.com/mysql-sub-query-example-nice/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mysql-sub-query-example-nice</link>
		<comments>http://alexyz.com/mysql-sub-query-example-nice/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 22:20:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=437</guid>
		<description><![CDATA[$cp_output = "";
if(!$get_cp_data = mysql_query("
<span style="color: #ff0000;">SELECT
q.*,
c.*,
vote_counts.Tally
FROM
questions q
LEFT JOIN
(SELECT
questionId,
count(1) as Tally
FROM
votes
GROUP BY
questionId
) vote_counts
ON
q.questionId = vote_counts.questionId
LEFT JOIN
customers c
ON
c.customerId = q.customerId
WHERE
q.courseId = 1
ORDER BY
vote_counts.Tally desc</span>
")){ echo mysql_error(); }

while($get_cp_data_array = mysql_fetch_array($get_cp_data)){
$q_id = $get_cp_data_array['questionId'];

$q_fname = $get_cp_data_array['customerFName'];
$q_lname = $get_cp_data_array['customerLName'];
$q_email = $get_cp_data_array['customerEmail'];

$q_topic = $get_cp_data_array['questionTopic'];
$q_question = $get_cp_data_array['question'];
$q_date = $get_cp_data_array['questionDate'];
//$q_count = $get_cp_data_array['votecount'];
$q_customer = $get_cp_data_array['customerId'];

if($q_topic == ""){ $q_topic = "--"; }
if($q_fname != "" &#124;&#124; $q_lname != ""){
$from = '&#60;strong&#62;' . $q_fname . ' ' . $q_lname . '&#60;/strong&#62; - ';
}

# Parse the question text.
$old = array("\n");
$new   = array("&#60;br/&#62;");
$q_question =  ... <a href="http://alexyz.com/mysql-sub-query-example-nice/">READ MORE</a>]]></description>
			<content:encoded><![CDATA[<p>$cp_output = &#8220;&#8221;;<br />
if(!$get_cp_data = mysql_query(&#8221;<br />
<span style="color: #ff0000;">SELECT<br />
q.*,<br />
c.*,<br />
vote_counts.Tally<br />
FROM<br />
questions q<br />
LEFT JOIN<br />
(SELECT<br />
questionId,<br />
count(1) as Tally<br />
FROM<br />
votes<br />
GROUP BY<br />
questionId<br />
) vote_counts<br />
ON<br />
q.questionId = vote_counts.questionId<br />
LEFT JOIN<br />
customers c<br />
ON<br />
c.customerId = q.customerId<br />
WHERE<br />
q.courseId = 1<br />
ORDER BY<br />
vote_counts.Tally desc</span><br />
&#8220;)){ echo mysql_error(); }</p>
<p>while($get_cp_data_array = mysql_fetch_array($get_cp_data)){<br />
$q_id = $get_cp_data_array['questionId'];</p>
<p>$q_fname = $get_cp_data_array['customerFName'];<br />
$q_lname = $get_cp_data_array['customerLName'];<br />
$q_email = $get_cp_data_array['customerEmail'];</p>
<p>$q_topic = $get_cp_data_array['questionTopic'];<br />
$q_question = $get_cp_data_array['question'];<br />
$q_date = $get_cp_data_array['questionDate'];<br />
//$q_count = $get_cp_data_array['votecount'];<br />
$q_customer = $get_cp_data_array['customerId'];</p>
<p>if($q_topic == &#8220;&#8221;){ $q_topic = &#8220;&#8211;&#8221;; }<br />
if($q_fname != &#8220;&#8221; || $q_lname != &#8220;&#8221;){<br />
$from = &#8216;&lt;strong&gt;&#8217; . $q_fname . &#8216; &#8216; . $q_lname . &#8216;&lt;/strong&gt; &#8211; &#8216;;<br />
}</p>
<p># Parse the question text.<br />
$old = array(&#8220;\n&#8221;);<br />
$new   = array(&#8220;&lt;br/&gt;&#8221;);<br />
$q_question = str_replace($old, $new, $q_question);</p>
<p># Output the question.<br />
$cp_output = $cp_output . &#8216;<br />
&lt;div&gt;&#8217; . $q_id . &#8216;&lt;/div&gt;<br />
&lt;div&gt;<br />
&lt;div&gt;&lt;strong&gt;&#8217; . $q_topic . &#8216;&lt;/strong&gt;&lt;/div&gt;<br />
&lt;div&gt;&#8217; . $q_question . &#8216;&lt;/div&gt;<br />
&lt;div&gt;&lt;strong&gt;Submitted&lt;/strong&gt; &#8216; . $q_date . &#8216; by &#8216; . $from . &#8216;&lt;a href=&#8221;mailto:&#8217; . $q_email . &#8216;&#8221;&gt;&#8217; . $q_email . &#8216;&lt;/a&gt;&lt;/div&gt;<br />
&lt;/div&gt;<br />
&lt;div&gt;&lt;/div&gt;<br />
&#8216;;<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/mysql-sub-query-example-nice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>clean &amp; simple check your $_SERVER var</title>
		<link>http://alexyz.com/clean-simple-check-your-_server-var/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=clean-simple-check-your-_server-var</link>
		<comments>http://alexyz.com/clean-simple-check-your-_server-var/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 21:43:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=428</guid>
		<description><![CDATA[&#60;?

echo "&#60;pre&#62;";
print_r($_SERVER);

?&#62;]]></description>
			<content:encoded><![CDATA[<p>&lt;?</p>
<p>echo &#8220;&lt;pre&gt;&#8221;;<br />
print_r($_SERVER);</p>
<p>?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/clean-simple-check-your-_server-var/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress PHP custom theme functions.php hook</title>
		<link>http://alexyz.com/wordpress-php-custom-theme-functions-php-hook/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=wordpress-php-custom-theme-functions-php-hook</link>
		<comments>http://alexyz.com/wordpress-php-custom-theme-functions-php-hook/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 23:33:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=420</guid>
		<description><![CDATA[In your theme (wp-content/themes/YourNewTheme) create or find functions.php

and start making whatever you need.  It's a nice clean place to put things <span style="color: #ff0000;">without</span> hacking away at your code,

dynamically inserting with JS, or whatever other measure you've either employed in the past, or are considering now...

for example,

<span style="color: #ff0000;">&#60;?php</span>
<span style="color: #ff6600;">//My own footer hook</span>
function my_footer() {

//code to execute

<span style="color: #ff0000;">?&#62;</span>&#60;div class="bigText"&#62;blah blah blah&#60;/div&#62;<span style="color: #ff0000;">&#60;?</span>

<span style="color: #000000;">}</span>

<span style="color: #ff0000;">?&#62;</span>

<span style="color: #000000;">then, wherever you like, call your new function, example, replace  ... <a href="http://alexyz.com/wordpress-php-custom-theme-functions-php-hook/">READ MORE</a>]]></description>
			<content:encoded><![CDATA[<p>In your theme (wp-content/themes/YourNewTheme) create or find functions.php</p>
<p>and start making whatever you need.  It&#8217;s a nice clean place to put things <span style="color: #ff0000;">without</span> hacking away at your code,</p>
<p>dynamically inserting with JS, or whatever other measure you&#8217;ve either employed in the past, or are considering now&#8230;</p>
<p>for example,</p>
<p><span style="color: #ff0000;">&lt;?php</span><br />
<span style="color: #ff6600;">//My own footer hook</span><br />
function my_footer() {</p>
<p>//code to execute</p>
<p><span style="color: #ff0000;">?&gt;</span>&lt;div class=&#8221;bigText&#8221;&gt;blah blah blah&lt;/div&gt;<span style="color: #ff0000;">&lt;?</span></p>
<p><span style="color: #000000;">}</span></p>
<p><span style="color: #ff0000;">?&gt;</span></p>
<p><span style="color: #000000;">then, wherever you like, call your new function, example, replace all <span style="color: #ff0000;">&lt;? wp_footer(); ?&gt;</span> calls with, you guested it, </span><span style="color: #ff0000;">&lt;? my_footer(); ?&gt;<br />
</span></p>
<p>thanks to: <a href="http://www.raymondselda.com/understanding-action-hooks-in-wordpress/">http://www.raymondselda.com/understanding-action-hooks-in-wordpress/</a></p>
<p>Don&#8217;t forget to include the following in your new custom theme functions.php file if you want the dynamic custom drag widget sidebar!:</p>
<p><span style="color: #ff0000;">if ( function_exists(&#8216;register_sidebar&#8217;) )<br />
register_sidebar();</span></p>
<p>reference: <a href="http://codex.wordpress.org/Widgetizing_Themes">http://codex.wordpress.org/Widgetizing_Themes</a></p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/wordpress-php-custom-theme-functions-php-hook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;&amp;&#8221; preceeding variable &amp; Passing function parameters by reference variable PHP</title>
		<link>http://alexyz.com/preceeding-variable-passing-function-parameters-by-reference-variable-php/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=preceeding-variable-passing-function-parameters-by-reference-variable-php</link>
		<comments>http://alexyz.com/preceeding-variable-passing-function-parameters-by-reference-variable-php/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 06:22:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=416</guid>
		<description><![CDATA[<strong>&#38; preceeds variable</strong>

$original = "foo";
$ref = &#38;$original;
echo $ref;  \\Prints "foo"
// now we change the value of $original
$original = "bar";
// and then print the value of the referring variable
echo $ref;  \\Now prints the new value: "bar"
source: <a href="http://www.whypad.com/posts/php-what-is-the-ampersand-preceding-variables/193/">http://www.whypad.com/posts/php-what-is-the-ampersand-preceding-variables/193/</a>

<strong>reference variable (&#38;variable)</strong>
<div>
<div>

<code> <span style="color: #ff0000;">&#60;?php
function add_some_extra(&#38;$string)
{
$string .= 'and something extra.';
}
$str = 'This is a string, ';
add_some_extra($str);
echo $str;    // outputs 'This is a string, and something extra.'
?&#62; </span></code>

</div>
</div>
<span style="color: #000000;">Basically, the argument is treated, referenced by the outside variable, as global
Without the &#38;, it would output 'This is a string'
</span>source: <a href="http://php.net/manual/en/functions.arguments.php">http://php.net/manual/en/functions.arguments.php</a>]]></description>
			<content:encoded><![CDATA[<p><strong>&amp; preceeds variable</strong></p>
<p>$original = &#8220;foo&#8221;;<br />
$ref = &amp;$original;<br />
echo $ref;  \\Prints &#8220;foo&#8221;<br />
// now we change the value of $original<br />
$original = &#8220;bar&#8221;;<br />
// and then print the value of the referring variable<br />
echo $ref;  \\Now prints the new value: &#8220;bar&#8221;<br />
source: <a href="http://www.whypad.com/posts/php-what-is-the-ampersand-preceding-variables/193/">http://www.whypad.com/posts/php-what-is-the-ampersand-preceding-variables/193/</a></p>
<p><strong>reference variable (&amp;variable)</strong></p>
<div>
<div>
<p><code> <span style="color: #ff0000;">&lt;?php<br />
function add_some_extra(&amp;$string)<br />
{<br />
$string .= 'and something extra.';<br />
}<br />
$str = 'This is a string, ';<br />
add_some_extra($str);<br />
echo $str;    // outputs 'This is a string, and something extra.'<br />
?&gt; </span></code></p>
</div>
</div>
<p><span style="color: #000000;">Basically, the argument is treated, referenced by the outside variable, as global<br />
Without the &amp;, it would output &#8216;This is a string&#8217;<br />
</span>source: <a href="http://php.net/manual/en/functions.arguments.php">http://php.net/manual/en/functions.arguments.php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/preceeding-variable-passing-function-parameters-by-reference-variable-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Postincrement Preincrement Postdecrement Predecrement PHP careful! ++ &#8211;</title>
		<link>http://alexyz.com/postincrement-preincrement-postdecrement-predecrement-php-careful/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=postincrement-preincrement-postdecrement-predecrement-php-careful</link>
		<comments>http://alexyz.com/postincrement-preincrement-postdecrement-predecrement-php-careful/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 06:07:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=412</guid>
		<description><![CDATA[<div>
<div>
<div><code> &#60;?php
echo "&#60;h3&#62;Postincrement&#60;/h3&#62;";
$a = 5;
echo "Should be 5: " . $a++ . "&#60;br /&#62;\n";
echo "Should be 6: " . $a . "&#60;br /&#62;\n";

echo "&#60;h3&#62;Preincrement&#60;/h3&#62;";
$a = 5;
echo "Should be 6: " . ++$a . "&#60;br /&#62;\n";
echo "Should be 6: " . $a . "&#60;br /&#62;\n";

echo "&#60;h3&#62;Postdecrement&#60;/h3&#62;";
$a = 5;
echo "Should be 5: " . $a-- . "&#60;br /&#62;\n";
echo "Should be 4: " . $a . "&#60;br /&#62;\n";

echo "&#60;h3&#62;Predecrement&#60;/h3&#62;";
$a = 5;
echo "Should be 4: " . --$a . "&#60;br /&#62;\n";
echo "Should be 4: " . $a . "&#60;br /&#62;\n";
?&#62; </code></div>
</div>
<div></div>
<div>source: <a href="http://php.net/manual/en/language.operators.increment.php">http://php.net/manual/en/language.operators.increment.php</a></div>
</div>]]></description>
			<content:encoded><![CDATA[<div>
<div>
<div><code> &lt;?php<br />
echo "&lt;h3&gt;Postincrement&lt;/h3&gt;";<br />
$a = 5;<br />
echo "Should be 5: " . $a++ . "&lt;br /&gt;\n";<br />
echo "Should be 6: " . $a . "&lt;br /&gt;\n";</p>
<p>echo "&lt;h3&gt;Preincrement&lt;/h3&gt;";<br />
$a = 5;<br />
echo "Should be 6: " . ++$a . "&lt;br /&gt;\n";<br />
echo "Should be 6: " . $a . "&lt;br /&gt;\n";</p>
<p>echo "&lt;h3&gt;Postdecrement&lt;/h3&gt;";<br />
$a = 5;<br />
echo "Should be 5: " . $a-- . "&lt;br /&gt;\n";<br />
echo "Should be 4: " . $a . "&lt;br /&gt;\n";</p>
<p>echo "&lt;h3&gt;Predecrement&lt;/h3&gt;";<br />
$a = 5;<br />
echo "Should be 4: " . --$a . "&lt;br /&gt;\n";<br />
echo "Should be 4: " . $a . "&lt;br /&gt;\n";<br />
?&gt; </code></div>
</div>
<div></div>
<div>source: <a href="http://php.net/manual/en/language.operators.increment.php">http://php.net/manual/en/language.operators.increment.php</a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/postincrement-preincrement-postdecrement-predecrement-php-careful/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I always like to have a nice simple AJAX example on hand, you never know&#8230;</title>
		<link>http://alexyz.com/i-always-like-to-have-a-nice-simple-ajax-example-on-hand-you-never-know/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=i-always-like-to-have-a-nice-simple-ajax-example-on-hand-you-never-know</link>
		<comments>http://alexyz.com/i-always-like-to-have-a-nice-simple-ajax-example-on-hand-you-never-know/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 04:52:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=409</guid>
		<description><![CDATA[<strong>reference:</strong>

<a href="http://w3schools.com/php/php_ajax_php.asp">http://w3schools.com/php/php_ajax_php.asp</a>

<strong>HTML:</strong>

&#60;html&#62;
&#60;head&#62;
&#60;script type="text/javascript"&#62;
function showHint(str)
{
if (str.length==0)
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 &#38;&#38; xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","gethint.php?q="+str,true);
xmlhttp.send();
}
&#60;/script&#62;
&#60;/head
&#60;body&#62;

&#60;p&#62;&#60;b&#62;Start typing a name in the input field below:&#60;/b&#62;&#60;/p&#62;
&#60;form&#62;
First name: &#60;input type="text" onkeyup="showHint(this.value)" size="20" /&#62;
&#60;/form&#62;
&#60;p&#62;Suggestions: &#60;span id="txtHint"&#62;&#60;/span&#62;&#60;/p&#62;

&#60;/body&#62;
&#60;/html&#62;

<strong>Script:</strong>

<span style="color: #ff0000;">&#60;?php
// Fill up array with names
$a[]="Anna";
$a[]="Brittany";
$a[]="Cinderella";
$a[]="Diana";
$a[]="Eva";
$a[]="Fiona";
$a[]="Gunda";
$a[]="Hege";
$a[]="Inga";
$a[]="Johanna";
$a[]="Kitty";
$a[]="Linda";
$a[]="Nina";
$a[]="Ophelia";
$a[]="Petunia";
$a[]="Amanda";
$a[]="Raquel";
$a[]="Cindy";
$a[]="Doris";
$a[]="Eve";
$a[]="Evita";
$a[]="Sunniva";
$a[]="Tove";
$a[]="Unni";
$a[]="Violet";
$a[]="Liza";
$a[]="Elizabeth";
$a[]="Ellen";
$a[]="Wenche";
$a[]="Vicky";

//get the q parameter from URL
$q=$_GET["q"];

//lookup all hints from array if length of q&#62;0
if (strlen($q) &#62; 0)
{
$hint="";
for($i=0; $i&#60;count($a); $i++)
{
if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q))))
{
if ($hint=="")
{
$hint=$a[$i];
}
else
{
$hint=$hint." , ".$a[$i];
}
}
}
}

// Set output to "no suggestion" if no hint were found
// or to the  ... <a href="http://alexyz.com/i-always-like-to-have-a-nice-simple-ajax-example-on-hand-you-never-know/">READ MORE</a>]]></description>
			<content:encoded><![CDATA[<p><strong>reference:</strong></p>
<p><a href="http://w3schools.com/php/php_ajax_php.asp">http://w3schools.com/php/php_ajax_php.asp</a></p>
<p><strong>HTML:</strong></p>
<p>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
function showHint(str)<br />
{<br />
if (str.length==0)<br />
{<br />
document.getElementById(&#8220;txtHint&#8221;).innerHTML=&#8221;";<br />
return;<br />
}<br />
if (window.XMLHttpRequest)<br />
{// code for IE7+, Firefox, Chrome, Opera, Safari<br />
xmlhttp=new XMLHttpRequest();<br />
}<br />
else<br />
{// code for IE6, IE5<br />
xmlhttp=new ActiveXObject(&#8220;Microsoft.XMLHTTP&#8221;);<br />
}<br />
xmlhttp.onreadystatechange=function()<br />
{<br />
if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)<br />
{<br />
document.getElementById(&#8220;txtHint&#8221;).innerHTML=xmlhttp.responseText;<br />
}<br />
}<br />
xmlhttp.open(&#8220;GET&#8221;,&#8221;gethint.php?q=&#8221;+str,true);<br />
xmlhttp.send();<br />
}<br />
&lt;/script&gt;<br />
&lt;/head<br />
&lt;body&gt;</p>
<p>&lt;p&gt;&lt;b&gt;Start typing a name in the input field below:&lt;/b&gt;&lt;/p&gt;<br />
&lt;form&gt;<br />
First name: &lt;input type=&#8221;text&#8221; onkeyup=&#8221;showHint(this.value)&#8221; size=&#8221;20&#8243; /&gt;<br />
&lt;/form&gt;<br />
&lt;p&gt;Suggestions: &lt;span id=&#8221;txtHint&#8221;&gt;&lt;/span&gt;&lt;/p&gt;</p>
<p>&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p><strong>Script:</strong></p>
<p><span style="color: #ff0000;">&lt;?php<br />
// Fill up array with names<br />
$a[]=&#8221;Anna&#8221;;<br />
$a[]=&#8221;Brittany&#8221;;<br />
$a[]=&#8221;Cinderella&#8221;;<br />
$a[]=&#8221;Diana&#8221;;<br />
$a[]=&#8221;Eva&#8221;;<br />
$a[]=&#8221;Fiona&#8221;;<br />
$a[]=&#8221;Gunda&#8221;;<br />
$a[]=&#8221;Hege&#8221;;<br />
$a[]=&#8221;Inga&#8221;;<br />
$a[]=&#8221;Johanna&#8221;;<br />
$a[]=&#8221;Kitty&#8221;;<br />
$a[]=&#8221;Linda&#8221;;<br />
$a[]=&#8221;Nina&#8221;;<br />
$a[]=&#8221;Ophelia&#8221;;<br />
$a[]=&#8221;Petunia&#8221;;<br />
$a[]=&#8221;Amanda&#8221;;<br />
$a[]=&#8221;Raquel&#8221;;<br />
$a[]=&#8221;Cindy&#8221;;<br />
$a[]=&#8221;Doris&#8221;;<br />
$a[]=&#8221;Eve&#8221;;<br />
$a[]=&#8221;Evita&#8221;;<br />
$a[]=&#8221;Sunniva&#8221;;<br />
$a[]=&#8221;Tove&#8221;;<br />
$a[]=&#8221;Unni&#8221;;<br />
$a[]=&#8221;Violet&#8221;;<br />
$a[]=&#8221;Liza&#8221;;<br />
$a[]=&#8221;Elizabeth&#8221;;<br />
$a[]=&#8221;Ellen&#8221;;<br />
$a[]=&#8221;Wenche&#8221;;<br />
$a[]=&#8221;Vicky&#8221;;</p>
<p>//get the q parameter from URL<br />
$q=$_GET["q"];</p>
<p>//lookup all hints from array if length of q&gt;0<br />
if (strlen($q) &gt; 0)<br />
{<br />
$hint=&#8221;";<br />
for($i=0; $i&lt;count($a); $i++)<br />
{<br />
if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q))))<br />
{<br />
if ($hint==&#8221;")<br />
{<br />
$hint=$a[$i];<br />
}<br />
else<br />
{<br />
$hint=$hint.&#8221; , &#8220;.$a[$i];<br />
}<br />
}<br />
}<br />
}</p>
<p>// Set output to &#8220;no suggestion&#8221; if no hint were found<br />
// or to the correct values<br />
if ($hint == &#8220;&#8221;)<br />
{<br />
$response=&#8221;no suggestion&#8221;;<br />
}<br />
else<br />
{<br />
$response=$hint;<br />
}</p>
<p>//output the response<br />
echo $response;<br />
?&gt;</span></p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/i-always-like-to-have-a-nice-simple-ajax-example-on-hand-you-never-know/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Expat XML Parser refresher</title>
		<link>http://alexyz.com/php-expat-xml-parser-refresher/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=php-expat-xml-parser-refresher</link>
		<comments>http://alexyz.com/php-expat-xml-parser-refresher/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 04:40:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=406</guid>
		<description><![CDATA[from: <a href="http://w3schools.com/php/php_xml_parser_expat.asp">http://w3schools.com/php/php_xml_parser_expat.asp</a>

<strong>example XML</strong>

&#60;?xml version="1.0" encoding="ISO-8859-1"?&#62;
&#60;note&#62;
&#60;to&#62;Tove&#60;/to&#62;
&#60;from&#62;Jani&#60;/from&#62;
&#60;heading&#62;Reminder&#60;/heading&#62;
&#60;body&#62;Don't forget me this weekend!&#60;/body&#62;
&#60;/note&#62;

<strong>script to parse:</strong>

<span style="color: #ff0000;">&#60;?php
//Initialize the XML parser
$parser=xml_parser_create();

//Function to use at the start of an element</span> <span style="color: #ff0000;">
function start($parser,$element_name,$element_attrs)
{
switch($element_name)
{
case "NOTE":
echo "-- Note --&#60;br /&#62;";
break;
case "TO":
echo "To: ";
break;
case "FROM":
echo "From: ";
break;
case "HEADING":
echo "Heading: ";
break;
case "BODY":
echo "Message: ";
}
}

//Function to use at the end of an element</span> <span style="color: #ff0000;">
function stop($parser,$element_name)
{
echo "&#60;br /&#62;";
}

//Function to use when finding character data</span> <span style="color: #ff0000;">
function char($parser,$data)
{
echo $data;
}

//Specify element handler</span> <span style="color: #ff0000;">
xml_set_element_handler($parser,"start","stop");

//Specify data handler</span> <span style="color:  ... <a href="http://alexyz.com/php-expat-xml-parser-refresher/">READ MORE</a>]]></description>
			<content:encoded><![CDATA[<p>from: <a href="http://w3schools.com/php/php_xml_parser_expat.asp">http://w3schools.com/php/php_xml_parser_expat.asp</a></p>
<p><strong>example XML</strong></p>
<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;ISO-8859-1&#8243;?&gt;<br />
&lt;note&gt;<br />
&lt;to&gt;Tove&lt;/to&gt;<br />
&lt;from&gt;Jani&lt;/from&gt;<br />
&lt;heading&gt;Reminder&lt;/heading&gt;<br />
&lt;body&gt;Don&#8217;t forget me this weekend!&lt;/body&gt;<br />
&lt;/note&gt;</p>
<p><strong>script to parse:</strong></p>
<p><span style="color: #ff0000;">&lt;?php<br />
//Initialize the XML parser<br />
$parser=xml_parser_create();</p>
<p>//Function to use at the start of an element</span> <span style="color: #ff0000;"><br />
function start($parser,$element_name,$element_attrs)<br />
{<br />
switch($element_name)<br />
{<br />
case &#8220;NOTE&#8221;:<br />
echo &#8220;&#8211; Note &#8211;&lt;br /&gt;&#8221;;<br />
break;<br />
case &#8220;TO&#8221;:<br />
echo &#8220;To: &#8220;;<br />
break;<br />
case &#8220;FROM&#8221;:<br />
echo &#8220;From: &#8220;;<br />
break;<br />
case &#8220;HEADING&#8221;:<br />
echo &#8220;Heading: &#8220;;<br />
break;<br />
case &#8220;BODY&#8221;:<br />
echo &#8220;Message: &#8220;;<br />
}<br />
}</p>
<p>//Function to use at the end of an element</span> <span style="color: #ff0000;"><br />
function stop($parser,$element_name)<br />
{<br />
echo &#8220;&lt;br /&gt;&#8221;;<br />
}</p>
<p>//Function to use when finding character data</span> <span style="color: #ff0000;"><br />
function char($parser,$data)<br />
{<br />
echo $data;<br />
}</p>
<p>//Specify element handler</span> <span style="color: #ff0000;"><br />
xml_set_element_handler($parser,&#8221;start&#8221;,&#8221;stop&#8221;);</p>
<p>//Specify data handler</span> <span style="color: #ff0000;"><br />
xml_set_character_data_handler($parser,&#8221;char&#8221;);</p>
<p>//Open XML file</span> <span style="color: #ff0000;"><br />
$fp=fopen(&#8220;test.xml&#8221;,&#8221;r&#8221;);</p>
<p>//Read data</span> <span style="color: #ff0000;"><br />
while ($data=fread($fp,4096))<br />
{<br />
xml_parse($parser,$data,feof($fp)) or<br />
die (sprintf(&#8220;XML Error: %s at line %d&#8221;,<br />
xml_error_string(xml_get_error_code($parser)),<br />
xml_get_current_line_number($parser)));<br />
}</p>
<p>//Free the XML parser</span> <span style="color: #ff0000;"><br />
xml_parser_free($parser);<br />
?&gt;</span></p>
<p><strong><span style="color: #000000;">output:</span></strong></p>
<p>&#8211; Note &#8211;<br />
To: Tove<br />
From: Jani<br />
Heading: Reminder<br />
Message: Don&#8217;t forget me this weekend!</p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/php-expat-xml-parser-refresher/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL refresher</title>
		<link>http://alexyz.com/mysql-refresher/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mysql-refresher</link>
		<comments>http://alexyz.com/mysql-refresher/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 04:28:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=403</guid>
		<description><![CDATA[datatypes:

<a href="http://w3schools.com/sql/sql_datatypes.asp">http://w3schools.com/sql/sql_datatypes.asp</a>

Order results by 2 columns:

<span style="color: #888888;">SELECT column_name(s)
FROM table_name
ORDER BY column1, column2</span>

<span style="color: #888888;"><span style="color: #000000;">Simple delete:</span></span>

<span style="color: #ff0000;">&#60;?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
mysql_query("DELETE FROM Persons WHERE LastName='Griffin'");
mysql_close($con);
?&#62;</span>]]></description>
			<content:encoded><![CDATA[<p>datatypes:</p>
<p><a href="http://w3schools.com/sql/sql_datatypes.asp">http://w3schools.com/sql/sql_datatypes.asp</a></p>
<p>Order results by 2 columns:</p>
<p><span style="color: #888888;">SELECT column_name(s)<br />
FROM table_name<br />
ORDER BY column1, column2</span></p>
<p><span style="color: #888888;"><span style="color: #000000;">Simple delete:</span></span></p>
<p><span style="color: #ff0000;">&lt;?php<br />
$con = mysql_connect(&#8220;localhost&#8221;,&#8221;peter&#8221;,&#8221;abc123&#8243;);<br />
if (!$con)<br />
{<br />
die(&#8216;Could not connect: &#8216; . mysql_error());<br />
}<br />
mysql_select_db(&#8220;my_db&#8221;, $con);<br />
mysql_query(&#8220;DELETE FROM Persons WHERE LastName=&#8217;Griffin&#8217;&#8221;);<br />
mysql_close($con);<br />
?&gt;</span></p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/mysql-refresher/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP custom error handling, log and email and user messaging</title>
		<link>http://alexyz.com/php-custom-error-handling-log-and-email-and-user-messaging/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=php-custom-error-handling-log-and-email-and-user-messaging</link>
		<comments>http://alexyz.com/php-custom-error-handling-log-and-email-and-user-messaging/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 03:33:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=399</guid>
		<description><![CDATA[<a href="http://w3schools.com/php/php_error.asp">http://w3schools.com/php/php_error.asp</a>

&#60;?php
//error handler function
function customError($errno, $errstr)
{
echo "&#60;b&#62;Error:&#60;/b&#62; [$errno] $errstr&#60;br /&#62;";
echo "Webmaster has been notified";
error_log("Error: [$errno] $errstr",1,
"someone@example.com","From: webmaster@example.com");
}

//set error handler
set_error_handler("customError",E_USER_WARNING);

//trigger error
$test=2;
if ($test&#62;1)
{
trigger_error("Value must be 1 or below",E_USER_WARNING);
}
?&#62;]]></description>
			<content:encoded><![CDATA[<p><a href="http://w3schools.com/php/php_error.asp">http://w3schools.com/php/php_error.asp</a></p>
<p>&lt;?php<br />
//error handler function<br />
function customError($errno, $errstr)<br />
{<br />
echo &#8220;&lt;b&gt;Error:&lt;/b&gt; [$errno] $errstr&lt;br /&gt;&#8221;;<br />
echo &#8220;Webmaster has been notified&#8221;;<br />
error_log(&#8220;Error: [$errno] $errstr&#8221;,1,<br />
&#8220;someone@example.com&#8221;,&#8221;From: webmaster@example.com&#8221;);<br />
}</p>
<p>//set error handler<br />
set_error_handler(&#8220;customError&#8221;,E_USER_WARNING);</p>
<p>//trigger error<br />
$test=2;<br />
if ($test&gt;1)<br />
{<br />
trigger_error(&#8220;Value must be 1 or below&#8221;,E_USER_WARNING);<br />
}<br />
?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/php-custom-error-handling-log-and-email-and-user-messaging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>open a file and read it line by line or character by character reference refresher</title>
		<link>http://alexyz.com/open-a-file-and-read-it-line-by-line-or-character-by-character-reference-refresher/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=open-a-file-and-read-it-line-by-line-or-character-by-character-reference-refresher</link>
		<comments>http://alexyz.com/open-a-file-and-read-it-line-by-line-or-character-by-character-reference-refresher/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 02:49:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=396</guid>
		<description><![CDATA[from <a href="http://w3schools.com/php/php_file.asp">http://w3schools.com/php/php_file.asp</a>
<h2>Reading a File Line by Line</h2>
The fgets() function is used to read a single line from a file.

<strong>Note:</strong> After a call to this function the file pointer has moved to the next  line.
<h3>Example</h3>
The example below reads a file line by line, until the end of  file is reached:
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>&#60;?php
$file = fopen("welcome.txt", "r") or exit("Unable to open file!");
//Output a line of the file until the end is reached
while(!feof($file))
{
echo fgets($file). "&#60;br /&#62;";
}
fclose($file);
?&#62;</td>
</tr>
</tbody>
</table>
<hr />
<h2>Reading a File  ... <a href="http://alexyz.com/open-a-file-and-read-it-line-by-line-or-character-by-character-reference-refresher/">READ MORE</a>]]></description>
			<content:encoded><![CDATA[<p>from <a href="http://w3schools.com/php/php_file.asp">http://w3schools.com/php/php_file.asp</a></p>
<h2>Reading a File Line by Line</h2>
<p>The fgets() function is used to read a single line from a file.</p>
<p><strong>Note:</strong> After a call to this function the file pointer has moved to the next  line.</p>
<h3>Example</h3>
<p>The example below reads a file line by line, until the end of  file is reached:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>&lt;?php<br />
$file = fopen(&#8220;welcome.txt&#8221;, &#8220;r&#8221;) or exit(&#8220;Unable to open file!&#8221;);<br />
//Output a line of the file until the end is reached<br />
while(!feof($file))<br />
{<br />
echo fgets($file). &#8220;&lt;br /&gt;&#8221;;<br />
}<br />
fclose($file);<br />
?&gt;</td>
</tr>
</tbody>
</table>
<hr />
<h2>Reading a File Character by Character</h2>
<p>The fgetc() function is used to read a single character from a file.</p>
<p><strong>Note:</strong> After a call to this function the file pointer moves to the next character.</p>
<h3>Example</h3>
<p>The example below reads a file character by character, until the end of  file is reached:</p>
<p>&lt;?php<br />
$file=fopen(&#8220;welcome.txt&#8221;,&#8221;r&#8221;) or exit(&#8220;Unable to open file!&#8221;);<br />
while (!feof($file))<br />
{<br />
echo fgetc($file);<br />
}<br />
fclose($file);<br />
?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/open-a-file-and-read-it-line-by-line-or-character-by-character-reference-refresher/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>date() and timestamp refresher</title>
		<link>http://alexyz.com/date-and-timestamp-refresher/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=date-and-timestamp-refresher</link>
		<comments>http://alexyz.com/date-and-timestamp-refresher/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 02:42:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=393</guid>
		<description><![CDATA[<span style="color: #ff0000;">date(<em>format</em>,<em>timestamp</em>)</span>

format is required, example:

<span style="color: #ff0000;">date("Y-m-d")</span>

of course, Y, m, and d stand for Year, month, day, and they may be separated by whatever you like, so the above example returns 2010-07-27, while <span style="color: #ff0000;">date("m/d/Y")</span> returns 07/27/2010

now for the <span style="color: #ff0000;">timestamp</span> parameter

MAKE what should be supplied for the <span style="color: #ff0000;">timestamp</span>, with <span style="color: #ff0000;">mktime(hour,minute,second,month,day,year,is_dst)</span>

<span style="color: #ff0000;"><span style="color: #000000;"><span style="color: #ff0000;">$tomorrow = mktime(0,0,0,date("m"),date("d")+1,date("Y"))</span></span></span>

<span style="color: #ff0000;">date("Y/m/d",$tomorrow) <span style="color: #000000;">returns tomorrow!</span>
</span>]]></description>
			<content:encoded><![CDATA[<p><span style="color: #ff0000;">date(<em>format</em>,<em>timestamp</em>)</span></p>
<p>format is required, example:</p>
<p><span style="color: #ff0000;">date(&#8220;Y-m-d&#8221;)</span></p>
<p>of course, Y, m, and d stand for Year, month, day, and they may be separated by whatever you like, so the above example returns 2010-07-27, while <span style="color: #ff0000;">date(&#8220;m/d/Y&#8221;)</span> returns 07/27/2010</p>
<p>now for the <span style="color: #ff0000;">timestamp</span> parameter</p>
<p>MAKE what should be supplied for the <span style="color: #ff0000;">timestamp</span>, with <span style="color: #ff0000;">mktime(hour,minute,second,month,day,year,is_dst)</span></p>
<p><span style="color: #ff0000;"><span style="color: #000000;"><span style="color: #ff0000;">$tomorrow = mktime(0,0,0,date(&#8220;m&#8221;),date(&#8220;d&#8221;)+1,date(&#8220;Y&#8221;))</span></span></span></p>
<p><span style="color: #ff0000;">date(&#8220;Y/m/d&#8221;,$tomorrow) <span style="color: #000000;">returns tomorrow!</span><br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/date-and-timestamp-refresher/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I never seem to use the &#8220;do&#8230;while&#8221; loop so here it is just to remind me&#8230;</title>
		<link>http://alexyz.com/i-never-seem-to-use-the-do-while-loop-so-here-it-is-just-to-remind-me/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=i-never-seem-to-use-the-do-while-loop-so-here-it-is-just-to-remind-me</link>
		<comments>http://alexyz.com/i-never-seem-to-use-the-do-while-loop-so-here-it-is-just-to-remind-me/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 02:36:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=391</guid>
		<description><![CDATA[example from :

<a href="http://w3schools.com/php/php_looping.asp">http://w3schools.com/php/php_looping.asp</a>

<span style="color: #ff0000;">&#60;?php</span>
$i=1;
do
{
$i++;
echo "The number is " . $i . "&#60;br /&#62;";
}
while ($i&#60;=5);
<span style="color: #ff0000;">?&#62;</span>

<span style="color: #ff0000;"><span style="color: #000000;">Key difference, it ALWAYS executes once, and THEN evaluates</span>
</span>]]></description>
			<content:encoded><![CDATA[<p>example from :</p>
<p><a href="http://w3schools.com/php/php_looping.asp">http://w3schools.com/php/php_looping.asp</a></p>
<p><span style="color: #ff0000;">&lt;?php</span><br />
$i=1;<br />
do<br />
{<br />
$i++;<br />
echo &#8220;The number is &#8221; . $i . &#8220;&lt;br /&gt;&#8221;;<br />
}<br />
while ($i&lt;=5);<br />
<span style="color: #ff0000;">?&gt;</span></p>
<p><span style="color: #ff0000;"><span style="color: #000000;">Key difference, it ALWAYS executes once, and THEN evaluates</span><br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/i-never-seem-to-use-the-do-while-loop-so-here-it-is-just-to-remind-me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>variable variables PHP awesome</title>
		<link>http://alexyz.com/variable-variable-php-awesome/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=variable-variable-php-awesome</link>
		<comments>http://alexyz.com/variable-variable-php-awesome/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 23:21:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=388</guid>
		<description><![CDATA[variable variables create variables with variable names

<code>$Bar = "a";
$Foo = "Bar";
$World = "Foo";
$Hello = "World";
$a = "Hello";</code>

$a; //Returns Hello
$$a; //Returns World
$$$a; //Returns Foo
$$$$a; //Returns Bar
$$$$$a; //Returns a

$$$$$$a; //Returns Hello
$$$$$$$a; //Returns World

//... and so on ...//

From:

<a href="http://www.php.net/manual/en/language.variables.variable.php">http://www.php.net/manual/en/language.variables.variable.php</a>]]></description>
			<content:encoded><![CDATA[<p>variable variables create variables with variable names</p>
<p><code>$Bar = "a";<br />
$Foo = "Bar";<br />
$World = "Foo";<br />
$Hello = "World";<br />
$a = "Hello";</code></p>
<p>$a; //Returns Hello<br />
$$a; //Returns World<br />
$$$a; //Returns Foo<br />
$$$$a; //Returns Bar<br />
$$$$$a; //Returns a</p>
<p>$$$$$$a; //Returns Hello<br />
$$$$$$$a; //Returns World</p>
<p>//&#8230; and so on &#8230;//</p>
<p>From:</p>
<p><a href="http://www.php.net/manual/en/language.variables.variable.php">http://www.php.net/manual/en/language.variables.variable.php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/variable-variable-php-awesome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>using a PHP variable in a MySQL IN batch query example</title>
		<link>http://alexyz.com/using-a-php-variable-in-a-mysql-query-example/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=using-a-php-variable-in-a-mysql-query-example</link>
		<comments>http://alexyz.com/using-a-php-variable-in-a-mysql-query-example/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 23:13:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=383</guid>
		<description><![CDATA[<span style="color: #800080;">Note the 's</span>

<strong>$product_list</strong> <span style="color: #339966;">= "</span><span style="color: #ff0000;">'1869', '1929', '549', '189', '419', '176', '192', '310', '291', '514', '1643', '1033'</span><span style="color: #339966;">"</span><span style="color: #339966;">;</span>

<strong>$db_name</strong> = "dbName"<span style="color: #339966;">;</span>
<span style="color: #993366;">//conditional platform logic to support multiple connection scenarios</span>

<span style="color: #339966;">switch(</span><span style="color: #ff0000;">$_SERVER</span>['HTTP_HOST']<span style="color: #339966;">)</span>
<span style="color: #339966;">{</span>
<span style="color: #339966;">case</span> 'localhost'<span style="color: #339966;">:</span>
<strong>$db_host</strong> = "localhost"<span style="color: #339966;">;</span>
<strong>$db_username</strong> = "userName"<span style="color: #339966;">;</span>
<strong>$db_password</strong> = "Password"<span style="color: #339966;">;</span>
<strong>$dblink</strong> = <span style="color: #ff0000;">mysql_connect</span> (<strong>$db_host</strong>, <strong>$db_username</strong>, <strong>$db_password</strong>);
<span style="color: #ff0000;">mysql_select_db</span>(<strong>$db_name</strong>, <strong>$dblink</strong>);
<span style="color: #339966;">break;</span>
<span style="color: #339966;">case</span> 'www-staging.site.com'<span style="color:  ... <a href="http://alexyz.com/using-a-php-variable-in-a-mysql-query-example/">READ MORE</a>]]></description>
			<content:encoded><![CDATA[<p><span style="color: #800080;">Note the &#8216;s</span></p>
<p><strong>$product_list</strong> <span style="color: #339966;">= &#8220;</span><span style="color: #ff0000;">&#8217;1869&#8242;, &#8217;1929&#8242;, &#8217;549&#8242;, &#8217;189&#8242;, &#8217;419&#8242;, &#8217;176&#8242;, &#8217;192&#8242;, &#8217;310&#8242;, &#8217;291&#8242;, &#8217;514&#8242;, &#8217;1643&#8242;, &#8217;1033&#8242;</span><span style="color: #339966;">&#8220;</span><span style="color: #339966;">;</span></p>
<p><strong>$db_name</strong> = &#8220;dbName&#8221;<span style="color: #339966;">;</span><br />
<span style="color: #993366;">//conditional platform logic to support multiple connection scenarios</span></p>
<p><span style="color: #339966;">switch(</span><span style="color: #ff0000;">$_SERVER</span>['HTTP_HOST']<span style="color: #339966;">)</span><br />
<span style="color: #339966;">{</span><br />
<span style="color: #339966;">case</span> &#8216;localhost&#8217;<span style="color: #339966;">:</span><br />
<strong>$db_host</strong> = &#8220;localhost&#8221;<span style="color: #339966;">;</span><br />
<strong>$db_username</strong> = &#8220;userName&#8221;<span style="color: #339966;">;</span><br />
<strong>$db_password</strong> = &#8220;Password&#8221;<span style="color: #339966;">;</span><br />
<strong>$dblink</strong> = <span style="color: #ff0000;">mysql_connect</span> (<strong>$db_host</strong>, <strong>$db_username</strong>, <strong>$db_password</strong>);<br />
<span style="color: #ff0000;">mysql_select_db</span>(<strong>$db_name</strong>, <strong>$dblink</strong>);<br />
<span style="color: #339966;">break;</span><br />
<span style="color: #339966;">case</span> &#8216;www-staging.site.com&#8217;<span style="color: #339966;">: break;</span><br />
<span style="color: #339966;">case</span> &#8216;www.site.com&#8217;<span style="color: #339966;">:</span><br />
<span style="color: #339966;">include(</span>&#8216;/var/www/includes/connection_script.php&#8217;<span style="color: #339966;">);</span><br />
<span style="color: #339966;">break;</span><br />
<span style="color: #339966;">}</span></p>
<p><strong>$result</strong> = <span style="color: #ff0000;">mysql_query(&#8221;<br />
SELECT<br />
product_id,<br />
product_name<br />
FROM<br />
tableNameHere<br />
WHERE<br />
product_id IN</span><span style="color: #ff0000;"> (&#8220;<span style="color: #000000;">.</span></span><strong>$product_list</strong>.<span style="color: #ff0000;">&#8220;)</span><br />
<span style="color: #ff0000;">&#8220;)</span><span style="color: #339966;">;</span><br />
<span style="color: #339966;">if (!<strong>$result</strong>) { echo &#8220;</span>Could not successfully run query ($sql) from DB:<span style="color: #339966;"> &#8220;</span> . <span style="color: #ff0000;">mysql_error</span>()<span style="color: #339966;">; exit; }</span></p>
<p><span style="color: #993366;"><br />
//let&#8217;s break out the resource so that it can be singularly requested when needed</span></p>
<p><span style="color: #339966;">while(</span><strong>$one</strong> = <span style="color: #ff0000;">mysql_fetch_assoc</span><span style="color: #339966;">(</span><strong>$result</strong><span style="color: #339966;">))</span><br />
<span style="color: #339966;">{</span><br />
<strong>$prod_id</strong> <span style="color: #339966;">=</span> <strong>$one</strong>['<span style="color: #ff0000;">product_id</span>']<span style="color: #339966;">;</span><br />
<strong>$product_name[</strong><strong>$prod_id]</strong> <span style="color: #339966;">=</span> <strong>$one</strong>['<span style="color: #ff0000;">product_name</span>']<span style="color: #339966;">;</span><br />
<span style="color: #339966;">}<br />
@</span><span style="color: #ff0000;">mysql_close</span>(<strong>$dblink</strong>)<span style="color: #339966;">;</span></p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/using-a-php-variable-in-a-mysql-query-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash Session Cookie SharedObject</title>
		<link>http://alexyz.com/flash-session-cookie-sharedobject/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=flash-session-cookie-sharedobject</link>
		<comments>http://alexyz.com/flash-session-cookie-sharedobject/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 18:11:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=377</guid>
		<description><![CDATA[<a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/net/SharedObject.html">http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/net/SharedObject.html</a>

<a href="http://en.wikipedia.org/wiki/Local_Shared_Object">http://en.wikipedia.org/wiki/Local_Shared_Object</a>

<a href="http://www.adobe.com/support/flash/action_scripts/actionscript_tutorial/actionscript_tutorial05.html">http://www.adobe.com/support/flash/action_scripts/actionscript_tutorial/actionscript_tutorial05.html</a>

<strong>to change settings:</strong>
<p style="padding-left: 30px;">right click on any flash swf</p>
<p style="padding-left: 30px;">or</p>
<p style="padding-left: 30px;"><a href="http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager02.html">http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager02.html</a></p>
<p style="padding-left: 30px;"></p>
<strong>stored here:</strong>
<ul>
	<li><em>Windows XP:</em>
<ul>
	<li>For Web sites: %APPDATA%\Macromedia\Flash  Player\#SharedObjects\&#60;random code&#62;\&#60;domain&#62;\&#60;path -  maybe°&#62;\&#60;object name&#62;.sol</li>
	<li>And Also: %APPDATA%\Macromedia\Flash  Player\macromedia.com\support\flashplayer\sys</li>
</ul>
</li>
</ul>
<ul>
	<li><em>Windows Vista</em> and later:
<ul>
	<li>For Web sites: %APPDATA%\Macromedia\Flash  Player\#SharedObjects\&#60;random code&#62;\&#60;domain&#62;\&#60;path -  maybe°&#62;\&#60;object name&#62;.sol</li>
	<li>And also: %APPDATA%\Macromedia\Flash  Player\macromedia.com\support\flashplayer\sys</li>
	<li>For AIR Applications: unknown, likely similar to the above</li>
</ul>
</li>
</ul>]]></description>
			<content:encoded><![CDATA[<p><a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/net/SharedObject.html">http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/net/SharedObject.html</a></p>
<p><a href="http://en.wikipedia.org/wiki/Local_Shared_Object">http://en.wikipedia.org/wiki/Local_Shared_Object</a></p>
<p><a href="http://www.adobe.com/support/flash/action_scripts/actionscript_tutorial/actionscript_tutorial05.html">http://www.adobe.com/support/flash/action_scripts/actionscript_tutorial/actionscript_tutorial05.html</a></p>
<p><strong>to change settings:</strong></p>
<p style="padding-left: 30px;">right click on any flash swf</p>
<p style="padding-left: 30px;">or</p>
<p style="padding-left: 30px;"><a href="http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager02.html">http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager02.html</a></p>
<p style="padding-left: 30px;">
<p><strong>stored here:</strong></p>
<ul>
<li><em>Windows XP:</em>
<ul>
<li>For Web sites: %APPDATA%\Macromedia\Flash  Player\#SharedObjects\&lt;random code&gt;\&lt;domain&gt;\&lt;path &#8211;  maybe°&gt;\&lt;object name&gt;.sol</li>
<li>And Also: %APPDATA%\Macromedia\Flash  Player\macromedia.com\support\flashplayer\sys</li>
</ul>
</li>
</ul>
<ul>
<li><em>Windows Vista</em> and later:
<ul>
<li>For Web sites: %APPDATA%\Macromedia\Flash  Player\#SharedObjects\&lt;random code&gt;\&lt;domain&gt;\&lt;path &#8211;  maybe°&gt;\&lt;object name&gt;.sol</li>
<li>And also: %APPDATA%\Macromedia\Flash  Player\macromedia.com\support\flashplayer\sys</li>
<li>For AIR Applications: unknown, likely similar to the above</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/flash-session-cookie-sharedobject/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP sprintf() quick example</title>
		<link>http://alexyz.com/php-sprintf-quick-example/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=php-sprintf-quick-example</link>
		<comments>http://alexyz.com/php-sprintf-quick-example/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 22:34:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=476</guid>
		<description><![CDATA[<strong>$template</strong> = '&#60;div class="%designIt"&#62;&#60;img src="%s" /&#62;&#60;br /&#62;%s&#60;br /&#62;by %s&#60;/div&#62;';
<strong>$designIt</strong> = "className";
<strong>$imgSrc</strong> = "http://www.imageLivesHere.com/yo.jpg";
<strong>$copyText</strong> = "What fabulous and interesting placeholder copy!";
<strong>$sourceAuthor</strong> = "Me";
<span style="color: #ff0000;"><strong>$altogetherNow</strong></span> = sprintf ( <strong>$template</strong>, <strong>$imgSrc</strong>, <strong>$linkText</strong>, <span style="color: #000000;"><strong>$sourceAuthor</strong></span><span style="color: #ff0000;">)</span>;

<span style="color: #ff00ff;">//Result</span>

&#60;div class="<span style="color: #ff0000;">className</span>"&#62;
&#60;img src="<span style="color: #ff0000;">http://www.imageLivesHere.com/yo.jpg</span>"/&#62;
&#60;br /&#62;
<span style="color: #ff0000;">What fabulous and interesting placeholder copy!</span>
&#60;br /&#62;
by <span style="color: #ff0000;">Me</span>
&#60;/div&#62;]]></description>
			<content:encoded><![CDATA[<p><strong>$template</strong> = &#8216;&lt;div class=&#8221;%designIt&#8221;&gt;&lt;img src=&#8221;%s&#8221; /&gt;&lt;br /&gt;%s&lt;br /&gt;by %s&lt;/div&gt;&#8217;;<br />
<strong>$designIt</strong> = &#8220;className&#8221;;<br />
<strong>$imgSrc</strong> = &#8220;http://www.imageLivesHere.com/yo.jpg&#8221;;<br />
<strong>$copyText</strong> = &#8220;What fabulous and interesting placeholder copy!&#8221;;<br />
<strong>$sourceAuthor</strong> = &#8220;Me&#8221;;<br />
<span style="color: #ff0000;"><strong>$altogetherNow</strong></span> = sprintf ( <strong>$template</strong>, <strong>$imgSrc</strong>, <strong>$linkText</strong>, <span style="color: #000000;"><strong>$sourceAuthor</strong></span><span style="color: #ff0000;">)</span>;</p>
<p><span style="color: #ff00ff;">//Result</span></p>
<p>&lt;div class=&#8221;<span style="color: #ff0000;">className</span>&#8220;&gt;<br />
&lt;img src=&#8221;<span style="color: #ff0000;">http://www.imageLivesHere.com/yo.jpg</span>&#8220;/&gt;<br />
&lt;br /&gt;<br />
<span style="color: #ff0000;">What fabulous and interesting placeholder copy!</span><br />
&lt;br /&gt;<br />
by <span style="color: #ff0000;">Me</span><br />
&lt;/div&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/php-sprintf-quick-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Close Fancybox from within, old (1.2) and new (1.3)</title>
		<link>http://alexyz.com/close-fancybox-from-within-old-1-2-and-new-1-3/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=close-fancybox-from-within-old-1-2-and-new-1-3</link>
		<comments>http://alexyz.com/close-fancybox-from-within-old-1-2-and-new-1-3/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 17:48:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://alexyz.com/?p=488</guid>
		<description><![CDATA[In 1.2 this worked:

onclick="<span style="color: #ff0000;">$("#fancy_outer",window.parent.document).hide(); $("#fancy_overlay",window.parent.document).hide();</span>"

1.3+ this has changed to:

onclick="<span style="color: #ff0000;">parent.$.fancybox.close();</span>"]]></description>
			<content:encoded><![CDATA[<p>In 1.2 this worked:</p>
<p>onclick=&#8221;<span style="color: #ff0000;">$(&#8220;#fancy_outer&#8221;,window.parent.document).hide(); $(&#8220;#fancy_overlay&#8221;,window.parent.document).hide();</span>&#8221;</p>
<p>1.3+ this has changed to:</p>
<p>onclick=&#8221;<span style="color: #ff0000;">parent.$.fancybox.close();</span>&#8220;</p>
]]></content:encoded>
			<wfw:commentRss>http://alexyz.com/close-fancybox-from-within-old-1-2-and-new-1-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
