/** {@inheritdoc} */
 public function showMain()
 {
     $modules = array();
     foreach (AbstractModule::getModuleList() as $className) {
         $parts = explode("_", str_replace("_Module_", "_", $className));
         $package = array_shift($parts);
         $modules[$package][$className] = join(" / ", $parts);
     }
     $templates = array('' => "[ None ]") + Curry_Backend_Template::getTemplateSelect();
     $form = new Curry_Form_ModelForm('Module', array('columnElements' => array('module_class' => array('select', array('multiOptions' => $modules)), 'content_visibility' => array('select', array('multiOptions' => PageModulePeer::$contentVisiblityOptions)), 'template' => array('select', array('multiOptions' => $templates)))));
     $list = new Curry_ModelView_List('Module', array('modelForm' => $form));
     $this->addMainContent($list);
 }
Example #2
0
 public function initialize()
 {
     $modules = array();
     foreach (AbstractModule::getModuleList() as $className) {
         $parts = explode(" ", str_replace(" Module ", " ", strtr($className, "\\_", '  ')));
         $package = array_shift($parts);
         if (!$package) {
             $package = 'Other';
         }
         $modules[$package][$className] = join(" / ", $parts);
     }
     $templates = array('' => "[ None ]") + \Curry_Backend_Template::getTemplateSelect();
     $form = new ModelForm('Module', array('columnFields' => array('module_class' => array('type' => 'choice', 'choices' => $modules), 'content_visibility' => array('type' => 'choice', 'choices' => \PageModulePeer::$contentVisiblityOptions), 'template' => array('type' => 'choice', 'choices' => $templates))));
     $this->addView('modules', new ListView('Module', array('modelForm' => $form)));
 }
Example #3
0
 /** {@inheritdoc} */
 public function showBack()
 {
     $form = new \Curry_Form_SubForm();
     $form->addSubForm(new \Curry_Form_SubForm(array('legend' => 'Embed properties', 'class' => $this->module ? 'advanced' : '', 'elements' => array('flash' => array('filebrowser', array('label' => 'Flash', 'required' => true, 'value' => $this->flash)), 'method' => array('select', array('label' => 'Method', 'multiOptions' => array(FlashUtil::SWFOBJECT_DYNAMIC => "swfobject (dynamic)", FlashUtil::SWFOBJECT_STATIC => "swfobject (static)"), 'required' => true, 'value' => $this->method)), 'width' => array('text', array('label' => 'Width', 'required' => true, 'value' => $this->width)), 'height' => array('text', array('label' => 'Height', 'required' => true, 'value' => $this->height)), 'target' => array('text', array('label' => 'Target Id', 'required' => true, 'value' => $this->target)), 'version' => array('text', array('label' => 'Version', 'required' => true, 'value' => $this->version)), 'express_install' => array('text', array('label' => 'Express Install SWF', 'value' => (string) $this->expressInstall)), 'add_to_flashvars' => array('multiCheckbox', array('label' => 'Add to flashvars', 'multiOptions' => array('get' => 'GET', 'post' => 'POST', 'cookie' => 'Cookies'), 'value' => $this->addToFlashvars)), 'alternative_content' => array('textarea', array('label' => 'Alternative content', 'value' => $this->alternativeContent, 'rows' => 5, 'cols' => 40, 'wrap' => 'off'))))), 'embed');
     $form->addSubForm(new \Curry_Form_SubForm(array('legend' => 'Attributes', 'class' => 'advanced', 'elements' => array('name' => array('text', array('label' => 'Name', 'value' => $this->attributes['name'])), 'class' => array('text', array('label' => 'Class', 'value' => $this->attributes['class']))))), 'attributes');
     $form->addSubForm(new \Curry_Form_SubForm(array('legend' => 'Parameters', 'class' => 'advanced', 'elements' => array('play' => array('select', array('label' => 'Play', 'multiOptions' => array('' => '[Default]', 'true' => 'true', 'false' => 'false'), 'value' => $this->params['play'])), 'loop' => array('select', array('label' => 'Loop', 'multiOptions' => array('' => '[Default]', 'true' => 'true', 'false' => 'false'), 'value' => $this->params['loop'])), 'menu' => array('select', array('label' => 'Menu', 'multiOptions' => array('' => '[Default]', 'true' => 'true', 'false' => 'false'), 'value' => $this->params['menu'])), 'quality' => array('select', array('label' => 'Quality', 'multiOptions' => array('' => '[Default]', 'best' => 'best', 'high' => 'high', 'medium' => 'medium', 'autohigh' => 'autohigh', 'autolow' => 'autolow', 'low' => 'low'), 'value' => $this->params['quality'])), 'scale' => array('select', array('label' => 'Scale', 'multiOptions' => array('' => '[Default]', 'showall' => 'showall', 'noborder' => 'noborder', 'exactfit' => 'exactfit', 'noscale' => 'noscale'), 'value' => $this->params['scale'])), 'salign' => array('select', array('label' => 'salign', 'multiOptions' => array('' => '[Default]', 'tl' => 'tl', 'tr' => 'tr', 'bl' => 'bl', 'br' => 'br', 'l' => 'l', 't' => 't', 'r' => 'r', 'b' => 'b'), 'value' => $this->params['salign'])), 'wmode' => array('select', array('label' => 'wmode', 'multiOptions' => array('' => '[Default]', 'window' => 'window', 'opaque' => 'opaque', 'transparent' => 'transparent', 'direct' => 'direct', 'gpu' => 'gpu'), 'value' => $this->params['wmode'])), 'bgcolor' => array('text', array('label' => 'bgcolor', 'value' => $this->params['bgcolor'])), 'devicefont' => array('select', array('label' => 'devicefont', 'multiOptions' => array('' => '[Default]', 'true' => 'true', 'false' => 'false'), 'value' => $this->params['devicefont'])), 'seamlesstabbing' => array('select', array('label' => 'seamlesstabbing', 'multiOptions' => array('' => '[Default]', 'true' => 'true', 'false' => 'false'), 'value' => $this->params['seamlesstabbing'])), 'swliveconnect' => array('select', array('label' => 'swliveconnect', 'multiOptions' => array('' => '[Default]', 'true' => 'true', 'false' => 'false'), 'value' => $this->params['swliveconnect'])), 'allowfullscreen' => array('select', array('label' => 'allowfullscreen', 'multiOptions' => array('' => '[Default]', 'true' => 'true', 'false' => 'false'), 'value' => $this->params['allowfullscreen'])), 'allowscriptaccess' => array('select', array('label' => 'allowscriptaccess', 'multiOptions' => array('' => '[Default]', 'always' => 'always', 'sameDomain' => 'sameDomain', 'never' => 'never'), 'value' => $this->params['allowscriptaccess'])), 'allownetworking' => array('select', array('label' => 'allownetworking', 'multiOptions' => array('' => '[Default]', 'all' => 'all', 'internal' => 'internal', 'none' => 'none'), 'value' => $this->params['allownetworking'])), 'base' => array('text', array('label' => 'base', 'value' => $this->params['base']))))), 'params');
     $variableForm = new \Curry_Form_Dynamic(array('legend' => 'Variable', 'elements' => array('name' => array('text', array('label' => 'Name', 'required' => true)), 'value' => array('text', array('label' => 'Value')))));
     $form->addSubForm(new \Curry_Form_MultiForm(array('legend' => 'Flashvars', 'class' => 'advanced', 'cloneTarget' => $variableForm, 'defaults' => $this->flashvars)), 'flashvars');
     $templatesSelect = array(null => "[ None ]") + \Curry_Backend_Template::getTemplateSelect();
     $classNames = array(null => "[ None ]") + AbstractModule::getModuleList();
     $form->addSubForm(new \Curry_Form_SubForm(array('legend' => 'Embedded module', 'class' => 'advanced', 'elements' => array('class_name' => array('select', array('label' => 'Module', 'multiOptions' => $classNames, 'value' => $this->className, 'disable' => array(__CLASS__))), 'template' => array('select', array('label' => 'Template', 'multiOptions' => $templatesSelect, 'value' => $this->template)), 'flashvar' => array('text', array('label' => 'Flashvar-name', 'value' => $this->moduleFlashvar))))), 'emodule');
     if ($this->module) {
         $form->addSubForm($this->module->showBack(), 'submodule');
     }
     return $form;
 }
Example #4
0
 /**
  * Create new module form.
  *
  * @param PageRevision $pageRevision
  * @param string $moduleClass
  * @return Curry_Form
  */
 public static function getNewModuleForm($pageRevision, $moduleClass, $target)
 {
     $valid = array();
     $modules = array();
     foreach (ModuleQuery::create()->orderByTitle()->find() as $module) {
         $inTargets = in_array($target, $module->getTargets());
         if (!$target || ($module->getTargetsExclude() ? !$inTargets : $inTargets)) {
             $modules[$module->getModuleId()] = $module->getTitle();
             $valid[] = $module->getModuleId();
         }
     }
     $user = User::getUser();
     $modulePermission = $user->hasPagePermission($pageRevision->getPage(), PageAccessPeer::PERM_MODULES);
     if ($modulePermission) {
         $modules = array('Predefined' => $modules);
         foreach (AbstractModule::getModuleList() as $className) {
             $parts = explode("_", str_replace("_Module_", "_", $className));
             $package = array_shift($parts);
             $modules[$package][$className] = join(" / ", $parts);
             $valid[] = $className;
         }
     }
     if (!$moduleClass || !in_array($moduleClass, $valid)) {
         $form = new Curry_Form(array('action' => url('', $_GET), 'method' => 'post', 'class' => isAjax() ? 'dialog-form' : '', 'elements' => array('module_class' => array('select', array('label' => 'Type', 'multiOptions' => $modules, 'required' => true)), 'next' => array('submit', array('label' => 'Next')))));
         return $form;
     } else {
         // Fetch template targets
         $targets = array();
         try {
             $template = $pageRevision->getInheritedProperty('Template');
             if ($template) {
                 $template = \Curry\App::getInstance()->twig->loadTemplate($template);
             }
             while ($template) {
                 $targets = array_merge($targets, $template->getPlaceholders());
                 $template = $template->getParent(array());
             }
         } catch (Exception $e) {
             \Curry\App::getInstance()->logger->warning('Error in template: ' . $e->getMessage());
         }
         if (count($targets)) {
             $targets = array_combine(array_values($targets), array_values($targets));
         }
         // Check for predefined module creation
         if (ctype_digit($moduleClass)) {
             $module = ModuleQuery::create()->findPk($moduleClass);
             $form = new Curry_Form(array('action' => url('', $_GET), 'method' => 'post', 'class' => isAjax() ? 'dialog-form' : '', 'elements' => array('pid_newmodule' => array('hidden', array('value' => 1)), 'module_class' => array('hidden', array('value' => $moduleClass)), 'name' => array('text', array('label' => 'Name', 'required' => true, 'description' => 'A descriptive name of the module.', 'value' => $module->getName())))));
             if (!$target) {
                 // Show only acceptable targets...
                 $form->addElement('select', 'target', array('label' => 'Target', 'description' => 'Specifies what placeholder/variable in the page-template to attach this module to.', 'multiOptions' => $targets));
             } else {
                 $form->addElement('hidden', 'target', array('value' => $target));
                 $form->setCsrfCheck(false);
                 $_POST = $form->getValues();
             }
             $form->addElement('submit', 'add', array('label' => 'Add module'));
             return $form;
         }
         if (!class_exists($moduleClass)) {
             throw new Exception('Class \'' . $moduleClass . '\' could not be loaded, please check the path and classname.');
         }
         $defaultName = substr($moduleClass, strrpos($moduleClass, '_') + 1);
         $targets[''] = '[ Custom ]';
         asort($targets);
         $templates = array('' => "[ None ]", 'new' => "[ Create new ]") + Curry_Backend_Template::getTemplateSelect();
         $defaultTemplateName = 'Modules/' . $defaultName . '.html';
         $defaultTemplate = '';
         if ($moduleClass !== 'Curry_Module_Article' && call_user_func(array($moduleClass, 'hasTemplate'))) {
             $defaultTemplate = array_key_exists($defaultTemplateName, $templates) ? $defaultTemplateName : 'new';
         }
         $predefinedTemplates = call_user_func(array($moduleClass, 'getPredefinedTemplates'));
         $predefinedTemplates = count($predefinedTemplates) ? array_combine(array_keys($predefinedTemplates), array_keys($predefinedTemplates)) : array();
         $predefinedTemplates = array('' => '[ Empty ]') + $predefinedTemplates;
         $form = new Curry_Form(array('action' => url('', $_GET), 'method' => 'post', 'class' => isAjax() ? 'dialog-form' : '', 'elements' => array('pid_newmodule' => array('hidden'), 'module_class' => array('hidden', array('value' => $moduleClass)), 'module_class_display' => array('rawHtml', array('label' => 'Type', 'value' => '<input type="text" value="' . $moduleClass . '" disabled="disabled" />')), 'name' => array('text', array('label' => 'Name', 'required' => true, 'description' => 'A descriptive name of the module.', 'value' => $defaultName)), 'target' => array('select', array('label' => 'Target', 'description' => 'Specifies what placeholder/variable in the page-template to attach this module to.', 'value' => isset($_GET['target']) ? $_GET['target'] : null, 'multiOptions' => $targets, 'class' => 'trigger-change', 'onchange' => "\$('#target_name-label, #target_name-element').toggle(\$(this).val() == '');")), 'target_name' => array('text', array('label' => 'Target Name')), 'template' => array('select', array('class' => 'trigger-change', 'label' => 'Template', 'multiOptions' => $templates, 'value' => $defaultTemplate, 'onchange' => "\$('#template_name-label, #template_name-element, #predefined_template-label, #predefined_template-element').toggle(\$(this).val() == 'new');")), 'template_name' => array('text', array('label' => 'Name', 'value' => $defaultTemplateName)), 'predefined_template' => array('select', array('label' => 'Predefined template', 'multiOptions' => $predefinedTemplates)), 'content_visibility' => array('select', array('label' => 'Content Visibility', 'description' => 'Set the visibility of this module in the Content backend module.', 'multiOptions' => PageModulePeer::$contentVisiblityOptions, 'value' => PageModulePeer::CONTENT_VISIBILITY_ALWAYS, 'required' => true)), 'search_visibility' => array('checkbox', array('label' => 'Search Visibility', 'description' => 'If this module should be rendered when indexing pages.', 'value' => true, 'required' => true)))));
         $form->addDisplayGroup(array('position', 'content_visibility', 'search_visibility'), 'advanced', array('class' => 'advanced', 'legend' => 'Advanced'));
         $form->addElement('submit', 'add', array('label' => 'Add module'));
     }
     return $form;
 }
Example #5
0
 public function showRoles()
 {
     if (!$this->hasPermission(self::PERMISSION_ROLES)) {
         throw new Exception('You dont have permission to access this view.');
     }
     $this->addMenu();
     $user = User::getUser();
     $backendModules = AbstractLegacyBackend::getBackendList();
     $disable = array();
     $backend = array("*" => "All");
     if (!$user->hasAccess('*')) {
         $disable[] = '*';
     }
     foreach ($backendModules as $backendClass => $backendName) {
         $backend[$backendClass] = $backendName;
         $permissions = method_exists($backendClass, 'getPermissions') ? call_user_func(array($backendClass, 'getPermissions')) : array();
         foreach ($permissions as $permission) {
             $backend[$backendClass . "/" . $permission] = "   " . $permission;
             if (!$user->hasAccess($backendClass . "/" . $permission)) {
                 $disable[] = $backendClass . "/" . $permission;
             }
         }
         if (!$user->hasAccess($backendClass)) {
             $disable[] = $backendClass;
         }
     }
     $content = array();
     $contentAccess = array("*" => "All") + AbstractModule::getModuleList();
     $allContentAccess = $user->hasAccess('Curry_Backend_Content/*');
     foreach ($contentAccess as $k => $v) {
         $content['Curry_Backend_Content/' . $k] = $v;
         if (!$allContentAccess && !$user->hasAccess('Curry_Backend_Content/' . $k)) {
             $disable[] = 'Curry_Backend_Content/' . $k;
         }
     }
     $form = new Curry_ModelView_Form('UserRole', array('elements' => array('backend' => array('multiselect', array('label' => 'Curry\\Controller\\Backend access', 'multiOptions' => $backend, 'size' => 10, 'order' => 1, 'disable' => $disable, 'validators' => array(array('InArray', true, array(array_diff(array_keys($backend), $disable)))))), 'content' => array('multiselect', array('label' => 'Content access', 'multiOptions' => $content, 'size' => 10, 'order' => 2, 'disable' => $disable, 'validators' => array(array('InArray', true, array(array_diff(array_keys($content), $disable))))))), 'onFillForm' => function (UserRole $role, $form) {
         $access = UserRoleAccessQuery::create()->filterByUserRole($role)->select('Module')->find()->getArrayCopy();
         $form->backend->setValue($access);
         $form->content->setValue($access);
     }, 'onFillModel' => function (UserRole $role, $form, $values) {
         $access = array_merge((array) $values['backend'], (array) $values['content']);
         $collection = new PropelObjectCollection();
         $collection->setModel('UserRoleAccess');
         foreach ($access as $a) {
             $ura = new UserRoleAccess();
             $ura->setModule($a);
             $collection->append($ura);
         }
         $role->setUserRoleAccesss($collection);
     }));
     $q = UserRoleQuery::create();
     $list = new Curry_ModelView_List($q, array('modelForm' => $form));
     $list->addAction('file_permissions', array('action' => $this->getFileAccessList(), 'class' => 'inline', 'single' => true));
     $this->addMainContent($list);
 }