diff --git a/oss/joomla/trunk/administrator/components/com_admin/admin.admin.html.php b/oss/joomla/trunk/administrator/components/com_admin/admin.admin.html.php new file mode 100644 index 00000000..336ac332 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_admin/admin.admin.html.php @@ -0,0 +1,335 @@ +setBuffer($contents, 'modules', 'submenu'); + ?> +
+ +
+
+ + + + +
+ +
+
+ +
+ + + + +
+ +
+
+ +
+ + + + +
+ +
+
+ +
+ + + + +
+ +
+
+ +
+ + + + +
+ +
+
+
+ +
+ + * In case of the remote server it is assumed that this server provide one specific + * help set of files in one particular language. + */ + function help() + { + global $mainframe; + jimport( 'joomla.filesystem.folder' ); + jimport( 'joomla.language.help' ); + + // Get Help URL - an empty helpurl is interpreted as local help files! + $helpurl = $mainframe->getCfg('helpurl'); + if ( $helpurl == 'http://help.mamboserver.com' ) { + $helpurl = 'http://help.joomla.org'; + } + $fullhelpurl = $helpurl . '/index2.php?option=com_content&task=findkey&pop=1&keyref='; + + $helpsearch = JRequest::getString('helpsearch'); + $page = JRequest::getCmd('page', 'joomla.whatsnew15.html'); + $toc = getHelpToc( $helpsearch ); + $lang =& JFactory::getLanguage(); + $langTag = $lang->getTag(); + if( !JFolder::exists( JPATH_BASE.DS.'help'.DS.$langTag ) ) { + $langTag = 'en-GB'; // use english as fallback + } + + if (!eregi( '\.html$', $page )) { + $page .= '.xml'; + } + ?> + + + + + + +
+ + + + + +
+ : + + + + + + + 'helpFrame')) ?> + | + 'helpFrame')) ?> + | + 'helpFrame')) ?> + + 'helpFrame')) ?> | + 'helpFrame')) ?> | + 'helpFrame')) ?> + + | + 'helpFrame')) ?> + | + 'helpFrame')) ?> + | + 'helpFrame')) ?> + | + 'helpFrame')) ?> +
+
+ +
+
+ + + + +
+
    + $v) { + if ($helpurl) { + echo '
  • '; + echo JHTML::_('link', JHelp::createUrl( $k ), $v, array('target' => 'helpFrame')); + echo '
  • '; + } else { + echo '
  • '; + echo JHTML::_('link', JURI::base() .'help/'.$langTag.'/'.$k, $v, array('target' => 'helpFrame')); + echo '
  • '; + } + } + ?> +
+
+
+
+ +
+
+ + + + + + + + +
+
+ + +
+ +
+			/','',$changelog);
+
+			// Convert all other HTML entities
+			echo htmlentities($changelog);
+			?>
+		
+ '. JText::_( 'Writable' ) .''; + $unwriteable = ''. JText::_( 'Unwritable' ) .''; + + echo ''; + echo ''; + echo $text; + if ( $visible ) { + echo $folder . '/'; + } + echo ''; + echo ''; + if ( $relative ) { + echo is_writable( "../$folder" ) ? $writeable : $unwriteable; + } else { + echo is_writable( "$folder" ) ? $writeable : $unwriteable; + } + echo ''; + echo ''; +} + +/** + * Compiles the help table of contents + * @param string A specific keyword on which to filter the resulting list + */ +function getHelpTOC( $helpsearch ) +{ + global $mainframe; + + $lang =& JFactory::getLanguage(); + jimport( 'joomla.filesystem.folder' ); + + $helpurl = $mainframe->getCfg('helpurl'); + + // Check for files in the actual language + $langTag = $lang->getTag(); + if( !JFolder::exists( JPATH_BASE.DS.'help'.DS.$langTag ) ) { + $langTag = 'en-GB'; // use english as fallback + } + $files = JFolder::files( JPATH_BASE.DS.'help'.DS.$langTag, '\.xml$|\.html$' ); + + $toc = array(); + foreach ($files as $file) { + $buffer = file_get_contents( JPATH_BASE.DS.'help'.DS.$langTag.DS.$file ); + if (preg_match( '#(.*?)#', $buffer, $m )) { + $title = trim( $m[1] ); + if ($title) { + if ($helpurl) { + // strip the extension + $file = preg_replace( '#\.xml$|\.html$#', '', $file ); + } + if ($helpsearch) { + if (JString::strpos( strip_tags( $buffer ), $helpsearch ) !== false) { + $toc[$file] = $title; + } + } else { + $toc[$file] = $title; + } + } + } + } + asort( $toc ); + return $toc; +} diff --git a/oss/joomla/trunk/administrator/components/com_admin/admin.admin.php b/oss/joomla/trunk/administrator/components/com_admin/admin.admin.php new file mode 100644 index 00000000..eae282ec --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_admin/admin.admin.php @@ -0,0 +1,48 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_admin/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_admin/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_admin/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_admin/tmpl/navigation.php b/oss/joomla/trunk/administrator/components/com_admin/tmpl/navigation.php new file mode 100644 index 00000000..2a8d3d02 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_admin/tmpl/navigation.php @@ -0,0 +1,36 @@ + + +
\ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_admin/tmpl/sysinfo_config.php b/oss/joomla/trunk/administrator/components/com_admin/tmpl/sysinfo_config.php new file mode 100644 index 00000000..b88cd9d7 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_admin/tmpl/sysinfo_config.php @@ -0,0 +1,73 @@ + +
+ + + + + + + + + + + + + + + + $v) { + if (eregi( 'var \$host', $v)) { + $cf[$k] = 'var $host = \'xxxxxx\''; + } else if (eregi( 'var \$user', $v)) { + $cf[$k] = 'var $user = \'xxxxxx\''; + } else if (eregi( 'var \$password', $v)) { + $cf[$k] = 'var $password = \'xxxxxx\''; + } else if (eregi( 'var \$db ', $v)) { + $cf[$k] = 'var $db = \'xxxxxx\''; + } else if (eregi( 'var \$ftp_user ', $v)) { + $cf[$k] = 'var $ftp_user = \'xxxxxx\''; + } else if (eregi( 'var \$ftp_pass ', $v)) { + $cf[$k] = 'var $ftp_pass = \'xxxxxx\''; + } else if (eregi( 'var \$smtpuser ', $v)) { + $cf[$k] = 'var $smtpuser = \'xxxxxx\''; + } else if (eregi( 'var \$smtppass ', $v)) { + $cf[$k] = 'var $smtppass = \'xxxxxx\''; + } else if (eregi( '', $v)) { + $cf[$k] = ''; + } else if (eregi( '}', $v)) { + $cf[$k] = ''; + } else if (eregi( 'class JConfig {', $v)) { + $cf[$k] = ''; + } + $cf[$k] = str_replace('var ','',$cf[$k]); + $cf[$k] = str_replace(';','',$cf[$k]); + $cf[$k] = str_replace(' = ',''; + if ($cf[$k] != '') { + $config_output[] = $cf[$k]; + } + } + echo implode( '', $config_output ); + ?> + + +
+ + + +
+   +
',$cf[$k]); + $cf[$k] = ''. $cf[$k] .'
+
diff --git a/oss/joomla/trunk/administrator/components/com_admin/tmpl/sysinfo_directory.php b/oss/joomla/trunk/administrator/components/com_admin/tmpl/sysinfo_directory.php new file mode 100644 index 00000000..a9a3853a --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_admin/tmpl/sysinfo_directory.php @@ -0,0 +1,80 @@ + +
+ + + + + + + + + + + + + + + get('image_path')); + writableCell( 'language' ); + + // List all site languages + $site_langs = JFolder::folders(JPATH_SITE.DS.'language'); + foreach ($site_langs as $slang) + { + writableCell( 'language/'.$slang ); + } + + writableCell( 'media' ); + writableCell( 'modules' ); + writableCell( 'plugins' ); + writableCell( 'plugins/content' ); + writableCell( 'plugins/editors' ); + writableCell( 'plugins/editors-xtd' ); + writableCell( 'plugins/search' ); + writableCell( 'plugins/system' ); + writableCell( 'plugins/user' ); + writableCell( 'plugins/xmlrpc' ); + writableCell( 'templates' ); + writableCell( JPATH_SITE.DS.'cache', 0, ''. JText::_( 'Cache Directory' ) .' ' ); + writableCell( JPATH_ADMINISTRATOR.DS.'cache', 0, ''. JText::_( 'Cache Directory' ) .' ' ); + writableCell( $config->getValue('config.log_path', JPATH_ROOT.DS.'log'),0, ''. JText::_( 'Log Directory' ) . + ' ($log_path) '); + writableCell( $config->getValue('config.tmp_path', JPATH_ROOT.DS.'tmp'),0, ''. JText::_( 'Temp Directory' ) . + ' ($tmp_path) '); + ?> + +
+ + + +
+   +
+
diff --git a/oss/joomla/trunk/administrator/components/com_admin/tmpl/sysinfo_phpinfo.php b/oss/joomla/trunk/administrator/components/com_admin/tmpl/sysinfo_phpinfo.php new file mode 100644 index 00000000..a1366b65 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_admin/tmpl/sysinfo_phpinfo.php @@ -0,0 +1,49 @@ + +
+ + + + + + + + + + + + + + + + + +
+   +
+   +
+ ]*>(.*)#siU', $phpinfo, $output); + $output = preg_replace('##', '', $output); + $output = str_replace('
', '', $output); + $output = str_replace('
', '', $output); + + echo $output; + ?> +
+
\ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_admin/tmpl/sysinfo_phpsettings.php b/oss/joomla/trunk/administrator/components/com_admin/tmpl/sysinfo_phpsettings.php new file mode 100644 index 00000000..776304a5 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_admin/tmpl/sysinfo_phpsettings.php @@ -0,0 +1,165 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + setQuery( $query, 0, 1 ); + $editor = $db->loadResult(); + ?> + + + + + +
+ + + +
  +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+
diff --git a/oss/joomla/trunk/administrator/components/com_admin/tmpl/sysinfo_system.php b/oss/joomla/trunk/administrator/components/com_admin/tmpl/sysinfo_system.php new file mode 100644 index 00000000..2e3fc114 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_admin/tmpl/sysinfo_system.php @@ -0,0 +1,98 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
  +
