Click here to Skip to main content
15,895,142 members

Roger Keulen - Professional Profile



Summary

    Blog RSS
3
Debator
6
Organiser
606
Participant
0
Author
0
Authority
0
Editor
0
Enquirer
I like syntactic sugar in my coffee

Reputation

Weekly Data. Recent events may not appear immediately. For information on Reputation please see the FAQ.

Privileges

Members need to achieve at least one of the given member levels in the given reputation categories in order to perform a given action. For example, to store personal files in your account area you will need to achieve Platinum level in either the Author or Authority category. The "If Owner" column means that owners of an item automatically have the privilege. The member types column lists member types who gain the privilege regardless of their reputation level.

ActionAuthorAuthorityDebatorEditorEnquirerOrganiserParticipantIf OwnerMember Types
Have no restrictions on voting frequencysilversilversilversilver
Bypass spam checks when posting contentsilversilversilversilversilversilvergoldSubEditor, Mentor, Protector, Editor
Store personal files in your account areaplatinumplatinumSubEditor, Editor
Have live hyperlinks in your profilebronzebronzebronzebronzebronzebronzesilverSubEditor, Protector, Editor
Have the ability to include a biography in your profilebronzebronzebronzebronzebronzebronzesilverSubEditor, Protector, Editor
Edit a Question in Q&AsilversilversilversilverYesSubEditor, Protector, Editor
Edit an Answer in Q&AsilversilversilversilverYesSubEditor, Protector, Editor
Delete a Question in Q&AYesSubEditor, Protector, Editor
Delete an Answer in Q&AYesSubEditor, Protector, Editor
Report an ArticlesilversilversilversilverSubEditor, Mentor, Protector, Editor
Approve/Disapprove a pending ArticlegoldgoldgoldgoldSubEditor, Mentor, Protector, Editor
Edit other members' articlesSubEditor, Protector, Editor
Create an article without requiring moderationplatinumSubEditor, Mentor, Protector, Editor
Approve/Disapprove a pending QuestionProtector
Approve/Disapprove a pending AnswerProtector
Report a forum messagesilversilverbronzeProtector, Editor
Approve/Disapprove a pending Forum MessageProtector
Have the ability to send direct emails to members in the forumsProtector
Create a new tagsilversilversilversilver
Modify a tagsilversilversilversilver

Actions with a green tick can be performed by this member.


 
GeneralMY -> Generic.List(Of T) Math with a generic list in .net [modified] Pin
Roger Keulen13-Jun-11 6:35
Roger Keulen13-Jun-11 6:35 
GeneralPHP Simple List object [modified] Pin
Roger Keulen13-Jun-11 6:25
Roger Keulen13-Jun-11 6:25 
<?PHP

include_once('DList.php');

session_start();


class TestList extends cDList {
  private $TestPrivate = 'Prive';
  protected $TestProtected = 'Beveiligd';
  public $TestPublic = 'Publiek';

   // Everything starting with '_' we dont use...
  public $_DEZE_NIET_MEE_NEMEN = 'FOUT!';

  public function __construct($DATA) {
    parent::__construct($DATA);
    parent::Add('Test','Test Add!');
  }
}

// Simple list...
$Test = new TestList(array('MyProp1' => 1, 'MyProp2' => 2, 'MyProp3' => 3));
$Test->TestDynamisch = 'Dynamisch';


echo 'Simpel lijstje:<BR>';
echo $Test->TestDynamisch.'-'.$Test->MyProp1.'-'.$Test->MyProp2.'-'.$Test->MyProp3.'<BR><BR>';


echo 'Toevoegen  Sub-lijstje:<BR>';
$Test->Tree = new cDList();
$Test->Tree->Kind = "Kind Object";
$Test->Tree->Getal = (int) 123456;
$Test->Tree->Tree = new cDList();
$Test->Tree->Tree->Kind = "Kind van Kind";

echo '$Test->Tree->Tree->Kind='.$Test->Tree->Tree->Kind.'<BR><BR>';

// Serialisatie
$Test->SaveToFile('Test.txt');

// De-Serialisatie
$Kopie = TestList::LoadFromFile('Test.txt');

echo 'Orineel:<BR>';
echo $Test.'<BR><BR>';
echo 'Geladen van file:<BR>';
echo $Kopie.'<BR><HR>';


// DATASOURCE
if(!array_key_exists('GEBRUIKERS',$_SESSION)) { $_SESSION['GEBRUIKERS'] = array(); }
$DATASOURCE = &$_SESSION['GEBRUIKERS'];

$List = new cDList(false, $DATASOURCE);

if(!isset($List->IsIngeloged)) {
  $List->IsIngeloged = false;
  $List->Gebruiker = '(Gast)';
}


// ... inloggen ergens....
/*
  $List->IsIngeloged = true;
  $List->Gebruiker = 'Gebruiker';
*/

echo 'Lijst gekoppeld aan $_SESSION Array:<BR>';
echo $List;



?>


Source:
<?PHP


class cDList implements Iterator {
  protected $DATA = array();

  // ---- << No-Serialize >> ----
  protected $_Reflect = false;
  protected $_AllProperties = false;
  protected $_ObjectProperties = false;
  protected $_PublicProperties = false;
  protected $_ProtectedProperties = false;
  protected $_ItteratorArray = false;
  // ---- << No-Serialize >> ----

  public function __construct($DATA = false, &$DATASOURCE = false) {
    if(is_array($DATASOURCE)) { $this->DATA = &$DATASOURCE; }
    if(is_array($DATA)) { $this->DATA = $DATA; }
    if($DATA==false AND $DATASOURCE==false) { $this->DATA = array(); }
  }

