当前位置: 首页>>代码示例>>PHP>>正文


PHP cmsFramework::makeAbsUrl方法代码示例

本文整理汇总了PHP中cmsFramework::makeAbsUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsFramework::makeAbsUrl方法的具体用法?PHP cmsFramework::makeAbsUrl怎么用?PHP cmsFramework::makeAbsUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cmsFramework的用法示例。


在下文中一共展示了cmsFramework::makeAbsUrl方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: socialBookmarks

 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;
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:22,代码来源:community.php

示例2: _send

 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;
//.........这里部分代码省略.........
开发者ID:bizanto,项目名称:Hooked,代码行数:101,代码来源:inquiry_controller.php

示例3: plgAfterSave

 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));
//.........这里部分代码省略.........
开发者ID:bizanto,项目名称:Hooked,代码行数:101,代码来源:activities.php

示例4: makeUrl

 function makeUrl($url)
 {
     return cmsFramework::makeAbsUrl($url, array('sef' => true, 'ampreplace' => true));
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:4,代码来源:facebook_controller.php

示例5: shortenUrl

 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=' . $this->bitly_user . '&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'];
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:22,代码来源:twitter.php

示例6: plgAfterSave

 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;
//.........这里部分代码省略.........
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:101,代码来源:admin_notifications.php

示例7: listings


//.........这里部分代码省略.........
             $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();
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:67,代码来源:categories_controller.php

示例8: facebookOpenGraph

 /**
  * 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 . '"/>');
     }
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:57,代码来源:jreviews.php


注:本文中的cmsFramework::makeAbsUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。