Syntaxhighlight: Unterschied zwischen den Versionen

Aus mw139
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
 
(2 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
== python ==
== python ==
‎<syntaxhighlight lang="python" line>
‎<syntaxhighlight>
def quick_sort(arr):
xx
less = []
pivot_list = []
more = []
if len(arr) <= 1:
return arr
else:
pass
‎</syntaxhighlight>
‎</syntaxhighlight>


== php ==
== php ==
use Drupal\sxt_mediawiki\SxtMediawiki;
‎<syntaxhighlight lang="php" highlight="3-5,8,15-17,30" line>
use Drupal\node\NodeInterface;
<?php
use Drupal\Core\Form\FormStateInterface;


/**
/**
  * Implements hook_form_FORM_ID_alter().
  * @file
* Contains \Drupal\sxt_mediawiki\Plugin\Field\FieldType\MwCommentFieldType.
  */
  */
function sxt_mediawiki_form_field_config_edit_form_alter(array &$form, FormStateInterface $form_state) {
 
  SxtMediawiki::configEditFormAlter($form, $form_state);
namespace Drupal\sxt_mediawiki\Plugin\Field\FieldType;
}
 
use Drupal\sxt_mediawiki\Plugin\Field\FieldType\MediaWikiFieldType;
use Drupal\Core\Field\FieldDefinitionInterface;


/**
/**
  * Implements hook_form_FORM_ID_alter() for node entities.
  * Plugin implementation of the 'sxt_mwcomment' field type.
*
* @FieldType(
*  id = "sxt_mwcomment",
*  label = @Translation("MW Comment"),
*  description = @Translation("This field stores comments in mediawiki format."),
*  category = @Translation("Text"),
*  default_widget = "sxt_mediawiki",
*  default_formatter = "sxt_mediawiki"
* )
  */
  */
function sxt_mediawiki_form_node_form_alter(array &$form, FormStateInterface $form_state) {
class MwCommentFieldType extends MediaWikiFieldType {
  SxtMediawiki::nodeFormAlter($form, $form_state);
 
}
  /**
  * {@inheritdoc}
  */
  public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
    $values['value'] = self::generateParagraphs(mt_rand(1, 4), self::PARA_TEXT);
    return $values;
  }
 
  protected static function getParagraphsAvailable() {
    return [
      self::PARA_TEXT,
      self::PARA_ULIST,
      self::PARA_ULIST,
      self::PARA_OLIST,
      self::PARA_OLIST,
      self::PARA_DEFLIST,
    ];
  }


== json ==
{
    "state": "xtwf_collect_content",
    "league": 0,
    "workflow": "xxtwig01",
    "severity": "leight",
    "data": {
        "finalize_by_timeout": false,
        "finalize_strict": false,
        "started": 1610286511,
        "changed": 1610286805,
        "user_data": {
            "1": {
                "129": {
                    "nid": "2505",
                    "shared": 0
                },
                "last_sid": "129",
                "shared": 0
            }
        },
        "state_data": {
            "base-tid": "111",
            "draft-tid": "112",
            "shared-tid": "113",
        },
        "jsmeta_data": {
            "contribution": {
                "type": "openDialog",
                "fullPath": "sxt_opentalk\/xtajx\/collaborate\/c\/1092\/workflow\/ccollect\/{action}"
            }
        },
        "workflow_parents": {
            "twig": "xxtrunkb01:xtwf_run_twig__twig1"
        }
    },
    "expire": 1611150511
}
}
</syntaxhighlight>

Aktuelle Version vom 28. Juni 2022, 20:50 Uhr

python[Bearbeiten]

xx
‎

php[Bearbeiten]

<?php

/**
 * @file
 * Contains \Drupal\sxt_mediawiki\Plugin\Field\FieldType\MwCommentFieldType.
 */

namespace Drupal\sxt_mediawiki\Plugin\Field\FieldType;

use Drupal\sxt_mediawiki\Plugin\Field\FieldType\MediaWikiFieldType;
use Drupal\Core\Field\FieldDefinitionInterface;

/**
 * Plugin implementation of the 'sxt_mwcomment' field type.
 *
 * @FieldType(
 *   id = "sxt_mwcomment",
 *   label = @Translation("MW Comment"),
 *   description = @Translation("This field stores comments in mediawiki format."),
 *   category = @Translation("Text"),
 *   default_widget = "sxt_mediawiki",
 *   default_formatter = "sxt_mediawiki"
 * )
 */
class MwCommentFieldType extends MediaWikiFieldType {

  /**
   * {@inheritdoc}
   */
  public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
    $values['value'] = self::generateParagraphs(mt_rand(1, 4), self::PARA_TEXT);
    return $values;
  }

  protected static function getParagraphsAvailable() {
    return [
      self::PARA_TEXT,
      self::PARA_ULIST,
      self::PARA_ULIST,
      self::PARA_OLIST,
      self::PARA_OLIST,
      self::PARA_DEFLIST,
    ];
  }

}