Slightly Some

Nucleus core bugs/change suggestions

By: Leo
04/03-11, 01:50
Category: Code
Nucleus CMS

During the making of the skin and template for this blog, I found some problems with the Nucleus core. These problems have I reported as bugs or change suggestions on the Nucleus forum.

This post is mostly for me to track these bugs and change suggestions. The individual bugs and change suggestions are described, and the source code updated with my changes can be downloaded.

Fancy url keywords not used for "extra" parameters

Fancy url's generated by Nucleus don't use configured fancy url keywords for "extra" parameters when Fancy URL mode is set in global setting. The correct keywords is used for the main parameters for each link type, but if you have extra parameters the internal name of the parameter is used as keyword.

Status: Reported as a bug in Nucleus v3.62. Update 2011-06-25: This was fixed in Nucleus v3.64.

Example

The default keywords for some of the parameters are:

$CONF['ArchiveKey'] = 'archive';
$CONF['ArchivesKey'] = 'archives';
$CONF['BlogKey'] = 'blog';
$CONF['CategoryKey'] = 'category';

Category links on the main index page is generated as: "/category/11/blogid/1", should be "/category/11/blog/1"

Category links on the archivelist page is generated as: "/category/10/archivelist/1", should be "/category/10/archives/1"

On archivelist page with active category, a link to a month archive is generated as: "/archive/1/2011-01/catid/10", should be "/archive/1/2011-01/category/10"

Code change suggestion

This can be fixed by changing line 1592 in globalfunctions.php from:

$link .= '/' . $param . '/' . urlencode($value);
to:
switch ($param) {
      case 'itemid':
            $link .= '/' . $CONF['ItemKey'] . '/' . urlencode($value);
            break;

      case 'memberid':
            $link .= '/' . $CONF['MemberKey'] . '/' . urlencode($value);
            break;

      case 'catid':
            $link .= '/' . $CONF['CategoryKey'] . '/' . urlencode($value);
            break;

      case 'archivelist':
            $link .= '/' . $CONF['ArchivesKey'] . '/' . urlencode($value);
            break;

      case 'archive':
            $link .= '/' . $CONF['ArchiveKey'] . '/' . urlencode($value);
            break;

      case 'blogid':
            $link .= '/' . $CONF['BlogKey'] . '/' . urlencode($value);
            break;

      default:
            $link .= '/' . $param . '/' . urlencode($value);
            break;
}

Special skin part fancy url's not working

Special skin part fancy url's (like /special/name) don't work when Fancy URL mode is set in global setting. Just shows blog index page.

Status: Reported as a bug in Nucleus v3.62. Update 2011-06-25: This was fixed in Nucleus v3.64.

Code change suggestion

Can be fixed by changing line 500 in globalfunctions.php from:

$_REQUEST['special'] = $data[$i];

to:

$special = $data[$i];

catiscurrent template variable in comment header

The catiscurrent template variable can be used in in the category list item section in a template to be able to style a category different when it's active. I want a similar possibility in the category list header when no categories are active.

In my category list header I have a link that shows all categories. This link I want to style differently when no category is active.

One way to obtain this is to make it possible to use the catiscurrent template variable in category list header (and footer). The catiscurrent should then be "yes" in the header/footer if no category is active.

Status: Reported as a change suggestion for Nucleus v3.62. Update 2011-06-25: This changes was included in Nucleus v3.64.

Code change suggestion

Here is my suggestion for a showCategoryList function in BLOG.php that implements this. My changes are commented with "//:".

