/**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('xmlsitemap.settings');
     $intervals = array(300, 900, 1800, 3600, 10800, 21600, 43200, 86400, 172800, 259200, 604800);
     $intervals = array_combine($intervals, $intervals);
     $format_intervals = array();
     foreach ($intervals as $key => $value) {
         $format_intervals[$key] = $this->date->formatInterval($key);
     }
     $form['minimum_lifetime'] = array('#type' => 'select', '#title' => t('Minimum sitemap lifetime'), '#options' => array(0 => t('No minimum')) + $format_intervals, '#description' => t('The minimum amount of time that will elapse before the sitemaps are regenerated. The sitemaps will also only be regenerated on cron if any links have been added, updated, or deleted.') . '<br />' . t('Recommended value: %value.', array('%value' => t('1 day'))), '#default_value' => $config->get('minimum_lifetime'));
     $form['xsl'] = array('#type' => 'checkbox', '#title' => t('Include a stylesheet in the sitemaps for humans.'), '#description' => t('When enabled, this will add formatting and tables with sorting to make it easier to view the XML sitemap data instead of viewing raw XML output. Search engines will ignore this.'), '#default_value' => $config->get('xsl'));
     $form['prefetch_aliases'] = array('#type' => 'checkbox', '#title' => t('Prefetch URL aliases during sitemap generation.'), '#description' => t('When enabled, this will fetch all URL aliases at once instead of one at a time during sitemap generation. For medium or large sites, it is recommended to disable this feature as it uses a lot of memory.'), '#default_value' => $config->get('prefetch_aliases'));
     $form['advanced'] = array('#type' => 'details', '#title' => t('Advanced settings'), '#collapsible' => TRUE, '#collapsed' => !$this->state->get('xmlsitemap_developer_mode'), '#weight' => 10);
     $form['advanced']['gz'] = array('#type' => 'checkbox', '#title' => t('Generate additional compressed sitemaps using gzip.'), '#default_value' => $config->get('gz'), '#disabled' => !function_exists('gzencode'));
     $chunk_sizes = array(100, 500, 1000, 2500, 5000, 10000, 25000, XMLSITEMAP_MAX_SITEMAP_LINKS);
     $form['advanced']['chunk_size'] = array('#type' => 'select', '#title' => t('Number of links in each sitemap page'), '#options' => array('auto' => t('Automatic (recommended)')) + array_combine($chunk_sizes, $chunk_sizes), '#default_value' => xmlsitemap_var('chunk_size'), '#description' => t('If there are problems with rebuilding the sitemap, you may want to manually set this value. If you have more than @max links, an index with multiple sitemap pages will be generated. There is a maximum of @max sitemap pages.', array('@max' => XMLSITEMAP_MAX_SITEMAP_LINKS)));
     $batch_limits = array(5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000);
     $form['advanced']['batch_limit'] = array('#type' => 'select', '#title' => t('Maximum number of sitemap links to process at once'), '#options' => array_combine($batch_limits, $batch_limits), '#default_value' => xmlsitemap_var('batch_limit'), '#description' => t('If you have problems running cron or rebuilding the sitemap, you may want to lower this value.'));
     if (!xmlsitemap_check_directory()) {
         $form_state->setErrorByName('path', t('The directory %directory does not exist or is not writable.', array('%directory' => xmlsitemap_get_directory())));
     }
     $form['advanced']['path'] = array('#type' => 'textfield', '#title' => t('Sitemap cache directory'), '#default_value' => $config->get('path'), '#size' => 30, '#maxlength' => 255, '#description' => t('Subdirectory where the sitemap data will be stored. This folder <strong>must not be shared</strong> with any other Drupal site or install using XML sitemap.'), '#field_prefix' => file_build_uri(''), '#required' => TRUE);
     $form['advanced']['xmlsitemap_base_url'] = array('#type' => 'textfield', '#title' => t('Default base URL'), '#default_value' => $this->state->get('xmlsitemap_base_url'), '#size' => 30, '#description' => t('This is the default base URL used for sitemaps and sitemap links.'), '#required' => TRUE);
     $form['advanced']['lastmod_format'] = array('#type' => 'select', '#title' => t('Last modification date format'), '#options' => array(XMLSITEMAP_LASTMOD_SHORT => t('Short'), XMLSITEMAP_LASTMOD_MEDIUM => t('Medium'), XMLSITEMAP_LASTMOD_LONG => t('Long')), '#default_value' => $config->get('lastmod_format'));
     foreach ($form['advanced']['lastmod_format']['#options'] as $key => &$label) {
         $label .= ' (' . gmdate($key, REQUEST_TIME) . ')';
     }
     $form['advanced']['xmlsitemap_developer_mode'] = array('#type' => 'checkbox', '#title' => t('Enable developer mode to expose additional settings.'), '#default_value' => $this->state->get('xmlsitemap_developer_mode'));
     $form['xmlsitemap_settings'] = array('#type' => 'vertical_tabs', '#weight' => 20);
     $entities = xmlsitemap_get_link_info(NULL, TRUE);
     foreach ($entities as $entity => $entity_info) {
         $form[$entity] = array('#type' => 'details', '#title' => $entity_info['label'], '#collapsible' => TRUE, '#collapsed' => TRUE, '#group' => 'xmlsitemap_settings');
         if (!empty($entity_info['bundles'])) {
             // If this entity has bundles, show a bundle setting summary.
             xmlsitemap_add_form_entity_summary($form[$entity], $entity, $entity_info);
         }
         if (!empty($entity_info['xmlsitemap']['settings callback'])) {
             // Add any entity-specific settings.
             $entity_info['xmlsitemap']['settings callback']($form[$entity]);
         }
         // Ensure that the entity fieldset is not shown if there are no accessible
         // sub-elements.
         $form[$entity]['#access'] = (bool) Element::getVisibleChildren($form[$entity]);
     }
     return parent::buildForm($form, $form_state);
 }
コード例 #2
0
 /**
  * Test the getViaUri() and getViaScheme() methods and target functions.
  */
 function testUriFunctions()
 {
     $config = $this->config('system.file');
     $instance = \Drupal::service('stream_wrapper_manager')->getViaUri($this->scheme . '://foo');
     $this->assertEqual($this->classname, get_class($instance), 'Got correct class type for dummy URI.');
     $instance = \Drupal::service('stream_wrapper_manager')->getViaUri('public://foo');
     $this->assertEqual('Drupal\\Core\\StreamWrapper\\PublicStream', get_class($instance), 'Got correct class type for public URI.');
     // Test file_uri_target().
     $this->assertEqual(file_uri_target('public://foo/bar.txt'), 'foo/bar.txt', 'Got a valid stream target from public://foo/bar.txt.');
     $this->assertEqual(file_uri_target('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='), 'image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', t('Got a valid stream target from a data URI.'));
     $this->assertFalse(file_uri_target('foo/bar.txt'), 'foo/bar.txt is not a valid stream.');
     $this->assertFalse(file_uri_target('public://'), 'public:// has no target.');
     $this->assertFalse(file_uri_target('data:'), 'data: has no target.');
     // Test file_build_uri() and
     // Drupal\Core\StreamWrapper\LocalStream::getDirectoryPath().
     $this->assertEqual(file_build_uri('foo/bar.txt'), 'public://foo/bar.txt', 'Expected scheme was added.');
     $this->assertEqual(\Drupal::service('stream_wrapper_manager')->getViaScheme('public')->getDirectoryPath(), PublicStream::basePath(), 'Expected default directory path was returned.');
     $this->assertEqual(\Drupal::service('stream_wrapper_manager')->getViaScheme('temporary')->getDirectoryPath(), $config->get('path.temporary'), 'Expected temporary directory path was returned.');
     $config->set('default_scheme', 'private')->save();
     $this->assertEqual(file_build_uri('foo/bar.txt'), 'private://foo/bar.txt', 'Got a valid URI from foo/bar.txt.');
     // Test file_create_url()
     // TemporaryStream::getExternalUrl() uses Url::fromRoute(), which needs
     // route information to work.
     $this->container->get('router.builder')->rebuild();
     $this->assertTrue(strpos(file_create_url('temporary://test.txt'), 'system/temporary?file=test.txt'), 'Temporary external URL correctly built.');
     $this->assertTrue(strpos(file_create_url('public://test.txt'), Settings::get('file_public_path') . '/test.txt'), 'Public external URL correctly built.');
     $this->assertTrue(strpos(file_create_url('private://test.txt'), 'system/files/test.txt'), 'Private external URL correctly built.');
 }
