Support > cpg1.5 miscellaneous

CPMfetch for 1.5.6

<< < (24/26) > >>

gmc:

--- Quote from: Solare on March 04, 2018, 03:45:40 pm ---First of all, thank you for your answer.
I'm using CPMFetch 2.0.0

Yes, should be what I'm looking for!

I'm testing CPMFetch in this page:
http://www.rotabili.ferrovie.it/schede/ - main page with random thumbnails from Coppermine
http://www.rotabili.ferrovie.it/schede/fs/locoele/fs-e402006-045.php - one of the technical sheets. After the table, all the pictures (random) about this locomotive from mine Coppermine album. I would be happy to have the photos of the locomotives in numerical order (E.402.010, E.402.011, E.402.017, ecc.)!


--- Code: ---$objCpm->cpm_viewRandomMediaFrom("album= 323",999, 3, $options);
--- End code ---
Code setted on 999 to take all the photos from album 323.

Thanks!

--- End quote ---

I have to set up a testbed for 2.0.0... (I use developers release 2.1.1) but if you are willing to try 'untested' (beyond syntax checking) code... I think this will work for you.
Need to update two members in cpmfetch folder

in cpmfetch.php - insert the following at the bottom (just above "}  //END OF CLASS")

--- Code: ---/**
* GMC Addition:
* http://forum.coppermine-gallery.net/index.php/topic,65412.msg384710.html#msg384710
*
* Displays sorted images from specific album or category
*
* This will generate a table and populate it with sorted media from the combination of
* categories and albums specified and style it based on entries in the style hash.
* The number of photos returned matches the number of rows multiplied by the number of columns.
* Supports the setReturnType option.
*
* @param int $rows The number of rows desired in the output
* @param int $columns The number of columns desired in the output
* @param int $sources The sources you want to draw from ("cat=1,4,5:album=6,7,8")
* @param array $options Optional, Configuration options
* @tutorial explainations.optionsarray.pkg
* @tutorial explainations.sourcetag.pkg
*
* @todo allow for media to be specified / filtered - jpg, mp3, etc
*/
function cpm_viewMediaFrom($source,$rows, $columns, $options="") {
    $this->loadOptions($options);
    $resultset = $this->getImageFrom ($source, $rows*$columns);
    $this->addDescriptionsToResultSet($resultset);

    $retval = "";
    switch ($this->returntype) {
        case ('resultset'):
            $retval = $resultset;
            break;
        case ('html'):
            $retval = $this->createTable($resultset,$rows,$columns);
            break;
        case ('print'):
        default:
            print $this->createTable($resultset,$rows,$columns);
    }

    $this->clearOptions();
    return ($retval);
}

--- End code ---

In cpmfetch_dao.php - insert the following at the bottom (just above "}  //END OF CLASS")

--- Code: ---/**
* GMC Addition:
* http://forum.coppermine-gallery.net/index.php/topic,65412.msg384710.html#msg384710
*
* Returns a 'sorted' image from a category in cpm
* Sort order from CPG config at time of CPMFETCH install
* Available options:
* ("ta") - Title ascending
* ("td") - Title descending
* ("na") - Name ascending
* ("nd") - Name descending
* ("da") - Date ascending
* ("dd") - Date descending
* ("pa") - Position ascending
* ("pd") - Position descending
*
* @access private
*/
function getImageFrom ($source, $count) {
    global $config_cpgSettings;
    $resultset = array();

    if (is_numeric($count)) {

    $sourceSql = $this->makeSourceSql($source);

    switch($config_cpgSettings['default_sort_order']) {
        case 'ta':
          $orderby = "title";
        break;
        case 'td':
          $orderby = "title DESC";
        break;
        case 'na':
          $orderby = "filename";
        break;
        case 'nd':
          $orderby = "filename DESC";
        break;
        case 'da':
          $orderby = "ctime";
        break;
        case 'dd':
          $orderby = "ctime DESC";
        break;
        case 'pa':
          $orderby = "position";
        break;
        case 'pd':
          $orderby = "position DESC";
        break;
        default:
          $orderby = "filename";
        break;
       }
   
    if ($sourceSql != "") $sourceSql = " AND " . $sourceSql;

        $sqlcode = "SELECT {$this->sqlPostSelect} " . $this->sqlSelect . " FROM "
            . $this->sqlTableSelect
            . " WHERE 1 "
            . $this->sqlUserDataLink
            . " AND p.approved='YES' "
            . $this->filetypefilter . " "
            . $this->privacyfilter . $sourceSql
            . " ORDER BY $orderby) LIMIT $count";

        $resultset = $this->dbExecuteSql($sqlcode);
        $this->addPathInfo($resultset);

    } //end if
    elseif ($this->cfg['cfDebugMode'] == 'true'){
        debugPrint("Non numeric count submitted");
    }

    return($resultset);

} //end function

