public function GetChunk() { if ($this->IsActive()) { $title = str_replace(' ', '_', $this->title); $return = '<div class="adblock-' . strtolower($title) . '">' . "\n"; if ($this->ad_mode == 2) { $return .= stripcslashes($this->ad_code); } elseif ($this->ad_mode == 3) { $the_block =& OnePanelConfig::GetAdBlock($this->title); $the_palette =& $the_block->GetPalette(OnePanelTheme::GetActiveSkin()->GetName()); $return .= '<script type="text/javascript"><!--' . "\n"; $return .= 'google_ad_client = "' . $this->adsense_id . '";' . "\n"; $return .= 'google_ad_width = "' . $the_block->GetWidth() . '";' . "\n"; $return .= 'google_ad_height = "' . $the_block->GetHeight() . '";' . "\n"; $return .= 'google_ad_format = "' . $the_block->GetWidth() . 'x' . $the_block->GetHeight() . '_as";' . "\n"; $return .= 'google_ad_type = "text_image";' . "\n"; $return .= 'google_color_border = "' . $the_palette->GetBorderColor() . '";' . "\n"; $return .= 'google_color_bg = "' . $the_palette->GetBackgroundColor() . '";' . "\n"; $return .= 'google_color_link = "' . $the_palette->GetLinkColor() . '";' . "\n"; $return .= 'google_color_text = "' . $the_palette->GetTextColor() . '";' . "\n"; $return .= 'google_color_url = "' . $the_palette->GetUrlColor() . '";' . "\n"; $return .= is_null($this->adsense_channel) ? '' : 'google_ad_channel = "' . $this->adsense_channel . '";' . "\n"; $return .= '//--></script>' . "\n"; $return .= '<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">' . "\n"; $return .= '</script>' . "\n"; } $return .= '</div>' . "\n"; return $return; } }
public function GetChunk() { global $post; $post_id = $post->ID; $post_title = $post->post_title; $keywords = explode(' ', $post_title); $word_count = count($keywords); $overusedwords = array('', 'a', 'an', 'the', 'and', 'of', 'i', 'to', 'is', 'in', 'with', 'for', 'as', 'that', 'on', 'at', 'this', 'my', 'was', 'our', 'it', 'you', 'we', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '10', 'about', 'after', 'all', 'almost', 'along', 'also', 'amp', 'another', 'any', 'are', 'area', 'around', 'available', 'back', 'be', 'because', 'been', 'being', 'best', 'better', 'big', 'bit', 'both', 'but', 'by', 'c', 'came', 'can', 'capable', 'control', 'could', 'course', 'd', 'dan', 'day', 'decided', 'did', 'didn', 'different', 'div', 'do', 'doesn', 'don', 'down', 'drive', 'e', 'each', 'easily', 'easy', 'edition', 'end', 'enough', 'even', 'every', 'example', 'few', 'find', 'first', 'found', 'from', 'get', 'go', 'going', 'good', 'got', 'gt', 'had', 'hard', 'has', 'have', 'he', 'her', 'here', 'how', 'if', 'into', 'isn', 'just', 'know', 'last', 'left', 'li', 'like', 'little', 'll', 'long', 'look', 'lot', 'lt', 'm', 'made', 'make', 'many', 'mb', 'me', 'menu', 'might', 'mm', 'more', 'most', 'much', 'name', 'nbsp', 'need', 'new', 'no', 'not', 'now', 'number', 'off', 'old', 'one', 'only', 'or', 'original', 'other', 'out', 'over', 'part', 'place', 'point', 'pretty', 'probably', 'problem', 'put', 'quite', 'quot', 'r', 're', 'really', 'results', 'right', 's', 'same', 'saw', 'see', 'set', 'several', 'she', 'sherree', 'should', 'since', 'size', 'small', 'so', 'some', 'something', 'special', 'still', 'stuff', 'such', 'sure', 'system', 't', 'take', 'than', 'their', 'them', 'then', 'there', 'these', 'they', 'thing', 'things', 'think', 'those', 'though', 'through', 'time', 'today', 'together', 'too', 'took', 'two', 'up', 'us', 'use', 'used', 'using', 've', 'very', 'want', 'way', 'well', 'went', 'were', 'what', 'when', 'where', 'which', 'while', 'white', 'who', 'will', 'would', 'your'); if ($word_count == 0) { return false; } global $wpdb; $sql = "SELECT ID AS id, post_title AS post_title, post_content AS post_content FROM " . DB_NAME . ".{$wpdb->prefix}posts WHERE "; for ($i = 0; $i < $word_count; $i++) { $keyword = mysql_real_escape_string($keywords[$i]); if (!in_array($keyword, $overusedwords)) { $sql .= "post_title LIKE '%{$keyword}%' AND ID != {$post_id} AND post_type='post' AND post_status='publish' "; if ($i + 1 != $word_count) { $sql .= "OR "; } } } $sql .= 'LIMIT 3'; $result = mysql_query($sql); $error = '<div id="related-articles"> <div class="error">There are no related articles.</div> </div>'; $return = ''; if (!$result) { return $error; } else { $num_rows = mysql_numrows($result); $return .= '<div id="related-articles"><div class="title">' . OnePanelLanguage::GetText('related') . '</div>'; if ($num_rows > 0) { for ($i = 0; $i < $num_rows; $i++) { $id = mysql_result($result, $i, 'ID'); $title = mysql_result($result, $i, 'post_title'); $content = mysql_result($result, $i, 'post_content'); $return .= '<div class="related-article">'; $return .= OnePanelTheme::GetThumbnail($id); $return .= '<div class="title"><a href="' . get_permalink($id) . '">' . substr($title, 0, 39) . '...</a></div>'; $return .= substr(strip_tags($content), 0, 135) . '...'; $return .= '</div>'; } $return .= '</div>'; return $return; } else { return $error; } } }
* TODO consider allowing language terms of One Panel to be editable in future, * the object will need to be started here at that point. */ OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/language.php'); // Include the config class, and create the OnePanelConfig Object OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/onepanelconfig.php'); OnePanelConfig::Start(); // Include Externals //OnePanelLib::RequireFileOnce( ONE_PANEL_DIR .'/onepanelexternals.php' ); //OnePanelExternals::AddActions(); // THESE ARE BROKEN /* * Create one of two objects depending on which environment we appear * to be using. The OnePanelTheme has methods that should be available to * theme developers, but do not need to be present in the backend. */ if (is_admin() || OnePanelLib::InAjaxMode()) { // Log OnePanelDebug::Info('Running non AJAX mode in OnePanel.'); // Instantiate the OnePanel Object OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/onepanel.php'); OnePanel::Start(); } else { /* * TODO There is no reason to load the OnePanelTheme object if a config file * isnt present in the theme folder. */ // Instantiate the OnePanelTheme Object OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/onepaneltheme.php'); OnePanelTheme::Start(); }
public static function PrintPostInfo($gravatar_size = 40) { $enabled = self::FeatureIsActive('PostHeader', 'PostInfoFeature'); if ($enabled == false) { return false; } ?> <div id="post-info"> <?php OnePanelTheme::PrintAuthorGravatar($gravatar_size); ?> <span class="written-by"><?php echo OnePanelLanguage::GetText('written_by'); ?> </span> <span class="author-post-link"><?php the_author_posts_link(); ?> </span> <span class="comments-link"> <?php if (!is_single()) { comments_popup_link('' . OnePanelLanguage::GetText('no_comments') . '', '' . OnePanelLanguage::GetText('1_comments') . '', '% Comments'); } else { ?> <a href="#comments"><?php comments_number('' . OnePanelLanguage::GetText('no_comments') . '', '' . OnePanelLanguage::GetText('1_comments') . '', '% Comments'); ?> </a> <?php } ?> </span> <span class="edit-link"><?php edit_post_link(OnePanelLanguage::GetText('edit_this')); ?> </span> <br /> <span class="last-updated"><?php echo OnePanelLanguage::GetText('last_updated'); ?> </span> <span class="last-updated"><?php the_time(OnePanelLanguage::GetText('date_format')); ?> </span> </div> <?php }
public static function GetText($term) { self::Start(); if (class_exists('OnePanelTheme')) { $language_data = OnePanelTheme::GetLanguageData(self::$default_language); } if (empty($language_data)) { $language_data =& self::$data[self::$default_language]; } if (!isset($language_data[$term])) { return false; } // Get the term content $content = $language_data[$term]; // check for %THE_HOOKS% with regex $matches = array(); $number_of_matches = preg_match_all('/%([A-Z_]*)%/', $content, $matches); if ($number_of_matches > 0) { $hooks_to_use =& $matches[0]; foreach ($hooks_to_use as $key => &$hook) { if (array_key_exists($hook, self::$hooks)) { $function = self::$hooks[$hook]; $return_value = call_user_func($function); $content = preg_replace('/' . $hook . '/', $return_value, $content); } } } $content = stripslashes($content); return $content; }
/** * BehaviourIsActive * * Used by OnePanelModule to discern whether the requirements have been * met for a particular behaviour. * * @param $behaviour * @return boolean */ public static function BehaviourIsActive(OnePanelBehaviour &$behaviour) { $requirements =& $behaviour->GetRequirements(); foreach ($requirements as &$requirement) { if ($requirement instanceof OnePanelHomePageLayout) { if (class_exists('OnePanelTheme')) { $active_layout =& OnePanelTheme::GetActiveLayout(); if ($active_layout == $requirement) { return true; } } } else { // TODO ADD SKINS } return false; } }
/** * Start * * Singleton shortcut to run the constructor without returning an object * */ public static function Start() { OnePanelDebug::Info('Starting up OnePanel'); if (!is_object(self::$instance)) { // Check for the existence of the OnePanelTheme object if (class_exists('OnePanelTheme')) { if (is_object(OnePanelTheme::GetInstance())) { OnePanelDebug::Error('OnePanelTheme instance detected. Possible Hack!'); return false; } } else { self::$instance = new OnePanel(); } } }
public function BuildChunks() { // Get the skin switcher chunks $enabled = $this->features['SkinFeatureSwitcher']->IsActive(); if ($enabled == false) { return false; } // Get the skins $skins =& $this->GetSkinFeatures(); $active_skin =& OnePanelTheme::GetActiveSkin(); // Do the select $select = '<select class="select" onchange="OnePanelTheme.SwitchSkin( this.value )">' . "\n"; foreach ($skins as $key => &$skin) { if ($skin->IsActive()) { $select .= '<option value="' . $skin->GetName() . '">' . $skin->GetName() . '</option>' . "\n"; } } $select .= '</select>' . "\n"; $this->chunks['Select'] =& $select; // Do the list $list = '<ul>' . "\n"; foreach ($skins as $key => &$skin) { if ($skin->IsActive()) { $list .= '<li class="' . $skin->GetName() . ' ' . ($active_skin->GetName() == $skin->GetName() ? 'active' : 'inactive') . '"><a href="javascript:;" onclick="OnePanelTheme.SwitchSkin( \'' . $skin->GetName() . '\' )">' . $skin->GetName() . '</a></li>' . "\n"; } } $list .= '</ul>' . "\n"; $this->chunks['List'] =& $list; }