Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sourcefabric/Newscoop into consol…
Browse files Browse the repository at this point in the history
…e_commands
  • Loading branch information
takeit committed Mar 27, 2014
2 parents 84da387 + 09aa685 commit 33894c3
Show file tree
Hide file tree
Showing 15 changed files with 285 additions and 155 deletions.
10 changes: 4 additions & 6 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant::Config.run do |config|
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure( VAGRANTFILE_API_VERSION ) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
Expand Down Expand Up @@ -29,12 +30,9 @@ Vagrant::Config.run do |config|

# Forward a port from the guest to the host, which allows for outside
# computers to access the VM, whereas host only networking does not.
config.vm.forward_port 80, 8080
config.vm.network "forwarded_port", guest:80, host:8080

# Share an additional folder to the guest VM. The first argument is
# an identifier, the second is the path on the guest to mount the
# folder, and the third is the path on the host to the actual folder.
config.vm.share_folder "v-root", "/vagrant", "./", {:extra => 'dmode=777,fmode=777'}
config.vm.synced_folder "./", "/vagrant"

# Enable provisioning with Puppet stand alone. Puppet manifests
# are contained in a directory path relative to this Vagrantfile.
Expand Down
6 changes: 5 additions & 1 deletion newscoop/admin-style/fg.menu.css
Original file line number Diff line number Diff line change
Expand Up @@ -949,4 +949,8 @@ a.fg-button-menu { font-size: 12px !important; padding: 9px 25px 9px 15px;}
margin: 9px 0;
overflow: hidden;
background-color: #535353;
}
}

