'star-o', 'stars' => 'star' ); // store rating stars
$retval = ''; // final result
$pdfval = ''; // pdf description result
$is_pdf = $logged_in ? $is_pdf : false; // disable pdf is user is not logged in
foreach( $json as $key => $properties ):
if( $score == 0 ): // score output here
$sitescreen = !is_null( $properties->thumbnail ) ? '
'; // group all data within the row
if( !in_array( $properties->model->category->display, $categories ) ):
array_push( $categories, $properties->model->category->display );
$retval .= empty( $properties->model->category->display )
? ''
: '
' . $properties->model->category->display . '
'
. '
'
. '
';
$pdfval .= $is_pdf
? '
' . $properties->model->category->display . '
'
: '';
endif;
if( !in_array( $properties->model->category->group->name, $groups ) ):
array_push( $groups, $properties->model->category->group->name );
$retval .= empty( $properties->model->category->group->name )
? ''
: '
' . $properties->model->category->group->name . '
'
. '
';
$pdfval .= $is_pdf
? '
' . $properties->model->category->group->name . '
'
: '';
endif;
switch( $properties->model->status ):
case 'MISSING':
case 'RED': {
$status = 'times';
break;
}
case 'ORANGE': {
$status = 'minus';
break;
}
case 'GREEN': {
$status = 'check';
break;
}
default: {
$status = 'question-circle';
}
endswitch;
$status = $logged_in ? $status : 'question-circle';
$statuscolor = $logged_in ? strtolower( $properties->model->status ) : '';
$rendering = array(
'name' => $properties->model->name,
'type' => $properties->model->type,
'model' => $properties->model->model,
'data' => $properties->data,
'status'=> $properties->model->status,
'free' => $properties->model->free,
'pro' => $properties->model->pro_only,
);
$colsize = 8; // set default to 8
if( $properties->model->display == 'Text/HTML ratio' ) $rendering['data'] = intval( round( $rendering['data'] ) );
$retval .= '
'
. ''
. '';
$retval .= '
'
. ( $status ? '' : '' )
. $properties->model->display
. '
';
$pdfval .= $is_pdf
? '
' . $properties->model->display . ': '
: '';
$retval .= '';
$retval .= render2html( $rendering['name'], $rendering['type'], $rendering['model'], $rendering['data'], $rendering['status'], $rendering['free'], $rendering['pro'], $logged_in );
$retval .= '
';
if( $is_pdf ):
$pdfval .= html_entity_decode( $properties->model->description ) . '
Solution: ' . $properties->model->solution . '
Article: ' . $properties->model->article . ''
. ''; // close factors item
else:
$retval .= $logged_in ? '
' . html_entity_decode( $properties->model->description ) . '
' : '';
endif;
$retval .= '
' // close inside section row
. ''
. '
'; // row ends here
endif;
$score++;
endforeach;
if( $is_pdf ):
$retval .= '' : ''; // trick div
$factors_labels = array(
'favicon' => 'Make favicon small and cacheable',
'no404' => 'Avoid HTTP 404 (Not Found) error',
'cdn' => 'Use a Content Delivery Network (CDN)',
'expires' => 'Add Expires headers',
'compress' => 'Compress components with gzip',
'numreq' => 'Make fewer HTTP Requests',
'emptysrc' => 'Avoid empty src or href',
'csstop' => 'Put CSS at top',
'jsbottom' => 'Put JavaScript at bottom',
'mindom' => 'Reduce the number of DOM elements',
'mincookie' => 'Reduce cookie size',
'imgnoscale'=> 'Do not scale images in HTML',
'etags' => 'Configure entity tags (ETags)',
'dns' => 'Reduce DNS lookups',
'cookiefree'=> 'Use cookie-free domains',
'dupes' => 'Remove duplicate JavasScript and CSS',
'redirects' => 'Avoid URL redirects',
'xhr' => 'Make AJAX cacheable',
'xhrmethod' => 'Use GET for AJAX requests',
);
foreach( $data->grades as $label => $grade ):
$html .= '
';
$html .= '
' . $factors_labels[$label] . '
'
. '
'
. '
' . $grade . '%
';
$html .= '
'; // close row
endforeach;
$html .= '
';
return $html;
}
function get_base64image( $value ) {
$favicon = str_replace("http://", "", str_replace("https://", "", $value));
$valueLen = strlen($favicon);
$result = null;
$has_favicon = false;
if ($valueLen > 0) {
if (strpos($favicon, ".ico") !== false) {
$has_favicon = true;
$has_mime = "data:image/png;base64,";
}
if (strpos($favicon, ".jpg") !== false) {
$has_favicon = true;
$has_mime = "data:image/jpeg;base64,";
}
if (strpos($favicon, ".png") !== false) {
$has_favicon = true;
$has_mime = "data:image/png;base64,";
}
if (strpos($favicon, ".gif") !== false) {
$has_favicon = true;
$has_mime = "data:image/gif;base64,";
}
if (strpos($favicon, ".svg") !== false) {
$has_favicon = true;
$has_mime = "data:image/svg+xml;base64,";
}
if ($has_favicon && $has_mime) {
$callback = @file_get_contents($value);
if ($callback) {
$result = $has_mime . base64_encode($callback);
} else {
$result = $has_mime;
}
}
}
return $result;
}
function get_imagefromtext( $string ) {
ob_start();
$width = 100;
$height = 25;
$font = 4;
$font_family = 'fonts/open-sans/OpenSans-Regular.ttf';
$width = imagefontwidth($font) * strlen($string);
$height = imagefontheight($font);
$image = imagecreatetruecolor ($width,$height);
$white = imagecolorallocate ($image,255,255,255);
$black = imagecolorallocate ($image,0,0,0);
imagefill($image,0,0,$white);
imagestring ($image,$font,0,0,$string,$black);
//imagettftext($image, 20, 0, 10, 20, $black, $font_family, $string);
imagepng ($image);
imagedestroy($image);
$sImage = base64_encode(ob_get_contents());
ob_end_clean();
return 'data:image/png;base64,'.$sImage;
}
function render_backlinks( $value ) {
$out = '';
$pairs = array(
/* pairs of min. two as key => label */
array( 'text' => 'Text', 'image' => 'Images' ),
array( 'refpages' => 'Referal Pages', 'pages' => 'Pages' ),
array( 'nofollow' => 'NoFollow', 'dofollow' => 'DoFollow' ),
array( 'sitewide' => 'Site Wide', 'not_sitewide' => 'Not Site Wide' ),
array( 'links_internal' => 'Internal links', 'links_external' => 'External links' ),
array( 'gov' => 'Gov', 'edu' => 'Edu', 'rss' => 'Rss' ),
array( 'redirect' => 'Redirect', 'canonical' => 'Canonical' ),
array( 'alternate' => 'Alternate', 'html_pages' => 'HTML Pages' ),
);
if( is_object( $value ) ) {
foreach( $pairs as $pair ) {
$chart = '
';
foreach( $pair as $key => $label ) {
$chart .= '
';
}
$chart .= '
';
$out .= $chart;
}
}
return '
' // trick div
. '
' . $out . '
'
. '
';
}
function render_gmaps( $value ) {
$ispdf = $_GET['pdf'] ? true : false;
if( is_object( $value ) ) {
if( !empty( $value->longitude ) && !empty( $value->latitude ) ) {
$map = '
companyname ) ) $map .= 'data-title="' . $value->companyname . '" ';
$map .= 'data-maplng="' . $value->longitude . '" data-maplat="' . $value->latitude . '">
';
}
}
return $map ?: false;
}
/*
* eRanker default methods
*/
if( !function_exists('get_date_time') ) {
function get_date_time( $date_time ) {
return date( 'd/m/y, H:i', strtotime( get_date_from_gmt( $date_time, get_option( 'date_format' ) . ' ' . get_option('time_format') ) ) );
}
}
?>