+ : + + +
+ : + + getVersion(); ?> +
+ : + + getCollation(); ?> +
+ : + + +
+ : + + +
+ : + + +
+ : + + getLongVersion(); + ?> +
+ : + + +
+
\ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_admin/toolbar.admin.html.php b/oss/joomla/trunk/administrator/components/com_admin/toolbar.admin.html.php new file mode 100644 index 00000000..0854b425 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_admin/toolbar.admin.html.php @@ -0,0 +1,48 @@ +get('secure',false); + $icon_dir = $mainframe->getSiteURL() . 'components/com_attachments/media/icons/'; + $num_columns = 8; + ?> +
+ + + + + + + + get('user_field_1_name', '') != '' ): $num_columns++; ?> + + + get('user_field_2_name', '') != '' ): $num_columns++; ?> + + + get('user_field_3_name', '') != '' ): $num_columns++; ?> + + + + + + + + + + + + getSiteURL() . $row->url; + if ( $secure ) { + $url = "index.php?option=com_attachments&task=download&id=" . $row->id; + $url = JRoute::_($url); + } + else + $url = $mainframe->getSiteURL() . $row->url; + $checked = JHTML::_('grid.id', $i, $row->id ); + $published = JHTML::_('grid.published', $row, $i ); + $size = intval($row->file_size / 1024); + $link = JFilterOutput::ampReplace( 'index.php?option=' . $option . '&task=edit&cid[]='. $row->id ); + $artLink = JFilterOutput::ampReplace( '../index.php?option=com_content&view=article&id=' . $row->article_id ); + $view_article_title = JText::_('VIEW ARTICLE TITLE'); + if ( strlen($row->icon_filename) > 0 ) + $icon_url = $icon_dir . $row->icon_filename; + else + $icon_url = $icon_dir . 'generic.gif'; + $add_attachment_icon = $mainframe->getSiteURL() . 'components/com_attachments/media/add_attachment.gif'; + $add_attachment_title = JText::_('ADD ATTACHMENT TITLE'); + $edit_attachment_title = JText::_('EDIT THIS ATTACHMENT TITLE'); + $access_attachment_title = JText::_('ACCESS THIS ATTACHMENT TITLE'); + + // Set up the create/modify dates + jimport( 'joomla.utilities.date' ); + $cdate = new JDate($row->create_date, -$mainframe->getCfg('offset')); + $create_date = $cdate->toFormat("%x %H:%M"); + $mdate = new JDate($row->modification_date, -$mainframe->getCfg('offset')); + $modification_date = $mdate->toFormat("%x %H:%M"); + + $add_attachment_txt = JText::_('ADD ATTACHMENT'); + if ($row->article_id != $last_article_id) { + $addAttachLink = 'index.php?option=' . $option . '&task=add&article_id='. $row->article_id; + $addAttachLink = JFilterOutput::ampReplace($addAttachLink); + $artLine = "\n"; + echo $artLine; + $k = 0; + } + $last_article_id = $row->article_id; + $download_verb = JText::_('DOWNLOAD VERB'); + ?> + "> + + + + + get('user_field_1_name', '') != '' ): ?> + + + get('user_field_2_name', '') != '' ): ?> + + + get('user_field_3_name', '') != '' ): ?> + + + + + + + + + + + + + + + + +
+ + get('user_field_1_name', '') ?>get('user_field_2_name', '') ?>get('user_field_3_name', '') ?>
"; + $artLine .= "".JText::_('ARTICLE')." " . $row->title . ""; + $artLine .= JFilterOutput::ampReplace('    '); + $artLine .= "\"$add_attachment_txt\" "; + $artLine .= "$add_attachment_txt"; + $artLine .= "
+ <?php echo $download_verb; ?> filename; ?>  <?php echo $download_verb; ?> + description; ?>user_field_1; ?>user_field_2; ?>user_field_3; ?>file_type; ?>download_count; ?>
getListFooter(); ?>
+ + + +
+ get('secure',false); + + // Set up the create/modify dates + jimport( 'joomla.utilities.date' ); + $cdate = new JDate($row->create_date, -$mainframe->getCfg('offset')); + $create_date = $cdate->toFormat("%x %H:%M"); + $mdate = new JDate($row->modification_date, -$mainframe->getCfg('offset')); + $modification_date = $mdate->toFormat("%x %H:%M"); + + $change_article_url = "index.php?option=com_attachments&task=edit&cid[]={$row->id}&change=article"; + $update_file_url = "index.php?option=com_attachments&task=edit&cid[]={$row->id}&change=file"; + + if ( $update_file ) + $enctype = "enctype=\"multipart/form-data\""; + else + $enctype = ''; + + ?> +
name="adminForm" id="adminForm"> +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + get('user_field_1_name', '') != '' ): ?> + + + + + get('user_field_2_name', '') != '' ): ?> + + + + + get('user_field_3_name', '') != '' ): ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  + + + article_title; ?> + +
+ + + +  filename; ?> + +
filename_sys; ?>
  
uploader_name;?>
url; ?>
file_type; ?>
size; ?>
:
:
:download_count; ?>
+
+ + + + + +
addStyleSheet( $mainframe->getSiteURL() . 'plugins/content/attachments.css', + 'text/css', null, array() ); + + // Get the article title (if any) + $article_title = false; + if ( $article_id ) { + // Get the article names + $query = "SELECT * FROM #__content WHERE id='$article_id' LIMIT 1"; + $db->setQuery($query); + $rows = $db->loadObjectList(); + if ( count($rows) != 1 ) { + $errmsg = JText::_('ERROR INVALID ARTICLE ID') . " ($article_id)"; + JError::raiseError(500, $errmsg); + } + $article_title = $rows[0]->title; + } + if ( $article_title ) { + echo "

" . JText::_('ARTICLE') . " “$article_title”

"; + } + + // Show the existing attachments + require_once(JPATH_COMPONENT_SITE.DS.'helper.php'); + echo AttachmentsHelper::attachmentsTableHTML($article_id, + 'EXISTING ATTACHMENTS', false,false,$from); + + // Handle the from option + if ( $from ) + $fromval = $from; + else + $fromval = ''; + + $save_url = JRoute::_(JURI::root() . "administrator/index.php?option=com_attachments&task=save"); + ?> + +
+
+ + +

+ +

+   + + +

+ +

+

+

+  

+

+

+
+ + + + + +
+ +
+ + +
+ diff --git a/oss/joomla/trunk/administrator/components/com_attachments/admin.attachments.php b/oss/joomla/trunk/administrator/components/com_attachments/admin.attachments.php new file mode 100644 index 00000000..6cf0ee09 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/admin.attachments.php @@ -0,0 +1,46 @@ +addStyleSheet( $mainframe->getSiteURL() . 'administrator/components/com_attachments/attachments.css', + 'text/css', null, array() ); + +// Check for requests for named controller +$controller = JRequest::getWord('controller', False); +if ( $controller ) { + // Invoke the named controller, if it exists + $path = JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php'; + jimport('joomla.filesystem.file'); + if ( JFile::exists($path) ) { + require_once( $path ); + $classname = 'AttachmentsController'.ucfirst($controller); + $controller = new $classname( ); + $controller->execute( JRequest::getCmd( 'task' ) ); + $controller->redirect(); + } + else { + echo "

Error! Unable to find controller '$controller'!


