Esempio n. 1
0
 public function breadcrumbmenu($options)
 {
     $selectedItemMenuID = 0;
     $menuTitle = isset($options['menuTitle']) ? $options['menuTitle'] : '';
     if (Zend_Registry::isRegistered('selectedItemMenuID')) {
         $selectedItemMenuID = Zend_Registry::get('selectedItemMenuID');
     }
     return Cible_FunctionsPages::buildClientBreadcrumbMenu($selectedItemMenuID, 1, $menuTitle);
 }
Esempio n. 2
0
 function indexAction()
 {
     // retrieve the ID of the requested page
     $pageID = $this->view->pageID = $this->_getParam('ID');
     $pageDetails = new PagesIndex();
     $pageDetailsSelect = $pageDetails->select();
     $pageDetailsSelect->where('PI_PageID = ?', $pageID)->where('PI_LanguageID = ?', $this->_defaultEditLanguage);
     $pageDetailsData = $pageDetails->fetchRow($pageDetailsSelect)->toArray();
     $this->view->assign("pageTitle", $pageDetailsData["PI_PageTitle"]);
     $authData = $this->view->user;
     $authID = $authData['EU_ID'];
     if (Cible_FunctionsAdministrators::checkAdministratorPageAccess($authID, $pageID, "data")) {
         $authData = $this->view->user;
         $authID = $authData['EU_ID'];
         if (Cible_FunctionsAdministrators::checkAdministratorPageAccess($authID, $pageID, "structure")) {
             $this->view->assign('hasAccessToStructure', true);
         }
         // Retrieve the page view layout
         $page = new Pages();
         $page_select = $page->select()->setIntegrityCheck(false);
         $page_select->from('Pages')->join('Views', 'Pages.P_ViewID = Views.V_ID')->where('P_ID = ?', $pageID);
         $page_info = Cible_FunctionsPages::getPageViewDetails($pageID);
         $template_file = 'index/' . $page_info['V_Path'];
         $_zone_count = $page_info['V_ZoneCount'];
         // make a request to get all the blocks to be displayed
         $blocks = new Blocks();
         $select = $blocks->select()->setIntegrityCheck(false);
         $select->from('Blocks')->join('Modules', 'Modules.M_ID = Blocks.B_ModuleID')->join('Pages', 'Blocks.B_PageID = P_ID')->join('BlocksIndex', 'Blocks.B_ID = BlocksIndex.BI_BlockID')->where('Blocks.B_PageID = ?', $pageID)->where('BlocksIndex.BI_LanguageID = ?', Zend_Registry::get('languageID'))->order('Blocks.B_Position ASC');
         //Send the results to the view
         $rows = $blocks->fetchAll($select);
         $_blocks = array();
         foreach ($rows as $row) {
             // create the placeholder object if not already defined
             if (!isset($_blocks[$row['B_ZoneID']])) {
                 $_blocks[$row['B_ZoneID']] = array();
             }
             $_blocks[$row['B_ZoneID']][] = $row->toArray();
         }
         $this->view->assign('template_file', $template_file);
         $this->view->assign('zone_count', $_zone_count);
         $this->view->assign('blocks', $_blocks);
         // Load the modules in the view
         $Modules = new Modules();
         $modules = $Modules->fetchAll();
         $this->view->assign('modules', $modules->toArray());
     } else {
         $this->view->assign('template_file', "");
         $this->view->assign('error_message_permission', $this->view->getCibleText('error_message_permission'));
     }
 }
Esempio n. 3
0
 /**
  * Render form element
  * 
  * @param  Zend_View_Interface $view 
  * @return string
  */
 public function render(Zend_View_Interface $view = null)
 {
     $_baseUrl = $this->getView()->baseUrl();
     $this->_view->headScript()->appendFile("{$_baseUrl}/js/cible.form.element.pagepicker.js");
     $pages_list = Cible_FunctionsPages::getAllPagesDetailsArray(0, Cible_Controller_Action::getDefaultEditLanguage());
     $_pages = array();
     foreach ($pages_list as $page) {
         $tmp = array('ID' => $page['P_ID'], 'Title' => $page['PI_PageTitle'], 'onClick' => str_replace(array('%PAGEID%', '%PAGEINDEX%'), array($page['P_ID'], $page['PI_PageIndex']), $this->_onClick));
         if (!empty($page['child'])) {
             $tmp['child'] = $this->fillChildren($page['child']);
         }
         array_push($_pages, $tmp);
     }
     $content = $this->getView()->collapsibleTree($_pages, array('id' => $this->getId(), 'images' => array('close' => $this->getView()->baseUrl() . '/themes/default/images/treeview-open.gif', 'open' => $this->getView()->baseUrl() . '/themes/default/images/treeview-close.gif'), 'class' => 'collapsible_tree'));
     foreach ($this->getDecorators() as $decorator) {
         $decorator->setElement($this);
         $content = $decorator->render($content);
     }
     return $content;
 }
Esempio n. 4
0
 private function appendIfNotFound($children, $tmp, $appendTo = array())
 {
     foreach ($children as $child) {
         $index = '';
         if ($child['PageID'] != -1) {
             $index = Cible_FunctionsPages::getPageNameByID($child['PageID']);
         } else {
             $index = $child['Link'];
         }
         if (!empty($index) && !isset($tmp[$index])) {
             $tmp[$index] = '';
             array_push($appendTo, array('ID' => $child['ID'], 'Title' => strip_tags($child['Title']), 'Link' => $child['Link'], 'PageID' => $child['PageID'], 'Placeholder' => $child['Placeholder']));
             if (!empty($child['child'])) {
                 $index = count($appendTo) - 1;
                 $appendTo[$index]['child'] = $child['child'];
             }
         }
     }
     return $appendTo;
 }
Esempio n. 5
0
 public function gallerymenuAction()
 {
     $db = Zend_Registry::get('db');
     $gallerySelect = new GalleriesIndex();
     $select = $db->select()->distinct()->from('ModuleCategoryViewPage')->join('CategoriesIndex', 'CI_CategoryID = MCVP_CategoryID AND CI_LanguageID = ' . Zend_Registry::get("languageID"))->where('MCVP_ViewID = 9001');
     $galleryData = $db->fetchAll($select);
     $arrayLink = array();
     foreach ($galleryData as $gallery) {
         $link = Cible_FunctionsPages::getPageLinkByID($gallery['MCVP_PageID']);
         array_push($arrayLink, array('ID' => $gallery['MCVP_PageID'], 'title' => $gallery['CI_Title'], 'link' => $link));
     }
     $pageParentID = Cible_FunctionsPages::findParentPageID(Zend_Registry::get("pageID"));
     $parentID = 9002;
     if ($pageParentID['P_ParentID'] == 9016) {
         $parentID = 9009;
     }
     $selectedMenuItem = Cible_FunctionsPages::findMenuID(10, $parentID);
     $this->view->assign('parentID', $pageParentID['P_ParentID']);
     $this->view->assign('menuSelectedItem', $selectedMenuItem['MII_MenuItemDataID']);
     $this->view->assign('arrayLinks', $arrayLink);
 }
Esempio n. 6
0
 /**
  * Build the breadcrumd for the catalog page.
  *
  * @param int $lang  <Optional> Id of the current language
  * 
  * @return string 
  */
 public function breadcrumbCatalog($level = 1, $showHome = true, $langId = null)
 {
     if ($langId == null) {
         $langId = Zend_Registry::get('languageID');
     }
     $_baseUrl = Zend_Registry::get('baseUrl');
     $_breadcrumb = array();
     $_first = true;
     $pathInfo = $this->view->request->getPathInfo();
     $oProducts = new ProductsCollection();
     $oProducts->setActions($pathInfo);
     $oProducts->getDataByName();
     $catId = $oProducts->getCatId();
     $subCatId = $oProducts->getSubCatId();
     $prodId = $oProducts->getProdId();
     if ($catId == null && $subCatId == null && $prodId == null) {
         $_breadcrumb = $this->view->breadcrumb(true) . "<b>" . $this->view->selectedPage . "</b>";
         return $_breadcrumb;
     } else {
         $pathElemts = $oProducts->getActions();
         if ($prodId) {
             $_class = '';
             $product = new ProductsObject();
             $details = $product->populate($prodId, $langId);
             if ($_first) {
                 $_class = 'current_page';
             }
             $link = $_first ? "<b>" . $details['PI_Name'] . "</b>" : "<a href='{$_baseUrl}/{$this->view->selectedPage}/{$pathElemts[0]}/{$pathElemts[1]}/{$pathElemts[2]}' class='{$_class}'>{$details['PI_Name']}</a>";
             array_push($_breadcrumb, $link);
             if ($_first) {
                 $_first = false;
             }
         }
         if ($subCatId) {
             $_class = '';
             $object = new SubCategoriesObject();
             $details = $object->populate($subCatId, $langId);
             if ($_first) {
                 $_class = 'current_page';
             }
             $link = $_first ? "<b>" . $details['SCI_Name'] . "</b>" : "<a href='{$_baseUrl}/{$this->view->selectedPage}/{$pathElemts[0]}/{$pathElemts[1]}' class='{$_class}'>{$details['SCI_Name']}</a>";
             array_push($_breadcrumb, $link);
             if ($_first) {
                 $_first = false;
             }
         }
         if ($catId) {
             $_class = '';
             $object = new CatalogCategoriesObject();
             $details = $object->populate($catId, $langId);
             if ($_first) {
                 $_class = 'current_page';
             }
             $link = $_first ? "<b>" . $details['CCI_Name'] . "</b>" : "<a href='{$_baseUrl}/{$this->view->selectedPage}/{$pathElemts[0]}' class='{$_class}'>{$details['CCI_Name']}</a>";
             array_push($_breadcrumb, $link);
             if ($_first) {
                 $_first = false;
             }
         }
         $details = Cible_FunctionsPages::getPageDetails($this->view->currentPageID, $langId);
         $link = $_first ? '' : "<a href='{$_baseUrl}/{$details['PI_PageIndex']}' class='{$_class}'>{$details['PI_PageTitle']}</a>";
         array_push($_breadcrumb, $link);
         if ($showHome) {
             $homeDetails = Cible_FunctionsPages::getHomePageDetails();
             $link = "<a href='{$_baseUrl}/{$homeDetails['PI_PageIndex']}' class='{$_class}'>" . $homeDetails['PI_PageTitle'] . "</a>";
             array_push($_breadcrumb, $link);
         }
         $_breadcrumb = array_reverse($_breadcrumb);
         //var_dump($_breadcrumb);
         //            for($i=0;$i<$level;$i++){
         //                array_splice($_breadcrumb,$i+1,1);
         //            }
         // add the > after the breadcrumb when only on item is found
         if (count($_breadcrumb) == 1) {
             return "{$_breadcrumb[0]} > ";
         } else {
             return implode(' > ', $_breadcrumb);
         }
     }
 }
