Jump to content
RobAnderson

Article Manager v1.0

Recommended Posts

 

re: v1.57_5 NewFiles/admin

articles_xsell.php - this loop:

 

for ($i=0;$i<$num_of_rows;++$i)

(occurs 4 times throughout code)

 

should that be $i++ or

can you invert the plus signs

jk

 

actually your answer may impact numerous occurrences of ++$y as well

anyway moving on to NewFiles/admin

articles_config.php

 

$cfg_group_query = tep_db_query("select configuration_group_id as id from " . TABLE_CONFIGURATION_GROUP . " where configuration_group_title = 'Article Manager' limit 1");

 

was getting blank page until

pluralized Article Manager to Articles Manager

it made a big difference

 

jk

Share this post


Link to post
Share on other sites

re: v1.57_5 NewFiles/admin

articles_xsell.php - this loop:

 

for ($i=0;$i<$num_of_rows;++$i)

(occurs 4 times throughout code)

 

should that be $i++ or

can you invert the plus signs

It generally doesn't matter. Having the ++ first can be faster in some situations so I always use it.

Share this post


Link to post
Share on other sites

actually your answer may impact numerous occurrences of ++$y as well

anyway moving on to NewFiles/admin

articles_config.php

 

$cfg_group_query = tep_db_query("select configuration_group_id as id from " . TABLE_CONFIGURATION_GROUP . " where configuration_group_title = 'Article Manager' limit 1");

 

was getting blank page until

pluralized Article Manager to Articles Manager

it made a big difference

If you look at the sql install file, you'll see it adds Article Manager. If you have more than one entry in that table though, be it Article Manager or Articles Manager or some variation of either, you have something wrong with that table.

Share this post


Link to post
Share on other sites

If you look at the sql install file, you'll see it adds Article Manager. If you have more than one entry in that table though, be it Article Manager or Articles Manager or some variation of either, you have something wrong with that table.

 

Thanks for your feedback.

Yes, have both. Looks like Article Manager is the most recent addition with a group_id of 457. Guess the original may have been

called Articles Manager. Okay, in retracing my steps, when I ran the article_manager_update_configure.php to upgrade the sql settings:

 

$config_query = tep_db_query("select configuration_group_id from " . TABLE_CONFIGURATION_GROUP . " where configuration_group_title = 'Article Manager' limit 1");

 

it was looking for Article, not the original Articles, so the test:

 

if (tep_db_num_rows($config_query) > 0)

 

