11
chefry
Re: xoops 2.4.3 and article RC 2.0
  • 2010/1/12 14:13

  • chefry

  • Home away from home

  • Posts: 1005

  • Since: 2006/10/14


I can't get the spotlight to work. In fact, when i click on the spotlight tab it goes out of the XOOPS template for the backend (Oxygen)

here's the admin/admin.spotlight.php file. Can someone take a look at it?

Quote:

/**
* Article module for XOOPS
*
* 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.
*
* @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
* @package article
* @since 1.0
* @author Taiwen Jiang
* @version $Id: admin.spotlight.php 2178 2008-09-26 08:34:09Z phppp $
*/

include "header.php";
include_once XOOPS_ROOT_PATH . "/modules/" . $GLOBALS["artdirname"] . "/class/xoopsformloader.php";

$start = intval( @$_GET['start'] );
$article_handler =& xoops_getmodulehandler('article', $GLOBALS["artdirname"]);
$spotlight_handler =& xoops_getmodulehandler('spotlight', $GLOBALS["artdirname"]);

if (!empty($_POST['submit'])) {
$spotlight_current =& $spotlight_handler->get();
if (empty($_POST['option']) || empty($_POST["art_id"])) {
$art_id = 0;
} else {
$art_id = intval($_POST["art_id"]);
}
if ($art_id != $spotlight_current->getVar("art_id")) {
$spotlight_obj =& $spotlight_handler->create();
$spotlight_obj->setVar("art_id", $art_id);
} else {
$spotlight_obj =& $spotlight_current;
}
if ($art_id != $spotlight_current->getVar("art_id") || $spotlight_obj->isNew()) {
$spotlight_obj->setVar("sp_time", time());
}
$sp_categories = empty($_POST["sp_categories"]) ? array() : $_POST["sp_categories"];
$sp_note = $_POST["sp_note"];

$error_upload = "";
$sp_image_file = "";
if (!empty($_FILES['userfile']['name'])) {
require_once XOOPS_ROOT_PATH . "/modules/" . $GLOBALS["artdirname"] . "/class/uploader.php";
$uploader = new art_uploader(
XOOPS_ROOT_PATH . "/" . $xoopsModuleConfig['path_image']
);
if ( $uploader->fetchMedia( $_POST['xoops_upload_file'][0]) ) {
if ( !$uploader->upload() ){
$error_upload = $uploader->getErrors();
} elseif ( file_exists( $uploader->getSavedDestination() )) {
$sp_image_file = $uploader->getSavedFileName();
}
} else {
$error_upload = $uploader->getErrors();
}
}
$sp_image_caption = !empty($_POST["sp_image_caption"]) ? $_POST["sp_image_caption"] : "";
$sp_image_caption_strip = $myts->htmlSpecialChars($myts->stripSlashesGPC($sp_image_caption));
$sp_image["caption"] = $sp_image_caption;
if ($sp_image_file) {
$sp_image["file"] = $sp_image_file;
$spotlight_obj->setVar("sp_image", $sp_image);
} else {
$sp_image["file"] = empty($_POST['sp_image_file'])?"":$_POST['sp_image_file'];
$image = $spotlight_obj->getVar("sp_image");
if ($image["file"]!=$sp_image["file"] || $sp_image_caption_strip!=$sp_image["caption"]) {
$spotlight_obj->setVar("sp_image", $sp_image);
}
}

if ($xoopsUser->getVar("uid") != $spotlight_obj->getVar("uid")) {
$spotlight_obj->setVar("uid", $xoopsUser->getVar("uid"));
}
if (serialize($sp_categories) != serialize($spotlight_obj->getVar("sp_categories"))) {
$spotlight_obj->setVar("sp_categories", $sp_categories);
}
if ($sp_note != $spotlight_obj->getVar("sp_note")) {
$spotlight_obj->setVar("sp_note", $sp_note);
}
if ($sp_image != $spotlight_obj->getVar("sp_image")) {
$spotlight_obj->setVar("sp_image", $sp_image);
}

if ($res = $spotlight_handler->insert($spotlight_obj)) {
if ($art_id > 0 && !empty($xoopsModuleConfig['notification_enabled'])) {
$notification_handler =& xoops_gethandler('notification');
$tags = array();
$article_obj =& $article_handler->get($spotlight_obj->getVar("art_id"));
$tags['ARTICLE_TITLE'] = $article_obj->getVar("art_title");
$tags['ARTICLE_URL'] = XOOPS_URL . '/modules/' . $GLOBALS["artdirname"] . '/view.article.php' . URL_DELIMITER . $art_id;
$tags['ARTICLE_ACTION'] = art_constant("MD_NOT_ACTION_PUBLISHED");
$notification_handler->triggerEvent('global', 0, 'article_monitor', $tags);
$notification_handler->triggerEvent('article', $art_id, 'article_monitor', $tags);
}
}
redirect_header( "admin.spotlight.php", 1 , art_constant("AM_DBUPDATED") );
}

xoops_cp_header();
require XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->getVar("dirname") . "/include/vars.php";
loadModuleAdminMenu(6);

$spotlight_obj =& $spotlight_handler->get();

echo "
" . art_constant("AM_SPOTLIGHT") . "";
echo "
";

$form_sp = new XoopsThemeForm(art_constant("AM_SPOTLIGHT"), "formsp", xoops_getenv('PHP_SELF'));
$form_sp->setExtra('enctype="multipart/form-data"');

// Current Spotlight
if ($spotlight_obj->getVar("art_id")) {
$option = 1;
$article_obj =& $article_handler->get($spotlight_obj->getVar("art_id"));
$message = "" . $article_obj->getVar('art_title') . "";
} else {
$option = 0;
$message = art_constant("AM_SPOTLIGHT_LASTARTICLE");
}
if (!$spotlight_obj->isNew()) {
$uid = $spotlight_obj->getVar("uid");
if ($xoopsUser->getVar("uid") == $uid) {
$uname = $xoopsUser->getVar("uname");
} else {
$uname = XoopsUser::getUnameFromId($uid);
}
$form_sp->addElement(new XoopsFormLabel(art_constant("AM_SPOTLIGHT_CURRENT"), "" . $uname . " - " . $spotlight_obj->getTime() . ": " . $message));
}

