Main Page | Directories | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages | Examples

SC_alt_shortcut Class Reference

List of all members.

Public Member Functions

 preinit ()
 Pre-initialization - setting input variables for storing shortcuts etc.
 preprocess ()
 Adding shortcuts, editing shortcuts etc.
 init ()
 Initialize (page output).
 main ()
 Main function, creating content in the frame.
 editLoadedFunc ()
 Creates lines for the editing form.
 editPageIdFunc ()
 If "editPage" value is sent to script and it points to an accessible page, the internal var $this->theEditRec is set to the page record which should be loaded.
 printContent ()
 Outputting the accumulated content to screen.
 mIconFilename ($Ifilename, $backPath)
 Returns relative filename for icon.
 getIcon ($modName)
 Returns icon for shortcut display.
 itemLabel ($inlabel, $modName, $M_modName='')
 Returns title-label for icon.

Public Attributes

 $modName
 $M_modName
 $URL
 $editSC
 $deleteCategory
 $editName
 $editGroup
 $whichItem
 $loadModules
 $doc
 $nGroups
 $nGlobals
 $content
 $lines
 $editLoaded
 $editError
 $editPath
 $editSC_rec
 $theEditRec
 $editPage
 $selOpt

Member Function Documentation

SC_alt_shortcut::editLoadedFunc  ) 
 

Creates lines for the editing form.

Returns:
void

Definition at line 335 of file alt_shortcut.php.

References $a, $LANG, and table().

00335                               {
00336       global $BE_USER,$LANG;
00337 
00338       $this->editLoaded=0;
00339       if (is_array($this->editSC_rec) && ($this->editSC_rec['sc_group']>=0 || $BE_USER->isAdmin()))   {  // sc_group numbers below 0 requires admin to edit those. sc_group numbers above zero must always be owned by the user himself.
00340          $this->editLoaded=1;
00341 
00342          $opt=array();
00343          $opt[]='<option value="0"></option>';
00344          for($a=1;$a<=$this->nGroups;$a++)   {
00345             $opt[]='<option value="'.$a.'"'.(!strcmp($this->editSC_rec['sc_group'],$a)?' selected="selected"':'').'>'.$LANG->getLL('shortcut_group',1).' '.$a.'</option>';
00346          }
00347          if ($BE_USER->isAdmin())   {
00348             for($a=1;$a<=$this->nGlobals;$a++)  {
00349                $opt[]='<option value="-'.$a.'"'.(!strcmp($this->editSC_rec['sc_group'],'-'.$a)?' selected="selected"':'').'>'.$LANG->getLL('shortcut_GLOBAL',1).': '.$a.'</option>';
00350             }
00351             $opt[]='<option value="-100"'.(!strcmp($this->editSC_rec['sc_group'],'-100')?' selected="selected"':'').'>'.$LANG->getLL('shortcut_GLOBAL',1).': '.$LANG->getLL('shortcut_ALL',1).'</option>';
00352          }
00353 
00354             // border="0" hspace="2" width="21" height="16" - not XHTML compliant in <input type="image" ...>
00355          $manageForm='
00356 
00357 
00358             <!--
00359                Shortcut Editing Form:
00360             -->
00361             <table border="0" cellpadding="0" cellspacing="0" id="typo3-shortcuts-editing">
00362                <tr>
00363                   <td>&nbsp;&nbsp;</td>
00364                   <td><input type="image" class="c-inputButton" name="_savedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/savedok.gif','').' title="'.$LANG->getLL('shortcut_save',1).'" /></td>
00365                   <td><input type="image" class="c-inputButton" name="_saveclosedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/saveandclosedok.gif','').' title="'.$LANG->getLL('shortcut_saveClose',1).'" /></td>
00366                   <td><input type="image" class="c-inputButton" name="_closedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/closedok.gif','').' title="'.$LANG->getLL('shortcut_close',1).'" /></td>
00367                   <td><input type="image" class="c-inputButton" name="_deletedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/deletedok.gif','').' title="'.$LANG->getLL('shortcut_delete',1).'" /></td>
00368                   <td><input name="editName" type="text" value="'.htmlspecialchars($this->editSC_rec['description']).'"'.$this->doc->formWidth(15).' /></td>
00369                   <td><select name="editGroup">'.implode('',$opt).'</select></td>
00370                </tr>
00371             </table>
00372             <input type="hidden" name="whichItem" value="'.$this->editSC_rec['uid'].'" />
00373 
00374             ';
00375       } else $manageForm='';
00376 //debug(count($opt));
00377       if (!$this->editLoaded && count($this->selOpt)>1)  {
00378          $this->lines[]='<td>&nbsp;</td>';
00379          $this->lines[]='<td><select name="_selSC" onchange="eval(this.options[this.selectedIndex].value);this.selectedIndex=0;">'.implode('',$this->selOpt).'</select></td>';
00380       }
00381       if (count($this->lines))   {
00382          if (!$BE_USER->getTSConfigVal('options.mayNotCreateEditShortcuts'))  {
00383             $this->lines=array_merge(array('<td><input type="checkbox" name="editShortcut_check" value="1"'.($this->editSC?' checked="checked"':'').' />'.$LANG->getLL('shortcut_edit',1).'&nbsp;</td>'),$this->lines);
00384             $this->lines[]='<td>'.$manageForm.'</td>';
00385          }
00386          $this->lines[]='<td><img src="clear.gif" width="10" height="1" alt="" /></td>';
00387       }
00388    }