failed and it executed the else instead of deleting all configuration settings with group_id 456

) else {

echo 'Article Manager is not installed.<br><br>';

 

technically true but leaving Articles Manager intact with the group_id of 456

the code then goes on to give the new configuration fields a group_id of 457...

anyway, deleted all configuration settings for group_ids 456 and 457,

then added new configuration settings from article_manager_V_1.57.sql,

changed Articles Manager group_id to 455(retained in case of something unexpected),

then changed Article Manager group_id from 457 to 456

and in articles_config.php, changed the query back to Article Manager so

it now associates Article Manager with group_id 456.

 

I'm wondering if the update SQL (article_manager_update_configure.php)

should maybe also check for Articles Manager? (I bet you have a suggestion for me too!)

 

Hey, the redesigned Article Infobox is a great improvement

in both style and function.

 

jk

Share this post


Link to post
Share on other sites

Hi Jack,

 

Hope all is excellent with you.

Trying to get catalog/article_submit.php to upload image.

this line is failing

if (isset($_FILES['uploadedfile']) && tep_not_null($_FILES['uploadedfile']['tmp_name'])) {

 

did a printout:

print ' in article_submit line 91 ' . "<br />\n";

print 'Array FILES: <pre>';

print_r ($_FILES);

print '</pre>' . "<br />\n";

--------

 

results:

in article_submit line 91

Array FILES:

 

Array

(

)

-------- end of results printout --------

 

looks like the array is not being populated?

 

Thanks for any guidance.

jk

Share this post


Link to post
Share on other sites

this line is failing

What does that mean? Is an error shown? Is it skipping the upload? Possibly something else?

 

What version are you using?

Edited by Jack_mcs

Share this post


Link to post
Share on other sites

nevermind the above post, it's working now after reloading the article-submit.php

shoulda tried that hours ago, boy do i feel brainless

 

jk

Share this post


Link to post
Share on other sites

Hi Jack,

Re: ArticlesManager_1.57_5

 

When onsite Users upload an article there is no author name nor author info

associated with it, which poses a problem with the content display after clicking

the Article Box options, namely no author name for the article and even after adding

an author name in admin because the author_info table is not filled on the initial

upload, it affects the content display when clicking the author in author box because the

Heading says Articles by (blank)

anyway, here is a snippet that fills in the author and author_info tables when the user is logged in.

Requires adding customer_id field to TABLE_AUTHORS

 

in NEWFILES/article-submit.php

 

AFTER

if (! $error)

{

 

ADD

// 9-24-10 added to put Author/Customer name and generic Author info into db when User is logged in

// Requires adding customer_id field to TABLE_AUTHORS

 

if (tep_session_is_registered('customer_id')) {

$account_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");

$account = tep_db_fetch_array($account_query);

 

$author_name = $account['customers_firstname'] . ' ' . $account['customers_lastname'];

 

$author_query = tep_db_query("select authors_id, authors_name from " . TABLE_AUTHORS . " where customers_id = '" . (int)$customer_id . "'");

$author = tep_db_fetch_array($author_query);

 

if ($author['authors_id'] < 1) {

 

// no author_id found for this customer need to add

$authors_date_added = date('Y-m-d');

$sql_data_array = array('authors_name' => $author_name,

'date_added' => $authors_date_added,

'customers_id' => (int)$customer_id);

 

tep_db_perform(TABLE_AUTHORS, $sql_data_array);

$authors_id = tep_db_insert_id();

 

// add generic author description to authors_info table

 

$languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order");

while ($languages = tep_db_fetch_array($languages_query)) {

$languages_array[] = array('id' => $languages['languages_id'],

'name' => $languages['name'],

'code' => $languages['code'],

'image' => $languages['image'],

'directory' => $languages['directory']);

}

 

$authors_description = $author_name . " is a valued member of our community.";

$authors_url = '';

 

$languages = $languages_array;

 

// used optimize array technique including ++$i instead of - for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

$max = sizeof($languages);

for ($i=0; $i<$max; ++$i) {

 

$language_id = $languages[$i]['id'];

 

$sql_data_array = array('authors_description' => $authors_description ,

'authors_url' => $authors_url);

 

$insert_sql_data = array('authors_id' => $authors_id,

'languages_id' => $language_id);

 

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

 

tep_db_perform(TABLE_AUTHORS_INFO, $sql_data_array);

}

 

} else {

 

// found customer's authors_id

$authors_id = $author['authors_id'];

}

} // X if (tep_session_is_registered('customer_id')) {

// X 9-24-10 added to put Author/Customer name and generic Author info into db

 

(Hope you don't mind my posting this, just wanted to share)

jk

Share this post


Link to post
Share on other sites

Please feel free to post what you like. It may help someone. And I don't mind problems with code I've written being pointed out. Another pair of eyes always helps. :)

Share this post


Link to post
Share on other sites

Hi Jack,

RE: ArticlesManager_1.57_5

 

While testing, was receiving 'image failed to upload' error.

Reason why: no article_manager_uploads folder in images directory.

Added a line of code to resolve it since I'm updating a number of sites, as well as,

for future sites, so it's all done in one step.

 

in catalog/article-submit.php

 

FIND:

if (isset($_FILES['uploadedfile']) && tep_not_null($_FILES['uploadedfile']['tmp_name'])) {

 

ADD AFTER:

// make sure article_manager_uploads directory exists

if(!is_dir(DIR_WS_IMAGES . 'article_manager_uploads'))mkdir(DIR_WS_IMAGES . 'article_manager_uploads');

 

That's it, originally I tried adding a permissions parameter (mkdir(DIR_WS_IMAGES . 'article_manager_uploads', '755')

but the folder was assigned permissions of 134 for some reason, so I removed that parameter and the folder was created

with permissions of 755 (which is the default for this particular hosting server).

 

Hope this might help someone else.

 

jk

Share this post


Link to post
Share on other sites

RE: ArticlesManager_1.57_5

 

Here's something that php5.3 doesn't swallow (causes php to be rendered as html)

admin/articles_xsell.php

 

FIND:

</table>

<?

} // the end of -> if (!$_POST['add_related_article_ID'])

 

CHANGE TO:

</table>

<?php

} // the end of -> if (!$_POST['add_related_article_ID'])

 

until next time

jk

Share this post


Link to post
Share on other sites

Hi Jack,

 

RE: ArticlesManager_1.57_5 (and php5.3?)

 

Here is something that I haven't been able to figure out

despite hours of head scratching.

 

In admin/articles.php, when clicking the topics folder, it fails to open.

The infobox on the right shows there are articles in the folder:

 

Date Added: 09/25/2010

 

Subtopics: 0

Articles: 2

 

The folder can be opened by doing a search but the articles display is missing the

'go back' button. This only occurs on localhost using xxamp with php5.3, the hosted

sites work correctly using <php5.3 which is what makes me think it may be php5.3 compliance related.

 

Things I've tried:

1. reloading the articles.php

2. searching for deprecated ereg and eregi expressions in artcles.php- both in admin and admin/includes/functions

3. comparing articles.php to categories.php(which works correctly on localhost)

4. commenting out the error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED) in admin/includes/application_top.php

5. prayer

 

so far it's been a big fat nothingburger...

jk

Edited by jfkafka

Share this post


Link to post
Share on other sites

RE: ArticlesManager_1.57_5 (and php5.3?)

 

Here is something that I haven't been able to figure out

despite hours of head scratching.

 

In admin/articles.php, when clicking the topics folder, it fails to open.

The infobox on the right shows there are articles in the folder:

I don't have this setup on a server using 5.3 so I can't test it. Since no one else has mentioned this, you are probably correct about it being related to 5.3 but I don't have any suggestions for you to try.

Share this post


Link to post
Share on other sites

Thanks to this contribution.

I installed this and getting a error as below

"1146 - Table 'p4134_oscommerce.authors' doesn't exist

 

select count(*) as total from authors"

 

I did upload the sql tables but not sure why the error occurs. The Article box in the home page also doesnt comeup due to this reason.

please help to provide a solution.

Share this post


Link to post
Share on other sites

Thanks to this contribution.

I installed this and getting a error as below

"1146 - Table 'p4134_oscommerce.authors' doesn't exist

 

select count(*) as total from authors"

 

I did upload the sql tables but not sure why the error occurs. The Article box in the home page also doesnt comeup due to this reason.

please help to provide a solution.

 

I ran the sql file again but found error as below. So tables are not getting updated.

"Error

SQL query:

 

INSERT INTO `configuration_group` ( `configuration_group_id` , `configuration_group_title` , `configuration_group_description` , `sort_order` , `visible` )

VALUES (

 

'456', 'Article Manager', 'Article Manager site wide options', '20', '1'

);

 

 

 

MySQL said:

 

#1062 - Duplicate entry '456' for key 1 "

 

Whats the solution to correct it and run the sql file?

 

Thanks

Share this post


Link to post
Share on other sites

I ran the sql file again but found error as below. So tables are not getting updated.

"Error

SQL query:

 

INSERT INTO `configuration_group` ( `configuration_group_id` , `configuration_group_title` , `configuration_group_description` , `sort_order` , `visible` )

VALUES (

 

'456', 'Article Manager', 'Article Manager site wide options', '20', '1'

);

 

MySQL said:

 

#1062 - Duplicate entry '456' for key 1 "

 

Whats the solution to correct it and run the sql file?

If, and only if, you are installing my version, 1_57, then use the article_manager_update_configure.php file in the archive. The error you are getting is due to the id for the new changes already existing for some other contribution. This file will change the number to the next available one so that error should not occur. If you are installing a different version, you will need to edit the file to have it use another id.

Share this post


Link to post
Share on other sites

Hi Jack,

 

RE: ArticlesManager_1.57_5 (and php5.3?)

 

Here is something that I haven't been able to figure out

despite hours of head scratching.

 

In admin/articles.php, when clicking the topics folder, it fails to open.

The infobox on the right shows there are articles in the folder:

 

 

still trying to ascertain the cause and remedy

maybe this isn't correct but

 

in admin/includes/functions/articles.php:

 

here is the code:

function tep_remove_topic($topic_id) {

$topic_image_query = tep_db_query("select topics_image from " . TABLE_TOPICS . " where topics_id = '" . (int)$topic_id . "'");

$topic_image = tep_db_fetch_array($topic_image_query);

 

$duplicate_image_query = tep_db_query("select count(*) as total from " . TABLE_TOPICS . " where topics_image = '" . tep_db_input($topic_image['topics_image']) . "'");

$duplicate_image = tep_db_fetch_array($duplicate_image_query);

 

if ($duplicate_image['total'] < 2) {

if (file_exists(DIR_FS_CATALOG_IMAGES . $topic_image['topics_image'])) {

@unlink(DIR_FS_CATALOG_IMAGES . $topic_image['topics_image']);

}

}

 

tep_db_query("delete from " . TABLE_TOPICS . " where topics_id = '" . (int)$topic_id . "'");

tep_db_query("delete from " . TABLE_TOPICS_DESCRIPTION . " where topics_id = '" . (int)$topic_id . "'");

tep_db_query("delete from " . TABLE_ARTICLES_TO_TOPICS . " where topics_id = '" . (int)$topic_id . "'");

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('topics');

tep_reset_cache_block('also_purchased');

}

}

 

