예제 #1
0
 function run()
 {
     $json = array();
     // get action
     $data = json_decode(file_get_contents("php://input"));
     // switch
     switch ($data->action) {
         case 'views':
             // variables
             $view_array = views_get_all_views($reset = FALSE);
             // build array for each view and their display
             foreach ($view_array as $view => $v) {
                 foreach ($view_array[$view]->display as $display => $d) {
                     $arr = array('id' => "{$v->name}:{$display}", 'name' => "{$v->human_name} ({$d->display_title})");
                     $json[] = $arr;
                 }
             }
             break;
         case 'settings':
             // variables
             // log
             $settings = CRM_Core_BAO_Setting::getItem('windowsill', 'settings');
             $json = json_decode(utf8_decode($settings), true);
             break;
     }
     // return JSON
     // http://wiki.civicrm.org/confluence/display/CRMDOC/Create+a+Module+Extension
     // http://civicrm.stackexchange.com/questions/2348/how-to-display-a-drupal-view-in-a-civicrm-tab
     print json_encode($json, JSON_PRETTY_PRINT);
     // exit
     CRM_Utils_System::civiExit();
 }
예제 #2
0
 /**
  * Implements \SiteAudit\Check\Abstract\calculateScore().
  */
 public function calculateScore()
 {
     $this->registry['views'] = array();
     foreach (views_get_all_views() as $view) {
         if ($view->disabled) {
             continue;
         }
         $this->registry['views'][] = $view;
     }
     if (empty($this->registry['views'])) {
         $this->abort = TRUE;
         return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN;
     }
     return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS;
 }
예제 #3
0
 /**
  * @inheritDoc
  */
 public function optionsForm(&$form, &$form_state)
 {
     $options = array();
     foreach (views_get_all_views() as $view) {
         foreach ($view->display as $display) {
             if ($display['id'] != 'default') {
                 $view->set_display($display['id']);
                 $viewname = sprintf('%s (%s)', $view->human_name, $view->name);
                 if ($view->display_handler->get_option('style_plugin') == 'openlayers_source_vector') {
                     $options[$viewname][$view->name . ':' . $display['id']] = sprintf('%s:%s', $view->human_name, $display['id']);
                 }
                 if ($view->display_handler->get_option('style_plugin') == 'openlayers_map_views') {
                     $options[$viewname][$view->name . ':' . $display['id']] = sprintf('%s:%s', $view->human_name, $display['id']);
                 }
             }
         }
     }
     $form['view'] = array('#type' => 'select', '#title' => 'View and display', '#options' => $options, '#default_value' => $this->getOption('view'), '#required' => TRUE);
     return parent::optionsForm($form, $form_state);
 }
 /**
  * Installs Atrium instead of Drupal
  * 
  * Generates a random database prefix, runs the install scripts on the
  * prefixed database and enable the specified modules. After installation
  * many caches are flushed and the internal browser is setup so that the
  * page requests will run on the new prefix. A temporary files directory
  * is created with the same name as the database prefix.
  *
  * @param ...
  *   List of modules to enable for the duration of the test.
  */
 protected function setUp()
 {
     global $db_prefix, $user, $language, $profile, $install_locale;
     // $language (Drupal 6).
     // Store necessary current values before switching to prefixed database.
     $this->originalPrefix = $db_prefix;
     $this->originalLanguage = clone $language;
     $clean_url_original = variable_get('clean_url', 0);
     // Must reset locale here, since schema calls t().  (Drupal 6)
     if (module_exists('locale')) {
         $language = (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => '');
         locale(NULL, NULL, TRUE);
     }
     // Generate temporary prefixed database to ensure that tests have a clean starting point.
     //    $db_prefix = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
     $db_prefix = 'simpletest' . mt_rand(1000, 1000000);
     $install_locale = $this->install_locale;
     $profile = $this->install_profile;
     //    include_once DRUPAL_ROOT . '/includes/install.inc';
     include_once './includes/install.inc';
     drupal_install_system();
     //    $this->preloadRegistry();
     // Set up theme system for the maintenance page.
     // Otherwise we have trouble: https://ds.openatrium.com/dsi/node/18426#comment-38118
     // @todo simpletest module patch
     drupal_maintenance_theme();
     // Add the specified modules to the list of modules in the default profile.
     $args = func_get_args();
     //    $modules = array_unique(array_merge(drupal_get_profile_modules('default', 'en'), $args));
     $modules = array_unique(array_merge(drupal_verify_profile($this->install_profile, $this->install_locale), $args));
     //    drupal_install_modules($modules, TRUE);
     drupal_install_modules($modules);
     // Because the schema is static cached, we need to flush
     // it between each run. If we don't, then it will contain
     // stale data for the previous run's database prefix and all
     // calls to it will fail.
     drupal_get_schema(NULL, TRUE);
     if ($this->install_profile == 'openatrium') {
         // Download and import translation if needed
         if ($this->install_locale != 'en') {
             $this->installLanguage($this->install_locale);
         }
         // Install more modules
         $modules = _openatrium_atrium_modules();
         drupal_install_modules($modules);
         // Configure intranet
         // $profile_tasks = $this->install_profile . '_profile_tasks';
         _openatrium_intranet_configure();
         _openatrium_intranet_configure_check();
         variable_set('atrium_install', 1);
         // Clear views cache before rebuilding menu tree. Requires patch
         // [patch_here] to Views, as new modules have been included and
         // default views need to be re-detected.
         module_exists('views') ? views_get_all_views(TRUE) : TRUE;
         menu_rebuild();
     }
     _drupal_flush_css_js();
     $this->refreshVariables();
     $this->checkPermissions(array(), TRUE);
     user_access(NULL, NULL, TRUE);
     // Drupal 6.
     // Log in with a clean $user.
     $this->originalUser = $user;
     //    drupal_save_session(FALSE);
     //    $user = user_load(1);
     session_save_session(FALSE);
     $user = user_load(array('uid' => 1));
     // Restore necessary variables.
     variable_set('install_profile', $this->install_profile);
     variable_set('install_task', 'profile-finished');
     variable_set('clean_url', $clean_url_original);
     variable_set('site_mail', '*****@*****.**');
     // Use temporary files directory with the same prefix as database.
     $this->originalFileDirectory = file_directory_path();
     variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix);
     $directory = file_directory_path();
     // Create the files directory.
     file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
     set_time_limit($this->timeLimit);
 }