// Image
if (!empty($xoopsModuleConfig['path_image'])) {
$sp_image = $spotlight_obj->getImage();

$image_option_tray = new XoopsFormElementTray(art_constant("AM_IMAGE_UPLOAD"), '
');
$image_option_tray->addElement(new XoopsFormFile('', 'userfile',''));
$form_sp->addElement($image_option_tray);
$form_sp->addElement(new XoopsFormText(art_constant("AM_IMAGE_CAPTION"), "sp_image_caption", 50, 255, @$sp_image["caption"]));
unset($image_tray);
unset($image_option_tray);

$image_option_tray = new XoopsFormElementTray(art_constant("AM_IMAGE_SELECT"), "
");
$image_array =& XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . "/". $xoopsModuleConfig["path_image"] . "/");
array_unshift($image_array, _NONE);
$image_select = new XoopsFormSelect("", "sp_image_file", @$sp_image["file"]);
$image_select->addOptionArray($image_array);
$image_select->setExtra("onchange="showImgSelected('img', 'sp_image_file', '/" . $xoopsModuleConfig["path_image"] . "/', '', '" . XOOPS_URL . "')"");
$image_tray = new XoopsFormElementTray("", " 
");
$image_tray->addElement($image_select);
if (!empty($sp_image["url"])) {
$label = "
" . (empty($sp_image["caption"]) ? "" : "
" . $sp_image["caption"]);
} else {
$label = "
";
}
$image_tray->addElement(new XoopsFormLabel(art_constant("AM_IMAGE_CURRENT"), $label));
$image_option_tray->addElement($image_tray);
$form_sp->addElement($image_option_tray);
}

// Options
$spot_options = array(0=>art_constant("AM_SPOTLIGHT_LASTARTICLE"), 1=>art_constant("AM_SPOTLIGHT_SPECIFIED"));
$option_select = new XoopsFormSelect(art_constant("AM_SPOTLIGHT_OPTION"), 'option', $option);
$option_select->addOptionArray($spot_options);
$form_sp->addElement($option_select);

// CATEGORIES
$category_handler =& xoops_getmodulehandler('category', $GLOBALS["artdirname"]);
$categories =& $category_handler->getTree(0, "all");
$cat_option = array();
$cat_option[0] = _ALL;
foreach ($categories as $id => $cat) {
$cat_option[$id] = $cat['prefix'] . $cat['cat_title'];
}
$cat_select = new XoopsFormSelect(art_constant("AM_SPOTLIGHT_CATEGORIES"), 'sp_categories', $spotlight_obj->getVar("sp_categories"), 5, true);
$cat_select->addOptionArray($cat_option);
$form_sp->addElement($cat_select);

// Editor's Note
$form_sp->addElement(new XoopsFormTextArea(art_constant("AM_SPOTLIGHT_NOTE"), "sp_note", $spotlight_obj->getVar("sp_note")));

$criteria = new CriteriaCompo(new Criteria('art_time_publish', 0, ">"));
if (count($spotlight_obj->getVar("sp_categories")) > 0) {
$criteria->add(new Criteria('cat_id', '(' . implode(',', $spotlight_obj->getVar("sp_categories")) . ')', '>'), "AND");
}
$articles_count = $article_handler->getCount($criteria);
if ($articles_count > 0) {
$tags = array("art_title","cat_id");
$criteria->setStart($start);
$criteria->setLimit($xoopsModuleConfig["articles_perpage"]);
$articles_obj =& $article_handler->getAll($criteria, $tags);
foreach ( $articles_obj as $id => $article ) {
$cat_id[]=$article->getVar('cat_id');
}
$criteria = new Criteria("cat_id", "(" . implode(",", $cat_id) . ")", "IN");
$categories = $category_handler->getList($criteria);

$heading = array( "ID", art_constant("AM_TITLE"), art_constant("AM_CATEGORY"), art_constant("AM_SPOTIT") );
$article_table = "\n";
$article_table .= "\n";
$article_table .= "\n";
for ( $i = 0; $i < count( $heading ); $i++ ) {
$article_table .= "";
}
$article_table .= "";

foreach( $articles_obj as $id => $article ) {
$article_table .= "\n";
$article_table .= "";

if ( $spotlight_obj->getVar("art_id") == $id ) {
$selected = "checked";
} else {
$selected = "";
}
$article_table .= "";
}
$article_table .= "\n
" . $heading[$i] . "
" . $id . "";
$article_table .= "
" . $article->getVar('art_title');
$article_table .= "
" . $categories[$article->getVar('cat_id')];
$article_table .= "
";
$article_table .= "

\n";
if ( $articles_count > $xoopsModuleConfig['articles_perpage']) {
include XOOPS_ROOT_PATH . '/class/pagenav.php';
$nav = new XoopsPageNav($articles_count, $xoopsModuleConfig['articles_perpage'], $start, "start");
$article_table .= $nav->renderNav(4);
}
$article_table .= "\n\n";

$form_sp->addElement( $article_table );
}

$button_tray = new XoopsFormElementTray('', '');
$button_tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
$button_tray->addElement(new XoopsFormButton('', '', _CANCEL, 'button'));
$form_sp->addElement($button_tray);

$form_sp->display();

echo "
";
echo "

";

xoops_cp_footer();
?>

Login

Who's Online

177 user(s) are online (71 user(s) are browsing Support Forums)


Members: 0


Guests: 177


more...

Donat-O-Meter

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

Latest GitHub Commits