Exemplo n.º 1
0
 /**
  * Render the menu.
  *
  * @return string HTML fragment containing the menu.
  */
 public function render()
 {
     $page = Page::getInstance();
     $menu = $this->load();
     $page->addContent($menu);
     return $page->render('Menu', true);
 }
Exemplo n.º 2
0
 /**
  * Return a piece of html code to edit the attribute.
  *
  * @param array $record Current record
  * @param string $fieldprefix The fieldprefix to put in front of the name
  *                            of any html form element for this attribute.
  * @param string $mode The mode we're in ('add' or 'edit')
  *
  * @return string piece of html code
  */
 public function edit($record, $fieldprefix, $mode)
 {
     $this->createDestination();
     $this->createLink();
     $result = '';
     $selectedPk = $this->getSelectedRecords($record);
     $recordset = $this->_getSelectableRecords($record, $mode);
     $total_records = count($recordset);
     if ($total_records > 0) {
         $page = Page::getInstance();
         $page->register_script(Config::getGlobal('assets_url') . 'javascript/class.atkprofileattribute.js');
         if (!$this->hasFlag(self::AF_MANYBOOL_NO_TOOLBAR)) {
             $result .= '<div align="left">
                   [<a href="javascript:void(0)" onclick="profile_checkAll(\'' . $this->getHtmlId($fieldprefix) . '\'); return false;">' . Tools::atktext('check_all', 'atk') . '</a> <a href="javascript:void(0)" onclick="profile_checkNone(\'' . $this->getHtmlId($fieldprefix) . '\'); return false;">' . Tools::atktext('check_none', 'atk') . '</a> <a href="javascript:void(0)" onclick="profile_checkInvert(\'' . $this->getHtmlId($fieldprefix) . '\'); return false;">' . Tools::atktext('invert_selection', 'atk') . '</a>]</div>';
         }
         $result .= '<div>';
         for ($i = 0; $i < $total_records; ++$i) {
             $detailLink = '';
             $sel = '';
             $onchange = '';
             $inputId = $this->getHtmlId($fieldprefix) . '_' . $i;
             if (in_array($this->m_destInstance->primaryKey($recordset[$i]), $selectedPk)) {
                 $sel = 'checked';
                 if ($this->getShowDetailsLink() && !$this->m_linkInstance->hasFlag(Node::NF_NO_EDIT) && $this->m_linkInstance->allowed('edit')) {
                     $localPkAttr = $this->getOwnerInstance()->getAttribute($this->getOwnerInstance()->primaryKeyField());
                     $localValue = $localPkAttr->value2db($record);
                     $remotePkAttr = $this->getDestination()->getAttribute($this->getDestination()->primaryKeyField());
                     $remoteValue = $remotePkAttr->value2db($recordset[$i]);
                     $selector = $this->m_linkInstance->m_table . '.' . $this->getLocalKey() . '=' . $localValue . '' . ' AND ' . $this->m_linkInstance->m_table . '.' . $this->getRemoteKey() . "='" . $remoteValue . "'";
                     $detailLink = Tools::href(Tools::dispatch_url($this->m_link, 'edit', array('atkselector' => $selector)), '[' . Tools::atktext('edit', 'atk') . ']', SessionManager::SESSION_NESTED, true);
                 }
             }
             if (count($this->m_onchangecode)) {
                 $onchange = ' onChange="' . $inputId . '_onChange(this);"';
                 $this->_renderChangeHandler($fieldprefix, '_' . $i);
             }
             $value = $recordset[$i][$this->m_destInstance->primaryKeyField()];
             $css = $this->getCSSClassAttribute('atkcheckbox');
             $label = $this->m_destInstance->descriptor($recordset[$i]);
             $result .= '<div>';
             $result .= '  <input type="checkbox" id="' . $inputId . '" name="' . $this->getHtmlName($fieldprefix) . '[][' . $this->getRemoteKey() . ']" value="' . $value . '" ' . $css . ' ' . $sel . $onchange . ' />';
             $result .= '  <label for="' . $inputId . '">' . $label . '</label>';
             if ($detailLink != '') {
                 $result .= ' ' . $detailLink;
             }
             $result .= '</div>';
         }
         $result .= '</div>';
     } else {
         $nodename = $this->m_destInstance->m_type;
         $modulename = $this->m_destInstance->m_module;
         $result .= Tools::atktext('select_none', $modulename, $nodename) . ' ';
     }
     if ($this->hasFlag(self::AF_MANYBOOL_AUTOLINK) && $this->m_destInstance->allowed('add')) {
         $result .= Tools::href(Tools::dispatch_url($this->m_destination, 'add'), $this->getAddLabel(), SessionManager::SESSION_NESTED) . "\n";
     }
     return $result;
 }
