Total Pageviews

Sunday, June 19, 2011

Assignment 12 - Rich Text Editor (Ability to modify text from a database file directly)

Definition:  An RTE adds WYSIWYG (What You See Is What You Get) editing to our web pages. 

TO DO: 
1) Created RTE table in phpMinAdmin


I uploaded the files listed in the folder: 
sprokets > fckeditor  (FOLDER)
sprokets > rte_test.php (requires admin login)

    When I log in as admin and go to this page it looks like this after I finished editing in the box: 
 2) Change line 37 in fckconfig.js

FCKConfig.BaseHref = 'http://zephir.seattlecentral.edu/~horsey01/sprockets/';
  (now test with rte_test.php)

Reaching the config.php: 

fckeditor/editor/filemanager/connectors/php/config.php

3) changes to the file lie on line 46: 
require_once '/home/classes/horsey01/public_html/sprockets/inc_0700/config_inc.php';  


// Path to user files relative to the document root.
//$Config['UserFilesPath'] = '/userfiles/' ;
$Config['UserFilesPath'] = VIRTUAL_PATH . 'upload/rte/';

// Fill the following value it you prefer to specify the absolute path for the
// user files directory. Useful if you are using a virtual directory, symbolic
// link or alias. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
// Attention: The above 'UserFilesPath' must point to the same directory.
$Config['UserFilesAbsolutePath'] = PHYSICAL_PATH . 'upload/rte/';  

3a) then in fckconfig.js file, line 31
FCKConfig.EditorAreaCSS = 'http://zephir.seattlecentral.edu/~dpham004/foo/themes/DarkRitual/default.css'';  

   3b)Then modified the default Dark Ritual stylesheet (style.css) and renamed it to  fckeditor.css
 Made the following changes in lines 38-44: 
body {
    /*background: #333 url('img/bg.gif');*/
    color: #333;
    /*font: normal 62.5% "Lucida Sans Unicode",sans-serif; */
    font: normal 75% "Lucida Sans Unicode",sans-serif;
    margin: 3% 0;
 } 

4) Then I changed line 99 in fckconfig.js from 

