Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
pat_amazon_isbn
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: pat_amazon_isbn
Pat64 wrote:
what a cool website and even cooler plugin.
PS why when we go to http://cara-tm.com does an opinion poll start-up? did you intend this?
Last edited by bici (2013-11-19 06:15:18)
…. texted postive
Offline
Re: pat_amazon_isbn
Free lite version added (only redirect to Amazon Spanish stores).
Check the plugin website.
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: pat_amazon_isbn
FYI: Textpattern shows a preview of a plugin’s code before the user finally installs it in her system. This is done with the intention to find malevolent plugin code before it even touches a site’s database.
The plugin advertised in this thread contains obfuscated PHP code. Users cannot read all of its code in the plugin preview stage mentioned above and thus will have to jump through extra hoops to learn about it’s real inner workings.
Personally I cannot think of any sensible reason why the author chose to use this uncommon method of code distribution.
Offline
Re: pat_amazon_isbn
wet wrote:
Personally I cannot think of any sensible reason why the author chose to use this uncommon method of code distribution.
Hi Robert
The plugin is now free for download. And there is no obfuscated PHP code in it.
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: pat_amazon_isbn
I don’t see issues in distributing obfuscated plugin packages. If you want to do that, its fine. It’s your right, as long as you follow GNU General Public License version 2 terms. Selling plugins is fine too.
The plugin code contains:
@license: commercial
What is this mentioned “commercial” license? I don’t see terms. This license should be, no matter whether the plugin is commercial or not, GPLv2 (or compatible).
To comment on the source itself:
$isbn = implode( '', explode('-', $number) );
Is same as str_replace('-', '', $number);
used elsewhere in the code.
function validate_url ($host)
…function validate_isbn ($isbn)
Both function definitions should either be prefixed or namespaced to avoid conflicts and collisions. Plugins should never defined elements in global namespace without it being prefixed with your plugin author prefix.
trigger_error('error with the url attribute', E_USER_WARNING);
Textpattern has a localized error string for invalid attributes you can use, I believe.
$host = parse_url($host);
preg_match('/(.*?)((\.co)?.[a-z]{2,4})$/i', $host['host'], $m);
$link = isset($m[2]) ? 'http://www.amazon'.$m[2].'/dp/' : trigger_error('error with the url attribute', E_USER_WARNING);
That seems rather strange. It works as long as processed domains are limited, but still seems strange to openly parse the tld to only use hard-coded amazon as the TLD. I would rather just ask a TLD from the user and then use that as the target.
@param:
These look like docblocks, but they aren’t. The comment syntax many PHP projects use, including Textpattern, is an actual syntax and is used by IDE and to generate API documentation, opposed to being stylistically chosen. For instance the comment for validate_url
could look like:
/**
* Validates and builds an URL.
*
* Extracts the TLD extension from the given URL, and
* uses it to create a link to a specific international Amazon
* store.
*
* @param string $host The Amazon store URL
* @return string URL to the Amazon store based on the given $host extension
*/
Formatted according the PHPdoc spec:
- DocBlocks are indicated with
/**
opening. They are their own comment type in PHP. - First paragraph is short description. Should be single liner, short. Usually used as a tag line or as a tooltip in documentation pages and IDEs.
- Long description, separated by empty line. Describes the element in question. Can use limited set of HTML formatting.
- Tags such as param and return, documenting arguments and returned values.
Last edited by Gocom (2013-11-21 10:23:44)
Offline
Pages: 1