Beispiel #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('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;
 }
Beispiel #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('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;
 }
 private function LoadData()
 {
     $parser = new ParseFile();
     $this->data = $parser->RunParse('dane.txt', ' ');
 }
 /**
  * ParseClient::_decode, internal method for decoding server responses.
  *
  * @param mixed $data The value to decode
  *
  * @return mixed
  * @ignore
  */
 public static function _decode($data)
 {
     // The json decoded response from Parse will make JSONObjects into stdClass
     //   objects.  We'll change it to an associative array here.
     if ($data instanceof \stdClass) {
         $tmp = (array) $data;
         if (!empty($tmp)) {
             return self::_decode(get_object_vars($data));
         }
     }
     if (!$data && !is_array($data)) {
         return null;
     }
     if (is_array($data)) {
         $typeString = isset($data['__type']) ? $data['__type'] : null;
         if ($typeString === 'Date') {
             return new \DateTime($data['iso']);
         }
         if ($typeString === 'Bytes') {
             return base64_decode($data['base64']);
         }
         if ($typeString === 'Pointer') {
             return ParseObject::create($data['className'], $data['objectId']);
         }
         if ($typeString === 'File') {
             return ParseFile::_createFromServer($data['name'], $data['url']);
         }
         if ($typeString === 'GeoPoint') {
             return new ParseGeoPoint($data['latitude'], $data['longitude']);
         }
         if ($typeString === 'Object') {
             $output = ParseObject::create($data['className']);
             $output->_mergeAfterFetch($data);
             return $output;
         }
         if ($typeString === 'Relation') {
             return $data;
         }
         $newDict = array();
         foreach ($data as $key => $value) {
             $newDict[$key] = static::_decode($value);
         }
         return $newDict;
     }
     return $data;
 }
Beispiel #5
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'));
     }
 }