skip to main content

kiesler.at
You are NOT logged in. ( login | New Account Signup | Forgot Your Password? ) Why log in?
View Topic
Forums > Content Management > phpWebSite > Iimage in the summary of the article


The ad will go away if you log in.

<< [ 1 ] >>

| NewTopic New Topic | Reply Reply

 

JMB “Iimage in the summary of the article” #1
Activator[12] 2008-01-18 19:33

Hi,

I sent a note to rck about his Article Manager 3.4 (
http://www.phpwsforums.com/showthread.php?t=3994&highlight=article+image) but I'm not sure he comes always on his web site =sad
In fact, I'm loocking for piece of code to add image in the summary of the article (to transform Article module on "blog" module). Somebody can help me please ?

Thanks.

JM
Quote Quote
JMB “Re: Iimage in the summary of the article” #2
Activator[12] 2008-03-10 21:51

He he ! I have an answer ... but just for my second question : this site is not a "ghost" site : I saw a rck post yesterday ... after 1 year !!

Good news =;)

Maybe can I hope an answer for my main question : insert an image in the summary of an article ?

M. rck ... please.

Regards
Quote Quote
rck “Re: Iimage in the summary of the article” #3
Admin[1999] from Korneuburg 2008-03-10 22:50

Well... The way i USED to do it should still work

[code]here goes your summary text[/code]

Works nicely. Here, on kiesler.at, I have a slightly modified Article Manager. There's a new field for the image, but the image has to be set directly in the database. I think, the new Article Manager has a better solution, but only works for 1.x

I also have a front-end for that, used on ko2100.at, but it's VERY fragile, I cannot give it away the way it is. But who knows, if there is enough demand and maybe some bribery involved...

Regarding "ghost site" ... I still hope, that SOMEONE can answer other users questions. Alternatively, again, if there's enough interest, I could come up with a "support plan". As always, everyone is free to contact me regarding (commercial) phpWebSite consulting work.
---
200 channels and... nothing but cats.
Quote Quote
JMB “Re: Iimage in the summary of the article” #4
Activator[12] 2008-03-11 10:40

Thanks for your answer and sorry for "ghost" site but one year and no post from the webmaster ...

I use too but it's not really the best way and I will try to continue to make an hack from the "articles" mod ... even if I'm a php novice.

Have a good day ...
Quote Quote
rck “Re: Iimage in the summary of the article” #5
Admin[1999] from Korneuburg 2008-03-11 19:49

If you post your steps here, I might be able to help. Essentially, it comes down to

a) having a new database field with an image URL (via your favorite MySQL Frontend)
b) uploading a file there.
c) changing the summary - template, so it would show a new template field
d) change the view - function within article.php, so it would fill the template field.

I just looked into the source code of KO2100, I already did three different attempts for solving that problem. What I have right now are three new variables in class/Article.php:

[code]var $image;
var $old_image;
var $temp_image;[/code]

That's where I store stuff from a)

In the constructor of class/Article.php (function PHPWS_Article) I set those to null and load image_name, image_directory, image_width and image_height, putting them into the image variable. That looks something like this:

[code] if( isset($data['image_name']) and
isset($data['image_directory']) and
isset($data['image_width']) and
isset($data['image_height'])
) {

$this->image=array();

if(isset($data['image_name']))
$this->image['name']=$data['image_name'];

if(isset($data['image_directory']))
$this->image['directory']=$data['image_directory'];

if(isset($data['image_width']))
$this->image['width']=$data['image_width'];

if(isset($data['image_height']))
$this->image['height']=$data['image_height'];

} else
$this->image=null;[/code]

when you have loaded those values, you can just fill a tag with that, like:


[code]
$image_string = genImageString($this->image, $this->temp_image, $_SESSION['SES_ART_master']->image_directory);

if(isset($image_string))
$article_tags['IMAGE'] = $image_string;
else
$article_tags['IMAGE'] = null;
[/code]

