Source for file CMS_MEDIA_PAGE.phpclass
Documentation is available at CMS_MEDIA_PAGE.phpclass
* Class file CMS_MEDIA_PAGE.phpclass
* @project Open CSP-Management
* @author Peter Krebs <p.krebs@wpus.at>
* @copyright (c) 2002-2005 by Peter Krebs and WURM und Partner Unternehmensservice GesmbH.
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
require_once $GLOBALS['DEFAULTCONFPATH'].
"cms.conf.phpinc";
require_once $GLOBALS['DEFAULTCONFPATH'].
"media.conf.phpinc";
require_once $GLOBALS['CMS']['PHPINCPATH'].
"page/CMS_PAGE_V2.phpclass";
* class to handel PAGES with list of medias and show medias
* @project Open CSP-Management
* @author Peter Krebs <p.krebs@wpus.at>
* @copyright (c) 2002-2005 by Peter Krebs and WURM und Partner Unternehmensservice GesmbH.
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @staticvar string $myClassName name of the class
* @var string $medCatRoot
* @var MED_CATEGORY_NODE $myCatNode
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// page definition methods
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* returns a array of variables used by the page object
* [FLDCLASS] name of DBMS_FIELD* class
* [CLASSVALS] array of values of [FLDCLASS]
require_once $GLOBALS['OCSP']['DBMSFLD_PATH'].
"DBMS_FIELD_HEADLINE.phpclass";
$retArr['MYFORMHAEDLINE']=
array(
"FLDCLASS" =>
"DBMS_FIELD_HEADLINE",
"label" =>
"<b>MEDIEN</b>"
require_once $GLOBALS['OCSP']['DBMSFLD_PATH'].
"DBMS_FIELD_TREESELECT.phpclass";
$retArr['MEDIACATEGORY']=
array(
"FLDCLASS" =>
"DBMS_FIELD_TREESELECT",
"label" =>
"Wurzelkategorie",
"foreignTbl" =>
"T_MED_CATEGORY",
"showField" =>
"MEC_NAME",
"sortField" =>
"MEC_NAME",
"parentField" =>
"MEC_PARENT",
"allowNullSelect" =>
TRUE,
"reloadFormOnChange"=>
FALSE,
require_once $GLOBALS['OCSP']['DBMSFLD_PATH'].
"DBMS_FIELD_CHECKBOX.phpclass";
$retArr['MED_SHOWALL']=
array(
"FLDCLASS" =>
"DBMS_FIELD_CHECKBOX",
"label" =>
"Alle Medien",
"checkText" =>
"ja alle in der Kategorie"
require_once $GLOBALS['OCSP']['DBMSFLD_PATH'].
"DBMS_FIELD_FOREIGNKEY.phpclass";
$retArr['LSTFORM']=
array(
"FLDCLASS" =>
"DBMS_FIELD_FOREIGNKEY",
"label" =>
"Listen Formular",
"foreignTbl" =>
"T_DBMS_FORM",
"showField" =>
"FRM_NAME",
"sortField" =>
"FRM_NAME",
"whereAnd" =>
"(FRM_TABLES LIKE \"%T_MEDPAG_MEDIA%\" OR FRM_TABLES LIKE \"%T_MED_FILES%\")",
"allowNullSelect" =>
TRUE,
"reloadFormOnChange"=>
FALSE
require_once $GLOBALS['OCSP']['DBMSFLD_PATH'].
"DBMS_FIELD_GROUPSELECT.phpclass";
$retArr['GRP_FILEADD'] =
array(
"FLDCLASS" =>
"DBMS_FIELD_GROUPSELECT",
"label" =>
"Upload Gruppe",
"defaultValue" =>
$GLOBALS['GROUPS']['CMSADMIN']
require_once $GLOBALS['OCSP']['DBMSFLD_PATH'].
"DBMS_FIELD_GLOBALARRSELECTLIST.phpclass";
$retArr['MED_NEWSTATE'] =
array(
"FLDCLASS" =>
"DBMS_FIELD_GLOBALARRSELECTLIST",
"label" =>
"Default Upload State",
"arrayName" =>
"MED|FILESTATE",
"defaultValue" =>
$GLOBALS['MED']['ONLINESTATE']
$retArr['LSTORDERBY'] =
array(
"FLDCLASS" =>
"DBMS_FIELD",
"label" =>
"Listensortierung ORDER BY",
"defaultValue" =>
"MEF_UPLTIME DESC"
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* returns the current MEC_ID
* if ($chkGet) $_GET['MEC_ID'] is set this is used instead of the root category
if ($debug) echo
"<p><b>CMS_MEDIA_PAGE::getMediaCatId(".
($chkGet ?
"USE GET" :
"USE ROOT").
")</b> (".
get_class($this).
")</p>";
if (($chkGet) &&
(intval($_GET['MEC_ID']))) {
* @return MED_CATEGORY_NODE
if ($debug) echo
"<p><b>CMS_MEDIA_PAGE::getMediaCatObj(".
($chkGet ?
"USE GET" :
"USE ROOT").
")</b> (".
get_class($this).
")</p>";
// we either don't have a object or a wrong object -> greate a new one
require_once $GLOBALS['MED']['PHPINCPATH'].
"MED_CATEGORY_NODE.phpclass";
* checks if a user can upload new files
* @todo if $mediaCatId != MEDIACATEGORY (root) we have to check the media category
if ($debug) echo
"<p><b>CMS_MEDIA_PAGE::userCanUploadMedia()</b> (".
get_class($this).
")</p>";
if ($GLOBALS['USER']->isGroupMember($this->getDBField("GRP_FILEADD"))) {
// #########################################
* returns the HTML Code for the media file list
* @param boolean $previewMode
if ($debug) echo
"<p><b>CMS_MEDIA_PAGE::getMED_FileLst()</b> (".
get_class($this).
")</p>";
$where =
"mf.MEF_SHOWFROM <= NOW() AND mf.MEF_SHOWTILL >= NOW()";
if (!$this->MED_SHOWALL) {
$where.=
" AND mf.MEF_STATE = ".
$GLOBALS['MED']['ONLINESTATE'];
if ($this->MED_SHOWALL) {
$query =
"SELECT * FROM T_MED_FILES mf WHERE MEC_ID=".
intval($this->MEDIACATEGORY);
if (empty($this->LSTORDERBY)) {
$query.=
" ORDER BY MEF_UPLTIME DESC";
$query.=
" ORDER BY ".
$this->LSTORDERBY;
$query =
"SELECT * FROM T_MEDPAG_MEDIA pm, T_MED_FILES mf WHERE mf.MEF_ID=pm.MEF_ID";
if (empty($this->LSTORDERBY)) {
$query.=
" ORDER BY MPM_SORTORDER";
$query.=
" ORDER BY ".
$this->LSTORDERBY;
'TEXT' =>
'<img src="'.
$GLOBALS['PROJECT']['SYSIMGURL'].
'form_buttons/lst_edit.gif" border="0" alt="bearbeiten" title="bearbeiten">'
'TEXT' =>
'<img src="'.
$GLOBALS['PROJECT']['SYSIMGURL'].
'form_buttons/lst_delete.gif" border="0" alt="lüschen" title="lüschen">'
if ($cursor=
$GLOBALS['USRDB']->query($query)) {
require_once $GLOBALS['OCSP']['PHPFORMPATH'].
"forms.phpinc";
$ret.=
$frmObj->getHTMLLstFromCursor($cursor,$nofRows,$a_lstLnks,NULL,$debug);
while($row =
$cursor->fetchArrayFld()) {
foreach($row as $key =>
$val) {
if ($debug) echo
"<p>ERROR: ".
$query.
"</p>";
* returns the file Upload Formul
* @param boolean $mediaCatId
if ($debug) echo
"<p><b>CMS_MEDIA_PAGE::getUploadForm()</b> (".
get_class($this).
")</p>";
require_once $GLOBALS['OCSP']['PHPINCPATH'].
"common/pcf_templates.phpinc";
// otherwise it makeas no sence to write the form
// use a default template
<form name=\"frmNewMedia\" action=\"\$*FRM_ACTION\$\" method=\"post\" ENCTYPE=\"multipart/form-data\" \$*UPLOADFORMTAG\$>
<tr style=\"background-color: #C0C0C0\">
<td class=\"fldName\" valign=\"middle\">Neue Datei:</td>
<td class=\"fldValue\" valign=\"middle\">
<input type=\"file\" name=\"NEWMEDIAFILE\" size=\"40\">
<button title=\"Datei anlegen\" type=\"button\" onClick=\"document.forms['frmNewMedia'].submit()\">
<img src=\"".
$GLOBALS['PROJECT']['SYSIMGURL'].
"icons-22x22/filenew.png\" alt=\"Neue Datei\">
* echos the content of the page
* @param int $chaShowMode
function content($chaShowMode=
0,$debug=
FALSE) {
if ($debug) echo
"<p><b>CMS_MEDIA_PAGE::content(Mode: $chaShowMode)</b> (".
get_class($this).
")</p>";
$this->getMediaCatId(TRUE,$debug); // ($chkGet=FALSE,$debug=FALSE)
// just call this method as it sets $this->myMediaCatId
// and to ensure we use the get param
if (!intval($_GET['MEF_ID'])) {
if ($debug) echo
"<p>FILE POSTED: </p><blockquote><pre>".
print_r($_FILES,TRUE).
"</pre></blockquote>";
$this->getMediaCatObj(FALSE,$debug); // ($chkGet=FALSE,$debug=FALSE) no checkgroup as we alread called getMediaCatId
// just call it to set $this->myMediaCatNode
foreach($_FILES as $s_key =>
$a_ulFData) {
if ($o_mefObj=
$this->myMediaCatNode->addUploadFile($a_ulFData,$debug)) {
// echo "<pre>".pcf_object_info($o_mefObj,3,FALSE)."<pre>";
if ($debug) echo
"<pre>".
print_r($o_mefObj->getDBVal(),TRUE).
"</pre>";
$o_mefObj->dbSave("USRDB",$debug);
$frmObj=
&$o_mefObj->dbGetForm(FRM_MODE_EDIT,$this->LSTFORM,$debug);
$a_aktRec=
$o_mefObj->getDBVal();
$a_defaults=
$frmObj->getDefaultValArr("",$debug);
// check if we have some form defaults
if ($debug) echo
"Defaults:<pre>".
print_r($a_defaults,TRUE).
"</pre>";
if (!intval($a_aktRec['MEF_STATE'])) $a_aktRec['MEF_STATE']=
$a_defaults['MEF_STATE'];
global $
{"DBVAL_".
$s_key};
$
{"DBVAL_".
$s_key}=
$frmObj->reloadCheck($a_aktRec,$debug);
if ($debug) echo
"<pre>".
print_r($
{"DBVAL_".
$s_key},TRUE).
"</pre>";
echo
$frmObj->getHTMLFormFromArray($
{"DBVAL_".
$s_key},FRM_MODE_EDIT,NULL,$s_link,"DBVAL_".
$s_key,$debug);
} else { // we do not have posted files or the user is not allowed to post files
$s_query=
"SELECT * FROM T_MED_FILES WHERE MEF_ID=".
intval($_GET['MEF_ID']);
$a_mefRow=
$GLOBALS['USRDB']->quickQuery($s_query);
if ($debug) echo
"<pre>".
print_r($a_mefRow,TRUE).
"</pre>";
if (file_exists($GLOBALS['MED']['PHPINCPATH'].
$a_mefRow['MEF_OBJCLASS'].
".phpclass")) {
require_once $GLOBALS['MED']['PHPINCPATH'].
$a_mefRow['MEF_OBJCLASS'].
".phpclass";
require_once $GLOBALS['MED']['PHPINCPATH'].
"MED_FILE.phpclass";
$a_mefRow['MEF_OBJCLASS']=
"MED_FILE";
eval
('$o_mefObj=new '.
$a_mefRow['MEF_OBJCLASS'].
'('.
$a_mefRow['MEF_ID'].
');');
// echo "<pre>".print_r($_GET,TRUE)."</pre>";
switch($_GET['MEFCMD']) {
$s_cmd=
"DELETE FROM T_MED_FILES WHERE MEF_ID=".
intval($_GET['MEF_ID']);
echo
"<p>NOT FINISHED CANCLENEW</p>";
$a_aktRec=
$o_mefObj->getDBVal();
$frmObj=
$o_mefObj->dbGetForm(FRM_MODE_EDIT,"ID:".
$this->LSTFORM,$debug);
$DBVAL=
$frmObj->reloadCheck($a_aktRec,$debug);
echo
$frmObj->getHTMLFormFromArray($DBVAL,FRM_MODE_EDIT,NULL,$s_link,"DBVAL",$debug);
$a_aktRec=
$o_mefObj->getDBVal();
$DBVAL=
$frmObj->reloadCheck($a_aktRec,$debug);
echo
$frmObj->getHTMLFormFromArray($DBVAL,FRM_MODE_DELETE,NULL,$s_link,"DBVAL",$debug);
Documentation generated on Thu, 08 Jan 2009 17:39:05 +0100 by phpDocumentor 1.4.0a2