Example #1
0
 /**
  * @param $object     object|string object or class name
  * @param $parameters string[] parameters
  * @return Button[]
  */
 protected function getGeneralButtons($object, $parameters)
 {
     $buttons = parent::getGeneralButtons($object, $parameters);
     $close_link = View::link(Names::classToSet(get_class($object)));
     list($close_link) = $this->prepareThen($object, $parameters, $close_link);
     return array_merge($buttons, [Feature::F_CLOSE => new Button('Close', $close_link, Feature::F_CLOSE, [new Color('close'), Target::MAIN])]);
 }
Example #2
0
 /**
  * @param $object     object|string object or class name
  * @param $parameters string[] parameters
  * @return Button[]
  */
 protected function getGeneralButtons($object, $parameters)
 {
     list($close_link, $follows) = $this->prepareThen($object, $parameters, View::link($object));
     $buttons = parent::getGeneralButtons($object, $parameters);
     unset($buttons['edit']);
     $fill_combo = isset($parameters['fill_combo']) ? ['fill_combo' => $parameters['fill_combo']] : [];
     return array_merge($buttons, [Feature::F_CLOSE => new Button('Close', $close_link, Feature::F_CLOSE, [new Color(Feature::F_CLOSE), Target::MAIN]), Feature::F_WRITE => new Button('Write', View::link($object, Feature::F_WRITE, null, array_merge($fill_combo, $follows)), Feature::F_WRITE, [new Color(Color::GREEN), Target::MESSAGES, '.submit'])]);
 }
Example #3
0
 /**
  * @param $parameters Parameters
  * @param $form       array
  * @param $files      array
  * @param $class_name string
  * @return mixed
  */
 public function run(Parameters $parameters, $form, $files, $class_name)
 {
     $sub_feature = $parameters->shiftUnnamed();
     if (!$sub_feature) {
         $sub_feature = 'form';
     }
     $get = $parameters->toGet();
     return (new Main())->runController(View::link($class_name, Feature::F_IMPORT), $get, $form, $files, 'import' . ucfirst($sub_feature));
 }
Example #4
0
 /**
  * @param $class_name string object or class name
  * @param $parameters string[] parameters
  * @return Button[]
  */
 protected function getGeneralButtons($class_name, $parameters)
 {
     return [Feature::F_ADD => new Button('Add', View::link($class_name, Feature::F_ADD), Feature::F_ADD, [Target::MAIN, new Color(Color::GREEN)]), Feature::F_IMPORT => new Button('Import', View::link($class_name, Feature::F_IMPORT), Feature::F_IMPORT, [Target::MAIN, new Color(Color::GREEN)]), Feature::F_WRITE => new Button('Save', View::link($this->class_names), 'custom_save', [Target::MAIN, new Color(Color::GREEN), '.submit', 'title' => 'save this view as a custom list']), Feature::F_DELETE => new Button('Delete', View::link($this->class_names, null, null, ['delete_name' => true]), 'custom_delete', [Target::MAIN, new Color(Color::RED), '.submit', 'title' => 'delete this custom list'])];
 }
Example #5
0
 /**
  * Prepare close link and follows links for buttons
  *
  * @example Call this from getGeneralButtons() :
  * list($close_link, $follows) = $this->prepareThen($object, $parameters);
  * Then use $close_link and $follows as needed
  * @param $object             object
  * @param $parameters         array
  * @param $default_close_link string
  * @return array first element is the close link, second element is an array of a link parameter
  */
 protected function prepareThen($object, $parameters, $default_close_link = null)
 {
     if (isset($parameters[Controller::THEN])) {
         $close_link = $parameters[Controller::THEN];
         $follows = [Controller::THEN => $parameters[Controller::THEN]];
     } else {
         $close_link = $default_close_link ?: View::link(Names::classToSet(get_class($object)));
         $follows = [];
     }
     return [$close_link, $follows];
 }
 /**
  * @param $class_name string object or class name
  * @return Button[]
  */
 protected function getGeneralButtons($class_name)
 {
     return [Feature::F_WRITE => new Button('Save', View::link($class_name, Feature::F_IMPORT, 'preview'), 'custom_save', [new Color(Color::BLUE), Target::MAIN, '.submit']), Feature::F_DELETE => new Button('Delete', View::link($class_name, Feature::F_IMPORT, 'preview', ['delete_name' => true]), 'custom_delete', [new Color(Color::RED), Target::MAIN, '.submit'])];
 }
Example #7
0
 /**
  * @param $class_name Object
  * @return Button
  */
 protected function getGeneralButtons($class_name)
 {
     return new Button('Add', View::link($class_name, Feature::F_ADD), Feature::F_ADD, [Target::MAIN, '.submit']);
 }
Example #8
0
 /**
  * @param $file File
  * @return Anchor
  */
 protected function buildFileAnchor(File $file)
 {
     /** @var $session_files Files */
     $session_files = Session::current()->get(Files::class, true);
     $session_files->files[] = $file;
     $image = $file->getType()->is('image') ? new Image(View::link(Session_File::class, 'output', [$file->name], ['size' => 22])) : '';
     $anchor = new Anchor(View::link(Session_File::class, 'image', [$file->name]), $image . new Span($file->name));
     if ($file->getType()->is('image')) {
         $anchor->setAttribute('target', Target::BLANK);
         //$anchor->addClass('popup');
     }
     return $anchor;
 }
Example #9
0
 /**
  * Returns a link to the nearest object
  *
  * @param $template Template
  * @param $feature  string
  * @return string
  */
 public function getLink(Template $template, $feature = null)
 {
     foreach ($template->objects as $object) {
         if (is_object($object)) {
             return View::link($object, $feature);
         }
     }
     return null;
 }