Esempio n. 7
0
 function deleteAction()
 {
     $this->view->title = "Supprimer une page";
     // retrieve the ID of the parent page
     $PageID = $this->_getParam('ID');
     if (Cible_ACL::hasAccess($PageID)) {
         // generates tree by Language and send the result to the view
         Zend_Registry::set('baseUrl', $this->view->baseUrl());
         $this->view->TreeView = $this->view->getTreeView();
         if ($this->_request->isPost()) {
             //$PageID = (int)$this->_request->getPost('PageID');
             // if is set delete, then delete
             $delete = isset($_POST['delete']);
             if ($delete && $PageID > 0) {
                 Cible_FunctionsPages::deleteAllChildPage($PageID);
                 Cible_FunctionsPages::deleteAllBlock($PageID);
                 $pageSelect = new PagesIndex();
                 $select = $pageSelect->select()->where('PI_PageID = ?', $PageID);
                 $pageData = $pageSelect->fetchAll($select)->toArray();
                 foreach ($pageData as $page) {
                     $indexData['moduleID'] = 0;
                     $indexData['contentID'] = $PageID;
                     $indexData['languageID'] = $page['PI_LanguageID'];
                     $indexData['action'] = 'delete';
                     Cible_FunctionsIndexation::indexation($indexData);
                 }
                 $Page = new Pages();
                 $Where = 'P_ID = ' . $PageID;
                 $Page->delete($Where);
                 $PageIndex = new PagesIndex();
                 $Where = 'PI_PageID = ' . $PageID;
                 $PageIndex->delete($Where);
                 if (!$this->_request->isXmlHttpRequest()) {
                     $this->_redirect('/');
                 }
             } else {
                 if (!$this->_isXmlHttpRequest) {
                     $this->_redirect('/page/edit/ID/' . $PageID);
                 }
             }
         } else {
             if ($PageID > 0) {
                 $Page = new Pages();
                 $this->view->page = $Page->fetchRow('P_ID=' . $PageID);
                 $PageIndex = new PagesIndex();
                 $Select = $PageIndex->select()->where("PI_PageID = ?", $PageID)->where("PI_LanguageID = ?", $this->_defaultEditLanguage);
                 $this->view->pageindex = $PageIndex->fetchRow($Select);
             }
         }
     }
 }
Esempio n. 8
0
 /**
  * Controller action to manage the details of the cart.
  * Update/delete items or load the list.
  *
  * @return void
  */
 public function cartdetailsAction()
 {
     $account = Cible_FunctionsGeneral::getAuthentication();
     if (!$account) {
         $this->_redirect(Cible_FunctionsPages::getPageNameByID(1, Zend_Registry::get('languageID')));
     }
     $productData = array();
     $cart = new Cart();
     if ($this->_isXmlHttpRequest) {
         $this->disableLayout();
         $this->disableView();
         $action = $this->_getParam('do');
         $productId = $this->_getParam('pId');
         $itemId = $this->_getParam('itemId');
         $quantity = $this->_getParam('quantity');
         $size = $this->_getParam('size');
         $category = $this->_getParam('category');
         $disable = $this->_getParam('disable');
         $cartId = $this->_getParam('cartItemsId');
         if ($action == 'update' && !empty($productId)) {
             if (!empty($size)) {
                 $cart->updateItem($productId, -1, array('CI_TailleID' => $size, 'CI_ItemID' => $itemId, 'CI_CartItemsID' => $cartId));
             } elseif (!empty($category)) {
                 $cart->updateItem($productId, -1, array('CI_CatTailleID' => $category, 'CI_ItemID' => $itemId, 'CI_CartItemsID' => $cartId));
             } else {
                 $oItem = new ItemsObject();
                 $oItem->setId($itemId);
                 $amount = $oItem->getPrice($quantity);
                 $cart->updateItem($productId, $quantity, array('CI_ItemID' => $itemId, 'CI_Total' => $amount, 'CI_CartItemsID' => $cartId));
             }
             echo 'updated';
         } elseif ($action == 'delete' && !empty($productId)) {
             if ($itemId && $cartId) {
                 $cart->updateItem($productId, 0, array('CI_ItemID' => $itemId, 'CI_CartItemsID' => $cartId));
                 echo 'deletedRow';
             } else {
                 $cart->updateItem($productId);
                 echo 'deleted';
             }
         } elseif ($action == 'disable' && !empty($productId)) {
             $cart->updateItem($productId, -1, array('CI_IsToSend' => $disable, 'CI_ItemID' => $itemId));
         } elseif ($action == 'addSize' && !empty($productId)) {
             $lastId = $cart->addSize(array('CI_ID' => $productId, 'CI_Quantity' => 1, 'CI_CatTailleID' => $category, 'CI_ItemID' => $itemId));
         } elseif ($action == 'getSizes' && !empty($category)) {
             $oSize = new TailleObject();
             $langId = $this->_getParam('langId');
             $size = $oSize->getDataByCategoryTailleId($category, $langId);
             echo json_encode($size);
             exit;
         }
     } else {
         $url = $this->view->absolute_web_root . $this->getRequest()->getPathInfo();
         $exclude = preg_match('/resume-order/', $url);
         if (!$exclude) {
             Cible_View_Helper_LastVisited::saveThis($url);
         }
         $urlBack = '';
         $urlNextStep = '';
         $urls = Cible_View_Helper_LastVisited::getLastVisited();
         if (count($urls) > 1) {
             $urlBack = $urls[1];
         }
         $account = Cible_FunctionsGeneral::getAuthentication();
         $profile = new MemberProfile();
         $memberData = $profile->findMember(array('email' => $account['email']));
         $memberData = $profile->addTaxRate($memberData);
         //            if ($memberData['validatedEmail'] == '')
         //                $this->view->assign('valide', true);
         //            else
         //                $this->view->assign('valide', false);
         $cartData = $cart->getAllIds();
         $allIds = $cartData['cartId'];
         if (count($allIds)) {
             $urlNextStep = $this->view->baseUrl() . '/' . Cible_FunctionsPages::getPageNameByID($this->_orderPageId, Zend_Registry::get('languageID')) . '/auth-order/';
         }
         $this->view->assign('itemCount', count($allIds));
         $this->view->assign('cartTotal', $cart->getTotalItem());
         $oProduct = new ProductsCollection();
         //            $orderPageId = Cible_FunctionsCategories::getPagePerCategoryView(0, 'order', 17);
         $resume = false;
         if ($this->_registry->pageID == $this->_orderPageId) {
             $resume = true;
         }
         foreach ($allIds as $key => $id) {
             $itemId = $cartData['itemId'][$key];
             $prodId = $cartData['prodId'][$key];
             $productData[$id] = $oProduct->getDetails($prodId, $itemId, $resume);
             $cartDetails = $cart->getItem($id, $itemId);
             if ($resume) {
                 $renderItem = $cart->renderResume($cartDetails, $itemId);
             } else {
                 $renderItem = $cart->renderCartLine($cartDetails, $itemId);
             }
             $productData[$id]['items']['render'] = $renderItem;
             $productData[$id]['cart']['disable'] = $cartDetails['Disable'];
             $productData[$id]['cart']['promoId'] = $cartDetails['PromoId'];
         }
         $hasBonus = $oProduct->getBonus();
         $orderParams = Cible_FunctionsGeneral::getParameters();
         $parameters = array('nbPoint' => 0, 'taxeProv' => $memberData['taxProv'], 'taxeCode' => $memberData['taxCode'], 'tpsFee' => $orderParams['CP_ShippingFees'], 'limitTpsFee' => $orderParams['CP_ShippingFeesLimit'], 'CODFees' => $orderParams['CP_MontantFraisCOD'], 'noProvTax' => $memberData['noProvTax'], 'noFedTax' => $memberData['noFedTax']);
         if ($memberData['taxCode'] == 'QC') {
             $parameters['taxeFed'] = $orderParams['CP_TauxTaxeFed'];
         }
         if ($hasBonus) {
             $parameters['nbPoint'] = $orderParams['CP_BonusPointDollar'];
         }
         $this->view->assign('productData', $productData);
         $this->view->assign('urlBack', $urlBack);
         $this->view->assign('nextStep', $urlNextStep);
         $this->view->assign('step', 1);
         $this->view->assign('hasBonus', $oProduct->getBonus());
         $this->view->assign('parameters', $parameters);
         if ($this->_registry->pageID == $this->_orderPageId) {
             $this->renderScript('index/cart-summary.phtml');
         } else {
             $this->renderScript('index/cart-details.phtml');
         }
     }
 }
