public function executeManuf(sfWebRequest $request) { $this->param = array(); $this->param['category'] = 'Fuses'; $this->param['cat_slug'] = 'fuses'; $this->param['manuf_slug'] = $this->getRequestParameter('manuf_slug'); $this->param['manuf_id'] = LWS::getManufPk($this->param['manuf_slug']); $this->param['manuf'] = LWS::unslugify($this->param['manuf_slug'], true); $this->param['subnav_grouping'] = intval(sfConfig::get('app_cb_max_subcat_grouping')); $this->param['subcategory'] = 'Classes/Types'; $this->param['subcat_slug'] = 'class-type'; // should be overwritten for each section $category = new FUCategory(); $this->param['manuf_list'] = $category->fetchManufList($this->param['manuf_id']); $this->param['manuf_list_class'] = 'bottom'; $this->param['sections'] = $category->fetchSectionsByManuf(LWS::getManufPk($this->param['manuf_slug'])); if (!$this->param['sections']) { // do something as a backup indexing/flattening strategy if DAO returned NULL $this->param['subnav_count'] = 0; // no subnav for sections of subcategory } else { if (count($this->param['sections']) > $this->param['subnav_grouping']) { $this->param['subnav_count'] = ceil(sizeof($this->param['sections']) / $this->param['subnav_grouping']); // just experimenting with various ways to control the subnav grouping etc. // so far it is too much work for the results. only edge cases matter so far. /*$xtra = count($this->param['sections']) - intval(sfConfig::get('app_subnav_grouping_top')); $mids = ceil($xtra / intval(sfConfig::get('app_subnav_grouping_middle'))); $rem = $xtra % intval(sfConfig::get('app_subnav_grouping_middle')); $lows = ceil($rem / intval(sfConfig::get('app_subnav_grouping_bottom'))); $this->param['subnav_count'] = $mids + $lows;*/ } else { $this->param['subnav_count'] = 1; } } $this->featured_parts = $category->fetchFeaturedParts($this->param['manuf_id']); // count number of cycle images for this manufacturer $cycle_img_dir = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'cycle' . DIRECTORY_SEPARATOR . $this->param['cat_slug'] . DIRECTORY_SEPARATOR . $this->param['manuf_slug'] . DIRECTORY_SEPARATOR; $this->param['manuf_box_class'] = '_' . count(glob('' . $cycle_img_dir . '*.png')); if (!$this->featured_parts) { // what to do if there are no featured parts found. we are missing data. } $response = $this->getResponse(); $response->addMeta('description', "LiveWire Supply is the Internet's #1 Supplier for {$this->param['manuf']} Fuses. We have a massive selection and shipping points across the country."); $response->setSlot('body_class', 'fu_manuf'); $response->setSlot('body_id', $this->param['manuf_slug']); $response->setTitle("{$this->param['manuf']} Fuses - " . sfConfig::get('app_biz_name')); return sfView::SUCCESS; }
public function executeManuf(sfWebRequest $request) { $this->param = array(); $this->param['category'] = 'Busway'; $this->param['cat_slug'] = 'busway'; $this->param['manuf_slug'] = $this->getRequestParameter('manuf_slug'); $this->param['manuf_id'] = LWS::getManufPk($this->param['manuf_slug']); $this->param['manuf'] = LWS::unslugify($this->param['manuf_slug'], true); $this->param['subnav_grouping'] = intval(sfConfig::get('app_cb_max_subcat_grouping')); $this->param['subcategory'] = 'Busway Components'; $this->param['subcat_slug'] = 'component'; $category = new BUCategory(); $this->param['manuf_list'] = $category->fetchManufList($this->param['manuf_id']); $this->param['manuf_list_class'] = 'bottom'; $this->param['sections'] = $category->fetchSectionsByManuf(LWS::getManufPk($this->param['manuf_slug'])); if (!$this->param['sections']) { // do something as a backup indexing/flattening strategy if DAO returned NULL $this->param['subnav_count'] = 0; // no subnav for sections of subcategory } else { if (sizeof($this->param['sections']) > $this->param['subnav_grouping']) { $this->param['subnav_count'] = ceil(sizeof($this->param['sections']) / $this->param['subnav_grouping']); } else { $this->param['subnav_count'] = 1; } } $this->featured_parts = $category->fetchFeaturedParts($this->param['manuf_id']); // count number of cycle images for this manufacturer $cycle_img_dir = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'cycle' . DIRECTORY_SEPARATOR . $this->param['cat_slug'] . DIRECTORY_SEPARATOR . $this->param['manuf_slug'] . DIRECTORY_SEPARATOR; $this->param['manuf_box_class'] = '_' . count(glob('' . $cycle_img_dir . '*.png')); // start preload logic $num_cycle_imgs = count(glob('' . $cycle_img_dir . '*.png')); $this->param['cycle_imgs'] = array(); for ($i = 0; $i < $num_cycle_imgs; $i++) { $this->param['cycle_imgs'][] = "/images/cycle/busway/{$this->param['manuf_slug']}/cycle-{$i}-trans.png"; } // end preload logic $response = $this->getResponse(); $response->addMeta('description', "LiveWire Supply is the Internet's #1 Supplier for {$this->param['manuf']} Busway. We have a massive selection and shipping points across the country."); $response->setSlot('body_class', 'bu_manuf'); $response->setSlot('body_id', $this->param['manuf_slug']); $response->setTitle("{$this->param['manuf']} Busway - " . sfConfig::get('app_biz_name')); return sfView::SUCCESS; }
public function executeManuf(sfWebRequest $request) { $this->param = array(); $this->param['category'] = 'Electrical Transformers'; $this->param['cat_slug'] = 'electrical-transformers'; $this->param['manuf_slug'] = $this->getRequestParameter('manuf_slug'); $this->param['manuf_id'] = LWS::getManufPk($this->param['manuf_slug']); // No manuf-level page for 'Rebuilt' manufacturer $this->forward404If($this->param['manuf_id'] == 23); $this->param['manuf'] = LWS::unslugify($this->param['manuf_slug'], true); $this->param['subnav_grouping'] = intval(sfConfig::get('app_subnav_grouping_max')); $this->param['subcategory'] = 'KVA Ratings'; $this->param['subcat_slug'] = 'kva-rating'; $category = new TRCategory(); $this->param['manuf_list'] = $category->fetchManufList($this->param['manuf_id']); $this->param['manuf_list_class'] = 'bottom'; $this->param['sections'] = $category->fetchSectionsByManuf(LWS::getManufPk($this->param['manuf_slug'])); if (!$this->param['sections']) { // do something as a backup indexing/flattening strategy if DAO returned NULL $this->param['subnav_count'] = 0; // no subnav for sections of subcategory } else { if (sizeof($this->param['sections']) > $this->param['subnav_grouping']) { $this->param['subnav_count'] = ceil(sizeof($this->param['sections']) / $this->param['subnav_grouping']); } else { $this->param['subnav_count'] = 1; } } $this->featured_parts = $category->fetchFeaturedParts($this->param['manuf_id']); // count number of cycle images for this manufacturer $cycle_img_dir = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'cycle' . DIRECTORY_SEPARATOR . 'electrical-transformers' . DIRECTORY_SEPARATOR . $this->param['manuf_slug'] . DIRECTORY_SEPARATOR; $this->param['manuf_box_class'] = '_' . count(glob('' . $cycle_img_dir . '*.png')); $response = $this->getResponse(); $response->addMeta('description', "LiveWire Supply is the Internet's #1 Supplier for {$this->param['manuf']} Electrical Transformers. We have a massive selection and shipping points across the country."); $response->setSlot('body_class', 'tr_manuf'); $response->setSlot('body_id', $this->param['manuf_slug']); $response->setTitle("{$this->param['manuf']} Transformers - " . sfConfig::get('app_biz_name')); return sfView::SUCCESS; }
public function executeRfq(sfWebRequest $request) { $this->cat_slug = $request->getParameter('category'); $this->category = strtoupper(LWS::unslugify($this->cat_slug)); if ($request->isMethod('POST')) { sfProjectConfiguration::getActive()->loadHelpers('Partial'); if ($this->cat_slug == 'electrical-transformers') { array_pop($this->_req_fields); } if ($this->rfqIsValid($request)) { // remove any saved form values from previous erroneous submission attempts $this->getUser()->getAttributeHolder()->remove('rfq_form_values'); // build email message if ($this->cat_slug == 'electrical-transformers') { $message = $this->buildTrEmail($request->getPostParameters()); } else { $message = $this->buildOtherEmail($request->getPostParameters()); } $to = 'Napoleon Esparrago <*****@*****.**>'; //$to = 'Morgan Ney <*****@*****.**>'; //qmail replaces LF(\n) with CRLF(\r\n), so only use LF in headers $headers = "Content-type: text/html; charset=iso-8859-1\nFrom: RFQ Form <*****@*****.**>\nCc: adam@livewiresupply.com\n"; if (@mail($to, "REQUEST FOR QUOTE - {$this->category}", $message, $headers)) { $this->getUser()->setFlash('rfq_notice', get_partial('formSuccess')); } else { $this->getUser()->setFlash('rfq_notice', get_partial('emailError')); } $this->redirect("@rfq?category={$this->cat_slug}"); } else { // save form values to restore $this->getUser()->setAttribute('rfq_form_values', $request->getPostParameters()); $this->getUser()->setFlash('rfq_notice', get_partial('formError', array('errors' => $this->_errors))); } } $this->partial = $this->cat_slug == 'electrical-transformers' ? 'ElectricalTransformers' : 'Other'; $this->getResponse()->setSlot('body_id', str_replace('-', '_', $this->cat_slug)); return sfView::SUCCESS; }
public function executeSelect(sfWebRequest $request) { if ($request->isXmlHttpRequest()) { // steps 1-3 requests & restart $this->setLayout(false); sfProjectConfiguration::getActive()->loadHelpers('Partial'); $agent = new CircuitBreakerSelectionAgent($request->getGetParameters()); if ($data = $agent->executeStep()) { $partial = 'filter' . ucfirst($request->getParameter('step')) . 'Step'; $html = get_partial($partial, array('selection' => $request->getParameter($request->getParameter('step'), NULL), 'back_qs' => $data['back_qs'], 'data' => $data['data'], 'results_so_far' => $data['results_so_far'], 'search_params' => $agent->getSearchParameters())); } else { /* * Would only get here if LWS DB is incomplete. * In this case we need to use the query string to retrieve the relevant * data set from teh DB and then fill in the missing values. * * Do not throw 404 from Ajax request, * just send error messgae back to user. * * !! I should log the query string in these cases to facilitate * updating of DB. */ $html = "<p id='tech_prob'>Sorry, we our experiencing technical difficulties. Please contact technical support at <a href='mailto:webmaster@livewiresupply.com'>webmaster@livewiresupply.com</a></p>"; } $response = $this->getResponse(); $response->addCacheControlHttpHeader('no-cache'); $response->setContentType('text/html'); $response->sendHttpHeaders(); return $this->renderText($html); } else { // ONLY FOR VOLTS/LAST STEP, or graceful degradation for non JavaScript enabled browsers $this->manuf_slug = LWS::getManufSlug($request->getParameter('manuf_id')); $this->manuf = LWS::unslugify($this->manuf_slug, true); $template = 'Filter' . ucfirst($request->getParameter('step')) . 'Step'; $this->selection = $request->getParameter($request->getParameter('step')); $agent = new CircuitBreakerSelectionAgent($request->getGetParameters()); /* * $agent would not return data only if LWS DB is incomplete. * Sequence of steps dictate that once LWS DB is complete, * server should throw a 404. User may have be url surfing. * * !!! be sure to update DB if necessary. */ $this->forward404Unless($this->data = $agent->executeStep()); if ($request->getParameter('step') == 'volts') { $this->redirect("@part?cat_slug=circuit-breakers&manuf_slug={$this->manuf_slug}&part_no=" . LWS::encode($this->data[0]['part']['part_no'])); } else { // remove unecessary ajax 'back a step' query string from end of data array unset($this->data['back_qs']); $this->results_so_far = $this->data['results_so_far']; $this->data = $this->data['data']; $this->search_params = $agent->getSearchParameters(); $response = $this->getResponse(); $response->setTitle("{$this->manuf} Circuit Breakers Selection Process"); $response->setSlot('body_class', 'cb_manuf'); return $template; } } }
public function executeSubpagination(sfWebRequest $request) { // eliminated subcategory route to prevent dup. content issues on page-1 $manuf_slug = $request->getParameter('manuf_slug'); $this->param = array(); $this->param['cat_id'] = LWS::getCategoryPk($request->getParameter('cat_slug')); $this->param['manuf'] = LWS::unslugify($manuf_slug, true); $this->param['category'] = LWS::getCategoryName($request->getParameter('cat_slug')); $this->param['subcategory'] = LWS::unslugify($request->getParameter('subcat_slug')); $this->param['section'] = LWS::getSectionName($this->param['subcategory'], $request->getParameter('section')); $this->param['current_page_num'] = LWS::extractPaginationNum($request->getParameter('page_num')); $category = CategoryFactory::make(array('cat_id' => $this->param['cat_id'], 'list_decorator_type' => 'basic')); $this->param['parts'] = $category->fetchSubcatListByManuf(LWS::getManufPk($manuf_slug), $this->param['section'], $this->param['current_page_num']); $this->forward404Unless($this->param['parts']); $this->param['part_count'] = $this->param['parts'][0]['part_count']; $this->param['next_page_num'] = $this->param['current_page_num'] + 1; $this->param['total_pages'] = ceil($this->param['part_count'] / intval(sfConfig::get('app_pagination_items_limit', 100))); $prefix = $this->param['current_page_num'] > 1 ? "Page {$this->param['current_page_num']} of {$this->param['total_pages']} : " : ''; $response = $this->getResponse(); $response->setSlot('body_id', str_replace('-', '_', $request->getParameter('cat_slug'))); $response->setSlot('body_class', 'pagination'); $response->addMeta('description', "{$this->param['manuf']} {$this->param['category']} {$this->param['section']} {$this->param['subcategory']} Catalog - {$prefix}"); $response->setTitle("{$prefix}{$this->param['section']} {$this->param['subcategory']} - {$this->param['manuf']} {$this->param['category']} - " . sfConfig::get('app_biz_name')); return sfView::SUCCESS; }