Currently I am working on a solution for uploading and selecting images from within htmlarea. When a user clicks on the image icon a custom php page is displayed. On this page users are able to upload a new image or select an existing image. After selecting/uploading the image is added to the document.
I want to use php to enable uploading and to restrict access to known users with specific roles. To keep related stuff together I would also like to add this functionality to the 'misc/htmlarea/popups' directory. I also want to use drupal functionality (e.g. 'common.inc') to re-use specific drupal functions.
When I include 'common.inc' in 'misc/htmlarea/popups/add_image.php' the trouble starts ;-( Within 'add_image.php' I refer to 'common.inc' by using 'include_once("../../../includes/common.inc")'. 'common.inc' is found, but PHP cannot find the includes defined in 'common.inc' and lots of errors are displayed. I could use a global $base_path variable which refers to Drupal's base directory, but then I have to change all include statements within drupal.
How do I use drupal functionality within specific php pages which are not related to modules? Thank you in advance...
Comments
Comment #1
moshe weitzman commentedNot sure how to fix this per your instructions. I have always put these sorts of php pages in the drupal root directory thus avoiding include path problems.
your project sounds interesting.
Comment #2
gordon commentedI have already completed this functionality and once the the person who paid for it is happy I will be releasing this into cvs for drupal 4.4. This should be in the next week or so depending on a few things. We are having a few problems with the image module on windows.
You can look at this on my demo page at http://www.heydon.com.au/htmlareademo. You will be able to select images from drupal and link them into your node. Anonymous or Registered users will not be able to upload.
As a word of advice, do not do this as a popup, as you will need to maintain a separate tree for your code. Also I will not be including these patches into htmlarea. Create a plugin which makes the changes that you require.
Basically to be able to include access to drupal function you need to cd to the route of your drupal installation and then include bootstrap.inc (cvs only) and common.inc
Comment #3
gordon commented