This commit is contained in:
afornerot 2024-11-03 14:47:30 +01:00
parent 33202511c8
commit 0254848d39
8 changed files with 130 additions and 19 deletions

View File

@ -15,3 +15,4 @@ twig:
appNinegateactivate: '%appNinegateactivate%'
appNinegateurl: '%appNinegateurl%'
appNinegatemoderegistration: '%appNinegatemoderegistration%'
protocole: '%protocole%'

View File

@ -3,9 +3,14 @@ app_home:
path: /
defaults: { _controller: App\Controller\HomeController:home }
app_feed:
path: /feed/{nb}
defaults: { _controller: App\Controller\HomeController:feed, nb: 0 }
app_feedhome:
path: /feedhome/{nb}
defaults: { _controller: App\Controller\HomeController:feedhome, nb: 0 }
app_feeduser:
path: /feeduser/{userpseudo}/{nb}
defaults: { _controller: App\Controller\HomeController:feeduser, nb: 0 }
app_admin:
path: /admin/home
@ -167,15 +172,15 @@ app_user_category:
defaults: { _controller: App\Controller\CategoryController:listuser }
app_category_submit:
path: /admin/category/submit/{by}/{userid}
path: /user/category/submit/{by}/{userid}
defaults: { _controller: App\Controller\CategoryController:submit }
app_category_update:
path: /admin/category/update/{id}/{by}
path: /user/category/update/{id}/{by}
defaults: { _controller: App\Controller\CategoryController:update }
app_category_delete:
path: /admin/category/delete/{id}/{by}
path: /user/category/delete/{id}/{by}
defaults: { _controller: App\Controller\CategoryController:delete }
#== Illustration ==================================================================================================
@ -225,19 +230,19 @@ app_webzine_submit:
defaults: { _controller: App\Controller\WebzineController:submit }
app_webzine_update:
path: /admin/webzine/update/{id}/{by}
path: /user/webzine/update/{id}/{by}
defaults: { _controller: App\Controller\WebzineController:update }
app_webzine_delete:
path: /admin/webzine/delete/{id}/{by}
path: /user/webzine/delete/{id}/{by}
defaults: { _controller: App\Controller\WebzineController:delete }
app_webzine_crop:
path: /admin/webzine/crop/{type}/{reportinput}
path: /user/webzine/crop/{type}/{reportinput}
defaults: { _controller: App\Controller\CropController:crop02 }
app_webzine_upload:
path: /admin/webzine/upload
path: /user/webzine/upload
defaults: { _controller: App\Controller\WebzineController:upload }
app_webzine_view:

View File

@ -179,7 +179,7 @@ class CategoryController extends AbstractController
return $this->redirectToRoute("app_home");
}
if($by!="admin"&&$by!="update") {
if($this->getUser()!=$data->getCategory()->getUser()&&!$this->getUser()->hasRole("ROLE_ADMIN"))
if($this->getUser()!=$data->getUser()&&!$this->getUser()->hasRole("ROLE_ADMIN"))
return $this->redirectToRoute("app_home");
}

View File

