コード例 #1
0
ファイル: Upgrade.php プロジェクト: rpquadrat/core
 /**
  * Run the controller
  */
 public function run()
 {
     // Check if shop has been installed
     $blnInstalled = \Database::getInstance()->tableExists(\Isotope\Model\Config::getTable());
     $strStep = '';
     foreach (scan(TL_ROOT . '/system/modules/isotope/library/Isotope/Upgrade') as $strFile) {
         $strVersion = pathinfo($strFile, PATHINFO_FILENAME);
         if (preg_match('/To[0-9]{10}/', $strVersion)) {
             $strClass = 'Isotope\\Upgrade\\' . $strVersion;
             $strStep = 'Version ' . \Haste\Util\Format::repositoryVersion(substr($strVersion, 2));
             try {
                 $objUpgrade = new $strClass();
                 $objUpgrade->run($blnInstalled);
             } catch (\Exception $e) {
                 $this->handleException($strStep, $e);
             }
         }
     }
     if ($blnInstalled) {
         try {
             $this->verifySystemIntegrity();
             $this->purgeCaches();
         } catch (\Exception $e) {
             $this->handleException('Finalization', $e);
         }
     }
 }
コード例 #2
0
ファイル: OrderDetails.php プロジェクト: Aziz-JH/core
 /**
  * Generate the module
  */
 protected function compile()
 {
     // Also check owner (see #126)
     if (($objOrder = Order::findOneBy('uniqid', (string) \Input::get('uid'))) === null || FE_USER_LOGGED_IN === true && $objOrder->member > 0 && \FrontendUser::getInstance()->id != $objOrder->member) {
         $this->Template = new \Isotope\Template('mod_message');
         $this->Template->type = 'error';
         $this->Template->message = $GLOBALS['TL_LANG']['ERR']['orderNotFound'];
         return;
     }
     // Order belongs to a member but not logged in
     if (TL_MODE == 'FE' && $this->iso_loginRequired && $objOrder->member > 0 && FE_USER_LOGGED_IN !== true) {
         global $objPage;
         $objHandler = new $GLOBALS['TL_PTY']['error_403']();
         $objHandler->generate($objPage->id);
         exit;
     }
     Isotope::setConfig($objOrder->getRelated('config_id'));
     $objTemplate = new \Isotope\Template($this->iso_collectionTpl);
     $objTemplate->linkProducts = true;
     $objOrder->addToTemplate($objTemplate, array('gallery' => $this->iso_gallery, 'sorting' => $objOrder->getItemsSortingCallable($this->iso_orderCollectionBy)));
     $this->Template->collection = $objOrder;
     $this->Template->products = $objTemplate->parse();
     $this->Template->info = deserialize($objOrder->checkout_info, true);
     $this->Template->date = Format::date($objOrder->locked);
     $this->Template->time = Format::time($objOrder->locked);
     $this->Template->datim = Format::datim($objOrder->locked);
     $this->Template->orderDetailsHeadline = sprintf($GLOBALS['TL_LANG']['MSC']['orderDetailsHeadline'], $objOrder->document_number, $this->Template->datim);
     $this->Template->orderStatus = sprintf($GLOBALS['TL_LANG']['MSC']['orderStatusHeadline'], $objOrder->getStatusLabel());
     $this->Template->orderStatusKey = $objOrder->getStatusAlias();
 }
コード例 #3
0
ファイル: Label.php プロジェクト: ralfhartmann/isotope_core
 /**
  * Generate a product label and return it as HTML string
  * @param array
  * @param string
  * @param object
  * @param array
  * @return string
  */
 public function generate($row, $label, $dc, $args)
 {
     foreach ($GLOBALS['TL_DCA'][$dc->table]['list']['label']['fields'] as $i => $field) {
         if ($field == 'name' && $row['fallback']) {
             $args[$i] = sprintf('%s <span style="color:#b3b3b3; padding-left:3px;">[%s]</span>', $row['name'], Format::dcaLabel($dc->table, 'fallback'));
         } else {
             $args[$i] = Format::dcaValue($dc->table, $field, $row[$field]);
         }
     }
     return $args;
 }
コード例 #4
0
ファイル: Label.php プロジェクト: rpquadrat/core
 /**
  * Generate a product label and return it as HTML string
  * @param array
  * @param string
  * @param object
  * @param array
  * @return string
  */
 public function generate($row, $label, $dc, $args)
 {
     $objProduct = Product::findByPk($row['id']);
     foreach ($GLOBALS['TL_DCA'][$dc->table]['list']['label']['fields'] as $i => $field) {
         switch ($field) {
             // Add an image
             case 'images':
                 $arrImages = deserialize($objProduct->images);
                 $args[$i] = '&nbsp;';
                 if (is_array($arrImages) && !empty($arrImages)) {
                     foreach ($arrImages as $image) {
                         $strImage = 'isotope/' . strtolower(substr($image['src'], 0, 1)) . '/' . $image['src'];
                         if (!is_file(TL_ROOT . '/' . $strImage)) {
                             continue;
                         }
                         $size = @getimagesize(TL_ROOT . '/' . $strImage);
                         $args[$i] = sprintf('<a href="%s" onclick="Backend.openModalImage({\'width\':%s,\'title\':\'%s\',\'url\':\'%s\'});return false"><img src="%s" alt="%s" align="left"></a>', $strImage, $size[0], str_replace("'", "\\'", $objProduct->name), $strImage, \Image::get($strImage, 50, 50, 'proportional'), $image['alt']);
                         break;
                     }
                 }
                 break;
             case 'name':
                 $args[$i] = $objProduct->name;
                 /** @var \Isotope\Model\ProductType $objProductType */
                 if ($row['pid'] == 0 && ($objProductType = ProductType::findByPk($row['type'])) !== null && $objProductType->hasVariants()) {
                     // Add a variants link
                     $args[$i] = sprintf('<a href="%s" title="%s">%s</a>', ampersand(\Environment::get('request')) . '&amp;id=' . $row['id'], specialchars($GLOBALS['TL_LANG'][$dc->table]['showVariants']), $args[$i]);
                 }
                 break;
             case 'price':
                 $objPrice = ProductPrice::findPrimaryByProductId($row['id']);
                 if (null !== $objPrice) {
                     /** @var \Isotope\Model\TaxClass $objTax */
                     $objTax = $objPrice->getRelated('tax_class');
                     $strTax = null === $objTax ? '' : ' (' . $objTax->getName() . ')';
                     $args[$i] = $objPrice->getValueForTier(1) . $strTax;
                 }
                 break;
             case 'variantFields':
                 $attributes = array();
                 foreach ($GLOBALS['TL_DCA'][$dc->table]['list']['label']['variantFields'] as $variantField) {
                     $attributes[] = '<strong>' . Format::dcaLabel($dc->table, $variantField) . ':</strong>&nbsp;' . Format::dcaValue($dc->table, $variantField, $objProduct->{$variantField});
                 }
                 $args[$i] = ($args[$i] ? $args[$i] . '<br>' : '') . implode(', ', $attributes);
                 break;
         }
     }
     return $args;
 }
