Coppermine pull photos from XML? Coppermine pull photos from XML?
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Coppermine pull photos from XML?

Started by fareforce, December 18, 2007, 08:25:47 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

fareforce

I have a flash gallery in place that generates a XML file to pull categories, photos, descriptions, etc.   Is is possible to have coppermine read this XML file and load the photos, categories, etc. from it, instead of having to load them into both systems?
~fareforce
Anchorage, AK
Home of the frozen weasel
http://www.alaskastudio.com

Stramm


fareforce

Would it even be feasable to try to modify it to do that?
~fareforce
Anchorage, AK
Home of the frozen weasel
http://www.alaskastudio.com

Stramm

If you want to use the list to import the images into your coppermine gallery it should be possible without to much work. If you want to use your flash gallery as base gallery and coppermine shall use instead of its own db the XML file of your other gallery, then I'd say you've a lot of work to do.

fareforce

Quote from: Stramm on December 18, 2007, 08:56:22 AM
If you want to use the list to import the images into your coppermine gallery it should be possible without to much work. If you want to use your flash gallery as base gallery and coppermine shall use instead of its own db the XML file of your other gallery, then I'd say you've a lot of work to do.

Hmm, I was afraid you were going to say that. I was hoping to do it the second way you mentioned, but the first way would work fine too. Any chance you could point me in the right direction to use the XML list to import the images into the coppermine DB?

Not sure if this will make a big difference, but this is what a section of the xml looks like:

<?xml version="1.0" encoding="utf-8" ?>
- <albums>
  <id type="gall" value="6" />
- <gallery id="1" name="ANIMALS" path="gallery/1/">
  <id type="img" value="12" />
  <image id="1" thumbnail="1s.jpg" pic="1.jpg" name="1" description="Lorem ipsum dolor sit amet, consectetuer adipiscing elit." def="1" />
  <image id="2" thumbnail="2s.jpg" pic="2.jpg" name="2" description="Donec at metus quis neque pulvinar convallis. Nulla ante purus, ornare id, fringilla at, tincidunt eget, libero." def="0" />
  <image id="3" thumbnail="3s.jpg" pic="3.jpg" name="3" description="Mauris ut sem eget tortor adipiscing facilisis. Etiam a massa. Vestibulum eleifend convallis tellus." def="0" />
~fareforce
Anchorage, AK
Home of the frozen weasel
http://www.alaskastudio.com

Joachim Müller

You'll need an XML library that read the xml file and converts the data into an array. Cpg1.5.x will be using lib.xml.php for that purpose. I suggest using searchnew.php as a base, integrate the xml library there and then start processing the data from the xml file.

fareforce

Thank you much! Looks like I have some work ahead of me! =)
~fareforce
Anchorage, AK
Home of the frozen weasel
http://www.alaskastudio.com

fareforce

Okay, so I thought of another way. If I used coppermine as the main gallery (uploading, making categories, etc.) how hard would it be to write a php script that would use the coppermine db to create an xml page with this format? I have no problem running the php file manually every time I make a change as I only do updates about once a month.

<?xml version="1.0" encoding="utf-8" ?>
- <albums>
  <id type="gall" value="6" />
- <gallery id="1" name="ANIMALS" path="gallery/1/">
  <id type="img" value="12" />
  <image id="1" thumbnail="1s.jpg" pic="1.jpg" name="1" description="Lorem ipsum dolor sit amet, consectetuer adipiscing elit." def="1" />
  <image id="2" thumbnail="2s.jpg" pic="2.jpg" name="2" description="Donec at metus quis neque pulvinar convallis. Nulla ante purus, ornare id, fringilla at, tincidunt eget, libero." def="0" />
  <image id="3" thumbnail="3s.jpg" pic="3.jpg" name="3" description="Mauris ut sem eget tortor adipiscing facilisis. Etiam a massa. Vestibulum eleifend convallis tellus." def="0" />



This is what I currently have in my flash file to pull the xml file, but I don't think flash can connect to db's.
var gallMenuNames:Array = new Array();

var xml:XML = new XML();
xml.ignoreWhite = true;

xml.onLoad = function(ok:Boolean){
if (ok){
var temp:Array = _root.xml.childNodes[0].childNodes;

for (i=1; i<temp.length; i++){
gallMenuNames.push(temp[i].attributes.name);
}
}
}

xml.load("cgal.xml");



Any help would be greatly appriciated on this one. I know only enough php to get me into trouble, and dont know the coppermine db at all.    ???  I know it is asking for a lot but it would be greatly appriciated!
~fareforce
Anchorage, AK
Home of the frozen weasel
http://www.alaskastudio.com

Stramm

with some basic php/ mysql knowledge it shouldn't be hard at all

fareforce

I have posted this in the paid/freelance section as I dont know enough about php/mysql to do this, and I need it done very soon.  I have tried, and the closest I can get the php to generate is:

<?xml version="1.0" ?>
- <entries>
- <entry>
  <date />
  <text />
  </entry>
- <entry>
  <date />
  <text />
  </entry>
  </entries>



Here is the code I used, but I can't get it to display any of the actual data.   :'(

<?php 

header
("Content-type: text/xml"); 

$host "host"
$user "user"
$pass "password"
$database "db_name"

$linkID mysql_connect($host$user$pass) or die("Could not connect to host."); 
mysql_select_db($database$linkID) or die("Could not find database."); 

$query "SELECT * FROM cpg_categories GROUP BY name"
$resultID mysql_query($query$linkID) or die("Data not found."); 

$xml_output "<?xml version=\"1.0\"?>
\n";
$xml_output .= "<entries>\n";

for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
    $row = mysql_fetch_assoc($resultID);
    $xml_output .= "\t<entry>\n";
    $xml_output .= "\t\t<date>" . $row['date'] . "</date>\n";
        // Escaping illegal characters
        $row['text'] = str_replace("&", "&", $row['text']);
        $row['text'] = str_replace("<", "<", $row['text']);
        $row['text'] = str_replace(">", "&gt;", $row['text']);
        $row['text'] = str_replace("\"", "&quot;", $row['text']);
    $xml_output .= "\t\t<text>" . $row['text'] . "</text>\n";
    $xml_output .= "\t</entry>\n";
}

$xml_output .= "</entries>";

echo $xml_output;

?>
~fareforce
Anchorage, AK
Home of the frozen weasel
http://www.alaskastudio.com

Joachim Müller

OK, thread continues on the paid support section, in your new thread there. Marking this one as closed.
In the future, if you decide that you need a thread continued on the paid support board, just let us know by replying accordingly - a moderator will then move your thread accordingly, which keeps the board less cluttered.