<?php
    if(!Config::get('lang_selector_enabled')) {
        $opts = array();
        $code = Lang::getCode();
        foreach(Lang::getAvailableLanguages() as $id => $dfn) {
            $selected = ($id == $code) ? 'selected="selected"' : '';
            $opts[] = '<option value="'.$id.'" '.$selected.'>'.Utilities::sanitizeOutput($dfn['name']).'</option>';
        }

        echo '
<select id="language_selector">'.implode('', $opts).'</select>
';
    }

    if(!array_key_exists('token', $_REQUEST))
        throw new TokenIsMissingException();

    $token = $_REQUEST['token'];
    if(!Utilities::isValidUID($token))
        throw new TokenHasBadFormatException($token);

    $translatable = TranslatableEmail::fromToken($token);

    $translation = $translatable->translate();

    /*
     * Do not call Template::sanitizeOutput on email contents after that because
     * TranslatableEmail::translate calls Translation::replace which itself calls
     * Utilities::sanitizeOutput, use Template::sanitize instead !
     */

    ?>

{tr:subject} :

<?php echo Template::sanitize($translation->subject) ?>

{tr:message}

<?php echo Template::sanitize($translation->html) ?>

<?php
    if(!Config::get('lang_selector_enabled')) {
        $opts = array();
        $code = Lang::getCode();
        foreach(Lang::getAvailableLanguages() as $id => $dfn) {
            $selected = ($id == $code) ? 'selected="selected"' : '';
            $opts[] = '<option value="'.$id.'" '.$selected.'>'.Utilities::sanitizeOutput($dfn['name']).'</option>';
        }

        echo '
<select id="language_selector">'.implode('', $opts).'</select>
';
    }

    if(!array_key_exists('token', $_REQUEST))
        throw new TokenIsMissingException();

    $token = $_REQUEST['token'];
    if(!Utilities::isValidUID($token))
        throw new TokenHasBadFormatException($token);

    $translatable = TranslatableEmail::fromToken($token);

    $translation = $translatable->translate();

    /*
     * Do not call Template::sanitizeOutput on email contents after that because
     * TranslatableEmail::translate calls Translation::replace which itself calls
     * Utilities::sanitizeOutput, use Template::sanitize instead !
     */

    $subject = array_filter($translation->subject->out());

    ?>

{tr:subject} :

<?php echo Template::sanitize(array_pop($subject)) ?>

{tr:message}

<?php echo Template::sanitize($translation->html) ?>

Fix subject getter to support subject alts

git-svn-id: 28fe03dfd74dd77dcc8ecfe99fabcec8eed81bba@3722 8555b757-d854-4b86-925a-82fd84c90ff4


<?php
/**
 * @license   http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
 * @copyright Copyright (c) 2015 Matthew Weier O'Phinney (https://mwop.net)
 */

require __DIR__ . '/../vendor/autoload.php';

use Zend\Console\Console;
use ZF\Console\Application;
use ZF\Console\Dispatcher;

$version = '0.0.1';

$application = new Application(
    'Component Installer',
    $version,
    include __DIR__ . '/../config/routes.php',
    Console::getInstance(),
    new Dispatcher()
);

$exit = $application->run();
exit($exit);

<?php
/**
 * @license   http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
 * @copyright Copyright (c) 2015 Matthew Weier O'Phinney (https://mwop.net)
 */

require __DIR__ . '/../vendor/autoload.php';

use Zend\Console\Console;
use ZF\Console\Application;
use ZF\Console\Dispatcher;

$version = '@package_version@';

$application = new Application(
    'Component Installer',
    $version,
    include __DIR__ . '/../config/routes.php',
    Console::getInstance(),
    new Dispatcher()
);

$exit = $application->run();
exit($exit);

Use git version for package version

Use git version for package version


<?php

namespace Ddeboer\Imap;

use Ddeboer\Imap\Exception\AuthenticationFailedException;

class Server
{
    protected $hostname;
    protected $port;
    protected $connection;
    protected $mailboxes;

    public function __construct($hostname, $port = '993')
    {
        if ($port == 993) {
            $cert = 'ssl';
        } else {
            $cert = 'novalidate-cert';
        }
        $this->server = '{' . $hostname . ':' . $port . '/imap/' . $cert . '}';
    }

    /**
     * Authenticate connection
     *
     * @param string $username Username
     * @param string $password Password
     *
     * @return \Ddeboer\Imap\Connection
     * @throws AuthenticationFailedException
     */
    public function authenticate($username, $password)
    {
        $resource = @\imap_open($this->server, $username, $password, null, 1);

        if (false === $resource) {
            throw new AuthenticationFailedException($username);
        }

        $check = imap_check($resource);
        $mailbox = $check->Mailbox;
        $this->connection = substr($mailbox, 0, strpos($mailbox, '}')+1);

        // These are necessary to get rid of PHP throwing IMAP errors
        imap_errors();
        imap_alerts();

        return new Connection($resource, $this->connection);
    }
}

<?php

namespace Ddeboer\Imap;

use Ddeboer\Imap\Exception\AuthenticationFailedException;

class Server
{
    protected $hostname;
    protected $port;
    protected $connection;
    protected $mailboxes;

    /**
     * Constructor
     *
     * @param string $hostname
     * @param int    $port
     * @param string $flags
     */
    public function __construct($hostname, $port = 993, $flags = '/imap/ssl/validate-cert')
    {
        $this->server = "{{$hostname}:{$port}{$flags}}";
    }

    /**
     * Authenticate connection
     *
     * @param string $username Username
     * @param string $password Password
     *
     * @return \Ddeboer\Imap\Connection
     * @throws AuthenticationFailedException
     */
    public function authenticate($username, $password)
    {
        $resource = @\imap_open($this->server, $username, $password, null, 1);

        if (false === $resource) {
            throw new AuthenticationFailedException($username);
        }

        $check = imap_check($resource);
        $mailbox = $check->Mailbox;
        $this->connection = substr($mailbox, 0, strpos($mailbox, '}')+1);

        // These are necessary to get rid of PHP throwing IMAP errors
        imap_errors();
        imap_alerts();

        return new Connection($resource, $this->connection);
    }
}

Allow user to change connection flags

Allow user to change connection flags


<?php
/**
 * @author        "Michael Collette" <metrol@metrol.net>
 * @package       Metrol/DBSql
 * @version       1.0
 * @copyright (c) 2016, Michael Collette
 */

namespace Metrol\DBSql;

/**
 * Define what the Case/When class should look like
 *
 */
interface CaseFieldInterface extends CaseInterface
{
    /**
     * Assembles the CASE statement, pushes it onto the Select object, then
     * passes back the Select object to continue chaining the query.
     *
     * @param string $alias
     *
     * @return SelectInterface
     */
    public function endCase($alias);
}

<?php
/**
 * @author        "Michael Collette" <metrol@metrol.net>
 * @package       Metrol/DBSql
 * @version       1.0
 * @copyright (c) 2016, Michael Collette
 */

namespace Metrol\DBSql;

/**
 * Define what the Case/When class should look like
 *
 */
interface CaseFieldInterface extends CaseInterface
{
    /**
     * Assembles the CASE statement, pushes it onto the Select object, then
     * passes back the Select object to continue chaining the query.
     *
     * @param string $alias
     *
     * @return SelectInterface
     */
    public function endCase($alias = null);
}

Allow the alias to be null

Allow the alias to be null

Follow up fix to the previous commit


<?php

use Rector\Core\Configuration\Option;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Utils\Rector\UnderscoreToCamelCaseVariableNameRector;

return static function (ContainerConfigurator $containerConfigurator): void {
	$parameters = $containerConfigurator->parameters();

	// paths to refactor; solid alternative to CLI arguments
	$parameters->set(Option::PATHS, [__DIR__ . '/app', __DIR__ . '/system']);

	// is there a file you need to skip?
	$parameters->set(Option::EXCLUDE_PATHS, [
		__DIR__ . '/app/Views',
		__DIR__ . '/system/Debug/Toolbar/Views/toolbar.tpl.php',
		__DIR__ . '/system/ThirdParty',
	]);

	// Rector relies on autoload setup of your project; Composer autoload is included by default; to add more:
	$parameters->set(Option::AUTOLOAD_PATHS, [
		// autoload specific file
		__DIR__ . '/system/Test/bootstrap.php',
	]);

	$services = $containerConfigurator->services();
	$services->set(UnderscoreToCamelCaseVariableNameRector::class);

	$parameters->set(Option::SKIP, [
		// skipped for UnderscoreToCamelCaseVariableNameRector rule
		// as the underscored variable in system/Autoloader/Autoloader.php removed in 4.1 branch
		UnderscoreToCamelCaseVariableNameRector::class => [__DIR__ . '/system/Autoloader/Autoloader.php'],
	]);
};

<?php

use Rector\Core\Configuration\Option;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Utils\Rector\UnderscoreToCamelCaseVariableNameRector;

return static function (ContainerConfigurator $containerConfigurator): void {
	$parameters = $containerConfigurator->parameters();

	// paths to refactor; solid alternative to CLI arguments
	$parameters->set(Option::PATHS, [__DIR__ . '/app', __DIR__ . '/system']);

	// is there a file you need to skip?
	$parameters->set(Option::EXCLUDE_PATHS, [
		__DIR__ . '/app/Views',
		__DIR__ . '/system/Autoloader/Autoloader.php',
		__DIR__ . '/system/Debug/Toolbar/Views/toolbar.tpl.php',
		__DIR__ . '/system/ThirdParty',
	]);

	// Rector relies on autoload setup of your project; Composer autoload is included by default; to add more:
	$parameters->set(Option::AUTOLOAD_PATHS, [
		// autoload specific file
		__DIR__ . '/system/Test/bootstrap.php',
	]);

	$services = $containerConfigurator->services();
	$services->set(UnderscoreToCamelCaseVariableNameRector::class);
};

Revert "using option skip for skip system/Autoloader/Autoloader.php for UnderscoreToCamelCaseVariableNameRector with reason comment"

This reverts commit c95d52e45abe03693f2e28ae45aa92eaabe197e0.


<?php namespace Orchestra\Widget;

use Illuminate\Support\ServiceProvider;
use Illuminate\Foundation\AliasLoader;

class WidgetServiceProvider extends ServiceProvider
{
    /**
     * Indicates if loading of the provider is deferred.
     *
     * @var boolean
     */
    protected $defer = true;

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->app['orchestra.widget'] = $this->app->share(function ($app) {
            return new WidgetManager($app);
        });

        $this->app->booting(function () {
            $loader = AliasLoader::getInstance();
            $loader->alias('Orchestra\Widget', 'Orchestra\Support\Facades\Widget');
        });
    }

    /**
     * Bootstrap the application events.
     *
     * @return void
     */
    public function boot()
    {
        $path = realpath(__DIR__.'/../../');

        $this->package('orchestra/widget', 'orchestra/widget', $path);
    }

    /**
     * Get the services provided by the provider.
     *
     * @return array
     */
    public function provides()
    {
        return array('orchestra.widget');
    }
}

<?php namespace Orchestra\Widget;

use Illuminate\Support\ServiceProvider;
use Illuminate\Foundation\AliasLoader;

class WidgetServiceProvider extends ServiceProvider
{
    /**
     * Indicates if loading of the provider is deferred.
     *
     * @var boolean
     */
    protected $defer = true;

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bindShared('orchestra.widget', function ($app) {
            return new WidgetManager($app);
        });

        $this->app->booting(function () {
            $loader = AliasLoader::getInstance();
            $loader->alias('Orchestra\Widget', 'Orchestra\Support\Facades\Widget');
        });
    }

    /**
     * Bootstrap the application events.
     *
     * @return void
     */
    public function boot()
    {
        $path = realpath(__DIR__.'/../../');

        $this->package('orchestra/widget', 'orchestra/widget', $path);
    }

    /**
     * Get the services provided by the provider.
     *
     * @return array
     */
    public function provides()
    {
        return array('orchestra.widget');
    }
}

