Beispiel #1
0
 function getTplName($tpl_name)
 {
     if (file_exists($this->getTemplatePath($tpl_name))) {
         return $this->getTemplatePath($tpl_name);
     }
     // FIX FOR ajax_file_upload_handler function called from admin panel
     $httpReferrer = SJB_Request::getVar('HTTP_REFERER', '', 'SERVER');
     $requestUri = SJB_Request::getVar('REQUEST_URI', '', 'SERVER');
     if (!empty($httpReferrer) && !empty($requestUri) && strpos($httpReferrer, '/admin/') !== false && strpos($requestUri, '/ajax_file_upload_handler/') !== false) {
         $currValue = SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE');
         SJB_System::setSystemSettings('SYSTEM_ACCESS_TYPE', 'admin');
         $systemTpl = SJB_System::getSystemSettings('SYSTEM_TEMPLATE_DIR') . '/';
         // ok. Now - set previous value
         SJB_System::setSystemSettings('SYSTEM_ACCESS_TYPE', $currValue);
     } else {
         $systemTpl = SJB_System::getSystemSettings('SYSTEM_TEMPLATE_DIR') . '/';
     }
     // END OF FIX
     $fileName = SJB_TemplatePathManager::getAbsoluteTemplatesPath() . $systemTpl . $this->module_name . '/' . $tpl_name;
     // ?
     if (file_exists($fileName)) {
         return $fileName;
     }
     return null;
 }
Beispiel #2
0
 /**
  * returns theme list
  * @return array
  */
 function getThemeList()
 {
     $system_tpl = SJB_System::getSystemSettings('SYSTEM_TEMPLATE_DIR');
     $themes = array();
     $templates_path = SJB_TemplatePathManager::getAbsoluteTemplatesPath();
     if (is_dir($templates_path)) {
         $templates_dir = opendir($templates_path);
         while (($file_in_dir = readdir($templates_dir)) !== false) {
             if ($file_in_dir != '.' && $file_in_dir != '..' && $file_in_dir != 'CVS' && $file_in_dir != '.svn' && $file_in_dir != $system_tpl) {
                 if (is_dir($templates_path . $file_in_dir)) {
                     $themes[] = $file_in_dir;
                 }
             }
         }
         closedir($templates_dir);
     }
     return $themes;
 }
