Пример #1
0
/**
 *
 * Enter description here ...
 * @param unknown_type $name
 * @todo Move to a static class method
 */
function icms_openclose_collapsable($name)
{
    $urls = icms_getCurrentUrls();
    $path = $urls['phpself'];
    $cookie_name = $path . '_icms_collaps_' . $name;
    $cookie_name = str_replace('.', '_', $cookie_name);
    $cookie = icms_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>
    	 ';
    		}
    		*/
}
Пример #2
0
 /**
  *
  * @param $fetchOnly
  * @param $debug
  */
 public function render($fetchOnly = false, $debug = false)
 {
     global $impresscms;
     $this->_tpl = new icms_view_Tpl();
     /**
      * We need access to the vars of the icms_ipf_Object for a few things in the table creation.
      * Since we may not have an icms_ipf_Object 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]) ? (int) $_GET['start' . $this->_objectHandler->keyName] : 0);
     $this->setSortOrder();
     if (!$this->_isTree) {
         $this->_limitsel = isset($_GET['limitsel']) ? $_GET['limitsel'] : icms_getCookieVar($_SERVER['SCRIPT_NAME'] . '_limitsel', '15');
     } else {
         $this->_limitsel = 'all';
     }
     $this->_limitsel = isset($_POST['limitsel']) ? $_POST['limitsel'] : $this->_limitsel;
     icms_setCookieVar($_SERVER['SCRIPT_NAME'] . '_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;
     icms_setCookieVar($_SERVER['SCRIPT_NAME'] . '_' . $this->_id . '_filtersel', $this->_filtersel);
     $filtersArray = $this->getFiltersArray();
     if ($filtersArray) {
         $this->_tpl->assign('icms_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('icms_optionssel_filters2Array', $filters2Array);
                 icms_setCookieVar($_SERVER['SCRIPT_NAME'] . '_filtersel2', $this->_filtersel2);
                 if ($this->_filtersel2 != 'default') {
                     $this->_criteria->add(new icms_db_criteria_Item($this->_filtersel, $this->_filtersel2));
                 }
             }
         }
     }
     // Check if we have a quicksearch
     if (isset($_POST['quicksearch_' . $this->_id]) && $_POST['quicksearch_' . $this->_id] != '') {
         $quicksearch_criteria = new icms_db_criteria_Compo();
         if (is_array($this->_quickSearch['fields'])) {
             foreach ($this->_quickSearch['fields'] as $v) {
                 $quicksearch_criteria->add(new icms_db_criteria_Item($v, '%' . $_POST['quicksearch_' . $this->_id] . '%', 'LIKE'), 'OR');
             }
         } else {
             $quicksearch_criteria->add(new icms_db_criteria_Item($this->_quickSearch['fields'], '%' . $_POST['quicksearch_' . $this->_id] . '%', 'LIKE'));
         }
         $this->_criteria->add($quicksearch_criteria);
     }
     $this->_objects = $this->fetchObjects($debug);
     /**
      * $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();
     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();
         $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 icms_view_PageNav($this->_objectHandler->getCount($this->_criteria), $this->_criteria->getLimit(), $this->_criteria->getStart(), 'start' . $this->_objectHandler->keyName, $otherParams);
         $this->_tpl->assign('icms_pagenav', $pagenav->renderNav());
     }
     $this->renderOptionSelection($limitsArray, $params_of_the_options_sel);
     // retreive the current url and the query string
     $current_url = $impresscms->urls['full_phpself'];
     $query_string = $impresscms->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) {
         $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_icmspersistableobjects" name="checkall_icmspersistableobjects"' . ' value="checkall_icmspersistableobjects" onclick="icms_checkall(window.document.form_' . $this->_id . ', \'selected_icmspersistableobjects\');" />';
         } 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] != '') {
             $filter = isset($_POST['quicksearch_' . $this->_id]) ? INPUT_POST : INPUT_GET;
             $qs_param = "&amp;quicksearch_" . $this->_id . "=" . filter_input($filter, 'quicksearch_' . $this->_id, FILTER_SANITIZE_SPECIAL_CHARS);
         } else {
             $qs_param = '';
         }
         if (!$this->_enableColumnsSorting || $column->_keyname == 'checked' || !$column->_sortable) {
             $aColumn['caption'] = $aColumn['caption'];
         } elseif ($getSort) {
             $aColumn['caption'] = '<a href="' . $current_url . '?' . $this->_objectHandler->_itemname . '_' . 'sortsel=' . $column->getKeyName() . '&amp;' . $this->_objectHandler->_itemname . '_' . 'ordersel=' . $orderArray[$order]['neworder'] . $qs_param . '&amp;' . $new_query_string . '">' . $aColumn['caption'] . ' <img src="' . ICMS_IMAGES_SET_URL . '/actions/' . $orderArray[$order]['image'] . '" alt="ASC" /></a>';
         } else {
             $aColumn['caption'] = '<a href="' . $current_url . '?' . $this->_objectHandler->_itemname . '_' . 'sortsel=' . $column->getKeyName() . '&amp;' . $this->_objectHandler->_itemname . '_' . 'ordersel=ASC' . $qs_param . '&amp;' . $new_query_string . '">' . $aColumn['caption'] . '</a>';
         }
         $aColumns[] = $aColumn;
     }
     $this->_tpl->assign('icms_columns', $aColumns);
     if ($this->_quickSearch) {
         $this->_tpl->assign('icms_quicksearch', $this->_quickSearch['caption']);
     }
     $this->createTableRows();
     $this->_tpl->assign('icms_showFilterAndLimit', $this->_showFilterAndLimit);
     $this->_tpl->assign('icms_isTree', $this->_isTree);
     $this->_tpl->assign('icms_show_action_column_title', $this->_showActionsColumnTitle);
     $this->_tpl->assign('icms_table_header', $this->_tableHeader);
     $this->_tpl->assign('icms_table_footer', $this->_tableFooter);
     $this->_tpl->assign('icms_printer_friendly_page', $this->_printerFriendlyPage);
     $this->_tpl->assign('icms_user_side', $this->_userSide);
     $this->_tpl->assign('icms_has_actions', $this->_hasActions);
     $this->_tpl->assign('icms_head_css_class', $this->_head_css_class);
     $this->_tpl->assign('icms_actionButtons', $this->_actionButtons);
     $this->_tpl->assign('icms_introButtons', $this->_introButtons);
     $this->_tpl->assign('icms_id', $this->_id);
     if (!empty($this->_withSelectedActions)) {
         $this->_tpl->assign('icms_withSelectedActions', $this->_withSelectedActions);
     }
     $icms_table_template = $this->_customTemplate ? $this->_customTemplate : 'system_persistabletable_display.html';
     if ($fetchOnly) {
         return $this->_tpl->fetch('db:' . $icms_table_template);
     } else {
         $this->_tpl->display('db:' . $icms_table_template);
     }
 }