SC_alt_shortcut::editPageIdFunc  ) 
 

If "editPage" value is sent to script and it points to an accessible page, the internal var $this->theEditRec is set to the page record which should be loaded.

Returns void

Returns:
void

Definition at line 396 of file alt_shortcut.php.

References $LANG, t3lib_BEfunc::getRecord(), t3lib_BEfunc::getRecordPath(), t3lib_BEfunc::getRecordsByField(), t3lib_extMgm::isLoaded(), and t3lib_BEfunc::openPageTree().

00396                               {
00397       global $BE_USER,$LANG;
00398 
00399       if (!t3lib_extMgm::isLoaded('cms')) return;
00400 
00401          // EDIT page:
00402       $this->editPage = trim(strtolower($this->editPage));
00403       $this->editError = '';
00404       $this->theEditRec = '';
00405       if ($this->editPage) {
00406          $where = ' AND ('.$BE_USER->getPagePermsClause(2).' OR '.$BE_USER->getPagePermsClause(16).')';
00407          if (t3lib_div::testInt($this->editPage))  {
00408             $this->theEditRec = t3lib_BEfunc::getRecord ('pages',$this->editPage,'*',$where);
00409          } else {
00410             $records = t3lib_BEfunc::getRecordsByField('pages','alias',$this->editPage,$where);
00411             if (is_array($records)) {
00412                reset($records);
00413                $this->theEditRec = current($records);
00414             }
00415          }
00416          if (!is_array($this->theEditRec) || !$BE_USER->isInWebMount($this->theEditRec['uid'])) {
00417             unset($this->theEditRec);
00418             $this->editError=$LANG->getLL('shortcut_notEditable');
00419          } else {
00420                // Visual path set:
00421             $perms_clause = $BE_USER->getPagePermsClause(1);
00422             $this->editPath = t3lib_BEfunc::getRecordPath($this->theEditRec['pid'], $perms_clause, 30);
00423 
00424             if(!$BE_USER->getTSConfigVal('options.shortcut_onEditId_dontSetPageTree')) {
00425 
00426                   // Expanding page tree:
00427                t3lib_BEfunc::openPageTree($this->theEditRec['pid'],!$BE_USER->getTSConfigVal('options.shortcut_onEditId_keepExistingExpanded'));
00428             }
00429          }
00430       }
00431    }

SC_alt_shortcut::getIcon modName  ) 
 

Returns icon for shortcut display.