コード例 #5
0
 /**
  * Send the news message
  * @param integer
  * @return boolean
  */
 public function sendNewsMessage($intId)
 {
     $objNews = \NewsModel::findByPk($intId);
     if ($objNews === null) {
         return false;
     }
     $objArchive = $objNews->getRelated('pid');
     if ($objArchive === null || !$objArchive->newsletter || !$objArchive->newsletter_channel || !$objArchive->nc_notification) {
         return false;
     }
     $objNotification = \NotificationCenter\Model\Notification::findByPk($objArchive->nc_notification);
     if ($objNotification === null) {
         return false;
     }
     $objRecipients = \NewsletterRecipientsModel::findBy(array("pid=? AND active=1"), $objArchive->newsletter_channel);
     if ($objRecipients === null) {
         return false;
     }
     $arrTokens = array();
     // Generate news archive tokens
     foreach ($objArchive->row() as $k => $v) {
         $arrTokens['news_archive_' . $k] = \Haste\Util\Format::dcaValue('tl_news_archive', $k, $v);
     }
     // Generate news tokens
     foreach ($objNews->row() as $k => $v) {
         $arrTokens['news_' . $k] = \Haste\Util\Format::dcaValue('tl_news', $k, $v);
     }
     $arrTokens['news_text'] = '';
     $objElement = \ContentModel::findPublishedByPidAndTable($objNews->id, 'tl_news');
     // Generate news text
     if ($objElement !== null) {
         while ($objElement->next()) {
             $arrTokens['news_text'] .= $this->getContentElement($objElement->id);
         }
     }
     // Generate news URL
     $objPage = \PageModel::findWithDetails($objNews->getRelated('pid')->jumpTo);
     $arrTokens['news_url'] = ($objPage->rootUseSSL ? 'https://' : 'http://') . ($objPage->domain ?: \Environment::get('host')) . TL_PATH . '/' . $objPage->getFrontendUrl(($GLOBALS['TL_CONFIG']['useAutoItem'] && !$GLOBALS['TL_CONFIG']['disableAlias'] ? '/' : '/items/') . (!$GLOBALS['TL_CONFIG']['disableAlias'] && $objNews->alias != '' ? $objNews->alias : $objNews->id), $objPage->language);
     // Administrator e-mail
     $arrTokens['admin_email'] = $GLOBALS['TL_ADMIN_EMAIL'];
     while ($objRecipients->next()) {
         $arrTokens['recipient_email'] = $objRecipients->email;
         $objNotification->send($arrTokens);
     }
     // Set the newsletter flag
     $objNews->newsletter = 1;
     $objNews->save();
     return true;
 }
コード例 #6
0
ファイル: OrderHistory.php プロジェクト: Aziz-JH/core
 /**
  * Generate the module
  * @return void
  */
 protected function compile()
 {
     $arrOrders = array();
     $objOrders = Order::findBy(array('order_status>0', 'member=?', 'config_id IN (?)'), array(\FrontendUser::getInstance()->id, implode("','", $this->iso_config_ids)), array('order' => 'locked DESC'));
     // No orders found, just display an "empty" message
     if (null === $objOrders) {
         $this->Template = new \Isotope\Template('mod_message');
         $this->Template->type = 'empty';
         $this->Template->message = $GLOBALS['TL_LANG']['ERR']['emptyOrderHistory'];
         return;
     }
     while ($objOrders->next()) {
         Isotope::setConfig($objOrders->current()->getRelated('config_id'));
         $arrOrders[] = array('collection' => $objOrders->current(), 'raw' => $objOrders->current()->row(), 'date' => Format::date($objOrders->current()->locked), 'time' => Format::time($objOrders->current()->locked), 'datime' => Format::datim($objOrders->current()->locked), 'grandTotal' => Isotope::formatPriceWithCurrency($objOrders->current()->getTotal()), 'status' => $objOrders->current()->getStatusLabel(), 'link' => $this->jumpTo ? \Haste\Util\Url::addQueryString('uid=' . $objOrders->current()->uniqid, $this->jumpTo) : '', 'class' => $objOrders->current()->getStatusAlias());
     }
     RowClass::withKey('class')->addFirstLast()->addEvenOdd()->applyTo($arrOrders);
     $this->Template->orders = $arrOrders;
 }
