Replace Picnik image editor by Pixlr

Permalink
Before i try to dive in the code, Anyone have some hint, sample.. for replace Picnik image editor by Pixlr in the file manager?

fabienapd
 
Mainio replied on at Permalink Reply
Mainio
The file you need to edit is:

/concrete/elements/files/edit/image.php


EDIT: Forgot to mention that before editing, you should copy it outside the /concrete/ to folder here:
/elements/files/edit/image.php


Br,
Antti / Mainio
Mainio replied on at Permalink Reply
Mainio
I couldn't answer you below because there is a bug in this forum that if you don't include the code-tags, it messes up the syntax here.

That just prints out the Picnik API url with a unique validation token from concrete5. The helper there just prints out a validation hash for the 'input_remote' validation action. Just a unique md5-hash for the service.

The thing you should be interested about is below that line:
$aPicnikParams['image_file'] = "@".$fv->getPath();


Here you can see that the image path in given as parameter for the Picnik API. Also, if you need the relative (external) url, you can see that above the $strPicnikUrl, it is also provided:
$image = BASE_URL . $fv->getRelativePath();


Also, you can notice that the Picnik "exports" (saves back) the image through this URL:
$export = BASE_URL . REL_DIR_FILES_TOOLS_REQUIRED . '/files/importers/remote';


So this is (probably) the call back to concrete5 that you should also be interested about.


I don't really know anything about the Pixlr editor or its API but I think you need at least the image path or URL for it to be able to find the image. You'll probably also need API keys and/or security tokens from the service, I'm not sure...


Antti
fabienapd replied on at Permalink Reply
fabienapd
Thanks again. I edit my message with the Quote code. I am a C5 newbie :/

It's the opposite for me, never work with picnick. From what i see here, pixlr is more simple. you don't need api key and token or similar at your choice with your own code if you want more secure connection. it's pretty straight forward.

My main issue is the call back to concrete5. Pixlr send us 3 variables with a choice of 2 different method GET or POST.

- image
-> GET the value of image is an url to where pixlr saved the image.
-> POST the value of image is the actual image.
- title The title of the image.
- type The type of image can be: jpg, png....

I can't figure out how to grab them with the importer.
Mainio replied on at Permalink Reply
Mainio
You probably already know already where the importer lies? It's here:
/concrete/tools/files/importers/remote.php



From there you can check what it needs. You can see that for the request, you can pass this parameter that contains the image url:
// Replace the X with the image queue number
// If just importing 1 file, replace it with 1
$_REQUEST['url_upload_X'];


And that needs to be VALID and whole URL that is passed there, otherwise it will throw you an error.

EDIT: Also I noticed that you need to return also the validation token sent to the API in this parameter (that's why it was there in the first place):
$_REQUEST['ccm_token'];


That just ensures that no one can abuse your importer.

I _think_ that's all you need. If you're not please with the importer, just write your own. Here's how to work with concrete "tools":
http://andrewembler.com/posts/javascript-jquery-and-concrete5/... (under AJAX)
http://www.c5tutorials.com/tutorials/ajax-ifying-your-site-part-1/...


Antti
BHWW replied on at Permalink Reply
BHWW
Hi Manio, i know it's an old post, but looking at the 5.8 code, the same old remote importer tool is there.

I'm trying to import to the filemanger via a url and hopefully get a fileID returned.

Are you able to please point me in the right direction if you still have anything to do with C5 :)

Thanks in advance

where i'm at the mo is:

public function saveRemoteFile($fileurl)
  {
   $_REQUEST['ccm_token'];
   $_REQUEST['url_upload_1'] = $fileurl;
   $import = BASE_URL . REL_DIR_FILES_TOOLS_REQUIRED . '/files/importers/remote';
   return $import;
  }


this was just producing errors:

public function saveRemoteFile($file,$filename)
  {
    $error = \Concrete\Core\File\Importer::E_PHP_FILE_ERROR_DEFAULT;
    if (isset($filename) && is_uploaded_file($file)) {
        $importer = new \Concrete\Core\File\Importer();
        $result = $importer->import($file, $filename);
        if ($result instanceof \Concrete\Core\Entity\File\Version) {
           return $result->getFileID();
        } else {
            $error = $result;
        }
    } 
    return \Concrete\Core\File\Importer::getErrorMessage($error);  
  }
fabienapd replied on at Permalink Reply
fabienapd
thanks for your quick reply. Until here i was ok. i try to play around with the code for a while but i can't figure out how the launch variable work :
$strPicnikUrl = "http://www.picnik.com/service?".$valt->getParameter('import_remote');
pochis replied on at Permalink Reply
hi did you get it
TheRealSean replied on at Permalink Reply
TheRealSean
Try over here instead, think someone resolved a similar issue

http://www.concrete5.org/community/forums/usage/5.5.2-image-editor/...