вівторок, 2 серпня 2011 р.

Пательню нарешті знесуть?

Йшов сьогодні по парку приблизно опів на першу. Дощ уже пройшов, з дерев не капає, вода під ногами не заважає, аж раптом чую тріск зліва по курсу. Думаю: і сьогодні побачу як дерево падає, як на тому тижні. Аж ні, то стіна закладу, відомого в народі як "пательня" падає. Гарно так, вперше у житті на свої очі таке побачив.
Підійшов ближче. З "пательні" вийшли два чолов'яги, підійшли до пролому, дивляться, обговорюють. А звідти ще й досі то одна цеглина, то декілька одразу випадають.



Підійшло ще декілька людей, кажуть, що ця стіна вже давно хилилася, а тепер після дощу землю розмило, і стіна обвалилася. Дивлюся, поруч стіна теж нахилена, і крім цього пролому (4-4,5 м) може утворитися інший.

Що ж, схоже, здійсниться таки, мрія багатьох знайомих про зникнення цього "шедевру" архітектури з нашого парку.

PS. Все відновили...

четвер, 13 січня 2011 р.

Створення wiki в Drupal (Create a wiki with Drupal)

Що потрібно:

  1. Створити новий тип node (напр. “my_wiki_page”).
    Або через інтерфейс Друпал, або через модуль. Тут і надалі буде описуватися створення через написання власного модуля my_wiki.
/**
* Implementation of hook_node_info()
*/
function my_wiki_node_info() {
  return array(
      'my_wiki_page' => array(
        'name' => t('My wiki page'),
        'module' => 'my_wiki',
        'description' => 'My Drupal wiki pages',
        ),
  );
}

/**
 * Implementation of hook_perm()
 */
function my_wiki_perm() {
  return array(
      'create wiki page',
      'edit any wiki page',
      'edit own wiki page',
      'delete any wiki page',
      );
}

/**
 * Implementation of hook_access()
 */