コード例 #7
0
ファイル: ModelData.php プロジェクト: codefog/contao-haste
 /**
  * Auto-format model data based on DCA config
  * @param   \Model
  * @param   callable
  * @return  \ArrayObject
  */
 public static function generate(\Model $objModel = null, $varCallable = null)
 {
     if (null === $objModel) {
         return new \ArrayObject(array(), \ArrayObject::ARRAY_AS_PROPS);
     }
     $strTable = $objModel->getTable();
     $objDca = new \DcaExtractor($strTable);
     $arrRelations = $objDca->getRelations();
     $arrData = array();
     \System::loadLanguageFile($strTable);
     \Controller::loadDataContainer($strTable);
     $arrFields =& $GLOBALS['TL_DCA'][$strTable]['fields'];
     foreach ($objModel->row() as $strField => $varValue) {
         $arrAdditional = array();
         $strLabel = Format::dcaLabel($strTable, $strField);
         if (isset($arrRelations[$strField])) {
             $objRelated = $objModel->getRelated($strField);
             if ($objRelated == null) {
                 $arrData[$strField] = new Plain('', $strLabel, $arrAdditional);
             } elseif ($objRelated instanceof \Model\Collection) {
                 $arrCollection = array();
                 foreach ($objRelated as $objRelatedModel) {
                     $arrCollection[] = new Relation($objRelatedModel, '', array(), $varCallable);
                 }
                 $arrData[$strField] = new Collection($arrCollection, $strLabel);
             } else {
                 $arrData[$strField] = new Relation($objRelated, $strLabel, array(), $varCallable);
             }
             continue;
         }
         $arrAdditional['formatted'] = Format::dcaValue($strTable, $strField, $varValue);
         if (in_array($arrFields[$strField]['eval']['rgxp'], array('date', 'datim', 'time'))) {
             $arrData[$strField] = new Timestamp($varValue, $strLabel, $arrAdditional);
         } else {
             $arrData[$strField] = new Plain($varValue, $strLabel, $arrAdditional);
         }
     }
     if (null !== $varCallable) {
         call_user_func_array($varCallable, array($objModel, &$arrData));
     }
     return new \ArrayObject($arrData, \ArrayObject::ARRAY_AS_PROPS);
 }
コード例 #8
0
ファイル: Callback.php プロジェクト: Aziz-JH/core
 /**
  * Generate header fields for product or variant
  * @param   array
  * @param   \Contao\DataContainer
  */
 public function headerFields($arrFields, $dc)
 {
     $t = Product::getTable();
     $arrNew = array();
     $objProduct = Product::findByPk($dc->id);
     if (null === $objProduct) {
         return $arrFields;
     }
     $arrAttributes = array('name', 'alias', 'sku');
     if ($objProduct->isVariant()) {
         $arrAttributes = array_merge($arrAttributes, array_intersect(array_merge($objProduct->getAttributes(), $objProduct->getVariantAttributes()), Attribute::getVariantOptionFields()));
     }
     foreach ($arrAttributes as $field) {
         $v = $objProduct->{$field};
         if ($v != '') {
             $arrNew[Format::dcaLabel($t, $field)] = Format::dcaValue($t, $field, $v);
         }
     }
     // Add fields that have potentially been added through the DCA, but do not allow to override the core fields
     return array_merge($arrNew, array_diff_key($arrFields, $arrNew));
 }
コード例 #9
0
ファイル: Attribute.php プロジェクト: bytehead/core
 /**
  * Generate HTML markup of product data for this attribute
  *
  * @param   IsotopeProduct $objProduct
  * @param   array          $arrOptions
  *
  * @return string
  */
 public function generate(IsotopeProduct $objProduct, array $arrOptions = array())
 {
     $varValue = $this->getValue($objProduct);
     if (is_array($varValue) && !array_is_assoc($varValue) && is_array($varValue[0])) {
         // Generate a HTML table for associative arrays
         $strBuffer = $this->generateTable($varValue, $objProduct);
     } elseif (is_array($varValue)) {
         // Generate ul/li listing for simple arrays
         foreach ($varValue as &$v) {
             $v = Format::dcaValue('tl_iso_product', $this->field_name, $v);
         }
         $strBuffer = $this->generateList($varValue);
     } else {
         $strBuffer = Format::dcaValue('tl_iso_product', $this->field_name, $varValue);
     }
     return $strBuffer;
 }
コード例 #10
0
 /**
  * Get formatted column labels
  * @return  array
  */
 protected function getColumnLabels()
 {
     $arrLabels = array();
     $count = 0;
     foreach ($this->arrListFields as $strField) {
         // Use a custom label
         if (count($this->customLabels) > 0) {
             $label = $this->customLabels[$count++];
         } else {
             // Get the label from DCA
             list($strTable, $strColumn) = explode('.', $strField);
             $label = \Haste\Util\Format::dcaLabel($strTable, $strColumn);
         }
         $arrLabels[standardize($strField)]['label'] = $label;
     }
     \Haste\Generator\RowClass::withKey('rowClass')->addCustom('row')->addCount('row_')->addFirstLast('row_')->addEvenOdd('row_')->applyTo($arrLabels);
     return $arrLabels;
 }
コード例 #11
0
 /**
  * Get attributes that can be filtered
  *
  * @param   DataContainer
  * @return  array
  */
 public function getAttributeNames($dc)
 {
     $arrAttributes = array();
     foreach ($GLOBALS['TL_DCA']['tl_iso_product']['fields'] as $attribute => $config) {
         if ($config['attributes']['legend'] != '' && $attribute != 'pages' && $config['inputType'] != 'mediaManager') {
             $arrAttributes[$attribute] = Format::dcaLabel('tl_iso_product', $attribute);
         }
     }
     asort($arrAttributes);
     return $arrAttributes;
 }