"; + exit(); + } + } + +// Use default controller +$controller = new AttachmentsController( array('default_task' => 'showAttachments') ); +$controller->execute( JRequest::getVar( 'task' ) ); +$controller->redirect(); + +?> diff --git a/oss/joomla/trunk/administrator/components/com_attachments/attachments.css b/oss/joomla/trunk/administrator/components/com_attachments/attachments.css new file mode 100644 index 00000000..b7201349 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/attachments.css @@ -0,0 +1,164 @@ +/* Styles for the main list of attachments in the administrative back end */ + +table.adminlist th { + text-align: left; + border-bottom: 0; +} +table.adminlist th.at_published { text-align: center; } +table.adminlist th.at_filename { text-align: left; } +table.adminlist th.at_description { text-align: left; } +table.adminlist th.at_user_field { text-align: left; } +table.adminlist th.at_file_type { text-align: center; } +table.adminlist th.at_file_size { text-align: center; } +table.adminlist th.at_create_date { text-align: center; } +table.adminlist th.at_mod_date { text-align: center; } +table.adminlist th.at_downloads { text-align: center; } + +table.adminlist td { + text-align: left; + border-bottom: 0; +} +table.adminlist td.at_published { text-align: center; } + +table.adminlist td.at_filename { + text-align: left; + font-size: 125%; +} +table.adminlist td.at_filename a img { + vertical-align: text-bottom; +} + +table.adminlist td.at_description { text-align: left; } +table.adminlist td.at_user_field { text-align: left; } +table.adminlist td.at_file_type { text-align: center; } +table.adminlist td.at_file_size { text-align: center; } +table.adminlist td.at_create_date { text-align: center; } +table.adminlist td.at_mod_date { text-align: center; } +table.adminlist td.at_downloads { text-align: center; } + + +table.adminlist td.at_articlesep { + height: 0.8em; + background-color: #DDD; + border-top: 1px solid #999; + border-bottom: 1px solid #BBB; + font-weight: bold; +} + + +/* For the link to download a file */ + +a.downloadAttach { + margin-left: 0px; + font-size: 80%; + color : red; + text-decoration: none; +} +a.downloadAttach:link { color : red; text-decoration: none; } +a.downloadAttach:visited { color : red; text-decoration: none; } +a.downloadAttach:hover { color : red; text-decoration: underline; } +a.downloadAttach:active { color : red; text-decoration: none; } + + + +/* For the link to add another attachment to an article */ + +a.addAttach { + font-weight: normal; + color: red; + text-decoration: none; +} +a.addAttach:link { color : red; text-decoration: none; } +a.addAttach:visited { color : red; text-decoration: none; } +a.addAttach:hover { color : red; text-decoration: underline; } +a.addAttach:active { color : red; text-decoration: none; } + +a.addAttach img { + vertical-align: text-bottom; +} + + +/* For the link to change the article */ + +a.changeButton { + padding-top: 1px; + padding-top: 1px; + padding-left: 4px; + padding-right: 4px; + margin-left: 20px; + font-size: 90%; + color : #333333; + text-decoration: none; + background-color: #CCCCCC; + border: 1px solid #888888; +} +a.changeButton:link { color : #333333; text-decoration: none; } +a.changeButton:visited { color : #333333; text-decoration: none; } +a.changeButton:hover { color : #333333; text-decoration: none; background-color: #DDDDDD; } +a.changeButton:active { color : #333333; text-decoration: none; } + +a.modal-button { + padding-top: 1px; + padding-top: 1px; + padding-left: 4px; + padding-right: 4px; + color: #333333; + background-color: #CCCCCC; + border: 1px solid #888888; + font-weight: bold; +} + +a.modal-button:link { color: #333333; text-decoration: none; } +a.modal-button:hover { color: #333333; text-decoration: none; background-color: #DDDDDD; } +a.modal-button:visited { color: #333333; text-decoration: none; } +a.modal-button:active { color: #333333; text-decoration: none; } + + +/* For the upload attachment form */ + +form.attachmentsBackend { + margin-top: 10px; + margin-left: -8px; +} + +form.attachmentsBackend legend { + font-size: 140%; + font-weight: bold; +} + + +/* Styles for attachments admin */ +div.attachmentsAdmin { + margin-left: 20px; + margin-top: 20px; +} + +div.attachmentsAdmin h1 { + line-height: normal; + font-size: 200%; + font-weight: bold; + color: #000088; +} + +div.attachmentsAdmin h2 { + line-height: normal; + font-size: 150%; + font-weight: bold; +} + +div.attachmentsAdmin li a { padding: 2px; } +div.attachmentsAdmin li a:link { color: #0000FF; text-decoration: none; } +div.attachmentsAdmin li a:hover { + color: #0000FF; text-decoration: none; + background-color: #DDDDDD; + } +div.attachmentsAdmin li a:visited { color: #0000FF; text-decoration: none; } +div.attachmentsAdmin li a:active { color: #0000FF; text-decoration: none; } + +/* For icons */ + +.icon-48-attachments { background-image: url(../../components/com_attachments/attachments_logo48.png); } + +.icon-16-attachments { background-image: url(../../components/com_attachments/icon-16-attachments.png); } + +.icon-32-admin { background-image: url(../../components/com_attachments/attachments_admin32.png); } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_attachments/attachments.png b/oss/joomla/trunk/administrator/components/com_attachments/attachments.png new file mode 100644 index 00000000..eb324220 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_attachments/attachments.png differ diff --git a/oss/joomla/trunk/administrator/components/com_attachments/attachments.xml b/oss/joomla/trunk/administrator/components/com_attachments/attachments.xml new file mode 100644 index 00000000..b3698ffe --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/attachments.xml @@ -0,0 +1,124 @@ + + + + Attachments + Jonathan M. Cameron + August 17, 2008 + (C) 2007, 2008 Jonathan M. Cameron. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + jmcameron@jmcameron.net + http://joomlacode.org/gf/project/attachments/ + 1.3.4 + Attachments for Articles installed: This component allows files to be uploaded and attached to articles. + install.attachments.php + uninstall.attachments.php + + + install.mysql.sql + install.noutf8.sql + + + + + uninstall.mysql.sql + + + + en-GB.com_attachments.ini + + + attachments.php + controller.php + helper.php + permissions.php + file_types.php + router.php + index.html + models/index.html + models/update.php + views/index.html + views/update/index.html + views/update/view.php + views/update/metadata.xml + views/upload/index.html + views/upload/metadata.xml + views/upload/view.php + media/index.html + media/add_attachment.gif + media/attachment.gif + media/delete.gif + media/pencil.gif + media/update.gif + media/icons/index.html + media/icons/3d.gif + media/icons/archive.gif + media/icons/audio.gif + media/icons/c.gif + media/icons/cpp.gif + media/icons/css.gif + media/icons/csv.gif + media/icons/download.gif + media/icons/eps.gif + media/icons/excel.gif + media/icons/flash.gif + media/icons/generic.gif + media/icons/h.gif + media/icons/image.gif + media/icons/js.gif + media/icons/midi.gif + media/icons/mov.gif + media/icons/music.gif + media/icons/odg.gif + media/icons/odp.gif + media/icons/ods.gif + media/icons/odt.gif + media/icons/pdf.gif + media/icons/php.gif + media/icons/ppt.gif + media/icons/ps.gif + media/icons/rtf.gif + media/icons/sql.gif + media/icons/text.gif + media/icons/video.gif + media/icons/word.gif + media/icons/xml.gif + media/icons/zip.gif + + + Attachments + + en-GB.com_attachments.ini + en-GB.com_attachments.menu.ini + + + install.mysql.sql + install.noutf8.sql + uninstall.mysql.sql + config.xml + admin.attachments.html.php + admin.attachments.php + controller.php + controllers/index.html + controllers/special.php + models/index.html + models/special.php + tables/attachments.php + tables/index.html + views/index.html + views/special/index.html + views/special/view.php + update.php + help/index.html + help/en-GB/help.html + help/en-GB/help.css + help/en-GB/index.html + toolbar.attachments.html.php + toolbar.attachments.php + attachments.css + attachments.png + attachments_admin32.png + attachments_logo48.png + index.html + + + diff --git a/oss/joomla/trunk/administrator/components/com_attachments/attachments_admin32.png b/oss/joomla/trunk/administrator/components/com_attachments/attachments_admin32.png new file mode 100644 index 00000000..ea04c969 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_attachments/attachments_admin32.png differ diff --git a/oss/joomla/trunk/administrator/components/com_attachments/attachments_logo48.png b/oss/joomla/trunk/administrator/components/com_attachments/attachments_logo48.png new file mode 100644 index 00000000..e9dd5b72 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_attachments/attachments_logo48.png differ diff --git a/oss/joomla/trunk/administrator/components/com_attachments/config.xml b/oss/joomla/trunk/administrator/components/com_attachments/config.xml new file mode 100644 index 00000000..86b3bf87 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/config.xml @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/oss/joomla/trunk/administrator/components/com_attachments/controller.php b/oss/joomla/trunk/administrator/components/com_attachments/controller.php new file mode 100644 index 00000000..78c1b0a0 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/controller.php @@ -0,0 +1,441 @@ +registerTask('apply', 'save'); + $this->registerTask('applyNew', 'saveNew'); + $this->registerTask('unpublish', 'publish'); + } + + function showAttachments() + { + global $option, $mainframe; + $limit = JRequest::getVar('limit', $mainframe->getCfg('list_limit')); + $limitstart = JRequest::getVar('limitstart', 0); + $db =& JFactory::getDBO(); + $query = "SELECT count(*) FROM #__attachments"; + $db->setQuery($query); + $total = $db->loadResult(); + $query = "SELECT *, #__attachments.id as id, c.title as title FROM #__attachments "; + $query .= "LEFT JOIN #__content as c ON #__attachments.article_id = c.id ORDER BY c.id"; + $db->setQuery($query, $limitstart, $limit); + $rows = $db->loadObjectList(); + if ($db->getErrorNum()) { + echo $db->stderr(); + return false; + } + jimport('joomla.html.pagination'); + $pageNav = new JPagination($total, $limitstart, $limit); + HTML_attachments::showAttachments($option, $rows, $pageNav); + } + + function add() + { + global $mainframe, $option; + + // See if an article is specified + $article_id = JRequest::getVar('article_id', false); + $from = JRequest::getVar('from', false); + + // Use a different template for the iframe view + if ( $from == 'closeme') { + JRequest::setVar('tmpl', 'component'); + } + + // Add the published selection + $lists['published'] = JHTML::_('select.booleanlist', + 'published', 'class="inputbox"', false); + + if ( !$article_id ) { + // Set up the necessary javascript + $document = & JFactory::getDocument(); + $document->addScript( JURI::root(true).'/media/system/js/modal.js' ); + $js = " + function jSelectArticle(id, title) { + document.getElementById('article_id').value = id; + document.getElementById('article_title').value = title; + document.getElementById('sbox-window').close(); + }"; + $document->addScriptDeclaration($js); + JHTML::_('behavior.modal', 'a.modal-button'); + } + else { + if ( !is_numeric($article_id) ) { + $errmsg = JText::_('ERROR INVALID ARTICLE ID') . " ($article_id)"; + JError::raiseError(500, $errmsg); + } + } + + JRequest::setVar( 'hidemainmenu', 1 ); + + HTML_attachments::newAttachment($article_id, $lists, $option, $from); + } + + function edit() + { + global $option, $mainframe; + + $db =& JFactory::getDBO(); + + $row =& JTable::getInstance('Attachments', 'Table'); + $cid = JRequest::getVar( 'cid', array(0), '', 'array'); + $change_article = JRequest::getVar('change', False) == 'article'; + $update_file = JRequest::getVar('change', False) == 'file'; + $id = $cid[0]; + $row->load($id); + $lists = array(); + $lists['published'] = JHTML::_('select.booleanlist', 'published', + 'class="inputbox"', $row->published); + + // Construct the drop-down list for legal icon filenames + $icon_filenames = array(); + require_once(JPATH_COMPONENT_SITE.DS.'file_types.php'); + foreach ( AttachmentsFileTypes::unique_icon_filenames() as $ifname) { + $icon_filenames[] = JHTML::_('select.option', $ifname); + } + $lists['icon_filenames'] = JHTML::_('select.genericlist', $icon_filenames, + 'icon_filename', 'class="inputbox" size="1"', 'value', 'text', $row->icon_filename); + + // Get the uploaders name + $query = "SELECT name FROM #__users WHERE id='" . $row->uploader_id . "' LIMIT 1"; + $db->setQuery($query); + $row->uploader_name = $db->loadResult(); + + // Massage the data + $row->size = intval( $row->file_size / 1024.0 ); + $row->url = $mainframe->getSiteURL() . $row->url; + + // Get the article name + $article_id = $row->article_id; + $query = "SELECT * FROM #__content WHERE id='$article_id' LIMIT 1"; + $db->setQuery($query); + $arows = $db->loadObjectList(); + if ( count($arows) != 1 ) { + $errmsg = JText::_('ERROR INVALID ARTICLE ID') . " ($article_id)"; + JError::raiseError(500, $errmsg); + } + $row->article_title = $arows[0]->title; + + if ( $change_article ) { + $document = & JFactory::getDocument(); + $document->addScript( JURI::root(true).'/media/system/js/modal.js' ); + $js = " + function jSelectArticle(id, title) { + document.getElementById('article_id').value = id; + document.getElementById('article_title').value = title; + document.getElementById('sbox-window').close(); + }"; + $document->addScriptDeclaration($js); + JHTML::_('behavior.modal', 'a.modal-button'); + } + + JRequest::setVar( 'hidemainmenu', 1 ); + + HTML_attachments::editAttachment($row, $lists, $option, $change_article, $update_file); + } + + function save() + { + // Check for request forgeries + JRequest::checkToken() or die( 'Invalid Token'); + + global $option; + $row =& JTable::getInstance('Attachments', 'Table'); + if (!$row->bind(JRequest::get('post'))) { + JError::raiseError(500, $errmsg); + } + + // See if the article has been changed, rename files if necessary + $old_article_id = JRequest::getVar('old_article_id', false); + if ( $old_article_id && is_numeric($old_article_id) ) { + $old_article_id = intval($old_article_id); + } + $article_id = intval($row->article_id); + if ( $old_article_id && ( $article_id != $old_article_id ) ) { + require_once(JPATH_BASE.DS.'..'.DS.'components'.DS.'com_attachments'.DS.'helper.php'); + $error_msg = AttachmentsHelper::switch_article($row, $old_article_id, $article_id); + if ( $error_msg != '' ) { + $warning = JText::_($error_msg); + JError::raiseError(500, $warning); + } + } + + // Compute the update time + jimport( 'joomla.utilities.date' ); + $now = new JDate(); + $row->modification_date = $now->toMySQL(); + + // Update the record + $update_file = JRequest::getVar('update_file', False); + $msg = ""; + if ( $update_file && ( ($_FILES['upload']['size'] > 0) || + ($_FILES['upload']['tmp_name'] != '') ) ) { + // Process the uploaded file (if one was uploaded) + // (Note that this also save the record) + require_once(JPATH_BASE.DS.'..'.DS.'components'.DS.'com_attachments'.DS.'helper.php'); + $msg = AttachmentsHelper::upload_file($row, $article_id, true); + } + else { + // Save the updated attachment + if (!$row->store()) { + JError::raiseError(500, $row->getError()); + } + } + + switch ($this->_task) + { + case 'apply': + $msg = JText::_('CHANGES TO ATTACHMENT SAVED'); + $link = 'index.php?option=' . $option . '&task=edit&cid[]=' . $row->id; + break; + + case 'save': + default: + $msg = JText::_('ATTACHMENT SAVED'); + $link = 'index.php?option=' . $option; + break; + } + + $this->setRedirect($link, $msg); + } + + + function saveNew() + { + // Check for request forgeries + JRequest::checkToken() or die( 'Invalid Token'); + + // Make sure we have a user + $user =& JFactory::getUser(); + if ( $user->get('username') == '' ) { + $errmsg = JText::_('ERROR MUST BE LOGGED IN TO UPLOAD ATTACHMENT'); + JError::raiseError(500, $errmsg); + } + + // Make sure we have a valid article ID + require_once(JPATH_BASE.DS.'..'.DS.'components'.DS.'com_attachments'.DS.'helper.php'); + $article_id = AttachmentsHelper::valid_article_id($_POST['article_id']); + if ( $article_id == -1 ) { + + // Save the warning message for the pop-up window + + // ??? + // echo ""; + // echo ""; + +// require_once(JPATH_BASE.DS.'..'.DS.'components'.DS.'com_attachments'.DS.'helper.php'); +// $msg = JText::_('ERROR MUST SELECT ARTICLE'); +// AttachmentsHelper::save_warning_message($msg); +// $button->set('options', "{handler: 'iframe', size: {x: 400, y: 300}}"); +// $link = "index.php?option=com_attachments&task=warning&tmpl=component"; + + $errmsg = JText::_('ERROR MUST SELECT ARTICLE'); + echo "\n"; +// exit(); + } + + // Make sure this user has permission to upload (should never fail with admin?) + require_once(JPATH_COMPONENT_SITE.DS.'permissions.php'); + if ( !AttachmentsPermissions::user_may_add_attachment($user, $article_id) ) { + $errmsg = JText::_('ERROR NO PERMISSION TO UPLOAD'); + JError::raiseError(500, $errmsg); + exit(); + } + + // Set up the new record + $row =& JTable::getInstance('Attachments', 'Table'); + if (!$row->bind(JRequest::get('post'))) { + JError::raiseError(500, $row->getError()); + } + $row->uploader_id = $user->get('id'); + $row->article_id = $article_id; + + // Handle 'from' clause + $from = JRequest::getVar('from', ' (no from)'); + + $msg = AttachmentsHelper::upload_file($row, $article_id); + + // See where to go to next + global $option; + switch ($this->_task) + { + case 'applyNew': + $link = 'index.php?option=' . $option . '&task=edit&cid[]=' . $row->id; + break; + + case 'saveNew': + default: + $link = 'index.php?option=' . $option; + break; + } + + // If called from the editor, go back to it + if ($from == 'editor') { + $link = 'index.php?option=com_content&task=edit&cid[]=' . $article_id; + } + + // If we are supposed to close this iframe, do it now. + if ( $from == 'closeme' ) { + echo ""; + exit(); + } + + $this->setRedirect($link, $msg); + } + + + function myCancel() + { + // See if we have a special 'from' to handle + $from = JRequest::getVar('from', false); + if ( $from == 'editor' ) { + + // Make sure we have a valid article ID + require_once(JPATH_BASE.DS.'..'.DS.'components'.DS.'com_attachments'.DS.'helper.php'); + $article_id = AttachmentsHelper::valid_article_id($_POST['article_id']); + if ( $article_id == -1 ) { + $this->execute('cancel'); // Give up + } + + $link = 'index.php?option=com_content&task=edit&cid[]=' . $article_id; + $this->setRedirect($link, JText::_('UPLOAD CANCELED')); + } + + $this->execute('cancel'); + } + + + function download() + { + global $mainframe; + if ( ! $mainframe->isAdmin() ) { + $errmsg = JText::_('ERROR MUST BE LOGGED IN AS ADMIN'); + JError::raiseError(500, $errmsg); + } + + // Get the attachment ID + $id = JRequest::getVar('id', null); + if ( !is_numeric($id) ) { + JError::raiseError(500, $errmsg); + } + + require_once(JPATH_BASE.DS.'..'.DS.'components'.DS.'com_attachments'.DS.'helper.php'); + + AttachmentsHelper::download_attachment($id); + } + + + + function remove() + { + jimport('joomla.filesystem.file'); + + global $option; + $cid = JRequest::getVar('cid', array(), '', 'array'); + $db =& JFactory::getDBO(); + if (count($cid)) { + $cids = implode(',', $cid); + $query = "SELECT filename_sys, id FROM #__attachments WHERE id IN ( $cids )"; + $db->setQuery($query); + $rows = $db->loadObjectList(); + + // First delete the actual attachment files + foreach ($rows as $row) { + JFile::delete($row->filename_sys); + } + + // Delete the entries in the attachments table + $query = "DELETE FROM #__attachments WHERE id IN ( $cids )"; + $db->setQuery($query); + if (!$db->query()) { + JError::raiseError(500, $db->getErrorMsg()); + } + } + + $this->setRedirect( 'index.php?option=' . $option); + } + + + function publish() + { + global $option; + $cid = JRequest::getVar('cid', array(), '', 'array'); + if ($this->_task == 'publish') { + $publish = 1; + } + else { + $publish = 0; + } + $attachmentTable =& JTable::getInstance('attachments', 'Table'); + $attachmentTable->publish($cid, $publish); + $this->setRedirect('index.php?option=' . $option); + } + + + function admin() + { + // Set up the tooltip behavior + $opts = Array( 'hideDelay' => 0, 'showDelay' => 0 ); + JHTML::_('behavior.tooltip', '.hasTip', $opts); + + // Set up url/link/tooltip for each command + $url_top = JURI::base() . "index.php?option=com_attachments"; + + // Set up the HTML for each command + $disable_mysql_uninstall_url = "$url_top&controller=special&task=disable_sql_uninstall&tmpl=component&close=true"; + // $disable_mysql_uninstall = JText::_('DISABLE MYSQL UNINSTALLATION'); + $disable_mysql_uninstall_tooltip = JText::_('DISABLE MYSQL UNINSTALLATION TOOLTIP'); + $disable_mysql_uninstall_html = + JHTML::_('tooltip', $disable_mysql_uninstall_tooltip, null, null, + 'DISABLE MYSQL UNINSTALLATION' , $disable_mysql_uninstall_url ); + + $regenerate_system_filenames_url = "$url_top&controller=special&task=regenerate_system_filenames&tmpl=component&close=true"; + // $regenerate_system_filenames = JText::_('REGENERATE ATTACHMENT SYSTEM FILENAMES'); + $regenerate_system_filenames_tooltip = JText::_('REGENERATE ATTACHMENT SYSTEM FILENAMES TOOLTIP'); + $regenerate_system_filenames_html = + JHTML::_('tooltip', $regenerate_system_filenames_tooltip, null, null, + 'REGENERATE ATTACHMENT SYSTEM FILENAMES', $regenerate_system_filenames_url); + ?> +
+