--- End code ---

To use - change your $objCpm line to: (removes 'Random' from function name)

--- Code: ---$objCpm->cpm_viewMediaFrom("album= 323",999, 3, $options);

--- End code ---

In theory - this will produce a sorted view of up to 2,997 pictures (999*3) - from whatever category or album you ask for using standard cpmfetch parms (album= or cat= or again in theory both...)
The sort order is determined by your CPG default sort order variable that was copied into cpmfetch at install time - and can be updated/overridden in cpmfetch_config.php.  the default if it can't find config value is filename ascending.

I expect the same change can be made to CPG 2.0.1 (supports CPG 1.6 and PHP 7) - as I didn't make any changes in areas that would be affected.

I'll try to get my sandbox setup this week - but didn't want you to wait if I had something working. :)

Solare:
Greg,
first of all thanks for the interest!
I entered the codes as indicated and I removed 'Random' from function name, but unfortunately it doesn't work and a white page appears :-(
I have to customize some lines in your code perhaps?

For your information:

--- Code: ---Runs on: Tested on coppermine 1.3.2,
 * HTML: Generates XHTML (as far as I can tell)
 * PHP: Tested on version 4
 * RELEASE VERSION 2.0.0
 *
 * @version $Revision: 1.12 $
 * @package cpmfetch
--- End code ---

cpmfetch.php (last lines original file and your new code):

--- Code: ---/**
*
* @access private
*/
function clearOptions( ) {
$this->optionHash = array();
$this->styleHash = array();
}





/**
* GMC Addition:
* http://forum.coppermine-gallery.net/index.php/topic,65412.msg384710.html#msg384710
*
* Displays sorted images from specific album or category
*
* This will generate a table and populate it with sorted media from the combination of
* categories and albums specified and style it based on entries in the style hash.
* The number of photos returned matches the number of rows multiplied by the number of columns.
* Supports the setReturnType option.
*
* @param int $rows The number of rows desired in the output
* @param int $columns The number of columns desired in the output
* @param int $sources The sources you want to draw from ("cat=1,4,5:album=6,7,8")
* @param array $options Optional, Configuration options
* @tutorial explainations.optionsarray.pkg
* @tutorial explainations.sourcetag.pkg
*
* @todo allow for media to be specified / filtered - jpg, mp3, etc
*/
function cpm_viewMediaFrom($source,$rows, $columns, $options="") {
    $this->loadOptions($options);
    $resultset = $this->getImageFrom ($source, $rows*$columns);
    $this->addDescriptionsToResultSet($resultset);

    $retval = "";
    switch ($this->returntype) {
        case ('resultset'):
            $retval = $resultset;
            break;
        case ('html'):
            $retval = $this->createTable($resultset,$rows,$columns);
            break;
        case ('print'):
        default:
            print $this->createTable($resultset,$rows,$columns);
    }

    $this->clearOptions();
    return ($retval);
}
} // end class

?>
--- End code ---

And cpmfetch_dao.php  (last lines original file and your new code):

--- Code: ---/**
*
* @access private
*/
function getRandomSeed() {
return microtime()*1000000;
}

