diff --git a/action.php b/action.php index 4d603bf..9b9a9f6 100644 --- a/action.php +++ b/action.php @@ -58,7 +58,7 @@ function _handle(&$event, $param){ } function _editbutton(&$event, $param) { - if ($event->data['target'] !== 'plugin_data') { + if ($event->data['target'] !== 'plugin_data' OR $this->getConf('hide_edit_button')) { return; } diff --git a/conf/default.php b/conf/default.php index c09c56f..67133f1 100644 --- a/conf/default.php +++ b/conf/default.php @@ -3,3 +3,4 @@ $conf['edit_content_only'] = 0; $conf['use_dataresolve'] = 1; $conf['rownumbers'] = 0; +$conf['hide_edit_button'] = 0; diff --git a/conf/metadata.php b/conf/metadata.php index 9f3992e..224434f 100644 --- a/conf/metadata.php +++ b/conf/metadata.php @@ -3,3 +3,4 @@ $meta['edit_content_only'] = array('onoff'); $meta['use_dataresolve'] = array('onoff');; $meta['rownumbers'] = array('onoff'); +$meta['hide_edit_button'] = array('onoff'); diff --git a/lang/en/settings.php b/lang/en/settings.php index 427f22a..43fb7c4 100644 --- a/lang/en/settings.php +++ b/lang/en/settings.php @@ -5,3 +5,4 @@ // https://github.com/splitbrain/dokuwiki-plugin-data/commit/8a16166886238906c21c7babc44bccf49c7f50a1 $lang['use_dataresolve'] = 'Use DATARESOLVE calls for LIKE statements'; $lang['rownumbers'] = 'Enable "rownumbers" by default in all tables'; +$lang['hide_edit_button'] = 'Hide the edit button on page'; diff --git a/syntax/cloud.php b/syntax/cloud.php index cf5f04b..8b13789 100644 --- a/syntax/cloud.php +++ b/syntax/cloud.php @@ -1,194 +1 @@ - - */ -// must be run within Dokuwiki -if(!defined('DOKU_INC')) die(); -require_once(dirname(__FILE__).'/table.php'); - -class syntax_plugin_data_cloud extends syntax_plugin_data_table { - - /** - * will hold the data helper plugin - * @var $dthlp helper_plugin_data - */ - var $dthlp = null; - - /** - * Constructor. Load helper plugin - */ - function syntax_plugin_data_cloud(){ - $this->dthlp = plugin_load('helper', 'data'); - if(!$this->dthlp) msg('Loading the data helper failed. Make sure the data plugin is installed.',-1); - } - - /** - * What kind of syntax are we? - */ - function getType(){ - return 'substition'; - } - - /** - * What about paragraphs? - */ - function getPType(){ - return 'block'; - } - - /** - * Where to sort in? - */ - function getSort(){ - return 155; - } - - - /** - * Connect pattern to lexer - */ - function connectTo($mode) { - $this->Lexer->addSpecialPattern('----+ *datacloud(?: [ a-zA-Z0-9_]*)?-+\n.*?\n----+',$mode,'plugin_data_cloud'); - } - - function _buildSQL(&$data){ - $ckey = array_keys($data['cols']); - $ckey = $ckey[0]; - - $from = ' '; - $where = ' '; - $pagesjoin = ''; - $tables = array(); - - $sqlite = $this->dthlp->_getDB(); - if(!$sqlite) return false; - - $fields = array('pageid' => 'page', 'class' => 'class', - 'title' => 'title'); - // prepare filters (no request filters - we set them ourselves) - if(is_array($data['filter']) && count($data['filter'])){ - - foreach($data['filter'] as $filter){ - $col = $filter['key']; - $closecompare = ($filter['compare'] == 'IN(' ? ')' : ''); - - if (preg_match('/^%(\w+)%$/', $col, $m) && isset($fields[$m[1]])) { - $where .= " ".$filter['logic']." pages." . $fields[$m[1]] . - " " . $filter['compare']." '".$filter['value']."'".$closecompare; - $pagesjoin = ' LEFT JOIN pages ON pages.pid = data.pid'; - }else{ - // filter by hidden column? - if(!$tables[$col]){ - $tables[$col] = 'T'.(++$cnt); - $from .= ' LEFT JOIN data AS '.$tables[$col].' ON '.$tables[$col].'.pid = data.pid'; - $from .= ' AND '.$tables[$col].".key = ".$sqlite->quote_string($col); - } - - $where .= ' '.$filter['logic'].' '.$tables[$col].'.value '.$filter['compare']. - " '".$filter['value']."'".$closecompare; //value is already escaped - } - } - } - - // build query - $sql = "SELECT data.value, COUNT(data.pid) as cnt - FROM data $from $pagesjoin - WHERE data.key = ".$sqlite->quote_string($ckey)." - $where - GROUP BY data.value"; - if(isset($data['min'])) $sql .= ' HAVING cnt >= '.$data['min']; - $sql .= ' ORDER BY cnt DESC'; - if($data['limit']) $sql .= ' LIMIT '.$data['limit']; - - return $sql; - } - - protected $before_item = '