@ -72,7 +72,7 @@ class HomeController extends AbstractController
}
public function feed($nb)
public function feedhome($nb)
{
$feeds=[];
@ -123,12 +123,81 @@ class HomeController extends AbstractController
$columns = array_column($feeds, 'pubtime');
array_multisort($columns, SORT_DESC, $feeds);
$response = new Response($this->renderView('Home/feed.xml.twig',["feeds" => $feeds]));
$response = new Response($this->renderView('Home/feed.xml.twig',["by"=>"home","feeds" => $feeds]));
$response->headers->set('Content-Type', 'application/xml; charset=utf-8');
return $response;
}
public function feeduser($userpseudo,$nb)
{
$feeds=[];
$em = $this->getDoctrine()->getManager();
$qb = $em ->createQueryBuilder()
->select('i')
->from("App:Illustration", 'i')
->from("App:Category", 'c')
->from("App:User",'u')
->Where('c=i.category')
->andWhere('u=c.user')
->andWhere('u.slug=:userpseudo')
->setParameter('userpseudo',$userpseudo)
->orderBy('i.submittime','DESC');
if($nb!=0) $qb->setMaxResults($nb);
$illustrations=$qb->getQuery()->getResult();
foreach($illustrations as $illustration) {
$tmp["path"] = "app_illustration_view";
$tmp["type"] = "illustration";
$tmp["idcat"] = $illustration->getCategory()->getId();
$tmp["cat"] = $illustration->getCategory()->getName();
$tmp["id"] = $illustration->getId();
$tmp["name"] = $illustration->getName();
$tmp["illustration"] = $illustration->getIllustration();
$tmp["pubtime"] = $illustration->getSubmittime();
$tmp["description"] = $illustration->getDescription();
array_push($feeds,$tmp);
}
$qb = $em ->createQueryBuilder()
->select('w')
->from("App:Webzine", 'w')
->from("App:User", 'u')
->Where('u=w.user')
->andWhere('u.slug=:userpseudo')
->setParameter('userpseudo',$userpseudo)
->orderBy('w.submittime','DESC');
if($nb!=0) $qb->setMaxResults($nb);
$webzines=$qb->getQuery()->getResult();
foreach($webzines as $webzine) {
if($webzine->getWebzinepages()) {
$tmp["path"] = "app_webzine_view";
$tmp["type"] = "webzine";
$tmp["idcat"] = $webzine->getId();
$tmp["cat"] = "Webzine".($webzine->getSet()?" - ".$webzine->getSet():"");
$tmp["id"] = $webzine->getWebzinepages()[0]->getId();
$tmp["name"] = $webzine->getName();
$tmp["illustration"] = $webzine->getWebzinepages()[0]->getIllustration();
$tmp["pubtime"] = $webzine->getSubmittime();
$tmp["description"] = $webzine->getDescription();
array_push($feeds,$tmp);
}
}
$columns = array_column($feeds, 'pubtime');
array_multisort($columns, SORT_DESC, $feeds);
$response = new Response($this->renderView('Home/feed.xml.twig',["by"=>"user","feeds" => $feeds]));
$response->headers->set('Content-Type', 'application/xml; charset=utf-8');
return $response;
}
public function admin()
{
return $this->render('Home/admin.html.twig',[

View File

@ -111,6 +111,11 @@ class User implements UserInterface, \Serializable
*/
private $links;
/**
* @ORM\OneToMany(targetEntity="Config", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true)
*/
private $configs;
public function __construct()
{
$this->groups = new ArrayCollection();
@ -119,6 +124,7 @@ class User implements UserInterface, \Serializable
$this->illustrations = new ArrayCollection();
$this->webzines = new ArrayCollection();
$this->links = new ArrayCollection();
$this->configs = new ArrayCollection();
}
public function getUsername(): ?string
@ -387,6 +393,36 @@ class User implements UserInterface, \Serializable
return $this;
}
/**
* @return Collection|Config[]
*/
public function getConfigs(): Collection
{
return $this->configs;
}
public function addConfig(Config $config): self
{
if (!$this->configs->contains($config)) {
$this->configs[] = $config;
$config->setUser($this);
}
return $this;
}
public function removeConfig(Config $config): self
{
if ($this->configs->removeElement($config)) {
// set the owning side to null (unless already changed)
if ($config->getUser() === $this) {
$config->setUser(null);
}
}
return $this;
}
public function getPseudo(): ?string
{

View File

@ -7,7 +7,7 @@
<link>{{ absolute_url(path("app_home")) }}</link>
<description>{{ app.session.get('appname') }} - {{app.session.get('appsubname') }}</description>
{% for feed in feeds %}
{% set url = absolute_url(path(feed.path,{"idcat":feed.idcat,"id":feed.id}))|replace({'http://': 'https://'}) %}
{% set url = absolute_url(path(feed.path,{"by":by, "idcat":feed.idcat,"id":feed.id}))|replace({'http://': protocole~'://'}) %}
<item>
<guid><![CDATA[{{url}}]]></guid>
<title>{{ app.session.get('appname') }} - {{feed.name}}</title>
@ -16,7 +16,7 @@
<pubDate>{{feed.pubtime|date('D, d M Y H:i:s O')}}</pubDate>
<link><![CDATA[{{url}}]]></link>
<description><![CDATA[
<a href="{{ url }}"><img src='{{ "https://"~appWeburl~"/"~appAlias~"/uploads/"~feed.type~"/thumbori_"~feed.illustration }}'></p>
<a href="{{ url }}"><img src='{{ protocole~"://"~appWeburl~"/"~appAlias~"/uploads/"~feed.type~"/thumbori_"~feed.illustration }}'></p>
<h3>{{feed.name}}</h3>
{% autoescape 'html' %}
@ -26,8 +26,8 @@
{% endautoescape %}
]]></description>
<enclosure url="{{ "https://"~appWeburl~"/"~appAlias~"/uploads/"~feed.type~"/thumbori_"~feed.illustration }}" rel="thumb" />
<enclosure url="{{ "https://"~appWeburl~"/"~appAlias~"/uploads/"~feed.type~"/"~feed.illustration }}" rel="big" />
<enclosure url="{{ protocole~"://"~appWeburl~"/"~appAlias~"/uploads/"~feed.type~"/thumbori_"~feed.illustration }}" rel="thumb" />
<enclosure url="{{ protocole~"://"~appWeburl~"/"~appAlias~"/uploads/"~feed.type~"/"~feed.illustration }}" rel="big" />
</item>
{% endfor %}

View File

@ -172,7 +172,7 @@
{% if app.session.get('youtube') is not empty %}
<a href="{{ app.session.get('youtube') }}" target="_blank" title="Youtube"><i class="fab fa-youtube fa-2x"></i></a>
{% endif %}
<a href="{{ path("app_feed") }}" target="_blank" title="RSS"><i class="fa fa-rss-square fa-2x"></i></a>
<a href="{{ path("app_feedhome") }}" target="_blank" title="RSS"><i class="fa fa-rss-square fa-2x"></i></a>
</div>
<div class="catmenu">

View File

@ -188,7 +188,7 @@
{% if config.youtube is not empty %}
<a href="{{ config.youtube }}" target="_blank" title="Youtube"><i class="fab fa-youtube fa-2x"></i></a>
{% endif %}
<a href="{{ path("app_feed") }}" target="_blank" title="RSS"><i class="fa fa-rss-square fa-2x"></i></a>
<a href="{{ path("app_feeduser",{userpseudo:user.slug}) }}" target="_blank" title="RSS"><i class="fa fa-rss-square fa-2x"></i></a>
</div>