  protected function OnGet($Key, &$Value, $Exists) { return true; }
  public function __get($Key) {
    $Value = null;
    $Exists = array_key_exists($Key, $this->DATA);
    if($Exists==true) { $Value = $this->DATA[$Key]; }
    if($this->OnGet($Key, $Value, $Exists)) {
      if($Exists==true) { return $this->DATA[$Key]; }
      else { return null; } }
    else { throw new Exception("Eigenschap `$Key` niet gevonden.",1001); }
  }

  protected function OnSet($Key, &$Value, $IsNew) { return true; }
  public function __set($Key, $Value) {
    if(array_key_exists($Key, $this->DATA)) { $IsNew = false; } else { $IsNew = true; }
    if($this->OnSet($Key, $Value, $IsNew)==true) {
      $this->DATA[$Key] = $Value;
      if($IsNew==true) { $this->_AllProperties = false; $this->_PublicProperties = false; } // Reset Property Cache
    }
  }

  public function __isset($Key) { return isset($this->DATA[$Key]); }
  public function __sleep() {
    try { return $this->GetObjectProperties(); }
    catch (exception $err) { return array(); }
  }
  public function __wakeup() {

  }
  public function __toString() {
    $Result = ""; $Props = $this->GetPublicProperties();
    foreach($Props as $Key) {
      if($Result!="") { $Result .= ", "; }
      $Result .= $Key.' = '.$this->GetValueAsString($this->$Key);
    }
    return $Result;
  }

  protected function GetValueAsString($Value) {
    if(is_double($Value) or is_integer($Value)) { return $Value; }
    if(is_object($Value)) { return 'List:['.$Value->__toString().']'; }
    if(is_bool($Value)) { if($Value) { return 'True'; } else { return 'False'; }}
    return '\''.$Value.'\'';
  }

  // Toevoegen, Verwijderen van eigenschappen.
  protected function Add($Property, $Value) {
    if(!array_key_exists($Property, $this->DATA)) { $this->DATA[$Property] = $Value; }
  }
  protected function Remove($Property) {
    unset($this->DATA[$Property]);
  }

  // Ophalen niet dynamische eigenschappen via reflectie
  private function GetObjectProps($Visible) {
    if($this->_Reflect==false) { $this->_Reflect = new ReflectionClass($this);  }
    $Props = $this->_Reflect->getProperties($Visible); $Return = array();
    foreach ($Props as $Prop) {
      $PropName = $Prop->getName();
      if((substr($PropName,0,1)!='_')) {   // Properties beginend met een "_" gebruiken we niet !
        $Return[] = $PropName; }
    }
    return $Return;
  }
  // Genereerd lijst van eigenschappen..
  private function GetAllProperties() {
    return array_merge(array_keys($this->DATA), $this->PropertiesObject());
  }
  private function GetObjectProperties() {
    return $this->GetObjectProps(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED | ReflectionProperty::IS_PRIVATE);
  }
  private function GetProtectedProperties() {
    return $this->GetObjectProps(ReflectionProperty::IS_PROTECTED);
  }
  private function GetPublicProperties() {
    return array_merge(array_keys($this->DATA), $this->GetObjectProps(ReflectionProperty::IS_PUBLIC));
  }


  // Doorgeven van lijst van eigenschappen....
  protected function PropertiesAll() {
    if($this->_AllProperties==false) { $this->_AllProperties = $this->GetAllProperties(); }
    return $this->_AllProperties;
  }
  protected function PropertiesObject() {
    if($this->_ObjectProperties==false) { $this->_ObjectProperties = $this->GetObjectProperties(); }
    return $this->_ObjectProperties;
  }
  protected function PropertiesProtected() {
    if($this->_ProtectedProperties==false) { $this->_ProtectedProperties = $this->GetProtectedProperties(); }
    return $this->_ProtectedProperties;
  }
  protected function PropertiesPublic() {
    if($this->_PublicProperties==false) { $this->_PublicProperties = $this->GetPublicProperties(); }
    return $this->_PublicProperties;
  }

  // Serialisatie
  public static function LoadFromFile($Filename) {
    $String = file_get_contents($Filename);
    return unserialize($String);
  }
  public function SaveToFile($Filename) {
    $String = serialize($this);
    file_put_contents($Filename, $String);
  }

   // Iterator Implementatie
  public function rewind() {
    if($this->_PublicProperties==false) { $this->_PublicProperties = $this->GetPublicProperties(); }
    reset($this->_PublicProperties);
  }
  public function current() {
    if($this->_PublicProperties==false) { $this->_PublicProperties = $this->GetPublicProperties(); }
    $Prop = current($this->_PublicProperties);
    return $this->$Prop;
  }
  public function key() {
    if($this->_PublicProperties==false) { $this->_PublicProperties = $this->GetPublicProperties(); }
    $Prop = current($this->_PublicProperties);
    return $Prop;
  }
  public function next() {
      if($this->_PublicProperties==false) { $this->_PublicProperties = $this->GetPublicProperties(); }
      $Prop = next($this->_PublicProperties);
      return $this->$Prop;
    }
  public function valid() {
      if($this->_PublicProperties==false) { $this->_PublicProperties = $this->GetPublicProperties(); }
      $key = key($this->_PublicProperties);
      return ($key !== NULL && $key !== FALSE);
    }
}

?>


modified on Monday, June 13, 2011 12:39 PM

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.