Thanks for your persistance. I'm curious how your solution works out. If you get stuck, just post...
---
200 channels and... nothing but cats.
Quote Quote
JMB “Re: Iimage in the summary of the article” #6
Activator[12] 2008-03-20 18:21

Hi,

I'm working always on this problem ...
- I hacked the Article table in the DataBase ;
- I hacked the "a_edit.php" script (after the "// Get the article summary text" block ):
// JMB ...
/* If there is a current image, show it */
if($this->image['name'])
/* If this is a temporary image, look in the main directory */
if ($this->temp_image)
$article_tags['ART_IMAGE'] = '';
else
$article_tags['ART_IMAGE'] = '';
/* If user is allowed to play around with the images... */
//if ($_SESSION['OBJ_user']->allow_access('article', 'images_in_article')
//|| ($_SESSION['SES_ART_master']->val['user_images_in_article'] && $_SESSION['OBJ_user']->isUser()))
{
/* allow them to remove it */
if($this->image['name'])
{
$article_tags['ART_REMOVEIMAGE_LABEL'] = $_SESSION['translate']->it('Remove Image');
$form->add('REMOVEARTICLEIMAGE', 'checkbox');
$form->setMatch('REMOVEARTICLEIMAGE', false);
}

/* If allowed, upload your image here */
//if ($_SESSION['OBJ_user']->allow_access('article', 'upload_images')
//|| ($_SESSION['SES_ART_master']->val['user_upload_images'] && $_SESSION['OBJ_user']->isUser()))
{
$article_tags['ART_LOADED_IMAGE_ERR'] = $_SESSION['SES_ART_master']->get_error('ARTICLE_LOADED_IMAGE');
$article_tags['ART_LOADED_IMAGE_LABEL'] = $_SESSION['translate']->it('Upload a new image');
$form->add('ARTICLE_LOADED_IMAGE', 'file');
$form->setWidth('ARTICLE_LOADED_IMAGE', 40);
}
}
// ... JMB

- I initialized the variables in "PHPWS_Article" class in the "article.php" script and hacked the "update_title" function:

function update_title (){
$this->updated_username = $_SESSION['OBJ_user']->username;
$this->updated_date = date("Y-m-d H:i:s");
if (isset($_POST['ARTICLE_title']))
$this->title = stripslashes($_POST['ARTICLE_title']);
if (isset($_POST['ARTICLE_summary']))
$this->summary =
//JMB ...
stripslashes($_POST['ARTICLE_summary']);
if (isset($_POST['ARTICLE_loaded_image']))
$this->image = stripslashes($_POST['ARTICLE_loaded_image']);

include(PHPWS_SOURCE_DIR . 'mod/article/inc/AI_update.php');
//... JMB
}

- I wrote a new "AI_update.php" script (similar to the "S_update.php" script) :

/**
* Assigns a free image directory.
*
* @version $Id: S_update.php,v 1.3 2004/09/30 05:14:32 adarkling Exp $
*
* Imagefile Storage Optimization
* Most OSs optimally search & retrieve up to about 500 files per directory.
* This function just makes new directories as the old ones are filled up.
* It assumes that the first directory (/1) is already created.
*
* @author Eloi George
* @module Article Manager
* @param none
* @return string : directory name
*/
function AssignImageDir ()
{
/* Load up all numbered image directories */
$dir_list = array();
$dir_handle = opendir($_SESSION['SES_ART_master']->image_path);

while($value = readdir($dir_handle))
{
if (is_numeric($value) && is_dir($_SESSION['SES_ART_master']->image_path.$value))
$dir_list[] = $value;
}
closedir($dir_handle);

/* Find the highest directory number in a sorted list */
sort($dir_list);
$last_dir = end($dir_list);
/* Count how many files are in the last directory. Allow for "." & ".."*/
$count = -2;
if ($dir_handle = opendir($_SESSION['SES_ART_master']->image_path . $last_dir . '/'))
while($value = readdir($dir_handle))
$count++;
closedir($dir_handle);
/* If this dir is full, then make a new directory */
if ($count > 499)
{
$oldumask = umask(0);
if (!mkdir($_SESSION['SES_ART_master']->image_path . ++$last_dir, 0775))
$_SESSION['SES_ART_master']->error['ARTICLE_loaded_image'][] = $_SESSION['translate']->it('Image Directory "[var1]" could not be created. Image was not saved.', $last_dir);
umask($oldumask);
}
return $last_dir . '/';
}


