Page MenuHomeIn-Portal Phabricator

configuration_tag_processor.php
No OneTemporary

File Metadata

Created
Wed, Feb 26, 4:35 PM

configuration_tag_processor.php

<?php
class ConfigurationTagProcessor extends kDBTagProcessor {
function PrintList($params)
{
$params['per_page'] = -1;
$list =& $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix.'_List',$params);
$id_field = $this->Application->getUnitOption($this->Prefix,'IDField');
if ( !($list->OriginalParams == $params) ) {
$this->Application->removeObject($this->getPrefixSpecial());
$list =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix.'_List',$params);
}
$list->PerPage = -1;
$list->Query();
$o = '';
$list->GoFirst();
$block_params=$this->prepareTagParams($params);
$block_params['name']=$params['block'];
$block_params['pass_params']='true';
$block_params['IdField'] = $id_field;
$next_block=$params['full_block'];
$prev_title="";
while (!$list->EOL())
{
$nextItemPrompt=$list->Records[$list->CurrentIndex+1]['prompt'];
$thisItemPrompt=$list->Records[$list->CurrentIndex]['prompt'];
$this_title=$list->Records[$list->CurrentIndex]['heading'];
if ($this_title!=$prev_title){
$prev_title=$this_title;
$section_header_params=array();
$section_header_params['name']='config_section_header';
$section_header_params['title']=$this->Application->Phrase($this_title);
$o.= $this->Application->ParseBlock($section_header_params, 1);
}
if ($nextItemPrompt==$thisItemPrompt){
$curr_block=$params['half_block1'];
$next_block=$params['half_block2'];
}else{
$curr_block=$next_block;
$next_block=$params['full_block'];
}
$block_params['name']=$curr_block;
$this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) );
$o.= $this->Application->ParseBlock($block_params, 1);
$list->GoNext();
}
return $o;
}
function PrintConfList($params){
$list =& $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix.'_List',$params);
$id_field = $this->Application->getUnitOption($this->Prefix,'IDField');
$list->PerPage=-1;
$list->Query();
$o = '';
$list->GoFirst();
$tmp_row=array();
while (!$list->EOL())
{
$rec = $list->getCurrentRecord();
$tmp_row[0][$rec['VariableName']]=$rec['VariableValue'];
$tmp_row[0]['prompt']=$rec['prompt'];
$list->GoNext();
}
$list->Records = $tmp_row;
$block_params=$this->prepareTagParams($params);
$block_params['name']=$params['block'];
$list->GoFirst();
return $this->Application->ParseBlock($block_params, 1);
}
function GetToEnv($params){
$vars = explode(',', $params['vars']);
foreach ($vars as $key => $var){
$val=$this->Application->GetVar($var);
if ($val) {
$this->Application->SetVar("conf_".$var, $this->myUrlEncode($val));
}
}
}
function myUrlDecode($str){
$str=str_replace(';',':', $str);
$str=str_replace('!','-', $str);
return $str;
}
function myUrlEncode($str){
$str=str_replace('-', '!', $str);
$str=str_replace(':', ';', $str);
return $str;
}
function ConfigValue($params){
return $this->Application->ConfigValue($params['name']);
}
function Error($params)
{
$object =& $this->Application->recallObject( $this->getPrefixSpecial() );
$field = $object->GetDBField($params['id_field']);
$errors = $this->Application->GetVar('errormsgs');
$errors = $errors[$this->getPrefixSpecial()];
if (isset($errors[$field])){
$msg = $this->Application->Phrase($errors[$field]);
}
else {
$msg = '';
}
return $msg;
}
}
?>

Event Timeline