+ +
+ addStyleSheet( $mainframe->getSiteURL() . 'plugins/content/attachments.css', + 'text/css', null, array() ); + $document->addStyleDeclaration( + 'div.componentheading { display: none; } * { overflow: hidden; };'); + + echo '

' . JText::_('WARNING') . '

'; + echo '

'; + echo ''; + echo '

'; + } + +} +?> diff --git a/oss/joomla/trunk/administrator/components/com_attachments/controllers/index.html b/oss/joomla/trunk/administrator/components/com_attachments/controllers/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/controllers/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_attachments/controllers/special.php b/oss/joomla/trunk/administrator/components/com_attachments/controllers/special.php new file mode 100644 index 00000000..faa30e62 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/controllers/special.php @@ -0,0 +1,180 @@ +Special function not specified!"; + exit(); + } + + function editParams() + { + // This function allows editing the Attachments parameters + // with a form that has a regular submit button (not Javascript). + // + // This function is for automated testing of the Attachments + // extension and as exactly the same functionality as the regular + // Attachments parameter editor in the component manager, except + // that it is not a pop-up window. + // + // Due to the implementation of the component parameter editor for + // pop up frames, this save form pops back into edit mode after saving. + + $model = $this->getModel('Special'); + if ( !$model ) { + echo "Unable to find Special model!
"; + exit(); + } + + $table =& JTable::getInstance('component'); + if (!$table->loadByOption( 'com_attachments' )) + { + JError::raiseWarning( 500, 'Unable to load Attachments component' ); + return false; + } + + require_once(JPATH_COMPONENT.DS.'views'.DS.'special'.DS.'view.php'); + $view = new AttachmentsViewSpecial( ); + $view->assignRef('component', $table); + $view->setModel( $model, true ); + $view->display(); + } + + + function showSEF() + { + global $mainframe; + echo ''; + echo "SEF Status"; + echo "SEF: " . $mainframe->getCfg('sef') . "
"; + echo ""; + exit(); + } + + function listAttachmentIDs() + { + $db =& JFactory::getDBO(); + $query = "SELECT attach.id,article_id,art.sectionid,art.catid FROM #__attachments as attach "; + $query .= "LEFT JOIN #__content as art ON attach.article_id = art.id ORDER BY art.id"; + $db->setQuery($query); + $rows = $db->loadObjectList(); + echo ''; + echo "\nAttachment IDs\n"; + echo "Attachment IDS:"; + foreach ($rows as $row) { + echo " " . $row->id . "/" . $row->article_id . "/" . $row->sectionid . "/" . $row->catid; + } + echo "\n"; + exit(); + } + + + // Define some functions for URLs to invoke the udpate functions + // (We could move these to an update controller...) + // + + function add_icon_filenames() + { + global $option; + require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_attachments'.DS.'update.php'); + $msg = AttachmentsUpdate::add_icon_filenames(); + $this->setRedirect('index.php?option=' . $option, $msg); + } + + + function update_null_dates($redirect=true) + { + global $option; + require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_attachments'.DS.'update.php'); + + $numUpdated = AttachmentsUpdate::update_null_dates(); + $msg = JText::sprintf( 'UPDATED N ATTACHMENTS', $numUpdated ); + $this->setRedirect('index.php?option=' . $option, $msg); + } + + + function update_attachments_table() + { + global $option; + require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_attachments'.DS.'update.php'); + + echo ''; + echo "\nUpdating Attachments Tables\n"; + echo "

Updating Attachments Tables

\n"; + + AttachmentsUpdate::update_attachments_table(); + + $return_url = JURI::base(); + echo "
 
Return to Admin page\n"; + echo "\n"; + + exit(); + } + + function disable_sql_uninstall() + { + require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_attachments'.DS.'update.php'); + + $close =JRequest::getVar('close', false); + $msg = AttachmentsUpdate::disable_sql_uninstall(); + + if ( $close ) { + require_once(JPATH_COMPONENT_SITE.DS.'helper.php'); + AttachmentsHelper::enqueueSystemMessage($msg); + + // Close this window and refesh the parent window + echo ""; + } + else { + global $option; + $this->setRedirect('index.php?option=' . $option, $msg); + } + } + + + function regenerate_system_filenames() + { + require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_attachments'.DS.'update.php'); + + $close =JRequest::getVar('close', false); + $msg = AttachmentsUpdate::regenerate_system_filenames(); + + if ( $close ) { + require_once(JPATH_SITE.DS.'components'.DS.'com_attachments'.DS.'helper.php'); + AttachmentsHelper::enqueueSystemMessage($msg); + echo ""; + } + else { + global $option; + $this->setRedirect('index.php?option=' . $option, $msg); + } + } + + +} diff --git a/oss/joomla/trunk/administrator/components/com_attachments/help/en-GB/help.css b/oss/joomla/trunk/administrator/components/com_attachments/help/en-GB/help.css new file mode 100644 index 00000000..41a57215 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/help/en-GB/help.css @@ -0,0 +1,54 @@ +ul li { + /* border: 1px solid blue; */ + border-top: 12px solid transparent; +} + +ol li { + border-top: 4px solid transparent; + /* border: 1px solid red; */ +} + +h1 { + margin-bottom: 0px; + /* border: 1px solid red; */ +} + +h2 { + margin-top: 18px; + margin-bottom: 4px; + /* border: 1px solid red; */ +} +h3 { + margin-top: 0px; + /* border: 1px solid red; */ +} + +ul { + margin-top: 4px; +} + +span.atop { + padding-left: 1em; + font-size: 90%; +} + +a:link { color : #0033ff; text-decoration: none; } +a:visited { color : #0033ff; text-decoration: none; } +a:hover { color : #0033ff; text-decoration: underline; } +a:active { color : #0033ff; text-decoration: none; } + +ul.url { + margin-top: 4px; + padding-top: 0; +} + +ul.url li { + list-style-type: none; + padding: 0; + margin: 0; + border: 0; +} + +ul.url a { + font-weight: bold; +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_attachments/help/en-GB/help.html b/oss/joomla/trunk/administrator/components/com_attachments/help/en-GB/help.html new file mode 100644 index 00000000..8f5dca93 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/help/en-GB/help.html @@ -0,0 +1,509 @@ + + + + +Attachments Documentation + + + + +

Attachments Documentation

+

Version 1.3.4 - August 2008

+ +
    +
  1. Introduction
  2. +
  3. Uploading Restrictions
  4. +
  5. Settings
  6. +
  7. Display Filenames
  8. +
  9. CSS Styling of Attachment Lists
  10. +
  11. File Type Icons
  12. +
  13. Warnings
  14. +
  15. Upgrading
  16. +
  17. Acknowledgements
  18. +
+ +

Introduction

+The 'Attachments' extension for Joomla! allows files to be uploaded +and attached to content articles. 'Attachments' includes a +plugin to display the attachments and a component for uploading and managing +attachments. There are options to control who can see the attachments and +who can upload them, along with several other options to increase its +flexibility and usefulness. Note: all options are controlled through +the component manager. This extension only works for Joomla! 1.5 or later. +
 
+ +If you wish to subsribe to an email list for announcements about +this extension, please subscribe using this web page: + + +This extension provides translation capabilities and supports the following +languages (besides English): + +Many thanks to the translators! If you would like to help translate the +extension to any other language, please contact the author (see end). +[Back to top] + +

Uploading Restrictions

+Not all types of attachment files can be uploaded. The 'Attachments' extension +will not allow uploading of files that are not permitted by the Joomla! Media Manager. +To see (or change) what file types are allowed, go to the Global Configuration +page and click on the System tab. In the Media Settings area, there are +options for controlling what types of file extensions and mime types are permitted +for uploads. The 'Attachments' respects these limitations. However, the +restriction on 'Legal Image Extensions (File Types)' is ignored. +[Back to top] + +

Attachments Settings

+All of the settings for 'Attachments' are controlled via the + component manager. To access these settings, go to the administrative +back end and select "Article Attachments" under the "Component" menu. Click +on the "Parameters" button on the right end of the tool bar and you will see +a series of parameters for this extension. These parameters include +the following:
+ +[Back to top] + +

Display Filename

+Normally, when files are uploaded and listed in a list of attachments, the full +filename is shown as a link to download the attachment. In some cases, the +filenames may be too long for this to work nicely. In the upload form, there is +another field called "Display Filename" in which the person uploading the file +can insert an alternative filename or label to display instead of the full filename. +For instance, some abbreviation of the filename could be added in this field. The +field may be edited in the administrative back end when attachments are edited. +Note: There is an option called "Maximum Filename Length" in the plugin options. +It can be set to automatically truncate uploaded displayed filenames; the +resulting truncated filename will be inserted into the "Display Filename" field. + +[Back to top] + +

CSS Styling of Attachment Lists

