Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Blocks
Author Message
testy1
Involved
Involved



Joined: Apr 06, 2008
Posts: 484

PostPosted: Sun Dec 14, 2008 4:46 pm Reply with quote

I've been looking at sommaire and the mess it is in and thought I would play around with it.I am attempting to fix it up but I am having trpouble understanding the following

Code:


$active[$row['title']] = $tempo['active'];


No I understand sort of but can someone explain exactly what is going on here, as normally I would define a variable to a particular field e.g.

Code:


$active = $row['active'];


I understand they are using arrays somehow but not sure what is really happening Sad

and here is the full code I am looking at

Code:


$sql = "SELECT * FROM ".$prefix."_modules WHERE active='1' AND inmenu='1' ORDER BY custom_title ASC";
   $modulesaffiche= $db->sql_query($sql);
   $compteur=0;
   while ($tempo = $db->sql_fetchrow($modulesaffiche)) {
      $module[$compteur] = $tempo['title'];
      $customtitle[$compteur] = $tempo['custom_title'];
      $view[$compteur] = $tempo['view'];
      $active[$row['title']] = $tempo['active'];
      $mod_group[$compteur] = ($gestiongroupe==1 && isset($tempo['mod_group'])) ? $tempo['mod_group'] : "";
      $nsngroups[$compteur]=(isset($tempo['groups'])) ? $tempo['groups'] : "" ; // NSN Groups
      $gt_url[$compteur]=(isset($tempo['url'])) ? $tempo['url'] : "" ; //GoogleTap-NextGen
      $compteur++;
      if ($tempo['view']==3) { $gestionsubscription="yes";}
   }
 
View user's profile Send private message
Palbin
Site Admin



Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania

PostPosted: Sun Dec 14, 2008 7:30 pm Reply with quote

$active is an array. $row['title'] is going to be the title of each of your modules as it cycles through.

$tempo is an array of the values of the row as queried here
Code:


$sql = "SELECT * FROM ".$prefix."_modules WHERE active='1' AND inmenu='1' ORDER BY custom_title ASC";
$modulesaffiche= $db->sql_query($sql);
$tempo = $db->sql_fetchrow($modulesaffiche)


So basically $tempo['active'] tell you if a certain module is active or not. (corresponding to the $row['title'])

So to get down to the root of it, the code is creating an array ($active) that contains an array of all the modules and if they are active or not. $row['title'] is the KEY and $tempo['active'] is the value of that key (1 or 0).

Hope I explained that good enough for you Dance-Y
 
View user's profile Send private message
testy1







PostPosted: Mon Dec 15, 2008 1:25 am Reply with quote

mmmmm ok, so can anyone see why Im getting

Quote:

undefined index title


and its in relation to this line

Code:


$active[$row['title']] = $tempo['active'];


I would have thought it should be

Code:


$active[$tempo['title']] = $tempo['active'];


But that doesnt fix it
 
testy1







PostPosted: Mon Dec 15, 2008 2:05 am Reply with quote

sorry

Code:


$active[$tempo['title']] = $tempo['active'];


the above fixed it Sad

on to the next one

Code:


$moduleinthisgroup[$som_groupmenu][$keyinthisgroup]


arrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrgh
 
Palbin







PostPosted: Mon Dec 15, 2008 6:29 am Reply with quote

Still undefined index? Or do you want to know about multi-dimensional arrays? If you want to know about multi-dimentional arrays just look them up on Google. If it is an error what is it?
 
testy1







PostPosted: Mon Dec 15, 2008 3:57 pm Reply with quote

Yer Ive never been one for regular expressions or arrays but it looks like I have to Sad
 
Dawg
RavenNuke(tm) Development Team



Joined: Nov 07, 2003
Posts: 928

PostPosted: Mon Dec 15, 2008 4:44 pm Reply with quote

Arrays are pretty easy....RE's on the other hand....are WAY over my head!

Sommaire....is a mess. I have played with mine a couple times and it is tough to mess with.

Dawg
 
View user's profile Send private message
testy1







PostPosted: Mon Dec 15, 2008 5:07 pm Reply with quote