Exemplo n.º 3
0
 public function registerScriptsAndStyles($fieldprefix)
 {
     $htmlId = $this->getHtmlId($fieldprefix) . '_group';
     $page = Page::getInstance();
     $base = Config::getGlobal('assets_url') . 'lib/bootstrap-colorpicker/dist/';
     $page->register_script($base . 'js/bootstrap-colorpicker.min.js');
     $page->register_style($base . 'css/bootstrap-colorpicker.min.css');
     $opts = json_encode($this->colorPickerOptions);
     $page->register_scriptcode("\n            jQuery(function(\$){\n                \$('#{$htmlId}').colorpicker({$opts});\n            });");
 }
Exemplo n.º 4
0
 public function registerScriptsAndStyles($fieldprefix)
 {
     $htmlId = $this->getHtmlId($fieldprefix);
     $page = Page::getInstance();
     $base = Config::getGlobal('assets_url') . 'lib/bootstrap-switch/';
     $page->register_script($base . 'js/bootstrap-switch.min.js');
     $page->register_style($base . 'css/bootstrap3/bootstrap-switch.min.css');
     $opts = json_encode($this->switchOptions);
     $page->register_loadscript("\n            jQuery(function(\$){\n                \$('#{$htmlId}').bootstrapSwitch({$opts});\n            });");
 }
Exemplo n.º 5
0
 /**
  * Constructor
  * @param $atk Atk
  *
  * @return IndexPage
  */
 public function __construct(Atk $atk)
 {
     global $ATK_VARS;
     $this->atk = $atk;
     $this->m_page = Page::getInstance();
     $this->m_ui = Ui::getInstance();
     $this->m_output = Output::getInstance();
     $this->m_user = SecurityManager::atkGetUser();
     $this->m_flags = array_key_exists('atkpartial', $ATK_VARS) ? Page::HTML_PARTIAL : Page::HTML_STRICT;
 }
Exemplo n.º 6
0
 public function edit($record, $fieldprefix, $mode)
 {
     $page = Page::getInstance();
     $id = $this->getHtmlId($fieldprefix);
     $master = $fieldprefix . $this->m_masterattribute;
     $page->register_scriptcode("function {$id}_ReloadTextDiv()\n                                  {\n                                    var NewText = document.getElementById('{$master}').value;\n                                    var DivElement = document.getElementById('{$id}_preview');\n                                    " . ($this->hasFlag(self::AF_LIVETEXT_NL2BR) ? "NewText = NewText.split(/\\n/).join('<br />');" : '') . '
                                 DivElement.innerHTML = NewText;
                               }                                                                    
                               ');
     $page->register_loadscript("document.entryform.{$this->m_masterattribute}.onkeyup = {$id}_ReloadTextDiv;");
     return '<span id="' . $id . '_preview">' . $record[$this->m_masterattribute] . '</span>';
 }