Parameters:
string Backend module name
Returns:
string Icon file name

Definition at line 479 of file alt_shortcut.php.

References $LANG.

00479                               {
00480       global $LANG;
00481       if ($LANG->moduleLabels['tabs_images'][$modName.'_tab']) {
00482          $icon = $this->mIconFilename($LANG->moduleLabels['tabs_images'][$modName.'_tab'],'');
00483       } elseif ($modName=='xMOD_alt_doc.php') {
00484          $icon = 'gfx/edit2.gif';
00485       } elseif ($modName=='xMOD_file_edit.php') {
00486          $icon = 'gfx/edit_file.gif';
00487       } elseif ($modName=='xMOD_wizard_rte.php') {
00488          $icon = 'gfx/edit_rtewiz.gif';
00489       } else {
00490          $icon = 'gfx/dummy_module.gif';
00491       }
00492       return $icon;
00493    }

SC_alt_shortcut::init  ) 
 

Initialize (page output).

Returns:
void

Definition at line 200 of file alt_shortcut.php.

00200                      {
00201       global $BACK_PATH;
00202 
00203       $this->doc = t3lib_div::makeInstance('template');
00204       $this->doc->backPath = $BACK_PATH;
00205       $this->doc->form='<form action="alt_shortcut.php" name="shForm" method="post">';
00206       $this->doc->docType='xhtml_trans';
00207       $this->doc->divClass='typo3-shortcut';
00208       $this->doc->JScode.=$this->doc->wrapScriptTags('
00209          function jump(url,modName,mainModName) {  //
00210                // Clear information about which entry in nav. tree that might have been highlighted.
00211             top.fsMod.navFrameHighlightedID = new Array();
00212             if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav)   {
00213                top.content.nav_frame.refresh_nav();
00214             }
00215 
00216             top.nextLoadModuleUrl = url;
00217             top.goToModule(modName);
00218          }
00219          function editSh(uid) {  //
00220             document.location="alt_shortcut.php?editShortcut="+uid;
00221          }
00222          function submitEditPage(id)   {  //
00223             document.location="alt_shortcut.php?editPage="+top.rawurlencode(id);
00224          }
00225          ');
00226       $this->content.=$this->doc->startPage('Shortcut frame');
00227    }

SC_alt_shortcut::itemLabel inlabel,
modName,
M_modName = ''
 

Returns title-label for icon.

Parameters:
string In-label
string Backend module name (key)
string Backend module label (user defined?)
Returns:
string Label for the shortcut item

Definition at line 503 of file alt_shortcut.php.

References $LANG.

00503                                                          {
00504       global $LANG;
00505       if (substr($modName,0,5)=='xMOD_')  {
00506          $label=substr($modName,5);
00507       } else {
00508          $split = explode('_',$modName);
00509          $label = $LANG->moduleLabels['tabs'][$split[0].'_tab'];
00510          if (count($split)>1) {
00511             $label.='>'.$LANG->moduleLabels['tabs'][$modName.'_tab'];
00512          }
00513       }
00514       if ($M_modName)   $label.=' ('.$M_modName.')';
00515       $label.=': '.$inlabel;
00516       return $label;
00517    }

SC_alt_shortcut::main  ) 
 

Main function, creating content in the frame.

Returns:
void

Definition at line 234 of file alt_shortcut.php.

References $a, t3lib_extMgm::isLoaded(), and table().

