PHP Classes

File: modules/new/View.php

Recommend this page to a friend!
  Classes of Adrian M   upMVC   modules/new/View.php   Download  
File: modules/new/View.php
Role: Class source
Content type: text/plain
Description: Class source
Class: upMVC
Pure PHP web development without other frameworks
Author: By
Last change:
Date: 2 months ago
Size: 7,063 bytes
 

Contents

Class file image Download
<?php

/**
    Generated by PHPistols
    The PHP code generator https://www.phpistols.com

    Created on Tue Oct 31 2023
 
    Copyright (c) 2023 BitsHost
    All rights reserved.

 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:

 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.

 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 * Here you may host your app for free:
     https://bitshost.biz/
 */

namespace New;

use
Common\Bmvc\BaseView;

class
View extends BaseView
{


    function
submenu() //renamed
   
{

?>
<p><a class="btn" href="new?">View list</a>
            <a class="btn" href="new?&task=edit-list">Edit list</a>
            <a class="btn btn-primary" href="new?&task=edit">Add Users</a>
        <?php
   
}

    function
header()
    {

       
$this->startHead('Users'); //from BasevView
       
?>
<!-- Bootstrap -->
            <link href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet" media="screen">
            <?php
            $this
->endHead(); //from BasevView
           
$this->startBody('Users made with phpistols.com'); //from BasevView

       
}

        function
footer()
        {

           
$this->endBody();
           
$this->startFooter();
           
$this->endFooter();
        }


        function
pagination($numberOfPages, $curentPage, $link)
        {
           
//if($numberOfPages >1){
           
echo '<nav aria-label="Page navigation"><ul class="pagination">';
            for (
$i = 1; $i <= $numberOfPages; $i++) {
                if (
$i == $curentPage) {
           
?>
<li class="active"><a href="<?= $link ?>page=<?= $i ?>"><?= $i ?></a></li>
                <?php
               
} else {
               
?>
<li><a href="<?= $link ?>page=<?= $i ?>"><?= $i ?></a></li>
                <?php
               
}
            }
            echo
'</ul></nav>';
           
//}
       
}

        function
message($message, $messageType = 'success')
        {
            if (
$message != '') {
               
?>
<div class="alert alert-<?= $messageType ?>">
            <?= $message ?>
</div>
    <?php
           
}
        }

        function
form($data, $message = null)
        {
           
$this->message($message['text'], $message['type']);
   
?>
<div>
        <h2>Edit / Add</h2>
        <form method="POST" action="<?= $_SERVER['REQUEST_URI'] ?>">
            <fieldset>



                <div class="form-group">
                    <label class="control-label">Id:</label>
                    <input class="form-control" type="text" name="id" id="id" size="10" value="<?= htmlentities($data->id) ?>" />
                </div>


                <div class="form-group">
                    <label class="control-label">Name:</label>
                    <input class="form-control" type="text" name="name" id="name" size="10" value="<?= htmlentities($data->name) ?>" />
                </div>


                <div class="form-group">
                    <label class="control-label">Email:</label>
                    <input class="form-control" type="text" name="email" id="email" size="10" value="<?= htmlentities($data->email) ?>" />
                </div>

                <div class="form-group">
                    <input type="hidden" name="id" id="id" value="<?= $data->id ?>" />
                    <input type="submit" name="Envoyer" title="Envoyer" value="Save" class="btn btn-primary">
                </div>



            </fieldset>
        </form>
    </div>
<?php
       
}


        function
displayList($data, $link = '', $orderBy = '', $order = 'desc', $message = null)
        {
           
$this->message($message['text'], $message['type']);


?>
<h2>List</h2>
    <table class="table table-bordered">
        <thead>
            <tr>
                <th scope="col" id="id"><a href="<?= $link ?>&orderBy=id&order=<?php if ($orderBy == "id") echo $order;
                                                                                else echo
'asc'; ?>">Id</a></th>
                <th scope="col" id="name"><a href="<?= $link ?>&orderBy=name&order=<?php if ($orderBy == "name") echo $order;
                                                                                    else echo
'asc'; ?>">Name</a></th>
                <th scope="col" id="email"><a href="<?= $link ?>&orderBy=email&order=<?php if ($orderBy == "email") echo $order;
                                                                                        else echo
'asc'; ?>">Email</a></th>

                <th></th>
            </tr>
        </thead>
        <tbody>
            <?php
            $i
= 1;


            foreach (
$data as $element) {
           
?>
<tr>
                    <td><?php echo $element['id'] ?></td>
                    <td><?php echo $element['name'] ?></td>
                    <td><?php echo $element['email'] ?></td>

                    <td><a href="new?&task=view&id=<?php echo $element['id'] ?>" class="btn">View</a></td>
                </tr>
            <?php
           
} ?>
</tbody>
    </table>
    <?php



    ?>
<tfoot>
        <tr>
            <td colspan="6" class="phppistolsTFooter"></td>
        </tr>
    </tfoot>

    </table>
    <?php
       
}


        function
displayDetails($data, $message = null)
        {
           
$this->message($message['text'], $message['type']);


           
$i = 1;

            if (
$data->id != null) {
   
?>
<h2>View</h2>
        <div class="panel panel-default">
            <div class="panel-body">
                <div class="row">
                    <h6>id: <?php echo $data->id ?></h6>
                    <h6>name: <?php echo $data->name ?></h6>
                    <h6>email: <?php echo $data->email ?></h6>
                </div>
            </div>
        </div>
    <?php
           
} else {
               
$this->message('No data', 'warning');
            }
        }


        function
editList($data, $link = '', $orderBy = '', $order = 'desc', $message = null)
        {
           
$this->message($message['text'], $message['type']);


   
?>
<h2>Edit List</h2>
    <table class="table table-bordered">
        <thead>
            <tr>
                <th scope="col" id="id"><a href="<?= $link ?>&orderBy=id&order=<?php if ($orderBy == "id") echo $order;
                                                                                else echo
'asc'; ?>">Id</a></th>
                <th scope="col" id="name"><a href="<?= $link ?>&orderBy=name&order=<?php if ($orderBy == "name") echo $order;
                                                                                    else echo
'asc'; ?>">Name</a></th>
                <th scope="col" id="email"><a href="<?= $link ?>&orderBy=email&order=<?php if ($orderBy == "email") echo $order;
                                                                                        else echo
'asc'; ?>">Email</a></th>

                <th></th>
                <th></th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            <?php
            $i
= 1;


            foreach (
$data as $element) {
           
?>
<tr>
                    <td><?php echo $element['id'] ?></td>
                    <td><?php echo $element['name'] ?></td>
                    <td><?php echo $element['email'] ?></td>

                    <td><a href="new?&task=view&id=<?php echo $element['id'] ?>" class="btn">View</a></td>
                    <td><a href="new?&task=edit&id=<?php echo $element['id'] ?>" class="btn btn-primary">Edit</a></td>
                    <td><a href="new?&task=del&id=<?php echo $element['id'] ?>" class="btn btn-danger">Del</a></td>
                </tr>
            <?php
           
} ?>
</tbody>
    </table>
    <?php



    ?>
<tfoot>
        <tr>
            <td colspan="6" class="phppistolsTFooter"></td>
        </tr>
    </tfoot>

    </table>
<?php
       
}
    }