1 (edited by Developer 2018-03-31 00:07:28)

Topic: A couple of fixes v2.1.1

Good afternoon. I saw that my thoughts and amendments, which I indicated in this message, were added to the release.
However, I noticed that some of my suggestions were added to the release as is.
In this case, some parts of the code will not work or will not work correctly.
I apologize for not specifying what is an assumption, and what is the correction of errors.
Today I want to clarify all the points, and also make some critical amendments.
All the code specified in this message can be used as is. This is not an assumption, but a fix option.



[fonts]
First of all, I want to note that there was a problem with loading fonts.
The "glyphicons" family placed not where they shuld.
For this time , they are located in (\libs\fonts\) with "fontawesome" fons.
And if "fontawesome" they are all right, then "glyphicons" not on worked place.
In version 2.1.0 - theme and skins has been changed and (bootstraps.css)
was moved to (\libs\css\themes\NAME).
But the font loading still refers to the (..\fonts\) directory from (bootstraps.css).
So it turns out that the "glyphicons" fonts should be located at (\libs\css\themes\fonts\).
There are two solutions.
1. The first is to move the fonts to worked place.
2. The second is rewrite all bootsrap.
From my point of view, that in the future not to get confused, it is easier to transfer fonts.
If you want to store all fonts in the same directory, then you should place all css
at the same level of relative distance to the fonts.


Now about code.

[/core/core.php] 1361
Corrected the output template for the function msg_info()
Corrected in connection with bootstrap

    echo '<section><div class="container"><div class="alert alert-warning">';
    echo '<strong>'.i18n('Warning!').' </strong> '.i18n($title).' <a href="'.$go_back.'" class="btn btn-warning btn-xs">OK</a>';
    echo '</div></div></section>'; 


[/core/core.php] 1429
When I described adding the Login button to the menu,
I did not want that you add the button itself,
but suggested that you shuld install the Hook in that place, to adapt the menu.
Without a separate wrapper with pre-processing the "?Login" value, such link is useless.
I wrote a small hook, similar to the hook for an authorized menu to fix this issue.
I checked it for work and I already wrote a plug-in for expanding the menu for my needs.
You may add it to release.

 // Make 'Top menu' for Guests
// Create a HOOK 'core/headermenu' and add One hided <li> menu.
// User may add new one with adding to the hook   ARRAY('#URL','TITLE');   

    $headermenu = hook('core/headermenu', array ('version' => array()));
    $menu_result = '';    
    foreach ($headermenu as $menu_key => $vol)
    {
        $menu_target = isset($vol[0]) ? $vol[0] : false;
        $menu_title = isset($vol[1]) ? $vol[1] : false;
        
        if (($menu_target) && ($menu_target[0] == '#')) {
            $menu_target = substr($menu_target, 1);
        } else {
            $menu_target = PHP_SELF;
        } 

        if ($menu_title) {
            $menu_result .= '<li><a class="nav-top-item" href="'.$menu_target.'">'.i18n($menu_title).'</a></li>';
        } else {
            $menu_result .= '<!--li><a class="nav-top-item" href="'.PHP_SELF.'">'.VERSION_NAME.'</a></li-->';
        }
    }    

    if (isset($_SESSION['user']))
    {
         $skin_header = preg_replace("/{menu}/", $skin_menu, $skin_header);
    }
    else 
    {
        $skin_header = preg_replace("/{menu}/", $menu_result, $skin_header);
    }


[/core/core.php] 3888
Now about redirection.
in the last message  i told about reassign PHP_SELF.
I gave an example of the code for the case with the Disabled overwrite module.
However, you should also add a reassignment in case if the module is enabled.
This is necessary for the correct formation of links in the case of using "cn_rewrite_url" value.
In my case, I wrote a wrapper for dashboard, search, news and plug-ins in one script.
So I redirect all requests to one script. And I have both variants of events
like working with redirection through "cn_rewrite_url"
and working with GET \ POST directly with the script.
Otherwise, if you do not reassign PHP_SELF, then 'show_news.php' script  may not get $PHP_SELF values.

        define('CN_REWRITE', $layout);                    
        if (isset($PHP_SELF)) 
        {
            define('PHP_SELF', $PHP_SELF);
        } 
        else 
        {
            define('PHP_SELF',  pathinfo(str_replace($basedir, '', $layout),PATHINFO_BASENAME));
        } 



