private function get_form_part_html($form_part = null, $product, $params = array())
 {
     //$template = Mage::getModel('webtoprint/template')->load($template_guid);
     //if (!$template->getId())
     //  return false;
     if (!($xml = $this->getTemplateXmlForCurrentProduct())) {
         return;
     }
     //if ($form_part === 'text-fields' || $form_part === 'image-fields')
     //  $this->add_values_from_cache($xml);
     if ($form_part === 'image-fields' && Mage::registry('webtoprint-user-was-registered')) {
         $this->add_user_images($xml);
     }
     if ($form_part === 'page-size-table' && !isset($xml->Pages->Page[0]['WidthIn'])) {
         return false;
     }
     $params = array_merge($params, array('zetaprints-api-url' => Mage::getStoreConfig('webtoprint/settings/url') . '/'));
     //Append translations to xml
     $locale_file = Mage::getBaseDir('locale') . DS . Mage::app()->getLocale()->getLocaleCode() . DS . 'ZetaPrints_WebToPrint.csv';
     $custom_translations_file = Mage::getBaseDir('locale') . DS . Mage::app()->getLocale()->getLocaleCode() . DS . 'ZetaPrints_WebToPrintCustomTranslations.csv';
     if (file_exists($locale_file) || file_exists($custom_translations_file)) {
         $cache = Mage::getSingleton('core/cache');
         $out = $cache->load("XMLTranslation" . Mage::app()->getLocale()->getLocaleCode());
         if (strlen($out) == 0) {
             $locale = @file_get_contents($locale_file) . @file_get_contents($custom_translations_file);
             preg_match_all('/"(.*?)","(.*?)"(:?\\r|\\n|$)/', $locale, $array, PREG_PATTERN_ORDER);
             if (is_array($array) && count($array[1]) > 0) {
                 $out = '<trans>';
                 foreach ($array[1] as $key => $value) {
                     if (strlen($value) > 0 && strlen($array[2][$key]) > 0) {
                         $out .= "<phrase key=\"" . $value . "\" value=\"" . $array[2][$key] . "\"/>";
                     }
                 }
                 $out .= "</trans>";
                 $cache->save($out, "XMLTranslation" . Mage::app()->getLocale()->getLocaleCode(), array('TRANSLATE'));
             }
         }
         $doc = new DOMDocument();
         $doc->loadXML($out);
         $node = $doc->getElementsByTagName("trans")->item(0);
         $xml_dom = new DOMDocument();
         $xml_dom->loadXML($xml->asXML());
         $node = $xml_dom->importNode($node, true);
         $xml_dom->documentElement->appendChild($node);
     } else {
         $xml_dom = new DOMDocument();
         $xml_dom->loadXML($xml->asXML());
     }
     return zetaprints_get_html_from_xml($xml_dom, $form_part, $params);
 }
Ejemplo n.º 2
0
function search_ajax_request($keywords, $size, $qty)
{
    list($width, $height) = explode('x', $size);
    $params = array();
    //$params['page'] = 'api-search';
    $params['Search'] = $keywords;
    $params['Width'] = $width;
    $params['Height'] = $height;
    $params['Units'] = 'px';
    $params['GeneratePrintPdf'] = 'image';
    $params['From'] = '0';
    $params['Qty'] = $qty;
    list($header, $content) = zp_api_common_post_request('http://zetaprints.com', '/?page=api-search', $params);
    list(, $content) = explode("\r\n", $content);
    return zetaprints_get_html_from_xml($content, 'search-results', '');
}