Exemplo n.º 1
0
 function socialBookmarks($listing)
 {
     $googlePlusOne = $twitter = $facebook = '';
     $facebook_xfbml = Sanitize::getBool($this->Config, 'facebook_opengraph') && Sanitize::getBool($this->Config, 'facebook_appid');
     $href = cmsFramework::makeAbsUrl($listing['Listing']['url'], array('sef' => true));
     $twitter = '
         <a href="http://twitter.com/share" data-url="' . $href . '" class="twitter-share-button" data-count="horizontal">Tweet</a>
         <script type="text/javascript">jQuery(document).ready(function(){jQuery.getScript("http://platform.twitter.com/widgets.js");})</script>';
     if ($facebook_xfbml) {
         $facebook = '<fb:like href="' . $href . '" action="like" colorscheme="light" layout="button_count" show_faces="false"></fb:like>';
     } else {
         $facebook = '<script src="http://connect.facebook.net/' . cmsFramework::getLocale() . '/all.js#xfbml=1"></script><fb:like layout="button_count" show_faces="false"></fb:like>';
     }
     if ($this->Config->facebook_send) {
         $facebook .= '<div style="display:inline;margin-right: 15px;"><fb:send href="' . $href . '" colorscheme="light"></fb:send></div>';
     }
     $googlePlusOne = '
         <g:plusone href="' . $href . '" size="medium"></g:plusone>
         <script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>
     ';
     return $googlePlusOne . $twitter . $facebook;
 }
Exemplo n.º 2
0
 function _send()
 {
     $recipient = '';
     $error = array();
     $response = array();
     $this->components = array('security');
     $this->__initComponents();
     if ($this->invalidToken) {
         $error[] = 'jQuery("#jr_inquiryTokenValidation").show();';
         return json_encode(array('error' => $this->makeJS($error)));
     }
     // Required fields
     $fields = array('name', 'email', 'text');
     //        $fields = array('name','email','phone','text');
     foreach ($fields as $id) {
         $input_id = '#jr_inquiry' . Inflector::camelize($id) . 'Validation';
         if ($this->data['Inquiry'][$id] == '') {
             $error[] = 'jQuery("' . $input_id . '").show();';
         } else {
             $reponse[] = 'jQuery("' . $input_id . '").hide();';
         }
     }
     # Validate user's email
     $this->Listing->validateInput($this->data['Inquiry']['email'], "email", "email", __t("You must fill in a valid email address.", true), 1);
     # Validate security code
     if ($this->Access->showCaptcha()) {
         if (!isset($this->data['Captcha']['code'])) {
             $this->Listing->validateSetError("code", __t("The security code you entered was invalid.", true));
         } elseif ($this->data['Captcha']['code'] == '') {
             $this->Listing->validateSetError("code", __t("You must fill in the security code.", true));
         } else {
             if (!$this->Captcha->checkCode($this->data['Captcha']['code'], $this->ipaddress)) {
                 $this->Listing->validateSetError("code", __t("The security code you entered was invalid.", true));
             }
         }
     }
     # Process validation errors
     $validation = $this->Listing->validateGetErrorArray();
     $validation = is_array($validation) ? implode("<br />", $validation) : '';
     if (!empty($error) || $validation != '') {
         // Reissue form token
         if (isset($this->Security)) {
             $error[] = "jQuery('#jr_inquiryToken').val('" . $this->Security->reissueToken() . "');";
         }
         if ($this->Access->showCaptcha()) {
             // Replace captcha with new instance
             $captcha = $this->Captcha->displayCode();
             $error[] = "jQuery('#captcha').attr('src','{$captcha['src']}');";
             $error[] = "jQuery('#jr_inquiryCode').val('');";
         }
         if ($validation != '') {
             $error[] = "jQuery('#jr_inquiryCodeValidation').html('{$validation}').show();";
         }
         return json_encode(array('error' => $this->makeJS($error)));
     }
     // Now we can send the email
     # Read cms mail config settings
     $configSendmailPath = cmsFramework::getConfig('sendmail');
     $configSmtpAuth = cmsFramework::getConfig('smtpauth');
     $configSmtpUser = cmsFramework::getConfig('smtpuser');
     $configSmtpPass = cmsFramework::getConfig('smtppass');
     $configSmtpHost = cmsFramework::getConfig('smtphost');
     $configSmtpSecure = cmsFramework::getConfig('smtpsecure');
     $configSmtpPort = cmsFramework::getConfig('smtpport');
     $configMailFrom = cmsFramework::getConfig('mailfrom');
     $configFromName = cmsFramework::getConfig('fromname');
     $configMailer = cmsFramework::getConfig('mailer');
     # Get the recipient email
     Configure::write('Cache.query', false);
     $listing = $this->Listing->findRow(array('fields' => array('User.email AS `Listing.email`'), 'conditions' => array('Listing.id = ' . (int) $this->data['Inquiry']['listing_id'])));
     $url = cmsFramework::makeAbsUrl($listing['Listing']['url'], array('sef' => true));
     $link = '<a href="' . $url . '">' . $listing['Listing']['title'] . '</a>';
     switch ($this->Config->inquiry_recipient) {
         case 'owner':
             $recipient = Sanitize::getString($listing['Listing'], 'email');
             break;
         case 'admin':
             $recipient = $configMailFrom;
             break;
         case 'field':
             if (isset($listing['Field']['pairs'][$this->Config->inquiry_field])) {
                 $recipient = $listing['Field']['pairs'][$this->Config->inquiry_field]['value'][0];
             }
             break;
     }
     if ($recipient == '') {
         $recipient = $configMailFrom;
     }
     if (!class_exists('PHPMailer')) {
         App::import('Vendor', 'phpmailer' . DS . 'class.phpmailer');
     }
     $mail = new PHPMailer();
     $mail->CharSet = cmsFramework::getCharset();
     $mail->SetLanguage('en', S2_VENDORS . 'phpmailer' . DS . 'language' . DS);
     $mail->Mailer = $configMailer;
     // Mailer used mail,sendmail,smtp
     switch ($configMailer) {
         case 'smtp':
             $mail->Host = $configSmtpHost;
             $mail->SMTPAuth = $configSmtpAuth;
             $mail->Username = $configSmtpUser;
             $mail->Password = $configSmtpPass;
             $mail->SMTPSecure = $configSmtpSecure != '' ? $configSmtpSecure : '';
             $mail->Port = $configSmtpPort;
             break;
         case 'sendmail':
             $mail->Sendmail = $configSendmailPath;
             break;
         default:
             break;
     }
     $mail->isHTML(true);
     $mail->From = $configMailFrom;
     $mail->FromName = $configFromName;
     $mail->addReplyTo($this->data['Inquiry']['email']);
     $mail->AddAddress($recipient);
     $mail->Subject = sprintf(__t("New inquiry for: %s", true), $listing['Listing']['title']);
     $mail->Body = sprintf(__t("From: %s", true), Sanitize::getString($this->data['Inquiry'], 'name')) . "<br />";
     $mail->Body .= sprintf(__t("Email: %s", true), Sanitize::getString($this->data['Inquiry'], 'email')) . "<br />";
     //        $mail->Body .= sprintf(__t("Phone number: %s",true),Sanitize::getString($this->data['Inquiry'],'phone')) . "<br />";
     $mail->Body .= sprintf(__t("Listing: %s", true), $listing['Listing']['title']) . "<br />";
     $mail->Body .= sprintf(__t("Listing link: %s", true), $link) . "<br />";
     $mail->Body .= $this->data['Inquiry']['text'];
     if (!$mail->Send()) {
         unset($mail);
         $error[] = 'jQuery("#jr_inquiryTokenValidation").show();';
         return json_encode(array('error' => $this->makeJS($error)));
     }
     $mail->ClearAddresses();
     $bccAdmin = $this->Config->inquiry_bcc;
     if ($bccAdmin != '' && $bccAdmin != $recipient) {
         $mail->AddAddress($bccAdmin);
         $mail->Send();
     }
     unset($mail);
     return json_encode(array('error' => $this->makeJS($response), 'html' => true));
 }