function tep_remove_article($article_id) {

tep_db_query("delete from " . TABLE_ARTICLES . " where articles_id = '" . (int)$article_id . "'");

tep_db_query("delete from " . TABLE_ARTICLES_TO_TOPICS . " where articles_id = '" . (int)$article_id . "'");

tep_db_query("delete from " . TABLE_ARTICLES_DESCRIPTION . " where articles_id = '" . (int)$article_id . "'");

 

$article_reviews_query = tep_db_query("select reviews_id from " . TABLE_ARTICLE_REVIEWS . " where articles_id = '" . (int)$article_id . "'");

while ($article_reviews = tep_db_fetch_array($article_reviews_query)) {

tep_db_query("delete from " . TABLE_ARTICLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . (int)$article_reviews['reviews_id'] . "'");

}

tep_db_query("delete from " . TABLE_ARTICLE_REVIEWS . " where articles_id = '" . (int)$article_id . "'");

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('topics');

tep_reset_cache_block('also_purchased');

}

}

 

I'm wondering if the code to remove the image should be tep_remove_article not tep_remove_topic

because there is no place to enter a topic image when using the admin interface to set up a new topic

(even though there is a topics_image field in the topics table) but the field value is NULL

(maybe because this code was improvised from products functions as evidenced from

tep_reset_cache_block('also_purchased');?)

 

