Exemple #1
0
 public function loadListFromTable($listName)
 {
     $tableName = $listName;
     // table must have columns: key, text and sort_index
     // the row with option_id = null indicates the "please select" value
     $peerName = $peerName = "DB_" . capitalizeFirstLetter(underscoreToLowerCase($tableName)) . "Peer";
     $peer = new $peerName();
     $c = new Criteria();
     $c->add("key", null);
     $pleaseSelectOption = $peer->selectOne($c);
     $c = new Criteria();
     $c->add("key", null, "!=");
     $c->addOrderAscending("sort_index");
     $c->addOrderAscending("text");
     $options = $peer->select($c);
     if ($pleaseSelectOption != null) {
         $this->pleaseSelectValues["{$listName}"] = $pleaseSelectOption->getText();
     } else {
         // try SELECT_PLEASE_SELECT from the messages...
         $text = MessageResolver::instance()->message("SELECT_PLEASE_SELECT");
         if ($text != null) {
             $this->pleaseSelectValues["{$listName}"] = $text;
         }
     }
     $out = array();
     foreach ($options as $option) {
         $optionKey = $option->getKey();
         $out["{$optionKey}"] = $option->getText();
     }
     $this->storage["{$listName}"] = $out;
 }
 public function message($key)
 {
     return MessageResolver::instance()->message($key);
 }