示例#1
0
 public function getSitemapInList()
 {
     global $site;
     $answer = '';
     $answer .= '<ul id="ipSitemap">' . "\n";
     $answer .= '<li><a href="' . BASE_URL . '">Home</a></li>' . "\n";
     $languages = \Frontend\Db::getLanguages(true);
     //get all languages including hidden
     foreach ($languages as $language) {
         $link = $site->generateUrl($language['id']);
         $answer .= '<li><a href="' . $link . '">' . htmlspecialchars($language['d_long']) . ' (' . htmlspecialchars($language['d_short']) . ')</a>' . "\n";
         $zones = $site->getZones();
         if (sizeof($zones) > 0) {
             $answer .= '<ul>';
             foreach ($zones as $key => $zone) {
                 $answer .= '<li><a href="' . $site->generateUrl($language['id'], $zone->getName()) . '">' . $zone->getTitle() . '</a>' . "\n";
                 $answer .= $this->getPagesList($language, $zone);
                 $answer .= '</li>' . "\n";
             }
             $answer .= '</ul>';
         }
         $answer .= '</li>' . "\n";
     }
     $answer .= '<ul>' . "\n";
     $answer = str_replace('?cms_action=manage', '', $answer);
     $answer = str_replace('&cms_action=manage', '', $answer);
     return $answer;
 }
示例#2
0
 /**
  * Generate link to website. Use it with no arguments to get link to main page of current language.
  * 
  * Don't use it to generate link to existing page. To get link to existing page, use method getLink() on Element object. 
  * 
  * @param $languageId
  *   Id of language
  * @param $zoneName
  *   Zone name
  * @param $urlVars
  *   Array of additional url variables. Eg. array('var1', 'var2')
  * @param $getVars
  *   Array of additional get variables. Eg. array('var1'='val1', 'val2'='val2')
  * @return string - requested link or link to first page of current language if all parameters are not specified or null
  */
 public function generateUrl($languageId = null, $zoneName = null, $urlVars = null, $getVars = null)
 {
     global $parametersMod;
     if ($languageId == null) {
         $languageId = $this->currentLanguage['id'];
     }
     /*generates link to first page of current language*/
     // get parameter for cms management
     if (isset($this->getVars['cms_action']) && $this->getVars['cms_action'] == 'manage') {
         if ($getVars == null) {
             $getVars = array('cms_action' => 'manage');
         } else {
             $getVars['cms_action'] = 'manage';
         }
     }
     // get parameter for cms management
     if ($parametersMod->getValue('standard', 'languages', 'options', 'multilingual')) {
         $answer = BASE_URL . urlencode($this->languages[$languageId]['url']) . '/';
     } else {
         $answer = BASE_URL;
     }
     if ($zoneName != null) {
         if ($languageId == $this->currentLanguage['id']) {
             //current language
             if (isset($this->zones[$zoneName])) {
                 $answer .= urlencode($this->zones[$zoneName]['url']) . '/';
             } else {
                 $backtrace = debug_backtrace();
                 if (isset($backtrace[0]['file']) && $backtrace[0]['line']) {
                     trigger_error('Undefined zone ' . $zoneName . ' (Error source: ' . $backtrace[0]['file'] . ' line: ' . $backtrace[0]['line'] . ' ) ');
                 } else {
                     trigger_error('Undefined zone ' . $zoneName);
                 }
                 return '';
             }
         } else {
             if (!isset($this->otherZones[$languageId])) {
                 $this->otherZones[$languageId] = \Frontend\Db::getZones($languageId);
             }
             if (isset($this->otherZones[$languageId])) {
                 $answer .= urlencode($this->otherZones[$languageId][$zoneName]['url']) . '/';
             } else {
                 $backtrace = debug_backtrace();
                 if (isset($backtrace[0]['file']) && $backtrace[0]['line']) {
                     trigger_error('Undefined zone ' . $zoneName . ' (Error source: ' . $backtrace[0]['file'] . ' line: ' . $backtrace[0]['line'] . ' ) ');
                 } else {
                     trigger_error('Undefined zone ' . $zoneName);
                 }
                 return '';
             }
         }
     }
     if ($urlVars) {
         foreach ($urlVars as $key => $value) {
             $answer .= urlencode($value) . '/';
         }
     }
     if ($getVars && sizeof($getVars) > 0) {
         $first = true;
         foreach ($getVars as $key => $value) {
             if ($first) {
                 $answer .= '?' . $key . '=' . urlencode($value);
             } else {
                 $answer .= '&amp;' . $key . '=' . urlencode($value);
             }
             $first = false;
         }
     }
     return $answer;
 }