Exemplo n.º 3
0
 function plgAfterSave(&$model)
 {
     $data = array();
     App::import('Model', 'activity', 'jreviews');
     App::import('Helper', 'routes', 'jreviews');
     $Activity = new ActivityModel();
     $Routes = RegisterClass::getInstance('RoutesHelper');
     $data['Activity']['user_id'] = $this->c->_user->id;
     $data['Activity']['email'] = $this->c->_user->email;
     $data['Activity']['created'] = gmdate('Y-m-d H:i:s');
     $data['Activity']['ipaddress'] = $this->c->ipaddress;
     $data['Activity']['activity_new'] = isset($model->data['insertid']) ? 1 : 0;
     switch ($this->activityModel->name) {
         case 'Claim':
             //Get the full listing info to create proper permalinks
             $listing = $this->c->Listing->findRow(array('conditions' => array('Listing.id = ' . (int) $model->data['Claim']['listing_id'])), array());
             $permalink = $Routes->content('', $listing, array('return_url' => true));
             $permalink = cmsFramework::makeAbsUrl($permalink);
             $data['Activity']['activity_type'] = 'claim';
             $data['Activity']['listing_id'] = $model->data['Claim']['listing_id'];
             $data['Activity']['extension'] = 'com_content';
             $data['Activity']['activity_new'] = 1;
             $data['Activity']['permalink'] = $permalink;
             $Activity->store($data);
             break;
         case 'Listing':
             // Skip logging of admin actions on user listings
             //                if($this->c->_user->id != $model->data['Listing']['created_by']) break;
             //Get the full listing info to create proper permalinks
             $listing = $this->c->Listing->findRow(array('conditions' => array('Listing.id = ' . (int) $model->data['Listing']['id'])));
             $permalink = $Routes->content('', $listing, array('return_url' => true));
             $permalink = cmsFramework::makeAbsUrl($permalink);
             $data['Activity']['activity_type'] = 'listing';
             $data['Activity']['email'] = Sanitize::getString($model->data, 'email');
             $data['Activity']['listing_id'] = $model->data['Listing']['id'];
             $data['Activity']['extension'] = 'com_content';
             $data['Activity']['permalink'] = $permalink;
             $Activity->store($data);
             break;
         case 'Review':
             // Skip logging of admin actions on user listings
             //                if($this->c->_user->id != $model->data['Review']['userid']) break;
             $data['Activity']['activity_type'] = 'review';
             $data['Activity']['listing_id'] = $model->data['Review']['pid'];
             $data['Activity']['review_id'] = $model->data['Review']['id'];
             $data['Activity']['extension'] = $model->data['Review']['mode'];
             $data['Activity']['value'] = round(Sanitize::getVar($model->data, 'average_rating'), 0);
             $data['Activity']['permalink'] = $Routes->reviewDiscuss('', array('review_id' => $data['Activity']['review_id']), array('return_url' => true));
             $Activity->store($data);
             break;
         case 'OwnerReply':
             // Skip logging of admin actions on user listings
             //                if($this->c->_user->id != $model->data['Listing']['created_by']) break;
             $data['Activity']['activity_type'] = 'owner_reply';
             $data['Activity']['listing_id'] = $model->data['Listing']['listing_id'];
             $data['Activity']['review_id'] = $model->data['OwnerReply']['id'];
             $data['Activity']['extension'] = $model->data['Listing']['extension'];
             // Editing not yet implemented so all replies are new
             $data['Activity']['activity_new'] = 1;
             $data['Activity']['permalink'] = $Routes->reviewDiscuss('', array('review_id' => $data['Activity']['review_id']), array('return_url' => true));
             $Activity->store($data);
             break;
         case 'Discussion':
             // Skip logging of admin actions on user listings
             //                if($this->c->_user->id != $model->data['Discussion']['user_id']) break;
             // Get listing id and extension
             $this->c->_db->setQuery("\n                    SELECT \n                        Review.pid AS listing_id, Review.`mode` AS extension\n                    FROM \n                        #__jreviews_comments AS Review\n                    WHERE \n                        Review.id = " . $model->data['Discussion']['review_id']);
             // Get listing owner id and check if it matches the current user
             if ($listing = current($this->c->_db->loadAssocList())) {
                 $data['Activity']['activity_type'] = 'review_discussion';
                 $data['Activity']['listing_id'] = $listing['listing_id'];
                 $data['Activity']['review_id'] = $model->data['Discussion']['review_id'];
                 $data['Activity']['post_id'] = $model->data['Discussion']['discussion_id'];
                 $data['Activity']['extension'] = $listing['extension'];
                 $data['Activity']['permalink'] = $Routes->reviewDiscuss('', array('review_id' => $data['Activity']['review_id']), array('return_url' => true));
                 $Activity->store($data);
             }
             break;
         case 'Report':
             $data['Activity']['activity_type'] = $model->data['Report']['post_id'] ? 'discussion_report' : 'review_report';
             $data['Activity']['listing_id'] = $model->data['Report']['listing_id'];
             $data['Activity']['review_id'] = $model->data['Report']['review_id'];
             $data['Activity']['extension'] = $model->data['Report']['extension'];
             // Editing not yet implemented so all replies are new
             $data['Activity']['activity_new'] = 1;
             $data['Activity']['permalink'] = $Routes->reviewDiscuss('', array('review_id' => $data['Activity']['review_id']), array('return_url' => true));
             $Activity->store($data);
             break;
         case 'Vote':
             // Get listing id and extension
             $this->c->_db->setQuery("\n                    SELECT \n                        Review.pid AS listing_id, Review.`mode` AS extension\n                    FROM \n                        #__jreviews_comments AS Review\n                    WHERE \n                        Review.id = " . $model->data['Vote']['review_id']);
             // Get listing owner id and check if it matches the current user
             if ($listing = current($this->c->_db->loadAssocList())) {
                 $data['Activity']['activity_type'] = 'helpful_vote';
                 $data['Activity']['listing_id'] = $listing['listing_id'];
                 $data['Activity']['review_id'] = $model->data['Vote']['review_id'];
                 $data['Activity']['helpful_vote_id'] = $model->data['Vote']['vote_id'];
                 $data['Activity']['extension'] = $listing['extension'];
                 $data['Activity']['value'] = $model->data['Vote']['vote_yes'];
                 $data['Activity']['permalink'] = $Routes->reviewDiscuss('', array('review_id' => $data['Activity']['review_id']), array('return_url' => true));
                 $Activity->store($data);
             }
             break;
     }
     $this->published = false;
     // Run once. With paid listings it is possible for a plugin to run a 2nd time when the order is processed together with the listing (free)
 }
