@@ -5,39 +5,50 @@ use \BNETDocs\Libraries\Common;
55use \BNETDocs \Libraries \Gravatar ;
66use \BNETDocs \Libraries \Pair ;
77
8- $ title = $ this ->context -> news_post -> getTitle () ;
9- $ description = Common:: stripUpTo ( trim ( filter_var ( $ this ->context ->news_post -> getContent ( true ), FILTER_SANITIZE_STRING )), "\n" , 300 ) ;
8+ $ object_id = $ this ->getContext ()-> news_post_id ;
9+ $ object = $ this ->getContext () ->news_post ;
1010
11- $ this ->opengraph ->attach (new Pair ("url " , "/news/ " . $ this ->context ->news_post_id ));
11+ $ title = ($ object ? $ object ->getTitle () : "News Post Not Found " );
12+ $ description = Common::stripUpTo (trim (filter_var (
13+ ($ object ? $ object ->getContent (true ) : "The requested news post does not exist or could not be found. " ),
14+ FILTER_SANITIZE_STRING
15+ )), "\n" , 300 );
16+
17+ $ this ->opengraph ->attach (new Pair ("url " , "/news/ " . urlencode ($ object_id )));
1218$ this ->opengraph ->attach (new Pair ("type " , "article " ));
13- $ this ->opengraph ->attach (new Pair ("image " , "/a/news_categories/ " . $ this ->context ->news_post ->getCategory ()->getFilename ()));
14- $ this ->opengraph ->attach (new Pair ("article:published_time " , $ this ->context ->news_post ->getCreatedDateTime ()->format ("c " )));
15- if (!is_null ($ this ->context ->news_post ->getEditedDateTime ())) {
16- $ this ->opengraph ->attach (new Pair ("article:modified_time " , $ this ->context ->news_post ->getEditedDateTime ()->format ("c " )));
19+ if ($ object ) {
20+ $ this ->opengraph ->attach (new Pair ("image " , "/a/news_categories/ " . $ object ->getCategory ()->getFilename ()));
21+ $ this ->opengraph ->attach (new Pair ("article:published_time " , $ object ->getCreatedDateTime ()->format ("c " )));
22+ if (!is_null ($ object ->getEditedDateTime ())) {
23+ $ this ->opengraph ->attach (new Pair ("article:modified_time " , $ object ->getEditedDateTime ()->format ("c " )));
24+ }
25+ $ this ->opengraph ->attach (new Pair ("article:author:username " , $ object ->getUser ()->getName ()));
26+ $ this ->opengraph ->attach (new Pair ("article:section " , $ object ->getCategory ()->getLabel ()));
1727}
18- $ this ->opengraph ->attach (new Pair ("article:author:username " , $ this ->context ->news_post ->getUser ()->getName ()));
19- $ this ->opengraph ->attach (new Pair ("article:section " , $ this ->context ->news_post ->getCategory ()->getLabel ()));
2028
21- $ url = Common::relativeUrlToAbsolute ("/news/ " . urlencode ($ this ->context ->news_post ->getId ()));
22- $ url .= "/ " . Common::sanitizeForUrl ($ this ->context ->news_post ->getTitle (), true );
29+ $ url = Common::relativeUrlToAbsolute ("/news/ " . urlencode ($ object_id ));
2330
24- $ user_name = $ this ->context ->news_post ->getUser ()->getName ();
25- $ user_id = $ this ->context ->news_post ->getUserId ();
26- $ user_url = Common::relativeUrlToAbsolute ("/user/ " . $ user_id . "/ " . Common::sanitizeForUrl ($ user_name , true ));
27- $ user_avatar = "https: " . (new Gravatar ($ this ->context ->news_post ->getUser ()->getEmail ()))->getUrl (22 , "identicon " );
31+ if ($ object ) {
32+ $ url .= "/ " . Common::sanitizeForUrl ($ object ->getTitle (), true );
33+ $ user_name = $ object ->getUser ()->getName ();
34+ $ user_id = $ object ->getUserId ();
35+ $ user_url = Common::relativeUrlToAbsolute ("/user/ " . $ user_id . "/ " . Common::sanitizeForUrl ($ user_name , true ));
36+ $ user_avatar = "https: " . (new Gravatar ($ object ->getUser ()->getEmail ()))->getUrl (22 , "identicon " );
37+ }
2838
2939$ this ->additional_css [] = "/a/news.css " ;
3040require ("./header.inc.phtml " );
3141?>
3242 <article>
43+ <?php if ($ object ) { ?>
3344 <a href="https://plus.google.com/share?url=<?php echo urlencode ($ url ); ?> " rel="external" data-popup="1"><img class="social-btn float-right" src="<?php echo Common::relativeUrlToAbsolute ("/a/social-gplus-24px.png " ); ?> "/></a>
34- <a href="https://twitter.com/share?text=<?php echo urlencode ($ this -> context -> news_post ->getTitle ()); ?> &url=<?php echo urlencode ($ url ); ?> " rel="external" data-popup="1"><img class="social-btn float-right" src="<?php echo Common::relativeUrlToAbsolute ("/a/social-twitter-24px.png " ); ?> "/></a>
45+ <a href="https://twitter.com/share?text=<?php echo urlencode ($ object ->getTitle ()); ?> &url=<?php echo urlencode ($ url ); ?> " rel="external" data-popup="1"><img class="social-btn float-right" src="<?php echo Common::relativeUrlToAbsolute ("/a/social-twitter-24px.png " ); ?> "/></a>
3546 <a href="https://facebook.com/sharer/sharer.php?u=<?php echo urlencode ($ url ); ?> " rel="external" data-popup="1"><img class="social-btn float-right" src="<?php echo Common::relativeUrlToAbsolute ("/a/social-facebook-24px.png " ); ?> "/></a>
36- <header><a href="<?php echo $ url ; ?> "><?php echo $ this -> context -> news_post ->getTitle (); ?> </a></header>
37- <section class="news"><img class="category" alt="<?php echo $ this -> context -> news_post -> getCategory ()->getLabel (); ?> " title="<?php echo $ this -> context -> news_post -> getCategory ()->getLabel (); ?> " src="<?php echo Common::relativeUrlToAbsolute ("/a/news_categories/ " . $ this -> context -> news_post -> getCategory ()->getFilename ()); ?> "/><?php echo $ this -> context -> news_post ->getContent (true ); ?> </section>
47+ <header><a href="<?php echo $ url ; ?> "><?php echo $ object ->getTitle (); ?> </a></header>
48+ <section class="news"><img class="category" alt="<?php echo $ object -> getCategory ()->getLabel (); ?> " title="<?php echo $ object -> getCategory ()->getLabel (); ?> " src="<?php echo Common::relativeUrlToAbsolute ("/a/news_categories/ " . $ object -> getCategory ()->getFilename ()); ?> "/><?php echo $ object ->getContent (true ); ?> </section>
3849 <footer>
3950 <span class="float-left"><a href="<?php echo $ user_url ; ?> "><img class="avatar" src="<?php echo $ user_avatar ; ?> "/> <?php echo htmlspecialchars ($ user_name , ENT_HTML5 , "UTF-8 " ); ?> </a></span>
40- <span class="float-right"><?php echo $ this -> context -> news_post ->getPublishedDateTime ()->format ("l, F j, Y " ); ?> </span>
51+ <span class="float-right"><?php echo $ object ->getPublishedDateTime ()->format ("l, F j, Y " ); ?> </span>
4152 </footer>
4253 </article>
4354 <article>
@@ -46,5 +57,9 @@ require("./header.inc.phtml");
4657 <?php require ("./NYI.inc.phtml " ); ?>
4758 <p class="center">If you'd like to leave a suggestion or concern, you can do so <a href="https://github.com/BNETDocs/bnetdocs-web/issues/new?labels[]=bnetdocs-phoenix&labels[]=question&body=<?php echo rawurlencode ("Hi, \n\n<fill in your question here> \n\nThanks! \n\nReference: " . $ url ); ?> " rel="external">over on GitHub</a>. Sorry for the trouble!</p>
4859 </section>
60+ <?php } else { ?>
61+ <header class="red"><?php echo htmlspecialchars ($ title , ENT_HTML5 , "UTF-8 " ); ?> </header>
62+ <section class="red"><?php echo htmlspecialchars ($ description , ENT_HTML5 , "UTF-8 " ); ?> </section>
63+ <?php } ?>
4964 </article>
5065<?php require ("./footer.inc.phtml " ); ?>
0 commit comments