yer simple arrays are fine but the multi-multi-multi-multi-multi-dimensional i dis-like Sad

Ill keep plodding along, I still have 4892 validation errors to fix lol
 
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

PostPosted: Mon Dec 15, 2008 7:38 pm Reply with quote

Don't use the second level menu, that will clear up about 4800 of them.
montego and I both cleared up a lot of the 'notice' errors and I think montego also did some further compliance work but to be honest, Sommaire has had it's day and it would be easier to write a new script than patch up Sommaire.
TS Menu is pretty good but it does use the old DB abstraction layer in places and it isn't language file aware.
 
View user's profile Send private message Send e-mail
Palbin







PostPosted: Mon Dec 15, 2008 7:43 pm Reply with quote

testy1 wrote:
Ill keep plodding along, I still have 4892 validation errors to fix lol


That is why you need to use regular expressions in your text editor. Laughing
 
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Tue Dec 16, 2008 5:28 am Reply with quote

Yeah, I have a need and desire to rewrite the blasted thing and now that RN has jQuery, that might be a lot easier than it would have been previously. Wink

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
testy1







PostPosted: Mon Dec 22, 2008 4:39 am Reply with quote

Im extremely close except for I cant really follow this but from what I can figure out it seems to me that a lot of this could be optimised by using the is_user($user) or is_group?

can anyone follow this well enough to explain it to me Sad


It first defines managementgroup

Code:
$managementgroup = 1; // to 0 will force Summary Paramétrable not manage groups. (gain of 1 SQL)



then the function which seems to check if your a user and if so it selects your points for some reason ?

Code:


function sommaire_is_user($user, $managementgroup) {
    global $prefix, $db, $user_prefix, $uid, $userpoints;
    if(!is_array($user)) {
      $user = addslashes($user); //v2.1.2
        $user = base64_decode($user);
      $user = addslashes($user); //v2.1.2
        $user = explode(":", $user);
        $uid = "$user[0]";
        $pwd = "$user[2]";
    } else {
        $uid = "$user[0]";
        $pwd = "$user[2]";
    }
   $uid = addslashes($uid); //v2.1.2
   $uid=intval($uid); //v2.1.2
    if ($uid != "" AND $pwd != "") {
      if ($managementgroup == 0) {
           $sql = "SELECT user_password FROM ".$user_prefix."_users WHERE user_id='$uid'";
      }
      else if ($managementgroup == 1) {
         $sql = "SELECT user_password, points FROM ".$user_prefix."_users WHERE user_id='$uid'";
      }
      else {
      die("Problème!!");
      }
        $result = $db->sql_query($sql);
        $row = $db->sql_fetchrow($result);
        $pass = $row['user_password'];
        if($pass == $pwd && $pass != "") {
         $userpoints = ($managementgroup==1) ? $row['points'] : "";
            return 1;
        }
    }
    return 0;
}



Code:


$is_user = (sommaire_is_user($user, $managementgroup)) ? 1 : 0; // cf. sommaire_is_user function () down


and here is an example of how it is being used

Code:


if ($is_user == 1) {
  if ($managementgroup == 1 && $subscriptionmanagement == "yes") {
    $sql = "SELECT group.id, group.points, sub.userid, sub.subscription_expire FROM " . $prefix . "_groups as group, " . $prefix . "_subscriptions as sub WHERE sub.userid=" . $uid . "";
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($sql)) {
      $pointsneeded[$row['id']] = $row['points'];
      echo "$row[subscription_expire]<br />";
    }
  } elseif ($managementgroup == 1) {
    $sql = "SELECT id, points FROM " . $prefix . "_groups";
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($sql)) {
      $pointsneeded[$row['id']] = $row['points'];
      echo "$row[subscription_expire]<br />";
    }
  } elseif ($subscriptionmanagement == "yes") {
    $sql = "SELECT id, points FROM " . $prefix . "_groups";
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($sql)) {
      $pointsneeded[$row['id']] = $row['points'];
      echo "$row[subscription_expire]<br />";
    }
  }
}



The reason I am even looking at this code is because when you log out of the site you get the following notice

Code:



