Beispiel #1
0
 protected function _parse_schemes_css_code()
 {
     foreach (Plugin::instance()->widgets_manager->get_widget_types() as $widget) {
         foreach ($widget->get_scheme_controls() as $control) {
             $scheme_value = Plugin::instance()->schemes_manager->get_scheme_value($control['scheme']['type'], $control['scheme']['value']);
             if (empty($scheme_value)) {
                 continue;
             }
             if (!empty($control['scheme']['key'])) {
                 $scheme_value = $scheme_value[$control['scheme']['key']];
             }
             if (empty($scheme_value)) {
                 continue;
             }
             $element_unique_class = 'elementor-widget-' . $widget->get_name();
             $control_obj = Plugin::instance()->controls_manager->get_control($control['type']);
             if (Controls_Manager::FONT === $control_obj->get_type()) {
                 $this->add_enqueue_font($scheme_value);
             }
             foreach ($control['selectors'] as $selector => $css_property) {
                 $output_selector = str_replace('{{WRAPPER}}', '.' . $element_unique_class, $selector);
                 $output_css_property = $control_obj->get_replaced_style_values($css_property, $scheme_value);
                 $this->stylesheet->add_rules($output_selector, $output_css_property);
             }
         }
     }
 }
 public function __construct($node, $parent)
 {
     parent::__construct($node, $parent);
     self::$possible_attributes = array_merge(parent::$possible_attributes, self::$possible_attributes);
     self::$required_attributes = array_merge(parent::$required_attributes, self::$required_attributes);
     self::$possible_children = array_merge(parent::$possible_children, self::$possible_children);
     self::$required_children = array_merge(parent::$required_children, self::$required_children);
 }
 /**
  * Creates a new response object
  *
  * @return  scriptlet.xml.XMLScriptletResponse
  */
 protected function newResponse(Stylesheet $stylesheet)
 {
     $res = new XMLScriptletResponse();
     $res->setProcessor(new DOMXSLProcessor());
     $stylesheet->addParam('__state');
     $stylesheet->addParam('__page');
     $stylesheet->addParam('__lang');
     $stylesheet->addParam('__product');
     $stylesheet->addParam('__sess');
     $stylesheet->addParam('__query');
     $res->setStylesheet($stylesheet, XSLT_TREE);
     return $res;
 }
Beispiel #4
0
 private function add_control_style_rules($control, $value, $placeholders, $replacements)
 {
     if (!is_numeric($value) && !is_float($value) && empty($value)) {
         return;
     }
     if (Controls_Manager::FONT === $control['type']) {
         $this->fonts[] = $value;
     }
     $control_obj = Plugin::instance()->controls_manager->get_control($control['type']);
     foreach ($control['selectors'] as $selector => $css_property) {
         $parsed_css_property = $control_obj->get_replaced_style_values($css_property, $value);
         if (!$parsed_css_property) {
             continue;
         }
         $parsed_selector = str_replace($placeholders, $replacements, $selector);
         $device = !empty($control['responsive']) ? $control['responsive'] : Element_Base::RESPONSIVE_DESKTOP;
         $this->stylesheet_obj->add_rules($parsed_selector, $parsed_css_property, $device);
     }
 }
Beispiel #5
0
 /**
  * Renders the HTML to PDF
  */
 function render()
 {
     $this->_process_html();
     $this->_css->apply_styles($this->_tree);
     $root = null;
     foreach ($this->_tree->get_frames() as $frame) {
         // Set up the root frame
         if (is_null($root)) {
             $root = Frame_Factory::decorate_root($this->_tree->get_root());
             continue;
         }
         // Create the appropriate decorators, reflowers & positioners.
         $deco = Frame_Factory::decorate_frame($frame, $this);
         $deco->set_root($root);
         // FIXME: handle generated content
         if ($frame->get_style()->display == "list-item" && in_array($frame->get_style()->list_style_type, List_Bullet_Frame_Decorator::$BULLET_TYPES)) {
             // Insert a list-bullet frame
             $node = $this->_xml->createElement("bullet");
             // arbitrary choice
             $b_f = new Frame($node);
             $style = $this->_css->create_style();
             $style->display = "-dompdf-list-bullet";
             $style->inherit($frame->get_style());
             $b_f->set_style($style);
             $deco->prepend_child(Frame_Factory::decorate_frame($b_f));
         }
     }
     $this->_pdf = Canvas_Factory::get_instance($this->_paper_size, $this->_orientation);
     $root->set_containing_block(0, 0, $this->_pdf->get_width(), $this->_pdf->get_height());
     // This is where the magic happens:
     $root->reflow();
     $renderer = new Renderer($this->_pdf);
     $renderer->render($root);
 }
Beispiel #6
0
if (strpos($ruri, '?') === false) {
    $params = '';
    $path = $ruri;
} else {
    list($path, $params) = preg_split('/\\?/', $ruri, 2);
}
$special = array('css/icinga.css', 'css/icinga.min.css', 'js/icinga.dev.js', 'js/icinga.ie8.js', 'js/icinga.min.js');
if (in_array($path, $special)) {
    include_once __DIR__ . '/EmbeddedWeb.php';
    EmbeddedWeb::start();
    switch ($path) {
        case 'css/icinga.css':
            Stylesheet::send();
            exit;
        case 'css/icinga.min.css':
            Stylesheet::send(true);
            exit;
        case 'js/icinga.dev.js':
            JavaScript::send();
            exit;
        case 'js/icinga.min.js':
            JavaScript::sendMinified();
            break;
        case 'js/icinga.ie8.js':
            JavaScript::sendForIe8();
            break;
        default:
            return false;
    }
} elseif ($path === 'svg/chart.php') {
    if (!array_key_exists('data', $_GET)) {
Beispiel #7
0
 /**
  * Renders the HTML to PDF
  */
 function render()
 {
     $this->save_locale();
     $log_output_file = $this->get_option("log_output_file");
     if ($log_output_file) {
         if (!file_exists($log_output_file) && is_writable(dirname($log_output_file))) {
             touch($log_output_file);
         }
         $this->_start_time = microtime(true);
         ob_start();
     }
     //enable_mem_profile();
     $this->_process_html();
     $this->_css->apply_styles($this->_tree);
     // @page style rules : size, margins
     $page_styles = $this->_css->get_page_styles();
     $base_page_style = $page_styles["base"];
     unset($page_styles["base"]);
     foreach ($page_styles as $_page_style) {
         $_page_style->inherit($base_page_style);
     }
     if (is_array($base_page_style->size)) {
         $this->set_paper(array(0, 0, $base_page_style->size[0], $base_page_style->size[1]));
     }
     $this->_pdf = Canvas_Factory::get_instance($this, $this->_paper_size, $this->_paper_orientation);
     Font_Metrics::init($this->_pdf);
     if ($this->get_option("enable_font_subsetting") && $this->_pdf instanceof CPDF_Adapter) {
         foreach ($this->_tree->get_frames() as $frame) {
             $style = $frame->get_style();
             $node = $frame->get_node();
             // Handle text nodes
             if ($node->nodeName === "#text") {
                 $this->_pdf->register_string_subset($style->font_family, $node->nodeValue);
                 continue;
             }
             // Handle generated content (list items)
             if ($style->display === "list-item") {
                 $chars = List_Bullet_Renderer::get_counter_chars($style->list_style_type);
                 $this->_pdf->register_string_subset($style->font_family, $chars);
                 continue;
             }
             // Handle other generated content (pseudo elements)
             // FIXME: This only captures the text of the stylesheet declaration,
             //        not the actual generated content, and forces all possible counter
             //        values. See notes in issue #750.
             if ($frame->get_node()->nodeName == "dompdf_generated") {
                 // all possible counter values
                 $chars = List_Bullet_Renderer::get_counter_chars('decimal');
                 $this->_pdf->register_string_subset($style->font_family, $chars);
                 $chars = List_Bullet_Renderer::get_counter_chars('upper-alpha');
                 $this->_pdf->register_string_subset($style->font_family, $chars);
                 $chars = List_Bullet_Renderer::get_counter_chars('lower-alpha');
                 $this->_pdf->register_string_subset($style->font_family, $chars);
                 $chars = List_Bullet_Renderer::get_counter_chars('lower-greek');
                 $this->_pdf->register_string_subset($style->font_family, $chars);
                 // the text of the stylesheet declaration
                 $this->_pdf->register_string_subset($style->font_family, $style->content);
                 continue;
             }
         }
     }
     $root = null;
     foreach ($this->_tree->get_frames() as $frame) {
         // Set up the root frame
         if (is_null($root)) {
             $root = Frame_Factory::decorate_root($this->_tree->get_root(), $this);
             continue;
         }
         // Create the appropriate decorators, reflowers & positioners.
         Frame_Factory::decorate_frame($frame, $this, $root);
     }
     // Add meta information
     $title = $this->_xml->getElementsByTagName("title");
     if ($title->length) {
         $this->_pdf->add_info("Title", trim($title->item(0)->nodeValue));
     }
     $metas = $this->_xml->getElementsByTagName("meta");
     $labels = array("author" => "Author", "keywords" => "Keywords", "description" => "Subject");
     foreach ($metas as $meta) {
         $name = mb_strtolower($meta->getAttribute("name"));
         $value = trim($meta->getAttribute("content"));
         if (isset($labels[$name])) {
             $this->_pdf->add_info($labels[$name], $value);
             continue;
         }
         if ($name === "dompdf.view" && $this->parse_default_view($value)) {
             $this->_pdf->set_default_view($this->_default_view, $this->_default_view_options);
         }
     }
     $root->set_containing_block(0, 0, $this->_pdf->get_width(), $this->_pdf->get_height());
     $root->set_renderer(new Renderer($this));
     // This is where the magic happens:
     $root->reflow();
     // Clean up cached images
     Image_Cache::clear();
     global $_dompdf_warnings, $_dompdf_show_warnings;
     if ($_dompdf_show_warnings) {
         echo '<b>DOMPDF Warnings</b><br><pre>';
         foreach ($_dompdf_warnings as $msg) {
             echo $msg . "\n";
         }
         echo $this->get_canvas()->get_cpdf()->messages;
         echo '</pre>';
         flush();
     }
     $this->restore_locale();
 }
 protected function _image($val)
 {
     $DEBUGCSS = DEBUGCSS;
     $parsed_url = "none";
     if (mb_strpos($val, "url") === false) {
         $path = "none";
         //Don't resolve no image -> otherwise would prefix path and no longer recognize as none
     } else {
         $val = preg_replace("/url\\(['\"]?([^'\")]+)['\"]?\\)/", "\\1", trim($val));
         // Resolve the url now in the context of the current stylesheet
         $parsed_url = explode_url($val);
         if ($parsed_url["protocol"] == "" && $this->_stylesheet->get_protocol() == "") {
             if ($parsed_url["path"][0] === '/' || $parsed_url["path"][0] === '\\') {
                 $path = $_SERVER["DOCUMENT_ROOT"] . '/';
             } else {
                 $path = $this->_stylesheet->get_base_path();
             }
             $path .= $parsed_url["path"] . $parsed_url["file"];
             $path = realpath($path);
             // If realpath returns FALSE then specifically state that there is no background image
             if (!$path) {
                 $path = 'none';
             }
         } else {
             $path = build_url($this->_stylesheet->get_protocol(), $this->_stylesheet->get_host(), $this->_stylesheet->get_base_path(), $val);
         }
     }
     if ($DEBUGCSS) {
         print "<pre>[_image\n";
         print_r($parsed_url);
         print $this->_stylesheet->get_protocol() . "\n" . $this->_stylesheet->get_base_path() . "\n" . $path . "\n";
         print "_image]</pre>";
     }
     return $path;
 }
Beispiel #9
0
     $result = $db->Execute($query);
     if ($result && $result->RecordCount() > 0) {
         $error .= "<li>" . lang('cssalreadyused') . "</li>";
         $validinfo = false;
     }
 }
 # now checking the content of the CSS
 if ("" == $css_text) {
     $error .= "<li>" . lang('nofieldgiven', array(lang('content'))) . "</li>";
     $validinfo = false;
 }
 #******************************************************************************
 # everythings seems to be ok, we can try to save the form
 #******************************************************************************
 if ($validinfo) {
     $newstylesheet = new Stylesheet();
     $newstylesheet->name = $css_name;
     $newstylesheet->value = $css_text;
     $types = "";
     #generate comma separated list
     foreach ($media_type as $onetype) {
         $types .= "{$onetype}, ";
     }
     if ($types != '') {
         $types = substr($types, 0, -2);
         #strip last space and comma
     } else {
         $types = '';
     }
     $newstylesheet->media_type = $types;
     Events::SendEvent('Core', 'AddStylesheetPre', array('stylesheet' => &$newstylesheet));
Beispiel #10
0
 /**
  *  Minify, combine and load site stylesheet
  */
 public static function load()
 {
     $backend_site_css_path = MINIFY . DS . 'backend_site.minify.css';
     $frontend_site_css_path = MINIFY . DS . 'frontend_site.minify.css';
     // Load stylesheets
     if (count(Stylesheet::$stylesheets) > 0) {
         $backend_buffer = '';
         $backend_regenerate = false;
         $frontend_buffer = '';
         $frontend_regenerate = false;
         // Sort stylesheets by priority
         $stylesheets = Arr::subvalSort(Stylesheet::$stylesheets, 'priority');
         if (BACKEND) {
             // Build backend site stylesheets
             foreach ($stylesheets as $stylesheet) {
                 if (file_exists(ROOT . DS . $stylesheet['file']) and ($stylesheet['load'] == 'backend' or $stylesheet['load'] == 'both')) {
                     if (!file_exists($backend_site_css_path) or filemtime(ROOT . DS . $stylesheet['file']) > filemtime($backend_site_css_path)) {
                         $backend_regenerate = true;
                         break;
                     }
                 }
             }
             // Regenerate site stylesheet
             if ($backend_regenerate) {
                 foreach ($stylesheets as $stylesheet) {
                     if (file_exists(ROOT . DS . $stylesheet['file']) and ($stylesheet['load'] == 'backend' or $stylesheet['load'] == 'both')) {
                         $backend_buffer .= file_get_contents(ROOT . DS . $stylesheet['file']);
                     }
                 }
                 $backend_buffer = Stylesheet::parseVariables($backend_buffer);
                 file_put_contents($backend_site_css_path, MinifyCSS::process($backend_buffer));
                 $backend_regenerate = false;
             }
         } else {
             // Build frontend site stylesheets
             foreach ($stylesheets as $stylesheet) {
                 if (file_exists(ROOT . DS . $stylesheet['file']) and ($stylesheet['load'] == 'frontend' or $stylesheet['load'] == 'both')) {
                     if (!file_exists($frontend_site_css_path) or filemtime(ROOT . DS . $stylesheet['file']) > filemtime($frontend_site_css_path)) {
                         $frontend_regenerate = true;
                         break;
                     }
                 }
             }
             // Regenerate site stylesheet
             if ($frontend_regenerate) {
                 foreach ($stylesheets as $stylesheet) {
                     if (file_exists(ROOT . DS . $stylesheet['file']) and ($stylesheet['load'] == 'frontend' or $stylesheet['load'] == 'both')) {
                         $frontend_buffer .= file_get_contents(ROOT . DS . $stylesheet['file']);
                     }
                 }
                 $frontend_buffer = Stylesheet::parseVariables($frontend_buffer);
                 file_put_contents($frontend_site_css_path, MinifyCSS::process($frontend_buffer));
                 $frontend_regenerate = false;
             }
         }
         // Render
         if (BACKEND) {
             echo '<link rel="stylesheet" href="' . Option::get('siteurl') . '/tmp/minify/backend_site.minify.css?' . Option::get('styles_version') . '" type="text/css" />';
         } else {
             echo '<link rel="stylesheet" href="' . Option::get('siteurl') . '/tmp/minify/frontend_site.minify.css?' . Option::get('styles_version') . '" type="text/css" />' . "\n";
         }
     }
 }
Beispiel #11
0
 private static function readCss($pdf, $view)
 {
     $css = "";
     $files = $view->getCssFiles();
     foreach ($files as $file) {
         $css = Stylesheet::minify($file);
         $pdf->WriteHtml($css, 1);
     }
     return $css;
 }
Beispiel #12
0
 /**
  * Outputs concatenated CSS for the specified view
  * @param string view | the view - optional
  */
 public function css()
 {
     $this->setContentType('text/css; charset=utf-8;');
     $this->setCache(Date::SPAN_MONTH);
     require_once Pimple::instance()->getBaseDir() . 'lib/Stylesheet.php';
     $cacheDir = Pimple::instance()->getSiteDir() . 'cache/css/';
     Dir::ensure($cacheDir);
     $templates = array();
     if (!Request::get('skipLayout', false)) {
         $templates[] = 'application';
     }
     $view = Request::get('view', false);
     if ($view) {
         $templates[] = $view;
     }
     $used = array();
     $isDebug = Settings::get(Settings::DEBUG, false);
     foreach ($templates as $template) {
         $cacheFile = $cacheDir . $template . '.css';
         echo "/* {$template} */\n";
         if ($isDebug) {
             $view = new View($template);
             $files = $view->getInternalCssFiles();
             echo "/*FILES:\n\t" . implode("\n\t", $files) . '*/' . chr(10);
             foreach ($files as $file) {
                 if (in_array($file, $used) || String::StartsWith($file, "http://") || String::StartsWith($file, "https://")) {
                     continue;
                 }
                 $used[] = $file;
                 echo "/*FILE:" . basename($file) . '*/' . chr(10) . Stylesheet::minify($file) . chr(10);
             }
         } else {
             Dir::ensure(dirname($cacheFile));
             if (!is_file($cacheFile)) {
                 File::truncate($cacheFile);
                 $view = new View($template);
                 $files = $view->getInternalCssFiles();
                 File::append($cacheFile, "/*FILES:\n\t" . implode("\n\t", $files) . '*/' . chr(10));
                 foreach ($files as $file) {
                     if (in_array($file, $used) || String::StartsWith($file, "http://") || String::StartsWith($file, "https://")) {
                         continue;
                     }
                     $used[] = $file;
                     File::append($cacheFile, "/*FILE:" . basename($file) . '*/' . chr(10) . Stylesheet::minify($file) . chr(10));
                 }
             }
             echo file_get_contents($cacheFile);
         }
     }
     Pimple::end();
 }
 /**
  * Builds the {@link Frame_Tree}, loads any CSS and applies the styles to
  * the {@link Frame_Tree}
  */
 protected function _process_html()
 {
     $this->_tree->build_tree();
     $this->_css->load_css_file(Stylesheet::DEFAULT_STYLESHEET, Stylesheet::ORIG_UA);
     $acceptedmedia = Stylesheet::$ACCEPTED_GENERIC_MEDIA_TYPES;
     $acceptedmedia[] = $this->get_option("default_media_type");
     // <base href="" />
     $base_nodes = $this->_xml->getElementsByTagName("base");
     if ($base_nodes->length && ($href = $base_nodes->item(0)->getAttribute("href"))) {
         list($this->_protocol, $this->_base_host, $this->_base_path) = explode_url($href);
     }
     // Set the base path of the Stylesheet to that of the file being processed
     $this->_css->set_protocol($this->_protocol);
     $this->_css->set_host($this->_base_host);
     $this->_css->set_base_path($this->_base_path);
     // Get all the stylesheets so that they are processed in document order
     $xpath = new DOMXPath($this->_xml);
     $stylesheets = $xpath->query("//*[name() = 'link' or name() = 'style']");
     foreach ($stylesheets as $tag) {
         switch (strtolower($tag->nodeName)) {
             // load <link rel="STYLESHEET" ... /> tags
             case "link":
                 if (mb_strtolower(stripos($tag->getAttribute("rel"), "stylesheet") !== false) || mb_strtolower($tag->getAttribute("type")) === "text/css") {
                     //Check if the css file is for an accepted media type
                     //media not given then always valid
                     $formedialist = preg_split("/[\\s\n,]/", $tag->getAttribute("media"), -1, PREG_SPLIT_NO_EMPTY);
                     if (count($formedialist) > 0) {
                         $accept = false;
                         foreach ($formedialist as $type) {
                             if (in_array(mb_strtolower(trim($type)), $acceptedmedia)) {
                                 $accept = true;
                                 break;
                             }
                         }
                         if (!$accept) {
                             //found at least one mediatype, but none of the accepted ones
                             //Skip this css file.
                             continue;
                         }
                     }
                     $url = $tag->getAttribute("href");
                     $url = build_url($this->_protocol, $this->_base_host, $this->_base_path, $url);
                     $this->_css->load_css_file($url, Stylesheet::ORIG_AUTHOR);
                 }
                 break;
                 // load <style> tags
             // load <style> tags
             case "style":
                 // Accept all <style> tags by default (note this is contrary to W3C
                 // HTML 4.0 spec:
                 // http://www.w3.org/TR/REC-html40/present/styles.html#adef-media
                 // which states that the default media type is 'screen'
                 if ($tag->hasAttributes() && ($media = $tag->getAttribute("media")) && !in_array($media, $acceptedmedia)) {
                     continue;
                 }
                 $css = "";
                 if ($tag->hasChildNodes()) {
                     $child = $tag->firstChild;
                     while ($child) {
                         $css .= $child->nodeValue;
                         // Handle <style><!-- blah --></style>
                         $child = $child->nextSibling;
                     }
                 } else {
                     $css = $tag->nodeValue;
                 }
                 $this->_css->load_css($css);
                 break;
         }
     }
 }
<?php

// Add Plugin Javascript
Stylesheet::add('plugins/box/filesmanager/css/style.css', 'backend', 11);
Javascript::add('plugins/box/filesmanager/js/fileuploader.js', 'backend', 11);
Javascript::add('plugins/box/filesmanager/js/filesmanager.js', 'backend', 11);
// Add plugin navigation link
Navigation::add(__('Files', 'filesmanager'), 'content', 'filesmanager', 3);
/**
 * Filesmanager Admin Class
 */
class FilesmanagerAdmin extends Backend
{
    /**
     * Main function
     */
    public static function main()
    {
        // Array of forbidden types
        $forbidden_types = array('html', 'htm', 'js', 'jsb', 'mhtml', 'mht', 'php', 'phtml', 'php3', 'php4', 'php5', 'phps', 'shtml', 'jhtml', 'pl', 'py', 'cgi', 'sh', 'ksh', 'bsh', 'c', 'htaccess', 'htpasswd', 'exe', 'scr', 'dll', 'msi', 'vbs', 'bat', 'com', 'pif', 'cmd', 'vxd', 'cpl', 'empty');
        // Array of image types
        $image_types = array('jpg', 'png', 'bmp', 'gif', 'tif');
        // Get Site url
        $site_url = Option::get('siteurl');
        // Init vars
        if (Request::get('path')) {
            $path = Request::get('path');
        } else {
            $path = 'uploads/';
        }
        // Add slash if not exists
 /**
  * Themes plugin admin
  */
 public static function main()
 {
     // Get current themes
     $current_site_theme = Option::get('theme_site_name');
     $current_admin_theme = Option::get('theme_admin_name');
     // Init vars
     $themes_site = Themes::getSiteThemes();
     $themes_admin = Themes::getAdminThemes();
     $templates = Themes::getTemplates();
     $chunks = Themes::getChunks();
     $styles = Themes::getStyles();
     $scripts = Themes::getScripts();
     $errors = array();
     $chunk_path = THEMES_SITE . DS . $current_site_theme . DS;
     $template_path = THEMES_SITE . DS . $current_site_theme . DS;
     $style_path = THEMES_SITE . DS . $current_site_theme . DS . 'css' . DS;
     $script_path = THEMES_SITE . DS . $current_site_theme . DS . 'js' . DS;
     // Save site theme
     if (Request::post('save_site_theme')) {
         if (Security::check(Request::post('csrf'))) {
             Option::update('theme_site_name', Request::post('themes'));
             // Clean Monstra TMP folder.
             Monstra::cleanTmp();
             // Increment Styles and Javascript version
             Stylesheet::stylesVersionIncrement();
             Javascript::javascriptVersionIncrement();
             Request::redirect('index.php?id=themes');
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Save site theme
     if (Request::post('save_admin_theme')) {
         if (Security::check(Request::post('csrf'))) {
             Option::update('theme_admin_name', Request::post('themes'));
             // Clean Monstra TMP folder.
             Monstra::cleanTmp();
             Request::redirect('index.php?id=themes');
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Its mean that you can add your own actions for this plugin
     Action::run('admin_themes_extra_actions');
     // Check for get actions
     // -------------------------------------
     if (Request::get('action')) {
         // Switch actions
         // -------------------------------------
         switch (Request::get('action')) {
             // Add chunk
             // -------------------------------------
             case "add_chunk":
                 if (Request::post('add_file') || Request::post('add_file_and_exit')) {
                     if (Security::check(Request::post('csrf'))) {
                         if (trim(Request::post('name')) == '') {
                             $errors['file_empty_name'] = __('Required field', 'themes');
                         }
                         if (file_exists($chunk_path . Security::safeName(Request::post('name'), null, false) . '.chunk.php')) {
                             $errors['file_exists'] = __('This chunk already exists', 'themes');
                         }
                         if (count($errors) == 0) {
                             // Save chunk
                             File::setContent($chunk_path . Security::safeName(Request::post('name'), null, false) . '.chunk.php', Request::post('content'));
                             Notification::set('success', __('Your changes to the chunk <i>:name</i> have been saved.', 'themes', array(':name' => Security::safeName(Request::post('name'), null, false))));
                             if (Request::post('add_file_and_exit')) {
                                 Request::redirect('index.php?id=themes');
                             } else {
                                 Request::redirect('index.php?id=themes&action=edit_chunk&filename=' . Security::safeName(Request::post('name'), null, false));
                             }
                         }
                     } else {
                         die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                     }
                 }
                 // Save fields
                 if (Request::post('name')) {
                     $name = Request::post('name');
                 } else {
                     $name = '';
                 }
                 if (Request::post('content')) {
                     $content = Request::post('content');
                 } else {
                     $content = '';
                 }
                 // Display view
                 View::factory('box/themes/views/backend/add')->assign('name', $name)->assign('content', $content)->assign('errors', $errors)->assign('action', 'chunk')->display();
                 break;
                 // Add template
                 // -------------------------------------
             // Add template
             // -------------------------------------
             case "add_template":
                 if (Request::post('add_file') || Request::post('add_file_and_exit')) {
                     if (Security::check(Request::post('csrf'))) {
                         if (trim(Request::post('name')) == '') {
                             $errors['file_empty_name'] = __('Required field', 'themes');
                         }
                         if (file_exists($template_path . Security::safeName(Request::post('name'), null, false) . '.template.php')) {
                             $errors['file_exists'] = __('This template already exists', 'themes');
                         }
                         if (count($errors) == 0) {
                             // Save chunk
                             File::setContent($template_path . Security::safeName(Request::post('name'), null, false) . '.template.php', Request::post('content'));
                             Notification::set('success', __('Your changes to the chunk <i>:name</i> have been saved.', 'themes', array(':name' => Security::safeName(Request::post('name'), null, false))));
                             if (Request::post('add_file_and_exit')) {
                                 Request::redirect('index.php?id=themes');
                             } else {
                                 Request::redirect('index.php?id=themes&action=edit_template&filename=' . Security::safeName(Request::post('name'), null, false));
                             }
                         }
                     } else {
                         die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                     }
                 }
                 // Save fields
                 if (Request::post('name')) {
                     $name = Request::post('name');
                 } else {
                     $name = '';
                 }
                 if (Request::post('content')) {
                     $content = Request::post('content');
                 } else {
                     $content = '';
                 }
                 // Display view
                 View::factory('box/themes/views/backend/add')->assign('name', $name)->assign('content', $content)->assign('errors', $errors)->assign('action', 'template')->display();
                 break;
                 // Add styles
                 // -------------------------------------
             // Add styles
             // -------------------------------------
             case "add_styles":
                 if (Request::post('add_file') || Request::post('add_file_and_exit')) {
                     if (Security::check(Request::post('csrf'))) {
                         if (trim(Request::post('name')) == '') {
                             $errors['file_empty_name'] = __('Required field', 'themes');
                         }
                         if (file_exists($style_path . Security::safeName(Request::post('name'), null, false) . '.css')) {
                             $errors['file_exists'] = __('This styles already exists', 'themes');
                         }
                         if (count($errors) == 0) {
                             // Save chunk
                             File::setContent($style_path . Security::safeName(Request::post('name'), null, false) . '.css', Request::post('content'));
                             Notification::set('success', __('Your changes to the styles <i>:name</i> have been saved.', 'themes', array(':name' => Security::safeName(Request::post('name'), null, false))));
                             // Clean Monstra TMP folder.
                             Monstra::cleanTmp();
                             // Increment Styles version
                             Stylesheet::stylesVersionIncrement();
                             if (Request::post('add_file_and_exit')) {
                                 Request::redirect('index.php?id=themes');
                             } else {
                                 Request::redirect('index.php?id=themes&action=edit_styles&filename=' . Security::safeName(Request::post('name'), null, false));
                             }
                         }
                     } else {
                         die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                     }
                 }
                 // Save fields
                 if (Request::post('name')) {
                     $name = Request::post('name');
                 } else {
                     $name = '';
                 }
                 if (Request::post('content')) {
                     $content = Request::post('content');
                 } else {
                     $content = '';
                 }
                 // Display view
                 View::factory('box/themes/views/backend/add')->assign('name', $name)->assign('content', $content)->assign('errors', $errors)->assign('action', 'styles')->display();
                 break;
                 // Add script
                 // -------------------------------------
             // Add script
             // -------------------------------------
             case "add_script":
                 if (Request::post('add_file') || Request::post('add_file_and_exit')) {
                     if (Security::check(Request::post('csrf'))) {
                         if (trim(Request::post('name')) == '') {
                             $errors['file_empty_name'] = __('Required field', 'themes');
                         }
                         if (file_exists($script_path . Security::safeName(Request::post('name'), null, false) . '.js')) {
                             $errors['file_exists'] = __('This script already exists', 'themes');
                         }
                         if (count($errors) == 0) {
                             // Save chunk
                             File::setContent($script_path . Security::safeName(Request::post('name'), null, false) . '.js', Request::post('content'));
                             Notification::set('success', __('Your changes to the script <i>:name</i> have been saved.', 'themes', array(':name' => Security::safeName(Request::post('name'), null, false))));
                             // Clean Monstra TMP folder.
                             Monstra::cleanTmp();
                             // Increment Javascript version
                             Javascript::javascriptVersionIncrement();
                             if (Request::post('add_file_and_exit')) {
                                 Request::redirect('index.php?id=themes');
                             } else {
                                 Request::redirect('index.php?id=themes&action=edit_script&filename=' . Security::safeName(Request::post('name'), null, false));
                             }
                         }
                     } else {
                         die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                     }
                 }
                 // Save fields
                 if (Request::post('name')) {
                     $name = Request::post('name');
                 } else {
                     $name = '';
                 }
                 if (Request::post('content')) {
                     $content = Request::post('content');
                 } else {
                     $content = '';
                 }
                 // Display view
                 View::factory('box/themes/views/backend/add')->assign('name', $name)->assign('content', $content)->assign('errors', $errors)->assign('action', 'script')->display();
                 break;
                 // Edit chunk
                 // -------------------------------------
             // Edit chunk
             // -------------------------------------
             case "edit_chunk":
                 // Save current chunk action
                 if (Request::post('edit_file') || Request::post('edit_file_and_exit')) {
                     if (Security::check(Request::post('csrf'))) {
                         if (trim(Request::post('name')) == '') {
                             $errors['file_empty_name'] = __('Required field', 'themes');
                         }
                         if (file_exists($chunk_path . Security::safeName(Request::post('name'), null, false) . '.chunk.php') and Security::safeName(Request::post('chunk_old_name'), null, false) !== Security::safeName(Request::post('name'), null, false)) {
                             $errors['file_exists'] = __('This chunk already exists', 'themes');
                         }
                         // Save fields
                         if (Request::post('content')) {
                             $content = Request::post('content');
                         } else {
                             $content = '';
                         }
                         if (count($errors) == 0) {
                             $chunk_old_filename = $chunk_path . Request::post('chunk_old_name') . '.chunk.php';
                             $chunk_new_filename = $chunk_path . Security::safeName(Request::post('name'), null, false) . '.chunk.php';
                             if (!empty($chunk_old_filename)) {
                                 if ($chunk_old_filename !== $chunk_new_filename) {
                                     rename($chunk_old_filename, $chunk_new_filename);
                                     $save_filename = $chunk_new_filename;
                                 } else {
                                     $save_filename = $chunk_new_filename;
                                 }
                             } else {
                                 $save_filename = $chunk_new_filename;
                             }
                             // Save chunk
                             File::setContent($save_filename, Request::post('content'));
                             Notification::set('success', __('Your changes to the chunk <i>:name</i> have been saved.', 'themes', array(':name' => basename($save_filename, '.chunk.php'))));
                             if (Request::post('edit_file_and_exit')) {
                                 Request::redirect('index.php?id=themes');
                             } else {
                                 Request::redirect('index.php?id=themes&action=edit_chunk&filename=' . Security::safeName(Request::post('name'), null, false));
                             }
                         }
                     } else {
                         die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                     }
                 }
                 if (Request::post('name')) {
                     $name = Request::post('name');
                 } else {
                     $name = File::name(Request::get('filename'));
                 }
                 $content = File::getContent($chunk_path . Request::get('filename') . '.chunk.php');
                 // Display view
                 View::factory('box/themes/views/backend/edit')->assign('content', $content)->assign('name', $name)->assign('errors', $errors)->assign('action', 'chunk')->display();
                 break;
                 // Edit Template
                 // -------------------------------------
             // Edit Template
             // -------------------------------------
             case "edit_template":
                 // Save current chunk action
                 if (Request::post('edit_file') || Request::post('edit_file_and_exit')) {
                     if (Security::check(Request::post('csrf'))) {
                         if (trim(Request::post('name')) == '') {
                             $errors['file_empty_name'] = __('Required field', 'themes');
                         }
                         if (file_exists($template_path . Security::safeName(Request::post('name'), null, false) . '.template.php') and Security::safeName(Request::post('template_old_name'), null, false) !== Security::safeName(Request::post('name'), null, false)) {
                             $errors['template_exists'] = __('This template already exists', 'themes');
                         }
                         // Save fields
                         if (Request::post('content')) {
                             $content = Request::post('content');
                         } else {
                             $content = '';
                         }
                         if (count($errors) == 0) {
                             $template_old_filename = $template_path . Request::post('template_old_name') . '.template.php';
                             $template_new_filename = $template_path . Security::safeName(Request::post('name'), null, false) . '.template.php';
                             if (!empty($template_old_filename)) {
                                 if ($template_old_filename !== $template_new_filename) {
                                     rename($template_old_filename, $template_new_filename);
                                     $save_filename = $template_new_filename;
                                 } else {
                                     $save_filename = $template_new_filename;
                                 }
                             } else {
                                 $save_filename = $template_new_filename;
                             }
                             // Save chunk
                             File::setContent($save_filename, Request::post('content'));
                             Notification::set('success', __('Your changes to the template <i>:name</i> have been saved.', 'themes', array(':name' => basename($save_filename, '.template.php'))));
                             if (Request::post('edit_file_and_exit')) {
                                 Request::redirect('index.php?id=themes');
                             } else {
                                 Request::redirect('index.php?id=themes&action=edit_template&filename=' . Security::safeName(Request::post('name'), null, false));
                             }
                         }
                     } else {
                         die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                     }
                 }
                 if (Request::post('name')) {
                     $name = Request::post('name');
                 } else {
                     $name = File::name(Request::get('filename'));
                 }
                 $content = File::getContent($chunk_path . Request::get('filename') . '.template.php');
                 // Display view
                 View::factory('box/themes/views/backend/edit')->assign('content', $content)->assign('name', $name)->assign('errors', $errors)->assign('action', 'template')->display();
                 break;
                 // Edit Styles
                 // -------------------------------------
             // Edit Styles
             // -------------------------------------
             case "edit_styles":
                 // Save current chunk action
                 if (Request::post('edit_file') || Request::post('edit_file_and_exit')) {
                     if (Security::check(Request::post('csrf'))) {
                         if (trim(Request::post('name')) == '') {
                             $errors['file_empty_name'] = __('Required field', 'themes');
                         }
                         if (file_exists($style_path . Security::safeName(Request::post('name'), null, false) . '.css') and Security::safeName(Request::post('styles_old_name'), null, false) !== Security::safeName(Request::post('name'), null, false)) {
                             $errors['file_exists'] = __('This styles already exists', 'themes');
                         }
                         // Save fields
                         if (Request::post('content')) {
                             $content = Request::post('content');
                         } else {
                             $content = '';
                         }
                         if (count($errors) == 0) {
                             $styles_old_filename = $style_path . Request::post('styles_old_name') . '.css';
                             $styles_new_filename = $style_path . Security::safeName(Request::post('name'), null, false) . '.css';
                             if (!empty($styles_old_filename)) {
                                 if ($styles_old_filename !== $styles_new_filename) {
                                     rename($styles_old_filename, $styles_new_filename);
                                     $save_filename = $styles_new_filename;
                                 } else {
                                     $save_filename = $styles_new_filename;
                                 }
                             } else {
                                 $save_filename = $styles_new_filename;
                             }
                             // Save chunk
                             File::setContent($save_filename, Request::post('content'));
                             Notification::set('success', __('Your changes to the styles <i>:name</i> have been saved.', 'themes', array(':name' => basename($save_filename, '.css'))));
                             // Clean Monstra TMP folder.
                             Monstra::cleanTmp();
                             // Increment Styles version
                             Stylesheet::stylesVersionIncrement();
                             if (Request::post('edit_file_and_exit')) {
                                 Request::redirect('index.php?id=themes');
                             } else {
                                 Request::redirect('index.php?id=themes&action=edit_styles&filename=' . Security::safeName(Request::post('name'), null, false));
                             }
                         }
                     } else {
                         die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                     }
                 }
                 if (Request::post('name')) {
                     $name = Request::post('name');
                 } else {
                     $name = File::name(Request::get('filename'));
                 }
                 $content = File::getContent($style_path . Request::get('filename') . '.css');
                 // Display view
                 View::factory('box/themes/views/backend/edit')->assign('content', $content)->assign('name', $name)->assign('errors', $errors)->assign('action', 'styles')->display();
                 break;
                 // Edit Script
                 // -------------------------------------
             // Edit Script
             // -------------------------------------
             case "edit_script":
                 // Save current chunk action
                 if (Request::post('edit_file') || Request::post('edit_file_and_exit')) {
                     if (Security::check(Request::post('csrf'))) {
                         if (trim(Request::post('name')) == '') {
                             $errors['file_empty_name'] = __('Required field', 'themes');
                         }
                         if (file_exists($script_path . Security::safeName(Request::post('name'), null, false) . '.js') and Security::safeName(Request::post('script_old_name'), null, false) !== Security::safeName(Request::post('name'), null, false)) {
                             $errors['file_exists'] = __('This script already exists', 'themes');
                         }
                         // Save fields
                         if (Request::post('content')) {
                             $content = Request::post('content');
                         } else {
                             $content = '';
                         }
                         if (count($errors) == 0) {
                             $script_old_filename = $script_path . Request::post('script_old_name') . '.js';
                             $script_new_filename = $script_path . Security::safeName(Request::post('name'), null, false) . '.js';
                             if (!empty($script_old_filename)) {
                                 if ($script_old_filename !== $script_new_filename) {
                                     rename($script_old_filename, $script_new_filename);
                                     $save_filename = $script_new_filename;
                                 } else {
                                     $save_filename = $script_new_filename;
                                 }
                             } else {
                                 $save_filename = $script_new_filename;
                             }
                             // Save chunk
                             File::setContent($save_filename, Request::post('content'));
                             Notification::set('success', __('Your changes to the script <i>:name</i> have been saved.', 'themes', array(':name' => basename($save_filename, '.js'))));
                             // Clean Monstra TMP folder.
                             Monstra::cleanTmp();
                             // Increment Javascript version
                             Javascript::javascriptVersionIncrement();
                             if (Request::post('edit_file_and_exit')) {
                                 Request::redirect('index.php?id=themes');
                             } else {
                                 Request::redirect('index.php?id=themes&action=edit_script&filename=' . Security::safeName(Request::post('name'), null, false));
                             }
                         }
                     } else {
                         die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                     }
                 }
                 if (Request::post('name')) {
                     $name = Request::post('name');
                 } else {
                     $name = File::name(Request::get('filename'));
                 }
                 $content = File::getContent($script_path . Request::get('filename') . '.js');
                 // Display view
                 View::factory('box/themes/views/backend/edit')->assign('content', $content)->assign('name', $name)->assign('errors', $errors)->assign('action', 'script')->display();
                 break;
                 // Delete chunk
                 // -------------------------------------
             // Delete chunk
             // -------------------------------------
             case "delete_chunk":
                 if (Security::check(Request::get('token'))) {
                     File::delete($chunk_path . Request::get('filename') . '.chunk.php');
                     Notification::set('success', __('Chunk <i>:name</i> deleted', 'themes', array(':name' => File::name(Request::get('filename')))));
                     Request::redirect('index.php?id=themes');
                 } else {
                     die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                 }
                 break;
                 // Delete styles
                 // -------------------------------------
             // Delete styles
             // -------------------------------------
             case "delete_styles":
                 if (Security::check(Request::get('token'))) {
                     File::delete($style_path . Request::get('filename') . '.css');
                     Notification::set('success', __('Styles <i>:name</i> deleted', 'themes', array(':name' => File::name(Request::get('filename')))));
                     // Clean Monstra TMP folder.
                     Monstra::cleanTmp();
                     // Increment Styles version
                     Stylesheet::stylesVersionIncrement();
                     Request::redirect('index.php?id=themes');
                 } else {
                     die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                 }
                 break;
                 // Delete script
                 // -------------------------------------
             // Delete script
             // -------------------------------------
             case "delete_script":
                 if (Security::check(Request::get('token'))) {
                     File::delete($script_path . Request::get('filename') . '.js');
                     Notification::set('success', __('Script <i>:name</i> deleted', 'themes', array(':name' => File::name(Request::get('filename')))));
                     // Clean Monstra TMP folder.
                     Monstra::cleanTmp();
                     // Increment Javascript version
                     Javascript::javascriptVersionIncrement();
                     Request::redirect('index.php?id=themes');
                 } else {
                     die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                 }
                 break;
                 // Delete template
                 // -------------------------------------
             // Delete template
             // -------------------------------------
             case "delete_template":
                 if (Security::check(Request::get('token'))) {
                     File::delete($template_path . Request::get('filename') . '.template.php');
                     Notification::set('success', __('Template <i>:name</i> deleted', 'themes', array(':name' => File::name(Request::get('filename')))));
                     Request::redirect('index.php?id=themes');
                 }
                 break;
                 // Clone styles
                 // -------------------------------------
             // Clone styles
             // -------------------------------------
             case "clone_styles":
                 if (Security::check(Request::get('token'))) {
                     File::setContent(THEMES_SITE . DS . $current_site_theme . DS . 'css' . DS . Request::get('filename') . '_clone_' . date("Ymd_His") . '.css', File::getContent(THEMES_SITE . DS . $current_site_theme . DS . 'css' . DS . Request::get('filename') . '.css'));
                     // Clean Monstra TMP folder.
                     Monstra::cleanTmp();
                     // Increment Styles version
                     Stylesheet::stylesVersionIncrement();
                     Request::redirect('index.php?id=themes');
                 }
                 break;
                 // Clone script
                 // -------------------------------------
             // Clone script
             // -------------------------------------
             case "clone_script":
                 if (Security::check(Request::get('token'))) {
                     File::setContent(THEMES_SITE . DS . $current_site_theme . DS . 'js' . DS . Request::get('filename') . '_clone_' . date("Ymd_His") . '.js', File::getContent(THEMES_SITE . DS . $current_site_theme . DS . 'js' . DS . Request::get('filename') . '.js'));
                     // Clean Monstra TMP folder.
                     Monstra::cleanTmp();
                     // Increment Javascript version
                     Javascript::javascriptVersionIncrement();
                     Request::redirect('index.php?id=themes');
                 }
                 break;
                 // Clone template
                 // -------------------------------------
             // Clone template
             // -------------------------------------
             case "clone_template":
                 if (Security::check(Request::get('token'))) {
                     File::setContent(THEMES_SITE . DS . $current_site_theme . DS . Request::get('filename') . '_clone_' . date("Ymd_His") . '.template.php', File::getContent(THEMES_SITE . DS . $current_site_theme . DS . Request::get('filename') . '.template.php'));
                     Request::redirect('index.php?id=themes');
                 }
                 break;
                 // Clone chunk
                 // -------------------------------------
             // Clone chunk
             // -------------------------------------
             case "clone_chunk":
                 if (Security::check(Request::get('token'))) {
                     File::setContent(THEMES_SITE . DS . $current_site_theme . DS . Request::get('filename') . '_clone_' . date("Ymd_His") . '.chunk.php', File::getContent(THEMES_SITE . DS . $current_site_theme . DS . Request::get('filename') . '.chunk.php'));
                     Request::redirect('index.php?id=themes');
                 }
                 break;
         }
     } else {
         // Display view
         View::factory('box/themes/views/backend/index')->assign('themes_site', $themes_site)->assign('themes_admin', $themes_admin)->assign('templates', $templates)->assign('chunks', $chunks)->assign('styles', $styles)->assign('scripts', $scripts)->assign('current_site_theme', $current_site_theme)->assign('current_admin_theme', $current_admin_theme)->display();
     }
 }
 *	Events plugin admin
 *
 *  Provides CRUD for events and different output possibilities for event lists
 *
 *	@package    Monstra
 *  @subpackage Plugins
 *	@author     Andreas Müller | devmount <*****@*****.**>
 *	@license    MIT
 *  @link       https://github.com/devmount-monstra/events
 *
 */
// Add plugin styles and scripts
Stylesheet::add('plugins/events/css/events.admin.css', 'backend', 11);
Javascript::add('plugins/events/js/events.admin.js', 'backend', 11);
// lib: Image Picker http://rvera.github.io/image-picker/
Stylesheet::add('plugins/events/lib/image-picker/image-picker.css', 'backend', 11);
Javascript::add('plugins/events/lib/image-picker/image-picker.js', 'backend', 11);
// Admin Navigation: add new item
Navigation::add(__('Events', 'events'), 'content', 'events', 10);
// Add action on admin_pre_render hook
Action::add('admin_pre_render', 'EventsAdmin::_getAjaxData');
// register repository classes
require_once 'repositories/repository.events.php';
require_once 'repositories/repository.categories.php';
require_once 'repositories/repository.locations.php';
/**
 * Events class
 *
 */
class EventsAdmin extends Backend
{
Beispiel #17
0
if (strpos($ruri, '?') === false) {
    $params = '';
    $path = $ruri;
} else {
    list($path, $params) = preg_split('/\\?/', $ruri, 2);
}
$special = array('css/icinga.css', 'css/icinga.min.css', 'js/icinga.dev.js', 'js/icinga.min.js');
if (in_array($path, $special)) {
    include_once __DIR__ . '/EmbeddedWeb.php';
    EmbeddedWeb::start();
    switch ($path) {
        case 'css/icinga.css':
            Stylesheet::send();
            exit;
        case 'css/icinga.min.css':
            Stylesheet::sendMinified();
            exit;
        case 'js/icinga.dev.js':
            JavaScript::send();
            exit;
        case 'js/icinga.min.js':
            JavaScript::sendMinified();
            break;
        default:
            return false;
    }
} elseif ($path === 'svg/chart.php') {
    if (!array_key_exists('data', $_GET)) {
        return false;
    }
    include __DIR__ . '/EmbeddedWeb.php';
<?php

// Add Plugin Javascript
Stylesheet::add('public/assets/css/daterangepicker-bs3.css', 'backend', 11);
Javascript::add('public/assets/js/moment.min.js', 'backend', 11);
Javascript::add('public/assets/js/daterangepicker.js', 'backend', 12);
Javascript::add('plugins/box/dashboard/js/ganalytics.js', 'backend', 13);
/**
 * Dashboard admin class
 */
class DashboardAdmin extends Backend
{
    /**
     * Main Dashboard admin function
     */
    public static function main()
    {
        // set/update google analytics settings
        if (Request::post('ga_settings_update')) {
            if (Security::check(Request::post('csrf'))) {
                // client id
                $ga_client_id = trim(Request::post('ga_client_id'));
                if (!empty($ga_client_id)) {
                    $opt_client_id = Option::get('ga_client_id');
                    if (empty($opt_client_id)) {
                        Option::add('ga_client_id', $ga_client_id);
                    } else {
                        Option::update('ga_client_id', $ga_client_id);
                    }
                }
                // API key
 /**
  * Renders the HTML to PDF
  */
 function render()
 {
     //enable_mem_profile();
     $this->_process_html();
     $this->_css->apply_styles($this->_tree);
     $root = null;
     foreach ($this->_tree->get_frames() as $frame) {
         // Set up the root frame
         if (is_null($root)) {
             $root = Frame_Factory::decorate_root($this->_tree->get_root(), $this);
             continue;
         }
         // Create the appropriate decorators, reflowers & positioners.
         $deco = Frame_Factory::decorate_frame($frame, $this);
         $deco->set_root($root);
         // FIXME: handle generated content
         if ($frame->get_style()->display === "list-item") {
             // Insert a list-bullet frame
             $node = $this->_xml->createElement("bullet");
             // arbitrary choice
             $b_f = new Frame($node);
             $style = $this->_css->create_style();
             $style->display = "-dompdf-list-bullet";
             $style->inherit($frame->get_style());
             $b_f->set_style($style);
             $deco->prepend_child(Frame_Factory::decorate_frame($b_f, $this));
         }
     }
     $this->_pdf = Canvas_Factory::get_instance($this->_paper_size, $this->_paper_orientation);
     $root->set_containing_block(0, 0, $this->_pdf->get_width(), $this->_pdf->get_height());
     $root->set_renderer(new Renderer($this));
     // This is where the magic happens:
     $root->reflow();
     // Clean up cached images
     Image_Cache::clear();
     global $_dompdf_warnings, $_dompdf_show_warnings;
     if ($_dompdf_show_warnings) {
         echo '<b>DOMPDF Warnings</b><br><pre>';
         foreach ($_dompdf_warnings as $msg) {
             echo $msg . "\n";
         }
         echo $this->get_canvas()->get_cpdf()->messages;
         echo '</pre>';
         flush();
     }
 }
/public/assets/css/messenger.css" type="text/css" />
        <link rel="stylesheet" href="<?php 
echo Site::url();
?>
/public/assets/css/messenger-theme-flat.css" type="text/css" />
        <?php 
Stylesheet::add('public/assets/css/bootstrap-lightbox.css', 'backend', 2);
?>
        <?php 
Stylesheet::add('public/assets/css/bootstrap-fileupload.css', 'backend', 3);
?>
        <?php 
Stylesheet::add('admin/themes/default/css/default.css', 'backend', 5);
?>
        <?php 
Stylesheet::load();
?>

        <!-- JavaScripts -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script src="<?php 
echo Site::url();
?>
/public/assets/js/bootstrap.min.js"></script>
        <script src="<?php 
echo Site::url();
?>
/public/assets/js/messenger.min.js"></script>
        <script src="<?php 
echo Site::url();
?>
Beispiel #21
0
 /**
  * Renders the HTML to PDF
  */
 function render()
 {
     $this->save_locale();
     if (DOMPDF_LOG_OUTPUT_FILE) {
         if (!file_exists(DOMPDF_LOG_OUTPUT_FILE) && is_writable(dirname(DOMPDF_LOG_OUTPUT_FILE))) {
             touch(DOMPDF_LOG_OUTPUT_FILE);
         }
         $this->_start_time = microtime(true);
         ob_start();
     }
     //enable_mem_profile();
     $this->_process_html();
     $this->_css->apply_styles($this->_tree);
     $root = null;
     foreach ($this->_tree->get_frames() as $frame) {
         // Set up the root frame
         if (is_null($root)) {
             $root = Frame_Factory::decorate_root($this->_tree->get_root(), $this);
             continue;
         }
         // Create the appropriate decorators, reflowers & positioners.
         $deco = Frame_Factory::decorate_frame($frame, $this);
         $deco->set_root($root);
         // FIXME: handle generated content
         if ($frame->get_style()->display === "list-item") {
             // Insert a list-bullet frame
             $node = $this->_xml->createElement("bullet");
             // arbitrary choice
             $b_f = new Frame($node);
             $parent_node = $frame->get_parent()->get_node();
             if (!$parent_node->hasAttribute("dompdf-children-count")) {
                 $count = 0;
                 foreach ($parent_node->childNodes as $_node) {
                     if ($_node instanceof DOMElement) {
                         $count++;
                     }
                 }
                 $parent_node->setAttribute("dompdf-children-count", $count);
             }
             $index = 0;
             if (!$parent_node->hasAttribute("dompdf-counter")) {
                 $index = 1;
                 $parent_node->setAttribute("dompdf-counter", 1);
             } else {
                 $index = $parent_node->getAttribute("dompdf-counter");
                 $index++;
                 $parent_node->setAttribute("dompdf-counter", $index);
             }
             $node->setAttribute("dompdf-counter", $index);
             $style = $this->_css->create_style();
             $style->display = "-dompdf-list-bullet";
             $style->inherit($frame->get_style());
             $b_f->set_style($style);
             $deco->prepend_child(Frame_Factory::decorate_frame($b_f, $this));
         }
     }
     $page_styles = $this->_css->get_page_styles();
     $base_page_style = $page_styles["base"];
     unset($page_styles["base"]);
     foreach ($page_styles as $_page_style) {
         $_page_style->inherit($base_page_style);
     }
     if (is_array($base_page_style->size)) {
         $this->set_paper(array(0, 0, $base_page_style->size[0], $base_page_style->size[1]));
     }
     $this->_pdf = Canvas_Factory::get_instance($this->_paper_size, $this->_paper_orientation);
     // Add meta information
     $title = $this->_xml->getElementsByTagName("title");
     if ($title->length) {
         $this->_pdf->add_info("Title", trim($title->item(0)->nodeValue));
     }
     $metas = $this->_xml->getElementsByTagName("meta");
     $labels = array("author" => "Author", "keywords" => "Keywords", "description" => "Subject");
     foreach ($metas as $meta) {
         $name = mb_strtolower($meta->getAttribute("name"));
         $value = trim($meta->getAttribute("content"));
         if (isset($labels[$name])) {
             $this->_pdf->add_info($labels[$name], $value);
             continue;
         }
         if ($name === "dompdf.view" && $this->parse_default_view($value)) {
             $this->_pdf->set_default_view($this->_default_view, $this->_default_view_options);
         }
     }
     $root->set_containing_block(0, 0, $this->_pdf->get_width(), $this->_pdf->get_height());
     $root->set_renderer(new Renderer($this));
     // This is where the magic happens:
     $root->reflow();
     // Clean up cached images
     Image_Cache::clear();
     global $_dompdf_warnings, $_dompdf_show_warnings;
     if ($_dompdf_show_warnings) {
         echo '<b>DOMPDF Warnings</b><br><pre>';
         foreach ($_dompdf_warnings as $msg) {
             echo $msg . "\n";
         }
         echo $this->get_canvas()->get_cpdf()->messages;
         echo '</pre>';
         flush();
     }
     $this->restore_locale();
 }
Beispiel #22
0
    /**
     * Builds the {@link Frame_Tree}, loads any CSS and applies the styles to
     * the {@link Frame_Tree}
     */
    protected function _process_html()
    {
        $this->save_locale();

        $this->_tree->build_tree();

        $this->_css->load_css_file(Stylesheet::DEFAULT_STYLESHEET, Stylesheet::ORIG_UA);

        $acceptedmedia = Stylesheet::$ACCEPTED_GENERIC_MEDIA_TYPES;
        if (defined("DOMPDF_DEFAULT_MEDIA_TYPE")) {
            $acceptedmedia[] = DOMPDF_DEFAULT_MEDIA_TYPE;
        } else {
            $acceptedmedia[] = Stylesheet::$ACCEPTED_DEFAULT_MEDIA_TYPE;
        }

        // load <link rel="STYLESHEET" ... /> tags
        $links = $this->_xml->getElementsByTagName("link");
        foreach ($links as $link) {
            if (mb_strtolower($link->getAttribute("rel")) === "stylesheet" ||
                mb_strtolower($link->getAttribute("type")) === "text/css"
            ) {
                //Check if the css file is for an accepted media type
                //media not given then always valid
                $formedialist = preg_split("/[\s\n,]/", $link->getAttribute("media"), -1, PREG_SPLIT_NO_EMPTY);
                if (count($formedialist) > 0) {
                    $accept = false;
                    foreach ($formedialist as $type) {
                        if (in_array(mb_strtolower(trim($type)), $acceptedmedia)) {
                            $accept = true;
                            break;
                        }
                    }
                    if (!$accept) {
                        //found at least one mediatype, but none of the accepted ones
                        //Skip this css file.
                        continue;
                    }
                }

                $url = $link->getAttribute("href");
                $url = build_url($this->_protocol, $this->_base_host, $this->_base_path, $url);

                $this->_css->load_css_file($url, Stylesheet::ORIG_AUTHOR);
            }

        }

        // Set the base path of the Stylesheet to that of the file being processed
        $this->_css->set_protocol($this->_protocol);
        $this->_css->set_host($this->_base_host);
        $this->_css->set_base_path($this->_base_path);

        // load <style> tags
        $styles = $this->_xml->getElementsByTagName("style");
        foreach ($styles as $style) {

            // Accept all <style> tags by default (note this is contrary to W3C
            // HTML 4.0 spec:
            // http://www.w3.org/TR/REC-html40/present/styles.html#adef-media
            // which states that the default media type is 'screen'
            if ($style->hasAttributes() &&
                ($media = $style->getAttribute("media")) &&
                !in_array($media, $acceptedmedia)
            )
                continue;

            $css = "";
            if ($style->hasChildNodes()) {

                $child = $style->firstChild;
                while ($child) {
                    $css .= $child->nodeValue; // Handle <style><!-- blah --></style>
                    $child = $child->nextSibling;
                }

            } else
                $css = $style->nodeValue;

            $this->_css->load_css($css);
        }

        $this->restore_locale();
    }
Beispiel #23
0
 /**
  * Set the background image url
  *
  * @link http://www.w3.org/TR/CSS21/colors.html#background-properties
  * @param string $url
  */
 function set_background_image($val)
 {
     if (mb_strpos($val, "url") !== false) {
         $val = preg_replace("/url\\(['\"]?([^'\")]+)['\"]?\\)/", "\\1", trim($val));
     } else {
         $val = "none";
     }
     // Resolve the url now in the context of the current stylesheet
     $parsed_url = explode_url($val);
     if ($parsed_url["protocol"] == "" && $this->_stylesheet->get_protocol() == "") {
         $url = realpath($this->_stylesheet->get_base_path() . $parsed_url["file"]);
     } else {
         $url = build_url($this->_stylesheet->get_protocol(), $this->_stylesheet->get_host(), $this->_stylesheet->get_base_path(), $val);
     }
     $this->_props["background_image"] = $url;
 }
 /**
  * Plugins admin
  */
 public static function main()
 {
     // Get siteurl
     $site_url = Option::get('siteurl');
     // Get installed plugin from $plugins array
     $installed_plugins = Plugin::$plugins;
     // Get installed users plugins
     $_users_plugins = array();
     foreach (Plugin::$plugins as $plugin) {
         if ($plugin['privilege'] !== 'box') {
             $_users_plugins[] = $plugin['id'];
         }
     }
     // Get plugins table
     $plugins = new Table('plugins');
     // Delete plugin
     // -------------------------------------
     if (Request::get('delete_plugin')) {
         if (Security::check(Request::get('token'))) {
             // Nobody cant remove box plugins
             if ($installed_plugins[Text::lowercase(str_replace("Plugin", "", Request::get('delete_plugin')))]['privilege'] !== 'box') {
                 // Run plugin uninstaller file
                 $plugin_name = Request::get('delete_plugin');
                 if (File::exists(PLUGINS . DS . $plugin_name . DS . 'install' . DS . $plugin_name . '.uninstall.php')) {
                     include PLUGINS . DS . $plugin_name . DS . 'install' . DS . $plugin_name . '.uninstall.php';
                 }
                 // Clean Monstra TMP folder.
                 Monstra::cleanTmp();
                 // Increment Styles and Javascript version
                 Stylesheet::stylesVersionIncrement();
                 Javascript::javascriptVersionIncrement();
                 // Delete plugin form plugins table
                 $plugins->deleteWhere('[name="' . Request::get('delete_plugin') . '"]');
                 // Redirect
                 Request::redirect('index.php?id=plugins');
             }
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Install new plugin
     // -------------------------------------
     if (Request::get('install')) {
         if (Security::check(Request::get('token'))) {
             // Load plugin install xml file
             $plugin_xml = XML::loadFile(PLUGINS . DS . basename(Text::lowercase(Request::get('install')), '.manifest.xml') . DS . 'install' . DS . Request::get('install'));
             // Add plugin to plugins table
             $plugins->insert(array('name' => basename(Request::get('install'), '.manifest.xml'), 'location' => (string) $plugin_xml->plugin_location, 'status' => (string) $plugin_xml->plugin_status, 'priority' => (int) $plugin_xml->plugin_priority));
             // Clean Monstra TMP folder.
             Monstra::cleanTmp();
             Stylesheet::stylesVersionIncrement();
             Javascript::javascriptVersionIncrement();
             // Run plugin installer file
             $plugin_name = str_replace(array("Plugin", ".manifest.xml"), "", Request::get('install'));
             if (File::exists(PLUGINS . DS . basename(Text::lowercase(Request::get('install')), '.manifest.xml') . DS . 'install' . DS . $plugin_name . '.install.php')) {
                 include PLUGINS . DS . basename(Text::lowercase(Request::get('install')), '.manifest.xml') . DS . 'install' . DS . $plugin_name . '.install.php';
             }
             Request::redirect('index.php?id=plugins');
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Delete plugin from server
     // -------------------------------------
     if (Request::get('delete_plugin_from_server')) {
         if (Security::check(Request::get('token'))) {
             // Clean Monstra TMP folder.
             Monstra::cleanTmp();
             Stylesheet::stylesVersionIncrement();
             Javascript::javascriptVersionIncrement();
             Dir::delete(PLUGINS . DS . basename(Request::get('delete_plugin_from_server'), '.manifest.xml'));
             Request::redirect('index.php?id=plugins');
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Upload & extract plugin archive
     // -------------------------------------
     if (Request::post('upload_file')) {
         if (Security::check(Request::post('csrf'))) {
             if ($_FILES['file']) {
                 if (in_array(File::ext($_FILES['file']['name']), array('zip'))) {
                     $tmp_dir = ROOT . DS . 'tmp' . DS . uniqid('plugin_');
                     $error = 'Plugin was not uploaded';
                     if (Dir::create($tmp_dir)) {
                         $file_locations = Zip::factory()->extract($_FILES['file']['tmp_name'], $tmp_dir);
                         if (!empty($file_locations)) {
                             $manifest = '';
                             foreach ($file_locations as $filepath) {
                                 if (substr($filepath, -strlen('.manifest.xml')) === '.manifest.xml') {
                                     $manifest = $filepath;
                                     break;
                                 }
                             }
                             if (!empty($manifest) && basename(dirname($manifest)) === 'install') {
                                 $manifest_file = pathinfo($manifest, PATHINFO_BASENAME);
                                 $plugin_name = str_replace('.manifest.xml', '', $manifest_file);
                                 if (Dir::create(PLUGINS . DS . $plugin_name)) {
                                     $tmp_plugin_dir = dirname(dirname($manifest));
                                     Dir::copy($tmp_plugin_dir, PLUGINS . DS . $plugin_name);
                                     Notification::set('success', __('Plugin was uploaded', 'plugins'));
                                     $error = false;
                                 }
                             }
                         }
                     } else {
                         $error = 'System error';
                     }
                 } else {
                     $error = 'Forbidden plugin file type';
                 }
             } else {
                 $error = 'Plugin was not uploaded';
             }
             if ($error) {
                 Notification::set('error', __($error, 'plugins'));
             }
             if (Request::post('dragndrop')) {
                 Request::shutdown();
             } else {
                 Request::redirect($site_url . '/admin/index.php?id=plugins#installnew');
             }
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Installed plugins
     $plugins_installed = array();
     // New plugins
     $plugins_new = array();
     // Plugins to install
     $plugins_to_intall = array();
     // Scan plugins directory for .manifest.xml
     $plugins_new = File::scan(PLUGINS, '.manifest.xml');
     // Get installed plugins from plugins table
     $plugins_installed = $plugins->select(null, 'all', null, array('location', 'priority'), 'priority', 'ASC');
     // Update $plugins_installed array. extract plugins names
     foreach ($plugins_installed as $plg) {
         $_plg[] = basename($plg['location'], 'plugin.php') . 'manifest.xml';
     }
     // Diff
     $plugins_to_install = array_diff($plugins_new, $_plg);
     // Create array of plugins to install
     $count = 0;
     foreach ($plugins_to_install as $plugin) {
         $plg_path = PLUGINS . DS . Text::lowercase(basename($plugin, '.manifest.xml')) . DS . 'install' . DS . $plugin;
         if (file_exists($plg_path)) {
             $plugins_to_intall[$count]['path'] = $plg_path;
             $plugins_to_intall[$count]['plugin'] = $plugin;
             $count++;
         }
     }
     // Draw template
     View::factory('box/plugins/views/backend/index')->assign('installed_plugins', $installed_plugins)->assign('plugins_to_intall', $plugins_to_intall)->assign('_users_plugins', $_users_plugins)->assign('fileuploader', array('uploadUrl' => $site_url . '/admin/index.php?id=plugins', 'csrf' => Security::token(), 'errorMsg' => __('Upload server error', 'filesmanager')))->display();
 }