예제 #1
0
/**
* Compiles information to add or edit a category
* @param string The name of the category section
* @param integer The unique id of the category to edit (0 if new)
* @param string The name of the current user
*/
function editCategory($uid = 0, $section = '')
{
    global $database, $my, $adminLanguage;
    global $mosConfig_absolute_path, $mosConfig_live_site;
    $type = mosGetParam($_REQUEST, 'type', '');
    $redirect = mosGetParam($_POST, 'section', '');
    $row = new mosCategory($database);
    // load the row from the db table
    $row->load($uid);
    // fail if checked out not by 'me'
    if ($row->checked_out && $row->checked_out != $my->id) {
        mosRedirect('index2.php?option=categories&section=' . $row->section, $adminLanguage->A_COMP_CATEG_MESSAGE . " " . $row->title . " " . $adminLanguage->A_COMP_CATEG_MESSAGE2);
    }
    if ($uid) {
        // existing record
        $row->checkout($my->id);
        // code for Link Menu
        if ($row->section > 0) {
            $query = "SELECT *" . "\n FROM #__menu" . "\n WHERE componentid = " . $row->id . "\n AND ( type = 'content_archive_category' OR type = 'content_blog_category' OR type = 'content_category' )";
            $database->setQuery($query);
            $menus = $database->loadObjectList();
            $count = count($menus);
            for ($i = 0; $i < $count; $i++) {
                switch ($menus[$i]->type) {
                    case 'content_category':
                        $menus[$i]->type = $adminLanguage->A_COMP_CATEG_TABLE;
                        break;
                    case 'content_blog_category':
                        $menus[$i]->type = $adminLanguage->A_COMP_CATEG_BLOG;
                        break;
                    case 'content_archive_category':
                        $menus[$i]->type = $adminLanguage->A_COMP_CATEG_BLOG_ARCHIVE;
                        break;
                }
            }
        } else {
            $menus = array();
        }
    } else {
        // new record
        $row->section = $section;
        $row->published = 1;
        $menus = NULL;
    }
    // make order list
    $order = array();
    $database->setQuery("SELECT COUNT(*) FROM #__categories WHERE section='{$row->section}'");
    $max = intval($database->loadResult()) + 1;
    for ($i = 1; $i < $max; $i++) {
        $order[] = mosHTML::makeOption($i);
    }
    // build the html select list for sections
    if ($section == 'content') {
        $query = "SELECT s.id AS value, s.title AS text" . "\n FROM #__sections AS s" . "\n ORDER BY s.ordering";
        $database->setQuery($query);
        $sections = $database->loadObjectList();
        $lists['section'] = mosHTML::selectList($sections, 'section', 'class="inputbox" size="1"', 'value', 'text');
    } else {
        if ($type == 'other') {
            $section_name = 'N/A';
        } else {
            $temp = new mosSection($database);
            $temp->load($row->section);
            $section_name = $temp->name;
        }
        $lists['section'] = '<input type="hidden" name="section" value="' . $row->section . '" />' . $section_name;
    }
    // build the html select list for category types
    $types[] = mosHTML::makeOption('', $adminLanguage->A_COMP_CATEG_SELECT_TYPE);
    $types[] = mosHTML::makeOption('content_category', $adminLanguage->A_COMP_CATEG_TABLE);
    $types[] = mosHTML::makeOption('content_blog_category', $adminLanguage->A_COMP_CATEG_BLOG);
    $types[] = mosHTML::makeOption('content_archive_category', $adminLanguage->A_COMP_CATEG_BLOG_ARCHIVE);
    $lists['link_type'] = mosHTML::selectList($types, 'link_type', 'class="inputbox" size="1"', 'value', 'text');
    // build the html select list for ordering
    $query = "SELECT ordering AS value, title AS text" . "\n FROM #__categories" . "\n WHERE section = '{$row->section}'" . "\n ORDER BY ordering";
    $lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $uid, $query);
    // build the select list for the image positions
    $active = $row->image_position ? $row->image_position : 'left';
    $lists['image_position'] = mosAdminMenus::Positions('image_position', $active, NULL, 0, 0);
    // Imagelist
    $lists['image'] = mosAdminMenus::Images('image', $row->image);
    // build the html select list for the group access
    $lists['access'] = mosAdminMenus::Access($row);
    // build the html radio buttons for published
    $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published);
    // build the html select list for menu selection
    $lists['menuselect'] = mosAdminMenus::MenuSelect();
    categories_html::edit($row, $section, $lists, $redirect, $menus);
}
예제 #2
0
/**
* Compiles information to add or edit a section
* @param database A database connector object
* @param string The name of the category section
* @param integer The unique id of the category to edit (0 if new)
* @param string The name of the current user
*/
function editSection($uid = 0, $scope = '', $option)
{
    global $database, $my, $mainframe;
    $row = new mosSection($database);
    // load the row from the db table
    $row->load((int) $uid);
    // fail if checked out not by 'me'
    if ($row->isCheckedOut($my->id)) {
        $msg = 'The section ' . $row->title . ' is currently being edited by another administrator';
        mosRedirect('index2.php?option=' . $option . '&scope=' . $row->scope . '&mosmsg=' . $msg);
    }
    $selected_folders = NULL;
    if ($uid) {
        $row->checkout($my->id);
        if ($row->id > 0) {
            $query = "SELECT *" . "\n FROM #__menu" . "\n WHERE componentid = " . (int) $row->id . "\n AND ( type = 'content_archive_section' OR type = 'content_blog_section' OR type = 'content_section' )";
            $database->setQuery($query);
            $menus = $database->loadObjectList();
            $count = count($menus);
            for ($i = 0; $i < $count; $i++) {
                switch ($menus[$i]->type) {
                    case 'content_section':
                        $menus[$i]->type = 'Section Table';
                        break;
                    case 'content_blog_section':
                        $menus[$i]->type = 'Section Blog';
                        break;
                    case 'content_archive_section':
                        $menus[$i]->type = 'Section Blog Archive';
                        break;
                }
            }
        } else {
            $menus = array();
        }
        // handling for MOSImage directories
        if (trim($row->params)) {
            // get params definitions
            $params = new mosParameters($row->params, $mainframe->getPath('com_xml', 'com_sections'), 'component');
            $temps = $params->get('imagefolders', '');
            $temps = explode(',', $temps);
            foreach ($temps as $temp) {
                $selected_folders[] = mosHTML::makeOption($temp, $temp);
            }
        } else {
            $selected_folders[] = mosHTML::makeOption('*1*');
        }
    } else {
        $row->scope = $scope;
        $row->published = 1;
        $menus = array();
        // handling for MOSImage directories
        $selected_folders[] = mosHTML::makeOption('*1*');
    }
    // build the html select list for section types
    $types[] = mosHTML::makeOption('', 'Select Type');
    $types[] = mosHTML::makeOption('content_section', 'Section List');
    $types[] = mosHTML::makeOption('content_blog_section', 'Section Blog');
    $types[] = mosHTML::makeOption('content_archive_section', 'Section Archive Blog');
    $lists['link_type'] = mosHTML::selectList($types, 'link_type', 'class="inputbox" size="1"', 'value', 'text');
    // build the html select list for ordering
    $query = "SELECT ordering AS value, title AS text" . "\n FROM #__sections" . "\n WHERE scope=" . $database->Quote($row->scope) . " ORDER BY ordering";
    $lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $uid, $query);
    // build the select list for the image positions
    $active = $row->image_position ? $row->image_position : 'left';
    $lists['image_position'] = mosAdminMenus::Positions('image_position', $active, NULL, 0);
    // build the html select list for images
    $lists['image'] = mosAdminMenus::Images('image', $row->image);
    // build the html select list for the group access
    $lists['access'] = mosAdminMenus::Access($row);
    // build the html radio buttons for published
    $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published);
    // build the html select list for menu selection
    $lists['menuselect'] = mosAdminMenus::MenuSelect();
    // list of folders in images/stories/
    $imgFiles = recursive_listdir(COM_IMAGE_BASE);
    $len = strlen(COM_IMAGE_BASE);
    // handling for MOSImage directories
    $folders[] = mosHTML::makeOption('*1*', 'All');
    $folders[] = mosHTML::makeOption('*0*', 'None');
    $folders[] = mosHTML::makeOption('*#*', '---------------------');
    $folders[] = mosHTML::makeOption('/');
    foreach ($imgFiles as $file) {
        $folders[] = mosHTML::makeOption(substr($file, $len));
    }
    $lists['folders'] = mosHTML::selectList($folders, 'folders[]', 'class="inputbox" size="17" multiple="multiple"', 'value', 'text', $selected_folders);
    sections_html::edit($row, $option, $lists, $menus);
}
예제 #3
0
/**
* Compiles information to add or edit content
* @param database A database connector object
* @param string The name of the category section
* @param integer The unique id of the category to edit (0 if new)
*/
function edit($uid, $option)
{
    global $database, $my, $mainframe;
    global $mosConfig_absolute_path, $mosConfig_live_site;
    $row = new mosContent($database);
    // fail if checked out not by 'me'
    if ($row->checked_out && $row->checked_out != $my->id) {
        echo "<script>alert('" . sprintf(T_('The module % is currently being edited by another administrator'), $row->title) . "'); document.location.href='index2.php?option={$option}'</script>\n";
        exit(0);
    }
    $lists = array();
    if ($uid) {
        // load the row from the db table
        $row->load($uid);
        $row->checkout($my->id);
        if (trim($row->images)) {
            $row->images = explode("\n", $row->images);
        } else {
            $row->images = array();
        }
        if (trim($row->publish_down) == "0000-00-00 00:00:00") {
            $row->publish_down = "Never";
        }
        $query = "SELECT name from #__users" . "\n WHERE id={$row->created_by}";
        $database->setQuery($query);
        $row->creator = $database->loadResult();
        $query = "SELECT name from #__users" . "\n WHERE id={$row->modified_by}";
        $database->setQuery($query);
        $row->modifier = $database->loadResult();
        $query = "SELECT content_id from #__content_frontpage" . "\n WHERE content_id={$row->id}";
        $database->setQuery($query);
        $row->frontpage = $database->loadResult();
        // get list of links to this item
        $_and = "\n AND componentid = " . $row->id;
        $menus = mosAdminMenus::Links2Menu('content_typed', $_and);
    } else {
        // initialise values for a new item
        $row->version = 0;
        $row->state = 1;
        $row->images = array();
        $row->publish_up = date("Y-m-d", time());
        $row->publish_down = "Never";
        $row->sectionid = 0;
        $row->catid = 0;
        $row->creator = '';
        $row->modifier = '';
        $row->ordering = 0;
        $row->frontpage = 0;
        $menus = array();
    }
    // calls function to read image from directory
    $pathA = $mosConfig_absolute_path . '/images/stories';
    $pathL = $mosConfig_live_site . '/images/stories';
    $images = array();
    $folders = array();
    $folders[] = mosHTML::makeOption('/');
    mosAdminMenus::ReadImages($pathA, '/', $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);
    // 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 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 positions
    $lists['_align'] = mosAdminMenus::Positions('_align');
    // build the select list for the image caption alignment
    $lists['_caption_align'] = mosAdminMenus::Positions('_caption_align');
    // build the select list for the image caption position
    $pos[] = mosHTML::makeOption('bottom', T_('Bottom'));
    $pos[] = mosHTML::makeOption('top', T_('Top'));
    $lists['_caption_position'] = mosHTML::selectList($pos, '_caption_position', 'class="inputbox" size="1"', 'value', 'text');
    // get params definitions
    $params =& new mosAdminParameters($row->attribs, $mainframe->getPath('com_xml', 'com_typedcontent'), 'component');
    HTML_typedcontent::edit($row, $images, $lists, $params, $option, $menus);
}
예제 #4
0
function editCategory($section = '', $uid = 0)
{
    global $database, $my, $acl;
    global $mosConfig_absolute_path, $mosConfig_live_site;
    $type = mosGetParam($_REQUEST, 'type', '');
    $redirect = mosGetParam($_POST, 'section', '');
    $row = new mainBooklibraryCategories($database);
    //for 1.6
    // load the row from the db table
    $row->load($uid);
    // fail if checked out not by 'me'
    if ($row->checked_out && $row->checked_out != $my->id) {
        mosRedirect('index.php?option=com_booklibrary&task=categories', 'The category ' . $row->title . ' is currently being edited by another administrator');
    }
    $is_new = false;
    if ($uid) {
        // existing record
        $row->checkout($my->id);
        // code for Link Menu
    } else {
        $is_new = true;
        // new record
        $row->section = $section;
        $row->published = 1;
    }
    // make order list
    $order = array();
    $database->setQuery("SELECT COUNT(*) FROM #__booklibrary_main_categories WHERE section='{$row->section}'");
    //for 1.6
    $max = intval($database->loadResult()) + 1;
    for ($i = 1; $i < $max; $i++) {
        $order[] = mosHTML::makeOption($i);
    }
    // build the html select list for ordering
    $query = "SELECT ordering AS value, title AS text" . "\n FROM #__booklibrary_main_categories" . "\n WHERE section = '{$row->section}'" . "\n ORDER BY ordering";
    $mosAdminMenus = new mosAdminMenus();
    //$lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $uid, $query);
    $lists['ordering'] = version_compare(JVERSION, '3.0', 'ge') ? NUll : $mosAdminMenus->SpecificOrdering($row, $uid, $query);
    // build the select list for the image positions
    $active = $row->image_position ? $row->image_position : 'left';
    $lists['image_position'] = version_compare(JVERSION, '3.0', 'ge') ? NUll : $mosAdminMenus->Positions('image_position', $active, null, 0, 0);
    //$lists['image_position'] = mosAdminMenus::Positions('image_position', $active, null, 0, 0);
    // Imagelist
    $lists['image'] = HTML::imageList('image', $row->image);
    // build the html radio buttons for published
    $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published);
    // build the html select list for paraent item
    $options = array();
    $options[] = mosHTML::makeOption('0', _BOOKLIBRARY_A_SELECT_TOP);
    //***********access category */
    $gtree[] = mosHTML::makeOption('-2', 'Everyone');
    $gtree = get_group_children_tree_bl();
    $f = "";
    $s = explode(',', $row->params);
    for ($i = 0; $i < count($s); $i++) {
        $f[] = mosHTML::makeOption($s[$i]);
    }
    $lists['category']['registrationlevel'] = mosHTML::selectList($gtree, 'category_registrationlevel[]', 'size="" multiple="multiple"', 'value', 'text', $f);
    //********end access category*/
    //-------langarray-------------
    $retVal1 = mosBooklibraryOthers::getLanguageArray();
    $lang = null;
    for ($i = 0, $n = count($retVal1); $i < $n; $i++) {
        $help = $retVal1[$i];
        $lang[] = mosHTML::makeOption($help[0], $help[1]);
    }
    $lists['langlist'] = mosHTML::selectList($lang, 'language', 'class="inputbox" size="1"', 'value', 'text');
    //-----------------------------
    $lists['parent'] = HTML::categoryParentList($row->id, "", $is_new, $options);
    $params2 = unserialize($row->params2);
    $alone = '';
    $view = '';
    if ($uid != 0) {
        if (isset($params2->alone_category) or isset($params2->view_book)) {
            $alone = $params2->alone_category;
            $view = $params2->view_book;
        }
    }
    $component_path = JPath::clean(JPATH_SITE . '/components/com_booklibrary/views/showCategory/tmpl');
    $component_layouts = array();
    $options = array();
    if (is_dir($component_path) && ($component_layouts = JFolder::files($component_path, '^[^_]*\\.php$', false, true))) {
        $alone_category[] = JHtml::_('select.option', '', 'Use Global');
        foreach ($component_layouts as $i => $file) {
            $select_file_name = pathinfo($file);
            $select_file_name = $select_file_name['filename'];
            $alone_category[] = JHtml::_('select.option', $select_file_name, $select_file_name);
        }
    }
    $component_path = JPath::clean(JPATH_SITE . '/components/com_booklibrary/views/view_book/tmpl');
    $component_layouts = array();
    $options = array();
    if (is_dir($component_path) && ($component_layouts = JFolder::files($component_path, '^[^_]*\\.php$', false, true))) {
        $view_book[] = JHtml::_('select.option', '', 'Use Global');
        foreach ($component_layouts as $i => $file) {
            $select_file_name = pathinfo($file);
            $select_file_name = $select_file_name['filename'];
            $view_book[] = JHtml::_('select.option', $select_file_name, $select_file_name);
        }
    }
    $lists['view_book'] = mosHTML::selectList($view_book, 'view_book', 'class="inputbox" size="1"', 'value', 'text', $view);
    HTML_Categories::edit($row, $section, $lists, $redirect);
}
예제 #5
0
파일: content.php 프로젝트: cwcw/cms
function editItem($uid, $gid, &$access, $sectionid = 0, $task, $Itemid)
{
    global $database, $mainframe, $my;
    global $mosConfig_absolute_path, $mosConfig_live_site;
    $row = new mosContent($database);
    // load the row from the db table
    $row->load($uid);
    if ($uid) {
        // existing record
        if (!($access->canEdit || $access->canEditOwn && $row->created_by == $my->id)) {
            mosNotAuth();
            return;
        }
    } else {
        // new record
        if (!($access->canEdit || $access->canEditOwn)) {
            mosNotAuth();
            return;
        }
    }
    if ($uid) {
        $sectionid = $row->sectionid;
    }
    $lists = array();
    // get the type name - which is a special category
    $database->setQuery("SELECT name FROM #__sections WHERE id={$sectionid}");
    $section = $database->loadResult();
    // fail if checked out not by 'me'
    if ($row->checked_out && $row->checked_out != $my->id) {
        echo "<script>alert('The module " . $row->title . " is currently being edited by another person.')</script>";
        mosRedirect('index.php?option=com_content&amp;task=view&amp;id=' . $row->id);
    }
    if ($uid == 0) {
        $row->catid = 0;
    }
    if ($uid) {
        $row->checkout($my->id);
        if (trim($row->publish_down) == "0000-00-00 00:00:00") {
            $row->publish_down = "Never";
        }
        if (trim($row->images)) {
            $row->images = explode("\n", $row->images);
        } else {
            $row->images = array();
        }
        $database->setQuery("SELECT name from #__users" . "\n WHERE id = " . $row->created_by);
        $row->creator = $database->loadResult();
        $database->setQuery("SELECT name from #__users" . "\n WHERE id = " . $row->modified_by);
        $row->modifier = $database->loadResult();
        $database->setQuery("SELECT content_id from #__content_frontpage" . "\n WHERE content_id = " . $row->id);
        $row->frontpage = $database->loadResult();
    } else {
        $row->sectionid = $sectionid;
        $row->version = 0;
        $row->state = 0;
        $row->ordering = 0;
        $row->images = array();
        $row->publish_up = date('Y-m-d', time());
        $row->publish_down = 'Never';
        $row->creator = 0;
        $row->modifier = 0;
        $row->frontpage = 0;
    }
    // calls function to read image from directory
    $pathA = $mosConfig_absolute_path . '/images/stories';
    $pathL = $mosConfig_live_site . '/images/stories';
    $images = array();
    $folders = array();
    $folders[] = mosHTML::makeOption('/');
    mosAdminMenus::ReadImages($pathA, '/', $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);
    // list of saved images
    $lists['imagelist'] = mosAdminMenus::GetSavedImages($row, $pathL);
    // make the select list for the states
    $states[] = mosHTML::makeOption(0, _CMN_UNPUBLISHED);
    $states[] = mosHTML::makeOption(1, _CMN_PUBLISHED);
    $lists['state'] = mosHTML::selectList($states, 'state', 'class="inputbox" size="1"', 'value', 'text', intval($row->state));
    // build the html select list for ordering
    $query = "SELECT ordering AS value, title AS text" . "\n FROM #__content" . "\n WHERE catid = '{$row->catid}'" . "\n ORDER BY ordering";
    $lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $uid, $query, 1);
    // build list of categories
    $lists['catid'] = mosAdminMenus::ComponentCategory('catid', $sectionid, intval($row->catid));
    // build the select list for the image positions
    $lists['_align'] = mosAdminMenus::Positions('_align');
    // build the html select list for the group access
    $lists['access'] = mosAdminMenus::Access($row);
    HTML_content::editContent($row, $section, $lists, $images, $access, $my->id, $sectionid, $task, $Itemid);
}
예제 #6
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 = mosGetParam($_POST, 'redirect', '');
    if (!$redirect) {
        $redirect = $sectionid;
    }
    // load the row from the db table
    $row = new mosContent($database);
    $row->load($uid);
    if ($uid) {
        $sectionid = $row->sectionid;
        if ($row->state < 0) {
            mosRedirect('index2.php?option=com_content&sectionid=' . $row->sectionid, T_('You cannot edit an archived item'));
        }
    }
    if ($sectionid == 0) {
        $where = "\n WHERE section NOT LIKE '%com_%'";
    } else {
        $where = "\n WHERE section='{$sectionid}'";
    }
    // get the type name - which is a special category
    if ($row->sectionid) {
        $query = "SELECT name FROM #__sections WHERE id={$row->sectionid}";
        $database->setQuery($query);
        $section = $database->loadResult();
        $contentSection = $section;
    } else {
        $query = "SELECT name FROM #__sections WHERE id={$sectionid}";
        $database->setQuery($query);
        $section = $database->loadResult();
        $contentSection = $section;
    }
    // fail if checked out not by 'me'
    if ($row->checked_out && $row->checked_out != $my->id) {
        mosRedirect('index2.php?option=com_content', sprintf(T_('The module %s is currently being edited by another administrator'), $row->title));
    }
    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, '%Y-%m-%d %H:%M:%S');
        $row->modified = mosFormatDate($row->modified, '%Y-%m-%d %H:%M:%S');
        $row->publish_up = mosFormatDate($row->publish_up, '%Y-%m-%d %H:%M:%S');
        if (trim($row->publish_down) == '0000-00-00 00:00:00') {
            $row->publish_down = T_('Never');
        }
        $query = "SELECT name from #__users" . "\n WHERE id={$row->created_by}";
        $database->setQuery($query);
        $row->creator = $database->loadResult();
        $query = "SELECT name from #__users" . "\n WHERE id={$row->modified_by}";
        $database->setQuery($query);
        $row->modifier = $database->loadResult();
        $query = "SELECT content_id from #__content_frontpage" . "\n WHERE content_id={$row->id}";
        $database->setQuery($query);
        $row->frontpage = $database->loadResult();
        // get list of links to this item
        $_and = "\n AND componentid = " . $row->id;
        $menus = mosAdminMenus::Links2Menu('content_item_link', $_and);
    } else {
        $row->sectionid = $sectionid;
        $row->version = 0;
        $row->state = 1;
        $row->ordering = 0;
        $row->images = array();
        //$row->publish_up 	= date( 'Y-m-d', time() );
        $row->publish_up = date('Y-m-d', time() + $mosConfig_offset * 60 * 60);
        $row->publish_down = T_('Never');
        $row->catid = NULL;
        $row->creator = '';
        $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 AS value, s.title AS text" . "\n FROM #__sections AS s" . "\n ORDER BY s.ordering";
    $database->setQuery($query);
    $sections = $database->loadObjectList();
    if ($sectionid == 0) {
        if ($sections) {
            array_unshift($sections, mosHTML::makeOption('-1', T_('Select Section')));
        } else {
            $sections[] = mosHTML::makeOption('-1', T_('Add Section(s) First'));
        }
        $lists['sectionid'] = mosHTML::selectList($sections, 'sectionid', 'class="inputbox" size="1" ' . $javascript, 'value', 'text');
    } else {
        $lists['sectionid'] = mosHTML::selectList($sections, 'sectionid', 'class="inputbox" size="1" ' . $javascript, 'value', 'text', intval($row->sectionid));
    }
    $sectioncategories = array();
    $sectioncategories[-1] = array();
    $sectioncategories[-1][] = mosHTML::makeOption('-1', T_('Select Category'));
    if ($sections) {
        foreach ($sections as $section) {
            $sectioncategories[$section->value] = array();
            $query = "SELECT id AS value, name AS text" . "\n FROM #__categories" . "\n WHERE section='{$section->value}'" . "\n ORDER BY ordering";
            $database->setQuery($query);
            $rows2 = $database->loadObjectList();
            if ($rows2) {
                foreach ($rows2 as $row2) {
                    $sectioncategories[$section->value][] = mosHTML::makeOption($row2->value, $row2->text);
                }
            } else {
                $sectioncategories[$section->value][] = mosHTML::makeOption("-1", T_('Add Categories First'));
            }
        }
    }
    // get list of categories
    if (!$row->catid && !$row->sectionid) {
        $categories[] = mosHTML::makeOption('-1', T_('Select Category'));
        $lists['catid'] = mosHTML::selectList($categories, 'catid', 'class="inputbox" size="1"', 'value', 'text');
    } else {
        $query = "SELECT id AS value, name AS text" . "\n FROM #__categories" . $where . "\n ORDER BY ordering";
        $database->setQuery($query);
        $categories[] = mosHTML::makeOption('-1', T_('Select Category'));
        $categories = array_merge($categories, $database->loadObjectList());
        $lists['catid'] = mosHTML::selectList($categories, 'catid', 'class="inputbox" size="1"', 'value', 'text', intval($row->catid));
    }
    // build the html select list for ordering
    $query = "SELECT ordering AS value, title AS text" . "\n FROM #__content" . "\n WHERE catid='{$row->catid}'" . "\n AND state >= 0" . "\n ORDER BY ordering";
    $lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $uid, $query, 1);
    // calls function to read image from directory
    $pathA = $mosConfig_absolute_path . '/images/stories';
    $pathL = $mosConfig_live_site . '/images/stories';
    $images = array();
    $folders = array();
    $folders[] = mosHTML::makeOption('/');
    mosAdminMenus::ReadImages($pathA, '/', $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);
    // 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', T_('Bottom'));
    $pos[] = mosHTML::makeOption('top', T_('Top'));
    $lists['_caption_position'] = mosHTML::selectList($pos, '_caption_position', 'class="inputbox" size="1"', 'value', 'text');
    // get params definitions
    $params =& new mosAdminParameters($row->attribs, $mainframe->getPath('com_xml', 'com_content'), 'component');
    HTML_content::editContent($row, $contentSection, $lists, $sectioncategories, $images, $params, $option, $redirect, $menus);
}
예제 #7
0
파일: admin.content.php 프로젝트: cwcw/cms
/**
* 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, $adminLanguage;
    global $mosConfig_absolute_path, $mosConfig_live_site;
    $redirect = mosGetParam($_POST, 'redirect', '');
    if (!$redirect) {
        $redirect = $sectionid;
    }
    // load the row from the db table
    $row = new mosContent($database);
    $row->load($uid);
    if ($uid) {
        $sectionid = $row->sectionid;
        if ($row->state < 0) {
            mosRedirect('index2.php?option=com_content&sectionid=' . $row->sectionid, $adminLanguage->A_COMP_CONTENT_CANNOT);
        }
    }
    if ($sectionid == 0) {
        $where = "\n WHERE section NOT LIKE '%com_%'";
    } else {
        $where = "\n WHERE section='{$sectionid}'";
    }
    // get the type name - which is a special category
    if ($row->sectionid) {
        $query = "SELECT name FROM #__sections WHERE id={$row->sectionid}";
        $database->setQuery($query);
        $section = $database->loadResult();
        $contentSection = $section;
    } else {
        $query = "SELECT name FROM #__sections WHERE id={$sectionid}";
        $database->setQuery($query);
        $section = $database->loadResult();
        $contentSection = $section;
    }
    // fail if checked out not by 'me'
    if ($row->checked_out && $row->checked_out != $my->id) {
        mosRedirect("index2.php?option=com_content", $adminLanguage->A_COMP_CONTENT_MODULE . " " . $row->title . " " . $adminLanguage->A_COMP_CONTENT_ANOTHER);
    }
    if ($uid) {
        $row->checkout($my->id);
        if (trim($row->images)) {
            $row->images = explode("\n", $row->images);
        } else {
            $row->images = array();
        }
        if (trim($row->publish_down) == '0000-00-00 00:00:00') {
            $row->publish_down = 'Never';
        }
        $query = "SELECT name from #__users" . "\n WHERE id={$row->created_by}";
        $database->setQuery($query);
        $row->creator = $database->loadResult();
        $query = "SELECT name from #__users" . "\n WHERE id={$row->modified_by}";
        $database->setQuery($query);
        $row->modifier = $database->loadResult();
        $query = "SELECT content_id from #__content_frontpage" . "\n WHERE content_id={$row->id}";
        $database->setQuery($query);
        $row->frontpage = $database->loadResult();
        // get list of links to this item
        $and = "\n AND componentid = " . $row->id;
        $menus = mosAdminMenus::Links2Menu('content_item_link', $and);
    } else {
        $row->sectionid = $sectionid;
        $row->version = 0;
        $row->state = 1;
        $row->ordering = 0;
        $row->images = array();
        $row->publish_up = date('Y-m-d', time());
        $row->publish_down = 'Never';
        $row->catid = NULL;
        $row->creator = '';
        $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 AS value, s.title AS text" . "\n FROM #__sections AS s" . "\n ORDER BY s.ordering";
    $database->setQuery($query);
    if ($sectionid == 0) {
        $sections[] = mosHTML::makeOption('-1', $adminLanguage->A_COMP_CONTENT_SELECT_SEC);
        $sections = array_merge($sections, $database->loadObjectList());
        $lists['sectionid'] = mosHTML::selectList($sections, 'sectionid', 'class="inputbox" size="1" ' . $javascript, 'value', 'text');
    } else {
        $lists['sectionid'] = mosHTML::selectList($database->loadObjectList(), 'sectionid', 'class="inputbox" size="1" ' . $javascript, 'value', 'text', intval($row->sectionid));
    }
    $sections = $database->loadObjectList();
    $sectioncategories = array();
    $sectioncategories[-1] = array();
    $sectioncategories[-1][] = mosHTML::makeOption('-1', $adminLanguage->A_COMP_CONTENT_SELECT_CAT);
    foreach ($sections as $section) {
        $sectioncategories[$section->value] = array();
        $query = "SELECT id AS value, name AS text" . "\n FROM #__categories" . "\n WHERE section='{$section->value}'" . "\n ORDER BY ordering";
        $database->setQuery($query);
        $rows2 = $database->loadObjectList();
        foreach ($rows2 as $row2) {
            $sectioncategories[$section->value][] = mosHTML::makeOption($row2->value, $row2->text);
        }
    }
    //echo "<div align=left><pre>"; print_r($sectioncategories); die;
    $query = "SELECT id AS value, name AS text" . "\n FROM #__categories" . $where . "\n ORDER BY ordering";
    $database->setQuery($query);
    if (!$row->catid && !$row->sectionid) {
        // get list of categories
        $categories[] = mosHTML::makeOption('-1', $adminLanguage->A_COMP_CONTENT_SELECT_CAT);
        /*
        $categories = array_merge( $categories, $database->loadObjectList() );
        if (count( $categories ) < 2) {
        	mosRedirect( 'index2.php?option=com_categories&section='. $sectionid, 'You must add a category for this section first.' );
        }
        */
        $lists['catid'] = mosHTML::selectList($categories, 'catid', 'class="inputbox" size="1"', 'value', 'text');
    } else {
        $lists['catid'] = mosHTML::selectList($database->loadObjectList(), 'catid', 'class="inputbox" size="1"', 'value', 'text', intval($row->catid));
    }
    // build the html select list for ordering
    $query = "SELECT ordering AS value, title AS text" . "\n FROM #__content" . "\n WHERE catid='{$row->catid}'" . "\n AND state >= 0" . "\n ORDER BY ordering";
    $lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $uid, $query, 1);
    // calls function to read image from directory
    $pathA = $mosConfig_absolute_path . '/images/stories';
    $pathL = $mosConfig_live_site . '/images/stories';
    $images = array();
    $folders = array();
    $folders[] = mosHTML::makeOption('/');
    mosAdminMenus::ReadImages($pathA, '/', $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);
    // 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 positions
    $lists['_align'] = mosAdminMenus::Positions('_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();
    // get params definitions
    $params =& new mosParameters($row->attribs, $mainframe->getPath('com_xml', 'com_content'), 'component');
    HTML_content::editContent($row, $contentSection, $lists, $sectioncategories, $images, $my->id, $params, $option, $redirect, $menus);
}
예제 #8
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);
}
예제 #9
0
파일: admin.sections.php 프로젝트: cwcw/cms
/**
* Compiles information to add or edit a section
* @param database A database connector object
* @param string The name of the category section
* @param integer The unique id of the category to edit (0 if new)
* @param string The name of the current user
*/
function editSection($uid = 0, $scope = '', $option)
{
    global $database, $my, $adminLanguage;
    global $mosConfig_absolute_path, $mosConfig_live_site;
    $row = new mosSection($database);
    // load the row from the db table
    $row->load($uid);
    // fail if checked out not by 'me'
    if ($row->checked_out && $row->checked_out != $my->id) {
        $msg = $adminLanguage->A_COMP_SECT_THE . " " . $row->title . " " . $adminLanguage->A_COMP_ANOTHER_ADMIN;
        mosRedirect('index2.php?option=' . $option . '&scope=' . $row->scope . '&mosmsg=' . $msg);
    }
    if ($uid) {
        $row->checkout($my->id);
        if ($row->id > 0) {
            $query = "SELECT *" . "\n FROM #__menu" . "\n WHERE componentid = " . $row->id . "\n AND ( type = 'content_archive_section' OR type = 'content_blog_section' OR type = 'content_section' )";
            $database->setQuery($query);
            $menus = $database->loadObjectList();
            $count = count($menus);
            for ($i = 0; $i < $count; $i++) {
                switch ($menus[$i]->type) {
                    case 'content_section':
                        $menus[$i]->type = 'Section Table';
                        break;
                    case 'content_blog_section':
                        $menus[$i]->type = 'Section Blog';
                        break;
                    case 'content_archive_section':
                        $menus[$i]->type = 'Section Blog Archive';
                        break;
                }
            }
        } else {
            $menus = array();
        }
    } else {
        $row->scope = $scope;
        $row->published = 1;
        $menus = array();
    }
    // build the html select list for section types
    $types[] = mosHTML::makeOption('', $adminLanguage->A_COMP_CATEG_SELECT_TYPE);
    $types[] = mosHTML::makeOption('content_section', $adminLanguage->A_COMP_SECT_LIST);
    $types[] = mosHTML::makeOption('content_blog_section', $adminLanguage->A_COMP_SECT_BLOG);
    $types[] = mosHTML::makeOption('content_archive_section', $adminLanguage->A_COMP_SECT_ARCHIVE_BLOG);
    $lists['link_type'] = mosHTML::selectList($types, 'link_type', 'class="inputbox" size="1"', 'value', 'text');
    // build the html select list for ordering
    $query = "SELECT ordering AS value, title AS text" . "\n FROM #__sections" . "\n WHERE scope='{$row->scope}' ORDER BY ordering";
    $lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $uid, $query);
    // build the select list for the image positions
    $active = $row->image_position ? $row->image_position : 'left';
    $lists['image_position'] = mosAdminMenus::Positions('image_position', $active, NULL, 0);
    // build the html select list for images
    $lists['image'] = mosAdminMenus::Images('image', $row->image);
    // build the html select list for the group access
    $lists['access'] = mosAdminMenus::Access($row);
    // build the html radio buttons for published
    $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published);
    // build the html select list for menu selection
    $lists['menuselect'] = mosAdminMenus::MenuSelect();
    sections_html::edit($row, $option, $lists, $menus);
}
    function editMailing($mailingEdit, $new, $listId, $forms, $show)
    {
        global $my, $_VERSION;
        $lists = array();
        $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $mailingEdit->published);
        $lists['visible'] = mosHTML::yesnoRadioList('visible', 'class="inputbox"', $mailingEdit->visible);
        $images = $mailingEdit->images;
        if (!isset($mailingEdit->list_id)) {
            $mailingEdit->list_id = $listId;
        }
        $pathA = $GLOBALS['mosConfig_absolute_path'] . '/images/stories';
        $pathL = $GLOBALS['mosConfig_live_site'] . '/images/stories';
        $images = array();
        $folders = array();
        $folders[] = mosHTML::makeOption('/');
        mosAdminMenus::ReadImages($pathA, '/', $folders, $images);
        $joomAca15 = $_VERSION->RELEASE != '1.0' && class_exists('JFactory') ? true : false;
        if (!$joomAca15) {
            $lists['folders'] = mosAdminMenus::GetImageFolders($folders, $pathL);
            $lists['imagefiles'] = mosAdminMenus::GetImages($images, $pathL);
            $lists['imagelist'] = mosAdminMenus::GetSavedImages($mailingEdit, $pathL);
        }
        $lists['_align'] = mosAdminMenus::Positions('_align');
        $lists['_caption_align'] = mosAdminMenus::Positions('_caption_align');
        $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');
        backHTML::formStart('edit_mailing', $mailingEdit->html, $images);
        echo $forms['main'];
        if ($new and $mailingEdit->list_type == 7) {
            $mailingEdit->issue_nb = 0;
        }
        mailingsHTML::layout($mailingEdit, $lists, $show);
        ?>
		<input type="hidden" name="images" value="" />
		<input type="hidden" name="html" value="<?php 
        echo $mailingEdit->html;
        ?>