Update service provider to use bindShared.

Signed-off-by: Mior Muhammad Zaki <e1a543840a942eb68427510a8a483282a7bfeddf@gmail.com>


<?php $id = $category['id']; ?>
<a class="category-link" href="products.php?category_id=<?php echo $id; ?>">
  <article class="category" id="<?php echo $id; ?>">

      <img src="assets/category_images/<?php echo $id; ?>.jpg" alt="<?php echo $category['title']; ?>">

<?php echo $category['title'] ?>

Fix validation error in products.php since h3 couldn't be child of span in category partial.


<script src="{{ URL::to('vendor/redooor/redminportal/js/tinymce/tinymce.min.js') }}"></script>
<script>
    !function ($) {
        $(function(){
            tinymce.init({
                skin: 'redooor',
                selector:'textarea',
                menubar:false,
                plugins: "link image code",
                convert_urls: false,
                relative_urls: false,
                toolbar: "undo redo | formatselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link | image | code",
                content_css: [
                @foreach (config('redminportal::tinymce') as $tinymce_css)
                    "{{ url($tinymce_css) }}",
                @endforeach
                ]
            });
        })
    }(window.jQuery);
</script>

<script src="{{ URL::to('vendor/redooor/redminportal/js/tinymce/tinymce.min.js') }}"></script>
<script>
    !function ($) {
        $(function(){
            tinymce.init({
                skin: 'redooor',
                selector:'textarea',
                menubar:false,
                plugins: "link image code",
                convert_urls: false,
                relative_urls: false,
                toolbar: "undo redo | formatselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link | image | code",
                body_class: 'container-fluid',
                content_css: [
                @foreach (config('redminportal::tinymce') as $tinymce_css)
                    "{{ url($tinymce_css) }}",
                @endforeach
                ]
            });
        })
    }(window.jQuery);
</script>

Fix Tinymce editor not showing Bootstrap components correctly by adding container-fluid class to body.


<?php
class Kwc_Directories_TopChoose_Component extends Kwc_Directories_Top_Component
{
    public static function getSettings()
    {
        $ret = parent::getSettings();
        $ret['showDirectoryClass'] = 'Kwc_Directories_Item_Directory_Component'; // nur für form
        $ret['ownModel'] = 'Kwc_Directories_TopChoose_Model';
        $ret['extConfig'] = 'Kwf_Component_Abstract_ExtConfig_Form';
        return $ret;
    }

    public static function getItemDirectoryClasses($directoryClass)
    {
        $ret = array();
        $class = self::getSetting($directoryClass, 'showDirectoryClass');
        foreach (Kwf_Component_Data_Root::getInstance()->getComponentsByClass($class) as $component) {
            $ret[] = $component->componentClass;
        }
        return $ret;
    }

    protected function _getItemDirectory()
    {
        $row = $this->_getRow();
        if ($row && $row->directory_component_id) {
            return Kwf_Component_Data_Root::getInstance()->getComponentByDbId($row->directory_component_id);
        }
        return null;
    }
}

<?php
class Kwc_Directories_TopChoose_Component extends Kwc_Directories_Top_Component
{
    public static function getSettings()
    {
        $ret = parent::getSettings();
        $ret['showDirectoryClass'] = 'Kwc_Directories_Item_Directory_Component'; // nur für form
        $ret['ownModel'] = 'Kwc_Directories_TopChoose_Model';
        $ret['extConfig'] = 'Kwf_Component_Abstract_ExtConfig_Form';
        return $ret;
    }

    public static function getItemDirectoryClasses($directoryClass)
    {
        $ret = array();
        $class = self::getSetting($directoryClass, 'showDirectoryClass');
        foreach (Kwf_Component_Data_Root::getInstance()->getComponentsByClass($class) as $component) {
            $ret[] = $component->componentClass;
        }
        return $ret;
    }

    protected function _getItemDirectory()
    {
        $row = $this->_getRow();
        if ($row && $row->directory_component_id) {
            $component = Kwf_Component_Data_Root::getInstance()
                ->getComponentByDbId($row->directory_component_id);
            if (is_instance_of($component, 'Kwc_Directories_Item_DirectoryNoAdmin_Component')) {
                return $component;
            }
        }
        return null;
    }
}

Check if target is directory in top choose component


<?php

class get_names {

	function get_users_name($username)
		{

			$q = mysql_query("SELECT * FROM `cm_users` WHERE `username` = '$username' LIMIT 1");
			$qq = mysql_fetch_object($q);
			$real_name = $qq->first_name . " " . $qq->last_name;
			return $real_name;

		}

	function get_users_name_initial($username)
		{

			$q = mysql_query("SELECT * FROM `cm_users` WHERE `username` = '$username' LIMIT 1");
			$qq = mysql_fetch_object($q);
			$real_name_init = substr($qq->first_name,0,1) . ". " . $qq->last_name;
			return $real_name_init;

		}

	function get_clients_name($id)
		{

			$q = mysql_query("SELECT * FROM `cm` WHERE `id` = '$id' LIMIT 1");
			$qq = mysql_fetch_object($q);
			$real_name = $qq->first_name . " $qq->m_initial" . " $qq->last_name";
			return $real_name;

		}

}

?>

<?php

class get_names {

	function get_users_name($username)
		{

			$q = mysql_query("SELECT * FROM `cm_users` WHERE `username` = '$username' LIMIT 1");
			$qq = mysql_fetch_object($q);
			$real_name = $qq->first_name . " " . $qq->last_name;
			return $real_name;

		}

	function get_users_name_initial($username)
		{

			$q = mysql_query("SELECT * FROM `cm_users` WHERE `username` = '$username' LIMIT 1");
			$qq = mysql_fetch_object($q);
			$real_name_init = substr($qq->first_name,0,1) . ". " . $qq->last_name;
			return $real_name_init;

		}

	function get_clients_name($id)
		{

			$q = mysql_query("SELECT * FROM `cm` WHERE `id` = '$id' LIMIT 1");
			$qq = mysql_fetch_object($q);
			$real_name = $qq->first_name . " $qq->m_initial" . " $qq->last_name";
			return $real_name;

		}

	function get_clients_name_by_casenum($case_id)
		{

			$q = mysql_query("SELECT * FROM `cm` WHERE `clinic_id` = '$case_id' LIMIT 1");
			$qq = mysql_fetch_object($q);
			$real_name = $qq->first_name . " $qq->m_initial" . " $qq->last_name";
			return $real_name;

		}

}

?>

Add function to retrieve client name via case number

git-svn-id: 236d1da889b004185c53d75d23fb6bdc6a50cecb@712 54a900ba-8191-11dd-a5c9-f1483cedc3eb


<?php
/**
 * @copyright (c) 2016 Jacob Martin
 * @license MIT https://opensource.org/licenses/MIT
 */

namespace App\Http\Controllers\Admin\Crud;

use App\Http\Controllers\Controller;

/**
 * ChangesController Displays change logs for the crud system.
 *
 * @package App\Http\Controllers\Admin\Crud
 */
class ChangesController extends Controller
{
	/**
	 * Get the change log for a model's column as a series of pretty HTML diff tables.
	 *
	 * Called via AJAX from the crud add/edit pages.
	 *
	 * @param $crudRepository string The fully namespaced class name of the CrudRepository for the
	 *                                model.
	 * @param $id string|int The ID of the model in question.
	 * @param $column string The column in question.
	 * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
	 */
	public function getLog($crudRepository, $id, $column)
	{
		$repository = app($crudRepository);
		$model      = $repository->find($id);
		$changes    = $repository->getChangesForColumn($model, $column);

		// This is loaded into a modal window and thus far does not need $this->data.
		return view('admin.crud.changes-log', compact('repository', 'model', 'changes', 'column'));
	}
}

<?php

namespace App\Http\Controllers\Admin\Crud;

use App\Http\Controllers\Controller;

/**
 * ChangesController Displays change logs for the crud system.
 *
 * @package App\Http\Controllers\Admin\Crud
 */
class ChangesController extends Controller
{
	/**
	 * Get the change log for a model's column as a series of pretty HTML diff tables.
	 *
	 * Called via AJAX from the crud add/edit pages.
	 *
	 * @param $crudRepository string The fully namespaced class name of the CrudRepository for the
	 *                                model.
	 * @param $hashid string The hashid of the model in question.
	 * @param $column string The column in question.
	 * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
	 */
	public function getLog($crudRepository, $hashid, $column)
	{
		$repository = app($crudRepository);
		$model      = $repository->getByHashId($hashid);
		$changes    = $repository->getChangesForColumn($model, $column);

		return view('admin.crud.modals.changes-log', compact('repository', 'model', 'changes', 'column'));
	}
}

Fix change controller for hashids

Fix change controller for hashids


<?php
/**
 * Copyright © 2017 Sam Granger. All rights reserved.
 *
 * @author Sam Granger <sam.granger@gmail.com>
 */

namespace SamGranger\StoreCodeBodyClass\Plugin;

use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer;
use Magento\Framework\View\Page\Config;
use Magento\Store\Model\StoreManagerInterface;

class StoreCodeBodyClassPlugin implements ObserverInterface
{
    protected $config;
    protected $storeManager;

    public function __construct(
        Config $config,
        StoreManagerInterface $storeManager
    ){
        $this->config = $config;
        $this->storeManager = $storeManager;
    }

    public function execute(Observer $observer){
        $storeCode = $this->storeManager->getStore()->getCode();
        $this->config->addBodyClass($storeCode);
    }
}

<?php
/**
 * Copyright © 2017 Sam Granger. All rights reserved.
 *
 * @author Sam Granger <sam.granger@gmail.com>
 */

namespace SamGranger\StoreCodeBodyClass\Plugin;

use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer;
use Magento\Framework\View\Page\Config;
use Magento\Store\Model\StoreManagerInterface;

class StoreCodeBodyClassPlugin implements ObserverInterface
{
    protected $config;
    protected $storeManager;

    public function __construct(
        Config $config,
        StoreManagerInterface $storeManager
    ){
        $this->config = $config;
        $this->storeManager = $storeManager;
    }

    public function execute(Observer $observer){
        $store = $this->storeManager->getStore();
        $storeCode = $store->getCode();
        $websiteCode = $store->getWebsite()->getCode();
        $this->config->addBodyClass($storeCode);
        $this->config->addBodyClass($websiteCode);
    }
}

Add website code to body class

Add website code to body class


<?php
// Autoloader
require('Providers/Rng/MCryptRNGProvider.php');
require('Providers/Rng/IRNGProvider.php');
require('Providers/Rng/CSRNGProvider.php');
require('Providers/Qr/IQRCodeProvider.php');
require('Providers/Qr/BaseHTTPQRCodeProvider.php');
require('Providers/Qr/GoogleQRCodeProvider.php');
require('TwoFactorAuth.php');

<?php
// Autoloader
require('Providers/Rng/IRNGProvider.php');
require('Providers/Rng/MCryptRNGProvider.php');
require('Providers/Rng/CSRNGProvider.php');
require('Providers/Qr/IQRCodeProvider.php');
require('Providers/Qr/BaseHTTPQRCodeProvider.php');
require('Providers/Qr/GoogleQRCodeProvider.php');
require('TwoFactorAuth.php');

Change loading order of TFA requirements

Change loading order of TFA requirements within autoloader


<?php
/*
 * WellCommerce Open-Source E-Commerce Platform
 *
 * This file is part of the WellCommerce package.
 *
 * (c) Adam Piotrowski <adam@wellcommerce.org>
 *
 * For the full copyright and license information,
 * please view the LICENSE file that was distributed with this source code.
 */

namespace WellCommerce\Bundle\CategoryBundle\Tests\Manager;

use WellCommerce\Bundle\CoreBundle\Test\Manager\AbstractManagerTestCase;

/**
 * Class CategoryManagerTest
 *
 * @author  Adam Piotrowski <adam@wellcommerce.org>
 */
class CategoryManagerTest extends AbstractManagerTestCase
{
    protected function get()
    {
        return $this->container->get('category.manager');
    }
}

<?php
/*
 * WellCommerce Open-Source E-Commerce Platform
 *
 * This file is part of the WellCommerce package.
 *
 * (c) Adam Piotrowski <adam@wellcommerce.org>
 *
 * For the full copyright and license information,
 * please view the LICENSE file that was distributed with this source code.
 */

namespace WellCommerce\Bundle\CategoryBundle\Tests\Manager;

use WellCommerce\Bundle\CoreBundle\Test\Manager\AbstractManagerTestCase;
use WellCommerce\Bundle\DoctrineBundle\Manager\ManagerInterface;

/**
 * Class CategoryManagerTest
 *
 * @author  Adam Piotrowski <adam@wellcommerce.org>
 */
class CategoryManagerTest extends AbstractManagerTestCase
{
    protected function get() : ManagerInterface
    {
        return $this->container->get('category.manager');
    }
}

Return types in manager tests

Return types in manager tests


<?php

/**
 * Description of User
 *
 * @author pirhoo
 */
class User extends Record{

    private $email;
    private $password;
    private $trust_level;

    public function getId() {
        return $this->id;
    }

    public function setId($id) {
        $this->id = $id;
    }

    public function getEmail() {
        return $this->email;
    }

    public function setEmail($mail) {
        $this->email = $mail;
    }

    public function getPassword() {
        return $this->password;
    }

    public function setPassword($password) {
        $this->password = $password;
    }

    public function getTrustLevel() {
        return $this->trust_level;
    }

    public function setTrustLevel($trust_level) {
        $this->trust_level = $trust_level;
    }

}

?>

<?php
/**
 * User class extends Record class
 *
 * This class represents user.
 *
 * @author Pirhoo <pierre@owni.fr>
 * @version 1.0
 * @package Record
 * @subpackage User
 */
class User extends Record{

    private $email;
    private $password;
    private $trust_level;
    private $pending;
    private $confirmationCode;

    public function getId() {
        return $this->id;
    }

    public function setId($id) {
        $this->id = $id;
    }

    public function getEmail() {
        return $this->email;
    }

    public function setEmail($mail) {
        $this->email = $mail;
    }

    public function getPassword() {
        return $this->password;
    }

    public function setPassword($password) {
        $this->password = $password;
    }

    public function getTrustLevel() {
        return $this->trust_level;
    }

    public function setTrustLevel($trust_level) {
        $this->trust_level = $trust_level;
    }

    public function getPending() {
        return $this->pending;
    }

    public function setPending($pending) {
        $this->pending = $pending;
    }

    public function getConfirmationCode() {
        return $this->confirmationCode;
    }

    public function setConfirmationCode($confirmationCode) {
        $this->confirmationCode = $confirmationCode;
    }

}

?>

Add pending getter and setter

Add pending getter and setter


<?php
/**
 * Copyright (c) 2011 Marvin Thomas Rabe <mrabe@marvinrabe.de>
 * Copyright (c) 2011 Arthur Schiwon <blizzz@arthur-schiwon.de>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
?>
<input type="hidden" id="bookmarkFilterTag" value="<?php if(isset($_GET['tag'])) echo htmlentities($_GET['tag']); ?>" />

	<input type="hidden" id="bookmark_add_id" value="0" />
	<input type="text" id="bookmark_add_url" placeholder="<?php echo $l->t('Address'); ?>" class="bookmarks_input" />
	<input type="text" id="bookmark_add_title" placeholder="<?php echo $l->t('Title'); ?>" class="bookmarks_input" />
	<input type="text" id="bookmark_add_tags" placeholder="<?php echo $l->t('Tags'); ?>" class="bookmarks_input" />
	<input type="submit" value="<?php echo $l->t('Add bookmark'); ?>" id="bookmark_add_submit" />

	<?php
		echo $l->t('You have no bookmarks');
		require_once(OC::$APPSROOT . '/apps/bookmarks/templates/bookmarklet.php');
		createBookmarklet();
	?>

<?php
/**
 * Copyright (c) 2011 Marvin Thomas Rabe <mrabe@marvinrabe.de>
 * Copyright (c) 2011 Arthur Schiwon <blizzz@arthur-schiwon.de>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
?>
<input type="hidden" id="bookmarkFilterTag" value="<?php if(isset($_GET['tag'])) echo htmlentities($_GET['tag']); ?>" />

	<input type="hidden" id="bookmark_add_id" value="0" />
	<input type="text" id="bookmark_add_url" placeholder="<?php echo $l->t('Address'); ?>" class="bookmarks_input" />
	<input type="text" id="bookmark_add_title" placeholder="<?php echo $l->t('Title'); ?>" class="bookmarks_input" />
	<input type="text" id="bookmark_add_tags" placeholder="<?php echo $l->t('Tags'); ?>" class="bookmarks_input" />
	<input type="submit" value="<?php echo $l->t('Save bookmark'); ?>" id="bookmark_add_submit" />

	<?php
		echo $l->t('You have no bookmarks');
		require_once(OC::$APPSROOT . '/apps/bookmarks/templates/bookmarklet.php');
		createBookmarklet();
	?>

Change label for saving bookmark button

Change label for saving bookmark button


<?php

use Illuminate\Database\Seeder;
use REBELinBLUE\Deployer\SharedFile;

class SharedFileTableSeeder extends Seeder
{
    public function run()
    {
        DB::table('shared_files')->delete();

        SharedFile::create([
            'name'        => 'Storage',
            'file'        => 'storage/',
            'target_type' => 'project',
            'target_id'   => 1,
        ]);

        SharedFile::create([
            'name'        => 'README',
            'file'        => 'README.md',
            'target_type' => 'project',
            'target_id'   => 1,
        ]);

        SharedFile::create([
            'name'        => 'LICENSE',
            'file'        => '/LICENSE.md',
            'target_type' => 'project',
            'target_id'   => 1,
        ]);

        SharedFile::create([
            'name'        => 'CSS',
            'file'        => 'resources/assets/css/console.css',
            'target_type' => 'project',
            'target_id'   => 1,
        ]);
    }
}

<?php

use Illuminate\Database\Seeder;
use REBELinBLUE\Deployer\SharedFile;

class SharedFileTableSeeder extends Seeder
{
    public function run()
    {
        DB::table('shared_files')->delete();

        SharedFile::create([
            'name'        => 'Storage',
            'file'        => 'storage/',
            'target_type' => 'project',
            'target_id'   => 1,
        ]);

        SharedFile::create([
            'name'        => 'README',
            'file'        => 'README.md',
            'target_type' => 'project',
            'target_id'   => 1,
        ]);

        SharedFile::create([
            'name'        => 'LICENSE',
            'file'        => '/LICENSE.md',
            'target_type' => 'project',
            'target_id'   => 1,
        ]);

//        SharedFile::create([
//            'name'        => 'CSS',
//            'file'        => 'resources/assets/css/console.css',
//            'target_type' => 'project',
//            'target_id'   => 1,
//        ]);
    }
}

Remove file from SharedFileTable seed

Remove file from SharedFileTable seed


<!DOCTYPE html>
<html <?php language_attributes(); ?> class="no-js no-svg">

    <meta charset="<?php bloginfo('charset'); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="profile" href="http://gmpg.org/xfn/11">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <?php wp_head(); ?>

  <body <?php body_class(); ?>>

      <div class="<?php
      if (is_home()) : echo 'container';
      else : echo 'container-fluid';
      endif;
      ?>">

              <?php get_template_part('templates/header/logo'); ?>

              <?php get_template_part('templates/navigation/main', 'menu'); ?>

    <?php
    if (is_home()):
      get_template_part('templates/header/hero');
    endif;

<!DOCTYPE html>
<html <?php language_attributes(); ?> class="no-js no-svg">

        <meta charset="<?php bloginfo('charset'); ?>">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="profile" href="http://gmpg.org/xfn/11">
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <?php wp_head(); ?>

    <body <?php body_class(); ?>>

            <div class="<?php
            if (is_home()) : echo 'container';
            else : echo 'container-fluid';
            endif;
            ?>">

                            <?php get_template_part(SNIPPETS_DIR . '/header/logo'); ?>

                            <?php get_template_part(SNIPPETS_DIR . '/navigation/main', 'menu'); ?>

        <?php get_template_part(SNIPPETS_DIR . '/navigation/breadcrumb'); ?>
        <?php
        if (is_home()):
            get_template_part(SNIPPETS_DIR . '/header/hero');
    endif;

Include template snippets and retab code


<?php
/**
 *
 * @param array &$hookinfo  hookinfo
 */
function consentSimpleAdmin_hook_sanitycheck(&$hookinfo) {
	assert('is_array($hookinfo)');
	assert('array_key_exists("errors", $hookinfo)');
	assert('array_key_exists("info", $hookinfo)');

	try {
		$consentconfig = SimpleSAML_Configuration::getConfig('module_consentSimpleAdmin.php');

		// Parse consent config
		$consent_storage = sspmod_consent_Store::parseStoreConfig($consentconfig->getValue('store'));

		// Get all consents for user
		$stats = $consent_storage->getStatistics();

		$hookinfo['info'][] = '[consentSimpleAdmin] Consent Storage connection OK.';

	} catch (Exception $e) {
		$hookinfo['errors'][] = '[consentSimpleAdmin] Error connecting to storage: ' . $e->getMessage();
	}

}
?>

<?php
/**
 *
 * @param array &$hookinfo  hookinfo
 */
function consentSimpleAdmin_hook_sanitycheck(&$hookinfo) {
	assert('is_array($hookinfo)');
	assert('array_key_exists("errors", $hookinfo)');
	assert('array_key_exists("info", $hookinfo)');

	try {
		$consentconfig = SimpleSAML_Configuration::getConfig('module_consentSimpleAdmin.php');

		// Parse consent config
		$consent_storage = sspmod_consent_Store::parseStoreConfig($consentconfig->getValue('store'));

		if (!is_callable(array($consent_storage, 'selftest'))) {
			/* Doesn't support a selftest. */
			return;
		}
		$testres = $consent_storage->selftest();
		if ($testres) {
			$hookinfo['info'][] = '[consentSimpleAdmin] Consent Storage selftest OK.';
		} else {
			$hookinfo['errors'][] = '[consentSimpleAdmin] Consent Storage selftest failed.';
		}

	} catch (Exception $e) {
		$hookinfo['errors'][] = '[consentSimpleAdmin] Error connecting to storage: ' . $e->getMessage();
	}

}
?>

consentSimpleAdmin: Use new selftest-function on database backend.

git-svn-id: a243b28a2a52d65555a829a95c8c333076d39ae1@3309 44740490-163a-0410-bde0-09ae8108e29a


    Tags

     $filter]) }}"
        class="group flex items-center px-3 py-2 text-sm font-medium text-gray-600 hover:bg-white {{ (! isset($activeTag) ? 'bg-white text-lio-500 border-lio-500 border-l-2' : '') }}"
    >

            All

    @foreach ($tags as $tag)
        slug(), 'filter' => $filter]) }}"
            class="group flex items-center px-3 py-2 text-sm font-medium text-gray-600 hover:bg-white {{ (isset($activeTag) && $activeTag->id() === $tag->id() ? 'bg-white text-lio-500 border-lio-500 border-l-2' : '') }}"
        >

                {{ $tag->name() }}

    @endforeach

    Tags

     $filter]) }}"
        class="group flex items-center px-2 py-1 text-sm font-medium text-gray-600 hover:bg-white {{ (! isset($activeTag) ? 'bg-white text-lio-500 border-lio-500 border-l-2' : '') }}"
    >

            All

    @foreach ($tags as $tag)
        slug(), 'filter' => $filter]) }}"
            class="group flex items-center px-2 py-1 text-sm font-medium text-gray-600 hover:bg-white {{ (isset($activeTag) && $activeTag->id() === $tag->id() ? 'bg-white text-lio-500 border-lio-500 border-l-2' : '') }}"
        >

                {{ $tag->name() }}

    @endforeach

Reduce sizes of tags sidebar

Reduce sizes of tags sidebar


<?php

return array(

    'table'    => '',

    'instance' => function()
    {
        return App::make('Algorit\Synchronizer\Storage\SyncInterface');
    },

    'create'   => function($system, $resource, $entity, $type)
    {
        $company_id 	   = null;
        $representative_id = null;

        // Not the best code in the world.
        $class = explode('\\', get_class($this->resource));

        switch(end($class))
        {
            case 'Erp':
                $erp_id = $resource->id;
            break;
            case 'Company':
                $company_id = $resource->id;
                $erp_id 	= $resource->erp->id;
            break;
            case 'Representative':
                $representative_id = $resource->id;
                $company_id 	   = $resource->company->id;
                $erp_id 		   = $resource->company->erp->id;
            break;
        }

        return array(
            'erp_id' 			=> $erp_id,
            'company_id' 		=> $company_id,
            'representative_id' => $representative_id,
            'entity' 			=> $entity,
            'type' 				=> $type,
            'class' 			=> get_class($system),
            'status' 			=> 'processing',
        );
    },
);

<?php

return array(

    'table'    => '',

    'instance' => 'Algorit\Synchronizer\Storage\SyncInterface',

    'create'   => function($system, $resource, $entity, $type)
    {
        $company_id 	   = null;
        $representative_id = null;

        // Not the best code in the world.
        $class = explode('\\', get_class($this->resource));

        switch(end($class))
        {
            case 'Erp':
                $erp_id = $resource->id;
            break;
            case 'Company':
                $company_id = $resource->id;
                $erp_id 	= $resource->erp->id;
            break;
            case 'Representative':
                $representative_id = $resource->id;
                $company_id 	   = $resource->company->id;
                $erp_id 		   = $resource->company->erp->id;
            break;
        }

        return array(
            'erp_id' 			=> $erp_id,
            'company_id' 		=> $company_id,
            'representative_id' => $representative_id,
            'entity' 			=> $entity,
            'type' 				=> $type,
            'class' 			=> get_class($system),
            'status' 			=> 'processing',
        );
    },
);

Remove instance config from closure

Remove instance config from closure


<?php

class DataTypeTest extends PHPUnit_Framework_TestCase {

	public function testAutoload() {
		$this->assertInstanceOf('DataType', new DataType);
	}

	public function testImportDataType() {
		$xml = new SimpleXMLElement('
			<DataType dtName="Test" dtHandle="test"/>
		');
		$DataType = new DataType;
		$dataType = $DataType->import($xml);
		$this->assertNotEmpty('dtID', $dataType);
		$this->assertEquals('Test', $dataType->dtName);
		$this->assertEquals('test', $dataType->dtHandle);
	}

	public function testImportDataTypeIncorrectElementName() {
		$xml = new SimpleXMLElement('
			<Data dtName="Test" dtHandle="test"/>
		');
		$DataType = new DataType;
		$dataType = new $DataType;
		$this->setExpectedException('DataTypeException');
		$dataType->import($xml);
	}
}

<?php

class DataTypeTest extends PHPUnit_Framework_TestCase {

	public function testAutoload() {
		$this->assertInstanceOf('DataType', new DataType);
	}

	public function testImportDataType() {
		$xml = new SimpleXMLElement('
			<DataType dtName="Test" dtHandle="test"/>
		');
		$DataType = new DataType;
		$dataType = $DataType->import($xml);
		$this->assertNotEmpty('dtID', $dataType);
		$this->assertEquals('Test', $dataType->dtName);
		$this->assertEquals('test', $dataType->dtHandle);
	}

	public function testImportDataTypeIncorrectElementName() {
		$xml = new SimpleXMLElement('
			<Data dtName="Test" dtHandle="test"/>
		');
		$DataType = new DataType;
		$this->setExpectedException('DataTypeException');
		$DataType->import($xml);
	}
}

Fix type in DataType test

Fix type in DataType test


<?php

namespace Rogue\Http\Requests;

class SignupRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'northstar_id' => 'required|string',
            'campaign_id' => 'required|int',
            'campaign_run_id' => 'required|int',
            'quantity' => 'int',
            'why_participated' => 'string',
            'source' => 'string',
        ];
    }
}

<?php

namespace Rogue\Http\Requests;

class SignupRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'northstar_id' => 'required|string',
            'campaign_id' => 'required|int',
            'campaign_run_id' => 'required|int',
            'quantity' => 'int',
            'why_participated' => 'string',
            'source' => 'string|nullable',
        ];
    }
}

Allow null values to be provided for source.


<?php

require_once __DIR__.'/config.php';

// uMailPHP's configuration.
\uMailPHP\Mail::configure([
  'site_name' => 'Tilmeld Example Site',
  'site_link' => 'http://localhost:8080/examples/examples/tilmeld/components.php',
  'master_address' => 'noreply@example.com',
  'testing_mode' => true,
  'testing_email' => 'hperrin@localhost',
]);

// Tilmeld's configuration.
$tilmeldConfig = [
  'app_url' => 'http://localhost:8080/',
  'setup_url' => 'http://localhost:8080/examples/examples/tilmeld/setup.php',
  'email_usernames' => true,
  'verify_redirect' => 'http://localhost:8080/examples/examples/tilmeld/components.php',
];
if (getenv('TILMELD_SECRET_FILE')) {
  $tilmeldConfig['jwt_secret'] = base64_decode(
      file_get_contents(getenv('TILMELD_SECRET_FILE'))
  );
} else {
  $tilmeldConfig['jwt_secret'] = str_repeat('a', 256);
}
\Tilmeld\Tilmeld::configure($tilmeldConfig);

<?php

require_once __DIR__.'/config.php';

$site = 'http://localhost:8080';
if (getenv('NYMPH_PRODUCTION')) {
  $site = 'https://nymph-demo.herokuapp.com';
}

// uMailPHP's configuration.
\uMailPHP\Mail::configure([
  'site_name' => 'Tilmeld Example Site',
  'site_link' => "$site/examples/examples/tilmeld/components.php",
  'master_address' => 'noreply@example.com',
  'testing_mode' => true,
  'testing_email' => 'hperrin@localhost',
]);

// Tilmeld's configuration.
$tilmeldConfig = [
  'app_url' => "$site/",
  'setup_url' => "$site/examples/examples/tilmeld/setup.php",
  'email_usernames' => true,
  'verify_redirect' => "$site/examples/examples/tilmeld/components.php",
];
if (getenv('TILMELD_SECRET_FILE')) {
  $tilmeldConfig['jwt_secret'] = base64_decode(
      file_get_contents(getenv('TILMELD_SECRET_FILE'))
  );
} else {
  $tilmeldConfig['jwt_secret'] = str_repeat('a', 256);
}
\Tilmeld\Tilmeld::configure($tilmeldConfig);

Set host correctly in production.

Set host correctly in production.


<?php

// Files that are needed that aren't classes, as well as basic initialization
// Core requirements
define('IN_SCRIPT', 1);
define('HESK_PATH', '../');
require_once(__DIR__ . '/vendor/autoload.php');
require_once(__DIR__ . '/bootstrap.php');
require_once(__DIR__ . '/../hesk_settings.inc.php');
require_once(__DIR__ . '/../inc/common.inc.php');
require_once(__DIR__ . '/Core/output.php');
require_once(__DIR__ . '/../hesk_settings.inc.php');
require_once(__DIR__ . '/http_response_code.php');
require_once(__DIR__ . '/../inc/admin_functions.inc.php');

hesk_load_api_database_functions();

global $hesk_settings;

// HESK files that require database access
require_once(__DIR__ . '/../inc/custom_fields.inc.php');

// Load the ApplicationContext
$builder = new \DI\ContainerBuilder();

$applicationContext = $builder->build();

// Fix for getallheaders() on PHP-FPM and nginx
if (!function_exists('getallheaders')) {
    function getallheaders() {
        $headers = [];
        foreach ($_SERVER as $name => $value) {
            if (substr($name, 0, 5) == 'HTTP_') {
                $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
            }
        }
        return $headers;
    }
}

<?php

// Files that are needed that aren't classes, as well as basic initialization
// Core requirements
define('IN_SCRIPT', 1);
define('HESK_PATH', '../');
require_once(__DIR__ . '/vendor/autoload.php');
require_once(__DIR__ . '/bootstrap.php');
require_once(__DIR__ . '/../hesk_settings.inc.php');
require_once(__DIR__ . '/../inc/common.inc.php');
require_once(__DIR__ . '/Core/output.php');
require_once(__DIR__ . '/../hesk_settings.inc.php');
require_once(__DIR__ . '/http_response_code.php');
require_once(__DIR__ . '/../inc/admin_functions.inc.php');

hesk_load_api_database_functions();

global $hesk_settings;

// HESK files that require database access
require_once(__DIR__ . '/../inc/custom_fields.inc.php');

// Load the ApplicationContext
$builder = new \DI\ContainerBuilder();

$applicationContext = $builder->build();

// Fix for getallheaders() on PHP-FPM and nginx
if (!function_exists('getallheaders')) {
    function getallheaders() {
        $headers = array();
        foreach ($_SERVER as $name => $value) {
            if (substr($name, 0, 5) == 'HTTP_') {
                $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
            }
        }
        return $headers;
    }
}

Fix issue in PHP 5.3

Fix issue in PHP 5.3


<?php

/*
 * This file is part of Slim JSON Web Token Authentication middleware
 *
 * Copyright (c) 2015 Mika Tuupola
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Project home:
 *   https://github.com/tuupola/slim-jwt-auth
 *
 */

namespace Slim\Middleware\JwtAuthentication;

use \Psr\Http\Message\RequestInterface;

class RequestPathRule implements RuleInterface
{
    protected $options = array(
        "path" => "/",
        "passthrough" => array()
    );

    public function __construct($options = array())
    {
        $this->options = array_merge($this->options, $options);
    }

    public function __invoke(RequestInterface $request)
    {
        /* If request path is matches passthrough should not authenticate. */
        foreach ($this->options["passthrough"] as $passthrough) {
            $passthrough = rtrim($passthrough, "/");
            if (!!preg_match("@^{$passthrough}(/.*)?$@", $app->request->getResourceUri())) {
                return false;
            }
        }

        /* Otherwise check if path matches and we should authenticate. */
        $path = rtrim($this->options["path"], "/");
        return !!preg_match("@^{$path}(/.*)?$@", $app->request->getResourceUri());
    }
}

<?php

/*
 * This file is part of Slim JSON Web Token Authentication middleware
 *
 * Copyright (c) 2015 Mika Tuupola
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Project home:
 *   https://github.com/tuupola/slim-jwt-auth
 *
 */

namespace Slim\Middleware\JwtAuthentication;

use \Psr\Http\Message\RequestInterface;

class RequestPathRule implements RuleInterface
{
    protected $options = array(
        "path" => "/",
        "passthrough" => array()
    );

    public function __construct($options = array())
    {
        $this->options = array_merge($this->options, $options);
    }

    public function __invoke(RequestInterface $request)
    {
        /* If request path is matches passthrough should not authenticate. */
        foreach ($this->options["passthrough"] as $passthrough) {
            $passthrough = rtrim($passthrough, "/");
            if (!!preg_match("@^{$passthrough}(/.*)?$@", $request->getUri()->getPath())) {
                return false;
            }
        }

        /* Otherwise check if path matches and we should authenticate. */
        $path = rtrim($this->options["path"], "/");
        return !!preg_match("@^{$path}(/.*)?$@", $request->getUri()->getPath());
    }
}

Use PSR-7 way of accessing uri