Esempio n. 9
0
 public function indexAction()
 {
     $Param = $this->_getParam('Param');
     $Action = $Param['action'];
     // if user has an account and is logged
     $islogged = Cible_FunctionsGeneral::getAuthentication();
     Zend_Registry::set('user', $islogged);
     // grab the Id, language and title of the page called
     $Row = $this->_getParam('Row');
     $view_template = $Row['V_Path'];
     Zend_Registry::set('pageID', $Row['PI_PageID']);
     Zend_Registry::set('languageID', $Row['PI_LanguageID']);
     Zend_Registry::set('currentUrlAction', $this->_request->getParam('action'));
     $session = new Cible_Sessions();
     $session->languageID = $Row['PI_LanguageID'];
     Zend_Registry::set('altImageFirst', $Row['PI_AltPremiereImage']);
     Zend_Registry::set('languageSuffix', $Row['L_Suffix']);
     $languageSuffix = $Row['L_Suffix'];
     Zend_Registry::set('pageTitle', $Row['PI_PageTitle']);
     Zend_Registry::set('pageIndex', $Row['PI_PageIndex']);
     Zend_Registry::set('current_theme', $Row['PT_Folder']);
     if (!Zend_Registry::isRegistered('selectedItemMenuLevel')) {
         Zend_Registry::set('selectedItemMenuLevel', 0);
     }
     Zend_Registry::set('config', $this->_config);
     $absolute_web_root = Zend_Registry::get('absolute_web_root');
     // Set Meta Tags
     $this->view->headMeta()->appendName('viewport', 'width=device-width, initial-scale=1.0');
     $this->view->headMeta()->appendName('Author', 'Cible Solutions d\'Affaires');
     $this->view->headMeta()->appendName('Copyright', 'Cible Solutions d\'Affaires - ' . date('Y'));
     $this->view->headMeta()->appendName('Publisher', 'Cible Solutions d\'Affaires - ' . date('Y'));
     $this->view->headMeta()->appendName('Language', Zend_Registry::get("languageSuffix"));
     $this->view->placeholder('metaOther')->set($Row['PI_MetaOther']);
     $this->view->headMeta()->appendName('Description', $Row['PI_MetaDescription']);
     $this->view->headMeta()->appendName('Keywords', $Row['PI_MetaKeywords']);
     $this->view->headMeta()->appendName('Robots', 'all, noodp');
     $this->view->headMeta()->appendName('Date-Revision-yyyymmdd', date('Ymd'));
     $this->view->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=utf-8');
     $this->view->headMeta()->appendHttpEquiv('Content-Language', $languageSuffix . '-ca');
     $this->view->headMeta()->appendHttpEquiv('X-UA-Compatible', 'IE=8');
     $this->view->headMeta()->appendName('DC.Description', $Row['PI_MetaDescription']);
     $this->view->headMeta()->appendName('DC.Subject', $Row['PI_MetaKeywords']);
     $this->view->headMeta()->appendName('DC.format', 'text/html');
     $this->view->headMeta()->appendName('DC.language', $languageSuffix . '-ca', array('scheme' => 'RFC3066'));
     $clientLogo = $this->_config->clientLogo->src;
     Zend_Registry::set('addThis', "{$absolute_web_root}/themes/default/images/{$languageSuffix}/{$clientLogo}");
     $this->view->assign('showTitle', $Row['P_ShowTitle']);
     $this->view->assign('selectedPage', $Row['PI_PageIndex']);
     $this->view->assign('imgHeader', $Row['PI_TitleImageSrc']);
     $this->view->assign('PI_Secure', $Row['PI_Secure']);
     $this->view->assign('PI_TitleImageAlt', $Row['PI_TitleImageAlt']);
     $currentPageID = $Row['PI_PageID'];
     // finds the current page layout and swap it
     $layout_file = Cible_FunctionsPages::getLayoutPath($currentPageID);
     $this->_helper->layout->setLayout(str_replace('.phtml', '', $layout_file));
     // put the baseurl on a registry key
     Zend_Registry::set('baseUrl', $this->getFrontController()->getBaseUrl());
     // display the page title on the website
     if (!empty($Row['PI_MetaTitle'])) {
         $this->view->headTitle($Row['PI_MetaTitle']);
         $this->view->headMeta()->appendName('DC.title', $Row['PI_MetaTitle']);
     } else {
         $this->view->headTitle($this->_config->site->title);
         $this->view->headTitle()->setSeparator(' > ');
         $this->view->headTitle(Zend_Registry::get("pageTitle"));
     }
     // display metadata on the website
     $this->view->metaDescription = $Row['PI_MetaDescription'];
     $this->view->metaKeywords = $Row['PI_MetaKeywords'];
     $this->view->pageTitle = $Row['PI_PageTitle'];
     // make a request to get all the blocks to be displayed
     $Blocks = new Blocks();
     $Select = $Blocks->select()->setIntegrityCheck(false);
     $Select->from('Blocks')->join('Modules', 'Modules.M_ID = Blocks.B_ModuleID')->join('Parameters', 'Parameters.P_BlockID = Blocks.B_ID', array('B_Action' => 'P_Value'))->where('Parameters.P_Number  = ?', 999)->where('Blocks.B_PageID = ?', Zend_Registry::get("pageID"))->where('Blocks.B_Online = ?', 1)->order('Blocks.B_Position ASC');
     //        if (!$islogged)
     //            $Select->where ('B_Secured = ?', 0);
     $Rows = $Blocks->fetchAll($Select);
     // Actions to be called in the view for rendering the page's blocks
     $blocks = array();
     // for all blocks to display, call the proper controller module
     foreach ($Rows as $Row) {
         $Module = $Row['M_MVCModuleTitle'];
         $ActionIndex = $Row['B_Action'];
         $Param['BlockID'] = $Row['B_ID'];
         $Param['secured'] = $Row['B_Secured'];
         if (!isset($blocks[$Row['B_ZoneID']])) {
             $blocks[$Row['B_ZoneID']] = array();
         }
         array_push($blocks[$Row['B_ZoneID']], array('action' => $ActionIndex, 'controller' => 'index', 'module' => $Module, 'params' => $Param));
     }
     $this->view->assign('blocks', $blocks);
     $this->view->assign('view_template', $view_template);
     $this->view->assign('currentPageID', $currentPageID);
     $this->view->assign('absolute_web_root', $absolute_web_root);
     $i = 0;
     foreach ($this->_config->themes->default->styles as $style) {
         if (!is_null($style->ie_version)) {
             $this->view->headLink()->offsetSetStylesheet(200 + $i, "{$this->view->baseUrl()}/themes/default/css/{$style->filename}", $style->media, $style->ie_version);
             $this->view->headLink()->prependStylesheet("{$this->view->baseUrl()}/themes/default/css/{$style->filename}", $style->media, $style->ie_version);
         } else {
             $this->view->headLink()->offsetSetStylesheet(1, "{$this->view->baseUrl()}/themes/default/css/{$style->filename}", $style->media);
             $this->view->headLink()->prependStylesheet("{$this->view->baseUrl()}/themes/default/css/{$style->filename}", $style->media);
         }
         $i++;
     }
     $this->view->headLink(array('rel' => 'canonical', 'href' => $absolute_web_root . $this->_request->getPathInfo()));
     if ($this->_config->fontController->embeded) {
         $this->view->headScript()->appendFile($this->view->locateFile('font-controller.js', 'jquery'));
         $this->view->headScript()->appendFile($this->view->locateFile('jquery.cookie.js', 'jquery'));
     }
     if ($this->_config->addthisWidget->embeded) {
         $this->view->headScript()->appendFile($this->view->locateFile('addthis_widget.js'));
     }
     if ($this->_config->setBgStyle) {
         $this->view->setBgStyle();
     }
 }
Esempio n. 10
0
 public function subscribeAction()
 {
     // VARIABLES
     $blockID = $this->_getParam('BlockID');
     $config = Zend_Registry::get('config');
     $pageId = $config->privacyPolicy->pageId;
     $urlPrivacy = Cible_FunctionsPages::getPageLinkByID($pageId);
     $messageConf = str_replace('##URL##', $urlPrivacy, $this->view->getCibleText('joindre_fo_form_label_confident_joindre'));
     $this->view->assign('messageConfidentialite', $messageConf);
     $newsletterID = $this->_getParam('newsletterID');
     $back_to_newsletter = !empty($newsletterID) ? "/ID/{$newsletterID}" : '';
     $blockParams = Cible_FunctionsBlocks::getBlockParameters($blockID)->toArray();
     $newsletterCategoryID = $blockParams[0]['P_Value'];
     $newsletterCategoryDetails = Cible_FunctionsCategories::getCategoryDetails($newsletterCategoryID);
     $this->view->assign('newsletterTitle', $newsletterCategoryDetails['CI_Title']);
     $this->view->assign('subscribeLink', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'subscribe', 8));
     $this->view->assign('unsubscribeLink', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'unsubscribe', 8));
     $this->view->assign('back_to_release', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'details_release', 8) . $back_to_newsletter);
     $this->view->assign('archivesLink', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'list_archives', 8) . '/categoryID/' . $newsletterCategoryID);
     $form = new FormNewsletterSubscription(array());
     $this->view->assign('form', $form);
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         //$this->view->dump($formData);
         if (array_key_exists('subscribe', $formData)) {
             if ($form->isValid($formData)) {
                 $messageSuccess = str_replace('###member_name###', " <b>{$formData['firstName']} {$formData['lastName']}</b>", $this->view->getCibleText('newsletter_subscribe_confirmation_message1'));
                 $messageSuccess = str_replace('###img-pierre-gervais###', $this->view->baseUrl() . '/themes/default/images/common/img-signature-pierre-gervais.png', $messageSuccess);
                 $message[0] = $messageSuccess;
                 $message[1] = $this->view->getCibleText('newsletter_subscribe_confirmation_message2');
                 $this->view->assign('inscriptionValidate', true);
                 $this->view->assign('returnLink', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'subscribe', 8));
                 $genericProfil = new GenericProfile();
                 $members = $genericProfil->findMembers(array('email' => $formData['email']));
                 $memberProfile = new MemberProfile();
                 // if member dont exist in the system
                 if (count($members) == 0) {
                     $newsletterProfile = new NewsletterProfile();
                     $formData['newsletter_categories'] = $newsletterCategoryID;
                     $newsletterProfile->addMember($formData);
                     $members = $genericProfil->findMembers(array('email' => $formData['email']));
                     $memberID = $members[0]['member_id'];
                     $memberProfile->updateMember($memberID, $formData);
                     $this->view->assign('message', $message[0]);
                 } else {
                     $memberID = $members[0]['member_id'];
                     $newsletterProfile = new NewsletterProfile();
                     $memberDetails = $newsletterProfile->getMemberDetails($memberID);
                     //if(array_key_exists('newsletter_categories',$memberDetails)){
                     if ($memberDetails != '') {
                         $memberNewsletterCategories = explode(',', $memberDetails['newsletter_categories']);
                         // if member is already subscribe to the newsletter
                         if (in_array($newsletterCategoryID, $memberNewsletterCategories)) {
                             $this->view->assign('message', $message[1]);
                         } else {
                             $memberNewsletterCategories[] = $newsletterCategoryID;
                             $newMemberNewsletterCategories = implode(',', $memberNewsletterCategories);
                             $newsletterProfile->updateMember($memberID, array('newsletter_categories' => $newMemberNewsletterCategories));
                             $this->view->assign('message', $message[0]);
                         }
                     } else {
                         $newsletterProfile->updateMember($memberID, array('newsletter_categories' => $newsletterCategoryID));
                         $this->view->assign('message', $message[0]);
                     }
                 }
                 $this->_params = array('memberId' => $memberID, 'category' => $newsletterCategoryID);
                 $this->logSubscription();
             }
         } elseif (array_key_exists('unsubscribe', $formData)) {
             $this->_redirect(Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'unsubscribe', 8));
         }
     }
 }
 function addAction()
 {
     // page title
     $this->view->title = "Ajout d'un groupe d'administrateur";
     // js import
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/js/administrator.js');
     /********** ACTIONS ***********/
     $form = new FormExtranetGroup(array('baseDir' => $this->view->baseUrl()));
     $form->setDecorators(array('PrepareElements', array('ViewScript', array('viewScript' => 'administrator-group/formGroup.phtml'))));
     $returnLink = $this->view->url(array('controller' => 'administrator-group', 'action' => 'index'));
     $form->getElement('cancel')->setAttrib('onclick', 'document.location.href="' . $returnLink . '"');
     $this->view->form = $form;
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             // validate name is unique
             $findGroup = new ExtranetGroupsIndex();
             $select = $findGroup->select()->where('EGI_Name = ?', $form->getValue('EGI_Name'));
             $findGroupData = $findGroup->fetchAll($select);
             // name is allready use
             if ($findGroupData->count() > 0) {
                 $form->getElement('EGI_Name')->addError('Un autre groupe possède déjà ce nom');
             } else {
                 // create group
                 $groupData = new ExtranetGroups();
                 $row = $groupData->createRow();
                 $row->EG_Status = $form->getValue('EG_Status');
                 $row->save();
                 $groupID = $row->EG_ID;
                 // create index group as many language in the system
                 $languages = Cible_FunctionsGeneral::getAllLanguage();
                 foreach ($languages as $language) {
                     $groupData = new ExtranetGroupsIndex();
                     $row = $groupData->createRow();
                     $row->EGI_GroupID = $groupID;
                     $row->EGI_LanguageID = $language["L_ID"];
                     $row->EGI_Name = $form->getValue('EGI_Name');
                     $row->EGI_Description = $form->getValue('EGI_Description');
                     $row->save();
                 }
                 // get pages data
                 $pagesArray = Cible_FunctionsPages::getAllPagesDetailsArray();
                 // save group pages permissions
                 if (!empty($_POST["submitSave"])) {
                     // save pages access
                     //$this->deleteGroupPagesPermissions($newInsertID);
                     $this->saveGroupPagesPermissions($groupID, $pagesArray, $_POST, "structure");
                     $this->saveGroupPagesPermissions($groupID, $pagesArray, $_POST, "data");
                     // save roles
                     //$this->deleteGroupRoles($newInsertID);
                     $this->saveGroupRoles($groupID, $_POST);
                 }
                 header("location:" . $returnLink);
             }
         }
     }
 }