/**
* GMC Addition:
* http://forum.coppermine-gallery.net/index.php/topic,65412.msg384710.html#msg384710
*
* Returns a 'sorted' image from a category in cpm
* Sort order from CPG config at time of CPMFETCH install
* Available options:
* ("ta") - Title ascending
* ("td") - Title descending
* ("na") - Name ascending
* ("nd") - Name descending
* ("da") - Date ascending
* ("dd") - Date descending
* ("pa") - Position ascending
* ("pd") - Position descending
*
* @access private
*/
function getImageFrom ($source, $count) {
    global $config_cpgSettings;
    $resultset = array();

    if (is_numeric($count)) {

    $sourceSql = $this->makeSourceSql($source);

    switch($config_cpgSettings['default_sort_order']) {
        case 'ta':
          $orderby = "title";
        break;
        case 'td':
          $orderby = "title DESC";
        break;
        case 'na':
          $orderby = "filename";
        break;
        case 'nd':
          $orderby = "filename DESC";
        break;
        case 'da':
          $orderby = "ctime";
        break;
        case 'dd':
          $orderby = "ctime DESC";
        break;
        case 'pa':
          $orderby = "position";
        break;
        case 'pd':
          $orderby = "position DESC";
        break;
        default:
          $orderby = "filename";
        break;
       }
   
    if ($sourceSql != "") $sourceSql = " AND " . $sourceSql;

        $sqlcode = "SELECT {$this->sqlPostSelect} " . $this->sqlSelect . " FROM "
            . $this->sqlTableSelect
            . " WHERE 1 "
            . $this->sqlUserDataLink
            . " AND p.approved='YES' "
            . $this->filetypefilter . " "
            . $this->privacyfilter . $sourceSql
            . " ORDER BY $orderby) LIMIT $count";

        $resultset = $this->dbExecuteSql($sqlcode);
        $this->addPathInfo($resultset);

    } //end if
    elseif ($this->cfg['cfDebugMode'] == 'true'){
        debugPrint("Non numeric count submitted");
    }

    return($resultset);

} //end function
}  //END OF CLASS

?>
--- End code ---

David

gmc:
David,

I'll try to get my sandbox up and running with 2.0.0 this weekend and see what I can find...
Can't really suggest a change just from that result.

Greg

Solare:
Ok Greg, no problem.

Thanks!

MG:
I tried to find information on integration of CPMfetch together with vBulletin / vBadvanced.
The modification works with vBulletin 4.1.11 and vBadvanced CMPS v4.2.0.

I'm not a programmer and I do not know about coding, but I managed to integrate CPMfetch for vBadvanced.

First of all, you need to create a new .php file.
I used Rapid php for this.
You can name the .php file as you like it. I called to "om_resources_thumbnail_gallery.php"
- ./gallery/ name is your name folder where you have CPMfetch mod.

- in line   $objCpm->cpm_viewLastAddedMedia(1,1); set how many images you want to show.


--- Code: ---<?php
    include "./gallery/cpmfetch/cpmfetch.php";
    $objCpm = new cpm("./gallery/cpmfetch/cpmfetch_config.php");
    $objCpm->cpm_viewLastAddedMedia(1,1);
    $objCpm->cpm_close();
?>
--- End code ---

Next step is upload your new file .php ("om_resources_thumbnail_gallery.php") to your folder on serwer where you have Modules from vBadvanced.
Next you go to vBulletin Admin Panel > vBa CMPS > Add Module > (Module Type set to ) [PHP File Module].

In next window you need to add :
- Module Title: whatever you called
- set module to Active : YES
- File to Include: pick up your .php file from the list > (om_resources_thumbnail_gallery_1) or whatever you called this file.
- Identifier: PHP file modules require a unique identifier to help identify the module and its settings. Please note that this cannot be changed later and the identifier used for each PHP module must be unique.
- Clean File Output: set to YES ( If you check this option on "NO" your thumbnail preview from galleri will be displayed at the very top of the page instead of in the module with vBadvanced. So I suggest you check this option on "YES")

- Use Module Wrapper Template : set to YES
- Usergroup Permissions: You can select groups for which images from the gallery will be displayed in the vBadvanced module.

Next step is Save and you go to the next page from vBa Admin Panel: 
- Your module has been successfully saved. Click "Go Back" to add another module, or click "Continue" to activate this module on your CMPS pages. So click "Continue"
- Pick where you want to show this modules ( whitch page and whitch column )
Thats all.

I hope that my English is understandable (English is not too strong for me, sorry) and I hope that someone will find this information useful.
In the attachments I added a preview from "vBA Admin Panel"
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
One thing I don't now how to solved:

Everything works fine but the thumbnail in module shows from left side (check image from attachments) 
I would like to show images to center not from lef side.
BTW is there a chance to show some info below thumbnails something like title this image and autor?


Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version