parse_params_filter( $filter, true ); $filterstr = ''; if ( $filterarray != null ) { foreach ( $filterarray as $name => $value ) { if ( $filterstr != '' ) { $filterstr .= '&'; } $filterstr .= $name . '=' . $value . ''; } } $templatehelper = new atkp_template_helper(); $resultValue = $templatehelper->createLiveOutput( $shop_ids, $livetemplate, $template, $filterstr, $elementcss, $containercss, $limit ); return $resultValue; $resultValue = apply_filters( 'atkp_modify_output_livelist', $resultValue, $shop_ids, $template ); return $resultValue; } /** * Erstellt die Ausgabe einer konfigurierten Liste und aufgrund der Parameter. * * @id int Die eindeutige ID der Liste im Wordpress-Custom-Posttype. * * @template string Entweder ein Standardtemplate (wide, box,...) oder die ID der Vorlage (Customposttype). * * @content string Ein benutzerdefinierter Text welcher bis zur Vorlage durchgeschleift wird. * * @return string Gibt das vollständige HTML zurück. */ public function get_list_output( $id, $template = 'wide', $content = '', $buttontype = 'notset', $elementcss = '', $containercss = '', $limit = 10, $randomsort = false, $hidedisclaimer = false, $tracking_id = '', $product_ids = array(), $offerstemplate = '', $imagetemplate = '', $parseparams = false, $itemsPerPage = 0, $filter = '' ) { $template = apply_filters( 'atkp_modify_template', $template ); $template = apply_filters( 'atkp_modify_template_list', $template, $id, $content ); //Ausgabe der Liste vorbereiten if ( $itemsPerPage <= 0 ) { $itemsPerPage = 25; } else { //wenn items per page mitgegeben wurde, dann wird das limit übersteuert $limit = $itemsPerPage; } $productlist = array(); $max_num_pages = 0; $found_posts = 0; if ( $parseparams || $filter != '' ) { //TODO: parameter parsen und productids laden $filterhelper = new atkp_filter_helper(); $productlist = $filterhelper->parse_params_products( $itemsPerPage, $parseparams, $filter ); $max_num_pages = $filterhelper->max_num_pages; $found_posts = $filterhelper->found_posts; if ( $productlist == null || ! is_array( $productlist ) ) { return $productlist; } } else if ( count( $product_ids ) > 0 ) { foreach ( $product_ids as $productid ) { $item = array(); $item['type'] = 'productid'; $item['value'] = $productid; array_push( $productlist, $item ); } } else { $productlist = ATKPTools::get_post_setting( $id, ATKP_LIST_POSTTYPE . '_productlist' ); //abwärtskompatiblität einbauen für noch nicht aktualisierte listen... if ( ! isset( $productlist ) || $productlist == null ) { $productlist = get_transient( ATKP_PLUGIN_PREFIX . '_' . $id ); } //wenn liste noch nicht im cache ist, dann bau diese jetzt auf... das kann vorkommen wenn das plugin deaktiviert wurde und nach längerem wieder aktiviert wurde. //if($productlist == null) { // $cronjob = new atkp_cronjob(array()); // $cronjob->update_list($id); // ATKPTools::set_post_setting( $id, ATKP_LIST_POSTTYPE.'_productlist', $productlist); //} } $preferlocalproductinfo = ATKPTools::get_post_setting( $id, ATKP_LIST_POSTTYPE . '_preferlocalproduct' ); $outputprds = array(); if ( $productlist != null ) { if ( $randomsort ) { shuffle( $productlist ); } $counter = 0; foreach ( $productlist as $product ) { try { $type = $product['type']; $value = $product['value']; if ( $value == '' ) { continue; } if ( $counter >= $limit ) { break; } $counter = $counter + 1; switch ( $type ) { case 'product': //nur nach lokalen produkten suchen wenn in der if ( $preferlocalproductinfo ) { $prdfound = atkp_product::loadbyasin( $value->asin ); if ( $prdfound != null ) { $value = $prdfound; } } break; case 'productid': if ( get_post_status( $value ) == 'publish' || get_post_status( $value ) == 'draft' ) { $value = atkp_product::load( $value ); } else { $value = null; } break; } if ( $value != null ) { $shopid = ATKPTools::get_post_setting( $id, ATKP_LIST_POSTTYPE . '_shopid', 0 ); $value->init_list( $id, $shopid ); array_push( $outputprds, $value ); } } catch ( Exception $e ) { //TODO: 'Exception: ', $e->getMessage(), "\n"; } } } return $this->get_list_output2( $outputprds, $id, $template, $content, $buttontype, $elementcss, $containercss, $hidedisclaimer, $tracking_id, $offerstemplate, $imagetemplate, $itemsPerPage, $max_num_pages, $found_posts ); } public function get_list_output2( $productlist, $listid, $template = 'wide', $content = '', $buttontype = 'notset', $elementcss = '', $containercss = '', $hidedisclaimer = false, $tracking_id = '', $offerstemplate = '', $imagetemplate = '', $itemsPerPage = 0, $max_num_pages, $found_posts ) { $templatehelper = new atkp_template_helper(); $resultValue = $templatehelper->createOutput( $productlist, $content, $template, $containercss, $elementcss, $buttontype, $listid, $hidedisclaimer, 0, $tracking_id, $offerstemplate, $imagetemplate, $itemsPerPage, $max_num_pages, $found_posts ); $resultValue = apply_filters( 'atkp_modify_output_list', $resultValue, $productlist, $template ); return $resultValue; } public function get_searchform_output( $template = 'default', $targetpage = 0, $content = '' ) { $template = apply_filters( 'atkp_modify_template', $template ); $searchformhelper = new atkp_searchform_helper(); $resultValue = $searchformhelper->createOutput( $template, $targetpage, $content ); $resultValue = apply_filters( 'atkp_modify_output_searchform', $resultValue, $template ); return $resultValue; } private function override_notavailable_template( $productid, $template, &$isavailable ) { $isavailable = true; if ( ! atkp_options::$loader->get_show_nota_template() ) { return $template; } $saleprice = ATKPTools::get_post_setting( $productid, ATKP_PRODUCT_POSTTYPE . '_saleprice' ); $message = ATKPTools::get_post_setting( $productid, ATKP_PRODUCT_POSTTYPE . '_message' ); $temp = atkp_options::$loader->get_nota_template(); if ( $saleprice == '' || $message != '' ) { $template = $temp == '' ? 'notavailable' : $temp; $isavailable = false; } return $template; } public function get_product_output( $id, $template = 'box', $content = '', $buttontype = 'notset', $field, $link = false, $elementcss = '', $containercss = '', $hidedisclaimer = false, $tracking_id = '', $offerstemplate = '', $imagetemplate = '' ) { $isavailable = true; $template = $this->override_notavailable_template( $id, $template, $isavailable ); $template = apply_filters( 'atkp_modify_template', $template ); $template = apply_filters( 'atkp_modify_template_product', $template, $id, $content ); $resultValue = ''; if ( ( get_post_status( $id ) != 'publish' && get_post_status( $id ) != 'draft' ) ) { if ( $content == '' ) { $content = __( 'Product', ATKP_PLUGIN_PREFIX ); } return $link == true ? $content : ''; } if ( ! $isavailable && atkp_options::$loader->get_nota_disable_link() && $link ) { return $content; } $prd = atkp_product::load( $id ); $templatehelper = new atkp_template_helper(); if ( $field != '' ) { $placeholders = $templatehelper->createPlaceholderArray( $prd, 1, $containercss, $elementcss, $content, $buttontype, '', '', $tracking_id ); foreach ( array_keys( $placeholders ) as $key ) { if ( $key == $field ) { $resultValue = $placeholders[ $key ]; break; } } if ( $containercss != '' ) { $resultValue = '