diff --git a/oss/joomla/trunk/administrator/components/com_content/admin.content.html.php b/oss/joomla/trunk/administrator/components/com_content/admin.content.html.php new file mode 100644 index 00000000..2a12497e --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_content/admin.content.html.php @@ -0,0 +1,925 @@ + +
+ + + + + + +
+ : + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + getNullDate(); + for ($i=0, $n=count( $rows ); $i < $n; $i++) + { + $row = &$rows[$i]; + + $link = 'index.php?option=com_content§ionid='. $redirect .'&task=edit&cid[]='. $row->id; + + $row->sect_link = JRoute::_( 'index.php?option=com_sections&task=edit&cid[]='. $row->sectionid ); + $row->cat_link = JRoute::_( 'index.php?option=com_categories&task=edit&cid[]='. $row->catid ); + + $publish_up =& JFactory::getDate($row->publish_up); + $publish_down =& JFactory::getDate($row->publish_down); + $publish_up->setOffset($config->getValue('config.offset')); + $publish_down->setOffset($config->getValue('config.offset')); + if ( $now->toUnix() <= $publish_up->toUnix() && $row->state == 1 ) { + $img = 'publish_y.png'; + $alt = JText::_( 'Published' ); + } else if ( ( $now->toUnix() <= $publish_down->toUnix() || $row->publish_down == $nullDate ) && $row->state == 1 ) { + $img = 'publish_g.png'; + $alt = JText::_( 'Published' ); + } else if ( $now->toUnix() > $publish_down->toUnix() && $row->state == 1 ) { + $img = 'publish_r.png'; + $alt = JText::_( 'Expired' ); + } else if ( $row->state == 0 ) { + $img = 'publish_x.png'; + $alt = JText::_( 'Unpublished' ); + } else if ( $row->state == -1 ) { + $img = 'disabled.png'; + $alt = JText::_( 'Archived' ); + } + $times = ''; + if (isset($row->publish_up)) { + if ($row->publish_up == $nullDate) { + $times .= JText::_( 'Start: Always' ); + } else { + $times .= JText::_( 'Start' ) .": ". $publish_up->toFormat(); + } + } + if (isset($row->publish_down)) { + if ($row->publish_down == $nullDate) { + $times .= "
". JText::_( 'Finish: No Expiry' ); + } else { + $times .= "
". JText::_( 'Finish' ) .": ". $publish_down->toFormat(); + } + } + + if ( $user->authorize( 'com_users', 'manage' ) ) { + if ( $row->created_by_alias ) { + $author = $row->created_by_alias; + } else { + $linkA = 'index.php?option=com_users&task=edit&cid[]='. $row->created_by; + $author = ''. $row->author .''; + } + } else { + if ( $row->created_by_alias ) { + $author = $row->created_by_alias; + } else { + $author = $row->author; + } + } + + $access = JHTML::_('grid.access', $row, $i, $row->state ); + $checked = JHTML::_('grid.checkedout', $row, $i ); + ?> + "> + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ getListFooter(); ?> +
+ getRowOffset( $i ); ?> + + + + get ('id'), $row->checked_out ) ) { + echo $row->title; + } else if ($row->state == -1) { + echo htmlspecialchars($row->title, ENT_QUOTES, 'UTF-8'); + echo ' [ '. JText::_( 'Archived' ) .' ]'; + } else { + ?> + + title, ENT_QUOTES); ?> + + + + <?php echo $alt; ?> + + + <?php echo ( $row->frontpage ) ? JText::_( 'Yes' ) : JText::_( 'No' );?> + + orderUpIcon( $i, ($row->catid == @$rows[$i-1]->catid), 'orderup', 'Move Up', $ordering); ?> + orderDownIcon( $i, $n, ($row->catid == @$rows[$i+1]->catid), 'orderdown', 'Move Down', $ordering ); ?> + + class="text_area" style="text-align: center" /> + + + + + section_name; ?> + + + name; ?> + + + + created, JText::_('DATE_FORMAT_LC4') ); ?> + + hits ?> + + id; ?> +
+ + + + + + + + + +
+ + +
+ + + + + + +
+ : + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + cat_link = JRoute::_( 'index.php?option=com_categories&task=edit&cid[]='. $row->catid ); + $row->sec_link = JRoute::_( 'index.php?option=com_sections&task=edit&cid[]='. $row->sectionid ); + + if ( $user->authorize( 'com_users', 'manage' ) ) { + if ( $row->created_by_alias ) { + $author = $row->created_by_alias; + } else { + $linkA = JRoute::_( 'index.php?option=com_users&task=edit&cid[]='. $row->created_by ); + $author = ''. $row->author .''; + } + } else { + if ( $row->created_by_alias ) { + $author = $row->created_by_alias; + } else { + $author = $row->author; + } + } + + ?> + "> + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ getListFooter(); ?> +
+ getRowOffset( $i ); ?> + + id ); ?> + + title; ?> + + id; ?> + + + sectname; ?> + + + name; ?> + + + + created, JText::_( 'DATE_FORMAT_LC4' ) ); ?> +
+
+ + + + + + + + + + +
+ $row is passed with the id + * property set to 0. + * @param JTableContent The category object + * @param string The html for the groups select list + */ + function editContent( &$row, $section, &$lists, &$sectioncategories, $option, &$form ) + { + JRequest::setVar( 'hidemainmenu', 1 ); + + jimport('joomla.html.pane'); + JFilterOutput::objectHTMLSafe( $row ); + + $db = &JFactory::getDBO(); + $editor = &JFactory::getEditor(); + // TODO: allowAllClose should default true in J!1.6, so remove the array when it does. + $pane = &JPane::getInstance('sliders', array('allowAllClose' => true)); + + JHTML::_('behavior.tooltip'); + ?> + + +
+ + + + + + +
+ + + + + +
+ display( 'text', $row->text , '100%', '550', '75', '20' ) ; + ?> +
+
+ startPane("content-pane"); + echo $pane->startPanel( $title, "detail-page" ); + echo $form->render('details'); + + $title = JText::_( 'Parameters - Advanced' ); + echo $pane->endPanel(); + echo $pane->startPanel( $title, "params-page" ); + echo $form->render('params', 'advanced'); + + $title = JText::_( 'Metadata Information' ); + echo $pane->endPanel(); + echo $pane->startPanel( $title, "metadata-page" ); + echo $form->render('meta', 'metadata'); + + echo $pane->endPanel(); + echo $pane->endPane(); + ?> +
+ + + + + + + + +
+ + + +
+ + + + + + +
+ : +
+ +

+
+ : +
+ "; + foreach ( $items as $item ) { + echo "
  • ". $item->title ."
  • "; + } + echo ""; + ?> +
    +

    + + + + + "; + } + ?> + +
    + + +
    + + + + + + +
    + : +
    + +

    +
    + : +
    + "; + foreach ( $items as $item ) { + echo "
  • ". $item->title ."
  • "; + } + echo ""; + ?> +
    +

    + + + + + "; + } + ?> + +
    + setLink(JURI::root()); + + JHTML::_('behavior.caption'); + + ?> + + + + + + + + + +
    + + + +
    + + + + + + + + + +
    + + + +
    + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + +
    + + + + + + + +
    + + + + + + + +
    + getNullDate(); + + // used to hide "Reset Hits" when hits = 0 + if ( !$row->hits ) { + $visibility = 'style="display: none; visibility: hidden;"'; + } else { + $visibility = ''; + } + + ?> + + id ) { + ?> + + + + + + + + + + + + + + + + + + + + + + + + + +
    + : + + id; ?> +
    + + + state > 0 ? JText::_( 'Published' ) : ($row->state < 0 ? JText::_( 'Archived' ) : JText::_( 'Draft Unpublished' ) );?> +
    + + + hits;?> + > + + +
    + + + version;?> +
    + + + created == $nullDate ) { + echo JText::_( 'New document' ); + } else { + echo JHTML::_('date', $row->created, JText::_('DATE_FORMAT_LC2') ); + } + ?> +
    + + + modified == $nullDate ) { + echo JText::_( 'Not modified' ); + } else { + echo JHTML::_('date', $row->modified, JText::_('DATE_FORMAT_LC2')); + } + ?> +
    + execute( $task ); + $controller->redirect(); + break; + + case 'add' : + case 'new' : + ContentController::editContent(false); + break; + + case 'edit' : + ContentController::editContent(true); + break; + + case 'go2menu' : + case 'go2menuitem' : + case 'resethits' : + case 'menulink' : + case 'apply' : + case 'save' : + ContentController::saveContent(); + break; + + case 'remove' : + ContentController::removeContent(); + break; + + case 'publish' : + ContentController::changeContent(1); + break; + + case 'unpublish' : + ContentController::changeContent(0); + break; + + case 'toggle_frontpage' : + ContentController::toggleFrontPage(); + break; + + case 'archive' : + ContentController::changeContent(-1); + break; + + case 'unarchive' : + ContentController::changeContent(0); + break; + + case 'cancel' : + ContentController::cancelContent(); + break; + + case 'orderup' : + ContentController::orderContent(-1); + break; + + case 'orderdown' : + ContentController::orderContent(1); + break; + + //case 'showarchive' : + // JContentController::viewArchive(); + // break; + + case 'movesect' : + ContentController::moveSection(); + break; + + case 'movesectsave' : + ContentController::moveSectionSave(); + break; + + case 'copy' : + ContentController::copyItem(); + break; + + case 'copysave' : + ContentController::copyItemSave(); + break; + + case 'accesspublic' : + ContentController::accessMenu(0); + break; + + case 'accessregistered' : + ContentController::accessMenu(1); + break; + + case 'accessspecial' : + ContentController::accessMenu(2); + break; + + case 'saveorder' : + ContentController::saveOrder(); + break; + + case 'preview' : + ContentController::previewContent(); + break; + + case 'ins_pagebreak' : + ContentController::insertPagebreak(); + break; + + default : + ContentController::viewContent(); + break; +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_content/config.xml b/oss/joomla/trunk/administrator/components/com_content/config.xml new file mode 100644 index 00000000..900926cf --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_content/config.xml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_content/content.xml b/oss/joomla/trunk/administrator/components/com_content/content.xml new file mode 100644 index 00000000..bdee0dd0 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_content/content.xml @@ -0,0 +1,14 @@ + + + Content Page + 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 + DESCCONTENT + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_content/controller.php b/oss/joomla/trunk/administrator/components/com_content/controller.php new file mode 100644 index 00000000..cc75668c --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_content/controller.php @@ -0,0 +1,1469 @@ +getModel( 'element' ); + $view = &$this->getView( 'element'); + $view->setModel( $model, true ); + $view->display(); + } + + /** + * Compiles a list of installed or defined modules + * @param database A database connector object + */ + function viewContent() + { + global $mainframe; + + // Initialize variables + $db =& JFactory::getDBO(); + $filter = null; + + // Get some variables from the request + $sectionid = JRequest::getVar( 'sectionid', -1, '', 'int' ); + $redirect = $sectionid; + $option = JRequest::getCmd( 'option' ); + $context = 'com_content.viewcontent'; + $filter_order = $mainframe->getUserStateFromRequest( $context.'filter_order', 'filter_order', '', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( $context.'filter_state', 'filter_state', '', 'word' ); + $catid = $mainframe->getUserStateFromRequest( $context.'catid', 'catid', 0, 'int' ); + $filter_authorid = $mainframe->getUserStateFromRequest( $context.'filter_authorid', 'filter_authorid', 0, 'int' ); + $filter_sectionid = $mainframe->getUserStateFromRequest( $context.'filter_sectionid', 'filter_sectionid', -1, 'int' ); + $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'); + + // In case limit has been changed, adjust limitstart accordingly + $limitstart = ( $limit != 0 ? (floor($limitstart / $limit) * $limit) : 0 ); + + //$where[] = "c.state >= 0"; + $where[] = 'c.state != -2'; + + if (!$filter_order) { + $filter_order = 'section_name'; + } + if ($filter_order == 'c.ordering') { + $order = ' ORDER BY section_name, cc.title, c.ordering '. $filter_order_Dir; + } else { + $order = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', section_name, cc.title, c.ordering'; + } + $all = 1; + + if ($filter_sectionid >= 0) { + $filter = ' WHERE cc.section = '. (int) $filter_sectionid; + } + $section->title = 'All Articles'; + $section->id = 0; + + /* + * Add the filter specific information to the where clause + */ + // Section filter + if ($filter_sectionid >= 0) { + $where[] = 'c.sectionid = ' . (int) $filter_sectionid; + } + // Category filter + if ($catid > 0) { + $where[] = 'c.catid = ' . (int) $catid; + } + // Author filter + if ($filter_authorid > 0) { + $where[] = 'c.created_by = ' . (int) $filter_authorid; + } + // Content state filter + if ($filter_state) { + if ($filter_state == 'P') { + $where[] = 'c.state = 1'; + } else { + if ($filter_state == 'U') { + $where[] = 'c.state = 0'; + } else if ($filter_state == 'A') { + $where[] = 'c.state = -1'; + } else { + $where[] = 'c.state != -2'; + } + } + } + // Keyword filter + if ($search) { + $where[] = '(LOWER( c.title ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ) . + ' OR c.id = ' . (int) $search . ')'; + } + + // Build the where clause of the content record query + $where = (count($where) ? ' WHERE '.implode(' AND ', $where) : ''); + + // Get the total number of records + $query = 'SELECT COUNT(*)' . + ' FROM #__content AS c' . + ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . + ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . + $where; + $db->setQuery($query); + $total = $db->loadResult(); + + + // Create the pagination object + jimport('joomla.html.pagination'); + $pagination = new JPagination($total, $limitstart, $limit); + + // Get the articles + $query = 'SELECT c.*, g.name AS groupname, cc.title AS name, u.name AS editor, f.content_id AS frontpage, s.title AS section_name, v.name AS author' . + ' FROM #__content AS c' . + ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . + ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . + ' LEFT JOIN #__groups AS g ON g.id = c.access' . + ' LEFT JOIN #__users AS u ON u.id = c.checked_out' . + ' LEFT JOIN #__users AS v ON v.id = c.created_by' . + ' LEFT JOIN #__content_frontpage AS f ON f.content_id = c.id' . + $where . + $order; + $db->setQuery($query, $pagination->limitstart, $pagination->limit); + $rows = $db->loadObjectList(); + + // If there is a database query error, throw a HTTP 500 and exit + if ($db->getErrorNum()) { + JError::raiseError( 500, $db->stderr() ); + return false; + } + + // get list of categories for dropdown filter + $query = 'SELECT cc.id AS value, cc.title AS text, section' . + ' FROM #__categories AS cc' . + ' INNER JOIN #__sections AS s ON s.id = cc.section ' . + $filter . + ' ORDER BY s.ordering, cc.ordering'; + $lists['catid'] = ContentHelper::filterCategory($query, $catid); + + // get list of sections for dropdown filter + $javascript = 'onchange="document.adminForm.submit();"'; + $lists['sectionid'] = JHTML::_('list.section', 'filter_sectionid', $filter_sectionid, $javascript); + + // get list of Authors for dropdown filter + $query = 'SELECT c.created_by, u.name' . + ' FROM #__content AS c' . + ' INNER JOIN #__sections AS s ON s.id = c.sectionid' . + ' LEFT JOIN #__users AS u ON u.id = c.created_by' . + ' WHERE c.state <> -1' . + ' AND c.state <> -2' . + ' GROUP BY u.name' . + ' ORDER BY u.name'; + $authors[] = JHTML::_('select.option', '0', '- '.JText::_('Select Author').' -', 'created_by', 'name'); + $db->setQuery($query); + $authors = array_merge($authors, $db->loadObjectList()); + $lists['authorid'] = JHTML::_('select.genericlist', $authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'created_by', 'name', $filter_authorid); + + // state filter + $lists['state'] = JHTML::_('grid.state', $filter_state, 'Published', 'Unpublished', 'Archived'); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search'] = $search; + + ContentView::showContent($rows, $lists, $pagination, $redirect); + } + + /** + * Shows a list of archived articles + * @param int The section id + */ + function viewArchive() + { + global $mainframe; + + // Initialize variables + $db =& JFactory::getDBO(); + + $sectionid = JRequest::getVar( 'sectionid', 0, '', 'int' ); + $option = JRequest::getCmd( 'option' ); + + $filter_order = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.filter_order", 'filter_order', 'sectname', 'cmd'); + $filter_order_Dir = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.filter_order_Dir", 'filter_order_Dir', '', 'word'); + $catid = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.catid", 'catid', 0, 'int'); + $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); + $limitstart = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.limitstart", 'limitstart', 0, 'int'); + $filter_authorid = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.filter_authorid", 'filter_authorid', 0, 'int'); + $filter_sectionid = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.filter_sectionid", 'filter_sectionid', 0, 'int'); + $search = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.search", 'search', '', 'string'); + $search = JString::strtolower($search); + $redirect = $sectionid; + + // A section id of zero means view all articles [all sections] + if ($sectionid == 0) + { + $where = array ('c.state = -1', 'c.catid = cc.id', 'cc.section = s.id', 's.scope = "content"'); + $filter = ' , #__sections AS s WHERE s.id = c.section'; + $all = 1; + } + else + { + //We are viewing a specific section + $where = array ('c.state = -1', 'c.catid = cc.id', 'cc.section = s.id', 's.scope = "content"', 'c.sectionid= '.(int) $sectionid); + $filter = ' WHERE section = '.$db->Quote($sectionid); + $all = NULL; + } + + // Section filter + if ($filter_sectionid > 0) + { + $where[] = 'c.sectionid = ' . (int) $filter_sectionid; + } + // Author filter + if ($filter_authorid > 0) + { + $where[] = 'c.created_by = ' . (int) $filter_authorid; + } + // Category filter + if ($catid > 0) + { + $where[] = 'c.catid = ' . (int) $catid; + } + // Keyword filter + if ($search) + { + $where[] = 'LOWER( c.title ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + + // TODO: Sanitise $filter_order + $filter_order_Dir = ($filter_order_Dir == 'ASC' ? 'ASC' : 'DESC'); + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', sectname, cc.name, c.ordering'; + $where = (count($where) ? ' WHERE '.implode(' AND ', $where) : ''); + + // get the total number of records + $query = 'SELECT COUNT(*)' . + ' FROM #__content AS c' . + ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . + ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . + $where; + $db->setQuery($query); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pagination = new JPagination($total, $limitstart, $limit); + + $query = 'SELECT c.*, g.name AS groupname, cc.name, v.name AS author, s.title AS sectname' . + ' FROM #__content AS c' . + ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . + ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . + ' LEFT JOIN #__groups AS g ON g.id = c.access' . + ' LEFT JOIN #__users AS v ON v.id = c.created_by' . + $where . + $orderby; + $db->setQuery($query, $pagination->limitstart, $pagination->limit); + $rows = $db->loadObjectList(); + + // If there is a database query error, throw a HTTP 500 and exit + if ($db->getErrorNum()) + { + JError::raiseError( 500, $db->stderr() ); + return false; + } + + // get list of categories for dropdown filter + $query = 'SELECT c.id AS value, c.title AS text' . + ' FROM #__categories AS c' . + $filter . + ' ORDER BY c.ordering'; + $lists['catid'] = ContentHelper::filterCategory($query, $catid); + + // get list of sections for dropdown filter + $javascript = 'onchange="document.adminForm.submit();"'; + $lists['sectionid'] = JAdminMenus::SelectSection('filter_sectionid', $filter_sectionid, $javascript); + + $section = & JTable::getInstance('section'); + $section->load($sectionid); + + // get list of Authors for dropdown filter + $query = 'SELECT c.created_by, u.name' . + ' FROM #__content AS c' . + ' INNER JOIN #__sections AS s ON s.id = c.sectionid' . + ' LEFT JOIN #__users AS u ON u.id = c.created_by' . + ' WHERE c.state = -1' . + ' GROUP BY u.name' . + ' ORDER BY u.name'; + $db->setQuery($query); + $authors[] = JHTML::_('select.option', '0', '- '.JText::_('Select Author').' -', 'created_by', 'name'); + $authors = array_merge($authors, $db->loadObjectList()); + $lists['authorid'] = JHTML::_('select.genericlist', $authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'created_by', 'name', $filter_authorid); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search'] = $search; + + ContentView::showArchive($rows, $section, $lists, $pagination, $option, $all, $redirect); + } + + /** + * Compiles information to add or edit the record + * + * @param database A database connector object + * @param integer The unique id of the record to edit (0 if new) + * @param integer The id of the content section + */ + function editContent($edit) + { + global $mainframe; + + // Initialize variables + $db = & JFactory::getDBO(); + $user = & JFactory::getUser(); + + $cid = JRequest::getVar( 'cid', array(0), '', 'array' ); + JArrayHelper::toInteger($cid, array(0)); + $id = JRequest::getVar( 'id', $cid[0], '', 'int' ); + $option = JRequest::getCmd( 'option' ); + $nullDate = $db->getNullDate(); + $contentSection = ''; + $sectionid = 0; + + // Create and load the content table row + $row = & JTable::getInstance('content'); + if($edit) + $row->load($id); + + if ($id) { + $sectionid = $row->sectionid; + if ($row->state < 0) { + $mainframe->redirect('index.php?option=com_content', JText::_('You cannot edit an archived item')); + } + } + + // A sectionid of zero means grab from all sections + if ($sectionid == 0) { + $where = ' WHERE section NOT LIKE "%com_%"'; + } else { + // Grab from the specific section + $where = ' WHERE section = '. $db->Quote( $sectionid ); + } + + /* + * If the item is checked out we cannot edit it... unless it was checked + * out by the current user. + */ + if ( JTable::isCheckedOut($user->get ('id'), $row->checked_out )) + { + $msg = JText::sprintf('DESCBEINGEDITTED', JText::_('The item'), $row->title); + $mainframe->redirect('index.php?option=com_content', $msg); + } + + if ($id) + { + $row->checkout($user->get('id')); + + if (trim($row->images)) { + $row->images = explode("\n", $row->images); + } else { + $row->images = array (); + } + + $query = 'SELECT name' . + ' FROM #__users'. + ' WHERE id = '. (int) $row->created_by; + $db->setQuery($query); + $row->creator = $db->loadResult(); + + // test to reduce unneeded query + if ($row->created_by == $row->modified_by) { + $row->modifier = $row->creator; + } else { + $query = 'SELECT name' . + ' FROM #__users' . + ' WHERE id = '. (int) $row->modified_by; + $db->setQuery($query); + $row->modifier = $db->loadResult(); + } + + $query = 'SELECT COUNT(content_id)' . + ' FROM #__content_frontpage' . + ' WHERE content_id = '. (int) $row->id; + $db->setQuery($query); + $row->frontpage = $db->loadResult(); + if (!$row->frontpage) { + $row->frontpage = 0; + } + } + else + { + if (!$sectionid && JRequest::getInt('filter_sectionid')) { + $sectionid =JRequest::getInt('filter_sectionid'); + } + + if (JRequest::getInt('catid')) + { + $row->catid = JRequest::getInt('catid'); + $category = & JTable::getInstance('category'); + $category->load($row->catid); + $sectionid = $category->section; + } else { + $row->catid = NULL; + } + $createdate =& JFactory::getDate(); + $row->sectionid = $sectionid; + $row->version = 0; + $row->state = 1; + $row->ordering = 0; + $row->images = array (); + $row->publish_up = $createdate->toUnix(); + $row->publish_down = JText::_('Never'); + $row->creator = ''; + $row->created = $createdate->toUnix(); + $row->modified = $nullDate; + $row->modifier = ''; + $row->frontpage = 0; + + } + + $javascript = "onchange=\"changeDynaList( 'catid', sectioncategories, document.adminForm.sectionid.options[document.adminForm.sectionid.selectedIndex].value, 0, 0);\""; + + $query = 'SELECT s.id, s.title' . + ' FROM #__sections AS s' . + ' ORDER BY s.ordering'; + $db->setQuery($query); + + $sections[] = JHTML::_('select.option', '-1', '- '.JText::_('Select Section').' -', 'id', 'title'); + $sections[] = JHTML::_('select.option', '0', JText::_('Uncategorized'), 'id', 'title'); + $sections = array_merge($sections, $db->loadObjectList()); + $lists['sectionid'] = JHTML::_('select.genericlist', $sections, 'sectionid', 'class="inputbox" size="1" '.$javascript, 'id', 'title', intval($row->sectionid)); + + foreach ($sections as $section) + { + $section_list[] = (int) $section->id; + // get the type name - which is a special category + if ($row->sectionid) { + if ($section->id == $row->sectionid) { + $contentSection = $section->title; + } + } else { + if ($section->id == $sectionid) { + $contentSection = $section->title; + } + } + } + + $sectioncategories = array (); + $sectioncategories[-1] = array (); + $sectioncategories[-1][] = JHTML::_('select.option', '-1', JText::_( 'Select Category' ), 'id', 'title'); + $section_list = implode('\', \'', $section_list); + + $query = 'SELECT id, title, section' . + ' FROM #__categories' . + ' WHERE section IN ( \''.$section_list.'\' )' . + ' ORDER BY ordering'; + $db->setQuery($query); + $cat_list = $db->loadObjectList(); + + // Uncategorized category mapped to uncategorized section + $uncat = new stdClass(); + $uncat->id = 0; + $uncat->title = JText::_('Uncategorized'); + $uncat->section = 0; + $cat_list[] = $uncat; + foreach ($sections as $section) + { + $sectioncategories[$section->id] = array (); + $rows2 = array (); + foreach ($cat_list as $cat) + { + if ($cat->section == $section->id) { + $rows2[] = $cat; + } + } + foreach ($rows2 as $row2) { + $sectioncategories[$section->id][] = JHTML::_('select.option', $row2->id, $row2->title, 'id', 'title'); + } + } + $sectioncategories['-1'][] = JHTML::_('select.option', '-1', JText::_( 'Select Category' ), 'id', 'title'); + $categories = array(); + foreach ($cat_list as $cat) { + if($cat->section == $row->sectionid) + $categories[] = $cat; + } + + $categories[] = JHTML::_('select.option', '-1', JText::_( 'Select Category' ), 'id', 'title'); + $lists['catid'] = JHTML::_('select.genericlist', $categories, 'catid', 'class="inputbox" size="1"', 'id', 'title', intval($row->catid)); + + // build the html select list for ordering + $query = 'SELECT ordering AS value, title AS text' . + ' FROM #__content' . + ' WHERE catid = ' . (int) $row->catid . + ' AND state >= 0' . + ' ORDER BY ordering'; + if($edit) + $lists['ordering'] = JHTML::_('list.specificordering', $row, $id, $query, 1); + else + $lists['ordering'] = JHTML::_('list.specificordering', $row, '', $query, 1); + + // build the html radio buttons for frontpage + $lists['frontpage'] = JHTML::_('select.booleanlist', 'frontpage', '', $row->frontpage); + + // build the html radio buttons for published + $lists['state'] = JHTML::_('select.booleanlist', 'state', '', $row->state); + + /* + * We need to unify the introtext and fulltext fields and have the + * fields separated by the {readmore} tag, so lets do that now. + */ + if (JString::strlen($row->fulltext) > 1) { + $row->text = $row->introtext . "
    " . $row->fulltext; + } else { + $row->text = $row->introtext; + } + + // Create the form + $form = new JParameter('', JPATH_COMPONENT.DS.'models'.DS.'article.xml'); + + // Details Group + $active = (intval($row->created_by) ? intval($row->created_by) : $user->get('id')); + $form->set('created_by', $active); + $form->set('access', $row->access); + $form->set('created_by_alias', $row->created_by_alias); + + $form->set('created', JHTML::_('date', $row->created, '%Y-%m-%d %H:%M:%S')); + $form->set('publish_up', JHTML::_('date', $row->publish_up, '%Y-%m-%d %H:%M:%S')); + if (JHTML::_('date', $row->publish_down, '%Y') <= 1969 || $row->publish_down == $db->getNullDate()) { + $form->set('publish_down', JText::_('Never')); + } else { + $form->set('publish_down', JHTML::_('date', $row->publish_down, '%Y-%m-%d %H:%M:%S')); + } + + // Advanced Group + $form->loadINI($row->attribs); + + // Metadata Group + $form->set('description', $row->metadesc); + $form->set('keywords', $row->metakey); + $form->loadINI($row->metadata); + + ContentView::editContent($row, $contentSection, $lists, $sectioncategories, $option, $form); + } + + /** + * Saves the article an edit form submit + * @param database A database connector object + */ + function saveContent() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db = & JFactory::getDBO(); + $user = & JFactory::getUser(); + $dispatcher = & JDispatcher::getInstance(); + JPluginHelper::importPlugin('content'); + + $details = JRequest::getVar( 'details', array(), 'post', 'array'); + $option = JRequest::getCmd( 'option' ); + $task = JRequest::getCmd( 'task' ); + $sectionid = JRequest::getVar( 'sectionid', 0, '', 'int' ); + $redirect = JRequest::getVar( 'redirect', $sectionid, 'post', 'int' ); + $menu = JRequest::getVar( 'menu', 'mainmenu', 'post', 'cmd' ); + $menuid = JRequest::getVar( 'menuid', 0, 'post', 'int' ); + $nullDate = $db->getNullDate(); + + $row = & JTable::getInstance('content'); + if (!$row->bind(JRequest::get('post'))) { + JError::raiseError( 500, $db->stderr() ); + return false; + } + $row->bind($details); + + // sanitise id field + $row->id = (int) $row->id; + + $isNew = true; + // Are we saving from an item edit? + if ($row->id) { + $isNew = false; + $datenow =& JFactory::getDate(); + $row->modified = $datenow->toMySQL(); + $row->modified_by = $user->get('id'); + } + + $row->created_by = $row->created_by ? $row->created_by : $user->get('id'); + + if ($row->created && strlen(trim( $row->created )) <= 10) { + $row->created .= ' 00:00:00'; + } + + $config =& JFactory::getConfig(); + $tzoffset = $config->getValue('config.offset'); + $date =& JFactory::getDate($row->created, $tzoffset); + $row->created = $date->toMySQL(); + + // Append time if not added to publish date + if (strlen(trim($row->publish_up)) <= 10) { + $row->publish_up .= ' 00:00:00'; + } + + $date =& JFactory::getDate($row->publish_up, $tzoffset); + $row->publish_up = $date->toMySQL(); + + // Handle never unpublish date + if (trim($row->publish_down) == JText::_('Never') || trim( $row->publish_down ) == '') + { + $row->publish_down = $nullDate; + } + else + { + if (strlen(trim( $row->publish_down )) <= 10) { + $row->publish_down .= ' 00:00:00'; + } + $date =& JFactory::getDate($row->publish_down, $tzoffset); + $row->publish_down = $date->toMySQL(); + } + + // Get a state and parameter variables from the request + $row->state = JRequest::getVar( 'state', 0, '', 'int' ); + $params = JRequest::getVar( 'params', null, 'post', 'array' ); + + // Build parameter INI string + if (is_array($params)) + { + $txt = array (); + foreach ($params as $k => $v) { + $txt[] = "$k=$v"; + } + $row->attribs = implode("\n", $txt); + } + + // Get metadata string + $metadata = JRequest::getVar( 'meta', null, 'post', 'array'); + if (is_array($metadata)) + { + $txt = array(); + foreach ($metadata as $k => $v) { + if ($k == 'description') { + $row->metadesc = $v; + } elseif ($k == 'keywords') { + $row->metakey = $v; + } else { + $txt[] = "$k=$v"; + } + } + $row->metadata = implode("\n", $txt); + } + + // Prepare the content for saving to the database + ContentHelper::saveContentPrep( $row ); + + // Make sure the data is valid + if (!$row->check()) { + JError::raiseError( 500, $db->stderr() ); + return false; + } + + // Increment the content version number + $row->version++; + + $result = $dispatcher->trigger('onBeforeContentSave', array(&$row, $isNew)); + if(in_array(false, $result, true)) { + JError::raiseError(500, $row->getError()); + return false; + } + + // Store the content to the database + if (!$row->store()) { + JError::raiseError( 500, $db->stderr() ); + return false; + } + + // Check the article and update item order + $row->checkin(); + $row->reorder('catid = '.(int) $row->catid.' AND state >= 0'); + + /* + * We need to update frontpage status for the article. + * + * First we include the frontpage table and instantiate an instance of it. + */ + require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_frontpage'.DS.'tables'.DS.'frontpage.php'); + $fp = new TableFrontPage($db); + + // Is the article viewable on the frontpage? + if (JRequest::getVar( 'frontpage', 0, '', 'int' )) + { + // Is the item already viewable on the frontpage? + if (!$fp->load($row->id)) + { + // Insert the new entry + $query = 'INSERT INTO #__content_frontpage' . + ' VALUES ( '. (int) $row->id .', 1 )'; + $db->setQuery($query); + if (!$db->query()) + { + JError::raiseError( 500, $db->stderr() ); + return false; + } + $fp->ordering = 1; + } + } + else + { + // Delete the item from frontpage if it exists + if (!$fp->delete($row->id)) { + $msg .= $fp->stderr(); + } + $fp->ordering = 0; + } + $fp->reorder(); + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + $dispatcher->trigger('onAfterContentSave', array(&$row, $isNew)); + + switch ($task) + { + case 'go2menu' : + $mainframe->redirect('index.php?option=com_menus&menutype='.$menu); + break; + + case 'go2menuitem' : + $mainframe->redirect('index.php?option=com_menus&menutype='.$menu.'&task=edit&id='.$menuid); + break; + + case 'menulink' : + ContentHelper::menuLink($redirect, $row->id); + break; + + case 'resethits' : + ContentHelper::resetHits($redirect, $row->id); + break; + + case 'apply' : + $msg = JText::sprintf('SUCCESSFULLY SAVED CHANGES TO ARTICLE', $row->title); + $mainframe->redirect('index.php?option=com_content§ionid='.$redirect.'&task=edit&cid[]='.$row->id, $msg); + break; + + case 'save' : + default : + $msg = JText::sprintf('Successfully Saved Article', $row->title); + $mainframe->redirect('index.php?option=com_content§ionid='.$redirect, $msg); + break; + } + } + + /** + * Changes the state of one or more content pages + * + * @param string The name of the category section + * @param integer A unique category id (passed from an edit form) + * @param array An array of unique category id numbers + * @param integer 0 if unpublishing, 1 if publishing + * @param string The name of the current user + */ + function changeContent( $state = 0 ) + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db = & JFactory::getDBO(); + $user = & JFactory::getUser(); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + $option = JRequest::getCmd( 'option' ); + $task = JRequest::getCmd( 'task' ); + $rtask = JRequest::getCmd( 'returntask', '', 'post' ); + if ($rtask) { + $rtask = '&task='.$rtask; + } + + if (count($cid) < 1) { + $redirect = JRequest::getVar( 'redirect', '', 'post', 'int' ); + $action = ($state == 1) ? 'publish' : ($state == -1 ? 'archive' : 'unpublish'); + $msg = JText::_('Select an item to') . ' ' . JText::_($action); + $mainframe->redirect('index.php?option='.$option.$rtask.'§ionid='.$redirect, $msg, 'error'); + } + + // Get some variables for the query + $uid = $user->get('id'); + $total = count($cid); + $cids = implode(',', $cid); + + $query = 'UPDATE #__content' . + ' SET state = '. (int) $state . + ' WHERE id IN ( '. $cids .' ) AND ( checked_out = 0 OR (checked_out = '. (int) $uid .' ) )'; + $db->setQuery($query); + if (!$db->query()) { + JError::raiseError( 500, $db->getErrorMsg() ); + return false; + } + + if (count($cid) == 1) { + $row = & JTable::getInstance('content'); + $row->checkin($cid[0]); + } + + switch ($state) + { + case -1 : + $msg = JText::sprintf('Item(s) successfully Archived', $total); + break; + + case 1 : + $msg = JText::sprintf('Item(s) successfully Published', $total); + break; + + case 0 : + default : + if ($task == 'unarchive') { + $msg = JText::sprintf('Item(s) successfully Unarchived', $total); + } else { + $msg = JText::sprintf('Item(s) successfully Unpublished', $total); + } + break; + } + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + // Get some return/redirect information from the request + $redirect = JRequest::getVar( 'redirect', $row->sectionid, 'post', 'int' ); + + $mainframe->redirect('index.php?option='.$option.$rtask.'§ionid='.$redirect, $msg); + } + + /** + * Changes the frontpage state of one or more articles + * + */ + function toggleFrontPage() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db =& JFactory::getDBO(); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + $option = JRequest::getCmd( 'option' ); + $msg = null; + + JArrayHelper::toInteger($cid); + + if (count($cid) < 1) { + $msg = JText::_('Select an item to toggle'); + $mainframe->redirect('index.php?option='.$option, $msg, 'error'); + } + + /* + * We need to update frontpage status for the articles. + * + * First we include the frontpage table and instantiate an instance of + * it. + */ + require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_frontpage'.DS.'tables'.DS.'frontpage.php'); + $fp = new TableFrontPage($db); + + foreach ($cid as $id) + { + // toggles go to first place + if ($fp->load($id)) { + if (!$fp->delete($id)) { + $msg .= $fp->stderr(); + } + $fp->ordering = 0; + } else { + // new entry + $query = 'INSERT INTO #__content_frontpage' . + ' VALUES ( '. (int) $id .', 0 )'; + $db->setQuery($query); + if (!$db->query()) { + JError::raiseError( 500, $db->stderr() ); + return false; + } + $fp->ordering = 0; + } + $fp->reorder(); + } + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + $mainframe->redirect('index.php?option='.$option, $msg); + } + + function removeContent() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db = & JFactory::getDBO(); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + $option = JRequest::getCmd( 'option' ); + $return = JRequest::getCmd( 'returntask', '', 'post' ); + $nullDate = $db->getNullDate(); + + JArrayHelper::toInteger($cid); + + if (count($cid) < 1) { + $msg = JText::_('Select an item to delete'); + $mainframe->redirect('index.php?option='.$option, $msg, 'error'); + } + + // Removed content gets put in the trash [state = -2] and ordering is always set to 0 + $state = '-2'; + $ordering = '0'; + + // Get the list of content id numbers to send to trash. + $cids = implode(',', $cid); + + // Update articles in the database + $query = 'UPDATE #__content' . + ' SET state = '.(int) $state . + ', ordering = '.(int) $ordering . + ', checked_out = 0, checked_out_time = '.$db->Quote($nullDate). + ' WHERE id IN ( '. $cids. ' )'; + $db->setQuery($query); + if (!$db->query()) + { + JError::raiseError( 500, $db->getErrorMsg() ); + return false; + } + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + $msg = JText::sprintf('Item(s) sent to the Trash', count($cid)); + $mainframe->redirect('index.php?option='.$option.'&task='.$return, $msg); + } + + /** + * Cancels an edit operation + */ + function cancelContent() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db = & JFactory::getDBO(); + + // Check the article in if checked out + $row = & JTable::getInstance('content'); + $row->bind(JRequest::get('post')); + $row->checkin(); + + $mainframe->redirect('index.php?option=com_content'); + } + + /** + * Moves the order of a record + * @param integer The increment to reorder by + */ + function orderContent($direction) + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db = & JFactory::getDBO(); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + + if (isset( $cid[0] )) + { + $row = & JTable::getInstance('content'); + $row->load( (int) $cid[0] ); + $row->move($direction, 'catid = ' . (int) $row->catid . ' AND state >= 0' ); + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + } + + $mainframe->redirect('index.php?option=com_content'); + } + + /** + * Form for moving item(s) to a different section and category + */ + function moveSection() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db =& JFactory::getDBO(); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + $sectionid = JRequest::getVar( 'sectionid', 0, '', 'int' ); + + JArrayHelper::toInteger($cid); + + if (count($cid) < 1) { + $msg = JText::_('Select an item to move'); + $mainframe->redirect('index.php?option=com_content', $msg, 'error'); + } + + //seperate contentids + $cids = implode(',', $cid); + // Articles query + $query = 'SELECT a.title' . + ' FROM #__content AS a' . + ' WHERE ( a.id IN ( '. $cids .' ) )' . + ' ORDER BY a.title'; + $db->setQuery($query); + $items = $db->loadObjectList(); + + $query = 'SELECT CONCAT_WS( ", ", s.id, c.id ) AS `value`, CONCAT_WS( " / ", s.title, c.title ) AS `text`' . + ' FROM #__sections AS s' . + ' INNER JOIN #__categories AS c ON c.section = s.id' . + ' WHERE s.scope = "content"' . + ' ORDER BY s.title, c.title'; + $db->setQuery($query); + $rows[] = JHTML::_('select.option', "0, 0", JText::_('UNCATEGORIZED')); + $rows = array_merge($rows, $db->loadObjectList()); + // build the html select list + $sectCatList = JHTML::_('select.genericlist', $rows, 'sectcat', 'class="inputbox" size="8"', 'value', 'text', null); + + ContentView::moveSection($cid, $sectCatList, 'com_content', $sectionid, $items); + } + + /** + * Save the changes to move item(s) to a different section and category + */ + function moveSectionSave() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db = & JFactory::getDBO(); + $user = & JFactory::getUser(); + + $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + $sectionid = JRequest::getVar( 'sectionid', 0, '', 'int' ); + $option = JRequest::getCmd( 'option' ); + + JArrayHelper::toInteger($cid, array(0)); + + $sectcat = JRequest::getVar( 'sectcat', '', 'post', 'string' ); + $sectcat = explode(',', $sectcat); + $newsect = (int) @$sectcat[0]; + $newcat = (int) @$sectcat[1]; + + if ((!$newsect || !$newcat) && ($sectcat !== array('0', ' 0'))) { + $mainframe->redirect("index.php?option=com_content§ionid=$sectionid", JText::_('An error has occurred')); + } + + // find section name + $query = 'SELECT a.title' . + ' FROM #__sections AS a' . + ' WHERE a.id = '. (int) $newsect; + $db->setQuery($query); + $section = $db->loadResult(); + + // find category name + $query = 'SELECT a.title' . + ' FROM #__categories AS a' . + ' WHERE a.id = '. (int) $newcat; + $db->setQuery($query); + $category = $db->loadResult(); + + $total = count($cid); + $cids = implode(',', $cid); + $uid = $user->get('id'); + + $row = & JTable::getInstance('content'); + // update old orders - put existing items in last place + foreach ($cid as $id) + { + $row->load(intval($id)); + $row->ordering = 0; + $row->store(); + $row->reorder('catid = '.(int) $row->catid.' AND state >= 0'); + } + + $query = 'UPDATE #__content SET sectionid = '.(int) $newsect.', catid = '.(int) $newcat. + ' WHERE id IN ( '.$cids.' )' . + ' AND ( checked_out = 0 OR ( checked_out = '.(int) $uid.' ) )'; + $db->setQuery($query); + if (!$db->query()) + { + JError::raiseError( 500, $db->getErrorMsg() ); + return false; + } + + // update new orders - put items in last place + foreach ($cid as $id) + { + $row->load(intval($id)); + $row->ordering = 0; + $row->store(); + $row->reorder('catid = '.(int) $row->catid.' AND state >= 0'); + } + + if ($section && $category) { + $msg = JText::sprintf('Item(s) successfully moved to Section', $total, $section, $category); + } else { + $msg = JText::sprintf('ITEM(S) SUCCESSFULLY MOVED TO UNCATEGORIZED', $total); + } + + $mainframe->redirect('index.php?option='.$option.'§ionid='.$sectionid, $msg); + } + + /** + * Form for copying item(s) + **/ + function copyItem() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db = & JFactory::getDBO(); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + $sectionid = JRequest::getVar( 'sectionid', 0, '', 'int' ); + $option = JRequest::getCmd( 'option' ); + + JArrayHelper::toInteger($cid); + + if (count($cid) < 1) { + $msg = JText::_('Select an item to move'); + $mainframe->redirect('index.php?option='.$option, $msg, 'error'); + } + + //seperate contentids + $cids = implode(',', $cid); + ## Articles query + $query = 'SELECT a.title' . + ' FROM #__content AS a' . + ' WHERE ( a.id IN ( '. $cids .' ) )' . + ' ORDER BY a.title'; + $db->setQuery($query); + $items = $db->loadObjectList(); + + ## Section & Category query + $query = 'SELECT CONCAT_WS(",",s.id,c.id) AS `value`, CONCAT_WS(" / ", s.title, c.title) AS `text`' . + ' FROM #__sections AS s' . + ' INNER JOIN #__categories AS c ON c.section = s.id' . + ' WHERE s.scope = "content"' . + ' ORDER BY s.title, c.title'; + $db->setQuery($query); + + // Add a row for uncategorized content + $uncat = JHTML::_('select.option', '0,0', JText::_('UNCATEGORIZED')); + $rows = $db->loadObjectList(); + array_unshift($rows, $uncat); + // build the html select list + $sectCatList = JHTML::_('select.genericlist', $rows, 'sectcat', 'class="inputbox" size="10"', 'value', 'text', NULL); + + ContentView::copySection($option, $cid, $sectCatList, $sectionid, $items); + } + + /** + * saves Copies of items + **/ + function copyItemSave() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db = & JFactory::getDBO(); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + $sectionid = JRequest::getVar( 'sectionid', 0, '', 'int' ); + $option = JRequest::getCmd( 'option' ); + + JArrayHelper::toInteger($cid); + + $item = null; + $sectcat = JRequest::getVar( 'sectcat', '-1,-1', 'post', 'string' ); + //seperate sections and categories from selection + $sectcat = explode(',', $sectcat); + $newsect = (int) @$sectcat[0]; + $newcat = (int) @$sectcat[1]; + + if (($newsect == -1) || ($newcat == -1)) { + $mainframe->redirect('index.php?option=com_content§ionid='.$sectionid, JText::_('An error has occurred')); + } + + // find section name + $query = 'SELECT a.title' . + ' FROM #__sections AS a' . + ' WHERE a.id = '. (int) $newsect; + $db->setQuery($query); + $section = $db->loadResult(); + + // find category name + $query = 'SELECT a.title' . + ' FROM #__categories AS a' . + ' WHERE a.id = '. (int) $newcat; + $db->setQuery($query); + $category = $db->loadResult(); + + if (($newsect == 0) && ($newcat == 0)) + { + $section = JText::_('UNCATEGORIZED'); + $category = JText::_('UNCATEGORIZED'); + } + + $total = count($cid); + for ($i = 0; $i < $total; $i ++) + { + $row = & JTable::getInstance('content'); + + // main query + $query = 'SELECT a.*' . + ' FROM #__content AS a' . + ' WHERE a.id = '.(int) $cid[$i]; + $db->setQuery($query, 0, 1); + $item = $db->loadObject(); + + // values loaded into array set for store + $row->id = NULL; + $row->sectionid = $newsect; + $row->catid = $newcat; + $row->hits = '0'; + $row->ordering = '0'; + $row->title = $item->title; + $row->alias = $item->alias; + $row->title_alias = $item->title_alias; + $row->introtext = $item->introtext; + $row->fulltext = $item->fulltext; + $row->state = $item->state; + $row->mask = $item->mask; + $row->created = $item->created; + $row->created_by = $item->created_by; + $row->created_by_alias = $item->created_by_alias; + $row->modified = $item->modified; + $row->modified_by = $item->modified_by; + $row->checked_out = $item->checked_out; + $row->checked_out_time = $item->checked_out_time; + $row->publish_up = $item->publish_up; + $row->publish_down = $item->publish_down; + $row->images = $item->images; + $row->attribs = $item->attribs; + $row->version = $item->parentid; + $row->parentid = $item->parentid; + $row->metakey = $item->metakey; + $row->metadesc = $item->metadesc; + $row->access = $item->access; + $row->metadata = $item->metadata; + + if (!$row->check()) { + JError::raiseError( 500, $row->getError() ); + return false; + } + + if (!$row->store()) { + JError::raiseError( 500, $row->getError() ); + return false; + } + $row->reorder('catid='.(int) $row->catid.' AND state >= 0'); + } + + $msg = JText::sprintf('Item(s) successfully copied to Section', $total, $section, $category); + $mainframe->redirect('index.php?option='.$option.'§ionid='.$sectionid, $msg); + } + + /** + * @param integer The id of the article + * @param integer The new access level + * @param string The URL option + */ + function accessMenu($access) + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db = & JFactory::getDBO(); + + $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + $option = JRequest::getCmd( 'option' ); + $cid = $cid[0]; + + // Create and load the article table object + $row = & JTable::getInstance('content'); + $row->load($cid); + $row->access = $access; + + // Ensure the article object is valid + if (!$row->check()) { + JError::raiseError( 500, $row->getError() ); + return false; + } + + // Store the changes + if (!$row->store()) { + JError::raiseError( 500, $row->getError() ); + return false; + } + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + $mainframe->redirect('index.php?option='.$option); + } + + function saveOrder() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db = & JFactory::getDBO(); + + $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + $order = JRequest::getVar( 'order', array (0), 'post', 'array' ); + $redirect = JRequest::getVar( 'redirect', 0, 'post', 'int' ); + $rettask = JRequest::getVar( 'returntask', '', 'post', 'cmd' ); + $total = count($cid); + $conditions = array (); + + JArrayHelper::toInteger($cid, array(0)); + JArrayHelper::toInteger($order, array(0)); + + // Instantiate an article table object + $row = & JTable::getInstance('content'); + + // Update the ordering for items in the cid array + for ($i = 0; $i < $total; $i ++) + { + $row->load( (int) $cid[$i] ); + if ($row->ordering != $order[$i]) { + $row->ordering = $order[$i]; + if (!$row->store()) { + JError::raiseError( 500, $db->getErrorMsg() ); + return false; + } + // remember to updateOrder this group + $condition = 'catid = '.(int) $row->catid.' AND state >= 0'; + $found = false; + foreach ($conditions as $cond) + if ($cond[1] == $condition) { + $found = true; + break; + } + if (!$found) + $conditions[] = array ($row->id, $condition); + } + } + + // execute updateOrder for each group + foreach ($conditions as $cond) + { + $row->load($cond[0]); + $row->reorder($cond[1]); + } + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + $msg = JText::_('New ordering saved'); + switch ($rettask) + { + case 'showarchive' : + $mainframe->redirect('index.php?option=com_content&task=showarchive§ionid='.$redirect, $msg); + break; + + default : + $mainframe->redirect('index.php?option=com_content§ionid='.$redirect, $msg); + break; + } + } + + function previewContent() + { + // Initialize variables + $document =& JFactory::getDocument(); + $db =& JFactory::getDBO(); + $id = JRequest::getVar( 'id', 0, '', 'int' ); + $option = JRequest::getCmd( 'option' ); + + // Get the current default template + $query = 'SELECT template' . + ' FROM #__templates_menu' . + ' WHERE client_id = 0' . + ' AND menuid = 0'; + $db->setQuery($query); + $template = $db->loadResult(); + + // check if template editor stylesheet exists + if (!file_exists( JPATH_SITE.DS.'templates'.DS.$template.DS.'css'.DS.'editor.css' )) { + $template = 'system'; + } + + // Set page title + $document->setTitle(JText::_('Article Preview')); + $document->addStyleSheet(JURI::root() . 'templates/'.$template.'/css/editor.css'); + $document->setBase(JUri::root()); + + // Render article preview + ContentView::previewContent(); + } + + function insertPagebreak() + { + $document =& JFactory::getDocument(); + $document->setTitle(JText::_('PGB ARTICLE PAGEBRK')); + ContentView::insertPagebreak(); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_content/elements/article.php b/oss/joomla/trunk/administrator/components/com_content/elements/article.php new file mode 100644 index 00000000..0e8853b4 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_content/elements/article.php @@ -0,0 +1,60 @@ +getTemplate(); + $fieldName = $control_name.'['.$name.']'; + $article =& JTable::getInstance('content'); + if ($value) { + $article->load($value); + } else { + $article->title = JText::_('Select an Article'); + } + + $js = " + function jSelectArticle(id, title, object) { + document.getElementById(object + '_id').value = id; + document.getElementById(object + '_name').value = title; + document.getElementById('sbox-window').close(); + }"; + $doc->addScriptDeclaration($js); + + $link = 'index.php?option=com_content&task=element&tmpl=component&object='.$name; + + JHTML::_('behavior.modal', 'a.modal'); + $html = "\n".'
    '; +// $html .= "\n   "; + $html .= '
    '.JText::_('Select').'
    '."\n"; + $html .= "\n".''; + + return $html; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_content/elements/author.php b/oss/joomla/trunk/administrator/components/com_content/elements/author.php new file mode 100644 index 00000000..61fd0f34 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_content/elements/author.php @@ -0,0 +1,38 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_content/helper.php b/oss/joomla/trunk/administrator/components/com_content/helper.php new file mode 100644 index 00000000..4a4092d6 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_content/helper.php @@ -0,0 +1,122 @@ +', '
    ', $text ); + + // Search for the {readmore} tag and split the text up accordingly. + $pattern = '##i'; + $tagPos = preg_match($pattern, $text); + + if ( $tagPos == 0 ) + { + $row->introtext = $text; + } else + { + list($row->introtext, $row->fulltext) = preg_split($pattern, $text, 2); + } + + // Filter settings + jimport( 'joomla.application.component.helper' ); + $config = JComponentHelper::getParams( 'com_content' ); + $user = &JFactory::getUser(); + $gid = $user->get( 'gid' ); + + $filterGroups = $config->get( 'filter_groups' ); + + // convert to array if one group selected + if ( (!is_array($filterGroups) && (int) $filterGroups > 0) ) { + $filterGroups = array($filterGroups); + } + + if (is_array($filterGroups) && in_array( $gid, $filterGroups )) + { + $filterType = $config->get( 'filter_type' ); + $filterTags = preg_split( '#[,\s]+#', trim( $config->get( 'filter_tags' ) ) ); + $filterAttrs = preg_split( '#[,\s]+#', trim( $config->get( 'filter_attritbutes' ) ) ); + switch ($filterType) + { + case 'NH': + $filter = new JFilterInput(); + break; + case 'WL': + $filter = new JFilterInput( $filterTags, $filterAttrs, 0, 0, 0); // turn off xss auto clean + break; + case 'BL': + default: + $filter = new JFilterInput( $filterTags, $filterAttrs, 1, 1 ); + break; + } + $row->introtext = $filter->clean( $row->introtext ); + $row->fulltext = $filter->clean( $row->fulltext ); + } elseif(empty($filterGroups) && $gid != '25') { // no default filtering for super admin (gid=25) + $filter = new JFilterInput( array(), array(), 1, 1 ); + $row->introtext = $filter->clean( $row->introtext ); + $row->fulltext = $filter->clean( $row->fulltext ); + } + return true; + } + + /** + * Function to reset Hit count of an article + * + */ + function resetHits($redirect, $id) + { + global $mainframe; + + // Initialize variables + $db = & JFactory::getDBO(); + + // Instantiate and load an article table + $row = & JTable::getInstance('content'); + $row->Load($id); + $row->hits = 0; + $row->store(); + $row->checkin(); + + $msg = JText::_('Successfully Reset Hit count'); + $mainframe->redirect('index.php?option=com_content§ionid='.$redirect.'&task=edit&id='.$id, $msg); + } + + function filterCategory($query, $active = NULL) + { + // Initialize variables + $db = & JFactory::getDBO(); + + $categories[] = JHTML::_('select.option', '0', '- '.JText::_('Select Category').' -'); + $db->setQuery($query); + $categories = array_merge($categories, $db->loadObjectList()); + + $category = JHTML::_('select.genericlist', $categories, 'catid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $active); + + return $category; + } + +} diff --git a/oss/joomla/trunk/administrator/components/com_content/helper/content.php b/oss/joomla/trunk/administrator/components/com_content/helper/content.php new file mode 100644 index 00000000..4ad556a9 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_content/helper/content.php @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + +
    + <?php echo JText::_( 'Pending' ); ?> + + | + + <?php echo JText::_( 'Visible' ); ?> + + | + + <?php echo JText::_( 'Finished' ); ?> + + | + + <?php echo JText::_( 'Finished' ); ?> + + | + + <?php echo JText::_( 'Archived' ); ?> + + +
    + +
    + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_content/index.html b/oss/joomla/trunk/administrator/components/com_content/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_content/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_content/models/article.xml b/oss/joomla/trunk/administrator/components/com_content/models/article.xml new file mode 100644 index 00000000..d3612a3e --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_content/models/article.xml @@ -0,0 +1,97 @@ + +
    + Article Edit Form + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    diff --git a/oss/joomla/trunk/administrator/components/com_content/models/element.php b/oss/joomla/trunk/administrator/components/com_content/models/element.php new file mode 100644 index 00000000..73acffcb --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_content/models/element.php @@ -0,0 +1,156 @@ +_list)) { + return $this->_list; + } + + // Initialize variables + $db =& $this->getDBO(); + $filter = null; + + // Get some variables from the request + $sectionid = JRequest::getVar( 'sectionid', -1, '', 'int' ); + $redirect = $sectionid; + $option = JRequest::getCmd( 'option' ); + $filter_order = $mainframe->getUserStateFromRequest('articleelement.filter_order', 'filter_order', '', 'cmd'); + $filter_order_Dir = $mainframe->getUserStateFromRequest('articleelement.filter_order_Dir', 'filter_order_Dir', '', 'word'); + $catid = $mainframe->getUserStateFromRequest('articleelement.catid', 'catid', 0, 'int'); + $filter_authorid = $mainframe->getUserStateFromRequest('articleelement.filter_authorid', 'filter_authorid', 0, 'int'); + $filter_sectionid = $mainframe->getUserStateFromRequest('articleelement.filter_sectionid', 'filter_sectionid', -1, 'int'); + $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); + $limitstart = $mainframe->getUserStateFromRequest('articleelement.limitstart', 'limitstart', 0, 'int'); + $search = $mainframe->getUserStateFromRequest('articleelement.search', 'search', '', 'string'); + $search = JString::strtolower($search); + + //$where[] = "c.state >= 0"; + $where[] = "c.state != -2"; + + if (!$filter_order) { + $filter_order = 'section_name'; + } + $order = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', section_name, cc.name, c.ordering'; + $all = 1; + + if ($filter_sectionid >= 0) { + $filter = ' WHERE cc.section = '.$db->Quote($filter_sectionid); + } + $section->title = 'All Articles'; + $section->id = 0; + + /* + * Add the filter specific information to the where clause + */ + // Section filter + if ($filter_sectionid >= 0) { + $where[] = 'c.sectionid = '.(int) $filter_sectionid; + } + // Category filter + if ($catid > 0) { + $where[] = 'c.catid = '.(int) $catid; + } + // Author filter + if ($filter_authorid > 0) { + $where[] = 'c.created_by = '.(int) $filter_authorid; + } + + // Only published articles + $where[] = 'c.state = 1'; + + // Keyword filter + if ($search) { + $where[] = 'LOWER( c.title ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + + // Build the where clause of the content record query + $where = (count($where) ? ' WHERE '.implode(' AND ', $where) : ''); + + // Get the total number of records + $query = 'SELECT COUNT(*)' . + ' FROM #__content AS c' . + ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . + ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . + $where; + $db->setQuery($query); + $total = $db->loadResult(); + + // Create the pagination object + jimport('joomla.html.pagination'); + $this->_page = new JPagination($total, $limitstart, $limit); + + // Get the articles + $query = 'SELECT c.*, g.name AS groupname, cc.title as cctitle, u.name AS editor, f.content_id AS frontpage, s.title AS section_name, v.name AS author' . + ' FROM #__content AS c' . + ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . + ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . + ' LEFT JOIN #__groups AS g ON g.id = c.access' . + ' LEFT JOIN #__users AS u ON u.id = c.checked_out' . + ' LEFT JOIN #__users AS v ON v.id = c.created_by' . + ' LEFT JOIN #__content_frontpage AS f ON f.content_id = c.id' . + $where . + $order; + $db->setQuery($query, $this->_page->limitstart, $this->_page->limit); + $this->_list = $db->loadObjectList(); + + // If there is a db query error, throw a HTTP 500 and exit + if ($db->getErrorNum()) { + JError::raiseError( 500, $db->stderr() ); + return false; + } + + return $this->_list; + } + + function getPagination() + { + if (is_null($this->_list) || is_null($this->_page)) { + $this->getList(); + } + return $this->_page; + } +} +?> diff --git a/oss/joomla/trunk/administrator/components/com_content/models/index.html b/oss/joomla/trunk/administrator/components/com_content/models/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_content/models/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_content/toolbar.content.html.php b/oss/joomla/trunk/administrator/components/com_content/toolbar.content.html.php new file mode 100644 index 00000000..e6b2111c --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_content/toolbar.content.html.php @@ -0,0 +1,84 @@ +[ '. $text.' ]', 'addedit.png' ); + JToolBarHelper::preview( 'index.php?option=com_content&id='.$cid.'&tmpl=component', true ); + JToolBarHelper::save(); + JToolBarHelper::apply(); + if ( $edit ) { + // for existing articles the button is renamed `close` + JToolBarHelper::cancel( 'cancel', 'Close' ); + } else { + JToolBarHelper::cancel(); + } + JToolBarHelper::help( 'screen.content.edit' ); + } +/* + function _ARCHIVE() + { + JToolBarHelper::title( JText::_( 'Archive Manager' ), 'addedit.png' ); + JToolBarHelper::unarchiveList(); + JToolBarHelper::custom( 'remove', 'delete.png', 'delete_f2.png', 'Trash', false ); + JToolBarHelper::help( 'screen.content.archive' ); + } +*/ + function _MOVE() + { + JToolBarHelper::title( JText::_( 'Move Articles' ), 'move_f2.png' ); + JToolBarHelper::custom( 'movesectsave', 'save.png', 'save_f2.png', 'Save', false ); + JToolBarHelper::cancel(); + } + + function _COPY() + { + JToolBarHelper::title( JText::_( 'Copy Articles' ), 'copy_f2.png' ); + JToolBarHelper::custom( 'copysave', 'save.png', 'save_f2.png', 'Save', false ); + JToolBarHelper::cancel(); + } + + function _DEFAULT() + { + global $filter_state; + + JToolBarHelper::title( JText::_( 'Article Manager' ), 'article.png' ); + if ($filter_state == 'A' || $filter_state == NULL) { + JToolBarHelper::unarchiveList(); + } + if ($filter_state != 'A') { + JToolBarHelper::archiveList(); + } + JToolBarHelper::publishList(); + JToolBarHelper::unpublishList(); + JToolBarHelper::customX( 'movesect', 'move.png', 'move_f2.png', 'Move' ); + JToolBarHelper::customX( 'copy', 'copy.png', 'copy_f2.png', 'Copy' ); + JToolBarHelper::trash(); + JToolBarHelper::editListX(); + JToolBarHelper::addNewX(); + JToolBarHelper::preferences('com_content', '550'); + JToolBarHelper::help( 'screen.content' ); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_content/toolbar.content.php b/oss/joomla/trunk/administrator/components/com_content/toolbar.content.php new file mode 100644 index 00000000..b150f85e --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_content/toolbar.content.php @@ -0,0 +1,48 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_content/views/element/view.php b/oss/joomla/trunk/administrator/components/com_content/views/element/view.php new file mode 100644 index 00000000..9b578f47 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_content/views/element/view.php @@ -0,0 +1,204 @@ +getNullDate(); + + $document = & JFactory::getDocument(); + $document->setTitle(JText::_('Article Selection')); + + JHTML::_('behavior.modal'); + + $template = $mainframe->getTemplate(); + $document->addStyleSheet("templates/$template/css/general.css"); + + $limitstart = JRequest::getVar('limitstart', '0', '', 'int'); + + $lists = $this->_getLists(); + + //Ordering allowed ? + $ordering = ($lists['order'] == 'section_name' && $lists['order_Dir'] == 'ASC'); + + $rows = &$this->get('List'); + $page = &$this->get('Pagination'); + JHTML::_('behavior.tooltip'); + ?> +
    + + + + + + +
    + : + + + + + +
    + + + + + + + + + + + + + + + + + + + + created, JText::_('DATE_FORMAT_LC4') ); + $access = JHTML::_('grid.access', $row, $i, $row->state ); + ?> + "> + + + + + + + + + + +
    + + + + + + + + + + + + + +
    + getListFooter(); ?> +
    + getRowOffset( $i ); ?> + + title); ?>', '');"> + title, ENT_QUOTES, 'UTF-8'); ?> + + groupname;?> + + id; ?> + + section_name; ?> + + cctitle; ?> + + +
    + + + + +
    + getUserStateFromRequest('articleelement.filter_order', 'filter_order', '', 'cmd'); + $filter_order_Dir = $mainframe->getUserStateFromRequest('articleelement.filter_order_Dir', 'filter_order_Dir', '', 'word'); + $filter_state = $mainframe->getUserStateFromRequest('articleelement.filter_state', 'filter_state', '', 'word'); + $catid = $mainframe->getUserStateFromRequest('articleelement.catid', 'catid', 0, 'int'); + $filter_authorid = $mainframe->getUserStateFromRequest('articleelement.filter_authorid', 'filter_authorid', 0, 'int'); + $filter_sectionid = $mainframe->getUserStateFromRequest('articleelement.filter_sectionid', 'filter_sectionid', -1, 'int'); + $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); + $limitstart = $mainframe->getUserStateFromRequest('articleelement.limitstart', 'limitstart', 0, 'int'); + $search = $mainframe->getUserStateFromRequest('articleelement.search', 'search', '', 'string'); + $search = JString::strtolower($search); + + // get list of categories for dropdown filter + $filter = ($filter_sectionid >= 0) ? ' WHERE cc.section = '.$db->Quote($filter_sectionid) : ''; + + // get list of categories for dropdown filter + $query = 'SELECT cc.id AS value, cc.title AS text, section' . + ' FROM #__categories AS cc' . + ' INNER JOIN #__sections AS s ON s.id = cc.section' . + $filter . + ' ORDER BY s.ordering, cc.ordering'; + + $lists['catid'] = ContentHelper::filterCategory($query, $catid); + + // get list of sections for dropdown filter + $javascript = 'onchange="document.adminForm.submit();"'; + $lists['sectionid'] = JHTML::_('list.section', 'filter_sectionid', $filter_sectionid, $javascript); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search'] = $search; + + return $lists; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_content/views/index.html b/oss/joomla/trunk/administrator/components/com_content/views/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_content/views/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/assets/delete.png b/oss/joomla/trunk/administrator/components/com_media/assets/delete.png new file mode 100644 index 00000000..08f24936 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/assets/delete.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/assets/index.html b/oss/joomla/trunk/administrator/components/com_media/assets/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/assets/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/assets/medialist-details.css b/oss/joomla/trunk/administrator/components/com_media/assets/medialist-details.css new file mode 100644 index 00000000..f7ad6ca1 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/assets/medialist-details.css @@ -0,0 +1,39 @@ +/** + * CSS Document for media manager list view + * @version $Id: medialist-details.css 10387 2008-06-03 10:59:16Z pasamio $ + * @package Joomla + * @copyright Copyright (C) 2005 - 2006 Open Source Matters. All rights reserved. + * @license GNU/GPL, see LICENSE.php + * Joomla! is free software and parts of it may contain or be derived from the + * GNU General Public License or other free or open source software licenses. + * See COPYRIGHT.php for copyright notices and details. + */ + +.outline { + border: 1px solid #cccccc; + background: #ffffff; + padding: 2px; +} + +.manager table td, +.manager table th { + font-family: Arial, helvetica, sans-serif; + font-size: 11px; + border-right: 1px dashed #E7E7E7; + border-bottom: 1px solid #E7E7E7; + border-left: 1px solid #fff; + text-align: center; +} + +.manager table td.description { + text-align: left; +} + +.manager table th { + border-top: 1px solid #E7E7E7; + border-right: 1px solid #E7E7E7; + border-bottom: 1px solid #999; + background: #F0F0F0; + padding: 4px; + color: #666; +} diff --git a/oss/joomla/trunk/administrator/components/com_media/assets/medialist-thumbs.css b/oss/joomla/trunk/administrator/components/com_media/assets/medialist-thumbs.css new file mode 100644 index 00000000..da08cc03 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/assets/medialist-thumbs.css @@ -0,0 +1,105 @@ +/** + * CSS Document for media manager thumbnail view + * @version $Id: medialist-thumbs.css 10387 2008-06-03 10:59:16Z pasamio $ + * @package Joomla + * @copyright Copyright (C) 2005 - 2006 Open Source Matters. All rights reserved. + * @license GNU/GPL, see LICENSE.php + * Joomla! is free software and parts of it may contain or be derived from the + * GNU General Public License or other free or open source software licenses. + * See COPYRIGHT.php for copyright notices and details. + */ + +div.imgOutline { + float: left; + border: 1px; + + border-right: 1px solid #f0f0f0; + border-bottom: 1px solid #ccc; + width:90px; } + +div.imgTotal { } + +div.imgBorder { + height: 72px; + vertical-align: middle; + width: 88px; + overflow: hidden; +} + +div.imgBorder a { + height: 72px; + width: 88px; + display: block; +} + +div.imgBorder a:hover { + height: 72px; + width: 88px; + background-color: #f0f0f0; + color : #FF6600; +} + +.imgBorderHover { + background: #FFFFCC; + cursor: hand; +} + +div.controls { + text-align: center; + height: 20px; + line-height: 20px; + background: #f9fcf9; + border-top: 1px solid #ddd; +} + +div.controls input { + vertical-align: middle; +} + +div.controls img { + vertical-align: middle; +} + +div.controls:hover { + display: block; +} + +div.imginfoBorder { + background: #f9f9f9; + font-family: Arial, Helvetica, sans-serif; + font-size: 10px; + width: 88px; + height: 15px; + vertical-align: middle; + text-align: center; + overflow: hidden; +} + +div.imgBorder a { + cursor: pointer; +} + +.buttonHover { + border: 1px solid; + border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; + cursor: hand; + background: #FFFFCC; +} + +.buttonOut { + border: 0px; +} + +.imgCaption { + font-size: 9pt; + text-align: center; +} + +.dirField { + font-size: 9pt; + width:110px; +} + +div.image { + padding-top: 10px; +} diff --git a/oss/joomla/trunk/administrator/components/com_media/assets/mediamanager.css b/oss/joomla/trunk/administrator/components/com_media/assets/mediamanager.css new file mode 100644 index 00000000..8454a94f --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/assets/mediamanager.css @@ -0,0 +1,106 @@ +/** +* @version $Id: mediamanager.css 10387 2008-06-03 10:59:16Z pasamio $ +* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +* @license GNU/GPL, see LICENSE.php +* Joomla! is free software. This version may have been modified pursuant +* to the GNU General Public License, and as distributed it includes or +* is derivative of works licensed under the GNU General Public License or +* other free or open source software licenses. +* See COPYRIGHT.php for copyright notices and details. +*/ /** + * MediaManager javascript behvaior styling + * + * @author Johan Janssens + * @package Joomla + * @since 1.5 + * @version 1.0 + */ +#treeview { + padding: 10px; + width: 190px; + overflow: auto; + /*height: 390px;*/ + border: 0; +} + +#folderview { + +} + +#folderview .path { + margin-bottom: 10px; +} + +#folderview .view { + display: block; + margin: 0; + padding: 0; + height: 360px; +} + +#folderview input#folderpath { + width: 65%; + background-color: #EEE; +} + +#folderview input#foldername { + width: 20%; +} + +#folderview iframe#folderframe { + height: 100%; +} + +#uploads .upload { + padding: 4px; +} + +/** + * Upload Widget CSS + */ +.upload-queue { + list-style: none; +} + +.upload-queue li { + background: url(upload.png) no-repeat 0 5px; + padding: 5px 0 5px 22px; +} + +.upload-queue .queue-file { + font-weight: bold; +} + +.upload-queue .queue-size { + color: #aaa; + margin-left: 1em; + font-size: 0.9em; +} + +.upload-queue .queue-loader { + position: relative; + margin: 3px 15px; + font-size: 0.9em; + background-color: #ddd; + color: #fff; + border: 1px inset #ddd; +} + +.upload-queue .queue-subloader { + text-align: center; + position: absolute; + background-color: #81B466; + height: 100%; + width: 0%; + left: 0; + top: 0; +} + +.upload-queue .input-delete { + width: 16px; + height: 16px; + background: url(delete.png) no-repeat 0 0; + text-decoration: none; + border: none; + float: right; +} diff --git a/oss/joomla/trunk/administrator/components/com_media/assets/mediamanager.js b/oss/joomla/trunk/administrator/components/com_media/assets/mediamanager.js new file mode 100644 index 00000000..fbfe0ff4 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/assets/mediamanager.js @@ -0,0 +1,180 @@ +/** +* @version $Id: mediamanager.js 10710 2008-08-21 10:08:12Z eddieajau $ +* @package Joomla +* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +* @license GNU/GPL, see LICENSE.php +* Joomla! is free software. This version may have been modified pursuant +* to the GNU General Public License, and as distributed it includes or +* is derivative of works licensed under the GNU General Public License or +* other free or open source software licenses. +* See COPYRIGHT.php for copyright notices and details. +*/ + + +/** + * JMediaManager behavior for media component + * + * @package Joomla.Extensions + * @subpackage Media + * @since 1.5 + */ +var MediaManager = { + + initialize: function() + { + this.folderframe = $('folderframe'); + this.folderpath = $('folderpath'); + + this.updatepaths = $$('input.update-folder'); + + this.frame = window.frames['folderframe']; + this.frameurl = this.frame.location.href; + //this.frameurl = window.frames['folderframe'].location.href; + + this.tree = new MooTreeControl({ div: 'media-tree_tree', mode: 'folders', grid: true, theme: 'components/com_media/assets/mootree.gif', onClick: + function(node){ + target = $chk(node.data.target) ? node.data.target : '_self'; + window.frames[target].location.href = node.data.url; + } + },{ text: 'Media', open: true, data: { url: 'index.php?option=com_media&view=mediaList&tmpl=component', target: 'folderframe'}}); + this.tree.adopt('media-tree'); + }, + + submit: function(task) + { + form = window.frames['folderframe'].document.getElementById('mediamanager-form'); + form.task.value = task; + if ($('username')) { + form.username.value = $('username').value; + form.password.value = $('password').value; + } + form.submit(); + }, + + onloadframe: function() + { + // Update the frame url + this.frameurl = this.frame.location.href; + + var folder = this.getFolder(); + if (folder) { + this.updatepaths.each(function(path){ path.value =folder; }); + this.folderpath.value = basepath+'/'+folder; + node = this.tree.get('node_'+folder); + node.toggle(false, true); + } else { + this.updatepaths.each(function(path){ path.value = ''; }); + this.folderpath.value = basepath; + node = this.tree.root; + } + + if (node) { + this.tree.select(node, true); + } + + $(viewstyle).addClass('active'); + + a = this._getUriObject($('uploadForm').getProperty('action')); + q = $H(this._getQueryObject(a.query)); + q.set('folder', folder); + var query = []; + q.each(function(v, k){ + if ($chk(v)) { + this.push(k+'='+v); + } + }, query); + a.query = query.join('&'); + if (a.port) { + $('uploadForm').setProperty('action', a.scheme+'://'+a.domain+':'+a.port+a.path+'?'+a.query); + } else { + $('uploadForm').setProperty('action', a.scheme+'://'+a.domain+a.path+'?'+a.query); + } + }, + + oncreatefolder: function() + { + if ($('foldername').value.length) { + $('dirpath').value = this.getFolder(); + submitbutton('createfolder'); + } + }, + + setViewType: function(type) + { + $(type).addClass('active'); + $(viewstyle).removeClass('active'); + viewstyle = type; + var folder = this.getFolder(); + this._setFrameUrl('index.php?option=com_media&view=mediaList&tmpl=component&folder='+folder+'&layout='+type); + }, + + refreshFrame: function() + { + this._setFrameUrl(); + }, + + getFolder: function() + { + var url = this.frame.location.search.substring(1); + var args = this.parseQuery(url); + + if (args['folder'] == "undefined") { + args['folder'] = ""; + } + + return args['folder']; + }, + + parseQuery: function(query) + { + var params = new Object(); + if (!query) { + return params; + } + var pairs = query.split(/[;&]/); + for ( var i = 0; i < pairs.length; i++ ) + { + var KeyVal = pairs[i].split('='); + if ( ! KeyVal || KeyVal.length != 2 ) { + continue; + } + var key = unescape( KeyVal[0] ); + var val = unescape( KeyVal[1] ).replace(/\+ /g, ' '); + params[key] = val; + } + return params; + }, + + _setFrameUrl: function(url) + { + if ($chk(url)) { + this.frameurl = url; + } + this.frame.location.href = this.frameurl; + }, + + _getQueryObject: function(q) { + var vars = q.split(/[&;]/); + var rs = {}; + if (vars.length) vars.each(function(val) { + var keys = val.split('='); + if (keys.length && keys.length == 2) rs[encodeURIComponent(keys[0])] = encodeURIComponent(keys[1]); + }); + return rs; + }, + + _getUriObject: function(u){ + var bits = u.match(/^(?:([^:\/?#.]+):)?(?:\/\/)?(([^:\/?#]*)(?::(\d*))?)((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[\?#]|$)))*\/?)?([^?#\/]*))?(?:\?([^#]*))?(?:#(.*))?/); + return (bits) + ? bits.associate(['uri', 'scheme', 'authority', 'domain', 'port', 'path', 'directory', 'file', 'query', 'fragment']) + : null; + } +}; + +window.addEvent('domready', function(){ + // Added to populate data on iframe load + MediaManager.initialize(); + MediaManager.trace = 'start'; + document.updateUploader = function() { MediaManager.onloadframe(); }; + MediaManager.onloadframe(); +}); diff --git a/oss/joomla/trunk/administrator/components/com_media/assets/mootree.gif b/oss/joomla/trunk/administrator/components/com_media/assets/mootree.gif new file mode 100644 index 00000000..b0f73329 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/assets/mootree.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagelist.css b/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagelist.css new file mode 100644 index 00000000..c9df2904 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagelist.css @@ -0,0 +1,54 @@ +/** +* @version $Id: popup-imagelist.css 10387 2008-06-03 10:59:16Z pasamio $ +* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +* @license GNU/GPL, see LICENSE.php +* Joomla! is free software. This version may have been modified pursuant +* to the GNU General Public License, and as distributed it includes or +* is derivative of works licensed under the GNU General Public License or +* other free or open source software licenses. +* See COPYRIGHT.php for copyright notices and details. +*/ + +/** + * ImageManager imagelist styling + * + * @author Johan Janssens + * @package Joomla + * @since 1.5 + * @version 1.0 + */ + + html, body { margin: 0 !important; padding: 0 !important; font: 10px Tahoma, Verdana, sans-serif; } + +.item { float: left; border: 1px solid #ccc; margin: 3px; position: relative; } + +.item a { + display: table-cell !important; + display: block; + width: 80px; height: 90px; + overflow: hidden; + vertical-align: middle; + text-align: center; + text-decoration: none; + color: black; + + line-height: 90px; +} + +.item img { display: inline; margin-top: expression(( 80 - this.height ) / 2);} + +html>body .item img {margin: auto;} + +.item span { + line-height: 100%; + clear:both; + display: block; + width: 100%; + position: absolute; + bottom: 0; + left: 0; + padding: 2px 0; + background-color: #eee; + overflow: hidden; +} + diff --git a/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagemanager.css b/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagemanager.css new file mode 100644 index 00000000..362daa73 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagemanager.css @@ -0,0 +1,114 @@ +/** +* @version $Id: popup-imagemanager.css 10387 2008-06-03 10:59:16Z pasamio $ +* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +* @license GNU/GPL, see LICENSE.php +* Joomla! is free software. This version may have been modified pursuant +* to the GNU General Public License, and as distributed it includes or +* is derivative of works licensed under the GNU General Public License or +* other free or open source software licenses. +* See COPYRIGHT.php for copyright notices and details. +*/ + +/** + * ImageManager javascript behavior styling + * + * @author Johan Janssens + * @package Joomla + * @since 1.5 + * @version 1.0 + */ + +html, body { + background-color: #F0F0F0; + color: ButtonText; + font: 11px Tahoma, Verdana, sans-serif; + margin: 0px !important; padding: 0px !important; +} + +img { border: 0 none; } + +form { padding: 0px; margin: 0 auto; width: 100%; } +fieldset { border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; } +button { padding: 3px; border: 1px solid #CCCCCC; font-weight: bold; color: #0B55C4; background-color: white; } +button:hover { border: 1px solid #0B55C4; } + +select,input,button { font: 11px Tahoma, Verdana, sans-serif; } + +iframe { width: 100%; overflow-x: false; border: 0 none; margin: 0 0 0.5em 0; padding: 0;} +iframe#imageframe { height: 195px; } + +a { padding: 5px; border: 1px solid ButtonFace; } +a:hover { border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; } + +.buttons { width: 70px; text-align: center; } + +#f_alt, #f_url, #f_title { width: 22em; } + +#messages { + position: relative; + left: 175px; + top: 115px; + background-color: white; + width: 200px; + float: left; + margin-top: -52px; + border: 1px solid #ccc; + text-align: center; + padding: 15px; +} + +#message { + font-size: 15px; + font-weight: bold; + color: #69c; +} + +/** + * Upload Widget CSS + */ +.upload-queue { + list-style: none; +} + +.upload-queue li { + background: url(upload.png) no-repeat 0 5px; + padding: 5px 0 5px 5px; +} + +.upload-queue .queue-file { + font-weight: bold; +} + +.upload-queue .queue-size { + color: #aaa; + margin-left: 1em; + font-size: 0.9em; +} + +.upload-queue .queue-loader { + position: relative; + margin: 3px 15px; + font-size: 0.9em; + background-color: #ddd; + color: #fff; + border: 1px inset #ddd; +} + +.upload-queue .queue-subloader { + text-align: center; + position: absolute; + background-color: #81B466; + height: 100%; + width: 0%; + left: 0; + top: 0; +} + +.upload-queue .input-delete { + width: 16px; + height: 16px; + background: url(delete.png) no-repeat 0 0; + text-decoration: none; + border: none; + float: right; +} diff --git a/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagemanager.js b/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagemanager.js new file mode 100644 index 00000000..eb5532ba --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagemanager.js @@ -0,0 +1,246 @@ +/** +* @version $Id: popup-imagemanager.js 10702 2008-08-21 09:31:31Z eddieajau $ +* @package Joomla +* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +* @license GNU/GPL, see LICENSE.php +* Joomla! is free software. This version may have been modified pursuant +* to the GNU General Public License, and as distributed it includes or +* is derivative of works licensed under the GNU General Public License or +* other free or open source software licenses. +* See COPYRIGHT.php for copyright notices and details. +*/ + +/** + * JImageManager behavior for media component + * + * @package Joomla.Extensions + * @subpackage Media + * @since 1.5 + */ +var ImageManager = { + initialize: function() + { + o = this._getUriObject(window.self.location.href); + //console.log(o); + q = $H(this._getQueryObject(o.query)); + this.editor = decodeURIComponent(q.get('e_name')); + + // Setup image manager fields object + this.fields = new Object(); + this.fields.url = $("f_url"); + this.fields.alt = $("f_alt"); + this.fields.align = $("f_align"); + this.fields.title = $("f_title"); + this.fields.caption = $("f_caption"); + + // Setup image listing objects + this.folderlist = $('folderlist'); + + this.frame = window.frames['imageframe']; + this.frameurl = this.frame.location.href; + + // Setup imave listing frame + this.imageframe = $('imageframe'); + this.imageframe.manager = this; + this.imageframe.addEvent('load', function(){ ImageManager.onloadimageview(); }); + + // Setup folder up button + this.upbutton = $('upbutton'); + this.upbutton.removeEvents('click'); + this.upbutton.addEvent('click', function(){ ImageManager.upFolder(); }); + }, + + onloadimageview: function() + { + // Update the frame url + this.frameurl = this.frame.location.href; + + var folder = this.getImageFolder(); + for(var i = 0; i < this.folderlist.length; i++) + { + if(folder == this.folderlist.options[i].value) { + this.folderlist.selectedIndex = i; + break; + } + } + + a = this._getUriObject($('uploadForm').getProperty('action')); + //console.log(a); + q = $H(this._getQueryObject(a.query)); + q.set('folder', folder); + var query = []; + q.each(function(v, k){ + if ($chk(v)) { + this.push(k+'='+v); + } + }, query); + a.query = query.join('&'); + $('uploadForm').setProperty('action', a.scheme+'://'+a.domain+a.path+'?'+a.query); + }, + + getImageFolder: function() + { + var url = this.frame.location.search.substring(1); + var args = this.parseQuery(url); + + return args['folder']; + }, + + onok: function() + { + extra = ''; + // Get the image tag field information + var url = this.fields.url.getValue(); + var alt = this.fields.alt.getValue(); + var align = this.fields.align.getValue(); + var title = this.fields.title.getValue(); + var caption = this.fields.caption.getValue(); + + if (url != '') { + // Set alt attribute + if (alt != '') { + extra = extra + 'alt="'+alt+'" '; + } else { + extra = extra + 'alt="" '; + } + // Set align attribute + if (align != '') { + extra = extra + 'align="'+align+'" '; + } + // Set align attribute + if (title != '') { + extra = extra + 'title="'+title+'" '; + } + // Set align attribute + if (caption != '') { + extra = extra + 'class="caption" '; + } + + var tag = ""; + } + + window.parent.jInsertEditorText(tag, this.editor); + return false; + }, + + setFolder: function(folder) + { + //this.showMessage('Loading'); + + for(var i = 0; i < this.folderlist.length; i++) + { + if(folder == this.folderlist.options[i].value) { + this.folderlist.selectedIndex = i; + break; + } + } + this.frame.location.href='index.php?option=com_media&view=imagesList&tmpl=component&folder=' + folder; + }, + + getFolder: function() { + return this.folderlist.getValue(); + }, + + upFolder: function() + { + var currentFolder = this.getFolder(); + if(currentFolder.length < 2) { + return false; + } + + var folders = currentFolder.split('/'); + var search = ''; + + for(var i = 0; i < folders.length - 1; i++) { + search += folders[i]; + search += '/'; + } + + // remove the trailing slash + search = search.substring(0, search.length - 1); + + for(var i = 0; i < this.folderlist.length; i++) + { + var thisFolder = this.folderlist.options[i].value; + + if(thisFolder == search) + { + this.folderlist.selectedIndex = i; + var newFolder = this.folderlist.options[i].value; + this.setFolder(newFolder); + break; + } + } + }, + + populateFields: function(file) + { + $("f_url").value = image_base_path+file; + }, + + showMessage: function(text) + { + var message = $('message'); + var messages = $('messages'); + + if(message.firstChild) + message.removeChild(message.firstChild); + + message.appendChild(document.createTextNode(text)); + messages.style.display = "block"; + }, + + parseQuery: function(query) + { + var params = new Object(); + if (!query) { + return params; + } + var pairs = query.split(/[;&]/); + for ( var i = 0; i < pairs.length; i++ ) + { + var KeyVal = pairs[i].split('='); + if ( ! KeyVal || KeyVal.length != 2 ) { + continue; + } + var key = unescape( KeyVal[0] ); + var val = unescape( KeyVal[1] ).replace(/\+ /g, ' '); + params[key] = val; + } + return params; + }, + + refreshFrame: function() + { + this._setFrameUrl(); + }, + + _setFrameUrl: function(url) + { + if ($chk(url)) { + this.frameurl = url; + } + this.frame.location.href = this.frameurl; + }, + + _getQueryObject: function(q) { + var vars = q.split(/[&;]/); + var rs = {}; + if (vars.length) vars.each(function(val) { + var keys = val.split('='); + if (keys.length && keys.length == 2) rs[encodeURIComponent(keys[0])] = encodeURIComponent(keys[1]); + }); + return rs; + }, + + _getUriObject: function(u){ + var bits = u.match(/^(?:([^:\/?#.]+):)?(?:\/\/)?(([^:\/?#]*)(?::(\d*))?)((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[\?#]|$)))*\/?)?([^?#\/]*))?(?:\?([^#]*))?(?:#(.*))?/); + return (bits) + ? bits.associate(['uri', 'scheme', 'authority', 'domain', 'port', 'path', 'directory', 'file', 'query', 'fragment']) + : null; + } +}; + +window.addEvent('domready', function(){ + ImageManager.initialize(); +}); diff --git a/oss/joomla/trunk/administrator/components/com_media/assets/progress.gif b/oss/joomla/trunk/administrator/components/com_media/assets/progress.gif new file mode 100644 index 00000000..6d8652e8 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/assets/progress.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_media/assets/upload.png b/oss/joomla/trunk/administrator/components/com_media/assets/upload.png new file mode 100644 index 00000000..27c63c5a Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/assets/upload.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/config.xml b/oss/joomla/trunk/administrator/components/com_media/config.xml new file mode 100644 index 00000000..6240fbbf --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/config.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/oss/joomla/trunk/administrator/components/com_media/controller.php b/oss/joomla/trunk/administrator/components/com_media/controller.php new file mode 100644 index 00000000..d9263d4c --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/controller.php @@ -0,0 +1,90 @@ +getUserStateFromRequest('media.list.layout', 'layout', 'thumbs', 'word'); + + break; + + case 'media': + default: + $vName = 'media'; + $vLayout = JRequest::getCmd( 'layout', 'default' ); + $mName = 'manager'; + break; + } + + $document = &JFactory::getDocument(); + $vType = $document->getType(); + + // Get/Create the view + $view = &$this->getView( $vName, $vType); + + // Get/Create the model + if ($model = &$this->getModel($mName)) { + // Push the model into the view (as default) + $view->setModel($model, true); + } + + // Set the layout + $view->setLayout($vLayout); + + // Display the view + $view->display(); + } + + function ftpValidate() + { + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_media/controllers/file.php b/oss/joomla/trunk/administrator/components/com_media/controllers/file.php new file mode 100644 index 00000000..d13d6820 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/controllers/file.php @@ -0,0 +1,188 @@ +addEntry(array('comment' => 'Invalid: '.$filepath.': '.$err)); + header('HTTP/1.0 415 Unsupported Media Type'); + jexit('Error. Unsupported Media Type!'); + } else { + JError::raiseNotice(100, JText::_($err)); + // REDIRECT + if ($return) { + $mainframe->redirect(base64_decode($return).'&folder='.$folder); + } + return; + } + } + + if (JFile::exists($filepath)) { + if ($format == 'json') { + jimport('joomla.error.log'); + $log = &JLog::getInstance('upload.error.php'); + $log->addEntry(array('comment' => 'File already exists: '.$filepath)); + header('HTTP/1.0 409 Conflict'); + jexit('Error. File already exists'); + } else { + JError::raiseNotice(100, JText::_('Error. File already exists')); + // REDIRECT + if ($return) { + $mainframe->redirect(base64_decode($return).'&folder='.$folder); + } + return; + } + } + + if (!JFile::upload($file['tmp_name'], $filepath)) { + if ($format == 'json') { + jimport('joomla.error.log'); + $log = &JLog::getInstance('upload.error.php'); + $log->addEntry(array('comment' => 'Cannot upload: '.$filepath)); + header('HTTP/1.0 400 Bad Request'); + jexit('Error. Unable to upload file'); + } else { + JError::raiseWarning(100, JText::_('Error. Unable to upload file')); + // REDIRECT + if ($return) { + $mainframe->redirect(base64_decode($return).'&folder='.$folder); + } + return; + } + } else { + if ($format == 'json') { + jimport('joomla.error.log'); + $log = &JLog::getInstance(); + $log->addEntry(array('comment' => $folder)); + jexit('Upload complete'); + } else { + $mainframe->enqueueMessage(JText::_('Upload complete')); + // REDIRECT + if ($return) { + $mainframe->redirect(base64_decode($return).'&folder='.$folder); + } + return; + } + } + } else { + $mainframe->redirect('index.php', 'Invalid Request', 'error'); + } + } + + /** + * Deletes paths from the current path + * + * @param string $listFolder The image directory to delete a file from + * @since 1.5 + */ + function delete() + { + global $mainframe; + + JRequest::checkToken( 'request' ) or jexit( 'Invalid Token' ); + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + + // Get some data from the request + $tmpl = JRequest::getCmd( 'tmpl' ); + $paths = JRequest::getVar( 'rm', array(), '', 'array' ); + $folder = JRequest::getVar( 'folder', '', '', 'path'); + + // Initialize variables + $msg = array(); + $ret = true; + + if (count($paths)) { + foreach ($paths as $path) + { + if ($path !== JFile::makeSafe($path)) { + JError::raiseWarning(100, JText::_('Unable to delete:').htmlspecialchars($path, ENT_COMPAT, 'UTF-8').' '.JText::_('WARNFILENAME')); + continue; + } + + $fullPath = JPath::clean(COM_MEDIA_BASE.DS.$folder.DS.$path); + if (is_file($fullPath)) { + $ret |= !JFile::delete($fullPath); + } else if (is_dir($fullPath)) { + $files = JFolder::files($fullPath, '.', true); + $canDelete = true; + foreach ($files as $file) { + if ($file != 'index.html') { + $canDelete = false; + } + } + if ($canDelete) { + $ret |= !JFolder::delete($fullPath); + } else { + JError::raiseWarning(100, JText::_('Unable to delete:').$fullPath.' '.JText::_('Not Empty!')); + } + } + } + } + if ($tmpl == 'component') { + // We are inside the iframe + $mainframe->redirect('index.php?option=com_media&view=mediaList&folder='.$folder.'&tmpl=component'); + } else { + $mainframe->redirect('index.php?option=com_media&folder='.$folder); + } + } +} diff --git a/oss/joomla/trunk/administrator/components/com_media/controllers/folder.php b/oss/joomla/trunk/administrator/components/com_media/controllers/folder.php new file mode 100644 index 00000000..7a53b6cd --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/controllers/folder.php @@ -0,0 +1,130 @@ +redirect('index.php?option=com_media&view=mediaList&folder='.$folder.'&tmpl=component'); + } else { + $mainframe->redirect('index.php?option=com_media&folder='.$folder); + } + } + + /** + * Create a folder + * + * @param string $path Path of the folder to create + * @since 1.5 + */ + function create() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + + $folder = JRequest::getCmd( 'foldername', ''); + $folderCheck = JRequest::getVar( 'foldername', null, '', 'string', JREQUEST_ALLOWRAW); + $parent = JRequest::getVar( 'folderbase', '', '', 'path' ); + + JRequest::setVar('folder', $parent); + + if (($folderCheck !== null) && ($folder !== $folderCheck)) { + $mainframe->redirect('index.php?option=com_media&folder='.$parent, JText::_('WARNDIRNAME')); + } + + if (strlen($folder) > 0) { + $path = JPath::clean(COM_MEDIA_BASE.DS.$parent.DS.$folder); + if (!is_dir($path) && !is_file($path)) + { + jimport('joomla.filesystem.*'); + JFolder::create($path); + JFile::write($path.DS."index.html", "\n\n\n"); + } + JRequest::setVar('folder', ($parent) ? $parent.'/'.$folder : $folder); + } + $mainframe->redirect('index.php?option=com_media&folder='.$parent); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_media/controllers/index.html b/oss/joomla/trunk/administrator/components/com_media/controllers/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/controllers/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/helpers/index.html b/oss/joomla/trunk/administrator/components/com_media/helpers/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/helpers/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/helpers/media.php b/oss/joomla/trunk/administrator/components/com_media/helpers/media.php new file mode 100644 index 00000000..cbf469fb --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/helpers/media.php @@ -0,0 +1,186 @@ +get( 'upload_extensions' )); + $ignored = explode(',', $params->get( 'ignore_extensions' )); + if (!in_array($format, $allowable) && !in_array($format,$ignored)) + { + $err = 'WARNFILETYPE'; + return false; + } + + $maxSize = (int) $params->get( 'upload_maxsize', 0 ); + if ($maxSize > 0 && (int) $file['size'] > $maxSize) + { + $err = 'WARNFILETOOLARGE'; + return false; + } + + $user = JFactory::getUser(); + $imginfo = null; + if($params->get('restrict_uploads',1) ) { + $images = explode( ',', $params->get( 'image_extensions' )); + if(in_array($format, $images)) { // if its an image run it through getimagesize + if(($imginfo = getimagesize($file['tmp_name'])) === FALSE) { + $err = 'WARNINVALIDIMG'; + return false; + } + } else if(!in_array($format, $ignored)) { + // if its not an image...and we're not ignoring it + $allowed_mime = explode(',', $params->get('upload_mime')); + $illegal_mime = explode(',', $params->get('upload_mime_illegal')); + if(function_exists('finfo_open') && $params->get('check_mime',1)) { + // We have fileinfo + $finfo = finfo_open(FILEINFO_MIME); + $type = finfo_file($finfo, $file['tmp_name']); + if(strlen($type) && !in_array($type, $allowed_mime) && in_array($type, $illegal_mime)) { + $err = 'WARNINVALIDMIME'; + return false; + } + finfo_close($finfo); + } else if(function_exists('mime_content_type') && $params->get('check_mime',1)) { + // we have mime magic + $type = mime_content_type($file['tmp_name']); + if(strlen($type) && !in_array($type, $allowed_mime) && in_array($type, $illegal_mime)) { + $err = 'WARNINVALIDMIME'; + return false; + } + } else if(!$user->authorize( 'login', 'administrator' )) { + $err = 'WARNNOTADMIN'; + return false; + } + } + } + + $xss_check = JFile::read($file['tmp_name'],false,256); + $html_tags = array('abbr','acronym','address','applet','area','audioscope','base','basefont','bdo','bgsound','big','blackface','blink','blockquote','body','bq','br','button','caption','center','cite','code','col','colgroup','comment','custom','dd','del','dfn','dir','div','dl','dt','em','embed','fieldset','fn','font','form','frame','frameset','h1','h2','h3','h4','h5','h6','head','hr','html','iframe','ilayer','img','input','ins','isindex','keygen','kbd','label','layer','legend','li','limittext','link','listing','map','marquee','menu','meta','multicol','nobr','noembed','noframes','noscript','nosmartquotes','object','ol','optgroup','option','param','plaintext','pre','rt','ruby','s','samp','script','select','server','shadow','sidebar','small','spacer','span','strike','strong','style','sub','sup','table','tbody','td','textarea','tfoot','th','thead','title','tr','tt','ul','var','wbr','xml','xmp','!DOCTYPE', '!--'); + foreach($html_tags as $tag) { + // A tag is '' + if(stristr($xss_check, '<'.$tag.' ') || stristr($xss_check, '<'.$tag.'>')) { + $err = 'WARNIEXSS'; + return false; + } + } + return true; + } + + function parseSize($size) + { + if ($size < 1024) { + return $size . ' bytes'; + } + else + { + if ($size >= 1024 && $size < 1024 * 1024) { + return sprintf('%01.2f', $size / 1024.0) . ' Kb'; + } else { + return sprintf('%01.2f', $size / (1024.0 * 1024)) . ' Mb'; + } + } + } + + function imageResize($width, $height, $target) + { + //takes the larger size of the width and height and applies the + //formula accordingly...this is so this script will work + //dynamically with any size image + if ($width > $height) { + $percentage = ($target / $width); + } else { + $percentage = ($target / $height); + } + + //gets the new value and applies the percentage, then rounds the value + $width = round($width * $percentage); + $height = round($height * $percentage); + + return array($width, $height); + } + + function countFiles( $dir ) + { + $total_file = 0; + $total_dir = 0; + + if (is_dir($dir)) { + $d = dir($dir); + + while (false !== ($entry = $d->read())) { + if (substr($entry, 0, 1) != '.' && is_file($dir . DIRECTORY_SEPARATOR . $entry) && strpos($entry, '.html') === false && strpos($entry, '.php') === false) { + $total_file++; + } + if (substr($entry, 0, 1) != '.' && is_dir($dir . DIRECTORY_SEPARATOR . $entry)) { + $total_dir++; + } + } + + $d->close(); + } + + return array ( $total_file, $total_dir ); + } + +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/images/btnBack.gif b/oss/joomla/trunk/administrator/components/com_media/images/btnBack.gif new file mode 100644 index 00000000..62734b0b Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/btnBack.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/btnFolderNew.gif b/oss/joomla/trunk/administrator/components/com_media/images/btnFolderNew.gif new file mode 100644 index 00000000..0c2073bd Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/btnFolderNew.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/btnFolderUp.gif b/oss/joomla/trunk/administrator/components/com_media/images/btnFolderUp.gif new file mode 100644 index 00000000..7bd245db Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/btnFolderUp.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/con_info.png b/oss/joomla/trunk/administrator/components/com_media/images/con_info.png new file mode 100644 index 00000000..1903fabc Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/con_info.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/dots.gif b/oss/joomla/trunk/administrator/components/com_media/images/dots.gif new file mode 100644 index 00000000..859294e7 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/dots.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/edit_pencil.gif b/oss/joomla/trunk/administrator/components/com_media/images/edit_pencil.gif new file mode 100644 index 00000000..abb9fe4c Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/edit_pencil.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/edit_trash.gif b/oss/joomla/trunk/administrator/components/com_media/images/edit_trash.gif new file mode 100644 index 00000000..26b71846 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/edit_trash.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/folder.gif b/oss/joomla/trunk/administrator/components/com_media/images/folder.gif new file mode 100644 index 00000000..180ea1cc Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/folder.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/folder.png b/oss/joomla/trunk/administrator/components/com_media/images/folder.png new file mode 100644 index 00000000..e5ded3f2 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/folder.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/folder_sm.png b/oss/joomla/trunk/administrator/components/com_media/images/folder_sm.png new file mode 100644 index 00000000..30dd4eac Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/folder_sm.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/folderup.png b/oss/joomla/trunk/administrator/components/com_media/images/folderup.png new file mode 100644 index 00000000..c96e49b0 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/folderup.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/folderup_16.png b/oss/joomla/trunk/administrator/components/com_media/images/folderup_16.png new file mode 100644 index 00000000..c96e49b0 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/folderup_16.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/folderup_32.png b/oss/joomla/trunk/administrator/components/com_media/images/folderup_32.png new file mode 100644 index 00000000..a21c1699 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/folderup_32.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/index.html b/oss/joomla/trunk/administrator/components/com_media/images/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/images/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/images/info.png b/oss/joomla/trunk/administrator/components/com_media/images/info.png new file mode 100644 index 00000000..96d30691 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/info.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/avi.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/avi.png new file mode 100644 index 00000000..806aee2a Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/avi.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/doc.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/doc.png new file mode 100644 index 00000000..c816f94c Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/doc.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/index.html b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/mov.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/mov.png new file mode 100644 index 00000000..a7930e02 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/mov.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/mp3.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/mp3.png new file mode 100644 index 00000000..f6cd29be Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/mp3.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/mp4.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/mp4.png new file mode 100644 index 00000000..806aee2a Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/mp4.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/odc.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/odc.png new file mode 100644 index 00000000..91af5d13 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/odc.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/odd.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/odd.png new file mode 100644 index 00000000..cec26cd4 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/odd.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/odt.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/odt.png new file mode 100644 index 00000000..815851d1 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/odt.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/ogg.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/ogg.png new file mode 100644 index 00000000..a011502c Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/ogg.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/pdf.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/pdf.png new file mode 100644 index 00000000..f6cd7e26 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/pdf.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/ppt.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/ppt.png new file mode 100644 index 00000000..bc973248 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/ppt.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/rar.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/rar.png new file mode 100644 index 00000000..f1e5f224 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/rar.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/rtf.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/rtf.png new file mode 100644 index 00000000..fefd66c6 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/rtf.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/svg.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/svg.png new file mode 100644 index 00000000..e7d10949 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/svg.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/sxd.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/sxd.png new file mode 100644 index 00000000..606106f5 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/sxd.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/tar.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/tar.png new file mode 100644 index 00000000..ee953949 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/tar.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/tgz.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/tgz.png new file mode 100644 index 00000000..59a42805 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/tgz.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/wma.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/wma.png new file mode 100644 index 00000000..8b3e7c08 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/wma.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/wmv.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/wmv.png new file mode 100644 index 00000000..df6f0cc4 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/wmv.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/xls.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/xls.png new file mode 100644 index 00000000..7df67b1b Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/xls.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/zip.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/zip.png new file mode 100644 index 00000000..f6efb32f Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-16/zip.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/avi.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/avi.png new file mode 100644 index 00000000..8e286baa Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/avi.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/doc.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/doc.png new file mode 100644 index 00000000..a7f52d41 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/doc.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/index.html b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/mov.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/mov.png new file mode 100644 index 00000000..e6e384c8 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/mov.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/mp3.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/mp3.png new file mode 100644 index 00000000..c09dd0d7 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/mp3.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/mp4.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/mp4.png new file mode 100644 index 00000000..8e286baa Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/mp4.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/odc.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/odc.png new file mode 100644 index 00000000..51280736 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/odc.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/odd.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/odd.png new file mode 100644 index 00000000..b2881e0c Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/odd.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/odt.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/odt.png new file mode 100644 index 00000000..180d5952 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/odt.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/ogg.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/ogg.png new file mode 100644 index 00000000..8b6e7022 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/ogg.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/pdf.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/pdf.png new file mode 100644 index 00000000..1b4614b2 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/pdf.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/ppt.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/ppt.png new file mode 100644 index 00000000..b68d86f7 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/ppt.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/rar.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/rar.png new file mode 100644 index 00000000..e6337a02 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/rar.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/rtf.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/rtf.png new file mode 100644 index 00000000..598fe16d Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/rtf.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/svg.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/svg.png new file mode 100644 index 00000000..524a08e6 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/svg.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/sxd.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/sxd.png new file mode 100644 index 00000000..9a14a871 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/sxd.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/tar.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/tar.png new file mode 100644 index 00000000..24100ed6 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/tar.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/tgz.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/tgz.png new file mode 100644 index 00000000..b2705799 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/tgz.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/wma.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/wma.png new file mode 100644 index 00000000..e6f72d96 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/wma.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/wmv.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/wmv.png new file mode 100644 index 00000000..53c877af Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/wmv.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/xls.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/xls.png new file mode 100644 index 00000000..095a5932 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/xls.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/zip.png b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/zip.png new file mode 100644 index 00000000..2ed44349 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/mime-icon-32/zip.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/noimages.gif b/oss/joomla/trunk/administrator/components/com_media/images/noimages.gif new file mode 100644 index 00000000..3014d946 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/noimages.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/presentation_16.png b/oss/joomla/trunk/administrator/components/com_media/images/presentation_16.png new file mode 100644 index 00000000..da932550 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/presentation_16.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/remove.png b/oss/joomla/trunk/administrator/components/com_media/images/remove.png new file mode 100644 index 00000000..29c3a04e Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/remove.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/spreadsheet_16.png b/oss/joomla/trunk/administrator/components/com_media/images/spreadsheet_16.png new file mode 100644 index 00000000..91fb753e Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/spreadsheet_16.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/terminal_16.png b/oss/joomla/trunk/administrator/components/com_media/images/terminal_16.png new file mode 100644 index 00000000..f5410fc7 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/terminal_16.png differ diff --git a/oss/joomla/trunk/administrator/components/com_media/images/uploading.gif b/oss/joomla/trunk/administrator/components/com_media/images/uploading.gif new file mode 100644 index 00000000..3885617e Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_media/images/uploading.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_media/index.html b/oss/joomla/trunk/administrator/components/com_media/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/media.php b/oss/joomla/trunk/administrator/components/com_media/media.php new file mode 100644 index 00000000..56a96c66 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/media.php @@ -0,0 +1,77 @@ +authorize( 'com_media', 'manage' )) { + $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH')); +} + +$params =& JComponentHelper::getParams('com_media'); + +// Load the admin HTML view +require_once( JPATH_COMPONENT.DS.'helpers'.DS.'media.php' ); + +// Set the path definitions +$view = JRequest::getCmd('view',null); +$popup_upload = JRequest::getCmd('pop_up',null); +$path = "file_path"; +if(substr(strtolower($view),0,6) == "images" || $popup_upload == 1) $path = "image_path"; +define('COM_MEDIA_BASE', JPATH_ROOT.DS.$params->get($path, 'images/stories')); +define('COM_MEDIA_BASEURL', JURI::root().$params->get($path, 'images/stories')); + +// Require the base controller +require_once (JPATH_COMPONENT.DS.'controller.php'); + +$cmd = JRequest::getCmd('task', null); + +if (strpos($cmd, '.') != false) +{ + // We have a defined controller/task pair -- lets split them out + list($controllerName, $task) = explode('.', $cmd); + + // Define the controller name and path + $controllerName = strtolower($controllerName); + $controllerPath = JPATH_COMPONENT.DS.'controllers'.DS.$controllerName.'.php'; + + // If the controller file path exists, include it ... else lets die with a 500 error + if (file_exists($controllerPath)) { + require_once($controllerPath); + } else { + JError::raiseError(500, 'Invalid Controller'); + } +} +else +{ + // Base controller, just set the task :) + $controllerName = null; + $task = $cmd; +} + +// Set the name for the controller and instantiate it +$controllerClass = 'MediaController'.ucfirst($controllerName); +if (class_exists($controllerClass)) { + $controller = new $controllerClass(); +} else { + JError::raiseError(500, 'Invalid Controller Class'); +} + +// Perform the Request task +$controller->execute($task); + +// Redirect if set by the controller +$controller->redirect(); diff --git a/oss/joomla/trunk/administrator/components/com_media/media.xml b/oss/joomla/trunk/administrator/components/com_media/media.xml new file mode 100644 index 00000000..a47c39db --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/media.xml @@ -0,0 +1,12 @@ + + + Media Manager + 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 site media + diff --git a/oss/joomla/trunk/administrator/components/com_media/models/index.html b/oss/joomla/trunk/administrator/components/com_media/models/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/models/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/models/list.php b/oss/joomla/trunk/administrator/components/com_media/models/list.php new file mode 100644 index 00000000..6420a4b7 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/models/list.php @@ -0,0 +1,194 @@ +setState('folder', $folder); + + $parent = str_replace("\\", "/", dirname($folder)); + $parent = ($parent == '.') ? null : $parent; + $this->setState('parent', $parent); + $set = true; + } + return parent::getState($property); + } + + function getImages() + { + $list = $this->getList(); + return $list['images']; + } + + function getFolders() + { + $list = $this->getList(); + return $list['folders']; + } + + function getDocuments() + { + $list = $this->getList(); + return $list['docs']; + } + + /** + * Build imagelist + * + * @param string $listFolder The image directory to display + * @since 1.5 + */ + function getList() + { + static $list; + + // Only process the list once per request + if (is_array($list)) { + return $list; + } + + // Get current path from request + $current = $this->getState('folder'); + + // If undefined, set to empty + if ($current == 'undefined') { + $current = ''; + } + + // Initialize variables + if (strlen($current) > 0) { + $basePath = COM_MEDIA_BASE.DS.$current; + } else { + $basePath = COM_MEDIA_BASE; + } + $mediaBase = str_replace(DS, '/', COM_MEDIA_BASE.'/'); + + $images = array (); + $folders = array (); + $docs = array (); + + // Get the list of files and folders from the given folder + $fileList = JFolder::files($basePath); + $folderList = JFolder::folders($basePath); + + // Iterate over the files if they exist + if ($fileList !== false) { + foreach ($fileList as $file) + { + if (is_file($basePath.DS.$file) && substr($file, 0, 1) != '.' && strtolower($file) !== 'index.html') { + $tmp = new JObject(); + $tmp->name = $file; + $tmp->path = str_replace(DS, '/', JPath::clean($basePath.DS.$file)); + $tmp->path_relative = str_replace($mediaBase, '', $tmp->path); + $tmp->size = filesize($tmp->path); + + $ext = strtolower(JFile::getExt($file)); + switch ($ext) + { + // Image + case 'jpg': + case 'png': + case 'gif': + case 'xcf': + case 'odg': + case 'bmp': + case 'jpeg': + $info = @getimagesize($tmp->path); + $tmp->width = @$info[0]; + $tmp->height = @$info[1]; + $tmp->type = @$info[2]; + $tmp->mime = @$info['mime']; + + $filesize = MediaHelper::parseSize($tmp->size); + + if (($info[0] > 60) || ($info[1] > 60)) { + $dimensions = MediaHelper::imageResize($info[0], $info[1], 60); + $tmp->width_60 = $dimensions[0]; + $tmp->height_60 = $dimensions[1]; + } else { + $tmp->width_60 = $tmp->width; + $tmp->height_60 = $tmp->height; + } + + if (($info[0] > 16) || ($info[1] > 16)) { + $dimensions = MediaHelper::imageResize($info[0], $info[1], 16); + $tmp->width_16 = $dimensions[0]; + $tmp->height_16 = $dimensions[1]; + } else { + $tmp->width_16 = $tmp->width; + $tmp->height_16 = $tmp->height; + } + $images[] = $tmp; + break; + // Non-image document + default: + $iconfile_32 = JPATH_ADMINISTRATOR.DS."components".DS."com_media".DS."images".DS."mime-icon-32".DS.$ext.".png"; + if (file_exists($iconfile_32)) { + $tmp->icon_32 = "components/com_media/images/mime-icon-32/".$ext.".png"; + } else { + $tmp->icon_32 = "components/com_media/images/con_info.png"; + } + $iconfile_16 = JPATH_ADMINISTRATOR.DS."components".DS."com_media".DS."images".DS."mime-icon-16".DS.$ext.".png"; + if (file_exists($iconfile_16)) { + $tmp->icon_16 = "components/com_media/images/mime-icon-16/".$ext.".png"; + } else { + $tmp->icon_16 = "components/com_media/images/con_info.png"; + } + $docs[] = $tmp; + break; + } + } + } + } + + // Iterate over the folders if they exist + if ($folderList !== false) { + foreach ($folderList as $folder) { + $tmp = new JObject(); + $tmp->name = basename($folder); + $tmp->path = str_replace(DS, '/', JPath::clean($basePath.DS.$folder)); + $tmp->path_relative = str_replace($mediaBase, '', $tmp->path); + $count = MediaHelper::countFiles($tmp->path); + $tmp->files = $count[0]; + $tmp->folders = $count[1]; + + $folders[] = $tmp; + } + } + + $list = array('folders' => $folders, 'docs' => $docs, 'images' => $images); + + return $list; + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/models/manager.php b/oss/joomla/trunk/administrator/components/com_media/models/manager.php new file mode 100644 index 00000000..48a3469a --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/models/manager.php @@ -0,0 +1,133 @@ +setState('folder', $folder); + + $parent = str_replace("\\", "/", dirname($folder)); + $parent = ($parent == '.') ? null : $parent; + $this->setState('parent', $parent); + $set = true; + } + return parent::getState($property); + } + + /** + * Image Manager Popup + * + * @param string $listFolder The image directory to display + * @since 1.5 + */ + function getFolderList($base = null) + { + global $mainframe; + + // Get some paths from the request + if (empty($base)) { + $base = COM_MEDIA_BASE; + } + + // Get the list of folders + jimport('joomla.filesystem.folder'); + $folders = JFolder::folders($base, '.', true, true); + + // Load appropriate language files + $lang = & JFactory::getLanguage(); + $lang->load('', JPATH_ADMINISTRATOR); + $lang->load(JRequest::getCmd( 'option' ), JPATH_ADMINISTRATOR); + + $document =& JFactory::getDocument(); + $document->setTitle(JText::_('Insert Image')); + + // Build the array of select options for the folder list + $options[] = JHTML::_('select.option', "","/"); + foreach ($folders as $folder) { + $folder = str_replace(COM_MEDIA_BASE, "", $folder); + $value = substr($folder, 1); + $text = str_replace(DS, "/", $folder); + $options[] = JHTML::_('select.option', $value, $text); + } + + // Sort the folder list array + if (is_array($options)) { + sort($options); + } + + // Create the drop-down folder select list + $list = JHTML::_('select.genericlist', $options, 'folderlist', "class=\"inputbox\" size=\"1\" onchange=\"ImageManager.setFolder(this.options[this.selectedIndex].value)\" ", 'value', 'text', $base); + return $list; + } + + function getFolderTree($base = null) + { + // Get some paths from the request + if (empty($base)) { + $base = COM_MEDIA_BASE; + } + $mediaBase = str_replace(DS, '/', COM_MEDIA_BASE.'/'); + + // Get the list of folders + jimport('joomla.filesystem.folder'); + $folders = JFolder::folders($base, '.', true, true); + + $tree = array(); + foreach ($folders as $folder) + { + $folder = str_replace(DS, '/', $folder); + $name = substr($folder, strrpos($folder, '/') + 1); + $relative = str_replace($mediaBase, '', $folder); + $absolute = $folder; + $path = explode('/', $relative); + $node = (object) array('name' => $name, 'relative' => $relative, 'absolute' => $absolute); + + $tmp = &$tree; + for ($i=0,$n=count($path); $i<$n; $i++) + { + if (!isset($tmp['children'])) { + $tmp['children'] = array(); + } + if ($i == $n-1) { + // We need to place the node + $tmp['children'][$relative] = array('data' =>$node, 'children' => array()); + break; + } + if (array_key_exists($key = implode('/', array_slice($path, 0, $i+1)), $tmp['children'])) { + $tmp = &$tmp['children'][$key]; + } + } + } + $tree['data'] = (object) array('name' => JText::_('Media'), 'relative' => '', 'absolute' => $base); + return $tree; + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/views/images/index.html b/oss/joomla/trunk/administrator/components/com_media/views/images/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/images/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/views/images/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_media/views/images/tmpl/default.php new file mode 100644 index 00000000..e5c1d78c --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/images/tmpl/default.php @@ -0,0 +1,93 @@ + + +
    + +
    +
    + + folderList; ?> + +
    +
    + + +
    +
    + + +
    + + + + + + + + + + + + + + + + + +
    + +
    +
    + + + +
    +get('allowed_media_usergroup')) + { + case '1': + $acl->addACL( 'com_media', 'upload', 'users', 'publisher' ); + break; + case '2': + $acl->addACL( 'com_media', 'upload', 'users', 'publisher' ); + $acl->addACL( 'com_media', 'upload', 'users', 'editor' ); + break; + case '3': + $acl->addACL( 'com_media', 'upload', 'users', 'publisher' ); + $acl->addACL( 'com_media', 'upload', 'users', 'editor' ); + $acl->addACL( 'com_media', 'upload', 'users', 'author' ); + break; + case '4': + $acl->addACL( 'com_media', 'upload', 'users', 'publisher' ); + $acl->addACL( 'com_media', 'upload', 'users', 'editor' ); + $acl->addACL( 'com_media', 'upload', 'users', 'author' ); + $acl->addACL( 'com_media', 'upload', 'users', 'registered' ); + break; + } ?> + +authorize('com_media', 'upload')); ?> + +
    +
    + +
    + + + +
    +
      +
    • +
    +
    + +
    + diff --git a/oss/joomla/trunk/administrator/components/com_media/views/images/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_media/views/images/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/images/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/views/images/view.html.php b/oss/joomla/trunk/administrator/components/com_media/views/images/view.html.php new file mode 100644 index 00000000..b4d34848 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/images/view.html.php @@ -0,0 +1,61 @@ +getClientId() == 1) $append = 'administrator/'; + + JHTML::_('script' , 'popup-imagemanager.js', $append .'components/com_media/assets/'); + JHTML::_('stylesheet', 'popup-imagemanager.css', $append .'components/com_media/assets/'); + if ($config->get('enable_flash', 0)) { + JHTML::_('behavior.uploader', 'file-upload', array('onAllComplete' => 'function(){ ImageManager.refreshFrame(); }')); + } + + /* + * Display form for FTP credentials? + * Don't set them here, as there are other functions called before this one if there is any file write operation + */ + jimport('joomla.client.helper'); + $ftp = !JClientHelper::hasCredentials('ftp'); + + $this->assignRef( 'session', JFactory::getSession()); + $this->assignRef( 'config', $config); + $this->assignRef( 'state', $this->get('state')); + $this->assignRef( 'folderList', $this->get('folderList')); + $this->assign('require_ftp', $ftp); + + parent::display($tpl); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_media/views/imageslist/index.html b/oss/joomla/trunk/administrator/components/com_media/views/imageslist/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/imageslist/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/views/imageslist/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_media/views/imageslist/tmpl/default.php new file mode 100644 index 00000000..687d23d7 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/imageslist/tmpl/default.php @@ -0,0 +1,26 @@ + +images) > 0 || count($this->folders) > 0) { ?> +
    + + folders); $i<$n; $i++) : + $this->setFolder($i); + echo $this->loadTemplate('folder'); + endfor; ?> + + images); $i<$n; $i++) : + $this->setImage($i); + echo $this->loadTemplate('image'); + endfor; ?> + +
    + + + + + +
    +
    + +
    +
    + diff --git a/oss/joomla/trunk/administrator/components/com_media/views/imageslist/tmpl/default_folder.php b/oss/joomla/trunk/administrator/components/com_media/views/imageslist/tmpl/default_folder.php new file mode 100644 index 00000000..21bf71dd --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/imageslist/tmpl/default_folder.php @@ -0,0 +1,6 @@ + + diff --git a/oss/joomla/trunk/administrator/components/com_media/views/imageslist/tmpl/default_image.php b/oss/joomla/trunk/administrator/components/com_media/views/imageslist/tmpl/default_image.php new file mode 100644 index 00000000..0616a8d5 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/imageslist/tmpl/default_image.php @@ -0,0 +1,6 @@ + + diff --git a/oss/joomla/trunk/administrator/components/com_media/views/imageslist/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_media/views/imageslist/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/imageslist/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/views/imageslist/view.html.php b/oss/joomla/trunk/administrator/components/com_media/views/imageslist/view.html.php new file mode 100644 index 00000000..8fc682a2 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/imageslist/view.html.php @@ -0,0 +1,73 @@ +getClientId() == 1) $append = 'administrator/'; + + JHTML::_('behavior.mootools'); + JHTML::_('stylesheet', 'popup-imagelist.css', $append .'components/com_media/assets/'); + + $document =& JFactory::getDocument(); + $document->addScriptDeclaration("var ImageManager = window.parent.ImageManager;"); + + $this->assign('baseURL', COM_MEDIA_BASEURL); + $this->assignRef('images', $this->get('images')); + $this->assignRef('folders', $this->get('folders')); + $this->assignRef('state', $this->get('state')); + + parent::display($tpl); + } + + + function setFolder($index = 0) + { + if (isset($this->folders[$index])) { + $this->_tmp_folder = &$this->folders[$index]; + } else { + $this->_tmp_folder = new JObject; + } + } + + function setImage($index = 0) + { + if (isset($this->images[$index])) { + $this->_tmp_img = &$this->images[$index]; + } else { + $this->_tmp_img = new JObject; + } + } +} diff --git a/oss/joomla/trunk/administrator/components/com_media/views/media/index.html b/oss/joomla/trunk/administrator/components/com_media/views/media/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/media/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/views/media/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_media/views/media/tmpl/default.php new file mode 100644 index 00000000..c87f0892 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/media/tmpl/default.php @@ -0,0 +1,83 @@ + + + + + + +
    +
    + +
    + loadTemplate('folders'); ?> +
    +
    + require_ftp): ?> +
    +
    + + + + + + + + + + + + + +
    + + + +
    + + + +
    +
    +
    + + +
    +
    + +
    + / + + + +
    +
    + +
    +
    + +
    + +
    + + + +
    + + + user->authorize('com_media', 'upload')); ?> + +
    +
    + [  config->get('upload_maxsize') / 1000000); ?>M ] +
    + + + +
    +
      +
    • +
    +
    + +
    + +
    diff --git a/oss/joomla/trunk/administrator/components/com_media/views/media/tmpl/default_folders.php b/oss/joomla/trunk/administrator/components/com_media/views/media/tmpl/default_folders.php new file mode 100644 index 00000000..5e2291dd --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/media/tmpl/default_folders.php @@ -0,0 +1,6 @@ + +
      folders_id; ?>> +folders['children'] as $folder) : ?> +
    • name; ?>getFolderLevel($folder); ?>
    • + +
    diff --git a/oss/joomla/trunk/administrator/components/com_media/views/media/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_media/views/media/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/media/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/views/media/view.html.php b/oss/joomla/trunk/administrator/components/com_media/views/media/view.html.php new file mode 100644 index 00000000..e7ab7fef --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/media/view.html.php @@ -0,0 +1,133 @@ +getUserStateFromRequest('media.list.layout', 'layout', 'thumbs', 'word'); + + $listStyle = " + + "; + + $document =& JFactory::getDocument(); + $document->setBuffer($listStyle, 'modules', 'submenu'); + + JHTML::_('behavior.mootools'); + $document->addScript('components/com_media/assets/mediamanager.js'); + $document->addStyleSheet('components/com_media/assets/mediamanager.css'); + + JHTML::_('behavior.modal'); + $document->addScriptDeclaration(" + window.addEvent('domready', function() { + document.preview = SqueezeBox; + });"); + + JHTML::script('mootree.js'); + JHTML::stylesheet('mootree.css'); + + if ($config->get('enable_flash', 0)) { + JHTML::_('behavior.uploader', 'file-upload', array('onAllComplete' => 'function(){ MediaManager.refreshFrame(); }')); + } + + if(DS == '\\') + { + $base = str_replace(DS,"\\\\",COM_MEDIA_BASE); + } else { + $base = COM_MEDIA_BASE; + } + + $js = " + var basepath = '".$base."'; + var viewstyle = '".$style."'; + " ; + $document->addScriptDeclaration($js); + + /* + * Display form for FTP credentials? + * Don't set them here, as there are other functions called before this one if there is any file write operation + */ + jimport('joomla.client.helper'); + $ftp = !JClientHelper::hasCredentials('ftp'); + + $this->assignRef('session', JFactory::getSession()); + $this->assignRef('config', $config); + $this->assignRef('state', $this->get('state')); + $this->assign('require_ftp', $ftp); + $this->assign('folders_id', ' id="media-tree"'); + $this->assign('folders', $this->get('folderTree')); + + $user =& JFactory::getUser(); + $this->assignRef('user', $user); + + // Set the toolbar + $this->_setToolBar(); + + parent::display($tpl); + echo JHTML::_('behavior.keepalive'); + } + + function _setToolBar() + { + // Get the toolbar object instance + $bar =& JToolBar::getInstance('toolbar'); + + // Set the titlebar text + JToolBarHelper::title( JText::_( 'Media Manager' ), 'mediamanager.png'); + + // Add a delete button + $title = JText::_('Delete'); + $dhtml = " + + $title"; + $bar->appendButton( 'Custom', $dhtml, 'delete' ); + + // Add a popup configuration button + JToolBarHelper::help( 'screen.mediamanager' ); + } + + function getFolderLevel($folder) + { + $this->folders_id = null; + $txt = null; + if (isset($folder['children']) && count($folder['children'])) { + $tmp = $this->folders; + $this->folders = $folder; + $txt = $this->loadTemplate('folders'); + $this->folders = $tmp; + } + return $txt; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_media/views/medialist/index.html b/oss/joomla/trunk/administrator/components/com_media/views/medialist/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/medialist/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/default.php new file mode 100644 index 00000000..e69de29b diff --git a/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/details.php b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/details.php new file mode 100644 index 00000000..714494d3 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/details.php @@ -0,0 +1,39 @@ + +
    +
    + + + + + + + + + + + + loadTemplate('up'); ?> + + folders); $i<$n; $i++) : + $this->setFolder($i); + echo $this->loadTemplate('folder'); + endfor; ?> + + documents); $i<$n; $i++) : + $this->setDoc($i); + echo $this->loadTemplate('doc'); + endfor; ?> + + images); $i<$n; $i++) : + $this->setImage($i); + echo $this->loadTemplate('img'); + endfor; ?> + + +
    +
    + + + + +
    diff --git a/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/details_doc.php b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/details_doc.php new file mode 100644 index 00000000..7cc49269 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/details_doc.php @@ -0,0 +1,20 @@ + + + + + <?php echo $this->_tmp_doc->name; ?> + + + _tmp_doc->name; ?> + +   + + + + _tmp_doc->size); ?> + + + <?php echo JText::_( 'Delete' ); ?> + + + diff --git a/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/details_folder.php b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/details_folder.php new file mode 100644 index 00000000..14a30c93 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/details_folder.php @@ -0,0 +1,20 @@ + + + + + <?php echo $this->_tmp_folder->name; ?> + + + _tmp_folder->name; ?> + +   + + +   + + + + <?php echo JText::_( 'Delete' ); ?> + + + diff --git a/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/details_img.php b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/details_img.php new file mode 100644 index 00000000..2ca4eadf --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/details_img.php @@ -0,0 +1,19 @@ + + + + <?php echo $this->_tmp_img->name; ?> - <?php echo MediaHelper::parseSize($this->_tmp_img->size); ?> + + + escape( $this->_tmp_img->name); ?> + + + _tmp_img->width; ?> x _tmp_img->height; ?> + + + _tmp_img->size); ?> + + + <?php echo JText::_( 'Delete' ); ?> + + + diff --git a/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/details_up.php b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/details_up.php new file mode 100644 index 00000000..58023697 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/details_up.php @@ -0,0 +1,13 @@ + + + + + .. + + + .. + +   +   +   + diff --git a/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/thumbs.php b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/thumbs.php new file mode 100644 index 00000000..58f03bfb --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/thumbs.php @@ -0,0 +1,26 @@ + +
    +
    + loadTemplate('up'); ?> + + folders); $i<$n; $i++) : + $this->setFolder($i); + echo $this->loadTemplate('folder'); + endfor; ?> + + documents); $i<$n; $i++) : + $this->setDoc($i); + echo $this->loadTemplate('doc'); + endfor; ?> + + images); $i<$n; $i++) : + $this->setImage($i); + echo $this->loadTemplate('img'); + endfor; ?> + +
    + + + + +
    \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/thumbs_doc.php b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/thumbs_doc.php new file mode 100644 index 00000000..cc025f41 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/thumbs_doc.php @@ -0,0 +1,16 @@ + +
    +
    +
    + + <?php echo $this->_tmp_doc->name; ?> +
    +
    +
    + <?php echo JText::_( 'Delete' ); ?> + +
    +
    + _tmp_doc->name; ?> +
    +
    diff --git a/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/thumbs_folder.php b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/thumbs_folder.php new file mode 100644 index 00000000..32da61a4 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/thumbs_folder.php @@ -0,0 +1,16 @@ + + diff --git a/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/thumbs_img.php b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/thumbs_img.php new file mode 100644 index 00000000..c7c1ee47 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/thumbs_img.php @@ -0,0 +1,18 @@ + + diff --git a/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/thumbs_up.php b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/thumbs_up.php new file mode 100644 index 00000000..1e4397be --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/medialist/tmpl/thumbs_up.php @@ -0,0 +1,15 @@ + +
    +
    +
    + + .. +
    +
    +
    +   +
    +
    + .. +
    +
    diff --git a/oss/joomla/trunk/administrator/components/com_media/views/medialist/view.html.php b/oss/joomla/trunk/administrator/components/com_media/views/medialist/view.html.php new file mode 100644 index 00000000..92cc549a --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_media/views/medialist/view.html.php @@ -0,0 +1,90 @@ +getUserStateFromRequest('media.list.layout', 'layout', 'thumbs', 'word'); + + JHTML::_('behavior.mootools'); + + $document = &JFactory::getDocument(); + $document->addStyleSheet('components/com_media/assets/medialist-'.$style.'.css'); + + $document->addScriptDeclaration(" + window.addEvent('domready', function() { + window.top.document.updateUploader && window.top.document.updateUploader(); + $$('a.img-preview').each(function(el) { + el.addEvent('click', function(e) { + new Event(e).stop(); + window.top.document.preview.fromElement(el); + }); + }); + });"); + + $this->assign('baseURL', JURI::root()); + $this->assignRef('images', $this->get('images')); + $this->assignRef('documents', $this->get('documents')); + $this->assignRef('folders', $this->get('folders')); + $this->assignRef('state', $this->get('state')); + + parent::display($tpl); + } + + function setFolder($index = 0) + { + if (isset($this->folders[$index])) { + $this->_tmp_folder = &$this->folders[$index]; + } else { + $this->_tmp_folder = new JObject; + } + } + + function setImage($index = 0) + { + if (isset($this->images[$index])) { + $this->_tmp_img = &$this->images[$index]; + } else { + $this->_tmp_img = new JObject; + } + } + + function setDoc($index = 0) + { + if (isset($this->documents[$index])) { + $this->_tmp_doc = &$this->documents[$index]; + } else { + $this->_tmp_doc = new JObject; + } + } +} diff --git a/oss/joomla/trunk/administrator/components/com_menus/admin.menus.php b/oss/joomla/trunk/administrator/components/com_menus/admin.menus.php new file mode 100644 index 00000000..b832c2ba --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/admin.menus.php @@ -0,0 +1,24 @@ + 'viewMenus') ); +$controller->registerTask('apply', 'save'); +$controller->execute( JRequest::getCmd( 'task' ) ); +$controller->redirect(); \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/images/blank.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/images/blank.gif new file mode 100644 index 00000000..5c37109b Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/images/blank.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/images/blankbottom.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/images/blankbottom.gif new file mode 100644 index 00000000..e1b74894 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/images/blankbottom.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/images/empty.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/images/empty.gif new file mode 100644 index 00000000..b5cf5237 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/images/empty.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/images/folder.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/images/folder.gif new file mode 100644 index 00000000..08216269 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/images/folder.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/images/folderopen.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/images/folderopen.gif new file mode 100644 index 00000000..8ad32984 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/images/folderopen.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/images/gradient.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/images/gradient.gif new file mode 100644 index 00000000..fe9681ae Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/images/gradient.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/images/index.html b/oss/joomla/trunk/administrator/components/com_menus/assets/images/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/assets/images/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/images/join.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/images/join.gif new file mode 100644 index 00000000..8d495d65 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/images/join.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/images/joinbottom.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/images/joinbottom.gif new file mode 100644 index 00000000..90ce82fc Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/images/joinbottom.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/images/line.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/images/line.gif new file mode 100644 index 00000000..d81ee8b9 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/images/line.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/images/minus.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/images/minus.gif new file mode 100644 index 00000000..e9a0af71 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/images/minus.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/images/minusbottom.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/images/minusbottom.gif new file mode 100644 index 00000000..d9062406 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/images/minusbottom.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/images/node.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/images/node.gif new file mode 100644 index 00000000..651faa57 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/images/node.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/images/nolines_minus.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/images/nolines_minus.gif new file mode 100644 index 00000000..d87a0914 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/images/nolines_minus.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/images/nolines_plus.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/images/nolines_plus.gif new file mode 100644 index 00000000..a7da85ea Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/images/nolines_plus.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/images/page.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/images/page.gif new file mode 100644 index 00000000..4866cc43 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/images/page.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/images/plus.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/images/plus.gif new file mode 100644 index 00000000..c24da3e2 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/images/plus.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/images/plusbottom.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/images/plusbottom.gif new file mode 100644 index 00000000..cb3c72df Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/images/plusbottom.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/index.html b/oss/joomla/trunk/administrator/components/com_menus/assets/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/assets/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/blank.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/blank.gif new file mode 100644 index 00000000..957d2fc1 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/blank.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/blankbottom.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/blankbottom.gif new file mode 100644 index 00000000..a1ec37ea Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/blankbottom.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/empty.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/empty.gif new file mode 100644 index 00000000..b5cf5237 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/empty.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/folder.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/folder.gif new file mode 100644 index 00000000..5886ddd9 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/folder.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/folderopen.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/folderopen.gif new file mode 100644 index 00000000..8ad32984 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/folderopen.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/gradient.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/gradient.gif new file mode 100644 index 00000000..ca4e85a0 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/gradient.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/index.html b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/join.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/join.gif new file mode 100644 index 00000000..ec0b8c1f Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/join.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/joinbottom.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/joinbottom.gif new file mode 100644 index 00000000..013d39df Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/joinbottom.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/line.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/line.gif new file mode 100644 index 00000000..f7fecc3e Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/line.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/minus.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/minus.gif new file mode 100644 index 00000000..9b165fce Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/minus.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/minusbottom.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/minusbottom.gif new file mode 100644 index 00000000..a621a705 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/minusbottom.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/node.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/node.gif new file mode 100644 index 00000000..915651fc Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/node.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/nolines_minus.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/nolines_minus.gif new file mode 100644 index 00000000..d8c2618c Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/nolines_minus.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/nolines_plus.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/nolines_plus.gif new file mode 100644 index 00000000..095c8a39 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/nolines_plus.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/page.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/page.gif new file mode 100644 index 00000000..dd7f1877 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/page.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/plus.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/plus.gif new file mode 100644 index 00000000..2b727e03 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/plus.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/plusbottom.gif b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/plusbottom.gif new file mode 100644 index 00000000..378a97d3 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_menus/assets/rtl_images/plusbottom.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/type.css b/oss/joomla/trunk/administrator/components/com_menus/assets/type.css new file mode 100644 index 00000000..2df16a62 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/assets/type.css @@ -0,0 +1,59 @@ +/* ---- Basic tree styles ------------------- */ + +.jtree ul, .jtree li { margin: 0; padding: 0; list-style: none; } + +/* ---- Tree layout ------------------------- */ + +.jtree ul { margin-left: 20px; } + +.jtree li { background: url(images/line.gif) repeat-y; } +.jtree li.last { background-image: none; } + +.jtree div { + height: 100%; padding: 4px 0 4px 40px; + background-repeat: no-repeat; background-position: left bottom; +} +.jtree span { + display: block; position: absolute; width: 18px; height: 18px; margin: 0 0 0 -20px; + background-repeat: no-repeat; border: 0 none; +} + +.jtree a {} + +.jtree .root { padding-left: 20px;} +.jtree .root span { background: url(images/base.gif) no-repeat left bottom; } + +.jtree .node { background-image: url(images/plus.gif); } +.jtree .node span { background-image: url(images/folder.gif); } +.jtree li.last .node { background-image: url(images/plusbottom.gif); } +.jtree li.last .node span { background-image: url(images/folder.gif); } + +.jtree .node-open { background-image: url(images/minus.gif); } +.jtree .node-open span { background-image: url(images/folderopen.gif); } +.jtree li.last .node-open { background-image: url(images/minusbottom.gif); } +.jtree li.last .node-open span { background-image: url(images/folderopen.gif); } + +.jtree .leaf { background-image: url(images/join.gif); } +.jtree .leaf span { background-image: url(images/page.gif); } +.jtree li.last .leaf { background-image: url(images/joinbottom.gif); } +.jtree li.last .leaf span { background-image: url(images/page.gif); } + +.jtree .base { background-image: url(images/blank.gif); } +.jtree .base span { background-image: url(images/folder.gif); } +.jtree li.last .base { background-image: url(images/blankbottom.gif); } +.jtree li.last .base span { background-image: url(images/folder.gif); } + +.jtree ul .node { padding: 4px 0 4px 20px; } +.jtree ul .node span { display: none; } +.jtree ul .node-open { padding: 4px 0 4px 20px; } +.jtree ul .node-open span { display: none; } +.jtree ul li.last .node span { display: none; } +.jtree ul li.last .node span { padding: 4px 0 4px 20px; } +.jtree ul li.last .node-open span { display: none; } +.jtree ul li.last .node-open span { padding: 4px 0 4px 20px; } + +/* ---- Specific layout ------------------------- */ +#internal-node {} +#external-node {} +#separator-node {} +#link-node {} diff --git a/oss/joomla/trunk/administrator/components/com_menus/assets/type_rtl.css b/oss/joomla/trunk/administrator/components/com_menus/assets/type_rtl.css new file mode 100644 index 00000000..3ff8f92b --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/assets/type_rtl.css @@ -0,0 +1,59 @@ +/* ---- Basic tree styles ------------------- */ + +.jtree ul, .jtree li { margin: 0; padding: 0; list-style: none; } + +/* ---- Tree layout ------------------------- */ + +.jtree ul { margin-right: 20px; } + +.jtree li { background: url(rtl_images/line.gif) right repeat-y; } +.jtree li.last { background-image: none; } + +.jtree div { + height: 100%; padding: 4px 40px 4px 0px; + background-repeat: no-repeat; background-position: right bottom; +} +.jtree span { + display: block; position: absolute; width: 18px; height: 18px; margin: 0 -20px 0 0px; + background-repeat: no-repeat; border: 0 none; +} + +.jtree a {} + +.jtree .root { padding-right: 20px;} +.jtree .root span { background: url(rtl_images/base.gif) no-repeat right bottom; } + +.jtree .node { background-image: url(rtl_images/plus.gif); } +.jtree .node span { background-image: url(rtl_images/folder.gif); } +.jtree li.last .node { background-image: url(rtl_images/plusbottom.gif); } +.jtree li.last .node span { background-image: url(rtl_images/folder.gif); } + +.jtree .node-open { background-image: url(rtl_images/minus.gif); } +.jtree .node-open span { background-image: url(rtl_images/folderopen.gif); } +.jtree li.last .node-open { background-image: url(rtl_images/minusbottom.gif); } +.jtree li.last .node-open span { background-image: url(rtl_images/folderopen.gif); } + +.jtree .leaf { background-image: url(rtl_images/join.gif); } +.jtree .leaf span { background-image: url(rtl_images/page.gif); } +.jtree li.last .leaf { background-image: url(rtl_images/joinbottom.gif); } +.jtree li.last .leaf span { background-image: url(rtl_images/page.gif); } + +.jtree .base { background-image: url(rtl_images/blank.gif); } +.jtree .base span { background-image: url(rtl_images/folder.gif); } +.jtree li.last .base { background-image: url(rtl_images/blankbottom.gif); } +.jtree li.last .base span { background-image: url(rtl_images/folder.gif); } + +.jtree ul .node { padding: 4px 20px 4px 0px;} +.jtree ul .node span { display: none; } +.jtree ul .node-open { padding: 4px 20px 4px 0px; } +.jtree ul .node-open span { display: none; } +.jtree ul li.last .node span { display: none; } +.jtree ul li.last .node span { padding: 4px 20px 4px 0px; } +.jtree ul li.last .node-open span { display: none; } +.jtree ul li.last .node-open span { padding: 4px 20px 4px 0px; } + +/* ---- Specific layout ------------------------- */ +#internal-node {} +#external-node {} +#separator-node {} +#link-node {} diff --git a/oss/joomla/trunk/administrator/components/com_menus/classes/ilink.php b/oss/joomla/trunk/administrator/components/com_menus/classes/ilink.php new file mode 100644 index 00000000..75586069 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/classes/ilink.php @@ -0,0 +1,390 @@ +_cid = "&cid[]=".$id; + } else { + $this->_cid = null; + } + + if ($menutype) { + $this->_menutype = "&menutype=".$menutype; + } else { + $this->_menutype = null; + } + + $this->_com = preg_replace( '#\W#', '', $component ); + + // Build the tree + if (!$this->_getOptions($this->_getXML(JPATH_SITE.'/components/com_'.$this->_com.'/metadata.xml', 'menu'), $this->_root)) { + if (!$this->_getViews()) + { + // Default behavior + } + } + } + + /** + * Returns the component + * @return string + */ + function getComponent() + { + return $this->_com; + } + + function getTree() + { + $depth = 0; + $this->reset(); + $class = null; + + // Recurse through children if they exist + while ($this->_current->hasChildren()) + { + $this->_output .= '
      '; + $children = $this->_current->getChildren(); + for ($i=0,$n=count($children);$i<$n;$i++) + { + $this->_current = & $children[$i]; + $this->renderLevel($depth,($i==$n-1)?1:0); + } + $this->_output .= '
    '; + } + return $this->_output; + } + + function renderLevel($depth, $isLast=0) + { + $depth++; + if (!isset($this->_depthHash[$depth])) { + $this->_depthHash[$depth] = 0; + } + $this->_depthHash[$depth]++; + + if ($this->_current->hasChildren()) { + $classes = 'node-open'; + } else { + $classes = 'leaf'; + } + + if ($isLast) { + $last = ' class="last"'; + } else { + $last = ''; + } + + $parent = & $this->_current->getParent(); + // Print the item + $this->_output .= "\n"; + + // Print the url + if ($this->_current->hasChildren()) { + $this->_output .= ""; + } else { + $this->_output .= ""; + } + + // Recurse through children if they exist + while ($this->_current->hasChildren()) + { + $this->_output .= "
      \n"; + $children = $this->_current->getChildren(); + for ($i=0,$n=count($children);$i<$n;$i++) + { + $this->_current = & $children[$i]; + $this->renderLevel($depth,($i==$n-1)?1:0); + } + $this->_output .= "
    \n"; + } + + // Close item + $this->_output .= "\n"; + } + + function _getOptions($e, &$parent, $purl=null) + { + if (!$purl) { + $purl = 'url[option]=com_'.$this->_com; + + // No metadata xml file in component root + if (!$e) { + return false; + } + } + + // Does the metadata file say no options available? + if ($e->attributes('options') == 'none') { + $node =& new iLinkNode($e->attributes('name'), $purl, $e->attributes('msg')); + $parent->addChild($node); + return true; + } + + // Do we have defined options available? + $options = &$e->getElementByPath('options'); + if ($options) { + $children = $options->children(); + foreach ($children as $child) + { + if ($child->name() == 'option') { + $url = $purl.'&url['.$options->attributes('var').']='.$child->attributes('value'); + $node =& new iLinkNode($child->attributes('name'), $url, $child->attributes('msg')); + $parent->addChild($node); + } elseif ($child->name() == 'default') { + $node =& new iLinkNode($child->attributes('name'), $purl, $child->attributes('msg')); + $parent->addChild($node); + } + } + return true; + } else { + return false; + } + } + + /** + * @access private + */ + function _getViews() + { + $return = false; + $path = JPATH_SITE.DS.'components'.DS.'com_'.$this->_com.DS.'views'; + + if (JFolder::exists($path)) { + $views = JFolder::folders($path); + } else { + return $return; + } + + if (is_array($views) && count($views)) + { + //$this->addChild(new iLinkNode('Views', null, 'Select the view'), true); + $return = true; + foreach ($views as $view) + { + if (strpos($view, '_') === false) { + // Load view metadata if it exists + $xmlpath = $path.DS.$view.DS.'metadata.xml'; + if (JFile::exists($xmlpath)) { + $data = $this->_getXML($xmlpath, 'view'); + } else { + $data = null; + } + + $url = 'url[option]=com_'.$this->_com.'&url[view]='.$view; + if ($data) { + if ($data->attributes('hidden') != 'true') { + $m = $data->getElementByPath('message'); + if ($m) { + $message = $m->data(); + } + $node =& new iLinkNode($data->attributes('title'), $url, $message); + $this->addChild($node); + if ($options = $data->getElementByPath('options')) { + $this->_getOptions($data, $node, $url); + } else { + $this->_getLayouts(dirname($xmlpath), $node); + } + } + } else { + $onclick = null; + $node =& new iLinkNode(ucfirst($view), $url); + $this->addChild($node); + $this->_getLayouts(dirname($xmlpath), $node); + } + } + } + } + return $return; + } + + /** + * @access private + */ + function _getLayouts($path, &$node) + { + $return = false; + $folder = $path.DS.'tmpl'; + if (is_dir( $folder )) + { + $files = JFolder::files($folder, '.php$'); + if (count($files)) { + foreach ($files as $file) + { + if (strpos($file, '_') === false) { + // Load view metadata if it exists + $layout = JFile::stripext($file); + $xmlpath = $path.DS.'tmpl'.DS.$layout.'.xml'; + if (JFile::exists($xmlpath)) { + $data = $this->_getXML($xmlpath, 'layout'); + } else { + $data = null; + } + + if ($layout != 'default') { + $url = 'url[option]=com_'.$this->_com.'&url[view]='.basename($path).'&url[layout]='.$layout; + } else { + $url = 'url[option]=com_'.$this->_com.'&url[view]='.basename($path); + } + if ($data) { + if ($data->attributes('hidden') != 'true') { + $m = $data->getElementByPath('message'); + if ($m) { + $message = $m->data(); + } + $child =& new iLinkNode($data->attributes('title'), $url, $message); + $node->addChild($child); + } + } else { + // Add default info for the layout + $child =& new iLinkNode(ucfirst($layout).' '.JText::_('Layout'), $url); + $node->addChild($child); + } + } + } + } + } + return $return; + } + + function _getXML($path, $xpath='control') + { + // Initialize variables + $result = null; + // load the xml metadata + if (file_exists( $path )) { + $xml =& JFactory::getXMLParser('Simple'); + if ($xml->loadFile($path)) { + if (isset( $xml->document )) { + $result = $xml->document->getElementByPath($xpath); + } + } + return $result; + } + return $result; + } + + function _findNodes(&$node) + { + foreach ($node->children() as $step) + { + /* + * For each child we need to see if it is an include and if so we + * need to get those children and process them as well (break out into + * another method). Then we need to create the objects in the _steps + * array for each child of type step. For now we aren't going to handle + * nested includes. + */ + if ($step->name() == 'include') { + // Handle include + $this->_getIncludedSteps($step, $node); + } elseif ($step->name() == 'step') { + // Include step to array + $this->_nodes[] = $step; + } else { + // Do nothing + continue; + } + } + } + + function _getIncludedSteps($include, &$parent) + { + $tags = array(); + $source = $include->attributes('source'); + $path = $include->attributes('path'); + + preg_match_all( "/{([A-Za-z\-_]+)}/", $source, $tags); + if (isset( $tags[1] )) { + $n = count( $tags[1] ); + for ($i=0; $i < $n; $i++) + { + $source = str_replace($tags[0][$i], @$this->_vars[$tags[1][$i]], $source); + } + } + + // load the source xml file + if (file_exists( JPATH_ROOT.$source )) + { + $xml = & JFactory::getXMLParser('Simple'); + if ($xml->loadFile(JPATH_ROOT.$source)) + { + $document = &$xml->document; + $steps = $document->getElementByPath($path); + + foreach($steps->children() as $step) + { + if ($step->name() == 'include') { + // Handle include + } elseif ($step->name() == 'step') { + // Include step to array + $node->addChild('step', $step->attributes(), $node->level()+1); + } else { + // Do nothing + continue; + } + } + } + } + } +} + +class iLinkNode extends JNode +{ + /** + * Node Title + */ + var $title = null; + + /** + * Node URL + */ + var $url = null; + + /** + * Node message + */ + var $msg = null; + + function __construct($title, $url = null, $msg = null) + { + $this->title = trim($title); + $this->url = $url; + $this->msg = trim($msg); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/classes/index.html b/oss/joomla/trunk/administrator/components/com_menus/classes/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/classes/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/config.xml b/oss/joomla/trunk/administrator/components/com_menus/config.xml new file mode 100644 index 00000000..089a28fe --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/config.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/oss/joomla/trunk/administrator/components/com_menus/controller.php b/oss/joomla/trunk/administrator/components/com_menus/controller.php new file mode 100644 index 00000000..effb106d --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/controller.php @@ -0,0 +1,797 @@ +getModel( 'Item' ); + $view =& $this->getView( 'Item' ); + $view->setModel( $model, true ); + + // Set the layout and display + $view->setLayout('type'); + $view->type(); + } + /** + * Edit menu item wizard + */ + + function type() + { + JRequest::setVar( 'edit', true ); + $model =& $this->getModel( 'Item' ); + $view =& $this->getView( 'Item' ); + $view->setModel( $model, true ); + + // Set the layout and display + $view->setLayout('type'); + $view->type(); + } + + /** + * Edits a menu item + */ + function edit() + { + JRequest::setVar( 'edit', true ); + $model =& $this->getModel( 'Item' ); + $model->checkout(); + + $view =& $this->getView( 'Item' ); + $view->setModel( $model, true ); + // Set the layout and display + $view->setLayout('form'); + $view->edit(); + } + + /** + * Saves a menu item + */ + function save() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $model =& $this->getModel( 'Item' ); + $post = JRequest::get('post'); + // allow name only to contain html + $post['name'] = JRequest::getVar( 'name', '', 'post', 'string', JREQUEST_ALLOWHTML ); + $model->setState( 'request', $post ); + + if ($model->store()) { + $msg = JText::_( 'Menu item Saved' ); + } else { + $msg = JText::_( 'Error Saving Menu item' ); + } + + $item =& $model->getItem(); + switch ( $this->_task ) { + case 'apply': + $this->setRedirect( 'index.php?option=com_menus&menutype='.$item->menutype.'&task=edit&cid[]='.$item->id.'' , $msg ); + break; + + case 'save': + default: + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$item->menutype, $msg ); + break; + } + } + + /** + * Cancels an edit operation + */ + function cancelItem() + { + global $mainframe; + + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $menutype = $mainframe->getUserStateFromRequest( 'com_menus.menutype', 'menutype', 'mainmenu', 'string' ); + + $model = $this->getModel('item'); + $model->checkin(); + + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menutype); + } + + /** + * Cancels an edit operation + */ + function cancel() + { + $this->setRedirect( 'index.php?option=com_menus'); + } + + /** + * Form for copying item(s) to a specific menu + */ + function copy() + { + $model =& $this->getModel( 'List' ); + $view =& $this->getView( 'List' ); + $view->setModel( $model, true ); + $view->copyForm(); + } + + /** + * Save the item(s) to the menu selected + */ + function doCopy() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Get some variables from the request + $menu = JRequest::getString( 'menu', '', 'post'); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + //Check to see of a menu was selected to copy the items too + if (empty($menu)) + { + $msg = JText::_('Please select a menu from the list'); + $mainframe->enqueueMessage($msg, 'message'); + return $this->execute('copy'); + } + + $model =& $this->getModel( 'List' ); + + if ($model->copy($cid, $menu)) { + $msg = JText::sprintf( 'Menu Items Copied to', count( $cid ), $menu ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Form for moving item(s) to a specific menu + */ + function move() + { + $model =& $this->getModel( 'List'); + $view =& $this->getView( 'List' ); + $view->setModel( $model, true ); + $view->moveForm(); + } + + /** + * Save the item(s) to the menu selected + */ + function doMove() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Get some variables from the request + $menu = JRequest::getVar( 'menu', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + //Check to see if a menu was selected to copy the items too + if (empty($menu)) + { + $msg = JText::_('Please select a menu from the list'); + $mainframe->enqueueMessage($msg, 'message'); + return $this->execute('move'); + } + + $model =& $this->getModel( 'List' ); + + if ($model->move($cid, $menu)) { + $msg = JText::sprintf( 'Menu Items Moved to', count( $cid ), $menu ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Save the item(s) to the menu selected + */ + function publish() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Get some variables from the request + $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + $model =& $this->getModel( 'List' ); + if ($model->setItemState($cid, 1)) { + $msg = JText::sprintf( 'Menu Items Published', count( $cid ) ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Save the item(s) to the menu selected + */ + function unpublish() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Get some variables from the request + $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + $model =& $this->getModel( 'List' ); + if ($model->setItemState($cid, 0)) { + $msg = JText::sprintf( 'Menu Items Unpublished', count( $cid ) ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Save the item(s) to the menu selected + */ + function orderup() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + if (isset($cid[0]) && $cid[0]) { + $id = $cid[0]; + } else { + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('No Items Selected') ); + return false; + } + + $model =& $this->getModel( 'List' ); + if ($model->orderItem($id, -1)) { + $msg = JText::_( 'Menu Item Moved Up' ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Save the item(s) to the menu selected + */ + function orderdown() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + if (isset($cid[0]) && $cid[0]) { + $id = $cid[0]; + } else { + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('No Items Selected') ); + return false; + } + + $model =& $this->getModel( 'List' ); + if ($model->orderItem($id, 1)) { + $msg = JText::_( 'Menu Item Moved Down' ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Save the item(s) to the menu selected + */ + function saveorder() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + $model =& $this->getModel( 'List' ); + if ($model->setOrder($cid, $menu)) { + $msg = JText::_( 'New ordering saved' ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Save the item(s) to the menu selected + */ + function accesspublic() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Get some variables from the request + $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + $model =& $this->getModel( 'List' ); + if ($model->setAccess($cid, 0)) { + $msg = JText::sprintf( 'Menu Items Set Public', count( $cid ) ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Save the item(s) to the menu selected + */ + function accessregistered() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Get some variables from the request + $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + $model =& $this->getModel( 'List' ); + if ($model->setAccess($cid, 1)) { + $msg = JText::sprintf( 'Menu Items Set Registered', count( $cid ) ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Save the item(s) to the menu selected + */ + function accessspecial() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Get some variables from the request + $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + $model =& $this->getModel( 'List' ); + if ($model->setAccess($cid, 2)) { + $msg = JText::sprintf( 'Menu Items Set Special', count( $cid ) ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Save the item(s) to the menu selected + */ + function setdefault() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Get some variables from the request + $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + if (isset($cid[0]) && $cid[0]) { + $id = $cid[0]; + } else { + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('No Items Selected') ); + return false; + } + + $item =& JTable::getInstance( 'menu' ); + $item->load($id); + if(!$item->get('published')) { + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('The Default Menu Item Must Be Published') ); + return false; + } + + $model =& $this->getModel( 'List' ); + if ($model->setHome($id)) { + $msg = JText::_( 'Default Menu Item Set' ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + function remove() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Get some variables from the request + $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + if (!count($cid)) { + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('No Items Selected') ); + return false; + } + + $model =& $this->getModel( 'List' ); + if ($n = $model->toTrash($cid)) { + $msg = JText::sprintf( 'Item(s) sent to the Trash', $n ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Save the item(s) to the menu selected + */ + function view() + { + $model =& $this->getModel( 'List' ); + $view =& $this->getView( 'List' ); + $view->setModel( $model, true ); + $view->display(); + } + + + /** + * Controller for view listing menu types and related statical info + * @param string The URL option + */ + function viewMenus() + { + + $view =& $this->getView( 'Menus'); + $model =& $this->getModel( 'Menutype' ); + $view->setModel( $model, true ); + $view->display(); + } + + + /** + * Controller for view to edit a menu type + */ + function editMenu() + { + $view =& $this->getView( 'Menus' ); + $model =& $this->getModel( 'Menutype' ); + $view->setModel( $model, true ); + $view->editForm(true,null); + + } + + /** + * Controller for view to create a menu type + */ + function addMenu() + { + $view =& $this->getView( 'Menus' ); + $model =& $this->getModel( 'Menutype' ); + $view->setModel( $model, true ); + $view->editForm(false,null); + } + + /** + * Controller for saving a menu type + */ + function saveMenu() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $id = JRequest::getVar( 'id', 0, 'post', 'int' ); + + $oldType =& JTable::getInstance('menutypes' ); + $oldType->load( $id ); + + $menuType =& JTable::getInstance('menutypes'); + $menuType->bind( JRequest::get( 'post' ) ); + + $isNew = ($menuType->id == 0); + $isChanged = ($oldType->menutype != $menuType->menutype); + + if (!$menuType->check()) { + JError::raiseWarning( 500, $menuType->getError() ); + $this->setRedirect( 'index.php?option=com_menus&task=editMenu', 'Please check your menu settings' ); + return false; + } + + if (!$menuType->store()) { + JError::raiseWarning( 500, $menuType->getError() ); + $this->setRedirect( 'index.php?option=com_menus&task=editMenu', 'Please check your menu settings' ); + return false; + } + + if ($isNew) + { + if ($title = JRequest::getVar( 'module_title', $menuType->menutype, 'post', 'string' )) + { + $module =& JTable::getInstance( 'module'); + $module->title = $title; + $module->position = 'left'; + $module->module = 'mod_mainmenu'; + $module->published = 0; + $module->iscore = 0; + $module->params = 'menutype='. $menuType->menutype; + + // check then store data in db + if (!$module->check()) { + return JError::raiseWarning( 500, $module->getError() ); + } + if (!$module->store()) { + return JError::raiseWarning( 500, $module->getError() ); + } + $module->checkin(); + $module->reorder( 'position='.$db->Quote($module->position) ); + + // module assigned to show on All pages by default + // Clean up possible garbage first + $query = 'DELETE FROM #__modules_menu WHERE moduleid = '.(int) $module->id; + $db->setQuery( $query ); + if (!$db->query()) { + return JError::raiseWarning( 500, $db->getError() ); + } + + // ToDO: Changed to become a Joomla! db-object + $query = 'INSERT INTO #__modules_menu VALUES ( '.(int) $module->id.', 0 )'; + $db->setQuery( $query ); + if (!$db->query()) { + return JError::raiseWarning( 500, $db->getError() ); + } + } + + $msg = JText::sprintf( 'New Menu created', $menuType->menutype ); + } + else if ($isChanged) + { + $oldTerm = $oldType->menutype; + $newTerm = $menuType->menutype; + + // change menutype being of all mod_mainmenu modules calling old menutype + $query = 'SELECT id' + . ' FROM #__modules' + . ' WHERE module = "mod_mainmenu"' + . ' AND params LIKE "%menutype='.$db->getEscaped($oldTerm).'%"' + ; + $db->setQuery( $query ); + $modules = $db->loadResultArray(); + + foreach ($modules as $id) + { + $row =& JTable::getInstance('module'); + $row->load( $id ); + + $row->params = str_replace( $oldTerm, $newTerm, $row->params ); + + // check then store data in db + if ( !$row->check() ) { + return JError::raiseWarning( 500, $db->getError() ); + } + if ( !$row->store() ) { + return JError::raiseWarning( 500, $db->getError() ); + } + $row->checkin(); + } + + // change menutype of all menuitems using old menutype + $query = 'UPDATE #__menu' + . ' SET menutype = '.$db->Quote($newTerm) + . ' WHERE menutype = '.$db->Quote($oldTerm) + ; + $db->setQuery( $query ); + $db->query(); + + $msg = JText::_( 'Menu Items & Modules updated' ); + } + + $this->setRedirect( 'index.php?option=com_menus', $msg ); + } + + /** + * Controller for a view to confirm the deletion of a menu type + */ + function deleteMenu() + { + $view =& $this->getView( 'Menus' ); + $model =& $this->getModel( 'Menutype' ); + $view->setModel( $model, true ); + $view->deleteForm(); + } + + /** + * Delete a menu + */ + function doDeleteMenu() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $id = JRequest::getVar( 'id', 0, '', 'int' ); + if ($id <= 0) { + JError::raiseWarning( 500, JText::_( 'Invalid ID provided' ) ); + $this->setRedirect( 'index.php?option=com_menus' ); + return false; + } + + $model =& $this->getModel( 'Menutype' ); + if (!$model->canDelete()) { + JError::raiseWarning( 500, $model->getError() ); + $this->setRedirect( 'index.php?option=com_menus' ); + return false; + } + $err = null; + if (!$model->delete()) { + $err = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus', $err ); + } + + /** + * Compiles a list of the articles you have selected to Copy + */ + function copyMenu() + { + $view =& $this->getView( 'Menus' ); + $model =& $this->getModel( 'Menutype' ); + $view->setModel( $model, true ); + $view->copyForm(); + } + + /** + * Copies a complete menu, all its items and creates a new module, using the name speified + */ + function doCopyMenu() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $type = JRequest::getVar( 'type', '', 'post', 'string' ); + $menu_name = JRequest::getVar( 'menu_name', 'New Menu', 'post', 'string' ); + $module_name = JRequest::getVar( 'module_name', 'New Module', 'post', 'string' ); + + // check for unique menutype for new menu copy + $query = 'SELECT params' . + ' FROM #__modules' . + ' WHERE module = "mod_mainmenu"'; + $db->setQuery( $query ); + $menus = $db->loadResultArray(); + + foreach ( $menus as $menu ) + { + $params = new JParameter( $menu ); + if ( $params->get('menutype') == $menu_name ) { + JError::raiseWarning( 500, JText::_( 'ERRORMENUNAMEEXISTS' ) ); + $this->setRedirect( 'index.php?option=com_menus' ); + return; + } + } + + // copy the menu items + $mids = JRequest::getVar( 'mids', array(), 'post', 'array' ); + JArrayHelper::toInteger($mids); + $total = count( $mids ); + $copy =& JTable::getInstance('menu'); + $original =& JTable::getInstance('menu'); + sort( $mids ); + $a_ids = array(); + + foreach( $mids as $mid ) + { + $original->load( $mid ); + $copy = $original; + $copy->id = NULL; + $copy->parent = $a_ids[$original->parent]; + $copy->menutype = $menu_name; + $copy->home = 0; + + if ( !$copy->check() ) { + JError::raiseWarning( 500, $copy->getError() ); + $this->setRedirect( 'index.php?option=com_menus' ); + return; + } + if ( !$copy->store() ) { + JError::raiseWarning( 500, $copy->getError() ); + $this->setRedirect( 'index.php?option=com_menus' ); + return; + } + $a_ids[$original->id] = $copy->id; + } + + // create the module copy + $row =& JTable::getInstance('module'); + $row->load( 0 ); + $row->title = $module_name; + $row->iscore = 0; + $row->published = 1; + $row->position = 'left'; + $row->module = 'mod_mainmenu'; + $row->params = 'menutype='. $menu_name; + + if (!$row->check()) { + JError::raiseWarning( 500, $db->getError() ); + $this->setRedirect( 'index.php?option=com_menus' ); + return; + } + if (!$row->store()) { + JError::raiseWarning( 500, $db->getError() ); + $this->setRedirect( 'index.php?option=com_menus' ); + return; + } + $row->checkin(); + $row->reorder( 'position='.$db->Quote($row->position) ); + // module assigned to show on All pages by default + // ToDO: Changed to become a Joomla! db-object + $query = 'INSERT INTO #__modules_menu' . + ' VALUES ( '.(int) $row->id.', 0 )'; + $db->setQuery( $query ); + if ( !$db->query() ) { + JError::raiseWarning( 500, $db->getErrorMsg(true) ); + $this->setRedirect( 'index.php?option=com_menus' ); + return; + //echo "\n"; + //$mainframe->close(); + } + + // Insert the menu type + $query = 'INSERT INTO `#__menu_types` ( `menutype` , `title` , `description` ) ' . + ' VALUES ( '.$db->Quote($menu_name).', '.$db->Quote($menu_name).', "")'; + $db->setQuery( $query ); + if ( !$db->query() ) { + JError::raiseWarning( 500, $db->getErrorMsg(true) ); + $this->setRedirect( 'index.php?option=com_menus' ); + return; + //echo "\n"; + //$mainframe->close(); + } + + $msg = JText::sprintf( 'Copy of Menu created', $type, $total ); + $mainframe->redirect( 'index.php?option=com_menus', $msg ); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_menus/helpers/helper.php b/oss/joomla/trunk/administrator/components/com_menus/helpers/helper.php new file mode 100644 index 00000000..87093b8f --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/helpers/helper.php @@ -0,0 +1,171 @@ +setQuery( $query ); + return $db->loadObjectList(); + } + + /** + * Get a list of the menutypes + * @return array An array of menu type names + */ + function getMenuTypes() + { + $db = &JFactory::getDBO(); + $query = 'SELECT menutype' . + ' FROM #__menu_types'; + $db->setQuery( $query ); + return $db->loadResultArray(); + } + + /** + * Gets a list of components that can link to the menu + */ + function getComponentList() + { + $db = &JFactory::getDBO(); + $query = 'SELECT c.id, c.name, c.link, c.option' . + ' FROM #__components AS c' . + ' WHERE c.link <> "" AND parent = 0' . + ' ORDER BY c.name'; + $db->setQuery( $query ); + $result = $db->loadObjectList( ); + return $result; + } + + /** + * Build the select list for parent menu item + */ + function Parent( &$row ) + { + $db =& JFactory::getDBO(); + + // If a not a new item, lets set the menu item id + if ( $row->id ) { + $id = ' AND id != '.(int) $row->id; + } else { + $id = null; + } + + // In case the parent was null + if (!$row->parent) { + $row->parent = 0; + } + + // get a list of the menu items + // excluding the current menu item and its child elements + $query = 'SELECT m.*' . + ' FROM #__menu m' . + ' WHERE menutype = '.$db->Quote($row->menutype) . + ' AND published != -2' . + $id . + ' ORDER BY parent, ordering'; + $db->setQuery( $query ); + $mitems = $db->loadObjectList(); + + // establish the hierarchy of the menu + $children = array(); + + if ( $mitems ) + { + // first pass - collect children + foreach ( $mitems as $v ) + { + $pt = $v->parent; + $list = @$children[$pt] ? $children[$pt] : array(); + array_push( $list, $v ); + $children[$pt] = $list; + } + } + + // second pass - get an indent list of the items + $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0 ); + + // assemble menu items to the array + $mitems = array(); + $mitems[] = JHTML::_('select.option', '0', JText::_( 'Top' ) ); + + foreach ( $list as $item ) { + $mitems[] = JHTML::_('select.option', $item->id, '   '. $item->treename ); + } + + $output = JHTML::_('select.genericlist', $mitems, 'parent', 'class="inputbox" size="10"', 'value', 'text', $row->parent ); + + return $output; + } + + /** + * build the select list for target window + */ + function Target( &$row ) + { + $click[] = JHTML::_('select.option', '0', JText::_( 'Parent Window With Browser Navigation' ) ); + $click[] = JHTML::_('select.option', '1', JText::_( 'New Window With Browser Navigation' ) ); + $click[] = JHTML::_('select.option', '2', JText::_( 'New Window Without Browser Navigation' ) ); + $target = JHTML::_('select.genericlist', $click, 'browserNav', 'class="inputbox" size="4"', 'value', 'text', intval( $row->browserNav ) ); + + return $target; + } + + /** + * build the select list for target window + */ + function Published( &$row ) + { + $put[] = JHTML::_('select.option', '0', JText::_( 'No' )); + $put[] = JHTML::_('select.option', '1', JText::_( 'Yes' )); + + // If not a new item, trash is not an option + if ( !$row->id ) { + $row->published = 1; + } + $published = JHTML::_('select.radiolist', $put, 'published', '', 'value', 'text', $row->published ); + return $published; + } + + /** + * clean system cache + */ + function cleanCache() + { + global $mainframe; + + if ($mainframe->getCfg('caching')) { + // clean system cache + $cache =& JFactory::getCache('_system'); + $cache->clean(); + + // clean mod_mainmenu cache + $cache2 =& JFactory::getCache('mod_mainmenu'); + $cache2->clean(); + } + } +} diff --git a/oss/joomla/trunk/administrator/components/com_menus/helpers/index.html b/oss/joomla/trunk/administrator/components/com_menus/helpers/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/helpers/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/index.html b/oss/joomla/trunk/administrator/components/com_menus/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/menus.xml b/oss/joomla/trunk/administrator/components/com_menus/menus.xml new file mode 100644 index 00000000..876a799c --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/menus.xml @@ -0,0 +1,12 @@ + + + Menus Manager + Joomla! Project + 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 + Menu Manager + diff --git a/oss/joomla/trunk/administrator/components/com_menus/models/index.html b/oss/joomla/trunk/administrator/components/com_menus/models/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/models/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/models/item.php b/oss/joomla/trunk/administrator/components/com_menus/models/item.php new file mode 100644 index 00000000..a4ba5427 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/models/item.php @@ -0,0 +1,792 @@ +_url = 'index.php?option='.$url['option']; + unset($url['option']); + if (count($url)) { + foreach ($url as $k => $v) + { + $this->_url .= '&'.$k.'='.$v; + } + } + } + + $this->setId(); + } + + function setId() + { + $array = JRequest::getVar('cid', array(0), '', 'array'); + $this->_id = (int) $array[0]; + + if (!$this->_id) { + $this->_id = JRequest::getInt('id', 0); + } + } + + function &getItem() + { + static $item; + if (isset($item)) { + return $item; + } + + $table =& $this->_getTable(); + + // Load the current item if it has been defined + $edit = JRequest::getVar('edit',true); + $cid = JRequest::getVar( 'cid', array(0), '', 'array' ); + JArrayHelper::toInteger($cid, array(0)); + if ($edit) { + $table->load($cid[0]); + } + + // Override the current item's type field if defined in the request + if ($type = JRequest::getString('type')) { + $table->type = $type; + } + + // Override the current item's menutype field if defined in the request + if ($menu_type = JRequest::getString('menutype')) { + $table->menutype = $menu_type; + } + + switch ($table->type) + { + case 'separator': + $table->link = null; + $table->componentid = 0; + break; + case 'url': + $table->componentid = 0; + break; + case 'menulink': + $table->componentid = 0; + break; + case 'component': + // Override the current item's link field if defined in the request + if (!is_null($this->_url)) { + $table->link = $this->_url; + } + $url = str_replace('index.php?', '', $table->link); + $url = str_replace('&', '&', $url); + $table->linkparts = null; + if(strpos($url, '&') !== false) + { + $url = str_replace('&','&',$url); + } + + parse_str($url, $table->linkparts); + + $db = &$this->getDBO(); + if ($component = @$table->linkparts['option']) { + $query = 'SELECT `id`' . + ' FROM `#__components`' . + ' WHERE `link` <> \'\'' . + ' AND `parent` = 0' . + ' AND `option` = "'.$db->getEscaped($component).'"'; + $db->setQuery( $query ); + $table->componentid = $db->loadResult(); + } + break; + } + + $item = $table; + return $item; + } + + function &getExpansion() + { + $item = &$this->getItem(); + $return['option'] = JRequest::getCmd('expand'); + $menutype = JRequest::getString('menutype'); + + if ($return['option']) + { + require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_menus'.DS.'classes'.DS.'ilink.php'); + $handler = new iLink($return['option'], $item->id, $menutype); + $return['html'] = $handler->getTree(); + return $return; + } else { + $return['html'] = null; + } + return $return; + } + + function &getUrlParams() + { + // Get the state parameters + $item =& $this->getItem(); + $params = new JParameter(''); + + if ($state =& $this->_getStateXML()) + { + if (is_a($state, 'JSimpleXMLElement')) + { + $sp =& $state->getElementByPath('url'); + $params->setXML($sp); + if (isset($item->linkparts) && is_array($item->linkparts)) { + $params->loadArray($item->linkparts); + } + } + } + return $params; + } + + function &getStateParams() + { + // Get the state parameters + $item =& $this->getItem(); + $params = new JParameter($item->params); + + if ($state =& $this->_getStateXML()) + { + if (is_a($state, 'JSimpleXMLElement')) + { + $sp =& $state->getElementByPath('params'); + $params->setXML($sp); + } + } + return $params; + } + + function &getAdvancedParams() + { + // Get the state parameters + $item =& $this->getItem(); + $params = new JParameter($item->params); + + if ($state =& $this->_getStateXML()) + { + if (is_a($state, 'JSimpleXMLElement')) + { + $ap =& $state->getElementByPath('advanced'); + $params->setXML($ap); + } + } + return $params; + } + + function &getComponentParams() + { + // Initialize variables + $params = null; + $item = &$this->getItem(); + + if ($item->type == 'component') + { + $comp = &$this->getComponent(); + $option = preg_replace( '#\W#', '', $comp->option ); + $path = JPATH_ADMINISTRATOR.DS.'components'.DS.$option.DS.'config.xml'; + + $params = new JParameter( $item->params ); + if (file_exists( $path )) + { + $xml =& JFactory::getXMLParser('Simple'); + if ($xml->loadFile($path)) + { + $document =& $xml->document; + + // if hide is set, don't show the component configuration while editing menu item + $menu = $document->attributes('menu'); + if ( isset($menu) && $menu == 'hide' ) + { + $params = null; + return $params; + } + + if (isset($document->params[0]->param)) + { + // We will collect the hidden elements in an array + // loop will mess up if we do it within the loop + $hide = array(); + for ($i=0,$n=count($document->params[0]->param); $i<$n; $i++) + { + if ($document->params[0]->param[$i]->attributes('menu') == 'hide') + { + $hide[] = &$document->params[0]->param[$i]; + } + else if ($document->params[0]->param[$i]->attributes('type') == 'radio' || $document->params[0]->param[$i]->attributes('type') == 'list') { + $document->params[0]->param[$i]->addAttribute('default', ''); + $document->params[0]->param[$i]->addAttribute('type', 'list'); + $child = &$document->params[0]->param[$i]->addChild('option', array('value' => '')); + $child->setData('Use Global'); + } + } + // Now remove any hidden elements + for ($i = 0, $n = count( $hide ); $i < $n; $i++) { + $document->params[0]->removeChild( $hide[$i] ); + } + } + $params->setXML( $document->params[0] ); + } + } + } + return $params; + } + + function &getSystemParams() + { + // Initialize variables + $params = null; + $item = &$this->getItem(); + + $params = new JParameter( $item->params ); + if ($item->type == 'component') { + $path = JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'.DS.'metadata'.DS.'component.xml'; + if (file_exists( $path )) { + $xml =& JFactory::getXMLParser('Simple'); + if ($xml->loadFile($path)) { + $document =& $xml->document; + $params->setXML($document->getElementByPath('state/params')); + } + } + } + return $params; + } + + /** + * Get the name of the current menu item + * + * @return string + * @access public + * @since 1.5 + */ + function getStateName() + { + $state =& $this->_getStateXML(); + + if ( ! is_a($state, 'JSimpleXMLElement')) + { + return null; + } + + $name = null; + $sn =& $state->getElementByPath('name'); + if ($sn) { + $name = $sn->data(); + } + + return JText::_($name); + } + + /** + * Get the description of the current menu item + * + * @return string + * @access public + * @since 1.5 + */ + function getStateDescription() + { + $state =& $this->_getStateXML(); + + + if ( ! is_a($state, 'JSimpleXMLElement')) + { + return null; + } + + $description = null; + $sd =& $state->getElementByPath('description'); + if ($sd) { + $description = $sd->data(); + } + + return JText::_($description); + } + + /** + * Gets the componet table object related to this menu item + */ + function &getComponent() + { + $item =& $this->getItem(); + $id = $item->componentid; + $component = & JTable::getInstance( 'component'); + $component->load( $id ); + return $component; + } + + function checkout($uid = null) + { + $id = JRequest::getVar('cid', array(0), '', 'array'); + JArrayHelper::toInteger( $id, array(0) ); + + // Make sure we have a user id to checkout the article with + if (is_null($uid)) { + $user =& JFactory::getUser(); + $uid = $user->get('id'); + } + + // Lets get to it and checkout the thing... + $item =& $this->getItem(); + if(!$item->checkout($uid, $id[0])) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + + return true; + } + + function checkin() + { + if ($this->_id) { + $item =& $this->_getTable(); + + if(!$item->checkin($this->_id)) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + + return true; + } + + return false; + } + + function store() + { + // Initialize variables + $db =& JFactory::getDBO(); + $row =& $this->getItem(); + $post = $this->_state->get( 'request' ); + + switch ($post['type']) + { + case 'separator': + break; + case 'url': + break; + case 'menulink': + $post['link'] = 'index.php?Itemid='.$post['params']['menu_item']; + break; + case 'component': + break; + } + if (!$row->bind( $post )) { + echo "\n"; + return false; + } + + if ($row->id > 0) + { + // existing item + $query = 'SELECT menutype FROM #__menu WHERE id = '.(int) $row->id; + $this->_db->setQuery( $query ); + $oldType = $this->_db->loadResult(); + if ($oldType != $row->menutype) { + // moved to another menu, disconnect the old parent + $row->parent = 0; + } + $query = 'SELECT parent FROM #__menu WHERE id = '.(int) $row->id; + $this->_db->setQuery( $query ); + $oldParent = $this->_db->loadResult(); + if ($oldParent != $row->parent) { + // we have changed parents, so we have to fix the submenu values + if ($row->parent != 0) { + $query = 'SELECT sublevel FROM #__menu WHERE id = '.(int) $row->parent; + $this->_db->setQuery( $query ); + $sublevel = $this->_db->loadResult() + 1; + } else { + $sublevel = 0; + } + $row->sublevel = $sublevel; + $this->_setSubLevel( array( (int) $row->id ), $sublevel ); + } + } + else + { + // if new item order last in appropriate group + $where = "menutype = " . $db->Quote($row->menutype) . " AND published >= 0 AND parent = ".(int) $row->parent; + $row->ordering = $row->getNextOrder( $where ); + + if( $row->parent != 0 ) { + $query = 'SELECT sublevel FROM #__menu WHERE id = '. (int) $row->parent; + $this->_db->setQuery($query); + $row->sublevel = $this->_db->loadResult() + 1; + } + } + + if (isset($post['urlparams']) && is_array($post['urlparams'])) + { + $pos = strpos( $row->link, '?' ); + if ($pos !== false) + { + $prefix = substr( $row->link, 0, $pos ); + $query = substr( $row->link, $pos+1 ); + + $temp = array(); + if(strpos($query, '&') !== false) { + $query = str_replace('&', '&', $query); + } + parse_str( $query, $temp ); + $temp2 = array_merge( $temp, $post['urlparams'] ); + + $temp3 = array(); + foreach ($temp2 as $k => $v) + { + if ( $k && strlen($v) ) + { + $temp3[] = $k.'='.$v; + } + } + $url = null; + $row->link = $prefix . '?' . implode( '&', $temp3 ); + } + } + + if (!$row->check()) + { + echo "\n"; + return false; + } + + if (!$row->store()) + { + echo "\n"; + return false; + } + + $row->checkin(); + $row->reorder( 'menutype='.$db->Quote( $row->menutype ).' AND parent='.(int)$row->parent ); + + // clean cache + MenusHelper::cleanCache(); + + return true; + } + + + + /** + * Delete one or more menu items + * @param mixed int or array of id values + */ + function delete( $ids ) + { + JArrayHelper::toInteger($ids); + + $db = &$this->getDBO(); + + if (count( $ids )) + { + // Delete associated module and template mappings + $where = 'WHERE menuid = ' . implode( ' OR menuid = ', $ids ); + + $query = 'DELETE FROM #__modules_menu ' + . $where; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $menuTable->getErrorMsg() ); + return false; + } + + $query = 'DELETE FROM #__templates_menu ' + . $where; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $menuTable->getErrorMsg() ); + return false; + } + + // Set any alias menu types to not point to missing menu items + $query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND (link = '.implode( ' OR id = ', $ids ).')'; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $db->getErrorMsg() ); + return false; + } + + // Delete the menu items + $where = 'WHERE id = ' . implode( ' OR id = ', $ids ); + + $query = 'DELETE FROM #__menu ' . $where; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $db->getErrorMsg() ); + return false; + } + } + + // clean cache + MenusHelper::cleanCache(); + + return true; + } + + /** + * Delete menu items by type + */ + function deleteByType( $type = '' ) + { + $db = &$this->getDBO(); + + $query = 'SELECT id' . + ' FROM #__menu' . + ' WHERE menutype = ' . $db->Quote( $type ); + $db->setQuery( $query ); + $ids = $db->loadResultArray(); + + if ($db->getErrorNum()) + { + $this->setError( $db->getErrorMsg() ); + return false; + } + + return $this->delete( $ids ); + } + + /** + * Returns the internal table object + * @return JTable + */ + function &_getTable() + { + if ($this->_table == null) { + $this->_table =& JTable::getInstance( 'menu'); + } + return $this->_table; + } + + function &_getStateXML() + { + static $xml; + + if (isset($xml)) { + return $xml; + } + $xml = null; + $xmlpath = null; + $item = &$this->getItem(); + + switch ($item->type) + { + case 'separator': + $xmlpath = JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'.DS.'metadata'.DS.'separator.xml'; + break; + case 'url': + $xmlpath = JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'.DS.'metadata'.DS.'url.xml'; + break; + case 'menulink': + $xmlpath = JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'.DS.'metadata'.DS.'menulink.xml'; + break; + case 'component': + default: + if (isset($item->linkparts['view'])) + { + // View is set... so we konw to look in view file + if (isset($item->linkparts['layout'])) { + $layout = $item->linkparts['layout']; + } else { + $layout = 'default'; + } + $lpath = JPATH_ROOT.DS.'components'.DS.$item->linkparts['option'].DS.'views'.DS.$item->linkparts['view'].DS.'tmpl'.DS.$layout.'.xml'; + $vpath = JPATH_ROOT.DS.'components'.DS.$item->linkparts['option'].DS.'views'.DS.$item->linkparts['view'].DS.'metadata.xml'; + if (file_exists($lpath)) { + $xmlpath = $lpath; + } elseif (file_exists($vpath)) { + $xmlpath = $vpath; + } + } + if (!$xmlpath && isset($item->linkparts['option'])) { + $xmlpath = JPATH_ROOT.DS.'components'.DS.$item->linkparts['option'].DS.'metadata.xml'; + if(!file_exists($xmlpath)) { + $xmlpath = JApplicationHelper::getPath('com_xml', $item->linkparts['option']); + } + } + break; + } + + if (file_exists($xmlpath)) + { + $xml =& JFactory::getXMLParser('Simple'); + if ($xml->loadFile($xmlpath)) { + $this->_xml = &$xml; + $document =& $xml->document; + + /* + * HANDLE NO OPTION CASE + */ + $menus =& $document->getElementByPath('menu'); + if (is_a($menus, 'JSimpleXMLElement') && $menus->attributes('options') == 'none') { + $xml =& $menus->getElementByPath('state'); + } else { + $xml =& $document->getElementByPath('state'); + } + + // Handle error case... path doesn't exist + if (!is_a($xml, 'JSimpleXMLElement')) { + return $document; + } + + /* + * HANDLE A SWITCH IF IT EXISTS + */ + if ($switch = $xml->attributes('switch')) + { + $default = $xml->attributes('default'); + // Handle switch + $switchVal = (isset($item->linkparts[$switch]))? $item->linkparts[$switch] : 'default'; + $found = false; + + foreach ($xml->children() as $child) { + if ($child->name() == $switchVal) { + $xml =& $child; + $found = true; + break; + } + } + + if (!$found) { + foreach ($xml->children() as $child) { + if ($child->name() == $default) { + $xml =& $child; + break; + } + } + } + } + + /* + * HANDLE INCLUDED PARAMS + */ + $children = $xml->children(); + if (count($children) == 1) + { + if ($children[0]->name() == 'include') { + $ret =& $this->_getIncludedParams($children[0]); + if ($ret) { + $xml =& $ret; + } + } + } + + if ($switch = $xml->attributes('switch')) + { + $default = $xml->attributes('default'); + // Handle switch + $switchVal = ($item->linkparts[$switch])? $item->linkparts[$switch] : 'default'; + $found = false; + + foreach ($xml->children() as $child) { + if ($child->name() == $switchVal) { + $xml =& $child; + $found = true; + break; + } + } + + if (!$found) { + foreach ($xml->children() as $child) { + if ($child->name() == $default) { + $xml =& $child; + break; + } + } + } + } + } + } + return $xml; + } + + function &_getIncludedParams($include) + { + $tags = array(); + $state = null; + $source = $include->attributes('source'); + $path = $include->attributes('path'); + $item = &$this->getItem(); + + preg_match_all( "/{([A-Za-z\-_]+)}/", $source, $tags); + if (isset($tags[1])) { + for ($i=0;$ilinkparts[$tags[1][$i]], $source); + } + } + + // load the source xml file + if (file_exists( JPATH_ROOT.$source )) + { + $xml = & JFactory::getXMLParser('Simple'); + + if ($xml->loadFile(JPATH_ROOT.$source)) { + $document = &$xml->document; + $state = $document->getElementByPath($path); + } + } + return $state; + } + + /** + * Sets the sublevel for menu items + * + * @param array id values to set + * @param int level to assign to the sublevel + */ + function _setSubLevel( $cid, $level ) + { + JArrayHelper::toInteger($cid, array(0)); + + $ids = implode( ',', $cid ); + + $query = 'UPDATE #__menu SET sublevel = '.(int) $level + .' WHERE id IN ('.$ids.')'; + $this->_db->setQuery( $query ); + $this->_db->query(); + + $query = 'SELECT id FROM #__menu WHERE parent IN ('.$ids.')'; + $this->_db->setQuery( $query ); + $cids = $this->_db->loadResultArray( 0 ); + + if (!empty( $cids )) { + $this->_setSubLevel( $cids, $level + 1 ); + } + } +} diff --git a/oss/joomla/trunk/administrator/components/com_menus/models/list.php b/oss/joomla/trunk/administrator/components/com_menus/models/list.php new file mode 100644 index 00000000..25d842f7 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/models/list.php @@ -0,0 +1,749 @@ +_table == null) + { + $this->_table =& JTable::getInstance( 'menu'); + } + return $this->_table; + } + + function &getItems() + { + global $mainframe; + + static $items; + + if (isset($items)) { + return $items; + } + + $db =& $this->getDBO(); + + $menutype = $mainframe->getUserStateFromRequest( "com_menus.menutype", 'menutype', 'mainmenu', 'string' ); + $filter_order = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.filter_order', 'filter_order', 'm.ordering', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.filter_order_Dir', 'filter_order_Dir', 'ASC', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.filter_state', 'filter_state', '', 'word' ); + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg( 'list_limit' ), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.limitstart', 'limitstart', 0, 'int' ); + $levellimit = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.levellimit', 'levellimit', 10, 'int' ); + $search = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.search', 'search', '', 'string' ); + $search = JString::strtolower( $search ); + + $and = ''; + if ( $filter_state ) + { + if ( $filter_state == 'P' ) { + $and = ' AND m.published = 1'; + } else if ($filter_state == 'U' ) { + $and = ' AND m.published = 0'; + } + } + + // just in case filter_order get's messed up + if ($filter_order) { + $orderby = ' ORDER BY '.$filter_order .' '. $filter_order_Dir .', m.parent, m.ordering'; + } else { + $orderby = ' ORDER BY m.parent, m.ordering'; + } + + // select the records + // note, since this is a tree we have to do the limits code-side + if ($search) { + $query = 'SELECT m.id' . + ' FROM #__menu AS m' . + ' WHERE menutype = '.$db->Quote($menutype) . + ' AND LOWER( m.name ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ) . + $and; + $db->setQuery( $query ); + $search_rows = $db->loadResultArray(); + } + + $query = 'SELECT m.*, u.name AS editor, g.name AS groupname, c.publish_up, c.publish_down, com.name AS com_name' . + ' FROM #__menu AS m' . + ' LEFT JOIN #__users AS u ON u.id = m.checked_out' . + ' LEFT JOIN #__groups AS g ON g.id = m.access' . + ' LEFT JOIN #__content AS c ON c.id = m.componentid AND m.type = "content_typed"' . + ' LEFT JOIN #__components AS com ON com.id = m.componentid AND m.type = "component"' . + ' WHERE m.menutype = '.$db->Quote($menutype) . + ' AND m.published != -2' . + $and . + $orderby; + $db->setQuery( $query ); + $rows = $db->loadObjectList(); + + // establish the hierarchy of the menu + $children = array(); + // first pass - collect children + foreach ($rows as $v ) + { + $pt = $v->parent; + $list = @$children[$pt] ? $children[$pt] : array(); + array_push( $list, $v ); + $children[$pt] = $list; + } + // second pass - get an indent list of the items + $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, max( 0, $levellimit-1 ) ); + // eventually only pick out the searched items. + if ($search) { + $list1 = array(); + + foreach ($search_rows as $sid ) + { + foreach ($list as $item) + { + if ($item->id == $sid) { + $list1[] = $item; + } + } + } + // replace full list with found items + $list = $list1; + } + + $total = count( $list ); + + jimport('joomla.html.pagination'); + $this->_pagination = new JPagination( $total, $limitstart, $limit ); + + // slice out elements based on limits + $list = array_slice( $list, $this->_pagination->limitstart, $this->_pagination->limit ); + + $i = 0; + $query = array(); + foreach ( $list as $mitem ) + { + $edit = ''; + switch ( $mitem->type ) + { + case 'separator': + $list[$i]->descrip = JText::_('Separator'); + break; + + case 'url': + $list[$i]->descrip = JText::_('URL'); + break; + + case 'menulink': + $list[$i]->descrip = JText::_('Menu Link'); + break; + + case 'component': + $list[$i]->descrip = JText::_('Component'); + $query = parse_url($list[$i]->link); + $view = array(); + if(isset($query['query'])) { + if(strpos($query['query'], '&') !== false) + { + $query['query'] = str_replace('&','&',$query['query']); + } + parse_str($query['query'], $view); + } + $list[$i]->view = $list[$i]->com_name; + if (isset($view['view'])) + { + $list[$i]->view .= ' » '.JText::_(ucfirst($view['view'])); + } + if (isset($view['layout'])) + { + $list[$i]->view .= ' / '.JText::_(ucfirst($view['layout'])); + } + if (isset($view['task']) && !isset($view['view'])) + { + $list[$i]->view .= ' :: '.JText::_(ucfirst($view['task'])); + } + break; + + default: + $list[$i]->descrip = JText::_('Unknown'); + break; + } + $i++; + } + + $items = $list; + return $items; + } + + function &getPagination() + { + if ($this->_pagination == null) { + $this->getItems(); + } + return $this->_pagination; + } + + /** + * Form for copying item(s) to a specific menu + */ + function getItemsFromRequest() + { + static $items; + + if (isset($items)) { + return $items; + } + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + if (count($cid) < 1) { + $this->setError(JText::_( 'Select an item to move')); + return false; + } + + // Query to list the selected menu items + $db =& $this->getDBO(); + $cids = implode( ',', $cid ); + $query = 'SELECT `id`, `name`' . + ' FROM `#__menu`' . + ' WHERE `id` IN ( '.$cids.' )'; + + $db->setQuery( $query ); + $items = $db->loadObjectList(); + + return $items; + } + + /** + * Gets the componet table object related to this menu item + */ + function &getComponent() + { + $id = $this->_table->componentid; + $component = & JTable::getInstance( 'component'); + $component->load( $id ); + return $component; + } + + /** + * Save the item(s) to the menu selected + */ + function copy( $items, $menu ) + { + $curr =& JTable::getInstance('menu'); + $itemref = array(); + foreach ($items as $id) + { + $curr->load( $id ); + $curr->id = NULL; + $curr->home = 0; + if ( !$curr->store() ) { + $this->setError($curr->getError()); + return false; + } + $itemref[] = array($id, $curr->id); + } + foreach ($itemref as $ref) + { + $curr->load( $ref[1] ); + if ($curr->parent!=0) { + $found = false; + foreach ( $itemref as $ref2 ) + { + if ($curr->parent == $ref2[0]) { + $curr->parent = $ref2[1]; + $found = true; + break; + } // if + } + if (!$found && $curr->menutype!=$menu) { + $curr->parent = 0; + } + } + $curr->menutype = $menu; + $curr->ordering = '9999'; + $curr->home = 0; + if ( !$curr->store() ) { + $this->setError($curr->getError()); + return false; + } + $curr->reorder( 'menutype = '.$this->_db->Quote($curr->menutype).' AND parent = '.(int) $curr->parent ); + } // foreach + + //Now, we need to rebuild sublevels... + $this->_rebuildSubLevel(); + + // clean cache + MenusHelper::cleanCache(); + + return true; + } + + function move($items, $menu) + { + // Add all children to the list + foreach ($items as $id) + { + $this->_addChildren($id, $items); + } + + $row =& $this->getTable(); + $ordering = 1000000; + $firstroot = 0; + foreach ($items as $id) { + $row->load( $id ); + + // is it moved together with his parent? + $found = false; + if ($row->parent != 0) { + foreach ($items as $idx) + { + if ($idx == $row->parent) { + $found = true; + break; + } // if + } + } + if (!$found) { + $row->parent = 0; + $row->ordering = $ordering++; + if (!$firstroot) $firstroot = $row->id; + } // if + + $row->menutype = $menu; + if ( !$row->store() ) { + $this->setError($row->getError()); + return false; + } // if + } // foreach + + if ($firstroot) { + $row->load( $firstroot ); + $row->reorder( 'menutype = '.$this->_db->Quote($row->menutype).' AND parent = '.(int) $row->parent ); + } // if + + //Rebuild sublevel + $this->_rebuildSubLevel(); + + // clean cache + MenusHelper::cleanCache(); + + return true; + } + + function toTrash($items) + { + $db =& $this->getDBO(); + $nd = $db->getNullDate(); + $state = -2; + $row =& $this->getTable(); + $default = 0; + + // Add all children to the list + foreach ($items as $id) + { + //Check if it's the default item + $row->load( $id ); + if ($row->home != 1) { + $this->_addChildren($id, $items); + } else { + unset($items[$default]); + JError::raiseWarning( 'SOME_ERROR_CODE', JText::_('You cannot trash the default menu item')); + } + $default++; + } + if (!empty($items)) { + // Sent menu items to the trash + JArrayHelper::toInteger($items, array(0)); + $where = ' WHERE (id = ' . implode( ' OR id = ', $items ) . ') AND home = 0'; + $query = 'UPDATE #__menu' . + ' SET published = '.(int) $state.', parent = 0, ordering = 0, checked_out = 0, checked_out_time = '.$db->Quote($nd) . + $where; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $db->getErrorMsg() ); + return false; + } + } + + // clean cache + MenusHelper::cleanCache(); + + return count($items); + } + + function fromTrash($items) + { + $db =& $this->getDBO(); + $nd = $db->getNullDate(); + $state = 0; + + // Add all children to the list + foreach ($items as $id) + { + $this->_addChildren($id, $items); + } + + // Sent menu items to the trash + JArrayHelper::toInteger($items, array(0)); + $where = ' WHERE id = ' . implode( ' OR id = ', $items ); + $query = 'UPDATE #__menu' . + ' SET published = '.(int) $state.', parent = 0, ordering = 99999, checked_out = 0, checked_out_time = '.$db->Quote($nd) . + $where; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $db->getErrorMsg() ); + return false; + } + + // clean cache (require helper because method can be called from com_trash) + require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_menus'.DS.'helpers'.DS.'helper.php' ); + MenusHelper::cleanCache(); + + return count($items); + } + + /** + * Set the state of selected menu items + */ + function setHome( $item ) + { + $db =& $this->getDBO(); + + // Clear home field for all other items + $query = 'UPDATE #__menu' . + ' SET home = 0' . + ' WHERE 1'; + $db->setQuery( $query ); + if ( !$db->query() ) { + $this->setError($db->getErrorMsg()); + return false; + } + + // Set the given item to home + $query = 'UPDATE #__menu' . + ' SET home = 1' . + ' WHERE id = '.(int) $item; + $db->setQuery( $query ); + if ( !$db->query() ) { + $this->setError($db->getErrorMsg()); + return false; + } + + // clean cache + MenusHelper::cleanCache(); + + return true; + } + + /** + * Set the state of selected menu items + */ + function setItemState( $items, $state ) + { + if(is_array($items)) + { + $row =& $this->getTable(); + foreach ($items as $id) + { + $row->load( $id ); + + if ($row->home != 1) { + $row->published = $state; + + if ($state != 1) { + // Set any alias menu types to not point to unpublished menu items + $db = &$this->getDBO(); + $query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND link = '.(int)$id; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $db->getErrorMsg() ); + return false; + } + } + + if (!$row->check()) { + $this->setError($row->getError()); + return false; + } + if (!$row->store()) { + $this->setError($row->getError()); + return false; + } + } else { + JError::raiseWarning( 'SOME_ERROR_CODE', JText::_('You cannot unpublish the default menu item')); + return false; + } + } + } + + // clean cache + MenusHelper::cleanCache(); + + return true; + } + + /** + * Set the access of selected menu items + */ + function setAccess( $items, $access ) + { + $row =& $this->getTable(); + foreach ($items as $id) + { + $row->load( $id ); + $row->access = $access; + + // Set any alias menu types to not point to unpublished menu items + $db = &$this->getDBO(); + $query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND access < '.(int)$access.' AND link = '.(int)$id; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $db->getErrorMsg() ); + return false; + } + + if (!$row->check()) { + $this->setError($row->getError()); + return false; + } + if (!$row->store()) { + $this->setError($row->getError()); + return false; + } + } + + // clean cache + MenusHelper::cleanCache(); + + return true; + } + + function orderItem($item, $movement) + { + $row =& $this->getTable(); + $row->load( $item ); + if (!$row->move( $movement, 'menutype = '.$this->_db->Quote($row->menutype).' AND parent = '.(int) $row->parent )) { + $this->setError($row->getError()); + return false; + } + + // clean cache + MenusHelper::cleanCache(); + + return true; + } + + function setOrder($items, $menutype) + { + $total = count( $items ); + $row =& $this->getTable(); + $groupings = array(); + + $order = JRequest::getVar( 'order', array(), 'post', 'array' ); + JArrayHelper::toInteger($order); + + // update ordering values + for( $i=0; $i < $total; $i++ ) { + $row->load( $items[$i] ); + // track parents + $groupings[] = $row->parent; + if ($row->ordering != $order[$i]) { + $row->ordering = $order[$i]; + if (!$row->store()) { + $this->setError($row->getError()); + return false; + } + } // if + } // for + + // execute updateOrder for each parent group + $groupings = array_unique( $groupings ); + foreach ($groupings as $group){ + $row->reorder('menutype = '.$this->_db->Quote($menutype).' AND parent = '.(int) $group.' AND published >=0'); + } + + // clean cache + MenusHelper::cleanCache(); + + return true; + } + + /** + * Delete one or more menu items + * @param mixed int or array of id values + */ + function delete( $ids ) + { + JArrayHelper::toInteger($ids); + + if (!empty( $ids )) { + + // Add all children to the list + foreach ($ids as $id) + { + $this->_addChildren($id, $ids); + } + + $db = &$this->getDBO(); + + // Delete associated module and template mappings + $where = 'WHERE menuid = ' . implode( ' OR menuid = ', $ids ); + + $query = 'DELETE FROM #__modules_menu ' + . $where; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $menuTable->getErrorMsg() ); + return false; + } + + $query = 'DELETE FROM #__templates_menu ' + . $where; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $menuTable->getErrorMsg() ); + return false; + } + + // Set any alias menu types to not point to missing menu items + $query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND (link = '.implode( ' OR id = ', $ids ).')'; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $db->getErrorMsg() ); + return false; + } + + // Delete the menu items + $where = 'WHERE id = ' . implode( ' OR id = ', $ids ); + + $query = 'DELETE FROM #__menu ' . $where; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $db->getErrorMsg() ); + return false; + } + } + + // clean cache + MenusHelper::cleanCache(); + + return true; + } + + /** + * Delete menu items by type + */ + function deleteByType( $type = '' ) + { + $db = &$this->getDBO(); + + $query = 'SELECT id' . + ' FROM #__menu' . + ' WHERE menutype = ' . $db->Quote( $type ); + $db->setQuery( $query ); + $ids = $db->loadResultArray(); + + if ($db->getErrorNum()) { + $this->setError( $db->getErrorMsg() ); + return false; + } + + return $this->delete( $ids ); + } + + function _addChildren($id, &$list) + { + // Initialize variables + $return = true; + + // Get all rows with parent of $id + $db =& $this->getDBO(); + $query = 'SELECT id' . + ' FROM #__menu' . + ' WHERE parent = '.(int) $id; + $db->setQuery( $query ); + $rows = $db->loadObjectList(); + + // Make sure there aren't any errors + if ($db->getErrorNum()) { + $this->setError($db->getErrorMsg()); + return false; + } + + // Recursively iterate through all children... kinda messy + // TODO: Cleanup this method + foreach ($rows as $row) + { + $found = false; + foreach ($list as $idx) + { + if ($idx == $row->id) { + $found = true; + break; + } + } + if (!$found) { + $list[] = $row->id; + } + $return = $this->_addChildren($row->id, $list); + } + return $return; + } + + /* + * Rebuild the sublevel field for items in the menu (if called with 2nd param = 0 or no params, it will rebuild entire menu tree's sublevel + * @param array of menu item ids to change level to + * @param int level to set the menu items to (based on parent + */ + function _rebuildSubLevel($cid = array(0), $level = 0) + { + JArrayHelper::toInteger($cid, array(0)); + $db =& $this->getDBO(); + $ids = implode( ',', $cid ); + $cids = array(); + if($level == 0) { + $query = 'UPDATE #__menu SET sublevel = 0 WHERE parent = 0'; + $db->setQuery($query); + $db->query(); + $query = 'SELECT id FROM #__menu WHERE parent = 0'; + $db->setQuery($query); + $cids = $db->loadResultArray(0); + } else { + $query = 'UPDATE #__menu SET sublevel = '.(int) $level + .' WHERE parent IN ('.$ids.')'; + $db->setQuery( $query ); + $db->query(); + $query = 'SELECT id FROM #__menu WHERE parent IN ('.$ids.')'; + $db->setQuery( $query ); + $cids = $db->loadResultArray( 0 ); + } + if (!empty( $cids )) { + $this->_rebuildSubLevel( $cids, $level + 1 ); + } + } +} diff --git a/oss/joomla/trunk/administrator/components/com_menus/models/menutype.php b/oss/joomla/trunk/administrator/components/com_menus/models/menutype.php new file mode 100644 index 00000000..89ad3aab --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/models/menutype.php @@ -0,0 +1,280 @@ +_table == null) { + $this->_table = & JTable::getInstance('menuTypes'); + if ($id = JRequest::getVar('id', false, '', 'int')) { + $this->_table->load($id); + } + } + return $this->_table; + } + + /** + * Get a list of the menu records associated with the type + * + * @param string The menu type + * @return array An array of records as objects + */ + function getMenus() + { + global $mainframe; + + $menus= array(); + $db = &$this->getDBO(); + + // Preselect some aggregate data + + // Query to get published menu item counts + $query = 'SELECT a.menutype, COUNT( a.menutype ) AS num' . + ' FROM #__menu AS a' . + ' WHERE a.published = 1' . + ' GROUP BY a.menutype'; + $db->setQuery( $query ); + $published = $db->loadObjectList( 'menutype' ); + + // Query to get unpublished menu item counts + $query = 'SELECT a.menutype, COUNT( a.menutype ) AS num' . + ' FROM #__menu AS a' . + ' WHERE a.published = 0' . + ' GROUP BY a.menutype'; + $db->setQuery( $query ); + $unpublished = $db->loadObjectList( 'menutype' ); + + // Query to get trash menu item counts + $query = 'SELECT a.menutype, COUNT( a.menutype ) AS num' . + ' FROM #__menu AS a' . + ' WHERE a.published = -2' . + ' GROUP BY a.menutype'; + $db->setQuery( $query ); + $trash = $db->loadObjectList( 'menutype' ); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( 'com_menus.limitstart', 'limitstart', 0, 'int' ); + + $query = 'SELECT a.*, SUM(b.home) AS home' . + ' FROM #__menu_types AS a' . + ' LEFT JOIN #__menu AS b ON b.menutype = a.menutype' . + ' GROUP BY a.id'; + $db->setQuery( $query, $limitstart, $limit ); + $menuTypes = $db->loadObjectList(); + + $total = count( $menuTypes ); + $i = 0; + for ($i = 0; $i < $total; $i++) { + $row = &$menuTypes[$i]; + + // query to get number of modules for menutype + $query = 'SELECT count( id )' . + ' FROM #__modules' . + ' WHERE module = "mod_mainmenu"' . + ' AND params LIKE '.$db->Quote('%menutype='.$row->menutype.'%'); + $db->setQuery( $query ); + $modules = $db->loadResult(); + + if ( !$modules ) { + $modules = '-'; + } + $row->modules = $modules; + $row->published = @$published[$row->menutype]->num ? $published[$row->menutype]->num : '-' ; + $row->unpublished = @$unpublished[$row->menutype]->num ? $unpublished[$row->menutype]->num : '-'; + $row->trash = @$trash[$row->menutype]->num ? $trash[$row->menutype]->num : '-'; + $menus[] = $row; + } + return $menus; + } + + /** + * Get a list of the menu records associated with the type + * + * @param string The menu type + * @return array An array of records as objects + */ + function getPagination() + { + global $mainframe; + + $menutypes = MenusHelper::getMenuTypeList(); + $total = count( $menutypes ); + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( 'com_menus.limitstart', 'limitstart', 0, 'int' ); + + jimport('joomla.html.pagination'); + $pagination = new JPagination( $total, $limitstart, $limit ); + return $pagination; + } + + /** + * Get a list of the menu records associated with the type + * @param string The menu type + * @return array An array of records as objects + */ + function getMenuItems() + { + $table = & $this->getTable(); + if ($table->menutype == '') { + $table->menutype = JRequest::getString('menutype'); + } + + $db = &$this->getDBO(); + $query = 'SELECT a.name, a.id' . + ' FROM #__menu AS a' . + ' WHERE a.menutype = ' . $db->Quote( $table->menutype ) . + ' ORDER BY a.name'; + $db->setQuery( $query ); + $result = $db->loadObjectList(); + return $result; + } + + /** + * Get a list of the menu records associated with the type + * @param string The menu type + * @return array An array of records as objects + */ + function getModules( $type='' ) + { + if ($type == '') { + $type = $this->_table->menutype; + } + + $db = &$this->getDBO(); + $query = 'SELECT id, title, params' . + ' FROM #__modules' . + ' WHERE module = "mod_mainmenu"' . + ' AND params LIKE ' . $db->Quote( '%menutype=' . $type . '%' ); + $db->setQuery( $query ); + $temp = $db->loadObjectList(); + + $result = array(); + $n = count( $temp ); + for ($i = 0; $i < $n; $i++) + { + $params = new JParameter( $temp[$i]->params ); + if ($params->get( 'menutype' ) == $type) { + $result[] = $temp[$i]; + } + } + return $result; + } + + /** + * Checks if the menu can be deleted + * @param string The menu type + * @return boolean + */ + function canDelete( $type='' ) + { + if ($type == '') { + $type = $this->_table->menutype; + } + if ($type == 'mainmenu') { + $this->setError( JText::_( 'WARNDELMAINMENU' ) ); + return false; + } + return true; + } + + /** + * Deletes menu type and associations + * @param string The id of the menu type + * @return boolean + */ + function delete( $id = 0 ) + { + $table = &$this->getTable(); + if ($id != 0) { + $table->load( $id ); + } + + $db = &$this->getDBO(); + + // Delete Associations + if (!$this->deleteByType( $table->menutype )) { + $this->setError( $this->getError() ); + return false; + } + + // TODO: Should invoke JModuleModel::delete to delete the actual module + $moduleTable= &JTable::getInstance( 'module'); + $items = &$this->getModules( $table->menutype ); + $modulesIds = array(); + foreach ($items as $item) + { + if (!$moduleTable->delete( $item->id )) { + $this->setError( $moduleTable->getErrorMsg() ); + return false; + } + $modulesIds[] = (int) $item->id; + } + + if (count( $modulesIds )) { + $query = 'DELETE FROM #__modules_menu' . + ' WHERE menuid = '.implode( ' OR moduleid = ', $modulesIds ); + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $menuTable->getErrorMsg() ); + return false; + } + } + + $result = $table->delete(); + + return $result; + } + + /** + * Delete menu items by type + */ + function deleteByType( $type = '' ) + { + if (!$type) { + return false; + } + $db = &$this->getDBO(); + $query = 'DELETE FROM #__menu' . + ' WHERE menutype = '.$db->Quote( $type ); + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $menuTable->getErrorMsg() ); + return false; + } + + // clean cache + MenusHelper::cleanCache(); + + return true; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_menus/models/metadata/component.xml b/oss/joomla/trunk/administrator/components/com_menus/models/metadata/component.xml new file mode 100644 index 00000000..686d7cf3 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/models/metadata/component.xml @@ -0,0 +1,24 @@ + + + + Component + Component Parameters + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/models/metadata/index.html b/oss/joomla/trunk/administrator/components/com_menus/models/metadata/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/models/metadata/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/models/metadata/menulink.xml b/oss/joomla/trunk/administrator/components/com_menus/models/metadata/menulink.xml new file mode 100644 index 00000000..c4a6e28b --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/models/metadata/menulink.xml @@ -0,0 +1,11 @@ + + + + Menu Link + Menu Link parameters... + + + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/models/metadata/separator.xml b/oss/joomla/trunk/administrator/components/com_menus/models/metadata/separator.xml new file mode 100644 index 00000000..1eb0dfe7 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/models/metadata/separator.xml @@ -0,0 +1,11 @@ + + + + Separator + Separator parameters... + + + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/models/metadata/url.xml b/oss/joomla/trunk/administrator/components/com_menus/models/metadata/url.xml new file mode 100644 index 00000000..fb7dc359 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/models/metadata/url.xml @@ -0,0 +1,11 @@ + + + + External Link + External link parameters... + + + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/index.html b/oss/joomla/trunk/administrator/components/com_menus/views/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/views/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/item/index.html b/oss/joomla/trunk/administrator/components/com_menus/views/item/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/views/item/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/item/tmpl/form.php b/oss/joomla/trunk/administrator/components/com_menus/views/item/tmpl/form.php new file mode 100644 index 00000000..97d44214 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/views/item/tmpl/form.php @@ -0,0 +1,204 @@ + + + +
    + + + + + + +
    + +
    + + + +
    + +
    +

    name; ?>

    +
    + description; ?> +
    +
    + +
    + + + + + item->id) { ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + : + + item->id; ?> +
    + : + + +
    + : + + +
    + : + + lists->disabled;?> /> +
    + : + + menutypes, 'menutype', 'class="inputbox" size="1"', 'menutype', 'title', $this->item->menutype );?> +
    + : + + item ); ?> +
    + : + + lists->published ?> +
    + : + + item, $this->item->id ); ?> +
    + : + + item ); ?> +
    + : + + item ); ?> +
    +
    +
    + pane->startPane("menu-pane"); + echo $this->pane->startPanel(JText :: _('Parameters - Basic'), "param-page"); + echo $this->urlparams->render('urlparams'); + if(count($this->params->getParams('params'))) : + echo $this->params->render('params'); + endif; + + if(!count($this->params->getNumParams('params')) && !count($this->urlparams->getNumParams('urlparams'))) : + echo "
    ".JText::_('There are no parameters for this item')."
    "; + endif; + echo $this->pane->endPanel(); + + if($params = $this->advanced->render('params')) : + echo $this->pane->startPanel(JText :: _('Parameters - Advanced'), "advanced-page"); + echo $params; + echo $this->pane->endPanel(); + endif; + + if ($this->comp && ($params = $this->comp->render('params'))) : + echo $this->pane->startPanel(JText :: _('Parameters - Component'), "component-page"); + echo $params; + echo $this->pane->endPanel(); + endif; + + if ($this->sysparams && ($params = $this->sysparams->render('params'))) : + echo $this->pane->startPanel(JText :: _('Parameters - System'), "system-page"); + echo $params; + echo $this->pane->endPanel(); + endif; + echo $this->pane->endPane(); + ?> +
    + + item->linkfield; ?> + + + + + + + +
    diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/item/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_menus/views/item/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/views/item/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/item/tmpl/type.php b/oss/joomla/trunk/administrator/components/com_menus/views/item/tmpl/type.php new file mode 100644 index 00000000..a0d52ab4 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/views/item/tmpl/type.php @@ -0,0 +1,46 @@ + + + +
    + + + + + +
    + +
    + + +
    +
    +
    + + + +
    \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/item/view.php b/oss/joomla/trunk/administrator/components/com_menus/views/item/view.php new file mode 100644 index 00000000..059de3c3 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/views/item/view.php @@ -0,0 +1,187 @@ +_layout = 'form'; + + $item = &$this->get('Item'); + + // clean item data + JFilterOutput::objectHTMLSafe( $item, ENT_QUOTES, '' ); + + // Set toolbar items for the page + if (!$item->id) { + JToolBarHelper::title( JText::_( 'Menu Item' ) .': [ '. JText::_( 'New' ) .' ]', 'menu.png' ); + } else { + JToolBarHelper::title( JText::_( 'Menu Item' ) .': [ '. JText::_( 'Edit' ) .' ]', 'menu.png' ); + } + JToolBarHelper::save(); + JToolBarHelper::apply(); + if ($item->id) { + // for existing items the button is renamed `close` + JToolBarHelper::cancel( 'cancelItem', 'Close' ); + } else { + JToolBarHelper::cancel('cancelItem'); + } + JToolBarHelper::help( 'screen.menus.edit' ); + + // Load component language files + $component = &$this->get('Component'); + $lang->load($component->option, JPATH_ADMINISTRATOR); + + // Initialize variables + $urlparams = $this->get( 'UrlParams' ); + $params = $this->get( 'StateParams' ); + $sysparams = $this->get( 'SystemParams' ); + $advanced = $this->get( 'AdvancedParams' ); + $component = $this->get( 'ComponentParams' ); + $name = $this->get( 'StateName' ); + $description = $this->get( 'StateDescription' ); + $menuTypes = MenusHelper::getMenuTypeList(); + $components = MenusHelper::getComponentList(); + + JHTML::_('behavior.tooltip'); + + $document = & JFactory::getDocument(); + if ($item->id) { + $document->setTitle(JText::_( 'Menu Item' ) .': ['. JText::_( 'Edit' ) .']'); + } else { + $document->setTitle(JText::_( 'Menu Item' ) .': ['. JText::_( 'New' ) .']'); + } + + // Was showing up null in some cases.... + if (!$item->published) { + $item->published = 0; + } + $lists = new stdClass(); + $lists->published = MenusHelper::Published($item); + $lists->disabled = ($item->type != 'url' ? 'readonly="true"' : ''); + + $item->expansion = null; + if ($item->type != 'url') { + $lists->disabled = 'readonly="true"'; + $item->linkfield = ''; + if (($item->id) && ($item->type == 'component') && (isset($item->linkparts['option']))) { + $item->expansion = '&expand='.trim(str_replace('com_', '', $item->linkparts['option'])); + } + } else { + $lists->disabled = null; + $item->linkfield = null; + } + + $this->assignRef('lists' , $lists); + $this->assignRef('item' , $item); + $this->assignRef('urlparams', $urlparams); + $this->assignRef('sysparams', $sysparams); + $this->assignRef('params' , $params); + $this->assignRef('advanced' , $advanced); + $this->assignRef('comp' , $component); + $this->assignRef('menutypes', $menuTypes); + $this->assignRef('name' , $name); + $this->assignRef('description', $description); + + // Add slider pane + // TODO: allowAllClose should default true in J!1.6, so remove the array when it does. + $pane = &JPane::getInstance('sliders', array('allowAllClose' => true)); + $this->assignRef('pane', $pane); + + parent::display($tpl); + } + + function type($tpl = null) + { + JRequest::setVar( 'hidemainmenu', 1 ); + + global $mainframe; + + $lang =& JFactory::getLanguage(); + $this->_layout = 'type'; + + $item = &$this->get('Item'); + + // Set toolbar items for the page + if (!$item->id) { + JToolBarHelper::title( JText::_( 'Menu Item' ) .': [ '. JText::_( 'New' ) .' ]', 'menu.png' ); + } else { + JToolBarHelper::title( JText::_( 'Change Menu Item' ), 'menu.png' ); + } + + // Set toolbar items for the page + JToolBarHelper::cancel('view'); + JToolBarHelper::help( 'screen.menus.edit' ); + + // Add scripts and stylesheets to the document + $document = & JFactory::getDocument(); + + if($lang->isRTL()){ + $document->addStyleSheet('components/com_menus/assets/type_rtl.css'); + } else { + $document->addStyleSheet('components/com_menus/assets/type.css'); + } + JHTML::_('behavior.tooltip'); + + // Load component language files + $components = MenusHelper::getComponentList(); + $n = count($components); + for($i = 0; $i < $n; $i++) + { + $path = JPATH_SITE.DS.'components'.DS.$components[$i]->option.DS.'views'; + $components[$i]->legacy = !is_dir($path); + + $lang->load($components[$i]->option, JPATH_ADMINISTRATOR); + } + + // Initialize variables + $item = &$this->get('Item'); + $expansion = &$this->get('Expansion'); + $component = &$this->get('Component'); + $name = $this->get( 'StateName' ); + $description = $this->get( 'StateDescription' ); + $menuTypes = MenusHelper::getMenuTypeList(); + + // Set document title + if ($item->id) { + $document->setTitle(JText::_( 'Menu Item' ) .': ['. JText::_( 'Edit' ) .']'); + } else { + $document->setTitle(JText::_( 'Menu Item' ) .': ['. JText::_( 'New' ) .']'); + } + + $this->assignRef('item', $item); + $this->assignRef('components', $components); + $this->assignRef('expansion', $expansion); + + parent::display($tpl); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/list/index.html b/oss/joomla/trunk/administrator/components/com_menus/views/list/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/views/list/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/list/tmpl/copy.php b/oss/joomla/trunk/administrator/components/com_menus/views/list/tmpl/copy.php new file mode 100644 index 00000000..f19daad4 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/views/list/tmpl/copy.php @@ -0,0 +1,50 @@ + + + + +
    + + + + + + +
    + : +
    + MenuList; ?> +

    +
    + : +
    +
      + items as $item ) : ?> +
    1. name; ?>
    2. + +
    +
    + + + + + +items as $item ) : ?> + + + +
    \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/list/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_menus/views/list/tmpl/default.php new file mode 100644 index 00000000..b4cc545b --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/views/list/tmpl/default.php @@ -0,0 +1,130 @@ + + +
    + + + + + + +
    + : + + + + + lists['levellist']; + echo $this->lists['state']; + ?> +
    + + + + + + + + + + + + + + + + + + + + + + items ); + $rows = &$this->items; + foreach ($rows as $row) : + $access = JHTML::_('grid.access', $row, $i ); + $checked = JHTML::_('grid.checkedout', $row, $i ); + $published = JHTML::_('grid.published', $row, $i ); + ?> + "> + + + + + + + + + + + + + +
    + + + + + lists['order_Dir'], @$this->lists['order'] ); ?> + + + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + ordering) echo JHTML::_('grid.order', $this->items ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> +
    + pagination->getListFooter(); ?> +
    + pagination->limitstart;?> + + + + user->get('id'), $row->checked_out ) ) : ?> + treename; ?> + + + treename; ?> + + + home == 1 ) : ?> + <?php echo JText::_( 'Default' ); ?> + +   + + + + + pagination->orderUpIcon( $i, $row->parent == 0 || $row->parent == @$rows[$i-1]->parent, 'orderup', 'Move Up', $this->ordering); ?> + pagination->orderDownIcon( $i, $n, $row->parent == 0 || $row->parent == @$rows[$i+1]->parent, 'orderdown', 'Move Down', $this->ordering ); ?> + ordering ? '' : 'disabled="disabled"'; ?> + class="text_area" style="text-align: center" /> + + + + type == 'component') ? $row->view : $row->type; ?> + + id; ?> +
    + + + + + + + + +
    \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/list/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_menus/views/list/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/views/list/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/list/tmpl/move.php b/oss/joomla/trunk/administrator/components/com_menus/views/list/tmpl/move.php new file mode 100644 index 00000000..7e23be35 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/views/list/tmpl/move.php @@ -0,0 +1,52 @@ + + + + +
    + + + + + + +
    + : +
    + MenuList ?> +

    +
    + + : + +
    +
      + items as $item ) : ?> +
    1. name; ?>
    2. + +
    +
    + + + + + +items as $item ) : ?> + + + +
    diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/list/view.php b/oss/joomla/trunk/administrator/components/com_menus/views/list/view.php new file mode 100644 index 00000000..872c5b82 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/views/list/view.php @@ -0,0 +1,188 @@ +_layout = 'default'; + + /* + * Set toolbar items for the page + */ + $menutype = $mainframe->getUserStateFromRequest( 'com_menus.menutype', 'menutype', 'mainmenu', 'string' ); + + JToolBarHelper::title( JText::_( 'MENU ITEM MANAGER' ) .': ['.$menutype.']', 'menu.png' ); + + $bar =& JToolBar::getInstance('toolbar'); + $bar->appendButton( 'Link', 'menus', 'Menus', "index.php?option=com_menus" ); + + JToolBarHelper::makeDefault( 'setdefault' ); + JToolBarHelper::publishList(); + JToolBarHelper::unpublishList(); + JToolBarHelper::customX( 'move', 'move.png', 'move_f2.png', 'Move', true ); + JToolBarHelper::customX( 'copy', 'copy.png', 'copy_f2.png', 'Copy', true ); + JToolBarHelper::trash(); + JToolBarHelper::editListX(); + JToolBarHelper::addNewX('newItem'); + JToolBarHelper::help( 'screen.menus' ); + + $document = & JFactory::getDocument(); + $document->setTitle(JText::_('View Menu Items')); + + $limitstart = JRequest::getVar('limitstart', '0', '', 'int'); + $items = &$this->get('Items'); + $pagination = &$this->get('Pagination'); + $lists = &$this->_getViewLists(); + $user = &JFactory::getUser(); + + // Ensure ampersands and double quotes are encoded in item titles + foreach ($items as $i => $item) { + $treename = $item->treename; + $treename = JFilterOutput::ampReplace($treename); + $treename = str_replace('"', '"', $treename); + $items[$i]->treename = $treename; + } + + //Ordering allowed ? + $ordering = ($lists['order'] == 'm.ordering'); + + JHTML::_('behavior.tooltip'); + + $this->assignRef('items', $items); + $this->assignRef('pagination', $pagination); + $this->assignRef('lists', $lists); + $this->assignRef('user', $user); + $this->assignRef('menutype', $menutype); + $this->assignRef('ordering', $ordering); + $this->assignRef('limitstart', $limitstart); + + parent::display($tpl); + } + + function copyForm($tpl=null) + { + global $mainframe; + + $this->_layout = 'copy'; + + /* + * Set toolbar items for the page + */ + JToolBarHelper::title( JText::_( 'Menu Items' ) . ': [ '. JText::_( 'Copy' ) .' ]' ); + JToolBarHelper::custom( 'doCopy', 'copy.png', 'copy_f2.png', 'Copy', false ); + JToolBarHelper::cancel('cancelItem'); + JToolBarHelper::help( 'screen.menus' ); + + $document = & JFactory::getDocument(); + $document->setTitle(JText::_('Copy Menu Items')); + + $menutype = $mainframe->getUserStateFromRequest( 'com_menus.menutype', 'menutype', 'mainmenu', 'string' ); + + // Build the menutypes select list + $menuTypes = MenusHelper::getMenuTypes(); + foreach ( $menuTypes as $menuType ) { + $menu[] = JHTML::_('select.option', $menuType, $menuType ); + } + $MenuList = JHTML::_('select.genericlist', $menu, 'menu', 'class="inputbox" size="10"', 'value', 'text', null ); + + $items = &$this->get('ItemsFromRequest'); + + $this->assignRef('menutype', $menutype); + $this->assignRef('items', $items); + $this->assignRef('menutypes', $menuTypes); + $this->assignRef('MenuList', $MenuList); + + parent::display($tpl); + } + + function moveForm($tpl=null) + { + global $mainframe; + + $this->_layout = 'move'; + + /* + * Set toolbar items for the page + */ + JToolBarHelper::title( JText::_( 'Menu Items' ) . ': [ '. JText::_( 'Move' ) .' ]' ); + JToolBarHelper::custom( 'doMove', 'move.png', 'move_f2.png', 'Move', false ); + JToolBarHelper::cancel('cancelItem'); + JToolBarHelper::help( 'screen.menus' ); + + $document = & JFactory::getDocument(); + $document->setTitle(JText::_('Move Menu Items')); + + $menutype = $mainframe->getUserStateFromRequest( 'com_menus.menutype', 'menutype', 'mainmenu', 'string' ); + + // Build the menutypes select list + $menuTypes = MenusHelper::getMenuTypes(); + foreach ( $menuTypes as $menuType ) { + $menu[] = JHTML::_('select.option', $menuType, $menuType ); + } + $MenuList = JHTML::_('select.genericlist', $menu, 'menu', 'class="inputbox" size="10"', 'value', 'text', null ); + + $items = &$this->get('ItemsFromRequest'); + + $this->assignRef('menutype', $menutype); + $this->assignRef('items', $items); + $this->assignRef('menutypes', $menuTypes); + $this->assignRef('MenuList', $MenuList); + + parent::display($tpl); + } + + function &_getViewLists() + { + global $mainframe; + $db =& JFactory::getDBO(); + + $menutype = $mainframe->getUserStateFromRequest( "com_menus.menutype", 'menutype', 'mainmenu', 'string' ); + $filter_order = $mainframe->getUserStateFromRequest( "com_menus.$menutype.filter_order", 'filter_order', 'm.ordering', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( "com_menus.$menutype.filter_order_Dir", 'filter_order_Dir', 'ASC', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( "com_menus.$menutype.filter_state", 'filter_state', '', 'word' ); + $levellimit = $mainframe->getUserStateFromRequest( "com_menus.$menutype.levellimit", 'levellimit', 10, 'int' ); + $search = $mainframe->getUserStateFromRequest( "com_menus.$menutype.search", 'search', '', 'string' ); + $search = JString::strtolower( $search ); + + // level limit filter + $lists['levellist'] = JHTML::_('select.integerlist', 1, 20, 1, 'levellimit', 'size="1" onchange="document.adminForm.submit();"', $levellimit ); + + // 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; + + return $lists; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/menus/index.html b/oss/joomla/trunk/administrator/components/com_menus/views/menus/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/views/menus/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/menus/tmpl/copy.php b/oss/joomla/trunk/administrator/components/com_menus/views/menus/tmpl/copy.php new file mode 100644 index 00000000..d1b8122b --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/views/menus/tmpl/copy.php @@ -0,0 +1,63 @@ + + + +
    + + + + + + + + + + +
    + : +
    + +


    + : +
    + +

    +
    + : +
    + table->menutype; ?> +

    + : +
    +
      + items as $item) : ?> +
    1. + name; ?> +
    2. + + +
    +
     
    + + + + + +
    \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/menus/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_menus/views/menus/tmpl/default.php new file mode 100644 index 00000000..19932563 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/views/menus/tmpl/default.php @@ -0,0 +1,135 @@ + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + menus as $menu) : ?> + id; + $linkA = 'index.php?option=com_menus&task=view&menutype='. $menu->menutype; + ?> + "> + + + + + + + + + + + + + + +
    + + +   + + + + + + + + + + + + + + + + +
    + pagination->getListFooter(); ?> +
    + pagination->limitstart + 1 + $i; ?> + + + + + + title; ?> + + menutype; ?> + + + + + published; + ?> + + unpublished; + ?> + + trash; + ?> + + modules; + ?> + + id; + ?> +
    + + + + + +
    diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/menus/tmpl/delete.php b/oss/joomla/trunk/administrator/components/com_menus/views/menus/tmpl/delete.php new file mode 100644 index 00000000..1733362d --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/views/menus/tmpl/delete.php @@ -0,0 +1,42 @@ + + + +
    +
    +
    + modules ) : ?> + : +
      + modules as $module ) : ?> +
    1. title; ?>
    2. + +
    + +
    +
    + : +
      + menuItems as $item) : ?> +
    1. name; ?>
    2. + +
    +
    +
    +
    + + + + + +
    \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/menus/tmpl/edit.php b/oss/joomla/trunk/administrator/components/com_menus/views/menus/tmpl/edit.php new file mode 100644 index 00000000..0c695cf5 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/views/menus/tmpl/edit.php @@ -0,0 +1,88 @@ + + + +
    + + + + + + + + + + + + + + + isnew) : ?> + + + + + +
    + + + +
    + + + + +
    + + + + +
    + + + + +
    + + + + + +
    \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/menus/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_menus/views/menus/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/views/menus/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/menus/view.php b/oss/joomla/trunk/administrator/components/com_menus/views/menus/view.php new file mode 100644 index 00000000..f1ba5c36 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_menus/views/menus/view.php @@ -0,0 +1,142 @@ +_layout = 'default'; + + // Set toolbar items for the page + JToolBarHelper::title( JText::_( 'Menu Manager' ), 'menumgr.png' ); + JToolBarHelper::customX( 'copyMenu', 'copy.png', 'copy_f2.png', 'Copy', true ); + JToolBarHelper::customX( 'deleteMenu', 'delete.png', 'delete_f2.png', 'Delete', true ); + JToolBarHelper::editListX('editMenu'); + JToolBarHelper::addNewX('addMenu'); + JToolBarHelper::help( 'screen.menumanager' ); + + $document = & JFactory::getDocument(); + $document->setTitle(JText::_('View Menus')); + + $limitstart = JRequest::getVar('limitstart', '0', '', 'int'); + + $menus = &$this->get('Menus'); + $pagination = &$this->get('Pagination'); + + $this->assignRef('menus', $menus); + $this->assignRef('pagination', $pagination); + $this->assignRef('limitstart', $limitstart); + + JHTML::_('behavior.tooltip'); + + parent::display($tpl); + } + + function copyForm($tpl=null) + { + global $mainframe; + + $this->_layout = 'copy'; + + // view data + $table = $this->get('Table'); + $items = $this->get('MenuItems'); + + /* + * Set toolbar items for the page + */ + JToolBarHelper::title( JText::_( 'Copy Menu' ) ); + JToolBarHelper::custom( 'doCopyMenu', 'copy.png', 'copy_f2.png', 'Copy', false ); + JToolBarHelper::cancel(); + JToolBarHelper::help( 'screen.menumanager' ); + + $document = & JFactory::getDocument(); + $document->setTitle(JText::_('Copy Menu Items')); + + $this->assignRef('items', $items); + $this->assignRef('table', $table); + + parent::display($tpl); + } + + function deleteForm($tpl=null) + { + global $mainframe; + + $this->_layout = 'delete'; + + /* + * Set toolbar items for the page + */ + JToolBarHelper::title( JText::_( 'Menu' ) . ': [ '. JText::_( 'Delete' ) .' ]' ); + JToolBarHelper::custom( 'doDeleteMenu', 'delete.png', 'delete_f2.png', 'Delete', false ); + JToolBarHelper::cancel(); + JToolBarHelper::help( 'screen.menumanager.delete' ); + + // view data + $table = $this->get('Table'); + $modules = $this->get('Modules'); + $menuItems = $this->get('MenuItems'); + + $document = & JFactory::getDocument(); + $document->setTitle(JText::_('Confirm Delete Menu Type') . ': ' . $table->menutype ); + + + $this->assignRef('table', $table); + $this->assignRef('modules', $modules); + $this->assignRef('menuItems', $menuItems); + + parent::display($tpl); + } + + function editForm($edit,$tpl=null) + { + JRequest::setVar( 'hidemainmenu', 1 ); + + global $mainframe; + + $this->_layout = 'edit'; + if($edit) + $table = &$this->get('Table'); + else + $table=& JTable::getInstance('menuTypes'); + /* + * Set toolbar items for the page + */ + $text = ( ($table->id != 0) ? JText::_( 'Edit' ) : JText::_( 'New' ) ); + JToolBarHelper::title( JText::_( 'Menu Details' ).': [ '. $text.' ]', 'menumgr.png' ); + JToolBarHelper::custom( 'savemenu', 'save.png', 'save_f2.png', 'Save', false ); + JToolBarHelper::cancel(); + JToolBarHelper::help( 'screen.menumanager.new' ); + + $this->assignRef('row', $table); + $this->assign('isnew', ($table->id == 0)); + + JHTML::_('behavior.tooltip'); + + parent::display($tpl); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_messages/admin.messages.html.php b/oss/joomla/trunk/administrator/components/com_messages/admin.messages.html.php new file mode 100644 index 00000000..09f8cb6c --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_messages/admin.messages.html.php @@ -0,0 +1,296 @@ + +
    + + + + + + +
    + : + + + + + +
    + +
    + + + + + + + + + + + + + + + + + + state ? 'tick.png' : 'publish_x.png'; + $alt = $row->state ? JText::_( 'Read' ) : JText::_( 'Read' ); + + if ( $user->authorize( 'com_users', 'manage' ) ) { + $linkA = 'index.php?option=com_users&view=user&task=edit&cid[]='. $row->user_id_from; + $author = ''. $row->user_from .''; + } else { + $author = $row->user_from; + } + + ?> + "> + + + + + + + + + +
    + + + + + + + + + + + +
    + getListFooter(); ?> +
    + limitstart;?> + + message_id ); ?> + + + subject; ?> + + + <?php echo $alt; ?> + + + + date_time, JText::_('DATE_FORMAT_LC2')); ?> +
    +
    + + + + + + + +
    + + +
    + +
    + + + + + + + + + + + + + +
    + : + + +
    + : + + +
    + : + + + +
    +
    + + + + +
    + +
    + + + + + + + + + + + + + + + + + + +
    + : + + user_from;?> +
    + : + + date_time;?> +
    + : + + subject;?> +
    + : + +
    message, ENT_COMPAT, 'UTF-8' );?>
    +
    + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +
    + : + + +
    + : + + +
    + : + + +
    + + + + + +
    + getUserStateFromRequest( $context.'.filter_order', 'filter_order', 'a.date_time', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'.filter_order_Dir','filter_order_Dir', 'DESC', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( $context.'.filter_state', 'filter_state', '', 'word' ); + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $context.'.limitstart', 'limitstart', 0, 'int' ); + $search = $mainframe->getUserStateFromRequest( $context.'search', 'search', '', 'string' ); + $search = JString::strtolower( $search ); + + $where = array(); + $where[] = ' a.user_id_to='.(int) $user->get('id'); + + if ($search != '') { + $searchEscaped = $db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + $where[] = '( a.subject LIKE '.$searchEscaped.' OR a.message LIKE '.$searchEscaped.' )'; + } + if ( $filter_state ) { + if ( $filter_state == 'P' ) { + $where[] = 'a.state = 1'; + } else if ($filter_state == 'U' ) { + $where[] = 'a.state = 0'; + } + } + + $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', a.date_time DESC'; + + $query = 'SELECT COUNT(*)' + . ' FROM #__messages AS a' + . ' INNER JOIN #__users AS u ON u.id = a.user_id_from' + . $where + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pageNav = new JPagination( $total, $limitstart, $limit ); + + $query = 'SELECT a.*, u.name AS user_from' + . ' FROM #__messages AS a' + . ' INNER JOIN #__users AS u ON u.id = a.user_id_from' + . $where + . $orderby + ; + $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); + $rows = $db->loadObjectList(); + if ($db->getErrorNum()) { + echo $db->stderr(); + return false; + } + + // state filter + $lists['state'] = JHTML::_('grid.state', $filter_state, 'Read', 'Unread' ); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + HTML_messages::showMessages( $rows, $pageNav, $option, $lists ); +} + +function editConfig( $option ) +{ + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + $query = 'SELECT cfg_name, cfg_value' + . ' FROM #__messages_cfg' + . ' WHERE user_id = '.(int) $user->get('id') + ; + $db->setQuery( $query ); + $data = $db->loadObjectList( 'cfg_name' ); + + // initialize values if they do not exist + if (!isset($data['lock']->cfg_value)) { + $data['lock']->cfg_value = 0; + } + if (!isset($data['mail_on_new']->cfg_value)) { + $data['mail_on_new']->cfg_value = 0; + } + if (!isset($data['auto_purge']->cfg_value)) { + $data['auto_purge']->cfg_value = 7; + } + + $vars = array(); + $vars['lock'] = JHTML::_('select.booleanlist', "vars[lock]", '', $data['lock']->cfg_value, 'yes', 'no', 'varslock' ); + $vars['mail_on_new'] = JHTML::_('select.booleanlist', "vars[mail_on_new]", '', $data['mail_on_new']->cfg_value, 'yes', 'no', 'varsmail_on_new' ); + $vars['auto_purge'] = $data['auto_purge']->cfg_value; + + HTML_messages::editConfig( $vars, $option ); + +} + +function saveConfig( $option ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + $query = 'DELETE FROM #__messages_cfg' + . ' WHERE user_id = '.(int) $user->get('id') + ; + $db->setQuery( $query ); + $db->query(); + + $vars = JRequest::getVar( 'vars', array(), 'post', 'array' ); + foreach ($vars as $k=>$v) { + $v = $db->getEscaped( $v ); + $query = 'INSERT INTO #__messages_cfg' + . ' ( user_id, cfg_name, cfg_value )' + . ' VALUES ( '.(int) $user->get('id').', '.$db->Quote($k).', '.$db->Quote($v).' )' + ; + $db->setQuery( $query ); + $db->query(); + } + $mainframe->redirect( "index.php?option=$option" ); +} + +function newMessage( $option, $user, $subject ) +{ + $db =& JFactory::getDBO(); + $acl =& JFactory::getACL(); + + // get available backend user groups + $gid = $acl->get_group_id( 'Public Backend', 'ARO' ); + $gids = $acl->get_group_children( $gid, 'ARO', 'RECURSE' ); + JArrayHelper::toInteger($gids, array(0)); + $gids = implode( ',', $gids ); + + // get list of usernames + $recipients = array( JHTML::_('select.option', '0', '- '. JText::_( 'Select User' ) .' -' ) ); + $query = 'SELECT id AS value, username AS text FROM #__users' + . ' WHERE gid IN ( '.$gids.' )' + . ' ORDER BY name' + ; + $db->setQuery( $query ); + $recipients = array_merge( $recipients, $db->loadObjectList() ); + + $recipientslist = + JHTML::_('select.genericlist', $recipients, 'user_id_to', 'class="inputbox" size="1"', 'value', 'text', $user); + HTML_messages::newMessage($option, $recipientslist, $subject ); +} + +function saveMessage( $option ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + require_once(dirname(__FILE__).DS.'tables'.DS.'message.php'); + + $db =& JFactory::getDBO(); + $row = new TableMessage( $db ); + + if (!$row->bind(JRequest::get('post'))) { + JError::raiseError(500, $row->getError() ); + } + + if (!$row->check()) { + JError::raiseError(500, $row->getError() ); + } + + if (!$row->send()) { + $mainframe->redirect( "index.php?option=com_messages", $row->getError() ); + } + $mainframe->redirect( "index.php?option=com_messages" ); +} + +function viewMessage( $uid='0', $option ) +{ + $db =& JFactory::getDBO(); + + $query = 'SELECT a.*, u.name AS user_from' + . ' FROM #__messages AS a' + . ' INNER JOIN #__users AS u ON u.id = a.user_id_from' + . ' WHERE a.message_id = '.(int) $uid + . ' ORDER BY date_time DESC' + ; + $db->setQuery( $query ); + $row = $db->loadObject(); + + $query = 'UPDATE #__messages' + . ' SET state = 1' + . ' WHERE message_id = '.(int) $uid + ; + $db->setQuery( $query ); + $db->query(); + + HTML_messages::viewMessage( $row, $option ); +} + +function removeMessage( $cid, $option ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + + JArrayHelper::toInteger($cid); + + if (count( $cid ) < 1) { + JError::raiseError(500, JText::_( 'Select an item to delete' ) ); + } + + if (count( $cid )) + { + $cids = implode( ',', $cid ); + $query = 'DELETE FROM #__messages' + . ' WHERE message_id IN ( '. $cids .' )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + echo "\n"; + } + } + + $limit = JRequest::getVar( 'limit', 10, '', 'int' ); + $limitstart = JRequest::getVar( 'limitstart', 0, '', 'int' ); + + $mainframe->redirect( 'index.php?option='.$option.'&limit='.$limit.'&limitstart='.$limitstart ); +} diff --git a/oss/joomla/trunk/administrator/components/com_messages/index.html b/oss/joomla/trunk/administrator/components/com_messages/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_messages/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_messages/messages.xml b/oss/joomla/trunk/administrator/components/com_messages/messages.xml new file mode 100644 index 00000000..72497e2b --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_messages/messages.xml @@ -0,0 +1,12 @@ + + + Messaging + Joomla! Project + 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 + Messaging + diff --git a/oss/joomla/trunk/administrator/components/com_messages/tables/index.html b/oss/joomla/trunk/administrator/components/com_messages/tables/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_messages/tables/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_messages/tables/message.php b/oss/joomla/trunk/administrator/components/com_messages/tables/message.php new file mode 100644 index 00000000..4cfbcd53 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_messages/tables/message.php @@ -0,0 +1,187 @@ +user_id_from; + $toId = $toId ? $toId : $this->user_id_to; + $subject = $subject ? $subject : $this->subject; + $message = $message ? $message : $this->message; + } + + $query = 'SELECT cfg_name, cfg_value' . + ' FROM #__messages_cfg' . + ' WHERE user_id = '.(int) $toId; + $db->setQuery($query); + + $config = $db->loadObjectList('cfg_name'); + $locked = @ $config['lock']->cfg_value; + $domail = @ $config['mail_on_new']->cfg_value; + + if (!$locked) + { + $this->user_id_from = $fromId; + $this->user_id_to = $toId; + $this->subject = $subject; + $this->message = $message; + $date =& JFactory::getDate(); + $this->date_time = $date->toMySQL(); + + if ($this->store()) + { + if ($domail) + { + $query = 'SELECT name, email' . + ' FROM #__users' . + ' WHERE id = '.(int) $fromId; + $db->setQuery($query); + $fromObject = $db->loadObject(); + $fromname = $fromObject->name; + $mailfrom = $fromObject->email; + $siteURL = JURI::base(); + $sitename = $mainframe->getCfg( 'sitename' ); + + $query = 'SELECT email' . + ' FROM #__users' . + ' WHERE id = '.(int) $toId; + $db->setQuery($query); + $recipient = $db->loadResult(); + + $subject = sprintf (JText::_('A new private message has arrived'), $sitename); + $msg = sprintf (JText::_('Please login to read your message'), $siteURL); + + JUtility::sendMail($mailfrom, $fromname, $recipient, $subject, $msg); + } + return true; + } + } + else + { + if (is_object($this)) { + $this->setError(JText::_('MESSAGE_FAILED')); + } + } + return false; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_messages/toolbar.messages.html.php b/oss/joomla/trunk/administrator/components/com_messages/toolbar.messages.html.php new file mode 100644 index 00000000..e9c072bd --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_messages/toolbar.messages.html.php @@ -0,0 +1,55 @@ + +
    + + + + + + +
    + : + + + + + +
    + + + + + + + + + + + id == 0 ) { + ?> + + + + + + + + + + + + + + + id .'&task=edit&cid[]='. $row->id ); + + $access = JHTML::_('grid.access', $row, $i ); + $checked = JHTML::_('grid.checkedout', $row, $i ); + $published = JHTML::_('grid.published', $row, $i ); + ?> + "> + + + + + + id == 0 ) { + ?> + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + +
    + getListFooter(); ?> +
    + getRowOffset( $i ); ?> + + + + get ('id'), $row->checked_out ) ) { + echo $row->title; + } else { + ?> + + + title; ?> + + + + + + orderUpIcon( $i, ($row->position == @$rows[$i-1]->position), 'orderup', 'Move Up', $ordering ); ?> + orderDownIcon( $i, $n, ($row->position == @$rows[$i+1]->position),'orderdown', 'Move Down', $ordering ); ?> + + class="text_area" style="text-align: center" /> + + + + position; ?> + + pages )) { + echo JText::_( 'None' ); + } else if ($row->pages > 0) { + echo JText::_( 'Varies' ); + } else { + echo JText::_( 'All' ); + } + ?> + + module ? $row->module : JText::_( 'User' );?> + + id;?> +
    + + + + + + + + +
    + $row is passed with the id + * property set to 0. + * @param JTableCategory The category object + * @param array

    The modules of the left side. The array elements are in the form + * $leftorder[order] = label + * where order is the module order from the db table and label is a + * text label associciated with the order.

    + * @param array See notes for leftorder + * @param array An array of select lists + * @param object Parameters + */ + function edit( &$model, &$row, &$orders2, &$lists, &$params, $client ) + { + JRequest::setVar( 'hidemainmenu', 1 ); + + // clean item data + JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'content' ); + + // Check for component metadata.xml file + //$path = JApplicationHelper::getPath( 'mod'.$client->id.'_xml', $row->module ); + //$params = new JParameter( $row->params, $path ); + $document =& JFactory::getDocument(); + + JHTML::_('behavior.combobox'); + + jimport('joomla.html.pane'); + // TODO: allowAllClose should default true in J!1.6, so remove the array when it does. + $pane = &JPane::getInstance('sliders', array('allowAllClose' => true)); + $editor =& JFactory::getEditor(); + + JHTML::_('behavior.tooltip'); + ?> + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + : + + + module); ?> + +
    + + + +
    + : + + +
    + : + + +
    + + + + + +
    + + + +
    + + + +
    + : + + id; ?> +
    + : + + description); ?> +
    +
    +
    + + + + + + + + + + + +
    + : + + client_id != 1) : ?> + pages == 'all') { ?> + + + + pages == 'none') { ?> + + + + + + + + + +
    + : + + +
    + client_id != 1) : ?> + pages == 'all') { ?> + + pages == 'none') { ?> + + + + +
    +
    + +
    +
    + + + startPane("menu-pane"); + echo $pane->startPanel(JText :: _('Module Parameters'), "param-page"); + $p = $params; + if($params = $p->render('params')) : + echo $params; + else : + echo "
    ".JText::_('There are no parameters for this item')."
    "; + endif; + echo $pane->endPanel(); + + if ($p->getNumParams('advanced')) { + echo $pane->startPanel(JText :: _('Advanced Parameters'), "advanced-page"); + if($params = $p->render('params', 'advanced')) : + echo $params; + else : + echo "
    ".JText::_('There are no advanced parameters for this item')."
    "; + endif; + echo $pane->endPanel(); + } + + if ($p->getNumParams('legacy')) { + echo $pane->startPanel(JText :: _('Legacy Parameters'), "legacy-page"); + if($params = $p->render('params', 'legacy')) : + echo $params; + else : + echo "
    ".JText::_('There are no legacy parameters for this item')."
    "; + endif; + echo $pane->endPanel(); + } + + + if ($p->getNumParams('other')) { + echo $pane->startPanel(JText :: _('Other Parameters'), "other-page"); + if($params = $p->render('params', 'other')) : + echo $params; + else : + echo "
    ".JText::_('There are no other parameters for this item')."
    "; + endif; + echo $pane->endPanel(); + } + echo $pane->endPane(); + ?> +
    +
    +
    + + module || $row->module == 'custom' || $row->module == 'mod_custom' ) { + ?> +
    + + + display( 'content', $row->content, '100%', '400', '60', '20', array('pagebreak', 'readmore') ) ; + ?> + +
    + + + + + + + + + + +
    + + + + + + + + + + +
    + +
    + + + + + + + + + + + + + + + + = $count) : + ?> + + module . '&created=1&client=' . $client->id; + ?> + + + + + +
    + +
      +
      + + name, ENT_QUOTES, 'UTF-8'); ?> +
    + + + + + + + +
    + authorize( 'com_modules', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} + +// Require the base controller +require_once (JPATH_COMPONENT.DS.'controller.php'); + +// Create the controller +$controller = new ModulesController( array( 'default_task' => 'view' )); + +// Perform the Request task +$controller->execute( JRequest::getCmd('task', 'view') ); + +// Redirect if set by the controller +$controller->redirect(); diff --git a/oss/joomla/trunk/administrator/components/com_modules/controller.php b/oss/joomla/trunk/administrator/components/com_modules/controller.php new file mode 100644 index 00000000..2ae42ac4 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_modules/controller.php @@ -0,0 +1,830 @@ +registerTask( 'apply', 'save' ); + $this->registerTask( 'unpublish', 'publish' ); + $this->registerTask( 'orderup', 'reorder' ); + $this->registerTask( 'orderdown', 'reorder' ); + $this->registerTask( 'accesspublic', 'access' ); + $this->registerTask( 'accessregistered','access' ); + $this->registerTask( 'accessspecial', 'access' ); + } + + /** + * Compiles a list of installed or defined modules + */ + function view() + { + global $mainframe; + + // Initialize some variables + $db =& JFactory::getDBO(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $option = 'com_modules'; + + $filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'm.position', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( $option.'filter_state', 'filter_state', '', 'word' ); + $filter_position = $mainframe->getUserStateFromRequest( $option.'filter_position', 'filter_position', '', 'cmd' ); + $filter_type = $mainframe->getUserStateFromRequest( $option.'filter_type', 'filter_type', '', 'cmd' ); + $filter_assigned = $mainframe->getUserStateFromRequest( $option.'filter_assigned', 'filter_assigned', '', 'cmd' ); + $search = $mainframe->getUserStateFromRequest( $option.'search', 'search', '', 'string' ); + $search = JString::strtolower( $search ); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); + + $where[] = 'm.client_id = '.(int) $client->id; + + $joins[] = 'LEFT JOIN #__users AS u ON u.id = m.checked_out'; + $joins[] = 'LEFT JOIN #__groups AS g ON g.id = m.access'; + $joins[] = 'LEFT JOIN #__modules_menu AS mm ON mm.moduleid = m.id'; + + // used by filter + if ( $filter_assigned ) { + $joins[] = 'LEFT JOIN #__templates_menu AS t ON t.menuid = mm.menuid'; + $where[] = 't.template = '.$db->Quote($filter_assigned); + } + if ( $filter_position ) { + $where[] = 'm.position = '.$db->Quote($filter_position); + } + if ( $filter_type ) { + $where[] = 'm.module = '.$db->Quote($filter_type); + } + if ( $search ) { + $where[] = 'LOWER( m.title ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + if ( $filter_state ) { + if ( $filter_state == 'P' ) { + $where[] = 'm.published = 1'; + } else if ($filter_state == 'U' ) { + $where[] = 'm.published = 0'; + } + } + + $where = ' WHERE ' . implode( ' AND ', $where ); + $join = ' ' . implode( ' ', $joins ); + if ($filter_order == 'm.ordering') { + $orderby = ' ORDER BY m.position, m.ordering '. $filter_order_Dir; + } else { + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', m.ordering ASC'; + } + + // get the total number of records + $query = 'SELECT COUNT(DISTINCT m.id)' + . ' FROM #__modules AS m' + . $join + . $where + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pageNav = new JPagination( $total, $limitstart, $limit ); + + $query = 'SELECT m.*, u.name AS editor, g.name AS groupname, MIN(mm.menuid) AS pages' + . ' FROM #__modules AS m' + . $join + . $where + . ' GROUP BY m.id' + . $orderby + ; + $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); + $rows = $db->loadObjectList(); + if ($db->getErrorNum()) { + echo $db->stderr(); + return false; + } + + // get list of Positions for dropdown filter + $query = 'SELECT m.position AS value, m.position AS text' + . ' FROM #__modules as m' + . ' WHERE m.client_id = '.(int) $client->id + . ' GROUP BY m.position' + . ' ORDER BY m.position' + ; + $positions[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Position' ) .' -' ); + $db->setQuery( $query ); + $positions = array_merge( $positions, $db->loadObjectList() ); + $lists['position'] = JHTML::_('select.genericlist', $positions, 'filter_position', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "$filter_position" ); + + // get list of Positions for dropdown filter + $query = 'SELECT module AS value, module AS text' + . ' FROM #__modules' + . ' WHERE client_id = '.(int) $client->id + . ' GROUP BY module' + . ' ORDER BY module' + ; + $db->setQuery( $query ); + $types[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Type' ) .' -' ); + $types = array_merge( $types, $db->loadObjectList() ); + $lists['type'] = JHTML::_('select.genericlist', $types, 'filter_type', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "$filter_type" ); + + // state filter + $lists['state'] = JHTML::_('grid.state', $filter_state ); + + // template assignment filter + $query = 'SELECT DISTINCT(template) AS text, template AS value'. + ' FROM #__templates_menu' . + ' WHERE client_id = '.(int) $client->id; + $db->setQuery( $query ); + $assigned[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Template' ) .' -' ); + $assigned = array_merge( $assigned, $db->loadObjectList() ); + $lists['assigned'] = JHTML::_('select.genericlist', $assigned, 'filter_assigned', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "$filter_assigned" ); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + require_once( JApplicationHelper::getPath( 'admin_html' ) ); + HTML_modules::view( $rows, $client, $pageNav, $lists ); + } + + /** + * Compiles information to add or edit a module + * @param string The current GET/POST option + * @param integer The unique id of the record to edit + */ + function copy() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $db =& JFactory::getDBO(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + $n = count( $cid ); + + if ($n == 0) { + return JError::raiseWarning( 500, JText::_( 'No items selected' ) ); + } + + $row =& JTable::getInstance('module'); + $tuples = array(); + + foreach ($cid as $id) + { + // load the row from the db table + $row->load( (int) $id ); + $row->title = JText::sprintf( 'Copy of', $row->title ); + $row->id = 0; + $row->iscore = 0; + $row->published = 0; + + if (!$row->check()) { + return JError::raiseWarning( 500, $row->getError() ); + } + if (!$row->store()) { + return JError::raiseWarning( 500, $row->getError() ); + } + $row->checkin(); + + $row->reorder( 'position='.$db->Quote( $row->position ).' AND client_id='.(int) $client->id ); + + $query = 'SELECT menuid' + . ' FROM #__modules_menu' + . ' WHERE moduleid = '.(int) $cid[0] + ; + $db->setQuery( $query ); + $rows = $db->loadResultArray(); + + foreach ($rows as $menuid) { + $tuples[] = '('.(int) $row->id.','.(int) $menuid.')'; + } + } + + if (!empty( $tuples )) + { + // Module-Menu Mapping: Do it in one query + $query = 'INSERT INTO #__modules_menu (moduleid,menuid) VALUES '.implode( ',', $tuples ); + $db->setQuery( $query ); + if (!$db->query()) { + return JError::raiseWarning( 500, $db->getError() ); + } + } + + $msg = JText::sprintf( 'Items Copied', $n ); + $this->setRedirect( 'index.php?option=com_modules&client='. $client->id, $msg ); + } + + /** + * Saves the module after an edit form submit + */ + function save() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + global $mainframe; + + // Initialize some variables + $db =& JFactory::getDBO(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); + + $post = JRequest::get( 'post' ); + // fix up special html fields + $post['content'] = JRequest::getVar( 'content', '', 'post', 'string', JREQUEST_ALLOWRAW ); + $post['client_id'] = $client->id; + + $row =& JTable::getInstance('module'); + + if (!$row->bind( $post, 'selections' )) { + return JError::raiseWarning( 500, $row->getError() ); + } + + if (!$row->check()) { + return JError::raiseWarning( 500, $row->getError() ); + } + + // if new item, order last in appropriate group + if (!$row->id) { + $where = 'position='.$db->Quote( $row->position ).' AND client_id='.(int) $client->id ; + $row->ordering = $row->getNextOrder( $where ); + } + + if (!$row->store()) { + return JError::raiseWarning( 500, $row->getError() ); + } + $row->checkin(); + + $menus = JRequest::getVar( 'menus', '', 'post', 'word' ); + $selections = JRequest::getVar( 'selections', array(), 'post', 'array' ); + JArrayHelper::toInteger($selections); + + // delete old module to menu item associations + $query = 'DELETE FROM #__modules_menu' + . ' WHERE moduleid = '.(int) $row->id + ; + $db->setQuery( $query ); + if (!$db->query()) { + return JError::raiseWarning( 500, $db->getError() ); + } + + // check needed to stop a module being assigned to `All` + // and other menu items resulting in a module being displayed twice + if ( $menus == 'all' ) { + // assign new module to `all` menu item associations + $query = 'INSERT INTO #__modules_menu' + . ' SET moduleid = '.(int) $row->id.' , menuid = 0' + ; + $db->setQuery( $query ); + if (!$db->query()) { + return JError::raiseWarning( 500, $db->getError() ); + } + } + else + { + foreach ($selections as $menuid) + { + // this check for the blank spaces in the select box that have been added for cosmetic reasons + if ( (int) $menuid >= 0 ) { + // assign new module to menu item associations + $query = 'INSERT INTO #__modules_menu' + . ' SET moduleid = '.(int) $row->id .', menuid = '.(int) $menuid + ; + $db->setQuery( $query ); + if (!$db->query()) { + return JError::raiseWarning( 500, $db->getError() ); + } + } + } + } + + // clean cache for all 3 front-end user groups (guest, reg, special) + $cache =& JFactory::getCache(); + $cache->remove($row->id . '0', $row->module); + $cache->remove($row->id . '1', $row->module); + $cache->remove($row->id . '2', $row->module); + // clean content cache because of loadposition plugin + $cache->clean( 'com_content' ); + + $this->setMessage( JText::_( 'Item saved' ) ); + switch ($this->getTask()) + { + case 'apply': + $this->setRedirect( 'index.php?option=com_modules&client='. $client->id .'&task=edit&id='. $row->id ); + break; + } + } + + /** + * Compiles information to add or edit a module + * @param string The current GET/POST option + * @param integer The unique id of the record to edit + */ + function edit( ) + { + // Initialize some variables + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $module = JRequest::getVar( 'module', '', '', 'cmd' ); + $id = JRequest::getVar( 'id', 0, 'method', 'int' ); + $cid = JRequest::getVar( 'cid', array( $id ), 'method', 'array' ); + JArrayHelper::toInteger($cid, array(0)); + + $model = &$this->getModel('module'); + $model->setState( 'id', $cid[0] ); + $model->setState( 'clientId', $client->id ); + + $lists = array(); + $row =& JTable::getInstance('module'); + // load the row from the db table + $row->load( (int) $cid[0] ); + // fail if checked out not by 'me' + if ($row->isCheckedOut( $user->get('id') )) { + $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); + return JError::raiseWarning( 500, JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The module' ), $row->title ) ); + } + + $row->content = htmlspecialchars($row->content, ENT_COMPAT, 'UTF-8'); + + if ( $cid[0] ) { + $row->checkout( $user->get('id') ); + } + // if a new record we must still prime the JTableModel object with a default + // position and the order; also add an extra item to the order list to + // place the 'new' record in last position if desired + if ($cid[0] == 0) { + $row->position = 'left'; + $row->showtitle = true; + $row->published = 1; + //$row->ordering = $l; + + $row->module = $module; + } + + if ($client->id == 1) + { + $where = 'client_id = 1'; + $lists['client_id'] = 1; + $path = 'mod1_xml'; + } + else + { + $where = 'client_id = 0'; + $lists['client_id'] = 0; + $path = 'mod0_xml'; + } + + $query = 'SELECT position, ordering, showtitle, title' + . ' FROM #__modules' + . ' WHERE '. $where + . ' ORDER BY ordering' + ; + $db->setQuery( $query ); + $orders = $db->loadObjectList(); + if ($db->getErrorNum()) { + echo $db->stderr(); + return false; + } + + $orders2 = array(); + + $l = 0; + $r = 0; + for ($i=0, $n=count( $orders ); $i < $n; $i++) { + $ord = 0; + if (array_key_exists( $orders[$i]->position, $orders2 )) { + $ord =count( array_keys( $orders2[$orders[$i]->position] ) ) + 1; + } + + $orders2[$orders[$i]->position][] = JHTML::_('select.option', $ord, $ord.'::'.addslashes( $orders[$i]->title ) ); + } + + // get selected pages for $lists['selections'] + if ( $cid[0] ) { + $query = 'SELECT menuid AS value' + . ' FROM #__modules_menu' + . ' WHERE moduleid = '.(int) $row->id + ; + $db->setQuery( $query ); + $lookup = $db->loadObjectList(); + if (empty( $lookup )) { + $lookup = array( JHTML::_('select.option', '-1' ) ); + $row->pages = 'none'; + } elseif (count($lookup) == 1 && $lookup[0]->value == 0) { + $row->pages = 'all'; + } else { + $row->pages = null; + } + } else { + $lookup = array( JHTML::_('select.option', 0, JText::_( 'All' ) ) ); + $row->pages = 'all'; + } + + if ( $row->access == 99 || $row->client_id == 1 || $lists['client_id'] ) { + $lists['access'] = 'Administrator'; + $lists['showtitle'] = 'N/A '; + $lists['selections'] = 'N/A'; + } else { + if ( $client->id == '1' ) { + $lists['access'] = 'N/A'; + $lists['selections'] = 'N/A'; + } else { + $lists['access'] = JHTML::_('list.accesslevel', $row ); + + $selections = JHTML::_('menu.linkoptions'); + $lists['selections'] = JHTML::_('select.genericlist', $selections, 'selections[]', 'class="inputbox" size="15" multiple="multiple"', 'value', 'text', $lookup, 'selections' ); + } + $lists['showtitle'] = JHTML::_('select.booleanlist', 'showtitle', 'class="inputbox"', $row->showtitle ); + } + + // build the html select list for published + $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published ); + + $row->description = ''; + + $lang =& JFactory::getLanguage(); + if ( $client->id != '1' ) { + $lang->load( trim($row->module), JPATH_SITE ); + } else { + $lang->load( trim($row->module) ); + } + + // xml file for module + if ($row->module == 'custom') { + $xmlfile = JApplicationHelper::getPath( $path, 'mod_custom' ); + } else { + $xmlfile = JApplicationHelper::getPath( $path, $row->module ); + } + + $data = JApplicationHelper::parseXMLInstallFile($xmlfile); + if ($data) + { + foreach($data as $key => $value) { + $row->$key = $value; + } + } + + // get params definitions + $params = new JParameter( $row->params, $xmlfile, 'module' ); + + require_once( JApplicationHelper::getPath( 'admin_html' ) ); + HTML_modules::edit( $model, $row, $orders2, $lists, $params, $client ); + } + + /** + * Displays a list to select the creation of a new module + */ + function add() + { + global $mainframe; + + // Initialize some variables + $modules = array(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + + // path to search for modules + if ($client->id == '1') { + $path = JPATH_ADMINISTRATOR.DS.'modules'; + $langbase = JPATH_ADMINISTRATOR; + } else { + $path = JPATH_ROOT.DS.'modules'; + $langbase = JPATH_ROOT; + } + + jimport('joomla.filesystem.folder'); + $dirs = JFolder::folders( $path ); + $lang =& JFactory::getLanguage(); + + foreach ($dirs as $dir) + { + if (substr( $dir, 0, 4 ) == 'mod_') + { + $files = JFolder::files( $path.DS.$dir, '^([_A-Za-z0-9]*)\.xml$' ); + $module = new stdClass; + $module->file = $files[0]; + $module->module = str_replace( '.xml', '', $files[0] ); + $module->path = $path.DS.$dir; + $modules[] = $module; + + $lang->load( $module->module, $langbase ); + } + } + + require_once( JPATH_COMPONENT.DS.'helpers'.DS.'xml.php' ); + ModulesHelperXML::parseXMLModuleFile( $modules, $client ); + + $n = count($modules); + for ($i = 0; $i < $n; $i++) { + $modules[$i]->name = JText::_(stripslashes($modules[$i]->name)); + } + + // sort array of objects alphabetically by name + JArrayHelper::sortObjects( $modules, 'name' ); + + require_once( JApplicationHelper::getPath( 'admin_html' ) ); + HTML_modules::add( $modules, $client ); + } + + /** + * Deletes one or more modules + * + * Also deletes associated entries in the #__module_menu table. + * @param array An array of unique category id numbers + */ + function remove() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $db =& JFactory::getDBO(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger( $cid ); + + if (empty( $cid )) { + return JError::raiseWarning( 500, 'No items selected' ); + } + + $cids = implode( ',', $cid ); + + // pasamio: Disabled this as it breaks the uninstall ability! + /*$query = 'SELECT id, module, title, iscore, params' + . ' FROM #__modules WHERE id IN ('.$cids.')' + ; + $db->setQuery( $query ); + if (!($rows = $db->loadObjectList())) { + return JError::raiseError( 500, $db->getErrorMsg() ); + }*/ + + // remove mappings first (lest we leave orphans) + $query = 'DELETE FROM #__modules_menu' + . ' WHERE moduleid IN ( '.$cids.' )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + return JError::raiseError( 500, $db->getErrorMsg() ); + } + // remove module + $query = 'DELETE FROM #__modules' + . ' WHERE id IN ('.$cids.')' + ; + $db->setQuery( $query ); + if (!$db->query()) { + return JError::raiseError( 500, $db->getErrorMsg() ); + } + + $this->setMessage( JText::sprintf( 'Items removed', count( $cid ) ) ); + } + + /** + * Publishes or Unpublishes one or more modules + */ + function publish() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); + + $cache = & JFactory::getCache(); + $cache->clean( 'com_content' ); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + $task = $this->getTask(); + $publish = ($task == 'publish'); + + if (empty( $cid )) { + return JError::raiseWarning( 500, 'No items selected' ); + } + + $cids = implode( ',', $cid ); + + $query = 'UPDATE #__modules' + . ' SET published = ' . intval( $publish ) + . ' WHERE id IN ( '.$cids.' )' + . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ) )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + return JError::raiseWarning( 500, $db->getErrorMsg() ); + } + + if (count( $cid ) == 1) { + $row =& JTable::getInstance('module'); + $row->checkin( $cid[0] ); + } + } + + /** + * Cancels an edit operation + */ + function cancel() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $db =& JFactory::getDBO(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); + + $row =& JTable::getInstance('module'); + // ignore array elements + $row->bind(JRequest::get('post'), 'selections params' ); + $row->checkin(); + } + + /** + * Moves the order of a record + */ + function reorder() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $db =& JFactory::getDBO(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + $task = $this->getTask(); + $inc = ($task == 'orderup' ? -1 : 1); + + if (empty( $cid )) { + return JError::raiseWarning( 500, 'No items selected' ); + } + + $row =& JTable::getInstance('module'); + $row->load( (int) $cid[0] ); + + $row->move( $inc, 'position = '.$db->Quote( $row->position ).' AND client_id='.(int) $client->id ); + } + + /** + * Changes the access level of a record + */ + function access() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $db =& JFactory::getDBO(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + $task = JRequest::getCmd( 'task' ); + + if (empty( $cid )) { + return JError::raiseWarning( 500, 'No items selected' ); + } + + switch ( $task ) + { + case 'accesspublic': + $access = 0; + break; + + case 'accessregistered': + $access = 1; + break; + + case 'accessspecial': + $access = 2; + break; + } + + $row =& JTable::getInstance('module'); + $row->load( (int) $cid[0] ); + $row->access = $access; + + if ( !$row->check() ) { + JError::raiseWarning( 500, $row->getError() ); + } + if ( !$row->store() ) { + JError::raiseWarning( 500, $row->getError() ); + } + } + + /** + * Saves the orders of the supplied list + */ + function saveOrder() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $db =& JFactory::getDBO(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + if (empty( $cid )) { + return JError::raiseWarning( 500, 'No items selected' ); + } + + $total = count( $cid ); + $row =& JTable::getInstance('module'); + $groupings = array(); + + $order = JRequest::getVar( 'order', array(0), 'post', 'array' ); + JArrayHelper::toInteger($order); + + // update ordering values + for ($i = 0; $i < $total; $i++) + { + $row->load( (int) $cid[$i] ); + // track postions + $groupings[] = $row->position; + + if ($row->ordering != $order[$i]) + { + $row->ordering = $order[$i]; + if (!$row->store()) { + return JError::raiseWarning( 500, $db->getErrorMsg() ); + } + } + } + + // execute updateOrder for each parent group + $groupings = array_unique( $groupings ); + foreach ($groupings as $group){ + $row->reorder('position = '.$db->Quote($group).' AND client_id = '.(int) $client->id); + } + + $this->setMessage (JText::_( 'New ordering saved' )); + } + + function preview() + { + $document =& JFactory::getDocument(); + $document->setTitle(JText::_('Module Preview')); + + require_once( JApplicationHelper::getPath( 'admin_html' ) ); + HTML_modules::preview( ); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_modules/helpers/index.html b/oss/joomla/trunk/administrator/components/com_modules/helpers/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_modules/helpers/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_modules/helpers/xml.php b/oss/joomla/trunk/administrator/components/com_modules/helpers/xml.php new file mode 100644 index 00000000..c75479bb --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_modules/helpers/xml.php @@ -0,0 +1,46 @@ + $row) + { + if ($row->module == '') + { + $rows[$i]->name = 'custom'; + $rows[$i]->module = 'custom'; + $rows[$i]->descrip = 'Custom created module, using Module Manager `New` function'; + } + else + { + $data = JApplicationHelper::parseXMLInstallFile( $row->path.DS.$row->file); + + if ( $data['type'] == 'module' ) + { + $rows[$i]->name = $data['name']; + $rows[$i]->descrip = $data['description']; + } + } + } + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_modules/index.html b/oss/joomla/trunk/administrator/components/com_modules/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_modules/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_modules/models/index.html b/oss/joomla/trunk/administrator/components/com_modules/models/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_modules/models/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_modules/models/module.php b/oss/joomla/trunk/administrator/components/com_modules/models/module.php new file mode 100644 index 00000000..495e0de4 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_modules/models/module.php @@ -0,0 +1,170 @@ +getTable( 'Module', 'JTable' ); + if ($id = $this->getState( 'id' )) { + $instance->load( (int) $id ); + } + } + return $instance; + } + + function &_getXML() + { + if (!$this->_xml) + { + $clientId = $this->getState( 'clientId', 0 ); + $path = ($clientId == 1) ? 'mod1_xml' : 'mod0_xml'; + $module = &$this->getModule(); + + if ($module->module == 'custom') { + $xmlpath = JApplicationHelper::getPath( $path, 'mod_custom' ); + } else { + $xmlpath = JApplicationHelper::getPath( $path, $module->module ); + } + + if (file_exists($xmlpath)) + { + $xml =& JFactory::getXMLParser('Simple'); + if ($xml->loadFile($xmlpath)) { + $this->_xml = &$xml; + } + } + } + return $this->_xml; + } + + function &getParams() + { + // Get the state parameters + $module =& $this->getModule(); + $params = new JParameter($module->params); + + if ($xml =& $this->_getXML()) + { + if ($ps = & $xml->document->params) { + foreach ($ps as $p) + { + $params->setXML( $p ); + } + } + } + return $params; + } + + function getPositions() + { + jimport('joomla.filesystem.folder'); + + $client =& JApplicationHelper::getClientInfo($this->getState('clientId')); + if ($client === false) { + return false; + } + + //Get the database object + $db =& JFactory::getDBO(); + + // template assignment filter + $query = 'SELECT DISTINCT(template) AS text, template AS value'. + ' FROM #__templates_menu' . + ' WHERE client_id = '.(int) $client->id; + $db->setQuery( $query ); + $templates = $db->loadObjectList(); + + // Get a list of all module positions as set in the database + $query = 'SELECT DISTINCT(position)'. + ' FROM #__modules' . + ' WHERE client_id = '.(int) $client->id; + $db->setQuery( $query ); + $positions = $db->loadResultArray(); + $positions = (is_array($positions)) ? $positions : array(); + + // Get a list of all template xml files for a given application + + // Get the xml parser first + for ($i = 0, $n = count($templates); $i < $n; $i++ ) + { + $path = $client->path.DS.'templates'.DS.$templates[$i]->value; + + $xml =& JFactory::getXMLParser('Simple'); + if ($xml->loadFile($path.DS.'templateDetails.xml')) + { + $p =& $xml->document->getElementByPath('positions'); + if (is_a($p, 'JSimpleXMLElement') && count($p->children())) + { + foreach ($p->children() as $child) + { + if (!in_array($child->data(), $positions)) { + $positions[] = $child->data(); + } + } + } + } + } + + if(defined('_JLEGACY') && _JLEGACY == '1.0') + { + $positions[] = 'left'; + $positions[] = 'right'; + $positions[] = 'top'; + $positions[] = 'bottom'; + $positions[] = 'inset'; + $positions[] = 'banner'; + $positions[] = 'header'; + $positions[] = 'footer'; + $positions[] = 'newsflash'; + $positions[] = 'legals'; + $positions[] = 'pathway'; + $positions[] = 'breadcrumb'; + $positions[] = 'user1'; + $positions[] = 'user2'; + $positions[] = 'user3'; + $positions[] = 'user4'; + $positions[] = 'user5'; + $positions[] = 'user6'; + $positions[] = 'user7'; + $positions[] = 'user8'; + $positions[] = 'user9'; + $positions[] = 'advert1'; + $positions[] = 'advert2'; + $positions[] = 'advert3'; + $positions[] = 'debug'; + $positions[] = 'syndicate'; + } + + $positions = array_unique($positions); + sort($positions); + + return $positions; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_modules/modules.xml b/oss/joomla/trunk/administrator/components/com_modules/modules.xml new file mode 100644 index 00000000..ec6e6321 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_modules/modules.xml @@ -0,0 +1,12 @@ + + + Module Manager + Joomla! Project + 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 + Module Manager + diff --git a/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.html.php b/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.html.php new file mode 100644 index 00000000..0b69be78 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.html.php @@ -0,0 +1,73 @@ +[ '. JText::_( 'New' ) .' ]', 'module.png' ); + JToolBarHelper::customX( 'edit', 'forward.png', 'forward_f2.png', 'Next', true ); + JToolBarHelper::cancel(); + if ($client->name == 'site') { + JToolBarHelper::help( 'screen.modulessite.edit' ); + } + else { + JToolBarHelper::help( 'screen.modulesadministrator.edit'); + } + } + + /** + * Draws the menu for Editing an existing module + */ + function _EDIT( $client ) + { + $moduleType = JRequest::getCmd( 'module' ); + $cid = JRequest::getVar( 'cid', array(0), '', 'array' ); + JArrayHelper::toInteger($cid, array(0)); + + JToolBarHelper::title( JText::_( 'Module' ) . ': [ '. JText::_( 'Edit' ) .' ]', 'module.png' ); + + if($moduleType == 'custom') { + JToolBarHelper::Preview('index.php?option=com_modules&tmpl=component&client='.$client->id.'&pollid='.$cid[0]); + } + + JToolBarHelper::save(); + JToolBarHelper::apply(); + if ( $cid[0] ) { + // for existing items the button is renamed `close` + JToolBarHelper::cancel( 'cancel', 'Close' ); + } else { + JToolBarHelper::cancel(); + } + JToolBarHelper::help( 'screen.modules.edit' ); + } + + function _DEFAULT($client) + { + JToolBarHelper::title( JText::_( 'Module Manager' ), 'module.png' ); + JToolBarHelper::publishList(); + JToolBarHelper::unpublishList(); + JToolBarHelper::custom( 'copy', 'copy.png', 'copy_f2.png', 'Copy', true ); + JToolBarHelper::deleteList(); + JToolBarHelper::editListX(); + JToolBarHelper::addNewX(); + JToolBarHelper::help( 'screen.modules' ); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.php b/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.php new file mode 100644 index 00000000..568baa64 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.php @@ -0,0 +1,36 @@ + +
    + + + + + + +
    + : + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + id ); + + $checked = JHTML::_('grid.checkedout', $row, $i ); + $published = JHTML::_('grid.published', $row, $i ); + + $row->cat_link = JRoute::_( 'index.php?option=com_categories§ion=com_newsfeeds&task=edit&cid[]='. $row->catid ); + ?> + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + getListFooter(); ?> +
    + getRowOffset( $i ); ?> + + + + get ('id'), $row->checked_out ) ) { + echo $row->name; + } else { + ?> + + + name; ?> + + + + + orderUpIcon($i, ($row->catid == @$rows[$i-1]->catid), 'orderup', 'Move Up', $ordering ); ?> + orderDownIcon($i, $n, ($row->catid == @$rows[$i+1]->catid), 'orderdown', 'Move Down', $ordering ); ?> + + class="text_area" style="text-align: center" /> + + + catname;?> + + numarticles;?> + + cache_time;?> + + id; ?> +
    + + + + + +
    + + get('gid') == 25 ) { + $visible = 1; + } + HTML_newsfeeds::writableCell( JPATH_SITE.DS.'cache', 0, ''. JText::_('Cache Directory') .' ', $visible ); + ?> +
    +
    + + + + + + + +
    + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + +
    + + + +
    + : + + +
    + + + +
    + + + +
    + + + +
    + + + + + +
    + + + +
    + + + +
    +
    +
    +
    +
    + + + + + + +
    + '. 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 ''; + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_newsfeeds/admin.newsfeeds.php b/oss/joomla/trunk/administrator/components/com_newsfeeds/admin.newsfeeds.php new file mode 100644 index 00000000..e17327d5 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_newsfeeds/admin.newsfeeds.php @@ -0,0 +1,464 @@ +authorize( 'com_newsfeeds', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} + +// Set the table directory +JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_newsfeeds'.DS.'tables'); + +require_once( JApplicationHelper::getPath( 'admin_html' ) ); + +$task = JRequest::getCmd('task'); + +switch ($task) { + + case 'add' : + editNewsFeed(false); + break; + case 'edit': + editNewsFeed(true); + break; + + case 'save': + case 'apply': + saveNewsFeed( ); + break; + + case 'publish': + publishNewsFeeds( ); + break; + + case 'unpublish': + unPublishNewsFeeds( ); + break; + + case 'remove': + removeNewsFeeds( ); + break; + + case 'cancel': + cancelNewsFeed( ); + break; + + case 'orderup': + moveUpNewsFeed( ); + break; + + case 'orderdown': + moveDownNewsFeed( ); + break; + + case 'saveorder': + saveOrder( ); + break; + + default: + showNewsFeeds( ); + break; +} + +/** +* List the records +*/ +function showNewsFeeds( ) +{ + global $mainframe, $option; + + $db =& JFactory::getDBO(); + + $filter_order = $mainframe->getUserStateFromRequest( "$option.filter_order", 'filter_order', 'a.ordering', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.filter_order_Dir", 'filter_order_Dir', '', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( "$option.filter_state", 'filter_state', '', 'word' ); + $filter_catid = $mainframe->getUserStateFromRequest( "$option.filter_catid", 'filter_catid', 0, 'int' ); + $search = $mainframe->getUserStateFromRequest( "$option.search", 'search', '', 'string' ); + $search = JString::strtolower( $search ); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); + + $where = array(); + if ( $filter_catid ) { + $where[] = 'a.catid = '.(int) $filter_catid; + } + if ($search) { + $where[] = 'LOWER(a.name) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + if ( $filter_state ) { + if ( $filter_state == 'P' ) { + $where[] = 'a.published = 1'; + } else if ($filter_state == 'U' ) { + $where[] = 'a.published = 0'; + } + } + + $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); + if ($filter_order == 'a.ordering'){ + $orderby = ' ORDER BY catname, a.ordering'; + } else { + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', catname, a.ordering'; + } + + // get the total number of records + $query = 'SELECT COUNT(*) ' + . ' FROM #__newsfeeds AS a' + . $where + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pageNav = new JPagination( $total, $limitstart, $limit ); + + // get the subset (based on limits) of required records + $query = 'SELECT a.*, c.title AS catname, u.name AS editor' + . ' FROM #__newsfeeds AS a' + . ' LEFT JOIN #__categories AS c ON c.id = a.catid' + . ' LEFT JOIN #__users AS u ON u.id = a.checked_out' + . $where + . $orderby + ; + $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); + + $rows = $db->loadObjectList(); + if ($db->getErrorNum()) { + echo $db->stderr(); + return false; + } + + // build list of categories + $javascript = 'onchange="document.adminForm.submit();"'; + $lists['catid'] = JHTML::_('list.category', 'filter_catid', 'com_newsfeeds', $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; + + HTML_newsfeeds::showNewsFeeds( $rows, $lists, $pageNav, $option ); +} + +/** +* Creates a new or edits and existing user record +*/ +function editNewsFeed($edit) +{ + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + $catid = JRequest::getVar( 'catid', 0, '', 'int' ); + $cid = JRequest::getVar( 'cid', array(0), '', 'array' ); + $option = JRequest::getCmd( 'option' ); + JArrayHelper::toInteger($cid, array(0)); + + $row =& JTable::getInstance( 'newsfeed', 'Table' ); + // load the row from the db table + if($edit) + $row->load( $cid[0] ); + + if ($edit) { + // do stuff for existing records + $row->checkout( $user->get('id') ); + } else { + // do stuff for new records + $row->ordering = 0; + $row->numarticles = 5; + $row->cache_time = 3600; + $row->published = 1; + } + + // build the html select list for ordering + $query = 'SELECT a.ordering AS value, a.name AS text' + . ' FROM #__newsfeeds AS a' + . ' ORDER BY a.ordering' + ; + + if($edit) + $lists['ordering'] = JHTML::_('list.specificordering', $row, $cid[0], $query ); + else + $lists['ordering'] = JHTML::_('list.specificordering', $row, '', $query ); + + // build list of categories + $lists['category'] = JHTML::_('list.category', 'catid', $option, intval( $row->catid ) ); + // build the html select list + $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published ); + $rtl[] = JHTML::_('select.option', '0', JText::_( 'Site Language Direction' ) ); + $rtl[] = JHTML::_('select.option', '1', JText::_( 'Left to Right Direction' ) ); + $rtl[] = JHTML::_('select.option', '2', JText::_( 'Right to Left Direction' ) ); + $lists['rtl'] = JHTML::_('select.genericlist', $rtl, 'rtl', 'class="inputbox"', 'value', 'text', intval( $row->rtl ) ); + HTML_newsfeeds::editNewsFeed( $row, $lists, $option ); +} + +/** +* Saves the record from an edit form submit +*/ +function saveNewsFeed( ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $task = JRequest::getVar( 'task'); + + $row =& JTable::getInstance( 'newsfeed', 'Table' ); + if (!$row->bind(JRequest::get('post'))) { + JError::raiseError(500, $row->getError() ); + } + + // Sets rtl value when rtl checkbox ticked + $isRtl = JRequest::getInt('rtl'); + + + // pre-save checks + if (!$row->check()) { + JError::raiseError(500, $row->getError() ); + } + + // if new item, order last in appropriate group + if (!$row->id) { + $where = "catid = " . (int) $row->catid; + $row->ordering = $row->getNextOrder( $where ); + } + + // save the changes + if (!$row->store()) { + JError::raiseError(500, $row->getError() ); + } + $row->checkin(); + + switch ($task) + { + case 'apply': + $msg = JText::_( 'Changes to Newsfeed saved' ); + $link = 'index.php?option=com_newsfeeds&task=edit&cid[]='. $row->id ; + break; + + case 'save': + default: + $msg = JText::_( 'Newsfeed saved' ); + $link = 'index.php?option=com_newsfeeds'; + break; + } + + $mainframe->redirect( $link, $msg ); +} + +/** +* Publishes one or more modules +*/ +function publishNewsFeeds( ) { + changePublishNewsFeeds( 1 ); +} + +/** +* Unpublishes one or more modules +*/ +function unPublishNewsFeeds( ) { + changePublishNewsFeeds( 0 ); +} + +/** +* Publishes or Unpublishes one or more modules +* @param integer 0 if unpublishing, 1 if publishing +*/ +function changePublishNewsFeeds( $publish ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + $cid = JRequest::getVar('cid', array(), '', 'array'); + $option = JRequest::getCmd('option'); + JArrayHelper::toInteger($cid); + + if (empty( $cid )) { + JError::raiseWarning( 500, 'No items selected' ); + $mainframe->redirect( 'index.php?option='. $option ); + } + + $cids = implode( ',', $cid ); + + $query = 'UPDATE #__newsfeeds' + . ' SET published = '.(int) $publish + . ' WHERE id IN ( '. $cids .' )' + . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id') .' ) )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + JError::raiseError(500, $db->getErrorMsg() ); + } + + if (count( $cid ) == 1) { + $row =& JTable::getInstance( 'newsfeed', 'Table' ); + $row->checkin( $cid[0] ); + } + + $mainframe->redirect( 'index.php?option='. $option ); +} + +/** +* Removes records +*/ +function removeNewsFeeds( ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $cid = JRequest::getVar('cid', array(), '', 'array'); + $option = JRequest::getCmd('option'); + JArrayHelper::toInteger($cid); + + if (count($cid) < 1) { + JError::raiseWarning(500, JText::_( 'Select an item to delete', true ) ); + $mainframe->redirect( 'index.php?option='. $option ); + } + + $cids = implode( ',', $cid ); + $query = 'DELETE FROM #__newsfeeds' + . ' WHERE id IN ( '. $cids .' )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + echo "\n"; + } + + $mainframe->redirect( 'index.php?option='. $option ); +} + +/** +* Cancels an edit operation +*/ +function cancelNewsFeed( ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $option = JRequest::getCmd('option'); + + $row =& JTable::getInstance( 'newsfeed', 'Table' ); + $row->bind(JRequest::get('post')); + $row->checkin(); + $mainframe->redirect( 'index.php?option='. $option ); +} + +/** +* Moves the record up one position +*/ +function moveUpNewsFeed( ) { + orderNewsFeed( -1 ); +} + +/** +* Moves the record down one position +*/ +function moveDownNewsFeed( ) { + orderNewsFeed( 1 ); +} + +/** +* Moves the order of a record +* @param integer The direction to reorder, +1 down, -1 up +*/ +function orderNewsFeed( $inc ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $cid = JRequest::getVar('cid', array(0), '', 'array'); + $option = JRequest::getCmd('option'); + JArrayHelper::toInteger($cid, array(0)); + + $limit = JRequest::getVar( 'limit', 0, '', 'int' ); + $limitstart = JRequest::getVar( 'limitstart', 0, '', 'int' ); + $catid = JRequest::getVar( 'catid', 0, '', 'int' ); + + $row =& JTable::getInstance( 'newsfeed', 'Table' ); + $row->load( $cid[0] ); + $row->move( $inc, 'catid = '.(int) $row->catid.' AND published != 0' ); + + $mainframe->redirect( 'index.php?option='. $option ); +} + +/** +* Saves user reordering entry +*/ +function saveOrder( ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + $total = count( $cid ); + $order = JRequest::getVar( 'order', array(0), 'post', 'array' ); + JArrayHelper::toInteger($order, array(0)); + + $row =& JTable::getInstance( 'newsfeed', 'Table' ); + $groupings = array(); + + // update ordering values + for( $i=0; $i < $total; $i++ ) { + $row->load( (int) $cid[$i] ); + // track categories + $groupings[] = $row->catid; + + if ($row->ordering != $order[$i]) { + $row->ordering = $order[$i]; + if (!$row->store()) { + JError::raiseError(500, $db->getErrorMsg() ); + } + } + } + + // execute updateOrder for each parent group + $groupings = array_unique( $groupings ); + foreach ($groupings as $group){ + $row->reorder('catid = '.(int) $group); + } + + $msg = JText::_( 'New ordering saved' ); + $mainframe->redirect( 'index.php?option=com_newsfeeds', $msg ); +} diff --git a/oss/joomla/trunk/administrator/components/com_newsfeeds/config.xml b/oss/joomla/trunk/administrator/components/com_newsfeeds/config.xml new file mode 100644 index 00000000..6e85a72a --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_newsfeeds/config.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/oss/joomla/trunk/administrator/components/com_newsfeeds/elements/index.html b/oss/joomla/trunk/administrator/components/com_newsfeeds/elements/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_newsfeeds/elements/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_newsfeeds/elements/newsfeed.php b/oss/joomla/trunk/administrator/components/com_newsfeeds/elements/newsfeed.php new file mode 100644 index 00000000..69dfb6bf --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_newsfeeds/elements/newsfeed.php @@ -0,0 +1,59 @@ +setQuery( $query ); + $options = $db->loadObjectList( ); + + $n = count( $options ); + for ($i = 0; $i < $n; $i++) + { + $options[$i]->text = $options[$i]->title . '-' . $options[$i]->name; + } + + array_unshift($options, JHTML::_('select.option', '0', '- '.JText::_('Select Feed').' -', 'id', 'text')); + + return JHTML::_('select.genericlist', $options, ''.$control_name.'['.$name.']', 'class="inputbox"', 'id', 'text', $value, $control_name.$name ); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_newsfeeds/index.html b/oss/joomla/trunk/administrator/components/com_newsfeeds/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_newsfeeds/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_newsfeeds/newsfeeds.xml b/oss/joomla/trunk/administrator/components/com_newsfeeds/newsfeeds.xml new file mode 100644 index 00000000..2ec4c241 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_newsfeeds/newsfeeds.xml @@ -0,0 +1,12 @@ + + + Newsfeeds + Joomla! Project + April 2006 + (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 RSS/RDF newsfeeds + diff --git a/oss/joomla/trunk/administrator/components/com_newsfeeds/tables/index.html b/oss/joomla/trunk/administrator/components/com_newsfeeds/tables/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_newsfeeds/tables/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_newsfeeds/tables/newsfeed.php b/oss/joomla/trunk/administrator/components/com_newsfeeds/tables/newsfeed.php new file mode 100644 index 00000000..36d9bf2e --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_newsfeeds/tables/newsfeed.php @@ -0,0 +1,79 @@ +alias)) { + $this->alias = $this->name; + } + $this->alias = JFilterOutput::stringURLSafe($this->alias); + if(trim(str_replace('-','',$this->alias)) == '') { + $datenow =& JFactory::getDate(); + $this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); + } + + return true; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_newsfeeds/toolbar.newsfeeds.html.php b/oss/joomla/trunk/administrator/components/com_newsfeeds/toolbar.newsfeeds.html.php new file mode 100644 index 00000000..9cdad80d --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_newsfeeds/toolbar.newsfeeds.html.php @@ -0,0 +1,54 @@ +[ '. $text.' ]' ); + JToolBarHelper::save(); + JToolBarHelper::apply(); + if ($edit) { + // for existing items the button is renamed `close` + JToolBarHelper::cancel( 'cancel', 'Close' ); + } else { + JToolBarHelper::cancel(); + } + JToolBarHelper::help( 'screen.newsfeeds.edit' ); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_newsfeeds/toolbar.newsfeeds.php b/oss/joomla/trunk/administrator/components/com_newsfeeds/toolbar.newsfeeds.php new file mode 100644 index 00000000..a9dada68 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_newsfeeds/toolbar.newsfeeds.php @@ -0,0 +1,32 @@ +