Esempio n. 12
0
 public function __construct($options = null)
 {
     $this->_disabledDefaultActions = true;
     parent::__construct($options);
     $baseDir = $this->getView()->baseUrl();
     if (!empty($options['mode']) && $options['mode'] == 'edit') {
         $this->_mode = 'edit';
     } else {
         $this->_mode = 'add';
     }
     $langId = Zend_Registry::get('languageID');
     $this->setAttrib('id', 'accountManagement');
     $this->setAttrib('class', 'step3');
     //            $addressParams = array(
     //                "fieldsValue" => array(),
     //                "display"   => array(),
     //                "required" => array(),
     //            );
     //Hidden fields for the state and cities id
     $selectedState = new Zend_Form_Element_Hidden('selectedState');
     $selectedState->removeDecorator('label');
     $selectedCity = new Zend_Form_Element_Hidden('selectedCity');
     $selectedCity->removeDecorator('label');
     $this->addElement($selectedState);
     $this->addElement($selectedCity);
     // Salutation
     $salutation = new Zend_Form_Element_Select('salutation');
     $salutation->setLabel($this->getView()->getCibleText('form_label_salutation'))->setAttrib('class', 'smallTextInput')->setOrder(1);
     $greetings = $this->getView()->getAllSalutation();
     foreach ($greetings as $greeting) {
         $salutation->addMultiOption($greeting['S_ID'], $greeting['ST_Value']);
     }
     // language hidden field
     $language = new Zend_Form_Element_Hidden('language', array('value' => $langId));
     $language->removeDecorator('label');
     // langauge hidden field
     // FirstName
     $firstname = new Zend_Form_Element_Text('firstName');
     $firstname->setLabel($this->getView()->getCibleText('form_label_fName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('class' => 'stdTextInput'))->setOrder(2);
     // LastName
     $lastname = new Zend_Form_Element_Text('lastName');
     $lastname->setLabel($this->getView()->getCibleText('form_label_lName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('class' => 'stdTextInput'))->setOrder(3);
     // email
     $regexValidate = new Cible_Validate_Email();
     $regexValidate->setMessage($this->getView()->getCibleText('validation_message_emailAddressInvalid'), 'regexNotMatch');
     $emailNotFoundInDBValidator = new Zend_Validate_Db_NoRecordExists('GenericProfiles', 'GP_Email');
     $emailNotFoundInDBValidator->setMessage($this->getView()->getClientText('validation_message_email_already_exists'), 'recordFound');
     $email = new Zend_Form_Element_Text('email');
     $email->setLabel($this->getView()->getCibleText('form_label_email'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addFilter('StringToLower')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->addValidator($regexValidate)->setAttribs(array('maxlength' => 50, 'class' => 'stdTextInput'))->setOrder(4);
     if ($this->_mode == 'add') {
         $email->addValidator($emailNotFoundInDBValidator);
     }
     // email
     // password
     $password = new Zend_Form_Element_Password('password');
     if ($this->_mode == 'add') {
         $password->setLabel($this->getView()->getCibleText('form_label_password'));
     } else {
         $password->setLabel($this->getView()->getCibleText('form_label_newPwd'));
     }
     $password->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('class', 'stdTextInput')->setRequired(true)->setOrder(5)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))));
     // password
     // password confirmation
     $passwordConfirmation = new Zend_Form_Element_Password('passwordConfirmation');
     if ($this->_mode == 'add') {
         $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmPwd'));
     } else {
         $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmNewPwd'));
     }
     $passwordConfirmation->addFilter('StripTags')->addFilter('StringTrim')->setRequired(true)->setOrder(6)->setAttrib('class', 'stdTextInput');
     if (!empty($_POST['identification']['password'])) {
         $passwordConfirmation->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('error_message_password_isEmpty'))));
         $Identical = new Zend_Validate_Identical($_POST['identification']['password']);
         $Identical->setMessages(array('notSame' => $this->getView()->getCibleText('error_message_password_notSame')));
         $passwordConfirmation->addValidator($Identical);
     }
     // password confirmation
     // Company name
     $company = new Zend_Form_Element_Text('company');
     $company->setLabel($this->getView()->getCibleText('form_label_company'))->setRequired(false)->setOrder(7)->setAttribs(array('class' => 'stdTextInput'));
     // function in company
     $functionCompany = new Zend_Form_Element_Text('functionCompany');
     $functionCompany->setLabel($this->getView()->getCibleText('form_label_account_function_company'))->setRequired(false)->setOrder(8)->setAttribs(array('class' => 'stdTextInput'));
     // Are you a retailer
     $retailer = new Zend_Form_Element_Select('isRetailer');
     $retailer->setLabel($this->getView()->getClientText('form_label_retailer'))->setAttrib('class', 'smallTextInput');
     $retailer->addMultiOption(0, $this->getView()->getCibleText('button_no'));
     $retailer->addMultiOption(1, $this->getView()->getCibleText('button_yes'));
     // Text Subscribe
     $textSubscribe = $this->getView()->getCibleText('form_label_subscribe');
     $textSubscribe = str_replace('%URL_PRIVACY_POLICY%', Cible_FunctionsPages::getPageLinkByID($this->_config->page_privacy_policy->pageID), $textSubscribe);
     // Newsletter subscription
     $newsletterSubscription = new Zend_Form_Element_Checkbox('newsletterSubscription');
     $newsletterSubscription->setLabel($textSubscribe);
     if ($this->_mode == 'add') {
         $newsletterSubscription->setChecked(1);
     }
     $newsletterSubscription->setAttrib('class', 'long-text');
     $newsletterSubscription->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
     if ($this->_mode == 'add') {
         $termsAgreement = new Zend_Form_Element_Checkbox('termsAgreement');
         $termsAgreement->setLabel(str_replace('%URL_TERMS_CONDITIONS%', Cible_FunctionsPages::getPageLinkByID($this->_config->termsAndConditions->pageId), $this->getView()->getClientText('form_label_terms_agreement')));
         $termsAgreement->setAttrib('class', 'long-text');
         $termsAgreement->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
         $termsAgreement->setRequired(true);
         $termsAgreement->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'You must agree to the terms')));
     } else {
         $termsAgreement = new Zend_Form_Element_Hidden('termsAgreement', array('value' => 1));
     }
     // Submit button
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel($this->getView()->getCibleText('form_label_next_step_btn'))->setAttrib('class', 'nextStepButton');
     // Reference number for the job
     $txtConnaissance = new Cible_Form_Element_Html('knowYou', array('value' => $this->getView()->getCibleText('form_account_mieux_vous_connaitre_legend')));
     $txtConnaissance->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'description left'))));
     $refJobId = new Zend_Form_Element_Text('refJobId');
     $refJobId->setLabel('refJobId')->setRequired(false)->setAttribs(array('class' => 'stdTextInput'));
     // Reference number for the role
     $refRoleId = new Zend_Form_Element_Text('refRoleId');
     $refRoleId->setLabel('refRoleId')->setRequired(false)->setAttribs(array('class' => 'stdTextInput'));
     // Reference number for the job title
     $refJobTitleId = new Zend_Form_Element_Text('refJobTitleId');
     $refJobTitleId->setLabel('refJobTitleId')->setRequired(false)->setAttribs(array('class' => 'stdTextInput'));
     $refJobTitleId = new Zend_Form_Element_Text('refJobTitleId');
     $refJobTitleId->setLabel('refJobTitleId')->setRequired(false)->setAttribs(array('class' => 'stdTextInput'));
     // Provincial tax exemption
     $noProvTax = new Zend_Form_Element_Checkbox('noProvTax');
     $noProvTax->setLabel($this->getView()->getCibleText('form_label_account_provincial_tax'));
     $noProvTax->setAttrib('class', 'long-text')->setOrder(13);
     $noProvTax->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
     // Provincial tax exemption
     $noFedTax = new Zend_Form_Element_Checkbox('noFedTax');
     $noFedTax->setLabel($this->getView()->getCibleText('form_label_account_federal_tax'));
     $noFedTax->setAttrib('class', 'long-text')->setOrder(14);
     $noFedTax->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
     /*  Identification sub form */
     $identificationSub = new Zend_Form_SubForm();
     $identificationSub->setName('identification')->removeDecorator('DtDdWrapper');
     $identificationSub->setLegend($this->getView()->getCibleText('form_account_subform_identification_legend'));
     $identificationSub->setAttrib('class', 'identificationClass subFormClass');
     $identificationSub->addElement($language);
     $identificationSub->addElement($salutation);
     $identificationSub->addElement($lastname);
     $identificationSub->addElement($firstname);
     $identificationSub->addElement($email);
     $identificationSub->addElement($password);
     $identificationSub->addElement($passwordConfirmation);
     $identificationSub->addElement($company);
     $this->addSubForm($identificationSub, 'identification');
     //            $identificationSub->addElement($functionCompany);
     $addrContactMedia = new Cible_View_Helper_FormAddress($identificationSub);
     if ($options['resume']) {
         $addrContactMedia->setProperty('addScript', false);
     }
     $addrContactMedia->enableFields(array('firstTel', 'secondTel', 'fax', 'webSite'));
     $addrContactMedia->formAddress();
     $identificationSub->addElement($noProvTax);
     $identificationSub->addElement($noFedTax);
     /*  Identification sub form */
     /* billing address */
     // Billing address
     $addressFacturationSub = new Zend_Form_SubForm();
     $addressFacturationSub->setName('addressFact')->removeDecorator('DtDdWrapper');
     $addressFacturationSub->setLegend($this->getView()->getCibleText('form_account_subform_addBilling_legend'));
     $addressFacturationSub->setAttrib('class', 'addresseBillingClass subFormClass');
     $billingAddr = new Cible_View_Helper_FormAddress($addressFacturationSub);
     $billingAddr->setProperty('addScriptState', false);
     if ($options['resume']) {
         $billingAddr->setProperty('addScript', false);
     }
     $billingAddr->enableFields(array('firstAddress', 'secondAddress', 'state', 'cityTxt', 'zipCode', 'country', 'firstTel', 'secondTel'));
     $billingAddr->formAddress();
     $addrBill = new Zend_Form_Element_Hidden('addrBill');
     $addrBill->removeDecorator('label');
     $addressFacturationSub->addElement($addrBill);
     $addressFacturationSub->getElement('AI_SecondAddress')->removeDecorator('label');
     $this->addSubForm($addressFacturationSub, 'addressFact');
     /* delivery address */
     $addrShip = new Zend_Form_Element_Hidden('addrShip');
     $addrShip->removeDecorator('label');
     $addressShippingSub = new Zend_Form_SubForm();
     $addressShippingSub->setName('addressShipping')->removeDecorator('DtDdWrapper');
     $addressShippingSub->setLegend($this->getView()->getCibleText('form_account_subform_addShipping_legend'));
     $addressShippingSub->setAttrib('class', 'addresseShippingClass subFormClass');
     $shipAddr = new Cible_View_Helper_FormAddress($addressShippingSub);
     if ($options['resume']) {
         $shipAddr->setProperty('addScript', false);
     }
     $shipAddr->duplicateAddress($addressShippingSub);
     $shipAddr->setProperty('addScriptState', false);
     $shipAddr->enableFields(array('firstAddress', 'secondAddress', 'state', 'cityTxt', 'zipCode', 'country', 'firstTel', 'secondTel'));
     $shipAddr->formAddress();
     $addressShippingSub->addElement($addrShip);
     $this->addSubForm($addressShippingSub, 'addressShipping');
     if ($this->_mode == 'edit') {
         $this->addElement($termsAgreement);
     }
     $this->addElement($submit);
     $submit->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'stepBottomNext'))));
     if ($this->_mode == 'add') {
         $termsAgreement->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox', 'id' => 'dd-terms-agreement'))));
     }
 }
