function smart_openclose_collapsable($name) { $urls = smart_getCurrentUrls(); $path = $urls['phpself']; $cookie_name = $path . '_smart_collaps_' . $name; $cookie_name = str_replace('.', '_', $cookie_name); $cookie = smart_getCookieVar($cookie_name, ''); if ($cookie == 'none') { echo ' <script type="text/javascript"><!-- togglecollapse("' . $name . '"); toggleIcon("' . $name . '_icon"); //--> </script> '; } /* if ($cookie == 'none') { echo ' <script type="text/javascript"><!-- hideElement("' . $name . '"); //--> </script> '; } */ }
function render($fetchOnly = false, $debug = false) { include_once XOOPS_ROOT_PATH . '/class/template.php'; $this->_tpl = new XoopsTpl(); /** * We need access to the vars of the SmartObject for a few things in the table creation. * Since we may not have a SmartObject to look into now, let's create one for this purpose * and we will free it after */ $this->_tempObject =& $this->_objectHandler->create(); $this->_criteria->setStart(isset($_GET['start' . $this->_objectHandler->keyName]) ? intval($_GET['start' . $this->_objectHandler->keyName]) : 0); $this->setSortOrder(); if (!$this->_isTree) { $this->_limitsel = isset($_GET['limitsel']) ? $_GET['limitsel'] : smart_getCookieVar($_SERVER['PHP_SELF'] . '_limitsel', '15'); } else { $this->_limitsel = 'all'; } $this->_limitsel = isset($_POST['limitsel']) ? $_POST['limitsel'] : $this->_limitsel; smart_setCookieVar($_SERVER['PHP_SELF'] . '_limitsel', $this->_limitsel); $limitsArray = $this->getLimitsArray(); $this->_criteria->setLimit($this->_limitsel); $this->_filtersel = isset($_GET['filtersel']) ? $_GET['filtersel'] : $this->getDefaultFilter(); $this->_filtersel = isset($_POST['filtersel']) ? $_POST['filtersel'] : $this->_filtersel; smart_setCookieVar($_SERVER['PHP_SELF'] . '_' . $this->_id . '_filtersel', $this->_filtersel); $filtersArray = $this->getFiltersArray(); if ($filtersArray) { $this->_tpl->assign('smartobject_optionssel_filtersArray', $filtersArray); } // Check if the selected filter is defined and if so, create the selfilter2 if (isset($this->_filterseloptions[$this->_filtersel])) { // check if method associate with this filter exists in the handler if (is_array($this->_filterseloptions[$this->_filtersel])) { $filter = $this->_filterseloptions[$this->_filtersel]; $this->_criteria->add($filter['criteria']); } else { if (method_exists($this->_objectHandler, $this->_filterseloptions[$this->_filtersel])) { // then we will create the selfilter2 options by calling this method $method = $this->_filterseloptions[$this->_filtersel]; $this->_filtersel2options = $this->_objectHandler->{$method}(); $this->_filtersel2 = isset($_GET['filtersel2']) ? $_GET['filtersel2'] : $this->getDefaultFilter2(); $this->_filtersel2 = isset($_POST['filtersel2']) ? $_POST['filtersel2'] : $this->_filtersel2; $filters2Array = $this->getFilters2Array(); $this->_tpl->assign('smartobject_optionssel_filters2Array', $filters2Array); smart_setCookieVar($_SERVER['PHP_SELF'] . '_filtersel2', $this->_filtersel2); if ($this->_filtersel2 != 'default') { $this->_criteria->add(new Criteria($this->_filtersel, $this->_filtersel2)); } } } } // Check if we have a quicksearch if (isset($_POST['quicksearch_' . $this->_id]) && $_POST['quicksearch_' . $this->_id] != '') { $quicksearch_criteria = new CriteriaCompo(); if (is_array($this->_quickSearch['fields'])) { foreach ($this->_quickSearch['fields'] as $v) { $quicksearch_criteria->add(new Criteria($v, '%' . $_POST['quicksearch_' . $this->_id] . '%', 'LIKE'), 'OR'); } } else { $quicksearch_criteria->add(new Criteria($this->_quickSearch['fields'], '%' . $_POST['quicksearch_' . $this->_id] . '%', 'LIKE')); } $this->_criteria->add($quicksearch_criteria); } $this->_objects = $this->fetchObjects($debug); include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; if ($this->_criteria->getLimit() > 0) { /** * Geeting rid of the old params * $new_get_array is an array containing the new GET parameters */ $new_get_array = array(); /** * $params_of_the_options_sel is an array with all the parameters of the page * but without the pagenave parameters. This array will be used in the * OptionsSelection */ $params_of_the_options_sel = array(); $not_needed_params = array('sortsel', 'limitsel', 'ordersel', 'start' . $this->_objectHandler->keyName); foreach ($_GET as $k => $v) { if (!in_array($k, $not_needed_params)) { $new_get_array[] = "{$k}={$v}"; $params_of_the_options_sel[] = "{$k}={$v}"; } } /** * Adding the new params of the pagenav */ $new_get_array[] = "sortsel=" . $this->_sortsel; $new_get_array[] = "ordersel=" . $this->_ordersel; $new_get_array[] = "limitsel=" . $this->_limitsel; $otherParams = implode('&', $new_get_array); $pagenav = new XoopsPageNav($this->_objectHandler->getCount($this->_criteria), $this->_criteria->getLimit(), $this->_criteria->getStart(), 'start' . $this->_objectHandler->keyName, $otherParams); $this->_tpl->assign('smartobject_pagenav', $pagenav->renderNav()); } $this->renderOptionSelection($limitsArray, $params_of_the_options_sel); // retreive the current url and the query string $current_urls = smart_getCurrentUrls(); $current_url = $current_urls['full_phpself']; $query_string = $current_urls['querystring']; if ($query_string) { $query_string = str_replace('?', '', $query_string); } $query_stringArray = explode('&', $query_string); $new_query_stringArray = array(); foreach ($query_stringArray as $query_string) { if (strpos($query_string, 'sortsel') == FALSE && strpos($query_string, 'ordersel') == FALSE) { $new_query_stringArray[] = $query_string; } } $new_query_string = implode('&', $new_query_stringArray); $orderArray = array(); $orderArray['ASC']['image'] = 'desc.png'; $orderArray['ASC']['neworder'] = 'DESC'; $orderArray['DESC']['image'] = 'asc.png'; $orderArray['DESC']['neworder'] = 'ASC'; $aColumns = array(); foreach ($this->_columns as $column) { $qs_param = ''; $aColumn = array(); $aColumn['width'] = $column->getWidth(); $aColumn['align'] = $column->getAlign(); $aColumn['key'] = $column->getKeyName(); if ($column->_keyname == 'checked') { $aColumn['caption'] = '<input type ="checkbox" id="checkall_smartobjects" name="checkall_smartobjects"' . ' value="checkall_smartobjects" onclick="smartobject_checkall(window.document.form_' . $this->_id . ', \'selected_smartobjects\');" />'; } elseif ($column->getCustomCaption()) { $aColumn['caption'] = $column->getCustomCaption(); } else { $aColumn['caption'] = isset($this->_tempObject->vars[$column->getKeyName()]['form_caption']) ? $this->_tempObject->vars[$column->getKeyName()]['form_caption'] : $column->getKeyName(); } // Are we doing a GET sort on this column ? $getSort = isset($_GET[$this->_objectHandler->_itemname . '_' . 'sortsel']) && $_GET[$this->_objectHandler->_itemname . '_' . 'sortsel'] == $column->getKeyName() || $this->_sortsel == $column->getKeyName(); $order = isset($_GET[$this->_objectHandler->_itemname . '_' . 'ordersel']) ? $_GET[$this->_objectHandler->_itemname . '_' . 'ordersel'] : 'DESC'; if (isset($_REQUEST['quicksearch_' . $this->_id]) && $_REQUEST['quicksearch_' . $this->_id] != '') { $qs_param = "&quicksearch_" . $this->_id . "=" . $_REQUEST['quicksearch_' . $this->_id]; } if (!$this->_enableColumnsSorting || $column->_keyname == 'checked' || !$column->isSortable()) { $aColumn['caption'] = $aColumn['caption']; } elseif ($getSort) { $aColumn['caption'] = '<a href="' . $current_url . '?' . $this->_objectHandler->_itemname . '_' . 'sortsel=' . $column->getKeyName() . '&' . $this->_objectHandler->_itemname . '_' . 'ordersel=' . $orderArray[$order]['neworder'] . $qs_param . '&' . $new_query_string . '">' . $aColumn['caption'] . ' <img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . $orderArray[$order]['image'] . '" alt="ASC" /></a>'; } else { $aColumn['caption'] = '<a href="' . $current_url . '?' . $this->_objectHandler->_itemname . '_' . 'sortsel=' . $column->getKeyName() . '&' . $this->_objectHandler->_itemname . '_' . 'ordersel=ASC' . $qs_param . '&' . $new_query_string . '">' . $aColumn['caption'] . '</a>'; } $aColumns[] = $aColumn; } $this->_tpl->assign('smartobject_columns', $aColumns); if ($this->_quickSearch) { $this->_tpl->assign('smartobject_quicksearch', $this->_quickSearch['caption']); } $this->createTableRows(); $this->_tpl->assign('smartobject_showFilterAndLimit', $this->_showFilterAndLimit); $this->_tpl->assign('smartobject_isTree', $this->_isTree); $this->_tpl->assign('smartobject_show_action_column_title', $this->_showActionsColumnTitle); $this->_tpl->assign('smartobject_table_header', $this->_tableHeader); $this->_tpl->assign('smartobject_table_footer', $this->_tableFooter); $this->_tpl->assign('smartobject_printer_friendly_page', $this->_printerFriendlyPage); $this->_tpl->assign('smartobject_user_side', $this->_userSide); $this->_tpl->assign('smartobject_has_actions', $this->_hasActions); $this->_tpl->assign('smartobject_head_css_class', $this->_head_css_class); $this->_tpl->assign('smartobject_actionButtons', $this->_actionButtons); $this->_tpl->assign('smartobject_introButtons', $this->_introButtons); $this->_tpl->assign('smartobject_id', $this->_id); if (!empty($this->_withSelectedActions)) { $this->_tpl->assign('smartobject_withSelectedActions', $this->_withSelectedActions); } $smartobject_table_template = $this->_customTemplate ? $this->_customTemplate : 'smartobject_smarttable_display.html'; if ($fetchOnly) { return $this->_tpl->fetch('db:' . $smartobject_table_template); } else { $this->_tpl->display('db:' . $smartobject_table_template); } }