Archive

Archive for November, 2009

Taking apart a Panasonic Toughbook CF-51

November 27th, 2009 Ivan Villareal 5 comments

I’ve got in my hands a Panasonic Toughbook CF-51 and I didn’t went to work because of thanks giving day, so I was there waiting with this laptop and a little spare time, so to kill some time I’ve decided to disassemble the laptop and put it back together.

CF-51 Laptop

This are not instructions on how to take apart your laptop, this is only my experience and what I’ve learned, so here I go.

The first thing I did, was to remove the battery, and the cd, for the battery, I had to use a small screwdriver to pop the cover. Then I removed all the bottom screws, there were 13:

13 screws in the bottom

To remove the keyboard first I had to pop the frontal speakers cover, I’ve inserted a screwdriver beneath the lcd base, and carefully pull the cover:

Removing speakers cover

Speakers cover removed

Once the speakers cover was removed I’ve carefully picked up the keyboard to found that it is attached near the touchpad, it has a little white clip, that you need to pop in order to remove the cable.

Keyboard cable

Keyboard Cable ZoomIn

After removing the keyboard, I had to remove the screen to acces the main board, to do this there are 4 screws that support the screen, there are 2 on each side:

LCD base removal

After you remove the 4 screws you can move the screen but It has to be unplugged from the main board, and the connectors were located under the speakers, so I have to remove 7 more screws to have access to the lcd connectors:

Accessing the lcd Connectors 

Before removing the speakers and the touchpad section I had to unplug them, the connectors are located near the keyboard connector:

Speakers and touchpad connectors

Here is the top cover removed:

Top Cover Removed

From this point the only tricky part was finding 2 screws that are at the bottom of the lcd base, covered with a sticker:

cf51-disasemble8

I continued removing parts but there wasn’t any other tricky part, here are some more pics:

topviewnocover processorheater moboback fanremoval

Filling rtf templates with text and images using php

November 11th, 2009 Ivan Villareal 1 comment

We had a requirement to fill an rtf template file with some info from the system, the templates had some pictures that need to be retrieved from the system and placed in the rtf file.

The deadline for this requirement was very short, and the system where this was implemented was a large crm system so we didn’t had much time to dig up into the code to look for any useful class, so what we did was very simple.

Whenever a new document would be created, we get the template  related to that client opened the rtf file put it on a string and do a string replace for each field to be replaced, this is the code for this:

$this->keyVaribles = array
 (
 '<organization_name>' => $account->name,
 '<company_logos>'     => $img->getContent(),
 '<dates_of_event>'    => $account->date,
 '<link>'                     => $account->link,
 '<calendar>'              => $account->cal,
 '<signature>'             => $account->signature,
 );
 
// read file
$file = $bean->document_revision_id;
$handle = fopen ($file, 'r');
$content = fread($handle, filesize($file));
 
// replace content
foreach($this->keyVaribles as $from=> $to) {
   $content = str_replace($from, $to, $content);
}
 
// save file
file_put_contents($file, $content);
fclose($handle);

This worked for all the text fields, but there was one field  <company_logos> that needed an image to be inserted, I did little research on this, and used and old library (http://www.phprtf.com/) this didn’t worked very well, because it had only methods to save or send the generated rtf file, I needed only the image to be inserted so I did a class to convert an image into an rtf embeddable code, here it is:

 

<?php
 
/**
 *
 * This is the short Description for the Class
 *
 * This is the long description for the Class
 *
 * @author		Ivan Villareal
 * @version		$Id$
 * @package		Package
 * @subpackage	SubPackage
 *
 */
class image
{
	private $_cmInPoints = 0.026434;
	private $_twipsInCm  = 567;
	private $_imgFile;
	private $_width;
	private $_height;
	private $_defaultWidth;
	private $_defaultHeight;
 
	public function __construct($fileName, $width = 0, $height = 0)
	{
		$this->_imgFile = $fileName;
		$this->_width   = $width;
		$this->_height	= $height;
		$imgSize = getimagesize($fileName);
		$this->_defaultWidth  = $imgSize[0];
		$this->_defaultHeight = $imgSize[1];
	}
 
	private function _getWidth()
	{	
		if (!empty($this->_width)) {
			$width = $this->_width;
		} else if (!empty($this->_height)) {
			$width = ($this->_defaultWidth / $this->_defaultHeight) * $this->_height;
		} else {
			$width = $this->_defaultWidth * $this->_cmInPoints;
		}
		return round($width * $this->_twipsInCm);
	}
 
	private function _getHeight()
	{	
		if (!empty($this->_height)) {
			$height = $this->_height;
		} else if (!empty($this->_height)) {
			$height = ($this->_defaultHeight / $this->_defaultWidth) * $this->_width; 
		} else {
			$height = $this->_defaultHeight * $this->_cmInPoints;
		}
		return round($height * $this->_twipsInCm);
	}
 
 
	private	function _fileToHex() 
	{	  
	  	$f = fopen($this->_imgFile, "r");
		$string = fread($f, filesize($this->_imgFile));
		fclose($f);
 
		$str = '';
		for ($i = 0; $i < strlen($string); $i ++) {
			$hex = dechex( ord($string{$i}));
 
			if (strlen($hex) == 1) {			  
			  	$hex = '0'.$hex;
			}
 
			$str .= $hex;	
		}
 
		return $str;
	}
 
	public function getContent() 
	{	  
		$content = '{\pict';
		$content .= '\picwgoal'.$this->_getWidth();  		
		$content .= '\pichgoal'.$this->_getHeight();  
		$content .= $this->_fileToHex();		
		$content .= '}'; 			
		return $content;
	}
}

As you can see this class is very simple and you only have to instantiate it with the image file to be converted, and call the getContents method to get the rtf code for that image.

This worked pretty well so far, but I guess we need to do some more testing before deploying this.

 

Categories: Development Tags: