function tthemegeneratorInstall($self) { if (!ttheme::exists('generator')) { die('Theme "generator" not exists'); } //litepublisher::$urlmap->addget('/theme-generator.htm', get_class($self)); $about = tplugins::getabout(tplugins::getname(__FILE__)); $name = basename(dirname(__FILE__)); $merger = tlocalmerger::i(); $merger->lock(); $merger->add('themegenerator', "plugins/{$name}/res/scheme.ini"); $merger->add('themegenerator', sprintf('plugins/%s/res/%s.ini', $name, litepublisher::$options->language)); $merger->unlock(); $js = tjsmerger::i(); $js->lock(); $js->add('themegenerator', '/plugins/colorpicker/js/colorpicker.js'); $js->add('themegenerator', '/js/swfupload/swfupload.js'); $js->add('themegenerator', sprintf('/plugins/%s/themegenerator.min.js', basename(dirname(__FILE__)))); $js->addlang('themegenerator', 'lang', array('upload_header' => $about['upload_header'], 'upload_logo' => $about['upload_logo'])); $js->unlock(); $dir = litepublisher::$paths->files . 'themegen'; if (!is_dir($dir)) { mkdir($dir, 0777); @chmod($dir, 0777); file_put_contents($dir . DIRECTORY_SEPARATOR . 'index.htm', ' '); @chmod($dir . DIRECTORY_SEPARATOR . 'index.htm', 0666); } tcron::i()->addnightly(get_class($self), 'cron', null); $self->lock(); $self->title = $about['name']; $views = tviews::i(); $self->idview = $views->add($about['name']); $view = tview::i($self->idview); $view->themename = 'generator'; $self->leftview = $views->add($about['left']); $view = tview::i($self->leftview); $view->themename = 'generator-left'; $self->rightview = $views->add($about['right']); $view = tview::i($self->rightview); $view->themename = 'generator-right'; $self->url = '/theme-generator.htm'; $self->content = get_themegen_content($self); $self->parseselectors(); $menus = tmenus::i(); $menus->lock(); $menus->add($self); $fake = new tfakemenu(); $fake->title = $about['left']; $fake->url = $self->url . '?type=left'; $fake->parent = $self->id; $menus->add($fake); $fake = new tfakemenu(); $fake->title = $about['right']; $fake->url = $self->url . '?type=right'; $fake->parent = $self->id; $menus->add($fake); $menus->unlock(); $self->unlock(); litepublisher::$urlmap->setvalue($self->idurl, 'type', 'get'); }
public function request($arg) { $this->cache = false; $id = self::getget('id'); $sidebar = self::getget('sidebar'); $this->idurlcontext = self::getget('idurl'); if ($id === false || $sidebar === false || !$this->itemexists($id)) { return $this->error_request('Invalid params'); } $themename = isset($_GET['themename']) ? trim($_GET['themename']) : tview::i(1)->themename; if (!preg_match('/^\\w[\\w\\.\\-_]*+$/', $themename) || !ttheme::exists($themename)) { $themename = tviews::i(1)->themename; } $theme = ttheme::getinstance($themename); try { $result = $this->getwidgetcontent($id, $sidebar); return turlmap::htmlheader(false) . $result; } catch (Exception $e) { return $this->error_request('Cant get widget content'); } }
public function gettheme() { if (isset($this->themeinstance)) { return $this->themeinstance; } if (ttheme::exists($this->themename)) { $this->themeinstance = $this->get_theme_instance($this->themename); $viewcustom =& $this->data['custom']; $themecustom =& $this->themeinstance->templates['custom']; //aray_equal if (count($viewcustom) == count($themecustom) && !count(array_diff(array_keys($viewcustom), array_keys($themecustom)))) { $this->themeinstance->templates['custom'] = $viewcustom; } else { $this->data['custom'] = $themecustom; $this->save(); } } else { $this->setthemename('default'); } return $this->themeinstance; }