Esempio n. 13
0
 public function breadcrumb()
 {
     $pageId = Zend_Registry::get('pageID');
     return Cible_FunctionsPages::buildClientBreadcrumb($pageId, 1);
 }
Esempio n. 14
0
 public function listcollectionsAction()
 {
     $langId = Zend_Registry::get('languageID');
     $oSubCategories = new SubCategoriesObject();
     $subCategories = $oSubCategories->getSubCatAsCollections($langId);
     $page = Cible_FunctionsPages::getPageNameByID(14080, $langId);
     $this->view->assign('collections', $subCategories);
     $this->view->assign('page', $page);
 }
Esempio n. 15
0
 public function buildCatalogMenu($options = array())
 {
     $menuCatalogId = 0;
     $defaultCat = '';
     if (isset($options['menu'])) {
         $oMenu = new MenuObject($options['menu']);
         $menuCatalog = $oMenu->getMenuItemByPageId(null, 'catalog');
         //            if ($this->view->currentPageID)
         //            {
         //                $parentPage = Cible_FunctionsPages::findParentPageID($this->view->currentPageID);
         //                while ($parentPage['P_ParentID'] != 0 )
         //                {
         //                   $parentPage = Cible_FunctionsPages::findParentPageID($parentPage['P_ParentID']);
         //                }
         //
         //                $pageId      = $parentPage['P_ID'];
         //                $menuCatalog = $oMenu->getMenuItemByPageId($pageId);
         //            }
         //            else
         //            {
         //                $menuCatalog = $oMenu->getMenuItemByPageId();
         $parentPage = Cible_FunctionsPages::findParentPageID($menuCatalog['MII_PageID']);
         //            }
     }
     if ($this->view->controller != $parentPage['PI_PageIndex']) {
         $link = $parentPage['PI_PageIndex'] . "/";
     } else {
         $link = $this->view->selectedPage . "/";
     }
     $tree = array();
     $langId = Zend_Registry::get('languageID');
     $oCategories = new CatalogCategoriesObject();
     if (Zend_Registry::isRegistered('defaultCategory') && !is_null(Zend_Registry::get('defaultCategory'))) {
         $defaultCatId = Zend_Registry::get('defaultCategory');
         $tmpCat = $oCategories->populate($defaultCatId, $langId);
         if (empty($tmpCat['CI_ValUrl'])) {
             $tmpCat['CI_ValUrl'] = "";
         }
         $defaultCat = $tmpCat['CI_ValUrl'];
     }
     $categories = $oCategories->getAll($langId);
     $oSubCategories = new SubCategoriesObject();
     $catalog = array('ID' => $menuCatalog['MID_ID'], 'Title' => $menuCatalog['MII_Title'], 'PageID' => '', 'Link' => $link . $defaultCat, 'Placeholder' => 0, 'child' => array());
     foreach ($categories as $category) {
         $childs = array();
         $id = $category['C_ID'];
         $name = Cible_FunctionsGeneral::formatValueForUrl($category['CI_Name']);
         $linkCat = $link . $name;
         $menu['ID'] = $category['C_ID'];
         $menu['Title'] = $category['CI_Name'];
         $menu['PageID'] = '';
         $menu['Link'] = $linkCat;
         $menu['Placeholder'] = '2';
         $subCategories = $oSubCategories->getSubCatByCategory($id, true, $langId);
         if ($options['nesting'] > 1) {
             foreach ($subCategories as $subCat) {
                 $name = "/" . Cible_FunctionsGeneral::formatValueForUrl($subCat['SCI_Name']);
                 $linkSubCat = $linkCat . $name;
                 $child['ID'] = $subCat['SC_ID'];
                 $child['Title'] = $subCat['SCI_Name'];
                 $child['PageID'] = '';
                 $child['Link'] = $linkSubCat;
                 $child['Placeholder'] = '2';
                 $childs[] = $child;
                 $name = '';
             }
         }
         $menu['child'] = $childs;
         $catalog['child'][] = $menu;
     }
     $oMenu = new MenuObject($options['menu']);
     $first = $oMenu->populate($menuCatalog['MID_ID']);
     $childCombined = array();
     if (isset($options['merge']) && $options['merge']) {
         $childCombined = array_merge($catalog['child'], $first);
         $catalog['child'] = $childCombined;
     }
     $tree[] = $catalog;
     return $tree;
 }
Esempio n. 16
0
 /**
  * Set default values and the first level container (ul)
  *
  * @param Mixed $menu    If String: Fecth menu data according its name.<br/>
  *                       If Array: It must contain the menu tree.
  *
  * @param array $options Options to manage menu behaviour<br />
  *                       Ex: disable_nesting => true, parentAltId => (string)
  *
  * @return string html code to display the menu and is children
  */
 public function subMenu($options = array())
 {
     if (isset($options['addEnclosure'])) {
         $this->_addEnclosure = $options['addEnclosure'];
     }
     if ($this->view->selectedPage) {
         $this->_selectedPage = $this->view->selectedPage;
     } elseif (Zend_Registry::isRegistered('selectedPage')) {
         $this->_selectedPage = Zend_Registry::get('selectedPage');
     } else {
         $params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
         $this->_selectedPage = $params['controller'];
         if ($params['controller'] == 'index') {
             $this->_selectedPage = Cible_FunctionsPages::getPageNameByID(1);
         }
     }
     $oPages = new PagesObject();
     $pageData = $oPages->pageIdByController($this->_selectedPage);
     $this->_selectedPageId = $pageData['P_ID'];
     $menuData = $oPages->getRelatedMenu($this->_selectedPageId);
     $parentId = 0;
     if (!$menuData) {
         $parentId = $oPages->getParentRelatedID($this->_selectedPageId);
         $parentName = $oPages->getParentRelatedName($parentId);
         $menuData = $oPages->getRelatedMenu($parentId);
         $this->_selectedPageId = $parentId;
         $parentId = $menuData['MID_ParentID'];
         $this->view->assign('selectedPage', $parentName);
         //echo $parentName;
     }
     $_menu = new MenuObject($menuData['MID_MenuId']);
     if ($menuData['MID_ParentID'] == 0) {
         $parentId = $menuData['MID_ID'];
     } else {
         $menuItem = $_menu->getMenuItemByPageId($this->_selectedPageId);
         if ($menuItem) {
             $this->_getParentsMenuId($menuItem, $_menu);
         }
         if ($parentId == 0) {
             $parentId = $this->_parentsMenuId[0];
         }
     }
     if (!empty($options['parentId'])) {
         $parentId = $options['parentId'];
     }
     if (preg_match('/useCatalog/', $menuData['MID_Style'])) {
         $menu_item['Placeholder'] = 2;
         $collections = new SubCategoriesObject();
         //                $menuCatalog = $this->getMenuItemByPageId( null, 'collections');
         $catalogMenu = $collections->buildCatalogMenu($menu_item, array('nesting' => 1));
         $tree = $catalogMenu['child'];
         //               $first = $this->populate($menuCatalog['MID_ID']);
         //               $childCombined = array();
         //                   $childCombined = array_merge($catalogMenu['child'], $first);
         //                   $catalog['child'] = $childCombined;
     } elseif (!empty($parentId)) {
         $tree = $_menu->populate($parentId);
     }
     $tree['MID_MenuID'] = $menuData['MID_MenuId'];
     $tree['MID_ParentId'] = $parentId;
     return $tree;
 }
Esempio n. 17
0
 private function _getParentsMenuId(array $itemMenu, MenuObject $oMenu = null)
 {
     if (is_null($oMenu)) {
         $page = Cible_FunctionsPages::getPageDetails($itemMenu['PageID'], Zend_Registry::get('languageID'));
         $page = $page->toArray();
         $menu = Cible_FunctionsPages::getMenuByPageId($page['P_ParentID']);
         /*var_dump($menu);*/
         $oMenu = new MenuObject($menu[0]['MID_MenuID']);
         $menuId = $menu[0]['MID_ID'];
     } else {
         $menuId = $itemMenu['MID_ParentID'];
     }
     $menuId = $itemMenu['MID_ParentID'];
     $tmpArray = array();
     while ($menuId != 0) {
         $details = $oMenu->getMenuItemById($menuId);
         array_push($tmpArray, $details['MID_ID']);
         $menuId = $details['MID_ParentID'];
     }
     $this->_parentsMenuId = $tmpArray;
 }
Esempio n. 18
0
 public static function buildUlLiMenu($baseUrl, $parentID = 0, $lang = null)
 {
     if ($lang == null) {
         $lang = Zend_Registry::get('currentEditLanguage');
     }
     $pages_list = Cible_FunctionsPages::getAllPagesDetailsArray(0, $lang);
     $_pages = array();
     foreach ($pages_list as $page) {
         $tmp = array('ID' => $page['P_ID'], 'Title' => $page['PI_PageTitle'], 'onClick' => "{$baseUrl}/page/index/index/ID/{$page['P_ID']}");
         if (!empty($page['child'])) {
             $tmp['child'] = self::fillULLIChildren($baseUrl, $page['child']);
         }
         array_push($_pages, $tmp);
     }
     return $_pages;
 }
Esempio n. 19
0
 public function editBlockAction()
 {
     // variables
     $_pageID = $this->_getParam('ID');
     $_blockID = $this->_getParam('blockID');
     $_baseDir = $this->getFrontController()->getBaseUrl();
     $this->view->assign('success', false);
     if (Cible_ACL::hasAccess($_pageID)) {
         // generate the form
         $_options = array('baseDir' => $_baseDir, 'pageID' => $_pageID, 'blockID' => $_blockID);
         $form = $this->getForm($_options);
         // get page informations
         $page = $this->view->page = Cible_FunctionsPages::getPageDetails($_pageID);
         $page_info = $page->toArray();
         // get block informations
         $block = Cible_FunctionsBlocks::getBlockDetailsByLangID($_blockID, $this->_currentEditLanguage);
         $this->view->assign('block_zone', $block['B_ZoneID']);
         $this->view->assign('blockID', $block['B_ID']);
         // send form the the viewer
         $form->submit->setLabel('Enregistrer');
         $this->view->form = $form;
         // action if user save
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 $this->saveBlock($formData, $_pageID, $_blockID);
                 if (!$this->_isXmlHttpRequest) {
                     $this->_redirect('/page/manage/index/ID/' . $_pageID);
                 } else {
                     $this->view->assign('success', true);
                     $this->view->assign('block_id', $block['B_ID']);
                     $this->view->assign('blockTitle', $block['BI_BlockTitle']);
                     $this->view->assign('blockLangID', $this->_currentEditLanguage);
                     $this->view->assign('blockDescription', $this->getManageDescription($_blockID));
                 }
             }
         } else {
             if ($_blockID > 0) {
                 $block = Cible_FunctionsBlocks::getBlockDetailsByLangID($_blockID, $this->_currentEditLanguage);
                 $form->populate($block->toArray());
                 $blockParameters = Cible_FunctionsBlocks::getBlockParameters($_blockID);
                 foreach ($blockParameters as $parameter) {
                     $element = $form->getElement("Param{$parameter['P_Number']}");
                     if ($element) {
                         $element->setValue($parameter['P_Value']);
                     } else {
                         echo "Param{$parameter['P_Number']} is not found";
                     }
                 }
             }
         }
     }
     $this->view->jQuery()->enable();
 }
