1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-16 20:28:28 +01:00

Submit-news working again. Admin Newspost re-work (needs testing), additional JS for dialogs etc.

This commit is contained in:
CaMer0n 2012-05-17 09:19:44 +00:00
parent f8b32d89ce
commit 6b6701f900
10 changed files with 928 additions and 51 deletions

View File

@ -19,6 +19,12 @@ require_once('../class2.php');
//TODO - marj prepare language reorganisation
//include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE);
if($_GET['iframe'] == 1)
{
define('e_IFRAME', true);
}
$e_sub_cat = 'main';
require_once('auth.php');
require_once(e_HANDLER.'admin_handler.php');

View File

@ -245,10 +245,6 @@ class media_admin_ui extends e_admin_ui
// //protected $editQry = "SELECT * FROM #comments WHERE comment_id = {ID}";
// protected $tableJoin = array(
// 'u.user' => array('leftField' => 'media_author', 'rightField' => 'user_id', 'fields' => 'user_id,user_loginname,user_name')
// );
protected $pid = "media_id";
protected $perPage = 10;
protected $batchDelete = true;
@ -673,7 +669,7 @@ class media_admin_ui extends e_admin_ui
{
if(!$sc_path) return array();
$path = e107::getParser()->replaceConstants($sc_path);
$info = e107::getFile()->get_file_info($path);
$info = e107::getFile()->get_file_info($path,true);
return array(
'media_type' => $info['mime'],
'media_datestamp' => time(),

View File

@ -202,7 +202,15 @@ $text .= render_infopanel_options();
$text .= "</form>";
$text .= "</div>";
$ns->tablerender(ADLAN_47." ".ADMINNAME, $emessage->render().$text);
if($_GET['mode'] != 'customize')
{
$ns->tablerender(ADLAN_47." ".ADMINNAME, $emessage->render().$text);
}
else
{
echo render_infopanel_options(true);
}
@ -223,12 +231,21 @@ function render_info_panel($caption, $text)
// ------------------
function render_infopanel_options()
function render_infopanel_options($render = false)
{
$frm = e107::getSingleton('e_form');
$start = "<div>To customize this page, please <a href='#customize_icons' class='e-expandit'>click here</a>.</div>
<div class='e-hideme' id='customize_icons' style='border:1px solid silver;margin:10px'>";
$text2 = "<h2>Icons</h2>";
// $frm = e107::getSingleton('e_form');
$frm = e107::getForm();
$mes = e107::getMessage();
$start = "<div>
To customize this page, please <a title = 'Customize Admin' href='".e_SELF."?mode=customize&iframe=1' class='e-modal-iframe'>click here</a>.
</div>
";
if($render == false){ return $start; }
$text2 = "<div id='customize_icons' class='forumheader3' style='border:0px;margin:0px'>
<form method='post' 'id='e-modal-form' action='".e_SELF."?".e_QUERY."'>
<h2>Icons</h2>";
$text2 .= render_infopanel_icons();
$text2 .= "<div class='clear'>&nbsp;</div>";
$text2 .= "<h2>Menus</h2>";
@ -236,10 +253,11 @@ function render_infopanel_options()
$text2 .= "<div class='clear'>&nbsp;</div>";
$text2 .= "<div id='button' class='buttons-bar center'>";
$text2 .= $frm->admin_button('submit-mye107', 'Save', 'Save');
$text2 .= "</div>";
$text2 .= "</div></form></div>";
$end = "</div>";
return $start.render_info_panel("Customize", $text2).$end;
return $mes->render().$text2.$end;
}

View File

@ -41,6 +41,477 @@ if($newspost->ajax_observer()) exit;
e107::js('core','core/admin.js','prototype');
//e107::getJs()->requireCoreLib('core/admin.js');
class news_admin extends e_admin_dispatcher
{
protected $modes = array(
'main' => array(
'controller' => 'news_admin_ui',
'path' => null,
'ui' => 'news_form_ui',
'uipath' => null
),
'cat' => array(
'controller' => 'news_cat_ui',
'path' => null,
'ui' => 'news_cat_form_ui',
'uipath' => null
),
'sub' => array(
'controller' => 'news_sub_ui',
'path' => null,
'ui' => 'news_sub_form_ui',
'uipath' => null
)
);
protected $adminMenu = array(
'main/list' => array('caption'=> NWSLAN_44, 'perm' => 'H'),
'main/create' => array('caption'=> NWSLAN_45, 'perm' => 'H'), // Create/Edit News Item
// 'cat/list' => array('caption'=> NWSLAN_46, 'perm' => '7'), // Category List
'cat/list' => array('caption'=> NWSLAN_46, 'perm' => '7'), // Create Category.
'cat/create' => array('caption'=> "Create Category", 'perm' => '7'), // Category List
'main/settings' => array('caption'=> LAN_PREFS, 'perm' => '0'), // Preferences
'main/submitted' => array('caption'=> "Old Submitted ", 'perm' => 'N'), // Submitted News
'sub/list' => array('caption'=> NWSLAN_47, 'perm' => 'N'), // Submitted News
// 'main/maint' => array('caption'=> LAN_NEWS_55, 'perm' => '0') // Maintenance
);
protected $adminMenuAliases = array(
'main/edit' => 'main/list',
'cat/edit' => 'cat/list'
);
protected $menuTitle = "News";
}
class news_cat_ui extends e_admin_ui
{
protected $pluginTitle = 'News Categories';
protected $pluginName = 'core';
protected $table = "news_category";
protected $pid = "category_id";
protected $perPage = 0; //no limit
protected $batchDelete = false;
protected $fields = array(
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
'category_id' => array('title'=> LAN_ID, 'type' => 'number', 'width' =>'5%', 'forced'=> TRUE, 'readonly'=>TRUE),
'category_icon' => array('title'=> LAN_ICON, 'type' => 'icon', 'data' => 'str', 'width' => '100px', 'thclass' => 'center', 'class'=>'center', 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60','readonly'=>FALSE, 'batch' => FALSE, 'filter'=>FALSE),
'category_name' => array('title'=> LAN_TITLE, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE),
'category_meta_description' => array('title'=> LAN_DESCRIPTION, 'type' => 'textarea', 'width' => 'auto', 'thclass' => 'left','readParms' => 'expand=...&truncate=150&bb=1', 'readonly'=>FALSE),
'category_meta_keywords' => array('title'=> "Meta Keywords", 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE),
'category_sef' => array('title'=> "SEF Url String", 'type' => 'text', 'width' => 'auto', 'readonly'=>FALSE), // Display name
'category_manager' => array('title'=> "Manage Permissions",'type' => 'userclass', 'width' => 'auto', 'data' => 'int','batch'=>TRUE, 'filter'=>TRUE),
'category_order' => array('title'=> LAN_ORDER, 'type' => 'text', 'width' => 'auto', 'thclass' => 'right', 'class'=> 'right' ),
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'center')
);
protected $fieldpref = array('checkboxes', 'category_icon', 'category_id', 'category_name', 'category_description','category_manager', 'category_order', 'options');
protected $newspost;
function init()
{
$this->newspost = new admin_newspost;
}
// function createPage()
// {
// $this->newspost->show_categories();
// }
public function beforeCreate($new_data)
{
}
public function beforeUpdate($new_data, $old_data, $id)
{
}
}
class news_cat_form_ui extends e_admin_form_ui
{
}
// Submitted News Area.
class news_sub_ui extends e_admin_ui
{
protected $pluginTitle = NWSLAN_47;
protected $pluginName = 'core';
protected $table = "submitnews";
protected $pid = "submitnews_id";
protected $perPage = 20; //no limit
protected $batchDelete = true;
protected $formQuery = "mode=main&amp;action=create";
protected $listOrder = "submitnews_id desc";
// submitnews_id submitnews_name submitnews_email submitnews_title submitnews_category submitnews_item submitnews_datestamp submitnews_ip submitnews_auth submitnews_file
protected $fields = array(
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
'submitnews_id' => array('title'=> LAN_ID, 'type' => 'number', 'width' =>'5%', 'forced'=> TRUE, 'readonly'=>TRUE),
'submitnews_title' => array('title'=> LAN_TITLE, 'type' => 'method', 'width' => '65%', 'thclass' => 'left', 'readonly'=>TRUE),
'submitnews_datestamp' => array('title' => LAN_NEWS_32, 'type' => 'date', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'),
'submitnews_category' => array('title'=> LAN_CATEGORY, 'type' => 'dropdown', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE),
// 'submitnews_item' => array('title'=> LAN_DESCRIPTION, 'type' => 'method', 'width' => 'auto', 'thclass' => 'left','readParms' => 'expand=...&truncate=150&bb=1', 'readonly'=>TRUE),
'submitnews_name' => array('title'=> LAN_AUTHOR, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>TRUE),
'submitnews_ip' => array('title'=> "IP", 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>TRUE),
'submitnews_auth' => array('title'=> "User", 'type' => 'user', 'width' => 'auto', 'thclass' => 'right', 'class'=> 'right' ),
'options' => array('title'=> LAN_OPTIONS, 'type' => "method", 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'center')
);
protected $fieldpref = array('checkboxes', 'submitnews_id', 'submitnews_title', 'submitnews_category', 'options');
protected $newspost;
protected $cats;
function init()
{
$sql = e107::getDb();
$sql->db_Select_gen("SELECT category_id,category_name FROM #news_category");
while($row = $sql->db_Fetch())
{
$cat = $row['category_id'];
$this->cats[$cat] = $row['category_name'];
}
asort($this->cats);
$this->fields['submitnews_category']['writeParms'] = $this->cats;
$this->newspost = new admin_newspost;
}
// function createPage()
// {
// $this->newspost->show_categories();
// }
public function beforeCreate($new_data)
{
}
public function beforeUpdate($new_data, $old_data, $id)
{
}
}
class news_sub_form_ui extends e_admin_form_ui
{
function submitnews_title($cur,$val)
{
$tp = e107::getParser();
$row = $this->getController()->getListModel();
$submitnews_id = $row->get('submitnews_id');
$submitnews_title = $row->get('submitnews_title');
$submitnews_file = $row->get('submitnews_file');
$submitnews_item = $row->get('submitnews_item');
$text .= "<a href='#submitted_".$submitnews_id."' class='e-modal' >";
$text .= $tp->toHTML($submitnews_title,FALSE,'emotes_off, no_make_clickable');
$text .= '</a>';
$text .= "<div id='submitted_".$submitnews_id."' title='".$tp->toAttribute($submitnews_title)."' style='display:none'>".$tp->toHTML($submitnews_item,TRUE);
if($submitnews_file)
{
$tmp = explode(',',$submitnews_file);
$text .= "<br />";
foreach($tmp as $imgfile)
{
$text .= "<br /><img src='".e_UPLOAD.$imgfile."' alt='".$imgfile."' />";
}
}
$text .= "\n</div>";
return $text;
}
// Override the default Options field.
function options($parms, $value, $id, $attributes)
{
if($attributes['mode'] == 'read')
{
$approved = $this->getController()->getListModel()->get('submitnews_auth'); // approved;
if($approved == 0)
{
$text = $this->submit_image('submitnews['.$id.']', 1, 'execute', NWSLAN_58);
// NWSLAN_103;
}
else // Already submitted;
{
}
$text .= $this->submit_image('etrigger_delete['.$id.']', $id, 'delete', LAN_DELETE.' [ ID: '.$id.' ]', array('class' => 'action delete'.$delcls));
return $text;
}
}
}
// Main News Area.
class news_admin_ui extends e_admin_ui
{
protected $pluginTitle = 'Media Categories';
protected $pluginName = 'core';
protected $table = "news";
protected $pid = "news_id";
protected $perPage = 20; //no limit
protected $batchDelete = true;
protected $batchCopy = true;
protected $listOrder = "news_id desc";
protected $listQry = "SELECT n.*,u.user_id,u.user_name FROM #news AS n LEFT JOIN #user AS u ON n.news_author = u.user_id "; // without any Order or Limit.
protected $fields = array(
'checkboxes' => array('title' => '', 'type' => null, 'width' => '3%', 'thclass' => 'center first', 'class' => 'center', 'nosort' => true, 'toggle' => 'news_selected', 'forced' => TRUE),
'news_id' => array('title' => LAN_NEWS_45, 'type' => 'number', 'width' => '5%', 'thclass' => 'center', 'class' => 'center', 'nosort' => false),
'news_thumbnail' => array('title' => NWSLAN_67, 'type' => 'image', 'width' => '110px', 'thclass' => 'center', 'class' => "center", 'nosort' => false, 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60','writeParams' => 'path={e_MEDIA}','readonly'=>false),
'news_title' => array('title' => NWSLAN_40, 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_summary' => array('title' => LAN_NEWS_27, 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_meta_keywords' => array('title' => LAN_KEYWORDS, 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_meta_description' => array('title' => LAN_DESCRIPTION,'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_sef' => array('title' => 'SEF URL', 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'user_name' => array('title' => LAN_NEWS_50, 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_datestamp' => array('title' => LAN_NEWS_32, 'type' => 'datestamp', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'),
'news_category' => array('title' => NWSLAN_6, 'type' => 'dropdown', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'batch'=>true, 'filter'=>true),
'news_start' => array('title' => "Start", 'type' => 'datestamp', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'),
'news_end' => array('title' => "End", 'type' => 'datestamp', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'),
'news_class' => array('title' => NWSLAN_22, 'type' => 'userclass', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'batch'=>true, 'filter'=>true),
'news_render_type' => array('title' => LAN_NEWS_49, 'type' => 'dropdown', 'data' => 'int', 'width' => 'auto', 'thclass' => 'center', 'class' => null, 'nosort' => false, 'batch'=>true, 'filter'=>true),
'news_sticky' => array('title' => LAN_NEWS_28, 'type' => 'boolean', 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false, 'batch'=>true, 'filter'=>true),
'news_allow_comments' => array('title' => NWSLAN_15, 'type' => 'boolean', 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false),
'news_comment_total' => array('title' => LAN_NEWS_60, 'type' => 'number', 'width' => '10%', 'thclass' => '', 'class' => null, 'nosort' => false),
'options' => array('title' => LAN_OPTIONS, 'type' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center', 'nosort' => true, 'forced' => TRUE)
);
protected $cats = array();
protected $newspost;
function init()
{
$sql = e107::getDb();
$sql->db_Select_gen("SELECT category_id,category_name FROM #news_category");
while($row = $sql->db_Fetch())
{
$cat = $row['category_id'];
$this->cats[$cat] = $row['category_name'];
}
asort($this->cats);
$this->fields['news_category']['writeParms'] = $this->cats;
$this->fields['news_render_type']['writeParms'] = array(NWSLAN_75,NWSLAN_76,NWSLAN_77,NWSLAN_77." 2");
$this->newspost = new admin_newspost;
$this->newspost->observer();
}
function createPage()
{
// print_a($_POST);
if(isset($_POST['submitnews']))
{
$id = key($_POST['submitnews']);
$this->loadSubmitted($id);
}
else
{
$this->preCreate();
}
$this->newspost->show_create_item();
}
function categoryPage()
{
if(!getperms('0|7'))
{
$this->noPermissions();
}
$this->newspost->show_categories();
// $newspost->show_create_item();
}
function submittedPage()
{
$this->newspost->show_submitted_news();
}
function maintPage()
{
}
function settingsPage()
{
$this->newspost->show_news_prefs();
}
function noPermissions($qry = '')
{
$url = e_SELF.($qry ? '?'.$qry : '');
if($qry !== e_QUERY)
{
$mes = e107::getMessage();
$this->show_message('Insufficient permissions!', E_MESSAGE_ERROR, true);
session_write_close();
header('Location: '.$url);
}
exit;
}
function loadSubmitted($id)
{
$sql = e107::getDb();
$tp = e107::getParser();
if ($sql->db_Select("submitnews", "*", "submitnews_id=".intval($id), TRUE))
{
//list($id, $submitnews_name, $submitnews_email, $_POST['news_title'], $submitnews_category, $_POST['news_body'], $submitnews_datestamp, $submitnews_ip, $submitnews_auth, $submitnews_file) = $sql->db_Fetch();
$row = $sql->db_Fetch();
$_POST['news_title'] = $row['submitnews_title'];
$_POST['news_body'] = $row['submitnews_item'];
$_POST['cat_id'] = $row['submitnews_category'];
if (defsettrue('e_WYSIWYG'))
{
if (substr($_POST['news_body'],-7,7) == '[/html]') $_POST['news_body'] = substr($_POST['news_body'],0,-7);
if (substr($_POST['news_body'],0,6) == '[html]') $_POST['news_body'] = substr($_POST['news_body'],6);
$_POST['news_body'] .= "<br /><b>".NWSLAN_49." {$row['submitnews_name']}</b>";
$_POST['news_body'] .= ($row['submitnews_file'])? "<br /><br /><img src='{e_NEWSIMAGE}{$row['submitnews_file']}' class='f-right' />": '';
}
else
{
$_POST['news_body'] .= "\n[[b]".NWSLAN_49." {$row['submitnews_name']}[/b]]";
if($row['submitnews_file'])
{
$files = explode(",",$row['submitnews_file']);
foreach($files as $f)
{
if($bbpath = e107::getMedia()->importFile($f,'news'))
{
$_POST['news_body'] .= "\n\n[img]".$bbpath."[/img]";
}
}
}
}
$_POST['data'] = $tp->dataFilter($_POST['data']); // Filter any nasties
$_POST['news_title'] = $tp->dataFilter($_POST['news_title']);
}
}
function preCreate()
{
if($_GET['action'] == "edit" && !$_POST['preview'])
{
if(!isset($_POST['submit_news']))
{
if(e107::getDb()->db_Select('news', '*', 'news_id='.intval($_GET['id'])))
{
$row = e107::getDb()->db_Fetch();
// if(!isset($this->news_categories[$row['news_category']]))
{
// $this->noPermissions();
}
$_POST['news_title'] = $row['news_title'];
$_POST['news_sef'] = $row['news_sef'];
$_POST['news_body'] = $row['news_body'];
$_POST['news_author'] = $row['news_author'];
$_POST['news_extended'] = $row['news_extended'];
$_POST['news_allow_comments'] = $row['news_allow_comments'];
$_POST['news_class'] = $row['news_class'];
$_POST['news_summary'] = $row['news_summary'];
$_POST['news_sticky'] = $row['news_sticky'];
$_POST['news_datestamp'] = ($_POST['news_datestamp']) ? $_POST['news_datestamp'] : $row['news_datestamp'];
$_POST['cat_id'] = $row['news_category'];
$_POST['news_start'] = $row['news_start'];
$_POST['news_end'] = $row['news_end'];
$_POST['comment_total'] = e107::getDb()->db_Count("comments", "(*)", " WHERE comment_item_id={$row['news_id']} AND comment_type='0'");
$_POST['news_render_type'] = $row['news_render_type'];
$_POST['news_thumbnail'] = $row['news_thumbnail'];
$_POST['news_meta_keywords'] = $row['news_meta_keywords'];
$_POST['news_meta_description'] = $row['news_meta_description'];
}
}
}
}
}
class news_form_ui extends e_admin_form_ui
{
}
new news_admin();
require_once(e_ADMIN."auth.php");
e107::getAdminUI()->runPage();
if(!e_AJAX_REQUEST) require_once("footer.php");
exit;
function headerjs()
{
@ -1768,7 +2239,8 @@ class admin_newspost
";
$emessage = eMessage::getInstance();
$e107->ns->tablerender($this->getSubAction() == 'edit' ? NWSLAN_29a : NWSLAN_29, $emessage->render().$text);
echo $emessage->render().$text;
// $e107->ns->tablerender($this->getSubAction() == 'edit' ? NWSLAN_29a : NWSLAN_29, $emessage->render().$text);
}
@ -2056,8 +2528,9 @@ class admin_newspost
";
e107::getRender()->tablerender(NWSLAN_46a, e107::getMessage()->render().$text);
echo e107::getMessage()->render().$text;
// e107::getRender()->tablerender(NWSLAN_46a, e107::getMessage()->render().$text);
}
function show_categoriy_list()
@ -2110,8 +2583,15 @@ class admin_newspost
<td class='center middle'>{$icon}</td>
<td class='middle'>{$url}</td>
<td class='middle'>".$frm->uc_select('multi_category_manager['.$category['category_id'].']', vartrue($category['category_manager'], e_UC_ADMIN), 'main,admin,classes')."</td>
<td class='center middle'>
<a class='action' id='core-news-catedit-{$category['category_id']}' href='".e_SELF."?cat.edit.{$category['category_id']}' tabindex='".$frm->getNext()."'>".defset('ADMIN_EDIT_ICON', '<img src="'.e_IMAGE_ABS.'admin_images/edit_16.png" alt="Edit" />')."</a>
<td class='center middle'>";
$text .= "<a class='action' id='core-news-catedit-{$category['category_id']}' href='".e_SELF."?mode=cat&amp;action=edit&amp;id={$category['category_id']}' tabindex='".$frm->getNext()."'>".defset('ADMIN_EDIT_ICON', '<img src="'.e_IMAGE_ABS.'admin_images/edit_16.png" alt="Edit" />')."</a>";
// $text .= "<a class='action' id='core-news-catedit-{$category['category_id']}' href='".e_SELF."?cat.edit.{$category['category_id']}' tabindex='".$frm->getNext()."'>".defset('ADMIN_EDIT_ICON', '<img src="'.e_IMAGE_ABS.'admin_images/edit_16.png" alt="Edit" />')."</a>";
$text .= "
".$frm->submit_image("delete[category_{$category['category_id']}]", $category['category_id'], 'delete', e107::getParser()->toJS(NWSLAN_37." [ID: {$category['category_id']} ]"))."
</td>
<td class='middle center'>".$frm->text('multi_category_order['.$category['category_id'].']', $category['category_order'], 3, 'size=2&tabindex='.$tindex)."</td>
@ -2292,7 +2772,8 @@ class admin_newspost
</fieldset>
</form>
";
e107::getRender()->tablerender(NWSLAN_90, e107::getMessage()->render().$text);
echo e107::getMessage()->render().$text;
// e107::getRender()->tablerender(NWSLAN_90, e107::getMessage()->render().$text);
}

View File

@ -1102,6 +1102,54 @@ $text .= "
</fieldset>
";
// File Uploads
include_lan(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_upload.php");
$text .= "
<fieldset class='e-hideme' id='core-prefs-uploads'>
<legend>File Uploading</legend>
<table class='adminform'>
<colgroup>
<col class='col-label' />
<col class='col-control' />
</colgroup>
<tbody>
<tr>
<td class='label'>".UPLLAN_25."</td>
<td class='control'>".
$frm->radio_switch('upload_enabled', $pref['upload_enabled'], LAN_YES, LAN_NO)
."
<div class='field-help'>".UPLLAN_26."</div>
</td>
</tr>
<tr>
<td class='label'>".UPLLAN_33."<br />
</td>
<td class='control'>".
$frm->text('upload_maxfilesize', $pref['upload_maxfilesize'], 10)
."
<div class='field-help'>".UPLLAN_34." (upload_max_filesize = ".ini_get('upload_max_filesize').", post_max_size = ".ini_get('post_max_size')." )</div>
</td>
</tr>
<tr>
<td class='label'>".UPLLAN_37."</td>
<td class='control'>".r_userclass("upload_class", $pref['upload_class'],"off","nobody,public,guest,member,admin,classes")."
<div class='field-help'>".UPLLAN_38."</div>
</td>
</tr>
</tbody>
</table>
".pref_submit('uploads')."
</fieldset>";
// Javascript Control
//TODO LANS
$text .= "
@ -1353,6 +1401,7 @@ function prefs_adminmenu()
$var['core-prefs-textpost']['text'] = PRFLAN_101;
$var['core-prefs-security']['text'] = PRFLAN_47;
$var['core-prefs-comments']['text'] = PRFLAN_210;
$var['core-prefs-uploads']['text'] = "File Uploading"; // TODO LAN
$var['core-prefs-javascript']['text'] = "Javascript Framework"; // TODO LAN
$var['core-prefs-advanced']['text'] = PRFLAN_149;
e_admin_menu(LAN_OPTIONS.'--id--prev_nav', 'core-prefs-main', $var);

View File

@ -445,7 +445,7 @@ CREATE TABLE submitnews (
submitnews_datestamp int(10) unsigned NOT NULL default '0',
submitnews_ip varchar(45) NOT NULL default '',
submitnews_auth tinyint(3) unsigned NOT NULL default '0',
submitnews_file varchar(100) NOT NULL default '',
submitnews_file text NOT NULL,
PRIMARY KEY (submitnews_id)
) ENGINE=MyISAM;
# --------------------------------------------------------

View File

@ -0,0 +1,162 @@
/**
* @name Elastic
* @descripton Elastic is jQuery plugin that grow and shrink your textareas automatically
* @version 1.6.11
* @requires jQuery 1.2.6+
*
* @author Jan Jarfalk
* @author-email jan.jarfalk@unwrongest.com
* @author-website http://www.unwrongest.com
*
* @licence MIT License - http://www.opensource.org/licenses/mit-license.php
*/
(function($){
jQuery.fn.extend({
elastic: function() {
// We will create a div clone of the textarea
// by copying these attributes from the textarea to the div.
var mimics = [
'paddingTop',
'paddingRight',
'paddingBottom',
'paddingLeft',
'fontSize',
'lineHeight',
'fontFamily',
'width',
'fontWeight',
'border-top-width',
'border-right-width',
'border-bottom-width',
'border-left-width',
'borderTopStyle',
'borderTopColor',
'borderRightStyle',
'borderRightColor',
'borderBottomStyle',
'borderBottomColor',
'borderLeftStyle',
'borderLeftColor'
];
return this.each( function() {
// Elastic only works on textareas
if ( this.type !== 'textarea' ) {
return false;
}
var $textarea = jQuery(this),
$twin = jQuery('<div />').css({
'position' : 'absolute',
'display' : 'none',
'word-wrap' : 'break-word',
'white-space' :'pre-wrap'
}),
lineHeight = parseInt($textarea.css('line-height'),10) || parseInt($textarea.css('font-size'),'10'),
minheight = parseInt($textarea.css('height'),10) || lineHeight*3,
maxheight = parseInt($textarea.css('max-height'),10) || Number.MAX_VALUE,
goalheight = 0;
// Opera returns max-height of -1 if not set
if (maxheight < 0) { maxheight = Number.MAX_VALUE; }
// Append the twin to the DOM
// We are going to meassure the height of this, not the textarea.
$twin.appendTo($textarea.parent());
// Copy the essential styles (mimics) from the textarea to the twin
var i = mimics.length;
while(i--){
$twin.css(mimics[i].toString(),$textarea.css(mimics[i].toString()));
}
// Updates the width of the twin. (solution for textareas with widths in percent)
function setTwinWidth(){
var curatedWidth = Math.floor(parseInt($textarea.width(),10));
if($twin.width() !== curatedWidth){
$twin.css({'width': curatedWidth + 'px'});
// Update height of textarea
update(true);
}
}
// Sets a given height and overflow state on the textarea
function setHeightAndOverflow(height, overflow){
var curratedHeight = Math.floor(parseInt(height,10));
if($textarea.height() !== curratedHeight){
$textarea.css({'height': curratedHeight + 'px','overflow':overflow});
}
}
// This function will update the height of the textarea if necessary
function update(forced) {
// Get curated content from the textarea.
var textareaContent = $textarea.val().replace(/&/g,'&amp;').replace(/ {2}/g, '&nbsp;').replace(/<|>/g, '&gt;').replace(/\n/g, '<br />');
// Compare curated content with curated twin.
var twinContent = $twin.html().replace(/<br>/ig,'<br />');
if(forced || textareaContent+'&nbsp;' !== twinContent){
// Add an extra white space so new rows are added when you are at the end of a row.
$twin.html(textareaContent+'&nbsp;');
// Change textarea height if twin plus the height of one line differs more than 3 pixel from textarea height
if(Math.abs($twin.height() + lineHeight - $textarea.height()) > 3){
var goalheight = $twin.height()+lineHeight;
if(goalheight >= maxheight) {
setHeightAndOverflow(maxheight,'auto');
} else if(goalheight <= minheight) {
setHeightAndOverflow(minheight,'hidden');
} else {
setHeightAndOverflow(goalheight,'hidden');
}
}
}
}
// Hide scrollbars
$textarea.css({'overflow':'hidden'});
// Update textarea size on keyup, change, cut and paste
$textarea.bind('keyup change cut paste', function(){
update();
});
// Update width of twin if browser or textarea is resized (solution for textareas with widths in percent)
$(window).bind('resize', setTwinWidth);
$textarea.bind('resize', setTwinWidth);
$textarea.bind('update', update);
// Compact textarea on blur
$textarea.bind('blur',function(){
if($twin.height() < maxheight){
if($twin.height() > minheight) {
$textarea.height($twin.height());
} else {
$textarea.height(minheight);
}
}
});
// And this line is to catch the browser paste event
$textarea.bind('input paste',function(e){ setTimeout( update, 250); });
// Run update once when elastic is initialized
update();
});
}
});
})(jQuery);

View File

@ -21,7 +21,18 @@ if (!defined('e107_INIT')) { exit; }
*/
class e_media
{
public $imagelist = array();
protected $imagelist = array();
protected $mimePaths = array(
'text' => e_MEDIA_FILE,
'multipart' => e_MEDIA_FILE,
'application' => e_MEDIA_FILE,
'audio' => e_MEDIA_AUDIO,
'image' => e_MEDIA_IMAGE,
'video' => e_MEDIA_VIDEO,
'other' => e_MEDIA_FILE
);
/**
* Import files from specified path into media database.
@ -459,5 +470,133 @@ class e_media
return $text;
}
function checkDupe($oldpath,$newpath)
{
$mes = e107::getMessage();
$tp = e107::getParser();
$f = e107::getFile()->get_file_info($oldpath,TRUE);
// $mes->addDebug("checkDupe(): newpath=".$newpath."<br />oldpath=".$oldpath."<br />".print_r($upload,TRUE));
if(file_exists($newpath) || e107::getDb()->db_Select("core_media","*","media_url = '".$tp->createConstants($newpath,'rel')."' LIMIT 1") )
{
$mes->addWarning($newpath." already exists and was renamed during import.");
$file = $f['pathinfo']['filename']."_.".$f['pathinfo']['extension'];
$newpath = $this->getPath($f['mime']).'/'.$file;
}
return $newpath;
}
function getPath($mime)
{
$mes = e107::getMessage();
list($pmime,$tmp) = explode('/',$mime);
if(!vartrue($this->mimePaths[$pmime]))
{
$mes->add("Couldn't detect mime-type($mime). Upload failed.", E_MESSAGE_ERROR);
return FALSE;
}
$dir = $this->mimePaths[$pmime].date("Y-m");
if(!is_dir($dir))
{
if(!mkdir($dir, 0755))
{
$mes->add("Couldn't create folder ($dir).", E_MESSAGE_ERROR);
return FALSE;
};
}
return $dir;
}
public function mediaData($sc_path)
{
if(!$sc_path) return array();
$mes = e107::getMessage();
$path = e107::getParser()->replaceConstants($sc_path);
if(!is_readable($path))
{
$mes->addError("Couldn't read file: {$path}");
return FALSE;
}
$info = e107::getFile()->get_file_info($path);
return array(
'media_type' => $info['mime'],
'media_datestamp' => time(),
'media_url' => e107::getParser()->createConstants($path, 'rel'),
'media_size' => filesize($path),
'media_author' => USERID,
'media_usedby' => '',
'media_tags' => '',
'media_dimensions' => $info['img-width']." x ".$info['img-height']
);
}
public function importFile($file='',$category='_common')
{
$mes = e107::getMessage();
$tp = e107::getParser();
$sql = e107::getDb();
$oldpath = e_MEDIA."temp/".$file;
if(!file_exists($oldpath))
{
$mes->add("Couldn't find the file: ".$oldpath, E_MESSAGE_ERROR);
return;
}
$img_data = $this->mediaData($oldpath); // Basic File Info only
if(!$typePath = $this->getPath($img_data['media_type']))
{
$mes->addError("Couldn't generated path from file info:".$oldpath);
return FALSE;
}
$newpath = $this->checkDupe($oldpath,$typePath.'/'.$file);
if(!rename($oldpath, e_MEDIA.$newpath))
{
$mes->add("Couldn't move file from ".$oldpath." to ".$newpath, E_MESSAGE_ERROR);
return FALSE;
};
$img_data['media_url'] = $tp->createConstants($newpath,'rel');
$img_data['media_name'] = $tp->toDB($file);
$img_data['media_caption'] = $new_data['media_caption'];
$img_data['media_category'] = $category;
$img_data['media_description'] = $new_data['media_description'];
$img_data['media_userclass'] = 0;
if($sql->db_Insert("core_media",$img_data))
{
$mes->add("Importing Media: ".$file, E_MESSAGE_SUCCESS);
return $img_data['media_url'];
}
else
{
rename($newpath,$oldpath); //move it back.
return FALSE;
}
}
}

View File

@ -159,11 +159,37 @@ e107::js('inline','
var id = $(this).attr("href");
$(id).dialog({
minWidth: 800,
maxHeight: 800,
maxHeight: 700,
modal: true
});
});
// Modal Box - uses inline hidden content // NEEDS work - see customize link for admin-infopanel.
$(".e-modal-iframe").click(function (e) {
var id = $(this).attr("href");
e.preventDefault();
var page = $(this).attr("href")
var pagetitle = $(this).attr("title")
var $dialog = $("<div></div>")
.html("<iframe style=\"border: 0px; \" src=\"" + page + "\" width=\"100%\" height=\"100%\"></iframe>")
.dialog({
autoOpen: false,
modal: true,
width:800,
height: 700,
minWidth: 800,
minHeight: 700,
maxHeight: 700,
title: pagetitle
});
$dialog.dialog("open");
});
// Sorting
var fixHelper = function(e, ui) {

View File

@ -61,7 +61,7 @@ if (isset($_POST['submitnews_submit']) && $_POST['submitnews_title'] && $_POST['
if (FILE_UPLOADS && $_FILES['file_userfile'] && varsettrue($pref['subnews_attach']) && varsettrue($pref['upload_enabled']) && check_class($pref['upload_class']))
{
require_once(e_HANDLER.'upload_handler.php');
$uploaded = process_uploaded_files(e_IMAGE . 'newspost_images/', FALSE, array('file_mask' => 'jpg,gif,png', 'max_file_count' => 1));
$uploaded = process_uploaded_files(e_UPLOAD, FALSE, array('file_mask' => 'jpg,gif,png', 'max_file_count' => 1));
if (($uploaded === FALSE) || !is_array($uploaded))
{ // Non-specific error
@ -76,49 +76,49 @@ if (isset($_POST['submitnews_submit']) && $_POST['submitnews_title'] && $_POST['
{
if (varset($uploaded[$c]['error'],0) != 0)
{
$submitnews_error = TRUE;
$message = handle_upload_messages($uploaded);
}
else
{
$submitnews_error = TRUE;
$message = handle_upload_messages($uploaded);
}
else
{
if (isset($uploaded[$c]['name']) && isset($uploaded[$c]['type']) && isset($uploaded[$c]['size']))
{
{
$filename = $uploaded[$c]['name'];
$filetype = $uploaded[$c]['type'];
$filesize = $uploaded[$c]['size'];
$fileext = substr(strrchr($filename, "."), 1);
$today = getdate();
$fileext = substr(strrchr($filename, "."), 1);
$today = getdate();
$submitnews_file = USERID."_".$today[0]."_".$c."_".str_replace(" ", "_", substr($submitnews_title, 0, 6)).".".$fileext;
if (is_numeric($pref['subnews_resize']) && ($pref['subnews_resize'] > 30) && ($pref['subnews_resize'] < 5000))
{
require_once(e_HANDLER.'resize_handler.php');
if (!resize_image(e_IMAGE.'newspost_images/'.$filename, e_IMAGE.'newspost_images/'.$submitnews_file, $pref['subnews_resize']))
{
rename(e_IMAGE.'newspost_images/'.$filename, e_IMAGE.'newspost_images/'.$submitnews_file);
if (is_numeric($pref['subnews_resize']) && ($pref['subnews_resize'] > 30) && ($pref['subnews_resize'] < 5000))
{
require_once(e_HANDLER.'resize_handler.php');
if (!resize_image(e_UPLOAD.$filename, e_UPLOAD.$submitnews_file, $pref['subnews_resize']))
{
rename(e_UPLOAD.$filename, e_UPLOAD.$submitnews_file);
}
}
elseif ($filename)
{
rename(e_UPLOAD.$filename, e_UPLOAD.$submitnews_file);
}
}
}
elseif ($filename)
{
rename(e_IMAGE.'newspost_images/'.$filename, e_IMAGE.'newspost_images/'.$submitnews_file);
}
}
}
if ($filename && file_exists(e_IMAGE."newspost_images/".$submitnews_file))
{
if ($filename && file_exists(e_UPLOAD.$submitnews_file))
{
$submitnews_filearray[] = $submitnews_file;
}
}
}
}
}
}
if ($submitnews_error === FALSE)
{
$sql->db_Insert("submitnews", "0, '$submitnews_user', '$submitnews_email', '$submitnews_title', '".intval($_POST['cat_id'])."', '$submitnews_item', '".time()."', '$ip', '0', '$submitnews_file' ");
$sql->db_Insert("submitnews", "0, '$submitnews_user', '$submitnews_email', '$submitnews_title', '".intval($_POST['cat_id'])."', '$submitnews_item', '".time()."', '$ip', '0', '".implode(',',$submitnews_filearray)."' ");
$edata_sn = array("user" => $submitnews_user, "email" => $submitnews_email, "itemtitle" => $submitnews_title, "catid" => intval($_POST['cat_id']), "item" => $submitnews_item, "image" => $submitnews_file, "ip" => $ip);
$e_event->trigger("subnews", $edata_sn);
$ns->tablerender(LAN_133, "<div style='text-align:center'>".LAN_134."</div>");