PHP Classes

File: fwphp/glomodul/post/upd_post_frm.php

Recommend this page to a friend!
  Classes of Slavko Srakocic   B12 PHP FW   fwphp/glomodul/post/upd_post_frm.php   Download  
File: fwphp/glomodul/post/upd_post_frm.php
Role: Example script
Content type: text/plain
Description: Example script
Class: B12 PHP FW
Manage database records with a PDO CRUD interface
Author: By
Last change: Update of fwphp/glomodul/post/upd_post_frm.php
Date: 1 year ago
Size: 7,165 bytes


Class file image Download
namespace B12phpfw ; //FUNCTIONAL, NOT POSITIONAL :

use B12phpfw\core\b12phpfw\Config_allsites as utl ;
B12phpfw\core\b12phpfw\Db_allsites as db_shared ;
B12phpfw\dbadapter\post\Tbl_crud as db_module;
B12phpfw\dbadapter\post_category\Tbl_crud as db_module_category;

$pp1->stack_trace[]=str_replace('\\','/', __FILE__ ).', lin='.__LINE__ ;

// 1. S U B M I T E D A C T I O N S
$cursor = db_module::uu($pp1, $other=['caller' => __FILE__ .' '.', ln '. __LINE__]);
//E n d of S ubmit Button If-Condition

// 2. R E A D D B T B L R O W S
// returns object :
$cursor_LOVcategory = db_module_category::rr_all( $pp1
, $dmlrr='*'
, $qrywhere="'1'='1'"
, $binds=[]
$other=['caller' => __FILE__ .' '.', ln '. __LINE__] );

// 3. G U I to get user action

    //$uriq = $pp1->uriq ; $IdFromURL = $uriq->id ;
$IdFromURL = $pp1->uriq->id ;


$title = 'Edit Post' ;
//if form and form processing are in same script, redirect has problem :
require_once $pp1->shares_path . '/hdr.php';

<!-- HEADER -->
    <!--header class="bg-dark text-white py-3">
      <div class="container">
        <div class="row">
          <div class="col-md-12">
          <h1><i class="fas fa-edit" style="color:#27aae1;"></i> Edit Post</h1>
    <!-- HEADER END -->

     <!-- Main Area -->
<section class="container py-2 mb-4">
  <div class="row">
    <div class="offset-lg-1 col-lg-10" style="min-height:400px;">
//echo utl::MsgErr(); echo utl::MsgSuccess();
echo utl::msg_err_succ(__FILE__ .' '.', ln '. __LINE__);

// returns object :
$rpost_toedit = db_module::rr_byid( $IdFromURL, $other=[ 'caller' => __FILE__ .' '.', ln '. __LINE__ ] );
      switch (
db_shared::getdbi()) { case 'oracle' : $rpost_toedit = self::rlows($rpost_toedit) ; break; default: break; }

$TitleToBeUpdated = $rpost_toedit->title;
$CategoryToBeUpdated = $rpost_toedit->category;
$ImageToBeUpdated = $rpost_toedit->image;
$PostToBeUpdated = $rpost_toedit->post;
$summaryToBeUpdated = $rpost_toedit->summary;
$img_descToBeUpdated = $rpost_toedit->img_desc;
<form class="" action="<?=$pp1->editpost?>id/<?=$IdFromURL?>"
            method="post" enctype="multipart/form-data">
        <div class="card bg-secondary text-light mb-3">
          <div class="card-body bg-dark">

            <div class="form-group">
              <label for="title"> <span class="FieldInfo"> Post <?=$IdFromURL?> Title: </span></label>
               <input class="form-control" type="text" name="PostTitle" id="title" placeholder="Type title here" value="<?php echo $TitleToBeUpdated; ?>">

            <div class="form-group">
              <span class="FieldInfo">Existing Category: </span>
              <?php echo $CategoryToBeUpdated;?>
              <label for="CategoryTitle"> <span class="FieldInfo">
              Chose Category </span></label>

              <!-- LOV C a t e g o r i e s from D B -->
              <select class="form-control" id="CategoryTitle" name="Category">
while ( $rx = db_shared::rrnext( $cursor_LOVcategory
, $other=['caller' => __FILE__ .' '.', ln '. __LINE__ ] ) and $rx->rexists ):
if ($rx->title == $CategoryToBeUpdated)
                    { echo
' selected="selected"';
//$found = true;

              > <?=$rx->title?></option>
} endwhile;

            <div class="form=group mb-1">
              <span class="FieldInfo">Existing Image: </span>
              <img class="mb-1" src="Uploads/<?php echo $ImageToBeUpdated;?>"
                    width="170px"; height="70px"; >
              <div class="custom-file">
               <!--span class="FieldInfo">Select Image and write image description below</span-->
                <input class="custom-file-input" type="File" name="Image" id="imageSelect" value="">
                <label for="imageSelect" class="custom-file-label">Select Image and write image description below</label>
              <textarea class="form-control" id="img_desc" name="img_desc" rows="8" cols="80">

            <div class="form-group">
                    <!--div style="display: inline;"-->
                    <!--div class="col-lg-6 mb-2 form-inline d-none d-sm-block"-->
                <a href="<?=$pp1->edmkdpost?>flename/<?=$TitleToBeUpdated?>/id/<?=$IdFromURL?>"
                   class="btn btn-primary btn-block"
                >Edit post (markdown). Post Title must be = mkd_file_name.txt which exists !
                  Real title put in txt.

              <label for="Summary"> <span class="FieldInfo"> Summary: </span></label>
              <textarea class="form-control" id="Summary" name="SummaryDescription" rows="8" cols="80">
              <!--label for="Post"> <span class="FieldInfo"> Post: </span></label-->
              <!--textarea class="form-control" id="Post" name="PostDescription" rows="8" cols="80">
                <?php //echo $PostToBeUpdated;?>


            <div class="row">
              <div class="col-lg-6 mb-2">
                <a href="<?=$pp1->dashboard?>" class="btn btn-warning btn-block"><i class="fas fa-arrow-left"></i> Back To Dashboard</a>
              <div class="col-lg-6 mb-2">
                <button type="submit" name="subm_ed" class="btn btn-success btn-block">
                  <i class="fas fa-check"></i> Publish

<!-- End Main Area

    //if (!empty($_FILES["Image"]["name"])) {
                    /*$sql = "UPDATE posts
                            SET title='$PostTitle', category='$Category', image='$Image'
                              , summary='$SummaryText', img_desc='$img_desc'
                            WHERE id='$IdFromURL'";*/
    //}else {
                    /*$sql = "UPDATE posts
                            SET title='$PostTitle', category='$Category'
                              , summary='$SummaryText', img_desc='$img_desc'
                            WHERE id='$IdFromURL'";*/
                  //$this->p repareSQL($sql);
                  //$cursor = $this->e xecute();


<?php require $pp1->shares_path . '/ftr.php'; ?>