Login   Register  
PHP Classes
elePHPant
Icontem

File: doc.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Md. Shahadat Hossain Khan Razon  >  Status splitter  >  doc.txt  >  Download  
File: doc.txt
Role: Documentation
Content type: text/plain
Description: documents & example
Class: Status splitter
Set and get binary masks associated to labels
Author: By
Last change:
Date: 2011-10-08 03:40
Size: 4,284 bytes
 

Contents

Class file image Download
in DOS directory file attribute bit position represent as Hex Value with bit positions (7 6 5 4 3 2 1 0). So, you can find all possible attribute just with two bit byte of data.

Consider following possible attributes:
Bit Positions	Hex	Description
0 0 0 0 0 0 0 1	01h	Read Only file
0 0 0 0 0 0 1 0	02h	Hidden file
0 0 0 0 0 1 0 0	04h	System file
0 0 0 0 1 0 0 0	08h	Volume Label
0 0 0 1 0 0 0 0	10h	Subdirectory
0 0 1 0 0 0 0 0	20h	Archive
0 1 0 0 0 0 0 0	40h	Reserved
1 0 0 0 0 0 0 0	80h	Reserved

Now this example demonstrate for any file with any following possible combination by only the following hex velue.
0 0 1 0 0 0 0 1	21h	Read Only, Archive
0 0 1 1 0 0 1 0	32h	Hidden, Subdirectory, Archive
0 0 1 0 0 1 1 1	27h	Read Only, Hidden, Archive



// list of all possible status along with their value
$st = new MyStatusSplitter();
// the key must be string and value must be numeric
$cmdstatus['read']=1;
$cmdstatus['insert']=2;
$cmdstatus['edit']=4;
$cmdstatus['delete']=8;
$st->setStatus($cmdstatus);
// now input the status and check output for combination
example # 1 -
input: 5 i.e. 4 + 1 i.e. edit + read
usage: $file_permission=$st->getStatus(5);
output: object array along with value (true/false)
sample:
$file_permission->read=true;
$file_permission->insert=false;
$file_permission->edit=true;
$file_permission->delete=false;
example # 2 -
input: 10 i.e. 8 + 2 i.e. delete + insert
usage: $file_permission=$st->getStatusForVal(10);
description: same result as $st->getStatus(10);
example # 3 -
input: $file_permission as object. basically output of this::getStatusForVal(5);
usage: $status_val=$st->getStatusVal($file_permission);
description: to save into database or any other media for future use
output: $status_val=5;
example # 4 -
$job_apply_method_array['post']=1;
$job_apply_method_array['walkon']=2;
$job_apply_method_array['online']=4;
$job_apply_method_array['employee']=8;
$job_apply_method_array['agent']=16;
$job_apply_method_text['post']='Via Post/Courier';
$job_apply_method_text['walkon']='Walkon Interview';
$job_apply_method_text['online']='Apply Online';
$job_apply_method_text['employee']='Through Current Employee';
$job_apply_method_text['agent']='Through our Listed Recruiting Agent';

$st->setStatusLabel($job_apply_method_text);
unset($job_apply_method_array['agent']);
unset($job_apply_method_text['agent']);
$arr=$st->getStatusLabel($job_apply_method_text, $job_apply_method_array);
echo('<pre>'.print_r($arr, true).'</pre>');
echo('<br /><br />'.$st->getStatusLabelCSV(5).'<br /><br />');
echo('<pre>'.print_r($st->getStatusLabelArray(), true).'</pre><br />');
echo('<pre>'.print_r($st->getStatusLabelArray(9), true).'</pre><br />');
echo('<pre>'.print_r($st->getStatusLabelArray(12, false), true).'</pre><br />');
$newst=$st->getFilteredArray(11, $job_apply_method_text, $job_apply_method_array);
echo('<pre>'.print_r($newst, true).'</pre><br />');
$stX=new MyStatusSplitter($newst['value']);
$stX->setStatusLabel($newst['label']);
echo('<pre>'.print_r($stX->getStatusLabelArray(), true).'</pre><br />');
echo('<pre>'.print_r($stX->getStatusLabelArray(9), true).'</pre><br />');
echo('<pre>'.print_r($stX->getStatusLabelArray(12), true).'</pre><br />');

output:
Array
(
	[1] => Via Post/Courier
	[2] => Walkon Interview
	[4] => Apply Online
	[8] => Through Current Employee
)

Via Post/Courier, Apply Online

Array
(
	[1] => Via Post/Courier
	[2] => Walkon Interview
	[4] => Apply Online
	[8] => Through Current Employee
	[16] => Through our Listed Recruiting Agent
)

Array
(
	[1] => Via Post/Courier
	[8] => Through Current Employee
)

Array
(
	[online] => Apply Online
	[employee] => Through Current Employee
)

Array
(
	[label] => Array
		(
			[post] => Via Post/Courier
			[walkon] => Walkon Interview
			[employee] => Through Current Employee
		)

	[value] => Array
		(
			[post] => 1
			[walkon] => 2
			[employee] => 8
		)

)

Array
(
	[1] => Via Post/Courier
	[2] => Walkon Interview
	[8] => Through Current Employee
)

Array
(
	[1] => Via Post/Courier
	[8] => Through Current Employee
)

Array
(
	[1] => Via Post/Courier
	[2] => Walkon Interview
	[8] => Through Current Employee
)