コード例 #12
0
ファイル: Isotope.php プロジェクト: ralfhartmann/isotope_core
 /**
  * Format product configuration using \Haste\Data
  *
  * @param array                  $arrConfig
  * @param IsotopeProduct|Product $objProduct
  *
  * @return array
  */
 public static function formatProductConfiguration(array $arrConfig, IsotopeProduct $objProduct)
 {
     Product::setActive($objProduct);
     $strTable = $objProduct->getTable();
     foreach ($arrConfig as $k => $v) {
         /** @type \Isotope\Model\Attribute $objAttribute */
         if (($objAttribute = $GLOBALS['TL_DCA'][$strTable]['attributes'][$k]) !== null && $objAttribute instanceof IsotopeAttributeWithOptions) {
             /** @type \Widget $strClass */
             $strClass = $objAttribute->getFrontendWidget();
             $arrField = $strClass::getAttributesFromDca($GLOBALS['TL_DCA'][$strTable]['fields'][$k], $k, $v, $k, $strTable, $objProduct);
             $arrOptions = array();
             $values = $v;
             if (!empty($arrField['options']) && is_array($arrField['options'])) {
                 if (!is_array($values)) {
                     $values = array($values);
                 }
                 $arrOptions = array_filter($arrField['options'], function (&$option) use(&$values) {
                     if (($pos = array_search($option['value'], $values)) !== false) {
                         $option = $option['label'];
                         unset($values[$pos]);
                         return true;
                     }
                     return false;
                 });
                 if (!empty($values)) {
                     $arrOptions = array_merge($arrOptions, $values);
                 }
             }
             $formatted = implode(', ', $arrOptions);
         } else {
             $formatted = Format::dcaValue($strTable, $k, $v);
         }
         $arrConfig[$k] = new Plain($v, Format::dcaLabel($strTable, $k), array('formatted' => Haste::getInstance()->call('replaceInsertTags', array($formatted))));
     }
     Product::unsetActive();
     return $arrConfig;
 }
コード例 #13
0
ファイル: Order.php プロジェクト: ralfhartmann/isotope_core
 /**
  * Retrieve the array of notification data for parsing simple tokens
  *
  * @param int $intNotification
  *
  * @return array
  */
 public function getNotificationTokens($intNotification)
 {
     /** @type \Isotope\Model\Config $objConfig */
     $objConfig = $this->getRelated('config_id');
     $arrTokens = deserialize($this->email_data, true);
     $arrTokens['uniqid'] = $this->uniqid;
     $arrTokens['order_status_id'] = $this->order_status;
     $arrTokens['order_status'] = $this->getStatusLabel();
     $arrTokens['recipient_email'] = $this->getEmailRecipient();
     $arrTokens['order_id'] = $this->id;
     $arrTokens['order_items'] = $this->sumItemsQuantity();
     $arrTokens['order_products'] = $this->countItems();
     $arrTokens['order_subtotal'] = Isotope::formatPriceWithCurrency($this->getSubtotal(), false);
     $arrTokens['order_total'] = Isotope::formatPriceWithCurrency($this->getTotal(), false);
     $arrTokens['document_number'] = $this->document_number;
     $arrTokens['cart_html'] = '';
     $arrTokens['cart_text'] = '';
     $arrTokens['document'] = '';
     // Add all the collection fields
     foreach ($this->row() as $k => $v) {
         $arrTokens['collection_' . $k] = $v;
     }
     // Add billing/customer address fields
     if (($objAddress = $this->getBillingAddress()) !== null) {
         foreach ($objAddress->row() as $k => $v) {
             $arrTokens['billing_address_' . $k] = Format::dcaValue($objAddress->getTable(), $k, $v);
             // @deprecated (use ##billing_address_*##)
             $arrTokens['billing_' . $k] = $arrTokens['billing_address_' . $k];
         }
         $arrTokens['billing_address'] = $objAddress->generate($objConfig->getBillingFieldsConfig());
         // @deprecated (use ##billing_address##)
         $arrTokens['billing_address_text'] = $arrTokens['billing_address'];
     }
     // Add shipping address fields
     if (($objAddress = $this->getShippingAddress()) !== null) {
         foreach ($objAddress->row() as $k => $v) {
             $arrTokens['shipping_address_' . $k] = Format::dcaValue($objAddress->getTable(), $k, $v);
             // @deprecated (use ##billing_address_*##)
             $arrTokens['shipping_' . $k] = $arrTokens['shipping_address_' . $k];
         }
         $arrTokens['shipping_address'] = $objAddress->generate($objConfig->getShippingFieldsConfig());
         // Shipping address equals billing address
         // @deprecated (use ##shipping_address##)
         if ($objAddress->id == $this->getBillingAddress()->id) {
             $arrTokens['shipping_address_text'] = $this->requiresPayment() ? $GLOBALS['TL_LANG']['MSC']['useBillingAddress'] : $GLOBALS['TL_LANG']['MSC']['useCustomerAddress'];
         } else {
             $arrTokens['shipping_address_text'] = $arrTokens['shipping_address'];
         }
     }
     // Add payment method info
     if ($this->hasPayment() && ($objPayment = $this->getPaymentMethod()) !== null) {
         $arrTokens['payment_id'] = $objPayment->id;
         $arrTokens['payment_label'] = $objPayment->getLabel();
         $arrTokens['payment_note'] = $objPayment->note;
     }
     // Add shipping method info
     if ($this->hasShipping() && ($objShipping = $this->getShippingMethod()) !== null) {
         $arrTokens['shipping_id'] = $objShipping->id;
         $arrTokens['shipping_label'] = $objShipping->getLabel();
         $arrTokens['shipping_note'] = $objShipping->note;
     }
     // Add config fields
     if ($this->getRelated('config_id') !== null) {
         foreach ($this->getRelated('config_id')->row() as $k => $v) {
             $arrTokens['config_' . $k] = Format::dcaValue($this->getRelated('config_id')->getTable(), $k, $v);
         }
     }
     // Add member fields
     if ($this->member > 0 && $this->getRelated('member') !== null) {
         foreach ($this->getRelated('member')->row() as $k => $v) {
             $arrTokens['member_' . $k] = Format::dcaValue($this->getRelated('member')->getTable(), $k, $v);
         }
     }
     if ($intNotification > 0 && ($objNotification = Notification::findByPk($intNotification)) !== null) {
         $objTemplate = new \Isotope\Template($objNotification->iso_collectionTpl);
         $objTemplate->isNotification = true;
         $this->addToTemplate($objTemplate, array('gallery' => $objNotification->iso_gallery, 'sorting' => $this->getItemsSortingCallable($objNotification->iso_orderCollectionBy)));
         $arrTokens['cart_html'] = Haste::getInstance()->call('replaceInsertTags', array($objTemplate->parse(), false));
         $objTemplate->textOnly = true;
         $arrTokens['cart_text'] = strip_tags(Haste::getInstance()->call('replaceInsertTags', array($objTemplate->parse(), true)));
         // Generate and "attach" document
         /** @var \Isotope\Interfaces\IsotopeDocument $objDocument */
         if ($objNotification->iso_document > 0 && ($objDocument = Document::findByPk($objNotification->iso_document)) !== null) {
             $strFilePath = $objDocument->outputToFile($this, TL_ROOT . '/system/tmp');
             $arrTokens['document'] = str_replace(TL_ROOT . '/', '', $strFilePath);
         }
     }
     // !HOOK: add custom email tokens
     if (isset($GLOBALS['ISO_HOOKS']['getOrderNotificationTokens']) && is_array($GLOBALS['ISO_HOOKS']['getOrderNotificationTokens'])) {
         foreach ($GLOBALS['ISO_HOOKS']['getOrderNotificationTokens'] as $callback) {
             $objCallback = \System::importStatic($callback[0]);
             $arrTokens = $objCallback->{$callback}[1]($this, $arrTokens);
         }
     }
     return $arrTokens;
 }