Exemplo n.º 7
0
 /**
  * Creates a session aware button.
  *
  * @param string $text the self::text to display on the button
  * @param string $url the url to use for the button
  * @param int $sessionstatus the session flags
  *                              (SessionManager::SESSION_DEFAULT (default)|SessionManager::SESSION_NEW|SessionManager::SESSION_REPLACE|
  *                              SessionManager::SESSION_NESTED|SessionManager::SESSION_BACK)
  * @param string $cssclass the css class the button should get
  * @param bool $embeded wether or not it's an embedded button
  *
  * @return string html button
  */
 public static function atkButton($text, $url = '', $sessionstatus = SessionManager::SESSION_DEFAULT, $embedded = true, $cssclass = '')
 {
     $sm = SessionManager::getInstance();
     $page = Page::getInstance();
     $page->register_script(Config::getGlobal('assets_url') . 'javascript/formsubmit.js');
     static $cnt = 0;
     if ($cssclass == '') {
         $cssclass = 'btn btn-default';
     }
     $cssclass = ' class="' . $cssclass . '"';
     $script = 'atkSubmit("' . self::atkurlencode($sm->sessionUrl($url, $sessionstatus)) . '")';
     $button = '<input type="button" name="atkbtn' . ++$cnt . '" value="' . $text . '" onClick=\'' . $script . '\'' . $cssclass . '>';
     if (!$embedded) {
         $res = '<form name="entryform">';
         $res .= $sm->formState();
         $res .= $button . '</form>';
         return $res;
     } else {
         return $button;
     }
 }
Exemplo n.º 8
0
 /**
  * Display values.
  *
  * @param array $record Array with fields
  * @param string $mode
  *
  * @return string Filename or Nothing
  */
 public function display($record, $mode)
 {
     // Get random number to use as param when displaying images
     // while updating images was not allways visible due to caching
     $randval = mt_rand();
     $filename = isset($record[$this->fieldName()]['filename']) ? $record[$this->fieldName()]['filename'] : null;
     Tools::atkdebug($this->fieldName() . " - File: {$filename}");
     $prev_type = array('jpg', 'jpeg', 'gif', 'tif', 'png', 'bmp', 'htm', 'html', 'txt');
     // file types for preview
     $imgtype_prev = array('jpg', 'jpeg', 'gif', 'png');
     // types which are supported by GetImageSize
     if ($filename != '') {
         if (is_file($this->m_dir . $filename)) {
             $ext = $this->getFileExtension($filename);
             if (in_array($ext, $prev_type) && $this->hasFlag(self::AF_FILE_NO_AUTOPREVIEW) || !in_array($ext, $prev_type)) {
                 return '<a href="' . $this->m_url . "{$filename}\" target=\"_blank\">{$filename}</a>";
             } elseif (in_array($ext, $prev_type) && $this->hasFlag(self::AF_FILE_POPUP)) {
                 if (in_array($ext, $imgtype_prev)) {
                     $imagehw = getimagesize($this->m_dir . $filename);
                 } else {
                     $imagehw = array('0' => '640', '1' => '480');
                 }
                 $page = Page::getInstance();
                 $page->register_script(Config::getGlobal('assets_url') . 'javascript/newwindow.js');
                 return '<a href="' . $this->m_url . $filename . '" alt="' . $filename . '" onclick="NewWindow(this.href,\'name\',\'' . ($imagehw[0] + 50) . '\',\'' . ($imagehw[1] + 50) . '\',\'yes\');return false;">' . $filename . '</a>';
             }
             return '<img src="' . $this->m_url . $filename . '?b=' . $randval . '" alt="' . $filename . '">';
         } else {
             return $filename . '(<font color="#ff0000">' . Tools::atktext('file_not_exist', 'atk') . '</font>)';
         }
     }
 }