[core/modules/dashboard.php] 415
The problem with overriding PHP_SELF and finding the cause of incorrect links
caused me to look at entire rewriting module.
And I found another inaccuracy in the code.
When apply rewrite settings and generating ".htaccess" file ,
the redirection is written to show_news.php script.
But in case we use a wrapper that we specify in
the field ('Real path to your layout file'),
is still written a standard value of show_news.php  to the ".htaccess" file.
This is because in the code there is no validation and no substitution with layout.
Below is the code correcting this critical error.
In my case, in the past and now, I was manual  rewrite in ".htaccess".
But I decided to deal with problem and  fix this bug.

             if ($URI == '/') 
            {
                $URI = '/show_news.php'; 
            }
            else 
            {
                if (!empty($post_cfg['rw_layout'])) 
                {
                    $URI .= '/'.basename($post_cfg['rw_layout']);
                } 
                else 
                {
                    $URI .= '/show_news.php';
                }
            }



[core/modules/dashboard.php] 560
Another small problem was checking the Avatar when updating user data.
In order to save the data, we had to constantly substitute the avatar.
And half the verification code, just did not work.
Here is fix.

         $correct = (empty($avatar_file['tmp_name']))? true : false;



[/core/news.php] 261
Now about Hook for redefining the link to the user's questionnaire.
In my last mesage, I gave an example of how I use links to access a custom module. And suggested to setting up Hook there.
But inserting a link to the code without my module was a mistake. Without custom module, that link will not work.
I bring the ready-made code for the link-formation of the Hook Overriding.
In the code below, for example, the hook value is specified to invoke the author search.
Of course, only if a search script is initiated on the page.
thus calling a hook, any custom module can form a flexible link.
By the way, search by authors is not working. I have not looked yet for a reason, but i will if ill got time.

     // user allow to show his email?
    if (isset($user['e-hide']) && $user['e-hide'])
    {
        if (db_user_by_name($e['u'])) {
        // Users can modify URL template for make custom querry
        //  by returning modified data from hook('news/authorurl')             
            $authorurl = hook('news/authorurl', '?dosearch=yes&user=');
            return '<a href="' . PHP_SELF . $authorurl . $e['u'] . '">' . $username . '</a>';
        } else {
            return $username;
        }
    }
    else
    {
        return cn_user_email_as_site($user['email'], $username);
    }

Re: A couple of fixes v2.1.1

Below is an improved version of the bootstrap templates. Including navigation and all other templates.

#bootstrap
*active
   <div class="container">
       <div class="panel panel-default">
           <div class="panel-heading "  style='padding:5px;'>
               <div class="row">
                     <div class="col-xs-12 col-sm-3 col-md-2" style='padding:0px 5px;'>
                          <div class="col-xs-2 col-sm-4" style='padding:0px 5px;'>{avatar}</div>
                          <div class="col-xs-10 col-sm-8 text-center" style='padding:0px 5px;'>{date}<br />
                          [ {author} ]
                          </div>
                     </div> 
                     <div class="col-xs-12 col-sm-8 col-md-10 text-left" style='padding:5px;'>
                          <span class="h3">[link]{title}[/link]</span>
                     </div>
               </div>
           </div>
           
           <div class="panel-body">
                 {short-story}
           </div>
           
             <div class="panel-footer">
                <div class="row">
                      <div class="pull-left"  style="padding:2px;">
                          [full-link target=_blank]<button type="button" class="btn btn-primary btn-xs"><span class="glyphicon glyphicon-eye-open"> </span> Read more </button>[/full-link]
                          [com-link]<button type="button" class="btn btn-success btn-xs"><span class="glyphicon glyphicon-education"> </span> comments: {comments-num}</button>[/com-link]
                          [print]<button type="button" class="btn btn-info btn-xs"><span class="glyphicon glyphicon-print"> </span> print</button>[/print]
                      </div>
                    <div class="pull-left"  style="padding:2px;">{twitter}</div>
                    <div class="pull-left"  style="padding:2px;">{gplus}</div>
                     <div class="pull-left"  style="padding:2px;">{fb-like}</div>
           
                </div>  
               <div class="row">
                   <div class="col-xs-12"><strong>{tagline}</strong></div>
                   </div>
               </div>

           </div>
       </div>
   
*full

