getActions() public static method

Get all the actions
public static getActions ( ) : array
return array
Exemplo n.º 1
0
 /**
  * Get an unique URL for a page
  *
  * @param string $URL      The URL to base on.
  * @param int    $id       The id to ignore.
  * @param int    $parentId The parent for the page to create an url for.
  * @param bool   $isAction Is this page an action.
  * @return string
  */
 public static function getURL($URL, $id = null, $parentId = 0, $isAction = false)
 {
     $URL = (string) $URL;
     $parentIds = array((int) $parentId);
     // 0, 1, 2, 3, 4 are all top levels, so we should place them on the same level
     if ($parentId == 0 || $parentId == 1 || $parentId == 2 || $parentId == 3 || $parentId == 4) {
         $parentIds = array(0, 1, 2, 3, 4);
     }
     // get db
     $db = BackendModel::getContainer()->get('database');
     // no specific id
     if ($id === null) {
         // no items?
         if ((bool) $db->getVar('SELECT 1
              FROM pages AS i
              INNER JOIN meta AS m ON i.meta_id = m.id
              WHERE i.parent_id IN(' . implode(',', $parentIds) . ') AND i.status = ? AND m.url = ?
                 AND i.language = ?
              LIMIT 1', array('active', $URL, BL::getWorkingLanguage()))) {
             // add a number
             $URL = BackendModel::addNumber($URL);
             // recall this method, but with a new URL
             return self::getURL($URL, null, $parentId, $isAction);
         }
     } else {
         // one item should be ignored
         // there are items so, call this method again.
         if ((bool) $db->getVar('SELECT 1
              FROM pages AS i
              INNER JOIN meta AS m ON i.meta_id = m.id
              WHERE i.parent_id IN(' . implode(',', $parentIds) . ') AND i.status = ?
                 AND m.url = ? AND i.id != ? AND i.language = ?
              LIMIT 1', array('active', $URL, $id, BL::getWorkingLanguage()))) {
             // add a number
             $URL = BackendModel::addNumber($URL);
             // recall this method, but with a new URL
             return self::getURL($URL, $id, $parentId, $isAction);
         }
     }
     // get full URL
     $fullURL = self::getFullUrl($parentId) . '/' . $URL;
     // get info about parent page
     $parentPageInfo = self::get($parentId, null, BL::getWorkingLanguage());
     // does the parent have extras?
     if ($parentPageInfo['has_extra'] == 'Y' && !$isAction) {
         // set locale
         FrontendLanguage::setLocale(BL::getWorkingLanguage(), true);
         // get all on-site action
         $actions = FrontendLanguage::getActions();
         // if the new URL conflicts with an action we should rebuild the URL
         if (in_array($URL, $actions)) {
             // add a number
             $URL = BackendModel::addNumber($URL);
             // recall this method, but with a new URL
             return self::getURL($URL, $id, $parentId, $isAction);
         }
     }
     // check if folder exists
     if (is_dir(PATH_WWW . '/' . $fullURL) || is_file(PATH_WWW . '/' . $fullURL)) {
         // add a number
         $URL = BackendModel::addNumber($URL);
         // recall this method, but with a new URL
         return self::getURL($URL, $id, $parentId, $isAction);
     }
     // check if it is an application
     if (in_array(trim($fullURL, '/'), array_keys(\ApplicationRouting::getRoutes()))) {
         // add a number
         $URL = BackendModel::addNumber($URL);
         // recall this method, but with a new URL
         return self::getURL($URL, $id, $parentId, $isAction);
     }
     // return the unique URL!
     return $URL;
 }