/**
* function update ()
* Applies changes to this section in memory.
*
* @author Eloi George
* @module Article Manager
* @param none
* @return none
*/

$temp_name = NULL;

/* Image Removal */
if(isset($_POST['removeArticleImage']) && $this->image['name'] && $this->image['directory']!='library/')
{
/* If this is the original image, place its name into "old_image" */
if (empty($this->old_image['name']))
$this->old_image = $this->image;
/* otherwise, if this is a new(uncommitted) image, delete it */
else
{
@unlink($_SESSION['SES_ART_master']->image_path.$this->image['name']);
$this->temp_image = NULL;
}
/* Blank out the "imagename" var */
$this->image['name'] = NULL;
}


/* If a file was uploaded and is valid... */
if (!empty($_FILES['ARTICLE_LOADED_IMAGE']['size']))
{
/* Give it a unique name */
$ext = strrchr($_FILES['ARTICLE_loaded_image']['name'], '.');
$_FILES['ARTICLE_loaded_image']['name'] = time() . '-' . $_SESSION['OBJ_user']->user_id . $ext;
/* Place it into the temporary directory */
$image = EZform::saveImage('ARTICLE_loaded_image'
, $_SESSION['SES_ART_master']->image_path
, $_SESSION['SES_ART_master']->val['max_image_width']
, $_SESSION['SES_ART_master']->val['max_image_height']
, $_SESSION['SES_ART_master']->val['max_image_size'] * 1024);
if (PHPWS_Error::isError($image))
$_SESSION['SES_ART_master']->error['ARTICLE_loaded_image'][] = $image->_message;
else
{
/* If this is replacing the original image, place the original into "old_image" */
if (!$this->old_image)
$this->old_image = $this->image;
else
/* If this is replacing a new(uncommitted) image, delete the obsolete one */
if ($this->temp_image)
@unlink($_SESSION['SES_ART_master']->image_path.$this->temp_image);
/* Set the new image information */
if (!$this->image['directory'] || $this->image['directory']=='library/')
$this->image['directory'] = AssignImageDir();
$this->image = array_merge($this->image, $image);
$this->temp_image = $this->image;
}
}

But I have a problem because the $_FILES['ARTICLE_loaded_image']['size'] seems empty =sad
Maybe have you an idea ?

JM
Quote Quote
rck “Re: Iimage in the summary of the article” #7
Admin[1999] from Korneuburg 2008-03-20 23:52

A nice function I often use is print_r(). With print_r, you can show the contents of an array. Maybe, if you do a print_r($_FILES), we get more clues?

By the way, if you enclose text within [ code ] [ / code ] (without the blanks) the formatting is nicer for source code...
---
200 channels and... nothing but cats.
Quote Quote
JMB “Re: Iimage in the summary of the article” #8
Activator[12] 2008-03-30 16:57

Hello,

always the same problem but it seems its an old problem : http://sourceforge.net/forum/message.php?msg_id=2373548

I will try one or two another things but that will be the last =sad
Quote Quote

<< [ 1 ] >>
| Reply Reply |

Forum Menu

please log in for further options.

What's Related

Wiki

phpWebSite

Photo Albums

phpWebSite

Article Manager

phpWebSite

Link Manager

phpWebSite

Documents

phpWebSite

Bulletin Board

phpWebSite

FAQ

phpWebSite

Latest Updates

Free Image Hosting and Li...
created by mikepeterson, 1 week ago (, 86 views)
thread

how to start javascript !...
created by shopperpk, 3 weeks ago (, 143 views)
thread

Hello, new here !
created by shopperpk, 3 weeks ago (, 126 views)
thread

Re: how to run phpwebsite...
created by alexander, 2011-08-25 (2 rpls, 3440 views)
thread