" />
		<input type="hidden" name="new_list" value="<?php 
        echo $new;
        ?>
" />
		<input type="hidden" name="listid" value="<?php 
        echo $listId;
        ?>
" />
		<input type="hidden" name="listype" value="<?php 
        echo $mailingEdit->list_type;
        ?>
" />
		<input type="hidden" name="mailingid" value="<?php 
        echo $mailingEdit->id;
        ?>
" />
		<input type="hidden" name="issue_nb" value="<?php 
        echo $mailingEdit->issue_nb;
        ?>
" />
	    <input type="hidden" name="userid" value="<?php 
        echo $my->id;
        ?>
" />
		<?php 
    }
예제 #11
0
/**
* Compiles information to add or edit content
* @param database A database connector object
* @param string The name of the category section
* @param integer The unique id of the category to edit (0 if new)
*/
function edit($uid, $option)
{
    global $database, $my, $acl, $mainframe, $adminLanguage;
    global $mosConfig_absolute_path, $mosConfig_live_site;
    $row = new mosContent($database);
    // fail if checked out not by 'me'
    if ($row->checked_out && $row->checked_out != $my->id) {
        echo "<script>alert(\"" . $adminLanguage->A_COMP_CONTENT_MODULE . " " . $row->title . " " . $adminLanguage->A_COMP_ANOTHER_ADMIN . "\"); document.location.href='index2.php?option={$option}'</script>\n";
        exit(0);
    }
    $lists = array();
    if ($uid) {
        // load the row from the db table
        $row->load($uid);
        $row->checkout($my->id);
        if (trim($row->images)) {
            $row->images = explode("\n", $row->images);
        } else {
            $row->images = array();
        }
        if (trim($row->publish_down) == "0000-00-00 00:00:00") {
            $row->publish_down = "Never";
        }
        $query = "SELECT name from #__users" . "\n WHERE id={$row->created_by}";
        $database->setQuery($query);
        $row->creator = $database->loadResult();
        $query = "SELECT name from #__users" . "\n WHERE id={$row->modified_by}";
        $database->setQuery($query);
        $row->modifier = $database->loadResult();
        // get list of links to this item
        $and = "\n AND componentid = " . $row->id;
        $menus = mosAdminMenus::Links2Menu('content_typed', $and);
    } else {
        // initialise values for a new item
        $row->version = 0;
        $row->state = 1;
        $row->images = array();
        $row->publish_up = date("Y-m-d", time());
        $row->publish_down = "Never";
        $row->sectionid = 0;
        $row->catid = 0;
        $row->creator = '';
        $row->modifier = '';
        $row->ordering = 0;
        $menus = array();
    }
    // calls function to read image from directory
    $pathA = $mosConfig_absolute_path . '/images/stories';
    $pathL = $mosConfig_live_site . '/images/stories';
    $images = array();
    $folders = array();
    $folders[] = mosHTML::makeOption('/');
    mosAdminMenus::ReadImages($pathA, '/', $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);
    // 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 positions
    $lists['_align'] = mosAdminMenus::Positions('_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();
    // get params definitions
    $params =& new mosParameters($row->attribs, $mainframe->getPath('com_xml', 'com_typedcontent'), 'component');
    HTML_typedcontent::edit($row, $images, $lists, $my->id, $params, $option, $menus);
}
예제 #12
0
function editCategory($section = '', $uid = 0)
{
    global $database, $my;
    global $mosConfig_absolute_path, $mosConfig_live_site;
    // disable the main menu to force user to use buttons
    $_REQUEST['hidemainmenu'] = 1;
    $type = mosGetParam($_REQUEST, 'type', '');
    $redirect = mosGetParam($_POST, 'section', '');
    $row = new mosDMCategory($database);
    // load the row from the db table
    $row->load($uid);
    // fail if checked out not by 'me'
    if ($row->checked_out && $row->checked_out != $my->id) {
        mosRedirect('index2.php?option=com_docman&task=categories', 'The category ' . $row->title . ' is currently being edited by another administrator');
    }
    if ($uid) {
        // existing record
        $row->checkout($my->id);
        // code for Link Menu
    } else {
        // new record
        $row->section = $section;
        $row->published = 1;
    }
    // make order list
    $order = array();
    $database->setQuery("SELECT COUNT(*) FROM #__categories WHERE section='{$row->section}'");
    $max = intval($database->loadResult()) + 1;
    for ($i = 1; $i < $max; $i++) {
        $order[] = mosHTML::makeOption($i);
    }
    // build the html select list for ordering
    $query = "SELECT ordering AS value, title AS text" . "\n FROM #__categories" . "\n WHERE section = '{$row->section}'" . "\n ORDER BY ordering";
    $lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $uid, $query);
    // build the select list for the image positions
    $active = $row->image_position ? $row->image_position : 'left';
    $lists['image_position'] = mosAdminMenus::Positions('image_position', $active, null, 0, 0);
    // Imagelist
    $lists['image'] = dmHTML::imageList('image', $row->image);
    // build the html select list for the group access
    $lists['access'] = mosAdminMenus::Access($row);
    // build the html radio buttons for published
    $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published);
    // build the html select list for paraent item
    $options = array();
    $options[] = mosHTML::makeOption('0', _DML_TOP);
    $lists['parent'] = dmHTML::categoryParentList($row->id, "", $options);
    HTML_DMCategories::edit($row, $section, $lists, $redirect);
}
예제 #13
0
/**
* Compiles information to add or edit a category
* @param string The name of the category section
* @param integer The unique id of the category to edit (0 if new)
* @param string The name of the current user
*/
function editCategory($uid = 0, $section = '')
{
    global $database, $my, $mainframe;
    $type = strval(mosGetParam($_REQUEST, 'type', ''));
    $redirect = strval(mosGetParam($_REQUEST, 'section', 'content'));
    // check for existance of any sections
    $query = "SELECT COUNT( id )" . "\n FROM #__sections" . "\n WHERE scope = 'content'";
    $database->setQuery($query);
    $sections = $database->loadResult();
    if (!$sections && $type != 'other') {
        echo "<script> alert('You need to have at least one Section before you can create a Category'); window.history.go(-1); </script>\n";
        exit;
    }
    $row = new mosCategory($database);
    // load the row from the db table
    $row->load((int) $uid);
    // fail if checked out not by 'me'
    if ($row->checked_out && $row->checked_out != $my->id) {
        mosRedirect('index2.php?option=categories&section=' . $row->section, 'The category ' . $row->title . ' is currently being edited by another administrator');
    }
    $lists['links'] = 0;
    $menus = NULL;
    $selected_folders = NULL;
    if ($uid) {
        // existing record
        $row->checkout($my->id);
        // code for Link Menu
        switch ($row->section) {
            case 'com_weblinks':
                $and = "\n AND type = 'weblink_category_table'";
                $link = 'Table - Weblink Category';
                break;
            case 'com_newsfeeds':
                $and = "\n AND type = 'newsfeed_category_table'";
                $link = 'Table - Newsfeeds Category';
                break;
            case 'com_contact_details':
                $and = "\n AND type = 'contact_category_table'";
                $link = 'Table - Contacts Category';
                break;
            default:
                $and = '';
                $link = '';
                break;
        }
        // content
        if ($row->section > 0) {
            $query = "SELECT *" . "\n FROM #__menu" . "\n WHERE componentid = " . (int) $row->id . "\n AND ( type = 'content_archive_category' OR type = 'content_blog_category' OR type = 'content_category' )";
            $database->setQuery($query);
            $menus = $database->loadObjectList();
            $count = count($menus);
            for ($i = 0; $i < $count; $i++) {
                switch ($menus[$i]->type) {
                    case 'content_category':
                        $menus[$i]->type = 'Table - Content Category';
                        break;
                    case 'content_blog_category':
                        $menus[$i]->type = 'Blog - Content Category';
                        break;
                    case 'content_archive_category':
                        $menus[$i]->type = 'Blog - Content Category Archive';
                        break;
                }
            }
            $lists['links'] = 1;
            // handling for MOSImage directories
            if (trim($row->params)) {
                // get params definitions
                $params = new mosParameters($row->params, $mainframe->getPath('com_xml', 'com_categories'), 'component');
                $temps = $params->get('imagefolders', '');
                $temps = explode(',', $temps);
                foreach ($temps as $temp) {
                    $selected_folders[] = mosHTML::makeOption($temp, $temp);
                }
            } else {
                $selected_folders[] = mosHTML::makeOption('*2*');
            }
        } else {
            $query = "SELECT *" . "\n FROM #__menu" . "\n WHERE componentid = " . (int) $row->id . $and;
            $database->setQuery($query);
            $menus = $database->loadObjectList();
            $count = count($menus);
            for ($i = 0; $i < $count; $i++) {
                $menus[$i]->type = $link;
            }
            $lists['links'] = 1;
        }
    } else {
        // new record
        $row->section = $section;
        $row->published = 1;
        $menus = NULL;
        // handling for MOSImage directories
        if ($row->section == 'content') {
            $selected_folders[] = mosHTML::makeOption('*2*');
        }
    }
    // make order list
    $order = array();
    $query = "SELECT COUNT(*)" . "\n FROM #__categories" . "\n WHERE section = " . $database->Quote($row->section);
    $database->setQuery($query);
    $max = intval($database->loadResult()) + 1;
    for ($i = 1; $i < $max; $i++) {
        $order[] = mosHTML::makeOption($i);
    }
    // build the html select list for sections
    if ($section == 'content') {
        $query = "SELECT s.id AS value, s.title AS text" . "\n FROM #__sections AS s" . "\n ORDER BY s.ordering";
        $database->setQuery($query);
        $sections = $database->loadObjectList();
        $lists['section'] = mosHTML::selectList($sections, 'section', 'class="inputbox" size="1"', 'value', 'text');
    } else {
        if ($type == 'other') {
            $section_name = 'N/A';
        } else {
            $temp = new mosSection($database);
            $temp->load($row->section);
            $section_name = $temp->name;
        }
        $lists['section'] = '<input type="hidden" name="section" value="' . $row->section . '" />' . $section_name;
    }
    // build the html select list for category types
    $types[] = mosHTML::makeOption('', 'Select Type');
    if ($row->section == 'com_contact_details') {
        $types[] = mosHTML::makeOption('contact_category_table', 'Contact Category Table');
    } else {
        if ($row->section == 'com_newsfeeds') {
            $types[] = mosHTML::makeOption('newsfeed_category_table', 'Newsfeed Category Table');
        } else {
            if ($row->section == 'com_weblinks') {
                $types[] = mosHTML::makeOption('weblink_category_table', 'Weblink Category Table');
            } else {
                $types[] = mosHTML::makeOption('content_category', 'Content Category Table');
                $types[] = mosHTML::makeOption('content_blog_category', 'Content Category Blog');
                $types[] = mosHTML::makeOption('content_archive_category', 'Content Category Archive Blog');
            }
        }
    }
    // if
    $lists['link_type'] = mosHTML::selectList($types, 'link_type', 'class="inputbox" size="1"', 'value', 'text');
    // build the html select list for ordering
    $query = "SELECT ordering AS value, title AS text" . "\n FROM #__categories" . "\n WHERE section = " . $database->Quote($row->section) . "\n ORDER BY ordering";
    $lists['ordering'] = stripslashes(mosAdminMenus::SpecificOrdering($row, $uid, $query));
    // build the select list for the image positions
    $active = $row->image_position ? $row->image_position : 'left';
    $lists['image_position'] = mosAdminMenus::Positions('image_position', $active, NULL, 0, 0);
    // Imagelist
    $lists['image'] = mosAdminMenus::Images('image', $row->image);
    // build the html select list for the group access
    $lists['access'] = mosAdminMenus::Access($row);
    // build the html radio buttons for published
    $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published);
    // build the html select list for menu selection
    $lists['menuselect'] = mosAdminMenus::MenuSelect();
    // handling for MOSImage directories
    if ($row->section > 0 || $row->section == 'content') {
        // list of folders in images/stories/
        $imgFiles = recursive_listdir(COM_IMAGE_BASE);
        $len = strlen(COM_IMAGE_BASE);
        $folders[] = mosHTML::makeOption('*2*', 'Use Section settings');
        $folders[] = mosHTML::makeOption('*#*', '---------------------');
        $folders[] = mosHTML::makeOption('*1*', 'All');
        $folders[] = mosHTML::makeOption('*0*', 'None');
        $folders[] = mosHTML::makeOption('*#*', '---------------------');
        $folders[] = mosHTML::makeOption('/');
        foreach ($imgFiles as $file) {
            $folders[] = mosHTML::makeOption(substr($file, $len));
        }
        $lists['folders'] = mosHTML::selectList($folders, 'folders[]', 'class="inputbox" size="17" multiple="multiple"', 'value', 'text', $selected_folders);
    }
    categories_html::edit($row, $lists, $redirect, $menus);
}
예제 #14
0
/**
* Compiles information to add or edit a section
* @param database A database connector object
* @param string The name of the category section
* @param integer The unique id of the category to edit (0 if new)
* @param string The name of the current user
*/
function editSection($uid = 0, $scope = '', $option)
{
    global $database, $my;
    $row = new mosSection($database);
    // load the row from the db table
    $row->load($uid);
    $row->title = htmlspecialchars(str_replace('&amp;', '&', $row->title));
    $row->name = htmlspecialchars(str_replace('&amp;', '&', $row->name));
    // fail if checked out not by 'me'
    if ($row->checked_out && $row->checked_out != $my->id) {
        $msg = sprintf(T_('The section %s is currently being edited by another administrator'), $row->title);
        mosRedirect('index2.php?option=' . $option . '&scope=' . $row->scope . '&mosmsg=' . $msg);
    }
    if ($uid) {
        $row->checkout($my->id);
        if ($row->id > 0) {
            $query = "SELECT *" . "\n FROM #__menu" . "\n WHERE componentid = " . $row->id . "\n AND ( type = 'content_archive_section' OR type = 'content_blog_section' OR type = 'content_section' )";
            $database->setQuery($query);
            $menus = $database->loadObjectList();
            $count = count($menus);
            for ($i = 0; $i < $count; $i++) {
                switch ($menus[$i]->type) {
                    case 'content_section':
                        $menus[$i]->type = T_('Section Table');
                        break;
                    case 'content_blog_section':
                        $menus[$i]->type = T_('Section Blog');
                        break;
                    case 'content_archive_section':
                        $menus[$i]->type = T_('Section Blog Archive');
                        break;
                }
            }
        } else {
            $menus = array();
        }
    } else {
        $row->scope = $scope;
        $row->published = 1;
        $menus = array();
    }
    // build the html select list for section types
    $types[] = mosHTML::makeOption('', T_('Select Type'));
    $types[] = mosHTML::makeOption('content_section', T_('Section List'));
    $types[] = mosHTML::makeOption('content_blog_section', T_('Section Blog'));
    $types[] = mosHTML::makeOption('content_archive_section', T_('Section Archive Blog'));
    $lists['link_type'] = mosHTML::selectList($types, 'link_type', 'class="inputbox" size="1"', 'value', 'text');
    // build the html select list for ordering
    $query = "SELECT ordering AS value, title AS text" . "\n FROM #__sections" . "\n WHERE scope='{$row->scope}' ORDER BY ordering";
    $lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $uid, $query);
    // build the select list for the image positions
    $active = $row->image_position ? $row->image_position : 'left';
    $lists['image_position'] = mosAdminMenus::Positions('image_position', $active, NULL, 0);
    // build the html select list for images
    $lists['image'] = mosAdminMenus::Images('image', $row->image);
    // build the html select list for the group access
    $lists['access'] = mosAdminMenus::Access($row);
    // build the html radio buttons for published
    $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published);
    // build the html select list for menu selection
    $lists['menuselect'] = mosAdminMenus::MenuSelect();
    sections_html::edit($row, $option, $lists, $menus);
}
예제 #15
0
    function editMailing($mailingEdit, $new, $listId, $forms, $show)
    {
        $lists = array();
        $folders = array();
        if (ACA_CMSTYPE) {
            $my =& JFactory::getUser();
            $folders[] = JHTML::_('select.option', '/');
            $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $mailingEdit->published);
            $lists['visible'] = JHTML::_('select.booleanlist', 'visible', 'class="inputbox"', $mailingEdit->visible);
        } else {
            global $my;
            $folders[] = mosHTML::makeOption('/');
            $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $mailingEdit->published);
            $lists['visible'] = mosHTML::yesnoRadioList('visible', 'class="inputbox"', $mailingEdit->visible);
        }
        //endif
        $images = $mailingEdit->images;
        if (!isset($mailingEdit->list_id)) {
            $mailingEdit->list_id = $listId;
        }
        $pathA = ACA_JPATH_ROOT_NO_ADMIN . '/images/stories';
        $pathL = ACA_JPATH_LIVE . '/images/stories';
        $images = array();
        if (ACA_CMSTYPE) {
            mailingsHTML::ReadImages($pathA, '/', $folders, $images);
            if (!isset($images['/'])) {
                $images['/'][] = JHTML::_('select.option', '');
            }
            $javascript = "onchange=\"previewImage( 'imagefiles', 'view_imagefiles', '{$pathL}/' )\"";
            $lists['imagefiles'] = JHTML::_('select.genericlist', $images['/'], 'imagefiles', 'class="inputbox" size="10" multiple="multiple" ' . $javascript, 'value', 'text', null);
            $javascript = "onchange=\"changeDynaList( 'imagefiles', folderimages, document.adminForm.folders.options[document.adminForm.folders.selectedIndex].value, 0, 0);  previewImage( 'imagefiles', 'view_imagefiles', '{$pathL}/' );\"";
            $lists['folders'] = JHTML::_('select.genericlist', $folders, 'folders', 'class="inputbox" size="1" ' . $javascript, 'value', 'text', '/');
            $images2 = array();
            foreach ($mailingEdit->images as $file) {
                $temp = explode('|', $file);
                if (strrchr($temp[0], '/')) {
                    $filename = substr(strrchr($temp[0], '/'), 1);
                } else {
                    $filename = $temp[0];
                }
                $images2[] = JHTML::_('select.option', $file, $filename);
            }
            //$javascript	= "onchange=\"previewImage( 'imagelist', 'view_imagelist', '$path/' ); showImageProps( '$path/' ); \" onfocus=\"previewImage( 'imagelist', 'view_imagelist', '$path/' )\"";
            $javascript = "onchange=\"previewImage( 'imagelist', 'view_imagelist', '{$pathL}/' ); showImageProps( '{$pathL}/' ); \"";
            $lists['imagelist'] = JHTML::_('select.genericlist', $images2, 'imagelist', 'class="inputbox" size="10" ' . $javascript, 'value', 'text');
            $lists['_align'] = JHTML::_('list.positions', '_align');
            $lists['_caption_align'] = JHTML::_('list.positions', '_caption_align');
        } else {
            mosAdminMenus::ReadImages($pathA, '/', $folders, $images);
            $lists['folders'] = mosAdminMenus::GetImageFolders($folders, $pathL);
            $lists['imagefiles'] = mosAdminMenus::GetImages($images, $pathL);
            $lists['imagelist'] = mosAdminMenus::GetSavedImages($mailingEdit, $pathL);
            $lists['_align'] = mosAdminMenus::Positions('_align');
            $lists['_caption_align'] = mosAdminMenus::Positions('_caption_align');
        }
        //endif
        if (ACA_CMSTYPE) {
            // joomla 15
            $pos[] = JHTML::_('select.option', 'bottom', _CMN_BOTTOM);
            $pos[] = JHTML::_('select.option', 'top', _CMN_TOP);
            $lists['_caption_position'] = JHTML::_('select.genericlist', $pos, '_caption_position', 'class="inputbox" size="1"', 'value', 'text');
        } else {
            //joomla 1x
            $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');
        }
        //endif
        backHTML::formStart('edit_mailing', $mailingEdit->html, $images);
        echo $forms['main'];
        if ($new and $mailingEdit->list_type == 7) {
            $mailingEdit->issue_nb = 0;
        }
        mailingsHTML::layout($mailingEdit, $lists, $show);
        ?>
		<input type="hidden" name="images" value="" />
		<input type="hidden" name="html" value="<?php 
        echo $mailingEdit->html;
        ?>
