Update of /cvsroot/phpslash/phpslash-ft/class
In directory usw-pr-cvs1:/tmp/cvs-serv20464/phpslash-ft/class
Modified Files:
Author.class functions.inc
Log Message:
displayOptions
Index: Author.class
===================================================================
RCS file: /cvsroot/phpslash/phpslash-ft/class/Author.class,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** Author.class 31 May 2002 19:29:24 -0000 1.24
--- Author.class 1 Jun 2002 15:05:39 -0000 1.25
***************
*** 437,463 ****
));
! $optioncnt = count($this->psl[default_author_options]);
! $this->author_templ->set_block("newauthor","each_default_option", "doptions");
! for ($i =0; $i < $optioncnt; $i++) {
! $this->author_templ->set_var(array(
! 'DOPTION_NAME' => "optionname[]",
! 'DOPTION_NAME_VAL' => $this->psl['default_author_options'][$i]['name'],
! 'DOPTION_VALUE' => "optionval[]",
! 'DOPTION_VALUE_VAL' => $this->psl['default_author_options'][$i]['value']
! ));
! $this->author_templ->parse("doptions", "each_default_option", true);
! }
!
! $this->author_templ->set_block("newauthor","each_option", "options");
! $optioncnt = $this->psl[author_optioncount];
! for ($i =1; $i <= $optioncnt; $i++) {
! $this->author_templ->set_var(array(
! 'OPTION_NAME' => "optionname[$i]",
! 'OPTION_NAME_VAL' => "",
! 'OPTION_VALUE' => "optionval[$i]",
! 'OPTION_VALUE_VAL' => ""
! ));
! $this->author_templ->parse("options", "each_option", true);
! }
$this->author_templ->parse('OUT',array("newauthor"));
--- 437,441 ----
));
! $this->author_templ = displayoptions('author', $this->author_templ, "newauthor", '');
$this->author_templ->parse('OUT',array("newauthor"));
***************
*** 576,645 ****
}
! $optioncnt = count($this->psl[default_author_options]);
! $this->author_templ->set_block($template,"each_default_option", "doptions");
! for ($i =0; $i < $optioncnt; $i++) {
! if(is_array($temparray)) {
! reset($temparray);
! }
! $dname = $this->psl['default_author_options'][$i]['name'];
! $dvalue = $this->psl['default_author_options'][$i]['value'];
! if(isset($temparray[$dname])) {
! $dvalue = $temparray[$dname];
! $this->author_templ->set_var(array(
! 'DOPTION_NAME' => "optionname[]",
! 'DOPTION_NAME_VAL' => $dname,
! 'DOPTION_VALUE' => "optionval[]",
! 'DOPTION_VALUE_VAL' => $dvalue
! ));
! unset($temparray[$dname]);
! } else {
! $this->author_templ->set_var(array(
! 'DOPTION_NAME' => "optionname[]",
! 'DOPTION_NAME_VAL' => $dname,
! 'DOPTION_VALUE' => "optionval[]",
! 'DOPTION_VALUE_VAL' => $dvalue
! ));
! }
! $this->author_templ->parse("doptions", "each_default_option", true);
! }
!
! $this->author_templ->set_block($template,"each_option", "options");
! if (is_array($temparray)) {
! reset($temparray);
! }
! $optioncnt = $this->psl['author_optioncount'];
! $i = 1;
!
! if (is_array($temparray)) {
! for ($i =1; $i <= count($temparray); $i++) {
! $current=each($temparray);
! debug("current", $current);
!
! if ($current) {
! $this->author_templ->set_var(array(
! 'OPTION_NAME' => "optionname[]",
! 'OPTION_NAME_VAL' => $current[0],
! 'OPTION_VALUE' => "optionval[]",
! 'OPTION_VALUE_VAL' => $current[1]
! ));
! }
! $this->author_templ->parse("options", "each_option", true);
! }
! if( (count($temparray) - $optioncnt) >= 0) {
! $optioncnt = $i; // spit out one more;
! }
! }
- while ($i <= $optioncnt) {
- $this->author_templ->set_var(array(
- 'OPTION_NAME' => "optionname[]",
- 'OPTION_NAME_VAL' => "",
- 'OPTION_VALUE' => "optionval[]",
- 'OPTION_VALUE_VAL' => ""
- ));
- $this->author_templ->parse("options", "each_option", true);
- $i++;
- }
-
$this->author_templ->parse('OUT',$template);
$this->author_templ->p('OUT');
--- 554,559 ----
}
! $this->author_templ = displayoptions('author', $this->author_templ, $template, $temparray);
$this->author_templ->parse('OUT',$template);
$this->author_templ->p('OUT');
Index: functions.inc
===================================================================
RCS file: /cvsroot/phpslash/phpslash-ft/class/functions.inc,v
retrieving revision 1.104
retrieving revision 1.105
diff -C2 -d -r1.104 -r1.105
*** functions.inc 31 May 2002 19:29:24 -0000 1.104
--- functions.inc 1 Jun 2002 15:05:39 -0000 1.105
***************
*** 1212,1214 ****
--- 1212,1302 ----
}
+ /**
+ * displayOptions - display option fields
+ *
+ * @access private
+ * @param string module - author, block, story, etc.
+ * @param object tpl_object - template object
+ * @param string template - template variable used in set_file
+ * @param array options_ary - prviously stored options
+ *
+ * @return tpl_object
+ */
+ function displayOptions($module, $tpl_object, $template, $options_ary) {
+
+ global $_PSL;
+
+ $default_options = "default_".$module."_options";
+ $optioncount = $module."_optioncount";
+
+ $optioncnt = count($_PSL[$default_options]);
+ $tpl_object->set_block($template,"each_default_option", "doptions");
+ for ($i =0; $i < $optioncnt; $i++) {
+ if(is_array($options_ary)) {
+ reset($options_ary);
+ }
+ $dname = $_PSL[$default_options][$i]['name'];
+ $dvalue = $_PSL[$default_options][$i]['value'];
+ if(isset($options_ary[$dname])) {
+ $dvalue = $options_ary[$dname];
+ $tpl_object->set_var(array(
+ 'DOPTION_NAME' => "optionname[]",
+ 'DOPTION_NAME_VAL' => $dname,
+ 'DOPTION_VALUE' => "optionval[]",
+ 'DOPTION_VALUE_VAL' => $dvalue
+ ));
+ unset($options_ary[$dname]);
+ } else {
+ $tpl_object->set_var(array(
+ 'DOPTION_NAME' => "optionname[]",
+ 'DOPTION_NAME_VAL' => $dname,
+ 'DOPTION_VALUE' => "optionval[]",
+ 'DOPTION_VALUE_VAL' => $dvalue
+ ));
+ }
+ $tpl_object->parse("doptions", "each_default_option", true);
+ }
+
+ $tpl_object->set_block($template,"each_option", "options");
+ if (is_array($options_ary)) {
+ reset($options_ary);
+ }
+ $optioncnt = $_PSL[$optioncount];
+ $i = 1;
+
+ if (is_array($options_ary)) {
+ for ($i =1; $i <= count($options_ary); $i++) {
+ $current=each($options_ary);
+ debug("current", $current);
+
+ if ($current) {
+ $tpl_object->set_var(array(
+ 'OPTION_NAME' => "optionname[]",
+ 'OPTION_NAME_VAL' => $current[0],
+ 'OPTION_VALUE' => "optionval[]",
+ 'OPTION_VALUE_VAL' => $current[1]
+ ));
+ }
+ $tpl_object->parse("options", "each_option", true);
+ }
+ if( (count($options_ary) - $optioncnt) >= 0) {
+ $optioncnt = $i; // spit out one more;
+ }
+ }
+
+ while ($i <= $optioncnt) {
+ $tpl_object->set_var(array(
+ 'OPTION_NAME' => "optionname[]",
+ 'OPTION_NAME_VAL' => "",
+ 'OPTION_VALUE' => "optionval[]",
+ 'OPTION_VALUE_VAL' => ""
+ ));
+ $tpl_object->parse("options", "each_option", true);
+ $i++;
+ }
+
+ return $tpl_object;
+
+ } // end of function displayOptions
+
?>
|