вопрос
I am new to creating modules for Datalife Engine, I am building a module project, I already have the form through which are added to the project and the editing of this, but at the time of loading the images in the Editor, the images are stored in the table "_images, and I want the images to be loaded from the Editor of the module "Projects" are stored in the table "_projects_images.
File: project_add.php
File: doproject_add.php
File SQL
Thanks for your help!
File: project_add.php
<?php
/*
=====================================================
GuilleOz Projects V1.0 - by GuilleOz
=====================================================
*/
if( !defined( 'DATALIFEENGINE' ) OR !defined( 'LOGGED_IN' ) ) {
die( "Hacking attempt!" );
}
if( ! $user_group[$member_id['user_group']]['admin_addnews'] ) {
msg( "error", $lang['index_denied'], $lang['index_denied'] );
}
$id= "";
echoheader( "<i class=\"icon-file-alt\"></i> Módulo Proyectos", "Agregar Proyecto" );
if ( !$user_group[$member_id['user_group']]['allow_html'] ) $config['allow_admin_wysiwyg'] = 0;
if( $config['allow_admin_wysiwyg'] == "2" ) $save = "tinyMCE.triggerSave();"; else $save = "";
require_once (ENGINE_DIR . '/modules/projects/inc/projects.class.php');
echo <<<HTML
<div class="box">
<div class="box-header">
<ul class="nav nav-tabs nav-tabs-left">
<li class="active"><a href="#tabhome" data-toggle="tab"><i class="icon-home"></i> {$lang['tabs_news']}</a></li>
</ul>
</div>
<div class="box-content">
<form method="post" name="project_add" id="project_add" onsubmit="if(checkxf()=='fail') return false;" action="{$PHP_SELF}" class="form-horizontal">
<div class="tab-content">
<div class="tab-pane active" id="tabhome">
<div class="row box-section">
<div class="form-group">
<label class="control-label col-lg-2">Nombre del Proyecto</label>
<div class="col-lg-10">
<input type="text" style="width:99%;max-width:437px;" name="name" id="name">
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-2">Fecha de Inicio</label>
<div class="col-lg-10">
<input data-rel="calendar" type="text" name="start_date" size="20" > <input class="checkbox-inline" type="checkbox" id="allow_date" name="allow_date" value="yes" checked> <label for="allow_date">{$lang['edit_jdate']}</label> <span class="help-button" data-rel="popover" data-trigger="hover" data-placement="right" data-content="Seleccione la fecha en la cual iniciará el proyecto" >?</span>
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-2">Fecha de Finalización</label>
<div class="col-lg-10">
<input data-rel="calendar" type="text" name="finish_date" size="20" > <span class="help-button" data-rel="popover" data-trigger="hover" data-placement="right" data-content="Fecha de Finalización del Proyecto" >?</span>
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-2">SEO URL</label>
<div class="col-lg-10">
<input type="text" size="20" name="alt_url" id="alt_url">.html
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-2">Sitio Web</label>
<div class="col-lg-10">
<input type="text" size="20" name="site_url" id="site_url">
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-2">Icono</label>
<div class="col-lg-10">
<input type="text" size="20" name="icon" id="icon">
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-2">Descripción del Proyecto</label>
<div class="col-lg-10">
HTML;
if( $config['allow_static_wysiwyg'] ) {
include (ENGINE_DIR . '/modules/projects/admin/include/static.php');
} else {
include (ENGINE_DIR . '/inc/include/inserttag.php');
echo <<<HTML
{$bb_code}<textarea style="width:100%;max-width: 950px;height:350px;" name="descr" id="descr" onfocus="setFieldName(this.name)"></textarea><script type=text/javascript>var selField = "descr";</script>
HTML;
}
echo <<<HTML
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-2">Prioridad</label>
<div class="col-lg-10">
{$priority_list}
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-2">Estatus</label>
<div class="col-lg-10">
{$status_list}
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-2">Palabras Clave</label>
<div class="col-lg-10">
<textarea class="tags" name="keywords" id='keywords' style="width:437px;"></textarea>
</div>
</div>
</div>
</div>
<div class="padded">
<input type="submit" class="btn btn-green" value="{$lang['news_add']}" >
<a href="/admin.php?mod=projects" class="btn btn-red"> Regresar </a>
<input type="hidden" name="mod" value="projects">
<input type="hidden" name="action" value="doproject_add">
<input type="hidden" name="user_hash" value="$dle_login_hash" />
</div>
</form>
</div>
</div>
HTML;
echofooter();
?>
File: doproject_add.php
<?php
/*
=====================================================
GuilleOz Projects V1.0 - by GuilleOz
-----------------------------------------------------
http://www.guilleOz.pw/
-----------------------------------------------------
Copyright (c) 2015 GuilleOz.Pw
-----------------------------------------------------
Lisans : GPL License
=====================================================
archivo: engine/projects/adm/panel.php
=====================================================
*/
include_once ENGINE_DIR . '/classes/parse.class.php';
$parse = new ParseFilter( Array (), Array (), 1, 1 );
$name = $parse->process( trim( strip_tags ($_POST['name']) ) );
if ( $config['allow_admin_wysiwyg'] ) $parse->allow_code = false;
$descr = $parse->process( $_POST['descr'] );
$descr = $db->safesql( $parse->BB_Parse( $descr, false ) );
if( $parse->not_allowed_text ) {
msg( "error", $lang['addnews_error'], $lang['news_err_39'], "javascript:history.go(-1)" );
}
$alt_name = $_POST['alt_url'];
if( trim( $alt_name ) == "" or ! $alt_name ) $alt_name = totranslit( stripslashes( $name ), true, false );
else $alt_name = totranslit( stripslashes( $alt_name ), true, false );
$name = $db->safesql( $name );
if( @preg_match( "/[\||\<|\>|\"|\!|\?|\$|\@|\/|\\\|\&\~\*\+]/", $_POST['keywords'] ) ) $_POST['keywords'] = "";
else $_POST['keywords'] = @$db->safesql( htmlspecialchars( strip_tags( stripslashes( trim( $_POST['keywords'] ) ) ), ENT_COMPAT, $config['charset'] ) );
if ( $_POST['keywords'] ) {
$temp_array = array();
$tags_array = array();
$temp_array = explode (",", $_POST['keywords']);
if (count($temp_array)) {
foreach ( $temp_array as $value ) {
if( trim($value) ) $tags_array[] = trim( $value );
}
}
if ( count($tags_array) ) $_POST['keywords'] = implode(", ", $tags_array); else $_POST['keywords'] = "";
}
$ini_date = $_POST['start_date'];
$finish_date = $_POST['finish_date'];
$site_url = $_POST['site_url'];
$icon = $_POST['icon'];
$priority = $_POST['priority'];
$status = $_POST['status'];
// Validamos que el nombre del proyecto no exista en la BD
$row = $db->super_query( "SELECT project_id, name FROM " . PREFIX . "_projects WHERE name = '$name'" );
if( $row['name'] == $name ) {
msg( "error", $lang['cat_error'], "El proyecto <strong>\"" . $name . "\"</strong> ya existe en la base de datos", "javascript:history.go(-1)" );
}
// Validamos que el nombre del Proyecto no este vacio
if( trim( $name ) == "") {
msg( "error", $lang['addnews_error'], "Debe ingresar un nobre para el Proyecto.", "javascript:history.go(-1)" );
}
// Validamos que el nombre del Proyecto no exceda los 255 caracteres
if( dle_strlen( $name, $config['charset'] ) > 255 ) {
msg( "error", $lang['addnews_error'], "El nombre del Proyecto no puede exceder los 255 caracteres.", "javascript:history.go(-1)" );
}
// Validamos la fecha inicial y final
if ($finish_date < $ini_date) {
msg( "error", $lang['cat_error'], "La fecha final no puede ser menor a la fecha inicial del Proyecto", "javascript:history.go(-1)" );
}
// Validamos que el usuario tenga permisos
$have_perm = 0;
if( $user_group[$member_id['user_group']]['allow_all_edit'] ) $have_perm = 1;
if( $user_group[$member_id['user_group']]['allow_edit'] and $item_db[1] == $member_id['name'] ) {
$have_perm = 1;
}
if( !$user_group[$member_id['user_group']]['moderation']) {
$have_perm = 0;
}
// Обработка даты и времени
$added_time = time();
$newdate = $_POST['start_date'];
if( $_POST['allow_date'] != "yes" ) {
if( (($newsdate = strtotime( $newdate )) === - 1) OR !$newsdate ) {
msg( "error", $lang['addnews_error'], $lang['addnews_erdate'], "javascript:history.go(-1)" );
} else {
$thistime = date( "Y-m-d H:i:s", $newsdate );
}
if( ! intval( $config['no_date'] ) and $newsdate > $added_time ) {
$thistime = date( "Y-m-d H:i:s", $added_time );
}
} else
$thistime = date( "Y-m-d H:i:s", $added_time );
////////////////////////////
if( ($member_id['user_group'] == 1) ) {
$have_perm = 1;
}
$db->query( "INSERT INTO " . PREFIX . "_projects (name, alt_name, xfields, icon, site_url, descr, keywords, priority, status, start_date, finish_date) values ('$name', '$alt_name', '$filecontents', '$icon', '$site_url', '$descr', '{$_POST['keywords']}', '$priority', '$status', '$thistime', '$finish_date')" );
$row = $db->insert_id();
if( ! $_SESSION['admin_referrer'] ) {
$_SESSION['admin_referrer'] = "?mod=projects&action=list";
}
msg( "info", $lang['addnews_ok'], "El Proyecto" . " \"" . stripslashes( stripslashes( $name ) ) . "\" " . "se agrego correctamente.", $_SESSION['admin_referrer'] );
?>
File SQL
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `dle_projects`
--
CREATE TABLE IF NOT EXISTS `dle_projects` (
`project_id` mediumint(8) NOT NULL AUTO_INCREMENT,
`posi` mediumint(8) NOT NULL DEFAULT '1',
`name` varchar(50) NOT NULL DEFAULT '',
`alt_name` varchar(50) NOT NULL DEFAULT '',
`xfields` text NOT NULL,
`icon` varchar(200) NOT NULL DEFAULT '',
`site_url` varchar(50) NOT NULL DEFAULT '',
`descr` text NOT NULL,
`keywords` text NOT NULL,
`priority` int(11) NOT NULL DEFAULT '0',
`status` int(11) NOT NULL DEFAULT '0',
`task_num` mediumint(8) NOT NULL DEFAULT '0',
`start_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`finish_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`project_id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=2;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `dle_projects_images`
--
CREATE TABLE IF NOT EXISTS `dle_projects_images` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`images` text NOT NULL,
`project_id` int(10) NOT NULL DEFAULT '0',
`author` varchar(40) NOT NULL DEFAULT '',
`date` varchar(15) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `author` (`author`),
KEY `project_id` (`project_id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=1;
Thanks for your help!