+The lists of attachments on the front end are done using a special +'div' that contains a table for the attachments. The table has +several different CSS classes associated with it to allow the website +developer the flexibility to customize the appearance of the table. Look in +the attachments plugin file CSS file (in plugins/content/attachments.css) for +examples. If you wish to change the style, consider copying the original +styles into the end of the same file and renaming 'attachmentsList' in the +copied section to something of your choice. Edit the Attachments parameter +(in the component manager) and change the parameter attachments table style +to the new class name. Then modify the class definitions in your copied section +appropriately. This approach will allow you to quickly revert to the original +style by changing the plugin parameter attachments table style back to +its default, 'attachmentList'. This also has the advantage that the +section of modified styles can be copied to a file and easily brought back in +when the version of Attachments is upgraded. This could also be done via a +CSS @import command. + +[Back to top] + +

File Type Icons

+The 'Attachments' extension adds an icon in front of each attachment in the +list of attachments. If you wish to add a new icon type, follow these steps: +(1) Add an appropriate icon in the directory 'media/attachments/icons', if an +appropriate icon is not already there; (2) Edit the file +'components/com_attachments/file_types.php' and add an appropriate line to the +static array $attachments_icon_from_file_extension which maps a file extension to an icon +name (all in the media/attachments/icons directory). If this does not work, +you may need to add an appropriate line to the array $attachments_icon_from_mime_type. (3) +Don't forget to make copies of the icon file and the updated file_types.php to +some directory outside of the website directories before upgrading the version +of Attachments in the future. + +[Back to top] + +

Warnings

+ +[Back to top] + +

Upgrading

