jump to navigation

Zend_Mail attachment missing line October 14, 2008

Posted by ordinarywebguy in PHP, Zend Framework.
3 comments

If you may ever find hard to make it work using Zend_Mail file attachment and following the documentation here http://framework.zend.com/manual/en/zend.mail.attachments.html, there’s a missing line.

$mail = new Zend_Mail();

$at = $mail->createAttachment($myImage);
$at->type = ‘image/gif’;
$at->disposition = Zend_Mime::DISPOSITION_INLINE;
$at->encoding = Zend_Mime::ENCODING_8BIT;
$at->filename = ‘test.gif’;

$mail->send();

This should be

$mail = new Zend_Mail();

$myImage = file_get_contents($myImagePath);

$at = $mail->createAttachment($myImage);
$at->type = ‘image/gif’;
$at->disposition = Zend_Mime::DISPOSITION_INLINE;
$at->encoding = Zend_Mime::ENCODING_8BIT;
$at->filename = ‘test.gif’;

$mail->send();

This should work fine now. :)

Google Map Project October 13, 2008

Posted by ordinarywebguy in GMaps, Google Maps, Project Bookmark.
4 comments

Just a project bookmark.

My recent project at YW, Google Map API integration. It also utilizes jQuery, Zend_Db and Zend_Paginator.

Check it out here: http://88.191.66.96/index.php

Don’t use google chrome to open your google notebook October 13, 2008

Posted by ordinarywebguy in Google, Google Chrome, Google Notebook.
2 comments

Exactly as what the title is “Don’t use google chrome to open your google notebook” if you don’t want to lose data in your google notebook. It just happen to me after a click on my notebook section, the data on it was disappeared. And I can’t find a way how to retrieve it. :(

Google Chrome devs what is this going on? I can’t believe it happens. Errr…

Calendar with Zend_Date October 10, 2008

Posted by ordinarywebguy in PHP, PHP Frameworks, Zend Framework.
add a comment

As I’ve started to learn mvc zend framework, I’ve also started to use it as a stack framework library for some of my side projects. This module utilizes the Zend_Date component. See code:

class Calendar {
protected $year;
protected $month;
protected $day;
private $ctr = 0;

public function __construct() {
$date = Zend_Date::now();
$this->year = $date->get(Zend_Date::YEAR);
$this->month = $date->get(Zend_Date::MONTH);
$this->day = $date->get(Zend_Date::DAY);
unset($date);
}

public function viewMonth($year = NULL, $month = NULL, $computation = 0) {
$year = self::_setYear($year);
$month = self::_setMonth($month);

$date = new Zend_Date(
array(
‘year’ => $year,
‘month’ => $month,
‘day’ => 01
)
);

$monthDays = $date->get( Zend_Date::MONTH_DAYS );
$monthName = $date->get( Zend_Date::MONTH_NAME );
$firstWeekDay = $date->get( Zend_Date::WEEKDAY_DIGIT );

$html = ‘<table border=”1″ cellpadding=”4″ cellspacing=”0″>’;
$html .= ‘<tr><td colspan=”7″ align=”center”><b>’ . $monthName . ‘ ‘ . $year . ‘</b></td></tr>
<tr>
<td>Sun</td>
<td>Mon</td>
<td>Tue</td>
<td>Wed</td>
<td>Thu</td>
<td>Fri</td>
<td>Sat</td>
</tr>’;

$html .= ‘<tr>’;

$fWd = $firstWeekDay;
while ($fWd != 0) {
$html .= ‘<td>&nbsp;</td>’;
$fWd–;
}

for ($i = 1; $i <= $monthDays; $i++) {
$this->ctr++;
$is7 = $firstWeekDay + $i;
$html .= ‘<td>’.$i.’</td>’;

// Populate remaining <td>
if ($i == $monthDays) {
$date2 = new Zend_Date(
array(
‘year’ => $year,
‘month’ => $month,
‘day’ => $monthDays
)
);

$tds = $date2->get( Zend_Date::WEEKDAY_DIGIT );

while ($tds != 6) {
$html .= ‘<td>&nbsp;</td>’;
$tds++;
}

unset($date2);
}

if ( ($is7 % 7) == 0) {
$html .= “</tr>\n<tr>”;
}

}

$html .= ‘</tr>’;
$html .= ‘</table>’;

return $html;
}

public function viewYear($year = NULL, $month = NULL, $howManyMonths = NULL) {
$year = self::_setYear($year);
$howManyMonths = ($howManyMonths == NULL) ? 12 : (int) $howManyMonths;

$html = ‘<table border=”0″ cellpadding=”4″ cellspacing=”2″>’;

if ($month != NULL) {
$howManyMonths++;
}

$tmp = 1;
$col = 3;

for ($i = 1; $i <= $howManyMonths; $i++) {

if ($tmp == 1) {
$html .= ‘<tr valign=”top”><td>’;
} else {
$html .= ‘<td>’;
}

if ($month == NULL) {
$html .= self::viewMonth($year, $i, $i);
} else {
$html .= self::viewMonth($year, $month, $i);

if (($month % 12) == 0) {
$year++;
}
$month++;
}

if ($tmp == $col) {
$tmp = 1;
$html .= ‘</td></tr>’;
} else {
$tmp++;
$html .= ‘</td>’;
}
}

$html .= ‘</html>’;

return $html;
}

public function getMonth() {
return $this->month;
}

public function getDay() {
return $this->day;
}

public function getYear() {
return $this->year;
}

private function _setYear($year = NULL) {
return ($year == NULL) ? $this->year : $year;
}

private function _setMonth($month = NULL) {
return ($month == NULL) ? $this->month : $month;
}
}

$cal = new Calendar;
$month = isset($_REQUEST['month']) ? (int) $_REQUEST['month'] : $cal->getMonth();
$day = isset($_REQUEST['day']) ? (int) $_REQUEST['day'] : $cal->getDay();
$year = isset($_REQUEST['year']) ? (int) $_REQUEST['year'] : $cal->getYear();

echo $cal->viewMonth($year, $month);

It has still a lot of improvements. Feel free to modify it. ;)