Exemplo n.º 1
0
function fillUrlCache()
{
    echo "  Filling URL Cache...";
    $mapper = new Application_Model_UrlcacheMapper();
    foreach ($mapper->findAllUntitled() as $urlcache) {
        $url = $urlcache->getDomain() . $urlcache->getPath();
        $title = getTitle($url);
        if ($title == null) {
            $title = $urlcache->getPath();
        }
        echo "Setting title of {$url} to {$title}...\n";
        $urlcache->setTitle($title);
        $mapper->save($urlcache);
    }
}
Exemplo n.º 2
0
 public function submitAction()
 {
     /*****************************************************
      * Add a new comment to the database from a form,
      * or if there's none supplied return the form.
      * We then do a poll and send back the whole lot
      * as JSON.
      */
     //IE doesn't sent a content-type header with X site requests,
     //And PHP doesn't fill in $_POST if that happens. Fix it:
     $request_body = urldecode(file_get_contents("php://input"));
     parse_str($request_body, $_POST);
     $this->view->title = "Submit Conversation";
     $this->allowAccessControl();
     $request = $this->getRequest();
     $form = new Application_Form_Comment();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $initVals = $form->getValues();
             $initVals = $this->formDataToObjectData($initVals);
             if (!is_array($initVals)) {
                 throw new Exception("Can't initialize form data");
             }
             if (substr($initVals['content'], 0, 1) == "/") {
                 //Oh, special command!
                 $reply = $this->processCommand($initVals);
                 $this->doPollingStuffAndOutputJSON(array("command" => $initVals['content'], "content" => $reply));
             } else {
                 //Just submit the comment.
                 $comment = new Application_Model_Comment($initVals);
                 $mapper = new Application_Model_CommentMapper();
                 $mapper->save($comment);
                 $urlcachemapper = new Application_Model_UrlcacheMapper();
                 $urlcache = $urlcachemapper->findOneWhere($comment->getDomain(), $comment->getPath());
                 $urlcache->incPostcount();
                 $urlcachemapper->save($urlcache);
             }
             $this->doPollingStuffAndOutputJSON(array("content" => $comment->getContent(), "nick" => $comment->getNick(), "email" => $comment->getEmail()));
         }
     }
     $this->view->form = $form;
 }