Beispiel #3
0
 public function execute()
 {
     // таблица с данными xml-feeds
     $feedsTable = 'listing_feeds';
     $action = SJB_Request::getVar('action', '');
     $feedId = SJB_Request::getVar('feedId', null);
     $feedsArray = SJB_DB::query("SELECT f.*, f.count as count_listings, l.sid as typeId, l.id as type FROM {$feedsTable} as f LEFT JOIN `listing_types` as l ON (l.sid=f.type) ORDER BY f.sid");
     $listingTypes = SJB_DB::query("SELECT * FROM `listing_types`");
     $siteURL = SJB_System::getSystemSettings('SITE_URL');
     $tmp = strrchr(SJB_System::getSystemSettings('SITE_URL'), "/");
     $siteURL = str_replace($tmp, "", $siteURL);
     $tp = SJB_System::getTemplateProcessor();
     $tp->assign('listingTypes', $listingTypes);
     // данные для создания файлов-шаблонов для feed
     $module = SJB_System::getModuleManager()->getCurrentModuleAndFunction();
     $templatePath = SJB_TemplatePathManager::getAbsoluteTemplatesPath();
     $filePath = $templatePath . "_system/" . $module[0] . "/";
     switch ($action) {
         case 'add':
             // если была отправка формы
             if (isset($_REQUEST['addFeed']) && $_REQUEST['addFeed'] != '') {
                 $feed_name = $_REQUEST['feed_name'];
                 $feed_template = $_REQUEST['feed_template'];
                 $feed_desc = $_REQUEST['feed_desc'];
                 $typeId = $_REQUEST['typeId'];
                 $count_listings = $_REQUEST['count_listings'];
                 $feed_mimetype = $_REQUEST['mime_type'];
                 // создадим шаблон для нового feed
                 $feed_template = preg_replace("/^feed_|\\.tpl\$/", "", $feed_template);
                 $feed_template = "feed_" . $feed_template . ".tpl";
                 $filePath = $filePath . $feed_template;
                 $fileSystem = new SJB_Filesystem();
                 if (!file_exists($filePath)) {
                     $fileSystem->createFile($filePath);
                 } else {
                     $errors[] = array('code' => 'FILE_ALREADY_EXISTS', 'message' => "Template '{$filePath}' already exists!");
                     $tp->assign('feed', array('name' => $feed_name, 'template' => $feed_template, 'description' => $feed_desc, 'type' => $typeId, 'count_listings' => $count_listings, 'mime_type' => $feed_mimetype));
                     $tp->assign('errors', $errors);
                     $tp->display("add_listing_feed.tpl");
                     break;
                 }
                 SJB_DB::queryExec("INSERT INTO {$feedsTable} SET `name`=?s, `template`=?s, `description`=?s, `type`=?n, `count`=?n, `mime_type`=?s", $feed_name, $feed_template, $feed_desc, $typeId, $count_listings, $feed_mimetype);
                 $site_url = SJB_System::getSystemSettings("SITE_URL");
                 SJB_HelperFunctions::redirect($site_url . "/listing-feeds/");
             }
             $tp->display("add_listing_feed.tpl");
             break;
         case 'edit':
             // если была отправка формы редактирования элемента
             if ($form_submitted = SJB_Request::getVar('submit')) {
                 $feed_name = $_REQUEST['feed_name'];
                 $feed_template = $_REQUEST['feed_template'];
                 $feed_desc = $_REQUEST['feed_desc'];
                 $feedId = $_REQUEST['feedId'];
                 $typeId = $_REQUEST['typeId'];
                 $count_listings = $_REQUEST['count_listings'];
                 $feed_mimetype = $_REQUEST['mime_type'];
                 SJB_DB::queryExec("UPDATE {$feedsTable} SET `name`=?s, `template`=?s, `description`=?s, `type`=?n, `count`=?n, `mime_type`=?s WHERE `sid`=?n LIMIT 1", $feed_name, $feed_template, $feed_desc, $typeId, $count_listings, $feed_mimetype, $feedId);
                 $site_url = SJB_System::getSystemSettings("SITE_URL");
                 if ($form_submitted == 'save_info') {
                     SJB_HelperFunctions::redirect($site_url . "/listing-feeds/");
                 }
             }
             $feed = SJB_DB::query("SELECT f.*, f.count as count_listings  FROM {$feedsTable} as f WHERE `sid`=?n", $feedId);
             $feed = array_pop($feed);
             $tp->assign("feed", $feed);
             $tp->display("edit_listing_feed.tpl");
             break;
         case 'delete':
             $feed = SJB_DB::query("SELECT f.*, f.count as count_listings FROM {$feedsTable} as f WHERE `sid`=?n", $feedId);
             $feed = array_pop($feed);
             $filePath = $filePath . $feed['template'];
             $fileSystem = new SJB_Filesystem();
             if (file_exists($filePath)) {
                 $fileSystem->deleteFile($filePath);
             } else {
                 $errors[] = array('code' => 'FILE_NOT_EXISTS', 'message' => "Template for " . $feed['name'] . ": '{$filePath}' not exists!");
             }
             SJB_DB::queryExec("DELETE FROM {$feedsTable} WHERE `sid`=?n LIMIT 1", $feedId);
             $site_url = SJB_System::getSystemSettings("SITE_URL");
             SJB_HelperFunctions::redirect($site_url . "/listing-feeds/");
             break;
     }
     if ($action == '') {
         $tp->assign('siteURL', $siteURL);
         $tp->assign('feeds', $feedsArray);
         $tp->display('listing_feeds.tpl');
     }
 }