Exemplo n.º 9
0
 public function edit($record, $fieldprefix, $mode)
 {
     $page = Page::getInstance();
     $page->register_script(Config::getGlobal('assets_url') . 'javascript/tools.js');
     $page->register_script(Config::getGlobal('assets_url') . 'javascript/class.atkonetomanyrelation.js');
     $grid = $this->createGrid($record, 'admin', $mode);
     $params = [];
     if ($this->m_useFilterForEditLink && $this->m_destinationFilter != '') {
         $params['atkfilter'] = $this->m_destinationFilter;
     }
     if ($mode === 'add') {
         //All actions in the grid should be done in session store mode
         $params['atkstore'] = 'session';
         $params['atkstore_key'] = $this->getSessionStoreKey();
         // Make the grid use the OTM Session Grid Handler
         // which makes the grid get it's records from the session.
         $handler = new OneToManyRelationSessionGridHandler($this->getSessionStoreKey());
         $grid->setCountHandler(array($handler, 'countHandlerForAdd'));
         $grid->setSelectHandler(array($handler, 'selectHandlerForAdd'));
         // No searching and sorting on session data... for now...
         $grid->removeFlag(DataGrid::SEARCH);
         $grid->removeFlag(DataGrid::SORT);
         $grid->removeFlag(DataGrid::EXTENDED_SORT);
     }
     $actions = $this->m_destInstance->defaultActions('relation', $params);
     $grid->setDefaultActions($actions);
     $grid->loadRecords();
     // force early load of records
     if ($mode === 'edit') {
         $usesIndex = $grid->getIndex() != null;
         $isSearching = is_array($grid->getPostvar('atksearch')) && count($grid->getPostvar('atksearch')) > 0;
         if ($grid->getCount() == 0 && ($usesIndex || $isSearching)) {
             $grid->setComponentOption('list', 'alwaysShowGrid', true);
         }
     }
     $output = $this->editHeader($record, $grid->getRecords()) . $grid->render() . $this->editFooter($record, $grid->getRecords());
     if ($this->m_destInstance->allowed('add')) {
         $this->_addAddToEditOutput($output, $grid->getRecords(), $record, $mode, $fieldprefix);
     }
     return $output;
 }
Exemplo n.º 10
0
 /**
  * Render the console.
  *
  * @return string The HTML code
  */
 public function renderConsole()
 {
     $page = Page::getInstance();
     $data = $this->getDebuggerData(false, $_REQUEST['atkstackid']);
     $res = $this->consoleControls() . '<br/><br/>';
     switch ($_REQUEST['action']) {
         case 'query':
             $res .= $this->queryDetails($data['queries'], $_REQUEST['query_id']);
             break;
         case 'statement':
             $res .= $this->statementDetails($data['statements'], $_REQUEST['stmt_id']);
             break;
         default:
             $res .= $this->renderQueryList($data['queries']);
             $res .= $this->renderStatementList($data['statements']);
     }
     $page->addContent($res);
     return $page->render('Console');
 }
Exemplo n.º 11
0
 /**
  * Gets the cache of the recordlist and registers the appropriate javascript.
  *
  * @return string The cached recordlist
  */
 public function getCache()
 {
     $output = false;
     $this->_setCacheId();
     if (file_exists($this->m_cacheid) && filesize($this->m_cacheid) && !$this->noCaching()) {
         $page = Page::getInstance();
         $page->register_script(Config::getGlobal('assets_url') . 'javascript/formselect.js');
         $page->register_script(Config::getGlobal('assets_url') . 'javascript/recordlist.js');
         /*
          * RecordlistCache must call Tools::getUniqueId() too, or the counter will be off.
          */
         Tools::getUniqueId('normalRecordList');
         $sm = SessionManager::getInstance();
         $stackID = $sm->atkStackID();
         $page->register_loadscript(str_replace('*|REPLACESTACKID|*', $stackID, file_get_contents($this->m_cacheid . '_actionloader')));
         $output = str_replace('*|REPLACESTACKID|*', $stackID, file_get_contents($this->m_cacheid));
     }
     return $output;
 }