function showCategoryList($template) {
   global $CONF, $manager;

   // determine arguments next to catids
   // I guess this can be done in a better way, but it works
   global $archive, $archivelist;

   $linkparams = array();
   if ($archive) {
      $blogurl = createArchiveLink($this->getID(), $archive, '');
      $linkparams['blogid'] = $this->getID();
      $linkparams['archive'] = $archive;
   } else if ($archivelist) {
      $blogurl = createArchiveListLink($this->getID(), '');
      $linkparams['archivelist'] = $archivelist;
   } else {
      $blogurl = createBlogidLink($this->getID(), '');
      $linkparams['blogid'] = $this->getID();
   }

   //$blogurl = $this->getURL() . $qargs;
   //$blogurl = createBlogLink($this->getURL(), $linkparams);

   $template =& $manager->getTemplate($template);

   //: Change: Set nocatselected variable
   if ($this->getSelectedCategory()) {
      $nocatselected = 'no';
   }
   else {
      $nocatselected = 'yes';
   }
   
   echo TEMPLATE::fill((isset($template['CATLIST_HEADER']) ? $template['CATLIST_HEADER'] : null),
                  array(
                     'blogid' => $this->getID(),
                     'blogurl' => $blogurl,
                     'self' => $CONF['Self'],
                     //: Change: Set catiscurrent template variable for header
                     'catiscurrent' => $nocatselected,
                     'currentcat' => $nocatselected
                  ));

   $query = 'SELECT catid, cdesc as catdesc, cname as catname FROM '.sql_table('category').' WHERE cblog=' . $this->getID() . ' ORDER BY cname ASC';
   $res = sql_query($query);


   while ($data = sql_fetch_assoc($res)) {
      $data['blogid'] = $this->getID();
      $data['blogurl'] = $blogurl;
      $data['catlink'] = createLink(
                     'category',
                     array(
                        'catid' => $data['catid'],
                        'name' => $data['catname'],
                        'extra' => $linkparams
                     )
                     );
      $data['self'] = $CONF['Self'];
      
      //catiscurrent
      //: Change: Bugfix for catiscurrent logic so it gives catiscurrent = no when no category is selected.
      $data['catiscurrent'] = 'no';
      $data['currentcat'] = 'no';

      if ($this->getSelectedCategory()) {
         if ($this->getSelectedCategory() == $data['catid']) {
            $data['catiscurrent'] = 'yes';
            $data['currentcat'] = 'yes';
         }
      }
      else {
         global $itemid;
         if (intval($itemid) && $manager->existsItem(intval($itemid),0,0)) {
            $iobj =& $manager->getItem(intval($itemid),0,0);
            $cid = $iobj['catid'];
            if ($cid == $data['catid']) {
               $data['catiscurrent'] = 'yes';
               $data['currentcat'] = 'yes';
            }
         }
      }

      $manager->notify(
         'PreCategoryListItem',
         array(
            'listitem' => &$data
         )
      );

      echo TEMPLATE::fill((isset($template['CATLIST_LISTITEM']) ? $template['CATLIST_LISTITEM'] : null), $data);
      //$temp = TEMPLATE::fill((isset($template['CATLIST_LISTITEM']) ? $template['CATLIST_LISTITEM'] : null), $data);
      //echo strftime($temp, $current->itime);

   }

   sql_free_result($res);

   echo TEMPLATE::fill((isset($template['CATLIST_FOOTER']) ? $template['CATLIST_FOOTER'] : null),
                  array(
                     'blogid' => $this->getID(),
                     'blogurl' => $blogurl,
                     'self' => $CONF['Self'],
                     //: Change: Set catiscurrent template variable for footer
                     'catiscurrent' => $nocatselected,
                     'currentcat' => $nocatselected 
                  ));
} 

I use this change here on my blog to highlight the "All Categories" link when there are no active category.

Parameters for itemtitle comment template variable

In the item part of a template you have the "title" variable. This variable have some parameters (which is undocumented). Among these is the attribute parameter: <%title(attribute)%>. This will sanitize the title for use in html tag attributes.

In the comments part of a template you have the "itemtitle" variable. This variable don't have the attribute parameter, but there is still need to use the itemtitle variable in a html tag attribute in the comment section of a template. Because of this I would like to be able to use the attribute paramter also on the itemtitle template variable.

Status: Reported as a change suggestion for Nucleus v3.62. Update 2011-06-25: No change as of Nucleus v3.64.

Example

With a template code like this:

<a href='<%itemlink%>' title="Read entry: <%title(attribute)%>"><%title%></a>

the resulting html for an item title like Example > "Test" will be:

<a href='http://xxxxx/article/2011/03/example--test' title="Read entry: Example &gt; &quot;Test&quot;">Example > "Test"</a>
Code change suggestion

Here is my suggestion to for a parse_itemtitle function in COMMENTACTIONS.php that will implement this change:

function parse_itemtitle($param = '') {
   if (is_numeric($param)) {
      $maxLength = intval($param);
      $this->commentsObj->itemActions->parse_syndicate_title($maxLength);
   } else {
      $this->commentsObj->itemActions->parse_title($param);
   }
}

Download

Updated source code files for Nucleus v3.62 can be downloaded here.

Updated source code files for Nucleus v3.64 can be downloaded here.

Add new comment

Allowed BBCode:[b] [i] [u] [s] [color=] [size=] [quote] [code] [email] [url]

Comments must be approved before being published.

nucleuscms.org
Valid XHTML
Creative Commons License

Unless otherwise specified is all original material on this website licensed under a Creative Commons License.

Baronial