Esempio n. 20
0
 private function autogenerateMenuItemFromPageId($itemId, $parentId, $recursive = false)
 {
     $pageObject = new Pages();
     $select = $pageObject->select()->setIntegrityCheck(false)->from('Pages')->joinInner('PagesIndex', 'PI_PageID = P_ID')->where('PI_LanguageID = ?', Zend_Registry::get('languageID'))->where('P_ParentID = ?', $parentId)->order('P_Position');
     $pages = $pageObject->fetchAll($select)->toArray();
     foreach ($pages as $item) {
         $page_id = $item['P_ID'];
         $position = $this->_db->fetchCol("SELECT count(*) FROM MenuItemData WHERE MID_ParentID = '{$itemId}' AND MID_MenuID = '{$this->_id}'");
         $position = $position[0];
         $langs = Cible_FunctionsGeneral::getAllLanguage();
         foreach ($langs as $lang) {
             $page_details = Cible_FunctionsPages::getPageDetails($page_id, $lang['L_ID']);
             $page_title = !empty($page_details['PI_PageTitle']) ? $page_details['PI_PageTitle'] : null;
             if ($page_title != null) {
                 $found_status = $this->autogenerate_checkIfAlreadyExists($itemId, $page_id, $lang['L_ID']);
                 if (!$found_status['data']) {
                     $menuData = new MenuItem();
                     $_data = $menuData->createRow();
                     $_data->setFromArray(array('MID_MenuID' => $this->_id, 'MID_ParentID' => $itemId, 'MID_Position' => $position));
                     $_data->save();
                     $_dataId = $this->_db->lastInsertId();
                     $menuIndex = new MenuItemIndex();
                     $_index = $menuIndex->createRow();
                     $_index->setFromArray(array('MII_LanguageID' => $item['PI_LanguageID'], 'MII_MenuItemDataID' => $_dataId, 'MII_Title' => $page_title, 'MII_Link' => '', 'MII_PageID' => $page_id));
                     $_index->save();
                 } else {
                     if ($found_status['data'] && !$found_status['lang']) {
                         $_dataId = $found_status['dataID'];
                         $menuIndex = new MenuItemIndex();
                         $_index = $menuIndex->createRow();
                         $_index->setFromArray(array('MII_LanguageID' => $lang['L_ID'], 'MII_MenuItemDataID' => $_dataId, 'MII_Title' => $page_title, 'MII_Link' => '', 'MII_PageID' => $page_id));
                         $_index->save();
                     }
                 }
             }
         }
         if ($_dataId != -1 && $recursive) {
             $this->autogenerateMenuItemFromPageId($_dataId, $page_id, $recursive);
         }
     }
 }
Esempio n. 21
0
    public function errorAction()
    {
        $errors = $this->_getParam('error_handler');
        //$exception = $errors->exception;
        Zend_Registry::set('baseUrl', $this->getFrontController()->getBaseUrl());
        switch ($errors->type) {
            // if it is a controller error
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
                // grab the controller, action and settings requested by the user
                $ParamsArray = $errors->request->getParams();
                if ($this->_request->controller == "robots.txt") {
                    $this->robotsAction();
                    $this->_helper->layout()->disableLayout();
                    $this->_helper->viewRenderer->setNoRender(true);
                    //Cible_FunctionsRobots::robotsAction();
                    exit;
                }
                $ControllerName = $ParamsArray['controller'];
                $ActionName = $ParamsArray['action'];
                // check if the name of the controller is in the database
                $Pages = new PagesIndex();
                $Select = $Pages->select()->setIntegrityCheck(false)->from('PagesIndex')->join('Languages', 'Languages.L_ID = PagesIndex.PI_LanguageID')->join('Pages', 'Pages.P_ID = PagesIndex.PI_PageID')->join('Page_Themes', 'Page_Themes.PT_ID = Pages.P_ThemeID')->join('Views', 'Views.V_ID = Pages.P_ViewID')->where('PagesIndex.PI_PageIndex = ?', $ControllerName)->where('PI_Status = 1')->limit(1);
                $Row = $Pages->fetchRow($Select);
                // if the controller is found in the database
                if (count($Row) == 1) {
                    // call page controller to display blocks
                    $this->_helper->actionStack('index', 'page', 'default', array('Row' => $Row, 'Param' => $ParamsArray));
                    // does not render the page Error404
                    $this->disableView();
                } else {
                    $session = new Cible_Sessions();
                    $currentLanguageID = !empty($session->languageID) ? $session->languageID : $this->_config->defaultInterfaceLanguage;
                    $page_not_found_id = $this->_config->page_not_found->pageID;
                    $pageIndexName = Cible_FunctionsPages::getPageNameByID($page_not_found_id, $currentLanguageID);
                    // check if the name of the controller is in the database
                    $Pages = new PagesIndex();
                    $Select = $Pages->select()->setIntegrityCheck(false)->from('PagesIndex')->join('Languages', 'Languages.L_ID = PagesIndex.PI_LanguageID')->join('Pages', 'Pages.P_ID = PagesIndex.PI_PageID')->join('Page_Themes', 'Page_Themes.PT_ID = Pages.P_ThemeID')->join('Views', 'Views.V_ID = Pages.P_ViewID')->where('PagesIndex.PI_PageIndex = ?', $pageIndexName)->where('PI_Status = 1')->limit(1);
                    $Row = $Pages->fetchRow($Select);
                    if (count($Row) == 1) {
                        // call page controller to display blocks
                        $this->_helper->actionStack('index', 'page', 'default', array('Row' => $Row, 'Param' => $ParamsArray));
                        // does not render the page Error404
                        $this->disableView();
                    } else {
                        $this->disableLayout();
                        echo "404 Page not found.";
                    }
                    $this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found');
                }
                break;
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
                // does not render the page Error404
                $this->disableLayout();
                $this->disableView();
                echo "Erreur d'action   ";
                break;
            default:
                // application error; display error page, but don't change
                // status code
                // ...
                // Log the exception:
                $exception = $errors->exception;
                /*$log = new Zend_Log(
                      new Zend_Log_Writer_Stream(
                          '/tmp/applicationException.log'
                      )
                  );
                  $log->debug($exception->getMessage() . "\n" .
                              $exception->getTraceAsString());
                  */
                echo <<<End_of_error
                    <p>
                    <strong>Error</strong>
                    {$exception->getMessage()}
                    </p>
                    <p>
                    <strong>Stack Trace</strong>
                    {$exception->getTraceAsString()}
                    </p>
End_of_error;
                break;
        }
    }
