コード例 #1
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);
}
コード例 #2
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);
}
コード例 #3
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);
}
コード例 #4
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);
}
コード例 #5
0
ファイル: admin.typedcontent.php プロジェクト: cwcw/cms
/**
* 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);
}
コード例 #6
0
ファイル: admin.content.php プロジェクト: jwest00724/mambo
/**
* 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);
}