public function traverseHierarchy($path = "", $maxWidth = 170, $maxHeight = 170) { if (empty($path)) { $path = $_SERVER['DOCUMENT_ROOT'] . Zend_Registry::get('www_root') . '/data/images/catalog/products'; } $returnArray = array(); $tmp = array(); $dir = opendir($path); while (($file = readdir($dir)) !== false) { if ($file[0] == '.' || $file == 'tmp') { continue; } $fullPath = $path . '/' . $file; //Trouver la plus grande image. if (!is_dir($fullPath)) { $folder = dirname($fullPath); $tmp = explode('_', $file); $dim = explode('x', $tmp[0]); unset($tmp[0]); $prodId = substr($folder, strrpos($folder, '/') + 1, 3); if ($pid != $prodId) { $pid = $prodId; $dt1 = filemtime($fullPath); $data = array('P_Photo' => implode('_', $tmp)); } else { $dt2 = filemtime($fullPath); if ($dt1 < $dt2) { $data = array('P_Photo' => implode('_', $tmp)); } } $oProduct = new ProductsObject(); $oProduct->save($prodId, $data, 1); //construire le nom le chemin de l'image // if ($dim[0] > $maxWidth && $dim[1] > $maxHeight) // { // $srcThumb = $path . '/' . $maxWidth.'x'.$maxHeight.'_'.$tmp[1]; // //remplir le tableau image // $image = array( // 'src' => $srcThumb, // 'maxWidth' => $maxWidth, // 'maxHeight' => $maxHeight // ); // copy($fullPath, $srcThumb); // resampled($image); // } } else { // your if goes here: if(substr($file, -3) == "jpg") or something like that $this->traverseHierarchy($fullPath); } } }
/** * 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); } } }
/** * Get the list of the products for all categories * * * @return array */ public function getListOfAllNewProducts() { $products = array(); $this->getDataByName(); $oProducts = new ProductsObject(); $oSubCat = new SubCategoriesObject(); $oCategory = new CatalogCategoriesObject(); $subCategories = $oSubCat->getSubCatByCategory(0, false, $this->_currentLang); $oCategory->setQuery($subCategories); $categoryQuery = $oCategory->getDataCatagory($this->_currentLang, false); $oProducts->setQuery($categoryQuery); $select = $oProducts->getProducts($this->_currentLang, false); $select->where('P_New = 1'); $select->order('PI_Name ASC'); $products = $this->_db->fetchAll($select); //echo $select; return $products; }
/** * Class constructor * * @return void */ public function __construct($options = null) { parent::__construct($options); $labelCSS = Cible_FunctionsGeneral::getLanguageLabelColor($options); $imageSrc = $options['imageSrc']; $dataId = $options['dataId']; $imgField = $options['imgField']; $isNewImage = $options['isNewImage']; $moduleName = $options['moduleName']; $formItemPrices = new Zend_Form_SubForm(); $formTop = new Zend_Form_SubForm(); $formBottom = new Zend_Form_SubForm(); // $this = new Zend_Form_SubForm(); if ($dataId == '') { $pathTmp = "../../../../../data/images/" . $moduleName . "/tmp"; } else { $pathTmp = "../../../../../data/images/" . $moduleName . "/" . $dataId . "/tmp"; } // hidden specify if new image for the news // $newImage = new Zend_Form_Element_Hidden('isNewImage', array('value' => $isNewImage)); // $newImage->removeDecorator('Label'); // $this->addElement($newImage); // Name of the product line $name = new Zend_Form_Element_Text('II_Name'); $name->setLabel($this->getView()->getCibleText('item_label_name') . "<span class='field_required'>*</span>")->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('Errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'stdTextInput'); $label = $name->getDecorator('Label'); $label->setOption('class', $this->_labelCSS); $formTop->addElement($name); // List of products $oProducts = new ProductsObject(); $listProd = $oProducts->productsCollection(Zend_Registry::get('currentEditLanguage')); $products = new Zend_Form_Element_Select('I_ProductID'); $products->setLabel($this->getView()->getCibleText('form_item_products_label') . "<span class='field_required'>*</span>")->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttrib('class', 'largeSelect')->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('Errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title')))); $products->addMultiOption('', $this->getView()->getCibleText('form_select_default_label')); $products->addMultiOptions($listProd); // foreach ($listProd as $data) // { // $products->addMultiOption($data['P_ID'], $data['PI_Name']); // } $formTop->addElement($products); // Product $productCode = new Zend_Form_Element_Text('I_ProductCode'); $productCode->setLabel($this->getView()->getCibleText('form_product_code_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'stdTextInput'); $formTop->addElement($productCode); // Item sequence $sequence = new Zend_Form_Element_Text('I_Seq'); $sequence->setLabel($this->getView()->getCibleText('form_product_sequence_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'smallTextInput'); $formTop->addElement($sequence); // Detail Price $detailPrice = new Zend_Form_Element_Text('I_PriceDetail'); $detailPrice->setLabel($this->getView()->getCibleText('form_item_pricedetail_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'smallTextInput'); $formTop->addElement($detailPrice); // Pro price $proPrice = new Zend_Form_Element_Text('I_PricePro'); $proPrice->setLabel($this->getView()->getCibleText('form_item_pricepro_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'smallTextInput'); $formTop->addElement($proPrice); //******************************************************** //* Sub form containing data defining prices and volumes * //******************************************************** $txtQty = new Cible_Form_Element_Html('lblQty', array('value' => $this->getView()->getCibleText('form_item_qty_label'))); $txtQty->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline left')))); $formItemPrices->addElement($txtQty); $txtPrices = new Cible_Form_Element_Html('lblPrices', array('value' => $this->getView()->getCibleText('form_item_prices_label'))); $txtPrices->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline right')))); $formItemPrices->addElement($txtPrices); // Qty limit 1 $qtyInf = new Zend_Form_Element_Text('I_LimitVol1'); $qtyInf->setLabel($this->getView()->getCibleText('form_item_limitvol1_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'inputColLeft'))))->setAttrib('class', 'smallTextInput left'); $formItemPrices->addElement($qtyInf); // Price Vol 1 $firstPrice = new Zend_Form_Element_Text('I_PriceVol1'); $firstPrice->removeDecorator('Label')->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'inputColRight'))))->setAttrib('class', 'smallTextInput'); $formItemPrices->addElement($firstPrice); // Qty limit 2 $qtyMiddle = new Zend_Form_Element_Text('I_LimitVol2'); $qtyMiddle->setLabel($this->getView()->getCibleText('form_item_limitvol2_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'inputColLeft'))))->setAttrib('class', 'smallTextInput textRight'); $formItemPrices->addElement($qtyMiddle); // Price vol 2 $secondPrice = new Zend_Form_Element_Text('I_PriceVol2'); $secondPrice->removeDecorator('Label')->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'inputColRight', 'id' => 'title'))))->setAttrib('class', 'smallTextInput textRight'); $formItemPrices->addElement($secondPrice); // Price vol 3 $thirdPrice = new Zend_Form_Element_Text('I_PriceVol3'); $thirdPrice->setLabel($this->getView()->getCibleText('form_item_priceVol3_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'inputColRight'))))->setAttrib('class', 'smallTextInput textRight'); $formItemPrices->addElement($thirdPrice); //******************************************************** $special = new Zend_Form_Element_Checkbox('I_Special'); $special->setLabel($this->getView()->getCibleText('form_item_special_label')); $special->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')))); $formBottom->addElement($special); // Special Price $specialPrice = new Zend_Form_Element_Text('I_PrixSpecial'); $specialPrice->setLabel($this->getView()->getCibleText('form_item_specialPrice_label'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'smallTextInput'); $formBottom->addElement($specialPrice); // Checkbox for tax of the province $taxProv = new Zend_Form_Element_Checkbox('P_TaxProv'); $taxProv->setLabel($this->getView()->getCibleText('form_item_taxprov_label'))->setAttrib('checked', 'checked'); $taxProv->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')))); $formBottom->addElement($taxProv); // Checkbox for federal tax $taxFed = new Zend_Form_Element_Checkbox('P_TaxFed'); $taxFed->setLabel($this->getView()->getCibleText('form_item_taxfed_label'))->setAttrib('checked', 'checked'); $taxFed->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')))); $formBottom->addElement($taxFed); $formItemPrices->setLegend($this->getView()->getCibleText('subform_itemprices_legend')); $formItemPrices->setAttrib('class', 'smallFieldsetBorder'); // $this->setLegend($this->getView()->getCibleText('subform_professional_legend')); // $this->setAttrib('class', 'fieldsetBorder'); // $this->addSubForm($this, 'productFormLeft'); // $this->addSubForm($this, 'productFormRight'); $this->addSubForm($formTop, 'formTop'); $this->addSubForm($formItemPrices, 'formItemPrices'); $this->addSubForm($formBottom, 'formBottom'); }