コード例 #14
0
 /**
  * Export the file
  * @param object
  * @param boolean
  * @param boolean
  */
 protected function exportFile(\Haste\IO\Writer\WriterInterface $objWriter, $blnHeaderFields, $blnRawData)
 {
     $objMembers = \MemberModel::findAll();
     // Reload if there are no members
     if ($objMembers === null) {
         $this->reload();
     }
     $objReader = new \Haste\IO\Reader\ModelCollectionReader($objMembers);
     // Set header fields
     if ($blnHeaderFields) {
         $arrHeaderFields = array();
         foreach ($GLOBALS['TL_DCA']['tl_member']['fields'] as $strField => $arrField) {
             $arrHeaderFields[] = $blnRawData || !$arrField['label'][0] ? $strField : $arrField['label'][0];
         }
         $objReader->setHeaderFields($arrHeaderFields);
         $objWriter->enableHeaderFields();
     }
     // Format the values
     if (!$blnRawData) {
         $objWriter->setRowCallback(function ($arrRow) {
             foreach ($arrRow as $k => $v) {
                 $arrRow[$k] = \Haste\Util\Format::dcaValue('tl_member', $k, $v);
             }
             return $arrRow;
         });
     }
     $objWriter->writeFrom($objReader);
     $objFile = new \File($objWriter->getFilename());
     $objFile->sendToBrowser();
 }
コード例 #15
0
 /**
  * Send the personal data change e-mail
  * @param object
  * @param array
  * @param object
  */
 public function sendPersonalDataEmail($objUser, $arrData, $objModule)
 {
     if (!$objModule->nc_notification) {
         return;
     }
     $arrTokens = array();
     $arrTokens['admin_email'] = $GLOBALS['TL_ADMIN_EMAIL'];
     $arrTokens['domain'] = \Environment::get('host');
     // Support newsletters
     if (in_array('newsletter', $this->Config->getActiveModules())) {
         if (!is_array($arrData['newsletter'])) {
             if ($arrData['newsletter'] != '') {
                 $objChannels = \Database::getInstance()->execute("SELECT title FROM tl_newsletter_channel WHERE id IN(" . implode(',', array_map('intval', (array) $arrData['newsletter'])) . ")");
                 $arrTokens['member_newsletter'] = implode("\n", $objChannels->fetchEach('title'));
             } else {
                 $arrTokens['member_newsletter'] = '';
             }
         }
     }
     // Translate/format old values
     foreach ($_SESSION['PERSONAL_DATA'] as $strFieldName => $strFieldValue) {
         $arrTokens['member_old_' . $strFieldName] = \Haste\Util\Format::dcaValue('tl_member', $strFieldName, $strFieldValue);
     }
     // Translate/format new values
     foreach ($arrData as $strFieldName => $strFieldValue) {
         $arrTokens['member_' . $strFieldName] = \Haste\Util\Format::dcaValue('tl_member', $strFieldName, $strFieldValue);
     }
     $objNotification = \NotificationCenter\Model\Notification::findByPk($objModule->nc_notification);
     if ($objNotification !== null) {
         $objNotification->send($arrTokens);
     }
 }
