diff --git a/.gitignore b/.gitignore index 77e2c9527a..5250131295 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# ignore site directory +/_ + # ignore any files beginning with . \.* diff --git a/manager/actions/mutate_content.dynamic.php b/manager/actions/mutate_content.dynamic.php index 61027e1f3a..5425146f03 100644 --- a/manager/actions/mutate_content.dynamic.php +++ b/manager/actions/mutate_content.dynamic.php @@ -784,11 +784,14 @@ function decode(s) { echo "\t\t",'
',"\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",'',$row['caption'],"\n", "\t\t\t",'
',$row['description'],"\n", "\t\t\t",'',"\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\n"; + /* Changed by ProWebscape for custom tv */ } echo "\t\n"; } else { diff --git a/manager/actions/mutate_tmplvars.dynamic.php b/manager/actions/mutate_tmplvars.dynamic.php index 5186a48051..c6d7035cee 100644 --- a/manager/actions/mutate_tmplvars.dynamic.php +++ b/manager/actions/mutate_tmplvars.dynamic.php @@ -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;'; 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 = {}; @@ -308,6 +311,9 @@ function decode(s){ + + + @@ -331,6 +337,9 @@ function decode(s){ + + + diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index 0e798b709d..dff1454410 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -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 @@ -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"; diff --git a/manager/includes/tmplvars.format.inc.php b/manager/includes/tmplvars.format.inc.php index 74478cc927..a4ad07a619 100755 --- a/manager/includes/tmplvars.format.inc.php +++ b/manager/includes/tmplvars.format.inc.php @@ -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') { diff --git a/manager/includes/tmplvars.inc.php b/manager/includes/tmplvars.inc.php index c608ec8c88..754e71cc3d 100755 --- a/manager/includes/tmplvars.inc.php +++ b/manager/includes/tmplvars.inc.php @@ -1,7 +1,7 @@  '; 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 .= ''; diff --git a/manager/processors/save_content.processor.php b/manager/processors/save_content.processor.php index f4c81e1abc..9cabb8afa7 100755 --- a/manager/processors/save_content.processor.php +++ b/manager/processors/save_content.processor.php @@ -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)) { @@ -488,6 +493,14 @@ echo "An error occured while attempting to save the edited document. The generated SQL is: $sql ."; } + // 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 ();