示例#3
0
 public function catchEvent($moduleGroup, $moduleName, $event, $parameters)
 {
     if ($moduleGroup == 'developer' && $moduleName == 'zones' && $event == 'zone_deleted') {
         require_once __DIR__ . '/backend_worker.php';
         $backendWorker = new BackendWorker();
         $languages = Db::languages();
         foreach ($languages as $key => $language) {
             $rootElement = Db::rootMenuElement($parameters['zone_id'], $language['id']);
             global $log;
             $elements = Db::menuElementChildren($rootElement);
             foreach ($elements as $key => $element) {
                 $backendWorker->remove_element($element['id']);
             }
             Db::removeZoneToContent($parameters['zone_id'], $language['id']);
         }
     }
     if ($moduleGroup == 'standard' && $moduleName == 'languages' && $event == 'language_deleted') {
         require_once __DIR__ . '/backend_worker.php';
         $backendWorker = new BackendWorker();
         $zones = \Frontend\Db::getZones($parameters['language_id']);
         foreach ($zones as $key => $zone) {
             $rootElement = Db::rootMenuElement($zone['id'], $parameters['language_id']);
             $elements = Db::menuElementChildren($rootElement);
             foreach ($elements as $key => $element) {
                 $backendWorker->remove_element($element['id']);
             }
             Db::removeZoneToContent($parameters['language_id'], $zone['id']);
         }
     }
     if ($moduleGroup == 'administrator' && $moduleName == 'system' && $event == 'url_change') {
         global $log;
         $tmpModules = Db::menuModules();
         require_once __DIR__ . '/widgets/widget.php';
         foreach ($tmpModules as $groupKey => $group) {
             foreach ($group as $moduleKey => $module) {
                 require_once __DIR__ . '/widgets/' . $module['group_name'] . '/' . $module['module_name'] . '/module.php';
                 eval('$tmpObject = new \\Modules\\standard\\content_management\\Widgets\\' . $module['group_name'] . '\\' . $module['module_name'] . '\\Module();');
                 if (method_exists($tmpObject, 'updateLinks')) {
                     $tmpObject->updateLinks($parameters['old_url'], $parameters['new_url']);
                 }
             }
         }
         $tmpWorker = new BackendWorker();
         $content_elements = Db::getRealElements();
         foreach ($content_elements as $key => $id) {
             $_REQUEST['id'] = $id;
             $tmpWorker->make_html();
         }
         //update text parameters
         $sql = "update `" . DB_PREF . "par_string` set `value` = REPLACE(`value`, '" . mysql_real_escape_string($parameters['old_url']) . "', '" . mysql_real_escape_string($parameters['new_url']) . "') where 1 ";
         $rs = mysql_query($sql);
         if (!$rs) {
             trigger_error($sql . ' ' . mysql_error());
         }
         $sql = "update `" . DB_PREF . "par_lang` set `translation` = REPLACE(`translation`, '" . mysql_real_escape_string($parameters['old_url']) . "', '" . mysql_real_escape_string($parameters['new_url']) . "') where 1 ";
         $rs = mysql_query($sql);
         if (!$rs) {
             trigger_error($sql . ' ' . mysql_error());
         }
         $sql = "update `" . DB_PREF . "content_element` set `redirect_url` = REPLACE(`redirect_url`, '" . mysql_real_escape_string($parameters['old_url']) . "', '" . mysql_real_escape_string($parameters['new_url']) . "') where 1 ";
         $rs = mysql_query($sql);
         if (!$rs) {
             trigger_error($sql . ' ' . mysql_error());
         }
     }
 }
示例#4
0
 public static function createRootZoneElement($language)
 {
     $firstLanguage = \Frontend\Db::getFirstLanguage();
     $zones = \Frontend\Db::getZones($firstLanguage['id']);
     foreach ($zones as $key => $zone) {
         $sql2 = "insert into `" . DB_PREF . "zone_parameter` set\n        language_id = '" . mysql_real_escape_string($language) . "',\n        zone_id = '" . $zone['id'] . "',\n        title = '" . mysql_real_escape_string(Db::newUrl($language, $zone['title'])) . "',\n        url = '" . mysql_real_escape_string(Db::newUrl($language, $zone['url'])) . "'";
         $rs2 = mysql_query($sql2);
         if (!$rs2) {
             trigger_error($sql2 . " " . mysql_error());
         }
     }
 }
