Home > PHP, QCube > Read entry from directory handle

Read entry from directory handle

Howto read entry from directory handle.
In my QCube project i use php readdir function to read all i18n languages files.
Foreach language file, i create one button with label of current language and an Action to change current language on my site.

// function to check all i18n language files
protected function  agregateLanguage(){
$i = 0;
if ($handle = opendir(__QCUBED__ . '/i18n')){
while (false !== ($file = readdir($handle))){
$filearr = explode('.',$file);
if (end($filearr) === 'po'){
$this->btnLang[$i] = new QButton($this);
$this->btnLang[$i]->Text = $filearr[0];
$this->btnLang[$i]->ActionParameter = $filearr[0];
$this->btnLang[$i++]->AddAction(new QClickEvent(), new  QAjaxAction('btnLang_Click'));
}
}
}
}

// Function to change current language on my site
public function btnLang_Click($strFormId, $strControlId, $strParameter){
$_SESSION['language_code'] = $strParameter;
QApplication::Redirect('');
}

This code is used QCube my project but can be used with some changes for other php scripts.


Unique visitors to post: 2

Categories: PHP, QCube Tags: , ,
  1. No comments yet.
  1. October 17th, 2009 at 04:14 | #1
Google Analytics integration offered by Wordpress Google Analytics Plugin