Class DefaultController
*/
class DefaultController extends CommonFormController
{
/**
-
@param int $objectId
-
@param int $page
-
-
@return SymfonyComponentHttpFoundationJsonResponse|SymfonyComponentHttpFoundationRedirectResponse|SymfonyComponentHttpFoundationResponse
*/
public function indexAction($page=1)
{
//set some permissions
$permissions = $this->factory->getSecurity()->isGranted(array(
‘plugin:feedman:feed:create’,
), "RETURN_ARRAY");
//$permissions['plugin:feedman:feed:create'] =4;
$viewParameters = array(
/* 'searchValue' => $search,
'items' => $forms,
'totalItems' => $count,*/
/*'page' => $page,
'limit' => $limit,*/
'permissions' => $permissions,
'security' => $this->factory->getSecurity(),
'tmpl' => $this->request->get('tmpl', 'index')
);
return $this->delegateView(array(
'viewParameters' => $viewParameters,
'contentTemplate' => 'FeedManBundle:Default:index.html.php',
'passthroughVars' => array(
'activeLink' => '#feedman_index',
'mauticContent' => 'mydemo',
'route' => $this->generateUrl('feedman_index')
)
));
/*
$formModel = $this->factory->getModel('form.form');
$form = $formModel->getEntity($objectId);
$session = $this->factory->getSession();
$formPage = $session->get('mautic.form.page', 1);
$returnUrl = $this->generateUrl('mautic_form_index', array('page' => $formPage));
if ($form === null) {
//redirect back to form list
return $this->postActionRedirect(array(
'returnUrl' => $returnUrl,
'viewParameters' => array('page' => $formPage),
'contentTemplate' => 'MauticFormBundle:Form:index',
'passthroughVars' => array(
'activeLink' => 'mautic_form_index',
'mauticContent' => 'form'
),
'flashes' => array(array(
'type' => 'error',
'msg' => 'mautic.form.error.notfound',
'msgVars' => array('%id%' => $objectId)
))
));
} elseif (!$this->factory->getSecurity()->hasEntityAccess(
'form:forms:viewown', 'form:forms:viewother', $form->getCreatedBy()
)) {
return $this->accessDenied();
}
if ($this->request->getMethod() == 'POST') {
$this->setListFilters();
}
//set limits
$limit = $session->get('mautic.formresult.'.$objectId.'.limit', $this->factory->getParameter('default_pagelimit'));
$start = ($page === 1) ? 0 : (($page-1) * $limit);
if ($start < 0) {
$start = 0;
}
$orderBy = $session->get('mautic.formresult.'.$objectId.'.orderby', 's.date_submitted');
$orderByDir = $session->get('mautic.formresult.'.$objectId.'.orderbydir', 'ASC');
$filters = $session->get('mautic.formresult.'.$objectId.'.filters', array());
$model = $this->factory->getModel('form.submission');
//get the results
$entities = $model->getEntities(
array(
'start' => $start,
'limit' => $limit,
'filter' => array('force' => $filters),
'orderBy' => $orderBy,
'orderByDir' => $orderByDir,
'form' => $form,
'withTotalCount' => true
)
);
$count = $entities['count'];
$results = $entities['results'];
unset($entities);
if ($count && $count < ($start + 1)) {
//the number of entities are now less then the current page so redirect to the last page
$lastPage = ($count === 1) ? 1 : (ceil($count / $limit)) ?: 1;
$session->set('mautic.formresult.page', $lastPage);
$returnUrl = $this->generateUrl('mautic_form_results', array('objectId' => $objectId, 'page' => $lastPage));
return $this->postActionRedirect(array(
'returnUrl' => $returnUrl,
'viewParameters' => array('page' => $lastPage),
'contentTemplate' => 'MauticFormBundle:Result:index',
'passthroughVars' => array(
'activeLink' => 'mautic_form_index',
'mauticContent' => 'formresult'
)
));
}
//set what page currently on so that we can return here if need be
$session->set('mautic.formresult.page', $page);
$tmpl = $this->request->isXmlHttpRequest() ? $this->request->get('tmpl', 'index') : 'index';
return $this->delegateView(array(
'viewParameters' => array(
'items' => $results,
'filters' => $filters,
'form' => $form,
'page' => $page,
'totalCount' => $count,
'limit' => $limit,
'tmpl' => $tmpl,
'canDelete' => $this->factory->getSecurity()->hasEntityAccess('form:forms:editown', 'form:forms:editother', $form->getCreatedBy())
),
'contentTemplate' => 'MauticFormBundle:Result:list.html.php',
'passthroughVars' => array(
'activeLink' => 'mautic_form_index',
'mauticContent' => 'formresult',
'route' => $this->generateUrl('mautic_form_results', array(
'objectId' => $objectId,
'page' => $page
))
)
));*/
}
/**
-
@param int $objectId
-
@param string $format
-
-
@return SymfonyComponentHttpFoundationStreamedResponse
-
@throws Exception
*/
public function worldAction($objectId, $page){
return “Hello worerer”;
}
public function adminAction($objectId, $page){
return "Hello admin";
}
public function goodbyeAction($objectId, $page){
return "Hello goodbye";
}
public function contactAction($objectId, $page){
return "Hello contact";
}
public function howdyAction($objectId, $page){
return "Hello howdy";
}
}
[/code]