00234                      {
00235       global $BE_USER,$LANG;
00236 
00237          // Setting groups and globals
00238       $this->nGroups=4;
00239       $this->nGlobals=5;
00240 
00241       $globalGroups=array(-100);
00242       $shortCutGroups = $BE_USER->getTSConfig('options.shortcutGroups');
00243       for($a=1;$a<=$this->nGlobals;$a++)  {
00244          if ($BE_USER->isAdmin() || strcmp($shortCutGroups['properties'][$a],''))   {
00245             $globalGroups[]=-$a;
00246          }
00247       }
00248 
00249          // Fetching shortcuts to display for this user:
00250       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_be_shortcuts', '((userid='.$BE_USER->user['uid'].' AND sc_group>=0) OR sc_group IN ('.implode(',',$globalGroups).'))', '', 'sc_group,sorting');
00251 
00252          // Init vars:
00253       $this->lines=array();
00254       $this->editSC_rec='';
00255       $this->selOpt=array();
00256       $formerGr='';
00257 
00258          // Traverse shortcuts
00259       while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))   {
00260          if ($this->editSC && $row['uid']==$this->editSC)   {
00261             $this->editSC_rec=$row;
00262          }
00263 
00264          if (strcmp($formerGr,$row['sc_group']))   {
00265             if ($row['sc_group']!=-100)   {
00266                if ($row['sc_group']>=0)   {
00267                   $onC = 'if (confirm('.$GLOBALS['LANG']->JScharCode($LANG->getLL('shortcut_delAllInCat')).')){document.location=\'alt_shortcut.php?deleteCategory='.$row['sc_group'].'\';}return false;';
00268                   $this->lines[]='<td>&nbsp;</td><td class="bgColor5"><a href="#" onclick="'.htmlspecialchars($onC).'" title="'.$LANG->getLL('shortcut_delAllInCat',1).'">'.abs($row['sc_group']).'</a></td>';
00269                } else {
00270                   $this->lines[]='<td>&nbsp;</td><td class="bgColor5">'.abs($row['sc_group']).'</td>';
00271                }
00272             }
00273          }
00274 
00275          $mParts = explode('|',$row['module_name']);
00276          $row['module_name']=$mParts[0];
00277          $row['M_module_name']=$mParts[1];
00278          $mParts = explode('_',$row['M_module_name']?$row['M_module_name']:$row['module_name']);
00279          $qParts = parse_url($row['url']);
00280 
00281          $bgColorClass = $row['uid']==$this->editSC ? 'bgColor5' : ($row['sc_group']<0 ? 'bgColor6' : 'bgColor4');
00282          $titleA = $this->itemLabel($row['description']&&($row['uid']!=$this->editSC) ? $row['description'] : t3lib_div::fixed_lgd(rawurldecode($qParts['query']),150),$row['module_name'],$row['M_module_name']);
00283 
00284          $editSH = ($row['sc_group']>=0 || $BE_USER->isAdmin()) ? 'editSh('.intval($row['uid']).');' : "alert('".$LANG->getLL('shortcut_onlyAdmin')."')";
00285          $jumpSC = 'jump(unescape(\''.rawurlencode($row['url']).'\'),\''.implode('_',$mParts).'\',\''.$mParts[0].'\');';
00286          $onC = 'if (document.shForm.editShortcut_check && document.shForm.editShortcut_check.checked){'.$editSH.'}else{'.$jumpSC.'}return false;';
00287          $this->lines[]='<td class="'.$bgColorClass.'"><a href="#" onclick="'.htmlspecialchars($onC).'"><img src="'.$this->getIcon($row['module_name']).'" title="'.htmlspecialchars($titleA).'" alt="" /></a></td>';
00288          if (trim($row['description']))   {
00289             $kkey = strtolower(substr($row['description'],0,20)).'_'.$row['uid'];
00290             $this->selOpt[$kkey]='<option value="'.htmlspecialchars($jumpSC).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($row['description'],50)).'</option>';
00291          }
00292          $formerGr=$row['sc_group'];
00293       }
00294       ksort($this->selOpt);
00295       array_unshift($this->selOpt,'<option>['.$LANG->getLL('shortcut_selSC',1).']</option>');
00296 
00297       $this->editLoadedFunc();
00298       $this->editPageIdFunc();
00299 
00300       if (!$this->editLoaded && t3lib_extMgm::isLoaded('cms')) {
00301             $editIdCode = '<td nowrap="nowrap">'.$LANG->getLL('shortcut_editID',1).': <input type="text" value="'.($this->editError?htmlspecialchars($this->editPage):'').'" name="editPage"'.$this->doc->formWidth(5).' onchange="submitEditPage(this.value);" />'.
00302                ($this->editError?'&nbsp;<strong><span class="typo3-red">'.htmlspecialchars($this->editError).'</span></strong>':'').
00303                (is_array($this->theEditRec)?'&nbsp;<strong>'.$LANG->getLL('shortcut_loadEdit',1).' \''.t3lib_BEfunc::getRecordTitle('pages',$this->theEditRec,1).'\'</strong> ('.htmlspecialchars($this->editPath).')':'').
00304                '</td>';
00305       } else $editIdCode = '';
00306 
00307          // Adding CSH:
00308       $editIdCode.= '<td>&nbsp;'.t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'shortcuts', $GLOBALS['BACK_PATH'],'',TRUE).'</td>';
00309 
00310       $this->content.='
00311 
00312 
00313          <!--
00314             Shortcut Display Table:
00315          -->
00316          <table border="0" cellpadding="0" cellspacing="2" id="typo3-shortcuts">
00317             <tr>
00318             '.implode('
00319             ',$this->lines).$editIdCode.'
00320             </tr>
00321          </table>
00322 
00323          ';
00324 
00325       if ($this->theEditRec['uid']) {
00326          $this->content.=$this->doc->wrapScriptTags('top.loadEditId('.$this->theEditRec['uid'].');');
00327       }
00328    }