Exemplo n.º 12
0
 /**
  * Creates and returns the auto edit/view links.
  *
  * @param string $id The field html id
  * @param string $name The field html name
  * @param string $filter Filter that we want to apply on the destination node
  *
  * @return array The HTML code for the autolink links
  */
 public function getRelationAutolink($id, $name, $filter)
 {
     $autolink = [];
     if ($this->hasFlag(self::AF_RELATION_AUTOLINK)) {
         // auto edit/view link
         $page = Page::getInstance();
         $page->register_script(Config::getGlobal('assets_url') . 'javascript/class.atkmanytoonerelation.js');
         $sm = SessionManager::getInstance();
         if ($this->m_destInstance->allowed('edit')) {
             $editlink = $sm->sessionUrl(Tools::dispatch_url($this->getAutoLinkDestination(), 'edit', array('atkselector' => 'REPLACEME')), SessionManager::SESSION_NESTED);
             $autolink['edit'] = "<a href='javascript:atkSubmit(mto_parse(\"" . Tools::atkurlencode($editlink) . '", document.entryform.' . $id . ".value),true)' class='atkmanytoonerelation atkmanytoonerelation-link'>" . Tools::atktext('edit') . '</a>';
         }
         if ($this->m_destInstance->allowed('add')) {
             $autolink['add'] = ' ' . Tools::href(Tools::dispatch_url($this->getAutoLinkDestination(), 'add', array('atkpkret' => $name, 'atkfilter' => $this->m_useFilterForAddLink && $filter != '' ? $filter : '')), Tools::atktext('new'), SessionManager::SESSION_NESTED, true, 'class="atkmanytoonerelation atkmanytoonerelation-link"');
         }
     }
     return $autolink;
 }
Exemplo n.º 13
0
 /**
  * Returns a piece of html code that can be used in a form to edit this
  * attribute's value.
  *
  * @param array $record Array with fields
  * @param string $fieldprefix The fieldprefix to put in front of the name
  *                            of any html form element for this attribute.
  * @param string $mode The mode we're in ('add' or 'edit')
  *
  * @return string piece of html code with radioboxes
  */
 public function edit($record, $fieldprefix, $mode)
 {
     $id = $this->getHtmlId($fieldprefix);
     $name = $this->getHtmlName($fieldprefix);
     $page = Page::getInstance();
     $page->register_script(Config::getGlobal('assets_url') . 'javascript/class.atkprofileattribute.js');
     $result = '';
     if (!$this->hasFlag(self::AF_LINKS_BOTTOM)) {
         $result .= $this->_addLinks($fieldprefix);
     }
     $css = $this->getCSSClassAttribute('');
     $result .= '<div ' . $css . '>';
     $values = $this->getValues();
     if (!is_array($record[$this->fieldName()])) {
         $recordvalue = $this->db2value($record);
     } else {
         $recordvalue = $record[$this->fieldName()];
     }
     for ($i = 0; $i < count($values); ++$i) {
         $checkId = $id . '_' . $i;
         $checkName = $name . '[]';
         if (!$this->hasFlag(self::AF_CHECK_ALL)) {
             $sel = Tools::atk_in_array($values[$i], $recordvalue) ? 'checked' : '';
         } else {
             $sel = 'checked';
         }
         $result .= '<div>';
         $result .= '<input type="checkbox" id="' . $checkId . '" name="' . $checkName . '" value="' . $values[$i] . '" ' . $sel . '> ';
         $result .= $this->_translateValue($values[$i], $record);
         $result .= '</div>';
     }
     $result .= '</div>';
     if ($this->hasFlag(self::AF_LINKS_BOTTOM)) {
         $result .= $this->_addLinks($fieldprefix);
     }
     return $result;
 }
