Esempio n. 1
0
function showItem($id)
{
    global $database, $my;
    $link = new mosWeblink($database);
    $link->load((int) $id);
    /*
     * Check if link is published
     */
    if (!$link->published) {
        mosNotAuth();
        return;
    }
    $cat = new mosCategory($database);
    $cat->load((int) $link->catid);
    /*
     * Check if category is published
     */
    if (!$cat->published) {
        mosNotAuth();
        return;
    }
    /*
     * check whether category access level allows access
     */
    if ($cat->access > $my->gid) {
        mosNotAuth();
        return;
    }
    // Record the hit
    $query = "UPDATE #__weblinks" . "\n SET hits = hits + 1" . "\n WHERE id = " . (int) $id;
    $database->setQuery($query);
    $database->query();
    if ($link->url) {
        // redirects to url if matching id found
        mosRedirect($link->url);
    } else {
        // redirects to weblink category page if no matching id found
        listWeblinks($cat->id);
    }
}
Esempio n. 2
0
function showFeed($feedid)
{
    global $database, $mainframe, $mosConfig_absolute_path, $mosConfig_cachepath, $Itemid, $my;
    // check if cache directory is writeable
    $cacheDir = $mosConfig_cachepath . '/';
    if (!is_writable($cacheDir)) {
        echo 'Cache Directory Unwriteable';
        return;
    }
    require_once $mainframe->getPath('class');
    $newsfeed = new mosNewsFeed($database);
    $newsfeed->load((int) $feedid);
    /*
     * Check if newsfeed is published
     */
    if (!$newsfeed->published) {
        mosNotAuth();
        return;
    }
    $category = new mosCategory($database);
    $category->load((int) $newsfeed->catid);
    /*
     * Check if newsfeed category is published
     */
    if (!$category->published) {
        mosNotAuth();
        return;
    }
    /*
     * check whether category access level allows access
     */
    if ($category->access > $my->gid) {
        mosNotAuth();
        return;
    }
    // full RSS parser used to access image information
    require_once $mosConfig_absolute_path . '/includes/domit/xml_domit_rss.php';
    $LitePath = $mosConfig_absolute_path . '/includes/Cache/Lite.php';
    // Adds parameter handling
    $menu = $mainframe->get('menu');
    $params = new mosParameters($menu->params);
    $params->def('page_title', 1);
    $params->def('header', $menu->name);
    $params->def('pageclass_sfx', '');
    $params->def('back_button', $mainframe->getCfg('back_button'));
    // Feed Display control
    $params->def('feed_image', 1);
    $params->def('feed_descr', 1);
    $params->def('item_descr', 1);
    $params->def('word_count', 0);
    // Encoding
    $params->def('utf8', 1);
    if (!$params->get('page_title')) {
        $params->set('header', '');
    }
    $and = '';
    if ($feedid) {
        $and = "\n AND id = {$feedid}";
    }
    $mainframe->SetPageTitle($menu->name);
    HTML_newsfeed::showNewsfeeds($newsfeed, $LitePath, $cacheDir, $params);
}
Esempio n. 3
0
/**
* Save the item(s) to the menu selected
*/
function copySectionSave($sectionid)
{
    global $database;
    josSpoofCheck();
    $title = stripslashes(strval(mosGetParam($_REQUEST, 'title', '')));
    $categories = josGetArrayInts('category', $_REQUEST, array(0));
    $items = josGetArrayInts('content', $_REQUEST, array(0));
    // create new section
    $section = new mosSection($database);
    $section->id = null;
    $section->title = $title;
    $section->name = $title;
    $section->scope = 'content';
    $section->published = 1;
    if (!$section->check()) {
        echo "<script> alert('" . $section->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$section->store()) {
        echo "<script> alert('" . $section->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $section->checkin();
    $newSectionId = $section->id;
    // new section created, now copy categories
    // old/new category lookup array
    $newOldCatLookup = array();
    foreach ($categories as $categoryId) {
        $category = new mosCategory($database);
        $category->load($categoryId);
        $category->id = null;
        $category->section = $newSectionId;
        if (!$category->check()) {
            echo "<script> alert('" . $category->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$category->store()) {
            echo "<script> alert('" . $category->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $category->checkin();
        $newOldCatLookup[$categoryId] = $category->id;
    }
    // categories copied, now copy content items
    foreach ($items as $itemId) {
        $item = new mosContent($database);
        $item->load($itemId);
        $item->id = null;
        $item->catid = $newOldCatLookup[$item->catid];
        $item->sectionid = $newSectionId;
        if (!$item->check()) {
            echo "<script> alert('" . $item->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$item->store()) {
            echo "<script> alert('" . $item->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $item->checkin();
    }
    $msg = 'Selected sections content copied into ' . $title . ' section.';
    mosRedirect('index2.php?option=com_sections&scope=content&mosmsg=' . $msg);
}
Esempio n. 4
0
function menuLink($option)
{
    global $database;
    global $adminLanguage;
    $category = new mosCategory($database);
    $category->bind($_POST);
    $category->checkin();
    $redirect = mosGetParam($_POST, 'redirect', '');
    $menu = mosGetParam($_POST, 'menuselect', '');
    $name = mosGetParam($_POST, 'link_name', '');
    $id = mosGetParam($_POST, 'id', '');
    $sectionid = mosGetParam($_POST, 'sectionid', '');
    $type = mosGetParam($_POST, 'link_type', '');
    switch ($type) {
        case 'content_category':
            $link = 'index.php?option=com_content&task=category&sectionid=' . $sectionid . '&id=' . $id;
            $menutype = 'Category Table';
            break;
        case 'content_blog_category':
            $link = 'index.php?option=com_content&task=blogcategory&id=' . $id;
            $menutype = 'Category Blog';
            break;
        case 'content_archive_category':
            $link = 'index.php?option=com_content&task=archivecategory&id=' . $id;
            $menutype = 'Category Blog Archive';
            break;
    }
    $row = new mosMenu($database);
    $row->menutype = $menu;
    $row->name = $name;
    $row->type = $type;
    $row->published = 1;
    $row->componentid = $id;
    $row->link = $link;
    $row->ordering = 9999;
    if (!$row->check()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->store()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $row->checkin();
    $row->updateOrder("section='" . $sectionid . "'");
    $msg = $name . ' ( ' . $menutype . ' ) in menu: ' . $menu . ' successfully created';
    mosRedirect('index2.php?option=' . $option . '&section=' . $redirect, $msg);
}
Esempio n. 5
0
/**
* Save the item(s) to the menu selected
*/
function copySectionSave($option, $sectionid, $sectionID)
{
    global $database, $adminLanguage;
    $title = mosGetParam($_REQUEST, 'title', '');
    $contentid = mosGetParam($_REQUEST, 'content', '');
    $categoryid = mosGetParam($_REQUEST, 'category', '');
    $total = count($contentid);
    $sectionids = implode(',', $sectionid);
    $section = new mosSection($database);
    foreach ($sectionid as $id) {
        $section->load($id);
        $section->id = NULL;
        $section->title = $title;
        $section->name = $title;
        if (!$section->check()) {
            echo "<script> alert('" . $section->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$section->store()) {
            echo "<script> alert('" . $section->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $section->checkin();
        $section->updateOrder("section='" . $section->id . "'");
        // stores original catid
        $newsectids[]["old"] = $id;
        // pulls new catid
        $newsectids[]["new"] = $section->id;
    }
    $category = new mosCategory($database);
    foreach ($categoryid as $id) {
        $category->load($id);
        $category->id = NULL;
        $category->section = $sectionMove;
        foreach ($newsectids as $newsectid) {
            if ($category->section == $newsectid["old"]) {
                $category->section = $newsectid["new"];
            }
        }
        if (!$category->check()) {
            echo "<script> alert('" . $category->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$category->store()) {
            echo "<script> alert('" . $category->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $category->checkin();
        $category->updateOrder("section='" . $category->section . "'");
        // stores original catid
        $newcatids[]["old"] = $id;
        // pulls new catid
        $newcatids[]["new"] = $category->id;
    }
    $content = new mosContent($database);
    foreach ($contentid as $id) {
        $content->load($id);
        $content->id = NULL;
        $content->hits = 0;
        foreach ($newsectids as $newsectid) {
            if ($content->sectionid == $newsectid["old"]) {
                $content->sectionid = $newsectid["new"];
            }
        }
        foreach ($newcatids as $newcatid) {
            if ($content->catid == $newcatid["old"]) {
                $content->catid = $newcatid["new"];
            }
        }
        if (!$content->check()) {
            echo "<script> alert('" . $content->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$content->store()) {
            echo "<script> alert('" . $content->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $content->checkin();
    }
    $sectionOld = new mosSection($database);
    $sectionOld->load($sectionMove);
    $msg = $adminLanguage->A_COMP_SECTION . " " . $sectionOld->name . " " . $adminLanguage->A_COMP_SECT_AND_ALL . " " . $title;
    mosRedirect('index2.php?option=com_sections&scope=content&mosmsg=' . $msg);
}
Esempio n. 6
0
File: content.php Progetto: cwcw/cms
function BlogOutput(&$rows, &$params, $gid, &$access, $pop, &$menu, $archive = NULL)
{
    global $mainframe, $Itemid, $task, $id, $option, $database, $mosConfig_live_site;
    // parameters
    if ($params->get('page_title', 1)) {
        $header = $params->def('header', $menu->name);
    } else {
        $header = '';
    }
    $columns = $params->def('columns', 2);
    if ($columns == 0) {
        $columns = 1;
    }
    $intro = $params->def('intro', 4);
    $leading = $params->def('leading', 1);
    $links = $params->def('link', 4);
    $pagination = $params->def('pagination', 2);
    $pagination_results = $params->def('pagination_results', 1);
    $pagination_results = $params->def('pagination_results', 1);
    $descrip = $params->def('description', 1);
    $descrip_image = $params->def('description_image', 1);
    // needed for back button for page
    $back = $params->get('back_button', $mainframe->getCfg('back_button'));
    // needed to disable back button for item
    $params->set('back_button', 0);
    $params->def('pageclass_sfx', '');
    $params->set('intro_only', 1);
    $total = count($rows);
    // pagination support
    $limitstart = intval(mosGetParam($_REQUEST, 'limitstart', 0));
    $limit = $intro + $leading + $links;
    if ($total <= $limit) {
        $limitstart = 0;
    }
    $i = $limitstart;
    // needed to reduce queries used by getItemid
    $ItemidCount['bs'] = $mainframe->getBlogSectionCount();
    $ItemidCount['bc'] = $mainframe->getBlogCategoryCount();
    $ItemidCount['gbs'] = $mainframe->getGlobalBlogSectionCount();
    // used to display section/catagory description text and images
    // currently not supported in Archives
    if ($menu->componentid && ($descrip || $descrip_image)) {
        switch ($menu->type) {
            case 'content_blog_section':
                $description = new mosSection($database);
                $description->load($menu->componentid);
                break;
            case 'content_blog_category':
                $description = new mosCategory($database);
                $description->load($menu->componentid);
                break;
            case 'content_blog_category':
            case 'components':
            default:
                $menu->componentid = 0;
                break;
        }
    }
    // Page Output
    // page header
    if ($header) {
        echo '<div class="componentheading' . $params->get('pageclass_sfx') . '">' . $header . '</div>';
    }
    if ($archive) {
        echo '<br />';
        echo mosHTML::monthSelectList('month', 'size="1" class="inputbox"', $params->get('month'));
        echo mosHTML::integerSelectList(2000, 2010, 1, 'year', 'size="1" class="inputbox"', $params->get('year'), "%04d");
        echo '<input type="submit" class="button" />';
    }
    // checks to see if there are there any items to display
    if ($total) {
        $col_with = 100 / $columns;
        // width of each column
        $width = 'width="' . $col_with . '%"';
        if ($archive) {
            // Search Success message
            $msg = sprintf(_ARCHIVE_SEARCH_SUCCESS, $params->get('month'), $params->get('year'));
            echo "<br /><br /><div align='center'>" . $msg . "</div><br /><br />";
        }
        echo '<table class="' . $params->get('pageclass_sfx') . '" cellpadding="0" cellspacing="0">';
        // Secrion/Category Description & Image
        if ($menu->componentid && ($descrip || $descrip_image)) {
            $link = $mosConfig_live_site . '/images/stories/' . $description->image;
            echo '<tr>';
            echo '<td valign="top">';
            if ($descrip_image) {
                echo '<img src="' . $link . '" align="' . $description->image_position . '" hspace="6" alt="" />';
            }
            if ($descrip) {
                echo $description->description;
            }
            echo '<br/><br/>';
            echo '</td>';
            echo '</tr>';
        }
        // Leading story output
        if ($leading) {
            echo '<tr>';
            echo '<td valign="top">';
            for ($z = 0; $z < $leading; $z++) {
                if ($i >= $total) {
                    // stops loop if total number of items is less than the number set to display as leading
                    break;
                }
                echo '<div>';
                show($rows[$i], $params, $gid, $access, $pop, $option, $ItemidCount);
                echo '</div>';
                $i++;
            }
            echo '</td>';
            echo '</tr>';
        }
        if ($intro && $i < $total) {
            echo '<tr>';
            echo '<td valign="top">';
            echo '<table width="100%"  cellpadding="0" cellspacing="0">';
            // intro story output
            for ($z = 0; $z < $intro; $z++) {
                if ($i >= $total) {
                    // stops loop if total number of items is less than the number set to display as intro + leading
                    break;
                }
                if (!($z % $columns) || $columns == 1) {
                    echo '<tr>';
                }
                echo '<td valign="top" ' . $width . '>';
                // outputs either intro or only a link
                if ($z < $intro) {
                    show($rows[$i], $params, $gid, $access, $pop, $option, $ItemidCount);
                } else {
                    echo '</td>';
                    echo '</tr>';
                    break;
                }
                echo '</td>';
                if (!(($z + 1) % $columns) || $columns == 1) {
                    echo '</tr>';
                }
                $i++;
            }
            // this is required to output a final closing </tr> tag when the number of items does not fully
            // fill the last row of output - a blank column is left
            if ($intro % $columns) {
                echo '</tr>';
            }
            echo '</table>';
            echo '</td>';
            echo '</tr>';
        }
        // Links output
        if ($links && $i < $total) {
            echo '<tr>';
            echo '<td valign="top">';
            echo '<div class="blog_more' . $params->get('pageclass_sfx') . '">';
            HTML_content::showLinks($rows, $links, $total, $i, 1, $ItemidCount);
            echo '</div>';
            echo '</td>';
            echo '</tr>';
        }
        // Pagination output
        if ($pagination) {
            if ($pagination == 2 && $total <= $limit) {
                // not visible when they is no 'other' pages to display
            } else {
                // get the total number of records
                $limitstart = $limitstart ? $limitstart : 0;
                require_once $GLOBALS['mosConfig_absolute_path'] . '/includes/pageNavigation.php';
                $pageNav = new mosPageNav($total, $limitstart, $limit);
                if ($option == 'com_frontpage') {
                    $link = 'index.php?option=com_frontpage&amp;Itemid=' . $Itemid;
                } else {
                    if ($archive) {
                        $year = $params->get('year');
                        $month = $params->get('month');
                        $link = 'index.php?option=com_content&amp;task=' . $task . '&amp;id=' . $id . '&amp;Itemid=' . $Itemid . '&amp;year=' . $year . '&amp;month=' . $month;
                    } else {
                        $link = 'index.php?option=com_content&amp;task=' . $task . '&amp;id=' . $id . '&amp;Itemid=' . $Itemid;
                    }
                }
                echo '<tr>';
                echo '<td valign="top" align="center">';
                echo $pageNav->writePagesLinks($link);
                echo '<br /><br />';
                echo '</td>';
                echo '</tr>';
                if ($pagination_results) {
                    echo '<tr>';
                    echo '<td valign="top" align="center">';
                    echo $pageNav->writePagesCounter();
                    echo '</td>';
                    echo '</tr>';
                }
            }
        }
        echo '</table>';
    } else {
        if ($archive && !$total) {
            // Search Failure message for Archives
            $msg = sprintf(_ARCHIVE_SEARCH_FAILURE, $params->get('month'), $params->get('year'));
            echo '<br /><br /><div align="center">' . $msg . '</div><br />';
        } else {
            // Generic blog empty display
            echo _EMPTY_BLOG;
        }
    }
    // Back Button
    $params->set('back_button', $back);
    mosHTML::BackButton($params);
}
Esempio n. 7
0
/**
* 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($uid = 0, $sectionid = 0, $option)
{
    global $database, $my, $mainframe;
    global $mosConfig_absolute_path, $mosConfig_live_site, $mosConfig_offset;
    $redirect = strval(mosGetParam($_POST, 'redirect', ''));
    $nullDate = $database->getNullDate();
    if (!$redirect) {
        $redirect = $sectionid;
    }
    // load the row from the db table
    $row = new mosContent($database);
    $row->load((int) $uid);
    if ($uid) {
        $sectionid = $row->sectionid;
        if ($row->state < 0) {
            mosRedirect('index2.php?option=com_content&sectionid=' . $row->sectionid, 'You cannot edit an archived item');
        }
    }
    // fail if checked out not by 'me'
    if ($row->checked_out && $row->checked_out != $my->id) {
        mosRedirect('index2.php?option=com_content', 'The module ' . $row->title . ' is currently being edited by another administrator');
    }
    $selected_folders = NULL;
    if ($uid) {
        $row->checkout($my->id);
        if (trim($row->images)) {
            $row->images = explode("\n", $row->images);
        } else {
            $row->images = array();
        }
        $row->created = mosFormatDate($row->created, _CURRENT_SERVER_TIME_FORMAT);
        $row->modified = $row->modified == $nullDate ? '' : mosFormatDate($row->modified, _CURRENT_SERVER_TIME_FORMAT);
        $row->publish_up = mosFormatDate($row->publish_up, _CURRENT_SERVER_TIME_FORMAT);
        if (trim($row->publish_down) == $nullDate || trim($row->publish_down) == '' || trim($row->publish_down) == '-') {
            $row->publish_down = 'Never';
        }
        $row->publish_down = mosFormatDate($row->publish_down, _CURRENT_SERVER_TIME_FORMAT);
        $query = "SELECT name" . "\n FROM #__users" . "\n WHERE id = " . (int) $row->created_by;
        $database->setQuery($query);
        $row->creator = $database->loadResult();
        // test to reduce unneeded query
        if ($row->created_by == $row->modified_by) {
            $row->modifier = $row->creator;
        } else {
            $query = "SELECT name" . "\n FROM #__users" . "\n WHERE id = " . (int) $row->modified_by;
            $database->setQuery($query);
            $row->modifier = $database->loadResult();
        }
        $query = "SELECT content_id" . "\n FROM #__content_frontpage" . "\n WHERE content_id = " . (int) $row->id;
        $database->setQuery($query);
        $row->frontpage = $database->loadResult();
        // get list of links to this item
        $and = "\n AND componentid = " . (int) $row->id;
        $menus = mosAdminMenus::Links2Menu('content_item_link', $and);
    } else {
        if (!$sectionid && @$_POST['filter_sectionid']) {
            $sectionid = $_POST['filter_sectionid'];
        }
        if (@$_POST['catid']) {
            $row->catid = (int) $_POST['catid'];
            $category = new mosCategory($database);
            $category->load((int) $_POST['catid']);
            $sectionid = $category->section;
        } else {
            $row->catid = 0;
        }
        $row->sectionid = $sectionid;
        $row->version = 0;
        $row->state = 1;
        $row->ordering = 0;
        $row->images = array();
        $row->publish_up = date('Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60);
        $row->publish_down = 'Never';
        $row->creator = '';
        $row->modified = $nullDate;
        $row->modifier = '';
        $row->frontpage = 0;
        $menus = array();
    }
    $javascript = "onchange=\"changeDynaList( 'catid', sectioncategories, document.adminForm.sectionid.options[document.adminForm.sectionid.selectedIndex].value, 0, 0);\"";
    $query = "SELECT s.id, s.title" . "\n FROM #__sections AS s" . "\n ORDER BY s.ordering";
    $database->setQuery($query);
    if ($sectionid == 0) {
        $sections[] = mosHTML::makeOption('-1', 'Select Section', 'id', 'title');
        $sections = array_merge($sections, $database->loadObjectList());
        $lists['sectionid'] = mosHTML::selectList($sections, 'sectionid', 'class="inputbox" size="1" ' . $javascript, 'id', 'title');
    } else {
        $sections = $database->loadObjectList();
        $lists['sectionid'] = mosHTML::selectList($sections, 'sectionid', 'class="inputbox" size="1" ' . $javascript, 'id', 'title', intval($row->sectionid));
    }
    $contentSection = '';
    foreach ($sections as $section) {
        $section_list[] = $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][] = mosHTML::makeOption('-1', 'Select Category', 'id', 'name');
    mosArrayToInts($section_list);
    $section_list = 'section=' . implode(' OR section=', $section_list);
    $query = "SELECT id, name, section" . "\n FROM #__categories" . "\n WHERE ( {$section_list} )" . "\n ORDER BY ordering";
    $database->setQuery($query);
    $cat_list = $database->loadObjectList();
    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][] = mosHTML::makeOption($row2->id, $row2->name, 'id', 'name');
        }
    }
    // get list of categories
    if (!$row->catid && !$row->sectionid) {
        $categories[] = mosHTML::makeOption('-1', 'Select Category', 'id', 'name');
        $lists['catid'] = mosHTML::selectList($categories, 'catid', 'class="inputbox" size="1"', 'id', 'name');
    } else {
        $categoriesA = array();
        if ($sectionid == 0) {
            //$where = "\n WHERE section NOT LIKE '%com_%'";
            foreach ($cat_list as $cat) {
                $categoriesA[] = $cat;
            }
        } else {
            //$where = "\n WHERE section = '$sectionid'";
            foreach ($cat_list as $cat) {
                if ($cat->section == $sectionid) {
                    $categoriesA[] = $cat;
                }
            }
        }
        $categories[] = mosHTML::makeOption('-1', 'Select Category', 'id', 'name');
        $categories = array_merge($categories, $categoriesA);
        $lists['catid'] = mosHTML::selectList($categories, 'catid', 'class="inputbox" size="1"', 'id', 'name', intval($row->catid));
    }
    // build the html select list for ordering
    $query = "SELECT ordering AS value, title AS text" . "\n FROM #__content" . "\n WHERE catid = " . (int) $row->catid . "\n AND state >= 0" . "\n ORDER BY ordering";
    $lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $uid, $query, 1);
    // pull param column from category info
    $query = "SELECT params" . "\n FROM #__categories" . "\n WHERE id = " . (int) $row->catid;
    $database->setQuery($query);
    $categoryParam = $database->loadResult();
    $paramsCat = new mosParameters($categoryParam, $mainframe->getPath('com_xml', 'com_categories'), 'component');
    $selected_folders = $paramsCat->get('imagefolders', '');
    if (!$selected_folders) {
        $selected_folders = '*2*';
    }
    // check if images utilizes settings from section
    if (strpos($selected_folders, '*2*') !== false) {
        unset($selected_folders);
        // load param column from section info
        $query = "SELECT params" . "\n FROM #__sections" . "\n WHERE id = " . (int) $row->sectionid;
        $database->setQuery($query);
        $sectionParam = $database->loadResult();
        $paramsSec = new mosParameters($sectionParam, $mainframe->getPath('com_xml', 'com_sections'), 'component');
        $selected_folders = $paramsSec->get('imagefolders', '');
    }
    if (trim($selected_folders)) {
        $temps = explode(',', $selected_folders);
        foreach ($temps as $temp) {
            $temp = ampReplace($temp);
            $folders[] = mosHTML::makeOption($temp, $temp);
        }
    } else {
        $folders[] = mosHTML::makeOption('*1*');
    }
    // calls function to read image from directory
    $pathA = $mosConfig_absolute_path . '/images/stories';
    $pathL = $mosConfig_live_site . '/images/stories';
    $images = array();
    if ($folders[0]->value == '*1*') {
        $folders = array();
        $folders[] = mosHTML::makeOption('/');
        mosAdminMenus::ReadImages($pathA, '/', $folders, $images);
    } else {
        mosAdminMenus::ReadImagesX($folders, $images);
    }
    // list of folders in images/stories/
    $lists['folders'] = mosAdminMenus::GetImageFolders($folders, $pathL);
    // list of images in specfic folder in images/stories/
    $lists['imagefiles'] = mosAdminMenus::GetImages($images, $pathL, $folders);
    // list of saved images
    $lists['imagelist'] = mosAdminMenus::GetSavedImages($row, $pathL);
    // build list of users
    $active = intval($row->created_by) ? intval($row->created_by) : $my->id;
    $lists['created_by'] = mosAdminMenus::UserSelect('created_by', $active);
    // build the select list for the image position alignment
    $lists['_align'] = mosAdminMenus::Positions('_align');
    // build the select list for the image caption alignment
    $lists['_caption_align'] = mosAdminMenus::Positions('_caption_align');
    // build the html select list for the group access
    $lists['access'] = mosAdminMenus::Access($row);
    // build the html select list for menu selection
    $lists['menuselect'] = mosAdminMenus::MenuSelect();
    // build the select list for the image caption position
    $pos[] = mosHTML::makeOption('bottom', _CMN_BOTTOM);
    $pos[] = mosHTML::makeOption('top', _CMN_TOP);
    $lists['_caption_position'] = mosHTML::selectList($pos, '_caption_position', 'class="inputbox" size="1"', 'value', 'text');
    // get params definitions
    $params = new mosParameters($row->attribs, $mainframe->getPath('com_xml', 'com_content'), 'component');
    HTML_content::editContent($row, $contentSection, $lists, $sectioncategories, $images, $params, $option, $redirect, $menus);
}
Esempio n. 8
0
/**
* Publishes or Unpublishes one or more categories
*
* @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 publishCategories($section, $categoryid = null, $cid = null, $publish = 1)
{
    DOCMAN_token::check() or die('Invalid Token');
    global $database, $my;
    if (!is_array($cid)) {
        $cid = array();
    }
    if ($categoryid) {
        $cid[] = $categoryid;
    }
    if (count($cid) < 1) {
        $action = $publish ? _PUBLISH : _DML_UNPUBLISH;
        echo "<script> alert('" . _DML_SELECTCATTO . " {$action}'); window.history.go(-1);</script>\n";
        exit;
    }
    $cids = implode(',', $cid);
    $query = "UPDATE #__categories SET published={$publish}" . "\n WHERE id IN ({$cids}) AND (checked_out=0 OR (checked_out={$my->id}))";
    $database->setQuery($query);
    if (!$database->query()) {
        echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (count($cid) == 1) {
        $row = new mosCategory($database);
        $row->checkin($cid[0]);
    }
    mosRedirect('index2.php?option=com_docman&section=categories');
}
Esempio n. 9
0
function saveOrder(&$cid, $section)
{
    global $database;
    josSpoofCheck();
    $total = count($cid);
    $order = josGetArrayInts('order');
    $row = new mosCategory($database);
    $conditions = array();
    // update ordering values
    for ($i = 0; $i < $total; $i++) {
        $row->load((int) $cid[$i]);
        if ($row->ordering != $order[$i]) {
            $row->ordering = $order[$i];
            if (!$row->store()) {
                echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
                exit;
            }
            // if
            // remember to updateOrder this group
            $condition = "section=" . $database->Quote($row->section);
            $found = false;
            foreach ($conditions as $cond) {
                if ($cond[1] == $condition) {
                    $found = true;
                    break;
                }
            }
            // if
            if (!$found) {
                $conditions[] = array($row->id, $condition);
            }
        }
        // if
    }
    // for
    // execute updateOrder for each group
    foreach ($conditions as $cond) {
        $row->load($cond[0]);
        $row->updateOrder($cond[1]);
    }
    // foreach
    if ($section == 'content') {
        // clean any existing cache files
        mosCache::cleanCache('com_content');
    }
    $msg = 'New ordering saved';
    mosRedirect('index2.php?option=com_categories&section=' . $section, $msg);
}
Esempio n. 10
0
/**
* Save the item(s) to the menu selected
*/
function copySectionSave($sectionid)
{
    global $database;
    $title = mosGetParam($_REQUEST, 'title', '');
    $contentid = mosGetParam($_REQUEST, 'content', '');
    $categoryid = mosGetParam($_REQUEST, 'category', '');
    // copy section
    $section = new mosSection($database);
    foreach ($sectionid as $id) {
        $section->load($id);
        $section->id = NULL;
        $section->title = $title;
        $section->name = $title;
        if (!$section->check()) {
            echo "<script> alert('" . $section->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$section->store()) {
            echo "<script> alert('" . $section->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $section->checkin();
        $section->updateOrder("section='" . $section->id . "'");
        // stores original catid
        $newsectids[]["old"] = $id;
        // pulls new catid
        $newsectids[]["new"] = $section->id;
    }
    $sectionMove = $section->id;
    // copy categories
    $category = new mosCategory($database);
    foreach ($categoryid as $id) {
        $category->load($id);
        $category->id = NULL;
        $category->section = $sectionMove;
        foreach ($newsectids as $newsectid) {
            if ($category->section == $newsectid["old"]) {
                $category->section = $newsectid["new"];
            }
        }
        if (!$category->check()) {
            echo "<script> alert('" . $category->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$category->store()) {
            echo "<script> alert('" . $category->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $category->checkin();
        $category->updateOrder("section='" . $category->section . "'");
        // stores original catid
        $newcatids[]["old"] = $id;
        // pulls new catid
        $newcatids[]["new"] = $category->id;
    }
    $content = new mosContent($database);
    foreach ($contentid as $id) {
        $content->load($id);
        $content->id = NULL;
        $content->hits = 0;
        foreach ($newsectids as $newsectid) {
            if ($content->sectionid == $newsectid["old"]) {
                $content->sectionid = $newsectid["new"];
            }
        }
        foreach ($newcatids as $newcatid) {
            if ($content->catid == $newcatid["old"]) {
                $content->catid = $newcatid["new"];
            }
        }
        if (!$content->check()) {
            echo "<script> alert('" . $content->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if (!$content->store()) {
            echo "<script> alert('" . $content->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $content->checkin();
    }
    $sectionOld = new mosSection($database);
    $sectionOld->load($sectionMove);
    $msg = sprintf(T_('Section %s and all its Categories and Items have been copied as %s'), $sectionOld->name, $title);
    mosRedirect('index2.php?option=com_sections&scope=content&mosmsg=' . $msg);
}
Esempio n. 11
0
function saveOrder(&$cid, $section)
{
    global $database;
    $order = mosGetParam($_POST, 'order', array(0));
    $row = new mosCategory($database);
    $sections = array();
    // update ordering values
    foreach ($cid as $i => $ciditem) {
        $row->load($ciditem);
        if ($row->ordering != $order[$i]) {
            $row->ordering = $order[$i];
            if (!$row->store()) {
                echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
                exit;
            }
            // remember to updateOrder this group
            $sections[$row->section] = $row->id;
        }
    }
    // execute updateOrder for each group
    foreach ($sections as $sectionid => $rowid) {
        $row->updateOrder("section='{$sectionid}'");
    }
    // foreach
    $msg = T_('New ordering saved');
    mosRedirect('index2.php?option=com_categories&section=' . $section, $msg);
}