MDN

Go Back   Mambo - Forums Closed for posting > Mambo 4.5.5 - Stable > General Questions

Reply
 
Thread Tools Search this Thread Display Modes
Old June 19th, 2004, 10:33   #1
Casinnola
 
Join Date: Jun 2004
Posts: 10
Casinnola is on a distinguished road
Default Way to get word count of news items in backend?

My site is a newsletter with articles written by many authors.

I pay them bi-weekly based on the word counts of their articles.

Is there a way for me or someone with 'administrator' access to view word counts on articles? The ideal way would be a way to view all news items in a certain date range, with the author, title, and word count displayed.
Casinnola is offline   Reply With Quote
Old June 19th, 2004, 11:42   #2
troozers
 
troozers's Avatar
 
Join Date: Oct 2003
Location: Northampton, UK
Posts: 490
troozers is on a distinguished road
Default my meagre skills

Hi Cassinola,

I am trying to get my poor PHP skills upto scratch by doing small programming projects within Mambo, and this sounds like a small component/module/mosbot I could cut my teeth on.

As far as I am aware there is nothing as yet that is available to do this, although I am open to being corrected on this. Don't worry, I won't charge for doing this.

Where would you prefer to see the information, in the backend administrator screen or in the front-end? If it's in the front-end would you prefer it only viewable by Public/Registered/Only selected people?
__________________
Andy Stewart
http://www.troozers.com
troozers is offline   Reply With Quote
Old June 19th, 2004, 13:49   #3
Casinnola
 
Join Date: Jun 2004
Posts: 10
Casinnola is on a distinguished road
Default

Quote:
Originally Posted by troozers
Where would you prefer to see the information, in the backend administrator screen or in the front-end? If it's in the front-end would you prefer it only viewable by Public/Registered/Only selected people?

Very cool! Thanks for the offer!

It would work either way, but I think the best way would be a front-end module that would look something like this:

Date | Author | Article Title | Word Count
6 Jun 2004 | Mike | How To Build Widgets | 339


I think it should be front-end accessible so that the authors could verify what they are owed.

edit I originally thought it should go backend, hence the title of this thread. But after you mentioned the possibility of frontend access, I think it's better. And yes, in answer to your second question, it should have the choices of Public, Registered, or Special.

Last edited by Casinnola : June 19th, 2004 at 13:53.
Casinnola is offline   Reply With Quote
Old June 19th, 2004, 16:07   #4
tonyskyday
 
tonyskyday's Avatar
 
Join Date: Dec 2003
Location: Charlottesville, VA USA
Posts: 2,836
tonyskyday is on a distinguished road
Default

Oh, this could so totally be done with a mosbot so that when the superadminstrator (or any backend user) logs in, they see that info in the content, but everyone else just sees the content. It would be a great mosbot project.

-Tony
__________________
Great Mambo Hosting -- http://www.buyhttp.com
My Site: http://www.tonyscida.com
tonyskyday is offline   Reply With Quote
Old June 19th, 2004, 16:45   #5
troozers
 
troozers's Avatar
 
Join Date: Oct 2003
Location: Northampton, UK
Posts: 490
troozers is on a distinguished road
Default my thoughts too

that's the way I was thinking of it too... or a combination of component/mosbot.... I have already started parts of it already - I will keep you posted here on how I get on.
__________________
Andy Stewart
http://www.troozers.com
troozers is offline   Reply With Quote
Old June 19th, 2004, 17:11   #6
Casinnola
 
Join Date: Jun 2004
Posts: 10
Casinnola is on a distinguished road
Default

w00t

Thanks again, I look forward to seeing it.

And just so you know... it will save me close to 45 minutes every week of copy/pasting content into MS Word so I can get the word count.
Casinnola is offline   Reply With Quote
Old June 20th, 2004, 08:54   #7
stingrey
 
Join Date: Oct 2003
Location: Marikina, Manila, Philippines
Posts: 5,153
stingrey is on a distinguished road
Default

