Powered By Links

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Powered By Links

Post by cmb » Thu Dec 11, 2014 11:13 pm

Oops, I just noticed that we're in the Open Development forum, so we'd better try to communicate in English, as this topic is likely to be relevant not only for German speakers.
svasti wrote:Hatte noch gar nicht gesehen, dass php einige Funktionen zum Lesen des ini-Formats bereit stellt.
Yes, it does, but it seems to me there is a flaw: parse_ini_file() seems (I have not yet investigated closer) to evaluate defined constants. That might lead to unexpected behavior.
svasti wrote:Ich finde es jedenfalls viel einfacher zu erstellen und zu verwalten als das XML-Format. Die Dateien kann man ja ganz einfach im Editor schreiben.
Well, you can write XML in a text editor, too. I'm not a fan of XML for data storage, because IMO it's too bloated a format for that matter. However, it might be easy to read and write for those fluent with HTML, and it allows to be checked for validity (not only well-formedness).
svasti wrote:Darum schlage ich vor, auch die Plugin-Info-Dateien im selben Format zu halten.
As I already said, I'm not against it, but we better make sure that ini is flexible enough for our purposes (opposed to XML and some other formats it's rather limited).

BTW: there is an interesting article about Data File Metaformats available.
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1659
Joined: Wed Dec 17, 2008 5:08 pm

Re: Powered By Links

Post by svasti » Sat Dec 27, 2014 11:12 pm

As I have released a few new templates now, ... thinking about the new developer link ... and trying out some code.

Please check my site and click "Powered By"

Only 1 template has a template.nfo.
The template.nfo is an .ini-file starting with the name of the template. The rest of the file is free. No required values, just enter what you think necessary:

[my template]
key = value
next key = next value
...

The contents of the used template.nfo is:
[blog0]
© = "2014 by <a href='http://svasti.de'>svasti</a>"
licence = not published, used only here