SC_alt_shortcut::mIconFilename Ifilename,
backPath
 

Returns relative filename for icon.

Parameters:
string Absolute filename of the icon
string Backpath string to prepend the icon after made relative
Returns:
void

Definition at line 466 of file alt_shortcut.php.

References PATH_site.

00466                                                 {
00467       if (t3lib_div::isAbsPath($Ifilename))  {
00468          $Ifilename = '../'.substr($Ifilename,strlen(PATH_site));
00469       }
00470       return $backPath.$Ifilename;
00471    }

SC_alt_shortcut::preinit  ) 
 

Pre-initialization - setting input variables for storing shortcuts etc.

Returns:
void

Definition at line 118 of file alt_shortcut.php.

00118                         {
00119       global $TBE_MODULES;
00120 
00121          // Setting GPvars:
00122       $this->modName = t3lib_div::_GP('modName');
00123       $this->M_modName = t3lib_div::_GP('motherModName');
00124       $this->URL = t3lib_div::_GP('URL');
00125       $this->editSC = t3lib_div::_GP('editShortcut');
00126 
00127       $this->deleteCategory = t3lib_div::_GP('deleteCategory');
00128       $this->editPage = t3lib_div::_GP('editPage');
00129       $this->editName = t3lib_div::_GP('editName');
00130       $this->editGroup = t3lib_div::_GP('editGroup');
00131       $this->whichItem = t3lib_div::_GP('whichItem');
00132 
00133          // Creating modules object
00134       $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules');
00135       $this->loadModules->load($TBE_MODULES);
00136    }

SC_alt_shortcut::preprocess  ) 
 

Adding shortcuts, editing shortcuts etc.

Returns:
void

Definition at line 143 of file alt_shortcut.php.

