Ondersteuning » Code oplossingen gezocht » Data invoeren en opvragen

  • Beste,

    ik draai al even een site voor een kennis die een verzameling bevat van publishers van pianoquartet en quintet muziek. Dit is al best een oude site en draait op een niet langer ondersteunde versie van t Modx CMS Evo. Ik wil deze site overzetten naar een nog wel ondersteunde CMS. Bv WP.

    Er draaien custom scripts die ik zo 1,2,3 niet weet te plaatsen in WP. Onderstaand een van die scripts. Kan iemand mij een hint in de goede richting geven. Letop, de eigenaar kan via een formulier data toevoegen en editten danwel deleten, via het frontend.

    loadTemplates(); // Set class config dont do anything if there is nothing in the config if ( $config ) { foreach ($config as $key => $value) { $this->config[$key] = $value; $modx->setPlaceholder($key, $value); } } // Set the default category to prevent if ($this->config['defaultCategory']) { $this->config['composerCategories'] = $this->config['defaultCategory']; } // Set config for the class $this->config['edit'] = $modx->isMemberOfWebGroup(explode(",",$this->config['canEdit'])); $this->config['add'] = $modx->isMemberOfWebGroup(explode(",",$this->config['canAdd'])); $this->config['delete'] = $modx->isMemberOfWebGroup(explode(",",$this->config['canDelete'])); $this->config['table'] = $GLOBALS['table_prefix'] . $this->config['dataset']; // Added for ajax Support if ($this->db->config['ajax'] == 1 ) { $modx->regClientStartupScript('assets/snippets/ncr/jqcmd.js'); } // load jQuery Library if specified if ( $this->config['jQuery'] ) { $modx->regClientStartupScript($this->config['jQuery']); } // Load custom CSS and JS $modx->regClientCSS('assets/snippets/music/css/music.css'); $modx->regClientStartupScript('assets/snippets/music/js/music.js'); $modx->regClientStartupScript('assets/snippets/music/js/jquery.cookie.js'); // override action parameter if incoming URL has parameter action if ( $_REQUEST['action'] ) { $this->config['action'] = $_REQUEST['action']; } $this->db = new dataDBMusic($this->config); $this->fl = new MusicFiles($this->config); //print_r($this->config); } // End of class constructor function loadTemplates() { // Load Default Templates. $this->config['listTpl'] = file_get_contents('assets/snippets/music/templates/list.template.html','r'); $this->config['listPublisherTpl'] = file_get_contents('assets/snippets/music/templates/listpublisher.template.html','r'); $this->config['viewTpl'] = file_get_contents('assets/snippets/music/templates/view.template.html','r'); $this->config['viewPublisherTpl'] = file_get_contents('assets/snippets/music/templates/viewpublisher.template.html','r'); $this->config['addComposerTpl'] = file_get_contents('assets/snippets/music/templates/addcomposer.template.html','r'); $this->config['addPublisherTpl'] = file_get_contents('assets/snippets/music/templates/addpublisher.template.html','r'); $this->config['editTpl'] = file_get_contents('assets/snippets/music/templates/edit.template.html','r'); $this->config['editPublisherTpl'] = file_get_contents('assets/snippets/music/templates/editpublisher.template.html','r'); $this->config['fileimageTpl'] = file_get_contents('assets/snippets/music/templates/fileimage.template.html','r'); $this->config['deleteimageTpl'] = file_get_contents('assets/snippets/music/templates/deleteimage.template.html','r'); } function Run() { global $modx; // Write a cookie about the listpage for the composer database //setcookie("TestCookie", $value, time()+3600, "/~rasmus/", "example.com", 1); setcookie("composerListPage", $this->config['listPage'], time()+ (3600*60), "/", $_SERVER['SERVER_NAME'], 0) ; // $output = print_r($this->config) . print_r($this->config); // Put a div in for a message! $output = ""; // create the header - Only show if we are not doing any editing or adding if ( $this->config['action'] == "add" || $this->config['action'] == "edit" || $this->config['action'] == "view" ) { } else { $letterlinks = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; if ($this->config['dataset'] != "publisher") { // Add Category selection box $output .= ""; $output .= ""; $output .= ""; $output .= ""; $output .= ""; $output .= ""; $output .= ""; $output .= ""; $output .= ""; $output .= ""; $output .= ""; $output .= ""; $output .= ""; $output .= ""; $output .= "
    
    Category: "; $output .= ""; $output .= "
    
    "; $output .= $this->db->buildCategory($_REQUEST['category']); $output .= ""; $output .= ""; $output .= "
    
    Nationality: "; $output .= ""; $output .= "
    
    "; $output .= $this->db->buildNationality( $_REQUEST['nationality'], "GetRecords"); $output .= ""; $output .= ""; $output .= "
    
    "; $output .= "
    
    "; $output .= ""; $output .= "
    
    Search: "; $output .= ""; $output .= ""; $output .= ""; $output .= ""; } $output .= "
    
    "; // Create alphabet list to break the list down $output .= $this->db->displayBreakdown(); $output .= ""; $output .= ""; } // Display the list of quintets and quartets if ( $this->config['action'] == "list" && $_REQUEST['filter'] && $this->config['dataset'] != "publisher" ) { // List the quartets, quintets $modx->setPlaceholder( 'data', $this->db->listRecords() ); $output .= $this->config['listTpl']; } else if ( $this->config['action'] == "list" && $_REQUEST['filter'] && $this->config['dataset'] == "publisher") { // List the publishers $modx->setPlaceholder( 'data', $this->db->listPublishers() ); $output .= $this->config['listPublisherTpl']; } else if ( $this->config['action'] == "view" && $_REQUEST['idcomp'] ) { // View the quartets $this->db->getRecord(); $output .= $this->config['viewTpl']; } else if ( $this->config['action'] == "view" && $_REQUEST['idpub'] ) { // View the Publishers $this->db->getPublisherRecord(); $output .= $this->config['viewPublisherTpl']; } else if ( $this->config['action'] == "edit" && $this->config['edit'] && $_REQUEST['idcomp'] ) { // Get the record to edit for quartets and quintets $this->db->getRecord(); // Get the details so we can add a new publisher via the edit screen $modx->setPlaceholder('addPublisher', $this->config['addPublisherTpl']); // Make sure we build the drop down box for the publishers so a user can change to an existing record // Set Button Placeholder to Update $modx->setPlaceholder('updateAction', "Update"); $output .= $this->config['editTpl']; } else if ( $this->config['action'] == "edit" && $this->config['edit'] && $_REQUEST['idpub'] ) { // Get the Publisher record $this->db->getPublisherRecord(); // Set Button Placeholder to Update $output .= $this->config['editPublisherTpl']; } else if ( $this->config['action'] == "deletefile" && $this->config['edit'] ) { // Delete the image file in quartets, quintets if ( $this->fl->deleteFile() ) { // remove the entry in the database $this->db->deleteImage(); } } else if ( $this->config['action'] == "Update" && $this->config['edit'] && $this->config['dataset'] != "publisher") { // Update the quintets, quartets record // remove the file first due to class restrictions if ( $_POST['deletefile'] ) { $this->fl->deleteFile() ; $this->db->deleteImage(); } if ($_FILES['file']['name']) { // upload file // This should upload the file and update the database with the appropriate folder information. $this->db->updateImage($this->fl->uploadFile()); } // Update record back to database $this->db->updateRecord(); // Take me to view the page to see the changes $parameters = "&idcomp=".$_POST['idcomp']; $url = $modx->makeURL($modx->documentIdentifier, '', $parameters, 'full'); $modx->sendRedirect($url); } else if ( $this->config['action'] == "Update" && $this->config['edit'] && $this->config['dataset'] == "publisher" ) { // Update Publisher record back to database $this->db->updatePublisherRecord(); // Take me to view the page to see the changes $parameters = "&idpub=".$_POST['idpub']; $url = $modx->makeURL($modx->documentIdentifier, '', $parameters, 'full'); $modx->sendRedirect($url); } else if ( $_REQUEST['action'] == "deletecomposer" && $this->config['delete'] ) { // Delete Composer // check the image of the record to ensure there is a file to remove too $this->db->getRecord(); if ( $modx->getPlaceholder('composerimage') ) { $this->fl->deleteFile(); } $this->db->deleteComposer(); // If we sent a filter parameter then we should return to the same screen if ( $_REQUEST['filter'] ) { $parameters = "filter=".$_REQUEST['filter']; $url = $modx->makeURL($modx->documentIdentifier, '', $parameters, 'full'); $modx->sendRedirect($url); } } else if ( $_REQUEST['action'] == 'deletepublisher' && $this->config['delete'] ) { // Delete Publisher Record $this->db->deletePublisher(); // If we sent a filter parameter then we should return to the same screen if ( $_REQUEST['filter'] ) { $parameters = "filter=".$_REQUEST['filter']; $url = $modx->makeURL($modx->documentIdentifier, '', $parameters, 'full'); $modx->sendRedirect($url); } } else if ( $this->config['action'] == "add" && $this->config['dataset'] != "publisher" && $this->config['add'] ) { // Add a new quartet, quintet $modx->setPlaceholder('Nationality', $this->db->buildNationality()); $modx->setPlaceholder('Country', $this->db->buildNationality()); $modx->setPlaceholder('Publisher', $this->db->buildPublisher()); $modx->setPlaceholder('Category', $this->db->buildCategory()); $modx->setPlaceholder('updateAction', "Save"); $modx->setPlaceholder('addPublisher', $this->config['addPublisherTpl']); $output .= $this->config['addComposerTpl']; } else if ( $this->config['action'] == "add" && $this->config['dataset'] == "publisher" && $this->config['add'] ) { // Add a New Publisher $modx->setPlaceholder('Country', $this->db->buildNationality()); $output .= $this->config['addPublisherTpl']; } else if ( $this->config['action'] == "Save" && $this->config['add'] ) { // Save Composer Record if ( $_POST ) { $_REQUEST['idcomp'] = $this->db->saveComposer(); if ($_FILES['file']['name']) { // upload file // This should upload the file and update the database with the appropriate folder information. $this->db->updateImage($this->fl->uploadFile()); } $output .= "Record Saved!
    "; } } return $output; } } // end ?>
    
    >
    • Dit onderwerp is gewijzigd 1 maand, 2 weken geleden door franklos.
    • Dit onderwerp is gewijzigd 1 maand, 2 weken geleden door Jeroen Rotty. Reden: code blok

    De pagina waar ik hulp bij nodig heb: [log in om de link te zien]

