/**
 * Check for individual page description from the addons NEWS, TOPICs and for 
 * registered Addons - return an empty string or individual description
 * 
 * @param integer $page_id
 * @return string - title on success or empty string if search fail
 */
function get_addon_page_description($page_id)
{
    global $database;
    if (defined('POST_ID')) {
        $table = TABLE_PREFIX . 'mod_news_posts';
        $SQL = "SELECT `content_short` FROM `{$table}` WHERE `post_id`='" . POST_ID . "'";
        if (false === ($query = $database->query($SQL))) {
            trigger_error(sprintf('[%s - %s] %s', __FUNCTION__, __LINE__, $database->get_error()));
        }
        if ($query->numRows() > 0) {
            $result = $query->fetchRow(MYSQL_ASSOC);
            return strip_tags($result['content_short']);
        }
    } elseif (defined('TOPIC_ID')) {
        $table = TABLE_PREFIX . 'mod_topics';
        $SQL = "SELECT `description` FROM `{$table}` WHERE `topic_id`='" . TOPIC_ID . "'";
        if (false === ($query = $database->query($SQL))) {
            trigger_error(sprintf('[%s - %s] %s', __FUNCTION__, __LINE__, $database->get_error()));
        }
        if ($query->numRows() > 0) {
            $result = $query->fetchRow(MYSQL_ASSOC);
            return $result['description'];
        }
    } else {
        // check for addons which will set the page description
        $table = TABLE_PREFIX . 'mod_droplets_load';
        $SQL = "SELECT `id`, `module_directory` FROM `{$table}` WHERE `register_type`='addon' AND `file_type`='description'";
        if (false === ($query = $database->query($SQL))) {
            trigger_error(sprintf('[%s - %s] %s', __FUNCTION__, __LINE__, $database->get_error()));
        }
        if ($query->numRows() > 0) {
            $addon = $query->fetchRow(MYSQL_ASSOC);
            $file = LEPTON_PATH . '/modules/' . $addon['module_directory'] . '/headers.load.php';
            if (file_exists($file)) {
                include_once $file;
                $function = $addon['module_directory'] . '_get_page_description';
                if (function_exists($function)) {
                    // return individual page description
                    return call_user_func($function, $page_id);
                } else {
                    // function does not exists - unregister the addon!
                    unregister_addon_header($page_id, $addon['module_directory'], 'description');
                    return '';
                }
            } else {
                // function does not exists - unregister the addon!
                unregister_addon_header($page_id, $addon['module_directory'], 'description');
                return '';
            }
        }
    }
    return '';
}
Exemplo n.º 2
0
 /**
  * Unregister the Addon in $module_directory for $page_id for sending
  * page keywords to BC
  *
  * @param integer $page_id
  * @param string $module_directory
  * @return boolean true on success
  */
 public static function unregister_page_keywords($page_id, $module_directory)
 {
     return unregister_addon_header($page_id, $module_directory, 'keywords');
 }