" />
		<input type="hidden" name="new_list" value="<?php 
        echo $new;
        ?>
" />
		<input type="hidden" name="listid" value="<?php 
        echo $listId;
        ?>
" />
		<input type="hidden" name="listype" value="<?php 
        echo $mailingEdit->list_type;
        ?>
" />
		<input type="hidden" name="mailingid" value="<?php 
        echo $mailingEdit->id;
        ?>
" />
		<input type="hidden" name="issue_nb" value="<?php 
        echo $mailingEdit->issue_nb;
        ?>
" />
	    <input type="hidden" name="userid" value="<?php 
        echo $my->id;
        ?>
" />
		<?php 
    }
예제 #16
0
function editItem($uid, $gid, &$access, $sectionid = 0, $task, $Itemid)
{
    global $database, $my, $mainframe;
    global $mosConfig_absolute_path, $mosConfig_live_site, $mosConfig_offset;
    $nullDate = $database->getNullDate();
    $row = new mosContent($database);
    // load the row from the db table
    $row->load((int) $uid);
    // fail if checked out not by 'me'
    if ($row->isCheckedOut($my->id)) {
        mosErrorAlert("The module [ " . $row->title . " ] is currently being edited by another person.");
    }
    if ($uid) {
        // existing record
        if (!($access->canEdit || $access->canEditOwn && $row->created_by == $my->id)) {
            mosNotAuth();
            return;
        }
    } else {
        // new record
        if (!($access->canEdit || $access->canEditOwn)) {
            mosNotAuth();
            return;
        }
        if ($Itemid == 0 || $Itemid == 99999999) {
            // security check to see if link exists in a menu
            $link = 'index.php?option=com_content&task=new&sectionid=' . (int) $sectionid;
            $query = "SELECT id" . "\n FROM #__menu" . "\n WHERE (link LIKE '%{$link}' OR link LIKE '%{$link}&%')" . "\n AND published = 1";
            $database->setQuery($query);
            $exists = $database->loadResult();
            if (!$exists) {
                mosNotAuth();
                return;
            }
        }
    }
    if ($uid) {
        $sectionid = $row->sectionid;
    }
    $lists = array();
    // get the type name - which is a special category
    $query = "SELECT name FROM #__sections" . "\n WHERE id = " . (int) $sectionid;
    $database->setQuery($query);
    $section = $database->loadResult();
    if ($uid == 0) {
        $row->catid = 0;
    }
    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();
    } else {
        $row->sectionid = $sectionid;
        $row->version = 0;
        $row->state = 0;
        $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 = 0;
        $row->modifier = 0;
        $row->frontpage = 0;
    }
    // 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) {
            $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);
    // make the select list for the states
    $states[] = mosHTML::makeOption(0, _CMN_UNPUBLISHED);
    $states[] = mosHTML::makeOption(1, _CMN_PUBLISHED);
    $lists['state'] = mosHTML::selectList($states, 'state', 'class="inputbox" size="1"', 'value', 'text', intval($row->state));
    // 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 ORDER BY ordering";
    $lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $uid, $query, 1);
    // build list of categories
    $lists['catid'] = mosAdminMenus::ComponentCategory('catid', $sectionid, intval($row->catid));
    // build the select list for the image positions
    $lists['_align'] = mosAdminMenus::Positions('_align');
    // build the html select list for the group access
    $lists['access'] = mosAdminMenus::Access($row);
    // 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
    // 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');
    HTML_content::editContent($row, $section, $lists, $images, $access, $my->id, $sectionid, $task, $Itemid);
}
예제 #17
0
/**
* Compiles information to add or edit content
* @param database A database connector object
* @param string The name of the category section
* @param integer The unique id of the category to edit (0 if new)
*/
function edit($uid, $option)
{
    global $database, $my, $mainframe;
    global $mosConfig_absolute_path, $mosConfig_live_site, $mosConfig_offset;
    $row = new mosContent($database);
    $row->load((int) $uid);
    $lists = array();
    $nullDate = $database->getNullDate();
    if ($uid) {
        // fail if checked out not by 'me'
        if ($row->isCheckedOut($my->id)) {
            mosErrorAlert("The module " . $row->title . " is currently being edited by another administrator");
        }
        $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();
        }
        // get list of links to this item
        $and = "\n AND componentid = " . (int) $row->id;
        $menus = mosAdminMenus::Links2Menu('content_typed', $and);
    } else {
        // initialise values for a new item
        $row->version = 0;
        $row->state = 1;
        $row->images = array();
        $row->publish_up = date('Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60);
        $row->publish_down = 'Never';
        $row->sectionid = 0;
        $row->catid = 0;
        $row->creator = '';
        $row->modified = $nullDate;
        $row->modifier = '';
        $row->ordering = 0;
        $menus = array();
    }
    // calls function to read image from directory
    $pathA = $mosConfig_absolute_path . '/images/stories';
    $pathL = $mosConfig_live_site . '/images/stories';
    $images = array();
    $folders = array();
    $folders[] = mosHTML::makeOption('/');
    mosAdminMenus::ReadImages($pathA, '/', $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);
    // 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 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 positions
    $lists['_align'] = mosAdminMenus::Positions('_align');
    // build the select list for the image caption alignment
    $lists['_caption_align'] = mosAdminMenus::Positions('_caption_align');
    // 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_typedcontent'), 'component');
    HTML_typedcontent::edit($row, $images, $lists, $params, $option, $menus);
}
예제 #18
0
/**
* Compiles information to add or edit a category
* @param string The name of the category section
* @param integer The unique id of the category to edit (0 if new)
* @param string The name of the current user
*/
function editCategory($uid = 0, $section = '')
{
    global $database, $my;
    $type = mosGetParam($_REQUEST, 'type', '');
    $redirect = mosGetParam($_REQUEST, 'section', 'content');
    $row = new mosCategory($database);
    // load the row from the db table
    $row->load($uid);
    // fail if checked out not by 'me'
    if ($row->checked_out && $row->checked_out != $my->id) {
        mosRedirect('index2.php?option=categories&section=' . $row->section, sprintf(T_('The category %s is currently being edited by another administrator'), $row->title));
    }
    if ($uid) {
        // existing record
        $row->checkout($my->id);
        // code for Link Menu
        if ($row->section > 0) {
            $query = "SELECT *" . "\n FROM #__menu" . "\n WHERE componentid = " . $row->id . "\n AND ( type = 'content_archive_category' OR type = 'content_blog_category' OR type = 'content_category' )";
            $database->setQuery($query);
            $menus = $database->loadObjectList();
            $count = count($menus);
            for ($i = 0; $i < $count; $i++) {
                switch ($menus[$i]->type) {
                    case 'content_category':
                        $menus[$i]->type = T_('Category Table');
                        break;
                    case 'content_blog_category':
                        $menus[$i]->type = T_('Category Blog');
                        break;
                    case 'content_archive_category':
                        $menus[$i]->type = T_('Category Blog Archive');
                        break;
                }
            }
        } else {
            $menus = array();
        }
    } else {
        // new record
        $row->section = $section;
        $row->published = 1;
        $menus = NULL;
    }
    // make order list
    $order = array();
    $database->setQuery("SELECT COUNT(*) FROM #__categories WHERE section='{$row->section}'");
    $max = intval($database->loadResult()) + 1;
    for ($i = 1; $i < $max; $i++) {
        $order[] = mosHTML::makeOption($i);
    }
    // build the html select list for sections
    if ($section == 'content') {
        $query = "SELECT s.id AS value, s.title AS text" . "\n FROM #__sections AS s" . "\n ORDER BY s.ordering";
        $database->setQuery($query);
        $sections = $database->loadObjectList();
        $lists['section'] = mosHTML::selectList($sections, 'section', 'class="inputbox" size="1"', 'value', 'text');
    } else {
        if ($type == 'other') {
            $section_name = 'N/A';
        } else {
            $temp = new mosSection($database);
            $temp->load($row->section);
            $section_name = $temp->name;
        }
        $lists['section'] = '<input type="hidden" name="section" value="' . $row->section . '" />' . $section_name;
    }
    // build the html select list for category types
    $types[] = mosHTML::makeOption('', T_('Select Type'));
    if ($row->section == 'com_contact_details') {
        $types[] = mosHTML::makeOption('contact_category_table', T_('Contact Category Table'));
    } else {
        if ($row->section == 'com_newsfeeds') {
            $types[] = mosHTML::makeOption('newsfeed_category_table', T_('News Feed Category Table'));
        } else {
            if ($row->section == 'com_weblinks') {
                $types[] = mosHTML::makeOption('weblink_category_table', T_('Web Link Category Table'));
            } else {
                $types[] = mosHTML::makeOption('content_category', T_('Content Category Table'));
                $types[] = mosHTML::makeOption('content_blog_category', T_('Content Category Blog'));
                $types[] = mosHTML::makeOption('content_archive_category', T_('Content Category Archive Blog'));
            }
        }
    }
    // if
    $lists['link_type'] = mosHTML::selectList($types, 'link_type', 'class="inputbox" size="1"', 'value', 'text');
    // build the html select list for ordering
    $query = "SELECT ordering AS value, title AS text" . "\n FROM #__categories" . "\n WHERE section = '{$row->section}'" . "\n ORDER BY ordering";
    $lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $uid, $query);
    // build the select list for the image positions
    $active = $row->image_position ? $row->image_position : 'left';
    $lists['image_position'] = mosAdminMenus::Positions('image_position', $active, NULL, 0, 0);
    // Imagelist
    $lists['image'] = mosAdminMenus::Images('image', $row->image);
    // build the html select list for the group access
    $lists['access'] = mosAdminMenus::Access($row);
    // build the html radio buttons for published
    $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published);
    // build the html select list for menu selection
    $lists['menuselect'] = mosAdminMenus::MenuSelect();
    categories_html::edit($row, $lists, $redirect, $menus);
}