Use PSR-7 way of accessing uri


    <li<?php if(isset($site_page) && $site_page=='profile') :?> class="active"<?php endif; ?>>My profile

    <li<?php if(isset($site_page) && $site_page=='more-me') :?> class="active"<?php endif; ?>>Find me online

    <li<?php if(isset($site_page) && $site_page=='writings') :?> class="active"<?php endif; ?>>Things I've written

    <li<?php if(isset($site_page) && $site_page=='contact') :?> class="active"<?php endif; ?>>Contact me

    <li<?php if(isset($site_page) && $site_page=='profile') :?> class="active"<?php endif; ?>>My profile

    <li<?php if(isset($site_page) && $site_page=='contact') :?> class="active"<?php endif; ?>>Contact me

Remove unused pages from menu bar

Remove unused pages from menu bar


<?php
namespace DMS\Bundle\TwigExtensionBundle\Twig\Text;

/**
 * Adds support for Padding a String in Twig
 */
class PadStringExtension extends \Twig_Extension
{
    /**
     * Name of Extension
     *
     * @return string
     */
    public function getName()
    {
        return 'PadStringExtension';
    }

    /**
     * Available filters
     *
     * @return array
     */
    public function getFilters()
    {
        return array(
            'padString' => new \Twig_Filter_Method($this, 'padStringFilter'),
        );
    }

    /**
     * Pads string on right or left with given padCharacter until string
     * reaches maxLength
     *
     * @param string  $value
     * @param string  $padCharacter
     * @param int     $maxLength
     * @param string  $padType
     *
     * @return string
     * @throws \InvalidArgumentException
     */
    public function padStringFilter($value, $padCharacter, $maxLength, $padType = 'STR_PAD_RIGHT')
    {
        if ( ! is_int($maxLength)) {
            throw new \InvalidArgumentException('Pad String Filter expects its second argument to be an integer');
        }
        $diff = strlen($value) - mb_strlen($value);
        $padType = constant($padType);

        return str_pad($value, $maxLength + $diff, $padCharacter, $padType);
    }
}

<?php
namespace DMS\Bundle\TwigExtensionBundle\Twig\Text;

/**
 * Adds support for Padding a String in Twig
 */
class PadStringExtension extends \Twig_Extension
{
    /**
     * Name of Extension
     *
     * @return string
     */
    public function getName()
    {
        return 'PadStringExtension';
    }

    /**
     * Available filters
     *
     * @return array
     */
    public function getFilters()
    {
        return array(
            'padString' => new \Twig_Filter_Method($this, 'padStringFilter'),
        );
    }

    /**
     * Pads string on right or left with given padCharacter until string
     * reaches maxLength
     *
     * @param string  $value
     * @param string  $padCharacter
     * @param int     $maxLength
     * @param string  $padType
     *
     * @return string
     * @throws \InvalidArgumentException
     */
    public function padStringFilter($value, $padCharacter, $maxLength, $padType = 'STR_PAD_RIGHT')
    {
        if ($this->isNullOrEmptyString($padCharacter)) {
            throw new \InvalidArgumentException('Pad String Filter cannot accept a null value or empty string as its first argument');
        }
        if ( ! is_int($maxLength)) {
            throw new \InvalidArgumentException('Pad String Filter expects its second argument to be an integer');
        }
        $diff = strlen($value) - mb_strlen($value);
        $padType = constant($padType);

        return str_pad($value, $maxLength + $diff, $padCharacter, $padType);
    }

    /**
     * Make sure a padCharacter is provided
     *
     * @param $padCharacter
     * @return bool
     */
    protected function isNullOrEmptyString($padCharacter){
        return (!isset($padCharacter) || trim($padCharacter)==='' || is_null($padCharacter));
    }
}

Add method to check that padCharacter is not empty or null


<?php

use Sami\Sami;
use Sami\Version\GitVersionCollection;
use Symfony\Component\Finder\Finder;

$iterator = Finder::create()
    ->files()
    ->name('*.php')
    ->exclude('Resources')
    ->in($dir = 'src');

$versions = GitVersionCollection::create($dir)
    ->add('develop', 'develop branch')
    ->add('master', 'master branch')
    ->addFromTags('*');

return new Sami($iterator, array(
    'theme' => 'enhanced',
    'versions' => $versions,
    'title' => 'AuthBucket\Bundle\OAuth2Bundle API',
    'build_dir' => __DIR__ . '/build/sami/%version%',
    'cache_dir' => __DIR__ . '/build/cache/sami/%version%',
    'include_parent_data' => false,
    'default_opened_level' => 3,
));

<?php

use Sami\Sami;
use Sami\Version\GitVersionCollection;
use Symfony\Component\Finder\Finder;

$iterator = Finder::create()
    ->files()
    ->name('*.php')
    ->exclude('Resources')
    ->in($dir = 'src');

$versions = GitVersionCollection::create($dir)
    ->add('develop', 'develop branch')
    ->add('master', 'master branch')
    ->addFromTags('*');

return new Sami($iterator, array(
    'theme' => 'default',
    'versions' => $versions,
    'title' => 'AuthBucket\Bundle\OAuth2Bundle API',
    'build_dir' => __DIR__ . '/build/sami/%version%',
    'cache_dir' => __DIR__ . '/build/cache/sami/%version%',
    'include_parent_data' => false,
    'default_opened_level' => 3,
));

Update Sami theme as default.

Update Sami theme as default.


