Tema: Modificar modulo y bloque updownload
mintrak
avatar
Frecuente
Frecuente
Mensajes: 46

Enviado:
9.mar 2008 - 19:41

Hola he modificado el modulo updownload lo unico que le cambiado a sido el nombre ahora lo llamo descargas osea con un editor php sustitui todos los updonload por descargas en todos los archivos del modulo y yo pense que era una locura pero funciono cual es la razon necesitaba tener dos modulos de descaragas y para que fuera el mismo sin instalar dos modulos en apariencia distintos hice esto.
Ok todo funciona perfecto llego la ora de poner un segundo modulo central de descargas coji el bloque y ice lo mismo sustituir todos los updownload por descargas pero esto ya no ha sido tan facil y no me funciona creo que aunq con los cambios que hice sigue llamando a alguna tabla del modulo original updownload y ni tan siquiera me sale la ventana de crear bloque cuando subo el bloque al server

Hay algun alma caritataba que me allude con este codigo ?
No tengo mucha idea de codigo asi que imaginad mi confusion ante tanto simbolito raro

Gracias a todos !!


mintrak
avatar
Frecuente
Frecuente
Mensajes: 46

Enviado:
9.mar 2008 - 23:09

Este es el codigo original
Código
  1. Modules Presents: zUpDownload centerBlock v1.0 for Postnuke and the  */
  2. /* MD-Project. This centerBlock features: Recent DL's and Favoruite DL's */
  3. /*************************************************************************/
  4. // ----------------------------------------------------------------------
  5. // Last changes by Petzi-Juist, http://www.petzi-juist.de
  6. // ----------------------------------------------------------------------
  7.     $blocks_modules['z_updownload'] = array(
  8.     'func_display'   => 'z_updownload_display',
  9.     'func_add'       => 'z_updownload__add',
  10.     'func_edit'      => 'z_updownload__edit',
  11.     'func_update'    => 'z_updownload__update',
  12.     'text_type'      => 'z UpDownload Block',
  13.     'text_type_long' => 'z UpDownload Center Block',
  14.     'allow_create'   => false,
  15.     'allow_multiple' => true,
  16.     'allow_delete'   => false,
  17.     'form_content'   => false,
  18.     'form_refresh'   => false,
  19.     'show_preview'   => true
  20. );
  21.  
  22. // Security
  23. pnSecAddSchema('z_UpDownload::', 'Block title::');
  24.  
  25. function z_updownload_title_select ($selected) // selected is an array of the ids that are currently selected
  26. {
  27.  
  28.     $select="";
  29.  
  30.         $dbconn =& pnDBGetConn(true);
  31.           pnModDBInfoLoad('UpDownload');
  32.           $pntable =& pnDBGetTables();
  33.  
  34.         $table = $pntable['updownload_downloads'];
  35.         $column = &$pntable['updownload_downloads_column'];
  36.         //
  37.  
  38.     $sql = "SELECT $column[lid], $column[title] FROM $table";
  39.     $sql .=" order by $column[title]";
  40.  
  41.     $result = $dbconn->Execute($sql);
  42.  
  43.     $options="";
  44.     if(!$result->EOF)
  45.     {
  46.         while (list($lid, $title) = $result->fields)
  47.         {
  48.             $options .= "<option ";
  49.             if (in_array($lid, $selected)) $options .= "SELECTED ";
  50.             $options .= "value=\"".$lid."\">".$title."</option>\n";
  51.             $result->MoveNext();
  52.         }
  53.     } else {
  54.         $options = "<option value =\"\" SELECTED>"._ZUPDNONEAVIALABLE."</option>\n";
  55.     }
  56.  
  57.     $select = "<select multiple size=\"10\" name=\"nid[]\">\n";
  58.     $select .= $options;
  59.     $select .= "</select>\n";
  60.  
  61.     return $select;
  62. }
  63.  
  64. function z_updownload_display($row) {
  65.  
  66.  
  67.         $dbconn =& pnDBGetConn(true);
  68.           pnModDBInfoLoad('UpDownload');
  69.           $pntable =& pnDBGetTables();
  70.  
  71.         $table = $pntable['updownload_downloads'];
  72.         $column = &$pntable['updownload_downloads_column'];
  73.         //
  74.  
  75.     if (!pnSecAuthAction(0, 'z_UpDownload::', "$row[title]::", ACCESS_READ)) {
  76.         return;
  77.     }
  78.  
  79.  
  80.     $url = explode('|', $row['url']);
  81.     if (!$url[0]) // nid
  82.     {
  83.         $id ='';
  84.     } else {
  85.         $sevid = str_replace(",", "' or pn_lid='", "$url[0]");
  86.     }
  87.     if (!$url[1]) // include date
  88.     {
  89.         $url[1]="Y";
  90.     }
  91.     $col1_width= "100%";
  92.     if ($url[1]=="Y" or $url[1]=="y")
  93.     {
  94.         $col1_width= "80%";
  95.     }
  96.  
  97.     if (!$url[2]) // date format
  98.     {
  99.         $url[2]="d.m.y";
  100.     }
  101.     if (!$url[3]) // bullet
  102.     {
  103.         $url[3]="";
  104.     }
  105.     $amount = $url[4];
  106.     $maxlength = $url[5];
  107.     $length = $url[6];
  108.  
  109.     $descmaxlength = $url[7];
  110.     $desclength = $url[8];
  111.  
  112.     if (!$url[9]) // order
  113.     {
  114.         $url[9]="D,A"; // defaults to 'by date', 'ascending'
  115.     }
  116.     $order= explode (',',$url[10]);
  117.     if (!$url[10]) // order_map
  118.     {
  119.        $j=1;
  120.         while (list($k,$v)=each($url))
  121.         {
  122.             $temp_array[$j]=$v;
  123.             $j++;
  124.         }
  125.         $url[10]=serialize($temp_array); // just created a 'temp' order_map in case one didn't exist
  126.     }
  127.  
  128.  
  129.     $map_array=unserialize($url[10]);
  130.     if (is_array($map_array)) $order_map=array_flip($map_array); // turns this back in to an array and flips keys for vals
  131.     $ordertype="";
  132.     switch ($order[0])
  133.     {
  134.         case "A": // by alphabetical
  135.             $ordertype=$column[title];
  136.             break;
  137.         case "R": // by random
  138.             //$ordertype="RAND()";
  139.             $ordertype="RAND(" . time() . " * " . time() . ")";
  140.             break;
  141.         case "S": // specified
  142.             // will have to use array for this
  143.             //break;
  144.         default: // by date or any other choice
  145.             $ordertype=$column[date];
  146.     }
  147.  
  148.     $sql="SELECT $column[lid],
  149.         $column[title],
  150.         $column[description],
  151.         UNIX_TIMESTAMP($column[date])
  152.         FROM $table";
  153.     if ($sevid)
  154.     {
  155.         $sql .= " where pn_lid='$sevid' ";
  156.     }
  157.     $sql .=" order by ".$ordertype;
  158.     if ($order[1]=="D") $sql .= " DESC";
  159.  
  160.  
  161.     $result = $dbconn->SelectLimit($sql);
  162.  
  163.     if(!$result->EOF)
  164.     {
  165.         if ($url[0] == "")
  166.         {
  167.  
  168.             $content .= "<table width=\"100%\" cellpadding=\"2\" cellspacing=\"5\" border=\"0\">"
  169.             ."\n<tr><td>" . _ZUPDNONEAVIALABLE . "</td></tr>\n</table>\n";
  170.  
  171.         } else {
  172.  
  173.             $content .= "<table align=\"center\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">";
  174.                         $content .= "<tr><td width=\"90%\">&nbsp;</td><td width=\"10%\" rowspan=\"2\"><img src=\"images/zblocks/downloadheader.jpg\" align=\"right\" alt=\"\" /></td></tr>";
  175.                         $content .= "<tr><td width=\"90%\" style=\"background-color:#000000;height:0px;\"></td></tr></table>";
  176.             $content .= "<table align=\"center\" width=\"100%\" cellpadding=\"0\" cellspacing=\"5\" border=\"0\">";
  177.  
  178.             $content .= "<tr><td width=\"50%\" valign=\"top\"><span class=\"pn-title\"><strong>".Novedades."</strong></span></td>";
  179.             $content .= "<td width=\"50%\" valign=\"top\"><span class=\"pn-title\"><strong>".TopDescargas."</strong></span></td>";
  180.             $content .= "</tr></table>";
  181.  
  182.             $content .= "<table align=\"center\" width=\"100%\" cellpadding=\"0\" cellspacing=\"5\" border=\"0\">";
  183.             $content .= "<tr><td width=\"50%\" valign=\"top\">";
  184.             $j=1;
  185.             while (list($lid, $title, $description, $date) = $result->fields)
  186.             {
  187.                 $result_array[$lid]=array('lid'=>$lid, 'title'=>$title, 'date'=>$date);
  188.                 $std_order_map[$j]=$lid; // create 'standard' order map to use in most cases
  189.                 $j++;
  190.                 $result->MoveNext();
  191.             }
  192.  
  193.  
  194.              $result1 = $dbconn->Execute("SELECT $column[lid], UNIX_TIMESTAMP($column[date]),
  195.                                     $column[title], $column[description]
  196.                                     FROM $table
  197.                                     ORDER BY $column[date] DESC LIMIT $amount");
  198.                            if(!$result1->EOF)
  199.                             {
  200.             while (list($lid, $date, $title,) = $result1->fields) {
  201.             $result1->MoveNext();
  202.  
  203.  
  204.             $content .= "<table align=\"center\" width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" border=\"0\">";
  205.  
  206.             $content .= "<tr><td width=".$col1_width." valign=\"top\">";
  207.             if ($url[3])
  208.                {
  209.                     $content .= "<img src=\"".$url[3]."\" alt=\"\" />&nbsp;";
  210.                 } else {
  211.                    $content .= "<strong><big>&middot;</big></strong>&nbsp;";
  212.                 }
  213.             $linktitle = eregi_replace(" ", "_", $title);
  214.             $content .= "<strong><a title=\"$title\" class=\"pn-title\" href=\"index.php?name=UpDownload&amp;req=viewdownloaddetails&amp;lid=$lid\" style=\"text-decoration:none\">";
  215.  
  216.             if (strlen($title) > $maxlength) {
  217.                                 $title = substr($title,0,$length);
  218.                                 $title .= "...";}
  219.  
  220.             $content .= "".pnVarPrepForDisplay($title)."</a></strong></td>";
  221.  
  222.             $ndate = date($url[2], $date);
  223.             if ($url[1]=="Y" or $url[1]=="y") $content .= "<td width=\"20%\" valign=\"bottom\"><span class=\"pn-normal\">$ndate</span></td>";
  224.             $content .= "</tr>";
  225.             if (strlen($description) > $descmaxlength) {
  226.             $description = substr($description,0,$desclength);
  227.                                 $description .= "...";}
  228.  
  229.             $content .= "<tr><td width=\"70%\" valign=\"middle\"><span class=\"pn-normal\">$description</span></td>";
  230.             $content .= "</tr></table>";
  231.        }
  232.  
  233.  
  234.                   $content .= "</td>";
  235.                   $content .= "<td width=\"50%\" valign=\"top\">";
  236.  
  237.  
  238.  
  239.  
  240.  
  241.             $use_array=$std_order_map;
  242.             if (($order[0]=="S") && (is_array($order_map))) $use_array=$order_map;
  243.  
  244.             if (is_array($use_array)) {ksort($use_array); reset ($use_array);}
  245.  
  246.             while (list($k,$v) = each ($use_array))
  247.             {
  248.                 $lid=$result_array[$v]['lid'];
  249.                 $title=$result_array[$v]['title'];               
  250.                 $date=$result_array[$v]['date'];
  251.  
  252.                  $ndate = date($url[2], $date);
  253.                  $content .= "<table cellSpacing=\"0\" cellPadding=\"2\" width=\"100%\" border=\"0\">";
  254.  
  255.                  $content .= "<tr><td width=".$col1_width." valign=\"top\">";
  256.  
  257.                if ($url[3])
  258.                 {
  259.                     $content .= "<img src=\"".$url[3]."\" alt=\"\" />&nbsp;";
  260.                } else {
  261.                     $content .= "<strong><big>&middot;</big></strong>&nbsp;";
  262.                }
  263.  
  264.                 $linktitle = eregi_replace(" ", "_", $title);
  265.                 $content .= "<strong><a title=\"$title\" class=\"pn-title\" href=\"index.php?name=UpDownload&amp;req=viewdownloaddetails&amp;lid=$lid\" style=\"text-decoration:none\">";
  266.  
  267.                 //added to limit the title
  268.                 if ((strlen($title) > $maxlength) && ($maxlength<>0)) {
  269.                     $title = substr($title,0,$length);
  270.                         $title .= "..."; }
  271.  
  272.                 $content .= "" .stripslashes($title). "</a></strong>";
  273.  
  274.                 $content .= "</td>";
  275.  
  276.                 if (strtoupper($url[1])=="Y")
  277.                 {
  278.  
  279.                     $content .= "<td width=\"20%\" valign=\"bottom\">";
  280.                     if ($url[1]=="Y" or $url[1]=="y") $content .= "<span class=\"pn-normal\">$ndate</span></td>";
  281.                     $content .= "</tr>";
  282.  
  283.                    }
  284.                             if (strlen($description) > $descmaxlength) {
  285.                                 $description = substr($description,0,$desclength);
  286.                                 $description .= "...";}
  287.                            $content .= "<tr><td width=\"70%\" valign=\"middle\"><span class=\"pn-normal\">$description</span></td>";
  288.  
  289.                            $content .= "</tr></table>";
  290.  
  291.             }
  292.  
  293. }
  294.  
  295.  
  296.  
  297.  
  298.  
  299.        $result2 = $dbconn->Execute("SELECT SUM($column[hits])
  300.                               FROM $table");
  301.         if(!$result2->EOF)
  302.          list($sumhits) = $result2->fields;
  303.         else
  304.           $sumhits = 0;
  305.         $result2->Close();
  306.  
  307.         $result2 = $dbconn->Execute("select COUNT(*) from $table");
  308.         if (!$result2->EOF)
  309.         {
  310.             list($count) = $result2->fields;
  311.         } else {
  312.             $count = 0;
  313.         }
  314.         $result2->Close();
  315.  
  316.         if($sumhits > 0 || $count > 0)
  317.         {
  318.             $content .= "<br />\n";
  319.             $content .= "<table align=\"center\" width=\"95%\" cellpadding=\"1\" cellspacing=\"0\" border=\"0\">\n";
  320.             $content .= "<tr>\n";
  321.             $content .= "<td align=\"right\" width=\"60%\"><span class=\"pn-normal\">\n<a href=\"index.php?name=UpDownload\"><strong>".Mas."</strong></a></span></td>\n</tr>\n</table>\n";
  322.  
  323.  
  324.     } else {
  325.         $content .= _ZUPDNODOWN;
  326.     }
  327.  
  328.      $content .= "</td></tr></table>";
  329.  
  330.      }    }
  331.     $row[content] = $content;
  332.     themesideblock($row);
  333. }
  334.  
  335. function z_updownload__add($row)
  336. {
  337.     $row['url'] = '|Y|d.m.y|5|40|37|100|97|D,A|'.serialize(array(1=>1, 2=>2, 3=>3, 4=>4));
  338.     return $row;
  339. }
  340.  
  341. function z_updownload__update($vars)
  342. {
  343.     if (is_array($vars[nid]))
  344.     {
  345.         $vars['url'] = join(',',$vars[nid])
  346.                    ."|$vars[incdate]"
  347.                    ."|$vars[dateformat]"
  348.                    ."|$vars[bullet]"
  349.                    ."|$vars[amount]"
  350.                    ."|$vars[nmaxlength]"
  351.                    ."|$vars[nlength]"
  352.                    ."|$vars[ndescmaxlength]"
  353.                    ."|$vars[ndesclength]|"
  354.                    .join(',',$vars[order])."|"
  355.