Keep us posted on how you go troozers, cause now created a generic "code engine" for my mosbots, that allow me to customise and change it fairly quickly to show different output. So it would be fairly easy for me to reconfigure my mosbot to do this.
And I have already completed work on a Display - Author & Date mosbot
(I am using it on my site www.stingrey.biz)

Plus I already have code in my Display News modules, that counts either characters or words in the intro and/or full text of articles.
It is used to power the
limit_title, limit_intro & limit_full parameters.
__________________
All my posts are copyright © Rey Gigataras [aka stingrey] and cannot be be reproduced without permission

Former Mambo Core Team Member July 2004 - August 2005
stingrey is offline   Reply With Quote
Old June 20th, 2004, 09:06   #8
troozers
 
troozers's Avatar
 
Join Date: Oct 2003
Location: Northampton, UK
Posts: 490
troozers is on a distinguished road
Default update

Hi Cassinola & Stingrey,

So you can see what progress I am making, I have created the following --> http://www.troozers.net/The_News/Fun...hor_Statistics, which shows how I am getting on. It is currently a mambot still, but will be converted to a component once I have done some testing and finished a couple of items;

* Allow user to enter date range.

* Verify the word counting. There is a difference between what str_word_count( $row->text) and Microsoft Word say. I think the php function is counting special characters as well - so I am updating it to filter out these characters and also to strip out other mosbot calls such as {mosimage} and {mospagebreak}

ANY feed back or constructive critiscism is absolutely welcome.
__________________
Andy Stewart
http://www.troozers.com
troozers is offline   Reply With Quote
Old June 20th, 2004, 09:21   #9
stingrey
 
Join Date: Oct 2003
Location: Marikina, Manila, Philippines
Posts: 5,153
stingrey is on a distinguished road
Default

Thats looking pretty good troozers.


Quote:
Verify the word counting. There is a difference between what str_word_count( $row->text) and Microsoft Word say. I think the php function is counting special characters as well - so I am updating it to filter out these characters and also to strip out other mosbot calls such as {mosimage} and {mospagebreak}
If you need some filter code, in my Display News modules, in my dnl.functions.php file, there is a function called dnl_filter that I use to strip out all unneccessary markup and html code that affects word counts.
PHP Code:
/**---------------------------------------------------------------------**/
// Function to filter html code and special characters from text
function dnl_filter( &$text ) {
    
$text preg_replace("'<script[^>]*>.*?</script>'si","",$text);
    
$text preg_replace('/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is','\2 (\1)'$text);
    
$text preg_replace('/<!--.+?-->/','',$text);
    
$text preg_replace('/{.+?}/','',$text);
    
$text preg_replace('/&nbsp;/',' ',$text);
    
$text preg_replace('/&amp;/',' ',$text);
    
$text preg_replace('/&quot;/',' ',$text);
    
$text strip_tags($text);
    
$text htmlspecialchars($text);
}
//--------------------------------------------------------------------- 
__________________
All my posts are copyright © Rey Gigataras [aka stingrey] and cannot be be reproduced without permission

Former Mambo Core Team Member July 2004 - August 2005

Last edited by stingrey : June 20th, 2004 at 09:24.
stingrey is offline   Reply With Quote
Old June 21st, 2004, 04:45   #10
troozers
 
troozers's Avatar
 
Join Date: Oct 2003
Location: Northampton, UK
Posts: 490
troozers is on a distinguished road
Default that did it

excellent code tip there my stingrey, between your filters and mine I have gotten both Word and this component to report exactly the same figures per story.

The exception, and there are always some, is when the story contains a LOT of code fragments (which some of my stories do). For example I have an article called Mosviewonly & Events Component which has some coding tips on how to get mosviewonly working with Eric Lamette's Event component. This component reports 1077 and Word 761... I dont know how much of an issue this is, or who is more correct in this example.

You can now choose the dates to query on, it will default the dates as; From: (today - 2 weeks), and To: (today)