a.latest-published.fg-menu-indicator {
background-color: #008148;
}
1 change: 1 addition & 0 deletions newscoop/classes/Publication.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ public function getLanguages($p_excludeLanguageId = null,
}
$queryStr .= ' GROUP BY Languages.Id';
$order = Publication::ProcessLanguageListOrder($p_order);
$sqlOrder = array();
foreach ($order as $orderDesc) {
$sqlOrder[] = $orderDesc['field'] . ' ' . $orderDesc['dir'];
}
Expand Down
15 changes: 13 additions & 2 deletions newscoop/include/smarty/campsite_plugins/block.list_users.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,21 @@
function smarty_block_list_users($params, $content, &$smarty, &$repeat)
{
$context = $smarty->getTemplateVars('gimme');
$paginatorService = \Zend_Registry::get('container')->get('newscoop.listpaginator.service');
$cacheService = \Zend_Registry::get('container')->get('newscoop.cache');

if (!isset($content)) {
$start = $context->next_list_start('Newscoop\TemplateList\UsersList');
$list = new Newscoop\TemplateList\UsersList(new Newscoop\User\UserCriteria());
$list->getList($start, $params);
$list = new Newscoop\TemplateList\UsersList(
new Newscoop\User\UserCriteria(),
$paginatorService,
$cacheService
);

$list->setPageParameterName($context->next_list_id($context->getListName($list)));
$list->setPageNumber(\Zend_Registry::get('container')->get('request')->get($list->getPageParameterName(), 1));

$list->getList(0, $params);
if ($list->isEmpty()) {
$context->setCurrentList($list, array());
$context->resetCurrentList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function smarty_function_render($p_params, &$p_smarty)
}
if (isset($p_params['params'])) {
if (is_array($p_params['params'])) {
$campsiteVector['params'] = '';
foreach ($p_params['params'] as $key => $value) {
$campsiteVector['params'] .= $key .'__'. $value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ public function getUserPoints(User $user)
* @param Newscoop\User\UserCriteria $criteria
* @return Newscoop\ListResult
*/
public function getListByCriteria(UserCriteria $criteria)
public function getListByCriteria(UserCriteria $criteria, $results = true)
{
$qb = $this->createQueryBuilder('u');

Expand Down Expand Up @@ -748,6 +748,10 @@ public function getListByCriteria(UserCriteria $criteria)
$qb->orderBy($key, $order);
}

if (!$results) {
return $qb;
}

$list->items = array_map(function ($row) {
$user = $row[0];
$user->setPoints((int) $row['comments']);
Expand Down
63 changes: 40 additions & 23 deletions newscoop/library/Newscoop/Entity/Topic.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

namespace Newscoop\Entity;

use Doctrine\ORM\Mapping AS ORM;
use Doctrine\ORM\Mapping as ORM;
use Newscoop\View\TopicView;

/**
* Topic names entity
*
* @ORM\Entity(repositoryClass="Newscoop\Entity\Repository\TopicRepository")
* @ORM\Table(name="TopicNames")
*/
Expand All @@ -24,13 +26,6 @@ class Topic
*/
protected $id;

/**
* @ORM\ManyToOne(targetEntity="Newscoop\Entity\TopicNodes", inversedBy="names")
* @ORM\JoinColumn(name="fk_topic_id", referencedColumnName="id")
* @var Newscoop\Entity\TopicNodes
*/
protected $topic;

/**
* @ORM\Id
* @ORM\ManyToOne(targetEntity="Language")
Expand All @@ -51,18 +46,6 @@ class Topic
*/
protected $articlesLink;

/**
* @param int $id
* @param int $language
* @param int $name
*/
public function __construct($id, $language, $name)
{
$this->id = (int) $id;
$this->language = $language;
$this->name = (string) $name;
}

/**
* Get topic id
*
Expand All @@ -74,13 +57,17 @@ public function getTopicId()
}

/**
* Get topic left node
* Set topic id
*
* @param int $id
*
* @return int
*/
public function getTopicLeft()
public function setTopicId($id)
{
return $this->topic->getLeftNode();
$this->id = $id;

return $id;
}

/**
Expand All @@ -93,6 +80,20 @@ public function getLanguageId()
return $this->language->getId();
}

/**
* Set language
*
* @param Language $language
*
* @return int
*/
public function setLanguage($language)
{
$this->language = $language;

return $language;
}

/**
* Get name
*
Expand All @@ -103,8 +104,23 @@ public function getName()
return $this->name;
}

/**
* Set name
*
* @param string $name
*
* @return string
*/
public function setName($name)
{
$this->name = $name;

return $name;
}

/**
* Set link to topic articles resource
*
* @param string $articlesLink Link to topic articles resource
*/
public function setArticlesLink($articlesLink)
Expand Down Expand Up @@ -143,6 +159,7 @@ public function getView()
$view->identifier = $this->id;
$view->name = $this->name;
$view->value = sprintf('%s:%s', $this->name, $this->language->getCode());

return $view;
}
}
16 changes: 10 additions & 6 deletions newscoop/library/Newscoop/Entity/TopicNodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

namespace Newscoop\Entity;

use Doctrine\ORM\Mapping AS ORM;
use Doctrine\ORM\Mapping as ORM;

/**
* Topic nodes entity
*
* @ORM\Entity()
* @ORM\Table(name="Topics")
*/
Expand Down Expand Up @@ -59,13 +61,14 @@ public function getLeftNode()
/**
* Set left node
*
* @param int $leftNode
* @param int $leftNode
*
* @return int
*/
public function setLeftNode($leftNode)
{
$this->leftNode = $leftNode;

return $leftNode;
}

Expand All @@ -82,13 +85,14 @@ public function getRightNode()
/**
* Set right node
*
* @param int $rightNode
* @param int $rightNode
*
* @return int
*/
public function setRightNode($rightNode)
{
$this->rightNode = $rightNode;

return $rightNode;
}
}
}
5 changes: 3 additions & 2 deletions newscoop/library/Newscoop/TemplateList/PaginatedBaseList.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ public function getPaginator()
* @param int $pageNumber
* @param int $maxResults
* @param ListResult $list
* @param boolean $useCache
*
* @return ListResult
*/
protected function paginateList($target, $pageNumber, $maxResults, $list = null)
protected function paginateList($target, $pageNumber, $maxResults, $list = null, $useCache = true)
{
if (!$list) {
$list = new ListResult();
Expand All @@ -85,7 +86,7 @@ protected function paginateList($target, $pageNumber, $maxResults, $list = null)
$this->getCacheKey(), $this->getPageNumber()
), $this->getName());

if ($this->cacheService->contains($cacheId)) {
if ($this->cacheService->contains($cacheId) && $useCache) {
$this->pagination = $this->cacheService->fetch($cacheId);
} else {
$this->pagination = $this->paginatorService->paginate($target, $pageNumber, $maxResults);
Expand Down
19 changes: 14 additions & 5 deletions newscoop/library/Newscoop/TemplateList/UsersList.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,29 @@
namespace Newscoop\TemplateList;

use Newscoop\ListResult;
use Newscoop\TemplateList\PaginatedBaseList;

/**
* List users
*/
class UsersList extends BaseList
class UsersList extends PaginatedBaseList
{

protected function prepareList($criteria, $parameters)
{
$em = \Zend_Registry::get('container')->get('em');
$service = \Zend_Registry::get('container')->get('user.list');
$list = $service->findByCriteria($criteria);
foreach ($list as $key => $user) {
$list->items[$key] = new \MetaUser($user);
}
$qb = $em->getRepository('Newscoop\Entity\User')->getListByCriteria($criteria, false);
$list = $this->paginateList($qb, null, $criteria->maxResults, null, false);

$tempList = array_map(function ($row) {
$user = $row[0];
$user->setPoints((int) $row['comments']);

return new \MetaUser($user);
}, $list->items);

$list->items = $tempList;

return $list;
}
Expand Down
Loading

0 comments on commit 33894c3

Please sign in to comment.