+If you have previously added attachments that you wish to preserve +through an upgrade, use these steps: +
    +
  1. [This step is optional but encouraged, to make sure you have +a backup of the attachments database in case something goes wrong.]
    +Use phpMyAdmin +(or other SQL editing tool) to save the contents +of the jos_attachments table (Use the 'Export' option with +'Complete' inserts for data (not 'Extended' inserts). You should also +back up the uploaded attachments files (usually in the 'attachments' +directory ) +
  2. + +
  3. Go to the Attachments manager in the administrative back end and +click on the item labelled 'Admin' on the right end of the toolbar. +Click on the command 'Disable uninstallation of MySQL Attachments Table'. +This disables the deletion of the attachments database table during +uninstallation of the attachments component. +
  4. + +
  5. Uninstall the 'Attachments' component.
  6. + +
  7. Uninstall all of the 'Attachments' plugins
  8. + +
  9. Now install the new release by unziping the release file and +installing all of the new plugins and then the component. +During the installation of the component, the attachments database +table will be updated automatically. +
  10. + +
  11. Reenable all of the 'Attachments' plugins.
  12. + +
  13. Your attachments should be available again. Go to the Attachments +manager in the administrative back end to verify that your attachments +are okay.
  14. + +
+

Note that uninstalling the 'Attachments' extension does not +delete the previously uploaded files, but it does remove the attachments +table in the database. So after reinstalling a new version of +'Attachments', it is only necessary to restore the attachments +table to restore all the old attachments.

+ +

+If you decide not to restore the attachments database, do not forget to delete any +obsolete uploaded files in the attachments subdirectory to avoid filename conflicts +in the future. [Back to top]

+ +

Acknowledgements

+Many thanks for the following contributors or resources: + +[Back to top] + +

Please report bugs and suggestions to jmcameron@jmcameron.net.

+ + diff --git a/oss/joomla/trunk/administrator/components/com_attachments/help/en-GB/index.html b/oss/joomla/trunk/administrator/components/com_attachments/help/en-GB/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/help/en-GB/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_attachments/help/index.html b/oss/joomla/trunk/administrator/components/com_attachments/help/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/help/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_attachments/index.html b/oss/joomla/trunk/administrator/components/com_attachments/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_attachments/install.attachments.php b/oss/joomla/trunk/administrator/components/com_attachments/install.attachments.php new file mode 100644 index 00000000..4a246def --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/install.attachments.php @@ -0,0 +1,92 @@ +RELEASE < 1.5 ) { + echo "

The 'Attachments' package will only work on Joomla version 1.5 or later!

"; + return false; + } + + echo "

Updating Attachments Table...

\n"; + require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_attachments'.DS.'update.php'); + AttachmentsUpdate::update_attachments_table(); + + // Check to see if the plugin has been installed yet + $plugin_installed = false; + $plugin_published = false; + $db =& JFactory::getDBO(); + $query = "SELECT published FROM #__plugins WHERE element='attachments' AND folder='content' LIMIT 1"; + $db->setQuery($query); + $rows = $db->loadObjectList(); + if ( count($rows) > 0 ) { + $plugin_installed = true; + $plugin_published = (intval($rows[0]->published) == 1); + } + + echo '
Attachments for articles component succesfully installed!
'; + + if ( $plugin_installed ) { + if ( !$plugin_published ) + echo "Don’t forget to enable the plugins!"; + } + else { + echo "Don’t forget to install the plugins too!"; + } + ?> +
+

NOTES:

+ +

+ Once the attachment plugins and component have been installed and the plugins are enabled, + the attachments should work. The default after installation is for the attachments to be + visible to anyone that is logged in and for the link to add attachments to visible only + to the author of the article. Both of these options can be changed via the attachments + parameters which can be changed in the component manager (go to the administrative back end, + select "Article Attachments" under the "Components" menu, and click on the Parameters + item on the toolbar). +

+ +

+ Once an attachment is uploaded, it is not visible until it is published. To do this go to the + administrative backend and select "Article Attachments" under the "Components" menu. This will + show a list of attachments and has controls to publish the attachments. The option to make + attachments automatically be published after they are uploaded can be changed via the Attachments + component manager. +

+ +

+ This extension respects the options in the Media Manager regarding what types of files can + be uploaded. If you can’t attach certain file types (such as zip files), go to the + "Global Configuration" item under the "Site" menu in the administrative backend. Click + on the "System" tab and look for the "Media Settings" section. You can add appropriate + file extensions or mime types there. +

+ +

+ Please see the help page for further details, including known limitations of this extension + and suggestions on how to upgrade this extension. To get to the help page, select + "Article Attachments" under the "Components" menu in the adminstrative backend. + Click on the help icon on the toolbar to bring up the help page. Or you may use this URL: + Help File (in English). +

+ +

+ Please report bugs and suggestions to jmcameron@jmcameron.net. +

+ \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_attachments/install.mysql.sql b/oss/joomla/trunk/administrator/components/com_attachments/install.mysql.sql new file mode 100644 index 00000000..ab9b7ee5 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/install.mysql.sql @@ -0,0 +1,22 @@ +CREATE TABLE IF NOT EXISTS `#__attachments` +( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `filename` VARCHAR(80) NOT NULL, + `filename_sys` VARCHAR(255) NOT NULL, + `file_type` VARCHAR(30) NOT NULL, + `file_size` INT(11) UNSIGNED NOT NULL, + `icon_filename` VARCHAR(20) NOT NULL, + `display_filename` VARCHAR(80) NOT NULL DEFAULT '', + `description` VARCHAR(255) NOT NULL DEFAULT '', + `url` VARCHAR(255) NOT NULL, + `uploader_id` INT(11) NOT NULL, + `article_id` INT(11) UNSIGNED NOT NULL, + `published` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0', + `user_field_1` VARCHAR(100) NOT NULL DEFAULT '', + `user_field_2` VARCHAR(100) NOT NULL DEFAULT '', + `user_field_3` VARCHAR(100) NOT NULL DEFAULT '', + `create_date` DATETIME DEFAULT NULL, + `modification_date` DATETIME DEFAULT NULL, + `download_count` INT(11) UNSIGNED DEFAULT '0', + PRIMARY KEY (`id`) +); diff --git a/oss/joomla/trunk/administrator/components/com_attachments/install.noutf8.sql b/oss/joomla/trunk/administrator/components/com_attachments/install.noutf8.sql new file mode 100644 index 00000000..cbc9d9fd --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/install.noutf8.sql @@ -0,0 +1,23 @@ +CREATE TABLE IF NOT EXISTS `#__attachments` +( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `filename` VARCHAR(240) NOT NULL, + `filename_sys` TEXT NOT NULL, + `file_type` VARCHAR(30) NOT NULL, + `file_size` INT(11) UNSIGNED NOT NULL, + `icon_filename` VARCHAR(60) NOT NULL, + `display_filename` VARCHAR(240) NOT NULL DEFAULT '', + `description` TEXT NOT NULL DEFAULT '', + `url` TEXT NOT NULL, + `uploader_id` INT(11) NOT NULL, + `article_id` INT(11) UNSIGNED NOT NULL, + `published` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0', + `user_field_1` TEXT NOT NULL DEFAULT '', + `user_field_2` TEXT NOT NULL DEFAULT '', + `user_field_3` TEXT NOT NULL DEFAULT '', + `create_date` DATETIME DEFAULT NULL, + `modification_date` DATETIME DEFAULT NULL, + `download_count` INT(11) UNSIGNED DEFAULT '0', + PRIMARY KEY (`id`) +); + diff --git a/oss/joomla/trunk/administrator/components/com_attachments/models/index.html b/oss/joomla/trunk/administrator/components/com_attachments/models/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/models/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_attachments/models/special.php b/oss/joomla/trunk/administrator/components/com_attachments/models/special.php new file mode 100644 index 00000000..0a42d8d5 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/models/special.php @@ -0,0 +1,53 @@ +loadByOption( 'com_attachments' ); + + // work out file path + if ($path = JRequest::getString( 'path' )) { + $path = JPath::clean( JPATH_SITE.DS.$path ); + JPath::check( $path ); + } else { + $option = preg_replace( '#\W#', '', $table->option ); + $path = JPATH_ADMINISTRATOR.DS.'components'.DS.$option.DS.'config.xml'; + } + + jimport('joomla.filesystem.file'); + if (JFile::exists( $path )) { + $instance = new JParameter( $table->params, $path ); + } else { + $instance = new JParameter( $table->params ); + } + } + return $instance; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_attachments/tables/attachments.php b/oss/joomla/trunk/administrator/components/com_attachments/tables/attachments.php new file mode 100644 index 00000000..e8415d5a --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/tables/attachments.php @@ -0,0 +1,38 @@ + diff --git a/oss/joomla/trunk/administrator/components/com_attachments/tables/index.html b/oss/joomla/trunk/administrator/components/com_attachments/tables/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/tables/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_attachments/toolbar.attachments.html.php b/oss/joomla/trunk/administrator/components/com_attachments/toolbar.attachments.html.php new file mode 100644 index 00000000..e5cb7508 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/toolbar.attachments.html.php @@ -0,0 +1,52 @@ +[ '. $text.' ]', 'attachments.png' ); + + if ( $edit ) { + JToolBarHelper::save(); + JToolBarHelper::apply(); + // for existing attachments the button is renamed `close` + JToolBarHelper::cancel( 'cancel', 'Close' ); + } + else { + JToolBarHelper::save('saveNew', 'Save'); + JToolBarHelper::apply('applyNew', 'Apply'); + JToolBarHelper::cancel('myCancel', 'Cancel'); + } + } + + function _DEFAULT() + { + JToolBarHelper::title( JText::_( 'ARTICLE ATTACHMENTS' ), 'attachments'); + + JToolBarHelper::help('help', true); + JToolBarHelper::publishList(); + JToolBarHelper::unpublishList(); + JToolBarHelper::editListX(); + JToolBarHelper::addNewX(); + JToolBarHelper::deleteList(); + JToolBarHelper::preferences( 'com_attachments', $height='500', $width='800' ); + + // Add a button for extra admin commands + $bar = & JToolBar::getInstance('toolbar'); + $bar->appendButton( 'Popup', 'admin', $alt='ADMIN', + 'index.php?option=com_attachments&task=admin&tmpl=component', + $width='600', $height='450' ); + } +} +?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_attachments/toolbar.attachments.php b/oss/joomla/trunk/administrator/components/com_attachments/toolbar.attachments.php new file mode 100644 index 00000000..0f2b4273 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/toolbar.attachments.php @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_attachments/uninstall.attachments.php b/oss/joomla/trunk/administrator/components/com_attachments/uninstall.attachments.php new file mode 100644 index 00000000..cf2161b8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/uninstall.attachments.php @@ -0,0 +1,35 @@ +get('attachments_subdir', 'attachments'); + if ( $upload_subdir == '' ) { + $upload_subdir = "attachments"; + } + if ( !JFolder::exists( JPATH_BASE . $upload_subdir ) ) { + $upload_subdir = null; + } + + ?> +
The article attachments component is now removed from your system.
+ Don’t forget to remove the attachments plugins too!
+ You will also need to manually delete the attachments subdirectory: '" . $upload_subdir . "'\n"; + } +} +?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_attachments/uninstall.mysql.sql b/oss/joomla/trunk/administrator/components/com_attachments/uninstall.mysql.sql new file mode 100644 index 00000000..dbc9d677 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/uninstall.mysql.sql @@ -0,0 +1 @@ +DROP TABLE `#__attachments`; diff --git a/oss/joomla/trunk/administrator/components/com_attachments/update.php b/oss/joomla/trunk/administrator/components/com_attachments/update.php new file mode 100644 index 00000000..cb28f500 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/update.php @@ -0,0 +1,305 @@ +isAdmin() or die('Must be admin to execute!'); + +/** +* Attachments component +* @package Attachments +* @Copyright (C) 2007, 2008 Jonathan M. Cameron, All Rights Reserved +* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL +* @link http://joomlacode.org/gf/project/attachments/frs/ +* @author Jonathan M. Cameron +**/ + +/** + * A class for update functions + */ +class AttachmentsUpdate +{ + function add_icon_filenames() + { + require_once(JPATH_COMPONENT_SITE.DS.'file_types.php'); + + // Get all the attachment IDs + $db =& JFactory::getDBO(); + $query = "SELECT id, filename, file_type, icon_filename FROM #__attachments WHERE file_type IS NULL"; + $db->setQuery($query); + $rows = $db->loadObjectList(); + if ( count($rows) == 0 ) { + return 'No file_type fields need updating'; + } + $IDs = array(); + foreach ($rows as $row) { + $IDs[] = $row->id; + } + + // Update the icon file_types all the attachments (that do not have one already) + $row =& JTable::getInstance('Attachments', 'Table'); + $numUpdated = 0; + foreach ($IDs as $id) { + + $row->load($id); + + // Only update those attachment records that don't already have an icon_filename + if ( strlen( $row->icon_filename ) == 0 ) { + $new_icon_filename = AttachmentsFileTypes::icon_filename($row->filename, $row->file_type); + if ( strlen( $new_icon_filename) > 0 ) { + $row->icon_filename = $new_icon_filename; + if (!$row->store()) { + JError::raiseError(500, $row->getError()); + } + $numUpdated++; + } + } + } + + return JText::_('ADDED ICON FILENAMES TO') . " $numUpdated " . JText::_('ATTACHMENT S'); + } + + + function update_null_dates($redirect=true) + { + global $mainframe; + + // Get all the attachment IDs + $db =& JFactory::getDBO(); + $query = "SELECT * FROM #__attachments"; + $db->setQuery($query); + $rows = $db->loadObjectList(); + if ( count($rows) == 0 ) { + return 0; + } + + // Update the dates for all the attachments + $numUpdated = 0; + foreach ($rows as $row) { + + // Update the new create and update dates if they are null + $updated = false; + $create_date = $row->create_date; + if ( is_null($create_date) || $create_date == '' ) { + jimport( 'joomla.utilities.date' ); + $cdate = new JDate(filemtime($row->filename_sys), $mainframe->getCfg('offset')); + $create_date = $cdate->toMySQL(); + $updated = true; + } + $mod_date = $row->modification_date; + if ( is_null($mod_date) || $mod_date == '' ) { + jimport( 'joomla.utilities.date' ); + $mdate = new JDate(filemtime($row->filename_sys), $mainframe->getCfg('offset')); + $mod_date = $mdate->toMySQL(); + $updated = true; + } + + // Update the record + if ( $updated ) { + $query = "UPDATE #__attachments set modification_date='{$mod_date}', create_date='{$create_date}' WHERE id='{$row->id}'"; + $db->setQuery($query); + if (!$db->query()) { + echo "Error updating {$row->filename}: " . $db->stderr(); + } + $numUpdated++; + } + } + + return $numUpdated; + } + + + function update_attachments_table() + { + // NOTE: It should be harmless to run this function multiple times + + // Get the existing field names + $db =& JFactory::getDBO(); + $query = "explain #__attachments"; + $db->setQuery($query); + $rows = $db->loadObjectList(); + $fields = array(); + foreach ($rows as $row) { + $fields[] = $row->Field; + } + + // Define the columns/fields that may need to be added + $new_fields = Array(); + $new_fields['display_filename'] = + "ALTER TABLE #__attachments ADD `display_filename` VARCHAR(80) NOT NULL DEFAULT ''"; + $new_fields['user_field_1'] = + "ALTER TABLE #__attachments ADD `user_field_1` VARCHAR(100) NOT NULL DEFAULT ''"; + $new_fields['user_field_2'] = + "ALTER TABLE #__attachments ADD `user_field_2` VARCHAR(100) NOT NULL DEFAULT ''"; + $new_fields['user_field_3'] = + "ALTER TABLE #__attachments ADD `user_field_3` VARCHAR(100) NOT NULL DEFAULT ''"; + $new_fields['create_date'] = + "ALTER TABLE #__attachments ADD `create_date` DATETIME DEFAULT NULL"; + $new_fields['modification_date'] = + "ALTER TABLE #__attachments ADD `modification_date` DATETIME DEFAULT NULL"; + $new_fields['download_count'] = + "ALTER TABLE #__attachments ADD `download_count` INT(11) UNSIGNED DEFAULT '0'"; + + // See if we need to add specific fields + $num_fields_added = 0; + $dates_added = false; + foreach ($new_fields as $field => $query) { + if ( !in_array( $field , $fields ) ) { + echo "    Adding missing column '$field'
"; + $db->setQuery($query); + if (!$db->query()) { + JError::raiseError( 500, + "Error installing field " . $field . ": " . $db->stderr() ); + return false; + } + if ( $field == 'create_date' ) + $dates_added = true; + $num_fields_added++; + } + } + + if ( $num_fields_added != 0 ) + echo ""; + + if ( $dates_added ) { + echo "    Adding missing create/modification dates (using date each attachment file was created).
"; + require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_attachments'.DS.'update.php'); + $num = AttachmentsUpdate::update_null_dates(); + if ( $num == 0 ) + echo "       No attachments needed updating
"; + elseif ( $num == 1 ) + echo "       1 attachment updated
"; + else + echo "       $num attachments updated
"; + } + + // Get the existing indexed column names + $query = "show index from #__attachments"; + $db->setQuery($query); + $rows = $db->loadObjectList(); + $indexes = array(); + foreach ($rows as $row) { + $indexes[] = $row->Key_name; + } + + // Define the indexes that may need to get added + $new_indexes = Array(); + $new_indexes['attachment_article_id_index'] = + "CREATE INDEX attachment_article_id_index ON `#__attachments` (`article_id`)"; + /* These indeces do not add any benefit + See: http://dev.mysql.com/doc/refman/5.0/en/order-by-optimization.html + $new_indexes['attachment_filename_index'] = + "CREATE INDEX attachment_filename_index ON `#__attachments` (`filename`)"; + $new_indexes['attachment_file_size_index'] = + "CREATE INDEX attachment_file_size_index ON `#__attachments` (`file_size`)"; + $new_indexes['attachment_create_date_index'] = + "CREATE INDEX attachment_create_date_index ON `#__attachments` (`create_date`)"; + $new_indexes['attachment_modification_date_index'] = + "CREATE INDEX attachment_modification_date_index ON `#__attachments` (`modification_date`)"; + */ + + // Add any missing indexes + echo "
"; + $num_indexes_added = 0; + foreach ($new_indexes as $index => $query) { + if ( !in_array( $index , $indexes ) ) { + echo "    Adding index '$index'
"; + $db->setQuery($query); + if (!$db->query()) { + JError::raiseError( 500, "Error installing index " . $index . ": " . $db->stderr() ); + return false; + } + $num_indexes_added++; + } + } + echo "

The attachments table is now up to date.

\n"; + + return true; + } + + + function disable_sql_uninstall($dbtype = 'mysql') + { + jimport('joomla.filesystem.file'); + + // Construct the filenames + $filename = JPATH_COMPONENT_ADMINISTRATOR.DS."uninstall.$dbtype.sql"; + $tempfilename = $filename.'.tmp'; + $msg = ''; + + // Read the content of the old version of the unistall sql file + $contents = JFile::read($filename); + $lines = explode("\n", $contents); + $new_lines = Array(); + for ($i=0; $i < count($lines); $i++) { + $line = trim($lines[$i]); + if ( strlen($line) != 0 ) { + if ( $line[0] != '#' ) { + $line = '# ' . $line; + } + $new_lines[] = $line; + } + } + + // Overwrite the old file with a commented out version + $new_contents = implode("\n", $new_lines); + JFile::write($tempfilename, $new_contents); + if ( ! JFile::copy( $tempfilename, $filename) ) { + $msg = JText::_('ERROR UPDATING FILE') . ": $filename!"; + } + + // Let the user know what happened + if ( $msg == '' ) { + $msg = JText::_('DISABLED UNINSTALLING MYSQL ATTACHMENTS TABLE'); + } + return $msg; + } + + + function regenerate_system_filenames() + { + // Get the component parameters + jimport('joomla.application.component.helper'); + $params = JComponentHelper::getParams('com_attachments'); + + // Define where the attachments go + $upload_url = $params->get('attachments_subdir', 'attachments'); + $upload_dir = JPATH_SITE . DS . $upload_url; + + // Get all the attachment IDs + $db =& JFactory::getDBO(); + $query = "SELECT id FROM #__attachments"; + $db->setQuery($query); + $rows = $db->loadObjectList(); + if ( count($rows) == 0 ) { + return 'No records to update null dates for.'; + } + $IDs = array(); + foreach ($rows as $row) { + $IDs[] = $row->id; + } + + // Update the system filenames for all the attachments + $attachment =& JTable::getInstance('Attachments', 'Table'); + $numUpdated = 0; + foreach ($IDs as $id) { + + $attachment->load($id); + + // Construct the updated system filename + $filename_info = pathinfo($attachment->filename_sys); + $basename = $filename_info['basename']; + $filename_sys = $upload_dir.DS.$basename; + + $attachment->filename_sys = $filename_sys; + + // Update the record + if (!$attachment->store()) { + JError::raiseError(500, $attachment->getError()); + } + $numUpdated++; + } + + return JText::sprintf( 'UPDATED N ATTACHMENTS', $numUpdated ); + } + +} diff --git a/oss/joomla/trunk/administrator/components/com_attachments/views/index.html b/oss/joomla/trunk/administrator/components/com_attachments/views/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/views/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_attachments/views/special/index.html b/oss/joomla/trunk/administrator/components/com_attachments/views/special/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/views/special/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_attachments/views/special/view.php b/oss/joomla/trunk/administrator/components/com_attachments/views/special/view.php new file mode 100644 index 00000000..a453cf45 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_attachments/views/special/view.php @@ -0,0 +1,64 @@ +getModel(); + $params = &$model->getParams(); + +?> + + + + Edit Attachments Parameters + + + + +

Edit Attachments Parameters

+
+
+ +
+
+ + + + render();?> +
+ + + + + + + + +
+ + +authorize( 'com_banners', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} + +// Set the table directory +JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_banners'.DS.'tables'); + +$controllerName = JRequest::getCmd( 'c', 'banner' ); + +if($controllerName == 'client') { + JSubMenuHelper::addEntry(JText::_('Banners'), 'index.php?option=com_banners'); + JSubMenuHelper::addEntry(JText::_('Clients'), 'index.php?option=com_banners&c=client', true ); + JSubMenuHelper::addEntry(JText::_('Categories'), 'index.php?option=com_categories§ion=com_banner'); +} else { + JSubMenuHelper::addEntry(JText::_('Banners'), 'index.php?option=com_banners', true ); + JSubMenuHelper::addEntry(JText::_('Clients'), 'index.php?option=com_banners&c=client'); + JSubMenuHelper::addEntry(JText::_('Categories'), 'index.php?option=com_categories§ion=com_banner'); +} + +switch ($controllerName) +{ + default: + $controllerName = 'banner'; + // allow fall through + + case 'banner' : + case 'client': + // Temporary interceptor + $task = JRequest::getCmd('task'); + if ($task == 'listclients') { + $controllerName = 'client'; + } + + require_once( JPATH_COMPONENT.DS.'controllers'.DS.$controllerName.'.php' ); + $controllerName = 'BannerController'.$controllerName; + + // Create the controller + $controller = new $controllerName(); + + // Perform the Request task + $controller->execute( JRequest::getCmd('task') ); + + // Redirect if set by the controller + $controller->redirect(); + break; +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_banners/banners.xml b/oss/joomla/trunk/administrator/components/com_banners/banners.xml new file mode 100644 index 00000000..ee860619 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_banners/banners.xml @@ -0,0 +1,12 @@ + + + Banners + Joomla! Project + April 2006 + Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + This component manages banners and banner clients + diff --git a/oss/joomla/trunk/administrator/components/com_banners/config.xml b/oss/joomla/trunk/administrator/components/com_banners/config.xml new file mode 100644 index 00000000..6e6976a5 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_banners/config.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/oss/joomla/trunk/administrator/components/com_banners/controllers/banner.php b/oss/joomla/trunk/administrator/components/com_banners/controllers/banner.php new file mode 100644 index 00000000..cbb6bd11 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_banners/controllers/banner.php @@ -0,0 +1,447 @@ +registerTask( 'add', 'edit' ); + $this->registerTask( 'apply', 'save' ); + $this->registerTask( 'resethits', 'save' ); + $this->registerTask( 'unpublish', 'publish' ); + } + + /** + * Display the list of banners + */ + function display() + { + global $mainframe; + + $db =& JFactory::getDBO(); + + $context = 'com_banners.banner.list.'; + $filter_order = $mainframe->getUserStateFromRequest( $context.'filter_order', 'filter_order', 'cc.title', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); + $filter_catid = $mainframe->getUserStateFromRequest( $context.'filter_catid', 'filter_catid', '', 'int' ); + $filter_state = $mainframe->getUserStateFromRequest( $context.'filter_state', 'filter_state', '', 'word' ); + $search = $mainframe->getUserStateFromRequest( $context.'search', 'search', '', 'string' ); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $context.'limitstart', 'limitstart', 0, 'int' ); + + $where = array(); + + if ( $filter_state ) + { + if ( $filter_state == 'P' ) { + $where[] = 'b.showBanner = 1'; + } + else if ($filter_state == 'U' ) { + $where[] = 'b.showBanner = 0'; + } + } + if ($filter_catid) { + $where[] = 'cc.id = ' . (int) $filter_catid; + } + if ($search) { + $where[] = 'LOWER(b.name) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + + $where = count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : ''; + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', b.ordering'; + + // get the total number of records + $query = 'SELECT COUNT(*)' + . ' FROM #__banner AS b' + . ' LEFT JOIN #__categories AS cc ON cc.id = b.catid' + . $where + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pageNav = new JPagination( $total, $limitstart, $limit ); + + $query = 'SELECT b.*, c.name AS client_name, cc.title AS category_name, u.name AS editor' + . ' FROM #__banner AS b' + . ' INNER JOIN #__bannerclient AS c ON c.cid = b.cid' + . ' LEFT JOIN #__categories AS cc ON cc.id = b.catid' + . ' LEFT JOIN #__users AS u ON u.id = b.checked_out' + . $where + . $orderby + ; + $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); + $rows = $db->loadObjectList(); + + // build list of categories + $javascript = 'onchange="document.adminForm.submit();"'; + $lists['catid'] = JHTML::_('list.category', 'filter_catid', 'com_banner', (int) $filter_catid, $javascript ); + + // state filter + $lists['state'] = JHTML::_('grid.state', $filter_state ); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + require_once(JPATH_COMPONENT.DS.'views'.DS.'banner.php'); + BannersViewBanner::banners( $rows, $pageNav, $lists ); + } + + function edit() + { + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + if ($this->_task == 'edit') { + $cid = JRequest::getVar('cid', array(0), 'method', 'array'); + $cid = array((int) $cid[0]); + } else { + $cid = array( 0 ); + } + + $option = JRequest::getCmd('option'); + + $lists = array(); + + $row =& JTable::getInstance('banner', 'Table'); + $row->load( $cid[0] ); + + if ($cid[0]) { + $row->checkout( $user->get('id') ); + } else { + $row->showBanner = 1; + } + + // Build Client select list + $sql = 'SELECT cid, name' + . ' FROM #__bannerclient' + ; + $db->setQuery($sql); + if (!$db->query()) + { + $this->setRedirect( 'index.php?option=com_banners' ); + return JError::raiseWarning( 500, $db->getErrorMsg() ); + } + + $banner_params = new JParameter( $row->params ); + $lists['width'] = $banner_params->get( 'width'); + $lists['height'] = $banner_params->get( 'height'); + + $clientlist[] = JHTML::_('select.option', '0', JText::_( 'Select Client' ), 'cid', 'name' ); + $clientlist = array_merge( $clientlist, $db->loadObjectList() ); + $lists['cid'] = JHTML::_('select.genericlist', $clientlist, 'cid', 'class="inputbox" size="1"','cid', 'name', $row->cid ); + + // Imagelist + $javascript = 'onchange="changeDisplayImage();"'; + $directory = '/images/banners'; + $lists['imageurl'] = JHTML::_('list.images', 'imageurl', $row->imageurl, $javascript, $directory, "bmp|gif|jpg|png|swf" ); + + // build list of categories + $lists['catid'] = JHTML::_('list.category', 'catid', 'com_banner', intval( $row->catid ) ); + + // sticky + $lists['sticky'] = JHTML::_('select.booleanlist', 'sticky', 'class="inputbox"', $row->sticky ); + + // published + $lists['showBanner'] = JHTML::_('select.booleanlist', 'showBanner', '', $row->showBanner ); + + require_once(JPATH_COMPONENT.DS.'views'.DS.'banner.php'); + BannersViewBanner::banner( $row, $lists ); + } + + /** + * Save method + */ + function save() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $this->setRedirect( 'index.php?option=com_banners' ); + + // Initialize variables + $db =& JFactory::getDBO(); + + $post = JRequest::get( 'post' ); + // fix up special html fields + $post['custombannercode'] = JRequest::getVar( 'custombannercode', '', 'post', 'string', JREQUEST_ALLOWRAW ); + + $row =& JTable::getInstance('banner', 'Table'); + + // Save params temp fix + $temp1 = array(); + $temp2 = array(); + $temp1['width'] = (int) $post['width']; + $temp1['height'] = (int) $post['height']; + foreach ($temp1 as $k => $v) + { + if ( $k && strlen($v) ) + { + $temp2[] = $k.'='.$v; + } + } + $row->params = implode( "\n", $temp2 ); + + if (!$row->bind( $post )) { + return JError::raiseWarning( 500, $row->getError() ); + } + + // Resets clicks when `Reset Clicks` button is used instead of `Save` button + $task = JRequest::getCmd( 'task' ); + if ( $task == 'resethits' ) + { + $row->clicks = 0; + $msg = JText::_( 'Reset Banner clicks' ); + } + + // Sets impressions to unlimited when `unlimited` checkbox ticked + $unlimited = JRequest::getBool('unlimited'); + if ($unlimited) { + $row->imptotal = 0; + } + + if (!$row->check()) { + return JError::raiseWarning( 500, $row->getError() ); + } + + // if new item order last in appropriate group + if (!$row->bid) + { + $where = 'catid = '.(int) $row->catid; + $row->ordering = $row->getNextOrder( $where ); + } + + if (!$row->store()) { + return JError::raiseWarning( 500, $row->getError() ); + } + $row->checkin(); + + switch ($task) + { + case 'apply': + $link = 'index.php?option=com_banners&task=edit&cid[]='. $row->bid ; + break; + + case 'save': + default: + $link = 'index.php?option=com_banners'; + break; + } + + $this->setRedirect( $link, JText::_( 'Item Saved' ) ); + } + + function cancel() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $this->setRedirect( 'index.php?option=com_banners' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $post = JRequest::get( 'post' ); + $row =& JTable::getInstance('banner', 'Table'); + $row->bind( $post ); + $row->checkin(); + } + + /** + * Copies one or more banners + */ + function copy() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $this->setRedirect( 'index.php?option=com_banners' ); + + $cid = JRequest::getVar( 'cid', null, 'post', 'array' ); + $db =& JFactory::getDBO(); + $table =& JTable::getInstance('banner', 'Table'); + $user = &JFactory::getUser(); + $n = count( $cid ); + + if ($n > 0) + { + foreach ($cid as $id) + { + if ($table->load( (int)$id )) + { + $table->bid = 0; + $table->name = 'Copy of ' . $table->name; + $table->impmade = 0; + $table->clicks = 0; + $table->showBanner = 0; + $table->date = $db->getNullDate(); + + if (!$table->store()) { + return JError::raiseWarning( $table->getError() ); + } + } + else { + return JError::raiseWarning( 500, $table->getError() ); + } + } + } + else { + return JError::raiseWarning( 500, JText::_( 'No items selected' ) ); + } + $this->setMessage( JText::sprintf( 'Items copied', $n ) ); + } + + function publish() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $this->setRedirect( 'index.php?option=com_banners' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + $task = JRequest::getCmd( 'task' ); + $publish = ($task == 'publish'); + $n = count( $cid ); + + if (empty( $cid )) { + return JError::raiseWarning( 500, JText::_( 'No items selected' ) ); + } + + JArrayHelper::toInteger( $cid ); + $cids = implode( ',', $cid ); + + $query = 'UPDATE #__banner' + . ' SET showBanner = ' . (int) $publish + . ' WHERE bid IN ( '. $cids.' )' + . ' AND ( checked_out = 0 OR ( checked_out = ' .(int) $user->get('id'). ' ) )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + return JError::raiseWarning( 500, $db->getError() ); + } + $this->setMessage( JText::sprintf( $publish ? 'Items published' : 'Items unpublished', $n ) ); + } + + function remove() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $this->setRedirect( 'index.php?option=com_banners' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + $n = count( $cid ); + JArrayHelper::toInteger( $cid ); + + if ($n) + { + $query = 'DELETE FROM #__banner' + . ' WHERE bid = ' . implode( ' OR bid = ', $cid ) + ; + $db->setQuery( $query ); + if (!$db->query()) { + JError::raiseWarning( 500, $db->getError() ); + } + } + + $this->setMessage( JText::sprintf( 'Items removed', $n ) ); + } + + /** + * Save the new order given by user + */ + function saveOrder() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $this->setRedirect( 'index.php?option=com_banners' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + $order = JRequest::getVar( 'order', array(), 'post', 'array' ); + $row =& JTable::getInstance('banner', 'Table'); + $total = count( $cid ); + $conditions = array(); + + if (empty( $cid )) { + return JError::raiseWarning( 500, JText::_( 'No items selected' ) ); + } + + // update ordering values + for ($i = 0; $i < $total; $i++) + { + $row->load( (int) $cid[$i] ); + if ($row->ordering != $order[$i]) + { + $row->ordering = $order[$i]; + if (!$row->store()) { + return JError::raiseError( 500, $db->getErrorMsg() ); + } + // remember to reorder this category + $condition = 'catid = '.(int) $row->catid; + $found = false; + foreach ($conditions as $cond) { + if ($cond[1] == $condition) + { + $found = true; + break; + } + } + if (!$found) { + $conditions[] = array ( $row->bid, $condition ); + } + } + } + + // execute reorder for each category + foreach ($conditions as $cond) + { + $row->load( $cond[0] ); + $row->reorder( $cond[1] ); + } + + // Clear the component's cache + $cache =& JFactory::getCache('com_banners'); + $cache->clean(); + + $this->setMessage( JText::_('New ordering saved') ); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_banners/controllers/client.php b/oss/joomla/trunk/administrator/components/com_banners/controllers/client.php new file mode 100644 index 00000000..70229d6d --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_banners/controllers/client.php @@ -0,0 +1,213 @@ +registerTask( 'add', 'edit' ); + $this->registerTask( 'apply', 'save' ); + } + + function display() + { + global $mainframe; + + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + $context = 'com_banners.bannerclient.list.'; + $filter_order = $mainframe->getUserStateFromRequest( $context.'filter_order', 'filter_order', 'a.name', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); + $search = $mainframe->getUserStateFromRequest( $context.'search', 'search', '', 'string' ); + $search = JString::strtolower( $search ); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $context.'limitstart', 'limitstart', 0, 'int' ); + + $where = array(); + + if ($search) { + $where[] = 'LOWER(a.name) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + + $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', a.cid'; + + // get the total number of records + $query = 'SELECT a.*, count(b.bid) AS nbanners, u.name AS editor' + . ' FROM #__bannerclient AS a' + . ' LEFT JOIN #__banner AS b ON a.cid = b.cid' + . ' LEFT JOIN #__users AS u ON u.id = a.checked_out' + . $where + . ' GROUP BY a.cid' + . $orderby + ; + + $db->setQuery( $query ); + $db->query(); + $total = $db->getNumRows(); + + jimport('joomla.html.pagination'); + $pageNav = new JPagination( $total, $limitstart, $limit ); + + $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); + $rows = $db->loadObjectList(); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + require_once(JPATH_COMPONENT.DS.'views'.DS.'client.php'); + BannersViewClients::clients( $rows, $pageNav, $lists ); + } + + /** + * Edit a banner client record + */ + function edit() + { + // Initialize variables + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + $userId = $user->get ( 'id' ); + + if ($this->_task == 'edit') { + $cid = JRequest::getVar('cid', array(0), 'method', 'array'); + } else { + $cid = array( 0 ); + } + + $row =& JTable::getInstance('bannerclient', 'Table'); + $row->load( (int) $cid[0] ); + + // fail if checked out not by 'me' + if ($row->isCheckedOut( $userId )) { + $this->setRedirect( 'index.php?option=com_banners&c=client' ); + return JError::raiseWarning( JText::sprintf( 'WARNEDITEDBYPERSON', $row->name ) ); + } + + if ($row->cid) { + // do stuff for existing record + $row->checkout( $userId ); + } else { + // do stuff for new record + $row->published = 0; + $row->approved = 0; + } + + require_once(JPATH_COMPONENT.DS.'views'.DS.'client.php'); + BannersViewClients::client( $row ); + } + + function save() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $this->setRedirect( 'index.php?option=com_banners&c=client' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $table =& JTable::getInstance('bannerclient', 'Table'); + + if (!$table->bind( JRequest::get( 'post' ) )) { + return JError::raiseWarning( 500, $table->getError() ); + } + if (!$table->check()) { + return JError::raiseWarning( 500, $table->getError() ); + } + if (!$table->store()) { + return JError::raiseWarning( 500, $table->getError() ); + } + $table->checkin(); + + switch (JRequest::getCmd( 'task' )) + { + case 'apply': + $this->setRedirect( 'index.php?option=com_banners&c=client&task=edit&cid[]='. $table->cid ); + break; + } + + $this->setMessage( JText::_( 'Item Saved' ) ); + } + + function cancel() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $this->setRedirect( 'index.php?option=com_banners&c=client' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $table =& JTable::getInstance('bannerclient', 'Table'); + $table->cid = JRequest::getVar( 'cid', 0, 'post', 'int' ); + $table->checkin(); + } + + function remove() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $this->setRedirect( 'index.php?option=com_banners&c=client' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + $table =& JTable::getInstance('bannerclient', 'Table'); + $n = count( $cid ); + + for ($i = 0; $i < $n; $i++) + { + $query = 'SELECT COUNT( bid )' + . ' FROM #__banner' + . ' WHERE cid = '. (int) $cid[$i] + ; + $db->setQuery($query); + $count = $db->loadResult(); + if ($count === null) { + return JError::raiseWarning( 500, $db->getErrorMsg() ); + } + else if ($count > 0) { + return JError::raiseWarning( 500, JText::_( 'WARNCANNOTDELCLIENTBANNER' ) ); + } + else { + if (!$table->delete( (int) $cid[$i] )) { + return JError::raiseWarning( 500, $table->getError() ); + } + } + } + + $this->setMessage( JText::sprintf( 'Items removed', $n ) ); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_banners/controllers/index.html b/oss/joomla/trunk/administrator/components/com_banners/controllers/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_banners/controllers/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_banners/elements/bannerclient.php b/oss/joomla/trunk/administrator/components/com_banners/elements/bannerclient.php new file mode 100644 index 00000000..8662a2de --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_banners/elements/bannerclient.php @@ -0,0 +1,49 @@ +setQuery($query); + $options = $db->loadObjectList(); + array_unshift($options, JHTML::_('select.option', '0', '- '.JText::_('Select Client').' -', 'cid', 'name')); + + return JHTML::_('select.genericlist', $options, ''.$control_name.'['.$name.']', 'class="inputbox"', 'cid', 'name', $value, $control_name.$name ); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_banners/elements/index.html b/oss/joomla/trunk/administrator/components/com_banners/elements/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_banners/elements/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_banners/helpers/banner.php b/oss/joomla/trunk/administrator/components/com_banners/helpers/banner.php new file mode 100644 index 00000000..af5dfc5a --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_banners/helpers/banner.php @@ -0,0 +1,81 @@ +get( 'tag_prefix' ); + + $instance = array(); + + if (!is_array( $keywords )) + { + $keywords = explode( ',', $keywords ); + } + + foreach ($keywords as $keyword) + { + $keyword = trim( $keyword ); + $regex = '#^' . $prefix . '#'; + if (preg_match( $regex, $keyword )) + { + $instance[] = $keyword; + } + } + } + return $instance; + } + + /** + * Checks if a URL is an image + * + * @param string + * @return URL + */ + function isImage( $url ) + { + $result = preg_match( '#(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$#i', $url ); + return $result; + } + + /** + * Checks if a URL is a Flash file + * + * @param string + * @return URL + */ + function isFlash( $url ) + { + $result = preg_match( '#\.swf$#i', $url ); + return $result; + } +} +?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_banners/helpers/index.html b/oss/joomla/trunk/administrator/components/com_banners/helpers/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_banners/helpers/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_banners/index.html b/oss/joomla/trunk/administrator/components/com_banners/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_banners/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_banners/tables/banner.php b/oss/joomla/trunk/administrator/components/com_banners/tables/banner.php new file mode 100644 index 00000000..c9e90eec --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_banners/tables/banner.php @@ -0,0 +1,131 @@ +set( 'date', $now->toMySQL() ); + } + + function clicks() + { + $query = 'UPDATE #__banner' + . ' SET clicks = ( clicks + 1 )' + . ' WHERE bid = ' . (int) $this->bid + ; + $this->_db->setQuery( $query ); + $this->_db->query(); + } + + /** + * Overloaded check function + * + * @access public + * @return boolean + * @see JTable::check + * @since 1.5 + */ + function check() + { + // check for valid client id + if (is_null($this->cid) || $this->cid == 0) { + $this->setError(JText::_( 'BNR_CLIENT' )); + return false; + } + + // check for valid name + if(trim($this->name) == '') { + $this->setError(JText::_( 'BNR_NAME' )); + return false; + } + + if(empty($this->alias)) { + $this->alias = $this->name; + } + $this->alias = JFilterOutput::stringURLSafe($this->alias); + + /*if(trim($this->imageurl) == '') { + $this->setError(JText::_( 'BNR_IMAGE' )); + return false; + } + if(trim($this->clickurl) == '' && trim($this->custombannercode) == '') { + $this->setError(JText::_( 'BNR_URL' )); + return false; + }*/ + + return true; + } +} +?> diff --git a/oss/joomla/trunk/administrator/components/com_banners/tables/bannerclient.php b/oss/joomla/trunk/administrator/components/com_banners/tables/bannerclient.php new file mode 100644 index 00000000..3c28a11e --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_banners/tables/bannerclient.php @@ -0,0 +1,68 @@ +name == '')) { + $this->setError(JText::_( 'BNR_CLIENT_NAME' )); + return false; + } + + // check for valid client contact + if (trim($this->contact == '')) { + $this->setError(JText::_( 'BNR_CONTACT' )); + return false; + } + + // check for valid client email + jimport( 'joomla.mail.helper' ); + if (!JMailHelper::isEmailAddress( $this->email )) { + $this->setError(JText::_( 'BNR_VALID_EMAIL' )); + return false; + } + + return true; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_banners/tables/index.html b/oss/joomla/trunk/administrator/components/com_banners/tables/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_banners/tables/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_banners/views/banner.php b/oss/joomla/trunk/administrator/components/com_banners/views/banner.php new file mode 100644 index 00000000..04dcf050 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_banners/views/banner.php @@ -0,0 +1,473 @@ + +
+ + + + + +
+ : + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + id = $row->bid; + $link = JRoute::_( 'index.php?option=com_banners&task=edit&cid[]='. $row->id ); + + if( $row->imptotal <= 0 ) { + $row->imptotal = JText::_('unlimited'); + } + + if ( $row->impmade != 0 ) { + $percentClicks = 100 * $row->clicks/$row->impmade; + } else { + $percentClicks = 0; + } + + $row->published = $row->showBanner; + $published = JHTML::_('grid.published', $row, $i ); + $checked = JHTML::_('grid.checkedout', $row, $i ); + ?> + "> + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ getListFooter(); ?> +
+ getRowOffset($i); ?> + + + + + get ('id'), $row->checked_out ) ) { + echo $row->name; + } else { + ?> + + + name; ?> + + + + client_name;?> + + category_name;?> + + + + + class="text_area" style="text-align: center" /> + + sticky ? JText::_( 'Yes' ) : JText::_( 'No' );?> + + impmade.' '.JText::_('of').' '.$row->imptotal?> + + clicks;?> - + + + tags; ?> + + id; ?> +
+ + + + + + + + +
+ [ '. JText::_( 'New' ) .' ]' : JText::_( 'Banner' ) . ': [ '. JText::_( 'Edit' ) .' ]', 'generic.png' ); + JToolBarHelper::save( 'save' ); + JToolBarHelper::apply('apply'); + JToolBarHelper::cancel( 'cancel' ); + JToolBarHelper::help( 'screen.banners.edit' ); + } + + function banner( &$row, &$lists ) + { + BannersViewBanner::setBannerToolbar(); + JRequest::setVar( 'hidemainmenu', 1 ); + JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'custombannercode' ); + ?> + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + imptotal == 0) { + $unlimited = 'checked="checked"'; + $row->imptotal = ''; + } + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ : + + +
+ : + + +
+ + + +
+ + + +
+ + + +
+ + + +      + + /> +
+ + + +
+ : + + clicks;?> +      + +
+ + + +
+ + + +
+
+ + + +
+ + + +
+ + + +
+ : + + imageurl)) { + ?> + + + + imageurl)) { + ?> + + + + +
+ + + +
+
+
+
+ + + + + + + + +
+ +
+ + + + + + +
+ : + + + + +
+ + + + + + + + + + + + + + + + + + + id = $row->cid; + $link = JRoute::_( 'index.php?option=com_banners&c=client&task=edit&cid[]='. $row->id ); + + $checked = JHTML::_('grid.checkedout', $row, $i ); + ?> + "> + + + + + + + + + +
+ + + + + + + + + + + +
+ getListFooter(); ?> +
+ getRowOffset( $i ); ?> + + + + get ('id'), $row->checked_out ) ) { + echo $row->name; + } else { + ?> + + + name; ?> + + + + contact; ?> + + nbanners;?> + + cid; ?> +
+ + + + + + + + +
+ [ '. JText::_( 'New' ) .' ]' : JText::_( 'Banner Client' ) . ': [ '. JText::_( 'Edit' ) .' ]', 'generic.png' ); + JToolBarHelper::save( 'save' ); + JToolBarHelper::apply('apply'); + JToolBarHelper::cancel( 'cancel' ); + JToolBarHelper::help( 'screen.banners.client.edit' ); + } + + function client( &$row ) + { + BannersViewClients::setClientToolbar(); + JRequest::setVar( 'hidemainmenu', 1 ); + JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'extrainfo' ); + ?> + + +
+ +
+
+ + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+
+
+ +
+
+ + + + + + +
+ +
+
+
+
+ + + + + + + +
+ \ No newline at end of file