public function control_panel__add_to_foot() { if (URL::getCurrent(false) == '/publish') { $html = $this->js->link(array('fullscreen.js', 'redactor.min.js')); $options = $this->getConfig(); # Load image browser folder if (class_exists('Fieldtype_redactor') && method_exists('Fieldtype_redactor', 'get_field_settings')) { $field_settings = Fieldtype_redactor::get_field_settings(); if (isset($field_settings['image_dir'])) { $image_path = Path::tidy($field_settings['image_dir'] . '/'); $options['imageGetJson'] = Config::getSiteRoot() . "TRIGGER/redactor/fetch_images?path={$image_path}"; $options['imageUpload'] = Config::getSiteRoot() . "TRIGGER/redactor/upload?path={$image_path}"; } if (isset($field_settings['file_dir'])) { $file_path = Path::tidy($field_settings['file_dir'] . '/'); $options['fileUpload'] = Config::getSiteRoot() . "TRIGGER/redactor/upload?path={$file_path}"; } if (isset($field_settings['image_dir_append_slug'])) { $options['uploadFields'] = array('subfolder' => '#publish-slug'); } } $redactor_options = json_encode($options, JSON_FORCE_OBJECT); $html .= "<script>\n\n var redactor_options = {$redactor_options};\n\n \$(document).ready(\n function() {\n \$.extend(redactor_options, {'imageUploadErrorCallback': callback});\n \$('.redactor-container textarea').redactor(redactor_options);\n }\n\n );\n\n\n \$('body').on('addRow', '.grid', function() {\n \$.extend(redactor_options, {'imageUploadErrorCallback': callback});\n \$('.redactor-container textarea').redactor(redactor_options);\n });\n\n function callback(obj, json) {\n alert(json.error);\n }\n </script>"; return $html; } }
/** * Add JS to footer * */ public function control_panel__add_to_foot() { // Get the necessary support .js if (URL::getCurrent(false) == '/publish') { return $this->js->link('build/fileclerk.min.js'); } }
public function control_panel__add_to_head() { if (URL::getCurrent(false) == '/publish') { $file = 'defined-links.json'; $current_content_list = file_get_contents($file, true); $current_content_list = json_decode($current_content_list); $content_set = ContentService::getContentByFolders(array("/*")); $content_set->multisort('url'); $content_set = $content_set->get(); $content_list = []; $content_list[] = ['name' => 'Select...', 'url' => false]; foreach ($content_set as $content) { if (isset($content['url']) && isset($content['title'])) { $name = '[' . $content['url'] . '] ' . $content['title']; $url = $content['url']; $content_list[] = ['name' => $name, 'url' => $url]; } } if ($current_content_list !== $content_list) { $json = json_encode($content_list); file_put_contents($file, $json, FILE_USE_INCLUDE_PATH); } return $this->js->link('definedlinks.js'); } }
/** * The {{ all_the_vars }} tag * * @return string */ public function index() { $remove_underscored = $this->fetchParam('remove_underscored', true, null, true); // Tidy up the context values $context = $this->context; foreach ($context as $key => $val) { // Remove objects. You can't use them in templates. if (is_object($val)) { unset($context[$key]); } // Remove underscored variables. if ($remove_underscored && Pattern::startsWith($key, '_')) { unset($context[$key]); } } // Get extra page data $this->page_data = Content::get(URL::getCurrent()); // CSS $output = $this->css->link('all_the_vars'); if (!$this->fetchParam('websafe_font', false, null, true)) { $output .= '<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Ubuntu+Mono" />'; } // Create table $output .= $this->createTable($context, false); // Display on the screen die($output); }
public function control_panel__add_to_foot() { // only needed on publish pages if (URL::getCurrent(false) !== '/publish') { return ""; } return $this->js->link('section_tabs'); }
public function control_panel__add_to_foot() { // only needed on publish pages if (URL::getCurrent(false) !== '/globes') { return ''; } return $this->js->link('globes'); }
/** * Retrieve the parent page * @return Array Array containing the content of the parent page */ private function getParent() { $parent = URL::assemble(URL::popLastSegment(URL::getCurrent())); if (Taxonomy::isTaxonomyURL($parent)) { $parent = URL::popLastSegment($parent); } return Content::get($parent); }
public function control_panel__add_to_foot() { if (URL::getCurrent(false) === '/entries') { $add_on = 'pagereorder_redux'; $base_url = Config::get('_site_url', '/'); return '<script type="text/javascript" src="' . $base_url . '/_add-ons/' . $add_on . '/js/jquery.' . $add_on . '.js"></script>'; } }
public function control_panel__add_to_head() { if (URL::getCurrent(false) == '/publish') { // Inject JS & CSS file to head $js = $this->js->link('wChar.min.js'); $css = $this->css->link('limited.css'); return $js . $css; } }
/** * Creates JavaScript to add to the Control Panel's footer * * @return string */ function control_panel__add_to_foot() { if (URL::getCurrent() == '/publish') { $html = $this->js->link('jquery.spectrum.js'); // load in global options $spectrum_options = json_encode($this->getConfig()); $html .= $this->js->inline("\n var spectrum_options = {$spectrum_options};\n \$(document).ready(function() {\n \$('input[type=text].colorpicker').each(function() {\n var preferences = \$.extend({}, spectrum_options, \$(this).data('spectrum'));\n \$(this)\n .spectrum({\n color: \$(this).val() || preferences.starting_color,\n flat: preferences.select_on_page,\n showInput: preferences.show_input,\n showInitial: preferences.show_initial,\n showAlpha: preferences.show_alpha,\n localStorageKey: preferences.local_storage_key,\n showPalette: preferences.show_palette,\n showPaletteOnly: preferences.show_palette_only,\n showSelectionPalette: preferences.show_selection_palette,\n cancelText: preferences.cancel_text,\n chooseText: preferences.choose_text,\n preferredFormat: preferences.preferred_format,\n maxSelectionSize: preferences.max_selection_size,\n palette: preferences.palette\n });\n });\n\n // for dynamically loaded rows\n \$('body').on('addRow', '.grid', function() {\n var input = \$(this).find('input[type=text].colorpicker');\n\n input\n .each(function() {\n var preferences = \$.extend({}, spectrum_options, \$(this).data('spectrum'));\n\n // check for already-initialized fields\n if (\$(this).next().is('.sp-replacer')) {\n return;\n }\n\n \$(this)\n .spectrum({\n color: \$(this).val() || preferences.starting_color,\n flat: preferences.select_on_page,\n showInput: preferences.show_input,\n showInitial: preferences.show_initial,\n showAlpha: preferences.show_alpha,\n localStorageKey: preferences.local_storage_key,\n showPalette: preferences.show_palette,\n showPaletteOnly: preferences.show_palette_only,\n showSelectionPalette: preferences.show_selection_palette,\n cancelText: preferences.cancel_text,\n chooseText: preferences.choose_text,\n preferredFormat: preferences.preferred_format,\n maxSelectionSize: preferences.max_selection_size,\n palette: preferences.palette\n });\n });\n });\n });\n "); return $html; } }
public function control_panel__add_to_head() { if (URL::getCurrent(false) != '/publish' && URL::getCurrent(false) != '/member') { return; } $config = array('max_files' => 1, 'allowed' => array(), 'destination' => 'UPLOAD_PATH', 'browse' => false); $fieldtype = Fieldtype::render_fieldtype('file', 'markituploader', $config, null, null, 'markituploader', 'markituploader'); $template = File::get($this->getAddonLocation() . 'views/modal.html'); return $this->js->inline('Statamic.markituploader = ' . json_encode(Parse::template($template, compact('fieldtype'))) . ';'); }
/** * Creates JavaScript to add to the Control Panel's footer * * @return string */ function control_panel__add_to_foot() { if (URL::getCurrent(false) == '/publish') { $html = $this->js->link('jquery.spectrum.js'); // load in global options $spectrum_options = json_encode($this->getConfig()); $html .= $this->js->inline("\n var spectrum_options = {$spectrum_options};\n \$(document).ready(function() {\n\n function initSpectrum(el) {\n var preferences = \$.extend({}, spectrum_options, el.data('spectrum'));\n el.spectrum({\n color: el.val() || preferences.starting_color,\n flat: preferences.select_on_page,\n showInput: preferences.show_input,\n showInitial: preferences.show_initial,\n showAlpha: preferences.show_alpha,\n localStorageKey: preferences.local_storage_key,\n showPalette: preferences.show_palette,\n showPaletteOnly: preferences.show_palette_only,\n showSelectionPalette: preferences.show_selection_palette,\n cancelText: preferences.cancel_text,\n chooseText: preferences.choose_text,\n preferredFormat: preferences.preferred_format,\n maxSelectionSize: preferences.max_selection_size,\n palette: preferences.palette\n });\n }\n\n \$('input[type=text].colorpicker').each(function() {\n initSpectrum(\$(this));\n });\n\n // grid\n \$('body').on('addRow', '.grid', function() {\n \$(this).find('input[type=text].colorpicker').each(function() {\n initSpectrum(\$(this));\n });\n });\n\n // replicator\n \$('body').on('addSet', function(e, set) {\n \$(set).find('input[type=text].colorpicker').each(function() {\n initSpectrum(\$(this));\n });\n });\n });\n "); return $html; } }
/** * Adds items to control panel footer for certain pages * * @return string */ public function control_panel__add_to_foot() { if (URL::getCurrent(false) == '/publish') { $html = $this->js->link(array('leaflet.js', 'jquery.location.js')); $options = json_encode($this->getConfig()); // modal $html .= ' <div id="location-selector" style="display: none;"> <div class="modal" id="location-modal"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h3>Common Places</h3> </div> <div class="modal-body"> <ul></ul> </div> <div class="modal-footer"> </div> </div> </div> <div id="address-lookup" style="display: none;"> <div class="modal" id="address-modal"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h3>Locate an Address</h3> </div> <div class="modal-body"> <form> <p> <label for="modal-address-field">Address</label><br /> <input type="text" name="address" id="modal-address-field" value="" /> <input type="submit" name="lookup" value="Locate" /> <small> For example: 1120 Pine Grove Road, Gardners, PA </small> </p> </form> </div> <div class="modal-footer"> <small> Geocoding Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="//developer.mapquest.com/content/osm/mq_logo.png"><br> © OpenStreetMap contributors — <a href="http://www.openstreetmap.org/copyright">License</a> </small> </div> </div> </div> '; $html .= $this->js->inline("\n \$(document).ready(function() {\n var location_options = {$options};\n \$('.input-location').each(function() {\n \$(this).addClass('location-enabled').location(location_options);\n });\n\n // for dynamically loaded rows\n \$('body').on('addRow', '.grid', function() {\n var input = \$(this).find('input[type=text].location');\n\n input\n .each(function() {\n \$(this).location(location_options);\n });\n });\n\n // now for replicator\n \$('body').on('addSet', function() {\n \$('.input-location').not('.location-enabled').addClass('location-enabled').location(location_options);\n });\n });\n "); return $html; } return ""; }
public function count() { $url = $this->fetchParam('from', URL::getCurrent()); $url = Path::resolve($url); $max_depth = $this->fetchParam('max_depth', 1, 'is_numeric'); $tree = Statamic::get_content_tree($url, 1, $max_depth); if ($this->content != '') { return Parse::tagLoop($this->content, $tree); } else { return count($tree); } }
public function control_panel__add_to_foot() { if (URL::getCurrent() == '/publish' && Request::get('path') == $this->tasks->getFilename()) { return $this->js->inline(' $(".input-block").first().hide(); $(".status-block") .html("<span class=\'folder\'>' . Localization::fetch('editing_globals') . '</span>") .next().find("li").first().hide(); $("#item-content a").removeClass("active"); $("#item-globals a").addClass("active"); '); } }
/** * Adds items to control panel footer for certain pages * * @return string */ public function control_panel__add_to_foot() { if (URL::getCurrent(false) == '/publish') { $html = $this->js->link(array('leaflet.js', 'jquery.location.js')); $options = json_encode($this->getConfig()); // modal $html .= ' <div id="location-selector" style="display: none;"> <div class="modal" id="location-modal"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h3>Common Places</h3> </div> <div class="modal-body"> <ul></ul> </div> <div class="modal-footer"> </div> </div> </div> <div id="address-lookup" style="display: none;"> <div class="modal" id="address-modal"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h3>Locate an Address</h3> </div> <div class="modal-body"> <form> <p> <label for="modal-address-field">Address</label><br /> <input type="text" name="address" id="modal-address-field" value="" /> <input type="submit" name="lookup" value="Locate" /> <small> For example: 1120 Pine Grove Road, Gardners, PA </small> </p> </form> </div> <div class="modal-footer"> <small>Powered by <a href="http://open.mapquestapi.com">MapQuest</a>.</small> </div> </div> </div> '; $html .= $this->js->inline("\n \$(document).ready(function() {\n var location_options = {$options};\n \$('.input-location').each(function() {\n \$(this).location(location_options);\n });\n\n // for dynamically loaded rows\n \$('body').on('addRow', '.grid', function() {\n var input = \$(this).find('input[type=text].location');\n\n input\n .each(function() {\n \$(this).location(location_options);\n });\n });\n });\n "); return $html; } return ""; }
/** * Starts the application. * * Starts to process the request. The request will be processed using these * steps: * - If `TI_REQURLKEY` is not defined, this function will call enableWebUI. * This should not happen after the installation succeeded. * - If the request path starts with `TI_ADMIN_PATH` and a matching file in * the `assets` folder exists, it will be served. * - If the request path starts with `TI_ADMIN_PATH`, enableWebUI will be * called in order to provide the administration interface. * - If the requested path is considered equal to the base path of this * application, this function will process the request as specified with * the `home_action` option. * - Finally, this function uses {@link Database\LinksTableAdapter::resolvePath} * to find the target the given path should redirect to. * - If the previous step fails, a 404 error will be issued and a related * page will be shown. */ public static function start() { $currURL = URL::getCurrent(); if (!defined('TI_REQURLKEY')) { $path = isset($_GET['_webuipath']) ? $_GET['_webuipath'] : ''; return self::enableWebUI($path, $_GET); } $router = Router::fromGeneratedURL($currURL, TI_REQURLKEY); $match = $router->match(TI_ADMIN_PATH . '/assets/%%'); if ($match !== false) { $assetdir = realpath(Application::$rootDir . '/assets/'); $filepath = realpath($assetdir . '/' . $match[0]); if ($filepath !== false) { if (strpos($filepath, $assetdir) !== 0) { die('Attack attempt: directory traversal attack'); } if (file_exists($filepath) && is_file($filepath)) { header('Content-Type: ' . MimeContentTypes::getForFile($filepath)); readfile($filepath); exit; } } } $match = $router->match(TI_ADMIN_PATH . '/%%?'); if ($match !== false) { return self::enableWebUI($match[0], $router->getParameters()); } $dbc = self::dbConnection(); $path = implode('/', $router->getPathElements()); if ($path === '') { $opts = $dbc->options()->getOptions(array('home_action', 'home_target')); $target = WebUI\Page::getURL(''); switch ($opts['home_action']) { case 'redirect': $target = URL::parse($opts['home_target'], 'http'); break; } $target->redirectTo(); } else { $link = $dbc->links()->resolvePath($path); if (!$link) { $nfp = WebUI\NotFoundPage::getInstance($path, array()); self::startWebUI($nfp, array()); exit; } header('Location: ' . $link->resolved, 302); } }
public function index() { // if disabled, do nothing if (!$this->core->isEnabled()) { return Parse::contextualTemplate($this->content, array(), $this->context); } // grab and prepare parameters $key = $this->fetchParam('key', null, null, false, false); $age = time() - Date::resolve('-' . $this->fetch(array('for', 'default_cache_length'), '12 hours', null, false, false)); $hash = $this->fetch(array('scope', 'default_scope'), 'site') === 'page' ? Helper::makeHash(URL::getCurrent(), $this->content) : Helper::makeHash($this->content); $path = 'troves/' . $hash; // deal with keys if ($key) { // split on pipes $keys = explode('|', $key); // loop through keys, storing this hash to this key foreach ($keys as $key) { $key_path = 'keys/' . trim($key); // get existing keys $hashes = $this->cache->getYAML($key_path, array()); $new_hashes = array(); // check that the hashes are all still valid foreach ($hashes as $new_hash) { if ($this->cache->exists('troves/' . $new_hash)) { $new_hashes[] = $new_hash; } } // add this one $new_hashes[] = $hash; // append new ones $this->cache->putYAML($key_path, array_unique($new_hashes)); } } // check for pre-existing cache if (!$this->cache->exists($path) || $this->cache->getAge($path) > $age) { // cache doesn't exist or has expired, so parse this contextually... $html = Parse::contextualTemplate($this->content, array(), $this->context); // ...and store the HTML $this->cache->put($path, $html); } // garbage collection $this->core->collectGarbage(); // return what we know return $this->cache->get($path); }
public function require_password() { $password_list = trim($this->fetchParam('allowed', '', null, false, false)); $passwords = explode('|', $password_list); $password_url = $this->fetch('password_url', null, null, false, false); $no_access_url = $this->fetch('no_access_url', '/', null, false, false); $return_variable = $this->fetch('return_variable', 'return', null, false, false); // no passwords set? this is OK if (!$password_list) { return; } // determine form URL $form_url = Helper::pick($password_url, $no_access_url); if (!$this->tasks->hasPassword(URL::getCurrent(), $passwords)) { URL::redirect(URL::appendGetVariable($form_url, $return_variable, URL::getCurrent()), 302); exit; } }
function __construct() { parent::__construct(); $this->page = Content::get(URL::getCurrent()); // get control and location variables $this->ignore_seo_image_field = $this->fetchConfig('ignore_seo_image_field'); $this->sharable_image_default = $this->fetchConfig('default_image'); $this->sharable_image_source = $this->fetchConfig('sharable_image_source'); // get the variables that are actually printed in output $this->site_url = URL::getSiteURL(); $this->page_url = URL::tidy($this->site_url . URL::getCurrent(true)); $this->description = $this->getPageDescription(); $this->twitter = $this->fetchConfig('twitter'); $this->twitter_default_message = $this->fetchConfig('twitter_default_message'); $this->site_name = Config::getSiteName(); $this->image_url = $this->getShareableImage(); $this->page_title = $this->site_name . " | " . $this->getPageTitle(); $this->google_analytics = $this->fetchConfig('google_analytics_key'); }
public function control_panel__add_to_foot() { if (URL::getCurrent(false) == '/publish') { $options = $this->getConfig(); // Load Redactor plugins and scripts $plugins = array_get($options, 'plugins', array()); $scripts = array(); foreach ($plugins as $key => $plugin) { $scripts[] = $plugin . '.js'; } $scripts[] = 'redactor.min.js'; $html = $this->js->link($scripts); // Load image browser folder if (class_exists('Fieldtype_redactor') && method_exists('Fieldtype_redactor', 'get_field_settings')) { $field_settings = Fieldtype_redactor::get_field_settings(); $field_config = array_get($field_settings, 'field_config', $field_settings); // Image uploads if (array_get($field_config, 'image_dir', false)) { $image_path = Path::tidy($field_config['image_dir'] . '/'); $resize_options = array_get($field_config, 'resize', array()); if (count($resize_options)) { $resize_options['resize'] = true; } $resize_options_string = http_build_query($resize_options); $options['imageGetJson'] = Config::getSiteRoot() . "TRIGGER/redactor/fetch_images?path={$image_path}"; $options['imageUpload'] = Config::getSiteRoot() . "TRIGGER/redactor/upload?path={$image_path}&{$resize_options_string}&is_image=true"; } // File uploads if (array_get($field_config, 'file_dir', false)) { $file_path = Path::tidy($field_config['file_dir'] . '/'); $options['fileUpload'] = Config::getSiteRoot() . "TRIGGER/redactor/upload?path={$file_path}"; } if (isset($field_config['image_dir_append_slug'])) { $options['uploadFields'] = array('subfolder' => '#publish-slug'); } } $redactor_options = json_encode($options, true); // Initialization $html .= "<script>\n\n var redactor_options = {$redactor_options};\n\n \$(document).ready(function() {\n \n \$.extend(redactor_options, {'imageUploadErrorCallback': function(json) {\n alert(json.error);\n }});\n\n\n \$('.redactor-container textarea').redactor(redactor_options);\n });\n\n\n \$('body').on('addRow', '.grid', function() {\n \$.extend(redactor_options, {'imageUploadErrorCallback': callback});\n \$('.redactor-container textarea').redactor(redactor_options);\n });\n\n function callback(obj, json) {\n alert(json.error);\n }\n </script>"; return $html; } }
/** * Lists entries based on passed parameters * * @return array|string */ public function listing() { $folders = $this->fetchParam('folder', $this->fetchParam('folders', ltrim($this->fetchParam('from', URL::getCurrent()), "/"))); $folders = $folders === "/" ? "" : $folders; if ($this->fetchParam('taxonomy', false, null, true, null)) { $taxonomy_parts = Taxonomy::getCriteria(URL::getCurrent()); $taxonomy_type = $taxonomy_parts[0]; $taxonomy_slug = Config::get('_taxonomy_slugify') ? Slug::humanize($taxonomy_parts[1]) : urldecode($taxonomy_parts[1]); $content_set = ContentService::getContentByTaxonomyValue($taxonomy_type, $taxonomy_slug, $folders); } else { $content_set = ContentService::getContentByFolders($folders); } // filter $content_set->filter(array('show_all' => $this->fetchParam('show_hidden', false, null, true, false), 'since' => $this->fetchParam('since'), 'until' => $this->fetchParam('until'), 'show_past' => $this->fetchParam('show_past', TRUE, NULL, TRUE), 'show_future' => $this->fetchParam('show_future', FALSE, NULL, TRUE), 'type' => 'pages', 'conditions' => trim($this->fetchParam('conditions', "")))); // sort $content_set->sort($this->fetchParam('sort_by', 'order_key'), $this->fetchParam('sort_dir')); // grab total entries for setting later $total_entries = $content_set->count(); // limit $limit = $this->fetchParam('limit', null, 'is_numeric'); $offset = $this->fetchParam('offset', 0, 'is_numeric'); $paginate = $this->fetchParam('paginate', true, null, true, false); if ($limit || $offset) { if ($limit && $paginate && !$offset) { // pagination requested, isolate the appropriate page $content_set->isolatePage($limit, URL::getCurrentPaginationPage()); } else { // just limit $content_set->limit($limit, $offset); } } // manually supplement $content_set->supplement(array('total_found' => $total_entries)); // check for results if (!$content_set->count()) { return array('no_results' => true); } // if content is used in this entries loop, parse it $parse_content = (bool) preg_match(Pattern::USING_CONTENT, $this->content); return Parse::tagLoop($this->content, $content_set->get($parse_content)); }
public function listing() { // grab a taxonomy set from the content service $taxonomy_set = ContentService::getTaxonomiesByType($this->fetchParam('type', null)); // folders $folders = $this->fetchParam('folder', $this->fetchParam('folders', ltrim($this->fetchParam('from', URL::getCurrent()), "/"))); // now filter that down to just what we want $taxonomy_set->filter(array('folders' => $folders, 'show_hidden' => $this->fetchParam('show_hidden', false, null, true, false), 'show_drafts' => $this->fetchParam('show_drafts', false, null, true, false), 'since' => $this->fetchParam('since', null), 'until' => $this->fetchParam('until', null), 'min_count' => $this->fetchParam('min_count', 1, 'is_numeric'), 'show_future' => $this->fetchParam('show_future', false, null, true, false), 'show_past' => $this->fetchParam('show_past', true, null, true, false), 'conditions' => trim($this->fetchParam('conditions', null, false, false, false)), 'where' => trim($this->fetchParam('where', null, false, false, false)))); // sort as needed $taxonomy_set->sort($this->fetchParam('sort_by', 'name'), $this->fetchParam('sort_dir', 'asc')); // trim to limit the number of results $taxonomy_set->limit($this->fetchParam('limit', null, 'is_numeric')); // contextualize the urls to the given folder $taxonomy_set->contextualize($this->fetchParam('folder', null)); $output = $taxonomy_set->get(); // no results found, return so if (!count($output)) { return array('no_results' => true); } // results found, parse the tag loop with our content return Parse::tagLoop($this->content, $output, true, $this->context); }
/** * Add the modal to the footer * * @return string */ public function control_panel__add_to_foot() { // don't do anything on the login screen if (Request::getResourceURI() == '/login') { return false; } // master switch for revisions if (!$this->core->isEnabled()) { return false; } if (!URL::getCurrent() == '/publish') { return false; } $path = $this->core->getPath(); $view_data = array('revisions' => $this->core->getRevisions($path), 'path' => $path); // revision selector $view = File::get($this->getAddonLocation() . 'views/modal.html'); $html = Parse::template($view, $view_data); // revision message $view = File::get($this->getAddonLocation() . 'views/commit_modal.html'); $html .= Parse::template($view, $view_data); return $html; }
/** * Returns a ContentSet object with the appropriate content * * @param array $settings Settings for filtering content and such * @return ContentSet */ private function getContentSet($settings) { // create a unique hash for these settings $content_hash = Helper::makeHash($settings); if ($this->blink->exists($content_hash)) { // blink content exists, use that $content_set = new ContentSet($this->blink->get($content_hash)); } else { // no blink content exists, get data the hard way if ($settings['taxonomy']) { $taxonomy_parts = Taxonomy::getCriteria(URL::getCurrent()); $taxonomy_type = $taxonomy_parts[0]; $taxonomy_slug = Config::get('_taxonomy_slugify') ? Slug::humanize($taxonomy_parts[1]) : urldecode($taxonomy_parts[1]); $content_set = ContentService::getContentByTaxonomyValue($taxonomy_type, $taxonomy_slug, $settings['folders']); } else { $content_set = ContentService::getContentByFolders($settings['folders']); } // filter $content_set->filter($settings); // grab total entries for setting later $total_entries = $content_set->count(); // pre-sort supplement $content_set->supplement(array('total_found' => $total_entries) + $settings); // sort $content_set->multisort($settings['sort']); // post-sort supplement $content_set->supplement(array( 'group_by_date' => trim($this->fetchParam("group_by_date", null, null, false, false)) ), true); // store content as blink content for future use $this->blink->set($content_hash, $content_set->extract()); } return $content_set; }
public function count() { // grab parameters $from = $this->fetchParam('from', URL::getCurrent()); $exclude = $this->fetchParam('exclude', false); $max_depth = $this->fetchParam('max_depth', 1, 'is_numeric'); $include_entries = $this->fetchParam('include_entries', false, false, true); $folders_only = $this->fetchParam('folders_only', true, false, true); $include_content = $this->fetchParam('include_content', false, false, true); $show_hidden = $this->fetchParam('show_hidden', false, null, true); // add in left-/ if not present if (substr($from, 0, 1) !== '/') { $from = '/' . $from; } // if this doesn't start with the site root, add the site root if (!Pattern::startsWith($from, Config::getSiteRoot())) { $from = Path::tidy(Config::getSiteRoot() . '/' . $from); } // standardize excludes if ($exclude && !is_array($exclude)) { $exclude = Helper::explodeOptions($exclude, array()); foreach ($exclude as $key => $value) { $exclude[$key] = Path::tidy(Config::getSiteRoot() . '/' . $value); } } // option hash $hash = Helper::makeHash($from, $exclude, $max_depth, $include_entries, $folders_only, $include_content, $show_hidden); // load the content tree from cache if ($this->blink->exists($hash)) { $tree = $this->blink->get($hash); } else { $tree = ContentService::getContentTree($from, $max_depth, $folders_only, $include_entries, $show_hidden, $include_content, $exclude); $this->blink->set($hash, $tree); } if ($this->content) { return Parse::template($this->content, array('count' => count($tree))); } elseif (count($tree)) { return count($tree); } return ''; }
public function forgot_password_form() { // parse parameters and vars $attr_string = ''; $site_root = Config::getSiteRoot(); $return = $this->fetchParam('return', URL::getCurrent(), null, false, false); $reset_return = $this->fetchParam('reset_return', null, null, false, false); $allow_request_return = $this->fetchParam('allow_request_return', false, null, true, false); $logged_in_redirect = $this->fetchParam('logged_in_redirect', $return, null, false, false); $attr = $this->fetchParam('attr', false); // check that email template(s) exist if (!Theme::getTemplate($this->fetchConfig('reset_password_html_email', false, null, false, false)) && !Theme::getTemplate($this->fetchConfig('reset_password_text_email', false, null, false, false))) { throw new Exception('Your reset password email template(s) must exist and contain a {{ reset_url }}.'); } // grab request return $get_return = filter_input(INPUT_GET, 'return', FILTER_SANITIZE_URL); $post_return = filter_input(INPUT_POST, 'return', FILTER_SANITIZE_URL); $request_return = Helper::pick($post_return, $get_return); // is user already logged in? forward as needed if (Auth::isLoggedIn()) { URL::redirect($logged_in_redirect, 302); } // if we're letting return values to be set in URL and one exists, grab it if ($allow_request_return && $request_return) { $return = $request_return; } // set up any data to be parsed into content $data = array('error' => $this->flash->get('forgot_password_error', ''), 'email_sent' => $this->flash->get('forgot_password_sent')); // set up attributes if ($attr) { $attributes_array = Helper::explodeOptions($attr, true); foreach ($attributes_array as $key => $value) { $attr_string .= ' ' . $key . '="' . $value . '"'; } } // set up form HTML $html = '<form method="post" action="' . Path::tidy($site_root . "/TRIGGER/member/forgot_password") . '" ' . $attr_string . '>'; $html .= '<input type="hidden" name="return" value="' . $return . '">'; if ($reset_return) { $html .= '<input type="hidden" name="reset_return" value="' . $reset_return . '">'; } $html .= '<input type="hidden" name="token" value="' . $this->tokens->create() . '">'; $html .= Parse::template($this->content, $data); $html .= '</form>'; // return that HTML return $html; }
/** * Creates CSS tags to add to the Control Panel's head tag * * @return string */ function control_panel__add_to_head() { if (URL::getCurrent() == '/publish') { return $this->css->link('fieldtamer.css'); } }
/** * Raven form tag pair * * {{ raven:form }} {{ /raven:form }} * * @return string */ public function form() { /* |-------------------------------------------------------------------------- | Formset |-------------------------------------------------------------------------- | | Raven really needs a formset to make it useful and secure. We may even | write a form decorator in the future to generate forms from formsets. | */ $formset = $this->fetchParam('formset', false); $return = $this->fetchParam('return', URL::getCurrent()); $error_return = $this->fetchParam('error_return', URL::getCurrent()); $multipart = ($this->fetchParam('files', false)) ? "enctype='multipart/form-data'" : ''; $old_values = array(); // Fetch the content if in edit mode if ($edit = $this->fetchParam('edit')) { $old_values = Content::get($edit, false, false); // Throw exception if there's an invalid URL if (count($old_values) == 0) { throw new FatalException('Invalid URL for editing'); } $entry_hash = Helper::encrypt($edit); } // Merge old values $old_values = array_merge($this->flash->get('old_values', array()), $old_values); // Sanitize data before returning it for display // $old_values = array_map_deep($old_values, 'htmlspecialchars'); // Set old values to re-populate the form $data = array(); array_set($data, 'value', $old_values); array_set($data, 'old_values', $old_values); /* |-------------------------------------------------------------------------- | Form HTML |-------------------------------------------------------------------------- | | Raven writes a few hidden fields to the form to help processing data go | more smoothly. Form attributes are accepted as colon/piped options: | Example: attr="class:form|id:contact-form" | | Note: The content of the tag pair is inserted back into the template | */ $form_id = $this->fetchParam('id', true); $attributes_string = ''; if ($attr = $this->fetchParam('attr', false, null, false, false)) { $attributes_array = Helper::explodeOptions($attr, true); foreach ($attributes_array as $key => $value) { $attributes_string .= " {$key}='{$value}'"; } } $html = "<form method='post' {$multipart} {$attributes_string}>\n"; $html .= "<input type='hidden' name='hidden[raven]' value='{$form_id}' />\n"; $html .= "<input type='hidden' name='hidden[formset]' value='{$formset}' />\n"; $html .= "<input type='hidden' name='hidden[return]' value='{$return}' />\n"; $html .= "<input type='hidden' name='hidden[error_return]' value='{$error_return}' />\n"; if ($edit) { $html .= "<input type='hidden' name='hidden[edit]' value='{$entry_hash}' />\n"; } /* |-------------------------------------------------------------------------- | Hook: Form Begin |-------------------------------------------------------------------------- | | Occurs in the middle the form allowing additional fields to be added. | Has access to the current fieldset. Must return HTML. | */ $html .= Hook::run('raven', 'inside_form', 'cumulative', ''); /* |-------------------------------------------------------------------------- | Hook: Content Preparse |-------------------------------------------------------------------------- | | Allows the modification of the tag data inside the form. Also has access | to the current formset. | */ $html .= Hook::run('raven', 'content_preparse', 'replace', $this->content, $this->content); $html .= "</form>"; return Parse::template($html, $data, array('statamic_view', 'callback'), $this->context); }
public static function parseCurrentURL() { return (object) @parse_url(URL::getCurrent()); }