コード例 #3
0
 /**
  * Test the URI and target functions.
  */
 function testUriFunctions()
 {
     $config = \Drupal::config('system.file');
     $instance = file_stream_wrapper_get_instance_by_uri($this->scheme . '://foo');
     $this->assertEqual($this->classname, get_class($instance), 'Got correct class type for dummy URI.');
     $instance = file_stream_wrapper_get_instance_by_uri('public://foo');
     $this->assertEqual('Drupal\\Core\\StreamWrapper\\PublicStream', get_class($instance), 'Got correct class type for public URI.');
     // Test file_uri_target().
     $this->assertEqual(file_uri_target('public://foo/bar.txt'), 'foo/bar.txt', 'Got a valid stream target from public://foo/bar.txt.');
     $this->assertFalse(file_uri_target('foo/bar.txt'), 'foo/bar.txt is not a valid stream.');
     // Test file_build_uri() and
     // Drupal\Core\StreamWrapper\LocalStream::getDirectoryPath().
     $this->assertEqual(file_build_uri('foo/bar.txt'), 'public://foo/bar.txt', 'Expected scheme was added.');
     $this->assertEqual(file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath(), PublicStream::basePath(), 'Expected default directory path was returned.');
     $this->assertEqual(file_stream_wrapper_get_instance_by_scheme('temporary')->getDirectoryPath(), $config->get('path.temporary'), 'Expected temporary directory path was returned.');
     $config->set('default_scheme', 'private')->save();
     $this->assertEqual(file_build_uri('foo/bar.txt'), 'private://foo/bar.txt', 'Got a valid URI from foo/bar.txt.');
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function denormalize($data, $class, $format = NULL, array $context = array())
 {
     // File content can be passed base64 encoded in a special "data" property.
     // That property is not a field, so we remove it before denormalizing the
     // rest of the file entity.
     $file_data = $data['data'][0]['value'];
     unset($data['data']);
     $entity = parent::denormalize($data, $class, $format, $context);
     // Decode and save to file if it's a new file.
     if (!isset($context['request_method']) || $context['request_method'] != 'patch') {
         $file_contents = base64_decode($file_data);
         $dirname = $this->fileSystem->dirname($entity->getFileUri());
         file_prepare_directory($dirname, FILE_CREATE_DIRECTORY);
         if ($uri = file_unmanaged_save_data($file_contents, file_build_uri(drupal_basename($entity->getFilename())))) {
             $entity->setFileUri($uri);
         } else {
             throw new RuntimeException('failed to write ' . $entity->getFilename());
         }
     }
     return $entity;
 }
コード例 #5
0
function write_file_array($rel_path = '', $MODULE_NAME, $PATH_TO_MODULE, $BASE_SOURCE_REL_PATH, $DESTINATION_DIR)
{
    $output = '';
    $full_path = $PATH_TO_MODULE . $BASE_SOURCE_REL_PATH . $rel_path;
    if ($handle = opendir($full_path)) {
        while (false !== ($file = readdir($handle))) {
            if (is_dir($full_path . '/' . $file) && $file != '.' && $file != '..') {
                $output .= write_file_array('/' . $file, $MODULE_NAME, $PATH_TO_MODULE, $BASE_SOURCE_REL_PATH, $DESTINATION_DIR);
            } elseif ($file != '.' && $file != '..') {
                $uri = file_build_uri($DESTINATION_DIR . $rel_path . '/' . $file);
                $output .= "     '" . $uri . "' => array(\n";
                $output .= "     'uri' => '" . $uri . "',\n";
                $output .= "     'filename' => '" . $file . "',\n";
                $output .= "     'source' => \$module_dir.'" . $BASE_SOURCE_REL_PATH . $rel_path . '/' . $file . "',\n";
                $output .= "),\n";
            }
        }
        closedir($handle);
    }
    return $output;
}
コード例 #6
0
 /**
  * Test the URI and target functions.
  */
 function testUriFunctions()
 {
     $config = \Drupal::config('system.file');
     $instance = file_stream_wrapper_get_instance_by_uri($this->scheme . '://foo');
     $this->assertEqual($this->classname, get_class($instance), 'Got correct class type for dummy URI.');
     $instance = file_stream_wrapper_get_instance_by_uri('public://foo');
     $this->assertEqual('Drupal\\Core\\StreamWrapper\\PublicStream', get_class($instance), 'Got correct class type for public URI.');
     // Test file_uri_target().
     $this->assertEqual(file_uri_target('public://foo/bar.txt'), 'foo/bar.txt', 'Got a valid stream target from public://foo/bar.txt.');
     $this->assertEqual(file_uri_target('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='), 'image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', t('Got a valid stream target from a data URI.'));
     $this->assertFalse(file_uri_target('foo/bar.txt'), 'foo/bar.txt is not a valid stream.');
     $this->assertFalse(file_uri_target('public://'), 'public:// has no target.');
     $this->assertFalse(file_uri_target('data:'), 'data: has no target.');
     // Test file_build_uri() and
     // Drupal\Core\StreamWrapper\LocalStream::getDirectoryPath().
     $this->assertEqual(file_build_uri('foo/bar.txt'), 'public://foo/bar.txt', 'Expected scheme was added.');
     $this->assertEqual(file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath(), PublicStream::basePath(), 'Expected default directory path was returned.');
     $this->assertEqual(file_stream_wrapper_get_instance_by_scheme('temporary')->getDirectoryPath(), $config->get('path.temporary'), 'Expected temporary directory path was returned.');
     $config->set('default_scheme', 'private')->save();
     $this->assertEqual(file_build_uri('foo/bar.txt'), 'private://foo/bar.txt', 'Got a valid URI from foo/bar.txt.');
 }
コード例 #7
0
ファイル: html.vars.php プロジェクト: toptomatotwo/tomwebdev
/**
 * Add body classes if certain regions have content.
 */
function unikue_preprocess_html(&$vars)
{
    global $base_url;
    $css = "";
    $themepath = drupal_get_path('theme', 'unikue');
    drupal_add_js(array('themePath' => $themepath), 'setting');
    drupal_add_css($themepath . '/css/loading.css');
    drupal_add_css($themepath . '/css/base.css');
    drupal_add_css($themepath . '/css/normalize.css');
    drupal_add_css($themepath . '/css/style.css');
    drupal_add_css($themepath . '/css/drupal-additional.css');
    drupal_add_js($themepath . '/js/jquery-migrate-1.2.1.js');
    drupal_add_js($themepath . '/js/form.js');
    //drupal_add_js($themepath . '/js/jquery.min.js');
    drupal_add_js($themepath . '/js/jquery.countTo.js');
    drupal_add_js($themepath . '/js/modernizr.js');
    drupal_add_js($themepath . '/js/main.js');
    drupal_add_js($themepath . '/js/woozy.js');
    drupal_add_js($themepath . '/js/twd.js');
    drupal_add_js($themepath . '/js/jquery-ui.min.js');
    ///////////////////////////////////////// Construct page title //////////////////////////////////////////////////////.
    if (drupal_get_title()) {
        $head_title = array('title' => str_replace(array('&lt;i&gt;', '&lt;/i&gt;'), '', drupal_get_title()), 'name' => check_plain(variable_get('site_name', 'Drupal')));
    } else {
        $head_title = array('name' => check_plain(variable_get('site_name', 'Drupal')));
        if (variable_get('site_slogan', '')) {
            $head_title['slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
        }
    }
    $vars['head_title_array'] = $head_title;
    $vars['head_title'] = implode(' | ', $head_title);
    // Match path if necessary.
    $page_match = TRUE;
    $path = drupal_strtolower(drupal_get_path_alias($_GET['q']));
    //////////////////////////////////////////// FAVICON SETTING ////////////////////////////////////////////
    // Add favicon.
    if (theme_get_setting('toggle_fvicon')) {
        $favicon_path = $base_url . '/' . $themepath . '/favicon.ico';
        if (theme_get_setting('default_favicon') == 0) {
            if (module_exists('media')) {
                $favicon = theme_get_setting('fvicon_upload');
                if (!empty($favicon)) {
                    $file = json_decode($favicon);
                    $favicon_path = $file->url;
                }
            } else {
                if ($favicon_file = theme_get_setting('fvicon_file')) {
                    $favicon_path = file_create_url(file_build_uri($favicon_file));
                }
            }
        }
        $type = theme_get_setting('favicon_mimetype');
        drupal_add_html_head_link(array('rel' => 'shortcut icon', 'href' => drupal_strip_dangerous_protocols($favicon_path), 'type' => $type));
    }
    // iOs webclip
    $vars['ios_57'] = '';
    if (module_exists('media')) {
        if (theme_get_setting('ios_57x57_media_file')) {
            $file_upload = theme_get_setting('ios_57x57_media_file');
            if (!empty($file_upload)) {
                $file = json_decode($file_upload);
                $vars['ios_57'] = $file->url;
            }
        }
    } else {
        if (theme_get_setting('ios_57x57_form_file')) {
            $vars['ios_57'] = file_create_url(file_build_uri(theme_get_setting('ios_57x57_form_file')));
        }
    }
    $vars['ios_72'] = '';
    if (module_exists('media')) {
        if (theme_get_setting('ios_72x72_media_file')) {
            $file_upload = theme_get_setting('ios_72x72_media_file');
            if (!empty($file_upload)) {
                $file = json_decode($file_upload);
                $vars['ios_72'] = $file->url;
            }
        }
    } else {
        if (theme_get_setting('ios_72x72_form_file')) {
            $vars['ios_72'] = file_create_url(file_build_uri(theme_get_setting('ios_72x72_form_file')));
        }
    }
    $vars['ios_114'] = '';
    if (module_exists('media')) {
        if (theme_get_setting('ios_114x114_media_file')) {
            $file_upload = theme_get_setting('ios_114x114_media_file');
            if (!empty($file_upload)) {
                $file = json_decode($file_upload);
                $vars['ios_114'] = $file->url;
            }
        }
    } else {
        if (theme_get_setting('ios_114x114_form_file')) {
            $vars['ios_114'] = file_create_url(file_build_uri(theme_get_setting('ios_114x114_form_file')));
        }
    }
    $vars['ios_144'] = '';
    if (module_exists('media')) {
        if (theme_get_setting('ios_144x144_media_file')) {
            $file_upload = theme_get_setting('ios_144x144_media_file');
            if (!empty($file_upload)) {
                $file = json_decode($file_upload);
                $vars['ios_144'] = $file->url;
            }
        }
    } else {
        if (theme_get_setting('ios_144x144_form_file')) {
            $vars['ios_144'] = file_create_url(file_build_uri(theme_get_setting('ios_144x144_form_file')));
        }
    }
    $vars['theme_setting_css'] = $css;
    //Google Fonts
    if (theme_get_setting('typo_hidden')) {
        $typo = theme_get_setting('typo_hidden');
        $css .= unikue_typo_builder_to_css($typo);
    }
    /* Get theme settings
       ---------------------------------------------------------------------------------------- */
    $vars['footer_text'] = theme_get_setting('footer_text');
    $vars['header_code'] = theme_get_setting('header_code');
    $vars['footer_code'] = theme_get_setting('footer_code');
    if (theme_get_setting('custom_css')) {
        $vars['custom_css'] = theme_get_setting('custom_css');
    }
    drupal_add_css(path_to_theme() . '/css/ie7.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE));
    $vars['theme_setting_css'] = $css;
}
コード例 #8
0
 /**
  * {@inheritdoc}
  */
 public function buildUrl($path, $clean_urls = NULL)
 {
     $uri = $this->buildUri($path);
     // The token query is added even if the
     // 'image.settings:allow_insecure_derivatives' configuration is TRUE, so
     // that the emitted links remain valid if it is changed back to the default
     // FALSE. However, sites which need to prevent the token query from being
     // emitted at all can additionally set the
     // 'image.settings:suppress_itok_output' configuration to TRUE to achieve
     // that (if both are set, the security token will neither be emitted in the
     // image derivative URL nor checked for in
     // \Drupal\image\ImageStyleInterface::deliver()).
     $token_query = array();
     if (!\Drupal::config('image.settings')->get('suppress_itok_output')) {
         // The passed $path variable can be either a relative path or a full URI.
         $original_uri = file_uri_scheme($path) ? file_stream_wrapper_uri_normalize($path) : file_build_uri($path);
         $token_query = array(IMAGE_DERIVATIVE_TOKEN => $this->getPathToken($original_uri));
     }
     if ($clean_urls === NULL) {
         // Assume clean URLs unless the request tells us otherwise.
         $clean_urls = TRUE;
         try {
             $request = \Drupal::request();
             $clean_urls = RequestHelper::isCleanUrl($request);
         } catch (ServiceNotFoundException $e) {
         }
     }
     // If not using clean URLs, the image derivative callback is only available
     // with the script path. If the file does not exist, use Url::fromUri() to
     // ensure that it is included. Once the file exists it's fine to fall back
     // to the actual file path, this avoids bootstrapping PHP once the files are
     // built.
     if ($clean_urls === FALSE && file_uri_scheme($uri) == 'public' && !file_exists($uri)) {
         $directory_path = file_stream_wrapper_get_instance_by_uri($uri)->getDirectoryPath();
         return Url::fromUri('base:' . $directory_path . '/' . file_uri_target($uri), array('absolute' => TRUE, 'query' => $token_query))->toString();
     }
     $file_url = file_create_url($uri);
     // Append the query string with the token, if necessary.
     if ($token_query) {
         $file_url .= (strpos($file_url, '?') !== FALSE ? '&' : '?') . UrlHelper::buildQuery($token_query);
     }
     return $file_url;
 }
コード例 #9
0
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php 
print $GLOBALS['language']->language;
?>
" xml:lang="<?php 
print $GLOBALS['language']->language;
?>
">

<head>
  <title><?php 
print t('File viewer');
?>
</title>
  <script type="text/javascript">
    var epub_dir = "<?php 
print file_create_url(file_build_uri(variable_get('fileviewer_path', 'fileviewer') . '/' . $file->fid));
?>
";
  </script>
  <?php 
drupal_add_js(drupal_get_path('module', 'fileviewer') . '/epubjs/js/jquery-1.3.2.min.js');
?>
  <?php 
drupal_add_js(drupal_get_path('module', 'fileviewer') . '/epubjs/js/jquery-ui-1.7.1.custom.min.js');
?>
  <?php 
drupal_add_js(drupal_get_path('module', 'fileviewer') . '/epubjs/js/mousewheel.js');
?>
  <?php 
drupal_add_css(drupal_get_path('module', 'fileviewer') . '/epub/css/epubjs.css', array('scope' => 'footer'));
?>
コード例 #10
0
ファイル: page.vars.php プロジェクト: toptomatotwo/tomwebdev
/**
 * Implements hook_preprocess_page().
 */
function unikue_preprocess_page(&$vars)
{
    global $base_url;
    $themepath = drupal_get_path('theme', 'unikue');
    // check enable module panels
    if (module_exists('panels')) {
        // check page use panel
        $panel = panels_get_current_page_display();
        if (isset($panel) && !empty($panel->layout)) {
            $vars['theme_hook_suggestions'][] = 'page__panel';
        }
    }
    $vars['is_portfolio'] = FALSE;
    if (isset($vars['node'])) {
        $vars['theme_hook_suggestions'][] = 'page__node__' . $vars['node']->type;
        if ($vars['node']->type == 'portfolio') {
            $node_view = node_view(node_load($vars['node']->nid));
            if (isset($node_view['flippy_pager'])) {
                if (isset($node_view['flippy_pager']['#list']['prev']) && $node_view['flippy_pager']['#list']['prev'] != FALSE) {
                    $vars['prev_link'] = url('node/' . $node_view['flippy_pager']['#list']['prev']['nid']);
                }
                if (isset($node_view['flippy_pager']['#list']['next']) && $node_view['flippy_pager']['#list']['next'] != FALSE) {
                    $vars['next_link'] = url('node/' . $node_view['flippy_pager']['#list']['next']['nid']);
                }
            }
            $vars['is_portfolio'] = TRUE;
        }
    }
    // LOGO SETTINGS
    $vars['logo'] = $base_url . '/' . $themepath . '/logo.png';
    if (theme_get_setting('default_logo') == 0) {
        if (module_exists('media')) {
            if ($file_upload = theme_get_setting('logo_normal_media_file')) {
                if (!empty($file_upload)) {
                    $file_decode = json_decode($file_upload);
                    if (isset($file_decode->fid) && $file_decode->fid != 0) {
                        $file = file_load($file_decode->fid);
                        if ($file) {
                            $vars['logo'] = file_create_url($file->uri);
                        }
                    }
                }
            }
        } else {
            if ($logo_file = theme_get_setting('logo_normal_form_file')) {
                $vars['logo'] = file_create_url(file_build_uri($logo_file));
            }
        }
    }
    $vars['logo_footer'] = $base_url . '/' . $themepath . '/logo_footer.png';
    if (module_exists('media')) {
        if ($file_upload = theme_get_setting('logo_footer_media_file')) {
            if (!empty($file_upload)) {
                $file_decode = json_decode($file_upload);
                if (isset($file_decode->fid) && $file_decode->fid != 0) {
                    $file = file_load($file_decode->fid);
                    if ($file) {
                        $vars['logo_footer'] = file_create_url($file->uri);
                    }
                }
            }
        }
    } else {
        if ($logo_file = theme_get_setting('logo_footer_form_file')) {
            $vars['logo_footer'] = file_create_url(file_build_uri($logo_file));
        }
    }
    // Page title in node page
    if (isset($vars['node'])) {
        $node = $vars['node'];
        $vars['page_title'] = $vars['node']->type;
        if ($node->type == 'portfolio') {
        }
    }
    if (theme_get_setting('footer_text')) {
        $vars['footer_text'] = theme_get_setting('footer_text');
    }
    if (strpos(current_path(), 'portfolio_popup') !== false) {
    }
    /* layout */
    // Add information about the number of sidebars.
    if (!empty($vars['page']['sidebar_first']) && !empty($vars['page']['sidebar_second'])) {
        $vars['content_column_class'] = 'col-md-6';
    } elseif (!empty($vars['page']['sidebar_first']) || !empty($vars['page']['sidebar_second'])) {
        $vars['content_column_class'] = 'col-md-9';
    } else {
        $vars['content_column_class'] = '';
    }
    // Prepare dot navigation
    $tree = menu_tree_all_data('main-menu');
    $menu_tree_output = menu_tree_output($tree);
    $vars['dot_navigation'] = '';
    if (!empty($menu_tree_output)) {
        $vars['dot_navigation'] .= '<div class="w-hidden-medium w-hidden-small w-hidden-tiny dot-container" id="hide">';
    }
    foreach ($menu_tree_output as $menu_id => $value) {
        if (isset($value['#href']) && $value['#href'] == '<front>' && isset($value['#localized_options']['fragment']) && !empty($value['#localized_options']['fragment'])) {
            $vars['dot_navigation'] .= '<a class="w-inline-block dot-link" href="#' . $value['#localized_options']['fragment'] . '"></a>';
        }
    }
    if (!empty($menu_tree_output)) {
        $vars['dot_navigation'] .= '</div>';
    }
}
コード例 #11
0
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     $rows = array();
     // If the Data Entity row plugin is used, this will be an array of entities
     // which will pass through Serializer to one of the registered Normalizers,
     // which will transform it to arrays/scalars. If the Data field row plugin
     // is used, $rows will not contain objects and will pass directly to the
     // Encoder.
     foreach ($this->view->result as $row) {
         $tmpArrRender = $this->view->rowPlugin->render($row);
         /**
          * @var $entity \Drupal\node\Entity\Node
          * @var $fieldData \Drupal\Core\Field\FieldItemList|\Drupal\Core\Field\EntityReferenceFieldItemList
          * @var $imageData \Drupal\image\Plugin\Field\FieldType\ImageItem|\Drupal\Core\Entity\Plugin\DataType\EntityReference
          * @var $imageEntity \Drupal\Core\Entity\Plugin\DataType\EntityReference|\Drupal\file\Entity\File
          */
         $fields = array();
         $fieldGroup = array();
         $entity = $row->_entity;
         //could there be groups?
         if (function_exists('field_group_load_field_group')) {
             $groupingData = field_group_info_groups($entity->getEntityTypeId(), $entity->bundle(), 'view', 'api_structure');
             if (is_array($groupingData) && count($groupingData) > 0) {
                 foreach ($groupingData as $groupName => $group) {
                     $parent = $group->parent_name;
                     if (empty($parent)) {
                         //if we're a base group add us to fields
                         $fields[$groupName] = array();
                     } else {
                         //if we have a parent find it and add ourselves
                         $this->add_array_recursive($fields, $parent, $groupName);
                     }
                     //store group names
                     foreach ($group->children as $childName) {
                         if (substr($childName, 0, 6) !== "group_") {
                             $fieldGroup[$childName] = $groupName;
                         }
                     }
                 }
             }
         }
         foreach ($entity->getFields() as $fieldID => $fieldData) {
             $val = null;
             // if of type image
             if ($fieldData->getFieldDefinition()->getType() === "image") {
                 if (array_key_exists($fieldID, $tmpArrRender)) {
                     $val = array();
                     foreach ($fieldData as $imageData) {
                         $imageEntity = $imageData->getProperties(true)['entity']->getValue();
                         $val[] = array("alt" => $imageData->getValue()['alt'], "file" => str_replace(array("http:", "https:"), "", file_create_url(file_build_uri($imageEntity->getFilename()))), "type" => $imageEntity->getMimeType(), "size" => $imageEntity->getSize());
                     }
                 }
             }
             // if of type entity_reference
             if ($fieldData->getFieldDefinition()->getType() === "entity_reference") {
                 if (array_key_exists($fieldID, $tmpArrRender)) {
                     $val = $tmpArrRender[$fieldID];
                     $valDecode = json_decode($val, TRUE);
                     if ($fieldID == "field_technologies") {
                         $val = array();
                         foreach ($fieldData->getValue() as $referencedTechnology) {
                             $node = node_load($referencedTechnology['target_id']);
                             $title = $node->getFields()['title']->getValue()[0]['value'];
                             if (array_key_exists(0, $node->getFields()['field_marketing_url']->getValue())) {
                                 $url = $node->getFields()['field_marketing_url']->getValue()[0]['value'];
                             } else {
                                 $url = "";
                             }
                             $val[] = array("title" => $title, "field_marketing_url" => $url);
                         }
                     } else {
                         if ($valDecode !== NULL && is_array($valDecode)) {
                             $val = $valDecode;
                             array_walk_recursive($val, function (&$item) {
                                 if (!is_array($item)) {
                                     $item = htmlspecialchars_decode(html_entity_decode(urldecode($item), ENT_QUOTES));
                                 }
                             });
                         }
                     }
                 }
             }
             //make boolean a literal bool rather than string
             if ($fieldData->getFieldDefinition()->getType() === "boolean") {
                 if (array_key_exists($fieldID, $tmpArrRender)) {
                     $val = $tmpArrRender[$fieldID];
                     if ($val) {
                         $val = true;
                     } else {
                         $val = false;
                     }
                 }
             }
             //clean everything we get from json theme
             if ($val === null && array_key_exists($fieldID, $tmpArrRender)) {
                 $decodedData = json_decode($tmpArrRender[$fieldID], true);
                 if ($decodedData !== null && is_array($decodedData)) {
                     array_walk_recursive($decodedData, function (&$item) {
                         if (!is_array($item)) {
                             $item = htmlspecialchars_decode(html_entity_decode(urldecode($item), ENT_QUOTES));
                         }
                     });
                     $val = $decodedData;
                 } else {
                     $val = htmlspecialchars_decode(html_entity_decode(urldecode($tmpArrRender[$fieldID]), ENT_QUOTES));
                 }
             }
             if ($val !== null and !empty($val)) {
                 // Create leaf
                 $leaf = array("type" => $fieldData->getFieldDefinition()->getType(), "value" => $val);
                 if (isset($fieldGroup[$fieldID])) {
                     $groupName = $fieldGroup[$fieldID];
                     $this->add_array_recursive($fields, $groupName, $fieldID, $leaf);
                 } else {
                     $fields[$fieldID] = $leaf;
                 }
             }
         }
         $tmpArr = array("type" => $entity->getType(), "changed" => date("c", $entity->getChangedTime()), "fields" => $fields);
         //assign to working array
         $rows[] = $tmpArr;
     }
     // Get the content type configured in the display or fallback to the
     // default.
     if (empty($this->view->live_preview)) {
         $content_type = $this->displayHandler->getContentType();
     } else {
         $content_type = !empty($this->options['formats']) ? reset($this->options['formats']) : 'json';
     }
     return $this->serializer->serialize($rows, $content_type);
 }