From 743eb14baa25635e50484479e1f41a239846d78b Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Tue, 29 Sep 2009 00:03:01 +0000 Subject: [PATCH] Release plugin - work in progress --- e107_plugins/release/admin_config.php | 455 +++++++++++++++++++ e107_plugins/release/images/e107_icon_16.png | Bin 0 -> 848 bytes e107_plugins/release/images/e107_icon_32.png | Bin 0 -> 1646 bytes e107_plugins/release/plugin.xml | 13 + e107_plugins/release/release.php | 37 ++ e107_plugins/release/release_sql.php | 13 + 6 files changed, 518 insertions(+) create mode 100644 e107_plugins/release/admin_config.php create mode 100644 e107_plugins/release/images/e107_icon_16.png create mode 100644 e107_plugins/release/images/e107_icon_32.png create mode 100644 e107_plugins/release/plugin.xml create mode 100644 e107_plugins/release/release.php create mode 100644 e107_plugins/release/release_sql.php diff --git a/e107_plugins/release/admin_config.php b/e107_plugins/release/admin_config.php new file mode 100644 index 000000000..cf443b5ad --- /dev/null +++ b/e107_plugins/release/admin_config.php @@ -0,0 +1,455 @@ +submitPage($id); +} + +if(varset($_POST['delete'])) +{ + $id = key($_POST['delete']); + $ef->deleteRecord($id); + $_GET['mode'] = "list"; +} + +if(varset($_GET['mode'])=='create') +{ + $id = varset($_POST['edit']) ? key($_POST['edit']) : ""; + $ef->createRecord($id); +} +else +{ + $ef->listRecords(); +} + +if(isset($_POST['submit-e-columns'])) +{ + $user_pref['admin_release_columns'] = $_POST['e-columns']; + save_prefs('user'); +} + + +require_once(e_ADMIN."footer.php"); + + + +class efeed +{ + var $fields; + var $fieldpref; + var $listQry; + var $table; + var $primary; + + + function __construct() + { + + $this->fields = array( + 'release_id' => array('title'=> ID, 'width'=>'5%', 'forced'=> TRUE, 'primary'=>TRUE), + 'release_type' => array('title'=> 'type', 'width'=>'auto','method'=>'feed_type'), + 'release_folder' => array('title'=> 'folder', 'type' => 'text', 'width' => 'auto'), // User name + 'release_name' => array('title'=> 'name', 'type' => 'text', 'width' => 'auto'), + 'release_version' => array('title'=> 'version', 'type' => 'text', 'width' => 'auto'), + 'release_author' => array('title'=> LAN_AUTHOR, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left first'), // Display name + 'release_authorURL' => array('title'=> LAN_AUTHOR.'URL', 'type' => 'url', 'width' => 'auto', 'thclass' => 'left first'), // Display name + + 'release_date' => array('title'=> LAN_DATE, 'type' => 'text', 'width' => 'auto'), // Photo + 'release_compatibility' => array('title'=> 'compatib', 'type' => 'text', 'width' => '10%', 'thclass' => 'center' ), // Real name (no real vetting) + 'release_url' => array('title'=> 'URL', 'type' => 'url', 'width' => '10%', 'thclass' => 'center' ), // No real vetting + 'options' => array('title'=> LAN_OPTIONS, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last') + ); + + $this->fieldpref = (varset($user_pref['admin_release_columns'])) ? $user_pref['admin_release_columns'] : array_keys($this->fields); + $this->table = "release"; + $this->listQry = "SELECT * FROM #release ORDER BY release_id DESC"; + $this->editQry = "SELECT * FROM #release WHERE release_id = {ID}"; + $this->primary = "release_id"; + $this->pluginTitle = "e107 Release"; + + $this->listCaption = "Release List"; + $this->createCaption = LAN_CREATE."/".LAN_EDIT; + + } + + +// -------------------------------------------------------------------------- + /** + * Generic DB Record Listing Function. + * @param object $mode [optional] + * @return + */ + function listRecords($mode=FALSE) + { + $ns = e107::getRender(); + $sql = e107::getDb(); + + global $frm, $pref; + + $emessage = eMessage::getInstance(); + + $text = "
+
+ ".$this->pluginTitle." + ". + $frm->colGroup($this->fields,$this->fieldpref). + $frm->thead($this->fields,$this->fieldpref). + + ""; + + + if(!$sql->db_Select_gen($this->listQry)) + { + $text .= "\n\n"; + } + else + { + $row = $sql->db_getList('ALL', FALSE, FALSE); + + foreach($row as $field) + { + $text .= "\n"; + foreach($this->fields as $key=>$att) + { + $class = vartrue($this->fields[$key]['thclass']) ? "class='".$this->fields[$key]['thclass']."'" : ""; + $text .= (in_array($key,$this->fieldpref) || $att['forced']==TRUE) ? "\t\n" : ""; + } + $text .= "\n"; + } + } + + $text .= " + +
".CUSLAN_42."
".$this->renderValue($key,$field)."
+
+
+ "; + + $ns->tablerender($this->pluginTitle." :: ".$this->listCaption, $emessage->render().$text); + } + + /** + * Render Field value (listing page) + * @param object $key + * @param object $row + * @return + */ + function renderValue($key,$row) + { + $att = $this->fields[$key]; + + if($key == "options") + { + $id = $this->primary; + $text = ""; + $text .= ""; + return $text; + } + + switch($att['type']) + { + case 'url': + return "".$row[$key].""; + break; + + default: + return $row[$key]; + break; + } + return $row[$key] .$att['type']; + } + + /** + * Render Form Element (edit page) + * @param object $key + * @param object $row + * @return + */ + function renderElement($key,$row) + { + global $frm; + $att = $this->fields[$key]; + $value = $row[$key]; + + if($att['method']) + { + $meth = $att['method']; + return $this->$meth($value); + } + + return $frm->text($key, $row[$key], 50); + + } + + function feed_type($curVal) + { + $types = array("theme","plugin"); + $text = ""; + return $text; + } + + + function createRecord($id=FALSE) + { + global $frm, $e_userclass, $e_event; + + $tp = e107::getParser(); + $ns = e107::getRender(); + $sql = e107::getDb(); + + if($id) + { + $query = str_replace("{ID}",$id,$this->editQry); + $sql->db_Select_gen($query); + $row = $sql->db_Fetch(MYSQL_ASSOC); + } + else + { + $row = array(); + } + + $text = " +
+
+ ".$this->pluginTitle." + + + + + + "; + + foreach($this->fields as $key=>$att) + { + if($att['forced']!==TRUE) + { + $text .= " + + + + "; + } + + } + + $text .= " + +
".$att['title']."".$this->renderElement($key,$row)."
+
"; + + if($id) + { + $text .= $frm->admin_button('update', LAN_UPDATE, 'update'); + $text .= ""; + } + else + { + $text .= $frm->admin_button('create', LAN_CREATE, 'create'); + } + + $text .= " +
+
+
"; + + $ns->tablerender($this->pluginTitle." :: ".$this->createCaption, $text); + } + + /** + * Generic Save DB Record Function. + * @param object $id [optional] + * @return + */ + function submitPage($id=FALSE) + { + global $sql, $tp, $e107cache, $admin_log, $e_event; + $emessage = eMessage::getInstance(); + + $insert_array = array(); + + foreach($this->fields as $key=>$att) + { + if($att['forced']!=TRUE) + { + $insert_array[$key] = $_POST[$key]; + } + } + + if($id) + { + $insert_array['WHERE'] = $this->primary." = ".$id; + $status = $sql->db_Update($this->table,$insert_array) ? E_MESSAGE_SUCCESS : E_MESSAGE_FAILED; + $message = LAN_UPDATED; + + } + else + { + $status = $sql->db_Insert($this->table,$insert_array) ? E_MESSAGE_SUCCESS : E_MESSAGE_FAILED; + $message = LAN_CREATED; + } + + + $emessage->add($message, $status); + } + + function deleteRecord($id) + { + if(!$id || !$this->primary || !$this->table) + { + return; + } + + $emessage = eMessage::getInstance(); + $sql = e107::getDb(); + + $query = $this->primary." = ".$id; + $status = $sql->db_Delete($this->table,$query) ? E_MESSAGE_SUCCESS : E_MESSAGE_FAILED; + $message = LAN_DELETED; + $emessage->add($message, $status); + } + + function optionsPage() + { + global $e107, $pref, $frm, $emessage; + + if(!isset($pref['pageCookieExpire'])) $pref['pageCookieExpire'] = 84600; + + //XXX Lan - Options + $text = " +
+
+ ".LAN_OPTIONS." + + + + + + + + + + + + + + + + +
".CUSLAN_29." + ".$frm->radio_switch('listPages', $pref['listPages'])." +
".CUSLAN_30." + ".$frm->text('pageCookieExpire', $pref['pageCookieExpire'], 10)." +
+
+ ".$frm->admin_button('saveOptions', CUSLAN_40, 'submit')." +
+
+
+ "; + + $e107->ns->tablerender(LAN_OPTIONS, $emessage->render().$text); + } + + + function saveSettings() + { + global $pref, $admin_log, $emessage; + $temp['listPages'] = $_POST['listPages']; + $temp['pageCookieExpire'] = $_POST['pageCookieExpire']; + if ($admin_log->logArrayDiffs($temp, $pref, 'CPAGE_04')) + { + save_prefs(); // Only save if changes + $emessage->add(CUSLAN_45, E_MESSAGE_SUCCESS); + } + else + { + $emessage->add(CUSLAN_46); + } + } + + + function show_options($action) + { + $action = varset($_GET['mode'],'list'); + + $var['list']['text'] = $this->listCaption; + $var['list']['link'] = e_SELF."?mode=list"; + $var['list']['perm'] = "0"; + + $var['create']['text'] = $this->createCaption; + $var['create']['link'] = e_SELF."?mode=create"; + $var['create']['perm'] = 0; + +/* + $var['options']['text'] = LAN_OPTIONS; + $var['options']['link'] = e_SELF."?options"; + $var['options']['perm'] = "0";*/ + + e_admin_menu($this->pluginTitle, $action, $var); + } +} + +function admin_config_adminmenu() +{ + global $ef; + global $action; + $ef->show_options($action); +} + +/** + * Handle page DOM within the page header + * + * @return string JS source + */ +function headerjs() +{ + require_once(e_HANDLER.'js_helper.php'); + $ret = " + + + "; + + return $ret; +} +?> \ No newline at end of file diff --git a/e107_plugins/release/images/e107_icon_16.png b/e107_plugins/release/images/e107_icon_16.png new file mode 100644 index 0000000000000000000000000000000000000000..257b205f5fddc74911aadf5811b368965961072d GIT binary patch literal 848 zcmV-W1F!svP)k7RCwBA z`2YVu13F+~VF6M8Dk>@uEiEm-GBGhtVrFLM5)cqzke8Qdkdl&O5EmC`0E#gH1P}uj z1B8GY7CSjP{W);p!2f&q?)@(;Ec_4Dbc>6N%S%Q^2E_n?075q)5-9P!yuAGXl`B{N zKY#xG|C1+A{y%*9@c*)9%l`ZO`~L#EV7V9&h=_=Q4FCurMvwuFjEs^%JRRs<-^9d3 zCKD4AhQELRGJOC39ZUn|z=~hIc)@Vu#0iG8XV1R4bLURkvuDp10|XG*v#hMFhl7HG zl*7Wp82I@37#=)$0M-n{KY#vY`1kK00~;F~gSxspgRro$1Scow{CDr(@c{%7*Z@I6 zK}8M@4hEpJ89)K`_3KwK{`Kn@O27gwVgTCAaP{g{hChG)FmrQrdjkXz*Z`pBf3IG> zVtV}eG1vt>JUpf2GRHL z-v_fnX+T<9ngJA*FjoNt5ZC~qW=4?TL5e_vAOH&WFJHcZoeg3uC@8?=UrtUA9I!z3 zOaK7{HUJnPzkwQ=LC%7u3ve6*4FrZbIAB3GOG-+DHG^o7mwD zo0*xhgA{`_15+c|H6X>H@Buj+C+aV#`&=H0T4iN13*y*iY|~BzJ2?q0km-@&^0#v{QOMk z&!7K(>C&YYKvz`*^*l$;JOBX%4m41l^YZe7T_Gwe3ic;3l`#S1ya4E;9YA$a3^)Kl afB^tZmo65pbgiZU0000TM}0EWuX_wV0N1v;|h+qZA8aisx(0K)44pqw=j zcPc3(`)=U;w6-Z@_4p3Z%PX zp#d`kAb_wrKodw!5EBz~3kwTlu(!8o0H$yZUxO?L@qvku0ca@0j~_q4Y>+xw)&->> zkUC&`VYq$!Hp9Dj@6Mh(cP{Vk+qcJHW&s2cHU}I~Q&Y2#j*ezfRaFHiM408UsQLT% zFT?2ZxRKKgHUJU_>AimaIyg;$%mwmgfKu{640ZrO0AV-)nB{(h ze02Z*eTIh*A2P_x%QFD871+YhpFe|r3o8|I)gvG|P{@JgPngki{V1!+Z_1oS&Z`s{;T62*Ux$#V;sN zBl{MV2tf%Dgh37gsfCr8j~_n?w|h>z@Rn9pG}wh|N|fN-V(SO_3zGi29;d<~L+@ZbT%t5>hU zdO*I0S%}R6pmGB}1ONgEs{_zO0J-=@_5mykKs3m5WQ&n8EDDe-FBkv_APffpeZmZ~ z9F)*N4nQwxkV69$0-&sg?o(`z07VTbAv2-{0YCs@O9OX-aVif=NFa@%U_(yr$PNHu zPdmG1@OyU4!A<^X^IBFO=;&;VNQtEZ<|25c)BfqV|Cwy$2jdI#9>*bWR8 zkgrbz@dsjhMgRdsjssvNCa~qEmJbYmTVP6m0?fXkRxb$O0pdTzcFh0+h-?Qy0XGmU s12L$ceE`HH_YDC8h;g91=Kui)0Ku0)z;?REIsgCw07*qoM6N<$f*D|-ZU6uP literal 0 HcmV?d00001 diff --git a/e107_plugins/release/plugin.xml b/e107_plugins/release/plugin.xml new file mode 100644 index 000000000..2359d1cc5 --- /dev/null +++ b/e107_plugins/release/plugin.xml @@ -0,0 +1,13 @@ + + + + + Manage Release Feeds for e107 Plugins and Themes + tools + + + Configure + + + + \ No newline at end of file diff --git a/e107_plugins/release/release.php b/e107_plugins/release/release.php new file mode 100644 index 000000000..9e7dfc495 --- /dev/null +++ b/e107_plugins/release/release.php @@ -0,0 +1,37 @@ + +\n"; +$tp = e107::getParser(); + +e107::getDb()->db_Select_gen("SELECT * FROM #release ORDER BY release_type,release_date DESC"); +while ($row = e107::getDb()->db_Fetch(MYSQL_ASSOC)) +{ + echo "\t<".$row['release_type']." name='".$tp->toRss($row['release_name'])."' folder='".$tp->toRss($row['release_folder'])."' author='".$tp->toRss($row['release_author'])."' authorURL='".$row['release_authorURL']."' version='".$row['release_version']."' date='".$row['release_date']."' compatibility='".$row['release_compatibility']."' url='".$row['release_url']."' />\n"; +} + +echo ""; +/* + + + + + +*/ +?> diff --git a/e107_plugins/release/release_sql.php b/e107_plugins/release/release_sql.php new file mode 100644 index 000000000..80f06f5c2 --- /dev/null +++ b/e107_plugins/release/release_sql.php @@ -0,0 +1,13 @@ +CREATE TABLE release ( + `release_id` int(10) NOT NULL AUTO_INCREMENT, + `release_type` varchar(10) NOT NULL, + `release_name` varchar(50) NOT NULL, + `release_folder` varchar(50) NOT NULL, + `release_version` varchar(5) NOT NULL, + `release_author` varchar(50) NOT NULL, + `release_authorURL` varchar(255) NOT NULL, + `release_date` date NOT NULL, + `release_compatibility` varchar(5) NOT NULL, + `release_url` varchar(255) NOT NULL, + PRIMARY KEY (`release_id`) +) TYPE=MyISAM;