コード例 #16
0
ファイル: Address.php プロジェクト: bytehead/core
 /**
  * Compile the list of hCard tokens for this address
  *
  * @param array $arrFields
  *
  * @return array
  */
 public function getTokens($arrFields = null)
 {
     global $objPage;
     if (!is_array($arrFields)) {
         $arrFields = Isotope::getConfig()->getBillingFieldsConfig();
     }
     $arrTokens = array('outputFormat' => $objPage->outputFormat);
     foreach ($arrFields as $arrField) {
         $strField = $arrField['value'];
         // Set an empty value for disabled fields, otherwise the token would not be replaced
         if (!$arrField['enabled']) {
             $arrTokens[$strField] = '';
             continue;
         }
         if ($strField == 'subdivision' && $this->subdivision != '') {
             $arrSubdivisions = \Isotope\Backend::getSubdivisions();
             list($country, $subdivion) = explode('-', $this->subdivision);
             $arrTokens['subdivision'] = $arrSubdivisions[strtolower($country)][$this->subdivision];
             $arrTokens['subdivision_abbr'] = $subdivion;
             continue;
         }
         $arrTokens[$strField] = Format::dcaValue(static::$strTable, $strField, $this->{$strField});
     }
     /**
      * Generate hCard fields
      * See http://microformats.org/wiki/hcard
      */
     // Set "fn" (full name) to company if no first- and lastname is given
     if ($arrTokens['company'] != '') {
         $fn = $arrTokens['company'];
         $fnCompany = ' fn';
     } else {
         $fn = trim($arrTokens['firstname'] . ' ' . $arrTokens['lastname']);
         $fnCompany = '';
     }
     $street = implode($objPage->outputFormat == 'html' ? '<br>' : '<br />', array_filter(array($this->street_1, $this->street_2, $this->street_3)));
     $arrTokens += array('hcard_fn' => $fn ? '<span class="fn">' . $fn . '</span>' : '', 'hcard_n' => $arrTokens['firstname'] || $arrTokens['lastname'] ? '1' : '', 'hcard_honorific_prefix' => $arrTokens['salutation'] ? '<span class="honorific-prefix">' . $arrTokens['salutation'] . '</span>' : '', 'hcard_given_name' => $arrTokens['firstname'] ? '<span class="given-name">' . $arrTokens['firstname'] . '</span>' : '', 'hcard_family_name' => $arrTokens['lastname'] ? '<span class="family-name">' . $arrTokens['lastname'] . '</span>' : '', 'hcard_org' => $arrTokens['company'] ? '<div class="org' . $fnCompany . '">' . $arrTokens['company'] . '</div>' : '', 'hcard_email' => $arrTokens['email'] ? '<a href="mailto:' . $arrTokens['email'] . '">' . $arrTokens['email'] . '</a>' : '', 'hcard_tel' => $arrTokens['phone'] ? '<div class="tel">' . $arrTokens['phone'] . '</div>' : '', 'hcard_adr' => $street | $arrTokens['city'] || $arrTokens['postal'] || $arrTokens['subdivision'] || $arrTokens['country'] ? '1' : '', 'hcard_street_address' => $street ? '<div class="street-address">' . $street . '</div>' : '', 'hcard_locality' => $arrTokens['city'] ? '<span class="locality">' . $arrTokens['city'] . '</span>' : '', 'hcard_region' => $arrTokens['subdivision'] ? '<span class="region">' . $arrTokens['subdivision'] . '</span>' : '', 'hcard_region_abbr' => $arrTokens['subdivision_abbr'] ? '<abbr class="region" title="' . $arrTokens['subdivision'] . '">' . $arrTokens['subdivision_abbr'] . '</abbr>' : '', 'hcard_postal_code' => $arrTokens['postal'] ? '<span class="postal-code">' . $arrTokens['postal'] . '</span>' : '', 'hcard_country_name' => $arrTokens['country'] ? '<div class="country-name">' . $arrTokens['country'] . '</div>' : '');
     return $arrTokens;
 }
コード例 #17
0
 /**
  * Generate HTML markup of product data for this attribute
  *
  * @param IsotopeProduct $objProduct
  * @param array          $arrOptions
  *
  * @return string
  */
 public function generate(IsotopeProduct $objProduct, array $arrOptions = array())
 {
     $varValue = $this->getValue($objProduct);
     if (!is_array($varValue)) {
         return Format::dcaValue('tl_iso_product', $this->field_name, $varValue);
     }
     // Generate a HTML table for associative arrays
     if (!array_is_assoc($varValue) && is_array($varValue[0])) {
         return $arrOptions['noHtml'] ? $varValue : $this->generateTable($varValue, $objProduct);
     }
     if ($arrOptions['noHtml']) {
         $result = array();
         foreach ($varValue as $v) {
             $result[$v] = Format::dcaValue('tl_iso_product', $this->field_name, $v);
         }
         return $result;
     }
     // Generate ul/li listing for simple arrays
     foreach ($varValue as &$v) {
         $v = Format::dcaValue('tl_iso_product', $this->field_name, $v);
     }
     return $this->generateList($varValue);
 }
コード例 #18
0
ファイル: DcaWizard.php プロジェクト: terminal42/dcawizard
 /**
  * Get header fields
  *
  * @return array
  */
 public function getHeaderFields()
 {
     $arrHeaderFields = $this->headerFields;
     if (!is_array($arrHeaderFields) || empty($arrHeaderFields)) {
         foreach ($this->fields as $field) {
             if ($field == 'id') {
                 $arrHeaderFields[] = 'ID';
                 continue;
             }
             $arrHeaderFields[] = Format::dcaLabel($this->foreignTable, $field);
         }
     }
     return $arrHeaderFields;
 }
コード例 #19
0
ファイル: Callback.php プロジェクト: Aziz-JH/core
    /**
     * Generate address details amd return it as string
     * @param   Address
     * @return  string
     */
    protected function generateAddressData(Address $objAddress = null)
    {
        if (null === $objAddress) {
            return '<div class="tl_gerror">No address data available.</div>';
        }
        \System::loadLanguageFile($objAddress->getTable());
        $this->loadDataContainer($objAddress->getTable());
        $strBuffer = '
<div>
<table cellpadding="0" cellspacing="0" class="tl_show" summary="Table lists all details of an entry" style="width:650px">
  <tbody>';
        $i = 0;
        foreach ($GLOBALS['TL_DCA'][$objAddress->getTable()]['fields'] as $k => $v) {
            if (!isset($objAddress->{$k})) {
                continue;
            }
            $v = $objAddress->{$k};
            $strClass = ++$i % 2 ? '' : ' class="tl_bg"';
            $strBuffer .= '
  <tr>
    <td' . $strClass . ' style="vertical-align:top"><span class="tl_label">' . Format::dcaLabel($objAddress->getTable(), $k) . ': </span></td>
    <td' . $strClass . '>' . Format::dcaValue($objAddress->getTable(), $k, $v) . '</td>
  </tr>';
        }
        $strBuffer .= '
</tbody></table>
</div>';
        return $strBuffer;
    }
コード例 #20
0
ファイル: Isotope.php プロジェクト: Aziz-JH/core
 /**
  * Format options label and value
  *
  * @param array  $arrData
  * @param string $strTable
  * @param bool   $blnSkipEmpty
  *
  * @return array
  */
 public static function formatOptions(array $arrData, $strTable = 'tl_iso_product', $blnSkipEmpty = true)
 {
     $arrOptions = array();
     foreach ($arrData as $field => $value) {
         if ($blnSkipEmpty && ($value == '' || $value == '-')) {
             continue;
         }
         $arrOptions[$field] = array('label' => Format::dcaLabel($strTable, $field), 'value' => Haste::getInstance()->call('replaceInsertTags', Format::dcaValue($strTable, $field, $value)));
     }
     return $arrOptions;
 }
