Example #1
0
 function build_xml_string($objModule)
 {
     $error = false;
     $xmlString = object_to_xml($objModule);
     if ($error) {
         return $error;
     }
     return $xmlString;
 }
 function getOutput($type)
 {
     $ret = array("text/html", NULL);
     $tplmgr = TemplateManager::singleton();
     switch ($type) {
         case 'ajax':
             $ret = array("application/xml", $tplmgr->GenerateXML($this->data));
             break;
         case 'json':
         case 'jsonp':
             $jsonp = any($_REQUEST["jsonp"], "elation.ajax.processResponse");
             //$ret = array("application/javascript", $jsonp . "(" . json_encode($this->data) . ");");
             $ret = array("application/javascript", $tplmgr->GenerateJavascript($this->data, $jsonp));
             break;
         case 'js':
             $ret = array("application/javascript", @json_encode($this) . "\n");
             break;
         case 'jsi':
             $ret = array("application/javascript", json_indent(@json_encode($this)) . "\n");
             break;
         case 'txt':
             $ret = array("text/plain", $tplmgr->GenerateHTML($tplmgr->GetTemplate($this->template, NULL, $this->data)));
             break;
         case 'xml':
             $ret = array("application/xml", object_to_xml($this, "response"));
             break;
         case 'data':
             $ret = array("", $this->data);
             break;
         case 'componentresponse':
             $ret = array("", $this);
             break;
         case 'popup':
             // Popup is same as HTML, but we only use the bare-minimum html.page frame
             $vars["content"] = $this;
             $ret = array("text/html", ComponentManager::fetch("html.page", $vars, "inline"));
             break;
         case 'snip':
         case 'inline':
         case 'commandline':
             $ret = array("text/html", $tplmgr->GetTemplate($this->template, NULL, $this->data));
             break;
         case 'html':
         case 'fhtml':
         default:
             $cfg = ConfigManager::singleton();
             $framecomponent = any(ConfigManager::get("page.frame"), array_get($cfg->servers, "page.frame"), "html.page");
             // If framecomponent is false/0, just return the raw content
             $ret = array("text/html", empty($framecomponent) ? $this->data["content"] : ComponentManager::fetch($framecomponent, array("content" => $this), "inline"));
             //$ret = array("text/html", $tplmgr->GetTemplate($this->template, NULL, $this->data));
             break;
     }
     if (!empty($this->prefix)) {
         $ret[1] = $this->prefix . $ret[1];
     }
     return $ret;
 }
     $doc_title = db_prepare_input($_POST['newName']);
     $report = get_report_details($rID);
     $report->title = $doc_title;
     if ($_REQUEST['action'] == 'rename') {
         $sql_array = array('doc_title' => $doc_title, 'last_update' => date('Y-m-d'));
         db_perform(TABLE_PHREEFORM, $sql_array, 'update', 'id = ' . $rID);
         $message = PHREEFORM_RENAME_SUCCESS;
     } else {
         $result = $db->Execute("select * from " . TABLE_PHREEFORM . " where id = '" . $rID . "'");
         $sql_array = array('parent_id' => $result->fields['parent_id'], 'doc_title' => $doc_title, 'doc_group' => $report->groupname, 'doc_ext' => $report->reporttype, 'security' => $report->security, 'create_date' => date('Y-m-d'));
         db_perform(TABLE_PHREEFORM, $sql_array, 'insert');
         $rID = db_insert_id();
         $message = PHREEFORM_COPY_SUCCESS;
     }
     $filename = PF_DIR_MY_REPORTS . 'pf_' . $rID;
     $output = object_to_xml($report);
     if (!($handle = @fopen($filename, 'w'))) {
         $db->Execute("delete from " . TABLE_PHREEFORM . " where id = " . $rID);
         $messageStack->add(sprintf(PHREEFORM_WRITE_ERROR, $filename), 'error');
         break;
     }
     fwrite($handle, $output);
     fclose($handle);
     $messageStack->add($message, 'success');
     break;
 case 'export':
     $result = $db->Execute("select doc_title from " . TABLE_PHREEFORM . " where id = '" . $rID . "'");
     $filename = PF_DIR_MY_REPORTS . 'pf_' . $rID;
     $source_filename = str_replace(' ', '', $result->fields['doc_title']);
     $source_filename = str_replace('/', '_', $source_filename) . '.xml';
     $backup_filename = str_replace(' ', '', $result->fields['doc_title']);