<?php
  include_once("../includes/start.php");
  $title = 'Photo Uploader';
  $tpl->set('title', $title);
  $tpl->set('js', 'uploader.js');

  $tpl->set('previous', false, true);

  if (isset($_GET['previous'])) {
    $previous = array();

    $query = "SELECT `Filename`, `DateUploaded` FROM `photo_processing` ";
    $query .= "WHERE `Uploader` = '$username' ORDER BY `DateUploaded` ASC";
    $result = do_query($query);

    while ($row = fetch_row($result)) {
      $previous[] = array("filename" => $row['Filename'], "date" => howLong($row['DateUploaded']));
    }

    $tpl->set('oldFiles', $previous, true);
    $tpl->set('previous', true, true);
  } else {
    $tpl->set('warning', "This is a friendly reminder: upload all of the photos you have (including terrible photos), or Sam will hunt you down and take them from you.
Alternatively, just give Sam your memory card and he will copy them over manually.");
  }

  fetch();
?>

<?php
  include_once("../includes/start.php");
  $title = 'Photo Uploader';
  $tpl->set('title', $title);
  $tpl->set('contenttitle',
            $title . "Beta");
  $tpl->set('js', 'uploader.js');

  $tpl->set('previous', false, true);

  if (isset($_GET['previous'])) {
    $previous = array();

    $query = "SELECT `Filename`, `DateUploaded` FROM `photo_processing` ";
    $query .= "WHERE `Uploader` = '$username' ORDER BY `DateUploaded` ASC";
    $result = do_query($query);

    while ($row = fetch_row($result)) {
      $previous[] = array("filename" => $row['Filename'], "date" => howLong($row['DateUploaded']));
    }

    $tpl->set('oldFiles', $previous, true);
    $tpl->set('previous', true, true);
  } else {
    $tpl->set('warning', "This is a friendly reminder: upload all of the photos you have (including terrible photos), or Sam will hunt you down and take them from you.
Alternatively, just give Sam your memory card and he will copy them over manually.");
  }

  fetch();
?>

Set content title for photo uploader.

Set content title for photo uploader.


<?php

namespace Listabierta\Bundle\MunicipalesBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class SMSInboundController extends Controller
{
	public function indexAction(Request $request = NULL)
	{
		$query = $request->query;
		$msisdn = $query->msisdn;

		return new Response('OK', 200);
	}

	public function callbackAction(Request $request = NULL)
	{
		$query = $request->query;
		$msisdn = $query->msisdn;

		return new Response('OK', 200);
	}
}

<?php

namespace Listabierta\Bundle\MunicipalesBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class SMSInboundController extends Controller
{
	public function indexAction(Request $request = NULL)
	{
		$query = $request->query;
		//$msisdn = $query->msisdn;

		return new Response('OK', 200);
	}

	public function callbackAction(Request $request = NULL)
	{
		$query = $request->query;
		//$msisdn = $query->msisdn;

		return new Response('OK', 200);
	}
}

Comment the msisdn query data

Comment the msisdn query data


<?php
namespace Baum\Extensions\Eloquent;

use Illuminate\Database\Eloquent\Collection as BaseCollection;

class Collection extends BaseCollection {

  public function toHierarchy() {
    $dict = $this->getDictionary();

    return new BaseCollection($this->hierarchical($dict));
  }

  protected function hierarchical($result) {
    foreach($result as $key => $node)
      $node->setRelation('children', new BaseCollection);

    $nestedKeys = array();

    foreach($result as $key => $node) {
      $parentKey = $node->getParentId();

      if ( !is_null($parentKey) && array_key_exists($parentKey, $result) ) {
        $result[$parentKey]->children[] = $node;

        $nestedKeys[] = $node->getKey();
      }
    }

    foreach($nestedKeys as $key)
      unset($result[$key]);

    return $result;
  }

}

<?php
namespace Baum\Extensions\Eloquent;

use Illuminate\Database\Eloquent\Collection as BaseCollection;

class Collection extends BaseCollection {

  public function toHierarchy() {
    $dict = $this->getDictionary();

    // sort based on orderColumn
    uasort($dict, function($a, $b){
        return ($a->getOrder() >= $b->getOrder()) ? 1 : -1;
    });

    return new BaseCollection($this->hierarchical($dict));
  }

  protected function hierarchical($result) {
    foreach($result as $key => $node)
      $node->setRelation('children', new BaseCollection);

    $nestedKeys = array();

    foreach($result as $key => $node) {
      $parentKey = $node->getParentId();

      if ( !is_null($parentKey) && array_key_exists($parentKey, $result) ) {
        $result[$parentKey]->children[] = $node;

        $nestedKeys[] = $node->getKey();
      }
    }

    foreach($nestedKeys as $key)
      unset($result[$key]);

    return $result;
  }

}

Sort hierarchy tree by $orderColumn

Sort hierarchy tree by $orderColumn


<?php
/**
 * php-binary
 * A PHP library for parsing structured binary streams
 *
 * @package  php-binary
 * @author Damien Walsh <me@damow.net>
 */
namespace Binary\Exception;

/**
 * ValidatorException
 *
 * @since 1.0
 */
class ValidatorException extends \Exception
{
}

<?php
/**
 * php-binary
 * A PHP library for parsing structured binary streams
 *
 * @package  php-binary
 * @author Damien Walsh <me@damow.net>
 */
namespace Binary\Exception;

/**
 * ValidatorException
 * @todo Add expected and actual value fields.
 *
 * @since 1.0
 */
class ValidatorException extends \Exception
{
}

Add todo to expand the validation exception content.


<?php
namespace Crud\Error\Exception;

use Cake\Error\Exception;
use Cake\ORM\Entity;
use Cake\Utility\Hash;

/**
 * Exception containing validation errors from the model. Useful for API
 * responses where you need an error code in response
 *
 */
class ValidationException extends Exception {

/**
 * List of validation errors that occurred in the model
 *
 * @var array
 */
	protected $_validationErrors = [];

/**
 * How many validation errors are there?
 *
 * @var integer
 */
	protected $_validationErrorCount = 0;

/**
 * Constructor
 *
 * @param array $error list of validation errors
 * @param integer $code code to report to client
 * @return void
 */
	public function __construct(Entity $entity, $code = 412) {
		$this->_validationErrors = array_filter((array)$entity->errors());
		$flat = Hash::flatten($this->_validationErrors);

		$errorCount = $this->_validationErrorCount = count($flat);
		$this->message = __dn('crud', 'A validation error occurred', '%d validation errors occurred', $errorCount, [$errorCount]);

		parent::__construct($this->message, $code);
	}

/**
 * Returns the list of validation errors
 *
 * @return array
 */
	public function getValidationErrors() {
		return $this->_validationErrors;
	}

/**
 * How many validation errors are there?
 *
 * @return integer
 */
	public function getValidationErrorCount() {
		return $this->_validationErrorCount;
	}

}

<?php
namespace Crud\Error\Exception;

use Cake\Error\Exception;
use Cake\ORM\Entity;
use Cake\Utility\Hash;

/**
 * Exception containing validation errors from the model. Useful for API
 * responses where you need an error code in response
 *
 */
class ValidationException extends Exception {

/**
 * List of validation errors that occurred in the model
 *
 * @var array
 */
	protected $_validationErrors = [];

/**
 * How many validation errors are there?
 *
 * @var integer
 */
	protected $_validationErrorCount = 0;

/**
 * Constructor
 *
 * @param array $error list of validation errors
 * @param integer $code code to report to client
 * @return void
 */
	public function __construct(Entity $entity, $code = 412) {
		$this->_validationErrors = array_filter((array)$entity->errors());
		$flat = Hash::flatten($this->_validationErrors);

		$errorCount = $this->_validationErrorCount = count($flat);
		$this->message = __dn('crud', 'A validation error occurred', '{0} validation errors occurred', $errorCount, [$errorCount]);

		parent::__construct($this->message, $code);
	}

/**
 * Returns the list of validation errors
 *
 * @return array
 */
	public function getValidationErrors() {
		return $this->_validationErrors;
	}

/**
 * How many validation errors are there?
 *
 * @return integer
 */
	public function getValidationErrorCount() {
		return $this->_validationErrorCount;
	}

}

Update placeholder in translation string.


<?hh // strict

namespace HackPack\HackUnit\Tests\Doubles;

use HackPack\HackUnit\Contract\Assert;
use HackPack\HackUnit\Contract\Test\Suite;

type RunCounts = shape(
  'up' => int,
  'down' => int,
  'run' => int,
);

class SpySuite implements Suite {
  public RunCounts $counts = shape('up' => 0, 'down' => 0, 'run' => 0);

  public Vector<Assert> $asserts = Vector {};
  public Vector<(function(): void)> $passCallbacks = Vector {};
  public function __construct(
    private (function(): void) $runAction = () ==> {
    },
  ) {}

  public async function up(): Awaitable<void> {
    $this->counts['up']++;
  }

  public async function down(): Awaitable<void> {
    $this->counts['down']++;
  }

  public async function run(
    Assert $assert,
    (function(): void) $testPassed,
  ): Awaitable<void> {
    $this->asserts->add($assert);
    $this->passCallbacks->add($testPassed);
    $this->counts['run']++;
    $action = $this->runAction;
    $action();
  }

}

<?hh // strict

namespace HackPack\HackUnit\Tests\Doubles;

use HackPack\HackUnit\Contract\Assert;
use HackPack\HackUnit\Contract\Test\Suite;

type RunCounts = shape(
  'up' => int,
  'down' => int,
  'run' => int,
);

class SpySuite implements Suite {

  public RunCounts $counts = shape('up' => 0, 'down' => 0, 'run' => 0);
  public Vector<Assert> $asserts = Vector {};
  public Vector<(function(): void)> $passCallbacks = Vector {};

  private (function(): void) $runAction;

  public function __construct(
    ?(function(): void) $runAction = null,
  ) {
    $this->runAction = $runAction === null ? () ==> {} : $runAction;
  }

  public async function up(): Awaitable<void> {
    $this->counts['up']++;
  }

  public async function down(): Awaitable<void> {
    $this->counts['down']++;
  }

  public async function run(
    Assert $assert,
    (function(): void) $testPassed,
  ): Awaitable<void> {
    $this->asserts->add($assert);
    $this->passCallbacks->add($testPassed);
    $this->counts['run']++;
    $action = $this->runAction;
    $action();
  }

}

Use an easier to parse test double.

Use an easier to parse test double.

This fixes an issue that fredemmott/definition-finder has with parsing
constructor promotion callbacks.


<?php

namespace PHPCensor\Logging;

use b8\Store\Factory;
use Monolog\Handler\AbstractProcessingHandler;
use PHPCensor\Model\Build;
use Psr\Log\LogLevel;

/**
 * Class BuildDBLogHandler writes the build log to the database.
 */
class BuildDBLogHandler extends AbstractProcessingHandler
{
    /**
     * @var Build
     */
    protected $build;

    protected $logValue;

    /**
     * @param Build $build
     * @param bool $level
     * @param bool $bubble
     */
    public function __construct(
        Build $build,
        $level = LogLevel::INFO,
        $bubble = true
    ) {
        parent::__construct($level, $bubble);
        $this->build = $build;
        // We want to add to any existing saved log information.
        $this->logValue = $build->getLog();
    }

    /**
     * Write a log entry to the build log.
     * @param array $record
     */
    protected function write(array $record)
    {
        $message = (string)$record['message'];
        $message = str_replace($this->build->currentBuildPath, '/', $message);

        $this->logValue .= $message . PHP_EOL;
        $this->build->setLog($this->logValue);

        Factory::getStore('Build')->save($this->build);
    }
}

<?php

namespace PHPCensor\Logging;

use b8\Store\Factory;
use Monolog\Handler\AbstractProcessingHandler;
use PHPCensor\Model\Build;
use Psr\Log\LogLevel;

/**
 * Class BuildDBLogHandler writes the build log to the database.
 */
class BuildDBLogHandler extends AbstractProcessingHandler
{
    /**
     * @var Build
     */
    protected $build;

    protected $logValue;

    /**
     * @var int last flush timestamp
     */
    protected $flush_timestamp = 0;

    /**
     * @var int flush delay, seconds
     */
    protected $flush_delay = 1;

    /**
     * @param Build $build
     * @param bool $level
     * @param bool $bubble
     */
    public function __construct(
        Build $build,
        $level = LogLevel::INFO,
        $bubble = true
    ) {
        parent::__construct($level, $bubble);
        $this->build = $build;
        // We want to add to any existing saved log information.
        $this->logValue = $build->getLog();
    }

    /**
     * Destructor
     */
    public function __destruct()
    {
        $this->flushData();
    }

    /**
     * Flush buffered data
     */
    protected function flushData()
    {
        $this->build->setLog($this->logValue);
        Factory::getStore('Build')->save($this->build);
        $this->flush_timestamp = time();
    }

    /**
     * Write a log entry to the build log.
     * @param array $record
     */
    protected function write(array $record)
    {
        $message = (string)$record['message'];
        $message = str_replace($this->build->currentBuildPath, '/', $message);

        $this->logValue .= $message . PHP_EOL;

        if ($this->flush_timestamp < (time() - $this->flush_delay)) {
            $this->flushData();
        }
    }
}

Add write cache to build log (improve speed)


<?php
/* Development */
define('DB_NAME', getenv('DB_NAME'));
define('DB_USER', getenv('DB_USER'));
define('DB_PASSWORD', getenv('DB_PASSWORD'));
define('DB_HOST', getenv('DB_HOST') ? getenv('DB_HOST') : 'localhost');

define('WP_HOME', getenv('WP_HOME'));
define('WP_SITEURL', getenv('WP_SITEURL'));

define('SAVEQUERIES', true);
define('WP_DEBUG', true);
define('SCRIPT_DEBUG', true);

ini_set('display_errors','1');
ini_set('display_startup_errors','1');
error_reporting (E_ALL);include('index.php');

Revert "extra dev error logging"

Revert "extra dev error logging"

This reverts commit 57072be8905a19a8f7ea486006380134585d88ff.


<?php

// Autoload files using Composer autoload
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../aliases.php';

// Create application
$config_path = realpath('config/config.xml');
$app = \Arch\App::Instance($config_path);

// Add default route
$app->addRoute('/', function () use ($app) {
    $app->output->setContent('Hello Architect!');
});

// Run application
$app->run();

<?php

// Autoload files using Composer autoload
require_once realpath(__DIR__ . '/../vendor/autoload.php');
require_once realpath(__DIR__ . '/../aliases.php');

// Create application
$config_path = realpath('config/config.xml');
$app = \Arch\App::Instance($config_path);

// Add default route
$app->addRoute('/', function () use ($app) {
    $app->output->setContent('Hello Architect!');
});

// Run application
$app->run();

Improve path resolution on test

Improve path resolution on test


<?php
require_once 'minim/plugins/tests/tests.php';
require_once 'minim/minim.php';

class Minim_TestCase extends TestCase
{
    function test_minim_get_plugin()
    {
        $minim = new Minim();
        $this->assertTrue($minim !== minim());

        $minim->plugin_paths = array(
            build_path(dirname(__FILE__), 'res')
        );

        $plugin =& $minim->get_plugin('dummy');
        $class = get_class($plugin);
        $this->assertTrue(($class == 'DummyPlugin'),
            "Class mismatch: $class");
    }

    function test_minim_get_unregistered_plugin()
    {
        $minim = new Minim();
        try
        {
            $minim->get_plugin('not_registered');
        }
        catch (Minim_Exception $me)
        {
            // test passes
            return;
        }
        catch (Exception $e)
        {
            $this->fail('Caught unexpected exception: '.$e->getMessage());
        }
        $this->fail('Expected Minim_Exception');
    }

    function test_minim_get_null_plugin()
    {
        $minim = new Minim();
        try
        {
            $minim->get_plugin(NULL);
        }
        catch (Minim_Exception $me)
        {
            // test passes
            return;
        }
        catch (Exception $e)
        {
            $this->fail('Caught unexpected exception: '.$e);
        }
        $this->fail('Expected Minim_Exception');
    }
}

<?php
require_once 'minim/plugins/tests/tests.php';
require_once 'minim/minim.php';

class Minim_TestCase extends TestCase
{
    function test_minim_get_plugin()
    {
        $minim = new Minim();
        $this->assertTrue($minim !== minim());

        $minim->plugin_paths = array(
            path(dirname(__FILE__), 'res')
        );

        $plugin =& $minim->get_plugin('dummy');
        $class = get_class($plugin);
        $this->assertTrue(($class == 'DummyPlugin'),
            "Class mismatch: $class");
    }

    function test_minim_get_unregistered_plugin()
    {
        $minim = new Minim();
        try
        {
            $minim->get_plugin('not_registered');
        }
        catch (Minim_Exception $me)
        {
            // test passes
            return;
        }
        catch (Exception $e)
        {
            $this->fail('Caught unexpected exception: '.$e->getMessage());
        }
        $this->fail('Expected Minim_Exception');
    }

    function test_minim_get_null_plugin()
    {
        $minim = new Minim();
        try
        {
            $minim->get_plugin(NULL);
        }
        catch (Minim_Exception $me)
        {
            // test passes
            return;
        }
        catch (Exception $e)
        {
            $this->fail('Caught unexpected exception: '.$e);
        }
        $this->fail('Expected Minim_Exception');
    }
}

Update tests to use refactored path()

Update tests to use refactored path()


<?php

namespace PhpParser\Node\Expr;

use PhpParser\Node\Expr;

/**
 * @property Expr $var  Variable reference is assigned to
 * @property Expr $expr Variable which is referenced
 */
class AssignRef extends Expr
{
    /** @var Expr Variable reference is assigned to */
    public $var;
    /** @var Expr Variable which is referenced */
    public $expr;

    /**
     * Constructs an assignment node.
     *
     * @param Expr  $var        Variable
     * @param Expr  $expr       Expression
     * @param array $attributes Additional attributes
     */
    public function __construct(Expr $var, Expr $expr, array $attributes = array()) {
        parent::__construct($attributes);
        $this->var = $var;
        $this->expr = $expr;
    }

    public function getSubNodeNames() {
        return array('var', 'expr');
    }
}

<?php

namespace PhpParser\Node\Expr;

use PhpParser\Node\Expr;

class AssignRef extends Expr
{
    /** @var Expr Variable reference is assigned to */
    public $var;
    /** @var Expr Variable which is referenced */
    public $expr;

    /**
     * Constructs an assignment node.
     *
     * @param Expr  $var        Variable
     * @param Expr  $expr       Expression
     * @param array $attributes Additional attributes
     */
    public function __construct(Expr $var, Expr $expr, array $attributes = array()) {
        parent::__construct($attributes);
        $this->var = $var;
        $this->expr = $expr;
    }

    public function getSubNodeNames() {
        return array('var', 'expr');
    }
}

Remove some more unecessary @property doc comments


<?php

namespace Radebatz\Assetic\Tests;

use Assetic\Asset\AssetCollection;
use Assetic\Cache\ArrayCache;
use Radebatz\Assetic\Factory\Worker\CacheWorker;
use Radebatz\Assetic\Factory\Worker\PreprocessorWorker;

/**
 * Test CacheWorker.
 */
class CacheWorkerTest extends AsseticTestCase
{

    /**
     */
    public function testBasic()
    {
        $cacheWorker = new CacheWorker($cache = new ArrayCache());
        $factory = $this->getFactory($defaultRoot = __DIR__.'/assets', [$cacheWorker]);

        $asset = $factory->createAsset('core/js/require.js');
        $this->assertTrue($asset instanceof AssetCollection);
        // no preprocessor...
        $this->assertAssetSources(['core/js/require.js'], $asset);

        // force caching it...
        $asset->load();

        // check cache is not empty
        $rc = new \ReflectionClass($cache);
        $rp = $rc->getProperty('cache');
        $rp->setAccessible(true);
        $this->assertEquals(1, count($rp->getValue($cache)));
    }
}

<?php

namespace Radebatz\Assetic\Tests;

use Assetic\Asset\AssetCollection;
use Assetic\Cache\FilesystemCache;
use Radebatz\Assetic\Factory\Worker\CacheWorker;
use Radebatz\Assetic\Factory\Worker\PreprocessorWorker;

/**
 * Test CacheWorker.
 */
class CacheWorkerTest extends AsseticTestCase
{

    /**
     */
    public function testBasic()
    {
        $cacheDir = __DIR__.'/cache';
        @mkdir($cacheDir, 0777);
        $cacheWorker = new CacheWorker($cache = new FilesystemCache($cacheDir));
        $factory = $this->getFactory($defaultRoot = __DIR__.'/assets', [$cacheWorker]);

        $asset = $factory->createAsset('core/js/require.js');
        $this->assertTrue($asset instanceof AssetCollection);
        // no preprocessor...
        $this->assertAssetSources(['core/js/require.js'], $asset);

        // force caching it...
        $asset->load();

        // check cache is not empty
        $cacheFiles = glob($cacheDir.'/*');
        $this->assertEquals(1, count ($cacheFiles));

        $this->assertEquals(file_get_contents(array_pop($cacheFiles)), file_get_contents(__DIR__.'/assets/core/js/require.js'));
    }
}

Update test and make work

Update test and make work


<?php
/**
 * Default entry title template.
 *
 * @package BLR\Base_Theme\Templates
 */

use BLR\Base_Theme\Titles;
?>

<?php if ( is_singular() ) : ?>

		<?php echo esc_html( Titles\title() ); ?>

<?php else : ?>

		<a class="entry__permalink" href="<?php the_permalink(); ?>">
			<?php echo esc_html( Titles\title() ); ?>

<?php endif; ?>

<?php
/**
 * Default entry title template.
 *
 * @package BLR\Base_Theme\Templates
 */
?>

<?php if ( is_singular() ) : ?>

		<?php the_title(); ?>

<?php else : ?>

		<a class="entry__permalink" href="<?php the_permalink(); ?>">
			<?php the_title(); ?>

<?php endif; ?>

Use `the_title()` instead of `Titles\title()` for entry titles


<?php
/**
 * Copyright (c) 2013 Georg Ehrke georg@ownCloud.com
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkAdminUser();
OCP\JSON::callCheck();

if (!array_key_exists('appid', $_POST)) {
	OCP\JSON::error(array(
		'message' => 'No AppId given!'
	));
	exit;
}

$appId = $_POST['appid'];

if (!is_numeric($appId)) {
	$appId = OC_Appconfig::getValue($appId, 'ocsid', null);
	$isShipped = OC_App::isShipped($appId);

	if ($appId === null) {
		OCP\JSON::error(array(
			'message' => 'No OCS-ID found for app!'
		));
		exit;
	}
} else {
	$isShipped = false;
}

$appId = OC_App::cleanAppId($appId);

$result = OC_Installer::updateAppByOCSId($appId, $isShipped);
if($result !== false) {
	OC_JSON::success(array('data' => array('appid' => $appId)));
} else {
	$l = OC_L10N::get('settings');
	OC_JSON::error(array("data" => array( "message" => $l->t("Couldn't update app.") )));
}

<?php
/**
 * Copyright (c) 2013 Georg Ehrke georg@ownCloud.com
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkAdminUser();
OCP\JSON::callCheck();

if (!array_key_exists('appid', $_POST)) {
	OCP\JSON::error(array(
		'message' => 'No AppId given!'
	));
	exit;
}

$appId = $_POST['appid'];

if (!is_numeric($appId)) {
	$appId = OC_Appconfig::getValue($appId, 'ocsid', null);
	$isShipped = OC_App::isShipped($appId);

	if ($appId === null) {
		OCP\JSON::error(array(
			'message' => 'No OCS-ID found for app!'
		));
		exit;
	}
} else {
	$isShipped = false;
}

$appId = OC_App::cleanAppId($appId);

\OC_Config::setValue('maintenance', true);
$result = OC_Installer::updateAppByOCSId($appId, $isShipped);
\OC_Config::setValue('maintenance', false);

if($result !== false) {
	OC_JSON::success(array('data' => array('appid' => $appId)));
} else {
	$l = OC_L10N::get('settings');
	OC_JSON::error(array("data" => array( "message" => $l->t("Couldn't update app.") )));
}

Set maintaince mode when updating an app from the app store


<?php

namespace Archibald;

use Archibald\Request;

class Api
{
	private $slashToken = SLASHCOMMAND_TOKEN;
	private $commandName = '/archie';

	public function __construct($request)
	{
		if ($request['token'] && $request['command']) {
			$token      = $request['token'];
			$command    = $request['command'];

			if ($this->isValidToken($token) && $this->isValidCommand($command)) {

				$data = array(
					'team_id'   => $request['team_id'],
					'channel'   => $request['channel_id'],
					'user_id'   => $request['user_id'],
					'user'      => $request['user_name'],
					'body'      => $request['text']
				);

				$request = new Request($data);
			}
			else {
				echo 'Invalid Token or Command';
			}
		}
		else {
			echo 'No valid API call.';
		}
	}

	private function isValidToken($token)
	{
		return $token == $this->slashToken;
	}

	private function isValidCommand($command)
	{
		return $command == $this->commandName;
	}
}

<?php

namespace Archibald;

use Archibald\Request;

class Api
{
	private $slashToken = SLASHCOMMAND_TOKEN;
	private $commandName = '/archie';

	public function __construct($request)
	{
		if ($request['token'] && $request['command']) {
			$token      = $request['token'];
			$command    = $request['command'];

			if ($this->isValidToken($token)) {
				if ($this->isValidCommand($command)) {

					$data = array(
						'team_id'   => $request['team_id'],
						'channel'   => $request['channel_id'],
						'user_id'   => $request['user_id'],
						'user'      => $request['user_name'],
						'body'      => $request['text']
					);

					$request = new Request($data);
				}
				else {
					echo 'Invalid Command';
				}
			}
			else {
				echo 'Invalid Slash Command Token. Please check your config!';
			}
		}
		else {
			echo 'No valid API call.';
		}
	}

	private function isValidToken($token)
	{
		return $token == $this->slashToken;
	}

	private function isValidCommand($command)
	{
		return $command == $this->commandName;
	}
}

Split validation checks for more precise error output


<?php

use Cake\Core\Plugin;
use Cake\Routing\Router;

Router::scope('/', fnction($routes) {

/**
 * Here, we are connecting '/' (base path) to controller called 'Pages',
 * its action called 'display', and we pass a param to select the view file
 * to use (in this case, /app/View/Pages/home.ctp)...
 */
	$routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);

/**
 * ...and connect the rest of 'Pages' controller's urls.
 */
	$routes->connect('/pages/*', ['controller', => 'pages', 'action' => 'display']);

/**
 * Connect a route for the index action of any controller.
 * And a more general catch all route for any action.
 *
 * You can remove these routes once you've connected the
 * routes you want in your application.
 */
	$routes->connect('/:controller', ['action' => 'index'], ['routeClass' => 'InflectedRoute']);
	$routes->connect('/:controller/:action/*', [], ['routeClass' => 'InflectedRoute']);

});

