Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Panel Order with Vanilla 1.1.10

Anyone have Vanilla 1.1.10 with Panel Order extension working? If so can you please post the code or what you adjusted to get it working? Thanks!

Comments

  • Well, if anyone else was wondering, I figured it out. Looks like the problem was in the array_search() that was checking for the extension being listed in the $enabledextension array. I changed it up to be a strstr() encapsulated in a foreach() that runs through the array and fixed it. Here is the correct code for the PanelReOrder function:

    function PanelReOrder(&$Context) {
    $this->Name = 'PanelReOrder';
    $this->ValidActions = array('PanelReOrder');
    $this->Constructor($Context);

    if ($this->IsPostBack) {
    $Context->PageTitle = $this->Context->GetDefinition('PanelReOrder');

    if ($this->PostBackAction == 'PanelReOrder') {
    // Add the javascript to the head for sorting categories
    global $Head;
    $Head->AddScript('js/prototype.js');
    $Head->AddScript('js/scriptaculous.js');

    if (!file_exists($Context->Configuration['EXTENSIONS_PATH'].'PanelOrder/panelextensions.ini')) {
    $panelextensions = fopen($Context->Configuration['EXTENSIONS_PATH'].'PanelOrder/panelextensions.ini','w+');
    fwrite($panelextensions,"[PanelOrder]\r\n");
    } else {
    $panelextensions = fopen($Context->Configuration['EXTENSIONS_PATH'].'PanelOrder/panelextensions.ini','a');
    }

    $enabledextensions = file($Context->Configuration['APPLICATION_PATH'].'/conf/extensions.php');
    foreach ($enabledextensions as $ext_num => $currentextension) {
    if (strstr($currentextension, "include")) {
    $panelarray = parse_ini_file($Context->Configuration['EXTENSIONS_PATH'].'PanelOrder/panelextensions.ini');
    $panelnumber = count($panelarray);
    $currentextensionarray = explode('"', $currentextension);
    $extensionfile = $currentextensionarray[1];
    if ($extensionfile != "PanelOrder/default.php") {
    $fullextensionpath = $Context->Configuration['EXTENSIONS_PATH'].$extensionfile;
    if (!is_int(array_search($fullextensionpath, $panelarray))) {
    $currentextensioncontents = file($fullextensionpath);
    foreach ($currentextensioncontents as $line_num => $line) {
    if (strstr($line,"\$Panel->AddString(") || strstr($line,"\$Panel->AddList(")) {
    fwrite($panelextensions,$panelnumber."=".$fullextensionpath."\r\n");
    break;
    }
    }
    }
    }
    }
    }
    fclose($panelextensions);

    $panelarray = parse_ini_file($Context->Configuration['EXTENSIONS_PATH'].'PanelOrder/panelextensions.ini');
    $panelnumber = count($panelarray);
    $neworder = "[PanelOrder]\r\n";
    $n = 0;
    for ($i = 0;$i < $panelnumber;$i++) {
    $found = false;
    $x = $i - $n;
    $explode = explode($Context->Configuration['EXTENSIONS_PATH'],$panelarray[$i]);
    $search = 'include($Configuration[\'EXTENSIONS_PATH\']."'.$explode[1].'");'."\r\n";
    foreach($enabledextensions as $anext) {
    if(strstr($anext,$explode[1])) {
    $found = true;
    }
    }
    if ($found) {

    $neworder .= $x."=".$panelarray[$i]."\r\n";
    } else {
    $n++;
    }
    }
    $rewritefile = fopen($Context->Configuration['EXTENSIONS_PATH'].'PanelOrder/panelextensions.ini', 'w+');
    fwrite($rewritefile,$neworder);
    fclose($rewritefile);

    }
    }
    }
  • StashStash
    edited February 2010
    That looks great, but if you were to put <pre>tags</pre> around it, it would be a whole lot more readable and preserve the white space ;)
  • StashStash
    edited February 2010
    Okay, I just tried this using the below code, (which may or may not be the same as you posted :P) and it doesn't seem to be working for me with or without the JQuery and Set List extensions enabled or disabled.

    I can drag the boxes around just fine, and they remember where they were put, but it still just seems to keep my extension options in alphabetical order.

    Lines 65-74
    				for ($i = 0;$i < $panelnumber;$i++) {
    $found = false;
    $x = $i - $n;
    $explode = explode($Context->Configuration['EXTENSIONS_PATH'],$panelarray[$i]);
    $search = 'include($Configuration[\'EXTENSIONS_PATH\']."'.$explode[1].'");'."\r\n";
    foreach($enabledextensions as $anext) {
    if(strstr($anext,$explode[1])) {
    $found = true;
    }
    }
    if ($found) {

    $neworder .= $x."=".$panelarray[$i]."\r\n";
    } else {
    $n++;
    }
    }
Sign In or Register to comment.