ruleName = JText::translate('VBO_ROOM_UPGRADE'); $this->ruleDescr = JText::translate('VBO_ROOM_UPGRADE_CONDTEXT_H'); $this->ruleId = basename(__FILE__); } /** * Displays the rule parameters. * * @return void */ public function renderParams() { ?>
vbo_app->printYesNoButtons($this->inputName('can_upgrade'), JText::translate('VBYES'), JText::translate('VBNO'), (int)$this->getParam('can_upgrade', 0), 1, 0); ?>
vbo_app->printYesNoButtons($this->inputName('add_details'), JText::translate('VBYES'), JText::translate('VBNO'), (int)$this->getParam('add_details', 0), 1, 0); ?> {room_upgrade}
getParam('can_upgrade', 0); if (!$can_upgrade) { return true; } $booking = $this->getProperty('booking', []); if (!is_array($booking) || !count($booking)) { return false; } $rooms_booked = $this->getProperty('rooms', []); if (!is_array($rooms_booked) || !count($rooms_booked)) { return false; } // booking status must be confirmed if ($this->getPropVal('booking', 'status', '') != 'confirmed') { return false; } // translator object $vbo_tn = VikBooking::getTranslator(); // look for available upgrade options $this->upgrade_options = VBORoomHelper::getInstance([ 'booking' => $booking, 'rooms' => $rooms_booked, ], true)->getUpgradeOptions($vbo_tn); return ($this->upgrade_options && $this->upgrade_options['upgrade']); } /** * Allows to manipulate the message of the conditional text with dynamic contents. * * @override * * @param string $msg the current conditional text message. * * @return string the manipulated conditional text message. */ public function manipulateMessage($msg) { $add_details = (bool)$this->getParam('add_details', 0); if (!$add_details || !$this->upgrade_options || !$this->upgrade_options['upgrade']) { return $msg; } // build HTML content $upgrade_html_details = $this->buildHtmlUpgradeDetails(); if (strpos($msg, '{room_upgrade}') !== false) { // exact placeholder tag found return str_replace('{room_upgrade}', $upgrade_html_details, $msg); } // append upgrade details content to message return $msg . $upgrade_html_details; } /** * Builds the necessary HTML content with the upgrade details * to be added to the conditional text message. * * @return string */ protected function buildHtmlUpgradeDetails() { if (!$this->upgrade_options || !$this->upgrade_options['upgrade']) { return ''; } // access booking information $booking = $this->getProperty('booking', []); $rooms_booked = $this->getProperty('rooms', []); // build booking link $use_sid = !empty($booking['idorderota']) && !empty($booking['channel']) ? $booking['idorderota'] : $booking['sid']; $booking_link = VikBooking::externalroute("index.php?option=com_vikbooking&view=booking&sid={$use_sid}&ts={$booking['ts']}&room_upgrade=1", false); // get preferences $currencysymb = VikBooking::getCurrencySymb(); $pref_colors = VikBooking::getPreferredColors(); // default colors for button-links $btnlink_bgc = '#3d89d1'; $btnlink_col = '#ffffff'; if (!empty($pref_colors['bgcolor']) && !empty($pref_colors['fontcolor'])) { $btnlink_bgc = $pref_colors['bgcolor']; $btnlink_col = $pref_colors['fontcolor']; } // start output buffering ob_start(); foreach ($this->upgrade_options['upgrade'] as $upgk => $upg_data) { ?>
$upgrade_sol) { $upg_room_name = $this->upgrade_options['rooms'][$rid]['name']; ?>
upgrade_options['rooms'][$rid]['img'])) { ?> <?php echo htmlspecialchars($upg_room_name); ?>
upgrade_options['rooms'][$rid]['smalldesc'])) { ?>
shortenDescr($this->upgrade_options['rooms'][$rid]['smalldesc']); ?>
0) { ?>

tags with WordPress ?>
$chars) { // we are forced to strip any HTML tags when using a sub-string $descr = strip_tags($descr); if (mb_strlen($descr) > $chars) { // still exceeding the limit $descr = mb_substr($descr, 0, $chars, 'UTF-8') . '...'; } } return $descr; } if (strlen($descr) > $chars) { // we are forced to strip any HTML tags when using a sub-string $descr = strip_tags($descr); if (strlen($descr) > $chars) { // still exceeding the limit $descr = substr($descr, 0, $chars) . '...'; } } return $descr; } }