Exemple #1
0
 /**
  * handle tree edit
  */
 private function handleTreeEditGet($retrieveFields = true)
 {
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $view->setType(ViewManager::TREE_EDIT);
     if (!$request->exists('id')) {
         throw new Exception('Link is missing.');
     }
     $id = intval($request->getValue('id'));
     $template->setVariable('id', $id, false);
     $key = array('id' => $id);
     if ($retrieveFields) {
         $fields = $this->getDetail($key);
     } else {
         $fields = $this->getFields(SqlParser::MOD_UPDATE);
         $detail = $this->getDetail($key);
         $fields['image'] = $detail['image'];
     }
     $this->setFields($fields);
     if ($fields['image']) {
         $img = new Image($fields['image'], $this->getContentPath(true));
         $fields['image'] = array('src' => $this->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
     }
     $template->setVariable($fields, NULL, false);
     $this->handleTreeSettings($template);
     $template->setVariable('fckBox', $this->getEditor($fields['text']), false);
     // get all tree nodes which have plugin modules
     $site = new SystemSite();
     $tree = $site->getTree();
     $treelist = $tree->getList();
     foreach ($treelist as &$item) {
         $item['name'] = $tree->toString($item['id'], '/', 'name');
     }
     $template->setVariable('cbo_tree_id', Utils::getHtmlCombo($treelist, $fields['ref_tree_id'], '...'));
     // get crop settings
     $settings = $this->plugin->getObject(Links::TYPE_SETTINGS)->getSettings($fields['tag'], $fields['tree_id']);
     //only crop if both width and height defaults are set
     if ($fields['image'] && $settings['image_width'] && $settings['image_height'] && ($fields['image']['width'] > $settings['image_width'] || $fields['image']['height'] > $settings['image_height'])) {
         $theme = $this->director->theme;
         $parseFile = new ParseFile();
         $parseFile->setVariable($fields, NULL, false);
         $parseFile->setVariable('imgTag', 'imgsrc', false);
         $parseFile->setVariable($settings, NULL, false);
         $parseFile->setSource($this->getHtdocsPath(true) . "js/cropinit.js.in");
         //$parseFile->setDestination($this->getCachePath(true)."cropinit_tpl_content.js");
         //$parseFile->save();
         $theme->addJavascript($parseFile->fetch());
         //$this->headers[] = '<script type="text/javascript" src="'.$this->getCachePath().'cropinit_tpl_content.js"></script>';
         $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/prototype.js"></script>');
         $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/scriptaculous.js"></script>');
         $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/cropper.js"></script>');
         $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/mint.js"></script>');
     }
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }
Exemple #2
0
 /**
  * handle tree edit
  */
 private function handleTreeEditGet($retrieveFields = true)
 {
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $view->setType(ViewManager::TREE_EDIT);
     if (!$request->exists('id')) {
         throw new Exception('Calendar id is missing.');
     }
     $id = intval($request->getValue('id'));
     $key = array('id' => $id);
     $template->setVariable($key);
     if ($retrieveFields) {
         $fields = $this->getDetail($key);
         $fields['start'] = $fields['start'] ? strftime('%Y-%m-%d', $fields['start']) : '';
         $fields['stop'] = $fields['stop'] ? strftime('%Y-%m-%d', $fields['stop']) : '';
     } else {
         $fields = $this->getFields(SqlParser::MOD_UPDATE);
         $detail = $this->getDetail($key);
         $fields['image'] = $detail['image'];
     }
     $this->setFields($fields);
     if ($fields['image']) {
         $img = new Image($fields['image'], $this->plugin->getContentPath(true));
         $fields['image'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
     }
     $template->setVariable($fields);
     $this->handleTreeSettings($template);
     $template->setVariable('fckBox', $this->getEditor($fields['text']));
     $datefields = array();
     $datefields[] = array('dateField' => 'start', 'triggerElement' => 'start');
     $datefields[] = array('dateField' => 'stop', 'triggerElement' => 'stop');
     Utils::getDatePicker($this->director->theme, $datefields);
     // get crop settings
     $settings = $this->plugin->getSettings();
     //only crop if both width and height defaults are set
     if ($fields['image'] && $settings['image_width'] && $settings['image_height'] && ($fields['image']['width'] > $settings['image_width'] || $fields['image']['height'] > $settings['image_height'])) {
         $theme = $this->director->theme;
         $parseFile = new ParseFile();
         $parseFile->setVariable($fields);
         $parseFile->setVariable('imgTag', 'imgsrc');
         $parseFile->setVariable($settings);
         $parseFile->setSource($this->plugin->getHtdocsPath(true) . "js/cropinit.js.in");
         //$parseFile->setDestination($this->plugin->getCachePath(true)."cropinit_tpl_content.js");
         //$parseFile->save();
         $theme->addJavascript($parseFile->fetch());
         $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/prototype.js"></script>');
         $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/scriptaculous.js"></script>');
         $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/cropper.js"></script>');
         $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/mint.js"></script>');
     }
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }
Exemple #3
0
 private function handlePulldownMenu($settings, $template)
 {
     $this->handleMenu($settings, $template);
     $tag = $settings['tag'];
     $cssId = "menu{$tag}";
     $template->setVariable('cssid', $cssId);
     // parse unique stylesheet
     switch ($settings['type']) {
         case self::TYPE_HORIZONTAL_PULLDOWN:
             $cssfile = 'menu_horizontal_pulldown.css.in';
             break;
         case self::TYPE_VERTICAL_PULLDOWN:
             $cssfile = 'menu_vertical_pulldown.css.in';
             break;
         default:
             $cssfile = '';
     }
     if ($cssfile) {
         // retrieve tag to postfix scripts and stylesheets for uniqueness (there can be more than 1 banner in a single page)
         $cachePath = $this->getCachePath(true);
         $htdocsPath = $this->getHtdocsPath(true);
         $parseFile = new ParseFile();
         $parseFile->setVariable('cssid', $cssId, false);
         $parseFile->setVariable($settings, NULL, false);
         $parseFile->setVariable($this->director->theme->getFileVars(), NULL, false);
         // parse unique stylesheet
         $parseFile->setSource($htdocsPath . "css/{$cssfile}");
         //$parseFile->setDestination($cachePath."menu_$tag.css");
         //$parseFile->save();
         $theme->addStylesheet($parseFile->fetch());
         // parse unique javascript
         $parseFile->setSource($htdocsPath . "js/menuinit.js.in");
         //$parseFile->setDestination($cachePath."menuinit_$tag.js");
         //$parseFile->save();
         $theme->addJavascript($parseFile->fetch());
         $theme->addJavascript(file_get_contents($this->getHtdocsPath(true) . 'js/menu.js'));
     }
 }