/**
 * Load all plugin routes.  See the Plugin documentation on
 * how to customize the loading of plugin routes.
 */
Plugin::routes();

<?php

use Cake\Core\Plugin;
use Cake\Routing\Router;

Router::scope('/', function($routes) {

/**
 * Here, we are connecting '/' (base path) to controller called 'Pages',
 * its action called 'display', and we pass a param to select the view file
 * to use (in this case, /app/View/Pages/home.ctp)...
 */
	$routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);

/**
 * ...and connect the rest of 'Pages' controller's urls.
 */
	$routes->connect('/pages/*', ['controller', => 'pages', 'action' => 'display']);

/**
 * Connect a route for the index action of any controller.
 * And a more general catch all route for any action.
 *
 * You can remove these routes once you've connected the
 * routes you want in your application.
 */
	$routes->connect('/:controller', ['action' => 'index'], ['routeClass' => 'InflectedRoute']);
	$routes->connect('/:controller/:action/*', [], ['routeClass' => 'InflectedRoute']);

});

/**
 * Load all plugin routes.  See the Plugin documentation on
 * how to customize the loading of plugin routes.
 */
Plugin::routes();

Fix typo causing fatal error.

Fix typo causing fatal error.


<?php

namespace Freshwork\Transbank\Log;

class TransbankCertificationLogger implements LoggerInterface
{
	/**
	 * The logs directory. You need write permissions on that folder.
	 * @var string
	 */
	private $log_dir;

	/**
	 * TransbankCertificationLogHandler constructor.
	 * @param string $log_dir
	 */
	public function __construct($log_dir = '')
	{
		$this->log_dir = $log_dir;
	}

	public function log($data, $level = self::LEVEL_INFO, $type = null)
	{
		if (!is_string($data)) $data = print_r($data, true);

		file_put_contents(
			$this->getLogDirectory() . $this->getLogFilname(),
			$this->getLogMessage($data, $level, $type),
			FILE_APPEND
			);
	}

	protected function getLogDirectory()
	{
		return $this->log_dir;
	}

	protected function getLogFilname()
	{
		return date('Ymd') . '.transbank.log.txt';
	}

	protected function getLogMessage($data, $level, $type)
	{
		$time = date('d/m/Y H:i:s');
		return "\n=================================\n$time - " . strtoupper($level) . " ($type):\n=================================\n$data";
	}
}

<?php

namespace Freshwork\Transbank\Log;

class TransbankCertificationLogger implements LoggerInterface
{
    /**
     * The logs directory. You need write permissions on that folder.
     * @var string
     */
    private $log_dir;

    /**
     * TransbankCertificationLogHandler constructor.
     * @param string $log_dir
     */
    public function __construct($log_dir = '')
    {
        $this->log_dir = rtrim($log_dir, '/');

        if (!is_dir($this->log_dir))
            mkdir($this->log_dir, 0775, true);
    }

    public function log($data, $level = self::LEVEL_INFO, $type = null)
    {
        if (!is_string($data)) $data = print_r($data, true);

        file_put_contents(
            $this->getLogDirectory() . '/' . $this->getLogFilname(),
            $this->getLogMessage($data, $level, $type),
            FILE_APPEND
        );
    }

    protected function getLogDirectory()
    {
        return $this->log_dir;
    }