or maybe I missed something?

 

Thanks for your expertise.

jk

Share this post


Link to post
Share on other sites

If, and only if, you are installing my version, 1_57, then use the article_manager_update_configure.php file in the archive. The error you are getting is due to the id for the new changes already existing for some other contribution. This file will change the number to the next available one so that error should not occur. If you are installing a different version, you will need to edit the file to have it use another id.

I have installed Article Manager 1.57_5.

I ran the php file and got below message

"Article Manager has been removed form the database.

 

Attempting to install Article Manager database changes.

Article Manager database changes have been installed."

 

I checked the Article Manager link again and it shows the same error.

 

In the database in Configuration group, it says next available index is 457. Do I need to edit the sql file to show 457 and run the sql file again. Please help in able to run this contribution.

Share this post


Link to post
Share on other sites

I have installed Article Manager 1.57_5.

I ran the php file and got below message

"Article Manager has been removed form the database.

 

Attempting to install Article Manager database changes.

Article Manager database changes have been installed."

 

I checked the Article Manager link again and it shows the same error.

 

In the database in Configuration group, it says next available index is 457. Do I need to edit the sql file to show 457 and run the sql file again. Please help in able to run this contribution.

The database script ran as indicated. At that point you are done making database changes.

Share this post


Link to post
Share on other sites