Exemplo n.º 4
0
 function makeUrl($url)
 {
     return cmsFramework::makeAbsUrl($url, array('sef' => true, 'ampreplace' => true));
 }
Exemplo n.º 5
0
 function shortenUrl($url)
 {
     $url = cmsFramework::makeAbsUrl($url, array('sef' => false, 'ampreplace' => true));
     //create the URL
     $version = '2.0.1';
     $format = 'json';
     $bitly = 'http://api.bit.ly/shorten';
     $param = 'version=' . $version . '&longUrl=' . urlencode($url) . '&login='******'&apiKey=' . $this->bitly_key . '&format=' . $format . '&history=' . $this->bitly_history;
     //get the url
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $bitly . "?" . $param);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $response = curl_exec($ch);
     $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     curl_close($ch);
     if ($httpcode != 200) {
         // There was an error
         return false;
     }
     $json = @json_decode($response, true);
     return $json['results'][$url]['shortUrl'];
 }
 function plgAfterSave(&$model)
 {
     if (!isset($model->data['Email']) || !Sanitize::getInt($model->data['Email'], 'send')) {
         return false;
     }
     # Read cms mail config settings
     $configSendmailPath = cmsFramework::getConfig('sendmail');
     $configSmtpAuth = cmsFramework::getConfig('smtpauth');
     $configSmtpUser = cmsFramework::getConfig('smtpuser');
     $configSmtpPass = cmsFramework::getConfig('smtppass');
     $configSmtpHost = cmsFramework::getConfig('smtphost');
     $configSmtpSecure = cmsFramework::getConfig('smtpsecure');
     $configSmtpPort = cmsFramework::getConfig('smtpport');
     $configMailFrom = cmsFramework::getConfig('mailfrom');
     $configFromName = cmsFramework::getConfig('fromname');
     $configMailer = cmsFramework::getConfig('mailer');
     if (!class_exists('PHPMailer')) {
         App::import('Vendor', 'phpmailer' . DS . 'class.phpmailer');
     }
     $mail = new PHPMailer();
     $mail->CharSet = cmsFramework::getCharset();
     $mail->SetLanguage('en', S2_VENDORS . 'PHPMailer' . DS . 'language' . DS);
     $mail->Mailer = $configMailer;
     // Mailer used mail,sendmail,smtp
     switch ($configMailer) {
         case 'smtp':
             $mail->Host = $configSmtpHost;
             $mail->SMTPAuth = $configSmtpAuth;
             $mail->Username = $configSmtpUser;
             $mail->Password = $configSmtpPass;
             $mail->SMTPSecure = $configSmtpSecure != '' ? $configSmtpSecure : '';
             $mail->Port = $configSmtpPort;
             break;
         case 'sendmail':
             $mail->Sendmail = $configSendmailPath;
             break;
         default:
             break;
     }
     $mail->isHTML(true);
     $mail->From = $configMailFrom;
     $mail->FromName = $configFromName;
     $mail->AddReplyTo($configMailFrom, $configFromName);
     //    	$model->data[$this->notifyModel->name]['key'] = $value;
     $model->data['Email']['body'] = urldecode($model->data['__raw']['Email']['body']);
     // Send html email
     # In this observer model we just use the existing data to send the email notification
     switch ($this->notifyModel->name) {
         // Notification for claims moderation
         case 'Claim':
             if ($model->data['Email']['subject'] != '') {
                 $subject = $model->data['Email']['subject'];
                 $subject = str_ireplace('{name}', $model->data['Email']['name'], $subject);
                 $subject = str_ireplace('{listing_title}', $model->data['Email']['listing_title'], $subject);
             } else {
                 switch ($model->data['Claim']['approved']) {
                     case 1:
                         $subject = __a("Your claim has been approved", true);
                         break;
                     case -1:
                         $subject = __a("Your claim has been rejected", true);
                         break;
                     case 0:
                         $subject = __a("Your claim has been reviewed, but still pending moderation", true);
                         break;
                 }
             }
             // Get permalink
             $listing_id = $model->data['Listing']['id'];
             $listing = $this->controller->Listing->findRow(array('conditions' => 'Listing.id = ' . $listing_id), array('afterFind'));
             $permalink = cmsFramework::makeAbsUrl($listing['Listing']['url'], array('sef' => true));
             $message = $model->data['Email']['body'];
             $message = str_ireplace('{name}', $model->data['Email']['name'], $message);
             $message = str_ireplace('{listing_title}', $model->data['Email']['listing_title'], $message);
             $message = str_ireplace(array('{link}', '{url}'), $permalink, $message);
             if ($message != '') {
                 $mail->Subject = $subject;
                 // Convert line breaks to br tags if html code not found on the message body
                 $mail->Body = nl2br($message);
                 $mail->AddAddress($model->data['Email']['email']);
                 if (!$mail->Send()) {
                     appLogMessage(array("Admin claim moderation message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
                 }
             }
             break;
             # Notification for discussion post moderation
         # Notification for discussion post moderation
         case 'Discussion':
             if ($model->data['Email']['subject'] != '') {
                 $subject = $model->data['Email']['subject'];
                 $subject = str_ireplace('{name}', $model->data['Email']['name'], $subject);
                 $subject = str_ireplace('{review_title}', $model->data['Email']['review_title'], $subject);
             } else {
                 switch ($model->data['Discussion']['approved']) {
                     case 1:
                         $subject = __a("Your comment has been approved", true);
                         break;
                     case -1:
                         $subject = __a("Your comment has been rejected", true);
                         break;
                 }
             }
             // Get permalink
             $this->controller->EverywhereAfterFind = true;
             $this->controller->Review->runProcessRatings = false;
             $review = $this->controller->Review->findRow(array('conditions' => array('Review.id = ' . $model->data['Discussion']['review_id'])));
             $this->controller->viewVars['review'] = $review;
             // Make it available to other plugins
             App::import('helper', 'routes', 'jreviews');
             $Routes = ClassRegistry::getClass('RoutesHelper');
             $permalink = $Routes->reviewDiscuss('', $review, array('listing' => $review, 'return_url' => true));
             $permalink = cmsFramework::makeAbsUrl($permalink);
             $message = $model->data['Email']['body'];
             $message = str_ireplace('{name}', $model->data['Email']['name'], $message);
             $message = str_ireplace(array('{link}', '{url}'), $permalink, $message);
             $message = str_ireplace('{review_title}', $model->data['Email']['review_title'], $message);
             if ($message != '') {
                 $mail->Subject = $subject;
                 // Convert line breaks to br tags if html code not found on the message body
                 $mail->Body = nl2br($message);
                 $mail->AddAddress($model->data['Email']['email']);
                 if (!$mail->Send()) {
                     appLogMessage(array("Admin post discussion moderation message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
                 }
             }
             break;
             // Notification for listing moderation
         // Notification for listing moderation
         case 'Listing':
             if (Sanitize::getInt($model->data, 'moderation')) {
                 if ($model->data['Email']['subject'] != '') {
                     $subject = $model->data['Email']['subject'];
                     $subject = str_ireplace('{name}', $model->data['Email']['name'], $subject);
                     $subject = str_ireplace('{listing_title}', $model->data['Email']['listing_title'], $subject);
                 } else {
                     switch ($model->data['Listing']['state']) {
                         case 1:
                             $subject = __a("Your listing has been approved", true);
                             break;
                         case -2:
                             $subject = __a("Your listing has been rejected", true);
                             break;
                         case 0:
                             $subject = __a("Your listing has been reviewed, but it is still pending moderation", true);
                             break;
                     }
                 }
                 // Get permalink
                 $listing_id = $model->data['Listing']['id'];
                 $listing = $this->controller->Listing->findRow(array('conditions' => 'Listing.id = ' . $listing_id), array('afterFind'));
                 $permalink = cmsFramework::makeAbsUrl($listing['Listing']['url'], array('sef' => true));
                 $message = $model->data['Email']['body'];
                 $message = str_ireplace('{name}', $model->data['Email']['name'], $message);
                 $message = str_ireplace(array('{link}', '{url}'), $permalink, $message);
                 $message = str_ireplace('{listing_title}', $model->data['Email']['listing_title'], $message);
                 if ($message != '') {
                     $mail->Subject = $subject;
                     // Convert line breaks to br tags if html code not found on the message body
                     $mail->Body = nl2br($message);
                     $mail->AddAddress($model->data['Email']['email']);
                     if (!$mail->Send()) {
                         appLogMessage(array("Admin listing moderation message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
                     }
                 }
             }
             break;
             // Notification for reviews moderation
         // Notification for reviews moderation
         case 'Review':
             if (Sanitize::getInt($model->data, 'moderation')) {
                 if ($model->data['Email']['subject'] != '') {
                     $subject = $model->data['Email']['subject'];
                     $subject = str_ireplace('{name}', $model->data['Email']['name'], $subject);
                     $subject = str_ireplace('{listing_title}', $model->data['Email']['listing_title'], $subject);
                     $subject = str_ireplace('{review_title}', $model->data['Email']['review_title'], $subject);
                 } else {
                     switch ($model->data['Review']['published']) {
                         case 1:
                             $subject = __a("Your review has been approved", true);
                             break;
                         case -1:
                             $subject = __a("Your review has been rejected", true);
                             break;
                         case 0:
                             $subject = __a("Your review has been reviewed, but still pending moderation", true);
                             break;
                     }
                 }
                 // Get permalink
                 $this->controller->EverywhereAfterFind = true;
                 $this->controller->Review->runProcessRatings = false;
                 $review_id = $model->data['Review']['id'];
                 $review = $this->controller->Review->findRow(array('conditions' => array('Review.id = ' . $review_id)));
                 $this->controller->viewVars['review'] = $review;
                 // Make it available to other plugins
                 App::import('helper', 'routes', 'jreviews');
                 $Routes = ClassRegistry::getClass('RoutesHelper');
                 $permalink = $Routes->reviewDiscuss('', $review, array('listing' => $review, 'return_url' => true));
                 $permalink = cmsFramework::makeAbsUrl($permalink);
                 $message = $model->data['Email']['body'];
                 $message = str_ireplace('{name}', $model->data['Email']['name'], $message);
                 $message = str_ireplace(array('{link}', '{url}'), $permalink, $message);
                 $message = str_ireplace('{listing_title}', $model->data['Email']['listing_title'], $message);
                 $message = str_ireplace('{review_title}', $model->data['Email']['review_title'], $message);
                 if ($message != '') {
                     $mail->Subject = $subject;
                     // Convert line breaks to br tags if html code not found on the message body
                     $mail->Body = nl2br($message);
                     $mail->AddAddress($model->data['Email']['email']);
                     if (!$mail->Send()) {
                         appLogMessage(array("Admin review moderation message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
                     }
                 }
             }
             break;
             // Notification for owner reply to reviews moderation
         // Notification for owner reply to reviews moderation
         case 'OwnerReply':
             if ($model->data['Email']['subject'] != '') {
                 $subject = $model->data['Email']['subject'];
                 $subject = str_ireplace('{name}', $model->data['Email']['name'], $subject);
                 $subject = str_ireplace('{listing_title}', $model->data['Email']['listing_title'], $subject);
                 $subject = str_ireplace('{review_title}', $model->data['Email']['review_title'], $subject);
             } else {
                 switch ($model->data['OwnerReply']['owner_reply_approved']) {
                     case 1:
                         $subject = __a("Your reply has been approved", true);
                         break;
                     case -1:
                         $subject = __a("Your reply has been rejected", true);
                         break;
                     case 0:
                         $subject = __a("Your reply has been reviewed, but still pending moderation", true);
                         break;
                 }
             }
             // Get permalink
             $this->controller->EverywhereAfterFind = true;
             $this->controller->Review->runProcessRatings = false;
             $review_id = $model->data['OwnerReply']['id'];
             $review = $this->controller->Review->findRow(array('conditions' => array('Review.id = ' . $review_id)));
             $this->controller->viewVars['review'] = $review;
             // Make it available to other plugins
             App::import('helper', 'routes', 'jreviews');
             $Routes = ClassRegistry::getClass('RoutesHelper');
             $permalink = $Routes->reviewDiscuss('', $review, array('listing' => $review, 'return_url' => true));
             $permalink = cmsFramework::makeAbsUrl($permalink);
             $message = $model->data['Email']['body'];
             $message = str_ireplace('{name}', $model->data['Email']['name'], $message);
             $message = str_ireplace(array('{link}', '{url}'), $permalink, $message);
             $message = str_ireplace('{listing_title}', $model->data['Email']['listing_title'], $message);
             $message = str_ireplace('{review_title}', $model->data['Email']['review_title'], $message);
             if ($message != '') {
                 $mail->Subject = $subject;
                 // Convert line breaks to br tags if html code not found on the message body
                 $mail->Body = nl2br($message);
                 $mail->AddAddress($model->data['Email']['email']);
                 if (!$mail->Send()) {
                     appLogMessage(array("Admin owner reply moderation message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
                 }
             }
             break;
     }
     unset($mail);
     return true;
 }
 function listings()
 {
     if (Sanitize::getString($this->params, 'action') == 'xml') {
         $access = $this->cmsVersion == CMS_JOOMLA15 ? $this->Access->getAccessId() : $this->Access->getAccessLevels();
         $feed_filename = PATH_ROOT . 'cache' . DS . 'jreviewsfeed_' . md5($access . $this->here) . '.xml';
         $this->Feeds->useCached($feed_filename, 'listings');
     }
     $this->name = 'categories';
     // Required for assets helper
     if ($this->_user->id === 0 && ($this->action != 'search' || $this->action == 'search' && Sanitize::getVar($this->params, 'tag') != '')) {
         $this->cacheAction = Configure::read('Cache.expires');
     }
     $this->autoRender = false;
     $action = Sanitize::paranoid($this->action);
     $dir_id = str_replace(array('_', ' '), array(',', ''), Sanitize::getString($this->params, 'dir'));
     $section_id = Sanitize::getString($this->params, 'section');
     $cat_id = Sanitize::getString($this->params, 'cat');
     $criteria_id = Sanitize::getString($this->params, 'criteria');
     $user_id = Sanitize::getInt($this->params, 'user', $this->_user->id);
     $index = Sanitize::getString($this->params, 'index');
     $sort = Sanitize::getString($this->params, 'order');
     if ($sort == '' && in_array($this->action, array('category', 'section', 'alphaindex', 'search', 'custom'))) {
         $sort = Sanitize::getString($this->Config, 'list_order_field');
     }
     $sort == '' and $sort = Sanitize::getString($this->Config, 'list_order_default');
     $menu_id = Sanitize::getInt($this->params, 'menu', Sanitize::getString($this->params, 'Itemid'));
     // Avoid running the listing query if in section page and listings disabled
     $query_listings = $this->action != 'section' || $this->action == 'section' && $this->Config->list_show_sectionlist;
     $total_special = Sanitize::getInt($this->data, 'total_special');
     if (!in_array($this->action, array('section', 'category')) && $total_special > 0) {
         $total_special <= $this->limit and $this->limit = $total_special;
     }
     $listings = array();
     $parent_categories = array();
     $count = 0;
     $conditions = array();
     $joins = array();
     if ($action == 'category') {
         // Find directory and section id
         if ($this->cmsVersion == CMS_JOOMLA15 && ($category = $this->Category->findRow(array('conditions' => array('Category.id = ' . $cat_id))))) {
             $dir_id = $this->params['dir'] = $category['Category']['dir_id'];
             $section_id = $this->params['section'] = $category['Category']['section_id'];
         } elseif ($parent_categories = $this->Category->findParents($cat_id)) {
             $category = end($parent_categories);
             // This is the current category
             if (!$category['Category']['published'] || !$this->Access->isAuthorized($category['Category']['access'])) {
                 echo $this->render('elements', 'login');
                 return;
             }
             $dir_id = $this->params['dir'] = $category['Directory']['dir_id'];
             $categories = $this->Category->findTree(array('cat_id' => $cat_id));
         }
         # Override global configuration
         isset($category['ListingType']) and $this->Config->override($category['ListingType']['config']);
         $sort = Sanitize::getString($this->params, 'order', Sanitize::getString($this->Config, 'list_order_field'));
         $sort == '' and $sort = Sanitize::getString($this->Config, 'list_order_default');
     }
     # Remove unnecessary fields from model query
     $this->Listing->modelUnbind('Listing.fulltext AS `Listing.description`');
     # Get section and category database information
     if ($this->cmsVersion == CMS_JOOMLA15 && in_array($action, array('section', 'category'))) {
         $fields = array();
         # Get all categories for page
         if ($this->Config->dir_cat_num_entries || $this->Config->dir_category_hide_empty) {
             $fields = array(' 
                         (SELECT 
                           count(*) 
                           FROM #__content AS Listing
                           INNER JOIN #__jreviews_categories AS JreviewsCategory ON JreviewsCategory.id = Listing.catid AND JreviewsCategory.`option` = "com_content"
                           WHERE 
                                 Listing.sectionid = ' . $section_id . '
                                 AND Listing.catid = Category.id         
                                 AND Listing.state = 1 
                                 AND Listing.access <= ' . $this->Access->getAccessId() . '
                                 AND ( Listing.publish_up = "' . NULL_DATE . '" OR Listing.publish_up <= "' . _CURRENT_SERVER_TIME . '" ) 
                                 AND ( Listing.publish_down = "' . NULL_DATE . '" OR Listing.publish_down >= "' . _CURRENT_SERVER_TIME . '" )
                         ) AS `Category.listing_count`                    
                     ');
         }
         $categories = $this->Category->findAll(array('fields' => $fields, 'conditions' => array('Category.section = ' . (int) $section_id, 'Category.published = 1'), 'order' => $this->Config->dir_category_order ? 'Category.title ASC' : 'Category.ordering ASC'));
         $category_tmp = current($categories);
         $dir_id = $category_tmp['Category']['dir_id'];
         $section = $this->Section->findRow(array('fields' => array((int) $dir_id . ' AS `Section.dir_id`'), 'conditions' => array('Section.id = ' . (int) $section_id)));
         # Fake the parent_categories array based on section and category
         isset($section) and $parent_categories[]['Category'] = $section['Section'];
         isset($category) and $parent_categories[]['Category'] = $category['Category'];
     }
     # Set the theme layout and suffix
     $this->Theming->setSuffix(array('categories' => $parent_categories));
     $this->Theming->setLayout(array('categories' => $parent_categories));
     if (isset($section) && !empty($section) && (!$this->Access->isAuthorized($section['Section']['access']) || !$section['Section']['published']) || $this->action == 'category' && isset($category) && !empty($category) && (!$this->Access->isAuthorized($category['Category']['access']) || !$category['Category']['published'])) {
         echo $this->render('elements', 'login');
         return;
     }
     # Get listings
     # Modify and perform database query based on lisPage type
     if ($action == 'section' && $this->Config->list_show_sectionlist || $action != 'section') {
         // Build where statement
         switch ($action) {
             case 'alphaindex':
                 //                    $index = isset($index{0}) ? $index{0} : '';
                 $conditions[] = $index == '0' ? 'Listing.title REGEXP "^[0-9]"' : 'Listing.title LIKE ' . $this->quote($index . '%');
                 break;
         }
         $section_id = cleanIntegerCommaList($section_id);
         $cat_id = cleanIntegerCommaList($cat_id);
         $dir_id = cleanIntegerCommaList($dir_id);
         $criteria_id = cleanIntegerCommaList($criteria_id);
         if (!empty($cat_id)) {
             if ($this->cmsVersion == CMS_JOOMLA15 || $this->cmsVersion != CMS_JOOMLA15 && !$this->Config->list_show_child_listings) {
                 if ($this->cmsVersion != CMS_JOOMLA15) {
                     $conditions[] = 'ParentCategory.id IN (' . $cat_id . ')';
                 }
                 $conditions[] = 'Category.id IN (' . $cat_id . ')';
                 // Exclude listings from child categories
             } else {
                 $conditions[] = 'ParentCategory.id IN (' . $cat_id . ')';
             }
         } else {
             unset($this->Listing->joins['ParentCategory']);
         }
         empty($cat_id) and !empty($section_id) and $conditions[] = 'Listing.sectionid IN (' . $section_id . ')';
         empty($cat_id) and !empty($dir_id) and $conditions[] = 'JreviewsCategory.dirid IN (' . $dir_id . ')';
         empty($cat_id) and !empty($criteria_id) and $conditions[] = 'JreviewsCategory.criteriaid IN (' . $criteria_id . ')';
         if ($this->action == 'mylistings' && $user_id == $this->_user->id || $this->Access->isPublisher()) {
             $conditions[] = 'Listing.state >= 0';
         } else {
             $conditions[] = 'Listing.state = 1';
             $conditions[] = '( Listing.publish_up = "' . NULL_DATE . '" OR Listing.publish_up <= "' . _CURRENT_SERVER_TIME . '" )';
             $conditions[] = '( Listing.publish_down = "' . NULL_DATE . '" OR Listing.publish_down >= "' . _CURRENT_SERVER_TIME . '" )';
         }
         # Shows only links users can access
         if ($this->cmsVersion == CMS_JOOMLA15) {
             //                $conditions[] = 'Section.access <= ' . $this->Access->getAccessId();
             $conditions[] = 'Category.access <= ' . $this->Access->getAccessId();
             $conditions[] = 'Listing.access <= ' . $this->Access->getAccessId();
         } else {
             $conditions[] = 'Category.access IN ( ' . $this->Access->getAccessLevels() . ')';
             $conditions[] = 'Listing.access IN ( ' . $this->Access->getAccessLevels() . ')';
         }
         $queryData = array('joins' => $joins, 'conditions' => $conditions, 'limit' => $this->limit, 'offset' => $this->offset);
         # Modify query for correct ordering. Change FIELDS, ORDER BY and HAVING BY directly in Listing Model variables
         if ($this->action != 'custom' || $this->action == 'custom' && empty($this->Listing->order)) {
             $this->Listing->processSorting($action, $sort);
         }
         // This is used in Listings model to know whether this is a list page to remove the plugin tags
         $this->Listing->controller = 'categories';
         // Check if review scope checked in advancd search
         $scope = explode('_', Sanitize::getString($this->params, 'scope'));
         if ($this->action == 'search' && in_array('reviews', $scope)) {
             $queryData['joins'][] = "LEFT JOIN #__jreviews_comments AS Review ON Listing.id = Review.pid AND Review.published = 1 AND Review.mode = 'com_content'";
             $queryData['group'][] = "Listing.id";
             // Group By required due to one to many relationship between listings => reviews table
         }
         $query_listings and $listings = $this->Listing->findAll($queryData);
         # If only one result then redirect to it
         if ($this->Config->search_one_result && count($listings) == 1 && $this->action == 'search' && $this->page == 1) {
             $listing = array_shift($listings);
             $url = cmsFramework::makeAbsUrl($listing['Listing']['url'], array('sef' => true));
             cmsFramework::redirect($url);
         }
         # Get the listing count
         if (in_array($action, array('section', 'category'))) {
             unset($queryData['joins']);
             $this->Listing->joins = array("INNER JOIN #__jreviews_categories AS JreviewsCategory ON Listing.catid = JreviewsCategory.id AND JreviewsCategory.`option` = 'com_content'", 'Category' => "LEFT JOIN #__categories AS Category ON JreviewsCategory.id = Category.id", 'ParentCategory' => "LEFT JOIN #__categories AS ParentCategory ON Category.lft BETWEEN ParentCategory.lft AND ParentCategory.rgt", "LEFT JOIN #__jreviews_listing_totals AS Totals ON Totals.listing_id = Listing.id AND Totals.extension = 'com_content'", "LEFT JOIN #__jreviews_content AS Field ON Field.contentid = Listing.id", "LEFT JOIN #__jreviews_directories AS Directory ON JreviewsCategory.dirid = Directory.id");
         } elseif ($action != 'favorites') {
             unset($queryData['joins']);
             $this->Listing->joins = array("INNER JOIN #__jreviews_categories AS JreviewsCategory ON Listing.catid = JreviewsCategory.id AND JreviewsCategory.`option` = 'com_content'", 'Category' => "LEFT JOIN #__categories AS Category ON JreviewsCategory.id = Category.id", 'ParentCategory' => "LEFT JOIN #__categories AS ParentCategory ON Category.lft BETWEEN ParentCategory.lft AND ParentCategory.rgt", "LEFT JOIN #__jreviews_listing_totals AS Totals ON Totals.listing_id = Listing.id AND Totals.extension = 'com_content'", "LEFT JOIN #__jreviews_content AS Field ON Field.contentid = Listing.id", "LEFT JOIN #__jreviews_directories AS Directory ON JreviewsCategory.dirid = Directory.id");
             if ($this->action == 'search' && in_array('reviews', $scope)) {
                 $queryData['joins'][] = "LEFT JOIN #__jreviews_comments AS Review ON Listing.id = Review.pid AND Review.published = 1 AND Review.mode = 'com_content'";
             }
         }
         if ($this->cmsVersion == CMS_JOOMLA15 || empty($cat_id)) {
             unset($this->Listing->joins['ParentCategory']);
             // Exclude listings from child categories
         }
         // Need to add user table join for author searches
         if (isset($this->params['author'])) {
             $queryData['joins'][] = "LEFT JOIN #__users AS User ON User.id = Listing.created_by";
         }
         if ($query_listings && !isset($this->Listing->count)) {
             $count = $this->Listing->findCount($queryData, $this->action == 'search' && in_array('reviews', $scope) ? 'DISTINCT Listing.id' : '*');
         } else {
             $count = $this->Listing->count;
         }
         if ($total_special > 0 && $total_special < $count) {
             $count = Sanitize::getInt($this->data, 'total_special');
         }
     }
     # Get directory info for breadcrumb if dir id is a url parameter
     $directory = array();
     if (is_numeric($dir_id)) {
         $directory = $this->Directory->findRow(array('fields' => array('Directory.id AS `Directory.dir_id`', 'Directory.title AS `Directory.slug`', 'Directory.desc AS `Directory.title`'), 'conditions' => array('Directory.id = ' . $dir_id)));
     }
     /******************************************************************
      * Process page title and description
      *******************************************************************/
     $name_choice = $this->Config->name_choice == 'alias' ? 'username' : 'name';
     $page['show_title'] = 1;
     $page['show_description'] = 1;
     switch ($action) {
         case 'section':
             $menuParams = $this->Menu->getMenuParams($menu_id);
             $page = $section['Section'];
             $page['title'] = trim(Sanitize::getString($menuParams, 'title')) != '' ? Sanitize::getString($menuParams, 'title') : $section['Section']['title'];
             $page['show_title'] = Sanitize::getInt($this->data, 'dirtitle', 1);
             $page['show_description'] = 1;
             break;
         case 'category':
             $menuParams = $this->Menu->getMenuParams($menu_id);
             $page = $category['Category'];
             $page['title'] = trim(Sanitize::getString($menuParams, 'title')) != '' ? Sanitize::getString($menuParams, 'title') : $category['Category']['title'];
             $page['show_title'] = Sanitize::getInt($this->data, 'dirtitle', 1);
             $page['show_description'] = 1;
             Sanitize::getString($category['Category'], 'metadesc') == '' and $page['metadesc'] = Sanitize::htmlClean($category['Category']['description']);
             # Check if this is a listing submit category or disable listing submissions
             if (Sanitize::getInt($category['Category'], 'criteria_id') == 0) {
                 $this->Config->list_show_addnew = 0;
             }
             break;
         case 'custom':
             $menuParams = $this->Menu->getMenuParams($menu_id);
             $page['top_description'] = Sanitize::getString($menuParams, 'custom_description');
             $page['top_description'] = str_replace('\\n', '', $page['top_description']);
             $page['show_description'] = $page['top_description'] != '';
             $page['show_title'] = Sanitize::getInt($menuParams, 'dirtitle');
             $page['title'] = Sanitize::getString($menuParams, 'title');
             if (!$page['title']) {
                 $page['title'] = $this->Menu->getMenuName($menu_id);
             }
             break;
         case 'alphaindex':
             $title = isset($directory['Directory']) ? Sanitize::getString($directory['Directory'], 'title', '') : '';
             $page['title'] = $title != '' ? $title . ' - ' . ($index == '0' ? '0-9' : $index) : ($index == '0' ? '0-9' : $index);
             break;
         case 'mylistings':
             if ($user_id > 0) {
                 $user_name = $this->User->findOne(array('fields' => array('User.' . $name_choice . ' AS `User.name`'), 'conditions' => array('User.id = ' . $user_id)));
             } elseif ($this->_user->id > 0) {
                 $user_name = $this->_user->{$name_choice};
             }
             $page['title'] = sprintf(__t("Listings by %s", true), $user_name);
             break;
         case 'favorites':
             // Not running from CB Plugin so we change the page title
             if (!isset($this->Config->in_cb)) {
                 if ($user_id > 0) {
                     $user_name = $this->User->findOne(array('fields' => array('User.' . $name_choice . ' AS `User.name`'), 'conditions' => array('User.id = ' . $user_id)));
                 } elseif ($this->_user->id > 0) {
                     $user_name = $this->_user->{$name_choice};
                 }
                 $page['title'] = sprintf(__t("Favorites by %s", true), $user_name);
             }
             break;
         case 'list':
         case 'search':
             $this->__seo_fields($page);
             break;
         case 'featured':
         case 'latest':
         case 'mostreviews':
         case 'popular':
         case 'toprated':
         case 'topratededitor':
             $menuParams = $this->Menu->getMenuParams($menu_id);
             $page['show_title'] = Sanitize::getInt($menuParams, 'dirtitle');
             $page['title'] = Sanitize::getString($menuParams, 'title');
             if (!$page['title'] && isset($this->Menu->menues[$menu_id])) {
                 $page['title'] = $this->Menu->menues[$menu_id]->name;
             }
             break;
         default:
             $page['title'] = $this->Menu->getMenuName($menu_id);
             break;
     }
     // If empty unset the keys so they don't overwrite the ones set via menu
     if (trim(strip_tags(Sanitize::getString($page, 'description'))) == '') {
         unset($page['description']);
     }
     if (trim(strip_tags(Sanitize::getString($page, 'keywords'))) == '') {
         unset($page['keywords']);
     }
     /******************************************************************
      * Generate SEO titles for re-ordered pages (most reviews, top user rated, etc.)
      *******************************************************************/
     # Category ids to be used for ordering list
     $cat_ids = array();
     if (in_array($action, array('search', 'category'))) {
         $cat_ids = $cat_id;
     } elseif (!empty($categories)) {
         $cat_ids = implode(',', array_keys($categories));
     }
     $field_order_array = $this->Field->getOrderList($cat_ids, 'listing', $this->action, array('section', 'category', 'search', 'alphaindex'));
     isset($page['title']) and $page['title_seo'] = $page['title'];
     if (($this->action != 'search' || Sanitize::getVar($this->params, 'tag')) && isset($this->params['order']) && $sort != '') {
         App::import('helper', 'jreviews', 'jreviews');
         $ordering_options = JreviewsHelper::orderingOptions();
         $tmp_order = str_replace('rjr', 'jr', $sort);
         if (isset($ordering_options[$sort])) {
             $page['title_seo'] .= ' ' . sprintf(__t("ordered by %s", true), mb_strtolower($ordering_options[$sort], 'UTF-8'));
         } elseif (isset($field_order_array[$tmp_order])) {
             if ($sort[0] == 'r') {
                 $page['title_seo'] .= ' ' . sprintf(__t("ordered by %s desc", true), mb_strtolower($field_order_array[$tmp_order]['text'], 'UTF-8'));
             } else {
                 $page['title_seo'] .= ' ' . sprintf(__t("ordered by %s", true), mb_strtolower($field_order_array[$sort]['text'], 'UTF-8'));
             }
         }
     }
     $this->params['order'] = $sort;
     // This is the param read in the views so we need to update it
     /******************************************************************
      * Set view (theme) vars 
      *******************************************************************/
     $this->set(array('Config' => $this->Config, 'Access' => $this->Access, 'User' => $this->_user, 'subclass' => 'listing', 'page' => $page, 'directory' => $directory, 'section' => isset($section) ? $section : array(), 'category' => isset($category) ? $category : array(), 'categories' => isset($categories) ? $categories : array(), 'parent_categories' => $parent_categories, 'listings' => $listings, 'pagination' => array('total' => $count)));
     $query_listings and $this->set('order_list', $field_order_array);
     /******************************************************************
      * RSS Feed: caches and displays feed when xml action param is present
      *******************************************************************/
     if (Sanitize::getString($this->params, 'action') == 'xml') {
         $this->Feeds->saveFeed($feed_filename, 'listings');
     }
     echo $this->render('listings', 'listings_' . $this->tmpl_list);
 }
Exemplo n.º 8
0
 /**
  * Facebook Open Graph implementation
  * 
  * @param mixed $listing
  * @param mixed $meta
  */
 function facebookOpenGraph(&$listing, $meta)
 {
     // http://developers.facebook.com/docs/opengraph/
     $option = Sanitize::getString($_REQUEST, 'option', '');
     $view = Sanitize::getString($_REQUEST, 'view', '');
     $id = Sanitize::getInt($_REQUEST, 'id');
     // Make sure this is a Joomla article page
     if (!($option == 'com_content' && $view == 'article' && $id)) {
         return;
     }
     $Config = Configure::read('JreviewsSystem.Config');
     if (empty($Config)) {
         $cache_file = 'jreviews_config_' . md5(cmsFramework::getConfig('secret'));
         $Config = S2Cache::read($cache_file);
     }
     $facebook_xfbml = Sanitize::getBool($Config, 'facebook_opengraph') && Sanitize::getBool($Config, 'facebook_appid');
     // Make sure FB is enabled and we have an FB App Id
     if (!$facebook_xfbml) {
         return;
     }
     extract($meta);
     $title == '' and $title = $listing['Listing']['title'];
     $description == '' and $description = Sanitize::htmlClean(Sanitize::stripAll($listing['Listing'], 'summary'));
     $image = isset($listing['Listing']['images'][0]) ? cmsFramework::makeAbsUrl(_DS . _JR_WWW_IMAGES . $listing['Listing']['images'][0]['path']) : null;
     if (!$image) {
         $img_src = '/<img[^>]+src[\\s=\'"]+([^"\'>\\s]+(jpg)+)/is';
         preg_match($img_src, $listing['Listing']['summary'], $matches);
         if (isset($matches[1])) {
             $image = $matches[1];
         }
     }
     $url = cmsFramework::makeAbsUrl($listing['Listing']['url'], array('sef' => true, 'ampreplace' => true));
     $fields = $listing['Field']['pairs'];
     // You can add other Open Graph meta tags by adding the attribute, custom field pair to the array below
     $tags = array('title' => $title, 'url' => $url, 'image' => $image, 'site_name' => cmsFramework::getConfig('sitename'), 'description' => $description, 'type' => Sanitize::getString($listing['ListingType']['config'], 'facebook_opengraph_type'), 'latitude' => Sanitize::getString($Config, 'geomaps.latitude'), 'longitude' => Sanitize::getString($Config, 'geomaps.longitude'), 'street-address' => Sanitize::getString($Config, 'geomaps.address1'), 'locality' => Sanitize::getString($Config, 'geomaps.city'), 'region' => Sanitize::getString($Config, 'geomaps.state'), 'postal-code' => Sanitize::getString($Config, 'geomaps.postal_code'), 'country-name' => Sanitize::getString($Config, 'geomaps.country', Sanitize::getString($Config, 'geomaps.default_country')));
     cmsFramework::addScript('<meta property="fb:app_id" content="' . Sanitize::getString($Config, 'facebook_appid') . '"/>');
     Sanitize::getString($Config, 'facebook_admins') != '' and cmsFramework::addScript('<meta property="fb:admins" content="' . str_replace(' ', '', $Config->facebook_admins) . '"/>');
     //        cmsFramework::addScript('<meta property="fb:admins" content="YOUR-ADMIN-ID"/>'); // It's app_id or this, not both
     # Loop through the tags array to add the additional FB meta tags
     foreach ($tags as $attr => $fname) {
         $content = '';
         if (substr($fname, 0, 3) == 'jr_') {
             // It's a custom field
             $content = isset($fields[$fname]) ? htmlspecialchars($fields[$fname]['text'][0], ENT_QUOTES, 'utf-8') : '';
         } elseif ($fname != '') {
             // It's a static text, not a custom field
             $content = htmlspecialchars($fname);
         }
         $content != '' and cmsFramework::addScript('<meta property="og:' . $attr . '" content="' . $content . '"/>');
     }
 }