    protected function getLogFilname()
    {
        return date('Ymd') . '.transbank.log.txt';
    }

    protected function getLogMessage($data, $level, $type)
    {
        $time = date('d/m/Y H:i:s');
        return "\n=================================\n$time - " . strtoupper($level) . " ($type):\n=================================\n$data";
    }
}

Create log folder if not exists

Create log folder if not exists


<?php
namespace Simox;

class Loader
{
    private $registered_directories;

    public function __construct()
    {
        $this->registered_directories = array();
    }

    public function registerDirs( $dirs )
    {
        foreach( $dirs as $dir )
        {
            $this->registered_directories[] = $dir;
        }
    }

    /**
     * Register autoloader
     */
    public function register()
    {
        spl_autoload_register( function($name) {
            foreach ( $this->registered_directories as $dir )
            {
                if ( file_exists($dir . DIRECTORY_SEPARATOR . $name . ".php") )
                {
                    include($dir . DIRECTORY_SEPARATOR . $name . ".php");
                }
            }
        } );
    }
}

<?php
namespace Simox;

class Loader extends SimoxServiceBase
{
    /**
     * The autoloader will search the registered directories
     */
    private $registered_directories;

    public function __construct()
    {
        $this->registered_directories = array();
    }

    /**
     * Directories are registered relative to the project root path
     */
    public function registerDirs( $dirs )
    {
        foreach( $dirs as $dir )
        {
            $this->registered_directories[] = $this->url->getRootPath() . DIRECTORY_SEPARATOR . $dir;
        }
    }

    /**
     * Register autoloader
     */
    public function register()
    {
        spl_autoload_register( function($name) {
            foreach ( $this->registered_directories as $dir )
            {
                if ( file_exists($dir . DIRECTORY_SEPARATOR . $name . ".php") )
                {
                    include($dir . DIRECTORY_SEPARATOR . $name . ".php");
                }
            }
        } );
    }
}

Make loader use the url service

Make loader use the url service


<?php

namespace Air\Mapper;

use Air\Database;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Query\QueryBuilder;

abstract class Mapper implements MapperInterface
{
    /**
     * @var Database\ConnectionInterface $databaseConnection A database connection.
     */
    protected $databaseConnection;

    /**
     * @var Collection $collection A collection to store objects in.
     */
    protected $collection;

    /**
     * @param Database\ConnectionInterface $databaseConnection A database connection.
     * @param Collection $collection A collection to store objects in.
     */
    public function __construct(Database\ConnectionInterface $databaseConnection, Collection $collection)
    {
        $this->databaseConnection = $databaseConnection;
        $this->collection = $collection;
    }

    /**
     * @return QueryBuilder
     */
    public function getQueryBuilder()
    {
        return $this->databaseConnection->getQueryBuilder();
    }

    /**
     * Map a data to a collection of model objects.
     *
     * @param array $data An array of data.
     * @return Collection A collection of objects.
     */
    protected function mapToObjects($data)
    {
        $this->collection->clear();

        if (count($data) > 0) {
            foreach ($data as $row) {
                $this->collection->add($this->instantiateObject($row));
            }
        }

        return $this->collection;
    }

    /**
     * @param array $data An array of data to instantiate the object with.
     * @return mixed A collection.
     */
    abstract protected function instantiateObject(array $data);
}

<?php

namespace Air\Mapper;

use Air\Database;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Query\QueryBuilder;

abstract class Mapper implements MapperInterface
{
    /**
     * @var Database\ConnectionInterface $databaseConnection A database connection.
     */
    protected $databaseConnection;

    /**
     * @var Collection $collection A collection to store objects in.
     */
    protected $collection;

    /**
     * @param Database\ConnectionInterface $databaseConnection A database connection.
     * @param Collection $collection A collection to store objects in.
     */
    public function __construct(Database\ConnectionInterface $databaseConnection, Collection $collection)
    {
        $this->databaseConnection = $databaseConnection;
        $this->collection = $collection;
    }

    /**
     * @return QueryBuilder
     */
    public function getQueryBuilder()
    {
        return $this->databaseConnection->getQueryBuilder();
    }

    /**
     * Map a data to a collection of model objects.
     *
     * @param array $data An array of data.
     * @return Collection A collection of objects.
     */
    protected function mapToObjects($data)
    {
        $this->collection->clear();

        if (count($data) > 0) {
            foreach ($data as $row) {
                $this->collection->add($this->instantiateObject($row));
            }
        }

        return clone $this->collection;
    }

    /**
     * @param array $data An array of data to instantiate the object with.
     * @return mixed A collection.
     */
    abstract protected function instantiateObject(array $data);
}

Return a copy of the collection.

Return a copy of the collection.

Because the collection is re-used, we want to return a copy of it.


<?php

namespace Kunstmaan\NodeBundle\Entity;

use Doctrine\Common\Collections\Collection;

class NodeIterator implements \RecursiveIterator
{
    private $_data;

    public function __construct(Collection $data)
    {
        $this->_data = $data;
    }

    /**
     * @return bool
     */
    #[\ReturnTypeWillChange]
    public function hasChildren()
    {
        return !$this->_data->current()->getChildren()->isEmpty();
    }

    /**
     * @return \?RecursiveIterator
     */
    #[\ReturnTypeWillChange]
    public function getChildren()
    {
        return new NodeIterator($this->_data->current()->getChildren());
    }

    public function current()
    {
        return $this->_data->current();
    }

    public function next()
    {
        $this->_data->next();
    }

    public function key()
    {
        return $this->_data->key();
    }

    public function valid()
    {
        return $this->_data->current() instanceof Node;
    }

    public function rewind()
    {
        $this->_data->first();
    }
}

<?php

namespace Kunstmaan\NodeBundle\Entity;

use Doctrine\Common\Collections\Collection;

class NodeIterator implements \RecursiveIterator
{
    private $_data;

    public function __construct(Collection $data)
    {
        $this->_data = $data;
    }

    /**
     * @return bool
     */
    #[\ReturnTypeWillChange]
    public function hasChildren()
    {
        return !$this->_data->current()->getChildren()->isEmpty();
    }

    /**
     * @return \RecursiveIterator
     */
    #[\ReturnTypeWillChange]
    public function getChildren()
    {
        return new NodeIterator($this->_data->current()->getChildren());
    }

    /**
     * @return Node
     */
    public function current()
    {
        return $this->_data->current();
    }

    /**
     * @return void
     */
    public function next()
    {
        $this->_data->next();
    }

    /**
     * @return int
     */
    public function key()
    {
        return $this->_data->key();
    }

    /**
     * @return bool
     */
    public function valid()
    {
        return $this->_data->current() instanceof Node;
    }

    /**
     * @return void
     */
    public function rewind()
    {
        $this->_data->first();
    }
}

[NodeBundle] Add docblock return types for node iterator class


<?php

namespace Nova\Foundation\Providers;

use Nova\Support\AggregateServiceProvider;

class ConsoleSupportServiceProvider extends AggregateServiceProvider
{
	/**
	 * The Provider Class names.
	 *
	 * @var array
	 */
	protected $providers = array(
		'Nova\Foundation\Providers\ComposerServiceProvider',
		'Nova\Foundation\Providers\PublisherServiceProvider',
		'Nova\Queue\ConsoleServiceProvider',
	);
}

<?php

namespace Nova\Foundation\Providers;

use Nova\Support\AggregateServiceProvider;

class ConsoleSupportServiceProvider extends AggregateServiceProvider
{
	/**
	 * The Provider Class names.
	 *
	 * @var array
	 */
	protected $providers = array(
		'Nova\Console\Scheduling\ScheduleServiceProvider',
		'Nova\Foundation\Providers\ComposerServiceProvider',
		'Nova\Foundation\Providers\PublisherServiceProvider',
		'Nova\Queue\ConsoleServiceProvider',
	);
}

Complete the integration of Console Scheduling


<?php
/**
 * Created by mcfedr on 08/06/2016 23:37
 */

namespace Mcfedr\SqsQueueDriverBundle\Manager;

use Aws\Sqs\SqsClient;

trait SqsClientTrait
{
    /**
     * @var string
     */
    private $defaultUrl;

    /**
     * @var bool
     */
    private $debug;

    /**
     * @var SqsClient
     */
    private $sqs;

    /**
     * @var string[]
     */
    private $queues;

    private function setOptions(array $options)
    {
        $this->defaultUrl = $options['default_url'];
        $this->debug = $options['debug'];
        $this->queues = $options['queues'];
        if (!$this->debug) {
            $sqsOptions = [
                'region' => $options['region'],
                'version' => '2012-11-05'
            ];
            if (array_key_exists('credentials', $options)) {
                $sqsOptions['credentials'] = $options['credentials'];
            }
            $this->sqs = new SqsClient($sqsOptions);
        }
    }
}

<?php
/**
 * Created by mcfedr on 08/06/2016 23:37
 */

namespace Mcfedr\SqsQueueDriverBundle\Manager;

use Aws\Sqs\SqsClient;

trait SqsClientTrait
{
    /**
     * @var string
     */
    private $defaultUrl;

    /**
     * @var bool
     */
    private $debug;

    /**
     * @var SqsClient
     */
    private $sqs;

    /**
     * @var string[]
     */
    private $queues;

    private function setOptions(array $options)
    {
        $this->defaultUrl = $options['default_url'];
        $this->debug = $options['debug'];
        $this->queues = $options['queues'];
        if (!array_key_exists('default', $this->queues)) {
            $this->queues['default'] = $this->defaultUrl;
        }
        if (!$this->debug) {
            $sqsOptions = [
                'region' => $options['region'],
                'version' => '2012-11-05'
            ];
            if (array_key_exists('credentials', $options)) {
                $sqsOptions['credentials'] = $options['credentials'];
            }
            $this->sqs = new SqsClient($sqsOptions);
        }
    }
}

Make default available as a queue name

Make default available as a queue name


<?php

/*
 * This file is part of the Prophecy.
 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
 *     Marcello Duarte <marcello.duarte@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Prophecy\Exception\Doubler;

class MethodNotFoundException extends DoubleException
{
    /**
     * @var string
     */
    private $classname;

    /**
     * @var string
     */
    private $methodName;

    /**
     * @var array
     */
    private $arguments;

    /**
     * @param string $message
     * @param string $classname
     * @param string $methodName
     * @param null|Argument\ArgumentsWildcard|array $arguments
     */
    public function __construct($message, $classname, $methodName, $arguments = null)
    {
        parent::__construct($message);

        $this->classname  = $classname;
        $this->methodName = $methodName;
        $this->arguments = $arguments;
    }

    public function getClassname()
    {
        return $this->classname;
    }

    public function getMethodName()
    {
        return $this->methodName;
    }

    public function getArguments()
    {
        return $this->arguments;
    }
}

<?php

/*
 * This file is part of the Prophecy.
 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
 *     Marcello Duarte <marcello.duarte@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Prophecy\Exception\Doubler;

class MethodNotFoundException extends DoubleException
{
    /**
     * @var string|object
     */
    private $classname;

    /**
     * @var string
     */
    private $methodName;

    /**
     * @var array
     */
    private $arguments;

    /**
     * @param string $message
     * @param string|object $classname
     * @param string $methodName
     * @param null|Argument\ArgumentsWildcard|array $arguments
     */
    public function __construct($message, $classname, $methodName, $arguments = null)
    {
        parent::__construct($message);

        $this->classname  = $classname;
        $this->methodName = $methodName;
        $this->arguments = $arguments;
    }

    public function getClassname()
    {
        return $this->classname;
    }

    public function getMethodName()
    {
        return $this->methodName;
    }

    public function getArguments()
    {
        return $this->arguments;
    }
}

Document another possible argument type

Document another possible argument type

This class is sometimes instanciated in the codebase with objects rather
than strings, and used in phpspec by php functions able to deal with
both types.

See #369
See https://github.com/phpspec/phpspec/pull/1180