Members: 16,996
Threads: 38,846
Posts: 159,391
Online: 24

Newest Member: Kl_broka@rediffmail.com


Odoo.tv - Outdoor Television


Sedo - Domains kaufen und verkaufen das Projekt mambers.com steht zum Verkauf Besucherstatistiken von mambers.com etracker® Web-Controlling statt Logfile-Analyse

Go Back   Mambers.com > Archive > Mambo 4.5 > Mambo 4.5 'How Do I' Questions

 
 
LinkBack Thread Tools Display Modes
Old 31.08.2004, 23:36   #1 (permalink)
Expert Mamber
 
divamissx's Avatar
 
Join Date: Apr 2004
Location: Florida
Posts: 480
divamissx is on a distinguished road
Send a message via MSN to divamissx
Arrow Automated import of content into the database

There is a very long thread here pertaining to displaying static pages in mambo.

Best method of displaying Static Pages

The last post had the same question that I have but there has been no response. Are the static pages searchable? I'm thinking they probably are not since they don't reside inside the database.

I really need an automated way of importing files INTO the database as content items on a weekly or monthly basis. It's very important that this information is searchable.

I think the real solution is having a script that will simply create records in the mysql database with the appropriate field values. I know this is probably not difficult but scripting and mysql is not really my expertise. So I would appreciate if anyone could direct me to a solution for my dilemma.

Thanks!!

Stacey
__________________
Divamissx, Software Development Consultant
Increase your Forum Traffic: The Forum Seeders Network
divamissx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Sponsored Links
Old 31.08.2004, 23:42   #2 (permalink)
Baby Mamber
 
Join Date: Apr 2004
Location: Canada
Posts: 1
jpjanze is on a distinguished road
Default Re: Automated import of content into the database

I would be very interested in an answer for this question. I have a very real need to be able to import into the database with a script. I am not a developer, but can take instruction well! Thanks to anyone who can help with this (I am sure their are others with the same need)
jpjanze is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 01.09.2004, 03:00   #3 (permalink)
Expert Mamber
 
divamissx's Avatar
 
Join Date: Apr 2004
Location: Florida
Posts: 480
divamissx is on a distinguished road
Send a message via MSN to divamissx
Default Re: Automated import of content into the database

We are all Progress 4GL developers where I work and I decided to take a stab at writing a Progress program that will read thru a directory, import each file and take the contents of that file and set it as the appropriate parameter in another output file that will import a mos_content record straight into the mysql database.

I checked hotscripts.com and there are a lot of scripts there if you search using terms such as 'import files', 'import document', etc. I didn't really find what I was looking for but that doesn't mean it's not there.

I'll keep you posted on my progress... (that's a joke amongst Progress developers)


Stacey
__________________
Divamissx, Software Development Consultant
Increase your Forum Traffic: The Forum Seeders Network
divamissx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 01.09.2004, 22:34   #4 (permalink)
Expert Mamber
 
divamissx's Avatar
 
Join Date: Apr 2004
Location: Florida
Posts: 480
divamissx is on a distinguished road
Send a message via MSN to divamissx
Default Re: Automated import of content into the database

I've been working on this all day and I've succeeded in transferring one test document into the database.

I wrote a Progress program that reads files from a directory, imports each line of the file and exports it back out to a text file in the proper "INSERT" format.

I can then import the record into my mos_content table and it displays on the front end of the site.

The only problem I have right now is that the content is not properly formatted in that it all runs together as one huge wrapped line of text. I think it needs some html formatting to display correctly.

After that is resolved, then I just need to automate it which shouldn't be too difficult. There are plenty of script gurus around the office here to assist with that.

I'll post my results when I get there.

Stacey
__________________
Divamissx, Software Development Consultant
Increase your Forum Traffic: The Forum Seeders Network
divamissx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 03.09.2004, 23:05   #5 (permalink)
Expert Mamber
 
divamissx's Avatar
 
Join Date: Apr 2004
Location: Florida
Posts: 480
divamissx is on a distinguished road
Send a message via MSN to divamissx
Heart Re: Automated import of content into the database

Ok I am having much success with the import of external files into the mysql database.

I've even managed to create hyperlinks that link to other areas of the document and color all of the document comments a different color. It looks awesome.

Now I'm just trying to automate the process. I'm looking at the program:
installation/install2.php. It seems to handle the process of connecting to the database and uploading sample data into the tables.

Can anyone suggest how I could copy and modify this program to handle the import of our documents?

We only want a partial automation at this time. This means I can log in as administrator and select a new Import option, which would allow me to start the data transfer process.

This process must first execute my Progress 4GL program that will read the current development directories and output them to a text file in the form of many "INSERT INTO mos_content" commands (one for each document to be imported).

The text file will automatically be created on the actual server machine where the Mambo installation resides. So once the Progress program is done exporting the information to the text file, then the php program must be executed to read the text file and upload the data into the mysql database (like the mambo installation does when creating the sample data).

Ok feel free to ask questions if something is unclear.

Thanks!

Stacey
Software Developer
WebMD Practice Services

divamissx@hotmail.com
__________________
Divamissx, Software Development Consultant
Increase your Forum Traffic: The Forum Seeders Network
divamissx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 28.02.2005, 17:47   #6 (permalink)
dz0
Baby Mamber
 
Join Date: Aug 2004
Posts: 2
dz0 is on a distinguished road
Default Re: Automated import of content into the database

could you share your script , though I don't know much about progress

check out http://mamboforge.net/projects/import-site
dz0 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 28.02.2005, 19:34   #7 (permalink)
Expert Mamber
 
divamissx's Avatar
 
Join Date: Apr 2004
Location: Florida
Posts: 480
divamissx is on a distinguished road
Send a message via MSN to divamissx
Default Sample Progress 4GL Logic to create mos_content

