Skip to content
This repository was archived by the owner on Mar 8, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# ignore site directory
/_

# ignore any files beginning with .
\.*

Expand Down
5 changes: 4 additions & 1 deletion manager/actions/mutate_content.dynamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -784,11 +784,14 @@ function decode(s) {
echo "\t\t",'<tr><td colspan="2"><div class="split"></div></td></tr>',"\n";

$tvPBV = array_key_exists('tv'.$row['id'], $_POST) ? $_POST['tv'.$row['id']] : $row['value']; // post back value

/* Changed by ProWebscape for custom tv: Added $row to end of function. Give the whole row array to the TV */
echo "\t\t",'<tr style="height: 24px;"><td align="left" valign="top" width="150"><span class="warning">',$row['caption'],"</span>\n",
"\t\t\t",'<br /><span class="comment">',$row['description'],"</span></td>\n",
"\t\t\t",'<td valign="top" style="position:relative;',($row['type'] == 'date' ? 'z-index:500;' : ''),'">',"\n",
"\t\t\t",renderFormElement($row['type'], $row['id'], $row['default_text'], $row['elements'], $tvPBV, ' style="width:300px;"'),"\n",
"\t\t\t",renderFormElement($row['type'], $row['id'], $row['default_text'], $row['elements'], $tvPBV, ' style="width:300px;"', $row),"\n",
"\t\t</td></tr>\n";
/* Changed by ProWebscape for custom tv */
}
echo "\t</table>\n";
} else {
Expand Down
9 changes: 9 additions & 0 deletions manager/actions/mutate_tmplvars.dynamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ function deletedocument() {
widgetParams['datagrid'] = '&cols=Column Names;string &flds=Field Names;string &cwidth=Column Widths;string &calign=Column Alignments;string &ccolor=Column Colors;string &ctype=Column Types;string &cpad=Cell Padding;int;1 &cspace=Cell Spacing;int;1 &rowid=Row ID Field;string &rgf=Row Group Field;string &rgstyle = Row Group Style;string &rgclass = Row Group Class;string &rowsel=Row Select;string &rhigh=Row Hightlight;string; &psize=Page Size;int;100 &ploc=Pager Location;list;top-right,top-left,bottom-left,bottom-right,both-right,both-left; &pclass=Pager Class;string &pstyle=Pager Style;string &head=Header Text;string &foot=Footer Text;string &tblc=Grid Class;string &tbls=Grid Style;string &itmc=Item Class;string &itms=Item Style;string &aitmc=Alt Item Class;string &aitms=Alt Item Style;string &chdrc=Column Header Class;string &chdrs=Column Header Style;string;&egmsg=Empty message;string;No records found;';
widgetParams['richtext'] = '&w=Width;string;100% &h=Height;string;300px &edt=Editor;list;<?php echo $RTEditors; ?>';
widgetParams['image'] = '&alttext=Alternate Text;string &hspace=H Space;int &vspace=V Space;int &borsize=Border Size;int &align=Align;list;none,baseline,top,middle,bottom,texttop,absmiddle,absbottom,left,right &name=Name;string &class=Class;string &id=ID;string &style=Style;string &attrib=Attributes;string';
/* Changed by ProWebscape for custom widget */
widgetParams['custom_widget'] = '&output=Output;string';
/* Changed by ProWebscape for custom widget */

// Current Params
var currentParams = {};
Expand Down Expand Up @@ -308,6 +311,9 @@ function decode(s){
<option value="email" <?php echo ($content['type']=='email')? "selected='selected'":""; ?>>Email</option>
<option value="number" <?php echo ($content['type']=='number')? "selected='selected'":""; ?>>Number</option>
<option value="date" <?php echo ($content['type']=='date')? "selected='selected'":""; ?>>Date</option>
<!-- Changed by ProWebscape for custom tv -->
<option value="custom_tv" <?php echo ($content['type']=='custom_tv')? "selected='selected'":""; ?>>Custom Input</option>
<!-- Changed by ProWebscape for custom tv -->
</select>
</td>
</tr>
Expand All @@ -331,6 +337,9 @@ function decode(s){
<option value="richtext" <?php echo ($content['display']=='richtext')? "selected='selected'":""; ?>>RichText</option>
<option value="ticker" <?php echo ($content['display']=='ticker')? "selected='selected'":""; ?>>Ticker</option>
<option value="viewport" <?php echo ($content['display']=='viewport')? "selected='selected'":""; ?>>View Port</option>
<!-- Changed by ProWebscape for custom widget -->
<option value="custom_widget" <?php echo ($content['display']=='custom_widget')? "selected='selected'":""; ?>>Custom Widget</option>
<!-- Changed by ProWebscape for custom widget -->
</optgroup>
<optgroup label="Formats">
<option value="htmlentities" <?php echo ($content['display']=='htmlentities')? "selected='selected'":""; ?>>HTML Entities</option>
Expand Down
43 changes: 35 additions & 8 deletions manager/includes/document.parser.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,16 +524,42 @@ function checkPublishStatus() {
@include $this->config["base_path"] . "assets/cache/sitePublishing.idx.php";
$timeNow= time() + $this->config['server_offset_time'];
if ($cacheRefreshTime <= $timeNow && $cacheRefreshTime != 0) {
// now, check for documents that need publishing
$sql = "UPDATE ".$this->getFullTableName("site_content")." SET published=1, publishedon=".time()." WHERE ".$this->getFullTableName("site_content").".pub_date <= $timeNow AND ".$this->getFullTableName("site_content").".pub_date!=0 AND published=0";
if (@ !$result= $this->dbQuery($sql)) {
$this->messageQuit("Execution of a query to the database failed", $sql);
// Get documents that need to be published or unpublished
$sql = array();
$sql[] = "SELECT id";
$sql[] = "FROM {$this->getFullTableName('site_content')}";
$sql[] = "WHERE ";
$sql[] = "(pub_date <= {$timeNow} AND pub_date != 0 AND published = 0) "; // $unpublished == "";
$sql[] = " OR ";
$sql[] = " (unpub_date <= $timeNow AND unpub_date != 0 AND published = 1)"; // $published == "";

$sql = implode(' ', $sql);

$results = $this->db->makeArray($this->db->query($sql));
$to_publish = array();
$to_unpublish = array();
foreach($results as $result) {
if($result['published'] != 1) {
$to_publish[] = $result['id'];
} else {
$to_unpublish[] = $result['id'];
}
}

if( is_array($to_publish) and !empty($to_publish)) {
$publish_query = "UPDATE ".$this->getFullTableName("site_content")." SET published=1, publishedon=".time()." WHERE id IN (".implode(',', $to_publish).")";
$this->db->query($publish_query);
foreach($to_publish as $doc) {
$this->invokeEvent("OnDocPublished",array("docid"=>$doc['id']));
}
}

// now, check for documents that need un-publishing
$sql= "UPDATE " . $this->getFullTableName("site_content") . " SET published=0, publishedon=0 WHERE " . $this->getFullTableName("site_content") . ".unpub_date <= $timeNow AND " . $this->getFullTableName("site_content") . ".unpub_date!=0 AND published=1";
if (@ !$result= $this->dbQuery($sql)) {
$this->messageQuit("Execution of a query to the database failed", $sql);
if( is_array($to_unpublish) and !empty($to_unpublish)) {
$unpublish_query = "UPDATE ".$this->getFullTableName("site_content")." SET published=0, publishedon=0 WHERE id IN (".implode(',', $to_unpublish).")";
$this->db->query($unpublish_query);
foreach($to_unpublish as $doc) {
$this->invokeEvent("OnDocUnPublished",array("docid"=>$doc['id']));
}
}

// clear the cache
Expand All @@ -553,6 +579,7 @@ function checkPublishStatus() {
closedir($handle);
}

// (TODO: I think we can merge these 2 queries to offeset the added query above)
// update publish time file
$timesArr= array ();
$sql= "SELECT MIN(pub_date) AS minpub FROM " . $this->getFullTableName("site_content") . " WHERE pub_date>$timeNow";
Expand Down
19 changes: 19 additions & 0 deletions manager/includes/tmplvars.format.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,25 @@ function getTVDisplayFormat($name,$value,$format,$paramstring="",$tvtype="",$doc
$o = htmlentities($value, ENT_NOQUOTES, $modx->config['modx_charset']);
break;

/* Changed by ProWebscape for custom widget */
case 'custom_widget':
$widget_output = '';
/* If we are loading a file */
if(substr($params['output'], 0, 6) == "@FILE:") {
$file_name = MODX_BASE_PATH.trim(substr($params['output'], 6));
if( !file_exists($file_name) ) {
$widget_output = "$file_name does not exist";
} else {
/* The included file needs to set $widget_output. Can be string, array, object */
include $file_name;
}
} else {
$widget_output = str_replace('[+value+]', $value, $params['output']);
}
$o = $widget_output;
break;
/* Changed by ProWebscape for custom widget */

default:
$value = parseInput($value);
if($tvtype=='checkbox'||$tvtype=='listbox-multiple') {
Expand Down
33 changes: 31 additions & 2 deletions manager/includes/tmplvars.inc.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
// DISPLAY FORM ELEMENTS

function renderFormElement($field_type, $field_id, $default_text, $field_elements, $field_value, $field_style='') {
/* Changed by ProWebscape for custom tv: Added $row to end of function. Give the whole row array to the TV */
function renderFormElement($field_type, $field_id, $default_text, $field_elements, $field_value, $field_style='', $row = array()) {
global $modx;
global $base_url;
global $rb_base_url;
Expand Down Expand Up @@ -218,6 +218,35 @@ function SetUrl(url, width, height, alt){
$field_html .='<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$field_value .'" '.$field_style.' onchange="documentDirty=true;" />&nbsp;<input type="button" value="'.$_lang['insert'].'" onclick="BrowseFileServer(\'tv'.$field_id.'\')" />';

break;

/* Changed by ProWebscape for custom tv */
case 'custom_tv':
$custom_output = '';
/* If we are loading a file */
if(substr($field_elements, 0, 6) == "@FILE:") {
$file_name = MODX_BASE_PATH.trim(substr($field_elements, 6));
if( !file_exists($file_name) ) {
$custom_output = "$file_name does not exist";
} else {
ob_start();
include $file_name;
$custom_output = ob_get_contents();
ob_end_clean();
}
} else {
$replacements = array(
'[+field_type+]' => $field_type,
'[+field_id+]' => $field_id,
'[+default_text+]' => $default_text,
'[+field_value+]' => htmlspecialchars($field_value),
'[+field_style+]' => $field_style,
);
$custom_output = str_replace(array_keys($replacements), $replacements, $field_elements);
}
$field_html .= $custom_output;
break;
/* Changed by ProWebscape for custom tv */

default: // the default handler -- for errors, mostly
$field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.htmlspecialchars($field_value).'" '.$field_style.' onchange="documentDirty=true;" />';

Expand Down
13 changes: 13 additions & 0 deletions manager/processors/save_content.processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@
exit;
}

//Invoke onDocPublished (onDocUnPublished could never be called here)
if($published == 1) {
$modx->invokeEvent("OnDocPublished",array("docid"=>$key));
}

$tvChanges = array();
foreach ($tmplvars as $field => $value) {
if (is_array($value)) {
Expand Down Expand Up @@ -488,6 +493,14 @@
echo "An error occured while attempting to save the edited document. The generated SQL is: <i> $sql </i>.";
}

// Invoke onDocPublished/onDocUnPublished
if($was_published == 1 AND $published == 0) {
$modx->invokeEvent("OnDocUnPublished",array("docid"=>$id));
} elseif ($was_published == 0 AND $published == 1) {
$modx->invokeEvent("OnDocPublished",array("docid"=>$id));
}


// update template variables
$rs = $modx->db->select('id, tmplvarid', $tbl_site_tmplvar_contentvalues, 'contentid='. $id);
$tvIds = array ();
Expand Down