Notice: Undefined offset: 2 in I:\xampp\htdocs\rn23\blocks\block-Sommaire.php on line 1191


and here is the line if code (its from the function sommaire_is_user above)

Code:


$pwd = "$user[2]";
 
kguske
Site Admin



Joined: Jun 04, 2004
Posts: 6433

PostPosted: Mon Dec 22, 2008 7:48 am Reply with quote

Sorry to get off topic, but...

I absolutely agree with Montego - it would be much better to use a jquery plugin, CSS for controlling appearance, and a simple list of LI-tagged menu options.

The modules block (and menu / navigation in general) in Nuke is a serious limitation, IMO. We've seen the modules block's use of checking active modules and making those it cannot find inactive effectively shut down active sites simply when it cannot read files in a modules folder (and this happens on some high volume sites). The simple fix? Deactivate the modules block, and replace it with a simple HTML block.

But there really is no reason why we can't have a better approach to navigation in RavenNuke. Maybe start with TS Menu, replace the DB abstraction layer, then use something like this or this or this with standard heading, subheading and menu item classes. The point is, by defining standard classes, you could use CSS to format the menus and jQuery to add special effects and additional formatting. And, it would degrade nicely if a visitor doesn't allow JS (actually, it would look like the standard Nuke menu without the middots...).

Anyone up for this challenge?

_________________
I search, therefore I exist...
nukeSEO - nukeFEED - nukePIE - nukeSPAM - nukeWYSIWYG
 
View user's profile Send private message
kguske







PostPosted: Mon Dec 22, 2008 8:25 am Reply with quote

Oops! I forgot to include another great example: jQuery UI Accordion.
 
Guardian2003







PostPosted: Mon Dec 22, 2008 8:38 am Reply with quote