Ok this is a scaled-down version of my Progress program.

It first builds a temp-table to hold all of the filenames (Progress program files) that are in a previously specified group of directories (I did not include the code that performs the functionality of reading and storing the directory names).

Then it uses the directory temp-table to processes each filename (program). It reads each individual line of the program into another temp-table so it can embed html (for color and hyperlinks) and exports the newly-formatted lines to a text file along with the sql commands that will be used to upload the data into the mambo database.


============================================
Procedure Read-Files-from-Directory:
============================================

/* Input from the selected directory. */

input from os-dir (cCurrentRootDirectory).

/* Loop and read all of the files from the directory. */

repeat:

/* Import the current file name. */

import cFileName cFileFullName.

/* Store the file name as a record in the temp-table. */

create gttFile.

assign gttFile.iFileNumber = (iFileNumber + 1)
gttFile.cFileName = cFileName
gttFile.FullName = cFileFullName

end.

=================================================


/* Setup the output stream. */

OUTPUT STREAM TextFile TO VALUE(cOutputFile).

/* For each file name in the temp-table: */

for each gttFile no-lock by gttFile.FullName:

/* Set the line counter and function counter. */

assign iLineNumber = 1.

/* Set the input source to be the current filename. */

input from value (gttFile.FullName).

/* Read and process each line of this program: */

repeat:

/* Read a line from the input file */

import unformatted cMosContentLine.

/* Place input line into temp-table replacing commas
with backslashes for Mambo. */

create gttContent.
assign gttContent.LineNumber = iLineNumber
gttContent.cFileName = gttFile.cFileName
gttContent.ContentLine = REPLACE (cMosContentLine, "'", '\').

/* Increment the line number. */

iLineNumber = (iLineNumber + 1).
end.

/* Process and format the program lines. */

run Process-Content.

/* Build & write the SQL stmt prefix that includes the file name. */

run WritePrefix (input gttFile.cFileName).

/* Write the program content to the output file. */

run WriteContent.

/* Build the end of the SQL command statement. */

run WriteEndStmt (input gttFile.cFileName).

end. /* for each gttFile */

/* Close the output stream. */

output close.


================================================== ===
Procedure Process-Content:
================================================== ===

/* For each content line in the temp-table: */

for each gttContent:

/* Save the line content to a local variable. */
cMosContentLine = gttContent.ContentLine.

/* Add some html formatting in the line here.... */
if index (cMosContentLine, '&ANALYZE-SUSPEND') > 0 and
index (cMosContentLine, '_PROCEDURE') > 0 and
index (cMosContentLine, '_PROCEDURE-SETTINGS') = 0 then
assign cMosContentLine =
process-procedure-header (input cMosContentLine).

/* Assign the newly formatted line back to the temp-table. */
assign gttContent.ContentLine = cMosContentLine.

end.


================================================== ====
Procedure WritePrefix:
================================================== ====

/* Build the record prefix. */

cRecordPrefix =
"INSERT INTO mos_content (title,title_alias,introtext,state,sectionid,catid ,created,created_by)
VALUES('" + pcFileName + "','" + pcFileName + "','".

/* Output the record prefix. */

run writeOutput (input cRecordPrefix).


================================================== =====
Procedure WriteContent:
================================================== =====
/* For each content line for this program: */

for each gttContent:

/* Write the content line to the output file. */

run writeOutput (input gttContent.ContentLine).
end.

================================================== ====
Procedure WriteEndStmt:
================================================== ====
/* Build the end statement. */

cMosEndStmt = cMosHTMLEnd + cMosState + cMosSectionId +
cMosCatId + cMosCreated + cMosCreatedBy +
chr(10) + chr(10).

/* Output the end of the statement. */

run writeOutput (input cMosEndStmt).


================================================== ===
Procedure writeOutput:
================================================== ===

define input parameter cInputLine as character no-undo format 'x(256)'.

/* Output the line to the text file. */

put stream Textfile unformatted cInputLine.

================================================== ====




This is a sample of the output text file that contains the mysql commands that will add the programs line by line into the mos_content database:


================================================== ======
INSERT INTO mos_content (title,title_alias,introtext,state,sectionid,catid ,created,created_by)
VALUES('ProgramName1.p','ProgramName1.p',
'<font color="#FFFFFF"><br><strong>Progress Program File 1 Content with embedded html tags...</strong><br>',
'1','10','83','0000-00-00 00:00:00','62');

INSERT INTO mos_content (title,title_alias,introtext,state,sectionid,catid ,created,created_by)
VALUES('ProgramName2.p','ProgramName2.p',
'<font color="#FFFFFF"><br><strong>Progress Program File 2 Content with embedded html tags...</strong><br>',
'1','10','83','0000-00-00 00:00:00','62');

================================================== =====


I am importing the data above by copy/pasting the file contents into a query window and running it.


Hope that helps,

Stacey
__________________
Divamissx, Software Development Consultant
Increase your Forum Traffic: The Forum Seeders Network
divamissx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
related items doggett Mambo 4.5 'How Do I' Questions 7 08.06.2005 02:56
Automated import of Progress db schema into MySQL db for searches divamissx Mambo 4.5 'How Do I' Questions 1 12.05.2005 10:42
Content Structuring Basics for Newbies, MOS 4.5 mamster Mambo 4.5 'How Do I' Questions 9 01.09.2004 05:18
how to import variables to database for an object iwindsurf Mambo 4.5 'How Do I' Questions 3 26.07.2004 20:55
Import of static content eg htm in to mambo content SS101 Mambo 4.5 'How Do I' Questions 1 25.06.2004 06:42


All times are GMT +2. The time now is 06:32.

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
A vBSkinworks Design
© Copyright 2004-2008 by Arthur Konze Webdesign.