Skip to content

Commit

Permalink
Adds Help Doc section selection (for moving to new section) and Help …
Browse files Browse the repository at this point in the history
…Doc view by rank or by title.

[#165 state:resolved][#166 state:resolved]
  • Loading branch information
dleffler committed Jun 18, 2011
1 parent 2d6ea6b commit 4e4da73
Show file tree
Hide file tree
Showing 8 changed files with 260 additions and 148 deletions.
85 changes: 67 additions & 18 deletions framework/modules/help/controllers/helpController.php
Expand Up @@ -22,24 +22,40 @@ class helpController extends expController {
public $codequality = 'beta';

function name() { return $this->displayname(); } //for backwards compat with old modules
function displayname() { return "HELP!"; }
function displayname() { return "Help"; }
function description() { return "Module for managing Exponent CMS help files."; }
function author() { return "Adam Kessler - OIC Group, Inc"; }
function hasSources() { return false; }
function hasSources() { return true; }
function hasViews() { return true; }
function hasContent() { return true; }
function supportsWorkflow() { return false; }
function isSearchable() { return true; }

function __construct($src=null, $params=array()) {
global $db;
parent::__construct($src,$params);
if(!empty($params['version']) && !expSession::get('help-version')) {
expSession::set('help-version',isset($params['version']));
} elseif (empty($params['version']) && !expSession::get('help-version')) {
$version = $db->selectValue('help_version', 'version','is_current=1');
expSession::set('help-version',$version);
}

$this->help_version = expSession::get('help-version');
}

public function showall() {
expHistory::set('viewable', $this->params);
$hv = new help_version();
$current_version = $hv->find('first', 'is_current=1');
//$current_version = $hv->find('first', 'is_current=1');
$ref_version = $hv->find('first', 'version=\''.$this->help_version.'\'');

// pagination parameter..hard coded for now.
$where = 'help_version_id='.$current_version->id;
$where = $this->aggregateWhereClause();
$where .= 'AND help_version_id='.$ref_version->id;
$limit = 500;
$order = 'title';
// $order = 'rank';
$order = isset($this->config['order']) ? $this->config['order'] : 'rank';
$dir = 'ASC';

// grab the pagination object
Expand All @@ -54,37 +70,52 @@ public function showall() {
'columns'=>array('Title'=>'title', 'Body'=>'body', 'Version'=>'help_version_id'),
));

assign_to_template(array('current_version'=>$current_version, 'page'=>$page));
assign_to_template(array('current_version'=>$ref_version, 'page'=>$page, 'rank'=>($order==='rank')?1:0));
}

public function edit() {
global $db;
global $db, $sectionObj;
expHistory::set('editable', $this->params);
$id = empty($this->params['id']) ? null : $this->params['id'];
$help = new help($id);

// get the id of the current version and use it if we need to.
$version = $db->selectValue('help_version', 'id', 'is_current=1');
if (empty($help->help_version_id)) $help->help_version_id = $version;
assign_to_template(array('record'=>$help));

$sectionlist = array();
$sections = $db->selectObjectsIndexedArray('section',1);
$helpsections = $db->selectObjects('help',1);
foreach ($helpsections as $helpsection) {
if (!array_key_exists($helpsection->section, $sectionlist)) {
if (array_key_exists($helpsection->section, $sections)) {
$sectionlist[$helpsection->section] = $sections[$helpsection->section]->name;
}
}
}
$sectionlist[$sectionObj->id] = $sections[$sectionObj->id]->name." (current page)";

assign_to_template(array('record'=>$help,"cursec"=>$sectionObj->id,"sections"=>$sectionlist));
}

public function show() {
global $db;

expHistory::set('viewable', $this->params);

$help = new help();
if (empty($this->params['version'])) {
$version_id = $db->selectValue('help_version', 'id', 'is_current=1');
} else {
$version_id = $db->selectValue('help_version', 'id', 'version=\''.$this->params['version'].'\'');
}

$doc = $help->find('first', 'help_version_id='.$version_id.' AND title="'.$this->params['title'].'"');
assign_to_template(array('doc'=>$doc));
$doc = $help->find('first', 'help_version_id='.$version_id.' AND sef_url="'.$this->params['title'].'"');
assign_to_template(array('doc'=>$doc,"hv"=>$this->help_version));
}

public function manage() {
expHistory::set('managable', $this->params);
expHistory::set('manageable', $this->params);
global $db;

$hv = new help_version();
Expand All @@ -94,7 +125,9 @@ public function manage() {
flash('error', "You don't have any software versions created yet. Please do so now.");
redirect_to(array('controller'=>'help', 'action'=>'edit_version'));
}


$sections = $db->selectObjectsIndexedArray('section',1);

$where = empty($this->params['version']) ? 1 : 'help_version_id='.$this->params['version'];
$page = new expPaginator(array(
'model'=>'help',
Expand All @@ -104,31 +137,32 @@ public function manage() {
'dir'=>'DESC',
'controller'=>$this->baseclassname,
'action'=>$this->params['action'],
'columns'=>array('Title'=>'title', 'Body'=>'body', 'Version'=>'help_version_id'),
'columns'=>array('Title'=>'title', 'Version'=>'help_version_id', 'Section'=>'section'),
));

assign_to_template(array('current_version'=>$current_version, 'page'=>$page));
assign_to_template(array('current_version'=>$current_version, 'page'=>$page, 'sections'=>$sections));
}

private static function copydocs($from, $to) {
global $db;

$help = new help();
$current_docs = $help->find('all', 'help_version_id='.$from);
foreach ($current_docs as $doc) {
foreach ($current_docs as $key=>$doc) {
unset($doc->id);
unset($doc->id);
$doc->help_version_id = $to;
$doc->sef_url = $doc->makeSefUrl();
$doc->save();

foreach($doc->expFile as $subtype=>$files) {
foreach($files as $file) {
$doc->attachItem($file, $subtype);
}

}
}

// get version #'s for the two versions
$oldvers = $db->selectValue('help_version', 'version', 'id='.$from);
$newvers = $db->selectValue('help_version', 'version', 'id='.$to);
Expand All @@ -139,7 +173,7 @@ private static function copydocs($from, $to) {
}

public function manage_versions() {
expHistory::set('managable', $this->params);
expHistory::set('manageable', $this->params);

$hv = new help_version();
$current_version = $hv->find('first', 'is_current=1');
Expand Down Expand Up @@ -223,6 +257,21 @@ public function update_version() {
flash('message', 'Saved version '.$version->version);
expHistory::back();
}

public static function getSection($params) {
global $db;
$h = new help();
$hv = $db->selectValue('help_version', 'id', 'version='.$params['version']);
$help = $h->find('first','help_version_id='.$hv.' and sef_url=\''.$params['title'].'\'');
$sessec = expSession::get('last_section') ? expSession::get('last_section') : 1 ;
$sid = ($help->section!=0)?$help->section:$sessec;
if (!expSession::get('last_section')) {
expSession::set('last_section',$sid);
}
$section = $db->selectObject('section','id='. intval($sid));
return $section;
}

}

?>
20 changes: 20 additions & 0 deletions framework/modules/help/views/help/configure/help.tpl
@@ -0,0 +1,20 @@
{*
* Copyright (c) 2004-2011 OIC Group, Inc.
* Written and Designed by Adam Kessler
*
* This file is part of Exponent
*
* Exponent is free software; you can redistribute
* it and/or modify it under the terms of the GNU
* General Public License as published by the Free
* Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* GPL: http://www.gnu.org/licenses/gpl.txt
*
*}

<h2>Configure this Help Module</h2>
{control type=dropdown name=order label="Sort By" items="Title, Order Manually" values="title,rank" value=$config.order|default:rank}
{*control type="radiogroup" name="usebody" label="Body Text"|gettext value=$config.usebody|default:0 items="Full,Summary,None" values="0,1,2"*}

64 changes: 45 additions & 19 deletions framework/modules/help/views/help/edit.tpl
Expand Up @@ -17,44 +17,70 @@

{if $record->id != ""}<h1>Editing {$record->title}</h1>{else}<h1>New Help Document</h1>{/if}

{script unique="blogtabs" yuimodules="tabview, element"}
{literal}
var tabView = new YAHOO.widget.TabView('demo');
YAHOO.util.Dom.removeClass("edithelp", 'hide');
var loading = YAHOO.util.Dom.getElementsByClassName('loadingdiv', 'div');
YAHOO.util.Dom.setStyle(loading, 'display', 'none');

{/literal}
{/script}

{form action=update}
{form action=update record=$record}
{control type=hidden name=id value=$record->id}
<div id="demo" class="yui-navset">
<div id="helpedit" class="yui-navset">
<ul class="yui-nav">
<li class="selected"><a href="#tab1"><em>General</em></a></li>
<li><a href="#tab2"><em>Files</em></a></li>
<li><a href="#tab3"><em>SEO</em></a></li>
<li><a href="#tab2"><em>Actions and Views</em></a></li>
<li><a href="#tab3"><em>Configuration</em></a></li>
<li><a href="#tab5"><em>Videos</em></a></li>
<li><a href="#tab6"><em>Additional Info</em></a></li>
<li><a href="#tab7"><em>SEO</em></a></li>
</ul>
<div class="yui-content">
<div id="tab1">
<h2>General Information</h2>
{control type=text name=title label="Title" value=$record->title}
{control type=html name=body label="Body Content" value=$record->body}
{control type="dropdown" name="help_version_id" label="Version" frommodel="help_version" key=id display=version order=version dir=DESC value=$record->help_version_id}
{control type=textarea name=summary label="Summary" value=$record->summary}
{control type=html name=body label="General Information" value=$record->body}
{if $record->id != ""}
{*control type=text name="section" label="Help Section" value=$record->section*}
{control type="dropdown" name="section" label="Help Section" items=$sections value=$record->section}
{else}
{*control type=text name="section" label="Help Section" value=$cursec*}
{control type="dropdown" name="section" label="Help Section" items=$sections value=$cursec}
{/if}
</div>
<div id="tab2">
{control type="files" name="screenshots" label="Screenshots" subtype="screenshots" value=$record->expFile}
{control type="files" name="videos" label="Videos" subtype="videos" value=$record->expFile}
<h2>Actions and Views</h2>
{control type=html name=actions_views label="Actions and Views" value=$record->actions_views}
</div>
<div id="tab3">
<div id="tab2">
<h2>Configuration</h2>
{control type=html name=configuration label="Configurations" value=$record->configuration}
</div>
<div id="tab2">
<h2>YouTube Video Code</h2>
{control type=textarea cols=80 rows=30 name=youtube_vid_code label="YouTube Video Code" value=$record->youtube_vid_code}
</div>
<div id="tab2">
<h2>Additional Information</h2>
{control type=html name=additional label="Additional Info (displays in side column)" value=$record->additional}
</div>
<div id="tab2">
<h2>SEO Settings</h2>
{control type="text" name="sef_url" label="SEF URL" value=$record->sef_url}
{control type="text" name="meta_title" label="Meta Title" value=$record->meta_title}
{control type="textarea" name="meta_description" label="Meta Description" rows=5 cols=35 value=$record->meta_description}
{control type="textarea" name="meta_keywords" label="Meta Keywords" rows=5 cols=35 value=$record->meta_keywords}
{control type="textarea" name="meta_keywords" label="Meta Description" rows=5 cols=35 value=$record->meta_description}
{control type="textarea" name="meta_description" label="Meta Keywords" rows=5 cols=35 value=$record->meta_keywords}
</div>
</div>
</div>
{control type=buttongroup submit="Save Help Doc" cancel="Cancel"}
{/form}
</div>
<div class="loadingdiv">Loading</div>

{script unique="help-edit" yui2mods="tabview,element" yui3mods="node"}
{literal}
YUI(EXPONENT.YUI3_CONFIG).use('*', function(Y) {
var tabView = new YAHOO.widget.TabView('helpedit');
Y.one('#edithelp').removeClass('hide');
Y.one('.loadingdiv').remove();
});
{/literal}
{/script}

2 changes: 1 addition & 1 deletion framework/modules/help/views/help/edit_version.tpl
Expand Up @@ -21,7 +21,7 @@
<h1>New Help Version</h1>
<p>
Creating a new version will copy all the docs from the current version over to the
new version and make them available for viewing and editting
new version and make them available for viewing and editing
</p>
{/if}

Expand Down
42 changes: 18 additions & 24 deletions framework/modules/help/views/help/manage.tpl
@@ -1,5 +1,5 @@
{*
* Copyright (c) 2004-2011 OIC Group, Inc.
* Copyright (c) 2004-2008 OIC Group, Inc.
* Written and Designed by Adam Kessler
*
* This file is part of Exponent
Expand All @@ -14,24 +14,18 @@
*
*}

{css unique="managehelp" corecss="tables"}

{/css}

<div class="module help manage">
<h1>Manage Help Documents</h1>
<p>
This page allows you to manage help documents for Exponent CMS.
{br}
<em>The current version is {$current_version->version}</em>
</p>

<div class="module-actions">
{icon class=add action=edit_version title="Add new help version" text="Add a New Help Version"}{br}
{icon class=add action=edit title="Add a New Help Document" text="Add a New Help Document to version `$current_version->version`"}{br}
{icon class=manage action=manage_versions title="Manage Versions" text="Manage Versions"}{br}
</div>
{pagelinks paginate=$page top=1}

{icon class=add action=edit_version title="Add new help version" text="Add a New Help Version"}{br}
{icon class=add action=edit title="Add a New Help Document" text="Add a New Help Document to version `$current_version->version`"}{br}
{icon class=add action=manage_versions title="Manage Versions" text="Manage Versions"}{br}
{$page->links}
<table class="exp-skin-table">
<thead>
<tr>
Expand All @@ -41,20 +35,19 @@
</thead>
<tbody>
{foreach from=$page->records item=doc}
{assign var=sec value=$doc->section}
<tr class="{cycle values="odd,even"}">
<td><a href={link action=show version=$doc->help_version->version title=$doc->title}>{$doc->title}</a></td>
<td>{$doc->body|truncate:55}</td>
<td><a href="{link action=manage version=$doc->help_version->id}">{$doc->help_version->version|number_format:1}</a></td>
<td><a href="{link action=manage version=$doc->help_version->id}">{$doc->help_version->version}</a></td>
<td>{$sections[$sec]->name}</td>
<td>
{permissions}
<div class="item-actions">
{if $permissions.edit == 1}
{icon action=edit record=$doc title="Edit Help Doc"}
{/if}
{if $permissions.delete == 1}
{icon action=delete record=$doc title="Delete this help doc" onclick="return confirm('Are you sure you want to delete this help document?');"}
{/if}
</div>
{permissions level=$smarty.const.UILEVEL_NORMAL}
{if $permissions.edit == 1}
{icon img=edit.png action=edit record=$doc title="Edit Help Doc"}
{/if}
{if $permissions.delete == 1}
{icon action=delete img=delete.png record=$doc title="Delete this help doc" onclick="return confirm('Are you sure you want to delete this help document?');"}
{/if}
{/permissions}
</td>
</tr>
Expand All @@ -63,5 +56,6 @@
{/foreach}
</tbody>
</table>
{pagelinks paginate=$page bottom=1}
{$page->links}

</div>

0 comments on commit 4e4da73

Please sign in to comment.