Unfortunately you need to be signed on to use the calendar picker as the function showCalendar is initiated within mambojavascripts.js - you can however still manually enter dates if you are not signed on.

What do you think? I am moving some of the code over to a mosbot called {moswordcount} which can be included in an article to show how many words are in that article.
__________________
Andy Stewart
http://www.troozers.com

Last edited by troozers : June 21st, 2004 at 06:05.
troozers is offline   Reply With Quote
Old June 21st, 2004, 06:27   #11
Casinnola
 
Join Date: Jun 2004
Posts: 10
Casinnola is on a distinguished road
Default

troozers, it sounds awesome! i can't wait to give it a try on my site! thanks again for doing it
Casinnola is offline   Reply With Quote
Old June 21st, 2004, 06:40   #12
troozers
 
troozers's Avatar
 
Join Date: Oct 2003
Location: Northampton, UK
Posts: 490
troozers is on a distinguished road
Default over to you

OK,

I think it is time to send over to you now, cassinola, to test. I will create an installation script later on today. Can you send me a private message with your email address on so I can send it to you?
__________________
Andy Stewart
http://www.troozers.com
troozers is offline   Reply With Quote
Old June 21st, 2004, 07:37   #13
stingrey
 
Join Date: Oct 2003
Location: Marikina, Manila, Philippines
Posts: 5,153
stingrey is on a distinguished road
Default

Quote:
excellent code tip there my stingrey, between your filters and mine I have gotten both Word and this component to report exactly the same figures per story.
Could you post or email me (use the ocntact us form on my website) the filter code you used.

--------------------------------

Quote:
I am moving some of the code over to a mosbot called {moswordcount} which can be included in an article to show how many words are in that article.
Good stuff

--------------------------------
__________________
All my posts are copyright © Rey Gigataras [aka stingrey] and cannot be be reproduced without permission

Former Mambo Core Team Member July 2004 - August 2005
stingrey is offline   Reply With Quote
Old June 21st, 2004, 07:58   #14
troozers
 
troozers's Avatar
 
Join Date: Oct 2003
Location: Northampton, UK
Posts: 490
troozers is on a distinguished road
Default filter code

no problem, below is the filter code..... it is none too sophisticated as I went with the general rule "why run it through one filter, when you can run it through many?"

I was hoping at least this way I should capture most of the little critters before they reach the end.... as a theory it seems to work


PHP Code:
function cleanupText$text )
{
    
$pattern "/[^(\w|\d|\'|\"|\.|\!|\?|;|,|\\|\/|\-\-|:|\&|@)]+/";

    
$text str_replace"{mosimage}"""$text );
    
$text str_replace"{mospagebreak}"""$text );
    
$text str_replace"{moswordcount}"""$text );
    
$text strip_tags$text );
    
$text preg_replace ($pattern" "$text);
    
$text trim($text);

    
$text preg_replace("'<script[^>]*>.*?</script>'si","",$text);
    
$text preg_replace('/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is','\2 (\1)'$text);
    
$text preg_replace('/<!--.+?-->/','',$text);
    
$text preg_replace('/{.+?}/','',$text);
    
$text preg_replace('/&nbsp;/',' ',$text);
    
$text preg_replace('/&amp;/',' ',$text);
    
$text preg_replace('/&quot;/',' ',$text);    
    
$text strip_tags($text);
    
$text htmlspecialchars($text); 

    return 
$text;

__________________
Andy Stewart
http://www.troozers.com
troozers is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
updated version -> Version 1-2 of Display News Modules stingrey Modules 43 August 22nd, 2005 21:11
I want all the news categories / items on a single page diehlr General Questions 5 June 24th, 2005 09:16
One thing I want Johnboat 4.5.1 0 September 14th, 2004 12:30
Dynamically pull news items into main menu MamboKC General Questions 0 August 10th, 2004 11:18
updated version -> Version 1-2 of Display News Modules stingrey Open Source Products for Mambo 0 April 3rd, 2004 03:35


All times are GMT -7. The time now is 07:25.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.