コード例 #1
0
 private static function runController($url)
 {
     bu::lib(sf('%s_application', $url->getBinType()));
     $class_name = sf('%sApplication', ucfirst($url->getBinType()));
     $app = new $class_name();
     $app->runController($url);
 }
コード例 #2
0
ファイル: sitemap.php プロジェクト: h2dvnnet/eLib
 function get_sitemap_booklist()
 {
     global $database;
     $cate1 = $database->clear_param()->select(array('id', 'title'), 'cate1')->fetch();
     foreach ($cate1 as $data1) {
         $this->sitemap[] = ['/' . sf($data1['title'], 0) . '.' . $data1['id'], 'weekly', '0.80'];
         $id_list = [];
         $cate2 = $database->clear_param()->select(array('id', 'title'), 'cate2')->where(array('id1' => array('=', $data1['id'])))->fetch();
         foreach ($cate2 as $data2) {
             $this->sitemap[] = ['/' . sf($data1['title'], 0) . '/' . sf($data2['title'], 0) . '.' . $data2['id'], 'weekly', '0.80'];
             $id_list[] = $data2['id'];
             $num2 = $database->clear_param()->select(array('id'), 'book')->where(['cid' => ['=', $data2['id']]])->num_rows();
             $page2 = ceil($num2 / 12);
             if ($page2 > 1) {
                 for ($i2 = 1; $i2 <= $page2; $i2++) {
                     $this->sitemap[] = ['/' . sf($data1['title'], 0) . '/' . sf($data2['title'], 0) . '.' . $data2['id'] . '/trang-' . $i2, 'weekly', '0.80'];
                 }
             }
         }
         $num = $database->clear_param()->select(array('id'), 'book')->where(['cid' => ['IN', $id_list]])->num_rows();
         $page = ceil($num / 12);
         if ($page > 1) {
             for ($i = 1; $i <= $page; $i++) {
                 $this->sitemap[] = ['/' . sf($data1['title'], 0) . '.' . $data1['id'] . '/trang-' . $i, 'weekly', '0.80'];
             }
         }
     }
 }
コード例 #3
0
 function renderElement()
 {
     $date = $this->getValue();
     $minValue = is_array($date) && array_key_exists('min', $date) ? $date['min'] : null;
     $maxValue = is_array($date) && array_key_exists('max', $date) ? $date['max'] : null;
     $minOptions = sfl("<option value='' >Any</option>");
     for ($i = $this->ageMin; $i <= $this->ageMax; $i++) {
         // TODO: Bug here days don't always return the correct number of days...
         if ($minValue == $i) {
             $minOptions .= sfl("<option value='%s' selected='selected'>%s</option>", $i, $i);
         } else {
             $minOptions .= sfl("<option value='%s'>%s</option>", $i, $i);
         }
     }
     $maxOptions = sfl("<option value='' >Any</option>");
     for ($i = $this->ageMin; $i <= $this->ageMax; $i++) {
         // TODO: Bug here days don't always return the correct number of days...
         if ($maxValue == $i) {
             $maxOptions .= sfl("<option value='%s' selected='selected'>%s</option>", $i, $i);
         } else {
             $maxOptions .= sfl("<option value='%s'>%s</option>", $i, $i);
         }
     }
     $out = sfl("<select name='%s[min]' id='form_%s' %s class='inputAgeRange inputAgeRangeMin' >%s</select>", $this->getName(), $this->getName(), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $minOptions);
     $out .= sfl("<span class='inputAgeRangeSeparator'>%s</span> <select name='%s[max]' id='form_%s' %s class='inputAgeRange inputAgeRangeMax' >%s</select>", $this->separator, $this->getName(), $this->getName(), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $maxOptions);
     return $out;
 }
コード例 #4
0
 public function validate($arr)
 {
     if (empty($arr)) {
         return true;
     }
     $empty = true;
     foreach ($arr as $item) {
         if (!empty($item)) {
             $empty = false;
             break;
         }
     }
     if ($empty) {
         return true;
     }
     if (!is_array($arr)) {
         throw new Exception($this->errorMessage);
     }
     foreach ($this->requiredFields as $key => $value) {
         if (strlen($arr[$value]) > $this->maxChars) {
             throw new Exception(sf("You have entered: '<em>%s</em>'  this is over the allowed %s characters.", $arr[$value], $this->maxChars));
         }
     }
     /*
     
     if(empty($data) || strlen($data) < $this->maxChars)
     	return true;
     else 
     	throw new Exception(sf("You must enter less than %s characters",
     								$this->maxChars
     						));
     */
 }
