2017 © Pedro Peláez
 

library mq-util

Milq Media Utilities

image

milqmedia/mq-util

Milq Media Utilities

  • Tuesday, September 29, 2015
  • by yo-han
  • Repository
  • 4 Watchers
  • 0 Stars
  • 783 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

mq-util

mq-util is deprecated. Please use another package with active development., (*1)

Basic utillities used in ZF2 controller and views., (*2)

Zend Framework 2 View helpers - less() to convert LESS files to CSS - js() to retrieve versioned js files - dateFormat() to format dates in different, many used, formats - percent() to quickly calculate a percentage, (*3)

MQUtil\Collector\Milq, (*4)

ZendDeveloperTools collector listing environment, timezone and defaultlocale, (*5)

MQUtil\Log\Writer\Doctrine, (*6)

Doctrine log writer, (*7)

MQUtil\Service\ShortUrl, (*8)

Url shortner using the Google urlshortener API., (*9)

MQUtil\Service\Paginator, (*10)

Super simple and easy to use pagination class, (*11)

MQUtil\Service\Iterator, (*12)

Super simple and easy to use iteration class with prevItem support, (*13)

Installation

  1. Run php composer.phar require milqmedia/mq-util:dev-master
  2. Add MQUtil to the enabled modules list
  3. Use the less or js viewhelper in your template

Usage

Less & JS helpers, (*14)

$this->headLink()->setStylesheet($this->basePath($this->less('less/site.less')))
$this->headScript()->setFile({$this->basePath($this->js('jquery')))

Percent view helper, (*15)

$this->percent($total, $count, $reverse = false);
  • $total: Total items
  • $count: Items to calculate percentage of
  • $reverse: Return the remaining percentage instead of the calculated percentage

DateFormat view helper, (*16)

$this->dateFormat($date)->dayName();

Available methods: - forumDate: Returns "H:i" if today, "d-m H:i" if this year, else "d-m-y H:i" - ago: Returns seconds, minutes, hours, days, etc. ago since given date - dayName($short = false): Dayname for the given date, if short is true dayname is in a short format e.g. Sun. - monthName: Monthname for the given date, (*17)

MQUtil\Collector\Milq, (*18)

Add the collector to the zdt config file, (*19)

array(
    'zenddevelopertools' => array(
        'profiler' => array(
            'collectors' => array('milq' => 'MQUtil\Collector\Milq'),
        ),
    )

And a template to the toolbar, (*20)

array(
    'zenddevelopertools' => array(
        'toolbar' => array(
          'entries'       => array(
              'milq' => 'zend-developer-tools/toolbar/milq',
            ),
          )
       )
)

MQUtil\Log\Writer\Doctrine, (*21)

Copy the Log.php.dist file from the package root to your entity directory. Change the namespace if necessary., (*22)

Use it like this:, (*23)

$this->getServiceLocator()->get('Zend\Log\Logger')->err("error")

MQUtil\Service\ShortUrl, (*24)

Configure your Google API Key:, (*25)

return array(
    'google_short_url' => array(
        'apiKey' => '<key>',
    )
);

Use it like this:, (*26)

$shortUrlApi = $this->getServiceLocator()->get('MQUtil\Service\ShortUrl');
$response = $shortUrlApi->shortenUrl('http://google.com');

If successful, the response will look like:, (*27)

{
 "kind": "urlshortener#url",
 "id": "http://goo.gl/fbsS",
 "longUrl": "http://www.google.com/"
}

MQUtil\Service\Paginator, (*28)

Create a new pagination object:, (*29)

$paginator = $this->getServiceLocator()->get('MQUtil\Service\Paginator')->getPaginator($numberOfItems, $numberOfItemsPerPage, $currentPage);

Available methods:, (*30)

$paginator->next();
$paginator->prev();
$paginator->current();
$paginator->total();
$paginator->offsetStart();
$paginator->isLastPage();

MQUtil\Service\Iterator, (*31)

Create a new iteration object:, (*32)

$iterator = $this->getServiceLocator()->get('MQUtil\Service\Iterator')->getIterator($array, $currentItem);

Available methods:, (*33)

$iterator->hasNext();
$iterator->nextItem();
$iterator->hasPrev();
$iterator->prevItem();
$iterator->currentItem();
$iterator->isLastItem();

Development

..., (*34)

Contributing

  1. Fork it ( https://github.com/milqmedia/mq-util/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

The Versions

29/09 2015

dev-master

9999999-dev https://github.com/milqmedia/mq-util

Milq Media Utilities

  Sources   Download

The Requires

 

zf2 util milq media