예제 #1
0
 private function getSectionLimit()
 {
     $extman = Symphony::ExtensionManager();
     // limit section entries
     $status = $extman->fetchStatus(array('handle' => 'limit_section_entries', 'version' => '1'));
     if (in_array(EXTENSION_ENABLED, $status)) {
         require_once EXTENSIONS . '/limit_section_entries/lib/class.LSE.php';
         $limit = LSE::getMaxEntries();
         $total = LSE::getTotalEntries();
         return array('limit' => $limit, 'total' => $total);
     }
     return FALSE;
 }
 public function dInitaliseAdminPageHead()
 {
     $callback = Administration::instance()->getPageCallback();
     $this->_enabled = $this->_enable($callback);
     if (!$this->_enabled) {
         return false;
     }
     $this->_section = LSE::getSection($callback['context']['section_handle']);
     if (is_null($this->_section)) {
         $this->_enabled = false;
         return false;
     }
     $this->_max = LSE::getMaxEntries($this->_section);
     $this->_total = LSE::getTotalEntries($this->_section);
     $entry_id = LSE::getLastEntryID($this->_section);
     $params = $this->_fetchUrlParams();
     $section_handle = $this->_section->get('handle');
     /* Manage redirects */
     // index page
     if ($callback['context']['page'] === 'index') {
         // emulate Static section
         if ($this->_max === 1) {
             // entry exists, proceed to edit page
             if ($this->_total > 0 && is_int($entry_id)) {
                 $this->_redirect(SYMPHONY_URL . "/publish/{$section_handle}/edit/{$entry_id}/{$params}");
             } else {
                 $this->_redirect(SYMPHONY_URL . "/publish/{$section_handle}/new/{$params}");
             }
         }
     } elseif ($callback['context']['page'] === 'new') {
         // only if there is a limit
         if ($this->_max > 0) {
             // if limit exceeded, proceed to index page
             if ($this->_total >= $this->_max) {
                 $this->_redirect(SYMPHONY_URL . "/publish/{$section_handle}/{$params}");
             }
         }
     }
 }