コード例 #21
0
ファイル: Timestamp.php プロジェクト: codefog/contao-haste
 public function __construct($value, $label = '', array $additional = array())
 {
     $additional = array_merge(array('date' => Format::date($value), 'datim' => Format::datim($value), 'time' => Format::time($value)), $additional);
     parent::__construct($value, $label, $additional);
 }
コード例 #22
0
ファイル: InsertTag.php プロジェクト: codefog/contao-haste
 /**
  * Replace {{dca_value::*}} insert tag
  *
  * use case:
  *
  * {{dca_value::table::field::value}}
  *
  * @param array $arrTag
  *
  * @return string
  */
 private function replaceDcaValue($arrTag)
 {
     $strTable = $arrTag[1];
     $strField = $arrTag[2];
     $varValue = $arrTag[3];
     return Format::dcaValue($strTable, $strField, $varValue);
 }
コード例 #23
0
ファイル: Callback.php プロジェクト: Aziz-JH/core
    /**
     * Generate a list of tiers for a wizard in products
     * @param object
     * @param string
     * @return string
     */
    public function generateWizardList($objRecords, $strId)
    {
        $strReturn = '
<table class="tl_listing showColumns">
<thead>
    <td class="tl_folder_tlist">' . Format::dcaLabel('tl_iso_product_price', 'price_tiers') . '</td>
    <td class="tl_folder_tlist">' . Format::dcaLabel('tl_iso_product_price', 'tax_class') . '</td>
    <td class="tl_folder_tlist">' . Format::dcaLabel('tl_iso_product_price', 'config_id') . '</td>
    <td class="tl_folder_tlist">' . Format::dcaLabel('tl_iso_product_price', 'member_group') . '</td>
    <td class="tl_folder_tlist">' . Format::dcaLabel('tl_iso_product_price', 'start') . '</td>
    <td class="tl_folder_tlist">' . Format::dcaLabel('tl_iso_product_price', 'stop') . '</td>
</thead>
<tbody>';
        while ($objRecords->next()) {
            $arrTiers = array();
            $objTiers = \Database::getInstance()->execute("SELECT * FROM tl_iso_product_pricetier WHERE pid={$objRecords->id} ORDER BY min");
            while ($objTiers->next()) {
                $arrTiers[] = "{$objTiers->min}={$objTiers->price}";
            }
            $strReturn .= '
<tr>
    <td class="tl_file_list">' . implode(', ', $arrTiers) . '</td>
    <td class="tl_file_list">' . (Format::dcaValue('tl_iso_product_price', 'tax_class', $objRecords->tax_class) ?: '-') . '</td>
    <td class="tl_file_list">' . (Format::dcaValue('tl_iso_product_price', 'config_id', $objRecords->config_id) ?: '-') . '</td>
    <td class="tl_file_list">' . (Format::dcaValue('tl_iso_product_price', 'member_group', $objRecords->member_group) ?: '-') . '</td>
    <td class="tl_file_list">' . (Format::dcaValue('tl_iso_product_price', 'member_group', $objRecords->start) ?: '-') . '</td>
    <td class="tl_file_list">' . (Format::dcaValue('tl_iso_product_price', 'member_group', $objRecords->stop) ?: '-') . '</td>
</tr>
';
        }
        $strReturn .= '
</tbody>
</table>';
        return $strReturn;
    }
コード例 #24
0
ファイル: Attribute.php プロジェクト: Aziz-JH/core
 public function generate(IsotopeProduct $objProduct, array $arrOptions = array())
 {
     $varValue = $objProduct->{$this->field_name};
     // Generate a HTML table for associative arrays
     if (is_array($varValue) && !array_is_assoc($varValue) && is_array($varValue[0])) {
         $strBuffer = $this->generateTable($varValue, $objProduct);
     } elseif (is_array($varValue)) {
         $strBuffer = $this->generateList($varValue);
     } else {
         $strBuffer = Format::dcaValue('tl_iso_product', $this->field_name, $varValue);
     }
     return $strBuffer;
 }