00143                            {
00144       global $BE_USER;
00145 
00146          // Adding a shortcut being set from another frame
00147       if ($this->modName && $this->URL)   {
00148          $fields_values = array(
00149             'userid' => $BE_USER->user['uid'],
00150             'module_name' => $this->modName.'|'.$this->M_modName,
00151             'url' => $this->URL,
00152             'sorting' => time()
00153          );
00154          $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_be_shortcuts', $fields_values);
00155       }
00156 
00157          // Selection-clause for users - so users can deleted only their own shortcuts (except admins)
00158       $addUSERWhere = (!$BE_USER->isAdmin()?' AND userid='.intval($BE_USER->user['uid']):'');
00159 
00160          // Deleting shortcuts:
00161       if (strcmp($this->deleteCategory,''))  {
00162          if (t3lib_div::testInt($this->deleteCategory))  {
00163             $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_be_shortcuts', 'sc_group='.intval($this->deleteCategory).$addUSERWhere);
00164          }
00165       }
00166 
00167          // If other changes in post-vars:
00168       if (is_array($_POST))   {
00169             // Saving:
00170          if (isset($_POST['_savedok_x']) || isset($_POST['_saveclosedok_x'])) {
00171             $fields_values = array(
00172                'description' => $this->editName,
00173                'sc_group' => intval($this->editGroup)
00174             );
00175             if ($fields_values['sc_group']<0 && !$BE_USER->isAdmin())   {
00176                $fields_values['sc_group']=0;
00177             }
00178 
00179             $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_be_shortcuts', 'uid='.intval($this->whichItem).$addUSERWhere, $fields_values);
00180          }
00181             // If save without close, keep the session going...
00182          if (isset($_POST['_savedok_x'])) {
00183             $this->editSC=$this->whichItem;
00184          }
00185             // Deleting a single shortcut ?
00186          if (isset($_POST['_deletedok_x']))  {
00187             $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_be_shortcuts', 'uid='.intval($this->whichItem).$addUSERWhere);
00188 
00189             if (!$this->editSC)  $this->editSC=-1; // Just to have the checkbox set...
00190          }
00191       }
00192 
00193    }

SC_alt_shortcut::printContent  ) 
 

Outputting the accumulated content to screen.

Returns:
void

Definition at line 438 of file alt_shortcut.php.

00438                            {
00439       $this->content.= $this->doc->endPage();
00440       echo $this->content;
00441    }


Member Data Documentation

SC_alt_shortcut::$content
 

Definition at line 101 of file alt_shortcut.php.

SC_alt_shortcut::$deleteCategory
 

Definition at line 89 of file alt_shortcut.php.

SC_alt_shortcut::$doc
 

Definition at line 96 of file alt_shortcut.php.

SC_alt_shortcut::$editError
 

Definition at line 105 of file alt_shortcut.php.

SC_alt_shortcut::$editGroup
 

Definition at line 91 of file alt_shortcut.php.

SC_alt_shortcut::$editLoaded
 

Definition at line 104 of file alt_shortcut.php.

SC_alt_shortcut::$editName
 

Definition at line 90 of file alt_shortcut.php.

SC_alt_shortcut::$editPage
 

Definition at line 109 of file alt_shortcut.php.

SC_alt_shortcut::$editPath
 

Definition at line 106 of file alt_shortcut.php.

SC_alt_shortcut::$editSC
 

Definition at line 88 of file alt_shortcut.php.

SC_alt_shortcut::$editSC_rec
 

Definition at line 107 of file alt_shortcut.php.

SC_alt_shortcut::$lines
 

Definition at line 102 of file alt_shortcut.php.

SC_alt_shortcut::$loadModules
 

Definition at line 95 of file alt_shortcut.php.

SC_alt_shortcut::$M_modName
 

Definition at line 86 of file alt_shortcut.php.

SC_alt_shortcut::$modName
 

Definition at line 85 of file alt_shortcut.php.

SC_alt_shortcut::$nGlobals
 

Definition at line 98 of file alt_shortcut.php.

SC_alt_shortcut::$nGroups
 

Definition at line 97 of file alt_shortcut.php.

SC_alt_shortcut::$selOpt
 

Definition at line 110 of file alt_shortcut.php.

SC_alt_shortcut::$theEditRec
 

Definition at line 108 of file alt_shortcut.php.

SC_alt_shortcut::$URL
 

Definition at line 87 of file alt_shortcut.php.

SC_alt_shortcut::$whichItem
 

Definition at line 92 of file alt_shortcut.php.


The documentation for this class was generated from the following file:
Generated on Sun Oct 3 01:06:28 2004 for TYPO3core 3.7.0 dev by  doxygen 1.3.8-20040913