1
Peekay
Content 0.6 : Page title bug-fix
  • 2007/1/28 22:31

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


The nice thing about Content 0.6 is that you can add custom page titles. Unfortunately, the title was lost on editing the item (at least it was on my setup - see sig).

Anyway, I tinkered with 'admin/index.php' and it now works for me. If you have the same problem, my altered code is below if you want to try it. Make a backup first.

I have posted a report on module dev forge, although this may have already been fixed in the later version.

<?php
//  ------------------------------------------------------------------------ //
//                XOOPS - PHP Content Management System                      //
//                    Copyright (c) 2000 xoops.org                           //
//                       <https://xoops.org/>                             //
//  ------------------------------------------------------------------------ //
//  This program is free software; you can redistribute it and/or modify     //
//  it under the terms of the GNU General Public License as published by     //
//  the Free Software Foundation; either version 2 of the License, or        //
//  (at your option) any later version.                                      //
//                                                                           //
//  You may not change or alter any portion of this comment or credits       //
//  of supporting developers from this source code or any supporting         //
//  source code which is considered copyrighted (c) material of the          //
//  original comment or credit authors.                                      //
//                                                                           //
//  This program is distributed in the hope that it will be useful,          //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
//  ------------------------------------------------------------------------ //
// Author: Tobias Liegl (AKA CHAPI)                                          //
// Site: http://www.chapi.de                                                 //
// Project: The XOOPS Project                                                //
// ------------------------------------------------------------------------- //
include_once "admin_header.php";

if (isset(
$HTTP_GET_VARS)) {
    foreach (
$HTTP_GET_VARS as $k => $v) {
      $
$k $v;
    }
  }

  if (isset(
$HTTP_POST_VARS)) {
    foreach (
$HTTP_POST_VARS as $k => $v) {
      $
$k $v;
    }
  }

// Função que verifica se um conteúdo tem subcategorias
  
function tem_subcategorias($category_id) {
        global 
$xoopsDB;
    
$child_category_query $xoopsDB->query("select count(*) as count from " $xoopsDB->prefix('content') . " where parent_id = '" . (int)$category_id "'");
    
$child_category $xoopsDB->fetchArray($child_category_query);

    if (
$child_category['count'] > 0) {
      return 
true;
    } else {
      return 
false;
    }
  }

// Função que verifica se é Categoria Principal
  
function cat_principal($category_id) {
        global 
$xoopsDB;
    
$child_category_query $xoopsDB->query("select count(*) as count from " $xoopsDB->prefix('content') . " where storyid = '" . (int)$category_id "' and parent_id='0'");
    
$child_category $xoopsDB->fetchArray($child_category_query);

    if (
$child_category['count'] > 0) {
      return 
true;
    } else {
      return 
false;
    }
  }
  
//Função que montará o select
  
function gera_menus($currentParID,$menustr,$catstr,$level) {
    global 
$xoopsDB;
   
$retorna[0] = _C_MAINMENU;
   
$haschildren 0//padrão
   
$cat_principal 0;
   
$categorias_query_catmenu $xoopsDB->query("select storyid, parent_id, title from ".$xoopsDB->prefix('content')." where parent_id = " $currentParID " order by blockid, storyid");
   while (
$categorias $xoopsDB->fetchArray($categorias_query_catmenu))  {
     
//if ($categorias['parent_id'] == 0 ){
                 
$haschildren=tem_subcategorias($categorias['storyid']);
                    
//$cat_principal = cat_principal($categorias['storyid']);
             //if ($categorias['parent_id'] != 0) {
                    
$categorias['title'] = str_repeat("->"$level).$categorias['title'];
             
//}
             
if ($haschildren) {
                       
$menu_tmp $categorias['title'];
                       
$cat_tmp $categorias['storyid'];
                           
$retorna[$categorias['storyid']] = $menu_tmp;
                       
$retorna2 gera_menus($categorias['storyid'],'',''$level 1);
                       foreach (
$retorna2 as $k => $v) {
                               
$retorna[$k] = "&nbsp;&nbsp;&nbsp;  ".$v;
                       }
               } else {
                      
$retorna[$categorias['storyid']] = $categorias['title'];
              }
          
//}
  // Menu "árvore"
//        Menu1_1_1=new Array(Texto a exibir, Link, imagem de fundo (opcional), numero de sub menus, altura, largura);
    
}// end while
    
return $retorna;
  }  
//Fim de Monta Menu

  // checks browser compatibility with the control
  
