当前位置: 首页>>代码示例>>PHP>>正文


PHP Page::add方法代码示例

本文整理汇总了PHP中Page::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::add方法的具体用法?PHP Page::add怎么用?PHP Page::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Page的用法示例。


在下文中一共展示了Page::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: post_add_page

 public function post_add_page()
 {
     $rules = Config::get('rules.add_page');
     $validation = Validator::make(Input::get(), $rules);
     if ($validation->passes()) {
         if (Page::add(Input::get())) {
             return Redirect::to('add_page')->with('success', TRUE);
         }
         return Event::first('500', 'The page could not be added due to a system error. We apologize for any inconvenience.');
     }
     return Redirect::to('add_page')->with_input()->with_errors($validation);
 }
开发者ID:bankorh,项目名称:ecom1_laravel,代码行数:12,代码来源:admin.php

示例2: auth

	 *	N/X is free software; you can redistribute it and/or modify
	 *	it under the terms of the GNU General Public License as published by
	 *	the Free Software Foundation; either version 2 of the License, or
	 *	(at your option) any later version.
	 *
	 *	N/X is distributed in the hope that it will be useful,
	 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
	 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	 *	GNU General Public License for more details.
	 *
	 *	You should have received a copy of the GNU General Public License
	 *	along with N/X; if not, write to the Free Software
	 *	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
	**********************************************************************/
	
	require_once "../../config.inc.php";
	$auth = new auth("ANY");
	require_once "nxtoday.inc.php";

	$nxtoday = new NXToday();
	$nxtoday->QuickLinks->add(new NXToday_SPLink(100140));
	$nxtoday->QuickLinks->add(new NXToday_ChannelLink("News"));
	$nxtoday->QuickLinks->add(new NXToday_SPLink(100083));
	$nxtoday->QuickLinks->add(new NXToday_ChannelLink("test"));


$page = new Page('N/X Today');
$page->add($nxtoday);
$page->draw();
?>
开发者ID:BackupTheBerlios,项目名称:nxwcms-svn,代码行数:30,代码来源:nxtoday.php

示例3: importer

function importer($path, $node, $line)
{
    global $blogid, $migrational, $items, $item;
    switch ($path) {
        case '/blog/setting':
            setProgress($item++ / $items * 100, _t('블로그 설정을 복원하고 있습니다.'));
            $setting = new BlogSetting();
            if (isset($node['title'][0]['.value'])) {
                $setting->title = $node['title'][0]['.value'];
            }
            if (isset($node['description'][0]['.value'])) {
                $setting->description = $node['description'][0]['.value'];
            }
            if (isset($node['banner'][0]['name'][0]['.value'])) {
                $setting->banner = $node['banner'][0]['name'][0]['.value'];
            }
            if (isset($node['useSloganOnPost'][0]['.value'])) {
                $setting->useSloganOnPost = $node['useSloganOnPost'][0]['.value'];
            }
            if (isset($node['postsOnPage'][0]['.value'])) {
                $setting->postsOnPage = $node['postsOnPage'][0]['.value'];
            }
            if (isset($node['postsOnList'][0]['.value'])) {
                $setting->postsOnList = $node['postsOnList'][0]['.value'];
            }
            if (isset($node['postsOnFeed'][0]['.value'])) {
                $setting->postsOnFeed = $node['postsOnFeed'][0]['.value'];
            }
            if (isset($node['publishWholeOnFeed'][0]['.value'])) {
                $setting->publishWholeOnFeed = $node['publishWholeOnFeed'][0]['.value'];
            }
            if (isset($node['acceptGuestComment'][0]['.value'])) {
                $setting->acceptGuestComment = $node['acceptGuestComment'][0]['.value'];
            }
            if (isset($node['acceptcommentOnGuestComment'][0]['.value'])) {
                $setting->acceptcommentOnGuestComment = $node['acceptcommentOnGuestComment'][0]['.value'];
            }
            if (isset($node['language'][0]['.value'])) {
                $setting->language = $node['language'][0]['.value'];
            }
            if (isset($node['timezone'][0]['.value'])) {
                $setting->timezone = $node['timezone'][0]['.value'];
            }
            if (!$setting->save()) {
                user_error(__LINE__ . $setting->error);
            }
            if (!empty($setting->banner) && !empty($node['banner'][0]['content'][0]['.stream'])) {
                Attachment::confirmFolder();
                Utils_Base64Stream::decode($node['banner'][0]['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $setting->banner));
                Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $setting->banner));
                fclose($node['banner'][0]['content'][0]['.stream']);
                unset($node['banner'][0]['content'][0]['.stream']);
            }
            return true;
        case '/blog/category':
            setProgress($item++ / $items * 100, _t('분류를 복원하고 있습니다.'));
            $category = new Category();
            $category->name = $node['name'][0]['.value'];
            $category->priority = $node['priority'][0]['.value'];
            if (isset($node['root'][0]['.value'])) {
                $category->id = 0;
            }
            if (!$category->add()) {
                user_error(__LINE__ . $category->error);
            }
            if (isset($node['category'])) {
                for ($i = 0; $i < count($node['category']); $i++) {
                    $childCategory = new Category();
                    $childCategory->parent = $category->id;
                    $cursor =& $node['category'][$i];
                    $childCategory->name = $cursor['name'][0]['.value'];
                    $childCategory->priority = $cursor['priority'][0]['.value'];
                    if (!$childCategory->add()) {
                        user_error(__LINE__ . $childCategory->error);
                    }
                }
            }
            return true;
        case '/blog/post':
            setProgress($item++ / $items * 100, _t('글을 복원하고 있습니다.'));
            $post = new Post();
            $post->id = $node['id'][0]['.value'];
            $post->slogan = @$node['.attributes']['slogan'];
            $post->visibility = $node['visibility'][0]['.value'];
            if (isset($node['starred'][0]['.value'])) {
                $post->starred = $node['starred'][0]['.value'];
            } else {
                $post->starred = 0;
            }
            $post->title = $node['title'][0]['.value'];
            $post->content = $node['content'][0]['.value'];
            $post->contentformatter = isset($node['content'][0]['.attributes']['formatter']) ? $node['content'][0]['.attributes']['formatter'] : 'ttml';
            $post->contenteditor = isset($node['content'][0]['.attributes']['editor']) ? $node['content'][0]['.attributes']['editor'] : 'modern';
            $post->location = $node['location'][0]['.value'];
            $post->password = isset($node['password'][0]['.value']) ? $node['password'][0]['.value'] : null;
            $post->acceptcomment = $node['acceptComment'][0]['.value'];
            $post->accepttrackback = $node['acceptTrackback'][0]['.value'];
            $post->published = $node['published'][0]['.value'];
            if (isset($node['longitude'][0]['.value'])) {
                $post->longitude = $node['longitude'][0]['.value'];
//.........这里部分代码省略.........
开发者ID:webhacking,项目名称:Textcube,代码行数:101,代码来源:index.php

示例4: add

<?php

require 'Renderers.php';
class Page
{
    protected $renderers = [];
    public function add(Renderer $renderer)
    {
        $this->renderers[] = $renderer;
    }
    public function render()
    {
        $content = '';
        $content .= "--Start of Page--\n";
        $content .= array_reduce($this->renderers, function ($output, $r) {
            return $output .= $r->render() . "\n";
        }, '');
        $content .= "--End of Page--\n";
        return $content;
    }
}
$page = new Page();
$page->add(new BlogRenderer());
$page->add(new ArticleRenderer());
$page->add(new GraphRenderer());
// $page->add(new Page());
echo $page->render();
开发者ID:elagith,项目名称:learningMaterial,代码行数:27,代码来源:Example.php

示例5: Wizard

require_once $c["path"] . "api/userinterface/wizard/stcheckarchive.php";
require_once $c["path"] . "api/userinterface/wizard/stimportimages.php";
$wizard = new Wizard($lang->get("imp_impages", "Import Images"));
$wizard->setTitleText($lang->get("wz_import_im_title", "This wizard is used for importing importing images to N/X. Pack the images into a zip archive. The wizard will then create the data."));
if ($wizard->firstRun) {
    $_SESSION["archivefolder"] = "";
}
////// STEP 1 //////
$step1 = new Step();
$step1->setTitle($lang->get("wzt_archive_file", "Select Archive"));
$step1->setExplanation($lang->get("wze_archive_file", "Please select the zip-archive you want to import. The images must be into that archive in a flat structure, having no folders."));
$step1->add(new WZUploadArchive("upload"));
$step2 = new STCheckArchive();
$step2->setTitle($lang->get("wzt_ach_check", "Check Archive"));
$step2->setExplanation($lang->get("wze_arch_check", "Please control the result of the archive checks and press next if you want to resume."));
$step3 = new Step();
$step3->setTitle($lang->get("wzt_dest_folder", "Select destination folder"));
$step3->setExplanation($lang->get("wze_dest_folder", "Please select the folder, where all the new pictures will be copied to."));
$folders = array();
createFolders($folders, ' / ', 0);
$step3->add(new WZSelect('folder', $lang->get("dest_folder", "Destination folder"), $folders));
$step4 = new STImportImages();
$step4->setTitle($lang->get("wzt_imp_imag", "Importing images..."));
$wizard->add($step1);
$wizard->add($step2);
$wizard->add($step3);
$wizard->add($step4);
$page->add($wizard);
$page->draw();
$db->close();
echo $errors;
开发者ID:BackupTheBerlios,项目名称:nxwcms-svn,代码行数:31,代码来源:import.php

示例6: Page

<?php

require 'vendor/autoload.php';
require 'modules/appSettings.inc.php';
require 'modules/JsonSettings.class.php';
require 'modules/actionsRedirector.php';
if (!$isAction) {
    require 'modules/Page.class.php';
    $page = new Page();
    $page->add("header");
    $page->add("controls");
    $page->add("footer", $page->js());
}
开发者ID:pigetnet,项目名称:WEB_piget,代码行数:13,代码来源:index.php

示例7: addWordpressPage

 function addWordpressPage(Page $p, CollectionType $ct, PageLite $pl, $xmlID)
 {
     /*		echo $pl->getPostdate();
     		exit;
     		*/
     $u = new User();
     $pageAuthor = $pl->getAuthor();
     $ui = UserInfo::getByUserName($pageAuthor);
     if (is_object($ui)) {
         $uID = $ui->getUserID();
     } else {
         $uID = $u->getUserID();
     }
     $pageData = array('cName' => $pl->getTitle(), 'cDatePublic' => $pl->getPostdate(), 'cDateAdded' => $pl->getPostdate(), 'cDescription' => $pl->getExcerpt(), 'uID' => $uID);
     $newPage = $p->add($ct, $pageData);
     if (is_array($pl->getCategory())) {
         $newPage->setAttribute('wordpress_category', $pl->getCategory());
     }
     if (is_array($pl->getTags())) {
         $newPage->setAttribute('tags', $pl->getTags());
     }
     if (count($pl->getComments()) > 0) {
         $blocks = $newPage->getBlocks("Blog Post Footer");
         $haveGuestbook = 0;
         foreach ($blocks as $block) {
             if ($block->getBlockTypeHandle() == "guestbook") {
                 $bID = $block->getBlockID();
                 $haveGuestbook = 1;
             }
         }
         if ($haveGuestbook == 0) {
             $data = array();
             $data['title'] = "Comments:";
             $data['dateFormat'] = "M jS, Y";
             $data['requireApproval'] = 0;
             $data['displayGuestBookForm'] = 1;
             $data['authenticationRequired'] = 0;
             $data['displayCaptcha'] = 1;
             $bt = BlockType::getByHandle("guestbook");
             $guestbook = $newPage->addBlock($bt, "Blog Post Footer", $data);
             $bID = $guestbook->getBlockID();
         }
         Loader::model('comment_lite', 'wordpress_site_importer');
         $comments = $pl->getComments();
         foreach ($comments as $comment) {
             if (!$comment['comment_type'] == "pingback") {
                 CommentLite::addcomment($bID, $comment['commentText'], $comment['name'], $comment['email'], $comment['approved'], $newPage->getCollectionID(), 0, $comment['comment_date']);
             }
         }
     }
     $blocks = $newPage->getBlocks("Main");
     foreach ($blocks as $block) {
         $block->delete();
     }
     $blocks = $newPage->getBlocks("Blog Post More");
     foreach ($blocks as $block) {
         $block->delete();
     }
     Loader::model('block_types');
     $bt = BlockType::getByHandle('content');
     $data = array();
     $data['content'] = $this->importImages ? $this->determineImportableMediaFromContent($pl->getContent(), $pageData) : $pl->getContent();
     //we're either importing images or not
     $newPage->addBlock($bt, "Main", $data);
     $db = Loader::db();
     $q = 'UPDATE WordpressItems SET cID = ?, wpID = ?, wpParentID = ?, wpPostType = ? WHERE id=?';
     $v = array($newPage->getCollectionID(), $pl->getPostID(), $pl->getWpParentID(), $pl->getPostType(), $xmlID);
     $res = $db->query($q, $v);
     return $newPage;
 }
开发者ID:herent,项目名称:wordpress_site_importer,代码行数:70,代码来源:import.php

示例8: auth

 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with N/X; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 **********************************************************************/
require_once "../../config.inc.php";
require_once "ingredient_editor.php";
require_once "tag_selector.php";
$auth = new auth("ADMINISTRATOR");
$page = new Page("Edit Recipe");
$form = new stdEDForm($lang->get("edrecipe", "Edit Recipe"));
$cond = $form->setPK("pgn_recipes", "ID");
$form->addHeaderLink(crHeaderLink($lang->get("back"), "plugin/recipe/overview.php?sid=" . $sid));
$form->add(new TextInput($lang->get("name", "NAME"), "pgn_recipes", "NAME", $cond, "type:text,size:64,width:200", "MANDATORY"));
if ($page_action == "UPDATE") {
    $values = createNameValueArrayEx("pgn_recipes_tags", "TAG", "TAG_ID", "1", "ORDER BY TAG ASC");
    $form->add(new TagEditor("Tags", "pgn_recipes_tag_relation", "REC_ID", $oid, "TAG_ID", $values));
}
$form->add(new SubTitle("st", $lang->get("ingredients", "Ingredients"), 2));
$form->add(new IngredientEditor("pgn_recipes", $cond));
$form->add(new SubTitle("st", $lang->get("preparation", "Preparation"), 2));
$form->add(new TextInput($lang->get("preparation", "Preparation"), "pgn_recipes", "PREPARATION", $cond, "type:textarea,size:6,width:300", ""));
$form->add(new TextInput($lang->get("description", "Description"), "pgn_recipes", "DESCRIPTION", $cond, "type:textarea,size:6,width:300", ""));
$deleteHandler = new ActionHandler("DELETE");
$deleteHandler->addDbAction("DELETE FROM pgn_recipes WHERE ID={$oid} ");
$deleteHandler->addDbAction("DELETE FROM pgn_recipes_tag_relation WHERE REC_ID={$oid} ");
$form->registerActionHandler($deleteHandler);
$page->add($form);
$page->draw();
开发者ID:BackupTheBerlios,项目名称:nxwcms-svn,代码行数:31,代码来源:edit.php

示例9: Page

<?php

$this->addScript('/admin/js/ckeditor/ckeditor.js');
$this->addScript('/admin/js/ckeditor/adapters/jquery.js');
$objPage = new Page($this->objLanguage);
$objForm = new Form($this->objUrl);
$objValidation = new Validation($this->objLanguage);
$expected = array('name', 'content', 'meta_title', 'meta_description', 'meta_keywords', 'identity');
$required = array('name', 'content', 'meta_title', 'meta_description', 'meta_keywords', 'identity');
if (isset($_POST['name'])) {
    $array = $objForm->post2Array($expected, 'content', array('identity' => 'sanitise'));
    if (array_key_exists('identity', $array) && !empty($array['identity']) && $objPage->duplicate($array['identity'])) {
        $objValidation->add2Errors('identity', 'identity_taken');
    }
    if ($objValidation->isValid($array, $required)) {
        if ($objPage->add($array)) {
            Helper::redirect($this->objUrl->getCurrent(array('a', 'id')) . '/a/index');
        }
    }
}
require_once 'header.php';
?>

<h1><?php 
echo $this->objLanguage->labels[9];
?>
</h1>

<form method="post">
	<table class="tbl_insert">
		<tr>
开发者ID:joakinCC,项目名称:udemy.com-Multilingual-CMS-Website-with-PHP-MySQL-jQuery,代码行数:31,代码来源:add.php

示例10: addArticleAction

 public static function addArticleAction()
 {
     $titre = !empty($_POST['titre']) ? $_POST['titre'] : "Draft";
     $slug = !empty($_POST['slug']) ? $_POST['slug'] : "draft";
     $content = !empty($_POST['content']) ? $_POST['content'] : "";
     $shortDesc = strip_tags($content);
     $post_status = $_POST['post_status'] == 0 ? "publish" : $_POST['post_status'];
     $visibilite = $_POST['visibilite'] == 'password' && !empty($_POST['password']) ? $_POST['password'] : $_POST['visibilite'];
     $date = !empty($_POST['date']) ? $_POST['date'] : date("Y-m-d H:i:s");
     $tags = !empty($_POST['tags']) ? $_POST['tags'] : "";
     $format = $_POST['format'];
     $terms = !empty($_POST['terms']) ? $_POST['terms'] : 0;
     // echo json_encode($_POST);
     $page = new Page();
     $page->post_author = 1;
     $page->post_date = $date;
     $page->post_date_gmt = $date;
     $page->post_content = $content;
     $page->post_short_content = $shortDesc;
     $page->post_title = $titre;
     $page->post_status = $post_status;
     $page->comment_status = "open";
     $page->post_password = "";
     $page->post_name = $slug;
     $page->post_modified = "";
     $page->post_modified_gmt = "";
     $page->post_parent = 0;
     $page->guid = Config::get('app.base_url') . "page/t/" . $slug;
     //url
     $page->post_type = "post";
     $page->post_mime_type = "";
     $page->comment_count = 0;
     $page->terms_id = $terms;
     if ($page->add()) {
         switch ($format) {
             case "image":
                 break;
             case "video":
                 $media = new Media();
                 $getLastPosts = self::getPage("posts", "post_type='post'  ORDER BY ID DESC limit 0,1")[0];
                 $media->media_type = "video";
                 $media->media_name = $_POST['video_type'];
                 $media->media_value = $_POST['videoid'];
                 $media->post_id = $getLastPosts['ID'];
                 $media->add();
                 break;
             case "audio":
                 $media = new Media();
                 $getLastPosts = self::getPage("posts", "post_type='post'  ORDER BY ID DESC limit 0,1")[0];
                 $media->media_type = "audio";
                 $media->media_name = $_POST['audio_type'];
                 $media->media_value = $_POST['audioid'];
                 $media->post_id = $getLastPosts['ID'];
                 $media->add();
                 break;
         }
         if ($tags !== "") {
             $tagsOB = new Tag();
             $getLastPosts = self::getPage("posts", "post_type='post'  ORDER BY ID DESC limit 0,1")[0];
             $tagsOB->tag_value = $tags;
             $tagsOB->post_id = $getLastPosts['ID'];
             $tagsOB->add();
         }
         $arr = array('statut' => 'success', 'icon' => 'entypo-check alert-success', 'Message' => "Succeful !!");
         header("Content-type: application/json; charset=utf-8");
         echo json_encode($arr);
     } else {
         $arr = array('statut' => 'error', 'icon' => 'entypo-cancel-circled alert-danger', 'Message' => "Error d'insertion");
         header("Content-type: application/json; charset=utf-8");
         echo json_encode($arr);
     }
 }
开发者ID:amineabri,项目名称:ARFiesta,代码行数:72,代码来源:pages.php

示例11: DisplayStatistics

 public function DisplayStatistics(Page $oPage)
 {
     $aStats = array('Number of objects exported' => $this->aStatistics['objects_count'], 'Total export duration' => sprintf('%.3f s', $this->aStatistics['total_duration']), 'Data retrieval duration' => sprintf('%.3f s', $this->aStatistics['data_retrieval_duration']), 'Excel build duration' => sprintf('%.3f s', $this->aStatistics['excel_build_duration']), 'Excel write duration' => sprintf('%.3f s', $this->aStatistics['excel_write_duration']), 'Peak memory usage' => self::HumanDisplay($this->aStatistics['peak_memory_usage']));
     if ($oPage instanceof CLIPage) {
         $oPage->add($this->GetStatistics('text'));
     } else {
         $oPage->add($this->GetStatistics('html'));
     }
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:9,代码来源:excelexporter.class.inc.php

示例12: createForm

 /**
  * Creates log-in form.
  * Override if you want to use your own form. If you need to change template used by a log-in form,
  * add template/default/page/login.html.
  *
  * @param Page $page
  *
  * @return Form
  */
 public function createForm($page)
 {
     /** @type Form $form */
     $form = $page->add('Form', null, null, array('form/minimal'));
     /** @type Field $email */
     $email = $this->model->hasField($this->login_field);
     $email = $email ? $email->caption() : 'E-mail';
     /** @type Field $password */
     $password = $this->model->hasField($this->password_field);
     $password = $password ? $password->caption() : 'Password';
     $form->addField('Line', 'username', $email);
     $form->addField('Password', 'password', $password);
     $form->addSubmit('Login')->addClass('atk-jackscrew')->addClass('atk-swatch-green');
     //$form->add('View',null,'button_row_left')->addClass('atk-jackscrew');
     return $form;
 }
开发者ID:atk4,项目名称:atk4,代码行数:25,代码来源:Basic.php

示例13: Usage

function Usage(Page $oP)
{
    if (Utils::IsModeCLI()) {
        $oP->p('Usage: php ' . basename(__FILE__) . ' --auth_user=<user> --auth_pwd=<password> --expression=<OQL Query> --query=<phrasebook_id> [--arg_xxx=<query_arguments>] [--no_localize=0|1] [--format=<format>] [--format-options...]');
        $oP->p("Parameters:");
        $oP->p(" * auth_user: the iTop user account for authentication");
        $oP->p(" * auth_pwd: the password of the iTop user account");
    } else {
        $oP->p("Parameters:");
    }
    $oP->p(" * expression: an OQL expression (e.g. SELECT Contact WHERE name LIKE 'm%')");
    $oP->p(" * query: (alternative to 'expression') the id of an entry from the query phrasebook");
    $oP->p(" * arg_xxx: (needed if the query has parameters) the value of the parameter 'xxx'");
    $aSupportedFormats = BulkExport::FindSupportedFormats();
    $oP->p(" * format: (optional, default is html) the desired output format. Can be one of '" . implode("', '", array_keys($aSupportedFormats)) . "'");
    foreach ($aSupportedFormats as $sFormatCode => $sLabel) {
        $oExporter = BulkExport::FindExporter($sFormatCode);
        if ($oExporter !== null) {
            if (!Utils::IsModeCLI()) {
                $oP->add('<hr/>');
            }
            $oExporter->DisplayUsage($oP);
            if (!Utils::IsModeCLI()) {
                $oP->add('</div>');
            }
        }
    }
    if (!Utils::IsModeCLI()) {
        //$oP->add('</pre>');
    }
}
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:31,代码来源:export-v2.php

示例14:

     $response = Group::add(_::str('name'), _::str('description'));
     break;
 case 'group.all':
     $response = Page::all();
     break;
 case 'group.get':
     $response = Group::get(_::int('group'));
     break;
 case 'group.student':
     $response = Group::student(_::int('group'), _::int('student'));
     break;
 case 'group.notify':
     $response = Group::notify(_::int('group'), _::int('author'), _::str('header'), _::str('text'));
     break;
 case 'page.add':
     $response = Page::add(_::str('title'), _::raw('text'), _::int('author'));
     break;
 case 'page.all':
     $response = Page::all();
     break;
 case 'page.get':
     $response = Page::get(_::int('id'));
     break;
 case 'page.edit':
     $response = Page::edit(_::int('id'), _::str('title'), _::raw('text'));
     break;
     /** @subsection Обработка ошибочного запроса */
 /** @subsection Обработка ошибочного запроса */
 default:
     Api::error(0, $method . ' : Неверный запрос к Api');
     // Все прочие запросы игнорируются
开发者ID:xaota,项目名称:hello,代码行数:31,代码来源:server.php

示例15: import_movabletype

 /**
  * Function: import_movabletype
  * MovableType importing.
  */
 public function import_movabletype()
 {
     if (empty($_POST)) {
         redirect("/admin/?action=import");
     }
     if (!Visitor::current()->group->can("add_post")) {
         show_403(__("Access Denied"), __("You do not have sufficient privileges to import content."));
     }
     $config = Config::current();
     $trigger = Trigger::current();
     $dbcon = $dbsel = false;
     if ($link = @mysql_connect($_POST['host'], $_POST['username'], $_POST['password'])) {
         $dbcon = true;
         $dbsel = @mysql_select_db($_POST['database'], $link);
     }
     if (!$dbcon or !$dbsel) {
         Flash::warning(__("Could not connect to the specified MovableType database."), "/admin/?action=import");
     }
     mysql_query("SET NAMES 'utf8'");
     $get_authors = mysql_query("SELECT * FROM mt_author ORDER BY author_id ASC", $link) or error(__("Database Error"), mysql_error());
     $users = array();
     while ($author = mysql_fetch_array($get_authors)) {
         # Try to figure out if this author is the same as the person doing the import.
         if ($author["author_name"] == Visitor::current()->login or $author["author_nickname"] == Visitor::current()->login or $author["author_nickname"] == Visitor::current()->full_name or $author["author_url"] == Visitor::current()->website or $author["author_email"] == Visitor::current()->email) {
             $users[$author["author_id"]] = Visitor::current();
         } else {
             $users[$author["author_id"]] = User::add($author["author_name"], $author["author_password"], $author["author_email"], $author["author_nickname"] != $author["author_name"] ? $author["author_nickname"] : "", $author["author_url"], $author["author_can_create_blog"] == "1" ? Visitor::current()->group : null, $author["author_created_on"], false);
         }
     }
     $get_posts = mysql_query("SELECT * FROM mt_entry ORDER BY entry_id ASC", $link) or error(__("Database Error"), mysql_error());
     $posts = array();
     while ($post = mysql_fetch_array($get_posts)) {
         $posts[$post["entry_id"]] = $post;
     }
     foreach ($posts as $post) {
         $body = $post["entry_text"];
         if (!empty($post["entry_text_more"])) {
             $body .= "\n\n<!--more-->\n\n" . $post["entry_text_more"];
         }
         $regexp_url = preg_quote($_POST['media_url'], "/");
         if (!empty($_POST['media_url']) and preg_match_all("/{$regexp_url}([^\\.\\!,\\?;\"\\'<>\\(\\)\\[\\]\\{\\}\\s\t ]+)\\.([a-zA-Z0-9]+)/", $body, $media)) {
             foreach ($media[0] as $matched_url) {
                 $filename = upload_from_url($matched_url);
                 $body = str_replace($matched_url, $config->url . $config->uploads_path . $filename, $body);
             }
         }
         $status_translate = array(1 => "draft", 2 => "public", 3 => "draft", 4 => "draft");
         $clean = oneof($post["entry_basename"], sanitize($post["entry_title"]));
         if (empty($post["entry_class"]) or $post["entry_class"] == "entry") {
             $new_post = Post::add(array("title" => $post["entry_title"], "body" => $body, "imported_from" => "movabletype"), $clean, Post::check_url($clean), "text", @$users[$post["entry_author_id"]], false, $status_translate[$post["entry_status"]], oneof(@$post["entry_authored_on"], @$post["entry_created_on"], datetime()), $post["entry_modified_on"], "", false);
             $trigger->call("import_movabletype_post", $post, $new_post, $link);
         } elseif (@$post["entry_class"] == "page") {
             $new_page = Page::add($post["entry_title"], $body, null, 0, true, 0, $clean, Page::check_url($clean));
             $trigger->call("import_movabletype_page", $post, $new_page, $link);
         }
     }
     mysql_close($link);
     Flash::notice(__("MovableType content successfully imported!"), "/admin/?action=import");
 }
开发者ID:eadz,项目名称:chyrp,代码行数:63,代码来源:Admin.php


注:本文中的Page::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。