Example #1
0
function perch_get_javascript($opts = false, $return = false)
{
    $feathers = PerchSystem::get_registered_feathers();
    $out = '';
    if (PerchUtil::count($feathers)) {
        $count = PerchUtil::count($feathers);
        $i = 0;
        $components = array();
        foreach ($feathers as $feather) {
            $classname = 'PerchFeather_' . $feather;
            $Feather = new $classname($components);
            $out .= $Feather->get_javascript($opts, $i, $count);
            $components = $Feather->get_components();
            $i++;
        }
    }
    // Inject script when authed
    if (isset($_COOKIE['cmsa'])) {
        $out .= PerchSystem::get_helper_js();
    }
    if ($return) {
        return $out;
    }
    echo $out;
    PerchUtil::flush_output();
}
 public static function factory($bucket)
 {
     $type = isset($bucket['type']) ? $bucket['type'] : 'file';
     if (!PERCH_RUNWAY || $type == 'file') {
         return new PerchResourceBucket($bucket);
     }
     $handlers = PerchSystem::get_registered_bucket_handlers();
     if (isset($handlers[$type])) {
         return new $handlers[$type]($bucket);
     } else {
         $config = PerchConfig::get($type);
         if ($config && is_array($config) && isset($config['handler']) && isset($config['handler_path'])) {
             include $config['handler_path'];
             PerchSystem::register_bucket_handler($type, $config['handler']);
             return new $config['handler']($bucket);
         } else {
             error_log("Handler not found: {$type}");
         }
     }
 }
 public function render($vars = array())
 {
     $system_vars = PerchSystem::get_vars();
     if (is_array($system_vars) && is_array($vars)) {
         $vars = array_merge($system_vars, $vars);
     }
     $this->content_vars = $vars;
     $contents = $this->template;
     $i = 0;
     while (strpos($contents, 'perch:form') > 0 && $i < 10) {
         $s = '/(<perch:form[^>]*>)((?!perch:form).*?)(<\\/perch:form>)/s';
         $count = preg_match_all($s, $contents, $matches, PREG_SET_ORDER);
         if ($count > 0) {
             foreach ($matches as $match) {
                 $this->submitted = null;
                 $contents = $this->_render_form($match[0], $match[1], $match[2], $match[3], $contents, $vars);
             }
         }
         $i++;
     }
     return $contents;
 }
Example #4
0
<?php

PerchSystem::register_feather('Twitter');
class PerchFeather_Twitter extends PerchFeather
{
    public function get_css($opts, $index, $count)
    {
        $out = array();
        $out[] = $this->_single_tag('link', array('rel' => 'stylesheet', 'href' => $this->path . '/css/twitter.css', 'type' => 'text/css'));
        return implode("\n\t", $out) . "\n";
    }
    public function get_javascript($opts, $index, $count)
    {
        $out = array();
        if (!$this->component_registered('twitter')) {
            $out[] = $this->_script_tag(array('src' => '//platform.twitter.com/widgets.js'));
            $this->register_component('twitter');
        }
        return implode("\n\t", $out) . "\n";
    }
}
<?php

if ($CurrentUser->logged_in() && $CurrentUser->has_priv('perch_blog')) {
    $this->register_app('perch_blog', 'Blog', 1, 'A simple blog', '4.6');
    $this->require_version('perch_blog', '2.8');
    $this->add_setting('perch_blog_post_url', 'Blog post page path', 'text', '/blog/post.php?s={postSlug}');
    $this->add_setting('perch_blog_slug_format', 'Slug format', 'text', '%Y-%m-%d-{postTitle}');
    $this->add_setting('perch_blog_akismet_key', 'Akismet API key', 'text', '');
    $this->add_setting('perch_blog_comment_notify', 'Notify author of new comments', 'checkbox', '0');
    $this->add_setting('perch_blog_max_spam_days', 'Delete spam comments', 'select', '0', array(array('label' => 'Never', 'value' => '0'), array('label' => 'After 1 day', 'value' => '1'), array('label' => 'After 7 days', 'value' => '7'), array('label' => 'After 14 days', 'value' => '14'), array('label' => 'After 30 days', 'value' => '30'), array('label' => 'After 60 days', 'value' => '60'), array('label' => 'After 90 days', 'value' => '90')));
    $this->add_create_page('perch_blog', 'edit');
    PerchSystem::register_admin_search_handler('PerchBlog_SearchHandler');
    spl_autoload_register(function ($class_name) {
        if (strpos($class_name, 'PerchBlog') === 0) {
            include PERCH_PATH . '/addons/apps/perch_blog/' . $class_name . '.class.php';
            return true;
        }
        return false;
    });
}
Example #6
0

   <link rel="shortcut icon" href="http://andrewrmchugh.rocks/favicon.ico" type="image/x-icon" />
   <?php 
$domain = 'http://' . $_SERVER["HTTP_HOST"];
$url = $domain . $_SERVER["REQUEST_URI"];
$sitename = "Andrew R McHugh | UX Designer of New Futures";
$twittername = "@armthethinker";
$sharing_image = 'http://andrewrmchugh.rocks/img/andrew-mchugh-lg.jpg';
$fbname = "https://www.facebook.com/arm5629";
PerchSystem::set_var('sitename', $sitename);
PerchSystem::set_var('domain', $domain);
PerchSystem::set_var('url', $url);
PerchSystem::set_var('sharing_image', $sharing_image);
PerchSystem::set_var('twittername', $twittername);
PerchSystem::set_var('fbname', $fbname);
perch_page_attributes(array('template' => 'seo.html'));
?>

   <?php 
if ($old == true) {
    if ($m_location == "home") {
        echo '<link rel="stylesheet" href="' . $tooty . '/dist/css/DaseinDesign-v0.2.0.cover.css" media="screen" type="text/css" />';
    } else {
        echo '<link rel="stylesheet" href="' . $tooty . '/dist/css/DaseinDesign-v0.2.0.css" media="screen" type="text/css" />';
        echo '<link rel="stylesheet" href="/css/patch.css" media="screen" type="text/css" />';
        echo '<link href="http://fonts.googleapis.com/css?family=Lato:100,300,400,900,900italic|Vollkorn:400italic,400,700|Montserrat" rel="stylesheet" type="text/css">';
    }
} else {
    ?>
            <link rel="stylesheet" href="/dist/css/andrewrmchughrocks-2.2.min.css" media="screen" type="text/css" />
Example #7
0
<?php

PerchSystem::register_feather('Quill');
class PerchFeather_Quill extends PerchFeather
{
    public function get_css($opts, $index, $count)
    {
        $out = array();
        $out[] = $this->_single_tag('link', array('rel' => 'stylesheet', 'href' => '//fonts.googleapis.com/css?family=Droid+Sans:400,700', 'type' => 'text/css'));
        $out[] = $this->_single_tag('link', array('rel' => 'stylesheet', 'href' => $this->path . '/css/styles.css', 'type' => 'text/css'));
        if (!$this->component_registered('html5shiv')) {
            $out[] = $this->_conditional_comment('lt IE 9', $this->_script_tag(array('src' => $this->path . '/js/html5shiv.js')));
            $this->register_component('html5shiv');
        }
        return implode("\n\t", $out) . "\n";
    }
    public function get_javascript($opts, $index, $count)
    {
        $out = array();
        if (!$this->component_registered('jquery')) {
            $out[] = $this->_script_tag(array('src' => $this->path . '/js/jquery-1.8.2.min.js'));
            $this->register_component('jquery');
        }
        if (!$this->component_registered('respond.js')) {
            $out[] = $this->_conditional_comment('lt IE 9', $this->_script_tag(array('src' => $this->path . '/js/respond.min.js')));
            $this->register_component('respond.js');
        }
        return implode("\n\t", $out) . "\n";
    }
}
<?php

PerchSystem::register_search_handler('PerchMailchimp_SearchHandler');
require 'PerchMailchimp_Campaigns.class.php';
require 'PerchMailchimp_Campaign.class.php';
require 'PerchMailchimp_Subscribers.class.php';
require 'PerchMailchimp_Subscriber.class.php';
require 'PerchMailchimp_SearchHandler.class.php';
require 'MailChimp.class.php';
function perch_mailchimp_form_handler($SubmittedForm)
{
    if ($SubmittedForm->validate()) {
        $API = new PerchAPI(1.0, 'perch_mailchimp');
        $Subscribers = new PerchMailchimp_Subscribers($API);
        $Subscribers->subscribe_from_form($SubmittedForm);
    }
    $Perch = Perch::fetch();
    PerchUtil::debug($Perch->get_form_errors($SubmittedForm->formID));
}
/**
 * Display a form, e.g. a subscribe form
 * @param  [type]  $template [description]
 * @param  array   $content  [description]
 * @param  boolean $return   [description]
 * @return [type]            [description]
 */
function perch_mailchimp_form($template, $content = array(), $return = false)
{
    $API = new PerchAPI(1.0, 'perch_mailchimp');
    $Template = $API->get('Template');
    $Template->set('mailchimp' . DIRECTORY_SEPARATOR . $template, 'mailchimp');
Example #9
0
<?php

PerchSystem::register_feather('StartBlock');
class PerchFeather_StartBlock extends PerchFeather
{
    public function get_css($opts, $index, $count)
    {
        $out = array();
        if (!$this->component_registered('normalize')) {
            $out[] = $this->_single_tag('link', array('rel' => 'stylesheet', 'href' => $this->path . '/css/normalize.css', 'type' => 'text/css'));
            $this->register_component('normalize');
        }
        return implode("\n\t", $out) . "\n";
    }
    public function get_javascript($opts, $index, $count)
    {
        $out = array();
        if (!$this->component_registered('jquery')) {
            $out[] = $this->_script_tag(array('src' => $this->path . '/js/jquery-1.8.2.min.js'));
            $this->register_component('jquery');
        }
        return implode("\n\t", $out) . "\n";
    }
}
Example #10
0
<?php

PerchSystem::register_feather('MyFeather');
class PerchFeather_MyFeather extends PerchFeather
{
    public function get_css($opts, $index, $count)
    {
        return $this->_single_tag('link', array('rel' => 'stylesheet', 'href' => $this->path . '/css/app.css', 'type' => 'text/css'));
    }
    public function get_javascript($opts, $index, $count)
    {
        return $this->_script_tag(array('src' => $this->path . '/scripts/main.js'));
    }
}
Example #11
0
 public static function set_attr_vars($vars)
 {
     if (PerchUtil::count($vars)) {
         self::$attribute_vars = array_merge(self::$attribute_vars, $vars);
     }
 }
 public function apply_runtime_post_processing($html, $vars = array())
 {
     $handlers = PerchSystem::get_registered_template_handlers();
     if (PerchUtil::count($handlers)) {
         foreach ($handlers as $handlerClass) {
             $Handler = new $handlerClass();
             $html = $Handler->render_runtime($html, $this);
         }
     }
     $html = $this->render_settings($html);
     $html = $this->render_forms($html, $vars);
     $html = $this->render_layouts($html, $vars);
     return $html;
 }
Example #13
0
<?php

PerchSystem::register_feather('Sass');
class PerchFeather_Sass extends PerchFeather
{
    private $_site_path = false;
    public function get_css($opts, $index, $count)
    {
        if (!isset($opts['sass'])) {
            return;
        }
        $stylesheets = $opts['sass'];
        $out = '';
        // compile files
        if (PERCH_PRODUCTION_MODE < PERCH_PRODUCTION) {
            foreach ($stylesheets as $stylesheet) {
                $this->_compile_stylesheet($stylesheet);
            }
        }
        // link files
        foreach ($stylesheets as $stylesheet) {
            $out .= $this->_single_tag('link', array('rel' => 'stylesheet', 'href' => $this->_get_compiled_name($stylesheet, true), 'type' => 'text/css'));
        }
        return $out;
    }
    private function _get_compiled_name($file, $include_path = false)
    {
        $parts = explode('/', $file);
        $file = array_pop($parts);
        $parts = explode('.', $file);
        array_pop($parts);
 public function template_attribute($id, $opts)
 {
     $attr_vars = PerchSystem::get_attr_vars();
     if (isset($attr_vars[$id])) {
         return $attr_vars[$id];
     }
     if ($id == 'pageTitle' || $id == 'pageNavText') {
         return $this->details[$id];
     }
     $Template = new PerchTemplate('pages/attributes/' . $opts['template'], 'pages');
     $tag = $Template->find_tag($id, false, true);
     if ($tag) {
         $Template->load($tag);
         return $Template->render($this);
     }
     if (isset($this->details[$id])) {
         return $this->details[$id];
     }
     return false;
 }
Example #15
0
<?php

if (defined('PERCH_SSL') && PERCH_SSL) {
    PerchSystem::force_ssl();
}
/* Check for auth plugins */
if (defined('PERCH_AUTH_PLUGIN')) {
    require PERCH_PATH . DIRECTORY_SEPARATOR . 'addons' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'auth' . DIRECTORY_SEPARATOR . PERCH_AUTH_PLUGIN . DIRECTORY_SEPARATOR . 'auth.php';
} else {
    define('PERCH_AUTH_PLUGIN', false);
}
$Users = new PerchUsers();
$CurrentUser = $Users->get_current_user();
/* Check for incoming login form and attempt login */
$username = false;
$password = false;
if (isset($_POST['username']) && isset($_POST['password']) && $_POST['username'] != '' && $_POST['password'] != '') {
    $username = $_POST['username'];
    $password = $_POST['password'];
}
if ($username != false && $password != false) {
    $auth_succeeded = $CurrentUser->authenticate($username, $password);
    if (!$auth_succeeded) {
        header("HTTP/1.0 403 Forbidden", true, 403);
    }
}
if (!isset($auth_page)) {
    $auth_page = false;
}
if (!$CurrentUser->logged_in() && !$auth_page) {
    PerchUtil::debug('Not logged in');
Example #16
0
function perch_members_check_page_access()
{
    $Session = PerchMembers_Session::fetch();
    if ($Session->logged_in) {
        $user_tags = $Session->get_tags();
    } else {
        $user_tags = array();
    }
    if (!is_array($user_tags)) {
        $user_tags = array();
    }
    $Page = PerchSystem::get_page_object();
    if (!$Page) {
        $Pages = new PerchContent_Pages();
        $Perch = Perch::fetch();
        $Page = $Pages->find_by_path($Perch->get_page());
        if ($Page instanceof PerchContent_Page) {
            PerchSystem::set_page_object($Page);
        }
    }
    if ($Page) {
        $page_tags = $Page->access_tags();
        if (!is_array($page_tags)) {
            $page_tags = array();
        }
        if (PerchUtil::count($page_tags)) {
            $intersection = array_intersect($user_tags, $page_tags);
            if (PerchUtil::count($intersection) === 0) {
                // no access!
                $API = new PerchAPI(1.0, 'perch_members');
                $Settings = $API->get('Settings');
                $redirect_url = $Settings->get('perch_members_login_page')->val();
                if ($redirect_url) {
                    $redirect_url = str_replace('{returnURL}', $Perch->get_page(), $redirect_url);
                    PerchUtil::redirect($redirect_url);
                } else {
                    die('Access denied.');
                }
            }
        }
    }
}
Example #17
0
<?php

PerchSystem::register_feather('TheCross');
class PerchFeather_TheCross extends PerchFeather
{
    public function get_css($opts, $index, $count)
    {
        $out = array();
        if (!$this->component_registered('raleway')) {
            $out[] = $this->_single_tag('link', array('rel' => 'stylesheet', 'href' => '//fonts.googleapis.com/css?family=Raleway:400,300,600', 'type' => 'text/css'));
        }
        if (!$this->component_registered('normalize')) {
            $out[] = $this->_single_tag('link', array('rel' => 'stylesheet', 'href' => $this->path . '/css/normalize.css', 'type' => 'text/css'));
        }
        if (!$this->component_registered('skeleton')) {
            $out[] = $this->_single_tag('link', array('rel' => 'stylesheet', 'href' => $this->path . '/css/skeleton.css', 'type' => 'text/css'));
        }
        return implode("\n\t", $out) . "\n";
    }
    public function get_javascript($opts, $index, $count)
    {
        $out = array();
        if (!$this->component_registered('jquery')) {
            $out[] = $this->_script_tag(array('src' => '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'));
            $this->register_component('jquery');
        }
        if (!$this->component_registered('jquery.easing')) {
            $out[] = $this->_script_tag(array('src' => '//cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js'));
            $this->register_component('jquery.easing');
        }
        if (!$this->component_registered('functions')) {
Example #18
0
<?php 
perch_layout('header');
?>

<?php 
# get the post
$post = perch_blog_custom(array('filter' => 'postSlug', 'match' => 'eq', 'value' => perch_get('s'), 'skip-template' => 'true', 'return-html' => 'true'));
# set up the variables
$title = $post['0']['postTitle'];
$description = strip_tags($post['0']['postDescHTML']);
$description = substr($description, 0, 200);
$image = $post[0]['image'];
$keywords = $post[0]['postTags'];
$sidebarid = $post['0']['sidebar'];
PerchSystem::set_var('sidebarid', 'en');
# use the variables in the array value
perch_page_attributes_extend(array('description' => $description, 'pageNavText' => $title, 'image' => $image, 'keywords' => $keywords));
?>

<?php 
perch_layout('meta');
?>

<?php 
perch_layout('navigation');
?>

<span <?php 
perch_blog_custom(array('filter' => 'postSlug', 'match' => 'eq', 'value' => perch_get('s'), 'template' => 'sidebarid.html'));
?>
 static function get($var, $default = false)
 {
     if (isset($_GET[$var]) && $_GET[$var] != '') {
         return $_GET[$var];
     }
     if (PERCH_RUNWAY && class_exists('PerchSystem')) {
         $r = PerchSystem::get_url_var($var);
         if ($r) {
             return $r;
         }
     }
     return $default;
 }
Example #20
0
<?php

if (PerchSystem::get_var('contentstart')) {
    $notNav = true;
}
if ($notNav) {
    print "<h1>Links</h1>";
} else {
    print "<a class=\"lnk__icn appnav icn__links\" href=\"/blog/links\">Links</a>";
}
?>
<ul>
    <li><a class="lnk__icn facebook<?php 
if ($notNav) {
    print " displayblock";
}
?>
" target="_blank" href="https://facebook.com/frwssr" title="zur FEUERWASSER Facebook-Seite"><?php 
if ($notNav) {
    print " FW Facebook-Seite";
}
?>
</a> <a class="lnk__icn twitter<?php 
if ($notNav) {
    print " displayblock";
}
?>
" target="_blank" href="https://twitter.com/frwssr" title="zum FEUERWASSER Twitter-Stream"><?php 
if ($notNav) {
    print " FW Twitter-Stream";
}
<?php

include 'perch/runtime.php';
?>

<?php 
perch_layout('header');
$lang = PerchSystem::get_var('lang');
?>
<body>

	<?php 
if ($lang == 'it') {
    ?>
		<h1>Ciao!</h1>
	<?php 
} else {
    ?>
		<h1>Hello!</h1>
	<?php 
}
?>

	<?php 
perch_content('Main content - ' . $lang);
?>

</body>
</html>
Example #22
0
<?php

//RewriteRule ^rss.xml$ rss.php
header('Content-type: application/xml');
include $_SERVER['DOCUMENT_ROOT'] . '/perch/runtime.php';
PerchSystem::set_var('siteurl', 'http://' . $_SERVER['SERVER_NAME' . '/blog']);
echo '<' . '?xml version="1.0"?' . '>';
?>
<rss version="2.0">
<channel>
    <title>F R W S S R · Der FEUERWASSER-Blog</title>
    <description>Ein Blog zu den Themen Design für Print und Web, unsere Arbeitsweise, Design-Tipps für kleine und mittelgroße Unternehmen (KMU), Werkzeuge und Dienste, mit denen wir arbeiten, und allgemeine Gedanken zum Betrieb einer kleinen aber feinen Agentur in der nordbadischen Provinz – in Walldorf bei Heidelberg.</description>
    <language>de</language>
    <link><?php 
echo PerchSystem::get_var('siteurl');
?>
</link>
    <?php 
$opts = array('page' => 'index.php', 'template' => 'rssitem.html');
perch_blog_recent_posts();
?>
</channel>
</rss>
Example #23
0
<?php

include $_SERVER['DOCUMENT_ROOT'] . '/perch/runtime.php';
$domain = 'http://' . $_SERVER['HTTP_HOST'];
PerchSystem::set_var('domain', $domain);
header('Content-Type: application/rss+xml');
echo '<' . '?xml version="1.0"?' . '>';
?>

<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Latest school notices from Waterford Kamhlaba UWCSA</title>
        <link><?php 
echo PerchUtil::html($domain);
?>
/news/notices/</link>
        <description>Waterford Kamhlaba UWCSA is a remarkable and pioneering secondary school located in Mbabane, Swaziland.</description>
        <atom:link href="<?php 
echo PerchUtil::html($domain);
?>
/news/notices/rss.php" rel="self" type="application/rss+xml" />
        <?php 
perch_blog_custom(array('template' => 'rss_post.html', 'count' => 20, 'section' => 'school-notices', 'sort' => 'postDateTime', 'sort-order' => 'DESC'));
?>
    </channel>
</rss>
Example #24
0
<?php

include $_SERVER['DOCUMENT_ROOT'] . '/perch/runtime.php';
perch_layout('blog.header');
PerchSystem::set_var('contentstart', true);
perch_blog_tags();
perch_blog_date_archive_years();
perch_layout('blog.infos');
perch_layout('blog.footer');
 public function search_content($key, $opts, $admin = false)
 {
     PerchUtil::debug('Search term: ' . $key, 'success');
     $this->mb_fallback();
     $search_method = 'get_search_sql';
     $format_method = 'format_result';
     if ($admin) {
         $search_method = 'get_admin_search_sql';
         $format_method = 'format_admin_result';
     }
     $search_handlers = PerchSystem::get_registered_search_handlers();
     $search_content = true;
     if (PerchUtil::count($opts['apps'])) {
         $search_content = in_array('PerchContent', $opts['apps']);
         if (PerchUtil::count($search_handlers)) {
             $new_handlers = array();
             foreach ($search_handlers as $handler) {
                 $short = str_replace('_SearchHandler', '', $handler);
                 if (in_array($short, $opts['apps'])) {
                     $new_handlers[] = $handler;
                 }
             }
             $search_handlers = $new_handlers;
         }
     }
     $out = array();
     if ($key != '') {
         if (!$this->api) {
             $this->api = new PerchAPI(1.0, 'content');
         }
         $encoded_key = str_replace('"', '', PerchUtil::json_safe_encode($key));
         $Paging = $this->api->get('Paging');
         if (isset($opts['count'])) {
             $Paging->set_per_page($opts['count']);
             if (isset($opts['start']) && $opts['start'] != '') {
                 $Paging->set_start_position($opts['start']);
             }
         } else {
             $Paging->disable();
         }
         // Proper query using FULLTEXT
         $sql = $Paging->select_sql();
         if (!$search_content) {
             $sql .= ' \'PerchContent_SearchHandler\' AS source, \'\' AS score, \'\' AS col1, \'\' AS col2, \'\' AS col3, \'\' AS col4, \'\' AS col5, \'\' AS col6, \'\' AS col7, \'\' AS col8 FROM ' . $this->table . ' WHERE 1=0 UNION ';
         }
         if (PerchUtil::count($search_handlers)) {
             $first = true;
             foreach ($search_handlers as $handler) {
                 $handler_sql = false;
                 if (method_exists($handler, $search_method)) {
                     $handler_sql = call_user_func(array($handler, $search_method), $key, $opts);
                 }
                 if ($handler_sql) {
                     if ($first) {
                         $sql .= ' ' . $handler_sql . ' ';
                         $first = false;
                     } else {
                         $sql .= ' 
                         UNION 
                         ' . $handler_sql . ' ';
                     }
                 }
                 $handler_sql = false;
             }
         }
         $sql .= ' ORDER BY score DESC';
         if ($Paging->enabled()) {
             $sql .= ' ' . $Paging->limit_sql();
         }
         $rows = $this->db->get_rows($sql);
         if (PerchUtil::count($rows) == 0) {
             if ($search_content) {
                 $sql = $Paging->select_sql();
             } else {
                 $sql = $Paging->select_sql() . ' \'PerchContent_SearchHandler\' AS source, \'\' AS score, \'\' AS col1, \'\' AS col2, \'\' AS col3, \'\' AS col4, \'\' AS col5, \'\' AS col6, \'\' AS col7, \'\' AS col8 FROM ' . $this->table . ' WHERE 1=0 UNION ';
             }
             if (PerchUtil::count($search_handlers)) {
                 $first = true;
                 foreach ($search_handlers as $handler) {
                     $handler_sql = call_user_func(array($handler, 'get_backup_search_sql'), $key, $opts);
                     if ($handler_sql) {
                         if ($first) {
                             $sql .= ' ' . $handler_sql . ' ';
                             $first = false;
                         } else {
                             $sql .= ' 
                             UNION 
                             ' . $handler_sql . ' ';
                         }
                     }
                     $handler_sql = false;
                 }
             }
             $sql .= ' ORDER BY score ASC ';
             if ($Paging->enabled()) {
                 $sql .= ' ' . $Paging->limit_sql();
             }
             $rows = $this->db->get_rows($sql);
         }
         if ($Paging->enabled()) {
             $Paging->set_total($this->db->get_count($Paging->total_count_sql()));
         }
         if (PerchUtil::count($rows)) {
             foreach ($rows as $row) {
                 $className = $row['source'];
                 if (method_exists($className, $format_method)) {
                     $r = call_user_func(array($className, $format_method), $key, $opts, $row);
                 } else {
                     $r = false;
                 }
                 if ($r) {
                     $r['source'] = str_replace('_SearchHandler', '', $row['source']);
                     // duplicate vals
                     foreach ($r as $k => $val) {
                         $r['result_' . $k] = $val;
                         if ($opts['no-conflict']) {
                             //unset($r[$k]);
                         }
                     }
                     $r['search_key'] = $key;
                     if (!$opts['no-conflict']) {
                         $r['key'] = $key;
                     }
                     $out[] = $r;
                 }
             }
         }
     }
     if (isset($opts['skip-template']) && $opts['skip-template']) {
         return $out;
     }
     $Template = new PerchTemplate('search/' . $opts['template'], 'search');
     $Template->enable_encoding();
     if (PerchUtil::count($out)) {
         foreach ($out as &$row) {
             // compat
             if (!$opts['no-conflict']) {
                 $row['url'] = $row['result_url'];
                 if (isset($row['result_result_url'])) {
                     $row['result_url'] = $row['result_result_url'];
                 }
             }
             // hide default doc
             if ($opts['hide-default-doc']) {
                 $row['result_url'] = preg_replace('/' . preg_quote(PERCH_DEFAULT_DOC) . '$/', '', $row['result_url']);
             }
             if ($opts['hide-extensions'] && strpos($row['result_url'], '.')) {
                 $parts = explode('.', $row['result_url']);
                 $ext = array_pop($parts);
                 $query = '';
                 if (strpos($ext, '?') !== false) {
                     $qparts = explode('?', $ext);
                     array_shift($qparts);
                     if (PerchUtil::count($qparts)) {
                         $query = '?' . implode('?', $qparts);
                     }
                 }
                 $row['result_url'] = implode('.', $parts) . $query;
             }
             // trailing slash
             if ($opts['add-trailing-slash']) {
                 $row['result_url'] = rtrim($row['result_url'], '/') . '/';
             }
         }
         if (isset($Paging) && $Paging->enabled()) {
             $paging_array = $Paging->to_array($opts);
             // merge in paging vars
             foreach ($out as &$item) {
                 foreach ($paging_array as $key => $val) {
                     $item[$key] = $val;
                 }
             }
         }
         return $Template->render_group($out, 1);
     } else {
         $Template->use_noresults();
         return $Template->render(array('search_key' => $key, 'key' => $key));
     }
 }
Example #26
0
<?php

if ($CurrentUser->logged_in() && $CurrentUser->has_priv('root_locator')) {
    $this->register_app('root_locator', 'Locator', 1, 'Provide location based listings for your site', '2.0.0');
    $this->require_version('root_locator', '2.8.31');
    $this->add_create_page('root_locator', 'edit');
    $this->add_setting('root_locator_batch_size', 'Batch Size', 'select', 25, array(array('label' => '10 Locations', 'value' => 10), array('label' => '25 Locations', 'value' => 25), array('label' => '50 Locations', 'value' => 50), array('label' => '100 Locations', 'value' => 100)));
    $this->add_setting('root_locator_google_api_key', 'API key', 'text');
    include __DIR__ . '/lib/vendor/autoload.php';
    spl_autoload_register(function ($class_name) {
        if (strpos($class_name, 'RootLocator') === 0) {
            include PERCH_PATH . '/addons/apps/root_locator/lib/' . $class_name . '.class.php';
            return true;
        }
        return false;
    });
    // Search handler
    PerchSystem::register_admin_search_handler('RootLocator_SearchHandler');
}
Example #27
0
<?php

setlocale(LC_ALL, 'de_DE.UTF8');
$currentpage = str_replace(".php", "", basename($_SERVER['PHP_SELF']));
PerchSystem::set_var('currentpage', $currentpage);
// print $currentpage;
?>
<!DOCTYPE html>
<html lang="de">
    <head>
    <meta charset="utf-8">
    <title>F R W S S R
    <?php 
if (perch_get('post')) {
    print "| geblogt: ";
    print perch_blog_post_field(perch_get('post'), 'postTitle');
}
?>
    </title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="author" content="FEUERWASSER">
    <meta name="publisher" content="FEUERWASSER">
    <meta name="copyright" content="FEUERWASSER">
    <meta name="description" content="">
    <meta name="keywords" content="Blog, FEUERWASSER, Agentur, Grafik, Webdesign, Grafikdesign, Walldorf, Wiesloch, Heidelberg">
    <meta name="page-topic" content="Design für Print und Web, FEEURWASSER Arbeitsweise, Design-Tipps für kleine und mittelgroße Unternehmen (KMU), Werkzeuge und Dienste für Design und Webentwicklung">
    <meta name="robots" content="all">
    <meta http-equiv="pragma" content="no-cache">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--     <link rel="alternate" type="application/rss+xml" title="RSS" href="rss.php" /> -->
<?php 
Example #28
0
<?php

PerchSystem::register_search_handler('PerchEvents_SearchHandler');
require 'PerchEvents_Events.class.php';
require 'PerchEvents_Event.class.php';
require 'PerchEvents_Categories.class.php';
require 'PerchEvents_Category.class.php';
require 'PerchEvents_DisplayCalendar.class.php';
require 'PerchEvents_DisplayListing.class.php';
require 'PerchEvents_SearchHandler.class.php';
require 'PerchEvents_Cache.class.php';
function perch_events_calendar($opts = false, $return = false)
{
    $year = date('Y');
    $month = date('m');
    if (isset($_GET['d']) && $_GET['d'] != '') {
        $date = explode('-', $_GET['d']);
        if (isset($date[0])) {
            $year = (int) $date[0];
        }
        if (isset($date[1])) {
            $month = (int) $date[1];
        }
    }
    $API = new PerchAPI(1.0, 'perch_events');
    $Events = new PerchEvents_Events($API);
    $r = $Events->get_display('calendar', $month, $year, $opts);
    if ($return) {
        return $r;
    }
    echo $r;
Example #29
0
<?php

$domain = 'http://' . $_SERVER["HTTP_HOST"];
$url = $domain . $_SERVER["REQUEST_URI"];
$sitename = "Waterford Kamhlaba UWCSA";
$twittername = "@WaterfordUWCSA";
PerchSystem::set_var('domain', $domain);
PerchSystem::set_var('url', $url);
PerchSystem::set_var('sitename', $sitename);
PerchSystem::set_var('twittername', $twittername);
perch_page_attributes(array('template' => 'head.html'));
<?php

include 'classes/JwTranslations_TemplateHandler.php';
include 'classes/JwTranslations_Loader.php';
PerchSystem::register_template_handler('JwTranslations_TemplateHandler');
/**
 * Get translation string
 *
 * @param $id
 * @param array $opts
 * @param bool|false $return
 * @return array|mixed|null
 */
function get_translation($id, array $opts = array(), $return = false)
{
    $defaults = array('default' => null, 'lang' => PERCH_TRANSLATION_LANG, 'placeholders' => false);
    $opts = array_merge($defaults, $opts);
    $TranslationHelper = JwTranslations_Loader::fetch();
    $value_string = $TranslationHelper->get_translation($id, $opts['lang'], $opts['default']);
    if ($opts['placeholders']) {
        $s = '/:\\w+/';
        $count = preg_match_all($s, $value_string, $matches, PREG_SET_ORDER);
        if ($count > 0) {
            foreach ($matches as $match) {
                $replacement = $match[0];
                $placeholder = str_replace('-', '_', trim($match[0], ':'));
                if (array_key_exists($placeholder, $opts['placeholders'])) {
                    $value_string = str_replace($replacement, $opts['placeholders'][$placeholder], $value_string);
                }
            }
        }