Example #1
0
 function getRenderedLayout($layout, $tag, $topic)
 {
     //Get layout Markup and its tokens
     $layoutMarkup = $this->getLayoutSource($layout);
     // Get layout HTML content (default:layout_default.ctp)
     $matches = $this->getMatchElements($layoutMarkup);
     // Get matching elements
     $layoutTokens = $this->getLayoutModuleTokens($matches);
     // return arrays of token values
     App::import("Controller", "Modules");
     $Modules = new ModulesController();
     $Modules->constructClasses();
     $dataModuleResult = $Modules->getModules($layoutTokens);
     //Get Modules content
     App::import("Controller", "Datarows");
     $Datarows = new DatarowsController();
     $Datarows->constructClasses();
     $Content = $Datarows->getDatarows($layoutTokens, $tag, $topic);
     //Get final layout Markup
     $layoutMarkup = $this->getlayoutMarkup($layoutMarkup, $layoutTokens, $dataModuleResult, $Content, $matches, $topic);
     return $layoutMarkup;
 }
Example #2
0
 function getModuleJSON($name, $tag, $topic, &$json, $options)
 {
     //get content
     App::import("Controller", "Datarows");
     $Datarows = new DatarowsController();
     $Datarows->constructClasses();
     $module_content = $Datarows->setContent($name, $tag, $topic, $options);
     $output = array();
     //echo "<pre>"; print_r($module_content); echo "</pre>";
     foreach ($module_content as $item) {
         $date = date('Y-m-d', strtotime($item["Datarow"]["published"]));
         $date_published = date('M d, Y', strtotime($date));
         $date_twitter = getTwitterDateFormat($item["Datarow"]["published"]);
         if (!isset($output[$date])) {
             $output[$date] = array();
         }
         if ($name == "twitter") {
             //parse author
             $parts = explode(" (", $item["Datarow"]["author"]);
             if (count($parts) == 2) {
                 $screen_name = trim($parts[0]);
                 $real_name = trim(str_replace(")", "", $parts[1]));
             } else {
                 $screen_name = $item["Datarow"]["author"];
                 $real_name = $item["Datarow"]["author"];
             }
             //adjust date
             $post = array("topic" => $this->Topic->getTopicAbbr($topic), "user" => array("profile_image_url" => $item["Datarow"]["thumb"], "screen_name" => $screen_name, "name" => $real_name, "protected" => false), "id" => $item["Datarow"]["id"], "text" => str_replace(array('>', '<'), array('&gt;', '&lt;'), strip_tags($item["Datarow"]["content"])), "created_at" => $date_twitter, "truncated" => false, "status_id" => substr($item["Datarow"]["articleId"], strrpos($item["Datarow"]["articleId"], "statuses") + 9, 60));
         } else {
             if ($name == "youtube" || $name == "queue") {
                 $post = array("topic" => $this->Topic->getTopicAbbr($topic), "title" => str_replace(array('>', '<'), array('&gt;', '&lt;'), strip_tags($item["Datarow"]["title"])), "text" => str_replace(array('>', '<'), array('&gt;', '&lt;'), strip_tags($item["Datarow"]["content"])), "truncated" => false, "image_url" => $item["Datarow"]["thumb"], "service" => "youtube", "video_id" => $item["Datarow"]["articleId"], "id" => $item["Datarow"]["id"]);
             } else {
                 if ($name == "blogs" || $name == "news" || $name == "articles") {
                     //get source loaction
                     $location = $item["Datarow"]["articleId"];
                     $location = str_replace("http://", "", $location);
                     $parts = explode("/", $location);
                     $location = "http://" . $parts[0];
                     $post = array("topic" => $this->Topic->getTopicAbbr($topic), "source" => array("name" => $item["Datarow"]["author"], "location" => $location), "title" => str_replace(array('>', '<'), array('&gt;', '&lt;'), strip_tags($item["Datarow"]["title"])), "text" => str_replace(array('>', '<'), array('&gt;', '&lt;'), strip_tags($item["Datarow"]["content"])), "created_at" => $date_published, "truncated" => false, "location" => $item["Datarow"]["articleId"], "id" => $item["Datarow"]["id"]);
                 } else {
                     if ($name == "bubble" || $name == "featured") {
                         $post = array("topic" => $this->Topic->getTopicAbbr($topic), "title" => str_replace(array('>', '<'), array('&gt;', '&lt;'), strip_tags($item["Datarow"]["title"])), "text" => "", "truncated" => false, "location" => str_replace(array('>', '<'), array('&gt;', '&lt;'), strip_tags($item["Datarow"]["content"])), "image_url" => $item["Datarow"]["thumb"], "id" => $item["Datarow"]["id"]);
                     } else {
                         if ($name == "jobs") {
                             $post = array("topic" => $this->Topic->getTopicAbbr($topic), "title" => str_replace(array('>', '<'), array('&gt;', '&lt;'), strip_tags($item["Datarow"]["title"])), "content" => str_replace(array('>', '<'), array('&gt;', '&lt;'), strip_tags($item["Datarow"]["content"])), "truncated" => false, "position" => $item["Datarow"]["thumb"], "job_type" => $item["Datarow"]["author"], "id" => $item["Datarow"]["articleId"], "created" => $item["Datarow"]["created"], "modified" => $item["Datarow"]["modified"]);
                         }
                     }
                 }
             }
         }
         array_push($output[$date], $post);
     }
     //sort
     if ($name != "youtube" && $name != "queue") {
         krsort($output);
     }
     foreach ($output as $date => $posts) {
         $date_year = date('Y', strtotime($date));
         $date_day = date('j', strtotime($date));
         $date_month = date('F', strtotime($date));
         $date_dow = date('l', strtotime($date));
         $date_day_abbr = strtolower(date('D', strtotime($date)));
         $date_month_abbr = strtolower(date('M', strtotime($date)));
         if ($name != "youtube" && $name != "queue" && $name != "featured" && $name != "bubble") {
             array_push($json[$this->getModuleAlias($name)], array("date" => array("year" => $date_year, "month" => $date_month, "date" => $date_day, "day" => $date_dow, "day_abbr" => $date_day_abbr, "month_abbr" => $date_month_abbr), "posts" => $posts));
         } else {
             if (!isset($json[$this->getModuleAlias($name)]["posts"])) {
                 $json[$this->getModuleAlias($name)]["posts"] = array();
             }
             foreach ($posts as $post) {
                 array_push($json[$this->getModuleAlias($name)]["posts"], $post);
             }
         }
     }
     return $json;
 }