I experimented a bit with the .ini- format. There are a reserved chars, namely ?{}|&~![()^"<> (contrary to the php-docu <> seems to be reserved!), these chars however can be set inside " ".
Otherwise all uft-8 chars seem to be possible as key and as value (I even checked Devanagari and it works)

The code in the cms.php is enlarged from Christophs code

Code: Select all

if ($su == uenc('Powered By')) {
    $f = $title = 'Powered By';
    $s = -1;
    $o .= '<h1>' . $title . '</h1>' . tag('br')  //line changed
        . XH_poweredBy();
}

function XH_poweredBy()
{
    global $cf, $tx, $pth;   //line changed

    $o = '<h5>CMS</h5><ul><li><a href="http://cmsimple-xh.org">'  //line changed
        . CMSIMPLE_XH_VERSION . '</a></li></ul></p>';
    $defaulttpl = $tx['subsite']['template'] == ''
        ? $cf['site']['template']
        : $tx['subsite']['template'];

//following part greaty enlarged
    $tpltext = '';
    foreach (XH_templates() as $template) {
        
        $tpltext .= $defaulttpl == $template
            ? '<li><strong>Default template: ' . ucfirst($template) . '</strong>'
            : '<li>' . ucfirst($template);
        if(is_file($pth['folder']['templates'] . '/' . $template . '/template.nfo')) {
            $tplinfo = parse_ini_file($pth['folder']['templates'] . '/' . $template . '/template.nfo');
            $tplinfotext = '';
            foreach ( $tplinfo as $key=>$value) {
                $tplinfotext .= $key . ': ' . $value . tag('br');
            }
            if($tplinfotext) $tpltext .= '<p>' . $tplinfotext . '</p>';
        }
        $tpltext .= '</li>';
    }

    $o .= '<h5>Templates</h5><ul>' . $tpltext . '</ul>';  //line changed
    $o .= '<h5>Plugins</h5><ul>';                                   //line changed
    foreach (XH_plugins() as $plugin) {
        $url = XH_pluginURL($plugin);
        if ($url) {
            $o .= '<li><a href="' . $url . '">' . ucfirst($plugin)
                . '</a></li>';
        }
    }
    $o .= '</ul>';
    return $o;
}

function XH_pluginURL($plugin)
{
    global $pth;

    $internalPlugins = array(
        'filebrowser', 'meta_tags', 'page_params', 'tinymce', 'utf8', 'jquery', 'hi_updatecheck',  //line changed
    );
    if (in_array($plugin, $internalPlugins)) {
        $url = false;
    } else {
        $filename = $pth['folder']['plugins'] . $plugin . '/version.nfo';
        if (is_readable($filename)) {
            $contents = file_get_contents($filename);
            $contents = explode(',', $contents);
            $url = $contents[5];
        } else {
            $url = false;
        }
    }
    return $url;
}

function poweredByLink()
{
    global $sn;

    return '<a href="' . $sn . '?' . uenc('Powered By') . '">'
        . 'Powered By' . '</a>';
}

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Powered By Links

Post by cmb » Sun Dec 28, 2014 12:39 pm

svasti wrote:As I have released a few new templates now, ... thinking about the new developer link ... and trying out some code.

Please check my site and click "Powered By"
Thanks for advancing this idea.

I wonder, though, what's the advantage of having a INI file with arbitrary keys over a simple text/HTML file. Further up in this thread you uttered some IMO valid concerns regarding potential misuse of such a free format. If I'm not mistaken this could be easily done with such an INI format as well.

Instead I would rather prefer a well defined format only accepting certain keys, and possibly restricting the content type (plain text vs. XHTML[1]) and perhaps the length of the values. Your former suggestion would be more in line with that:

Code: Select all

template.nfo Beispiel:
name=mini1
author=svasti
licence=GPL3
download=http://cmsimple-xh.org/?Downloads
based_on_template=
based_on_author=
based_on_download=
notice=This is a simple template containing all template functions of CMSimple_XH, so that template designers can understand how to use these functions. Feel free to build your own templates starting with this template.
de-notice=Dies ist ein einfaches Template mit allen Templatefunktionen von CMSimple_XH. Es dient dazu Templatedesignern zu zeigen, wie man diese Funktionen einsetzen kann. Es ist aus Ausgangspunkt zum Erstellen anderer Templates gedacht.
Maybe the based_on_* keys could be merged into a single key, and perhaps it would make sense to use sections for the localizations, either:

Code: Select all

[en]
based_on=...
notice=...
[de]
based_on=...
notice=...
or:

Code: Select all

[based_on]
en=...
de=...
[notice]
en=...
de=...
And maybe we don't need any internationalization at all?

[1] The "usual" subset of XHTML can be converted to HTML more easily than the other way round.
Christoph M. Becker – Plugins for CMSimple_XH

lck
Posts: 2967
Joined: Wed Mar 23, 2011 11:43 am
Contact:

Re: Powered By Links

Post by lck » Sun Dec 28, 2014 12:59 pm

svasti wrote:As I have released a few new templates now, ... thinking about the new developer link ... and trying out some code.

Please check my site and click "Powered By"
Very nice, I like it. But, that all templates are listed, including those who are not active I don't personally like. Sometimes, you want to test just a template, forgets it but then to delete.

Here are some suggestions for the "powered by" link:
Powered Info
Powered by Info
Powered by List
Powered by Information
Powered by Infopoint
Powered by quick info
Powered by info sheet
Powered by info desk
Powered by CMSimple_XH & more

License Info
License Information

Copyright Info
Copyright Information

Site Info
Site Information
Site powered by
Site powered by Information

Website powered by
Website powered by Information

CMSimple_XH behind
CMSimple_XH inside
CMS Information
CMSimple_XH-Plugins-Templates-Info
„Bevor du den Pfeil der Wahrheit abschießt, tauche die Spitze in Honig!“   👉 Ludwig's XH-Templates for MultiPage & OnePage

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Powered By Links

Post by cmb » Sun Dec 28, 2014 1:40 pm

Ludwig wrote:But, that all templates are listed, including those who are not active I don't personally like. Sometimes, you want to test just a template, forgets it but then to delete.
Well, the same holds for plugins, and it's impossible to find out which plugins are used and which aren't. And after all, having one or two templates listed that are not in use might not be a big problem. However, considering the sites of template designers, the list might get extremly long. :?
Ludwig wrote:Here are some suggestions for the "powered by" link:
Thanks. Considering all these possibilities, I tend to like "Site/CMS Info(rmation)" best.
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1659
Joined: Wed Dec 17, 2008 5:08 pm

Re: Powered By Links

Post by svasti » Sun Dec 28, 2014 4:27 pm

Ludwig wrote:But, that all templates are listed, including those who are not active I don't personally like.
+1, maybe one could go through the pagedata to check if a template is used?
Ludwig wrote:Here are some suggestions for the "powered by" link:
very nice!
cmb wrote:I tend to like "Site/CMS Info(rmation)" best.
me too. "Site Info" being the shortest and also very international, I have implemented it as a test in my site.
cmb wrote:Maybe the based_on_* keys could be merged into a single key,
+1
cmb wrote:what's the advantage of having a INI file with arbitrary keys
I am simply aquainting myself with the possibilities of this format, also in view of a future "plugins.nfo" etc. (ini-Keys may contain spaces, we don't have to use "_".)
A template.nfo with simple text, let's say up to 160 chars, only allowing html links and no other html/php special chars, would also be possible.
Just changed my Site to template.nfo with simple text + links only
cmb wrote:I would rather prefer a well defined format only accepting certain keys, and possibly restricting the content type (plain text vs. XHTML[1]) and perhaps the length of the values.
A well defined format makes life more orderly, but takes away some freedom and is more difficult to change when the need arises. Depends on how strict the format is.
cmb wrote:And maybe we don't need any internationalization at all?
+1 As this information is rather structured, just English may be sufficient. Makes life easier.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Powered By Links

Post by cmb » Sun Dec 28, 2014 4:44 pm

svasti wrote:+1, maybe one could go through the pagedata to check if a template is used?
Yes, that would be possible. However, there are other solutions to dynamically change the template, for instance with CMSimple scripting or with Templateswitch.
svasti wrote:I am simply aquainting myself with the possibilities of this format, also in view of a future "plugins.nfo" etc.
Ah, fine. :)
svasti wrote:ini-Keys may contain spaces, we don't have to use "_"
Interesting; never seen that in the wild. However, it might be useful to not overly rely on PHP's parse_ini_file(), but to allow broader support. Unfortunately, there is no commonly agreed standard regarding the INI format, so we might constrain ourselves to some minimum feature subset (whatever that'll be).
svasti wrote:
cmb wrote:I would rather prefer a well defined format only accepting certain keys, and possibly restricting the content type (plain text vs. XHTML[1]) and perhaps the length of the values.
A well defined format makes life more orderly, but takes away some freedom and is more difficult to change when the need arises. Depends on how strict the format is.
ACK. If we use an INI format (or another structured format, for that matter), we shouldn't define it too rigidly.
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1659
Joined: Wed Dec 17, 2008 5:08 pm

