<commit_before><?php

namespace com\indigloo\sc\html {

    use \com\indigloo\Template as Template;
    use \com\indigloo\Util as Util ;
    use \com\indigloo\Url as Url ;
    use \com\indigloo\Constants as Constants ;
    use \com\indigloo\util\StringUtil as StringUtil ;

    use \com\indigloo\sc\util\PseudoId as PseudoId;
    use \com\indigloo\sc\ui\Constants as UIConstants ;
    use \com\indigloo\sc\Constants as AppConstants ;

    class Post {


        static function getGalleria($title,$images) {
            if(empty($images) || (sizeof($images) == 0)) { return '' ; }

            $view = new \stdClass;
            $view->title = $title ;
            $records = array();

            foreach($images as $image) {
                $record = array();
                $imgv = self::convertImageJsonObj($image);
                $record["source"] = $imgv["source"];
                $record["thumbnail"] = $imgv["thumbnail"];

                $record["originalName"] = $imgv["name"];
                $record["tname"] = $imgv["tname"];

                //for gallery - both height and width is fixed.
                $td = Util::foldXY($image->width,$image->height,190,140);
                $record["twidth"] = $td["width"];
                $record["theight"] = $td["height"];
                $records[] = $record;
            }

            $view->records = $records ;

            $template = '/fragments/item/galleria.tmpl' ;
            $html = Template::render($template,$view);
            return $html;

        }

        static function getFancybox($title,$images) {
            if(empty($images) || (sizeof($images) == 0)) { return '' ; }

            $view = new \stdClass;
            $view->title = $title ;
            $template = (sizeof($images) == 1 ) ? "fancybox-single.tmpl" : "fancybox.tmpl" ;

            $mainImage = array_shift($images);
            $view->mainImage = self::convertImageJsonObj($mainImage);

            $newd = Util::foldX($mainImage->width,$mainImage->height,550);
            $view->mainImage["width"] = $newd["width"];
            $view->mainImage["height"] = $newd["height"];

            $thumbnails = array();

            foreach($images as $image) {

                $record = array();
                $imgv = self::convertImageJsonObj($image);
                $record["source"] = $imgv["source"];
                $record["thumbnail"] = $imgv["thumbnail"];

                $record["originalName"] = $imgv["name"];
                $record["tname"] = $imgv["tname"];

                //for gallery - both height and width is fixed.
                $td = Util::foldXY($image->width,$image->height,190,140);
                $record["twidth"] = $td["width"];
                $record["theight"] = $td["height"];
                $thumbnails[] = $record;

            }

            $view->thumbnails = $thumbnails ;

            $template = "/fragments/item/".$template ;
            $html = Template::render($template,$view);
            return $html;

        }

        static function getHeader($postView,$loginIdInSession) {

            //toolbar stuff

            $postView->followerId = $loginIdInSession;
            $postView->followingId = $postView->loginId;

            //edit item
            $postView->isLoggedInUser = false ;
            if(!is_null($loginIdInSession) && ($loginIdInSession == $postView->loginId)) {
                $postView->isLoggedInUser = true ;
                $params = array('id' => $postView->itemId , 'q' => urlencode(Url::current()));
                $postView->editUrl = Url::createUrl('/qa/edit.php',$params);
            }

            $template = '/fragments/item/header.tmpl' ;
            $html = Template::render($template,$postView);
            return $html;
        }

        static function getActivity($feedHtml,$commentHtml) {
            if(empty($feedHtml) && empty($commentHtml)) { return "" ; }
            $view = new \stdClass;
            $view->feedHtml = $feedHtml;
            $view->commentHtml = $commentHtml;
            $template = '/fragments/item/activity.tmpl' ;
            $html = Template::render($template,$view);

            return $html;
        }

        static function getLinks($links,$siteDBRow) {
            if(sizeof($links) == 0 ) { return '' ; }

            $view = new \stdClass;
            $view->links = $links;
            $view->hasSite = false;

            if(!empty($siteDBRow)) {
                $view->siteId = $siteDBRow["id"];
                $view->siteUrl = $siteDBRow["canonical_url"];
                $view->hasSite = true ;
            }

            $template = '/fragments/item/links.tmpl' ;
            $html = Template::render($template,$view);
            return $html;
        }<commit_msg>bug fix: do empty string check instead of php empty check<commit_after><?php

namespace com\indigloo\sc\html {