示例#5
0
 public static function insertParameter($groupId, $parameter)
 {
     $sql = "insert into `" . DB_PREF . "parameter` \n      set name = '" . mysql_real_escape_string($parameter['name']) . "',\n      admin = '" . mysql_real_escape_string($parameter['admin']) . "',\n      group_id = " . (int) $groupId . ",\n      translation = '" . mysql_real_escape_string($parameter['translation']) . "',\n      type = '" . mysql_real_escape_string($parameter['type']) . "'";
     $rs = mysql_query($sql);
     if ($rs) {
         $last_insert_id = mysql_insert_id();
         switch ($parameter['type']) {
             case "string_wysiwyg":
                 $sql = "insert into `" . DB_PREF . "par_string` set `value` = '" . mysql_real_escape_string($parameter['value']) . "', `parameter_id` = " . $last_insert_id . "";
                 $rs = mysql_query($sql);
                 if (!$rs) {
                     trigger_error("Can't insert parameter " . $sql . " " . mysql_error());
                 }
                 break;
             case "string":
                 $sql = "insert into `" . DB_PREF . "par_string` set `value` = '" . mysql_real_escape_string($parameter['value']) . "', `parameter_id` = " . $last_insert_id . "";
                 $rs = mysql_query($sql);
                 if (!$rs) {
                     trigger_error("Can't insert parameter " . $sql . " " . mysql_error());
                 }
                 break;
             case "integer":
                 $sql = "insert into `" . DB_PREF . "par_integer` set `value` = " . mysql_real_escape_string($parameter['value']) . ", `parameter_id` = " . $last_insert_id . "";
                 $rs = mysql_query($sql);
                 if (!$rs) {
                     trigger_error("Can't insert parameter " . $sql . " " . mysql_error());
                 }
                 break;
             case "bool":
                 $sql = "insert into `" . DB_PREF . "par_bool` set `value` = " . mysql_real_escape_string($parameter['value']) . ", `parameter_id` = " . $last_insert_id . "";
                 $rs = mysql_query($sql);
                 if (!$rs) {
                     trigger_error("Can't insert parameter " . $sql . " " . mysql_error());
                 }
                 break;
             case "textarea":
                 $sql = "insert into `" . DB_PREF . "par_string` set `value` = '" . mysql_real_escape_string($parameter['value']) . "', `parameter_id` = " . $last_insert_id . "";
                 $rs = mysql_query($sql);
                 if (!$rs) {
                     trigger_error("Can't insert parameter " . $sql . " " . mysql_error());
                 }
                 break;
             case "lang":
                 $languages = \Frontend\Db::getLanguages();
                 foreach ($languages as $key => $language) {
                     $sql3 = "insert into `" . DB_PREF . "par_lang` set `translation` = '" . mysql_real_escape_string($parameter['value']) . "', `language_id` = '" . $language['id'] . "', `parameter_id` = " . $last_insert_id . " ";
                     $rs3 = mysql_query($sql3);
                     if (!$rs3) {
                         trigger_error("Can't update parameter " . $sql3 . " " . mysql_error());
                     }
                 }
                 break;
             case "lang_textarea":
                 $languages = \Frontend\Db::getLanguages();
                 foreach ($languages as $key => $language) {
                     $sql3 = "insert into `" . DB_PREF . "par_lang` set `translation` = '" . mysql_real_escape_string($parameter['value']) . "', `language_id` = '" . $language['id'] . "', `parameter_id` = " . $last_insert_id . " ";
                     $rs3 = mysql_query($sql3);
                     if (!$rs3) {
                         trigger_error("Can't update parameter " . $sql3 . " " . mysql_error());
                     }
                 }
                 break;
             case "lang_wysiwyg":
                 $languages = \Frontend\Db::getLanguages();
                 foreach ($languages as $key => $language) {
                     $sql3 = "insert into `" . DB_PREF . "par_lang` set `translation` = '" . mysql_real_escape_string($parameter['value']) . "', `language_id` = '" . $language['id'] . "', `parameter_id` = " . $last_insert_id . " ";
                     $rs3 = mysql_query($sql3);
                     if (!$rs3) {
                         trigger_error("Can't update parameter " . $sql3 . " " . mysql_error());
                     }
                 }
                 break;
         }
     } else {
         trigger_error($sql . " " . mysql_error());
     }
 }