protected function process() { $data = $this->preparse_data(); $data = $this->parse_data($data); $save = Request::from(['path' => Operation::encode("{$this->module}/save")], [$_SERVER]); # # override form # $core->events->attach(function (Operation\GetFormEvent $event, SaveOperation $operation) use($save) { if ($event->request !== $save) { return; } $event->form = new Form(); }); /* $siteid = $core->site_id; $keys = $core->models['nodes']->select('nid')->filter_by_siteid($siteid)->all(\PDO::FETCH_COLUMN); if ($keys) { $core->models['nodes']->where([ 'nid' => $keys ])->delete(); $core->models['pages']->where([ 'nid' => $keys ])->delete(); $core->models['pages/contents']->where([ 'pageid' => $keys ])->delete(); } */ $this->import($data, $save); $this->response->message = "Records were successfuly imported."; return true; }
protected function preview($path) { global $core; $w = $this->w; $h = $this->h; $url = Operation::encode('thumbnailer/get', array('src' => $path, 'w' => $w, 'h' => $h, 'format' => 'jpeg', 'quality' => 90, 'background' => 'silver,white,medium', 'uniqid' => uniqid())); $img = new Element('img', array('src' => $url, 'width' => $w, 'height' => $h, 'alt' => '')); $repository = $core->config['repository.temp']; if (strpos($path, $repository) === 0) { return $img; } return '<a href="' . $path . '&uniqid=' . uniqid() . '" rel="lightbox">' . $img . '</a>'; }
public static function create_attachment($entry, $hard_bond = false) { global $core; $hiddens = null; $links = array(); $i = uniqid(); $size = \ICanBoogie\I18n\format_size($entry->size); $preview = null; if ($entry instanceof Uploaded) { $title = $entry->name; $extension = $entry->extension; $hiddens .= '<input type="hidden" class="file" name="nodes_attachments[' . $i . '][file]" value="' . \ICanBoogie\escape(basename($entry->location)) . '" />' . PHP_EOL; $hiddens .= '<input type="hidden" name="nodes_attachments[' . $i . '][mime]" value="' . \ICanBoogie\escape($entry->mime) . '" />' . PHP_EOL; $links = array('<a href="#remove" class="btn btn-warning">' . I18n\t('label.remove') . '</a>'); } else { $fid = $entry->nid; $title = $entry->title; $extension = substr($entry->path, strrpos($entry->path, '.')); $hiddens .= '<input type="hidden" name="nodes_attachments[' . $i . '][fileid]" value="' . $fid . '" />'; $links = array('<a href="' . \ICanBoogie\Routing\contextualize('/admin/files/' . $fid . '/edit') . '" class="btn"><i class="icon-pencil"></i> ' . I18n\t('label.edit') . '</a>', '<a href="' . Operation::encode('files/' . $fid . '/download') . '" class="btn"><i class="icon-download-alt"></i> ' . I18n\t('label.download') . '</a>', $hard_bond ? '<a href="#delete" class="btn btn-danger"><i class="icon-remove icon-white"></i> ' . I18n\t('Delete file') . '</a>' : '<a href="#remove" class="btn btn-warning"><i class="icon-remove"></i> ' . t('Break link') . '</a>'); $node = $core->models['nodes'][$entry->nid]; if ($node instanceof \Icybee\Modules\Images\Image) { $preview = $node->thumbnail('$icon')->to_element(array('data-popover-image' => $node->thumbnail('$popup')->url)); } } $title = \ICanBoogie\escape($title); $links = empty($links) ? '' : ' – ' . implode(' ', $links); if ($extension) { $extension = '<span class="lighter">(' . $extension . ')</span>'; } return <<<EOT <li> \t<span class="handle">↕</span>{$preview}<input type="text" name="nodes_attachments[{$i}][title]" value="{$title}" /> \t<span class="small"> \t\t<span class="info light">{$size} {$extension}</span> {$links} \t</span> \t{$hiddens} </li> EOT; }
/** * Replaces managed images with width or height attributes by thumbnails, and transform markup * when the original image can be displayed in a lightbox. * * @see Icybee\Modules\Editor.Editor::render() */ public function render($content) { return preg_replace_callback('#<img\\s+[^>]+>#', function ($match) { global $core; preg_match_all('#([\\w\\-]+)\\s*=\\s*\\"([^"]+)#', $match[0], $attributes); $attributes = array_combine($attributes[1], $attributes[2]); $attributes = array_map(function ($v) { return html_entity_decode($v, ENT_COMPAT, \ICanBoogie\CHARSET); }, $attributes); $attributes += array('width' => null, 'height' => null, 'data-nid' => null); $w = $attributes['width']; $h = $attributes['height']; $nid = $attributes['data-nid']; if ($w && $h && $nid) { $attributes['src'] = Operation::encode('images/' . $nid . '/' . $w . 'x' . $h); } else { if (($w || $h) && preg_match('#^/repository/files/image/(\\d+)#', $attributes['src'], $matches)) { $nid = $matches[1]; $options = $attributes; unset($options['src']); $thumbnail = new Thumbnail($core->models['images'][$nid], $options); $attributes['src'] = $thumbnail->url; } } $path = null; if (isset($attributes['data-lightbox']) && $nid) { $attributes['src'] = preg_replace('#\\&lightbox=true#', '', $attributes['src']); $path = $core->models['images']->select('path')->filter_by_nid($nid)->rc; } unset($attributes['data-nid']); unset($attributes['data-lightbox']); $rc = (string) new Element('img', $attributes); if ($path) { $rc = '<a href="' . \ICanBoogie\escape($path) . '" rel="lightbox[]">' . $rc . '</a>'; } return $rc; }, $content); }
/** * Clears the `core.modules`, `core.configs` and `core.catalogs` caches. */ public static function clear_modules_cache() { Request::from(Operation::encode('cache/core.modules/clear'))->post(); Request::from(Operation::encode('cache/core.configs/clear'))->post(); Request::from(Operation::encode('cache/core.catalogs/clear'))->post(); }
public function __construct(array $attributes = array()) { $attributes += [self::POP_OPTIONS => [], self::UPLOAD_OPTIONS => []]; parent::__construct('div', $attributes + array(Element::CHILDREN => array($this->pop_image = new PopImage($attributes[self::POP_OPTIONS]), $this->upload_image = new UploadImage($attributes[self::UPLOAD_OPTIONS] + [UploadImage::FILE_WITH_LIMIT => true, 'data-name' => Image::PATH, 'data-upload-url' => Operation::encode('images/save')])), Element::WIDGET_CONSTRUCTOR => 'PopOrUploadImage')); }
/** * Revokes the cache. */ public static function revoke() { Request::from(Operation::encode('cache/icybee.views/clear'))->post(); }