Permalink
Browse files

Add plugins for angular-addtocalendar and angular-file-saver

  • Loading branch information...
bignall committed Oct 5, 2016
1 parent 7eda4ad commit 83b2cc31851b683e91d6af292b1934cb557ef9e3
@@ -206,7 +206,7 @@ public function setMinified($bool)
$this->_minified = ($bool==true);
return $this;
}
/**
* Use the minified version (true) or dev version (false)?
*
@@ -563,13 +563,13 @@ protected function _renderScriptTags()
document.createElement('ng-include');
document.createElement('ng-pluralize');
document.createElement('ng-view');
// Optionally these for CSS
document.createElement('ng:include');
document.createElement('ng:pluralize');
document.createElement('ng:view');
</script>
<![endif]-->
<![endif]-->
IEHAPPY;
foreach ($this->_plugins as $plugin) {
@@ -641,8 +641,7 @@ protected function _getAngularLibraryBaseCdnUri()
protected function _getAngularLibraryPath()
{
if($this->_angularLibraryPath != null) {
$source = $this->_angularLibraryPath .
($this->_minified==true? AngularZF1_Angular::CDN_ANGULAR_MIN_PATH_GOOGLE : AngularZF1_Angular::CDN_ANGULAR_PATH_GOOGLE);
$source = $this->_angularLibraryPath;
} else {
$baseUri = $this->_getAngularLibraryBaseCdnUri();
$source = $baseUri .
@@ -0,0 +1,79 @@
<?php
/**
* AngularZF1
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/bsd-license.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category AngularZF1
* @package AngularZF1_Angular
* @subpackage View
* @copyright Copyright (c) 2012 Gregory Wilson (http://www.drakos7.net) and Rosina Bignall (http://rosinabignall.com)
* @license http://opensource.org/licenses/bsd-license.php New BSD License
*/
/**
* @see Zend_Registry
*/
require_once 'Zend/Registry.php';
/**
* @see AngularZF1_Angular_View_Helper_Angular_Container
*/
require_once "AngularZF1/Angular/View/Helper/Angular/Container.php";
/**
* Angular Helper. Functions as a stack for code and loads all Angular dependencies.
*
* @package AngularZF1_Angular
* @subpackage View
* @copyright Copyright (c) 2012 Rosina Bignall (http://rosinabignall.com)
* @license http://opensource.org/licenses/bsd-license.php New BSD License
*/
class AngularZF1_Angular_View_Helper_AngularAddToCalendar extends Zend_View_Helper_Abstract
{
const ANGULAR_REGISTRY = 'AngularZF1_Angular_View_Helper_Angular';
/**
* Initialize helper
*
* Retrieve container from registry or create new container and store in
* registry.
*
* @return void
*/
public function __construct()
{
$registry = Zend_Registry::getInstance();
if (!isset($registry[self::ANGULAR_REGISTRY])) {
require_once 'AngularZF1/Angular/View/Helper/Angular/Container.php';
$container = new AngularZF1_Angular_View_Helper_Angular_Container();
$registry[self::ANGULAR_REGISTRY] = $container;
}
$this->_container = $registry[self::ANGULAR_REGISTRY];
}
/**
* Return Angular View Helper class, to execute UI Bootstrap library related functions.
*
* @return void
*/
public function angularAddToCalendar()
{
$plugin = $this->_container->getPlugin('AddToCalendar');
if ($plugin) {
$plugin->addScripts($this->view);
}
return ;
}
}
@@ -0,0 +1,79 @@
<?php
/**
* AngularZF1
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/bsd-license.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category AngularZF1
* @package AngularZF1_Angular
* @subpackage View
* @copyright Copyright (c) 2012 Gregory Wilson (http://www.drakos7.net) and Rosina Bignall (http://rosinabignall.com)
* @license http://opensource.org/licenses/bsd-license.php New BSD License
*/
/**
* @see Zend_Registry
*/
require_once 'Zend/Registry.php';
/**
* @see AngularZF1_Angular_View_Helper_Angular_Container
*/
require_once "AngularZF1/Angular/View/Helper/Angular/Container.php";
/**
* Angular Helper. Functions as a stack for code and loads all Angular dependencies.
*
* @package AngularZF1_Angular
* @subpackage View
* @copyright Copyright (c) 2012 Rosina Bignall (http://rosinabignall.com)
* @license http://opensource.org/licenses/bsd-license.php New BSD License
*/
class AngularZF1_Angular_View_Helper_AngularFileSaver extends Zend_View_Helper_Abstract
{
const ANGULAR_REGISTRY = 'AngularZF1_Angular_View_Helper_Angular';
/**
* Initialize helper
*
* Retrieve container from registry or create new container and store in
* registry.
*
* @return void
*/
public function __construct()
{
$registry = Zend_Registry::getInstance();
if (!isset($registry[self::ANGULAR_REGISTRY])) {
require_once 'AngularZF1/Angular/View/Helper/Angular/Container.php';
$container = new AngularZF1_Angular_View_Helper_Angular_Container();
$registry[self::ANGULAR_REGISTRY] = $container;
}
$this->_container = $registry[self::ANGULAR_REGISTRY];
}
/**
* Return Angular View Helper class, to execute UI Bootstrap library related functions.
*
* @return void
*/
public function angularFileSaver()
{
$plugin = $this->_container->getPlugin('FileSaver');
if ($plugin) {
$plugin->addScripts($this->view);
}
return ;
}
}
@@ -83,6 +83,8 @@ class AngularZF1_Application_Resource_Angular
'Restangular',
'Uirouter',
'BootstrapCalendar',
'AddToCalendar',
'FileSaver'
);
/**
@@ -114,18 +114,18 @@ protected function _parseOptions(array $options)
foreach ($options as $key => $value) {
switch(strtolower($key)) {
case 'minified':
$this->_view->Js()->setMinified($value);
$this->_view->Angular()->setMinified($value);
break;
case 'render_mode':
case 'rendermode':
$this->_view->Js()->setRenderMode($value);
$this->_view->Angular()->setRenderMode($value);
break;
case 'javascriptfile':
$this->_view->Js()->addJavascriptFile($value);
$this->_view->Angular()->addJavascriptFile($value);
break;
case 'javascriptfiles':
foreach($options['javascriptfiles'] as $file) {
$this->_view->Js()->addJavascriptFile($file);
$this->_view->Angular()->addJavascriptFile($file);
}
break;
case 'plugin':
@@ -151,12 +151,12 @@ protected function _parseOptions(array $options)
*/
protected function _registerPlugins($plugins)
{
$js = $this->_view->Js();
$angular = $this->_view->Js();
foreach ($plugins as $plugin => $options) {
// Register an instance
if (is_object($plugin) && in_array('AngularZF1_Application_Resource_Plugin_Interface', class_implements($plugin))) {
$js->registerPlugin($plugin);
$angular->registerPlugin($plugin);
continue;
}
@@ -178,8 +178,8 @@ protected function _registerPlugins($plugins)
}
require_once str_replace('_', DIRECTORY_SEPARATOR, $pluginClass) . '.php';
$object = new $pluginClass($options, $js);
$js->registerPlugin($object);
$object = new $pluginClass($options, $angular);
$angular->registerPlugin($object);
}
}
Oops, something went wrong.

0 comments on commit 83b2cc3

Please sign in to comment.