The database script ran as indicated. At that point you are done making database changes.

 

I get a Article Manager link in Config and also a separate link.

When I click the seperate Article Manager link, I get the same error but after going back on the page, I could see other sublinks in which only the config link is working. Other links are showing same error as database table not updated.

 

When I check the database tables, no article manager tables are added !!

Share this post


Link to post
Share on other sites

I get a Article Manager link in Config and also a separate link.

When I click the seperate Article Manager link, I get the same error but after going back on the page, I could see other sublinks in which only the config link is working. Other links are showing same error as database table not updated.

 

When I check the database tables, no article manager tables are added !!

I'm sorry but I can't follow that. "Article Manager link in Config" What is Config?

 

The bottom line is that you have to make the database changes for this to work. The included script should work.

Share this post


Link to post
Share on other sites

I'm sorry but I can't follow that. "Article Manager link in Config" What is Config?

 

The bottom line is that you have to make the database changes for this to work. The included script should work.

 

Sorry to confuse you.

I meant Admin->Configuration->Article Manager

I tried running again the php script but I get the same error as Authors table not found.

 

Let me go thro the installation once again.

Share this post


Link to post
Share on other sites

Hi Jack,

 

Re: ArticlesManager1.57_5

 

Hope all is excellent with you.

Having problem with article topic/subtopic content display

 

in articles infobox:

New Articles (2)

test 10

website inside info

All Topics

Miscellaneous Articles

Website Design -> (2)

website tricks (1)

 

when clicking on:

website tricks (1)

 

this is what the result is:

url window:

http://www.localdev.com/public_html/website-design-t-2_3.html

 

browser window:

Not Found

 

The requested URL /public_html/website-design-t-2_3.html was not found on this server.

 

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Apache/2.2.12 (Win32) DAV/2 mod_ssl/2.2.12 OpenSSL/0.9.8k mod_autoindex_color PHP/5.3.0 mod_perl/2.0.4 Perl/v5.10.0 Server at www.localdev.com Port 80

 

however when clicking:

New Articles (2)

test 10

website inside info

website inside info (which is the article in website tricks subtopic):

 

url address:

http://www.localdev.com/public_html/website-inside-info-a-3.html

 

article displays correctly

 

any ideas how to fix?

Thanks for your patience.

jk

Share this post


Link to post
Share on other sites

any ideas how to fix?

If all of the other links work, then it has to be something specific to the one that isn't workijng. I would first turn off the url rewriter to make sure that is not causing a problem. It will also allow you to see the actual path and compare it to one that is working.

Share this post


Link to post
Share on other sites

If all of the other links work, then it has to be something specific to the one that isn't workijng. I would first turn off the url rewriter to make sure that is not causing a problem. It will also allow you to see the actual path and compare it to one that is working.

 

Thanks for your feedback, found a solution to remove the prepended parent id and underscore and now it works for subtopics.

What I did was:

in public_html/includes/boxes/articles.php:

 

REPLACED

$tPath_new = 'tPath=' . $tree[$counter]['path'];

 

WITH:

/* 10-01-10 commented out original code which gives 404 error because adding parent id and _ to URL path

(ex. http://www.localdev.com/public_html/website-tricks-t-2_3.html)

$tPath_new = 'tPath=' . $tree[$counter]['path'];

X 10-01-10 commented out original code which gives 404 error because adding parent id and _ to URL path

*/

// 10-01-10 Solution: remove parent id and underscore in subtopic link

$pos = strpos($tree[$counter]['path'],"_");

 

if($pos === false) {

// _ NOT found in $tree[$counter]['path']

} else {

// _ found in $tree[$counter]['path']

$curr_subtopic_link = substr($tree[$counter]['path'], $pos+1);

$tPath_new = 'tPath=' . $curr_subtopic_link;

//echo "pos = ". $pos . '<br />';

//echo "curr_subtopic_link = ". $curr_subtopic_link . '<br />';

//echo ' in boxes/articles.php line 70 and tpath new = '. $tPath_new;

}

// X 10-01-10 Solution: remove parent id and underscore in subtopic link

 

Appreciate your support.

jk

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×