function checkBrowser() {
    global 
$HTTP_SERVER_VARS;
    
$browser $HTTP_SERVER_VARS['HTTP_USER_AGENT'];
    
// check if msie
    
if (eregi("MSIE[^;]*",$browser,$msie)) {
      
// get version
      
if (eregi("[0-9]+.[0-9]+",$msie[0],$version)) {
        
// check version
        
if ((float)$version[0]>=5.5) {
          
// finally check if it's not opera impersonating ie
          
if (!eregi("opera",$browser)) {
            return 
true;
          }
        }
      }
    }
    return 
false;
  }

// ------------------------------------------------------------------------- //
// Switch Statement for the different operations                             //
// ------------------------------------------------------------------------- //
$xoopsDB =& Database::getInstance();
global 
$op;
switch (
$op) {

// ------------------------------------------------------------------------- //
// Show Content Page -> Overview                                             //
// ------------------------------------------------------------------------- //
case "show":
        global 
$xoopsDB;
        
$myts =& MyTextSanitizer::getInstance();
    
xoops_cp_header();

        echo 
"<form action='index.php' method='post'>";
        echo 
"<h4>"._C_ADMINTITLE."</h4><table border='0' cellpadding='0' cellspacing='1' width='100%' class='outer'>";
        echo 
"<tr class='even'><td><b>"._C_HOMEPAGE."</b></td><td><b>"._C_POSITION."</b></td><td><b>"._C_LINKNAME."</b></td>";
        echo 
"<td><b>"._C_LINKID."</b></td><td><b>"._C_SUBLINKID."</b></td><td><b>"._C_VISIBLE."</b></td><td><b>"._COMMENTS."</b></td><td><b>"._C_SUBMENU."</b></td>";
        echo 
"<td><b>"._C_ACTION."</b></td></tr>";
    
$mostra gera_menus(0,'','');
    
$result $xoopsDB->query("SELECT child.visible, child.submenu, child.nocomments, child.homepage, child.storyid, child.blockid, child.title, child.visible, child.parent_id, child.address,CASE parent.parent_id WHEN 0 THEN parent.blockid ELSE child.blockid END 'menu_block', CASE child.parent_id WHEN 0 THEN child.storyid ELSE child.parent_id END 'menu_id'FROM ".$xoopsDB->prefix('content')." child LEFT JOIN ".$xoopsDB->prefix('content')." parent ON child.parent_id = parent.storyid ORDER BY menu_block, menu_id, parent_id, blockid");
    while (
$tcontent $xoopsDB->fetcharray($result)) {
            
$menu "<select name="parent_id[".$tcontent['storyid']."]">";
            foreach (
$mostra as $key => $value) {
                    if (
$key == $tcontent['storyid'])
                    continue;
                    if (
$key == $tcontent['parent_id']){
                            
$menu .= "<option value="".$key."" selected='selected'>$value</option>";
                    }else{
                            
$menu .= "<option value="".$key."">$value</option>";
                    }
            }
            
$menu .= '</select>';
      
$title=$myts->makeTboxData4Show($tcontent['title'], 000);

          if (
$tcontent['visible'] == '1') {
           
$check1 "";
           
$check2 "selected='selected'";
          } else {
           
$check1 "selected='selected'";
           
$check2 "";
          }

          if (
$tcontent['homepage'] == '1') {
           
$check3 "checked='checked'";
          } else {
           
$check3 "";
          }

          if (
$tcontent['nocomments'] == '1') {
           
$check4 "selected='selected'";
           
$check5 "";
          } else {
           
$check4 "";
           
$check5 "selected='selected'";
          }

          if (
$tcontent['submenu'] == '0') {
           
$check6 "selected='selected'";
           
$check7 "";
          } else {
           
$check6 "";
           
$check7 "selected='selected'";
          }
          echo 
"<tr class='odd'>";
          echo 
"<td><input type='radio' name='homepage[]' value='".$tcontent['storyid']."' ".$check3."></td>";
          echo 
"<td>$menu</td>";
          echo 
"<td><a href='".XOOPS_URL."/modules/".$xoopsModule->dirname()."/index.php?id=".$tcontent['storyid']."'>".$title."</a></td>";
          if (
$tcontent['parent_id'] == 0){
                  echo 
"<td><input type='hidden' name='id[]' value='".$tcontent['storyid']."' /><input type='text' name='blockid[".$tcontent['storyid']."]' size='2' maxlength='2' value='".$tcontent['blockid']."'/></td><td>&nbsp;</td>";
          }else{
                  echo 
"<td>--></td><td><input type='hidden' name='id[]' value='".$tcontent['storyid']."' /><input type='text' name='blockid[".$tcontent['storyid']."]' size='2' maxlength='2' value='".$tcontent['blockid']."'/></td>";
          }
          echo 
"<td><select name='visible[".$tcontent['storyid']."]'><option value='0' ".$check1." />"._C_NO."</option><option value='1' ".$check2." />"._C_YES."</option></select></td>";
          echo 
"<td><select name='nocomments[".$tcontent['storyid']."]'><option value='1' ".$check4." />"._C_NO."</option><option value='0' ".$check5." />"._C_YES."</option></select></td>";
          echo 
"<td><select name='submenu[".$tcontent['storyid']."]'><option value='0' ".$check5." />"._C_NO."</option><option value='1' ".$check7." />"._C_YES."</option></select></td>";
            if (
$tcontent['link'] == '1') {
              echo 
"<td><a href='index.php?op=elink&id=".$tcontent['storyid']."'>"._C_EDIT."</a>";
            } else {
              echo 
"<td><a href='index.php?op=edit&id=".$tcontent['storyid']."'>"._C_EDIT."</a>";
            }
          echo 
" | <a href='index.php?op=delete&id=".$tcontent['storyid']."'>"._C_DELETE."</a></td></tr>";

      }

          echo 
"</table>";

          echo 
"<br /><div align='center'>
               <input type='hidden' name='op' value='update' />
                  <input type='submit' name='submit' value="
._SUBMIT." /></div>";
      echo 
"</form>";

          
xoops_cp_footer();
        break;

// ------------------------------------------------------------------------- //
// Show add content Page                                                     //
// ------------------------------------------------------------------------- //
case "submit":
        global 
$xoopsDB$xoopsModuleConfig;
        
xoops_cp_header();
        
$currentParent 0;
        
$result $xoopsDB->query("SELECT CASE parent_id WHEN 0 THEN storyid ELSE parent_id END 'sortorder' FROM ".$xoopsDB->prefix('content')." WHERE visible='1' AND storyid=".$HTTP_GET_VARS['id']);
        list(
$currentParent) = $xoopsDB->fetchRow($result);
        echo 
"<h4>"._C_ADMINTITLE."</h4>";

        
$form = new XoopsThemeForm(_C_ADDCONTENT"form_name""index.php");
        
$categoria_select = new XoopsFormSelect(_C_POSITION"parent_id"$currentParent);
        
$categoria_select->addOptionArray(gera_menus(0,'',''));
        
$form->addElement($categoria_select);
        
// Search os menus na tabela:

        
$text_box = new XoopsFormText(_C_LINKNAME"title"5030);
        
$form->addElement($text_box);

        
$ptitle = new XoopsFormText(_C_PAGETITLE"ptitle"50300);
        
$form->addElement($ptitle);

        
$url_box = new XoopsFormText(_C_EXTURL"externalURL"50255);
        
$form->addElement($url_box);

        
$visible_checkbox = new XoopsFormCheckBox(_C_VISIBLE'visible');
          
$visible_checkbox->addOption(1_C_YES);
        
$form->addElement($visible_checkbox);

        
$submenu_checkbox = new XoopsFormCheckBox(_C_SUBMENU'submenu');
          
$submenu_checkbox->addOption(1_C_YES);
        
$form->addElement($submenu_checkbox);

        if (
$xoopsModuleConfig['cont_wysiwyg'] == '1') {
                
$fckeditor_root XOOPS_ROOT_PATH.'/modules/content/admin/fckeditor/';
                include 
XOOPS_ROOT_PATH.'/modules/content/admin/fckeditor/fckeditor.php';
                
ob_start();
                
$oFCKeditor = new FCKeditor('message') ;
                
$oFCKeditor->BasePath        XOOPS_URL."/modules/content/admin/fckeditor/" ;
                
$oFCKeditor->Value                $message ;
                
$oFCKeditor->Height                500 ;
                
$oFCKeditor->Create() ;
                
$form->addElement(new XoopsFormLabel(_C_CONTENTob_get_contents()));
                
ob_end_clean();
        } else {
                
$t_area = new XoopsFormDhtmlTextArea(_C_CONTENT'message'''3735);
                
$form->addElement($t_area);
        }
        
$option_tray = new XoopsFormElementTray(_OPTIONS,'<br />');

          if (
$xoopsModuleConfig['cont_wysiwyg'] != '1') {
                  
$form->addElement(new XoopsFormHidden(_DISABLEHTML0));
                
$form->addElement(new XoopsFormHidden(_DISABLESMILEY0));
          } else {
                 
$nohtml_checkbox = new XoopsFormCheckBox('''nohtml'0);
                  
$nohtml_checkbox->addOption(1_DISABLEHTML);
                
$option_tray->addElement($nohtml_checkbox);
                  
$smiley_checkbox = new XoopsFormCheckBox('''nosmiley'0);
                  
$smiley_checkbox->addOption(1_DISABLESMILEY);
                
$option_tray->addElement($smiley_checkbox);
          }

        if (
$xoopsModuleConfig['cont_wysiwyg'] != '1') {
          
$form->addElement(new XoopsFormHidden('nobreaks'1));
        } else {
          
$breaks_checkbox = new XoopsFormCheckBox('''nobreaks'0);
          
$breaks_checkbox->addOption(1_C_DISABLEBREAKS);
                
$option_tray->addElement($breaks_checkbox);
        }

          
$comments_checkbox = new XoopsFormCheckBox('''nocomments'0);
          
$comments_checkbox->addOption(1_C_DISABLECOM);

                
$option_tray->addElement($comments_checkbox);
        
$form->addElement($option_tray);
        
$add "add";
        
$form->addElement(new XoopsFormHidden('op'$add));
        if (
$return == 1) {
                
$form->addElement(new XoopsFormHidden('return'1));
        }
        
$submit = new XoopsFormButton("""submit"_SUBMIT"submit");
        
$form->addElement($submit);
        
$form->display();

        
xoops_cp_footer();
        break;

// ------------------------------------------------------------------------- //
// Add a content to database                                                 //
// ------------------------------------------------------------------------- //
case "add":
        
$myts =& MyTextSanitizer::getInstance();

        
$title=$myts->makeTboxData4Save($title);
        
$message=$myts->makeTareaData4Save($message);

        
$result $xoopsDB->query("SELECT * FROM ".$xoopsDB->prefix(_MIC_CONTENT_PREFIX)."");
        
$rows mysql_num_rows($result);

        if (
$rows == 0) {
          
$hp 1;
        } else {
          
$hp 0;
        }

        
$sqlinsert="INSERT INTO ".$xoopsDB->prefix(_MIC_CONTENT_PREFIX)." (parent_id,title,ptitle,text,visible,homepage,nohtml,nosmiley,nobreaks,nocomments,link,address,submenu) VALUES ('".intval($parent_id)."','".$title."','".$ptitle."','".$message."','".intval($visible)."','".$hp."','".intval($nohtml)."','".intval($nosmiley)."','".intval($nobreaks)."','"."','0','".$externalURL"','".intval($submenu)."')";
        if ( !
$result $xoopsDB->query($sqlinsert) )
                        {
                                echo 
_C_ERRORINSERT;
                        }
        if (
$return == 1) {
                
redirect_header(XOOPS_URL."/modules/content/index.php?id=".$xoopsDB->getInsertId(),2,_C_DBUPDATED);
        }else{
                
redirect_header("index.php?op=show",2,_C_DBUPDATED);
        }

        
redirect_header("index.php",2,_C_DBUPDATED);

        break;

// ------------------------------------------------------------------------- //
// Update Content -> Show Content Page                                       //
// ------------------------------------------------------------------------- //
case "update":

        foreach (
$id as $storyid) {

        if (
$storyid == intval($homepage[0])) {
            
$hp 1;
          } else {
            
$hp 0;
          }

          
$sqlinsert="UPDATE ".$xoopsDB->prefix(_MIC_CONTENT_PREFIX)." SET parent_id='".intval($parent_id[$storyid])."', blockid='".intval($blockid[$storyid])."',visible='".intval($visible[$storyid])."',homepage='".$hp."',nocomments='".intval($nocomments[$storyid])."',submenu='".intval($submenu[$storyid])."' WHERE storyid='".intval($storyid)."'";
        if ( !
$result $xoopsDB->query($sqlinsert) )
                        {
                                echo 
_C_ERRORINSERT;
                        }

        }
        
redirect_header("index.php?op=show",2,_C_DBUPDATED);

        break;

// ------------------------------------------------------------------------- //
// Show Edit Content Page                                                    //
// ------------------------------------------------------------------------- //
case "edit":
        global 
$xoopsDB$xoopsModuleConfig;
        
$myts =& MyTextSanitizer::getInstance();
        
xoops_cp_header();

    
$result $xoopsDB->query("SELECT storyid,parent_id,title,ptitle,text,visible,nohtml,nosmiley,nobreaks,nocomments,address,submenu FROM ".$xoopsDB->prefix(_MIC_CONTENT_PREFIX)." WHERE storyid=".intval($id));

    list(
$storyid,$parent_id,$title,$ptitle,$text,$visible,$nohtml,$nosmiley,$nobreaks,$nocomments,$externalURL,$submenu) = $xoopsDB->fetchRow($result);

        
$title=$myts->makeTboxData4Edit($title);
        
$message=$text;

        echo 
"<h4>"._C_ADMINTITLE."</h4>";

        
$form = new XoopsThemeForm(_C_EDITCONTENT"form_name""index.php");
        
$categoria_select = new XoopsFormSelect(_C_POSITION"parent_id"$parent_id);
        
$categoria_select->addOptionArray(gera_menus(0,'',''));
        
$form->addElement($categoria_select);
        
$text_box = new XoopsFormText(_C_LINKNAME"title"5030$title);
        
$form->addElement($text_box);
        
$ptitle = new XoopsFormText(_C_PAGETITLE"ptitle"50300$ptitle);
        
$form->addElement($ptitle);
        
$url_box = new XoopsFormText(_C_EXTURL"externalURL"50255$externalURL);
        
$form->addElement($url_box);

        
$visible_checkbox = new XoopsFormCheckBox(_C_VISIBLE'visible'$visible);
          
$visible_checkbox->addOption(1_C_YES);
        
$form->addElement($visible_checkbox);

        
$submenu_checkbox = new XoopsFormCheckBox(_C_SUBMENU'submenu'$submenu);
          
$submenu_checkbox->addOption(1_C_YES);
        
$form->addElement($submenu_checkbox);

        if (
$xoopsModuleConfig['cont_wysiwyg'] == '1') {
                
$fckeditor_root XOOPS_ROOT_PATH.'/modules/content/admin/fckeditor/';
                include 
XOOPS_ROOT_PATH.'/modules/content/admin/fckeditor/fckeditor.php';
                
ob_start();
                
$oFCKeditor = new FCKeditor('message') ;
                
$oFCKeditor->BasePath        XOOPS_URL."/modules/content/admin/fckeditor/" ;
                
$oFCKeditor->Value                $message ;
                
$oFCKeditor->Height                500 ;
                
$oFCKeditor->Create() ;
                
$form->addElement(new XoopsFormLabel(_C_CONTENTob_get_contents()));
                
ob_end_clean();
        } else {
                
$t_area = new XoopsFormDhtmlTextArea(_C_CONTENT'message'$message3735);
                
$form->addElement($t_area);
        }

        
$option_tray = new XoopsFormElementTray(_OPTIONS,'<br />');

          if (
$xoopsModuleConfig['cont_wysiwyg'] != '1') {
                  
$form->addElement(new XoopsFormHidden(_DISABLEHTML0));
                
$form->addElement(new XoopsFormHidden(_DISABLESMILEY0));
          } else {
                 
$nohtml_checkbox = new XoopsFormCheckBox('''nohtml'0);
                  
$nohtml_checkbox->addOption(1_DISABLEHTML);
                
$option_tray->addElement($nohtml_checkbox);
                  
$smiley_checkbox = new XoopsFormCheckBox('''nosmiley'0);
                  
$smiley_checkbox->addOption(1_DISABLESMILEY);
                
$option_tray->addElement($smiley_checkbox);
          }

        if (
$xoopsModuleConfig['cont_wysiwyg'] == '1') {
          
$form->addElement(new XoopsFormHidden('nobreaks'1));
        } else {
          
$breaks_checkbox = new XoopsFormCheckBox('''nobreaks'0);
          
$breaks_checkbox->addOption(1_C_DISABLEBREAKS);
                
$option_tray->addElement($breaks_checkbox);
        }

          
$comments_checkbox = new XoopsFormCheckBox('''nocomments'$nocomments);
          
$comments_checkbox->addOption(1_C_DISABLECOM);
                
$option_tray->addElement($comments_checkbox);
        
$form->addElement($option_tray);
        
$editit "editit";
        
$form->addElement(new XoopsFormHidden('op'$editit));
        
$form->addElement(new XoopsFormHidden('id'$storyid));
        if (
$return == 1) {
                
$form->addElement(new XoopsFormHidden('return'1));
        }
        
$submit = new XoopsFormButton("""submit"_SUBMIT"submit");
        
$form->addElement($submit);
        
$form->display();

        
xoops_cp_footer();
        break;

// ------------------------------------------------------------------------- //
// Do the edit of the Content                                                //
// ------------------------------------------------------------------------- //
case "editit":
        
$myts =& MyTextSanitizer::getInstance();

        
$title=$myts->makeTboxData4Save($title);
        
$message=$myts->makeTareaData4Save($message);

        
$sqlinsert="UPDATE ".$xoopsDB->prefix(_MIC_CONTENT_PREFIX)." SET parent_id='".intval($parent_id)."',title='".$title."',ptitle='".$ptitle."',text='".$message."',visible='".intval($visible)."',nohtml='".intval($nohtml)."',nosmiley='".intval($nosmiley)."',nobreaks='".intval($nobreaks)."',nocomments='".intval($nocomments)."',address='".$externalURL."',submenu='".intval($submenu)."' WHERE storyid='".intval($id)."'";
        if ( !
$result $xoopsDB->query($sqlinsert) )
                        {
                                echo 
_C_ERRORINSERT;
                        }
        if (
$return == 1) {
                
redirect_header(XOOPS_URL."/modules/content/index.php?id=".$id,2,_C_DBUPDATED);
        }else{

                
redirect_header("index.php?op=show",2,_C_DBUPDATED);
        }

        break;

// ------------------------------------------------------------------------- //
// Show new link Page                                                        //
// ------------------------------------------------------------------------- //
case "nlink":
        
xoops_cp_header();

        echo 
"<h4>"._C_ADMINTITLE."</h4>";

        
$dir XOOPS_ROOT_PATH."/modules/content/content/";
        if(!
eregi("777",decoct(fileperms($dir)))) {
          echo
"<font color='FF0000'><h4>"._C_PERMERROR."</h4></font>";
        }

// Upload File
        
echo "<form name='form_name2' id='form_name2' action='index.php' method='post' enctype='multipart/form-data'>";
        echo 
"<table cellspacing='1' width='100%' class='outer'>";
        echo 
"<tr><th colspan='2'>"._C_ULFILE."</th></tr>";
        echo 
"<tr valign='top' align='left'><td class='head'>"._C_SFILE."</td><td class='even'><input type='file' name='fileupload' id='fileupload' size='30' /></td></tr>";
        echo 
"<tr valign='top' align='left'><td class='head'><input type='hidden' name='MAX_FILE_SIZE' id='op' value='500000' /><input type='hidden' name='op' id='op' value='upload' /></td><td class='even'><input type='submit' name='submit' value='"._C_UPLOAD."' /></td></tr>";
        echo 
"</table>";
    echo 
"</form>";

// Delete File
        
$form = new XoopsThemeForm(_C_DELFILE"form_name""index.php");

        
$address_select = new XoopsFormSelect(_C_URL"address");
    
$folder dir("../content/");
        while(
$file $folder->read()) {
      if (
$file != "." && $file != "..") {
             
$address_select->addOption($file$file);
          }
        }
    
$folder->close();
        
$form->addElement($address_select);

        
$delfile "delfile";
        
$form->addElement(new XoopsFormHidden('op'$delfile));
        
$submit = new XoopsFormButton("""submit"_C_DELETE"submit");
        
$form->addElement($submit);
        
$form->display();

// Add PageWrap
        
$form = new XoopsThemeForm(_C_ADDLINK"form_name""index.php");
        
$categoria_select = new XoopsFormSelect(_C_POSITION"parent_id");
        
$categoria_select->addOptionArray(gera_menus(0,'',''));
        
$form->addElement($categoria_select);
        
$text_box = new XoopsFormText(_C_LINKNAME"title"5030);
        
$form->addElement($text_box);

        
$visible_checkbox = new XoopsFormCheckBox(_C_VISIBLE'visible');
          
$visible_checkbox->addOption(1_C_YES);
        
$form->addElement($visible_checkbox);

        
$submenu_checkbox = new XoopsFormCheckBox(_C_SUBMENU'submenu');
          
$submenu_checkbox->addOption(1_C_YES);
        
$form->addElement($submenu_checkbox);

        
$address_select = new XoopsFormSelect(_C_URL"address");
    
$folder dir("../content/");
        while(
$file $folder->read()) {
      if (
$file != "." && $file != "..") {
             
$address_select->addOption($file"".$file."");
          }
        }
    
$folder->close();
        
$form->addElement($address_select);

        
$comments_checkbox = new XoopsFormCheckBox(_C_DISABLECOM'nocomments'0);
          
$comments_checkbox->addOption(1_C_YES);
        
$form->addElement($comments_checkbox);

        
$addlink "addlink";
        
$form->addElement(new XoopsFormHidden('op'$addlink));
        
$submit = new XoopsFormButton("""submit"_SUBMIT"submit");
        
$form->addElement($submit);
        
$form->display();

        
xoops_cp_footer();
        break;

// ------------------------------------------------------------------------- //
// Upload File                                                //
// ------------------------------------------------------------------------- //
case "upload":

        
$uploadpath=XOOPS_ROOT_PATH."/modules/"._MIC_DIR_NAME."/content/";
        
$source=$_FILES[fileupload][tmp_name];
        
$fileupload_name=$_FILES[fileupload][name];
        if ( (
$source != 'none') && ($source != '' )) {
          
$dest=$uploadpath.$fileupload_name;
          if(
file_exists($uploadpath.$fileupload_name)) {
            
redirect_header("index.php",2,_C_ERRORUPL);
          } else {
            if (
copy($source$dest)) {
              
redirect_header("index.php",2,_C_UPLOADED);
            } else {
                  
redirect_header("index.php",2,_C_ERRORUPL);
            }
          
unlink ($source);
          }
        }

        break;

// ------------------------------------------------------------------------- //
// Delete File - Confirmation Question                                    //
// ------------------------------------------------------------------------- //
case "delfile":
        
xoops_cp_header();
        
xoops_confirm(array('address' => $address'op' => 'delfileok'), 'index.php'_C_RUSUREDELF_YES);
        
xoops_cp_footer();
        break;

// ------------------------------------------------------------------------- //
// Delete it definitely                                                      //
// ------------------------------------------------------------------------- //
case "delfileok":
        
$dir=XOOPS_ROOT_PATH."/modules/"._MIC_DIR_NAME."/content/";
        @
unlink($dir."/".$address);
    
redirect_header("index.php",2,_C_FDELETED);
        break;

// ------------------------------------------------------------------------- //
// Add a PageWrap to database                                                //
// ------------------------------------------------------------------------- //
case "addlink":
        
$myts =& MyTextSanitizer::getInstance();

        
$title=$myts->makeTboxData4Save($title);
        
$address=$myts->makeTboxData4Save($address);

        
$result $xoopsDB->query("SELECT * FROM ".$xoopsDB->prefix(_MIC_CONTENT_PREFIX)."");
        
$rows mysql_num_rows($result);

        if (
$rows == 0) {
          
$hp 1;
        } else {
          
$hp 0;
        }

        
$sqlinsert="INSERT INTO ".$xoopsDB->prefix(_MIC_CONTENT_PREFIX)." (parent_id,title,ptitle,text,visible,homepage,nohtml,nosmiley,nocomments,link,address,submenu) VALUES ('".intval($parent_id)."','".$title."','Page Title Here','0','".intval($visible)."','".$hp."','0','0','".intval($nocomments)."','1','".$address."','".intval($submenu)."')";
        if ( !
$result $xoopsDB->query($sqlinsert) )
                        {
                                echo 
_C_ERRORINSERT;
                        }
        
redirect_header("index.php",2,_C_DBUPDATED);

        break;

// ------------------------------------------------------------------------- //
// Show Edit Link Page                                                       //
// ------------------------------------------------------------------------- //
case "elink":
        global 
$xoopsDB;
        
$myts =& MyTextSanitizer::getInstance();
        
xoops_cp_header();

    
$result $xoopsDB->query("SELECT storyid,parent_id,title,ptitle,visible,nocomments,address,submenu FROM ".$xoopsDB->prefix(_MIC_CONTENT_PREFIX)." WHERE storyid=".intval($id));

    list(
$storyid,$parent_id,$title,$ptitle,$visible,$nocomments,$address,$submenu) = $xoopsDB->fetchRow($result);
$mostra gera_menus(0,'','');
$menu "<select name="parent_id">";
            foreach (
$mostra as $key => $value) {
                    if (
$key == $storyid)
                    continue;
                    if (
$key == $parent_id){
                            
$menu .= "<option value="".$key."" selected='selected'>$value</option>";
                    }else{
                            
$menu .= "<option value="".$key."">$value</option>";
                    }
            }
           
$menu .= '</select>';
        
$title=$myts->makeTboxData4Edit($title);
        
$address=$myts->makeTboxData4Edit($address);

        if (
$visible == 1) {
           
$check1 "checked";
          } else {
           
$check1 "";
          }

        if (
$nocomments == 1) {
           
$check2 "checked";
          } else {
           
$check2 "";
          }

        if (
$submenu == 1) {
           
$check3 "checked";
          } else {
           
$check3 "";
          }

        echo 
"<h4>"._C_ADMINTITLE."</h4>";
        echo 
"<form name='form_name' id='form_name' action='index.php' method='post'>";
        echo 
"<table cellspacing='1' width='100%' class='outer'>";
        echo 
"<tr><th colspan='2'>"._C_EDITLINK."</th></tr>";
        echo 
"<tr valign='top' align='left'><td class='head'>Exibir em:</td><td class='even'>$menu</td></tr>";
        echo 
"<tr valign='top' align='left'><td class='head'>"._C_LINKNAME."</td><td class='even'><input type='text' name='title' id='title' size='50' maxlength='30' value='".$title."' /></td></tr>";
        echo 
"<tr valign='top' align='left'><td class='head'>"._C_VISIBLE."</td><td class='even'><input type='checkbox' name='visible' value='1' ".$check1." /></td></tr>";
        echo 
"<tr valign='top' align='left'><td class='head'>"._C_SUBMENU."</td><td class='even'><input type='checkbox' name='submenu' value='1' ".$check3." /></td></tr>";
        echo 
"<tr valign='top' align='left'><td class='head'>"._C_URL."</td><td class='even'><select name='address' size='1' id='address'>";

   
$folder dir("../content/");
        while(
$file $folder->read()) {
      if (
$file != "." && $file != "..") {
             if (
$file == $address) {
                   echo 
"<option value='".$file."' selected>".$file."</option>";
                 } else {
                   echo 
"<option value='".$file."'>".$file."</option>";
                 }
          }
        }

        echo 
"</select></td></tr>";
        echo 
"<tr valign='top' align='left'><td class='head'>"._C_DISABLECOM."</td><td class='even'><input type='checkbox' name='nocomments' value='1' ".$check2." /></td></tr>";
        echo 
"<tr valign='top' align='left'><td class='head'><input type='hidden' name='id' value='".$storyid."' /><input type='hidden' name='op' id='op' value='linkeditit' /></td><td class='even'><input type='submit' name='submit' value='"._SUBMIT."' /></td></tr>";
        echo 
"</table>";
    echo 
"</form>";

        
xoops_cp_footer();
        break;

// ------------------------------------------------------------------------- //
// Do the edit of the PageWrap                                               //
// ------------------------------------------------------------------------- //
case "linkeditit":
        
$myts =& MyTextSanitizer::getInstance();

        
$title=$myts->makeTboxData4Save($title);
        
$address=$myts->makeTboxData4Save($address);

        
$sqlinsert="UPDATE ".$xoopsDB->prefix(_MIC_CONTENT_PREFIX)." SET parent_id='".intval($parent_id)."',title='".$title."',ptitle='".$ptitle."',visible='".intval($visible)."',nocomments='".intval($nocomments)."',address='".$address."',submenu='".$submenu."' WHERE storyid='".intval($id)."'";
        if ( !
$result $xoopsDB->query($sqlinsert) )
                        {

                                echo 
_C_ERRORINSERT;
                        }
        
redirect_header("index.php?op=show",2,_C_DBUPDATED);

        break;

// ------------------------------------------------------------------------- //
// Delete Content - Confirmation Question                                    //
// ------------------------------------------------------------------------- //
case "delete":
        
xoops_cp_header();
        
xoops_confirm(array('id' => intval($id), 'op' => 'deleteit'), 'index.php'_C_RUSUREDEL_YES);
        
xoops_cp_footer();
        break;

// ------------------------------------------------------------------------- //
// Delete it definitely                                                      //
// ------------------------------------------------------------------------- //
case "deleteit":
        global 
$xoopsDB;
    
$result=$xoopsDB->query("DELETE FROM ".$xoopsDB->prefix(_MIC_CONTENT_PREFIX)." WHERE storyid=".intval($id));
        
xoops_comment_delete($xoopsModule->getVar('mid'), $id);
        
redirect_header("index.php?op=show",1,_C_DBUPDATED);
        break;

// ------------------------------------------------------------------------- //
// Admin menu: displayed after click on module logo                          //
// ------------------------------------------------------------------------- //
default:
        
xoops_cp_header();
    echo 
"<h4>"._C_ADMINTITLE."</h4><table width='100%' border='0' cellspacing='1' class='outer'>";
        echo 
"<tr><td class='odd'> - <b><a href='index.php?op=submit'>"._C_MD_ADMENU1."</a></b>";
        echo 
"<br /><br />";
        echo 
" - <b><a href='index.php?op=nlink'>"._C_MD_ADMENU2."</a></b>";
        echo 
"<br /><br />";
        echo 
" - <b><a href='index.php?op=show'>"._C_MD_ADMENU3."</a></b>";
        echo 
"<br /><br />";
        echo 
" - <b><a href='order_menu.php'>"._C_MD_ADMENU4."</a></b>";
        echo 
"<br /><br />";
        echo 
" - <b><a href='migrate.php'>"._C_MD_ADMENU4."</a></b>";
        echo 
"<br /><br />";
        echo 
"- <b><a href='".XOOPS_URL."/modules/system/admin.php?fct=preferences&op=showmod&mod=".$xoopsModule->getVar('mid') ."'>"._PREFERENCES."</a></b></td></tr></table>";

        
xoops_cp_footer();
        break;
}
?>
A thread is for life. Not just for Christmas.

Login

Who's Online

261 user(s) are online (185 user(s) are browsing Support Forums)


Members: 0


Guests: 261


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits