Exemplo n.º 1
0
 /**
  * Render the form for removing a dashboard elemetn
  *
  * @return string                       The html representation of the form
  */
 protected function getRemoveForm()
 {
     // TODO: temporarily disabled, should point to a form asking for confirmal
     return '';
     $removeUrl = Url::fromPath('/dashboard/removecomponent', array('pane' => $this->pane->getName(), 'component' => $this->getTitle()));
     $form = new Form();
     $form->setMethod('POST');
     $form->setAttrib('class', 'inline');
     $form->setAction($removeUrl);
     $form->addElement(new Zend_Form_Element_Button('remove_pane_btn', array('class' => 'link-like pull-right', 'type' => 'submit', 'label' => 'x')));
     return $form;
 }
Exemplo n.º 2
0
 public function updateDashletAction()
 {
     $this->createTabs();
     $dashboard = $this->dashboard;
     $form = new DashletForm();
     $form->setDashboard($dashboard);
     $form->setSubmitLabel($this->translate('Update Dashlet'));
     if (!$this->_request->getParam('pane')) {
         throw new Zend_Controller_Action_Exception('Missing parameter "pane"', 400);
     }
     if (!$this->_request->getParam('dashlet')) {
         throw new Zend_Controller_Action_Exception('Missing parameter "dashlet"', 400);
     }
     $action = $this;
     $form->setOnSuccess(function (Form $form) use($dashboard, $action) {
         try {
             $pane = $dashboard->getPane($form->getValue('pane'));
         } catch (ProgrammingError $e) {
             $pane = new Dashboard\Pane($form->getValue('pane'));
             $pane->setUserWidget();
             $dashboard->addPane($pane);
         }
         try {
             $dashlet = $pane->getDashlet($form->getValue('dashlet'));
             $dashlet->setUrl($form->getValue('url'));
         } catch (ProgrammingError $e) {
             $dashlet = new Dashboard\Dashlet($form->getValue('dashlet'), $form->getValue('url'), $pane);
             $pane->addDashlet($dashlet);
         }
         $dashlet->setUserWidget();
         // Rename dashlet
         if ($form->getValue('org_dashlet') && $form->getValue('org_dashlet') !== $dashlet->getTitle()) {
             $pane->removeDashlet($form->getValue('org_dashlet'));
         }
         // Move
         if ($form->getValue('org_pane') && $form->getValue('org_pane') !== $pane->getTitle()) {
             $oldPane = $dashboard->getPane($form->getValue('org_pane'));
             $oldPane->removeDashlet($dashlet->getTitle());
         }
         $dashboardConfig = $dashboard->getConfig();
         try {
             $dashboardConfig->saveIni();
         } catch (Exception $e) {
             $action->view->error = $e;
             $action->view->config = $dashboardConfig;
             $action->render('error');
             return false;
         }
         Notification::success(t('Dashlet updated'));
         return true;
     });
     $form->setTitle($this->translate('Edit Dashlet'));
     $form->setRedirectUrl('dashboard/settings');
     $form->handleRequest();
     $pane = $dashboard->getPane($this->getParam('pane'));
     $dashlet = $pane->getDashlet($this->getParam('dashlet'));
     $form->load($dashlet);
     $this->view->form = $form;
 }
Exemplo n.º 3
0
 /**
  * Add a pane object to this dashboard
  *
  * @param Pane $pane        The pane to add
  *
  * @return $this
  */
 public function addPane(Pane $pane)
 {
     $this->panes[$pane->getName()] = $pane;
     return $this;
 }
Exemplo n.º 4
0
 /**
  * Load all config panes from @see Dashboard::$config
  *
  */
 private function loadConfigPanes()
 {
     $items = $this->config;
     foreach ($items->keys() as $key) {
         $item = $this->config->get($key, false);
         if (false === strstr($key, '.')) {
             $this->addPane(Pane::fromIni($key, $item));
         } else {
             list($paneName, $title) = explode('.', $key, 2);
             $pane = $this->getPane($paneName);
             $pane->addComponent(DashboardComponent::fromIni($title, $item, $pane));
         }
     }
 }
Exemplo n.º 5
0
 /**
  * Create a new pane with the title $title from the given configuration
  *
  * @param $title                The title for this pane
  * @param ConfigObject  $config The configuration to use for setup
  *
  * @return Pane
  */
 public static function fromIni($title, ConfigObject $config)
 {
     $pane = new Pane($title);
     if ($config->get('title', false)) {
         $pane->setTitle($config->get('title'));
     }
     return $pane;
 }