    use \com\indigloo\Template as Template;
    use \com\indigloo\Util as Util ;
    use \com\indigloo\Url as Url ;
    use \com\indigloo\Constants as Constants ;
    use \com\indigloo\util\StringUtil as StringUtil ;

    use \com\indigloo\sc\util\PseudoId as PseudoId;
    use \com\indigloo\sc\ui\Constants as UIConstants ;
    use \com\indigloo\sc\Constants as AppConstants ;

    class Post {


        static function getGalleria($title,$images) {
            if(empty($images) || (sizeof($images) == 0)) { return '' ; }

            $view = new \stdClass;
            $view->title = $title ;
            $records = array();

            foreach($images as $image) {
                $record = array();
                $imgv = self::convertImageJsonObj($image);
                $record["source"] = $imgv["source"];
                $record["thumbnail"] = $imgv["thumbnail"];

                $record["originalName"] = $imgv["name"];
                $record["tname"] = $imgv["tname"];

                //for gallery - both height and width is fixed.
                $td = Util::foldXY($image->width,$image->height,190,140);
                $record["twidth"] = $td["width"];
                $record["theight"] = $td["height"];
                $records[] = $record;
            }

            $view->records = $records ;

            $template = '/fragments/item/galleria.tmpl' ;
            $html = Template::render($template,$view);
            return $html;

        }

        static function getFancybox($title,$images) {
            if(empty($images) || (sizeof($images) == 0)) { return '' ; }

            $view = new \stdClass;
            $view->title = $title ;
            $template = (sizeof($images) == 1 ) ? "fancybox-single.tmpl" : "fancybox.tmpl" ;

            $mainImage = array_shift($images);
            $view->mainImage = self::convertImageJsonObj($mainImage);

            $newd = Util::foldX($mainImage->width,$mainImage->height,550);
            $view->mainImage["width"] = $newd["width"];
            $view->mainImage["height"] = $newd["height"];

            $thumbnails = array();

            foreach($images as $image) {

                $record = array();
                $imgv = self::convertImageJsonObj($image);
                $record["source"] = $imgv["source"];
                $record["thumbnail"] = $imgv["thumbnail"];

                $record["originalName"] = $imgv["name"];
                $record["tname"] = $imgv["tname"];

                //for gallery - both height and width is fixed.
                $td = Util::foldXY($image->width,$image->height,190,140);
                $record["twidth"] = $td["width"];
                $record["theight"] = $td["height"];
                $thumbnails[] = $record;

            }

            $view->thumbnails = $thumbnails ;

            $template = "/fragments/item/".$template ;
            $html = Template::render($template,$view);
            return $html;

        }

        static function getHeader($postView,$loginIdInSession) {

            //toolbar stuff

            $postView->followerId = $loginIdInSession;
            $postView->followingId = $postView->loginId;

            //edit item
            $postView->isLoggedInUser = false ;
            if(!is_null($loginIdInSession) && ($loginIdInSession == $postView->loginId)) {
                $postView->isLoggedInUser = true ;
                $params = array('id' => $postView->itemId , 'q' => urlencode(Url::current()));
                $postView->editUrl = Url::createUrl('/qa/edit.php',$params);
            }

            $template = '/fragments/item/header.tmpl' ;
            $html = Template::render($template,$postView);
            return $html;
        }

        static function getActivity($feedHtml,$commentHtml) {
      
            if(Util::tryEmpty($feedHtml) && Util::tryEmpty($commentHtml)) { 
                return "" ; 
            }

            $view = new \stdClass;
            $view->feedHtml = $feedHtml;
            $view->commentHtml = $commentHtml;
            $template = '/fragments/item/activity.tmpl' ;
            $html = Template::render($template,$view);

            return $html;
        }

        static function getLinks($links,$siteDBRow) {
            if(sizeof($links) == 0 ) { return '' ; }

            $view = new \stdClass;
            $view->links = $links;
            $view->hasSite = false;

            if(!empty($siteDBRow)) {
                $view->siteId = $siteDBRow["id"];
                $view->siteUrl = $siteDBRow["canonical_url"];
                $view->hasSite = true ;
            }

            $template = '/fragments/item/links.tmpl' ;
            $html = Template::render($template,$view);
            return $html;
        }
{'fraction_non_alphanumeric': 0.1579002079002079, 'fraction_numerical': 0.00395010395010395, 'mean_word_length': 1.8008733624454147, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '501975', 'n_tokens_mistral': 2853, 'n_tokens_neox': 2670, 'n_words': 478}