admin.comprofiler.html.php
上传用户:stephen_wu
上传日期:2008-07-05
资源大小:1757k
文件大小:144k
源码类别:
网络
开发平台:
Unix_Linux
- <?php
- /**
- * Joomla/Mambo Community Builder
- * @version $Id: admin.comprofiler.html.php 610 2006-12-13 17:33:44Z beat $
- * @package Community Builder
- * @subpackage admin.comprofiler.html.php
- * @author JoomlaJoe and Beat
- * @copyright (C) JoomlaJoe and Beat, www.joomlapolis.com
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU/GPL version 2
- */
- // ensure this file is being included by a parent file
- if ( ! ( defined( '_VALID_CB' ) || defined( '_JEXEC' ) || defined( '_VALID_MOS' ) ) ) { die( 'Direct Access to this location is not allowed.' ); }
- class HTML_comprofiler {
- function secureAboveForm( $functionName ) {
- // return cbJumpOutOfIframe();
- ?>
- <script type="text/javascript"><!--//--><![CDATA[//><!--
- if(self!=top) {
- parent.document.body.innerHTML='<div>Iframes not allowed, could be hack attempt..., sorry!</div>';
- self.top.location=self.location;
- }
- //--><!]]></script>
- <?php
- }
- function installPluginForm() {
- }
- function showLists( &$rows, $pageNav, $search, $option ) {
- global $_CB_framework;
- HTML_comprofiler::secureAboveForm('showLists');
- outputCbTemplate( 2 );
- outputCbJs( 2 );
- global $_CB_Backend_Title;
- $_CB_Backend_Title = array( 0 => array( 'cbicon-48-lists', "CB List Manager" ) );
- ?>
- <script type="text/javascript"><!--//--><![CDATA[//><!--
- function cbsaveorder( n ) {
- cbcheckAll_button( n );
- submitform('savelistorder');
- }
- //needed by cbsaveorder function
- function cbcheckAll_button( n ) {
- for ( var j = 0; j <= n; j++ ) {
- box = eval( "document.adminForm.cb" + j );
- if ( box.checked == false ) {
- box.checked = true;
- }
- }
- }
- //--><!]]></script>
- <form action="index2.php" method="post" name="adminForm">
- <table cellpadding="4" cellspacing="0" border="0" width="100%">
- <tr>
- <td>Search: <input type="text" name="search" value="<?php echo $search;?>" class="inputbox" onChange="document.adminForm.submit();" />
- </td>
- </tr>
- </table>
- <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
- <thead>
- <tr>
- <th width="2%" class="title">#</th>
- <th width="3%" class="title"> <input type="checkbox" name="toggle" value="" onClick="checkAll(<?php echo count($rows); ?>);" />
- </th>
- <th width="25%" class="title">Title</th>
- <th width="25%" class="title">Description</th>
- <th width="5%" class="title">Published?</th>
- <th width="5%" class="title">Default?</th>
- <th width="15%" class="title">Access</th>
- <th width="5%" class="title" colspan="2">Re-Order</th>
- <th width="1%"><a href="javascript: cbsaveorder( <?php echo count( $rows )-1; ?> )"><img src="images/filesave.png" border="0" width="16" height="16" alt="Save Order" /></a></th>
- <th width="2%" class="title">listid</th>
- </tr>
- </thead>
- <tbody>
- <?php
- $k = 0;
- $imgpath='../components/com_comprofiler/images/';
- for ($i=0, $n=count( $rows ); $i < $n; $i++) {
- $row =& $rows[$i];
- $img3 = $row->published ? 'tick.png' : 'publish_x.png';
- $task3 = $row->published ? 'listPublishedNo' : 'listPublishedYes';
- $img4 = $row->default ? 'tick.png' : 'publish_x.png';
- $task4 = $row->default ? 'listDefaultNo' : 'listDefaultYes';
- ?>
- <tr class="<?php echo "row$k"; ?>">
- <td><?php echo $i+1+$pageNav->limitstart;?></td>
- <td><input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row->listid; ?>" onClick="isChecked(this.checked);" /></td>
- <td> <a href="#editList" onClick="return listItemTask('cb<?php echo $i;?>','editList')"><?php echo getLangDefinition($row->title); ?></a></td>
- <td><?php echo getLangDefinition($row->description); ?></td>
- <td width="10%"><a href="javascript: void(0);" onClick="return listItemTask('cb<?php echo $i;?>
- ','<?php echo $task3;?>')"><img src="<?php echo $imgpath.$img3;?>" width="16" height="16" border="0" alt="" /></a></td>
- <td width="10%"><a href="javascript: void(0);" onClick="return listItemTask('cb<?php echo $i;?>
- ','<?php echo $task4;?>')"><img src="<?php echo $imgpath.$img4;?>" width="16" height="16" border="0" alt="" /></a></td>
- <td><?php
- if ( $row->useraccessgroupid >= 0 ) {
- echo '<span style="color:red;">' . $_CB_framework->acl->get_group_name( (int) $row->useraccessgroupid ) . '</span>';
- } elseif ( $row->useraccessgroupid == -2 ) {
- echo '<span style="color:green;">Everybody</span>';
- } elseif ( $row->useraccessgroupid == -1 ) {
- echo '<span style="color:orange;">All Registered Users</span>';
- }
- ?></td>
- <td>
- <?php if ($i > 0 || ($i+$pageNav->limitstart > 0)) { ?>
- <a href="#reorder" onClick="return listItemTask('cb<?php echo $i;?>','orderupList')">
- <img src="images/uparrow.png" width="12" height="12" border="0" alt="Move Up" />
- </a>
- <?php } ?>
- </td>
- <td>
- <?php if ($i < $n-1 || $i+$pageNav->limitstart < $pageNav->total-1) { ?>
- <a href="#reorder" onClick="return listItemTask('cb<?php echo $i;?>','orderdownList')">
- <img src="images/downarrow.png" width="12" height="12" border="0" alt="Move Down" />
- </a>
- <?php } ?>
- </td>
- <td align="center">
- <input type="text" name="order[]" size="5" value="<?php echo $row->ordering; ?>" class="text_area" style="text-align: center" />
- </td>
- <td style="text-align:right"><?php echo $row->listid;?></td>
- </tr>
- <?php $k = 1 - $k; } ?>
- </tbody>
- <tfoot>
- <tr>
- <th align="center" colspan="12"> <?php echo $pageNav->getListFooter(); ?></th>
- </tr>
- </tfoot>
- </table>
- <input type="hidden" name="option" value="<?php echo $option;?>" />
- <input type="hidden" name="task" value="showLists" />
- <input type="hidden" name="boxchecked" value="0" />
- <?php
- echo cbGetSpoofInputTag( 'list' );
- ?>
- </form>
- <?php
- }
- function editList( &$row, $lists, $fields, $option, $tabid, $paramsEditorHtml ) {
- global $_CB_database, $_CB_framework;
- HTML_comprofiler::secureAboveForm('editList');
- outputCbTemplate( 2 );
- // outputCbJs( 2 );
- echo initToolTip(2);
- global $_CB_Backend_Title;
- $_CB_Backend_Title = array( 0 => array( 'cbicon-48-lists', "Community Builder List: <small>" . ( $row->listid ? "Edit" . ' [ '. htmlspecialchars( getLangDefinition( $row->title ) ) .' ]' : "New" ) . '</small>' ) );
- if ( $row->listid && ( ! $row->published ) ) {
- echo '<div class="cbWarning">List is not published</div>' . "n";
- }
- $notFoundFielIds = array();
- $sqlWhere="";
- $fieldids=null;
- $col1options="";
- $col2options="";
- $col3options="";
- $col4options="";
- if($tabid >0) {
- $col1fields=explode('|*|',$row->col1fields);
- $fieldids="";
- for ($i=0, $n=count( $col1fields ); $i < $n; $i++) {
- $col1field = $col1fields[$i];
- if(trim($col1field)!='' && trim($col1field)!=null) {
- $text = array_search($col1field,$fields);
- if ( is_string( $text ) ) {
- $col1options .= "<option value="".$col1field."">".getLangDefinition($text)."n";
- if ( $fieldids ) {
- $fieldids .= ",";
- }
- $fieldids .= "'".$col1field."'";
- } else {
- $notFoundFielIds[] = $col1field;
- }
- }
- }
- $col2fields=explode('|*|',$row->col2fields);
- for ($i=0, $n=count( $col2fields ); $i < $n; $i++) {
- $col2field = $col2fields[$i];
- if(trim($col2field)!='' && trim($col2field)!=null) {
- $text = array_search($col2field,$fields);
- if ( is_string( $text ) ) {
- $col2options .= "<option value="".$col2field."">".getLangDefinition($text)."n";
- if ( $fieldids ) {
- $fieldids .= ",";
- }
- $fieldids .= "'".$col2field."'";
- } else {
- $notFoundFielIds[] = $col2field;
- }
- }
- }
- $col3fields=explode('|*|',$row->col3fields);
- for ($i=0, $n=count( $col3fields ); $i < $n; $i++) {
- $col3field = $col3fields[$i];
- if(trim($col3field)!='' && trim($col3field)!=null) {
- $text = array_search($col3field,$fields);
- if ( is_string( $text ) ) {
- $col3options .= "<option value="".$col3field."">".getLangDefinition($text)."n";
- if ( $fieldids ) {
- $fieldids .= ",";
- }
- $fieldids .= "'".$col3field."'";
- } else {
- $notFoundFielIds[] = $col3field;
- }
- }
- }
- $col4fields=explode('|*|',$row->col4fields);
- for ($i=0, $n=count( $col4fields ); $i < $n; $i++) {
- $col4field = $col4fields[$i];
- if(trim($col4field)!='' && trim($col4field)!=null) {
- $text = array_search($col4field,$fields);
- if ( is_string( $text ) ) {
- $col4options .= "<option value="".$col4field."">".getLangDefinition($text)."n";
- if ( $fieldids ) {
- $fieldids .= ",";
- }
- $fieldids .= "'".$col4field."'";
- } else {
- $notFoundFielIds[] = $col4field;
- }
- }
- }
- if($fieldids!=null) {
- $sqlWhere="nAND fieldid NOT IN ($fieldids)";
- }
- }
- // this query is for listing displayable fields:
- $_CB_database->setQuery( "SELECT f.fieldid, f.title, f.name"
- . "n FROM #__comprofiler_fields f"
- . "n INNER JOIN #__comprofiler_plugin AS p ON (f.pluginid = p.id)"
- . "n WHERE f.published = 1"
- . "n AND f.profile > 0"
- . "n AND p.published = 1"
- . $sqlWhere
- );
- $fields = $_CB_database->loadObjectList();
- $stripME = array(" ASC", " DESC","`");
- $sortsArray = explode( ', ', $row->sortfields );
- $SQLfunctions = array();
- foreach ( $sortsArray as $k => $v ) {
- $WhereIn = trim( str_replace($stripME, "", $v ) );
- if ( substr( $WhereIn, -1, 1 ) == ')') {
- $SQLfunctions[] = $WhereIn;
- unset( $sortsArray[$k] );
- } else {
- $sortsArray[$k] = $_CB_database->Quote( $WhereIn );
- }
- }
- $sortsArray[$k+1] = $_CB_database->Quote( 'onlinestatus' ); //TBD: refactor to field, temporarly in here...
- // this query is for listing sortable fields
- $_CB_database->setQuery( "SELECT f.title, f.name"
- . "n FROM #__comprofiler_fields f"
- . "n INNER JOIN #__comprofiler_plugin AS p ON (f.pluginid = p.id)"
- . "n WHERE f.published = 1"
- . "n AND f.name <> 'NA'"
- . "n AND f.tablecolumns <> ''"
- . "n AND p.published = 1"
- . "n AND f.name NOT IN(" . implode( ',', $sortsArray ) . ")"
- );
- /*
- $stripME = array(" ASC", " DESC","`");
- $WhereIn = str_replace($stripME, "", $row->sortfields);
- $WhereIn = "'".str_replace(", ","','",$WhereIn)."'";
- $_CB_database->setQuery( "SELECT f.title, f.name"
- . "nFROM #__comprofiler_fields f"
- . "nWHERE f.published = 1 AND f.name!='NA'"
- . "nAND f.name NOT IN(".$WhereIn.")"
- );
- */
- $sortfields = $_CB_database->loadObjectList();
- if ( is_array( $sortfields ) && ( count( $sortfields ) > 0 ) && ! in_array( 'RAND()', $SQLfunctions ) ) {
- $randomSort = new stdClass();
- $randomSort->title = CBTxt::T("Sort Randomly");
- $randomSort->name = "RAND()";
- $sortfields[] = $randomSort;
- }
- // this query is for listing filterable fields
- $_CB_database->setQuery( "SELECT f.title, f.name"
- . "n FROM #__comprofiler_fields f"
- . "n INNER JOIN #__comprofiler_plugin AS p ON (f.pluginid = p.id)"
- . "n WHERE f.published = 1"
- . "n AND f.name <> 'NA'"
- . "n AND f.tablecolumns <> ''"
- . "n AND p.published = 1"
- );
- $filterfields = $_CB_database->loadObjectList();
- $sortlists=explode(", ",str_replace("`","",$row->sortfields));
- $sortparts=array();
- $i=0;
- foreach($sortlists as $sortlist) {
- $sortlistpart=array();
- $sortlistpart=explode(" ",$sortlist);
- if(!ISSET($sortlistpart[1])) $sortlistpart[1]="";
- $sortparts[$i]['field']=$sortlistpart[0];
- $sortparts[$i]['dir']=$sortlistpart[1];
- if ( substr( $sortlistpart[0], -1, 1 ) != ')' ) {
- $_CB_database->setQuery("SELECT title FROM #__comprofiler_fields WHERE name='".$sortlistpart[0]."' LIMIT 1");
- $sortparts[$i]['title']=$_CB_database->loadResult();
- } else {
- switch ( $sortlistpart[0] ) {
- case 'RAND()':
- $sortparts[$i]['title'] = CBTxt::T("Sort Randomly");
- break;
- default:
- $sortparts[$i]['title'] = CBTxt::T("Non-existing field") . ": " . $sortlistpart[0];
- break;
- }
- }
- $i++;
- }
- if ( count( $notFoundFielIds ) > 0 ) {
- cbArrayToInts( $notFoundFielIds );
- $_CB_database->setQuery( "SELECT f.name, f.title, f.published, f.profile, p.published AS pluginpublished, p.name AS pluginname"
- . "n FROM #__comprofiler_fields AS f"
- . "n INNER JOIN #__comprofiler_plugin AS p ON (f.pluginid = p.id)"
- . "n WHERE f.fieldid IN (" . implode( ',', $notFoundFielIds ) . ")"
- // . "n WHERE f.published = 1"
- // . "n AND f.profile > 0"
- // . "n AND p.published = 1"
- . "n ORDER BY f.ordering"
- );
- $problemFields = $_CB_database->loadObjectList();
- if ( is_array( $problemFields ) && ( count( $problemFields ) > 0 ) ) {
- echo '<div class="cbWarning">Following fields are in list but not visible in here for following reason(s):<ul>';
- foreach ( $problemFields as $f ) {
- if ( $f->published != 1 ) {
- echo '<li>Field "' . getLangDefinition( $f->title ) . ' (' . $f->name . ')" ' . " is not published !";
- }
- if ( $f->profile <= 0 ) {
- echo '<li>Field "' . getLangDefinition( $f->title ) . ' (' . $f->name . ')" ' . " is not displayed on profile !";
- }
- if ( $f->pluginpublished != 1 ) {
- echo '<li>Field "' . getLangDefinition( $f->title ) . ' (' . $f->name . ')" ' . " is from plugin "" . $f->pluginname . "" but this plugin is not published !";
- }
- }
- echo '</ul>If you save list now, they will be removed from the list. If you want to keep them, cancel now and go to Components / CB / Field Manager.</div>' . "n";
- }
- }
- ?>
- <script type="text/javascript"><!--//--><![CDATA[//><!--
- function getObject(obj) {
- var strObj;
- if (document.all) {
- strObj = document.all.item(obj);
- } else if (document.getElementById) {
- strObj = document.getElementById(obj);
- }
- return strObj;
- }
- function shDiv(objID,sh) {
- var strObj;
- strObj = getObject(objID);
- if(sh==0) {
- strObj.style.display="none";
- } else {
- strObj.style.display="block";
- }
- }
- function submitbutton(pressbutton) {
- if (pressbutton == 'showLists') {
- <?php echo $_CB_framework->saveCmsEditorJS( 'description' ); ?>
- submitform( pressbutton );
- return;
- }
- var coll = document.adminForm;
- var errorMSG = '';
- var iserror=0;
- if (coll.col1enabled.checked == true) coll.col1title.setAttribute('mosReq',1);
- if (coll.col2enabled.checked == true) coll.col2title.setAttribute('mosReq',1);
- if (coll.col3enabled.checked == true) coll.col3title.setAttribute('mosReq',1);
- if (coll.col4enabled.checked == true) coll.col4title.setAttribute('mosReq',1);
- getSortList(document.adminForm.sort);
- getFilterList(document.adminForm.filter);
- if (coll != null) {
- var elements = coll.elements;
- // loop through all input elements in form
- for (var i=0; i < elements.length; i++) {
- // check if element is mandatory; here mosReq=1
- if ((typeof(elements.item(i).getAttribute('mosReq')) != "undefined") && (elements.item(i).getAttribute('mosReq') == 1)) {
- if (elements.item(i).value == '') {
- //alert(elements.item(i).getAttribute('mosLabel') + ':' + elements.item(i).getAttribute('mosReq'));
- // add up all error messages
- errorMSG += elements.item(i).getAttribute('mosLabel') + ' : <?php echo _UE_REQUIRED_ERROR; ?>n';
- // notify user by changing background color, in this case to red
- elements.item(i).style.backgroundColor = "red";
- iserror=1;
- }
- }
- }
- }
- if(iserror==1) { alert(errorMSG); }
- else {
- selectAll(document.adminForm.col1);
- selectAll(document.adminForm.col2);
- selectAll(document.adminForm.col3);
- selectAll(document.adminForm.col4);
- <?php echo $_CB_framework->saveCmsEditorJS( 'description' ); ?>
- submitform( pressbutton );
- }
- }
- function addOption(selectObj, value)
- {
- optionSelected = (value == null);
- if(value == null) value = prompt('', '');
- if(value != null)
- {
- if(value.indexOf(',') != -1)
- alert('Commas are not allowed in size values');
- else
- {
- var i = selectObj.options.length;
- value = value.replace(/1/2/g, '锟