Ejemplo n.º 1
0
 /**
  * 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();
 }
Ejemplo n.º 2
0
 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.');
         }
     }
 }
Ejemplo n.º 3
0
 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;
     }
 }
Ejemplo n.º 4
0
/**
 * 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');
    }
}
Ejemplo n.º 5
0
 /**
  * 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;
     }
 }
Ejemplo n.º 6
0
                        <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>
Ejemplo n.º 7
0
    $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";
?>
Ejemplo n.º 8
0
                        <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>