Exemplo n.º 14
0
 /**
  * Returns a piece of html code that can be used in a form to edit this
  * attribute's value.
  *
  * @param array $record Array with values
  * @param string $fieldprefix The attribute must use this to prefix its form elements (used for
  *                            embedded forms)
  * @param string $mode The mode we're in ('add' or 'edit')
  *
  * @return string Piece of htmlcode
  */
 public function edit($record, $fieldprefix, $mode)
 {
     $id = $this->getHtmlId($fieldprefix);
     $name = $this->getHtmlName($fieldprefix);
     if (count($this->m_onchangecode)) {
         $onchange = 'onChange="' . $id . '_onChange(this);"';
         $this->_renderChangeHandler($fieldprefix);
     } else {
         $onchange = '';
     }
     $size = $this->m_size;
     $maxsize = $this->m_maxsize;
     if ($this->getDecimals() > 0) {
         $size += $this->getDecimals() + 1;
         $maxsize += $this->getDecimals() + 1;
         // make room for the number of decimals
         // TODO we should also consider the sign symbol (for signed type)
     }
     $value = '';
     if (isset($record[$this->fieldName()]) && strlen($record[$this->fieldName()]) > 0) {
         $value = $this->formatNumber($record[$this->fieldName()], '', '', $mode);
     }
     $class = $this->getCSSClassAttribute(['form-control']);
     $result = '<input type="text" id="' . $id . '" ' . $class . ' name="' . $name . '" value="' . $value . '"' . ($size > 0 ? ' size="' . $size . '"' : '') . ($maxsize > 0 ? ' maxlength="' . $maxsize . '"' : '') . ' ' . $onchange . ' />';
     if (is_array($this->touchspin)) {
         $page = Page::getInstance();
         $base = Config::getGlobal('assets_url') . 'lib/bootstrap-touchspin/';
         $page->register_script($base . 'jquery.bootstrap-touchspin.min.js');
         $page->register_style($base . 'jquery.bootstrap-touchspin.min.css');
         $opts = json_encode($this->touchspin);
         $page->register_loadscript("\n                jQuery(function(\$){\n                    \$('#{$id}').TouchSpin({$opts});\n                });");
     }
     return $result;
 }