コード例 #25
0
 /**
  * Build palette for the current product type/variant
  */
 public function buildPaletteString()
 {
     $this->loadDataContainer(Attribute::getTable());
     if (\Input::get('act') == '' && \Input::get('key') == '' || \Input::get('act') == 'select') {
         return;
     }
     $arrTypes = array();
     $arrFields =& $GLOBALS['TL_DCA']['tl_iso_product']['fields'];
     /** @var IsotopeAttribute[] $arrAttributes */
     $arrAttributes =& $GLOBALS['TL_DCA']['tl_iso_product']['attributes'];
     $blnVariants = false;
     $act = \Input::get('act');
     $blnSingleRecord = $act === 'edit' || $act === 'show';
     if (\Input::get('id') > 0) {
         /** @type object $objProduct */
         $objProduct = \Database::getInstance()->prepare("SELECT p1.pid, p1.type, p2.type AS parent_type FROM tl_iso_product p1 LEFT JOIN tl_iso_product p2 ON p1.pid=p2.id WHERE p1.id=?")->execute(\Input::get('id'));
         if ($objProduct->numRows) {
             $objType = ProductType::findByPk($objProduct->pid > 0 ? $objProduct->parent_type : $objProduct->type);
             $arrTypes = null === $objType ? array() : array($objType);
             if ($objProduct->pid > 0 || $act != 'edit' && $act != 'copyFallback' && $act != 'show') {
                 $blnVariants = true;
             }
         }
     } else {
         $arrTypes = ProductType::findAllUsed() ?: array();
     }
     /** @var \Isotope\Model\ProductType $objType */
     foreach ($arrTypes as $objType) {
         // Enable advanced prices
         if ($blnSingleRecord && $objType->hasAdvancedPrices()) {
             $arrFields['prices']['exclude'] = $arrFields['price']['exclude'];
             $arrFields['prices']['attributes'] = $arrFields['price']['attributes'];
             $arrFields['price'] = $arrFields['prices'];
         } else {
             $GLOBALS['TL_DCA']['tl_iso_product']['config']['onversion_callback'][] = array('Isotope\\Backend\\Product\\Price', 'createVersion');
             $GLOBALS['TL_DCA']['tl_iso_product']['config']['onrestore_callback'][] = array('Isotope\\Backend\\Product\\Price', 'restoreVersion');
         }
         $arrInherit = array();
         $arrPalette = array();
         $arrLegends = array();
         $arrLegendOrder = array();
         $arrCanInherit = array();
         if ($blnVariants) {
             $arrConfig = $objType->variant_attributes;
             $arrEnabled = $objType->getVariantAttributes();
             $arrCanInherit = $objType->getAttributes();
         } else {
             $arrConfig = $objType->attributes;
             $arrEnabled = $objType->getAttributes();
         }
         // Go through each enabled field and build palette
         foreach ($arrFields as $name => $arrField) {
             if (in_array($name, $arrEnabled)) {
                 if ($arrField['inputType'] == '') {
                     continue;
                 }
                 // Variant fields can only be edited in variant mode
                 if (null !== $arrAttributes[$name] && !$blnVariants && $arrAttributes[$name]->isVariantOption()) {
                     continue;
                 }
                 // Field cannot be edited in variant
                 if ($blnVariants && $arrAttributes[$name]->inherit) {
                     continue;
                 }
                 $arrLegendOrder[$arrConfig[$name]['position']] = $arrConfig[$name]['legend'];
                 $arrPalette[$arrConfig[$name]['legend']][$arrConfig[$name]['position']] = $name;
                 // Apply product type attribute config
                 if ($arrConfig[$name]['tl_class'] != '') {
                     $arrFields[$name]['eval']['tl_class'] = $arrConfig[$name]['tl_class'];
                 }
                 if ($arrConfig[$name]['mandatory'] > 0) {
                     $arrFields[$name]['eval']['mandatory'] = $arrConfig[$name]['mandatory'] == 1 ? false : true;
                 }
                 if ($blnVariants && in_array($name, $arrCanInherit) && null !== $arrAttributes[$name] && !$arrAttributes[$name]->isVariantOption() && !in_array($name, array('price', 'published', 'start', 'stop'))) {
                     $arrInherit[$name] = Format::dcaLabel('tl_iso_product', $name);
                 }
             } else {
                 // Hide field from "show" option
                 if (!isset($arrField['attributes']) || $arrField['inputType'] != '' && $name != 'inherit') {
                     $arrFields[$name]['eval']['doNotShow'] = true;
                 }
             }
         }
         ksort($arrLegendOrder);
         $arrLegendOrder = array_unique($arrLegendOrder);
         // Build
         foreach ($arrLegendOrder as $legend) {
             $fields = $arrPalette[$legend];
             ksort($fields);
             $arrLegends[] = '{' . $legend . '},' . implode(',', $fields);
         }
         // Set inherit options
         $arrFields['inherit']['options'] = $arrInherit;
         // Add palettes
         $GLOBALS['TL_DCA']['tl_iso_product']['palettes'][$blnVariants ? 'default' : $objType->id] = ($blnVariants ? 'inherit,' : '') . implode(';', $arrLegends);
     }
     // Remove non-active fields from multi-selection
     if ($blnVariants && !$blnSingleRecord) {
         $arrInclude = empty($arrPalette) ? array() : call_user_func_array('array_merge', $arrPalette);
         foreach ($arrFields as $name => $config) {
             if ($arrFields[$name]['attributes']['legend'] != '' && !in_array($name, $arrInclude)) {
                 $arrFields[$name]['exclude'] = true;
             }
         }
     }
 }
コード例 #26
0
 /**
  * Generate a sorting form
  */
 protected function generateSorting()
 {
     $this->Template->hasSorting = false;
     if (!empty($this->iso_sortingFields)) {
         $arrOptions = array();
         // Cache new request value
         // @todo should support multiple sorting fields
         list($sortingField, $sortingDirection) = explode(':', \Input::post('sorting'));
         if ($this->blnUpdateCache && in_array($sortingField, $this->iso_sortingFields)) {
             Isotope::getRequestCache()->setSortingForModule($sortingField, $sortingDirection == 'DESC' ? Sort::descending() : Sort::ascending(), $this->id);
         } elseif (array_diff(array_keys(Isotope::getRequestCache()->getSortingsForModules(array($this->id))), $this->iso_sortingFields)) {
             // Request cache contains wrong value, delete it!
             $this->blnUpdateCache = true;
             Isotope::getRequestCache()->unsetSortingsForModule($this->id);
             RequestCache::deleteById(\Input::get('isorc'));
         } elseif (!$this->blnUpdateCache) {
             // No need to generate options if we reload anyway
             $first = Isotope::getRequestCache()->getFirstSortingFieldForModule($this->id);
             foreach ($this->iso_sortingFields as $field) {
                 list($asc, $desc) = $this->getSortingLabels($field);
                 $objSorting = $first == $field ? Isotope::getRequestCache()->getSortingForModule($field, $this->id) : null;
                 $arrOptions[] = array('label' => Format::dcaLabel('tl_iso_product', $field) . ', ' . $asc, 'value' => $field . ':ASC', 'default' => null !== $objSorting && $objSorting->isAscending() ? '1' : '');
                 $arrOptions[] = array('label' => Format::dcaLabel('tl_iso_product', $field) . ', ' . $desc, 'value' => $field . ':DESC', 'default' => null !== $objSorting && $objSorting->isDescending() ? '1' : '');
             }
         }
         $this->Template->hasSorting = true;
         $this->Template->sortingLabel = $GLOBALS['TL_LANG']['MSC']['orderByLabel'];
         $this->Template->sortingOptions = $arrOptions;
     }
 }