Skip to content

Instantly share code, notes, and snippets.

View slivorezka's full-sized avatar

Andriy Malyeyev slivorezka

View GitHub Profile
'[{"timetableId":0,"timetableTitle":"Friday evening","startTime":"22:00","endTime":"10:00","events":[{"eventId":0,"featureTitle":"Ses","featureDescription":"\\u003Cp\\u003Ezdsvzsdvsd\\u003C\\/p\\u003E","featureLink":"","sessions":[{"start":"2018-03-09 19:00:00","duration":"0:15","link":"","linkText":"","title":"Event 3","text":""}]},{"eventId":1,"featureTitle":"AEG Taste Theatre","featureDescription":"\\u003Cp\\u003Esefsefwsefwef\\u003C\\/p\\u003E","featureLink":"https:\\/\\/google.com","sessions":[{"start":"2018-03-09 18:00:00","duration":"0:30","link":"https:\\/\\/www.google.com","linkText":"scscsc","title":"Event 2","text":"\\u003Cp\\u003Ewdwdwd\\u003C\\/p\\u003E"},{"start":"2018-03-09 20:00:00","duration":"0:45","link":"https:\\/\\/www.google.com","linkText":"sswsdwdw","title":"Event 1","text":"\\u003Cp\\u003Ewadawdadawdwad\\u003C\\/p\\u003E"}]}]}]'
#calendar {
width: 100%;
}
#calendar ul.days {
list-style: none;
padding: 0;
margin: 0;
width: 100%;
}
@slivorezka
slivorezka / drupal_7_get_dump_project.php
Created August 29, 2017 08:01
Drupal 7 Get dump of the project
<?php
global $base_path;
global $base_url;
$path = getcwd();
$file_path = variable_get('file_public_path', conf_path() . '/files');
$rootPath = realpath($path);
$zip = new ZipArchive();
$zip->open($path . '/' . $file_path . '/project_damp.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($rootPath), RecursiveIteratorIterator::LEAVES_ONLY);
@slivorezka
slivorezka / find_broken_modules.php
Created August 27, 2017 19:45
Drupal 7 Find broken modules
<?php
$count = 0;
$records = db_select('system', 's')
->fields('s', array('filename', 'name', 'type', 'status'))
->execute()
->fetchAll();
if (!empty($records)) {
foreach ($records as $record) {
@slivorezka
slivorezka / get_entity_by_alias.php
Created March 29, 2017 18:26
Drupal 8: Get Entity By Alias
<?php
// Some entity alias (node, taxonomy_term, user, etc).
$alias = '/about';
// Get URL obj.
$url = Url::fromUri('internal:' . $alias);
// Check exist alias.
if ($url->isRouted()) {
$params = $url->getRouteParameters();
$entity_type = key($params);
// GEt entity.
<?php
$result = db_query('SHOW TABLES');
foreach ($result as $row) {
if (preg_match('/field_deleted_data_.*/', $row->Tables_in_|your_db_name|)) {
db_drop_table($row->Tables_in_|your_db_name|);
}
if (preg_match('/field_deleted_revision_.*/', $row->Tables_in_|your_db_name|)) {
db_drop_table($row->Tables_in_|your_db_name|);
}
@slivorezka
slivorezka / tree_traversal.php
Created March 23, 2017 14:28
Tree traversal Example
<?php
$array = array(
'nodes' => 5,
'left' => array(
'nodes' => 2,
'left' => array(
'nodes' => 1
),
),
'right' => array(
@slivorezka
slivorezka / ImageRenderExampleBlockByURI.php
Created February 22, 2017 10:01 — forked from jerbob92/ImageRenderExampleBlockByURI.php
Render image into a block Drupal 8 Example by URI
<?php
/**
* @file
* Contains Drupal\mymodule\Plugin\Block\ImageRenderExampleBlockByURI.
*/
namespace Drupal\mymodule\Plugin\Block;
use Drupal\Core\Block\BlockBase;
@slivorezka
slivorezka / get_link.php
Last active January 9, 2017 13:50
Drupal 8: Get link
@slivorezka
slivorezka / create_global_variable.php
Created December 28, 2016 11:36
Drupal 8: Create global variable
<?php
/**
* Implements hook_template_preprocess_default_variables_alter().
*/
function MYMODULE_template_preprocess_default_variables_alter(&$variables) {
$current_path = \Drupal::service('path.current')->getPath();
$variables['current_path'] = $current_path;
}