Exemplo n.º 15
0
 /**
  * Registers the scripts and styles for the date attribute. Can be used
  * to load the scripts beforehand from another location.
  *
  * @param bool $useCalendar use calendar widget? (defaults to true)
  */
 public static function registerScriptsAndStyles($useCalendar = true)
 {
     $page = Page::getInstance();
     // make sure we register the script code with translations for the months etc. only once!
     if (!self::$s_baseScriptsRegistered) {
         self::$s_baseScriptsRegistered = true;
         $m_months_short = array(1 => 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec');
         $m_months_long = array(1 => 'january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december');
         $m_weekdays_long = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
         $m_weekdays_short = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
         foreach ($m_months_short as &$m) {
             $m = Tools::atktext($m, 'atk');
         }
         foreach ($m_months_long as &$m) {
             $m = Tools::atktext($m, 'atk');
         }
         foreach ($m_weekdays_long as &$m) {
             $m = Tools::atktext($m, 'atk');
         }
         foreach ($m_weekdays_short as &$m) {
             $m = Tools::atktext($m, 'atk');
         }
         $page->register_scriptcode('
       var m_months_long    = Array("' . implode('","', $m_months_long) . '");
       var m_months_short   = Array("' . implode('","', $m_months_short) . '");
       var m_weekdays_long  = Array("' . implode('","', $m_weekdays_long) . '");
       var m_weekdays_short = Array("' . implode('","', $m_weekdays_short) . '");
     ', true);
         $page->register_script(Config::getGlobal('assets_url') . 'javascript/class.atkdateattribute.js');
     }
     if ($useCalendar) {
         $page->register_script(Config::getGlobal('assets_url') . 'javascript/calendar/calendar.js');
         $page->register_script(Config::getGlobal('assets_url') . 'javascript/calendar/calendar-runner.js');
         $page->register_script(Config::getGlobal('assets_url') . 'javascript/calendar/lang/calendar-' . Config::getGlobal('language') . '.js');
     }
 }
Exemplo n.º 16
0
 /**
  * Get the page instance of the page on which the node can render output.
  *
  * @return Page The page instance.
  */
 public function getPage()
 {
     $page = Page::getInstance();
     return $page;
 }
Exemplo n.º 17
0
 /**
  * Renders the onchange code on the page.
  *
  * @param string $fieldprefix The prefix to the field
  * @param string $elementNr The number of the element when attribute contains multiple options
  */
 public function _renderChangeHandler($fieldprefix, $elementNr = '')
 {
     if (count($this->m_onchangecode)) {
         $page = Page::getInstance();
         $page->register_scriptcode('
 function ' . $this->getHtmlId($fieldprefix) . $elementNr . "_onChange(el)\n    {\n      {$this->m_onchangehandler_init}\n      " . implode("\n      ", $this->m_onchangecode) . "\n    }\n");
     }
 }
Exemplo n.º 18
0
 /**
  * Display values.
  *
  * @param array $record Array with fields
  * @param string $mode
  *
  * @return string html
  */
 public function display($record, $mode)
 {
     $files = explode($this->m_delimiter, $record[$this->fieldName()]['orgfilename']);
     $prev_type = array('jpg', 'jpeg', 'gif', 'tif', 'png', 'bmp', 'htm', 'html', 'txt');
     // file types for preview
     $imgtype_prev = array('jpg', 'jpeg', 'gif', 'png');
     // types whitch are supported by GetImageSize
     $r = '';
     for ($i = 0; $i < count($files); ++$i) {
         if (is_file($this->m_dir . $files[$i])) {
             $ext = strtolower(substr($files[$i], strrpos($files[$i], '.') + 1, strlen($files[$i])));
             if (in_array($ext, $prev_type)) {
                 if (in_array($ext, $imgtype_prev)) {
                     $imagehw = getimagesize($this->m_dir . $files[$i]);
                 } else {
                     $imagehw = array('0' => '640', '1' => '480');
                 }
                 $page = Page::getInstance();
                 $page->register_script(Config::getGlobal('assets_url') . 'javascript/newwindow.js');
                 $r .= '<a href="' . $this->m_url . $files[$i] . '" alt="' . $files[$i] . '" onclick="NewWindow(this.href,\'name\',\'' . ($imagehw[0] + 50) . '\',\'' . ($imagehw[1] + 50) . '\',\'yes\');return false;">' . $files[$i] . '</a><br>';
             } else {
                 $r .= '<a href="' . $this->m_url . "{$files[$i]}\" target=\"_new\">{$files[$i]}</a><br>";
             }
         } else {
             if (strlen($files[$i]) > 0) {
                 $r .= $files[$i] . '(<font color="#ff0000">' . Tools::atktext('file_not_exist') . '</font><br>)';
             }
         }
     }
     return $r;
 }
Exemplo n.º 19
0
 /**
  * Display a login form.
  *
  * @param string $defaultname The username that might already be known
  * @param int $lastresponse The lastresponse when trying to login
  *                             possible values:
  *                             SecurityManager::AUTH_MISMATCH,
  *                             SecurityManager::AUTH_LOCKED,
  *                             SecurityManager::AUTH_MISSINGUSERNAME,
  *                             SecurityManager::AUTH_PASSWORDSENT
  */
 public function loginForm($defaultname, $lastresponse)
 {
     $page = Page::getInstance();
     $ui = Ui::getInstance();
     $page->register_script(Config::getGlobal('assets_url') . 'javascript/tools.js');
     $tplvars = [];
     $output = '<form action="' . Config::getGlobal('dispatcher') . '" method="post">';
     $output .= Tools::makeHiddenPostvars(array('atklogout'));
     $output .= '<br><br><table border="0" cellspacing="2" cellpadding="0" align="center">';
     $tplvars['atksessionformvars'] = Tools::makeHiddenPostvars(['atklogout', 'auth_rememberme']);
     $tplvars['formurl'] = Config::getGlobal('dispatcher');
     $tplvars['username'] = Tools::atktext('username');
     $tplvars['password'] = Tools::atktext('password');
     $tplvars['userfield'] = '<input class="form-control loginform" type="text" size="20" id="auth_user" name="auth_user" value="' . htmlentities($defaultname) . '" />';
     $tplvars['passwordfield'] = '<input class="loginform" type="password" size="20" name="auth_pw" value="" />';
     $tplvars['submitbutton'] = '<input name="login" class="button" type="submit" value="' . Tools::atktext('login') . '" />';
     $tplvars['title'] = Tools::atktext('login_form');
     if ($lastresponse == self::AUTH_LOCKED) {
         $output .= '<tr><td colspan=3 class=error>' . Tools::atktext('auth_account_locked') . '<br><br></td></tr>';
         $tplvars['auth_account_locked'] = Tools::atktext('auth_account_locked');
         $tplvars['error'] = Tools::atktext('auth_account_locked');
     } elseif ($lastresponse == self::AUTH_MISMATCH) {
         $output .= '<tr><td colspan=3 class=error>' . Tools::atktext('auth_mismatch') . '<br><br></td></tr>';
         $tplvars['auth_mismatch'] = Tools::atktext('auth_mismatch');
         $tplvars['error'] = Tools::atktext('auth_mismatch');
     } elseif ($lastresponse == self::AUTH_MISSINGUSERNAME) {
         $output .= '<tr><td colspan="3" class=error>' . Tools::atktext('auth_missingusername') . '<br /><br /></td></tr>';
         $tplvars['auth_mismatch'] = Tools::atktext('auth_missingusername');
         $tplvars['error'] = Tools::atktext('auth_missingusername');
     } elseif ($lastresponse == self::AUTH_PASSWORDSENT) {
         $output .= '<tr><td colspan="3">' . Tools::atktext('auth_passwordmail_sent') . '<br /><br /></td></tr>';
         $tplvars['auth_mismatch'] = Tools::atktext('auth_passwordmail_sent');
     }
     if (Config::getGlobal('auth_enable_rememberme')) {
         $tplvars['auth_enable_rememberme'] = true;
         if (isset($_POST['auth_rememberme']) && $_POST['auth_rememberme'] == '1') {
             $tplvars['auth_rememberme'] = true;
         }
     }
     // generate the form
     $output .= '<tr><td valign=top>' . Tools::atktext('username') . '</td><td>:</td><td>' . $tplvars['userfield'] . '</td></tr>';
     $output .= '<tr><td colspan=3 height=6></td></tr>';
     $output .= '<tr><td valign=top>' . Tools::atktext('password') . "</td><td>:</td><td><input type=password size=15 name=auth_pw value='' /></td></tr>";
     $output .= '<tr><td colspan="3" align="center" height="50" valign="middle">';
     $output .= '<input name="login" class="button" type="submit" value="' . Tools::atktext('login') . '">';
     $tplvars['auth_enablepasswordmailer'] = $this->get_enablepasswordmailer();
     if ($this->get_enablepasswordmailer()) {
         $output .= '&nbsp;&nbsp;<input name="login" class="button" type="submit" value="' . Tools::atktext('password_forgotten') . '">';
         $tplvars['forgotpasswordbutton'] = '<input name="login" class="button" type="submit" value="' . Tools::atktext('password_forgotten') . '">';
     }
     $output .= '</td></tr>';
     $output .= '</table></form>';
     $tplvars['content'] = $output;
     $page->addContent($ui->render('login.tpl', $tplvars));
     $o = Output::getInstance();
     $o->output($page->render(Tools::atktext('app_title'), Page::HTML_STRICT, '', $ui->render('login_meta.tpl')));
 }
Exemplo n.º 20
0
 /**
  * Renders a tabulated template
  * Registers some scriptcode for dhtml tab.
  *
  * @param array $vars the variables with which to render the template
  * @param string $module the name of the module requesting to render a template
  *
  * @return string the rendered template
  */
 public function renderTabs($vars, $module = '')
 {
     $page = Page::getInstance();
     $page->register_script(Config::getGlobal('assets_url') . 'javascript/tools.js');
     return $this->render('tabs.tpl', $vars, $module);
 }
Exemplo n.º 21
0
 /**
  * Restore divs states.
  *
  * @param Page $page
  */
 public function _restoreDivStates($page)
 {
     $postvars = $this->m_ownerInstance->m_postvars;
     if (!isset($postvars['divstate']) || !is_array($postvars['divstate']) || sizeof($postvars['divstate']) == 0) {
         return;
     }
     $divstate = $postvars['divstate'];
     $onLoadScript = '';
     foreach ($divstate as $key => $value) {
         $key = substr($key, 2, -2);
         if ($value == 'opened') {
             $onLoadScript .= "profile_swapProfileDiv('{$key}');";
         }
     }
     $page->register_loadscript($onLoadScript);
 }