コード例 #5
0
 public function render($options = array())
 {
     $out = $this->preRender();
     $out .= sf("%s", $this->html);
     $out .= $this->postRender();
     return $out;
 }
コード例 #6
0
    public function getInstructions($contentType)
    {
        switch ($contentType) {
            default:
            case 'text/plain':
                return sf('--Description\\nYou need to use the $this->setView() method within your function.\\n
--Example Code\\n
	public function %s() {

			$this->setView(string $ViewClassName);
			/* ... put your controller code here ... */

	}\\n', $this->method);
                break;
            case 'text/html':
                return sf('<h4>Description</h4><p>You need to use the $this->setView() method within your function.</p>
<h4>Example Code</h4>
<pre class="code">
public function %s() {

		$this->setView(<strong>string <em>$ViewClassName</em></strong>);
		/* ... put your controller code here ... */

}
</pre>', $this->method);
                break;
        }
    }
コード例 #7
0
ファイル: caster_MySqlToPhp.php プロジェクト: jenalgit/atsumi
 /**
  * Casts a variable into a MySql text
  * @param string $in String to be casted
  * @return string Casted string
  */
 static function text($in)
 {
     if (!is_string($in)) {
         throw new caster_StrictTypeException('Expected String, received: ' . $in . ' (' . gettype($in) . ')');
     }
     return sf("%s", $in);
 }
コード例 #8
0
 function renderElement()
 {
     $address = $this->getValue();
     if (!is_array($address)) {
         $address = array();
     }
     if (!array_key_exists('address1', $address)) {
         $address['address1'] = null;
     }
     if (!array_key_exists('address2', $address)) {
         $address['address2'] = null;
     }
     if (!array_key_exists('postcode', $address)) {
         $address['postcode'] = null;
     }
     if (!array_key_exists('town', $address)) {
         $address['town'] = null;
     }
     /*
      * The rendering of this element is SO messy due to IE compatibility - needs rewriting
      *
      */
     $out = sf("<div style='float:left;'><input type='text' name='%s[address1]' value='%s' %s id='form_%s' class='inputUkAddress inputUkAddress1' /><br />", $this->getName(), parent::makeInputSafe($address['address1']), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName());
     $out .= sf("<input type='text' name='%s[address2]' value='%s' %s id='form_%s' class='text' class='inputUkAddress inputUkAddress2' /><br />", $this->getName(), parent::makeInputSafe($address['address2']), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName());
     $out .= sf("</div><div style='clear:both;'><label for='form_%s'>%s</label>", $this->getName(), "Post Code");
     $out .= sfl("<table style='border:0px; border-spacing:0px;.' cellpadding=0 cellspacing=0><tr><td style=''><input type='text' name='%s[postcode]' value='%s' %s id='form_%s' class='postCode'  class='inputUkAddress inputUkAddressPostCode'  />", $this->getName(), parent::makeInputSafe($address['postcode']), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName());
     $out .= sfl("</td><td class='tRight'><label class='town'>Town</label></td><td><input type='text' name='%s[town]' value='%s' %s id='form_%s' class='town'  class='inputUkAddress inputUkAddressTown' /></td></tr></table></div>", $this->getName(), parent::makeInputSafe($address['town']), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName());
     return $out;
 }
コード例 #9
0
ファイル: validate_FileType.php プロジェクト: jenalgit/atsumi
 public function validate($data)
 {
     // test if the host supports finfo
     try {
         $supportsFinfo = class_exists('finfo');
     } catch (loader_ClassNotFoundException $e) {
         $supportsFinfo = false;
     }
     if ($data == '') {
         return true;
         // if finfo class exists then use that for mime validation
     } elseif ($supportsFinfo && $data['tmp_name']) {
         $finfo = new finfo(FILEINFO_MIME);
         $mime = $finfo->file($data['tmp_name']);
         if (strpos($mime, ';')) {
             $mime = substr($mime, 0, strpos($mime, ';'));
         }
         if (in_array($mime, $this->mimeTypes)) {
             return true;
         }
         $incorrectExtensionArr = $this->getExtensionFromMime($mime);
         // reply on the browsers mime type : not always present & secruity vunrebility
     } elseif (isset($data['type'])) {
         if (in_array($data['type'], $this->mimeTypes)) {
             return true;
         }
         $incorrectExtensionArr = $this->getExtensionFromMime($data['type']);
     }
     throw new ValidationIncorrectFileTypeException(sf('File should be a valid %s%s', $this->extensionText, count($incorrectExtensionArr) ? sf(' (not a %s)', implode('/', $incorrectExtensionArr)) : ''));
 }
コード例 #10
0
ファイル: db_PostgreSql.php プロジェクト: jenalgit/atsumi
 /**
  * PostgreSql Connect function, config options are:
  *
  * host			: The hostname on which the database server resides
  * port			: The port number where the database server is listening
  * dbname		: The name of the database
  * username		: The name of the user for the connection
  * password		: The password of the user for the connection
  *
  * @param $config array An array of settings
  */
 public function connect($config = array())
 {
     // Build the vender connection string
     $conString = sf('pgsql:%s%s%s', isset($config['host']) ? sf(' host=%s', $config['host']) : '', isset($config['port']) ? sf(' port=%s', $config['port']) : '', isset($config['dbname']) ? sf(' dbname=%s', $config['dbname']) : '');
     // Call the base connection function
     $this->connectReal($conString, $config);
 }
コード例 #11
0
    public function getInstructions($contentType)
    {
        switch ($contentType) {
            default:
            case 'text/plain':
                return sf('--Description\\nThe view class you specified could not be found. Please make sure you have named the class name the same as the filename and the class folder is loaded using Atsumi\'s load method.\\n
--Example basic HTML view\\n
	/*Save this as <strong>%s.php</strong> within a folder within classes/. Make sure you load the directory using Atsumi::load(); */
	class %s extends mvc_HtmlView {
		public function renderBodyContent() {
			/* ... put view code here ... */
		}
	}\\n', $this->viewName, $this->viewName);
                break;
            case 'text/html':
                return sf('<h4>Description</h4><p>The view class you specified could not be found. Please make sure you have named the class name the same as the filename and the class folder is loaded using Atsumi\'s load method.</p>
<h4>Example basic HTML view</h4>
<pre class="code">
/*Save this as <strong>%s.php</strong> within a folder within classes/. Make sure you load the directory using Atsumi::load(); */
class %s extends mvc_HtmlView {
		public function renderBodyContent() {
			/* ... put view code here ... */
		}
}
</pre>', $this->viewName, $this->viewName);
                break;
        }
    }
コード例 #12
0
 function renderElement()
 {
     $optionHtml = "";
     $elementValue = $this->getValue();
     if (!$this->defaultValue && $this->blankMessage) {
         $optionHtml .= sfl("<option value='' >%s</option>", $this->blankMessage);
     } elseif ($this->defaultValue) {
         // TODO: put this in a func...
         foreach ($this->defaultValue as $value => $option) {
             if (strval($elementValue) == strval($value)) {
                 $optionHtml .= sfl("<option value='%s' selected='selected'>%s</option>", $value, $option);
             } else {
                 $optionHtml .= sfl("<option value='%s'>%s</option>", $value, $option);
             }
         }
     }
     foreach ($this->options as $value => $option) {
         if (strval($elementValue) == strval($value)) {
             $optionHtml .= sfl("<option value='%s' selected='selected'>%s</option>", $value, $option);
         } else {
             $optionHtml .= sfl("<option value='%s'>%s</option>", $value, $option);
         }
     }
     return sfl("<select name='%s' %s id='form_%s' class='inputSelect'>%s</select>", $this->getName(), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName(), $optionHtml);
 }
コード例 #13
0
 function renderElement()
 {
     $name = $this->getValue();
     if (!is_array($name)) {
         $name = array();
     }
     if (!array_key_exists('title', $name)) {
         $name['title'] = null;
     }
     if (!array_key_exists('firstName', $name)) {
         $name['firstName'] = null;
     }
     if (!array_key_exists('lastName', $name)) {
         $name['lastName'] = null;
     }
     $titleOptions = sfl("<option value='' >Title</option>");
     foreach ($this->titles as $title => $data) {
         if ($name['title'] == $title) {
             $titleOptions .= sfl("<option value='%s' selected='selected'>%s</option>", parent::makeInputSafe($title), $data['text']);
         } else {
             $titleOptions .= sfl("<option value='%s'>%s</option>", parent::makeInputSafe($title), $data['text']);
         }
     }
     $out = sfl("<select name='%s[title]' %s id='form_%s' class='inputName inputNameTitle' >%s</select>", $this->getName(), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName(), $titleOptions);
     $out .= sfl("<input type='text' name='%s[firstName]' value='%s' %s id='form_%s' class='inputName inputNameFirst' class='text' />", $this->getName(), parent::makeInputSafe($name['firstName']), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName());
     $out .= sfl("<input type='text' name='%s[lastName]' value='%s' %s id='form_%s' class='inputName inputNameLast' class='text' />", $this->getName(), parent::makeInputSafe($name['lastName']), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName());
     return $out;
 }
コード例 #14
0
ファイル: validate_MaxWords.php プロジェクト: jenalgit/atsumi
 public function validate($data)
 {
     if (empty($data) || str_word_count($data) <= $this->maxWords) {
         return true;
     } else {
         throw new Exception(sf("You must enter %s words or less.", $this->maxWords));
     }
 }
コード例 #15
0
ファイル: validate_MinWords.php プロジェクト: jenalgit/atsumi
 public function validate($data)
 {
     if (empty($data) || str_word_count($data) >= $this->minWords) {
         return true;
     } else {
         throw new Exception(sf("You must enter %s or more words", $this->minWords));
     }
 }
コード例 #16
0
ファイル: mvc_ErrorView.php プロジェクト: jenalgit/atsumi
 public function setHeaders()
 {
     header(sf('Content-Type: text/html; charset=%s', $this->getCharset()));
     // display the custom http header eg: 404
     if (!is_null($this->get_httpHeader)) {
         header($this->get_httpHeader);
     }
 }
コード例 #17
0
 public function validate($data)
 {
     if (empty($data) || $data['size'] <= $this->maxFileSize) {
         return true;
     } else {
         throw new Exception(sf("The file uploaded is greater than %s mb", round($this->maxFileSize / 1024 / 1024, 2)));
     }
 }
コード例 #18
0
ファイル: atsumi_Version.php プロジェクト: jenalgit/atsumi
 public static function getName($html = false, $version = false)
 {
     if ($html) {
         return sf('<a class="atsumiLink" href="http://atsumi.org/" target="_TOP" title="Atsumi: PHP MVC Framework">Atsumi%s</a>', $version ? '&nbsp;v' . self::VERSION : '');
     } else {
         return sf('Atsumi%s', $version ? ' v' . self::VERSION : '');
     }
 }
コード例 #19
0
ファイル: atsumI_Security.php プロジェクト: jenalgit/atsumi
 public static function numericCode($ref, $salt, $length)
 {
     // seed random number generator
     srand(crc32(sf('%s:%s', $ref, $salt)));
     // generate the number
     $code = rand(pow(10, $length - 1), pow(10, $length) - 1);
     return $code;
 }
コード例 #20
0
 function renderElement()
 {
     $html = "";
     $elementValue = $this->getValue();
     foreach ($this->options as $value => $option) {
         $html .= sfl('<div class="radioOption">' . '	<input type="radio" name="%s" value="%s" %s %s %s id="form_%s[%s]"  class="inputRadio">' . '	<label for="form_%s[%s]">%s</label>' . '</div>', $this->getName(), $value, $this->onChange ? sf(' onchange="%s"', $this->onChange) : '', strval($elementValue) == strval($value) ? sf('checked="checked"') : '', $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName(), $value, $this->getName(), $value, $option);
     }
     return sf("<div class='radioGroup'>%s</div>", $html);
 }
コード例 #21
0
 function renderElement()
 {
     $htmlOut = "";
     $elementValue = $this->getValue();
     foreach ($this->options as $value => $imageUrl) {
         $htmlOut .= $this->renderThumbnail($value, $imageUrl, strval($elementValue) == strval($value));
     }
     return sfl("<div name='%s' %s id='form_%s' class='inputImagePicker'>%s</div>", $this->getName(), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName(), $htmlOut);
 }
コード例 #22
0
 public function render($viewName, $viewData)
 {
     // atsumi view specific handler
     if (!class_exists($viewName)) {
         throw new mvc_ViewNotFoundException(sf("View class does not exist: '%s'", $viewName), $viewName);
     }
     $viewClass = new $viewName($viewData);
     $viewClass->setHeaders();
     $viewClass->render();
 }
コード例 #23
0
 public function read($id)
 {
     atsumi_Debug::startTimer('SESSION_READ');
     $result = $this->cache->get($id, null, 'SESSION');
     if (is_null($result)) {
         return '';
     }
     atsumi_Debug::record('Session loaded from cache', sf('Session ID: %s', $id), $result, 'SESSION_READ', atsumi_Debug::AREA_SESSION, $result);
     return $result;
 }
コード例 #24
0
 function renderElement()
 {
     $attributesHtml = '';
     if (count($this->attributes)) {
         foreach ($this->attributes as $key => $val) {
             $attributesHtml .= sf(' %s="%s" ', $key, $val);
         }
     }
     return sf('<input type="%s" name="%s" value="%s" %s id="form_%s" class="%s" %s%s%s%s%s%s%s />', $this->htmlType, $this->getName(), parent::makeInputSafe($this->getValue()), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName(), $this->cssClassName, $attributesHtml, strlen($this->placeholder) ? sf(' placeholder="%s"', $this->placeholder) : '', !is_null($this->onChange) && strlen($this->onChange) ? sf(' onChange="%s"', $this->onChange) : '', !is_null($this->onKeydown) && strlen($this->onKeydown) ? sf(' onKeydown="%s"', $this->onKeydown) : '', !is_null($this->onFocus) && strlen($this->onFocus) ? sf(' onFocus="%s"', $this->onFocus) : '', !is_null($this->onBlur) && strlen($this->onBlur) ? sf(' onBlur="%s"', $this->onBlur) : '', $this->disabled ? ' disabled' : '');
 }
コード例 #25
0
 function renderElement()
 {
     $attributesHtml = '';
     if (count($this->attributes)) {
         foreach ($this->attributes as $key => $val) {
             $attributesHtml .= sf(' %s="%s" ', $key, $val);
         }
     }
     return sf("<input type='hidden' name='%s' value='%s' id='form_%s' class='inputHidden' %s />", $this->getName(), parent::makeInputSafe($this->getValue()), $this->getName(), $attributesHtml);
 }
コード例 #26
0
ファイル: validate_MinChars.php プロジェクト: jenalgit/atsumi
 public function validate($data)
 {
     if (is_array($data)) {
         $data = $data[0];
     }
     if (empty($data) || strlen($data) >= $this->minChars) {
         return true;
     } else {
         throw new Exception(sf("You must enter %s or more characters", $this->minChars));
     }
 }
コード例 #27
0
    function renderElement()
    {
        $output = sf('
			<script type="text/javascript"src="https://www.google.com/recaptcha/api/challenge?k=%s"></script>
			<noscript>
				<iframe src="https://www.google.com/recaptcha/api/noscript?k=%s" height="300" width="500" frameborder="0"></iframe><br>
					<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
					<input type="hidden" name="recaptcha_response_field" value="manual_challenge">
			</noscript>', $this->publicKey, $this->publicKey);
        return $output;
    }
コード例 #28
0
ファイル: widget_Calendar.php プロジェクト: jenalgit/atsumi
 private function checkDateArray($dateArr)
 {
     foreach ($dateArr as $date => $attributes) {
         if (!preg_match("|^[0-9]{4}-[0-9]{2}-[0-9]{2}\$|", $date)) {
             throw new Exception(sf("Malfromed date array: %s does not match format YYYY-MM-DD", $date));
         }
         if (!array_key_exists($date, $this->dates)) {
             throw new Exception(sf("Date not found in date range: %s", $date));
         }
     }
 }
コード例 #29
0
 /**
  * Retrieves a value by key from cache store
  * @access public
  * @param mixed $key The key by which the value was stored
  * @param mixed $default A value to return if the variable does not exists [optional, default: null]
  * @param string $namespace The namespace under which the variable is stored [optional, default: 'default']
  * @return mixed The value stored under the key or, $default on failure
  */
 protected function _get($key, $default = null, $namespace = 'default')
 {
     $return = $this->memcache->get($key);
     if (!is_array($return)) {
         if ($this->useExceptions) {
             throw new cache_NotFoundException(sf('Could not find \'%s\' variable', $key));
         }
         $return = array($default);
     }
     return $return[0];
 }
コード例 #30
0
ファイル: validate_MaxChars.php プロジェクト: jenalgit/atsumi
 public function validate($data)
 {
     if (is_array($data)) {
         $data = $data[0];
     }
     $data = str_replace("\n", " ", str_replace("\r", "", $data));
     if (empty($data) || mb_strlen($data, $this->encoding) <= $this->maxChars) {
         return true;
     } else {
         throw new Exception(sf("You must enter %s characters or less", $this->maxChars));
     }
 }