<div class="container">
       <div class="panel panel-default">
           <div class="panel-heading "  style='padding:5px;'>
               <div class="row">
                     <div class="col-xs-12 col-sm-3 col-md-2" style='padding:0px 5px;'>
                          <div class="col-xs-3 col-sm-5" style='padding:10px;'>{avatar}</div>
                          <div class="col-xs-9 col-sm-7 text-center" style='padding:0px 5px;'>{date}<br />
                              [ {author} ]<br />
                            [com-link]<button type="button" class="btn btn-success btn-xs"><span class="glyphicon glyphicon-education"> </span> comments: {comments-num}</button>[/com-link]
                          </div>
                     </div> 
                     <div class="col-xs-12 col-sm-8 col-md-10 text-left" style='padding:5px;'>
                          <span class="h3">[link]{title}[/link]</span>
                     </div>
               </div>
           </div>
           
           <div class="panel-body">
                 {full-story}
           </div>
           
             <div class="panel-footer">
                <div class="row">
                      <div class="pull-left"  style="padding:2px;">
                          [print]<button type="button" class="btn btn-info btn-xs"><span class="glyphicon glyphicon-print"> </span> print</button>[/print]
                      </div>
                    <div class="pull-left"  style="padding:2px;">{twitter}</div>
                    <div class="pull-left"  style="padding:2px;">{gplus}</div>
                     <div class="pull-left"  style="padding:2px;">{fb-like}</div>
           
                </div>  
                   <div class="row">
                   <div class="col-xs-12 col-sm-12"><strong>{tagline}</strong></div>
                   </div>
                   </div>
                 <div class="row">
                       <div class="col-xs-12 col-sm-12">{fb-comments}</div>
                   </div>
           </div>
       </div>

*comment

   <div class="container">
       <div class="panel panel-default">
           <div class="panel-heading">[delete]%cbox[/delete] by <strong>{author}</strong> @ {date} [edited](<i>Edited: %edited</i>)[/edited] [edit][Edit comment][/edit]
           </div>
           <div class="panel-body">{comment}
           </div>
       </div>
   </div>


*form

   <div class="container">
       <div class="panel panel-default panel-footer col-xs-12 col-md-4 col-sm-6 "><br />
           {remember_me}<br />
           &ensp; {input_username} {input_email} {input_commentbox} {smilies}<br />
           <br>[captcha]{captcha}[/captcha]<br />
           [submit]Add comment[/submit]<br />
           &ensp;
       </div>
   </div>

*prev_next

    <div class="text-center">   
        [prev-link]<button type="button" class="btn btn-primary btn-xs"><span class="glyphicon glyphicon-triangle-left"> </span> Previous page</button>[/prev-link]
        <span class="h4"><strong>{pages}</strong></span> 
        [next-link]<button type="button" class="btn btn-primary btn-xs"> Next page <span class="glyphicon glyphicon-triangle-right"></span> </button>[/next-link]
    </div>


*comments_prev_next
   
     <div class="text-center">   
        [prev-link]<button type="button" class="btn btn-primary btn-xs"><span class="glyphicon glyphicon-triangle-left"> </span> Previous page</button>[/prev-link]
        <span class="h4"><strong>{pages}</strong></span> 
        [next-link]<button type="button" class="btn btn-primary btn-xs"> Next page <span class="glyphicon glyphicon-triangle-right"></span> </button>[/next-link]
    </div>


*search

   <div class="container">
       <div class="panel panel-default panel-footer col-xs-12 col-md-4 col-sm-6 "><br />
            <form action="{php_self}" method="GET" class="form cn_search_form">
                 <div>{search_basic} Author: {author} {in_archives} In archives</div>
                 <div>{select=year:from} {select=mon:from} {select=day:from} &ndash; {select=year:to} {select=mon:to} {select=day:to}</div>
                 <div>[submit]Search[/submit]</div>
            </form>
         </div>
     </div>


 

3 (edited by Developer 2018-03-30 08:33:09)

Re: A couple of fixes v2.1.1

*tagline
       <a href="{url}" target="_blank" class="cn_tag_item{tag:selected| cn_tag_selected}"><button type="button" class="btn btn-default btn-xs">{tag}</button></a>{comma| }

*print
   <html>
       <head>
           <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
       </head>
       <body bgcolor="#ffffff" text="#000000" onload="window.print()">
          <strong>{title} @ <small>{date}</small></strong>
          <hr/>{full-story}<hr/>
          <small>News powered by CuteNews - http://cutephp.com</small>
       </body>
   </html>

I apologize for sending everything not in one message.
If the code contains links, you can not send everything in one. Restriction on the forum.

I hope my code and tips do not stay in the shadows. I will be happy if they are useful.

Re: A couple of fixes v2.1.1

Its very useful, I will test it! thanks