public function testDeclarativeUseShouldRenderTextareaWithSimpleTextareaDojoType()
 {
     Zend_Dojo_View_Helper_Dojo::setUseDeclarative(true);
     $html = $this->element->render();
     $this->assertContains('id="foo"', $html);
     $this->assertContains('<textarea', $html);
     $this->assertContains('dojoType="dijit.form.SimpleTextarea"', $html);
 }
Beispiel #2
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     Zend_Registry::_unsetInstance();
     Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
     $this->view = $this->getView();
     $this->helper = new Zend_Dojo_View_Helper_Editor();
     $this->helper->setView($this->view);
 }
 public function testDeclarativeUseShouldCreateTextareaWithSimpleTextareaDojoType()
 {
     Zend_Dojo_View_Helper_Dojo::setUseDeclarative(true);
     $html = $this->helper->simpleTextarea('foo', 'seeded text');
     $this->assertContains('id="foo"', $html);
     $this->assertContains('<textarea', $html);
     $this->assertContains('dojoType="dijit.form.SimpleTextarea"', $html);
 }
Beispiel #4
0
 public function changepasswordAction()
 {
     Zend_Layout::getMvcInstance()->disableLayout();
     Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
     $form = new Application_Form_ChangePasswordForm();
     $form->change->setAttrib('onclick', 'changePassword();');
     $this->view->changePasswordForm = $form;
 }
Beispiel #5
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     Zend_Registry::_unsetInstance();
     Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
     $this->view = $this->getView();
     $this->element = $this->getElement();
     $this->element->setView($this->view);
 }
Beispiel #6
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     Zend_Registry::_unsetInstance();
     Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
     $this->view = $this->getView();
     $this->decorator = new Zend_Dojo_Form_Decorator_SplitContainer();
     $this->element = $this->getElement();
     $this->element->setView($this->view);
     $this->decorator->setElement($this->element);
 }
Beispiel #7
0
 /**
  * Pre-Dispatch: set up dojo and context switching
  * 
  * @return void
  */
 public function preDispatch()
 {
     $request = $this->getRequest();
     Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
     $contextSwitch = $this->_helper->contextSwitch;
     if (!$contextSwitch->hasContext('ajax')) {
         $contextSwitch->addContext('ajax', array('suffix' => 'ajax'))->addActionContext('new', 'ajax')->addActionContext('followup', 'ajax')->addActionContext('display', 'ajax')->addActionContext('active', 'ajax')->addActionContext('active-data', 'ajax')->addActionContext('active-data-count', 'ajax')->initContext();
     }
     $message = array('Current request information', array(array('Module', 'Controller', 'Action'), array($request->getModuleName(), $request->getControllerName(), $request->getActionName())));
     Zend_Registry::get('log')->table($message);
 }
 public function init()
 {
     Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
     $this->view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper');
     $session = $this->getRequest()->getCookie('sessionid');
     $this->lib = new MetaNAS_Lib_MiniDLNA();
     /*
      * We need to make sure the user viewing this is logged in the MetaNAS GUI
      * Pass the sessionid via JSON-RPC and make sure it has access
      */
     $this->lib->isAuthorized($session);
 }
 protected function _initDojo()
 {
     $this->bootstrap('view');
     $view = $this->getResource('view');
     $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper');
     $view->dojo()->setLocalPath('/js/dojo/dojo.js');
     $view->dojo()->addStylesheetModule('dijit.themes.tundra');
     $view->dojo()->setDjConfigOption('usePlainJson', true);
     $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
     $viewRenderer->setView($view);
     Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
     Zend_Dojo_View_Helper_Dojo::setUseProgrammatic();
 }
Beispiel #10
0
 public function init()
 {
     $this->view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper');
     Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
     $layout = $this->_helper->layout;
     $root = realpath(dirname(__FILE__) . '/../../../');
     $layout->setLayoutPath(ZUPAL_LAYOUT_PATH);
     $layout->setLayout('default');
     $this->view->placeholder('base_path')->set($this->getFrontController()->getBaseUrl());
     // note -- deprecated, using ZUPAL_BASEURL constant.
     //	$this->view->dojo()
     //		->setLocalPath(ZUPAL_BASEURL . DS . 'scripts/Dojo/dojo/dojo.js')
     //->requireModule('dijit.form.Form')
     //         ->setDjConfigOption('dojoBlankHtmUrl', '/blank.html');
 }
Beispiel #11
0
 /**
  * dispatchLoopStartup
  *
  * @param  Zend_Controller_Request_Abstract $oRequest
  * @return void
  */
 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $oRequest)
 {
     // Hack DOJO
     Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
     $contextSwitch = Zend_Controller_Action_HelperBroker::getStaticHelper('ContextSwitch');
     $contextParam = $contextSwitch->getContextParam();
     $format = $oRequest->getParam($contextParam);
     // Inject javascript vars
     if (!$format or $format == "html" or $format == "html-json" or $format == "html-xml") {
         $this->_view->dojo()->setDjConfigOption('ZlBaseUrl', $this->_view->baseUrl());
         $this->_view->dojo()->setDjConfigOption('ZlBaseThemeUrl', $this->_view->baseThemeUrl());
         $this->_view->dojo()->setDjConfigOption('ZlModule', $oRequest->getModuleName());
         $this->_view->dojo()->setDjConfigOption('ZlController', $oRequest->getControllerName());
         $this->_view->dojo()->setDjConfigOption('ZlAction', $oRequest->getActionName());
     }
 }
Beispiel #12
0
 public static function getForm()
 {
     Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
     $form = new Zend_Form();
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'editor/changesForm.phtml'))));
     $zdate = new Zend_Date();
     $e = new Zend_Dojo_Form_Element_DateTextBox('fromDate', array('label' => 'From', 'required' => true));
     $e->setAttrib('onchange', 'admin.currentManObj.refresh()');
     $form->addElement($e);
     $e = new Zend_Dojo_Form_Element_DateTextBox('toDate', array('label' => 'To', 'required' => true));
     $e->setAttrib('onchange', 'admin.currentManObj.refresh()');
     $form->addElement($e);
     //		$e = new Zend_Dojo_Form_Element_Button( 'refresh', array ('label' => 'Refresh' ) );
     //		$e->setAttrib('onchange', 'admin.currentManObj.refresh()');
     //		$form->addElement($e);
     Zend_Dojo::enableForm($form);
     $form->setDefaults(array('toDate' => $zdate->getIso(), 'fromDate' => $zdate->getIso()));
     return $form;
 }
Beispiel #13
0
 public function testShouldAllowProgrammaticDijitCreation()
 {
     Zend_Dojo_View_Helper_Dojo::setUseProgrammatic();
     $html = $this->getContainer();
     $this->assertNotRegexp('/<div[^>]*(dojoType="dijit.layout.TabContainer")/', $html);
     $this->assertNotNull($this->view->dojo()->getDijit('container'));
 }
Beispiel #14
0
 /**
  * @group ZF-7134
  * @group ZF-7266
  */
 public function testComboBoxInSubFormShouldCreateJsonStoreBasedOnQualifiedId()
 {
     Zend_Dojo_View_Helper_Dojo::setUseProgrammatic();
     $this->element->setStoreId('foo')->setStoreType('dojo.data.ItemFileReadStore')->setStoreParams(array('url' => '/foo'));
     include_once 'Zend/Form/SubForm.php';
     $subform = new Zend_Form_SubForm(array('name' => 'bar'));
     $subform->addElement($this->element);
     $html = $this->element->render();
     $dojo = $this->view->dojo()->__toString();
     $this->assertContains('"store":"foo"', $dojo, $dojo);
 }
Beispiel #15
0
 /**
  * @group ZF-5987
  * @group ZF-7266
  */
 public function testStoreCreationWhenUsingProgrammaticCreationShouldRegisterAsDojoJavascript()
 {
     Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(true);
     $html = $this->getElementAsRemoter();
     $js = $this->view->dojo()->getJavascript();
     $this->assertContains('var stateStore;', $js);
     $onLoad = $this->view->dojo()->_getZendLoadActions();
     $storeDeclarationFound = false;
     foreach ($onLoad as $statement) {
         if (strstr($statement, 'stateStore = new ')) {
             $storeDeclarationFound = true;
             break;
         }
     }
     $this->assertTrue($storeDeclarationFound, 'Store definition not found');
 }
Beispiel #16
0
 public function testShouldAllowProgrammaticDijitCreation()
 {
     Zend_Dojo_View_Helper_Dojo::setUseProgrammatic();
     $html = $this->getElement();
     $this->assertNotRegexp('/<div[^>]*(dojoType="dijit.form.HorizontalSlider")/', $html);
     $this->assertNotNull($this->view->dojo()->getDijit('elementId-slider'));
 }
 /**
  * Set whether or not dijits should be created programmatically
  *
  * Optionally, specifiy whether or not dijit helpers should generate the
  * programmatic dojo.
  *
  * @param  int $style
  * @return void
  */
 public static function setUseProgrammatic($style = self::PROGRAMMATIC_SCRIPT)
 {
     if (!in_array($style, array(self::PROGRAMMATIC_SCRIPT, self::PROGRAMMATIC_NOSCRIPT))) {
         $style = self::PROGRAMMATIC_SCRIPT;
     }
     self::$_useProgrammatic = $style;
 }
Beispiel #18
0
 public function testShouldAllowSpecifyingProgrammaticDijitCreationWithNoScriptGeneration()
 {
     $this->testShouldUseDeclarativeDijitCreationByDefault();
     Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(-1);
     $this->assertTrue(Zend_Dojo_View_Helper_Dojo::useProgrammatic());
     $this->assertTrue(Zend_Dojo_View_Helper_Dojo::useProgrammaticNoScript());
 }
Beispiel #19
0
 /**
  * Initialize view and layouts
  * 
  * @param  bool $doLayout
  * @return My_Plugin_Initialize
  */
 public function initView($doLayout = true)
 {
     $view = new Zend_View();
     $view->addHelperPath('My/View/Helper/', 'My_View_Helper');
     $view->addHelperPath(APPLICATION_PATH . '/views/helpers', 'Zend_View_Helper');
     $view->addHelperPath(APPLICATION_PATH . '/modules/spindle/views/helpers', 'Spindle_View_Helper');
     Zend_Dojo::enableView($view);
     Zend_Dojo_View_Helper_Dojo::setUseDeclarative(true);
     $view->baseUrl = rtrim($this->getRequest()->getBaseUrl(), '/');
     $view->doctype('XHTML1_STRICT');
     $view->headTitle()->setSeparator(' - ')->append('Spindle');
     $view->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=utf-8');
     $view->dojo()->setDjConfigOption('isDebug', $this->config->view->dojo->isDebug)->setLocalPath('/js/dojo/dojo.js')->registerModulePath('../spindle', 'spindle')->addStylesheetModule('spindle.themes.spindle')->requireModule('spindle.main')->disable();
     Zend_Registry::set('view', $view);
     if ($doLayout) {
         $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
         $viewRenderer->setView($view);
         $layout = Zend_Layout::startMvc(array('layoutPath' => $this->config->appPath . '/layouts/scripts'));
     }
     return $this;
 }
Beispiel #20
0
 public function testInvalidFlagPassedToUseProgrammaticShouldUseProgrammaticWithScripts()
 {
     Zend_Dojo_View_Helper_Dojo::setUseProgrammatic('foo');
     $this->assertFalse(Zend_Dojo_View_Helper_Dojo::useProgrammaticNoScript());
     $this->assertTrue(Zend_Dojo_View_Helper_Dojo::useProgrammatic());
 }
 public function testShouldJsonEncodeConstraints()
 {
     $html = $this->getElement();
     if (!preg_match('/constraints="(.*?)(" )/', $html, $m)) {
         $this->fail('Did not serialize constraints');
     }
     $constraints = str_replace("'", '"', $m[1]);
     if (Zend_Dojo_View_Helper_Dojo::useDeclarative()) {
         // Convert &#39; to "'" for json_decode. See Zend_Dojo_View_Helper_Dijit::_prepareDijit() (line 254)
         $constraints = str_replace('&#39;', '"', $constraints);
     }
     $constraints = Zend_Json::decode($constraints);
     $this->assertTrue(is_array($constraints), var_export($m[1], 1));
     $this->assertTrue(array_key_exists('min', $constraints));
     $this->assertTrue(array_key_exists('max', $constraints));
     $this->assertTrue(array_key_exists('places', $constraints));
 }
 public function editAction()
 {
     $request = $this->getRequest();
     $id = $request->getParam('NODEID', -1);
     $ntid = $request->getParam('NODETYPEID');
     Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
     $this->view->addHelperPath('Uman/Dojo/View/Helper/', 'Uman_Dojo_View_Helper');
     $form = new Uman_Admin_Form();
     $form->setName('nodeEditorForm');
     $form->setAttrib('jsId', 'nodeEditorForm');
     $form->setAction('/admin/editor/save');
     $form->setMethod('post');
     $form->setEnctype('multipart/form-data');
     $dbModel = new Admin_Model_Admin();
     $nodeeditorInfo = $dbModel->getNodeEditorInfo($ntid);
     $fields = $dbModel->getEditorFields($nodeeditorInfo['DEFAULT_EDITOR_NODEID']);
     $parentidExists = false;
     $nodetypeidExists = false;
     $js_oncreate = '';
     $js_beforesubmit = '';
     foreach ($fields as $field) {
         if (!$field['VISIBLE']) {
             continue;
         }
         if ($field['FIELDNAME'] == 'PARENTID') {
             $parentidExists = true;
         } else {
             if ($field['FIELDNAME'] == 'NODETYPEID') {
                 $nodetypeidExists = true;
             }
         }
         $class = $field['ELEMENT_CLASS'];
         $e = new $class($field['FIELDNAME']);
         //			$e->setName($fieldName);
         if (!empty($field['ELEMENT_CONFIG'])) {
             /*
              * In php.ini must be:
              * allow_url_include = on;
              * allow_url_fopen = on;
             */
             $elem_cfg = new Zend_Config_Ini('data://,' . $field['ELEMENT_CONFIG']);
             $elem_cfg = $elem_cfg->toArray();
             $e->setOptions($elem_cfg);
         }
         $e->setLabel($field['TITLE']);
         //			if (@$field['REQUIRED'])
         $e->setRequired($field['REQUIRED']);
         switch ($class) {
             case 'Zend_Form_Element_Hidden':
                 $decor = array('ViewHelper');
                 break;
             case 'Zend_Form_Element_File':
                 //				$e->setMaxFileSize(1024);
                 $decor = $form->elementFileDecorators;
                 break;
             default:
                 $decor = $form->elementDecorators;
         }
         $e->setDecorators($decor);
         $form->addElement($e);
         $js_oncreate .= isset($field['JS_ONCREATE']) ? $field['JS_ONCREATE'] . "\n" : '';
         $js_beforesubmit .= isset($field['JS_BEFORESUBMIT']) ? $field['JS_BEFORESUBMIT'] . "\n" : '';
     }
     $e = new Zend_Dojo_Form_Element_SubmitButton('save', array('label' => 'Сохранить'));
     $e->setDecorators($form->buttonDecorators);
     $form->addElement($e);
     /*		$e = new Zend_Dojo_Form_Element_Button('cancel', array('label' => 'Отмена', 'onClick' => "dijit.byId('editorDialog').onCancel()"));
     		$e->setDecorators($form->buttonDecorators);
     		$form->addElement($e);*/
     $form->addElements(array($form->createElement('hidden', 'NODEID')->setDecorators(array('ViewHelper')), $form->createElement('hidden', 'MODE')->setDecorators(array('ViewHelper'))));
     if (!$nodetypeidExists) {
         $form->addElement($form->createElement('hidden', 'NODETYPEID')->setDecorators(array('ViewHelper')));
     }
     if (!$parentidExists) {
         $form->addElement($form->createElement('hidden', 'PARENTID')->setDecorators(array('ViewHelper')));
     }
     if ($request->isPost()) {
         $res = $form->processAjax($request->getPost());
         if ($res != 'true') {
             echo $res;
             exit;
         } else {
             //			if($form->isValid ( $request->getPost () )) {
             $dbModel->saveFieldsValues($fields, $request->getPost(), $nodeeditorInfo);
             //				$dbModel->copyResources ( $id, false );
             echo $res;
             // "<textarea>$res</textarea"; //OK for AJAX request
             exit;
         }
     } else {
         if ($id == -1) {
             // New page
             $pid = $request->getParam('PARENTID');
             $dbModel->checkRight($pid);
             $id = $dbModel->getNextId('GEN_TEMP_UID');
             $values = array_merge($dbModel->getNewValues($fields, $nodeeditorInfo), array('NODEID' => $id, 'PARENTID' => $pid, 'NODETYPEID' => $ntid, 'MODE' => 'ADD', 'SORTORDER' => $dbModel->getNextSortOrder($pid)));
             //				mkdir($this->_cfg['temp']['path'] . $id);
         } else {
             $dbModel->checkRight($id);
             $values = array_merge($dbModel->getFieldsValues($fields, $id, $nodeeditorInfo), array('MODE' => 'EDIT'));
             $dbModel->copyResources($id, $id, true);
         }
         $form->populate($values);
         $this->view->assign('form', $form);
         $this->view->assign('title', $nodeeditorInfo['TITLE']);
         if (!empty($js_oncreate)) {
             $this->view->assign('js_oncreate', $js_oncreate);
             $this->view->assign('id', $id);
             $this->view->assign('baseUrl', $request->getBaseUrl());
         }
         if (!empty($js_beforesubmit)) {
             $this->view->assign('js_beforesubmit', $js_beforesubmit);
         }
     }
 }
 public function testShouldAllowProgrammaticDijitCreation()
 {
     Zend_Dojo_View_Helper_Dojo::setUseProgrammatic();
     $html = $this->getElement();
     $this->assertNotRegexp('/<input[^>]*(dojoType="dijit.form.ValidationTextBox")/', $html);
     $this->assertNotNull($this->view->dojo()->getDijit('elementId'));
 }
    public function testShouldAllowProgrammaticDijitCreationAsRemoter()
    {
        Zend_Dojo_View_Helper_Dojo::setUseProgrammatic();
        $html = $this->getElementAsRemoter();
        $this->assertNotRegexp('/<input[^>]*(dojoType="dijit.form.FilteringSelect")/', $html);
        $this->assertRegexp('/<input[^>]*(type="text")/', $html);
        $this->assertNotNull($this->view->dojo()->getDijit('elementId'));

        $found = false;
        $scripts = $this->view->dojo()->getJavascript();
        foreach ($scripts as $js) {
            if (strstr($js, 'var stateStore;')) {
                $found = true;
                break;
            }
        }
        $this->assertTrue($found, 'No store declaration found: ' . var_export($scripts, 1));
    }
Beispiel #25
0
 /**
  * Whether or not to use programmatic dijit creation w/o script creation
  *
  * @return bool
  */
 protected function _useProgrammaticNoScript()
 {
     return Zend_Dojo_View_Helper_Dojo::useProgrammaticNoScript();
 }
Beispiel #26
0
 public function testOnlyIdShouldBeNecessary()
 {
     Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
     $html = $this->view->form('foo');
     $this->assertRegexp('/<form[^>]*(dojoType="dijit.form.Form")/', $html, $html);
     $this->assertRegexp('/<form[^>]*(id="foo")/', $html, $html);
 }
 /**
  * @group ZF-3962
  */
 public function testHelperShouldAllowDisablingParseOnLoadWithDeclarativeStyle()
 {
     Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
     $this->helper->requireModule('dijit.layout.ContentPane')->setDjConfigOption('parseOnLoad', 'false')->enable();
     $html = $this->helper->__toString();
     if (!preg_match('/(var djConfig = .*?(?:};))/s', $html, $matches)) {
         $this->fail('Failed to find djConfig settings: ' . $html);
     }
     $this->assertNotContains('"parseOnLoad":true', $matches[1]);
 }
Beispiel #28
0
 /**
  * @group ZF-3877
  */
 public function testContentPaneMarkupShouldNotContainNameAttribute()
 {
     $html = $this->view->contentPane('pane1', 'This is the pane content', array('id' => 'pane', 'title' => 'Pane 1'));
     $this->assertNotContains('name="/', $html, $html);
     Zend_Dojo_View_Helper_Dojo::setUseProgrammatic();
     $html = $this->view->contentPane('pane1', 'This is the pane content', array('id' => 'pane', 'title' => 'Pane 1'));
     $this->assertNotContains('name="/', $html, $html);
 }
Beispiel #29
0
 /**
  * String representation of dojo environment
  *
  * @return string
  */
 public function __toString()
 {
     if (!$this->isEnabled()) {
         return '';
     }
     $this->_isXhtml = $this->view->doctype()->isXhtml();
     if (Zend_Dojo_View_Helper_Dojo::useDeclarative()) {
         if (null === $this->getDjConfigOption('parseOnLoad')) {
             $this->setDjConfigOption('parseOnLoad', true);
         }
     }
     if (!empty($this->_dijits)) {
         $this->registerDijitLoader();
     }
     $html = $this->_renderStylesheets() . PHP_EOL . $this->_renderDjConfig() . PHP_EOL . $this->_renderDojoScriptTag() . PHP_EOL . $this->_renderLayers() . PHP_EOL . $this->_renderExtras();
     return $html;
 }
Beispiel #30
0
 public function testHelperInProgrammaticModeShouldGenerateDivWithoutPassedDojoType()
 {
     Zend_Dojo_View_Helper_Dojo::setUseProgrammatic();
     $content = $this->view->customDijit('foo', 'content', array('dojoType' => 'custom.Dijit'));
     $this->assertNotContains('dojoType="custom.Dijit"', $content);
 }