예제 #5
0
파일: drupal.php 프로젝트: JKeySZR/GraphML
/**
 *  Получить список VIEWS
 */
function dxray_get_views()
{
    $GML = new GraphML();
    $VIEWS = views_get_all_views();
    $nodeView = $GML->setOptionsNode()->Fill_setColor('#ccffff')->getOptions();
    $nodeDisplay = $GML->setOptionsNode()->Shape_setType('ellipse')->Fill_setColor('#ccffcc')->getOptions();
    $nodeDisplayPlug = $GML->setOptionsNode()->Shape_setType('parallelogram')->Fill_setColor('#33cccc')->getOptions();
    foreach ($VIEWS as $view) {
        //$id_view = $GML->addNodeShape($view->human_name);
        $v_data['attributes'] = array('Human name: ' . $view->human_name, 'Base_table: ' . $view->base_table, 'Base_field: ' . $view->base_field, 'Built: ' . dxray_convert_bool($view->built), 'Executed: ' . dxray_convert_bool($view->executed), 'Editing: ' . dxray_convert_bool($view->executed), 'Type: ' . $view->type);
        if ($view->attachment_before != '') {
            $v_data['attributes'][] = 'Attachment before: ' . $view->attachment_before;
            // string
        }
        if ($view->attachment_after != '') {
            $v_data['attributes'][] = 'Attachment after: ' . $view->attachment_after;
            // string
        }
        //$id_view = $GML->addNodeUMLClass($view->name, $v_data, $nodeView);
        $id_view = $GML->addNode($view->name, 'UMLClassNode', $nodeView, $v_data);
        $id_display = $GML->addNodeShape('Display', $nodeDisplay);
        $GML->addEdge($id_view, $id_display);
        $id_disp_plug_type = array();
        // name -> GML_ID
        foreach ($view->display as $display) {
            if (!isset($id_disp_plug_type[$display->display_plugin])) {
                $id_display_type = $GML->addNodeShape($display->display_plugin, $nodeDisplayPlug);
                $GML->addEdge($id_display, $id_display_type);
                $id_disp_plug_type[$display->display_plugin] = $id_display_type;
            } else {
                $id_display_type = $id_disp_plug_type[$display->display_plugin];
            }
            $data['attributes'] = array('ID: ' . $display->id, 'Display_Title: ' . $display->display_title, 'Display_plugin: ' . $display->display_plugin, 'DB table: ' . $display->db_table);
            if (isset($display->display_options['path'])) {
                $data['attributes'][] = 'Path: ' . $display->display_options['path'];
            }
            $id = $GML->addNodeUMLClass($display->display_title, $data);
            $GML->addEdge($id_display_type, $id);
        }
    }
    $dbg = 0;
    $file = DXRAY_OUTPATH . '/Views-' . date('d-m-Y_H-i-s') . '.graphml';
    $GML->createFullGraphML($file);
}
 function edit_form(&$form, &$form_state)
 {
     parent::edit_form($form, $form_state);
     $style = $form_state['item'];
     if (empty($style->name)) {
         $style = NULL;
     }
     module_load_include('inc', 'openlayers_ui', 'includes/openlayers_ui.styles');
     $properties = array('externalGraphic' => array('default' => '', 'desc' => t('The URL of an icon for points in a layer.  The following options are available:
     <ul><li>Full path, such as http://example.com/icon.png</li>
     <li>Relative Drupal path, such as sites/all/modules/example/icon.png</li>
     <li>Absolute path, such as /icon.png (though this is not suggested for maintainability reasons)</li></ul>'), 'maxlength' => 2083), 'backgroundGraphic' => array('default' => '', 'desc' => t('Url to a graphic to be used as the background under an externalGraphic.'), 'maxlength' => 2083), 'backgroundGraphicZIndex' => array('default' => '', 'desc' => t('The integer z-index value to use in rendering the background graphic.')), 'backgroundXOffset' => array('default' => '', 'desc' => t('The x offset (in pixels) for the background graphic.')), 'backgroundYOffset' => array('default' => '', 'desc' => t('The y offset (in pixels) for the background graphic.')), 'backgroundHeight' => array('default' => '', 'desc' => t('The height of the background graphic.  If not provided, the graphicHeight will be used.')), 'backgroundWidth' => array('default' => '', 'desc' => t('The width of the background width.  If not provided, the graphicWidth will be used.')), 'pointRadius' => array('default' => 6, 'desc' => t('The radius of a vector point or the size of
     an icon. Note that, when using icons, this value should be half the
     width of the icon image.')), 'fillColor' => array('default' => '#EE9900', 'desc' => t('This is the color used for
     filling in Polygons. It is also used in the center of marks for
     points: the interior color of circles or other shapes. It is
     not used if an externalGraphic is applied to a point.  This should be
     a hexadecimal value like #FFFFFF.')), 'fillOpacity' => array('default' => 1, 'desc' => t('This is the opacity used for filling in Polygons.
     It is also used in the center of marks for points: the interior
     color of circles or other shapes. It is not used if an
     externalGraphic is applied to a point.  This should be a value
     between 0 and 1.')), 'strokeColor' => array('default' => '#EE9900', 'desc' => t('This is color of the line on features. On
     polygons and point marks, it is used as an outline to the feature.
     On lines, this is the representation of the feature.  This should be
     a hexadecimal value like #FFFFFF.')), 'strokeWidth' => array('default' => 1, 'desc' => t('This is width of the line on features. On
     polygons and point marks, it is used as an outline to
     the feature. On lines, this is the representation of the
     feature.  This is a value in pixels.')), 'strokeOpacity' => array('default' => 1, 'desc' => t('This is opacity of the line on features.
     On polygons and point marks, it is used as an outline to the
     feature. On lines, this is the representation of the feature.
     This should be a value between 0 and 1.')), 'strokeLinecap' => array('default' => 'round', 'desc' => t('Options are butt, round, square. This property
     is similar to the SVG stroke-linecap property. It determines
     what the end of lines should look like. See the SVG link for
     image examples.'), 'options' => array('butt' => t('Butt'), 'round' => t('Round'), 'square' => t('Square'))), 'strokeDashstyle' => array('default' => 'solid', 'desc' => t('Options are dot, dash, dashdot, longdash, longdashdot, solid.'), 'options' => array('dot' => t('Dot'), 'dash' => t('Dash'), 'dashdot' => t('Dash-dot'), 'longdash' => t('Long-dash'), 'longdashdot' => t('Long-dash-dot'), 'solid' => t('Solid'))), 'cursor' => array('default' => '', 'desc' => t('Cursor used when mouse is over the feature. Default
     is an empty string, which inherits from parent elements.  See
     <a href="!url">CSS cursor styles</a>.', array('!url' => 'http://www.w3schools.com/css/pr_class_cursor.asp'))), 'graphicWidth' => array('default' => '', 'desc' => t('This properties define the width of an externalGraphic.
     This is an alternative to the pointRadius symbolizer property
     to be used when your graphic has different sizes in the X and
     Y direction.  This should be in pixels.')), 'graphicHeight' => array('default' => '', 'desc' => t('This properties define the height of an externalGraphic.
     This is an alternative to the pointRadius symbolizer property
     to be used when your graphic has different sizes in the X and
     Y direction.  This should be in pixels.')), 'graphicOpacity' => array('default' => '1', 'desc' => t('Opacity of an external graphic.  This should be a
     value between 0 and 1. Graphics that are already semitransparent,
     like alpha PNGs, should have this set to 1, or rendering problems in
     Internet Explorer will ensue.')), 'graphicXOffset' => array('default' => '', 'desc' => t('Where the X value of the "center" of an
   externalGraphic should be.  This should be in pixels.')), 'graphicYOffset' => array('default' => '', 'desc' => t('Where the Y value of the "center" of an
   externalGraphic should be.  This should be in pixels.')), 'graphicName' => array('default' => '', 'desc' => t('Name of a type of symbol to be used
     for a point mark.')), 'graphicZIndex' => array('default' => '', 'desc' => t('The integer z-index value to use in rendering.')), 'rotation' => array('default' => '', 'desc' => t('The rotation angle in degrees clockwise for
     a point symbolizer.')), 'display' => array('default' => '', 'desc' => t('Can be set to "none" to hide features
     from rendering.'), 'options' => array('' => t('On'), 'none' => t('None (off)'))), 'title' => array('default' => '', 'desc' => t('Tooltip when hovering over a feature.  Not supported by the canvas renderer.')), 'label' => array('default' => '', 'desc' => t('The text for an optional label. For browsers that use the canvas renderer, this requires either fillText or mozDrawText to be available. Typically used with ${attribute} syntax.')), 'labelAlign' => array('default' => 'cm', 'desc' => t('Label alignment.'), 'options' => array('cm' => t('Center, middle'), 'ct' => t('Center, top'), 'cb' => t('Center, bottom'), 'lm' => t('Left, middle'), 'lt' => t('Left, top'), 'lb' => t('Left, bottom'), 'rm' => t('Right, middle'), 'rt' => t('Right, top'), 'rb' => t('Right, bottom'))), 'labelXOffset' => array('default' => '', 'desc' => t('Label X offset. Positive numbers move label right.')), 'labelYOffset' => array('default' => '', 'desc' => t('Label Y offset. Positive numbers move label up.')), 'fontColor' => array('default' => '', 'desc' => t('The font color for the label, to be provided like CSS.')), 'fontOpacity' => array('default' => '', 'desc' => t('Opacity (0-1) for the label')), 'fontFamily' => array('default' => '', 'desc' => t('The font family for the label, to be provided like in CSS.')), 'fontSize' => array('default' => '', 'desc' => t('The font size for the label, to be provided like in CSS.')), 'fontStyle' => array('default' => '', 'desc' => t('The font style for the label, to be provided like in CSS.')), 'fontWeight' => array('default' => '', 'desc' => t('The font weight for the label, to be provided like in CSS.')));
     $form['info']['title'] = array('#id' => 'styletitle', '#type' => 'textfield', '#weight' => -1, '#title' => t('Style title'), '#default_value' => isset($style->title) ? $style->title : '', '#description' => t('The friendly name of your style, which will appear in the administration interface as well on the map interface.'));
     $form['info']['name']['#machine_name']['source'] = array('info', 'title');
     $fields = array();
     $views = views_get_all_views();
     foreach ($views as $vid => $view) {
         if (isset($view->display)) {
             foreach ($view->display as $vdid => $display) {
                 if (isset($display->display_options)) {
                     if (isset($display->display_options['style_plugin'])) {
                         if ($display->display_options['style_plugin'] == 'openlayers_data') {
                             foreach ($display->display_options['fields'] as $fid => $fdata) {
                                 $fields[] = t('<code>@fid</code> <em>(from view @viewname and display @displayname.)</em>', array('@fid' => '${' . $fid . '}', '@viewname' => $view->name, '@displayname' => $vdid));
                             }
                         }
                     }
                 }
             }
         }
     }
     $form['available_fields'] = array('#type' => 'fieldset', '#tree' => TRUE, '#collapsible' => TRUE, '#collapsed' => TRUE, '#title' => t('Available fields to use as token'), '#description' => t('Notice: Since OpenLayers beta 9, the rendering of
     . the fields has changed, it\'s not using the raw value of the field,
     . but the full row rendering. You must disable all the HTML element by
     . selecting None in the Style setting fieldset of the field in Views or
     . you might get a mix of HTML with the raw value of the field.'));
     if ($fields) {
         $form['available_fields']['fields'] = array('#markup' => theme('item_list', array('items' => $fields)));
     } else {
         $form['available_fields']['fields'] = array('#prefix' => '<p class="no-fields-message">', '#markup' => t('There are no available fields to use as tokens.'), '#suffix' => '</p>');
         $form['available_fields']['fields_instruction'] = array('#access' => user_access('administer views'), '#prefix' => '<p class="no-fields-instruction">', '#markup' => t('Go to the <a !attributes>Views administration</a> page and create an "OpenLayers Data Overlay" display.', array('!attributes' => drupal_attributes(array('href' => url('admin/structure/views'))))), '#suffix' => '</p>');
     }
     // OpenLayers style properties
     $form['data'] = array('#type' => 'fieldset', '#tree' => TRUE, '#title' => t('Style Properties'), '#description' => t('The specific properties for the style.'));
     foreach ($properties as $key => $prop) {
         $form['data'][$key] = array('#type' => !isset($prop['options']) ? 'textfield' : 'select', '#title' => !isset($prop['title']) ? check_plain($key) : check_plain($prop['title']), '#description' => filter_xss($prop['desc']), '#default_value' => isset($style->data[$key]) ? $style->data[$key] : $prop['default'], '#element_validate' => isset($prop['element_validate']) ? $prop['element_validate'] : array(), '#element_validate' => isset($prop['element_validate']) ? $prop['element_validate'] : array());
         // Add options if needed
         if (isset($prop['options']) && is_array($prop['options'])) {
             $form['data'][$key]['#options'] = $prop['options'];
         }
         // Add maxlength if needed
         if (isset($prop['maxlength']) && is_numeric($prop['maxlength'])) {
             $form['data'][$key]['#maxlength'] = $prop['maxlength'];
         }
     }
     // Add preview button.
     $form['buttons']['preview'] = array('#type' => 'button', '#value' => t('Preview'));
 }
예제 #7
0
파일: Views.php 프로젝트: pounard/yamm
 /**
  * (non-PHPdoc)
  * @see IFormable::form()
  */
 public function form()
 {
     yamm_api_bootstrap_entity();
     // Building views list.
     $base_table = $available_views = $selected_views = array();
     $views_list = views_get_all_views();
     $default_views = array();
     foreach (oox_registry_get('yamm_entity')->getItemCache() as $type => $value) {
         // Getting all base table with entities.
         if (isset($value['base_table'])) {
             $base_table[$value['base_table']] = $value['base_table'];
         }
     }
     foreach ($views_list as $name => $view) {
         // Check if the view has a known base table for entities.
         if (in_array($view->base_table, $base_table)) {
             $available_views[$view->name] = '<strong>' . $view->name . '</strong> - ' . filter_xss_admin($view->description);
             $default_views[$view->name] = 0;
         }
     }
     // Saved selected views.
     $selected_views = $this->getViews();
     // Check all selected views.
     foreach ($selected_views as $view) {
         //  Check if view has not been deleted.
         if (array_key_exists($view->name, $default_views)) {
             $default_views[$view->name] = $view->name;
         }
     }
     $form['views'] = array('#type' => 'checkboxes', '#options' => $available_views, '#default_value' => $default_views, '#title' => t('Views that export content'), '#description' => t('Select views that export content. Only the default display will be use for content export. All select views will be used at each client synchronization whatever is the entity type they return.'), '#required' => TRUE, '#multiple' => TRUE);
     return $form;
 }