Skip to content

Commit

Permalink
tweak forms portfolio display to optionally display 'group' category;…
Browse files Browse the repository at this point in the history
… also allow paged support for that view; fix bad output of portfolio view custom definition
  • Loading branch information
dleffler committed Oct 2, 2017
1 parent c3466c8 commit 6d50927
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 45 deletions.
3 changes: 3 additions & 0 deletions framework/core/expFramework.php
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,9 @@ function ($m) {
if (!empty($out2['report_desc'])) { // work-around for links in forms report descriptions
$out2['report_desc'] = stripslashes($out2['report_desc']);
}
if (!empty($out2['report_def_showall'])) { // work-around for links in forms report descriptions
$out2['report_def_showall'] = stripslashes($out2['report_def_showall']);
}
if (!empty($out2['response'])) { // work-around for links in forms response
$out2['response'] = stripslashes($out2['response']);
}
Expand Down
19 changes: 17 additions & 2 deletions framework/modules/forms/controllers/formsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,34 @@ public function showall() {
}
}
}
foreach ($items as $key => $item) {
//We have to create a show link
$items[$key]['link'] = makeLink(array(
'controller'=>'forms',
'action'=>'show',
'forms_id'=>$f->id,
'id'=>$items[$key]['id'],
'src'=>$this->loc->src
));
}

$limit = (isset($this->params['limit']) && $this->params['limit'] != '') ? $this->params['limit'] : 10;
if ($this->params['view'] !== 'showall_portfolio')
$limit = 0;

$page = new expPaginator(
array(
'records' => $items,
'where' => 1,
// 'limit' => (isset($this->params['limit']) && $this->params['limit'] != '') ? $this->params['limit'] : 10,
'limit' => $limit,
'order' => (isset($this->params['order']) && $this->params['order'] != '') ? $this->params['order'] : (!empty($this->config['order']) ? $this->config['order'] : 'id'),
'dir' => (isset($this->params['dir']) && $this->params['dir'] != '') ? $this->params['dir'] : (!empty($this->config['dir']) ? $this->config['dir'] : 'ASC'),
'page' => (isset($this->params['page']) ? $this->params['page'] : 1),
'controller' => $this->baseclassname,
'action' => $this->params['action'],
'src' => $this->loc->src,
'columns' => $columns
'columns' => $columns,
'view' => $this->params['view']
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*}

<h2>{'Configure Show All Records Portfolio View'|gettext}</h2>
{control type="checkbox" name="usecategories" label="Display the sort records by as a heading?"|gettext value=1 checked=$config.usecategories}
{control type="text" name="no_records_msg" label="No Records Message"|gettext value=$config.no_records_msg|default:'No Records Found'|gettext description='Message to display if there are no records'|gettext}
{control type=editor name='report_def_showall' label='Custom Showall View Template'|gettext value=$config.report_def_showall rows=10 cols=60
plugin="fieldinsert" additionalConfig="fieldinsert_list : `$fieldlist`"
Expand Down
108 changes: 65 additions & 43 deletions framework/modules/forms/views/forms/showall_portfolio.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@
{if !$error}
{css unique="data-view" corecss="button, tables"}

{/css}
{css unique="portfolio"}
{literal}
.forms.showall .item {
margin-left: 10px;
padding-left: 10px;
}
.forms.showall .category {
border-top: 1px black solid;
border-bottom: 1px black solid;
background-color: #fcf4ce;
padding-left: 4px;
}
{/literal}
{/css}
<div class="module forms showall">
{if !empty($title)}
Expand Down Expand Up @@ -61,53 +75,61 @@
{/permissions}
{pagelinks paginate=$page top=1}
<div style="overflow: auto; overflow-y: hidden;">
{$cat="bad"}
{$sort=$config.order}
{foreach from=$page->records item=fields key=key name=fields}
<div class="item-actions">
{if $permissions.edit}
{icon class=edit action=enterdata forms_id=$f->id id=$fields.id title='Edit this record'|gettext}
{/if}
{if $permissions.delete}
{icon class=delete action=delete forms_id=$f->id id=$fields.id title='Delete this record'|gettext}
{/if}
</div>
{if !empty($config.report_def_showall)}
{eval var=$config.report_def_showall}
{clear}
{elseif !empty($config.report_def)}
{eval var=$config.report_def}
{clear}
{else}
<table border="0" cellspacing="0" cellpadding="0" class="exp-skin-table">
<tbody>
{foreach from=$fields key=fieldname item=value}
<tr class="{cycle values="even,odd"}">
<td>
{$captions.$fieldname}
</td>
<td>
{if $fieldname|lower == 'email' && stripos($value, '<a ') === false}
<a href="mailto:{$value}">{$value}</a>
{elseif $fieldname|lower == 'image'}
{$matches = array()}
{$tmp = preg_match_all('~<a(.*?)href="([^"]+)"(.*?)>~', $value, $matches)}
{$filename1 = $matches.2.0}
{$filename2 = str_replace(URL_BASE, '/', $filename1)}
{$base = str_replace(PATH_RELATIVE, '', BASE)}
{$fileinfo = expFile::getImageInfo($base|cat:$filename2)}
{if $fileinfo.is_image == 1}
{img src=$filename1 w=64}
{if $cat !== $fields.$sort && $config.usecategories}
<h2 class="category">{if $fields.$sort!= ""}{$fields.$sort}{elseif $config.uncat!=''}{$config.uncat}{else}{'Uncategorized'|gettext}{/if}</h2>
{/if}
<div class="item">
<div class="item-actions">
{if $permissions.edit}
{icon class=edit action=enterdata forms_id=$f->id id=$fields.id title='Edit this record'|gettext}
{/if}
{if $permissions.delete}
{icon class=delete action=delete forms_id=$f->id id=$fields.id title='Delete this record'|gettext}
{/if}
</div>
{if !empty($config.report_def_showall)}
{eval var=$config.report_def_showall}
{clear}
{elseif !empty($config.report_def)}
{eval var=$config.report_def}
{clear}
{else}
<table border="0" cellspacing="0" cellpadding="0" class="exp-skin-table">
<tbody>
{foreach from=$fields key=fieldname item=value}
<tr class="{cycle values="even,odd"}">
<td>
{$captions.$fieldname}
</td>
<td>
{if $fieldname|lower == 'email' && stripos($value, '<a ') === false}
<a href="mailto:{$value}">{$value}</a>
{elseif $fieldname|lower == 'image'}
{$matches = array()}
{$tmp = preg_match_all('~<a(.*?)href="([^"]+)"(.*?)>~', $value, $matches)}
{$filename1 = $matches.2.0}
{$filename2 = str_replace(URL_BASE, '/', $filename1)}
{$base = str_replace(PATH_RELATIVE, '', BASE)}
{$fileinfo = expFile::getImageInfo($base|cat:$filename2)}
{if $fileinfo.is_image == 1}
{img src=$filename1 w=64}
{else}
{$value}
{/if}
{else}
{$value}
{/if}
{else}
{$value}
{/if}
</td>
</tr>
{/foreach}
</tbody>
</table>
{/if}
</td>
</tr>
{/foreach}
</tbody>
</table>
{/if}
{$cat=$fields.$sort}
</div>
{foreachelse}
<h4>{$config.no_records_msg|default:"No Records Found"|gettext}</h4>
{/foreach}
Expand Down

0 comments on commit 6d50927

Please sign in to comment.