Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!class_exists('bg3giProcessor')){
- class bg3giProcessor{
- private $csv ;
- function __construct()
- {
- $this->csv = new CSV("recordlist.csv");
- }
- function ProcessOneLine()
- {
- global $nggdb ;
- if($record = $this->GetRecord())
- {
- echo ("<br/>Processing line: ".$record."<br/>");
- $record = explode ( ";" , $record) ;
- $path = 'wp-content/gallery/foto/' . $record[1] ; // "wp-content/gallery/prova123" ;
- $title = $record[0]; // "Galleria di Prova" ;
- $album = (int)(trim($record[2])) ;// 15
- if ($alb = $nggdb->find_album($album))
- {
- $galId = nggAdmin::import_gallery($path, true);
- echo ("Added gallery #".$galId."<br/>");
- if($gal = $nggdb->find_gallery($galId))
- {
- $nggdb->update_gallery($galId, false, false, $title, false, false, false, false) ;
- echo ("Set name ".$title."<br/>");
- if ($alb)
- {
- //add to album and committ
- if(!is_array($alb->gallery_ids))
- $alb->gallery_ids = array( $galId ) ;
- if (!in_array($galId, $alb->gallery_ids))
- array_push($alb->gallery_ids, $galId) ;
- $nggdb->update_album($album, false, false, false, serialize($alb->gallery_ids), false );
- echo "Updated album ".$alb->name."!<br/>";
- echo "".$this->csv->Count()." album left!<br/>";
- }
- }
- else
- echo "<br/>Error creating gallery #$galId!<br/>";
- }
- else
- echo "<br/>No album found for #$album!<br/>";
- }
- else
- echo "<br/>Nothing to do!<br/>";
- $this->DeleteRecord();
- }
- function GetRecord()
- {
- //open CSV and
- return $this->csv->GetLast();
- }
- function DeleteRecord()
- {
- $this->csv->DeleteLast();
- $this->csv->Save();
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement