Ejemplo n.º 1
0
function wikipedia_process_term($term)
{
    $pts = urldecode($term);
    $pts = explode(' of ', $pts, 2);
    $pts = explode(' and ', $pts[0], 2);
    $pts = $pts[0];
    $ret = urlencode(depluralize($pts));
    return $ret;
}
Ejemplo n.º 2
0
function twig_depluralize_string_filter($string)
{
    return depluralize($string);
}
Ejemplo n.º 3
0
<?php

/**
 * Template Name: Three Columns
 * @package WordPress
 * @subpackage Zing_Design
 * @since Zing Design 1.0
 */
$current_page = get_post();
$page_name = depluralize($current_page->post_name);
$current_post_type = "zd_" . $page_name . "s";
// var_dump($page_name);
get_header();
?>

<div id="main-content" class="main-content">

<?php 
//if ( is_front_page() && zd_has_featured_posts() ) {
// Include the featured content template.
//	get_template_part( 'featured-content' );
//}
?>

<!--    <div class="row">-->
        <div class="medium-12 columns content">
            <?php 
// Start the Loop.
while (have_posts()) {
    the_post();
    // Include the page content template.
Ejemplo n.º 4
0
 /**
  * Function: from_url
  * Attempts to grab a post from its clean URL.
  */
 static function from_url($attrs = null, $options = array())
 {
     fallback($attrs, $_GET);
     $where = array();
     $times = array("year", "month", "day", "hour", "minute", "second");
     preg_match_all("/\\(([^\\)]+)\\)/", Config::current()->post_url, $matches);
     $params = array();
     foreach ($matches[1] as $attr) {
         if (in_array($attr, $times)) {
             $where[strtoupper($attr) . "(created_at)"] = $attrs[$attr];
         } elseif ($attr == "author") {
             $user = new User(array("login" => $attrs['author']));
             $where["user_id"] = $user->id;
         } elseif ($attr == "feathers") {
             $where["feather"] = depluralize($attrs['feathers']);
         } else {
             $tokens = array($where, $params, $attr);
             Trigger::current()->filter($tokens, "post_url_token");
             list($where, $params, $attr) = $tokens;
             if ($attr !== null) {
                 if (!isset($attrs[$attr])) {
                     continue;
                 }
                 $where[$attr] = $attrs[$attr];
             }
         }
     }
     return new self(null, array_merge($options, array("where" => $where, "params" => $params)));
 }
Ejemplo n.º 5
0
 /**
  * Function: __get
  * Automatically handle model relationships when grabbing attributes of an object.
  *
  * Returns:
  *     @mixed@
  */
 public function __get($name)
 {
     $model_name = get_class($this);
     $placeholders = (isset($this->__placeholders) and $this->__placeholders);
     Trigger::current()->filter($filtered, $model_name . "_" . $name . "_attr", $this);
     if ($filtered !== false) {
         $this->{$name} = $filtered;
     }
     $this->belongs_to = (array) $this->belongs_to;
     $this->has_many = (array) $this->has_many;
     $this->has_one = (array) $this->has_one;
     if (in_array($name, $this->belongs_to) or isset($this->belongs_to[$name])) {
         $class = isset($this->belongs_to[$name]) ? $this->belongs_to[$name] : $name;
         if (isset($this->belongs_to[$name])) {
             $opts =& $this->belongs_to[$name];
             $model = oneof(@$opts["model"], $name);
             if (preg_match("/^\\(([a-z0-9_]+)\\)\$/", $model, $match)) {
                 $model = $this->{$match}[1];
             }
             $match = oneof(@$opts["by"], strtolower($name));
             fallback($opts["where"], array("id" => $this->{$match . "_id"}));
             $opts["where"] = (array) $opts["where"];
             foreach ($opts["where"] as &$val) {
                 if (preg_match("/^\\(([a-z0-9_]+)\\)\$/", $val, $match)) {
                     $val = $this->{$match}[1];
                 }
             }
             fallback($opts["placeholders"], $placeholders);
         } else {
             $model = $name;
             $opts = array("where" => array("id" => $this->{$name . "_id"}));
         }
         return $this->{$name} = new $model(null, $opts);
     } elseif (in_array($name, $this->has_many) or isset($this->has_many[$name])) {
         if (isset($this->has_many[$name])) {
             $opts =& $this->has_many[$name];
             $model = oneof(@$opts["model"], depluralize($name));
             if (preg_match("/^\\(([a-z0-9_]+)\\)\$/", $model, $match)) {
                 $model = $this->{$match}[1];
             }
             $match = oneof(@$opts["by"], strtolower($name));
             fallback($opts["where"], array($match . "_id" => $this->id));
             $opts["where"] = (array) $opts["where"];
             foreach ($opts["where"] as &$val) {
                 if (preg_match("/^\\(([a-z0-9_]+)\\)\$/", $val, $match)) {
                     $val = $this->{$match}[1];
                 }
             }
             fallback($opts["placeholders"], $placeholders);
         } else {
             $model = depluralize($name);
             $match = $model_name;
             $opts = array("where" => array(strtolower($match) . "_id" => $this->id), "placeholders" => $placeholders);
         }
         return $this->{$name} = call_user_func(array($model, "find"), $opts);
     } elseif (in_array($name, $this->has_one) or isset($this->has_one[$name])) {
         if (isset($this->has_one[$name])) {
             $opts =& $this->has_one[$name];
             $model = oneof(@$opts["model"], depluralize($name));
             if (preg_match("/^\\(([a-z0-9_]+)\\)\$/", $model, $match)) {
                 $model = $this->{$match}[1];
             }
             $match = oneof(@$opts["by"], strtolower($name));
             fallback($opts["where"], array($match . "_id" => $this->id));
             $opts["where"] = (array) $opts["where"];
             foreach ($opts["where"] as &$val) {
                 if (preg_match("/^\\(([a-z0-9_]+)\\)\$/", $val, $match)) {
                     $val = $this->{$match}[1];
                 }
             }
         } else {
             $model = depluralize($name);
             $match = $model_name;
             $opts = array("where" => array(strtolower($match) . "_id" => $this->id));
         }
         return $this->{$name} = new $model(null, $opts);
     }
     if (isset($this->{$name})) {
         return $this->{$name};
     }
 }
Ejemplo n.º 6
0
 /**
  * Function: subnav_context
  * Generates the context variables for the subnav.
  */
 public function subnav_context($action)
 {
     $trigger = Trigger::current();
     $visitor = Visitor::current();
     $this->context["subnav"] = array();
     $subnav =& $this->context["subnav"];
     $subnav["write"] = array();
     $pages = array("manage" => array());
     foreach (Config::current()->enabled_feathers as $index => $feather) {
         $info = YAML::load(FEATHERS_DIR . "/" . $feather . "/info.yaml");
         $subnav["write"]["write_post&feather=" . $feather] = array("title" => __($info["name"], $feather), "show" => $visitor->group->can("add_draft", "add_post"), "attributes" => ' id="list_feathers[' . $feather . ']"', "selected" => isset($_GET['feather']) and $_GET['feather'] == $feather or !isset($_GET['feather']) and $action == "write_post" and !$index);
     }
     # Write navs
     $subnav["write"]["write_page"] = array("title" => __("Page"), "show" => $visitor->group->can("add_page"));
     $trigger->filter($subnav["write"], array("admin_write_nav", "write_nav"));
     $pages["write"] = array_merge(array("write_post"), array_keys($subnav["write"]));
     # Manage navs
     $subnav["manage"] = array("manage_posts" => array("title" => __("Posts"), "show" => Post::any_editable() or Post::any_deletable(), "selected" => array("edit_post", "delete_post")), "manage_pages" => array("title" => __("Pages"), "show" => $visitor->group->can("edit_page", "delete_page"), "selected" => array("edit_page", "delete_page")), "manage_users" => array("title" => __("Users"), "show" => $visitor->group->can("add_user", "edit_user", "delete_user"), "selected" => array("edit_user", "delete_user", "new_user")), "manage_groups" => array("title" => __("Groups"), "show" => $visitor->group->can("add_group", "edit_group", "delete_group"), "selected" => array("edit_group", "delete_group", "new_group")));
     $trigger->filter($subnav["manage"], "manage_nav");
     $subnav["manage"]["import"] = array("title" => __("Import"), "show" => $visitor->group->can("add_post"));
     $subnav["manage"]["export"] = array("title" => __("Export"), "show" => $visitor->group->can("add_post"));
     $pages["manage"][] = "new_user";
     $pages["manage"][] = "new_group";
     foreach (array_keys($subnav["manage"]) as $manage) {
         $pages["manage"] = array_merge($pages["manage"], array($manage, preg_replace_callback("/manage_(.+)/", function ($m) {
             return "edit_" . depluralize($m[1]);
         }, $manage), preg_replace_callback("/manage_(.+)/", function ($m) {
             return "delete_" . depluralize($m[1]);
         }, $manage)));
     }
     # Settings navs
     $subnav["settings"] = array("general_settings" => array("title" => __("General"), "show" => $visitor->group->can("change_settings")), "content_settings" => array("title" => __("Content"), "show" => $visitor->group->can("change_settings")), "user_settings" => array("title" => __("Users"), "show" => $visitor->group->can("change_settings")), "route_settings" => array("title" => __("Routes"), "show" => $visitor->group->can("change_settings")));
     $trigger->filter($subnav["settings"], "settings_nav");
     $pages["settings"] = array_keys($subnav["settings"]);
     # Extend navs
     $subnav["extend"] = array("modules" => array("title" => __("Modules"), "show" => $visitor->group->can("toggle_extensions")), "feathers" => array("title" => __("Feathers"), "show" => $visitor->group->can("toggle_extensions")), "themes" => array("title" => __("Themes"), "show" => $visitor->group->can("toggle_extensions")));
     $trigger->filter($subnav["extend"], "extend_nav");
     $pages["extend"] = array_keys($subnav["extend"]);
     foreach (array_keys($subnav) as $main_nav) {
         foreach ($trigger->filter($pages[$main_nav], $main_nav . "_nav_pages") as $extend) {
             $subnav[$extend] =& $subnav[$main_nav];
         }
     }
     foreach ($subnav as $main_nav => &$sub_nav) {
         foreach ($sub_nav as &$nav) {
             $nav["show"] = (!isset($nav["show"]) or $nav["show"]);
         }
     }
     $trigger->filter($subnav, "admin_subnav");
 }
Ejemplo n.º 7
0
 public function parse($route)
 {
     $config = Config::current();
     if ($this->feed) {
         $this->post_limit = $config->feed_items;
     } else {
         $this->post_limit = $config->posts_per_page;
     }
     if (empty($route->arg[0]) and !isset($config->routes["/"])) {
         # If they're just at /, don't bother with all this.
         return $route->action = "index";
     }
     # Protect non-responder functions.
     if (in_array($route->arg[0], array("__construct", "parse", "display", "current"))) {
         show_404();
     }
     # Feed
     if (preg_match("/\\/feed\\/?\$/", $route->request)) {
         $this->feed = true;
         $this->post_limit = $config->feed_items;
         if ($route->arg[0] == "feed") {
             # Don't set $route->action to "feed" (bottom of this function).
             return $route->action = "index";
         }
     }
     # Feed with a title parameter
     if (preg_match("/\\/feed\\/([^\\/]+)\\/?\$/", $route->request, $title)) {
         $this->feed = true;
         $this->post_limit = $config->feed_items;
         $_GET['title'] = $title[1];
         if ($route->arg[0] == "feed") {
             # Don't set $route->action to "feed" (bottom of this function).
             return $route->action = "index";
         }
     }
     # Paginator
     if (preg_match_all("/\\/((([^_\\/]+)_)?page)\\/([0-9]+)/", $route->request, $page_matches)) {
         foreach ($page_matches[1] as $key => $page_var) {
             $_GET[$page_var] = (int) $page_matches[4][$key];
         }
         if ($route->arg[0] == $page_matches[1][0]) {
             # Don't fool ourselves into thinking we're viewing a page.
             return $route->action = isset($config->routes["/"]) ? $config->routes["/"] : "index";
         }
     }
     # Viewing a type
     if ($route->arg[0] == "type") {
         $_GET['url'] = $route->arg[1];
         return $route->action = "type";
     }
     # Viewing a type (backwards-compatible URL)
     if ($route->arg[0] == "browse") {
         $_GET['url'] = depluralize($route->arg[1]);
         return $route->action = "type";
     }
     # Viewing an extension
     if ($route->arg[0] == "view") {
         $_GET['url'] = $route->arg[1];
         $_GET['version'] = @$route->arg[2];
         return $route->action = "view";
     }
     # Downloading an extension
     if ($route->arg[0] == "download") {
         $_GET['url'] = $route->arg[1];
         $_GET['version'] = @$route->arg[2];
         return $route->action = "download";
     }
     # Loving an extension
     if ($route->arg[0] == "love") {
         $_GET['url'] = $route->arg[1];
         $_GET['version'] = @$route->arg[2];
         return $route->action = "love";
     }
     # Adding an extension
     if ($route->arg[0] == "new_extension") {
         $_GET['type'] = oneof(@$route->arg[1], "module");
         return $route->action = "new_extension";
     }
     # Adding a new version of an extension
     if ($route->arg[0] == "new_version") {
         $_GET['url'] = $route->arg[1];
         return $route->action = "new_version";
     }
     if (in_array($route->arg[0], array("edit_version", "delete_version", "edit_note", "delete_note", "delete_extension"))) {
         $_GET['id'] = $route->arg[1];
         return $route->action = $route->arg[0];
     }
     # Searching
     if ($route->arg[0] == "search") {
         if (isset($route->arg[1])) {
             $_GET['query'] = $route->arg[1];
         }
         return $route->action = "search";
     }
     # Viewing a tag
     if ($route->arg[0] == "tag") {
         $_GET['url'] = $route->arg[1];
         return $route->action = "tag";
     }
     # Custom pages added by Modules, Feathers, Themes, etc.
     foreach ($config->routes as $path => $action) {
         if (is_numeric($action)) {
             $action = $route->arg[0];
         }
         preg_match_all("/\\(([^\\)]+)\\)/", $path, $matches);
         if ($path != "/") {
             $path = trim($path, "/");
         }
         $escape = preg_quote($path, "/");
         $to_regexp = preg_replace("/\\\\\\(([^\\)]+)\\\\\\)/", "([^\\/]+)", $escape);
         if ($path == "/") {
             $to_regexp = "\$";
         }
         if (preg_match("/^\\/{$to_regexp}/", $route->request, $url_matches)) {
             array_shift($url_matches);
             if (isset($matches[1])) {
                 foreach ($matches[1] as $index => $parameter) {
                     $_GET[$parameter] = urldecode($url_matches[$index]);
                 }
             }
             $params = explode(";", $action);
             $action = $params[0];
             array_shift($params);
             foreach ($params as $param) {
                 $split = explode("=", $param);
                 $_GET[$split[0]] = fallback($split[1], "", true);
             }
             $route->try[] = $action;
         }
     }
 }
Ejemplo n.º 8
0
                $i = 0;
                while ($i < count($data)) {
                    $tagsWord = $data[$i];
                    if (!in_array($tagsWord, $stopwords)) {
                        $class_word[$count1++] = depluralize($tagsWord);
                        $taglist[] = depluralize($tagsWord);
                    } else {
                        $junkWords[] = $tagsWord;
                    }
                    $i++;
                }
            } else {
                // remove stop words;
                if (!in_array($tagquery, $stopwords)) {
                    $class_word[$count1++] = depluralize($tagquery);
                    $taglist[] = depluralize($tagquery);
                } else {
                    $junkWords[] = $tagquery;
                }
            }
        }
    }
}
echo '</div>';
###############################################################
#   Compute Processing Time
###############################################################
//    $time_elapsed_secs = microtime(true) - $start;
//
//    echo 'Elapsed(s):' . $time_elapsed_secs;
//
Ejemplo n.º 9
0
 /**
  * Function: exists
  * Checks for flash messages.
  *
  * Parameters:
  *     $type - The type of message to check for.
  */
 static function exists($type = null)
 {
     if (self::$exists[$type]) {
         return self::$exists[$type];
     }
     if (isset($type)) {
         return self::$exists[$type] = !empty($_SESSION[pluralize($type)]);
     } else {
         foreach (array("messages", "notices", "warnings") as $type) {
             if (!empty($_SESSION[$type])) {
                 return self::$exists[depluralize($type)] = self::$exists[null] = true;
             }
         }
     }
     return false;
 }