Esempio n. 22
0
 public function orderAction()
 {
     $this->view->headLink()->prependStylesheet($this->view->LocateFile('cart.css'));
     $session = new Zend_Session_Namespace('order');
     $urlBack = '';
     $urlNextStep = '';
     $urls = Cible_View_Helper_LastVisited::getLastVisited();
     $profile = new MemberProfile();
     $oAddress = new AddressObject();
     $authentication = Cible_FunctionsGeneral::getAuthentication();
     $memberInfos = $profile->findMember(array('email' => $authentication['email']));
     $page = Cible_FunctionsCategories::getPagePerCategoryView(0, 'list_collections', 14);
     // If authentication is not present or if cart is empty, redirect to the cart page
     if (!is_null($authentication)) {
         //            $memberInfos = $profile->addTaxRate($memberInfos);
         if (!empty($memberInfos['addrBill'])) {
             $billAddr = $oAddress->populate($memberInfos['addrBill'], $this->_defaultInterfaceLanguage);
         }
         if (!empty($memberInfos['addrShip'])) {
             $shipAddr = $oAddress->populate($memberInfos['addrShip'], $this->_defaultInterfaceLanguage);
         }
         //            $oRetailer = new RetailersObject();
         //            $memberInfos['AI_FirstTel'] = $billAddr['AI_FirstTel'];
         //            $memberInfos['AI_SecondTel'] = $billAddr['AI_SecondTel'];
         //            $memberInfos['A_Fax'] = $billAddr['A_Fax'];
         if (isset($billAddr['AI_WebSite'])) {
             $memberInfos['AI_WebSite'] = $billAddr['AI_WebSite'];
         }
         $memberInfos['addressFact'] = $billAddr;
         if (isset($shipAddr['A_Duplicate']) && !$shipAddr['A_Duplicate']) {
             $shipAddr['duplicate'] = 0;
         }
         $memberInfos['addressShipping'] = $shipAddr;
         $current_state = $billAddr['A_StateId'] . '||' . $shipAddr['A_StateId'] . '||';
         $currentCity = $billAddr['A_CityId'] . '||' . $shipAddr['A_CityId'] . '||';
         //            $onWeb = $oRetailer->getRetailerInfos($memberInfos['member_id'], $this->_defaultInterfaceLanguage);
         //            if ($onWeb && !empty($onWeb['R_AddressId']))
         //            {
         //                $webAddr = $oAddress->populate($onWeb['R_AddressId'], $this->_defaultInterfaceLanguage);
         //
         //                $webAddr['isDistributeur'] = $onWeb['R_Status'];
         //                $memberInfos['addressDetaillant'] = $webAddr;
         //
         //                $current_state .= $webAddr['A_StateId'] . '||';
         //                $currentCity .= $webAddr['A_CityId'] . '||';
         //            }
         $return = $this->_getParam('return');
         if ($return && isset($_COOKIE['returnUrl'])) {
             $returnUrl = $_COOKIE['returnUrl'];
             $this->view->assign('return', $returnUrl);
         }
         $pageOrderName = Cible_FunctionsCategories::getPagePerCategoryView(0, 'order', $this->_moduleID);
         $tmp = explode('/', $pageOrderName);
         $tmp = array_unique($tmp);
         $pageOrderName = $tmp[0];
         $stepValues = array('auth-order' => array('step' => 2, 'next' => $pageOrderName . '/resume-order', 'prev' => ''), 'resume-order' => array('step' => 3, 'next' => $pageOrderName . '/send-order', 'prev' => 'auth-order'), 'send-order' => array('step' => 4, 'next' => '', 'prev' => 'resume-order'));
         $stepAction = $this->_getParam('action');
         $urlBack = $stepValues[$stepAction]['prev'];
         if (empty($stepValues[$stepAction]['prev']) && isset($urls[0])) {
             $urlBack = $urls[0];
         }
         $this->view->assign('step', $stepValues[$stepAction]['step']);
         $this->view->assign('nextStep', $stepValues[$stepAction]['next']);
         $this->view->assign('urlBack', $urlBack);
         $orderParams = Cible_FunctionsGeneral::getParameters();
         switch ($stepAction) {
             case 'resume-order':
                 if (empty($session->customer)) {
                     $this->_redirect(Cible_FunctionsPages::getPageNameByID(1));
                 }
                 // Create this form to fill with values used for the read-only rendering
                 $formOrder = new FormOrder(array('resume' => true));
                 // Store the state id in the session to allow tax calculation
                 $session->stateId = $billAddr['A_StateId'];
                 // Calculate totals to display and for the bill.
                 $totals = $this->calculateTotal($memberInfos);
                 $session->order['charge_total'] = $totals['total'];
                 $session->order['subTotal'] = $totals['subTot'];
                 $session->order['taxFed'] = $totals['taxFed'];
                 $session->order['taxProv'] = $totals['taxProv'];
                 $session->order['nbPoint'] = $totals['nbPoint'];
                 $session->order['shipFee'] = $orderParams['CP_ShippingFees'];
                 $session->order['limitShip'] = $orderParams['CP_ShippingFeesLimit'];
                 $session->order['CODFees'] = $orderParams['CP_MontantFraisCOD'];
                 $session->order['rateFed'] = 0;
                 if ($session->stateId == 11) {
                     $session->order['rateFed'] = $orderParams['CP_TauxTaxeFed'];
                 }
                 if (isset($session->customer['addressShipping']['duplicate']) && $session->customer['addressShipping']['duplicate']) {
                     unset($session->customer['addressShipping']);
                     $session->customer['addressShipping'] = $session->customer['addressFact'];
                 }
                 $dataBill = $this->getAddrData($session->customer['addressFact'], 'addressFact', $session);
                 $dataShip = $this->getAddrData($session->customer['addressShipping'], 'addressShipping', $session);
                 $salut = Cible_FunctionsGeneral::getSalutations($memberInfos['salutation'], Zend_Registry::get('languageID'));
                 if (isset($salut[$memberInfos['salutation']])) {
                     $session->customer['identification']['salutation'] = utf8_decode($salut[$memberInfos['salutation']]);
                 } else {
                     $session->customer['identification']['salutation'] = "-";
                 }
                 $formOrder->populate($session->customer);
                 $formOrder->getSubForm('addressShipping')->removeElement('duplicate');
                 $formOrder->getSubForm('identification')->removeElement('password');
                 $formOrder->getSubForm('identification')->removeElement('passwordConfirmation');
                 $formOrder->getSubForm('identification')->removeElement('noFedTax');
                 $formOrder->getSubForm('identification')->removeElement('noProvTax');
                 $formOrder->getSubForm('identification')->removeElement('AI_FirstTel');
                 $formOrder->getSubForm('identification')->removeElement('AI_SecondTel');
                 $formOrder->getSubForm('identification')->removeElement('AI_WebSite');
                 $formOrder->getSubForm('identification')->removeElement('A_Fax');
                 $readOnly = new Cible_View_Helper_FormReadOnly();
                 $readOnly->setAddSeparator(true);
                 $readOnly->setSeparatorClass('dotLine');
                 $readOnly->setListOpened(false);
                 $readOnly->setSeparatorPositon(array(1));
                 $readOnlyForm = $readOnly->subFormRender($formOrder);
                 $formPayment = new FormOrderPayment(array('readOnlyForm' => $readOnlyForm, 'payMean' => $session->customer['paymentMeans']));
                 //                    $formPayment->populate($session->order);
                 if ($this->_request->isPost() && array_key_exists('submit', $_POST)) {
                     $formData = $this->_request->getPost();
                     $session->customer['invoice'] = $formData;
                     //                        $session->customer['indentification'] = $memberInfos;
                     $this->_redirect($stepValues[$stepAction]['next']);
                 }
                 $session->customer['charge_total'] = sprintf('%.2f', $totals['total']);
                 $formPayment->populate($session->customer);
                 $this->view->assign('CODFees', $orderParams['CP_MontantFraisCOD']);
                 $this->view->assign('memberInfos', $memberInfos);
                 $this->view->assign('formOrder', $formPayment);
                 $this->renderScript('index/order-summary.phtml');
                 break;
             case 'send-order':
                 if ($this->_request->isPost()) {
                     //                        if ($this->_request->getParam('response_code') > 50)
                     if ($this->_request->getParam('response_code') < 50 && $this->_request->getParam('response_code') != 'null') {
                         $session->order['confirmation'] = $_POST;
                     } else {
                         $this->view->assign('errorValidation', $this->view->getClientText('card_payment_error_message'));
                         $session->customer['message'] = $this->view->getClientText('card_payment_error_message');
                         $this->_redirect($pageOrderName . '/' . $stepValues['resume-order']['prev'] . '/errorValidation/1');
                     }
                 }
                 $this->sendOrder();
                 $urlBack = $this->view->BaseUrl() . '/' . $page;
                 $this->view->assign('backHomeLink', $urlBack);
                 $this->renderScript('index/order-sent.phtml');
                 break;
             default:
                 //                    $oCart = new Cart();
                 //                    $cartHeader = $oCart->getCartData();
                 //                    $cartId = $oCart->getId();
                 //                    $files = $oCart->manageFileUpload();
                 $form = new FormOrderAddr(array('hasAccount' => $memberInfos['hasAccount']));
                 //                    $this->getAddrData($memberInfos['addressFact'], 'addressFact', $session);
                 //                    $address = array_merge($memberInfos['addressFact'], $session->customer['addressFact']);
                 //                    $form->getSubForm('addressFact')->populate($address);
                 //
                 //                    $readOnly = new Cible_View_Helper_FormReadOnly();
                 //                    $readOnly->setAddSeparator(true);
                 //                    $readOnly->setSeparatorClass('dotLine');
                 //                    $readOnly->setListOpened(true);
                 //                    $readOnly->setSeparatorPosition(array(1));
                 //                    $readOnlyForm = $readOnly->subFormRender($form, 'addressFact');
                 //
                 //                    $newForm = new FormOrderAddr(array('readOnlyBillAddr' => $readOnlyForm));
                 if ($this->_request->isPost()) {
                     $statePost = '';
                     $cityPost = '';
                     $data = $this->_request->getPost();
                     $currentCity = 0;
                     $current_state = $data['addressFact']['A_StateId'] . '||';
                     $current_state .= $data['addressShipping']['A_StateId'];
                     //                        $currentCity = (empty($cityPost)) ? substr($currentCity, 0, -1) : substr($cityPost, 0, -1);
                     //                        $current_state = (empty($statePost)) ? substr($current_state, 0, -1) : substr($statePost, 0, -1);
                     $memberInfos['selectedState'] = $session->customer['selectedState'];
                     $memberInfos['selectedCity'] = $session->customer['selectedCity'];
                 }
                 if ($this->_request->isPost() && array_key_exists('submit', $_POST)) {
                     $formData = $this->_request->getPost();
                     $formData['selectedState'] = $current_state;
                     $formData['selectedCity'] = $currentCity;
                     //Remove data validation if not a new address
                     $addrSource = $newForm->getSubForm('addressShipping')->getElement('addrSource')->getValue();
                     if ($addrSource == 1 || $addrSource == 3) {
                         $subFormShip = $form->getSubForm('addressShipping');
                         foreach ($subFormShip as $key => $value) {
                             $value->clearValidators()->setRequired(false);
                         }
                     }
                     //                        if ($formData['paymentMeans'] == 'compte' && !$memberInfos['hasAccount'])
                     //                        {
                     //                            $newForm->getElement('paymentMeans')->setErrors(array($this->view->getClientText('no_customer_account')));
                     //                            $formData['paymentMeans'] = null;
                     //                        }
                     if ($form->isValid($formData)) {
                         //                            if($formData['paymentMeans'] == 'cod')
                         //                                $session->order['cod'] = $formData['paymentMeans'];
                         //                            elseif(isset($session->order['cod']))
                         //                                unset($session->order['cod']);
                         $session->customer = $formData;
                         $session->customer['identification'] = $memberInfos;
                         $this->_redirect($stepValues[$stepAction]['next']);
                     } else {
                         $form->populate($formData);
                     }
                 } else {
                     $memberInfos['selectedState'] = $current_state;
                     $memberInfos['selectedCity'] = $currentCity;
                     $form->populate($memberInfos);
                 }
                 $this->view->assign('CODFees', $orderParams['CP_MontantFraisCOD']);
                 $this->view->assign('form', $form);
                 $this->view->assign('memberInfos', $memberInfos);
                 $this->view->assign('accountValidate', $memberInfos['validatedEmail']);
                 break;
         }
     } else {
         $this->_redirect(Cible_FunctionsPages::getPageNameByID(1));
     }
 }
