/** * constructor * * @access private * @return void **/ public static function getInstance() { if (!self::$instance) { self::$instance = new self(); } return self::$instance; }
/** * checks if given block has active sections * @access public * @param integer $block * @return boolean **/ function Dwoo_Plugin_check_block(Dwoo $dwoo, $block) { global $page_id; $sections = CAT_Sections::getInstance()->getActiveSections(intval($page_id), intval($block)); $return = is_array($sections) && count($sections) ? true : false; return $return; }
if ($section_id === false) { $backend->print_error('Error adding module'); } else { if (file_exists(CAT_PATH . '/modules/' . $module . '/add.php')) { global $backend, $admin; $admin =& $backend; require CAT_PATH . '/modules/' . $module . '/add.php'; } } } elseif ($delete_section_id != '') { $section_id = $delete_section_id; $section = CAT_Sections::getSection($section_id); if (file_exists(CAT_PATH . '/modules/' . $section['module'] . '/delete.php')) { require CAT_PATH . '/modules/' . $section['module'] . '/delete.php'; } if (CAT_Sections::deleteSection($section_id, $page_id)) { $backend->print_success('Success', CAT_ADMIN_URL . '/pages/modify.php?page_id=' . $page_id); exit; } } elseif ($update_section_id != '') { $block = $val->sanitizeGet('block'); $name = $val->sanitizeGet('name'); $day_from = is_numeric($val->sanitizeGet('day_from')) ? $val->sanitizeGet('day_from') : 0; $month_from = is_numeric($val->sanitizeGet('month_from')) ? $val->sanitizeGet('month_from') : 0; $year_from = is_numeric($val->sanitizeGet('year_from')) ? $val->sanitizeGet('year_from') : 0; $hour_from = is_numeric($val->sanitizeGet('hour_from')) ? $val->sanitizeGet('hour_from') : 0; $minute_from = is_numeric($val->sanitizeGet('minute_from')) ? $val->sanitizeGet('minute_from') : 0; $day_to = is_numeric($val->sanitizeGet('day_to')) ? $val->sanitizeGet('day_to') : 0; $month_to = is_numeric($val->sanitizeGet('month_to')) ? $val->sanitizeGet('month_to') : 0; $year_to = is_numeric($val->sanitizeGet('year_to')) ? $val->sanitizeGet('year_to') : 0; $hour_to = is_numeric($val->sanitizeGet('hour_to')) ? $val->sanitizeGet('hour_to') : 0;
$tpl_data['PAGE_ID'] = $results_array['page_id']; $tpl_data['PAGE_TITLE'] = $results_array['page_title']; $tpl_data['MENU_TITLE'] = $results_array['menu_title']; $tpl_data['PAGE_LINK'] = CAT_Helper_Page::getLink($results_array['page_id']); $tpl_data['MODIFIED_BY'] = $user['display_name']; $tpl_data['MODIFIED_BY_USERNAME'] = $user['username']; $tpl_data['MODIFIED_WHEN'] = $results_array['modified_when'] != 0 ? $modified_ts = CAT_Helper_DateTime::getDateTime($results_array['modified_when']) : false; $tpl_data['SECTION_BLOCKS'] = SECTION_BLOCKS; $tpl_data['SEC_ANCHOR'] = SEC_ANCHOR; $tpl_data['DATE_FORMAT'] = CAT_DATE_FORMAT; $tpl_data['CUR_TAB'] = 'modify'; $tpl_data['PAGE_HEADER'] = $backend->lang()->translate('Modify page'); // ========================================================= // ! Work-out if we should show the "manage sections" link // ========================================================= $section_id = CAT_Sections::getSectionForPage($page_id); $tpl_data['MANAGE_SECTIONS'] = $section_id || MANAGE_SECTIONS != 'enabled' ? false : true; // =========================================================================== // ! get template used for the displayed page (for displaying block details) // =========================================================================== $current_template = CAT_Helper_Page::getPageTemplate($page_id); // ============================== // ! Get sections for this page // ============================== $tpl_data['modules'] = $addons->get_addons(1, 'module', 'page'); // Remove menu_link from list foreach ($tpl_data['modules'] as $index => $module) { if ($module['VALUE'] == 'menu_link') { unset($tpl_data['modules'][$index]); } }
/** * Returns the URL of the first image found in a WYSIWYG section * * @param INT $page_id * @return STR URL oder BOOL FALSE */ public static function getFirstImageFromContent($page_id, $exec_droplets = true) { $self = self::getInstance(); $img = array(); $__CAT_Helper_Droplets_content = ''; $section = CAT_Sections::getSectionsByType($page_id); if (count($section)) { $SQL = "SELECT `content` FROM `:prefix:mod_wysiwyg` WHERE `section_id`=:id"; $params = array('id' => $section[0]['section_id']); $result = $self->db()->query($SQL, $params)->fetchColumn(); if ($self->db()->isError()) { return false; } if (is_string($result)) { $__CAT_Helper_Droplets_content = self::unsanitizeText($result); } } if (!empty($__CAT_Helper_Droplets_content)) { // scan content for images if ($exec_droplets && file_exists(CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/droplets/droplets.php'))) { // we must process the droplets to get the real output content $_SESSION['DROPLET_EXECUTED_BY_DROPLETS_EXTENSION'] = true; ob_start(); include_once CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/droplets/droplets.php'); if (function_exists('evalDroplets')) { try { $__CAT_Helper_Droplets_content = evalDroplets($__CAT_Helper_Droplets_content); } catch (Exception $e) { trigger_error(sprintf('[%s - %s] %s', __FUNCTION__, __LINE__, $e->getMessage()), E_USER_ERROR); } } ob_end_clean(); unset($_SESSION['DROPLET_EXECUTED_BY_DROPLETS_EXTENSION']); } if (preg_match('/<img[^>]*>/', $__CAT_Helper_Droplets_content, $matches)) { preg_match_all('/([a-zA-Z]*[a-zA-Z])\\s{0,3}[=]\\s{0,3}("[^"\\r\\n]*)"/', $matches[0], $attr); foreach ($attr as $attributes) { foreach ($attributes as $attribut) { if (strpos($attribut, "=") !== false) { list($key, $value) = explode("=", $attribut); $value = trim($value); $value = substr($value, 1, strlen($value) - 2); $img[strtolower(trim($key))] = trim($value); } } } } } if (isset($img['src'])) { $image = $img['src']; if (strpos($image, '..') !== false) { $image = substr($image, strpos($image, MEDIA_DIRECTORY . '/')); $image = CAT_URL . $image; } return $image; } else { return false; } }
/** * returns the sections of a page * * to get all sections of all pages, leave param empty * * @access public * @param integer $page_id * @return array **/ public static function getSections($page_id = NULL) { if (!count(self::$pages)) { self::getInstance(); } if (!count(self::$pages_sections)) { self::$pages_sections = CAT_Sections::getActiveSections(); } if ($page_id) { return isset(self::$pages_sections[$page_id]) ? self::$pages_sections[$page_id] : array(); } else { return self::$pages_sections; } }
/** * checks if given section exists, is active, and has content * @access public * @param integer $section * @return boolean **/ function Dwoo_Plugin_check_section(Dwoo $dwoo, $section_id) { global $page_id; $return = CAT_Sections::section_is_active($section_id); return $return; }
$options = array(); if ($block) { $options['block'] = $val->add_slashes($block); } if ($name) { $options['name'] = $val->add_slashes($name); } $date_from = $day_from * $month_from * $year_from > 0 ? mktime($hour_from, $minute_from, 0, $month_from, $day_from, $year_from) : 0; $date_to = $day_to * $month_to * $year_to > 0 ? mktime($hour_to, $minute_to, 0, $month_to, $day_to, $year_to) : 0; if ($date_from > $date_to) { $ajax = array('message' => $backend->lang()->translate('Please check your entries for dates.'), 'success' => false); print json_encode($ajax); exit; } else { $options['publ_start'] = $date_from; $options['publ_end'] = $date_to; } if (!CAT_Sections::updateSection($update_section_id, $options)) { $ajax = array('message' => $backend->lang()->translate('Unable to save section: ' . $backend->db()->getError()), 'success' => false); print json_encode($ajax); exit; } $updated_section = CAT_Sections::getSection($update_section_id); $updated_block = $parser->get_template_block_name(CAT_Helper_Page::getPageTemplate($page_id), $updated_section['block']) . ' (' . $backend->lang()->translate('Block number') . ': ' . $updated_section['block'] . ')'; } // ============================================ // ! Check for error or print success message // ============================================ $ajax = array('message' => $backend->lang()->translate('Section properties saved successfully.'), 'updated_section' => isset($updated_section) ? $updated_section : false, 'updated_block' => isset($updated_block) ? $updated_block : false, 'success' => true); print json_encode($ajax); exit;
public function section_is_active($section_id) { return CAT_Sections::section_is_active($section_id); }
/** * * @access public * @return **/ public function getSections() { if (!count($this->sections)) { $this->sections = CAT_Sections::getSections($this->_page_id); } return $this->sections; }