<?php
/**
 * Open Source Social Network
 *
 * @package   (softlab24.com).ossn
 * @author    OSSN Core Team <info@softlab24.com>
 * @copyright (C) SOFTLAB24 LIMITED
 * @license   Open Source Social Network License (OSSN LICENSE)  http://www.opensource-socialnetwork.org/licence
 * @link      https://www.opensource-socialnetwork.org/
 */

// Import the Worlds class from the correct namespace
use HelloWorld\Worlds;

// Instantiate the Worlds class
$worlds = new Worlds();

// Call the getAll() method on the instantiated object
$all = $worlds->getAll();
$count = count($all); // For pagination, you might need to adjust this according to your logic

?>

<a class="btn btn-success btn-sm" href="<?php echo ossn_site_url('administrator/settings/wpages?mpage=add'); ?>"><?php echo ossn_print('wpages:addnew'); ?></a>
<div class="alert alert-info margin-top-10">
    <?php echo ossn_print('wpages:menubuilder'); ?>
</div>
<table class="table table-striped margin-top-10">
    <tr>
        <th scope="col"><?php echo ossn_print('wpages:title'); ?></th>
        <th scope="col"><?php echo ossn_print('wpages:pageurl'); ?></th>
        <th scope="col"><?php echo ossn_print('wpages:settings:title'); ?></th>
        <th scope="col"><?php echo ossn_print('wpages:cover'); ?></th>
    </tr>
    <?php if ($all) {
        foreach ($all as $page) { ?>
            <tr>
                <td><a target="_blank" href="<?php echo ossn_site_url('worlds/' . $page->guid); ?>"><strong><?php echo $page->title; ?></strong></a></td>
                <td><?php echo ossn_site_url('worlds/' . $page->guid); ?></td>
                <td>
                    <a target="_blank" href="<?php echo ossn_site_url('worlds/' . $page->guid); ?>" class="label label-warning" title="<?php echo ossn_print('wpages:view'); ?>"><i class="fa fa-arrows-alt"></i></a>
                    <a href="<?php echo ossn_site_url('page/edit/' . $page->guid); ?>" class="label label-success" title="<?php echo ossn_print('wpages:edit'); ?>"><i class="fa fa-pencil"></i></a>
                    <a href="<?php echo ossn_site_url('action/wpages/delete?guid=' . $page->guid, true); ?>" class="label label-danger ossn-make-sure" title="<?php echo ossn_print('wpages:delete'); ?>"><i class="fa fa-trash-o"></i></a>
                </td>
            </tr>
        <?php }
    } ?>
</table>
<?php 
echo ossn_view_pagination($count); 
?>
