<?php // $Header$ require_once SAMPLE_PKG_PATH . 'BitSample.php'; $formSampleLists = array("sample_list_sample_id" => array('label' => 'Id', 'note' => 'Display the sample id.'), "sample_list_title" => array('label' => 'Title', 'note' => 'Display the title.'), "sample_list_description" => array('label' => 'Description', 'note' => 'Display the description.'), "sample_list_data" => array('label' => 'Text', 'note' => 'Display the text.')); $gBitSmarty->assign('formSampleLists', $formSampleLists); // Process the form if we've made some changes if (!empty($_REQUEST['sample_settings'])) { $sampleToggles = array_merge($formSampleLists); foreach ($sampleToggles as $item => $data) { simple_set_toggle($item, SAMPLE_PKG_NAME); } simple_set_int('sample_home_id', SAMPLE_PKG_NAME); } // The list of sample data is used to pick one to set the home // we need to make sure that all sample records are displayed $_REQUEST['max_records'] = 0; $sample = new BitSample(); $sample_data = $sample->getList($_REQUEST); $gBitSmarty->assign_by_ref('sample_data', $sample_data); $sample_home_id = $gBitSystem->getConfig("sample_home_id"); $gBitSmarty->assign('sample_home_id', $sample_home_id);
$formHash['submit_mult'] = 'remove_sample_data'; foreach ($_REQUEST["checked"] as $del) { $tmpPage = new BitSample($del); if ($tmpPage->load() && !empty($tmpPage->mInfo['title'])) { $info = $tmpPage->mInfo['title']; } else { $info = $del; } $formHash['input'][] = '<input type="hidden" name="checked[]" value="' . $del . '"/>' . $info; } $gBitSystem->confirmDialog($formHash, array('warning' => tra('Are you sure you want to delete ') . count($_REQUEST["checked"]) . ' sample records?', 'error' => tra('This cannot be undone!'))); } else { foreach ($_REQUEST["checked"] as $deleteId) { $tmpPage = new BitSample($deleteId); if (!$tmpPage->load() || !$tmpPage->expunge()) { array_merge($errors, array_values($tmpPage->mErrors)); } } if (!empty($errors)) { $gBitSmarty->assign_by_ref('errors', $errors); } } } // Create new sample object $sample = new BitSample(); $sampleList = $sample->getList($_REQUEST); $gBitSmarty->assign_by_ref('sampleList', $sampleList); // getList() has now placed all the pagination information in $_REQUEST['listInfo'] $gBitSmarty->assign_by_ref('listInfo', $_REQUEST['listInfo']); // Display the template $gBitSystem->display('bitpackage:sample/list_sample.tpl', tra('Sample'), array('display_mode' => 'list'));
<?php global $gContent; require_once SAMPLE_PKG_PATH . 'BitSample.php'; require_once LIBERTY_PKG_PATH . 'lookup_content_inc.php'; // if we already have a gContent, we assume someone else created it for us, and has properly loaded everything up. if (empty($gContent) || !is_object($gContent) || !$gContent->isValid()) { // if sample_id supplied, use that if (@BitBase::verifyId($_REQUEST['sample_id'])) { $gContent = new BitSample($_REQUEST['sample_id']); // if content_id supplied, use that } elseif (@BitBase::verifyId($_REQUEST['content_id'])) { $gContent = new BitSample(NULL, $_REQUEST['content_id']); } elseif (@BitBase::verifyId($_REQUEST['sample']['sample_id'])) { $gContent = new BitSample($_REQUEST['sample']['sample_id']); // otherwise create new object } else { $gContent = new BitSample(); } $gContent->load(); $gBitSmarty->assign_by_ref("gContent", $gContent); }