I would be up for re-working TS Menu to replace the DB abstraction layer and also make in language aware (which it isn't at the moment).
I really liked those jQuery UI Accordian examples in the first link and they seem to degrade fairly well with js disabled. In fact I'm now thinking that I could re-work my News module to be similiar to their first example; have the readmore in the second box and comments/ratings in the third - that would be cool.
 
Palbin







PostPosted: Mon Dec 22, 2008 8:53 am Reply with quote

kguske, Smack

testy1,
testy1 wrote:

It first defines managementgroup

Code:
$managementgroup = 1; // to 0 will force Summary Paramétrable not manage groups. (gain of 1 SQL)



then the function which seems to check if your a user and if so it selects your points for some reason ?

Code:


function sommaire_is_user($user, $managementgroup) {
    global $prefix, $db, $user_prefix, $uid, $userpoints;
    if(!is_array($user)) {
      $user = addslashes($user); //v2.1.2
        $user = base64_decode($user);
      $user = addslashes($user); //v2.1.2
        $user = explode(":", $user);
        $uid = "$user[0]";
        $pwd = "$user[2]";
    } else {
        $uid = "$user[0]";
        $pwd = "$user[2]";
    }
   $uid = addslashes($uid); //v2.1.2
   $uid=intval($uid); //v2.1.2
    if ($uid != "" AND $pwd != "") {
      if ($managementgroup == 0) {
           $sql = "SELECT user_password FROM ".$user_prefix."_users WHERE user_id='$uid'";
      }
      else if ($managementgroup == 1) {
         $sql = "SELECT user_password, points FROM ".$user_prefix."_users WHERE user_id='$uid'";
      }
      else {
      die("Problème!!");
      }
        $result = $db->sql_query($sql);
        $row = $db->sql_fetchrow($result);
        $pass = $row['user_password'];
        if($pass == $pwd && $pass != "") {
         $userpoints = ($managementgroup==1) ? $row['points'] : "";
            return 1;
        }
    }
    return 0;
}



Code:


$is_user = (sommaire_is_user($user, $managementgroup)) ? 1 : 0; // cf. sommaire_is_user function () down


All the above code does is set $is_user to either 1 or 0. I don't really see the purpose for all that code, and I hate shorthand if statements Smile


Try this:
Code:


function sommaire_is_user($user, $managementgroup) {
    global $prefix, $db, $user_prefix, $uid, $userpoints;
   if(is_user($user)) {
      if(!is_array($user)) {
        $user = addslashes($user); //v2.1.2
         $user = base64_decode($user);
        $user = addslashes($user); //v2.1.2
         $user = explode(":", $user);
         $uid = "$user[0]";
         $pwd = "$user[2]";
      } else {
         $uid = "$user[0]";
         $pwd = "$user[2]";
      }
      $uid = addslashes($uid); //v2.1.2
      $uid=intval($uid); //v2.1.2
      if ($uid != "" AND $pwd != "") {
        if ($managementgroup == 0) {
            $sql = "SELECT user_password FROM ".$user_prefix."_users WHERE user_id='$uid'";
        }
        else if ($managementgroup == 1) {
          $sql = "SELECT user_password, points FROM ".$user_prefix."_users WHERE user_id='$uid'";
        }
        else {
        die("Problème!!");
        }
         $result = $db->sql_query($sql);
         $row = $db->sql_fetchrow($result);
         $pass = $row['user_password'];
         if($pass == $pwd && $pass != "") {
          $userpoints = ($managementgroup==1) ? $row['points'] : "";
            return 1;
         }
      }
   } else {
      return 0;
   }
}
 
elnegro
Hangin' Around



Joined: Aug 25, 2006
Posts: 34
Location: Verona (ITALY)

PostPosted: Mon Dec 22, 2008 6:17 pm Reply with quote

kguske wrote:
Sorry to get off topic, but...

I absolutely agree with Montego - it would be much better to use a jquery plugin, CSS for controlling appearance, and a simple list of LI-tagged menu options.


I like JQuery too, but... I am not able to find a common way to call JQuery libraries inside RavenNuke, in other words, by taking a look to the RN CMS code, I've seen that every module call its javascript routines in its own way. And actually it's hard to integrate new modules without duplicating jquery libraries IMO.

So, what I'am asking is: wouldn't better to change the code in the next release to have a JQuery API (wrapper) to call when needed for new modules?
 
View user's profile Send private message
testy1







PostPosted: Mon Dec 22, 2008 7:08 pm Reply with quote

Guardian2003 wrote:
I would be up for re-working TS Menu to replace the DB abstraction layer and also make in language aware (which it isn't at the moment).


check your pm's Gaurdian


palbin I will check this out and let you know thanks
 
fkelly
Former Moderator in Good Standing



Joined: Aug 30, 2005
Posts: 3312
Location: near Albany NY

PostPosted: Mon Dec 22, 2008 7:09 pm Reply with quote

Kguske can address this better than I, but I believe that the basic Jquery code is loaded at line 78 of the header.php in RN 2.3. No, that's not true exactly, the code appears to only be loaded if you are inside the Your_Account module but you could easily enough modify that to load it more generally. See the if statement at line 18 of /includes/jquery/jquery.php.

The topic of how to include jquery more generally is under internal discussion for RN 2.4.

As to the original topic discussed in this thread, one of my clients -- who is not a programmer by any stretch of the imagination -- well she is very concerned with her site's appearance and "friendliness" to users and was thus revulsed by the appearance and inflexibility of the modules block. She did exactly what was suggested earlier in this thread: developed a html version of the block. Unless you are constantly fiddling with what modules to display, a simple block does just fine. You just need to know how to create links inside the block -- which the wysiwyg editor makes into a snap especially if you can copy and paste.
 
View user's profile Send private message Visit poster's website
Guardian2003







PostPosted: Mon Dec 22, 2008 8:29 pm Reply with quote

Testy1 - thanks!

Yeah, I hate the standard *nuke module block too but have just not got around to writing something better. I currently use a CSS driven menu on my site which I 'include' into my theme.php file
 
montego







PostPosted: Tue Dec 23, 2008 5:35 pm Reply with quote

Just remember, that whatever replacement is written / re-written, it needs to be "aware" of all the various options for when a module should be shown to whom (i.e., registered user, admin only, NSN Group, etc.) and I find the ability to also add an external link invaluable. What I also love about Sommaire is the flexibility to place the menu items just about anywhere.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Blocks

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©