function dispatcher() { // Parse the URL paramiters $params = make_params(); // Check paramiters if(isset($params[0])) $controller_class = $params[0]; else $controller_class = DEFAULT_CONTROLLER; if(isset($params[1])) $controller = $params[1]; else $controller = "index"; // import the controller file $path = "app/controllers/$controller_class.php"; if(file_exists($path)) include $path; // import helper file $hlp_path = "app/helpers/$controller_class.php"; if(file_exists($hlp_path)) include $hlp_path; $name_with_prefix = "ctrl_" . $controller_class; // Check the controller class exits if(!class_exists($name_with_prefix)) throw new exception("Controller class '$name_with_prefix' does not exist\n"); // Create an instance of the controller class $instance = new $name_with_prefix(); if(!is_subclass_of($instance, "controller_base")) throw new exception("Controllers must extend 'controller_base'\n"); $instance->params = $params; // pass paramiters through // Check that the controller exists if(!method_exists($instance, $controller)) throw new exception("Error: Controller '$controller_class'". " does not define method: '$controller'\n"); $instance->$controller(); $instance->display_outer(); }
function dump_product($fl, $product, $needed_cats) { get_option('check-restrict') == 'yes' ? $restrict = true : ($restrict = false); $categories = get_the_terms($product->id, 'product_cat'); foreach ($categories as $key => $cat) { if (!in_array($cat->term_id, $needed_cats)) { unset($categories[$key]); } } if ($restrict && empty($categories)) { return; } $currency = get_woocommerce_currency(); $avl = $product->is_in_stock() ? 'true' : 'false'; fwrite($fl, '<offer id="' . $product->id . '" type="vendor.model" available="' . $avl . '">' . "\n"); fwrite($fl, '<url>' . get_permalink() . '</url>' . "\n"); make_price($fl, $product); fwrite($fl, '<currencyId>' . $currency . '</currencyId>' . "\n"); if (!empty($categories)) { $cats = array_shift($categories); fwrite($fl, '<categoryId>' . $cats->term_id . "</categoryId>\n"); $type_prefix = create_type_prefix($cats, $needed_cats); } else { fwrite($fl, "<categoryId>0</categoryId>\n"); $type_prefix = ''; } fwrite($fl, '<picture>' . wp_get_attachment_url(get_post_thumbnail_id($product->post->ID, 'full')) . '</picture>' . "\n"); get_option('max_imgs') - 1 > 1 ? $max_imgs = get_option('max_imgs') - 1 : ($max_imgs = 1); $pictIDs = array_slice($product->get_gallery_attachment_ids(), 0, $max_imgs); foreach ($pictIDs as $picID) { fwrite($fl, '<picture>' . wp_get_attachment_url($picID) . '</picture>' . "\n"); } $title = strip_tags($product->get_title()); $title = str_replace(' ', '', $title); $type_prefix = apply_filters('bg_yml_type_prefix', $type_prefix, $product); fwrite($fl, '<typePrefix>' . $type_prefix . "</typePrefix>\n"); fwrite($fl, '<vendor>' . bg_get_brand($fl, $product) . "</vendor>\n"); fwrite($fl, '<model> ' . $title . ' </model>' . "\n"); $prod_str = $product->post->post_excerpt . "\n" . $product->post->post_content; $prod_str = strip_tags($prod_str); $prod_str = str_replace(' ', '', $prod_str); $product_extra_tags = ''; $product_extra_tags = apply_filters('bg_yml_extra_tags', $product_extra_tags, $product); if ($product_extra_tags != '') { fwrite($fl, $product_extra_tags); } fwrite($fl, '<description>' . strip_tags($prod_str) . '</description>' . "\n"); make_params($fl, $product); fwrite($fl, '</offer>' . "\n"); }
function get_segments($binding, $filter) { try { $attr = array(); $params = make_params($attr, $filter); $result = $binding->readSegments($params); return normalize_result($result); } catch (SoapFault $ex) { print_exception($binding, $ex); return null; } }