function my_wiki_access($op, $node, $account) {
  // NOTE: For creation operations the $node is a string, not an object

  if ($op == 'create' && $node) {
    // Only users with permission to do so may create this node type.
    if ($node === 'my_wiki_page') {
      return user_access('create wiki page', $account);
    }
  }

  if ($node->type == 'my_wiki_page') {
    // Operations with wiki pages

    // Only users with permission to do so may edit/delete this node type.
    // Users who create a node may edit or delete it later, assuming they have the
    // necessary permissions.
    if ($op == 'update') {
      if (user_access('edit any wiki page', $account)) {
        return TRUE;
      }
      if (user_access('edit own wiki page', $account) && ($account->uid == $node->uid)) {
        return TRUE;
      }
    }

    if ($op == 'delete') {
      if (user_access('delete any wiki page', $account)) {
        return TRUE;
      }
      if (user_access('edit own wiki page', $account) && ($account->uid == $node->uid)) {
        return TRUE;
      }
    }
  }
}

  1. Встановити модулі Wikitools, Diff  та Pathauto. Можна й не встановлювати, якщо правильно вказати залежності модуля, цей модуль встановиться автоматично разом з новим модулем. Досить лише помістити скачаний модуль до директорії "sites/all/modules".
  2. Встановити правильні дозволи.. Всі користувачі повинні мати наступні дозволи:
    "access content",
    "create wiki page",
    "edit own wiki page",
    "view revisions",
    "revert revisions".
    Привілейовані користувачі також можуть додатково мати наступні дозволи:
    "edit any wiki page",
    "delete any wiki page".

  3. Налаштувати шаблони Pathauto. Можна функцією:
    /*
     * Function which creates the "Pathauto" patterns for URLs of content related to wiki pages.
     */
    function _my_wiki_create_pathauto_patterns() {
      $node_type = 'my_wiki_page';
      variable_set('pathauto_node_' . $node_type . '_pattern', 'wiki/[title-raw]');
    }
    

  4. Встановити "My wiki page" як тип сторінки для модуля Wikitools.
    Функція встановлення налаштувань модуля Wikitools:
    /*
     * Function which enables needed settings of the Wikitools module.
     */
    function _my_wiki_wikitools_enable_settings() {
      // Load the "filter_admin_format_form" function and its "_submit".
      module_load_include('inc', 'wikitools', 'wikitools.admin');
    
      // Array of pages that should be used as wiki pages
      $wiki_pages = array(
          'my_wiki_page' => 1,
          );
    
      $wikitools_fields = array();
      $wikitools_fields['values']['wikitools_node_types'] = $wiki_pages;
    
      $wikitools_form = wikitools_admin_settings($wikitools_fields);
      system_settings_form_submit($wikitools_form, $wikitools_fields);
    
      // Print messages
      drupal_set_message();
    }
    
    
    
  5. Виклик останніх функцій слід помістити в hook_enable модуля:
    /**
     * Implementation of hook_enable()
     */
    function my_wiki_enable() {
      // Create needed Pathauto patterns of aliases
      _my_wiki_create_pathauto_patterns();
    
      // Enable needed settings of the Wikitools module.
      _my_wiki_wikitools_enable_settings();
    }
    
    
  6. Встановити правильні поля форми створення сторінки, використавши hook_form хук:
    /**
     * Implementation of hook_form()
     */
    function my_wiki_form(&$node, $form_state) {
      if (!empty($node)) {
        if ($node->type == 'my_wiki_page') {
          // Create modified form for create/edit wiki node.
    
          // Set proper title for wiki page creation
          if (arg(1) === 'add') {
            drupal_set_title(t('Create Wiki Page'));
          }
    
          $type = node_get_types('type', $node);
    
          // Set node parameters
          $node->promote = FALSE;
          $node->revision = 1;
          $node->comment = 0;
    
    
          // Set title
          $form['title'] = array(
              '#type' => 'textfield',
              '#title' => check_plain($type->title_label),
              '#required' => TRUE,
              '#default_value' => $node->title,
              '#weight' => -5
              );
    
          // Set body
          $form['body_filter']['body'] = array(
              '#type' => 'textarea',
              '#title' => check_plain($type->body_label),
              '#default_value' => $node->body,
              '#required' => FALSE
              );
          // Set format
          $form['body_filter']['filter'] = filter_form($node->format);
    
          // Set revisions
          $form['revision_information']['revision']['#default_value'] = $node->revision;
    
          // Disable comments
          if (isset($form['comment_settings']['comment'])) {
            $form['comment_settings']['comment']['#default_value'] = $node->comment;
          }
    
          // Node options for administrators
          $form['options'] = array(
              '#type' => 'fieldset',
              '#access' => user_access('administer nodes'),
              '#title' => t('Publishing options'),
              '#collapsible' => TRUE,
              '#collapsed' => TRUE,
              '#weight' => 25,
              );
    
          $form['options']['promote'] = array(
              '#type' => 'checkbox',
              '#title' => t('Promoted to front page'),
              '#default_value' => $node->promote,
              );
    
          return $form;
        }
      }
    }
    
    

  7. Встановити CKEditor як редактор для сторінок або використовувати якийсь із вікі-фільтрів, наприклад: flexifilter або pearwiki filter.

Тепер (після встановлення цього модуля) за шляхом "/wiki" Вашого сайту Вам буде запропоновано створити головну сторінку ("Main Page"). Так само, якщо ввести шлях типу "http://<Ваш сайт>/wiki/test", Вам буде запропоновано створити дану сторінку. Модуль Diff надасть можливість порівнювати зміни між ревізіями файла.

Дивіться також: http://cwgordon.com/how-to-create-a-wiki-with-drupal.

PS. Вміст .info файла  для модуля:

; $Id$
name = "My wiki"
description = "Module which provides wiki pages"
package = "My modules"
version = 1.0
core = 6.x

dependencies[] = diff
dependencies[] = pathauto
dependencies[] = wikitools