Example #4
0
 function object_to_xml($params, $multiple = false, $multiple_key = '')
 {
     $output = NULL;
     if (!is_array($params) && !is_object($params)) {
         return;
     }
     foreach ($params as $key => $value) {
         $xml_key = $multiple ? $multiple_key : $key;
         if (is_array($value)) {
             $output .= object_to_xml($value, true, $key);
         } elseif (is_object($value)) {
             $output .= "<" . $xml_key . ">\n" . object_to_xml($value) . "</" . $xml_key . ">\n";
         } else {
             if ($value != '') {
                 $output .= xmlEntry($xml_key, $value);
             }
         }
     }
     return $output;
 }
    /**
     * Export a single structure
     */
    function export_structure($parent_id)
    {
        /*
         * Define the location of the downloads directory.
         */
        $downloads_dir = WEB_ROOT . '/downloads/';
        $downloads_dir .= $this->edition['slug'] . '/';
        $structure_sql = '	SELECT structure_unified.*
							FROM structure
							LEFT JOIN structure_unified
								ON structure.id = structure_unified.s1_id';
        $structure_args = array();
        if (isset($parent_id)) {
            $structure_sql .= ' WHERE parent_id = :parent_id';
            $structure_args[':parent_id'] = $parent_id;
        } else {
            $structure_sql .= ' WHERE parent_id IS NULL';
        }
        $structure_sql .= ' AND edition_id = :edition_id';
        $structure_args[':edition_id'] = $this->edition_id;
        $structure_statement = $this->db->prepare($structure_sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
        $structure_result = $structure_statement->execute($structure_args);
        if ($structure_result === FALSE) {
            echo '<p>' . $structure_sql . '</p>';
            echo '<p>' . $structure_result->getMessage() . '</p>';
            return;
        }
        /*
         * Get results as an array to save memory
         */
        while ($item = $structure_statement->fetch(PDO::FETCH_ASSOC)) {
            /*
             * Figure out the URL for this structural unit by iterating through the "identifier"
             * columns in this row.
             */
            $identifier_parts = array();
            foreach ($item as $key => $value) {
                if (preg_match('/s[0-9]_identifier/', $key) == 1) {
                    /*
                     * Higher-level structural elements (e.g., titles) will have blank columns in
                     * structure_unified, so we want to omit any blank values. Because a valid
                     * structural unit identifier is "0" (Virginia does this), we check the string
                     * length, rather than using empty().
                     */
                    if (strlen($value) > 0) {
                        $identifier_parts[] = urlencode($value);
                    }
                }
            }
            $identifier_parts = array_reverse($identifier_parts);
            $token = implode('/', $identifier_parts);
            /*
             * This is slightly different from how we handle permalinks since we don't want to
             * overwrite files if current has changed.
             */
            $url = '/';
            if (defined('LAW_LONG_URLS') && LAW_LONG_URLS === TRUE) {
                $url .= $token . '/';
            }
            /*
             * Now we can use our data to build the child law identifiers
             */
            if (INCLUDES_REPEALED !== TRUE) {
                $laws_sql = '	SELECT id, structure_id, section AS section_number, catch_line
								FROM laws
								WHERE structure_id = :s_id
								AND edition_id = :edition_id
								ORDER BY order_by, section';
            } else {
                $laws_sql = '	SELECT laws.id, laws.structure_id, laws.section AS section_number,
								laws.catch_line
								FROM laws
								LEFT OUTER JOIN laws_meta
									ON laws_meta.law_id = laws.id AND laws_meta.meta_key = "repealed"
								WHERE structure_id = :s_id
								AND (laws_meta.meta_value = "n" OR laws_meta.meta_value IS NULL)
								AND edition_id = :edition_id
								ORDER BY order_by, section';
            }
            $laws_args = array(':s_id' => $item['s1_id'], ':edition_id' => $this->edition_id);
            $laws_statement = $this->db->prepare($laws_sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
            $laws_result = $laws_statement->execute($laws_args);
            if ($laws_result !== FALSE && $laws_statement->rowCount() > 0) {
                /*
                 * Establish the path of our code JSON storage directory.
                 */
                $json_dir = $downloads_dir . 'code-json' . $url;
                $this->mkdir($json_dir);
                /*
                 * Set a flag telling us that we may write JSON.
                 */
                $write_json = TRUE;
                /*
                 * Establish the path of our code text storage directory.
                 */
                $text_dir = $downloads_dir . 'code-text' . $url;
                $this->mkdir($text_dir);
                /*
                 * Set a flag telling us that we may write text.
                 */
                $write_text = TRUE;
                /*
                 * Establish the path of our code XML storage directory.
                 */
                $xml_dir = $downloads_dir . 'code-xml' . $url;
                $this->mkdir($xml_dir);
                /*
                 * Set a flag telling us that we may write XML.
                 */
                $write_xml = TRUE;
                /*
                 * Create a new instance of the Parser class, so that we have access to its
                 * get_structure_labels() method.
                 */
                $parser = new Parser(array('db' => $this->db, 'logger' => $this->logger, 'downloads_dir' => $this->downloads_dir, 'downloads_url' => $this->downloads_url));
                /*
                 * Create a new instance of the class that handles information about individual laws.
                 */
                $laws = new Law();
                /*
                 * Iterate through every section number, to pass to the Laws class.
                 */
                while ($section = $laws_statement->fetch(PDO::FETCH_OBJ)) {
                    /*
                     * Instruct the Law class on what, specifically, it should retrieve.
                     */
                    $laws->config->get_text = TRUE;
                    $laws->config->get_structure = TRUE;
                    $laws->config->get_amendment_attempts = FALSE;
                    $laws->config->get_court_decisions = TRUE;
                    $laws->config->get_metadata = TRUE;
                    $laws->config->get_references = TRUE;
                    $laws->config->get_related_laws = TRUE;
                    /*
                     * Pass the requested section number to Law.
                     */
                    $laws->law_id = $section->id;
                    $laws->edition_id = $this->edition_id;
                    unset($law, $section);
                    /*
                     * Get a list of all of the basic information that we have about this section.
                     */
                    $law = $laws->get_law();
                    if ($law !== FALSE) {
                        /*
                         * Eliminate colons from section numbers, since some OSes can't handle colons in
                         * filenames.
                         */
                        $filename = str_replace(':', '_', $law->section_number);
                        /*
                         * Store the JSON file.
                         */
                        if ($write_json === TRUE) {
                            $success = file_put_contents($json_dir . $filename . '.json', json_encode($law));
                            if ($success === FALSE) {
                                $this->logger->message('Could not write law JSON files "' . $json_dir . $filename . '.json' . '"', 9);
                                break;
                            } else {
                                $this->logger->message('Wrote file "' . $json_dir . $filename . '.json' . '"', 1);
                            }
                        }
                        /*
                         * Store the text file.
                         */
                        if ($write_text === TRUE) {
                            $success = file_put_contents($text_dir . $filename . '.txt', $law->plain_text);
                            if ($success === FALSE) {
                                $this->logger->message('Could not write law text files "' . $text_dir . $filename . '.txt', $law->plain_text . '"', 9);
                                break;
                            } else {
                                $this->logger->message('Wrote file "' . $json_dir . $filename . '.txt' . '"', 1);
                            }
                        }
                        /*
                         * Store the XML file.
                         */
                        if ($write_xml === TRUE) {
                            /*
                             * We need to massage the $law object into matching the State Decoded
                             * XML standard. The first step towards this is removing unnecessary
                             * elements.
                             */
                            unset($law->plain_text);
                            unset($law->structure_contents);
                            unset($law->next_section);
                            unset($law->previous_section);
                            unset($law->amendment_years);
                            unset($law->dublin_core);
                            unset($law->plain_text);
                            unset($law->section_id);
                            unset($law->structure_id);
                            unset($law->edition_id);
                            unset($law->full_text);
                            unset($law->formats);
                            unset($law->html);
                            $law->structure = $law->ancestry;
                            unset($law->ancestry);
                            $law->referred_to_by = $law->references;
                            unset($law->references);
                            /*
                             * Encode all entities as their proper Unicode characters, save for the
                             * few that are necessary in XML.
                             */
                            $law = html_entity_decode_object($law);
                            /*
                             * Quickly turn this into an XML string.
                             */
                            $xml = new SimpleXMLElement('<law />');
                            object_to_xml($law, $xml);
                            $xml = $xml->asXML();
                            /*
                             * Load the XML string into DOMDocument.
                             */
                            $dom = new DOMDocument();
                            $dom->loadXML($xml);
                            /*
                             * Simplify every reference, stripping them down to the cited sections.
                             */
                            $referred_to_by = $dom->getElementsByTagName('referred_to_by');
                            if (!empty($referred_to_by) && $referred_to_by->length > 0) {
                                $referred_to_by = $referred_to_by->item(0);
                                $references = $referred_to_by->getElementsByTagName('unit');
                                /*
                                 * Iterate backwards through our elements.
                                 */
                                for ($i = $references->length; --$i >= 0;) {
                                    $reference = $references->item($i);
                                    /*
                                     * Save the section number.
                                     */
                                    $section_number = trim($reference->getElementsByTagName('section_number')->item(0)->nodeValue);
                                    /*
                                     * Create a new element, named "reference," which contains the only
                                     * the section number.
                                     */
                                    $element = $dom->createElement('reference', $section_number);
                                    $reference->parentNode->insertBefore($element, $reference);
                                    /*
                                     * Remove the "unit" node.
                                     */
                                    $reference->parentNode->removeChild($reference);
                                }
                            }
                            /*
                             * Simplify and reorganize every structural unit.
                             */
                            $structure = $dom->getElementsByTagName('structure');
                            if (!empty($structure) && $structure->length > 0) {
                                $structure = $structure->item(0);
                                $structural_units = $structure->getElementsByTagName('unit');
                                /*
                                 * Iterate backwards through our elements.
                                 */
                                for ($i = $structural_units->length; --$i >= 0;) {
                                    $unit = $structural_units->item($i);
                                    /*
                                     * Add the "level" attribute.
                                     */
                                    $label = trim(strtolower($unit->getAttribute('label')));
                                    $level = $dom->createAttribute('level');
                                    $level->value = array_search($label, $parser->get_structure_labels()) + 1;
                                    $unit->appendChild($level);
                                    /*
                                     * Add the "identifier" attribute.
                                     */
                                    $identifier = $dom->createAttribute('identifier');
                                    $identifier->value = trim($unit->getElementsByTagName('identifier')->item(0)->nodeValue);
                                    $unit->appendChild($identifier);
                                    /*
                                     * Remove the "id" attribute from <unit>.
                                     */
                                    $unit->removeAttribute('id');
                                    /*
                                     * Store the name of this structural unit as the contents of <unit>.
                                     */
                                    $unit->nodeValue = trim($unit->getElementsByTagName('name')->item(0)->nodeValue);
                                    /*
                                     * Save these changes.
                                     */
                                    $structure->appendChild($unit);
                                }
                            }
                            /*
                             * Rename text units as text sections.
                             */
                            $text = $dom->getElementsByTagName('text');
                            if (!empty($text) && $text->length > 0) {
                                $text = $text->item(0);
                                $text_units = $text->getElementsByTagName('unit');
                                /*
                                 * Iterate backwards through our elements.
                                 */
                                for ($i = $text_units->length; --$i >= 0;) {
                                    $text_unit = $text_units->item($i);
                                    renameElement($text_unit, 'section');
                                }
                            }
                            /*
                             * Save the cleaned-up XML to the filesystem.
                             */
                            $success = file_put_contents($xml_dir . $filename . '.xml', $dom->saveXML());
                            if ($success === FALSE) {
                                $this->logger->message('Could not write law XML files', 9);
                                break;
                            }
                        }
                    }
                    // end the $law exists condition
                }
                // end the while() law iterator
            }
            // end the $laws condition
            $this->export_structure($item['s1_id']);
        }
        // end the while() structure iterator
    }
function object_to_xml($params, $multiple = false, $multiple_key = '', $level = 0)
{
    $output = NULL;
    if (!is_array($params) && !is_object($params)) {
        return;
    }
    foreach ($params as $key => $value) {
        $xml_key = $multiple ? $multiple_key : $key;
        if (is_array($value)) {
            $output .= object_to_xml($value, true, $key, $level);
        } elseif (is_object($value)) {
            for ($i = 0; $i < $level; $i++) {
                $output .= "\t";
            }
            $output .= "<" . $xml_key . ">\n";
            $output .= object_to_xml($value, '', '', $level + 1);
            for ($i = 0; $i < $level; $i++) {
                $output .= "\t";
            }
            $output .= "</" . $xml_key . ">\n";
        } else {
            if ($value != '') {
                for ($i = 0; $i < $level - 1; $i++) {
                    $output .= "\t";
                }
                $output .= xmlEntry($xml_key, $value);
            }
        }
    }
    return $output;
}
Example #7
0
function object_to_xml($obj, $container = "", $level = 0)
{
    $tabs = str_repeat("\t", $level);
    if (is_array($container)) {
        $properties = $container[1];
        $container = $container[0];
    } else {
        $properties = array();
    }
    if (is_object($obj)) {
        $xml = $tabs . "<{$container}";
        $properties = array_merge($properties, get_object_vars($obj));
        $attributes = $children = array();
        foreach ($properties as $k => $v) {
            if (is_object($v) || is_array($v)) {
                $children[$k] = $v;
            } else {
                $attributes[$k] = $v;
            }
        }
        foreach ($attributes as $k2 => $v2) {
            if ($v2 !== NULL) {
                $xml .= sprintf(' %s="%s"', htmlspecialchars($k2), htmlspecialchars($v2));
            }
        }
        if (!empty($children)) {
            $xml .= ">\n";
            foreach ($children as $k2 => $v2) {
                $xml .= object_to_xml($v2, $k2, $level + 1);
            }
            $xml .= $tabs . "</" . $container . ">\n";
        } else {
            $xml .= " />\n";
        }
    } else {
        if (is_array($obj)) {
            $subxml = "";
            $allnumeric = true;
            foreach ($obj as $k => $v) {
                $subcontainer = $k;
                if (is_object($v)) {
                    $allnumeric = false;
                    $subcontainer = get_class($v);
                } else {
                    if (is_numeric($k)) {
                        $subcontainer = array($container, array("id" => $k));
                    }
                }
                $subxml .= object_to_xml($v, $subcontainer, $level + 1);
            }
            if (!$allnumeric) {
                $xml = $tabs . "<{$container}";
                foreach ($properties as $k => $v) {
                    $xml .= sprintf(' %s="%s"', htmlspecialchars($k), htmlspecialchars($v));
                }
                $xml .= ">\n";
            }
            $xml .= $subxml;
            if (!$allnumeric) {
                $xml .= $tabs . "</" . $container . ">\n";
            }
        } else {
            if ($obj !== NULL) {
                $xml .= sprintf("%s<%s>%s</%s>\n", $tabs, $container, $obj, $container);
            }
        }
    }
    return $xml;
}
/**
 * Recusively travserses through an array to propagate SimpleXML objects.
 * @param array $array the array to parse
 * @param object $xml the Simple XML object (must be at least a single empty node)
 * @return object the Simple XML object (with array objects added)
 * @author Ben Balter
 */
function object_to_xml($array, $xml)
{
    /*
     * Array of keys that will be treated as attributes, not children.
     */
    $attributes = array('id', 'number', 'label', 'prefix');
    /*
     * Recursively loop through each item.
     */
    foreach ($array as $key => $value) {
        /*
         * If this is a numbered array, grab the parent node to determine the node name.
         */
        if (is_numeric($key)) {
            $key = 'unit';
        }
        /*
         * If this is an attribute, treat as an attribute.
         */
        if (in_array($key, $attributes)) {
            $xml->addAttribute($key, $value);
        } else {
            if (is_object($value) || is_array($value)) {
                $child = $xml->addChild($key);
                $child = object_to_xml($value, $child);
            } else {
                $xml->addChild($key, $value);
            }
        }
    }
    return $xml;
}
Example #9
0
function save_report($report, $rID = '', $save_path = PF_DIR_MY_REPORTS)
{
    global $db, $messageStack;
    $error = false;
    $output = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . chr(10);
    $output .= '<PhreeformReport>' . chr(10);
    $output .= object_to_xml($report);
    $output .= '</PhreeformReport>' . chr(10);
    //echo 'xml output = ' . str_replace(chr(10) , "<br>", htmlspecialchars($output)) . '<br>'; exit();
    // see if a folder exists with the group to put it in
    $result = $db->Execute("select id from " . TABLE_PHREEFORM . "\n\t  where doc_group = '" . $report->groupname . "' and doc_type = '0' and doc_ext in ('ff', 'fr')");
    if ($result->RecordCount() == 0) {
        if ($report->reporttype == 'frm') {
            $result = $db->Execute("select id from " . TABLE_PHREEFORM . "\n\t      where doc_group = 'misc:misc' and doc_type = '0'");
        } else {
            $result = $db->Execute("select id from " . TABLE_PHREEFORM . "\n\t      where doc_group = 'misc' and doc_type = '0'");
        }
    }
    $parent_id = $result->fields['id'];
    if ($report->standard_report == '1') {
        $report->standard_report = 's';
    }
    $sql_array = array('parent_id' => $parent_id, 'doc_type' => isset($report->standard_report) ? $report->standard_report : 's', 'doc_title' => $report->title, 'doc_group' => $report->groupname, 'doc_ext' => $report->reporttype, 'security' => $report->security);
    if ($rID) {
        // update
        $sql_array['last_update'] = date('Y-m-d');
        db_perform(TABLE_PHREEFORM, $sql_array, 'update', 'id = ' . $rID);
    } else {
        // add
        $sql_array['create_date'] = date('Y-m-d');
        db_perform(TABLE_PHREEFORM, $sql_array);
        $rID = db_insert_id();
    }
    $filename = $save_path . 'pf_' . $rID;
    if (!($handle = @fopen($filename, 'w'))) {
        $error = true;
    }
    if (!$error) {
        if (!fwrite($handle, $output)) {
            $error = true;
        }
        @fclose($handle);
    }
    if ($error) {
        $db->Execute("delete from " . TABLE_PHREEFORM . " where id = " . $rID);
        $messageStack->add(sprintf(PHREEFORM_WRITE_ERROR, $filename), 'error');
        return false;
    }
    return $rID;
}
Example #10
0
 function validateAddress($address)
 {
     // this can be called with ajax or directly
     global $messageStack;
     $output = array();
     $xml = '?input=<VERIFYADDRESS>';
     $xml .= '<COMMAND>ZIP1</COMMAND>';
     $xml .= '<SERIALNO>830413</SERIALNO>';
     // Phreesoft, LLC common Dial-A-Zip validation login info for use only with this module
     $xml .= '<USER>830413</USER>';
     $xml .= '<PASSWORD>Phreedom_2012_LLC</PASSWORD>';
     $xml .= '<ADDRESS0>' . urlencode(remove_special_chars($address->ship_primary_name)) . '</ADDRESS0>';
     $xml .= '<ADDRESS1>' . urlencode(remove_special_chars($address->ship_contact)) . '</ADDRESS1>';
     $xml .= '<ADDRESS2>' . urlencode(remove_special_chars($address->ship_address1) . ' ' . remove_special_chars($address->ship_address2)) . '</ADDRESS2>';
     $xml .= '<ADDRESS3>' . urlencode(strtoupper($address->ship_city_town) . ', ' . strtoupper($address->ship_state_province) . ' ' . strip_alphanumeric($address->ship_postal_code)) . '</ADDRESS3>';
     $xml .= '</VERIFYADDRESS>';
     $result = file_get_contents(MODULE_SHIPPING_ENDICIA_DIAL_A_ZIP_URL . $xml);
     $result = substr($result, strpos($result, '>') + 1);
     $result = str_replace('<Dial-A-ZIP_Response>', '', trim($result));
     $result = str_replace('</Dial-A-ZIP_Response>', '', trim($result));
     $parts = xml_to_object($result);
     if ($parts->ReturnCode == '31') {
         $address->ship_contact = '';
         $address->ship_address1 = $parts->AddrLine1;
         $address->ship_address2 = $parts->AddrLine2;
         $address->ship_city_town = $parts->City;
         $address->ship_state_province = $parts->State;
         $address->ship_postal_code = $parts->ZIP5 . '-' . $parts->Plus4;
         $response = array('result' => 'success', 'xmlString' => '<address>' . object_to_xml($address) . '</address>', 'message' => 'The address will be corrected per results from Dial-A-Zip.');
     } else {
         $response = array('result' => 'error', 'message' => sprintf(SHIPPING_ENDICIA_ADD_VAL_ERROR, $parts->ReturnCode, $this->dialAZipCodes[$parts->ReturnCode]));
     }
     return $response;
     // xml string response
 }