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


PHP Link::create方法代码示例

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


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

示例1: doSaveLink

 /**
  * Either updates the current link or creates a new one
  * Returns field template to update the interface
  * @return string
  **/
 public function doSaveLink($data, $form)
 {
     $link = $this->getLinkObject() ? $this->getLinkObject() : Link::create();
     $form->saveInto($link);
     try {
         $link->write();
     } catch (ValidationException $e) {
         $form->sessionMessage($e->getMessage(), 'bad');
         return $form->forTemplate();
     }
     $this->setValue($link->ID);
     $this->setForm($form);
     return $this->FieldHolder();
 }
开发者ID:sheadawson,项目名称:silverstripe-linkable,代码行数:19,代码来源:LinkField.php

示例2: addNew

 public function addNew()
 {
     //verify the user input and create account
     $validator = Validator::make(Input::all(), array('Name' => 'required|max:200', 'Link' => 'required|url|max:500', 'Description' => 'max:500'));
     if ($validator->fails()) {
         return Redirect::route('addlink-get')->withErrors($validator)->withInput();
     } else {
         $name = Input::get('Name');
         $link = Input::get('Link');
         $description = Input::get('Description');
         //register the new user
         $newlink = Link::create(array('username' => Auth::user()->username, 'name' => $name, 'link_name' => $link, 'link_description' => $description, 'clicks' => 0, 'active' => TRUE));
         if ($newlink) {
             return Redirect::route('addlink-get')->with('global', 'Success! Your link has been added.');
         }
     }
 }
开发者ID:franqq,项目名称:openAdvertiser,代码行数:17,代码来源:LinkController.php

示例3: valiableLang

 private function valiableLang($id = '', $table = '')
 {
     if ($id && $table) {
         $this->checkIfContentExistInCurrentLanguage($table, $id);
         if (in_array(currentLang(), $this->_valiableLang)) {
             return false;
         }
         $langs = ' (';
         foreach ($this->_valiableLang as $lang) {
             $langs .= languageNameIntongue($lang) . ' - ';
         }
         $langs = rtrim($langs, ' - ');
         $langs .= ')';
         return $langs;
     } else {
         $links = '';
         $link = new Link();
         foreach ($this->_valiableLang as $lang) {
             $links .= " - <a href='" . $link->create('', $lang) . "'>" . languageNameIntongue($lang) . "</a>";
         }
         return $links;
     }
 }
开发者ID:AtiqulHaque,项目名称:logaty-library,代码行数:23,代码来源:DBcontent.php

示例4: dol_add_file_process

/**
 * Get and save an upload file (for example after submitting a new file a mail form).
 * All information used are in db, conf, langs, user and _FILES.
 * Note: This function can be used only into a HTML page context.
 *
 * @param	string	$upload_dir				Directory where to store uploaded file (note: also find in first part of dest_file)
 * @param	int		$allowoverwrite			1=Allow overwrite existing file
 * @param	int		$donotupdatesession		1=Do no edit _SESSION variable
 * @param	string	$varfiles				_FILES var name
 * @param	string	$savingdocmask			Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__'
 * @param	string	$link					Link to add
 * @return	void
 */
function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesession = 0, $varfiles = 'addedfile', $savingdocmask = '', $link = null)
{
    global $db, $user, $conf, $langs;
    if (!empty($_FILES[$varfiles])) {
        dol_syslog('dol_add_file_process upload_dir=' . $upload_dir . ' allowoverwrite=' . $allowoverwrite . ' donotupdatesession=' . $donotupdatesession . ' savingdocmask=' . $savingdocmask, LOG_DEBUG);
        if (dol_mkdir($upload_dir) >= 0) {
            $TFile = $_FILES[$varfiles];
            if (!is_array($TFile['name'])) {
                foreach ($TFile as $key => &$val) {
                    $val = array($val);
                }
            }
            $nbfile = count($TFile['name']);
            for ($i = 0; $i < $nbfile; $i++) {
                // Define $destpath (path to file including filename) and $destfile (only filename)
                $destpath = $upload_dir . "/" . $TFile['name'][$i];
                $destfile = $TFile['name'][$i];
                $savingdocmask = dol_sanitizeFileName($savingdocmask);
                if ($savingdocmask) {
                    $destpath = $upload_dir . "/" . preg_replace('/__file__/', $TFile['name'][$i], $savingdocmask);
                    $destfile = preg_replace('/__file__/', $TFile['name'][$i], $savingdocmask);
                }
                $resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destpath, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles);
                if (is_numeric($resupload) && $resupload > 0) {
                    global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini;
                    include_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php';
                    if (empty($donotupdatesession)) {
                        include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
                        $formmail = new FormMail($db);
                        $formmail->add_attached_files($destpath, $destfile, $TFile['type'][$i]);
                    }
                    if (image_format_supported($destpath) == 1) {
                        // Create small thumbs for image (Ratio is near 16/9)
                        // Used on logon for example
                        $imgThumbSmall = vignette($destpath, $maxwidthsmall, $maxheigthsmall, '_small', 50, "thumbs");
                        // Create mini thumbs for image (Ratio is near 16/9)
                        // Used on menu or for setup page for example
                        $imgThumbMini = vignette($destpath, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs");
                    }
                    setEventMessages($langs->trans("FileTransferComplete"), null, 'mesgs');
                } else {
                    $langs->load("errors");
                    if ($resupload < 0) {
                        setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors');
                    } else {
                        if (preg_match('/ErrorFileIsInfectedWithAVirus/', $resupload)) {
                            setEventMessages($langs->trans("ErrorFileIsInfectedWithAVirus"), null, 'errors');
                        } else {
                            setEventMessages($langs->trans($resupload), null, 'errors');
                        }
                    }
                }
            }
        }
    } elseif ($link) {
        if (dol_mkdir($upload_dir) >= 0) {
            require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
            $linkObject = new Link($db);
            $linkObject->entity = $conf->entity;
            $linkObject->url = $link;
            $linkObject->objecttype = GETPOST('objecttype', 'alpha');
            $linkObject->objectid = GETPOST('objectid', 'int');
            $linkObject->label = GETPOST('label', 'alpha');
            $res = $linkObject->create($user);
            $langs->load('link');
            if ($res > 0) {
                setEventMessages($langs->trans("LinkComplete"), null, 'mesgs');
            } else {
                setEventMessages($langs->trans("ErrorFileNotLinked"), null, 'errors');
            }
        }
    } else {
        $langs->load("errors");
        setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("File")), null, 'errors');
    }
}
开发者ID:NoisyBoy86,项目名称:Dolibarr_test,代码行数:89,代码来源:files.lib.php

