2016-04-19 03:38:38 +00:00
< ? php
namespace Zotlabs\Module ;
2018-06-05 06:19:16 +00:00
use Zotlabs\Lib\Libzotdir ;
2016-04-19 03:38:38 +00:00
class Pubsites extends \Zotlabs\Web\Controller {
function get () {
2018-06-05 06:19:16 +00:00
2016-04-19 03:38:38 +00:00
$dirmode = intval ( get_config ( 'system' , 'directory_mode' ));
if (( $dirmode == DIRECTORY_MODE_PRIMARY ) || ( $dirmode == DIRECTORY_MODE_STANDALONE )) {
$url = z_root () . '/dirsearch' ;
}
if ( ! $url ) {
2018-06-05 06:19:16 +00:00
$directory = Libzotdir :: find_upstream_directory ( $dirmode );
2016-04-19 03:38:38 +00:00
$url = $directory [ 'url' ] . '/dirsearch' ;
}
$url .= '/sites' ;
2016-08-26 00:43:07 +00:00
$rating_enabled = get_config ( 'system' , 'rating_enabled' );
2016-04-19 03:38:38 +00:00
$o .= '<div class="generic-content-wrapper">' ;
$o .= '<div class="section-title-wrapper"><h2>' . t ( 'Public Hubs' ) . '</h2></div>' ;
$o .= '<div class="section-content-tools-wrapper"><div class="descriptive-text">' .
t ( 'The listed hubs allow public registration for the $Projectname network. All hubs in the network are interlinked so membership on any of them conveys membership in the network as a whole. Some hubs may require subscription or provide tiered service plans. The hub itself <strong>may</strong> provide additional details.' ) . '</div>' . EOL ;
$ret = z_fetch_url ( $url );
if ( $ret [ 'success' ]) {
$j = json_decode ( $ret [ 'body' ], true );
if ( $j ) {
2017-10-24 16:21:19 +00:00
$o .= '<table class="table table-striped table-hover"><tr><td>' . t ( 'Hub URL' ) . '</td><td>' . t ( 'Access Type' ) . '</td><td>' . t ( 'Registration Policy' ) . '</td><!--td>' . t ( 'Stats' ) . '</td--><td>' . t ( 'Software' ) . '</td>' ;
2016-08-26 00:43:07 +00:00
if ( $rating_enabled )
$o .= '<td colspan="2">' . t ( 'Ratings' ) . '</td>' ;
$o .= '</tr>' ;
2016-04-19 03:38:38 +00:00
if ( $j [ 'sites' ]) {
foreach ( $j [ 'sites' ] as $jj ) {
2017-09-22 04:32:59 +00:00
$projectname = explode ( ' ' , $jj [ 'project' ]);
2018-08-02 08:56:34 +00:00
// if(! \Zotlabs\Lib\System::compatible_project($projectname[0]))
// continue;
2016-09-09 05:56:51 +00:00
if ( strpos ( $jj [ 'version' ], ' ' )) {
$x = explode ( ' ' , $jj [ 'version' ]);
if ( $x [ 1 ])
$jj [ 'version' ] = $x [ 1 ];
}
2016-05-27 02:40:16 +00:00
$m = parse_url ( $jj [ 'url' ]);
2016-04-19 03:38:38 +00:00
$host = strtolower ( substr ( $jj [ 'url' ], strpos ( $jj [ 'url' ], '://' ) + 3 ));
2016-04-30 18:13:30 +00:00
$rate_links = (( local_channel ()) ? '<td><a href="rate?f=&target=' . $host . '" class="btn-btn-default"><i class="fa fa-check-square-o"></i> ' . t ( 'Rate' ) . '</a></td>' : '' );
2016-04-19 03:38:38 +00:00
$location = '' ;
if ( ! empty ( $jj [ 'location' ])) {
2016-04-30 18:13:30 +00:00
$location = '<p title="' . t ( 'Location' ) . '" style="margin: 5px 5px 0 0; text-align: right"><i class="fa fa-globe"></i> ' . $jj [ 'location' ] . '</p>' ;
2016-04-19 03:38:38 +00:00
}
else {
$location = '<br /> ' ;
}
$urltext = str_replace ( array ( 'https://' ), '' , $jj [ 'url' ]);
2017-10-24 16:21:19 +00:00
$o .= '<tr><td><a href="' . (( $jj [ 'sellpage' ]) ? $jj [ 'sellpage' ] : $jj [ 'url' ] . '/register' ) . '" ><i class="fa fa-link"></i> ' . $urltext . '</a>' . $location . '</td><td>' . $jj [ 'access' ] . '</td><td>' . $jj [ 'register' ] . '</td><!--td>' . '<a target="stats" href="https://hubchart-tarine.rhcloud.com/hub.jsp?hubFqdn=' . $m [ 'host' ] . '"><i class="fa fa-area-chart"></i></a></td--><td>' . ucwords ( $jj [ 'project' ]) . (( $jj [ 'version' ]) ? ' ' . $jj [ 'version' ] : '' ) . '</td>' ;
2016-08-26 00:43:07 +00:00
if ( $rating_enabled )
$o .= '<td><a href="ratings/' . $host . '" class="btn-btn-default"><i class="fa fa-eye"></i> ' . t ( 'View' ) . '</a></td>' . $rate_links ;
$o .= '</tr>' ;
2016-04-19 03:38:38 +00:00
}
}
$o .= '</table>' ;
$o .= '</div></div>' ;
}
}
return $o ;
}
}