Esempio n. 23
0
    public function __construct($options = null)
    {
        $this->_disabledDefaultActions = true;
        parent::__construct($options);
        $baseDir = $this->getView()->baseUrl();
        if (!empty($options['mode']) && $options['mode'] == 'edit') {
            $this->_mode = 'edit';
        } else {
            $this->_mode = 'add';
        }
        $langId = Zend_Registry::get('languageID');
        $this->setAttrib('id', 'accountManagement');
        //            $addressParams = array(
        //                "fieldsValue" => array(),
        //                "display"   => array(),
        //                "required" => array(),
        //            );
        // Salutation
        $salutation = new Zend_Form_Element_Select('salutation');
        $salutation->setLabel($this->getView()->getCibleText('form_label_salutation'))->setAttrib('class', 'smallSelect')->setAttrib('tabindex', '1')->setOrder(1);
        $greetings = $this->getView()->getAllSalutation();
        foreach ($greetings as $greeting) {
            $salutation->addMultiOption($greeting['S_ID'], $greeting['ST_Value']);
        }
        // Language
        $languages = new Zend_Form_Element_Select('language');
        $languages->setLabel($this->getView()->getCibleText('form_label_language'))->setAttrib('class', 'stdSelect')->setAttrib('tabindex', '9')->setOrder(9);
        foreach (Cible_FunctionsGeneral::getAllLanguage() as $lang) {
            $languages->addMultiOption($lang['L_ID'], $lang['L_Title']);
        }
        // FirstName
        $firstname = new Zend_Form_Element_Text('firstName');
        $firstname->setLabel($this->getView()->getCibleText('form_label_fName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('class' => 'stdTextInput'))->setAttrib('tabindex', '2')->setOrder(2);
        // LastName
        $lastname = new Zend_Form_Element_Text('lastName');
        $lastname->setLabel($this->getView()->getCibleText('form_label_lName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('class' => 'stdTextInput'))->setAttrib('tabindex', '3')->setOrder(3);
        // email
        $regexValidate = new Cible_Validate_Email();
        $regexValidate->setMessage($this->getView()->getCibleText('validation_message_emailAddressInvalid'), 'regexNotMatch');
        $emailNotFoundInDBValidator = new Zend_Validate_Db_NoRecordExists('GenericProfiles', 'GP_Email');
        $emailNotFoundInDBValidator->setMessage($this->getView()->getClientText('validation_message_email_already_exists'), 'recordFound');
        $email = new Zend_Form_Element_Text('email');
        $email->setLabel($this->getView()->getCibleText('form_label_email'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addFilter('StringToLower')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->addValidator($regexValidate)->setAttribs(array('maxlength' => 50, 'class' => 'stdTextInput'))->setAttrib('tabindex', '5')->setOrder(5);
        if ($this->_mode == 'add') {
            $email->addValidator($emailNotFoundInDBValidator);
        }
        // email
        // password
        $password = new Zend_Form_Element_Password('password');
        if ($this->_mode == 'add') {
            $password->setLabel($this->getView()->getCibleText('form_label_password'));
        } else {
            $password->setLabel($this->getView()->getCibleText('form_label_newPwd'));
        }
        $password->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('class', 'stdTextInput')->setAttrib('tabindex', '6')->setRequired(true)->setOrder(6)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))));
        // password
        // password confirmation
        $passwordConfirmation = new Zend_Form_Element_Password('passwordConfirmation');
        if ($this->_mode == 'add') {
            $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmPwd'));
        } else {
            $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmPwd'));
        }
        //                $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmNewPwd'));
        $passwordConfirmation->addFilter('StripTags')->addFilter('StringTrim')->setRequired(true)->setOrder(7)->setAttrib('class', 'stdTextInput')->setAttrib('tabindex', '7')->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd')), array('label', array('class' => 'test', 'tag' => 'dt', 'tagClass' => 'alignVertical'))));
        if (!empty($_POST['identification']['password'])) {
            $passwordConfirmation->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('error_message_password_isEmpty'))));
            $Identical = new Zend_Validate_Identical($_POST['identification']['password']);
            $Identical->setMessages(array('notSame' => $this->getView()->getCibleText('error_message_password_notSame')));
            $passwordConfirmation->addValidator($Identical);
        }
        // password confirmation
        // Company name
        $company = new Zend_Form_Element_Text('company');
        $company->setLabel($this->getView()->getCibleText('form_label_company'))->setRequired(false)->setAttrib('tabindex', '4')->setOrder(4)->setAttribs(array('class' => 'stdTextInput'));
        // Account number
        $account = new Zend_Form_Element_Text('accountNum');
        $account->setLabel($this->getView()->getCibleText('form_label_account'))->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setOrder(8)->setAttribs(array('class' => 'stdTextInput'))->setAttrib('tabindex', '8')->setDecorators(array('ViewHelper', 'Errors', array(array('row' => 'HtmlTag'), array('tag' => 'dd')), array('label', array('class' => 'test', 'tag' => 'dt', 'tagClass' => 'alignVertical'))));
        // Text Subscribe
        $textSubscribe = $this->getView()->getCibleText('form_label_subscribe');
        $textSubscribe = str_replace('%URL_PRIVACY_POLICY%', Cible_FunctionsPages::getPageLinkByID($this->_config->privacyPolicy->pageId), $textSubscribe);
        // Newsletter subscription
        $newsletterSubscription = new Zend_Form_Element_Checkbox('newsletterSubscription');
        $newsletterSubscription->setLabel($textSubscribe);
        if ($this->_mode == 'add') {
            $newsletterSubscription->setChecked(1);
        }
        $newsletterSubscription->setAttrib('class', 'long-text');
        $newsletterSubscription->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'id' => 'subscribeNewsletter', 'class' => 'label_after_checkbox'))));
        if ($this->_mode == 'add') {
            $termsAgreement = new Zend_Form_Element_Checkbox('termsAgreement');
            $termsAgreement->setLabel(str_replace('%URL_TERMS_CONDITIONS%', Cible_FunctionsPages::getPageLinkByID($this->_config->termsAndConditions->pageId), $this->getView()->getClientText('form_label_terms_agreement')));
            $termsAgreement->setAttrib('class', 'long-text');
            $termsAgreement->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
            $termsAgreement->setRequired(true);
            $termsAgreement->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'You must agree to the terms')));
        } else {
            $termsAgreement = new Zend_Form_Element_Hidden('termsAgreement', array('value' => 1));
        }
        // Submit button
        $submit = new Zend_Form_Element_Submit('submit');
        $submitLabel = $this->getView()->getCibleText('form_account_button_submit');
        if ($this->_mode == 'edit') {
            $submitLabel = $this->getView()->getCibleText('button_submit');
        }
        $submit->setLabel($submitLabel)->setAttrib('class', 'stdButton subscribeButton1-' . Zend_Registry::get("languageSuffix"));
        // Captcha
        // Refresh button
        $refresh_captcha = new Zend_Form_Element_Button('refresh_captcha');
        $refresh_captcha->setLabel($this->getView()->getCibleText('button_refresh_captcha'))->setAttrib('onclick', "refreshCaptcha('captcha-id')")->setAttrib('class', 'stdButton')->removeDecorator('Label')->removeDecorator('DtDdWrapper');
        $refresh_captcha->addDecorators(array(array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'dd-refresh-captcha-button'))));
        $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => $this->getView()->getCibleText('form_label_securityCaptcha'), 'captcha' => 'Image', 'captchaOptions' => array('captcha' => 'Word', 'wordLen' => 5, 'fontSize' => 28, 'height' => 67, 'width' => 169, 'timeout' => 300, 'dotNoiseLevel' => 0, 'lineNoiseLevel' => 0, 'font' => Zend_Registry::get('application_path') . "/../{$this->_config->document_root}/captcha/fonts/ARIAL.TTF", 'imgDir' => Zend_Registry::get('application_path') . "/../{$this->_config->document_root}/captcha/tmp", 'imgUrl' => "{$baseDir}/captcha/tmp")));
        $captcha->setAttrib('class', 'stdTextInputCatcha');
        $captcha->setRequired(true);
        $captcha->addDecorators(array(array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'id' => 'dd_captcha'))))->addDecorator('Label', array('class' => 'clear'));
        $french = array('badCaptcha' => 'Veuillez saisir la chaîne ci-dessus correctement.');
        $english = array('badCaptcha' => 'Captcha value is wrong');
        $translate = new Zend_Translate('array', $french, 'fr');
        $this->setTranslator($translate);
        $this->getView()->jQuery()->enable();
        $script = <<<EOS

            function refreshCaptcha(id){
                \$.getJSON('{$this->getView()->baseUrl()}/newsletter/index/captcha-reload',
                    function(data){

                        \$("dd#dd_captcha img").attr({src : data['url']});
                        \$("#"+id).attr({value: data['id']});

                });
            }

EOS;
        $this->getView()->headScript()->appendScript($script);
        // Captcha
        /*  Identification sub form */
        $identificationSub = new Cible_Form_SubForm();
        $identificationSub->setName('identification')->removeDecorator('DtDdWrapper');
        $identificationSub->setLegend($this->getView()->getCibleText('form_account_subform_identification_legend'));
        $identificationSub->setAttrib('class', 'identificationClass subFormClass');
        $identificationSub->addElement($languages);
        $identificationSub->addElement($salutation);
        $identificationSub->addElement($lastname);
        $identificationSub->addElement($firstname);
        $identificationSub->addElement($email);
        $identificationSub->addElement($password);
        $identificationSub->addElement($passwordConfirmation);
        $identificationSub->addElement($company);
        $identificationSub->addElement($account);
        $identificationSub->addDisplayGroup(array('salutation', 'firstName', 'company', 'password', 'accountNum'), 'leftColumn');
        $identificationSub->addDisplayGroup(array('lastName', 'email', 'passwordConfirmation', 'language'), 'rightColumn')->removeDecorator('DtDdWrapper');
        $leftColGroup = $identificationSub->getDisplayGroup('leftColumn');
        $rightColGroup = $identificationSub->getDisplayGroup('rightColumn');
        $leftColGroup->removeDecorator('DtDdWrapper');
        $rightColGroup->removeDecorator('DtDdWrapper');
        $this->addSubForm($identificationSub, 'identification');
        // Billing address
        $addressFacturationSub = new Cible_Form_SubForm();
        $addressFacturationSub->setName('addressFact')->removeDecorator('DtDdWrapper');
        $addressFacturationSub->setLegend($this->getView()->getCibleText('form_account_subform_addBilling_legend'));
        $addressFacturationSub->setAttrib('class', 'addresseBillingClass subFormClass');
        $billingAddr = new Cible_View_Helper_FormAddress($addressFacturationSub);
        $billingAddr->enableFields(array('firstAddress', 'secondAddress', 'cityTxt', 'zipCode', 'country', 'state', 'firstTel', 'secondTel', 'fax'));
        $billingAddr->formAddress();
        $addrBill = new Zend_Form_Element_Hidden('addrBill');
        $addrBill->removeDecorator('label');
        $addressFacturationSub->addElement($addrBill);
        $this->addSubForm($addressFacturationSub, 'addressFact');
        /* delivery address */
        $addrShip = new Zend_Form_Element_Hidden('addrShip');
        $addrShip->removeDecorator('label');
        $addressShippingSub = new Cible_Form_SubForm();
        $addressShippingSub->setName('addressShipping')->removeDecorator('DtDdWrapper');
        $addressShippingSub->setLegend($this->getView()->getCibleText('form_account_subform_addShipping_legend'));
        $addressShippingSub->setAttrib('class', 'addresseShippingClass subFormClass');
        $shipAddr = new Cible_View_Helper_FormAddress($addressShippingSub);
        $shipAddr->duplicateAddress($addressShippingSub);
        $shipAddr->setProperty('addScriptState', false);
        $shipAddr->enableFields(array('firstAddress', 'secondAddress', 'cityTxt', 'zipCode', 'country', 'state', 'firstTel', 'secondTel', 'fax'));
        $shipAddr->formAddress();
        $addressShippingSub->addElement($addrShip);
        $this->addSubForm($addressShippingSub, 'addressShipping');
        if ($this->_mode == 'add') {
            $this->getView()->jQuery()->enable();
            $script = <<<EOS

                function refreshCaptcha(id){
                    \$.getJSON('{$this->getView()->baseUrl()}/order/index/captcha-reload',
                        function(data){
                            \$("dd#dd_captcha img").attr({src : data['url']});
                            \$("#"+id).attr({value: data['id']});
                    });
                }

EOS;
            //                $this->getView()->headScript()->appendScript($script);
            //                $this->addElement($refresh_captcha);
            //                $this->addElement($captcha);
            $this->addElement($newsletterSubscription);
            $this->addElement($termsAgreement);
        }
        $this->addElement($submit);
        $submit->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'account-submit'))));
        if ($this->_mode == 'add') {
            $termsAgreement->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox', 'id' => 'dd-terms-agreement'))));
        }
        $captchaError = array('badCaptcha' => $this->getView()->getCibleText('validation_message_captcha_error'));
        $translate = new Zend_Translate('array', $captchaError, $this->getView()->registryGet('languageSuffix'));
        $this->setTranslator($translate);
    }