示例5: valiableLang

 /**
  * this function to create links for post in a valiable language (translation post)
  * 
  * @param number $id
  * @param string $table
  * @return boolean|string
  */
 private function valiableLang($id = '', $table = '')
 {
     // check if $id and $table are set
     if ($id && $table) {
         // call function checkIfContentExistInCurrentLanguage() to know
         // valiable languages .
         $this->checkIfContentExistInCurrentLanguage($table, $id);
         // if current language are exist return false!
         /**
          * i know you ask yourself WHY ????
          * if option hide untranslation is false we want to show users all posts (in current language and other)
          * so if any post exist in (current language and other language) the system well be desplay same post 2 more time
          * so we check if this post exist in current language show user this post in current language only.
          * 
          * too learn more see block code in line: 333 - 379 
          */
         if (in_array(currentLang(), $this->_valiableLang)) {
             return false;
         }
         /**
          * @var string $lang to store links for avaliable language in and return it.
          */
         // get initial bracket
         $langs = ' (';
         // get all languages of post translated in and get tongue name
         foreach ($this->_valiableLang as $lang) {
             $langs .= languageNameIntongue($lang) . ' - ';
         }
         // remove lanst dash
         $langs = rtrim($langs, ' - ');
         // close bracket
         $langs .= ')';
         return $langs;
     } else {
         // if $id and $table not set
         /**
          * @var string $links to save links in
          */
         $links = '';
         // create obect from Linke() Class
         $link = new Link();
         // get all languages of post translated in and get tongue name and create it in links
         foreach ($this->_valiableLang as $lang) {
             $links .= " - <a href='" . $link->create('', $lang) . "'>" . languageNameIntongue($lang) . "</a>";
         }
         return $links;
     }
 }
开发者ID:AtiqulHaque,项目名称:logaty-library,代码行数:55,代码来源:DBcontent.php

示例6: languageNameIntongue

                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="#"><?php 
__('the Library On GitHub');
?>
</a>
                </div>
                <!-- Collect the nav links, forms, and other content for toggling -->
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav">
                        <?php 
foreach (enabledLanguagesList() as $lang => $code) {
    ?>
                            <li>
                                <a href="<?php 
    echo $link->create('', $code);
    ?>
"><?php 
    echo languageNameIntongue($code);
    ?>
</a>
                            </li>
                            <?php 
}
?>
                        <li>
                            <a target="_blank" href="http://t3lam.net"><?php 
__("My Blog");
?>
</a>
                        </li>
开发者ID:AtiqulHaque,项目名称:logaty-library,代码行数:31,代码来源:index.php

示例7: strftime

    $link->sub_topic_4_id = !empty($_POST['sub_topic_4_id']) ? $_POST['sub_topic_4_id'] : 0;
    $link->category_id = $_POST['category_id'];
    $link->sub_category_1_id = !empty($_POST['sub_category_1_id']) ? $_POST['sub_category_1_id'] : 0;
    $link->content_source_id = $_POST['content_source_id'];
    $link->rank = 0;
    $link->toplinks = 0;
    $link->quicklink = !empty($_POST['quicklink']) ? $_POST['quicklink'] : 0;
    $link->link_text = $_POST['link_text'];
    $link->link_href = $_POST['link_href'];
    $link->link_desc = $_POST['link_desc'];
    $link->link_date = $_POST['link_date'];
    $link->upload_date = strftime("%Y-%m-%d %H:%M:%S", time());
    $linkpic = new LinkPic();
    $linkpic->attach_file($_FILES['link_pic']);
    $link->link_pic = $linkpic->save();
    if ($link->create()) {
        //echo "Link was created";
        $session->message("You successfully inserted a new link into the database!");
        $session->login($user);
        log_action('New Link Added To Database by ', "{$user->username}.");
    } else {
        echo "Link was not created";
    }
    // open and update logfile.txt with user action
    $action = "New Link Added to RazaWeb Database";
    $log_message = "By User Kamal Latif";
    log_action($action, $log_message);
}
// end submit
$message = "No Message";
?>
开发者ID:kamalrazalatif,项目名称:razaweb,代码行数:31,代码来源:new_link_oop.php


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