1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
<?php
namespace hji\geofarms\models;
use hji\geofarms\GeoFarms;
use hji\common\utils\Views;
class TinyMCE
{
function registerPlugin($plugin_array)
{
$plugin_array['GeoFarms'] = GeoFarms::$scripts . '/components/tinymce-geo-farms.js';
return $plugin_array;
}
function registerButton($buttons)
{
array_push($buttons, "|", "GeoFarms");
return $buttons;
}
function loadWindow()
{
if (!current_user_can('edit_pages') && !current_user_can('edit_posts'))
{
die(__("You are not allowed to be here"));
}
if (!$_REQUEST['plugin'])
{
die();
}
$vars['field'] = array_merge(
$this->addField('title'),
$this->addField('ids'),
$this->addField('tags'),
$this->addField('sort'),
$this->addField('display_type'),
$this->addField('grid_size'),
$this->addField('img_w'),
$this->addField('img_h'),
$this->addField('img_class')
);
$vars['sortOptions'] = array(
'No order' => 'none',
'Random' => 'rand',
'Area ID' => 'ID',
'Area Title' => 'title',
'Area Name (Slug)' => 'name',
'Date' => 'date',
'Modified Date' => 'modified',
'Menu Order' => 'menu_order',
'ID List Above' => 'post__in',
);
$vars['displayOptions'] = array('List', 'Grid');
$vars['gridSize'] = array(
'1' => '12',
'2' => '6',
'3' => '4',
'4' => '3'
);
$view = new Views(GeoFarms::$views);
echo $view->render('tinymce-widget', $vars);
die();
}
function addField($fieldName)
{
$field[$fieldName]['id'] = $fieldName;
$field[$fieldName]['name'] = $fieldName;
$field[$fieldName]['value'] = false;
return $field;
}
}