function memoryUsage($base_memory_usage) { printf("Bytes diff: %s<br />\n", getSimpleFileSize(memory_get_usage() - $base_memory_usage)); }
/** * show page with load info * s * @param int $id * @return none */ public function view($id = null) { //turn access $this->ACL->turn(array($this->module, 'view_materials')); $id = intval($id); if (empty($id) || $id < 1) { redirect('/'); } $this->Model->bindModel('attaches'); $this->Model->bindModel('author'); $this->Model->bindModel('category'); $entity = $this->Model->getById($id); if (empty($entity)) { $this->Parser->showHttpError(); } if ($entity->getAvailable() == 0 && !$this->ACL->turn(array('other', 'can_see_hidden'), false)) { return $this->showInfoMessage(__('Permission denied'), '/' . $this->module . '/'); } if (!$this->ACL->checkCategoryAccess($entity->getCategory()->getNo_access())) { return $this->showInfoMessage(__('Permission denied'), '/' . $this->module . '/'); } // Some gemor with add fields if (is_object($this->AddFields)) { $entity = $this->AddFields->mergeRecords(array($entity)); $entity = $entity[0]; } $max_attaches = $this->Register['Config']->read('max_attaches', $this->module); if (empty($max_attaches) || !is_numeric($max_attaches)) { $max_attaches = 5; } //category block $this->_getCatsTree($entity->getCategory()->getId()); /* COMMENT BLOCK */ if (Config::read('comment_active', $this->module) == 1 && $this->ACL->turn(array($this->module, 'view_comments'), false) && $entity->getCommented() == 1) { if ($this->ACL->turn(array($this->module, 'add_comments'), false)) { $this->comments_form = $this->_add_comment_form($id); } $this->comments = $this->_get_comments($entity); } $this->Register['current_vars'] = $entity; $this->addToPageMetaContext('category_title', h($entity->getCategory()->getTitle())); $this->addToPageMetaContext('entity_title', h($entity->getTitle())); $tags = $entity->getTags(); $description = $entity->getDescription(); if (!empty($tags)) { $this->page_meta_keywords = h($tags); } if (!empty($description)) { $this->page_meta_description = h($description); } $navi = array(); $navi['module_url'] = get_url('/' . $this->module . '/'); $navi['category_url'] = get_url('/' . $this->module . '/category/' . $entity->getCategory()->getId()); $navi['category_name'] = h($entity->getCategory()->getTitle()); $navi['navigation'] = $this->_buildBreadCrumbs($entity->getCategory()->getId()); $this->_globalize($navi); $markers = array(); $markers['moder_panel'] = $this->_getAdminBar($entity); if ($entity->getDownload() && is_file(ROOT . '/sys/files/' . $this->module . '/' . $entity->getDownload())) { $attach_serv = '<a target="_blank" href="' . get_url('/' . $this->module . '/download_file/' . $entity->getId()) . '">' . __('Download from server') . ' (' . getFileSize(ROOT . '/sys/files/' . $this->module . '/' . $entity->getDownload()) . ' Кб)</a>'; } else { if ($entity->getDownload() && !is_file(ROOT . '/sys/files/' . $this->module . '/' . $entity->getDownload())) { $attach_serv = '<span style="color:red;" class="atm-lost-file">' . __('File is deleted or damaged') . '</span>'; } else { $attach_serv = ''; } } if ($entity->getDownload_url_size()) { $attach_rem_size = ' (' . getSimpleFileSize($entity->getDownload_url_size()) . ')'; } else { $attach_rem_size = ''; } if ($entity->getDownload_url()) { $attach_rem_url = '<a target="_blank" href="' . get_url('/' . $this->module . '/download_file_url/' . $entity->getId()) . '">' . __('Download remotely') . $attach_rem_size . '</a>'; } else { $attach_rem_url = ''; } $markers['attachment'] = $attach_serv . ' | ' . $attach_rem_url; $announce = $this->Textarier->parseBBCodes($entity->getMain(), $entity); $markers['mainText'] = $announce; $markers['main_text'] = $announce; $entry_url = entryUrl($entity, $this->module); $markers['entry_url'] = $entry_url; $markers['profile_url'] = getProfileUrl($entity->getAuthor_id()); $entity->setAdd_markers($markers); if ($entity->getTags()) { $entity->setTags(explode(',', $entity->getTags())); } $source = $this->render('material.html', array('entity' => $entity)); $entity->setViews($entity->getViews() + 1); $entity->save(); $this->DB->cleanSqlCache(); return $this->_view($source); }