FCKConfig.ToolbarSets["Default"] = [...  to  FCKConfig.ToolbarSets["Goldilocks"] = [
 
5) Now, I just have to upload the files in the appropriate places:
sprockets > fckeditor/editor/filemanager/connectors/php/config.php
sprockets > fckeditor > fckconfig.js
sprockets > themes > Dark Ritual > fckeditor.css

file description here: 

--------------TROUBLESHOOTING ----------------------

Somehow the Editor stopped working after these changes took place. I must have made changes that I should not have made

Backtracking and got the editor to work again but not the stylesheet to show up properly... See below:
File uploading logging here:
________________

HOURLY LOG: 
6-18-2011 -- 3 hours implementing instructions and back tracking 
6-19-2011 -- 2.5 hours trying to figure out what I did wrong in the fckconfig.js (backtracked)

Assignment 11 - Upload Image

Confused about the file upload_image.php file... was not able to find this file

I'm not sure where to add the following code: 

<?php
      startSession(); # wrapper for session_start()
      if(isset($_SESSION["AdminID"]))
      {# only admins can see 'peek a boo' link:
            echo '<div align="center"><a href="' . VIRTUAL_PATH . 'upload_form.php?' . $_SERVER['QUERY_STRING'] . '">UPLOAD IMAGE</a></div>';
            /*
            # if you wish to overwrite any of these options on the view page,
            # you may uncomment this area, and provide different parameters:                               
            echo '<div align="center"><a href="' . VIRTUAL_PATH . 'upload_form.php?' . $_SERVER['QUERY_STRING'];
            echo '&imagePrefix=m';
            echo '&uploadFolder=upload/';
            echo '&extension=.jpg';
            echo '&createThumb=TRUE';
            echo '&thumbWidth=50';
            echo '&thumbSuffix=_thumb';
            echo '&sizeBytes=100000';
            echo '">UPLOAD IMAGE</a></div>';
            */                                 
           
      }
      if(isset($_GET['msg']))
      {# msg on querystring implies we're back from uploading new image
            $msgSeconds = (int)$_GET['msg'];
            $currSeconds = time();
            if(($msgSeconds + 2)> $currSeconds)
            {//link only visible once, due to time comparison of qstring data to current timestamp
                  echo '<div align="center"><script type="text/javascript">';
                  echo 'document.write("<form><input type=button value=\'IMAGE UPLOADED! CLICK TO VIEW!\' onClick=history.go()></form>")</scr';
                  echo 'ipt></div>';
            }
      }
?>
  Was I supposed to drop it directly below the <td> in the view page? Here's what it looks like anyway...
I also recently had to drop the upload_form.php & upload_form_execute.php in order for the hyperlink "Upload Image" to work properly. Images will reside in the "upload" folder 

Looks like it is working properly
extension should match with the BookId so that the image corresponds with the item. 


Looks like error testing works. It did not allow me to add animated .gif files and files that exceed 1000000 kbs. 


Viola! Image uploading works!




NOTES: 
Although the upload_form.php and the upload_execute.php have the "upload" extension, these files do NOT reside in the "upload" folder. 

- Only thumbnails will show when admin modifies the image in image upload executor.... 




Hourly Log: 
6-18-2011 -- .5 hour spent on uploading files and making sure they show up
                     1.5 hours troubleshooting and trying out code (dropping php code into the right file!!!)
                     1 hour implementing the thumbnail next to the list view page

Saturday, June 18, 2011

Assignment 10 - Admin Login

Added the files to the server and updated the config_inc.php file to include "Admin" login link. It now links to Admin login page. Please see the HW construction page for password.

Looks like everything is linked in order. I dropped the admin folder into the main root of the web application and everything seems to be in order!

Extra Credit: nmEdit is a table editor
1) edit line 25 in nmEdit.php


$myDB = "horsey01"; #identify current database
$defaultTable = "test_Customers";  #identify which table you wish to show by default

Logging on as admin to access the table editor on the menu:
Initially, the table looks like this, now after modifying the nmEdit file: 
$myDB = "dpham004"; #identify current database
$defaultTable = "test_Books";  #identify which table you wish to show by default
$allowEdit = 1; #1 allows add/edit/delete capabilities, zero disallows and hides
$allowDelete = 0; #1 allows deletes (no effect on update) zero disallows and hides
$allowQuery = 1; #1 allows SQL queries but no commands.  Zero disallows and hides
$allowCommand = 0; #1 allows raw SQL commands (update, alter) zero disallows
$useSandwich = TRUE; #If true will attempt to load sandwich_header_inc.php & sandwich_footer_inc.php from current theme
#$config->theme = "DarkRitual"; #Want to override the current theme on a single page basis?  Uncomment this!

uploaded the sandwich folders into Dark Ritual and testing now...

Looks like it works! Horray!
File Description:

Assignment 9 - Paging

 Couple confusions: I'm not sure if I've come across this error but when first reading this, it was a bit confusing...

# Create instance of new 'pager' class
$myPager = new Pager(2,'',$prev,$next,'');
$sql = $myPager->loadSQL($sql);  #load SQL, add offset – be sure to run SQL through the Pager, or it will error!

 TROUBLESHOOTING: I've included the Pager.php into the inc_700 folder and it seemed to work now

Link to pager for Books (list form) 

The view pager is slightly different from the book_view page. I've included the metaDescription next to the image of the book rather than just the title. 

  however, book_view_pager looks identical to that of book_view page. Is that supposed to happen?

See Descriptions page here, 

HOURLY LOG: 
6-18-2011 - 2 hours editing class file to fit assignment
                    1.5 hours troubleshooting

Assignment 8 Encounters & bugs

Onto Assignment 8
Current problems: I am not sure what this error means... It looks like my links are named correctly.

Is it because there is something there that doesn't match?