Re: Powered By Links

Post by svasti » Wed Jan 28, 2015 9:10 pm

Hi,

the Powered By Links has advanced a little bit further, see http://svasti.de

The call in the template is <?php echo poweredbylink()?>.
The link text can be changed, e.g.: poweredbylink('Wanna see the tech of this site?')
And you can add text on the page which is linked by creating a page with the name "Site/CMS Info".

The template.nfo contains plain text with link, bold, italic, underlined and strong marking allowed and not more than 160 chars.

So full flexibility... however until now unused templates also are listed.

If anybody wants to test, add in cms.php about 10 lines after the section beginning with // LEGAL NOTICES - not needed under GPL3

Code: Select all

if ($su == uenc('site/cms info')) {
    $f = $title = 'Site/CMS Info';
    $s = -1;
    $o .= '<h1>' . $title . '</h1>' . tag('br')
        . newsbox('Site/CMS Info')
        . XH_poweredBy();
}

function XH_poweredBy()
{
    global $cf, $tx, $pth;

    $o = '<h5>Content Management System</h5><ul><li><a href="http://cmsimple-xh.org">'
        . CMSIMPLE_XH_VERSION . '</a></li></ul></p>';
    $defaulttpl = $tx['subsite']['template'] == ''
        ? $cf['site']['template']
        : $tx['subsite']['template'];

    $tpltext = '';
    foreach (XH_templates() as $template) {

        $tpltext .= $defaulttpl == $template
            ? '<li><strong>Default template: ' . ucfirst($template) . '</strong>'
            : '<li>' . ucfirst($template);
        if(is_file($pth['folder']['templates'] . '/' . $template . '/template.nfo')) {
            $tplinfo = substr(strip_tags(file_get_contents($pth['folder']['templates']
                . '/' . $template . '/template.nfo'), '<a><b><i><u><em><strong>'), 0, 160);
            if($tplinfo) $tpltext .= '<p>' . $tplinfo . '</p>';
        }
        $tpltext .= '</li>';
    }

    $o .= '<h5>Templates</h5><ul>' . $tpltext . '</ul>';
    $o .= '<h5>Plugins</h5><ul>';
    foreach (XH_plugins() as $plugin) {
        $url = XH_pluginURL($plugin);
        if ($url) {
            $o .= '<li><a href="' . $url . '">' . ucfirst($plugin)
                . '</a></li>';
        }
    }
    $o .= '</ul>';
    return $o;
}


cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Powered By Links

Post by cmb » Wed Jan 28, 2015 11:28 pm

svasti wrote:the Powered By Links has advanced a little bit further, see http://svasti.de

The call in the template is <?php echo poweredbylink()?>.
The link text can be changed, e.g.: poweredbylink('Wanna see the tech of this site?')
And you can add text on the page which is linked by creating a page with the name "Site/CMS Info".

The template.nfo contains plain text with link, bold, italic, underlined and strong marking allowed and not more than 160 chars.
Very nice! :)

Code: Select all

$tplinfo = substr(strip_tags(file_get_contents($pth['folder']['templates']
                . '/' . $template . '/template.nfo'), '<a><b><i><u><em><strong>'), 0, 160); 
This might better use mb_substr() (or maybe utf8_substr) to avoid chopping Unicode code points in the middle, and to have a more accurate character count.
svasti wrote:If anybody wants to test, add in cms.php about 10 lines after the section beginning with // LEGAL NOTICES - not needed under GPL3
Note, that the function XH_pluginURL() has also to be defined, as in http://cmsimpleforum.com/viewtopic.php? ... =20#p45418.
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1659
Joined: Wed Dec 17, 2008 5:08 pm

Re: Powered By Links

Post by svasti » Thu Jan 29, 2015 12:10 am

cmb wrote:utf8_substr
yes, makes a big difference! Much better.
Now I find that 160 chars is too little, so I have set it to 400.
cmb wrote:that the function XH_pluginURL() has also to be defined
of course, I have it also in the cms.php

So corrected:

Code: Select all

if ($su == uenc('site/cms info')) {
    $f = $title = 'Site/CMS Info';
    $s = -1;
    $o .= '<h1>' . $title . '</h1>' . tag('br')
        . newsbox('Site/CMS Info')
        . XH_poweredBy();
}

function XH_poweredBy()
{
    global $cf, $tx, $pth;

    $o = '<h5>Content Management System</h5><ul><li><a href="http://cmsimple-xh.org">'
        . CMSIMPLE_XH_VERSION . '</a></li></ul></p>';
    $defaulttpl = $tx['subsite']['template'] == ''
        ? $cf['site']['template']
        : $tx['subsite']['template'];

    $tpltext = '';
    foreach (XH_templates() as $template) {

        $tpltext .= $defaulttpl == $template
            ? '<li><strong>Default template: ' . ucfirst($template) . '</strong>'
            : '<li>' . ucfirst($template);
        if(is_file($pth['folder']['templates'] . '/' . $template . '/template.nfo')) {
            $tplinfo = utf8_substr(strip_tags(file_get_contents($pth['folder']['templates']
                . '/' . $template . '/template.nfo'), '<a><b><i><u><em><strong>'), 0, 400);
            if($tplinfo) $tpltext .= '<p>' . $tplinfo . '</p>';
        }
        $tpltext .= '</li>';
    }

    $o .= '<h5>Templates</h5><ul>' . $tpltext . '</ul>';
    $o .= '<h5>Plugins</h5><ul>';
    foreach (XH_plugins() as $plugin) {
        $url = XH_pluginURL($plugin);
        if ($url) {
            $o .= '<li><a href="' . $url . '">' . ucfirst($plugin)
                . '</a></li>';
        }
    }
    $o .= '</ul>';
    return $o;
}

function XH_pluginURL($plugin)
{
    global $pth;

    $internalPlugins = array(
        'filebrowser', 'meta_tags', 'page_params', 'tinymce', 'utf8', 'jquery', 'hi_updatecheck',
    );
    if (in_array($plugin, $internalPlugins)) {
        $url = false;
    } else {
        $filename = $pth['folder']['plugins'] . $plugin . '/version.nfo';
        if (is_readable($filename)) {
            $contents = file_get_contents($filename);
            $contents = explode(',', $contents);
            $url = $contents[5];
        } else {
            $url = false;
        }
    }
    return $url;
}

function poweredByLink($linktext = '')
{
    global $sn;

    $linktext = $linktext ? $linktext : 'Site/CMS Info';
    return '<a href="' . $sn . '?' . uenc('site/cms info') . '">'
        . $linktext . '</a>';
}
 

Post Reply