3 reacties aan het bekijken - 1 tot 3 (van in totaal 3)
  • Guido

    (@guido07111975)

    Hoi Frank,

    Dit script trekt data uit een database zie ik, dus die moet dan ook gemigreerd worden. Dit zal een flinke klus worden, maatwerk.
    Maar misschien is dit ook wel op te bouwen in WP, middels een plugin. Kun je uitleggen wat dit script doet, iets met zoeken in een database?

    Guido

    Thread starter franklos

    (@franklos)

    Hoi Guido,

    dit stukje script doet wat je op de link ziet. Je kunt bv eerst een nationaliteit kiezen van bv een composer, klik vervolgens op een groene letter (witte letters geven aan dat er geen resultaten zijn). Bv kies, German, klik B en daar zie jv Bach en zijn pianoquarteten. Klik op t vergrootglas en dan kun je zien waar die bladmuziek kunt krijgen.

    Dan is er een stukje script waarmee de ingelogde gebruiker nieuwe composers en of publishers kan invoeren. Ik heb deze scripts niet zelf gemaakt, wel hier en daar (trial and error) aangepast. Zoals je ziet is de pagina niet beveiligd met een certificaat. Als ik dat doe klappen alle links. En EVO is depracated 🙁

    • Deze reactie is gewijzigd 1 maand, 2 weken geleden door franklos.
    Guido

    (@guido07111975)

    Hoi,

    Je zou op zoek kunnen gaan naar een kennisbank (wiki / knowledgebase) plugin die een eigen frontend zoekfunctie heeft. Maar dan moet alle data dus opnieuw ingevoerd worden.
    Of een WP specialist inhuren die de bestaande scripts gaat inbouwen in de WP site, als maatwerk project. Dat laatste zal veel werk zijn, schat ik in.

    Guido

3 reacties aan het bekijken - 1 tot 3 (van in totaal 3)