--------------------------------------------------------
Looks like I changed some things since the last time I had this error. I had to change the following line:
number_format((float)$row['Price'],2) to dbOut($row['ISBN']) since ISBN is no longer a float, but rather it is text. Now I'm facing this error:
So, the following error I encountered above is kind of linked to to top section of my list page, line 17-18. Originally, I modified it from
# SQL statement
$sql = "select MuffinName, MuffinID, Price from test_Muffins";

to this:

# SQL statement
$sql = "select BookID, Title, Author, ISBN, Description, MetaDescriptions, MetaKeywords from test_Books";

I'm not sure if I wrote this section of the book_list page right:
if(mysqli_num_rows($result) > 0)
{          #records exist - process
    while($row = mysqli_fetch_assoc($result))
    {      # process each row
         echo '<div align="center"><a href="' . VIRTUAL_PATH . 'book_view.php?id=' . (int)$row['BookID'] . '">' . dbOut($row['Title']) . '</a>';
         echo ' <i>Here with this ISBN:</i> <font color="red">$' . dbOut($row['ISBN'])  . '</font></div>';
    }
-------------------------------COMPLETED WORK------------------------------------
Looks like my List page is working finally! I just had the link to the subfolder wrong

   # '../' works for a sub-folder.  use './' for the root 
  require '../inc_0700/config_inc.php'; #provides configuration, pathing, error handling, db credentials 

I had to update the extension... After I uploaded the pictures, my View page looks good to go as well!

Here is a link to my Descriptions page

Hourly Log:
6-05-2011-- 2 hours on writing sql statement & editing book_list & book_view php files
6-18-2011 -- 5 hours on troubleshooting

Thursday, June 16, 2011

Assignment 7 Woes

Currently trying to fix my A7 to include the dynamic meta tags and title pages. I've already encountered a fundamental problem:

Left-side nav links seem to replicate themselves rather than replace the links listed in the theme. See here

The problems lies in my config_inc.php file:
// DECLARING ARRAY IN ADVANCE SHOULD BE UNNECESSARY - TRIP HAZARD!!$nav1 = array(); #nav1 is the current left nav - tilde separator below splits text of link from title attribute

//$nav1 = array(); #nav1 is the current left nav - tilde separator below splits text of link from title attribute
if(startSession() && isset($_SESSION['AdminID'])){$nav1[ADMIN_DASHBOARD] = "ADMIN~Go to Administrative Page";}#admin page added to link only if logged in
$nav1['index.php'] = "Home~A model for building largely static web pages";
$nav1['models/demo_contact.php'] = "Contact~A demo for building postback forms";
$nav1['models/demo_mysql.php'] = "mysql Classic~A demo for building mysql (classic) web applications";
$nav1['models/demo_mysqli.php'] = "mysqli Improved~A demo for building mysqli (improved) web applications";
$nav1['models/demo_shared.php'] = "MySQL Shared~A demo page for building mysqli shared connection based applications.";
$nav1['error_test.php'] = "Error Test~Click to see how errors are currently being handled";
$config->nav1 = $nav1; #add to global config object - now available in all header/footers


//echo makeLinks($config->nav1,'<li>','</li>');  #link arrays are created in config_inc.php file
echo makeLinks($config->nav1,'<li>','</li>'); #link arrays are created in config_inc.php file
# CONTENT CONFIGURATION AREA (theme, content areas & nav arrays for header/footer )-----------------------------------------


I'm not sure whether to write the makeLinks config written this way or the other. The latter just repeats the nav hyperlinks.

Also, I noticed that the index that went with the original Dark Ritual theme is being overwritten; is that supposed to happen? I don't have any of the lorem ipsum that I was expecting nor do I know how to make it come back up.

----------------------BREAK THROUGH ON A7-----------------------------------
Looks like I had to trace back where the sidebars resided (in this case, in the footer >.< not the header) and I had to paste the echo makeLinks statement in the footer_inc.php, not in config_inc.php file

Now would be nice to figure out how to have phpMinAdmin log in follow the theme that I currently have...